@statsig/js-on-device-eval-client 0.0.1-beta.39 → 0.0.1-beta.40

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.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Statsig=e():t.Statsig=e()}(this,()=>(()=>{"use strict";var $Q=(e)=>Object.defineProperty(e,"__esModule",{value:!0});var $P=(a,b)=>Object.assign(a,b);var $A=()=>((t,r,u,l)=>{return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})});var n={496:(t,e,n)=>{$Q(e),e.t=e.i=void 0,e.i=()=>null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:o;e.t=t=>{var e;return t?null==(e=null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.instances)?void 0:e[t]:null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.lastInstance};var i,r="__STATSIG__",s="undefined"!=typeof window?window:{},n=void 0!==n.g?n.g:{},u="undefined"!=typeof globalThis?globalThis:{};const o=null!=(i=null!=(i=null!=(i=s[r])?i:n[r])?i:u[r])?i:{instance:e.t};s[r]=o,n[r]=o,u[r]=o},856:(t,e)=>{$Q(e)},320:function(t,e,n){var u=this&&this.__awaiter||$A();$Q(e),e.DataAdapterCore=void 0;const o=n(780),i=n(283),r=n(296),s=n(444),l=n(412);e.DataAdapterCore=class{constructor(t,e){this.o=t,this.u=e,this.h=null,this.v={},this._="statsig.last_modified_time."+e}attach(t,e){this.h=t}getDataSync(t){var t=this.m(t),e=this.v[t];return e||((e=this.p(t))?(this.S(t,e),this.v[t]):null)}setData(t,e){e=this.m(e);this.S(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__primeInMemoryCache(t){this.v=$P($P({},this.v),t)}O(e,n,i){var r;return u(this,void 0,void 0,function*(){var t=null!=e?e:this.getDataSync(n),t=[this.en(null!=(r=null==t?void 0:t.data)?r:null,n,i)];return null!=i&&i.timeoutMs&&t.push(new Promise(t=>setTimeout(t,i.timeoutMs)).then(()=>(o.Log.debug("Fetching latest value timed out"),null))),yield Promise.race(t)})}T(n,i){return u(this,void 0,void 0,function*(){var t=this.m(n),e=yield this.O(null,n,i);e&&this.S(t,$P($P({},e),{source:"Prefetch"}))})}en(i,r,s){return u(this,void 0,void 0,function*(){var t=yield this.I(i,r,s);if(!t)return o.Log.debug("No response returned for latest value"),null;var e=(0,l.typedJsonParse)(t,"has_updates","Failure while attempting to persist latest value");let n=null;return!0===(null==e?void 0:e.has_updates)?n={source:"Network",data:t,receivedAt:Date.now()}:i&&!1===(null==e?void 0:e.has_updates)&&(n={source:"NetworkNotModified",data:i,receivedAt:Date.now()}),n?(t=this.m(r),this.S(t,n),yield this.A(t,n),n):null})}M(){return null!=this.h?this.h:(o.Log.error(this.o+" is not attached to a Client"),"")}m(t){t=(0,r.getUserStorageKey)(this.M(),t);return`${i.DataAdapterCachePrefix}.${this.u}.`+t}S(t,e){var n=Object.entries(this.v);n.length<10||([n]=n.reduce((t,e)=>e[1]<t[1]?e:t),delete this.v[n]),this.v[t]=e}p(t){var e=null==(e=s.Storage.D)?void 0:e.call(s.Storage,t);return null!=e&&(t=(0,l.typedJsonParse)(e,"source","Failed to parse cached result"))?$P($P({},t),{source:"Cache"}):null}A(t,e){return u(this,void 0,void 0,function*(){yield s.Storage.P(t,JSON.stringify(e)),yield this.k(t)})}k(n){var i;return u(this,void 0,void 0,function*(){var t=null!=(i=yield(0,s.N)(this._))?i:{},e=(t[n]=Date.now(),Object.entries(t));e.length<=10||(delete t[(e=e.reduce((t,e)=>e[1]<t[1]?e:t))[0]],yield s.Storage.C(e[0])),yield(0,s.G)(this._,t)})}}},280:(t,e)=>{$Q(e),e.Diagnostics=void 0;e.Diagnostics=class{static mark(){}}},184:(t,e)=>{$Q(e)},512:function(t,o,e){var n=this&&this.__awaiter||$A();Object.defineProperty(o,"__esModule",{value:!0}),o.ErrorBoundary=o.EXCEPTION_ENDPOINT=void 0;const i=e(780),l=e(360),a=e(972);o.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";o.ErrorBoundary=class{constructor(t,e,n){this.h=t,this.J=e,this.F=n,this.R=new Set}wrap(i){try{const t=i;!function(t){const e=new Set;let n=Object.getPrototypeOf(t);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).filter(t=>"function"==typeof(null===n||void 0===n?void 0:n[t])).forEach(t=>e.add(t)),n=Object.getPrototypeOf(n);return Array.from(e)}(t).forEach(e=>{const n=t[e];"$EB"in n||(t[e]=(...t)=>this.capture(e,()=>n.apply(i,t)),t[e].$EB=!0)})}catch(t){this.U("eb:wrap",t)}}capture(e,t){try{var n=t();return n&&n instanceof Promise?n.catch(t=>this.U(e,t)):n}catch(t){return this.U(e,t),null}}logError(t,e){this.U(t,e)}U(s,u){try{i.Log.warn("Caught error in "+s,{error:u});n(this,void 0,void 0,function*(){var t,e,n=null!=u?u:Error("[Statsig] Error was empty"),i=n instanceof Error,r=i?n.name:"No Name";this.R.has(r)||(this.R.add(r),null!=(t=null==(t=this.J)?void 0:t.networkConfig)&&t.preventAllNetworkTraffic?null!=(t=this.F)&&t.call(this,{name:"error",error:u}):(t=l.SDKType.K(this.h),e=a.StatsigMetadataProvider.get(),i=i?n.stack:function(t){try{return JSON.stringify(t)}catch(t){return"[Statsig] Failed to get string for error."}}(n),n=JSON.stringify($P({tag:s,exception:r,info:i},$P($P({},e),{sdkType:t}))),yield fetch(o.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.h,"STATSIG-SDK-TYPE":String(t),"STATSIG-SDK-VERSION":String(e.sdkVersion),"Content-Type":"application/json"},body:n}),null!=(r=this.F)&&r.call(this,{name:"error",error:u})))}).then(()=>{}).catch(()=>{})}catch(t){}}}},500:(t,e)=>{$Q(e)},788:(t,e)=>{$Q(e)},728:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.EventLogger=void 0;const r=n(832),s=n(780),u=n(716),o=n(48),l=n(876),a=n(444),c=n(412),d=n(84),h=n(100),v={},_=t=>{null!=(t=v[t])&&t.flush().catch(()=>{})};e.EventLogger=class{constructor(e,t,n,i){this.h=e,this.F=t,this.L=n,this.J=i,this.V=[],this.q={},this.B={},this.$=!1,this.H=Date.now(),(v[e]=this).Y=!0===(null==i?void 0:i.disableLogging),this.W=null!=(t=null==i?void 0:i.loggingBufferMaxSize)?t:50;t=null!=(n=null==i?void 0:i.loggingIntervalMs)?n:1e4;const r=setInterval(()=>{v[e]?_(e):clearInterval(r)},t);this.X=r;n=null==i?void 0:i.networkConfig;this.tt=(0,d.et)(null==n?void 0:n.logEventUrl,null==n?void 0:n.api,"/rgstr",u.NetworkDefault.eventsApi),this.nt=(0,d.et)(null==n?void 0:n.logEventBeaconUrl,null==n?void 0:n.api,"/log_event_beacon",u.NetworkDefault.eventsApi),(0,h.it)(t=>{"background"===t&&_(e)}),this.st()}setLoggingDisabled(t){this.Y=t}enqueue(t){this.rt(t)&&(this.ut(t),this.lt(),this.V.length>this.W)&&_(this.h)}incrementNonExposureCount(t){var e=null!=(e=this.B[t])?e:0;this.B[t]=e+1}reset(){this.q={}}shutdown(){return i(this,void 0,void 0,function*(){this.X&&(clearInterval(this.X),this.X=null),yield this.flush()})}flush(){return i(this,void 0,void 0,function*(){var t;this.ct(),0!==this.V.length&&(t=this.V,this.V=[],yield this.dt(t))})}lt(){this.$||(this.$=!0,200<Date.now()-this.H)||setTimeout(()=>_(this.h),200)}rt(t){if((0,l.ht)(t)){var t=[t.eventName,null==(e=t.user)?void 0:e.userID,null==(e=t.metadata)?void 0:e.gate,null==(e=t.metadata)?void 0:e.config,null==(e=t.metadata)?void 0:e.ruleID].join("|"),e=this.q[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3<Object.keys(this.q).length&&(this.q={}),this.q[t]=n}return!0}dt(t){return i(this,void 0,void 0,function*(){if(this.Y)this.vt(t);else try{(!(0,h._t)()&&this.L.isBeaconSupported()?yield this.ft(t):yield this.gt(t)).success?this.F({name:"logs_flushed",events:t}):this.vt(t)}catch(t){s.Log.warn("Failed to flush events.")}})}gt(e){return i(this,void 0,void 0,function*(){var t=yield this.L.post({sdkKey:this.h,data:{events:e},url:this.tt,retries:3,params:{[u.NetworkParam.EventCount]:String(e.length)}}),t=null!=t&&t.body?(0,c.typedJsonParse)(t.body,"success","Failed to parse SendEventsResponse"):null;return{success:!0===(null==t?void 0:t.success)}})}ft(t){return i(this,void 0,void 0,function*(){return{success:yield this.L.beacon({sdkKey:this.h,data:{events:t},url:this.nt})}})}vt(t){for(;500<t.length;)t.shift();var e=this.bt();(0,a.G)(e,t).catch(()=>{s.Log.warn("Unable to save failed logs to storage")})}st(){const e=this.bt();i(this,void 0,void 0,function*(){var t=yield(0,a.N)(e);t&&(yield a.Storage.C(e),yield this.dt(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}bt(){return"statsig.failed_logs."+(0,r.DJB2)(this.h)}ut(t){t.user&&(t.user=$P({},t.user),delete t.user.privateAttributes);var e={},n=this.yt();n&&(e.statsigMetadata={currentPage:n}),this.V.push($P($P({},t),e))}ct(){0!==Object.keys(this.B).length&&(this.ut({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:$P({},this.B)}}),this.B={})}yt(){var t;if(!1!==(null==(t=this.J)?void 0:t.includeCurrentPageUrlWithEvents))return(0,o.St)()}}},832:(t,e)=>{$Q(e),e.DJB2Object=e.DJB2=void 0;e.DJB2=e=>{let n=0;for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return String(n>>>0)};e.DJB2Object=t=>(0,e.DJB2)(JSON.stringify(r(t)));const r=n=>{if(null==n)return null;var t=Object.keys(n).sort();const i={};return t.forEach(t=>{let e=n[t];e instanceof Object&&(e=r(e)),i[t]=e}),i}},664:(t,e)=>{$Q(e)},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,r;$Q(e),e.Log=e.LogLevel=void 0,(r=i||(e.LogLevel=i={}))[r.None=0]="None",r[r.Error=1]="Error",r[r.Warn=2]="Warn",r[r.Info=3]="Info",r[r.Debug=4]="Debug";class s{static info(...t){this.level>=i.Info&&console.info(...n(t))}static debug(...t){this.level>=i.Debug&&console.debug(...n(t))}static warn(...t){this.level>=i.Warn&&console.warn(...n(t))}static error(...t){this.level>=i.Error&&console.error(...n(t))}}(e.Log=s).level=i.Error},716:(t,e)=>{$Q(e),e.NetworkParam=e.NetworkDefault=void 0,e.NetworkDefault={eventsApi:"https://prodregistryv2.org/v1",initializeApi:"https://featureassets.org/v1",specsApi:"https://assetsconfigcdn.org/v1"},e.NetworkParam={EventCount:"ec",SdkKey:"k",SdkType:"st",SdkVersion:"sv",Time:"t",SessionID:"sid",StatsigEncoded:"se"}},188:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.NetworkCore=void 0,n(496);const v=n(280),_=n(780),o=n(716),s=n(360),l=n(48),u=n(612),a=n(604),c=n(972);e.NetworkCore=class{constructor(t,e){this.J=t,this.F=e,this.Ot=null!=(t=null==(e=null==t?void 0:t.networkConfig)?void 0:e.networkTimeoutMs)?t:1e4}post(e){return i(this,void 0,void 0,function*(){var t=yield this.jt(e);return this.Tt($P({method:"POST",body:this.wt(e,t)},e))})}get(t){return this.Tt($P({method:"GET"},t))}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return i(this,void 0,void 0,function*(){var t,e;return!!f(n)&&(t=yield this.It(n),e=yield this.jt(n),navigator.sendBeacon(t,e))})}Tt(d){var h;return i(this,void 0,void 0,function*(){if(!f(d))return null;if(null!=(h=null==(h=this.J)?void 0:h.networkConfig)&&h.preventAllNetworkTraffic)return null;var{method:e,body:n,retries:i}=d;const r=new AbortController;var t=setTimeout(()=>r.abort(`Timeout of ${this.Ot}ms expired.`),this.Ot),s=yield this.It(d),u=null;try{var o,l,a,c={method:e,body:n,headers:$P({},d.headers),signal:r.signal,priority:d.priority},u=yield fetch(s,c);if(clearTimeout(t),u.ok)return a=yield u.text(),v.Diagnostics.mark(),{body:a,code:u.status};throw o=yield u.text().catch(()=>"No Text"),(l=new Error(`Failed to fetch: ${s} `+o)).name="NetworkError",l}catch(t){n=function(t,e){if(t.signal.aborted&&"string"==typeof t.signal.reason)return t.signal.reason;if("string"==typeof e)return e;if(e instanceof Error)return e.name+": "+e.message;return null}(r,t);return v.Diagnostics.mark(),!i||i<=0?(null!=(h=this.F)&&h.call(this,{name:"error",error:t}),_.Log.error(`A networking error occured during ${e} request to ${s}.`,n,t),null):this.Tt($P($P({},d),{retries:i-1}))}})}It(e){return i(this,void 0,void 0,function*(){var t=$P({[o.NetworkParam.SdkKey]:e.sdkKey,[o.NetworkParam.SdkType]:s.SDKType.K(e.sdkKey),[o.NetworkParam.SdkVersion]:c.SDK_VERSION,[o.NetworkParam.Time]:String(Date.now()),[o.NetworkParam.SessionID]:yield u.SessionID.get(e.sdkKey)},e.params),t=Object.entries(t).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return e.url+(t?"?"+t:"")})}jt(r){return i(this,void 0,void 0,function*(){var{data:t,sdkKey:e}=r,n=yield a.StableID.get(e),i=yield u.SessionID.get(e),e=s.SDKType.K(e);return JSON.stringify($P($P({},t),{statsigMetadata:$P($P({},c.StatsigMetadataProvider.get()),{stableID:n,sessionID:i,sdkType:e})}))})}wt(t,e){var n,i,r,s=(0,l.kt)();if(null==s||!s.btoa||null!=(null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__["no-encode"])||null!=(n=this.J)&&n.disableStatsigEncoding||!t.isStatsigEncodable)return e;try{var u=null!=(i=s.btoa(e).split("").reverse().join(""))?i:e;return t.params=$P($P({},null!=(r=t.params)?r:{}),{[o.NetworkParam.StatsigEncoded]:"1"}),u}catch(t){return _.Log.warn("/initialize request encoding failed"),e}}};const f=t=>!!t.sdkKey||(_.Log.warn("Unable to make request without an SDK key"),!1)},264:(t,e)=>{$Q(e)},360:(t,e)=>{$Q(e),e.SDKType=void 0;const n={};let i;e.SDKType={K:t=>{return(null!=(t=n[t])?t:"js-mono")+(null!==i&&void 0!==i?i:"")},At(t,e){n[t]=e},xt(t){i&&"-react"!==i||(i="-"+t)}}},48:(t,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.St=i.Mt=i.Dt=i.Et=i.Pt=i.kt=void 0;i.kt=()=>"undefined"!=typeof window?window:null,i.Pt=()=>{var t=(0,i.kt)();return null!=(t=null==t?void 0:t.document)?t:null},i.Et=()=>null!=(0,i.Pt)(),i.Dt=(t,e)=>{var n=(0,i.kt)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(t,e)},i.Mt=(t,e)=>{var n=(0,i.Pt)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(t,e)};i.St=()=>{var t;try{return null==(t=(0,i.kt)())?void 0:t.location.href.split(/[?#]/)[0]}catch(t){}}},612:function(t,e,n){var u=this&&this.__awaiter||$A();$Q(e),e.StatsigSession=e.SessionID=void 0;const i=n(832),o=n(780),l=n(444),a=n(556),c=18e5,d=144e5,h={};function v(e,t){return setTimeout(()=>{var t=null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.instance(e);t&&t.$emt({name:"session_expired"})},t)}function _(t){return"statsig.session_id."+(0,i.DJB2)(t)}e.SessionID={get:t=>u(void 0,void 0,void 0,function*(){return e.StatsigSession.get(t).then(t=>t.data.sessionID)})},e.StatsigSession={get:s=>u(void 0,void 0,void 0,function*(){null==h[s]&&(h[s]=function(n){return u(this,void 0,void 0,function*(){let t=yield function(t){t=_(t);return(0,l.N)(t)}(n);var e=Date.now();return{data:t=t||{sessionID:(0,a.getUUID)(),startTime:e,lastUpdate:e},sdkKey:n}})}(s));var t=yield h[s],e=Date.now(),n=t.data,i=((function({lastUpdate:t}){return Date.now()-t>c}(n)||function({startTime:t}){return Date.now()-t>d}(n))&&(n.sessionID=(0,a.getUUID)(),n.startTime=e),n.lastUpdate=e,n),r=t.sdkKey;return r=_(r),(0,l.G)(r,i).catch(()=>{o.Log.warn("Failed to save SessionID")}),clearTimeout(t.idleTimeoutID),clearTimeout(t.ageTimeoutID),e-=n.startTime,n=t.sdkKey,t.idleTimeoutID=v(n,c),t.ageTimeoutID=v(n,d-e),t})}},604:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.StableID=void 0;const r=n(832),s=n(780),u=n(444),o=n(556),l={};function a(t){return"statsig.stable_id."+(0,r.DJB2)(t)}function c(t,e){e=a(e);(0,u.G)(e,t).catch(()=>{s.Log.warn("Failed to save StableID")})}e.StableID={get:e=>i(void 0,void 0,void 0,function*(){return null==l[e]&&(l[e]=function(t){t=a(t);return(0,u.N)(t)}(e).then(t=>{return null!=t||c(t=(0,o.getUUID)(),e),t})),l[e]}),setOverride:(t,e)=>{l[e]=Promise.resolve(t),c(t,e)}}},688:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.StatsigClientBase=void 0,n(496);const l=n(496),a=n(512),c=n(728),d=n(780),h=n(48),v=n(604),_=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.Ft={};var r,s=this.$emt.bind(this),u=(0,l.i)(),o=null!=(o=u.instances)?o:{};null!=i&&i.logLevel&&(d.Log.level=null==i?void 0:i.logLevel),null!=i&&i.disableStorage&&_.Storage.Ut(!0),null!=i&&i.overrideStableID&&v.StableID.setOverride(i.overrideStableID,t),this.l=new a.ErrorBoundary(t,i,s),this.l.wrap(this),this.l.wrap(n),this.l.wrap(e),this.h=t,this.J=null!=i?i:{},this.Kt=null!=(r=null==i?void 0:i.overrideAdapter)?r:null,this.Lt=new c.EventLogger(t,s,n,i),null!=o[t]&&(0,h.Et)()&&d.Log.warn("Creating multiple Statsig clients with the same SDK key can lead to unexpected behavior. Multi-instance support requires different SDK keys."),o[t]=this,u.lastInstance=this,u.instances=o,__STATSIG__=u,this.dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&(this.J.disableLogging=t.disableLogging,this.Lt.setLoggingDisabled(t.disableLogging)),null!=t.disableStorage&&(this.J.disableStorage=t.disableStorage,_.Storage.Ut(t.disableStorage))}flush(){return this.Lt.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.$emt({name:"pre_shutdown"}),yield this.Lt.shutdown()})}on(t,e){this.Ft[t]||(this.Ft[t]=[]),this.Ft[t].push(e)}off(t,e){this.Ft[t]&&-1!==(e=this.Ft[t].indexOf(e))&&this.Ft[t].splice(e,1)}$on(t,e){e.__isInternal=!0,this.on(t,e)}$emt(n){var t;const e=e=>{try{e(n)}catch(t){!0===e.__isInternal?this.l.logError("__emit:"+n.name,t):d.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",n)}};this.Ft[n.name]&&this.Ft[n.name].forEach(t=>e(t)),null!=(t=this.Ft["*"])&&t.forEach(e)}Jt(t,e){this.loadingStatus=t,this.$emt({name:"values_updated",status:t,values:e})}Vt(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.Lt.incrementNonExposureCount(t):this.Lt.enqueue(e)}}},808:(t,e)=>{$Q(e)},283:(t,e)=>{$Q(e),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},876:(t,e)=>{$Q(e),e.qt=e.zt=e.Bt=e.ht=void 0;const n="statsig::config_exposure",i="statsig::gate_exposure",l=(t,e,n,i,r)=>({eventName:t,user:e,value:null,metadata:s(n,i),secondaryExposures:r,time:Date.now()});e.ht=({eventName:t})=>t===i||t===n,e.Bt=(t,e)=>{return l(i,t,e.details,{gate:e.name,gateValue:String(e.value),ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.zt=(t,e)=>{return l(n,t,e.details,{config:e.name,ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])};e.qt=(t,e,n)=>{var i,r=e.__evaluation,s=!0===(null==(s=null==r?void 0:r.explicit_parameters)?void 0:s.includes(n));let u="",o=null!=(i=null==r?void 0:r.undelegated_secondary_exposures)?i:[];return s&&(u=null!=(i=r.allocated_experiment_name)?i:"",o=r.secondary_exposures),l("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:u,isExplicitParameter:String(s)},o)};const s=(t,e)=>(e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut)),t.receivedAt&&(e.receivedAt=String(t.receivedAt)),e)},972:(t,e)=>{$Q(e),e.StatsigMetadataProvider=e.SDK_VERSION=void 0,e.SDK_VERSION="0.0.1-beta.39";let n={sdkVersion:e.SDK_VERSION,sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=$P($P({},n),t)}}},384:(t,e)=>{$Q(e)},396:(t,e)=>{$Q(e),e.$t=e.Ht=e.Yt=e.Wt=void 0;const r="default";function s(t,e,n,i){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:r,__evaluation:n,value:i}}function u(s,u){return(t,e)=>{var n,i,r=null!=(r=null==s?void 0:s[t])?r:null;return null==r||null!=e&&(n=e,(i=t=>Array.isArray(t)?"array":typeof t)(r)!==i(n))?null!=e?e:null:(null!=u&&u(t),r)}}e.Wt=function(t,e,n){return s(t,e,n,!0===(null==n?void 0:n.value))},e.Yt=function(t,e,n){return $P($P({},s(t,e,n,null!=(t=null==n?void 0:n.value)?t:{})),{groupName:null,get:u(null==n?void 0:n.value)})},e.Ht=function(t,e,n,i){return $P($P({},s(t,e,n,void 0)),{get:u(null==n?void 0:n.value,i),groupName:null!=(t=null==n?void 0:n.group_name)?t:null,__value:null!=(e=null==n?void 0:n.value)?e:{}})},e.$t=function(t,e,n,i){return $P($P($P({},t),e),{get:u(n,i)})}},136:(t,e)=>{$Q(e)},296:(t,e,n)=>{$Q(e),e.getUnitIDFromUser=e.getUserStorageKey=e.normalizeUser=void 0;const i=n(832);e.normalizeUser=function(t,e){try{var n=JSON.parse(JSON.stringify(t));return null!=e&&(n.statsigEnvironment=e),n}catch(t){throw new Error("User object must be convertable to JSON string.")}},e.getUserStorageKey=function(t,e){return(0,i.DJB2Object)({sdkKey:t,user:e})},e.getUnitIDFromUser=function(t,e){var n;return"string"==typeof e&&"userid"!==e.toLowerCase()?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(n=null==t?void 0:t.customIDs)?void 0:n[e.toLowerCase()]:t.userID}},444:function(t,e,n){var i=this&&this.__awaiter||$A(),n=($Q(e),e.G=e.N=e.Storage=void 0,n(780));const r={},s=t=>Promise.resolve(t),u={Qt:()=>"InMemory",D(t){return null!=(t=r[t])?t:null},Xt(t){return s(null!=(t=r[t])?t:null)},P(t,e){return r[t]=e,s()},C(t){return delete r[t],s()},Zt(){return s(Object.keys(r))}};let o=null;try{"undefined"!=typeof window&&"localStorage"in window&&(o={Qt:()=>"LocalStorage",D(t){return localStorage.getItem(t)},Xt(t){return s(localStorage.getItem(t))},P(t,e){return localStorage.setItem(t,e),s()},C(t){return localStorage.removeItem(t),s()},Zt(){var t=Object.keys(localStorage);return s(t)}})}catch(t){n.Log.warn("Failed to setup localStorageProvider.")}let l=null!==o&&void 0!==o?o:u,a=l;e.Storage={Qt:()=>a.Qt(),Xt:t=>a.Xt(t),P:(t,e)=>a.P(t,e),C:t=>a.C(t),Zt:()=>a.Zt(),D:t=>{var e;return null!=(e=null==(e=a.D)?void 0:e.call(a,t))?e:null},te:t=>{l=t,a=t},Ut:t=>{a=t?u:l}},e.N=function(e){return i(this,void 0,void 0,function*(){var t=yield a.Xt(e);return JSON.parse(null!=t?t:"null")})},e.G=function(t,e){return i(this,void 0,void 0,function*(){yield a.P(t,JSON.stringify(e))})}},412:(t,e,n)=>{$Q(e),e.typedJsonParse=void 0;const r=n(780);e.typedJsonParse=function(t,e,n){try{var i=JSON.parse(t);return"object"==typeof i&&0 in i,i}catch(t){}return r.Log.error(n),null}},556:(t,e)=>{$Q(e),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let n=(new Date).getTime(),i="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return`xxxxxxxx-xxxx-4xxx-${"89ab"[Math.floor(4*Math.random())]}xxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let e=16*Math.random();return 0<n?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(i+e)%16|0,i=Math.floor(i/16)),("x"===t?e:7&e|8).toString(16)})}},84:(t,e)=>{$Q(e),e.et=void 0,e.et=function(t,e,n,i){return t||(e?""+e+n:""+i+n)}},539:(t,e)=>{$Q(e)},100:(t,e,n)=>{$Q(e),e.ee=e.it=e._t=void 0;n=n(48);const i="foreground",r="background",s=[];let u=i;e._t=()=>u===i,e.it=t=>{s.unshift(t)};e.ee=e=>{e!==u&&(u=e,s.forEach(t=>t(e)))},(0,n.Dt)("focus",()=>(0,e.ee)(i)),(0,n.Dt)("blur",()=>(0,e.ee)(r)),(0,n.Dt)("beforeunload",()=>(0,e.ee)(r)),(0,n.Mt)("visibilitychange",()=>{(0,e.ee)("visible"===document.visibilityState?i:r)})},464:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&("get"in r?e.__esModule:!r.writable&&!r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};$Q(e),e.Log=e.Storage=e.EventLogger=void 0,n(496);const s=n(728),u=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return s.EventLogger}}),n(780));Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return u.Log}});var o=n(972);const l=n(444);Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return l.Storage}});var a=n(556);r(n(496),e),r(n(856),e),r(n(320),e),r(n(184),e),r(n(512),e),r(n(500),e),r(n(788),e),r(n(832),e),r(n(664),e),r(n(780),e),r(n(188),e),r(n(716),e),r(n(264),e),r(n(48),e),r(n(360),e),r(n(612),e),r(n(604),e),r(n(688),e),r(n(808),e),r(n(283),e),r(n(876),e),r(n(972),e),r(n(384),e),r(n(396),e),r(n(136),e),r(n(296),e),r(n(444),e),r(n(412),e),r(n(84),e),r(n(539),e),r(n(556),e),r(n(100),e),__STATSIG__=$P($P({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:s.EventLogger,Log:u.Log,getUUID:a.getUUID,Storage:l.Storage,SDK_VERSION:o.SDK_VERSION})},448:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&("get"in r?e.__esModule:!r.writable&&!r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};$Q(e),r(n(376),e),e.default=__STATSIG__},532:(t,e)=>{function o(t){return t.setUTCHours(0,0,0,0),t.getTime()}$Q(e),e.default={compareNumbers(t,e,n){if(null==t||null==e)return!1;var i=Number(t),r=Number(e);if(isNaN(i)||isNaN(r))return!1;switch(n){case"gt":return e<t;case"gte":return e<=t;case"lt":return t<e;case"lte":return t<=e;default:return!1}},compareVersions(t,e,n){if(null==t||null==e)return!1;var t=String(t),e=String(e),i=t=>{var e=t.indexOf("-");return-1!==e?t.substring(0,e):t},r=((t,e)=>{var n=t.split(".").map(t=>parseInt(t)),i=e.split(".").map(t=>parseInt(t));let r=0;for(;r<Math.max(n.length,i.length);){var s=r<n.length?n[r]:0,u=r<i.length?i[r]:0;if(s<u)return-1;if(u<s)return 1;r++}return 0})(i(t),i(e));switch(n){case"version_gt":return 0<r;case"version_gte":return 0<=r;case"version_lt":return r<0;case"version_lte":return r<=0;case"version_eq":return 0===r;case"version_neq":return 0!==r;default:return!1}},compareStringInArray(r,t,s){if(!Array.isArray(t))return!1;const u="any_case_sensitive"!==s&&"none_case_sensitive"!==s;var e=-1!==t.findIndex(t=>{var e=String(r),t=String(t),n=u?e.toLowerCase():e,i=u?t.toLowerCase():t;switch(s){case"any":case"none":case"any_case_sensitive":case"none_case_sensitive":return n===i;case"str_starts_with_any":return n.startsWith(i);case"str_ends_with_any":return n.endsWith(i);case"str_contains_any":case"str_contains_none":return n.includes(i);default:return!1}});switch(s){case"none":case"none_case_sensitive":case"str_contains_none":return!e;default:return e}},compareStringWithRegEx(t,e){try{var n=String(t);if(n.length<1e3)return new RegExp(String(e)).test(n)}catch(t){}return!1},compareTime(n,i,r){if(null==n||null==i)return!1;try{let t=new Date(String(n)),e=(isNaN(t.getTime())&&(t=new Date(Number(n))),new Date(String(i)));isNaN(e.getTime())&&(e=new Date(Number(i)));var s=t.getTime(),u=e.getTime();if(isNaN(s)||isNaN(u))return!1;switch(r){case"before":return s<u;case"after":return u<s;case"on":return o(t)===o(e);default:return!1}}catch(t){return!1}}}},947:(t,e)=>{$Q(e),e.resultToLayerEval=e.resultToConfigEval=e.resultToGateEval=e.makeEvalResult=void 0,e.makeEvalResult=function(t){return $P($P({},{unsupported:!1,bool_value:!1,rule_id:"",secondary_exposures:[],json_value:{},explicit_parameters:null,allocated_experiment_name:null,is_experiment_group:!1,group_name:null,undelegated_secondary_exposures:void 0}),t)},e.resultToGateEval=function(t,e){return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.bool_value,secondary_exposures:e.secondary_exposures}},e.resultToConfigEval=function(t,e){var n;return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.json_value,secondary_exposures:e.secondary_exposures,group:null!=(n=e.group_name)?n:"",group_name:null!=(n=e.group_name)?n:void 0,is_device_based:!1,is_experiment_active:t.isActive,is_user_in_experiment:e.is_experiment_group}},e.resultToLayerEval=function(t,e,n){return{name:t.name,rule_id:n.rule_id,value:n.json_value,secondary_exposures:n.secondary_exposures,undelegated_secondary_exposures:n.undelegated_secondary_exposures,allocated_experiment_name:null!=(t=n.allocated_experiment_name)?t:"",explicit_parameters:null!=(t=n.explicit_parameters)?t:[],group:null!=(t=n.group_name)?t:"",group_name:null!=(t=n.group_name)?t:void 0,is_device_based:!1,is_experiment_active:null==e?void 0:e.isActive,is_user_in_experiment:n.is_experiment_group}}},931:(t,e,n)=>{$Q(e);const c=n(464),i=n(452),d=n(532),h=n(947);function v(t){return(0,i.SHA256)(t).dataView().getBigUint64(0,!1)}function o(t){return null!=t&&"object"==typeof t}e.default=class{constructor(t){this.de=t}evaluateGate(t,e){var{spec:t,details:n}=this.Ge("gate",t);return t?{evaluation:(0,h.resultToGateEval)(t,this.Ce(t,e)),details:n}:{evaluation:null,details:n}}evaluateConfig(t,e){var{spec:t,details:n}=this.Ge("config",t);return t?{evaluation:(0,h.resultToConfigEval)(t,this.Ce(t,e)),details:n}:{evaluation:null,details:n}}evaluateLayer(t,e){var n,{spec:t,details:i}=this.Ge("layer",t);return t?(n=null!=(n=null==(e=this.Ce(t,e))?void 0:e.allocated_experiment_name)?n:"",n=this.de.getSpecAndSourceInfo("config",n).spec,{evaluation:(0,h.resultToLayerEval)(t,n,e),details:i}):{evaluation:null,details:i}}Ge(t,e){t=this.de.getSpecAndSourceInfo(t,e);return{details:this.Fe(t),spec:t.spec}}Fe(t){var{source:t,spec:e,lcut:n,receivedAt:i}=t;return"Uninitialized"===t||"NoValues"===t?{reason:t}:{reason:t+":"+(null==e?"Unrecognized":"Recognized"),lcut:n,receivedAt:i}}Ce(t,e){var n=o(t.defaultValue)?t.defaultValue:void 0;if(!t.enabled)return(0,h.makeEvalResult)({json_value:n,rule_id:"disabled"});var i=[];for(const u of t.rules){var r,s=this.Ke(u,e);if(s.unsupported)return s;if(i.push(...s.secondary_exposures),s.bool_value)return this.Ve(u.configDelegate,e,i)||(r=function(t,e,n){if(100===t.passPercentage)return!0;if(0===t.passPercentage)return!1;e=v(n.salt+"."+(null!=(n=t.salt)?n:t.id)+"."+(null!=(n=(0,c.getUnitIDFromUser)(e,t.idType))?n:""));return Number(e%BigInt(1e4))<100*t.passPercentage}(u,e,t),(0,h.makeEvalResult)({rule_id:s.rule_id,bool_value:r,json_value:r?s.json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,is_experiment_group:s.is_experiment_group,group_name:s.group_name}))}return(0,h.makeEvalResult)({json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,rule_id:"default"})}Ke(t,e){var n=[];let i=!0;for(const s of t.conditions){var r=this.Le(s,e);if(r.unsupported)return r;n.push(...r.secondary_exposures),r.bool_value||(i=!1)}return(0,h.makeEvalResult)({rule_id:t.id,bool_value:i,json_value:o(t.returnValue)?t.returnValue:void 0,secondary_exposures:n,is_experiment_group:!0===t.isExperimentGroup,group_name:t.groupName})}Le(t,e){let n=null,i=!1;var r=t.field,s=t.targetValue,u=t.idType,o=t.type;switch(o){case"public":return(0,h.makeEvalResult)({bool_value:!0});case"pass_gate":case"fail_gate":var l=String(s),l=this.Re(l,e);return(0,h.makeEvalResult)({bool_value:"fail_gate"===o?!l.bool_value:l.bool_value,secondary_exposures:l.secondary_exposures});case"multi_pass_gate":case"multi_fail_gate":return this.Ue(s,o,e);case"user_field":case"ip_based":case"ua_based":n=function(t,e){var n;if(null==e||"object"!=typeof t||null==t)return null;var i=t;return null!=(n=null!=(n=null!=(n=null!=(n=null!=(n=i[e])?n:i[e.toLowerCase()])?n:null==(i=null==t?void 0:t.custom)?void 0:i[e])?n:null==(i=null==t?void 0:t.custom)?void 0:i[e.toLowerCase()])?n:null==(i=null==t?void 0:t.privateAttributes)?void 0:i[e])?n:null==(i=null==t?void 0:t.privateAttributes)?void 0:i[e.toLowerCase()]}(e,r);break;case"environment_field":n=function(t,e){if(null==e)return null;t=t.statsigEnvironment;if(null!=t){const n=e.toLowerCase(),i=Object.keys(t).find(t=>t.toLowerCase()===n);return void 0!==i?t[i]:void 0}}(e,r);break;case"current_time":n=Date.now();break;case"user_bucket":l=v(null!==(l=String(null!=(l=null==(l=t.additionalValues)?void 0:l.salt)?l:"")+"."+(0,c.getUnitIDFromUser)(e,u))?l:"");n=Number(l%BigInt(1e3));break;case"unit_id":n=(0,c.getUnitIDFromUser)(e,u);break;default:return(0,h.makeEvalResult)({unsupported:!0})}var a=t.operator;switch(a){case"gt":case"gte":case"lt":case"lte":i=d.default.compareNumbers(n,s,a);break;case"version_gt":case"version_gte":case"version_lt":case"version_lte":case"version_eq":case"version_neq":i=d.default.compareVersions(n,s,a);break;case"any":case"none":case"str_starts_with_any":case"str_ends_with_any":case"str_contains_any":case"str_contains_none":case"any_case_sensitive":case"none_case_sensitive":i=d.default.compareStringInArray(n,s,a);break;case"str_matches":i=d.default.compareStringWithRegEx(n,s);break;case"before":case"after":case"on":i=d.default.compareTime(n,s,a);break;case"eq":i=n==s;break;case"neq":i=n!=s;break;case"in_segment_list":case"not_in_segment_list":return(0,h.makeEvalResult)({unsupported:!0})}return(0,h.makeEvalResult)({bool_value:i})}Ve(t,e,n){var i;return t&&(i=this.de.getSpecAndSourceInfo("config",t).spec,i)?(e=this.Ce(i,e),(0,h.makeEvalResult)($P($P({},e),{allocated_experiment_name:t,explicit_parameters:i.explicitParameters,secondary_exposures:n.concat(e.secondary_exposures),undelegated_secondary_exposures:n}))):null}Re(t,e){var n=[];let i=!1;var r=this.de.getSpecAndSourceInfo("gate",t)["spec"];if(r){r=this.Ce(r,e);if(r.unsupported)return r;i=r.bool_value,n.push(...r.secondary_exposures),n.push({gate:t,gateValue:String(i),ruleID:r.rule_id})}return(0,h.makeEvalResult)({bool_value:i,secondary_exposures:n})}Ue(t,e,n){if(!Array.isArray(t))return(0,h.makeEvalResult)({unsupported:!0});var i="multi_pass_gate"===e,r=[];let s=!1;for(const o of t){if("string"!=typeof o)return(0,h.makeEvalResult)({unsupported:!0});var u=this.Re(o,n);if(u.unsupported)return u;if(r.push(...u.secondary_exposures),i?!0===u.bool_value:!1===u.bool_value){s=!0;break}}return(0,h.makeEvalResult)({bool_value:s,secondary_exposures:r})}}},160:function(t,e,n){var r=this&&this.__awaiter||$A();$Q(e);const i=n(464);class s extends i.NetworkCore{constructor(t=null){super(t);t=null==t?void 0:t.networkConfig;this.qe=(0,i.et)(null==t?void 0:t.downloadConfigSpecsUrl,null==t?void 0:t.api,"/download_config_specs",i.NetworkDefault.specsApi)}fetchConfigSpecs(e,n){var i;return r(this,void 0,void 0,function*(){var t=yield this.get({sdkKey:e,url:this.qe,priority:n});return null!=(i=null==t?void 0:t.body)?i:null})}}e.default=s},480:(t,e,n)=>{$Q(e);const i=n(464);function r(t){return(0,i.typedJsonParse)(t,"has_updates","Failed to parse DownloadConfigSpecsResponse")}e.default=class{constructor(){this.ne=null,this.ie=null,this.oe="Uninitialized",this.se=0,this.re=0}getValues(){return this.ne?r(this.ne):null}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=r(t.data))?void 0:e.has_updates)&&(this.se=e.time,this.re=t.receivedAt,this.oe=t.source,this.ie=e,this.ne=t.data)}reset(){this.ie=null,this.ne=null,this.oe="Loading"}finalize(){this.ie||(this.oe="NoValues")}getSpecAndSourceInfo(t,e){var t=this.ze(t);return{spec:null!=(t=null==t?void 0:t.find(t=>t.name===e))?t:null,source:this.oe,lcut:this.se,receivedAt:this.re}}ze(t){var e;switch(t){case"gate":return null==(e=this.ie)?void 0:e.feature_gates;case"config":return null==(e=this.ie)?void 0:e.dynamic_configs;case"layer":return null==(e=this.ie)?void 0:e.layer_configs}}}},368:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e);const u=n(464),r=n(931),s=n(160),o=n(480),l=n(4);class a extends u.StatsigClientBase{static instance(t){var e=(0,u.i)().instance(t);return e instanceof a?e:(u.Log.warn("Unable to find StatsigOnDeviceEvalClient instance"),new a(null!=t?t:""))}constructor(t,e=null){u.SDKType.At(t,"js-on-device-eval-client");var n=new s.default(e);super(t,null!=(t=null==e?void 0:e.dataAdapter)?t:new l.StatsigSpecsDataAdapter,n,e),this.de=new o.default,this.Be=new r.default(this.de)}initializeSync(){this.updateSync()}initializeAsync(t){return i(this,void 0,void 0,function*(){return this.updateAsync(t)})}updateSync(){this.de.reset();var t=this.dataAdapter.getDataSync();this.de.setValuesFromDataAdapter(t),this.de.finalize(),this.Jt("Ready",t),this._e(t)}updateAsync(e){return i(this,void 0,void 0,function*(){this.de.reset(),this.Jt("Loading",null);var t=this.dataAdapter.getDataSync();this.de.setValuesFromDataAdapter(t),t=yield this.dataAdapter.getDataAsync(t,e),this.de.setValuesFromDataAdapter(t),this.de.finalize(),this.Jt("Ready",t)})}getContext(){return{sdkKey:this.h,options:this.J,values:this.de.getValues(),errorBoundary:this.l}}getAsyncContext(){return i(this,void 0,void 0,function*(){return $P($P({},this.getContext()),{session:yield u.StatsigSession.get(this.h),stableID:yield u.StableID.get(this.h)})})}checkGate(t,e,n){return this.getFeatureGate(t,e,n).value}getFeatureGate(t,e,n){e=(0,u.normalizeUser)(e,this.J.environment);var{evaluation:i,details:r}=this.Be.evaluateGate(t,e),r=(0,u.Wt)(t,r,i);return this.Vt(t,(0,u.Bt)(e,r),n),this.$emt({name:"gate_evaluation",gate:r}),r}getDynamicConfig(t,e,n){t=this.fe("dynamic_config",t,e,n);return this.$emt({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e,n){t=this.fe("experiment",t,e,n);return this.$emt({name:"experiment_evaluation",experiment:t}),t}getLayer(e,n,i){n=(0,u.normalizeUser)(n,this.J.environment);var{evaluation:t,details:r}=this.Be.evaluateLayer(e,n);const s=(0,u.Ht)(e,r,t,t=>{this.Vt(e,(0,u.qt)(n,s,t),i)});return this.$emt({name:"layer_evaluation",layer:s}),s}logEvent(t,e,n,i){this.Lt.enqueue($P($P({},"string"==typeof t?{eventName:t,value:n,metadata:i}:t),{user:e,time:Date.now()}))}_e(t){this.dataAdapter.getDataAsync(t,{priority:"low"}).catch(t=>{u.Log.error("An error occurred after update.",t)})}fe(t,e,n,i){n=(0,u.normalizeUser)(n,this.J.environment);var{evaluation:r,details:s}=this.Be.evaluateConfig(e,n),s=(0,u.Yt)(e,s,r),r="experiment"===t?null==(t=null==(r=this.Kt)?void 0:r.getExperimentOverride)?void 0:t.call(r,s,n,i):null==(r=null==(t=this.Kt)?void 0:t.getDynamicConfigOverride)?void 0:r.call(t,s,n,i),t=null!=r?r:s;return this.Vt(e,(0,u.zt)(n,t),i),t}}e.default=a},4:function(t,e,n){var r=this&&this.__awaiter||$A(),i=($Q(e),e.StatsigSpecsDataAdapter=void 0,n(464));const s=n(160);class u extends i.DataAdapterCore{constructor(){super("SpecsDataAdapter","specs"),this.L=null}attach(t,e){super.attach(t,e),this.L=new s.default(null!=e?e:{})}getDataAsync(t,e){return this.O(t,void 0,e)}prefetchData(t){return this.T(void 0,t)}I(t,e,n){var i;return r(this,void 0,void 0,function*(){return null!=(i=yield null==(i=this.L)?void 0:i.fetchConfigSpecs(this.M(),null==n?void 0:n.priority))?i:null})}}e.StatsigSpecsDataAdapter=u},376:(t,e,n)=>{$Q(e),e.StatsigSpecsDataAdapter=e.StatsigOnDeviceEvalClient=void 0;var i=n(368);e.StatsigOnDeviceEvalClient=i.default;const r=n(4);Object.defineProperty(e,"StatsigSpecsDataAdapter",{enumerable:!0,get:function(){return r.StatsigSpecsDataAdapter}}),__STATSIG__=$P($P({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigSpecsDataAdapter:r.StatsigSpecsDataAdapter,StatsigOnDeviceEvalClient:i.default}),e.default=__STATSIG__},452:(t,e,n)=>{$Q(e),e.SHA256=void 0;const i=n(891);Object.defineProperty(e,"SHA256",{enumerable:!0,get:function(){return i.SHA256}})},891:(t,e)=>{$Q(e),e.SHA256=void 0,e.SHA256=function(t){return(new i).update(t)};const n=[-2147483648,8388608,32768,128],u=[24,16,8,0],m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];class i{constructor(){this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.lastByteIndex=-1}update(n){if(!this.finalized){if("string"!=typeof n)throw new Error('Must be of type "string"');var i;let t=0,e;for(var r=n.length,s=this.blocks;t<r;){for(this.hashed&&(this.hashed=!1,s[0]=this.block,s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),e=this.start;t<r&&e<64;++t)(i=n.charCodeAt(t))<128?s[e>>2]|=i<<u[3&e++]:(i<2048?s[e>>2]|=(192|i>>6)<<u[3&e++]:(i<55296||57344<=i?s[e>>2]|=(224|i>>12)<<u[3&e++]:(i=65536+((1023&i)<<10|1023&n.charCodeAt(++t)),s[e>>2]|=(240|i>>18)<<u[3&e++],s[e>>2]|=(128|i>>12&63)<<u[3&e++]),s[e>>2]|=(128|i>>6&63)<<u[3&e++]),s[e>>2]|=(128|63&i)<<u[3&e++]);this.lastByteIndex=e,this.bytes+=e-this.start,64<=e?(this.block=s[16],this.start=e-64,this.hash(),this.hashed=!0):this.start=e}4294967295<this.bytes&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296)}return this}finalize(){var t,e;this.finalized||(this.finalized=!0,t=this.blocks,e=this.lastByteIndex,t[16]=this.block,t[e>>2]|=n[3&e],this.block=t[16],56<=e&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash())}hash(){var t=this.blocks;let e=this.h0,n=this.h1,i=this.h2,r=this.h3,s=this.h4,u=this.h5,o=this.h6,l=this.h7,a,c,d,h,v,_,f,g,p,y,b;for(a=16;a<64;++a)v=t[a-15],c=(v>>>7|v<<25)^(v>>>18|v<<14)^v>>>3,v=t[a-2],d=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,t[a]=t[a-16]+c+t[a-7]+d<<0;for(b=n&i,a=0;a<64;a+=4)this.first?(g=704751109,v=t[0]-210244248,l=v-1521486534<<0,r=v+143694565<<0,this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),g=e&n,h=g^e&i^b,f=s&u^~s&o,v=l+d+f+m[a]+t[a],_=c+h,l=r+v<<0,r=v+_<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),p=r&e,h=p^r&n^g,f=l&s^~l&u,v=o+d+f+m[a+1]+t[a+1],_=c+h,o=i+v<<0,i=v+_<<0,c=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),y=i&r,h=y^i&e^p,f=o&l^~o&s,v=u+d+f+m[a+2]+t[a+2],_=c+h,u=n+v<<0,n=v+_<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),b=n&i,h=b^n&r^y,f=u&o^~u&l,v=s+d+f+m[a+3]+t[a+3],_=c+h,s=e+v<<0,e=v+_<<0;this.h0=this.h0+e<<0,this.h1=this.h1+n<<0,this.h2=this.h2+i<<0,this.h3=this.h3+r<<0,this.h4=this.h4+s<<0,this.h5=this.h5+u<<0,this.h6=this.h6+o<<0,this.h7=this.h7+l<<0}arrayBuffer(){return this.Je().buffer}dataView(){return this.Je().dataView}Je(){this.finalize();var t=new ArrayBuffer(32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),e.setUint32(28,this.h7),{dataView:e,buffer:t}}}}},i={};function r(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,r)),e.exports}return r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r(448).default})());
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Statsig=e():t.Statsig=e()}(this,()=>(()=>{"use strict";var $Q=(e)=>Object.defineProperty(e,"__esModule",{value:!0});var $P=(a,b)=>Object.assign(a,b);var $A=()=>((t,r,u,l)=>{return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})});var n={496:(t,e,n)=>{$Q(e),e.t=e.i=void 0,e.i=()=>null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:o;e.t=t=>{var e;return t?null==(e=null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.instances)?void 0:e[t]:null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.lastInstance};var i,r="__STATSIG__",s="undefined"!=typeof window?window:{},n=void 0!==n.g?n.g:{},u="undefined"!=typeof globalThis?globalThis:{};const o=null!=(i=null!=(i=null!=(i=s[r])?i:n[r])?i:u[r])?i:{instance:e.t};s[r]=o,n[r]=o,u[r]=o},856:(t,e)=>{$Q(e)},320:function(t,e,n){var u=this&&this.__awaiter||$A();$Q(e),e.DataAdapterCore=void 0;const o=n(780),i=n(283),r=n(296),s=n(444),l=n(412);e.DataAdapterCore=class{constructor(t,e){this.o=t,this.u=e,this.h=null,this.v={},this._="statsig.last_modified_time."+e}attach(t,e){this.h=t}getDataSync(t){var t=this.m(t),e=this.v[t];return e||((e=this.p(t))?(this.S(t,e),this.v[t]):null)}setData(t,e){e=this.m(e);this.S(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__primeInMemoryCache(t){this.v=$P($P({},this.v),t)}O(e,n,i){var r;return u(this,void 0,void 0,function*(){var t=null!=e?e:this.getDataSync(n),t=[this.en(null!=(r=null==t?void 0:t.data)?r:null,n,i)];return null!=i&&i.timeoutMs&&t.push(new Promise(t=>setTimeout(t,i.timeoutMs)).then(()=>(o.Log.debug("Fetching latest value timed out"),null))),yield Promise.race(t)})}T(n,i){return u(this,void 0,void 0,function*(){var t=this.m(n),e=yield this.O(null,n,i);e&&this.S(t,$P($P({},e),{source:"Prefetch"}))})}en(i,r,s){return u(this,void 0,void 0,function*(){var t=yield this.I(i,r,s);if(!t)return o.Log.debug("No response returned for latest value"),null;var e=(0,l.typedJsonParse)(t,"has_updates","Failure while attempting to persist latest value");let n=null;return!0===(null==e?void 0:e.has_updates)?n={source:"Network",data:t,receivedAt:Date.now()}:i&&!1===(null==e?void 0:e.has_updates)&&(n={source:"NetworkNotModified",data:i,receivedAt:Date.now()}),n?(t=this.m(r),this.S(t,n),yield this.A(t,n),n):null})}M(){return null!=this.h?this.h:(o.Log.error(this.o+" is not attached to a Client"),"")}m(t){t=(0,r.getUserStorageKey)(this.M(),t);return`${i.DataAdapterCachePrefix}.${this.u}.`+t}S(t,e){var n=Object.entries(this.v);n.length<10||([n]=n.reduce((t,e)=>e[1]<t[1]?e:t),delete this.v[n]),this.v[t]=e}p(t){var e=null==(e=s.Storage.D)?void 0:e.call(s.Storage,t);return null!=e&&(t=(0,l.typedJsonParse)(e,"source","Failed to parse cached result"))?$P($P({},t),{source:"Cache"}):null}A(t,e){return u(this,void 0,void 0,function*(){yield s.Storage.P(t,JSON.stringify(e)),yield this.k(t)})}k(n){var i;return u(this,void 0,void 0,function*(){var t=null!=(i=yield(0,s.N)(this._))?i:{},e=(t[n]=Date.now(),Object.entries(t));e.length<=10||(delete t[(e=e.reduce((t,e)=>e[1]<t[1]?e:t))[0]],yield s.Storage.C(e[0])),yield(0,s.G)(this._,t)})}}},280:(t,e)=>{$Q(e),e.Diagnostics=void 0;e.Diagnostics=class{static mark(){}}},184:(t,e)=>{$Q(e)},512:function(t,o,e){var n=this&&this.__awaiter||$A();Object.defineProperty(o,"__esModule",{value:!0}),o.ErrorBoundary=o.EXCEPTION_ENDPOINT=void 0;const i=e(780),l=e(360),a=e(972);o.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";o.ErrorBoundary=class{constructor(t,e,n){this.h=t,this.J=e,this.F=n,this.R=new Set}wrap(i){try{const t=i;!function(t){const e=new Set;let n=Object.getPrototypeOf(t);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).filter(t=>"function"==typeof(null===n||void 0===n?void 0:n[t])).forEach(t=>e.add(t)),n=Object.getPrototypeOf(n);return Array.from(e)}(t).forEach(e=>{const n=t[e];"$EB"in n||(t[e]=(...t)=>this.capture(e,()=>n.apply(i,t)),t[e].$EB=!0)})}catch(t){this.U("eb:wrap",t)}}capture(e,t){try{var n=t();return n&&n instanceof Promise?n.catch(t=>this.U(e,t)):n}catch(t){return this.U(e,t),null}}logError(t,e){this.U(t,e)}U(s,u){try{i.Log.warn("Caught error in "+s,{error:u});n(this,void 0,void 0,function*(){var t,e,n=null!=u?u:Error("[Statsig] Error was empty"),i=n instanceof Error,r=i?n.name:"No Name";this.R.has(r)||(this.R.add(r),null!=(t=null==(t=this.J)?void 0:t.networkConfig)&&t.preventAllNetworkTraffic?null!=(t=this.F)&&t.call(this,{name:"error",error:u}):(t=l.SDKType.K(this.h),e=a.StatsigMetadataProvider.get(),i=i?n.stack:function(t){try{return JSON.stringify(t)}catch(t){return"[Statsig] Failed to get string for error."}}(n),n=JSON.stringify($P({tag:s,exception:r,info:i},$P($P({},e),{sdkType:t}))),yield(null!=(r=null==(i=null==(r=this.J)?void 0:r.networkConfig)?void 0:i.networkOverrideFunc)?r:fetch)(o.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.h,"STATSIG-SDK-TYPE":String(t),"STATSIG-SDK-VERSION":String(e.sdkVersion),"Content-Type":"application/json"},body:n}),null!=(i=this.F)&&i.call(this,{name:"error",error:u})))}).then(()=>{}).catch(()=>{})}catch(t){}}}},500:(t,e)=>{$Q(e)},788:(t,e)=>{$Q(e)},728:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.EventLogger=void 0;const r=n(832),s=n(780),u=n(716),o=n(48),l=n(876),a=n(444),c=n(412),d=n(84),h=n(100),v={},_=t=>{null!=(t=v[t])&&t.flush().catch(()=>{})};e.EventLogger=class{constructor(e,t,n,i){this.h=e,this.F=t,this.L=n,this.J=i,this.V=[],this.q={},this.B={},this.$=!1,this.H=Date.now(),(v[e]=this).Y=!0===(null==i?void 0:i.disableLogging),this.W=null!=(t=null==i?void 0:i.loggingBufferMaxSize)?t:50;t=null!=(n=null==i?void 0:i.loggingIntervalMs)?n:1e4;const r=setInterval(()=>{v[e]?_(e):clearInterval(r)},t);this.X=r;n=null==i?void 0:i.networkConfig;this.tt=(0,d.et)(null==n?void 0:n.logEventUrl,null==n?void 0:n.api,"/rgstr",u.NetworkDefault.eventsApi),this.nt=(0,d.et)(null==n?void 0:n.logEventBeaconUrl,null==n?void 0:n.api,"/log_event_beacon",u.NetworkDefault.eventsApi),(0,h.it)(t=>{"background"===t&&_(e)}),this.st()}setLoggingDisabled(t){this.Y=t}enqueue(t){this.rt(t)&&(this.ut(t),this.lt(),this.V.length>this.W)&&_(this.h)}incrementNonExposureCount(t){var e=null!=(e=this.B[t])?e:0;this.B[t]=e+1}reset(){this.q={}}shutdown(){return i(this,void 0,void 0,function*(){this.X&&(clearInterval(this.X),this.X=null),yield this.flush()})}flush(){return i(this,void 0,void 0,function*(){var t;this.ct(),0!==this.V.length&&(t=this.V,this.V=[],yield this.dt(t))})}lt(){this.$||(this.$=!0,200<Date.now()-this.H)||setTimeout(()=>_(this.h),200)}rt(t){if((0,l.ht)(t)){var t=[t.eventName,null==(e=t.user)?void 0:e.userID,null==(e=t.metadata)?void 0:e.gate,null==(e=t.metadata)?void 0:e.config,null==(e=t.metadata)?void 0:e.ruleID].join("|"),e=this.q[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3<Object.keys(this.q).length&&(this.q={}),this.q[t]=n}return!0}dt(t){var e,n;return i(this,void 0,void 0,function*(){if(this.Y)this.vt(t);else try{(!(0,h._t)()&&this.L.isBeaconSupported()&&null==(null==(n=null==(e=this.J)?void 0:e.networkConfig)?void 0:n.networkOverrideFunc)?yield this.ft(t):yield this.gt(t)).success?this.F({name:"logs_flushed",events:t}):this.vt(t)}catch(t){s.Log.warn("Failed to flush events.")}})}gt(e){return i(this,void 0,void 0,function*(){var t=yield this.L.post({sdkKey:this.h,data:{events:e},url:this.tt,retries:3,params:{[u.NetworkParam.EventCount]:String(e.length)}}),t=null!=t&&t.body?(0,c.typedJsonParse)(t.body,"success","Failed to parse SendEventsResponse"):null;return{success:!0===(null==t?void 0:t.success)}})}ft(t){return i(this,void 0,void 0,function*(){return{success:yield this.L.beacon({sdkKey:this.h,data:{events:t},url:this.nt})}})}vt(t){for(;500<t.length;)t.shift();var e=this.bt();(0,a.G)(e,t).catch(()=>{s.Log.warn("Unable to save failed logs to storage")})}st(){const e=this.bt();i(this,void 0,void 0,function*(){var t=yield(0,a.N)(e);t&&(yield a.Storage.C(e),yield this.dt(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}bt(){return"statsig.failed_logs."+(0,r.DJB2)(this.h)}ut(t){t.user&&(t.user=$P({},t.user),delete t.user.privateAttributes);var e={},n=this.yt();n&&(e.statsigMetadata={currentPage:n}),this.V.push($P($P({},t),e))}ct(){0!==Object.keys(this.B).length&&(this.ut({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:$P({},this.B)}}),this.B={})}yt(){var t;if(!1!==(null==(t=this.J)?void 0:t.includeCurrentPageUrlWithEvents))return(0,o.St)()}}},832:(t,e)=>{$Q(e),e.DJB2Object=e.DJB2=void 0;e.DJB2=e=>{let n=0;for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return String(n>>>0)};e.DJB2Object=t=>(0,e.DJB2)(JSON.stringify(r(t)));const r=n=>{if(null==n)return null;var t=Object.keys(n).sort();const i={};return t.forEach(t=>{let e=n[t];e instanceof Object&&(e=r(e)),i[t]=e}),i}},664:(t,e)=>{$Q(e)},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,r;$Q(e),e.Log=e.LogLevel=void 0,(r=i||(e.LogLevel=i={}))[r.None=0]="None",r[r.Error=1]="Error",r[r.Warn=2]="Warn",r[r.Info=3]="Info",r[r.Debug=4]="Debug";class s{static info(...t){this.level>=i.Info&&console.info(...n(t))}static debug(...t){this.level>=i.Debug&&console.debug(...n(t))}static warn(...t){this.level>=i.Warn&&console.warn(...n(t))}static error(...t){this.level>=i.Error&&console.error(...n(t))}}(e.Log=s).level=i.Error},716:(t,e)=>{$Q(e),e.NetworkParam=e.NetworkDefault=void 0,e.NetworkDefault={eventsApi:"https://prodregistryv2.org/v1",initializeApi:"https://featureassets.org/v1",specsApi:"https://assetsconfigcdn.org/v1"},e.NetworkParam={EventCount:"ec",SdkKey:"k",SdkType:"st",SdkVersion:"sv",Time:"t",SessionID:"sid",StatsigEncoded:"se"}},188:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.NetworkCore=void 0,n(496);const g=n(280),p=n(780),o=n(716),s=n(360),l=n(48),u=n(612),a=n(604),c=n(972);e.NetworkCore=class{constructor(t,e){this.J=t,this.F=e,this.Ot=null!=(t=null==(e=null==t?void 0:t.networkConfig)?void 0:e.networkTimeoutMs)?t:1e4}post(e){return i(this,void 0,void 0,function*(){var t=yield this.jt(e);return this.Tt($P({method:"POST",body:this.wt(e,t)},e))})}get(t){return this.Tt($P({method:"GET"},t))}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return i(this,void 0,void 0,function*(){var t,e;return!!y(n)&&(t=yield this.It(n),e=yield this.jt(n),navigator.sendBeacon(t,e))})}Tt(d){var h,v,_,f;return i(this,void 0,void 0,function*(){if(!y(d))return null;if(null!=(f=null==(f=this.J)?void 0:f.networkConfig)&&f.preventAllNetworkTraffic)return null;var{method:e,body:n,retries:i}=d;const r=new AbortController;var t=setTimeout(()=>r.abort(`Timeout of ${this.Ot}ms expired.`),this.Ot),s=yield this.It(d),u=null;try{var o,l,a,c={method:e,body:n,headers:$P({},d.headers),signal:r.signal,priority:d.priority,keepalive:!0},u=yield(null!=(_=null==(v=null==(h=this.J)?void 0:h.networkConfig)?void 0:v.networkOverrideFunc)?_:fetch)(s,c);if(clearTimeout(t),u.ok)return a=yield u.text(),g.Diagnostics.mark(),{body:a,code:u.status};throw o=yield u.text().catch(()=>"No Text"),(l=new Error(`Failed to fetch: ${s} `+o)).name="NetworkError",l}catch(t){n=function(t,e){if(t.signal.aborted&&"string"==typeof t.signal.reason)return t.signal.reason;if("string"==typeof e)return e;if(e instanceof Error)return e.name+": "+e.message;return"Unknown Error"}(r,t);return g.Diagnostics.mark(),!i||i<=0?(null!=(f=this.F)&&f.call(this,{name:"error",error:t}),p.Log.error(`A networking error occured during ${e} request to ${s}.`,n,t),null):this.Tt($P($P({},d),{retries:i-1}))}})}It(e){return i(this,void 0,void 0,function*(){var t=$P({[o.NetworkParam.SdkKey]:e.sdkKey,[o.NetworkParam.SdkType]:s.SDKType.K(e.sdkKey),[o.NetworkParam.SdkVersion]:c.SDK_VERSION,[o.NetworkParam.Time]:String(Date.now()),[o.NetworkParam.SessionID]:yield u.SessionID.get(e.sdkKey)},e.params),t=Object.entries(t).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return e.url+(t?"?"+t:"")})}jt(r){return i(this,void 0,void 0,function*(){var{data:t,sdkKey:e}=r,n=yield a.StableID.get(e),i=yield u.SessionID.get(e),e=s.SDKType.K(e);return JSON.stringify($P($P({},t),{statsigMetadata:$P($P({},c.StatsigMetadataProvider.get()),{stableID:n,sessionID:i,sdkType:e})}))})}wt(t,e){var n,i,r,s=(0,l.kt)();if(null==s||!s.btoa||null!=(null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__["no-encode"])||null!=(n=this.J)&&n.disableStatsigEncoding||!t.isStatsigEncodable)return e;try{var u=null!=(i=s.btoa(e).split("").reverse().join(""))?i:e;return t.params=$P($P({},null!=(r=t.params)?r:{}),{[o.NetworkParam.StatsigEncoded]:"1"}),u}catch(t){return p.Log.warn("/initialize request encoding failed"),e}}};const y=t=>!!t.sdkKey||(p.Log.warn("Unable to make request without an SDK key"),!1)},264:(t,e)=>{$Q(e)},360:(t,e)=>{$Q(e),e.SDKType=void 0;const n={};let i;e.SDKType={K:t=>{return(null!=(t=n[t])?t:"js-mono")+(null!==i&&void 0!==i?i:"")},At(t,e){n[t]=e},xt(t){i&&"-react"!==i||(i="-"+t)}}},48:(t,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.St=i.Mt=i.Dt=i.Et=i.Pt=i.kt=void 0;i.kt=()=>"undefined"!=typeof window?window:null,i.Pt=()=>{var t=(0,i.kt)();return null!=(t=null==t?void 0:t.document)?t:null},i.Et=()=>null!=(0,i.Pt)(),i.Dt=(t,e)=>{var n=(0,i.kt)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(t,e)},i.Mt=(t,e)=>{var n=(0,i.Pt)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(t,e)};i.St=()=>{var t;try{return null==(t=(0,i.kt)())?void 0:t.location.href.split(/[?#]/)[0]}catch(t){}}},612:function(t,e,n){var u=this&&this.__awaiter||$A();$Q(e),e.StatsigSession=e.SessionID=void 0;const i=n(832),o=n(780),l=n(444),a=n(556),c=18e5,d=144e5,h={};function v(e,t){return setTimeout(()=>{var t=null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.instance(e);t&&t.$emt({name:"session_expired"})},t)}function _(t){return"statsig.session_id."+(0,i.DJB2)(t)}e.SessionID={get:t=>u(void 0,void 0,void 0,function*(){return e.StatsigSession.get(t).then(t=>t.data.sessionID)})},e.StatsigSession={get:s=>u(void 0,void 0,void 0,function*(){null==h[s]&&(h[s]=function(n){return u(this,void 0,void 0,function*(){let t=yield function(t){t=_(t);return(0,l.N)(t)}(n);var e=Date.now();return{data:t=t||{sessionID:(0,a.getUUID)(),startTime:e,lastUpdate:e},sdkKey:n}})}(s));var t=yield h[s],e=Date.now(),n=t.data,i=((function({lastUpdate:t}){return Date.now()-t>c}(n)||function({startTime:t}){return Date.now()-t>d}(n))&&(n.sessionID=(0,a.getUUID)(),n.startTime=e),n.lastUpdate=e,n),r=t.sdkKey;return r=_(r),(0,l.G)(r,i).catch(()=>{o.Log.warn("Failed to save SessionID")}),clearTimeout(t.idleTimeoutID),clearTimeout(t.ageTimeoutID),e-=n.startTime,n=t.sdkKey,t.idleTimeoutID=v(n,c),t.ageTimeoutID=v(n,d-e),t})}},604:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.StableID=void 0;const r=n(832),s=n(780),u=n(444),o=n(556),l={};function a(t){return"statsig.stable_id."+(0,r.DJB2)(t)}function c(t,e){e=a(e);(0,u.G)(e,t).catch(()=>{s.Log.warn("Failed to save StableID")})}e.StableID={get:e=>i(void 0,void 0,void 0,function*(){return null==l[e]&&(l[e]=function(t){t=a(t);return(0,u.N)(t)}(e).then(t=>{return null!=t||c(t=(0,o.getUUID)(),e),t})),l[e]}),setOverride:(t,e)=>{l[e]=Promise.resolve(t),c(t,e)}}},688:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.StatsigClientBase=void 0,n(496);const l=n(496),a=n(512),c=n(728),d=n(780),h=n(48),v=n(604),_=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.Ft={};var r,s=this.$emt.bind(this),u=(0,l.i)(),o=null!=(o=u.instances)?o:{};null!=i&&i.logLevel&&(d.Log.level=null==i?void 0:i.logLevel),null!=i&&i.disableStorage&&_.Storage.Ut(!0),null!=i&&i.overrideStableID&&v.StableID.setOverride(i.overrideStableID,t),this.l=new a.ErrorBoundary(t,i,s),this.l.wrap(this),this.l.wrap(n),this.l.wrap(e),this.h=t,this.J=null!=i?i:{},this.Kt=null!=(r=null==i?void 0:i.overrideAdapter)?r:null,this.Lt=new c.EventLogger(t,s,n,i),null!=o[t]&&(0,h.Et)()&&d.Log.warn("Creating multiple Statsig clients with the same SDK key can lead to unexpected behavior. Multi-instance support requires different SDK keys."),o[t]=this,u.lastInstance=this,u.instances=o,__STATSIG__=u,this.dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&(this.J.disableLogging=t.disableLogging,this.Lt.setLoggingDisabled(t.disableLogging)),null!=t.disableStorage&&(this.J.disableStorage=t.disableStorage,_.Storage.Ut(t.disableStorage))}flush(){return this.Lt.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.$emt({name:"pre_shutdown"}),yield this.Lt.shutdown()})}on(t,e){this.Ft[t]||(this.Ft[t]=[]),this.Ft[t].push(e)}off(t,e){this.Ft[t]&&-1!==(e=this.Ft[t].indexOf(e))&&this.Ft[t].splice(e,1)}$on(t,e){e.__isInternal=!0,this.on(t,e)}$emt(n){var t;const e=e=>{try{e(n)}catch(t){!0===e.__isInternal?this.l.logError("__emit:"+n.name,t):d.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",n)}};this.Ft[n.name]&&this.Ft[n.name].forEach(t=>e(t)),null!=(t=this.Ft["*"])&&t.forEach(e)}Jt(t,e){this.loadingStatus=t,this.$emt({name:"values_updated",status:t,values:e})}Vt(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.Lt.incrementNonExposureCount(t):this.Lt.enqueue(e)}}},808:(t,e)=>{$Q(e)},283:(t,e)=>{$Q(e),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},876:(t,e)=>{$Q(e),e.qt=e.zt=e.Bt=e.ht=void 0;const n="statsig::config_exposure",i="statsig::gate_exposure",l=(t,e,n,i,r)=>({eventName:t,user:e,value:null,metadata:s(n,i),secondaryExposures:r,time:Date.now()});e.ht=({eventName:t})=>t===i||t===n,e.Bt=(t,e)=>{return l(i,t,e.details,{gate:e.name,gateValue:String(e.value),ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.zt=(t,e)=>{return l(n,t,e.details,{config:e.name,ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])};e.qt=(t,e,n)=>{var i,r=e.__evaluation,s=!0===(null==(s=null==r?void 0:r.explicit_parameters)?void 0:s.includes(n));let u="",o=null!=(i=null==r?void 0:r.undelegated_secondary_exposures)?i:[];return s&&(u=null!=(i=r.allocated_experiment_name)?i:"",o=r.secondary_exposures),l("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:u,isExplicitParameter:String(s)},o)};const s=(t,e)=>(e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut)),t.receivedAt&&(e.receivedAt=String(t.receivedAt)),e)},972:(t,e)=>{$Q(e),e.StatsigMetadataProvider=e.SDK_VERSION=void 0,e.SDK_VERSION="0.0.1-beta.40";let n={sdkVersion:e.SDK_VERSION,sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=$P($P({},n),t)}}},384:(t,e)=>{$Q(e)},396:(t,e)=>{$Q(e),e.$t=e.Ht=e.Yt=e.Wt=void 0;const r="default";function s(t,e,n,i){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:r,__evaluation:n,value:i}}function u(s,u){return(t,e)=>{var n,i,r=null!=(r=null==s?void 0:s[t])?r:null;return null==r||null!=e&&(n=e,(i=t=>Array.isArray(t)?"array":typeof t)(r)!==i(n))?null!=e?e:null:(null!=u&&u(t),r)}}e.Wt=function(t,e,n){return s(t,e,n,!0===(null==n?void 0:n.value))},e.Yt=function(t,e,n){return $P($P({},s(t,e,n,null!=(t=null==n?void 0:n.value)?t:{})),{groupName:null,get:u(null==n?void 0:n.value)})},e.Ht=function(t,e,n,i){return $P($P({},s(t,e,n,void 0)),{get:u(null==n?void 0:n.value,i),groupName:null!=(t=null==n?void 0:n.group_name)?t:null,__value:null!=(e=null==n?void 0:n.value)?e:{}})},e.$t=function(t,e,n,i){return $P($P($P({},t),e),{get:u(n,i)})}},136:(t,e)=>{$Q(e)},296:(t,e,n)=>{$Q(e),e.getUnitIDFromUser=e.getUserStorageKey=e.normalizeUser=void 0;const i=n(832);e.normalizeUser=function(t,e){try{var n=JSON.parse(JSON.stringify(t));return null!=e&&(n.statsigEnvironment=e),n}catch(t){throw new Error("User object must be convertable to JSON string.")}},e.getUserStorageKey=function(t,e){return(0,i.DJB2Object)({sdkKey:t,user:e})},e.getUnitIDFromUser=function(t,e){var n;return"string"==typeof e&&"userid"!==e.toLowerCase()?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(n=null==t?void 0:t.customIDs)?void 0:n[e.toLowerCase()]:t.userID}},444:function(t,n,e){var i=this&&this.__awaiter||$A(),e=(Object.defineProperty(n,"__esModule",{value:!0}),n.G=n.N=n.Storage=void 0,e(780));const r={},s=t=>Promise.resolve(t),u={Qt:()=>"InMemory",D(t){return null!=(t=r[t])?t:null},Xt(t){return s(null!=(t=r[t])?t:null)},P(t,e){return r[t]=e,s()},C(t){return delete r[t],s()},Zt(){return s(Object.keys(r))}};let o=null;try{"undefined"!=typeof window&&"localStorage"in window&&(o={Qt:()=>"LocalStorage",D(t){return localStorage.getItem(t)},Xt(t){return s(localStorage.getItem(t))},P(t,e){return localStorage.setItem(t,e),s()},C(t){return localStorage.removeItem(t),s()},Zt(){var t=Object.keys(localStorage);return s(t)}})}catch(t){e.Log.warn("Failed to setup localStorageProvider.")}let l=null!==o&&void 0!==o?o:u,a=l;function c(t){try{return t()}catch(t){if(t instanceof Error&&"SecurityError"===t.name)return n.Storage.te(u),null;throw t}}n.Storage={Qt:()=>a.Qt(),Xt:t=>i(void 0,void 0,void 0,function*(){return c(()=>a.Xt(t))}),D:e=>c(()=>{var t;return null!=(t=null==(t=a.D)?void 0:t.call(a,e))?t:null}),P:(t,e)=>a.P(t,e),C:t=>a.C(t),Zt:()=>a.Zt(),te:t=>{l=t,a=t},Ut:t=>{a=t?u:l}},n.N=function(e){return i(this,void 0,void 0,function*(){var t=yield n.Storage.Xt(e);return JSON.parse(null!=t?t:"null")})},n.G=function(t,e){return i(this,void 0,void 0,function*(){yield n.Storage.P(t,JSON.stringify(e))})}},412:(t,e,n)=>{$Q(e),e.typedJsonParse=void 0;const r=n(780);e.typedJsonParse=function(t,e,n){try{var i=JSON.parse(t);return"object"==typeof i&&0 in i,i}catch(t){}return r.Log.error(n),null}},556:(t,e)=>{$Q(e),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let n=(new Date).getTime(),i="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return`xxxxxxxx-xxxx-4xxx-${"89ab"[Math.floor(4*Math.random())]}xxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let e=16*Math.random();return 0<n?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(i+e)%16|0,i=Math.floor(i/16)),("x"===t?e:7&e|8).toString(16)})}},84:(t,e)=>{$Q(e),e.et=void 0,e.et=function(t,e,n,i){return t||(e?""+e+n:""+i+n)}},539:(t,e)=>{$Q(e)},100:(t,e,n)=>{$Q(e),e.ee=e.it=e._t=void 0;n=n(48);const i="foreground",r="background",s=[];let u=i;e._t=()=>u===i,e.it=t=>{s.unshift(t)};e.ee=e=>{e!==u&&(u=e,s.forEach(t=>t(e)))},(0,n.Dt)("focus",()=>(0,e.ee)(i)),(0,n.Dt)("blur",()=>(0,e.ee)(r)),(0,n.Dt)("beforeunload",()=>(0,e.ee)(r)),(0,n.Mt)("visibilitychange",()=>{(0,e.ee)("visible"===document.visibilityState?i:r)})},464:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&("get"in r?e.__esModule:!r.writable&&!r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};$Q(e),e.Log=e.Storage=e.EventLogger=void 0,n(496);const s=n(728),u=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return s.EventLogger}}),n(780));Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return u.Log}});var o=n(972);const l=n(444);Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return l.Storage}});var a=n(556);r(n(496),e),r(n(856),e),r(n(320),e),r(n(184),e),r(n(512),e),r(n(500),e),r(n(788),e),r(n(832),e),r(n(664),e),r(n(780),e),r(n(188),e),r(n(716),e),r(n(264),e),r(n(48),e),r(n(360),e),r(n(612),e),r(n(604),e),r(n(688),e),r(n(808),e),r(n(283),e),r(n(876),e),r(n(972),e),r(n(384),e),r(n(396),e),r(n(136),e),r(n(296),e),r(n(444),e),r(n(412),e),r(n(84),e),r(n(539),e),r(n(556),e),r(n(100),e),__STATSIG__=$P($P({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:s.EventLogger,Log:u.Log,getUUID:a.getUUID,Storage:l.Storage,SDK_VERSION:o.SDK_VERSION})},448:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&("get"in r?e.__esModule:!r.writable&&!r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};$Q(e),r(n(376),e),e.default=__STATSIG__},532:(t,e)=>{function o(t){return t.setUTCHours(0,0,0,0),t.getTime()}$Q(e),e.default={compareNumbers(t,e,n){if(null==t||null==e)return!1;var i=Number(t),r=Number(e);if(isNaN(i)||isNaN(r))return!1;switch(n){case"gt":return e<t;case"gte":return e<=t;case"lt":return t<e;case"lte":return t<=e;default:return!1}},compareVersions(t,e,n){if(null==t||null==e)return!1;var t=String(t),e=String(e),i=t=>{var e=t.indexOf("-");return-1!==e?t.substring(0,e):t},r=((t,e)=>{var n=t.split(".").map(t=>parseInt(t)),i=e.split(".").map(t=>parseInt(t));let r=0;for(;r<Math.max(n.length,i.length);){var s=r<n.length?n[r]:0,u=r<i.length?i[r]:0;if(s<u)return-1;if(u<s)return 1;r++}return 0})(i(t),i(e));switch(n){case"version_gt":return 0<r;case"version_gte":return 0<=r;case"version_lt":return r<0;case"version_lte":return r<=0;case"version_eq":return 0===r;case"version_neq":return 0!==r;default:return!1}},compareStringInArray(r,t,s){if(!Array.isArray(t))return!1;const u="any_case_sensitive"!==s&&"none_case_sensitive"!==s;var e=-1!==t.findIndex(t=>{var e=String(r),t=String(t),n=u?e.toLowerCase():e,i=u?t.toLowerCase():t;switch(s){case"any":case"none":case"any_case_sensitive":case"none_case_sensitive":return n===i;case"str_starts_with_any":return n.startsWith(i);case"str_ends_with_any":return n.endsWith(i);case"str_contains_any":case"str_contains_none":return n.includes(i);default:return!1}});switch(s){case"none":case"none_case_sensitive":case"str_contains_none":return!e;default:return e}},compareStringWithRegEx(t,e){try{var n=String(t);if(n.length<1e3)return new RegExp(String(e)).test(n)}catch(t){}return!1},compareTime(n,i,r){if(null==n||null==i)return!1;try{let t=new Date(String(n)),e=(isNaN(t.getTime())&&(t=new Date(Number(n))),new Date(String(i)));isNaN(e.getTime())&&(e=new Date(Number(i)));var s=t.getTime(),u=e.getTime();if(isNaN(s)||isNaN(u))return!1;switch(r){case"before":return s<u;case"after":return u<s;case"on":return o(t)===o(e);default:return!1}}catch(t){return!1}}}},947:(t,e)=>{$Q(e),e.resultToLayerEval=e.resultToConfigEval=e.resultToGateEval=e.makeEvalResult=void 0,e.makeEvalResult=function(t){return $P($P({},{unsupported:!1,bool_value:!1,rule_id:"",secondary_exposures:[],json_value:{},explicit_parameters:null,allocated_experiment_name:null,is_experiment_group:!1,group_name:null,undelegated_secondary_exposures:void 0}),t)},e.resultToGateEval=function(t,e){return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.bool_value,secondary_exposures:e.secondary_exposures}},e.resultToConfigEval=function(t,e){var n;return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.json_value,secondary_exposures:e.secondary_exposures,group:null!=(n=e.group_name)?n:"",group_name:null!=(n=e.group_name)?n:void 0,is_device_based:!1,is_experiment_active:t.isActive,is_user_in_experiment:e.is_experiment_group}},e.resultToLayerEval=function(t,e,n){return{name:t.name,rule_id:n.rule_id,value:n.json_value,secondary_exposures:n.secondary_exposures,undelegated_secondary_exposures:n.undelegated_secondary_exposures,allocated_experiment_name:null!=(t=n.allocated_experiment_name)?t:"",explicit_parameters:null!=(t=n.explicit_parameters)?t:[],group:null!=(t=n.group_name)?t:"",group_name:null!=(t=n.group_name)?t:void 0,is_device_based:!1,is_experiment_active:null==e?void 0:e.isActive,is_user_in_experiment:n.is_experiment_group}}},931:(t,e,n)=>{$Q(e);const c=n(464),i=n(452),d=n(532),h=n(947);function v(t){return(0,i.SHA256)(t).dataView().getBigUint64(0,!1)}function o(t){return null!=t&&"object"==typeof t}e.default=class{constructor(t){this.de=t}evaluateGate(t,e){var{spec:t,details:n}=this.Ge("gate",t);return t?{evaluation:(0,h.resultToGateEval)(t,this.Ce(t,e)),details:n}:{evaluation:null,details:n}}evaluateConfig(t,e){var{spec:t,details:n}=this.Ge("config",t);return t?{evaluation:(0,h.resultToConfigEval)(t,this.Ce(t,e)),details:n}:{evaluation:null,details:n}}evaluateLayer(t,e){var n,{spec:t,details:i}=this.Ge("layer",t);return t?(n=null!=(n=null==(e=this.Ce(t,e))?void 0:e.allocated_experiment_name)?n:"",n=this.de.getSpecAndSourceInfo("config",n).spec,{evaluation:(0,h.resultToLayerEval)(t,n,e),details:i}):{evaluation:null,details:i}}Ge(t,e){t=this.de.getSpecAndSourceInfo(t,e);return{details:this.Fe(t),spec:t.spec}}Fe(t){var{source:t,spec:e,lcut:n,receivedAt:i}=t;return"Uninitialized"===t||"NoValues"===t?{reason:t}:{reason:t+":"+(null==e?"Unrecognized":"Recognized"),lcut:n,receivedAt:i}}Ce(t,e){var n=o(t.defaultValue)?t.defaultValue:void 0;if(!t.enabled)return(0,h.makeEvalResult)({json_value:n,rule_id:"disabled"});var i=[];for(const u of t.rules){var r,s=this.Ke(u,e);if(s.unsupported)return s;if(i.push(...s.secondary_exposures),s.bool_value)return this.Ve(u.configDelegate,e,i)||(r=function(t,e,n){if(100===t.passPercentage)return!0;if(0===t.passPercentage)return!1;e=v(n.salt+"."+(null!=(n=t.salt)?n:t.id)+"."+(null!=(n=(0,c.getUnitIDFromUser)(e,t.idType))?n:""));return Number(e%BigInt(1e4))<100*t.passPercentage}(u,e,t),(0,h.makeEvalResult)({rule_id:s.rule_id,bool_value:r,json_value:r?s.json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,is_experiment_group:s.is_experiment_group,group_name:s.group_name}))}return(0,h.makeEvalResult)({json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,rule_id:"default"})}Ke(t,e){var n=[];let i=!0;for(const s of t.conditions){var r=this.Le(s,e);if(r.unsupported)return r;n.push(...r.secondary_exposures),r.bool_value||(i=!1)}return(0,h.makeEvalResult)({rule_id:t.id,bool_value:i,json_value:o(t.returnValue)?t.returnValue:void 0,secondary_exposures:n,is_experiment_group:!0===t.isExperimentGroup,group_name:t.groupName})}Le(t,e){let n=null,i=!1;var r=t.field,s=t.targetValue,u=t.idType,o=t.type;switch(o){case"public":return(0,h.makeEvalResult)({bool_value:!0});case"pass_gate":case"fail_gate":var l=String(s),l=this.Re(l,e);return(0,h.makeEvalResult)({bool_value:"fail_gate"===o?!l.bool_value:l.bool_value,secondary_exposures:l.secondary_exposures});case"multi_pass_gate":case"multi_fail_gate":return this.Ue(s,o,e);case"user_field":case"ip_based":case"ua_based":n=function(t,e){var n;if(null==e||"object"!=typeof t||null==t)return null;var i=t;return null!=(n=null!=(n=null!=(n=null!=(n=null!=(n=i[e])?n:i[e.toLowerCase()])?n:null==(i=null==t?void 0:t.custom)?void 0:i[e])?n:null==(i=null==t?void 0:t.custom)?void 0:i[e.toLowerCase()])?n:null==(i=null==t?void 0:t.privateAttributes)?void 0:i[e])?n:null==(i=null==t?void 0:t.privateAttributes)?void 0:i[e.toLowerCase()]}(e,r);break;case"environment_field":n=function(t,e){if(null==e)return null;t=t.statsigEnvironment;if(null!=t){const n=e.toLowerCase(),i=Object.keys(t).find(t=>t.toLowerCase()===n);return void 0!==i?t[i]:void 0}}(e,r);break;case"current_time":n=Date.now();break;case"user_bucket":l=v(null!==(l=String(null!=(l=null==(l=t.additionalValues)?void 0:l.salt)?l:"")+"."+(0,c.getUnitIDFromUser)(e,u))?l:"");n=Number(l%BigInt(1e3));break;case"unit_id":n=(0,c.getUnitIDFromUser)(e,u);break;default:return(0,h.makeEvalResult)({unsupported:!0})}var a=t.operator;switch(a){case"gt":case"gte":case"lt":case"lte":i=d.default.compareNumbers(n,s,a);break;case"version_gt":case"version_gte":case"version_lt":case"version_lte":case"version_eq":case"version_neq":i=d.default.compareVersions(n,s,a);break;case"any":case"none":case"str_starts_with_any":case"str_ends_with_any":case"str_contains_any":case"str_contains_none":case"any_case_sensitive":case"none_case_sensitive":i=d.default.compareStringInArray(n,s,a);break;case"str_matches":i=d.default.compareStringWithRegEx(n,s);break;case"before":case"after":case"on":i=d.default.compareTime(n,s,a);break;case"eq":i=n==s;break;case"neq":i=n!=s;break;case"in_segment_list":case"not_in_segment_list":return(0,h.makeEvalResult)({unsupported:!0})}return(0,h.makeEvalResult)({bool_value:i})}Ve(t,e,n){var i;return t&&(i=this.de.getSpecAndSourceInfo("config",t).spec,i)?(e=this.Ce(i,e),(0,h.makeEvalResult)($P($P({},e),{allocated_experiment_name:t,explicit_parameters:i.explicitParameters,secondary_exposures:n.concat(e.secondary_exposures),undelegated_secondary_exposures:n}))):null}Re(t,e){var n=[];let i=!1;var r=this.de.getSpecAndSourceInfo("gate",t)["spec"];if(r){r=this.Ce(r,e);if(r.unsupported)return r;i=r.bool_value,n.push(...r.secondary_exposures),n.push({gate:t,gateValue:String(i),ruleID:r.rule_id})}return(0,h.makeEvalResult)({bool_value:i,secondary_exposures:n})}Ue(t,e,n){if(!Array.isArray(t))return(0,h.makeEvalResult)({unsupported:!0});var i="multi_pass_gate"===e,r=[];let s=!1;for(const o of t){if("string"!=typeof o)return(0,h.makeEvalResult)({unsupported:!0});var u=this.Re(o,n);if(u.unsupported)return u;if(r.push(...u.secondary_exposures),i?!0===u.bool_value:!1===u.bool_value){s=!0;break}}return(0,h.makeEvalResult)({bool_value:s,secondary_exposures:r})}}},160:function(t,e,n){var r=this&&this.__awaiter||$A();$Q(e);const i=n(464);class s extends i.NetworkCore{constructor(t=null){super(t);t=null==t?void 0:t.networkConfig;this.qe=(0,i.et)(null==t?void 0:t.downloadConfigSpecsUrl,null==t?void 0:t.api,"/download_config_specs",i.NetworkDefault.specsApi)}fetchConfigSpecs(e,n){var i;return r(this,void 0,void 0,function*(){var t=yield this.get({sdkKey:e,url:this.qe,priority:n});return null!=(i=null==t?void 0:t.body)?i:null})}}e.default=s},480:(t,e,n)=>{$Q(e);const i=n(464);function r(t){return(0,i.typedJsonParse)(t,"has_updates","Failed to parse DownloadConfigSpecsResponse")}e.default=class{constructor(){this.ne=null,this.ie=null,this.oe="Uninitialized",this.se=0,this.re=0}getValues(){return this.ne?r(this.ne):null}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=r(t.data))?void 0:e.has_updates)&&(this.se=e.time,this.re=t.receivedAt,this.oe=t.source,this.ie=e,this.ne=t.data)}reset(){this.ie=null,this.ne=null,this.oe="Loading"}finalize(){this.ie||(this.oe="NoValues")}getSpecAndSourceInfo(t,e){var t=this.ze(t);return{spec:null!=(t=null==t?void 0:t.find(t=>t.name===e))?t:null,source:this.oe,lcut:this.se,receivedAt:this.re}}ze(t){var e;switch(t){case"gate":return null==(e=this.ie)?void 0:e.feature_gates;case"config":return null==(e=this.ie)?void 0:e.dynamic_configs;case"layer":return null==(e=this.ie)?void 0:e.layer_configs}}}},368:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e);const u=n(464),r=n(931),s=n(160),o=n(480),l=n(4);class a extends u.StatsigClientBase{static instance(t){var e=(0,u.i)().instance(t);return e instanceof a?e:(u.Log.warn("Unable to find StatsigOnDeviceEvalClient instance"),new a(null!=t?t:""))}constructor(t,e=null){u.SDKType.At(t,"js-on-device-eval-client");var n=new s.default(e);super(t,null!=(t=null==e?void 0:e.dataAdapter)?t:new l.StatsigSpecsDataAdapter,n,e),this.de=new o.default,this.Be=new r.default(this.de)}initializeSync(){this.updateSync()}initializeAsync(t){return i(this,void 0,void 0,function*(){return this.updateAsync(t)})}updateSync(){this.de.reset();var t=this.dataAdapter.getDataSync();this.de.setValuesFromDataAdapter(t),this.de.finalize(),this.Jt("Ready",t),this._e(t)}updateAsync(e){return i(this,void 0,void 0,function*(){this.de.reset(),this.Jt("Loading",null);var t=this.dataAdapter.getDataSync();this.de.setValuesFromDataAdapter(t),t=yield this.dataAdapter.getDataAsync(t,e),this.de.setValuesFromDataAdapter(t),this.de.finalize(),this.Jt("Ready",t)})}getContext(){return{sdkKey:this.h,options:this.J,values:this.de.getValues(),errorBoundary:this.l}}getAsyncContext(){return i(this,void 0,void 0,function*(){return $P($P({},this.getContext()),{session:yield u.StatsigSession.get(this.h),stableID:yield u.StableID.get(this.h)})})}checkGate(t,e,n){return this.getFeatureGate(t,e,n).value}getFeatureGate(t,e,n){e=(0,u.normalizeUser)(e,this.J.environment);var{evaluation:i,details:r}=this.Be.evaluateGate(t,e),r=(0,u.Wt)(t,r,i);return this.Vt(t,(0,u.Bt)(e,r),n),this.$emt({name:"gate_evaluation",gate:r}),r}getDynamicConfig(t,e,n){t=this.fe("dynamic_config",t,e,n);return this.$emt({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e,n){t=this.fe("experiment",t,e,n);return this.$emt({name:"experiment_evaluation",experiment:t}),t}getLayer(e,n,i){n=(0,u.normalizeUser)(n,this.J.environment);var{evaluation:t,details:r}=this.Be.evaluateLayer(e,n);const s=(0,u.Ht)(e,r,t,t=>{this.Vt(e,(0,u.qt)(n,s,t),i)});return this.$emt({name:"layer_evaluation",layer:s}),s}logEvent(t,e,n,i){this.Lt.enqueue($P($P({},"string"==typeof t?{eventName:t,value:n,metadata:i}:t),{user:e,time:Date.now()}))}_e(t){this.dataAdapter.getDataAsync(t,{priority:"low"}).catch(t=>{u.Log.error("An error occurred after update.",t)})}fe(t,e,n,i){n=(0,u.normalizeUser)(n,this.J.environment);var{evaluation:r,details:s}=this.Be.evaluateConfig(e,n),s=(0,u.Yt)(e,s,r),r="experiment"===t?null==(t=null==(r=this.Kt)?void 0:r.getExperimentOverride)?void 0:t.call(r,s,n,i):null==(r=null==(t=this.Kt)?void 0:t.getDynamicConfigOverride)?void 0:r.call(t,s,n,i),t=null!=r?r:s;return this.Vt(e,(0,u.zt)(n,t),i),t}}e.default=a},4:function(t,e,n){var r=this&&this.__awaiter||$A(),i=($Q(e),e.StatsigSpecsDataAdapter=void 0,n(464));const s=n(160);class u extends i.DataAdapterCore{constructor(){super("SpecsDataAdapter","specs"),this.L=null}attach(t,e){super.attach(t,e),this.L=new s.default(null!=e?e:{})}getDataAsync(t,e){return this.O(t,void 0,e)}prefetchData(t){return this.T(void 0,t)}I(t,e,n){var i;return r(this,void 0,void 0,function*(){return null!=(i=yield null==(i=this.L)?void 0:i.fetchConfigSpecs(this.M(),null==n?void 0:n.priority))?i:null})}}e.StatsigSpecsDataAdapter=u},376:(t,e,n)=>{$Q(e),e.StatsigSpecsDataAdapter=e.StatsigOnDeviceEvalClient=void 0;var i=n(368);e.StatsigOnDeviceEvalClient=i.default;const r=n(4);Object.defineProperty(e,"StatsigSpecsDataAdapter",{enumerable:!0,get:function(){return r.StatsigSpecsDataAdapter}}),__STATSIG__=$P($P({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigSpecsDataAdapter:r.StatsigSpecsDataAdapter,StatsigOnDeviceEvalClient:i.default}),e.default=__STATSIG__},452:(t,e,n)=>{$Q(e),e.SHA256=void 0;const i=n(891);Object.defineProperty(e,"SHA256",{enumerable:!0,get:function(){return i.SHA256}})},891:(t,e)=>{$Q(e),e.SHA256=void 0,e.SHA256=function(t){return(new i).update(t)};const n=[-2147483648,8388608,32768,128],u=[24,16,8,0],m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];class i{constructor(){this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.lastByteIndex=-1}update(n){if(!this.finalized){if("string"!=typeof n)throw new Error('Must be of type "string"');var i;let t=0,e;for(var r=n.length,s=this.blocks;t<r;){for(this.hashed&&(this.hashed=!1,s[0]=this.block,s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),e=this.start;t<r&&e<64;++t)(i=n.charCodeAt(t))<128?s[e>>2]|=i<<u[3&e++]:(i<2048?s[e>>2]|=(192|i>>6)<<u[3&e++]:(i<55296||57344<=i?s[e>>2]|=(224|i>>12)<<u[3&e++]:(i=65536+((1023&i)<<10|1023&n.charCodeAt(++t)),s[e>>2]|=(240|i>>18)<<u[3&e++],s[e>>2]|=(128|i>>12&63)<<u[3&e++]),s[e>>2]|=(128|i>>6&63)<<u[3&e++]),s[e>>2]|=(128|63&i)<<u[3&e++]);this.lastByteIndex=e,this.bytes+=e-this.start,64<=e?(this.block=s[16],this.start=e-64,this.hash(),this.hashed=!0):this.start=e}4294967295<this.bytes&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296)}return this}finalize(){var t,e;this.finalized||(this.finalized=!0,t=this.blocks,e=this.lastByteIndex,t[16]=this.block,t[e>>2]|=n[3&e],this.block=t[16],56<=e&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash())}hash(){var t=this.blocks;let e=this.h0,n=this.h1,i=this.h2,r=this.h3,s=this.h4,u=this.h5,o=this.h6,l=this.h7,a,c,d,h,v,_,f,g,p,y,b;for(a=16;a<64;++a)v=t[a-15],c=(v>>>7|v<<25)^(v>>>18|v<<14)^v>>>3,v=t[a-2],d=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,t[a]=t[a-16]+c+t[a-7]+d<<0;for(b=n&i,a=0;a<64;a+=4)this.first?(g=704751109,v=t[0]-210244248,l=v-1521486534<<0,r=v+143694565<<0,this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),g=e&n,h=g^e&i^b,f=s&u^~s&o,v=l+d+f+m[a]+t[a],_=c+h,l=r+v<<0,r=v+_<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),p=r&e,h=p^r&n^g,f=l&s^~l&u,v=o+d+f+m[a+1]+t[a+1],_=c+h,o=i+v<<0,i=v+_<<0,c=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),y=i&r,h=y^i&e^p,f=o&l^~o&s,v=u+d+f+m[a+2]+t[a+2],_=c+h,u=n+v<<0,n=v+_<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),b=n&i,h=b^n&r^y,f=u&o^~u&l,v=s+d+f+m[a+3]+t[a+3],_=c+h,s=e+v<<0,e=v+_<<0;this.h0=this.h0+e<<0,this.h1=this.h1+n<<0,this.h2=this.h2+i<<0,this.h3=this.h3+r<<0,this.h4=this.h4+s<<0,this.h5=this.h5+u<<0,this.h6=this.h6+o<<0,this.h7=this.h7+l<<0}arrayBuffer(){return this.Je().buffer}dataView(){return this.Je().dataView}Je(){this.finalize();var t=new ArrayBuffer(32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),e.setUint32(28,this.h7),{dataView:e,buffer:t}}}}},i={};function r(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,r)),e.exports}return r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r(448).default})());
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@statsig/js-on-device-eval-client",
3
- "version": "0.0.1-beta.39",
3
+ "version": "0.0.1-beta.40",
4
4
  "dependencies": {
5
- "@statsig/client-core": "0.0.1-beta.39",
6
- "@statsig/sha256": "0.0.1-beta.39"
5
+ "@statsig/client-core": "0.0.1-beta.40",
6
+ "@statsig/sha256": "0.0.1-beta.40"
7
7
  },
8
8
  "jsdelivr": "./build/statsig-js-on-device-eval-client.min.js",
9
9
  "type": "commonjs",