@statsig/js-on-device-eval-client 3.32.0 → 3.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var $Q=(e)=>Object.defineProperty(e,"__esModule",{value:!0});var $Q2=(a,b,c)=>Object.defineProperty(a,b,c);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())})});!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 n={1845:(t,n,e)=>{var i;$Q2(n,"__esModule",{value:!0}),n.t=n.i=n.l=void 0;const s=e(7512);n.l=()=>{try{return"undefined"!=typeof __STATSIG__?__STATSIG__:o}catch(t){return o}},n.i=t=>(0,n.l)()[t];n.t=t=>{var e=(0,n.l)();return t?e.instances&&e.instances[t]:(e.instances&&1<Object.keys(e.instances).length&&s.Log.warn("Call made to Statsig global instance without an SDK key but there is more than one client instance. If you are using mulitple clients, please specify the SDK key."),e.firstInstance)};var r="__STATSIG__",l="undefined"!=typeof window?window:{},e=void 0!==e.g?e.g:{},u="undefined"!=typeof globalThis?globalThis:{};const o=null!=(i=null!=(i=null!=(i=l[r])?i:e[r])?i:u[r])?i:{instance:n.t};l[r]=o,e[r]=o,u[r]=o},7463:(t,e,n)=>{$Q(e),e.BatchQueue=void 0;const s=n(1956),i=n(4309);e.BatchQueue=class{constructor(t=i.EventRetryConstants.DEFAULT_BATCH_SIZE){this.Fi=[],this.Ci=t}batchSize(){return this.Ci}requeueBatch(t){return this.Ai(t)}hasFullBatch(){return this.Fi.some(t=>t.events.length>=this.Ci)}takeNextBatch(){return this.Fi.shift()}takeAllBatches(){var t=this.Fi;return this.Fi=[],t}createBatches(t){let e=0,n=0;for(;e<t.length;){var i=t.slice(e,e+this.Ci);n+=this.Ai(new s.EventBatch(i)),e+=this.Ci}return n}Ai(t){this.Fi.push(t);let e=0;for(;this.Fi.length>i.EventRetryConstants.MAX_PENDING_BATCHES;){var n=this.Fi.shift();n&&(e+=n.events.length)}return e}}},2137:(t,e,n)=>{$Q(e),e.o=e.u=void 0;const s=n(1406);function i(t,e,n){if(n)return n(t,e);const i=e&&e.customIDs?e.customIDs:{};e=["uid:"+(null!=(n=null==e?void 0:e.userID)?n:""),"cids:"+Object.keys(i).sort((t,e)=>t.localeCompare(e)).map(t=>t+"-"+i[t]).join(","),"k:"+t];return(0,s.h)(e.join("|"))}e.u=i,e.o=function(t,e,n){return e?i(t,e,n):(0,s.h)("k:"+t)}},6427:(t,e,n)=>{$Q(e),e.PrecomputedEvaluationsContextHandle=void 0;const i=n(7512),s=n(6830),r=n(4143),l=n(9122);e.PrecomputedEvaluationsContextHandle=class{constructor(t,e,n,i,s,r){this.j=t,this.Ni=e,this.Ri=n,this.Ui=i,this.Pi=s,this.Li=r}get sdkKey(){return this.j}get options(){return this.Ni()}get errorBoundary(){return this.Ri()}get values(){return this.Ui()}get user(){let t=(0,s.Bi)("StatsigUser",this.Pi());return null==t&&(i.Log.error("Failed to clone user"),t={}),t}getSession(t=!0){return r.StatsigSession.get(this.j,t)}get stableID(){return l.StableID.get(this.j)}get sdkInstanceID(){return this.Li()}toContext(t=!0){return{sdkKey:this.sdkKey,options:this.options,values:this.values,user:this.user,errorBoundary:this.errorBoundary,session:this.getSession(t),stableID:this.stableID,sdkInstanceID:this.sdkInstanceID}}}},694:function(t,e,n){var s=this&&this.__awaiter||$A();$Q(e),e.v=e.DataAdapterCore=void 0;const o=n(7512),a=n(9122),r=n(8578),l=n(4534),c=n(3401);function h(t,e,n,i){return{source:t,data:e,receivedAt:Date.now(),stableID:n,fullUserHash:(0,r._)(i)}}e.DataAdapterCore=class{constructor(t,e){this.p=t,this.m=e,this.O=null,this.j=null,this.gn=10,this.S="statsig.last_modified_time."+e,this.k=new i}attach(t,e,n){this.j=t,this.O=e}getDataSync(t){var t=t&&(0,r.D)(t,this.O),e=this.I(t),n=this.k.get(e,t);return n&&this.M(n)?n:(n=this.T(e))&&this.M(n)?(this.k.add(e,n,this.gn),this.k.get(e,t)):null}setData(t,e){var e=e&&(0,r.D)(e,this.O),n=this.I(e);this.k.add(n,h("Bootstrap",t,null,e),this.gn)}M(t){return null==t.stableID||t.stableID===a.StableID.get(this.N())}C(e,n,i){return s(this,void 0,void 0,function*(){l.Storage.isReady()||(yield l.Storage.isReadyResolver());var t=null!=e?e:this.getDataSync(n),t=[this.R(t,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)})}U(n,i){return s(this,void 0,void 0,function*(){var t=n&&(0,r.D)(n,this.O),e=this.I(t),t=yield this.C(null,t,i);t&&this.k.add(e,$P($P({},t),{source:"Prefetch"}),this.gn)})}R(r,l,u){return s(this,void 0,void 0,function*(){var t=null!=(t=null==r?void 0:r.data)?t:null,e=null!=r&&this.A(r,l),e=yield this.F(t,l,u,e);if(!e)return o.Log.debug("No response returned for latest value"),null;var n=(0,c.P)(e,"has_updates","Response"),i=this.N(),i=a.StableID.get(i);let s=null;if(!0===(null==n?void 0:n.has_updates))s=h("Network",e,i,l);else{if(!t||!1!==(null==n?void 0:n.has_updates))return null;s=h("NetworkNotModified",t,i,l)}e=this.I(l);return this.k.add(e,s,this.gn),this.L(e,s),s})}N(){return null!=this.j?this.j:(o.Log.error(this.p+" is not attached to a Client"),"")}T(t){var e=null==(e=l.Storage.getItem)?void 0:e.call(l.Storage,t);return null!=e&&(t=(0,c.P)(e,"source","Cached Result"))?$P($P({},t),{source:"Cache"}):null}L(e,t){var n=JSON.stringify(t);for(let t=0;t<8;t++)try{l.Storage.setItem(e,n);break}catch(t){if(!(t instanceof Error)||!t.toString().includes("QuotaExceededError")&&!t.toString().includes("QUOTA_EXCEEDED_ERR")||this.gn<=1)throw t;this.gn=Math.ceil(this.gn/2),this.q(e,this.gn-1)}this.q(e)}q(t,e=this.gn){var n=null!=(i=(0,l.K)(this.S))?i:{},i=(n[t]=Date.now(),u(n,e));for(const s of i)delete n[s],l.Storage.removeItem(s);(0,l.B)(this.S,n)}},e.v=h;class i{constructor(){this.$={}}get(t,e){var t=this.$[t],n=null==t?void 0:t.stableID,e=null==(e=null==e?void 0:e.customIDs)?void 0:e.stableID;return e&&n&&e!==n?(o.Log.warn("'StatsigUser.customIDs.stableID' mismatch"),null):t}add(t,e,n){for(const i of u(this.$,n-1))delete this.$[i];this.$[t]=e}merge(t){this.$=$P($P({},this.$),t)}}function u(n,t){var e=Object.keys(n);return e.length<=t?[]:0===t?e:e.sort((t,e)=>{t=n[t],e=n[e];return"object"==typeof t&&"object"==typeof e?t.receivedAt-e.receivedAt:t-e}).slice(0,e.length-t)}},8962:(t,l)=>{$Q2(l,"__esModule",{value:!0}),l.Diagnostics=void 0;const i=new Map,n="start";function s(t,e,n,i){return $P({key:n,action:e,step:i,timestamp:Date.now()},t)}function r(t,e){var n=null!=(n=i.get(t))?n:[];n.push(e),i.set(t,n)}function e(t,e){if(e in t)return t[e]}l.Diagnostics={V:t=>i.get(t),G:t=>{r(t,s({},n,"overall"))},J:(t,e,n)=>{r(t,s({success:e,error:e?void 0:{name:"InitializeError",message:"Failed to initialize"},evaluationDetails:n},"end","overall"))},W:(t,e)=>{r(t,s(e,n,"initialize","network_request"))},Y:(t,e)=>{r(t,s(e,"end","initialize","network_request"))},X:t=>{r(t,s({},n,"initialize","process"))},H:(t,e)=>{r(t,s(e,"end","initialize","process"))},Z:t=>{i.delete(t)},tt(t){if(t&&"object"==typeof t)return{code:e(t,"code"),name:e(t,"name"),message:e(t,"message")}},et(t,e,n,i){return{success:!0===(null==t?void 0:t.ok),statusCode:null==t?void 0:t.status,sdkRegion:null==(t=null==t?void 0:t.headers)?void 0:t.get("x-statsig-region"),isDelta:!0===n.includes('"is_delta":true')||void 0,attempt:e,error:l.Diagnostics.tt(i)}},it(t,e,n,i){var s,r=l.Diagnostics.V(n);return null==r||r.length<=0?-1:(s=r[r.length-1].timestamp-r[0].timestamp,l.Diagnostics.Z(n),n=function(t,e){t={eventName:"statsig::diagnostics",user:t,value:null,metadata:e,time:Date.now()};return t}(t,{context:"initialize",markers:r.slice(),statsigOptions:i}),e.enqueue(n),s)}}},8809:function(t,e){var n=this&&this.__awaiter||$A();$Q(e),e.nt=void 0;const s=new Uint8Array([0,0,1,0,0,1,0,0,0,0,0,0,13,102,101,97,116,117,114,101,97,115,115,101,116,115,3,111,114,103,0,0,16,0,1]),r="https://cloudflare-dns.com/dns-query",l=["i","e","d"],u=200;e.nt=function(e){return n(this,void 0,void 0,function*(){var n=yield e(r,{method:"POST",headers:{"Content-Type":"application/dns-message",Accept:"application/dns-message"},body:s});if(n.ok){var t,n=yield n.arrayBuffer(),n=new Uint8Array(n);{var i=n,n=i.findIndex((t,e)=>e<u&&"="===String.fromCharCode(t)&&l.includes(String.fromCharCode(i[e-1])));if(-1===n)throw(t=new Error("Failed to parse TXT records from DNS")).name="DnsTxtParseError",t;let e="";for(let t=n-1;t<i.length;t++)e+=String.fromCharCode(i[t]);return e.split(",")}}throw(t=new Error("Failed to fetch TXT records from DNS")).name="DnsTxtFetchError",t})}},3539:(t,e)=>{$Q(e)},5542:function(t,a,e){var n=this&&this.__awaiter||$A();$Q2(a,"__esModule",{value:!0}),a.ErrorBoundary=a.EXCEPTION_ENDPOINT=void 0;const i=e(7512),c=e(5902),h=e(8e3),d=(a.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception","[Statsig] UnknownError");function v(t){return t instanceof Error?t:"string"==typeof t?new Error(t):new Error("An unknown error occurred.")}a.ErrorBoundary=class{constructor(t,e,n,i){this.j=t,this.O=e,this.st=n,this.rt=i,this.lt=new Set}wrap(i,s){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.ot(s?s+":"+e:e,()=>n.apply(i,t)),t[e].$EB=!0)})}catch(t){this.ut("eb:wrap",t)}}logError(t,e){this.ut(t,e)}logDroppedEvents(t,e,n){const i={eventCount:String(t)};n&&Object.keys(n).forEach(t=>{i[t]=String(n[t])}),this.ut("statsig::log_event_dropped_event_count",new Error(e),!0,i)}logEventRequestFailure(t,e,n,i,s){t={eventCount:String(t),flushType:n,statusCode:String(i),reason:e,retries:String(s)};this.ut("statsig::log_event_failed",new Error(e),!0,t)}getLastSeenErrorAndReset(){var t=this.rt;return this.rt=void 0,null!=t?t:null}attachErrorIfNoneExists(t){this.rt||(this.rt=v(t))}ot(e,t){try{var n=t();return n&&n instanceof Promise?n.catch(t=>this.ut(e,t)):n}catch(t){return this.ut(e,t),null}}ut(r,l,u=!1,o){try{i.Log.warn("Caught error in "+r,{error:l});n(this,void 0,void 0,function*(){var t,e=l||Error(d),n=e instanceof Error,i=n?e.name:"No Name",s=v(e);this.rt=s,!u&&this.lt.has(i)||(this.lt.add(i),null!=(s=null==(s=this.O)?void 0:s.networkConfig)&&s.preventAllNetworkTraffic?null!=(s=this.st)&&s.call(this,{name:"error",error:l,tag:r}):(s=c.SDKType.ct(this.j),t=h.StatsigMetadataProvider.get(),n=n?e.stack:function(t){try{return JSON.stringify(t)}catch(t){return d}}(e),e=$P($P({tag:r,exception:i,info:n,statsigOptions:function(i){if(!i)return{};const s={};return Object.keys(i).forEach(t=>{var e=t,n=i[e];switch(typeof n){case"number":case"bigint":case"boolean":s[String(e)]=n;break;case"string":n.length<50?s[String(e)]=n:s[String(e)]="set";break;case"object":"environment"===e?s.environment=n:"networkConfig"===e?s.networkConfig=n:s[String(e)]=null!=n?"set":"unset"}}),s}(this.O)},$P($P({},t),{sdkType:s})),null!=o?o:{}),yield(null!=(i=null==(n=null==(i=this.O)?void 0:i.networkConfig)?void 0:n.networkOverrideFunc)?i:fetch)(a.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.j,"STATSIG-SDK-TYPE":String(s),"STATSIG-SDK-VERSION":String(t.sdkVersion),"Content-Type":"application/json"},body:JSON.stringify(e)}),null!=(n=this.st)&&n.call(this,{name:"error",error:l,tag:r})))}).then(()=>{}).catch(()=>{})}catch(t){}}}},2922:(t,e)=>{$Q(e)},2417:(t,e)=>{$Q(e)},1956:(t,e)=>{$Q(e),e.EventBatch=void 0;e.EventBatch=class{constructor(t){this.attempts=0,this.createdAt=Date.now(),this.events=t}incrementAttempts(){this.attempts++}}},7770:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.EventLogger=void 0;const s=n(7463),r=n(2137),l=n(4309),u=n(4312),o=n(1406),a=n(7512),c=n(7410),h=n(1228),d=n(6830),v=n(1637),f=n(586),_=n(4534),g=n(1881),p=n(2397),b={};class y{static ht(t){null!=(t=b[t])&&t.flush().catch(()=>{})}constructor(t,e,n,i,s){this.j=t,this.st=e,this.ft=n,this.O=i,this.te=s,this.zi=null,this.Ki=null,this.$i=null,this._t={},this.bt={},this.qi=!1,this.Gi=null,this.Vi=null,this.jt=null!=(t=null==i?void 0:i.loggingEnabled)?t:!0===(null==i?void 0:i.disableLogging)?f.LoggingEnabledOption.disabled:f.LoggingEnabledOption.browserOnly,null!=i&&i.loggingEnabled&&void 0!==i.disableLogging&&a.Log.warn("Detected both loggingEnabled and disableLogging options. loggingEnabled takes precedence - please remove disableLogging.");e=null==i?void 0:i.networkConfig;this.wt=new g.UrlConfiguration(c.Endpoint.kt,null==e?void 0:e.logEventUrl,null==e?void 0:e.api,null==e?void 0:e.logEventFallbackUrls)}setLogEventCompressionMode(t){this.$i?this.$i.setLogEventCompressionMode(t):this.Vi=t}setLoggingEnabled(t){var e="disabled"===this.jt,n="disabled"!==t;this.jt=t,this.$i&&this.$i.setLoggingEnabled(t),e&&n&&(t=this.Ji(),a.Log.debug(`Loaded ${t.length} stored event(s) from storage`),0<t.length)&&(t.forEach(t=>{this.Wi().addEvent(t)}),this.flush().catch(t=>{a.Log.warn("Failed to flush events after enabling logging:",t)}))}enqueue(t){this.Et(t)&&(t=this.Qi(t),"disabled"===this.jt?this.Xi(t):(this.Wi().addEvent(t),null!=(t=this.$i)&&t.checkQuickFlush()))}incrementNonExposureCount(t){var e=null!=(e=this.bt[t])?e:0;this.bt[t]=e+1}reset(){this.flush().catch(()=>{}),this._t={}}start(){var t,e=(0,d.Mt)();if(!e||"always"===(null==(t=this.O)?void 0:t.loggingEnabled)){const n=this.Wi();b[this.j]=this,e||(0,p.xt)(t=>{"background"===t?y.ht(this.j):"foreground"===t&&n.startScheduledFlushCycle()}),n.loadAndRetryShutdownFailedEvents().catch(t=>{a.Log.warn("Failed to load failed shutdown events:",t)}),n.startScheduledFlushCycle()}}stop(){return i(this,void 0,void 0,function*(){this.qi=!0,this.$i&&(yield this.$i.processShutdown()),delete b[this.j],this.$i=null,this.zi=null,this.Ki=null})}flush(){return i(this,void 0,void 0,function*(){if(this.$i)return this.$i.processManualFlush()})}appendAndResetNonExposedChecks(){var t;0!==Object.keys(this.bt).length&&(t=$P({},this.bt),this.bt={},t=this.Qi({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:t}}),this.$i)&&this.$i.addEvent(t)}Et(t){if("always"!==(null==(e=this.O)?void 0:e.loggingEnabled)&&(0,d.Mt)())return!1;if((0,v.Ut)(t)){var e=t.user||{statsigEnvironment:void 0},e=(0,r.u)(this.j,e),n=t.metadata||{},t=[t.eventName,e,n.gate,n.config,n.ruleID,n.allocatedExperiment,n.parameterName,String(n.isExplicitParameter),n.reason].join("|"),e=this._t[t],n=Date.now();if(e&&n-e<6e5)return!1;1e3<Object.keys(this._t).length&&(this._t={}),this._t[t]=n}return!0}qt(){var t;if(!1!==(null==(t=this.O)?void 0:t.includeCurrentPageUrlWithEvents))return(0,d.Kt)()}o(){return this.Gi||(this.Gi="statsig.pending_events."+(0,o.h)(this.j)),this.Gi}Wi(){var t;return this.$i||(t=null!=(t=null==(t=this.O)?void 0:t.loggingBufferMaxSize)?t:l.EventRetryConstants.DEFAULT_BATCH_SIZE,this.zi=new h.PendingEvents(t),this.Ki=new s.BatchQueue(t),this.$i=new u.FlushCoordinator(this.Ki,this.zi,()=>this.appendAndResetNonExposedChecks(),this.j,this.ft,this.st,this.wt,this.O,this.jt,this.te),this.Vi&&(this.$i.setLogEventCompressionMode(this.Vi),this.Vi=null)),this.$i}Xi(e){var n=this.o();try{let t=this.Hi(n);t.push(e),t.length>l.EventRetryConstants.MAX_LOCAL_STORAGE&&(t=t.slice(-l.EventRetryConstants.MAX_LOCAL_STORAGE)),(0,_.B)(n,t)}catch(t){a.Log.warn("Unable to save events to storage")}}Hi(t){try{var e=(0,_.K)(t);return Array.isArray(e)?e:[]}catch(t){return[]}}Ji(){var t=this.o(),e=this.Hi(t);return 0<e.length&&_.Storage.removeItem(t),e}Qi(t){t.user&&(t.user=$P({},t.user),delete t.user.privateAttributes);var e={},n=this.qt();return n&&(e.statsigMetadata={currentPage:n}),$P($P({},t),e)}}e.EventLogger=y},4309:(t,e)=>{$Q(e),e.EventRetryConstants=void 0,e.EventRetryConstants={MAX_RETRY_ATTEMPTS:5,DEFAULT_BATCH_SIZE:100,MAX_PENDING_BATCHES:30,TICK_INTERVAL_MS:1e3,QUICK_FLUSH_WINDOW_MS:200,MAX_LOCAL_STORAGE:500,get MAX_QUEUED_EVENTS(){return this.DEFAULT_BATCH_SIZE*this.MAX_PENDING_BATCHES}}},6351:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.EventSender=void 0;const r=n(7512),s=n(7410),l=n(2397);e.EventSender=class{constructor(t,e,n,i,s,r){this.j=t,this.ft=e,this.st=n,this.O=s,this.wt=i,this.jt=r}setLogEventCompressionMode(t){this.ft.setLogEventCompressionMode(t)}setLoggingEnabled(t){this.jt=t}sendBatch(s){return i(this,void 0,void 0,function*(){var t,e;try{var n=(0,l.Ft)()&&this.ft.isBeaconSupported()&&null==(null==(e=null==(t=this.O)?void 0:t.networkConfig)?void 0:e.networkOverrideFunc),i=(this.st({name:"pre_logs_flushed",events:s.events}),n?this.Pt(s):yield this.Lt(s));return i.success?(this.st({name:"logs_flushed",events:s.events}),i):{success:!1,statusCode:i.statusCode}}catch(t){return r.Log.warn("Failed to send batch:",t),{success:!1,statusCode:-1}}})}Lt(e){return i(this,void 0,void 0,function*(){var t=yield this.ft.post(this.zt(e)),t=null!=(t=null==t?void 0:t.code)?t:-1;return{success:200<=t&&t<300,statusCode:t}})}Pt(t){t=this.ft.beacon(this.zt(t));return{success:t,statusCode:t?200:-1}}zt(t){return{sdkKey:this.j,data:{events:t.events},urlConfig:this.wt,retries:3,isCompressable:!0,params:{[s.NetworkParam.EventCount]:String(t.events.length)},headers:{"statsig-event-count":String(t.events.length),"statsig-retry-count":String(t.attempts)},credentials:"same-origin"}}}},4312:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.FlushCoordinator=void 0;const s=n(4309),c=n(6351),h=n(8153),r=n(323),l=n(1406),u=n(7512),o=n(7023),a=n(4143),d=n(4534);e.FlushCoordinator=class{constructor(t,e,n,i,s,r,l,u,o,a){this.Yi=null,this.Zi=null,this.yt=!1,this.Mn=null,this.Ot=Date.now(),this.qi=!1,this.Gi=null,this.In=new h.FlushInterval,this.Ki=t,this.zi=e,this.Tn=n,this.te=a,this.j=i,this.Fn=new c.EventSender(i,s,r,l,u,o)}setLoggingEnabled(t){this.Fn.setLoggingEnabled(t)}setLogEventCompressionMode(t){this.Fn.setLogEventCompressionMode(t)}startScheduledFlushCycle(){this.Cn()}stopScheduledFlushCycle(){this.An()}addEvent(t){this.zi.addToPendingEventsQueue(t),this.Mn||this.zi.hasEventsForFullBatch()&&this.processLimitFlush()}processManualFlush(){return i(this,void 0,void 0,function*(){return this.Mn&&(yield this.Mn),this.Mn=this.Nn(r.FlushType.Manual).finally(()=>{this.Mn=null,this.Cn()}),this.Mn})}processShutdown(){return i(this,void 0,void 0,function*(){return this.qi=!0,this.An(),this.Mn&&(yield this.Mn),this.Mn=this.Nn(r.FlushType.Shutdown).catch(t=>{u.Log.error("Error during shutdown flush: "+t)}).finally(()=>{this.Mn=null}),this.Mn})}Nn(e){return i(this,void 0,void 0,function*(){this.An();try{this.Rn(e);var t=this.Ki.takeAllBatches();0!==t.length&&(yield Promise.all(t.map(t=>this.Un(t,e))))}finally{this.qi||this.Cn()}})}checkQuickFlush(){this.yt||Date.now()-this.Ot>s.EventRetryConstants.QUICK_FLUSH_WINDOW_MS||(this.yt=!0,setTimeout(()=>{this.processManualFlush().catch(t=>{u.Log.warn("Quick flush failed:",t)})},s.EventRetryConstants.QUICK_FLUSH_WINDOW_MS))}Pn(){if(this.Mn)this.Cn();else{var e=this.containsAtLeastOneFullBatch(),t=this.In.hasReachedMaxInterval();if(e||t){this.In.markFlushAttempt();let t;t=e?r.FlushType.ScheduledFullBatch:r.FlushType.ScheduledMaxTime,this.Mn=this.Ln(t).then(()=>{}).catch(t=>{u.Log.error("Error during scheduled flush:",t)}).finally(()=>{this.Mn=null,this.Cn()})}else this.Bn()}}processLimitFlush(){!this.In.hasCompletelyRecoveredFromBackoff()||this.Mn||(this.Mn=this.zn().catch(t=>{u.Log.error("Error during limit flush",t)}).finally(()=>{this.Mn=null,this.Cn()}))}zn(){return i(this,void 0,void 0,function*(){const t=yield this.Ln(r.FlushType.Limit);if(t)for(;this.In.hasCompletelyRecoveredFromBackoff()&&this.containsAtLeastOneFullBatch();){const t=yield this.Ln(r.FlushType.Limit);if(!t)break}})}Cn(){var t;this.An(),this.qi||(t=Math.max(0,this.In.getTimeUntilNextFlush()),this.Yi=setTimeout(()=>{this.Yi=null,a.StatsigSession.checkForIdleSession(this.j),this.Pn()},t),t=Math.max(0,this.In.getTimeTillMaxInterval()),this.Zi=setTimeout(()=>{this.Zi=null,a.StatsigSession.checkForIdleSession(this.j),this.Pn()},t))}An(){null!==this.Yi&&(clearTimeout(this.Yi),this.Yi=null),null!==this.Zi&&(clearTimeout(this.Zi),this.Zi=null)}Bn(){var t;this.An(),this.qi||(this.Yi=setTimeout(()=>{this.Yi=null,a.StatsigSession.checkForIdleSession(this.j),this.Pn()},s.EventRetryConstants.TICK_INTERVAL_MS),t=Math.max(0,this.In.getTimeTillMaxInterval()),this.Zi=setTimeout(()=>{this.Zi=null,a.StatsigSession.checkForIdleSession(this.j),this.Pn()},t))}Ln(e){return i(this,void 0,void 0,function*(){this.Rn(e);var t=this.Ki.takeNextBatch();return!!t&&this.Un(t,e)})}Un(e,n){return i(this,void 0,void 0,function*(){var t=yield this.Fn.sendBatch(e);return t.success?(this.In.adjustForSuccess(),!0):(this.In.adjustForFailure(),this.Kn(e,n,t.statusCode),!1)})}Rn(t){this.Tn();var e=this.convertPendingEventsToBatches();0<e&&(u.Log.warn(`Dropped ${e} events`),this.te.logDroppedEvents(e,"Batch queue limit reached",{loggingInterval:this.In.getCurrentIntervalMs(),batchSize:this.Ki.batchSize(),maxPendingBatches:s.EventRetryConstants.MAX_PENDING_BATCHES,flushType:t,retries:"dropped before batching"}))}containsAtLeastOneFullBatch(){return this.zi.hasEventsForFullBatch()||this.Ki.hasFullBatch()}convertPendingEventsToBatches(){var t;return this.zi.isEmpty()?0:(t=this.zi.takeAll(),this.Ki.createBatches(t))}Kn(t,e,n){var i;e===r.FlushType.Shutdown?(u.Log.warn(e+" flush failed during shutdown. "+t.events.length+" event(s) will be saved to storage for retry in next session."),this.$n(t.events)):o.RETRYABLE_CODES.has(n)?t.attempts>=s.EventRetryConstants.MAX_RETRY_ATTEMPTS?(u.Log.warn(`${e} flush failed after ${t.attempts} attempt(s). `+t.events.length+" event(s) will be dropped."),this.te.logEventRequestFailure(t.events.length,"max retry attempts exceeded",e,n,t.attempts)):(t.incrementAttempts(),0<(i=this.Ki.requeueBatch(t))&&(u.Log.warn(`Failed to requeue batch : dropped ${i} events due to full queue`),this.te.logDroppedEvents(i,"Batch queue limit reached",{loggingInterval:this.In.getCurrentIntervalMs(),batchSize:this.Ki.batchSize(),maxPendingBatches:s.EventRetryConstants.MAX_PENDING_BATCHES,flushType:e,retries:t.attempts}))):(u.Log.warn(`${e} flush failed after ${t.attempts} attempt(s). `+t.events.length+" event(s) will be dropped. Non-retryable error: "+n),this.te.logEventRequestFailure(t.events.length,"non-retryable error",e,n,t.attempts))}loadAndRetryShutdownFailedEvents(){return i(this,void 0,void 0,function*(){var t=this.o();try{d.Storage.isReady()||(yield d.Storage.isReadyResolver());var e=this.qn(t);0!==e.length&&(u.Log.debug(`Loading ${e.length} failed shutdown event(s) from storage for retry`),d.Storage.removeItem(t),e.forEach(t=>{this.addEvent(t)}),yield this.processManualFlush())}catch(t){u.Log.warn("Failed to load and retry failed shutdown events:",t)}})}o(){return this.Gi||(this.Gi="statsig.failed_shutdown_events."+(0,l.h)(this.j)),this.Gi}$n(e){var n=this.o();try{let t=[...this.qn(n),...e];t.length>s.EventRetryConstants.MAX_LOCAL_STORAGE&&(t=t.slice(-s.EventRetryConstants.MAX_LOCAL_STORAGE)),(0,d.B)(n,t),u.Log.debug(`Saved ${e.length} failed shutdown event(s) to storage (total stored: ${t.length})`)}catch(t){u.Log.warn("Unable to save failed shutdown events to storage:",t)}}qn(t){try{var e=(0,d.K)(t);return Array.isArray(e)?e:[]}catch(t){return[]}}}},8153:(t,e)=>{$Q(e),e.FlushInterval=void 0;e.FlushInterval=class{constructor(){this.Gn=1e3,this.Vn=Date.now()}getCurrentIntervalMs(){return this.Gn}markFlushAttempt(){this.Vn=Date.now()}getTimeSinceLastAttempt(){return Date.now()-this.Vn}hasReachedMaxInterval(){return 6e4<=this.getTimeSinceLastAttempt()}getTimeTillMaxInterval(){return 6e4-this.getTimeSinceLastAttempt()}hasCompletelyRecoveredFromBackoff(){return this.Gn<=1e3}adjustForSuccess(){var t=this.Gn;1e3!==t&&(this.Gn=Math.max(1e3,Math.floor(t/2)))}adjustForFailure(){var t=this.Gn;this.Gn=Math.min(6e4,2*t)}getTimeUntilNextFlush(){return this.getCurrentIntervalMs()-this.getTimeSinceLastAttempt()}}},323:(t,e)=>{$Q(e),e.FlushType=void 0,e.FlushType={ScheduledMaxTime:"scheduled:max_time",ScheduledFullBatch:"scheduled:full_batch",Limit:"limit",Manual:"manual",Shutdown:"shutdown"}},1406:(t,r,e)=>{$Q2(r,"__esModule",{value:!0}),r.Bt=r.$t=r.h=void 0;const l=e(6634);r.h=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)},r.$t=(t,e)=>(0,r.h)(JSON.stringify((0,r.Bt)(t,e)));r.Bt=(n,i)=>{if(null==n)return null;var t=Object.keys(n).sort();const s={};return t.forEach(t=>{var e=n[t];0===i||"object"!==(0,l.Vt)(e)?s[t]=e:s[t]=(0,r.Bt)(e,null!=i?i-1:i)}),s}},1333:(t,e)=>{$Q(e)},7512:(t,e)=>{$Q(e),e.Log=e.LogLevel=void 0;function n(t){return t.unshift("[Statsig]"),t}e.LogLevel={None:0,Error:1,Warn:2,Info:3,Debug:4};class i{static info(...t){i.level>=e.LogLevel.Info&&console.info(" INFO ",...n(t))}static debug(...t){i.level>=e.LogLevel.Debug&&console.debug(" DEBUG ",...n(t))}static warn(...t){i.level>=e.LogLevel.Warn&&console.warn(" WARN ",...n(t))}static error(...t){i.level>=e.LogLevel.Error&&console.error(" ERROR ",...n(t))}}(e.Log=i).level=e.LogLevel.Warn},7787:(t,e)=>{$Q(e),e.createMemoKey=e.MemoPrefix=void 0,e.MemoPrefix={Gt:"g",Jt:"c",Wt:"e",Yt:"cl",Xt:"l",Ht:"p"};const r=new Set([]),l=new Set(["userPersistedValues"]);e.createMemoKey=function(t,e,n){let i=t+"|"+e;if(n)for(const s of Object.keys(n)){if(l.has(s))return;r.has(s)?i+=`|${s}=true`:i+=`|${s}=`+n[s]}return i}},7410:(t,e)=>{$Q(e),e.NetworkParam=e.NetworkDefault=e.Endpoint=void 0,e.Endpoint={Qt:"initialize",kt:"rgstr",Zt:"download_config_specs"},e.NetworkDefault={[e.Endpoint.kt]:"https://prodregistryv2.org/v1",[e.Endpoint.Qt]:"https://featureassets.org/v1",[e.Endpoint.Zt]:"https://api.statsigcdn.com/v1"},e.NetworkParam={EventCount:"ec",SdkKey:"k",SdkType:"st",SdkVersion:"sv",Time:"t",SessionID:"sid",StatsigEncoded:"se",IsGzipped:"gz"}},7023:function(t,y,e){var m=this&&this.__awaiter||$A();$Q2(y,"__esModule",{value:!0}),y.NetworkCore=y.RETRYABLE_CODES=void 0,e(1845);const v=e(1845),O=e(8962),j=e(7512),S=e(7410),n=e(308),f=e(3091),l=e(5902),s=e(6830),u=e(4143),o=e(9122),w=e(2636),a=e(8e3),_=e(586),E=e(2397),k=500,x=3e4;y.RETRYABLE_CODES=new Set([408,500,502,503,504,522,524,599]);y.NetworkCore=class{constructor(t,e){this.st=e,this.te=null,this.ee=1e4,this.ie={},this.O={},this.ne={},this.se=null,t&&(this.O=t),this.O.networkConfig&&(this.ie=this.O.networkConfig),this.ie.networkTimeoutMs&&(this.ee=this.ie.networkTimeoutMs),this.re=new n.NetworkFallbackResolver(this.O),this.setLogEventCompressionMode(this.le(t))}setLogEventCompressionMode(t){this.O.logEventCompressionMode=t}setErrorBoundary(t){this.te=t,this.te.wrap(this),this.te.wrap(this.re),this.re.setErrorBoundary(t)}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon}getLastUsedInitUrlAndReset(){var t=this.se;return this.se=null,t}beacon(t){var e,n;return!!D(t)&&(t=this.oe("POST",t),e=this.ue(t),(n=navigator).sendBeacon.bind(n)(e,t.body))}post(e){return m(this,void 0,void 0,function*(){var t=this.oe("POST",e);return this.ae(t),yield this.ce(t),this.he(t)})}get(t){t=this.oe("GET",t);return this.he(t)}he(b){return m(this,void 0,void 0,function*(){var e;if(!D(b))return null;if(this.ie.preventAllNetworkTraffic)return null;var{method:i,body:s,retries:n,attempt:r}=b,l=b.urlConfig.endpoint;if(this.de(l))return j.Log.warn(`Request to ${l} was blocked because you are making requests too frequently.`),null;r=null!=r?r:1;let u=!1;var o=this.ue(b);let a=null;var c,h=(0,E.Ft)();try{var t,d,v,f={method:i,body:s,headers:$P({},b.headers),priority:b.priority,keepalive:h},_=(c=r,(p=b).urlConfig.endpoint===S.Endpoint.Qt&&O.Diagnostics.W(p.sdkKey,{attempt:c}),this.ne[l]),g=(_&&(_.lastRequestTime=Date.now(),this.ne[l]=_),null!=(e=this.ie.networkOverrideFunc)?e:fetch);let n;if((a=yield Promise.race([g(o,f).finally(()=>clearTimeout(n)),new Promise((t,e)=>{n=setTimeout(()=>{u=!0,e(new Error(`Timeout of ${this.ee}ms expired.`))},this.ee)})])).ok)return v=yield a.text(),M(b,a,r,v),this.re.tryBumpExpiryTime(b.sdkKey,b.urlConfig),{body:v,code:a.status};throw t=yield a.text().catch(()=>"No Text"),(d=new Error(`NetworkError: ${o} `+t)).name="NetworkError",d}catch(t){var s=function(t){if("string"==typeof t)return t;if(t instanceof Error)return t.name+": "+t.message;return"Unknown Error"}(t),h=function(t,e){t=t.includes("Timeout");return t||e}(null!=s?s:"",u),p=(M(b,a,r,"",t),yield this.re.tryFetchUpdatedFallbackInfo(b.sdkKey,b.urlConfig,s,h));return(p&&(b.fallbackUrl=this.re.getActiveFallbackUrl(b.sdkKey,b.urlConfig)),!n||n<r||!y.RETRYABLE_CODES.has(null!=(c=null===a||void 0===a?void 0:a.status)?c:500))?(null!=(l=this.st)&&l.call(this,{name:"error",error:t,tag:w.ErrorTag.NetworkError,requestArgs:b}),_=`A networking error occurred during ${i} request to ${o}.`,j.Log.error(_,s,t),null!=(e=this.te)&&e.attachErrorIfNoneExists(_),null):(yield function(e){return m(this,void 0,void 0,function*(){yield new Promise(t=>setTimeout(t,Math.min(k*(e*e),x)))})}(r),this.he($P($P({},b),{retries:n,attempt:r+1})))}})}le(t){let e=null==t?void 0:t.logEventCompressionMode;return e=(e=e||!0!==(null==t?void 0:t.disableCompression)?e:_.LogEventCompressionMode.Disabled)||_.LogEventCompressionMode.Enabled}de(t){var e=Date.now(),n=null!=(n=this.ne[t])?n:{count:0,lastRequestTime:e},i=e-n.lastRequestTime,i=Math.floor(.05*i);return n.count=Math.max(0,n.count-i),50<=n.count||(n.count+=1,n.lastRequestTime=e,this.ne[t]=n,!1)}ue(t){var e=null!=(e=t.fallbackUrl)?e:t.urlConfig.getUrl();t.urlConfig.endpoint!==S.Endpoint.Qt&&t.urlConfig.endpoint!==S.Endpoint.Zt||(this.se=e);const n=$P({[S.NetworkParam.SdkKey]:t.sdkKey,[S.NetworkParam.SdkType]:l.SDKType.ct(t.sdkKey),[S.NetworkParam.SdkVersion]:a.SDK_VERSION,[S.NetworkParam.Time]:String(Date.now()),[S.NetworkParam.SessionID]:u.SessionID.get(t.sdkKey)},t.params);t=Object.keys(n).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(n[t])).join("&");return e+(t?"?"+t:"")}ae(e){var t,n=(0,s.ve)(),i=e.body;if(e.isStatsigEncodable&&!this.O.disableStatsigEncoding&&"string"==typeof i&&null==(0,v.i)("no-encode")&&null!=n&&n.btoa)try{e.body=n.btoa(i).split("").reverse().join(""),e.params=$P($P({},null!=(t=e.params)?t:{}),{[S.NetworkParam.StatsigEncoded]:"1"})}catch(t){j.Log.warn("Request encoding failed for "+e.urlConfig.getUrl(),t)}}ce(d){return m(this,void 0,void 0,function*(){var e,n=d.body;if("string"==typeof n&&function(t,e){if(!t.isCompressable)return;if(null!=(0,v.i)("no-compress")||"undefined"==typeof CompressionStream||"undefined"==typeof TextEncoder)return;var n=null!=t.urlConfig.customUrl||null!=t.urlConfig.fallbackUrls,i=!0===f.SDKFlags.get(t.sdkKey,"enable_log_event_compression");switch(e.logEventCompressionMode){case _.LogEventCompressionMode.Disabled:return;case _.LogEventCompressionMode.Enabled:return n&&!i?void 0:1;case _.LogEventCompressionMode.Forced:return 1;default:return}}(d,this.O))try{for(var i,s=(new TextEncoder).encode(n),r=new CompressionStream("gzip"),l=r.writable.getWriter(),u=(l.write(s).catch(j.Log.error),l.close().catch(j.Log.error),r.readable.getReader()),o=[];!(i=yield u.read()).done;)o.push(i.value);var a=o.reduce((t,e)=>t+e.length,0),c=new Uint8Array(a);let t=0;for(const h of o)c.set(h,t),t+=h.length;d.body=c,d.params=$P($P({},null!=(e=d.params)?e:{}),{[S.NetworkParam.IsGzipped]:"1"})}catch(t){j.Log.warn("Request compression failed for "+d.urlConfig.getUrl(),t)}})}oe(t,e){var n=this.re.getActiveFallbackUrl(e.sdkKey,e.urlConfig),t=$P($P({},e),{method:t,fallbackUrl:n});return"data"in e&&i(t,e.data),t}};const D=t=>!!t.sdkKey||(j.Log.warn("Unable to make request without an SDK key"),!1),i=(t,e)=>{var{sdkKey:n,fallbackUrl:i}=t,s=o.StableID.get(n),r=u.SessionID.get(n),n=l.SDKType.ct(n);t.body=JSON.stringify($P($P({},e),{statsigMetadata:$P($P({},a.StatsigMetadataProvider.get()),{stableID:s,sessionID:r,sdkType:n,fallbackUrl:i})}))};function M(t,e,n,i,s){t.urlConfig.endpoint===S.Endpoint.Qt&&O.Diagnostics.Y(t.sdkKey,O.Diagnostics.et(e,n,i,s))}},308:function(t,e,n){var u=this&&this.__awaiter||$A();$Q(e),e.fe=e.NetworkFallbackResolver=void 0;const l=n(8809),i=n(1406),r=n(7512),o=n(4534);function a(t,e){t=null!=(t=null==t?void 0:t.toLowerCase())?t:"";return e||t.includes("uncaught exception")||t.includes("failed to fetch")||t.includes("networkerror when attempting to fetch resource")}function c(t){return"statsig.network_fallback."+(0,i.h)(t)}function h(t,e){t=c(t);e&&0!==Object.keys(e).length?o.Storage.setItem(t,JSON.stringify(e)):o.Storage.removeItem(t)}e.NetworkFallbackResolver=class{constructor(t){this.ge=null,this.te=null,this._e={},this.pe=null==(t=t.networkConfig)?void 0:t.networkOverrideFunc}setErrorBoundary(t){this.te=t}tryBumpExpiryTime(t,e){var n=null==(n=this.ge)?void 0:n[e.endpoint];n&&(n.expiryTime=Date.now()+6048e5,h(t,$P($P({},this.ge),{[e.endpoint]:n})))}getActiveFallbackUrl(t,e){var n;if(null!=e.customUrl&&null!=e.fallbackUrls)return null;let i=this.ge;null==i&&(i=null!=(s=function(t){t=c(t),t=o.Storage.getItem(t);if(!t)return null;try{return JSON.parse(t)}catch(t){return r.Log.error("Failed to parse FallbackInfo"),null}}(t))?s:{},this.ge=i);var s=i[e.endpoint];return!s||Date.now()>(null!=(n=s.expiryTime)?n:0)||e.getChecksum()!==s.urlConfigChecksum?(delete i[e.endpoint],this.ge=i,h(t,this.ge),null):s.url||null}tryFetchUpdatedFallbackInfo(i,s,r,l){return u(this,void 0,void 0,function*(){var e,t,n;try{return a(r,l)?(t=null==s.customUrl&&null==s.fallbackUrls?yield this.be(s):s.fallbackUrls,!!(n=this.ye(null==(e=this.ge)?void 0:e[s.endpoint],t))&&(this.me(i,s,n),!0)):!1}catch(t){return null!=(e=this.te)&&e.logError("tryFetchUpdatedFallbackInfo",t),!1}})}me(t,e,n){var n={urlConfigChecksum:e.getChecksum(),url:n,expiryTime:Date.now()+6048e5,previous:[]},e=e.endpoint,i=null==(i=this.ge)?void 0:i[e],i=(i&&n.previous.push(...i.previous),10<n.previous.length&&(n.previous=[]),null==(i=null==(i=this.ge)?void 0:i[e])?void 0:i.url);null!=i&&n.previous.push(i),this.ge=$P($P({},this.ge),{[e]:n}),h(t,this.ge)}be(r){return u(this,void 0,void 0,function*(){var t=this._e[r.endpoint];if(t&&Date.now()<t)return null;this._e[r.endpoint]=Date.now()+144e5;var e=[],t=yield(0,l.nt)(null!=(t=this.pe)?t:fetch),n=function(t){try{return new URL(t).pathname}catch(t){return null}}(r.defaultUrl);for(const s of t)if(s.startsWith(r.endpointDnsKey+"=")){var i=s.split("=");if(1<i.length){let t=i[1];t.endsWith("/")&&(t=t.slice(0,-1)),e.push("https://"+t+n)}}return e})}ye(t,e){var n;if(null==e)return null;var i=new Set(null!=(n=null==t?void 0:t.previous)?n:[]),s=null==t?void 0:t.url;let r=null;for(const u of e){var l=u.endsWith("/")?u.slice(0,-1):u;if(!i.has(u)&&l!==s){r=l;break}}return r}},e.fe=a},1405:(t,e)=>{$Q(e)},1361:(t,e)=>{$Q(e)},1228:(t,e,n)=>{$Q(e),e.PendingEvents=void 0;const i=n(7512);e.PendingEvents=class{constructor(t){this.zi=[],this.Ci=t}addToPendingEventsQueue(t){this.zi.push(t),i.Log.debug("Enqueued Event:",t)}hasEventsForFullBatch(){return this.zi.length>=this.Ci}takeAll(){var t=this.zi;return this.zi=[],t}isEmpty(){return 0===this.zi.length}}},3091:(t,e)=>{$Q(e),e.SDKFlags=void 0;const n={};e.SDKFlags={setFlags:(t,e)=>{n[t]=e},get:(t,e)=>{return null!=(t=null==(t=n[t])?void 0:t[e])&&t}}},5902:(t,e)=>{$Q(e),e.SDKType=void 0;const n={};let i;e.SDKType={ct:t=>{return(null!=(t=n[t])?t:"js-mono")+(null!==i&&void 0!==i?i:"")},Oe(t,e){n[t]=e},je(t){i&&"-react"!==i||(i="-"+t)}}},6830:(t,i,e)=>{$Q2(i,"__esModule",{value:!0}),i.Bi=i.Se=i.Kt=i.we=i.ke=i.Mt=i.Ee=i.ve=void 0;const n=e(7512);i.ve=()=>"undefined"!=typeof window?window:null,i.Ee=()=>{var t=(0,i.ve)();return null!=(t=null==t?void 0:t.document)?t:null},i.Mt=()=>{var t;return null===(0,i.Ee)()&&(t="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,"string"==typeof EdgeRuntime||t)},i.ke=(t,e)=>{var n=(0,i.ve)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(t,e)},i.we=(t,e)=>{var n=(0,i.Ee)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(t,e)},i.Kt=()=>{var t;try{return null==(t=(0,i.ve)())?void 0:t.location.href.split(/[?#]/)[0]}catch(t){}},i.Se=()=>{var t=(0,i.ve)();return t&&"onpagehide"in t?"pagehide":"beforeunload"};i.Bi=(e,t)=>{try{return JSON.parse(JSON.stringify(t))}catch(t){return n.Log.error("Failed to clone object "+e),null}}},4143:(t,e,n)=>{$Q(e),e.StatsigSession=e.SessionID=void 0;const i=n(2137),s=n(7512),r=n(4534),l=n(8023);n=n(2397);const u=18e5,o=144e5,a=15e3,c={};function h(t){var e,n=t.data,n=(e=[n["lastUpdate"]][0],Date.now()-e>u||(e=[n["startTime"]][0],Date.now()-e>o));return n&&(t.data=f(),null!=(e=null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.instance(t.sdkKey)))&&e.$emt({name:"session_expired"}),n}function d(t){return"statsig.session_id."+(0,i.o)(t)}function v(t){try{(0,r.B)(t.storageKey,t.data),t.lastPersistedAt=Date.now()}catch(t){s.Log.warn("Failed to save SessionID")}}function f(){return{sessionID:(0,l.getUUID)(),startTime:Date.now(),lastUpdate:Date.now()}}(0,n.xt)(t=>{"background"===t&&Object.values(c).forEach(t=>v(t))}),e.SessionID={get:t=>e.StatsigSession.get(t).data.sessionID},e.StatsigSession={get:(t,e=!0)=>{null==c[t]&&(c[t]=function(t){var e=d(t),n=function(t){t=(0,r.K)(t);return t}(e);if(n&&n.sessionID&&n.startTime&&n.lastUpdate)return{data:n,sdkKey:t,lastPersistedAt:0,storageKey:e};return{data:f(),sdkKey:t,lastPersistedAt:0,storageKey:e}}(t));var t=c[t],n=Date.now(),i=h(t);i?v(t):e&&(t.data.lastUpdate=n,i=t,(e=Date.now())-i.lastPersistedAt>a)&&v(i);return t},overrideInitialSessionID:(t,e)=>{var n=Date.now(),t={data:{sessionID:t,startTime:n,lastUpdate:n},sdkKey:e,lastPersistedAt:Date.now(),storageKey:d(e)};v(t),c[e]=t},checkForIdleSession:t=>{t=c[t];t&&h(t)&&v(t)}}},2176:(t,u)=>{$Q2(u,"__esModule",{value:!0}),u.De=void 0;u.De=(e,n)=>{let i=0;var s=Object.keys(e);for(let t=0;t<s.length;t++){var r=s[t],l=e[r];if((i=(i+=r.length)+("object"==typeof l&&null!==l?(0,u.De)(l,n)+2:String(l).length+1))>=n)return i}return i}},9122:(t,e,n)=>{$Q(e),e.getCookieName=e.StableID=void 0;const i=n(2137),s=n(7512),r=n(6830),l=n(4534),u=n(8023),o={},a={},c={};function h(t){return"statsig.stable_id."+(0,i.o)(t)}function d(t,e){e=h(e);try{(0,l.B)(e,t)}catch(t){s.Log.warn("Failed to save StableID to storage")}}function v(t,e){var n;a[e]&&null!=(0,r.Ee)()&&((n=new Date).setFullYear(n.getFullYear()+1),document.cookie=`${f(e)}=${encodeURIComponent(t)}; expires=${n.toUTCString()}; path=/`)}function f(t){return"statsig.stable_id."+(0,i.o)(t)}e.StableID={cookiesEnabled:!1,randomID:Math.random().toString(36),get:t=>{if(c[t])return null;if(null!=o[t])return o[t];let e=null;return null!=(e=function(t){if(a[t]&&null!=(0,r.Ee)())for(const i of document.cookie.split(";")){var[e,n]=i.trim().split("=");if(e===f(t))return decodeURIComponent(n)}return null}(t))?d(o[t]=e,t):(d(e=null==(e=function(t){t=h(t);return(0,l.K)(t)}(t))?(0,u.getUUID)():e,t),v(e,t),o[t]=e),e},setOverride:(t,e)=>{d(o[e]=t,e),v(t,e)},Ie:(t,e)=>{a[t]=e},Me:(t,e)=>{c[t]=e}},e.getCookieName=f},1375:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.StatsigClientBase=void 0,n(1845);const l=n(1845),u=n(5542),o=n(7770),a=n(7512),r=n(7787),c=n(6830),h=n(4143),d=n(9122),s=n(586),v=n(4534);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.xe=null,this.Te={};var s,r=this.$emt.bind(this);null!=(null==i?void 0:i.logLevel)&&(a.Log.level=i.logLevel),null!=i&&i.disableStorage&&v.Storage.Me(!0),null!=i&&i.initialSessionID&&h.StatsigSession.overrideInitialSessionID(i.initialSessionID,t),null!=i&&i.storageProvider&&v.Storage.Ne(i.storageProvider),null!=i&&i.enableCookies&&d.StableID.Ie(t,i.enableCookies),null!=i&&i.disableStableID&&d.StableID.Me(t,!0),this.j=t,this.O=null!=i?i:{},this.Ce={},this.overrideAdapter=null!=(s=null==i?void 0:i.overrideAdapter)?s:null,this.te=new u.ErrorBoundary(t,i,r),this.Re=new o.EventLogger(t,r,n,i,this.te),this.te.wrap(this),this.te.wrap(e),this.te.wrap(this.Re),n.setErrorBoundary(this.te),this.dataAdapter=e,this.dataAdapter.attach(t,i,n),this.storageProvider=v.Storage,null!=(e=null==(r=null==(s=this.overrideAdapter)?void 0:s.loadFromStorage)?void 0:r.call(s))&&e.catch(t=>this.te.logError("OA::loadFromStorage",t)),this.Ue(),i=t,n=this,(0,c.Mt)()||(r=(0,l.l)(),s=null!=(s=r.instances)?s:{},n=n,null!=s[i]&&a.Log.warn("Creating multiple Statsig clients with the same SDK key can lead to unexpected behavior. Multi-instance support requires different SDK keys."),s[i]=n,r.firstInstance||(r.firstInstance=n),r.instances=s,__STATSIG__=r)}updateRuntimeOptions(t){t.loggingEnabled?(this.O.loggingEnabled=t.loggingEnabled,this.Re.setLoggingEnabled(t.loggingEnabled)):null!=t.disableLogging&&(this.O.disableLogging=t.disableLogging,this.Re.setLoggingEnabled(t.disableLogging?"disabled":"browser-only")),null!=t.disableStorage&&(this.O.disableStorage=t.disableStorage,v.Storage.Me(t.disableStorage)),null!=t.enableCookies&&(this.O.enableCookies=t.enableCookies,d.StableID.Ie(this.j,t.enableCookies)),t.logEventCompressionMode?this.Re.setLogEventCompressionMode(t.logEventCompressionMode):t.disableCompression&&this.Re.setLogEventCompressionMode(s.LogEventCompressionMode.Disabled)}flush(){return this.Re.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.$emt({name:"pre_shutdown"}),this.Ae("Uninitialized",null),this.xe=null,yield this.Re.stop()})}on(t,e){this.Te[t]||(this.Te[t]=[]),this.Te[t].push(e)}off(t,e){this.Te[t]&&-1!==(e=this.Te[t].indexOf(e))&&this.Te[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.te.logError("__emit:"+n.name,t):a.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",n)}};this.Te[n.name]&&this.Te[n.name].forEach(t=>e(t)),null!=(t=this.Te["*"])&&t.forEach(e)}Ae(t,e){this.loadingStatus=t,this.Ce={},this.$emt({name:"values_updated",status:t,values:e})}Fe(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.Re.incrementNonExposureCount(t):this.Re.enqueue(e)}Pe(i,s){return(t,e)=>{var n;return!this.O.disableEvaluationMemoization&&(n=(0,r.createMemoKey)(i,t,e))?(n in this.Ce||(3e3<=Object.keys(this.Ce).length&&(this.Ce={}),this.Ce[n]=s(t,e)),this.Ce[n]):s(t,e)}}}},2636:(t,e)=>{$Q(e),e.ErrorTag=void 0,e.ErrorTag={NetworkError:"NetworkError"}},3206:(t,e)=>{$Q(e),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},1637:(t,e)=>{$Q(e),e.Le=e.ze=e.qe=e.Ke=e.Ut=void 0;const r="statsig::config_exposure",l="statsig::gate_exposure",a="statsig::layer_exposure",c=(t,e,n,i,s)=>(n.bootstrapMetadata&&(i.bootstrapMetadata=n.bootstrapMetadata),{eventName:t,user:e,value:null,metadata:u(n,i),secondaryExposures:s,time:Date.now()});e.Ut=({eventName:t})=>t===l||t===r||t===a;function h(t,e){return t.map(t=>"string"==typeof t?(null!=e?e:{})[t]:t).filter(t=>null!=t)}e.Ke=(t,e,n)=>{var i,s={gate:e.name,gateValue:String(e.value),ruleID:e.ruleID};return null!=(null==(i=e.__evaluation)?void 0:i.version)&&(s.configVersion=e.__evaluation.version),c(l,t,e.details,s,h(null!=(t=null==(i=e.__evaluation)?void 0:i.secondary_exposures)?t:[],n))},e.qe=h;e.ze=(t,e,n)=>{var i,s={config:e.name,ruleID:e.ruleID};return null!=(null==(i=e.__evaluation)?void 0:i.version)&&(s.configVersion=e.__evaluation.version),null!=(null==(i=e.__evaluation)?void 0:i.passed)&&(s.rulePassed=String(e.__evaluation.passed)),c(r,t,e.details,s,h(null!=(t=null==(i=e.__evaluation)?void 0:i.secondary_exposures)?t:[],n))};e.Le=(t,e,n,i)=>{var s=e.__evaluation,r=!0===(null==(r=null==s?void 0:s.explicit_parameters)?void 0:r.includes(n));let l="",u=null!=(o=null==s?void 0:s.undelegated_secondary_exposures)?o:[];r&&(l=null!=(o=s.allocated_experiment_name)?o:"",u=null!=(o=s.secondary_exposures)?o:[]);var o=null==(s=e.__evaluation)?void 0:s.parameter_rule_ids,o={config:e.name,parameterName:n,ruleID:null!=(s=null==o?void 0:o[n])?s:e.ruleID,allocatedExperiment:l,isExplicitParameter:String(r)};return null!=(null==(n=e.__evaluation)?void 0:n.version)&&(o.configVersion=e.__evaluation.version),c(a,t,e.details,o,h(u,i))};const u=(t,e)=>(e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut)),t.receivedAt&&(e.receivedAt=String(t.receivedAt)),e)},8e3:(t,e)=>{$Q(e),e.StatsigMetadataProvider=e.SDK_VERSION=void 0,e.SDK_VERSION="3.32.0";let n={sdkVersion:e.SDK_VERSION,sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=$P($P({},n),t)}}},586:(t,e)=>{$Q(e),e.LoggingEnabledOption=e.LogEventCompressionMode=void 0,e.LogEventCompressionMode={Disabled:"d",Enabled:"e",Forced:"f"},e.LoggingEnabledOption={disabled:"disabled",browserOnly:"browser-only",always:"always"}},1098:(t,e)=>{$Q(e)},2059:(t,e,n)=>{$Q(e),e.Be=e.$e=e.Ve=e.Ge=e.Je=e.We=void 0;const l=n(7512),u=n(6634);function s(t,e,n,i){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:"",__evaluation:n,value:i}}function i(t,e,n){var i=null!=(i=null==n?void 0:n.value)?i:{};return $P($P({},s(t,e,n,i)),{idType:null!=(e=null==n?void 0:n.id_type)?e:null,get:r(t,null==n?void 0:n.value)})}function r(i,s,r){return(t,e)=>{var n=null!=(n=null==s?void 0:s[t])?n:null;return null==n?null!=e?e:null:null==e||(0,u.Ye)(n,e)?(null!=r&&r(t),n):(l.Log.warn(`Parameter type mismatch. '${i}.${t}' was found to be type '${typeof n}' but fallback/return type is '${typeof e}'. See https://docs.statsig.com/client/javascript-sdk/#typed-getters`),null!=e?e:null)}}e.We=function(t,e,n){return $P($P({},s(t,e,n,!0===(null==n?void 0:n.value))),{idType:null!=(t=null==n?void 0:n.id_type)?t:null})},e.Je=i,e.Ge=function(t,e,n){return t=i(t,e,n),$P($P({},t),{groupName:null!=(e=null==n?void 0:n.group_name)?e:null})},e.Ve=function(t,e,n,i){return $P($P({},s(t,e,n,void 0)),{get:r(t,null==n?void 0:n.value,i),groupName:null!=(e=null==n?void 0:n.group_name)?e:null,__value:null!=(t=null==n?void 0:n.value)?t:{}})},e.$e=function(t,e,n,i){return $P($P($P({},t),e),{get:r(t.name,n,i)})},e.Be=r},1812:(t,e)=>{$Q(e)},3932:(t,e)=>{$Q(e),e.UPDATE_DETAIL_ERROR_MESSAGES=e.createUpdateDetails=void 0;e.createUpdateDetails=(t,e,n,i,s,r)=>({duration:n,source:e,success:t,error:i,sourceUrl:s,warnings:r}),e.UPDATE_DETAIL_ERROR_MESSAGES={NO_NETWORK_DATA:"No data was returned from the network. This may be due to a network timeout if a timeout value was specified in the options or ad blocker error."}},8578:(t,e,n)=>{$Q(e),e.Jn=e._=e.D=void 0;const i=n(1406),s=n(7512),r=n(6830);e.D=function(t,e,n){return null==(t=(0,r.Bi)("StatsigUser",t))?(s.Log.error("Failed to clone user"),{statsigEnvironment:void 0}):(null!=e&&null!=e.environment?t.statsigEnvironment=e.environment:null!=n&&(t.statsigEnvironment={tier:n}),t)},e._=function(t){return t?(0,i.$t)(t):null},e.Jn=function(t,e){var n,i;return"string"==typeof e&&"userid"!==(i=e.toLowerCase())?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(e=t.customIDs)?void 0:e[i]:t.userID}},4534:(t,n,e)=>{$Q2(n,"__esModule",{value:!0}),n.B=n.K=n.Storage=void 0;const i=e(7512);e=e(6830);const s={},r={isReady:()=>!0,isReadyResolver:()=>null,getProviderName:()=>"InMemory",getItem:t=>s[t]||null,setItem:(t,e)=>{s[t]=e},removeItem:t=>{delete s[t]},getAllKeys:()=>Object.keys(s)};let l=null;try{const c=(0,e.ve)();c&&c.localStorage&&"function"==typeof c.localStorage.getItem&&(l={isReady:()=>!0,isReadyResolver:()=>null,getProviderName:()=>"LocalStorage",getItem:t=>c.localStorage.getItem(t),setItem:(t,e)=>c.localStorage.setItem(t,e),removeItem:t=>c.localStorage.removeItem(t),getAllKeys:()=>Object.keys(c.localStorage)})}catch(t){i.Log.warn("Failed to setup localStorageProvider.")}let u=null!==l&&void 0!==l?l:r,o=u;function a(t){try{return t()}catch(t){if(t instanceof Error&&"SecurityError"===t.name)return n.Storage.Ne(r),null;throw t}}n.Storage={isReady:()=>o.isReady(),isReadyResolver:()=>o.isReadyResolver(),getProviderName:()=>o.getProviderName(),getItem:t=>a(()=>o.getItem(t)),setItem:(t,e)=>a(()=>o.setItem(t,e)),removeItem:t=>o.removeItem(t),getAllKeys:()=>o.getAllKeys(),Ne:t=>{u=t,o=t},Me:t=>{o=t?r:u}},n.K=function(e){var t=n.Storage.getItem(e);try{return JSON.parse(null!=t?t:"null")}catch(t){return i.Log.error(`Failed to parse value for key "${e}"`),null}},n.B=function(t,e){n.Storage.setItem(t,JSON.stringify(e))}},3401:(t,e,n)=>{$Q(e),e.P=void 0;const s=n(7512);e.P=function(t,e,n){try{var i=JSON.parse(t);if(i&&"object"==typeof i&&e in i)return i}catch(t){}return s.Log.error("Failed to parse "+n),null}},6634:(t,e)=>{$Q(e),e.Ye=e.Vt=void 0,e.Vt=function(t){return Array.isArray(t)?"array":typeof t},e.Ye=function(t,e){var n=t=>Array.isArray(t)?"array":null===t?"null":typeof t;return n(t)===n(e)}},8023:(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)})}},1881:(t,e,n)=>{$Q(e),e.UrlConfiguration=void 0;const i=n(1406),s=n(7410),r={[s.Endpoint.Qt]:"i",[s.Endpoint.kt]:"e",[s.Endpoint.Zt]:"d"};e.UrlConfiguration=class{constructor(t,e,n,i){this.customUrl=null,this.fallbackUrls=null,this.endpoint=t,this.endpointDnsKey=r[t],e&&(this.customUrl=e),!e&&n&&(this.customUrl=n.endsWith("/")?""+n+t:n+"/"+t),i&&(this.fallbackUrls=i);e=s.NetworkDefault[t];this.defaultUrl=e+"/"+t}getUrl(){var t;return null!=(t=this.customUrl)?t:this.defaultUrl}getChecksum(){var t=(null!=(t=this.fallbackUrls)?t:[]).sort().join(",");return(0,i.h)(this.customUrl+t)}}},2397:(t,e,n)=>{$Q(e),e.Xe=e.xt=e.Ft=e.He=void 0;n=n(6830);const i="foreground",s="background",r=[];let l=i,u=!1;e.He=()=>l===i,e.Ft=()=>u,e.xt=t=>{r.unshift(t)};e.Xe=e=>{e!==l&&(l=e,r.forEach(t=>t(e)))},(0,n.ke)("focus",()=>{(u=!1,e.Xe)(i)}),(0,n.ke)("blur",()=>(0,e.Xe)(s)),(0,n.we)("visibilitychange",()=>{(0,e.Xe)("visible"===document.visibilityState?i:s)}),(0,n.ke)((0,n.Se)(),()=>{u=!0,(0,e.Xe)(s)})},6914:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var s=Object.getOwnPropertyDescriptor(e,n);s&&("get"in s?e.__esModule:!s.writable&&!s.configurable)||(s={enumerable:!0,get:function(){return e[n]}}),$Q2(t,i,s)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),s=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=($Q(e),e.Storage=e.Log=e.EventLogger=e.Diagnostics=void 0,n(1845),n(1845));const l=n(8962),u=($Q2(e,"Diagnostics",{enumerable:!0,get:function(){return l.Diagnostics}}),n(7770)),o=($Q2(e,"EventLogger",{enumerable:!0,get:function(){return u.EventLogger}}),n(7512));$Q2(e,"Log",{enumerable:!0,get:function(){return o.Log}});var a=n(8e3);const c=n(4534);$Q2(e,"Storage",{enumerable:!0,get:function(){return c.Storage}}),s(n(1845),e),s(n(2137),e),s(n(6427),e),s(n(694),e),s(n(8962),e),s(n(3539),e),s(n(5542),e),s(n(2922),e),s(n(2417),e),s(n(1406),e),s(n(1333),e),s(n(7512),e),s(n(7787),e),s(n(7410),e),s(n(7023),e),s(n(1405),e),s(n(1361),e),s(n(6830),e),s(n(5902),e),s(n(4143),e),s(n(2176),e),s(n(9122),e),s(n(1375),e),s(n(2636),e),s(n(3206),e),s(n(1637),e),s(n(8e3),e),s(n(586),e),s(n(1098),e),s(n(2059),e),s(n(1812),e),s(n(8578),e),s(n(4534),e),s(n(3401),e),s(n(6634),e),s(n(1881),e),s(n(8023),e),s(n(2397),e),s(n(3932),e),s(n(3091),e),$P((0,r.l)(),{Log:o.Log,SDK_VERSION:a.SDK_VERSION})},9638:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var s=Object.getOwnPropertyDescriptor(e,n);s&&("get"in s?e.__esModule:!s.writable&&!s.configurable)||(s={enumerable:!0,get:function(){return e[n]}}),$Q2(t,i,s)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),s=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},r=($Q(e),r(n(600)));s(n(600),e),e.default=r.default},1241:(t,e,n)=>{$Q(e),e.GCIRFormatter=void 0;const h=n(6914),d=n(3260);e.GCIRFormatter=class{constructor(t,e,n){this.en=t,this.Oi=e,this.O=n}getClientInitializeResponse(t,e){var t=(0,h.D)(t,this.O,this.Oi.getDefaultEnvironment()),n=null!=(n=null==e?void 0:e.hash)?n:"djb2";let i=null,s=null;var r=null==e?void 0:e.clientSDKKey,l=null!=(l=null==(l=this.Oi.getValues())?void 0:l.sdk_keys_to_app_ids)?l:{},u=null!=(u=null==(u=this.Oi.getValues())?void 0:u.hashed_sdk_keys_to_app_ids)?u:{},o=null!=(o=null==(o=this.Oi.getValues())?void 0:o.hashed_sdk_keys_to_entities)?o:{},a=(r&&(a=(0,d.hashString)(r,"djb2"),i=null!=(u=u[a])?u:null,s=null!=(u=o[a])?u:null,null==i)&&(i=null!=(o=l[r])?o:null),this.bn(t,e,i,s,n)),u=this.yn(t,e,i,s,n),l=this.mn(t,e,i,n),r={};t.userID&&(r.userID=t.userID),t.customIDs&&0<Object.keys(t.customIDs).length&&(r.customIDs=t.customIDs);let c=void 0;t.privateAttributes&&0<Object.keys(t.privateAttributes).length&&(c=(0,d.hashPrivateAttributes)(t.privateAttributes));o=$P({},t),delete o.privateAttributes,this.jn(o),e=this.On(i,n),t={feature_gates:a,dynamic_configs:u,layer_configs:l,param_stores:e,sdkParams:{},has_updates:!0,generator:"js-on-device-eval-client",sdkInfo:{sdkType:"js-on-device-eval-client",sdkVersion:"1.0.0"},time:this.Oi.getLastUpdateTime(),evaluated_keys:r,hash_used:n,user:o};return e&&0<Object.keys(e).length&&(t.param_stores=e),void 0!==c&&(t.pa_hash=c),t}bn(t,e,n,i,s){var r,l,u={};for(const o of this.Oi.getAllSpecs("gate"))"segment"===o.entity||"holdout"===o.entity||null!=i&&!i.gates.includes(o.name)||null!=n&&!(null!=(r=o.targetAppIDs)?r:[]).includes(n)||(r=this.wn(o,t),u[(l=this.Sn(o.name,r,o,null!=s?s:"djb2")).name]=l);return u}yn(t,e,n,i,s){var r={};for(const c of this.Oi.getAllSpecs("config"))if((null==i||i.configs.includes(c.name))&&(null==n||(null!=(o=c.targetAppIDs)?o:[]).includes(n))){var l,u,o=this.wn(c,t),a=this.Sn(c.name,o,c,null!=s?s:"djb2");if("dynamic_config"===c.entity&&(a.passed=o.bool_value),"dynamic_config"!==c.entity&&"autotune"!==c.entity&&(a.is_user_in_experiment=o.is_experiment_group,a.is_experiment_active=!0===c.isActive,c.hasSharedParams)){a.is_in_layer=!0,a.explicit_parameters=c.explicitParameters||[];const h=this.kn(c.name);h&&(l=this.Oi.getAllSpecs("layer").find(t=>t.name===h))&&(l=l.defaultValue||{},u=a.value||{},a.value=$P($P({},l),u))}r[a.name]=a}return r}mn(t,e,n,i){var s={};for(const o of this.Oi.getAllSpecs("layer"))if(null==n||(null!=(u=o.targetAppIDs)?u:[]).includes(n)){const a=this.wn(o,t);var r,l,u=this.Sn(o.name,a,o,null!=i?i:"djb2");u.explicit_parameters=null!=(r=o.explicitParameters)?r:[],a.allocated_experiment_name?(r=this.Oi.getAllSpecs("config").find(t=>t.name===a.allocated_experiment_name))&&((l=this.wn(r,t)).group_name&&(u.group_name=l.group_name),u.allocated_experiment_name=(0,d.hashString)(a.allocated_experiment_name,null!=i?i:"djb2"),u.is_experiment_active=!0===r.isActive,u.is_user_in_experiment=l.is_experiment_group,u.explicit_parameters=r.explicitParameters||[],l.undelegated_secondary_exposures)&&(u.undelegated_secondary_exposures=this.xn(l.undelegated_secondary_exposures,null!=i?i:"djb2")):u.undelegated_secondary_exposures=this.xn(a.undelegated_secondary_exposures||[],null!=i?i:"djb2"),s[u.name]=u}return s}Sn(t,e,n,i){var s="feature_gate"===n.entity?e.bool_value:!e.unsupported&&e.json_value||{},t={name:(0,d.hashString)(t,i),value:s,rule_id:e.rule_id||"default",secondary_exposures:this.xn(e.secondary_exposures||[],i),id_type:null==n?void 0:n.idType};return e.group_name&&(t.group_name=e.group_name),"feature_gate"!==n.entity&&(t.group=e.group_name||"",t.is_device_based=!1,"dynamic_config"!==n.entity&&"autotune"!==n.entity&&"layer"!==n.entity&&(t.is_experiment_active=n.isActive,t.is_user_in_experiment=e.is_experiment_group),t.passed=e.bool_value),t}wn(t,e){return this.en.evaluateSpec(t,e)}On(t,e){var n=null==(n=this.Oi.getValues())?void 0:n.param_stores;if(n){var i,s,r={};for([i,s]of Object.entries(n))if(!t||s.targetAppIDs&&s.targetAppIDs.includes(t)){var l,u,o={};for([l,u]of Object.entries(s.parameters||{})){var a=$P({},u);a.gate_name&&(a.gate_name=(0,d.hashString)(a.gate_name,e)),a.config_name&&(a.config_name=(0,d.hashString)(a.config_name,e)),a.layer_name&&(a.layer_name=(0,d.hashString)(a.layer_name,e)),a.experiment_name&&(a.experiment_name=(0,d.hashString)(a.experiment_name,e)),o[l]=a}r[(0,d.hashString)(i,e)]=o}return 0<Object.keys(r).length?r:void 0}}xn(t,e){return"none"===e?t:t.map(t=>$P($P({},t),{gate:(0,d.hashString)(t.gate,e)}))}jn(t){for(const e in t)void 0===t[e]?delete t[e]:"object"!=typeof t[e]||null===t[e]||Array.isArray(t[e])||this.jn(t[e])}kn(t){var e=this.Oi.getValues();if(null!=e&&e.layers)for(var[n,i]of Object.entries(e.layers))if(i.includes(t))return n;return null}}},3260:(t,e,n)=>{$Q(e),e.hashPrivateAttributes=e.hashString=void 0;const s=n(6914),i=n(5680),r=n(5680);e.hashString=(t,e)=>{return"none"===e?t:"djb2"===e?(0,s.h)(t):"sha256"===e?(e=(0,i.SHA256)(t).arrayBuffer(),r.Base64.encodeArrayBuffer(e)):t};e.hashPrivateAttributes=t=>{let e=0;for(const i in t){var n;Object.prototype.hasOwnProperty.call(t,i)&&(n=t[i],n=i+":"+(null==n?"":String(n)),n=parseInt((0,s.h)(n),10),e=e+n&4294967295)}return e.toString()}},8494:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e);const s=n(6914);class r extends s.NetworkCore{constructor(t=null){super(t);t=null==t?void 0:t.networkConfig;this.tn=new s.UrlConfiguration(s.Endpoint.Zt,null==t?void 0:t.downloadConfigSpecsUrl,null==t?void 0:t.api,null==t?void 0:t.downloadConfigSpecsFallbackUrls)}fetchConfigSpecs(e,n){return i(this,void 0,void 0,function*(){var t=yield this.get({sdkKey:e,urlConfig:this.tn,priority:n});return null!=(t=null==t?void 0:t.body)?t:null})}}e.default=r},6217:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e);const u=n(6914),s=n(3066),r=n(1241),l=n(8494),o=n(2660);class a extends u.StatsigClientBase{static instance(t){var e=(0,u.l)().instance(t);return e instanceof a?e:(u.Log.warn((0,u.Mt)()?"StatsigOnDeviceEvalClient.instance is not supported in server environments":"Unable to find StatsigOnDeviceEvalClient instance"),new a(null!=t?t:""))}constructor(t,e=null){u.SDKType.Oe(t,"js-on-device-eval-client");var n=new l.default(e);super(t,null!=(t=null==e?void 0:e.dataAdapter)?t:new o.StatsigSpecsDataAdapter,n,e),this.ft=n,this.Oi=new s.SpecStore,this.en=new s.Evaluator(this.Oi),this.wi=(0,u.getUUID)(),this.En=new r.GCIRFormatter(this.en,this.Oi,this.O)}initializeSync(t){return"Uninitialized"!==this.loadingStatus?{success:!0,duration:0,source:this.Oi.getSource(),sourceUrl:null,error:null}:(this.Re.start(),this.updateSync(t))}initializeAsync(t){return i(this,void 0,void 0,function*(){return this.xe||(this.xe=this.ki(t)),this.xe})}updateSync(t){var e=performance.now(),n=(this.Oi.reset(),this.dataAdapter.getDataSync());return this.Oi.setValuesFromDataAdapter(n),this.Oi.finalize(),this.Ae("Ready",n),null!=t&&t.disableBackgroundCacheRefresh||this.xi(n),(0,u.createUpdateDetails)(!0,this.Oi.getSource(),performance.now()-e,this.te.getLastSeenErrorAndReset(),this.ft.getLastUsedInitUrlAndReset())}updateAsync(n){return i(this,void 0,void 0,function*(){var t=performance.now(),e=(this.Oi.reset(),this.Ae("Loading",null),this.dataAdapter.getDataSync());return this.Oi.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,n),this.Oi.setValuesFromDataAdapter(e),this.Oi.finalize(),this.Ae("Ready",e),(0,u.createUpdateDetails)(!0,this.Oi.getSource(),performance.now()-t,this.te.getLastSeenErrorAndReset(),this.ft.getLastUsedInitUrlAndReset())})}getContext(){return{sdkKey:this.j,options:this.O,values:this.Oi.getValues(),errorBoundary:this.te,session:u.StatsigSession.get(this.j),stableID:u.StableID.get(this.j),sdkInstanceID:this.wi}}checkGate(t,e,n){return this.getFeatureGate(t,e,n).value}getFeatureGate(t,e,n){var e=this.D(e),{evaluation:i,details:s}=this.en.evaluateGate(t,e),s=(0,u.We)(t,s,i),r=null==(r=null==(i=this.overrideAdapter)?void 0:i.getGateOverride)?void 0:r.call(i,s,e,n),i=null!=r?r:s;return this.Fe(t,(0,u.Ke)(e,i),n),this.$emt({name:"gate_evaluation",gate:s}),i}getDynamicConfig(t,e,n){var e=this.D(e),{evaluation:i,details:s}=this.en.evaluateConfig(t,e),s=(0,u.Je)(t,s,i),r=null==(r=null==(i=this.overrideAdapter)?void 0:i.getDynamicConfigOverride)?void 0:r.call(i,s,e,n),i=null!=r?r:s;return this.Fe(t,(0,u.ze)(e,i),n),this.$emt({name:"dynamic_config_evaluation",dynamicConfig:i}),i}getExperiment(t,e,n){var e=this.D(e),{evaluation:i,details:s}=this.en.evaluateConfig(t,e),s=(0,u.Ge)(t,s,i),r=null==(r=null==(i=this.overrideAdapter)?void 0:i.getExperimentOverride)?void 0:r.call(i,s,e,n),i=null!=r?r:s;return this.Fe(t,(0,u.ze)(e,i),n),this.$emt({name:"experiment_evaluation",experiment:i}),i}getLayer(e,t,n){const i=this.D(t);var{evaluation:t,details:s}=this.en.evaluateLayer(e,i),s=(0,u.Ve)(e,s,t),r=null==(r=null==(t=this.overrideAdapter)?void 0:t.getLayerOverride)?void 0:r.call(t,s,i,n);const l=null!=r?r:s;return l.get=(0,u.Be)(l.name,l.__value,t=>{this.Fe(e,(0,u.Le)(i,l,t),n)}),this.$emt({name:"layer_evaluation",layer:l}),l}logEvent(t,e,n,i){this.Re.enqueue($P($P({},"string"==typeof t?{eventName:t,value:n,metadata:i}:t),{user:this.D(e),time:Date.now()}))}Ue(){this.$on("error",()=>{"Loading"===this.loadingStatus&&this.Mi(null)})}ki(t){return i(this,void 0,void 0,function*(){return u.Storage.isReady()||(yield u.Storage.isReadyResolver()),this.Re.start(),this.updateAsync(t)})}Mi(t){this.Oi.finalize(),this.Ae("Ready",t)}D(t){return(0,u.D)(t,this.O,this.Oi.getDefaultEnvironment())}xi(t){this.dataAdapter.getDataAsync(t,{priority:"low"}).catch(t=>{u.Log.error("An error occurred after update.",t)})}getClientInitializeResponse(t,e){return"Ready"!==this.loadingStatus?null:this.En.getClientInitializeResponse(t,e)}}e.default=a},2660:function(t,e,n){var i=this&&this.__awaiter||$A();$Q(e),e.StatsigSpecsDataAdapter=void 0;const s=n(6914),r=n(8494);class l extends s.DataAdapterCore{constructor(){super("SpecsDataAdapter","specs"),this.ft=null}attach(t,e,n){super.attach(t,e,n),null!==n&&n instanceof r.default?this.ft=n:this.ft=new r.default(null!=e?e:{})}getDataAsync(t,e){return this.C(t,void 0,e)}prefetchData(t){return this.U(void 0,t)}F(t,e,n){return i(this,void 0,void 0,function*(){var t;return null!=(t=yield null==(t=this.ft)?void 0:t.fetchConfigSpecs(this.N(),null==n?void 0:n.priority))?t:null})}I(){var t=(0,s.o)(this.N());return`${s.DataAdapterCachePrefix}.${this.m}.`+t}A(t,e){return 0<t.data.length}}e.StatsigSpecsDataAdapter=l},600:(t,e,n)=>{$Q(e),e.StatsigSpecsDataAdapter=e.StatsigOnDeviceEvalClient=void 0;var i=n(6914),s=n(6217);e.StatsigOnDeviceEvalClient=s.default;const r=n(2660);$Q2(e,"StatsigSpecsDataAdapter",{enumerable:!0,get:function(){return r.StatsigSpecsDataAdapter}});n=$P((0,i.l)(),{StatsigSpecsDataAdapter:r.StatsigSpecsDataAdapter,StatsigOnDeviceEvalClient:s.default});e.default=n},6535:(t,e)=>{function u(t){return t.setUTCHours(0,0,0,0),t.getTime()}function o(t){var e=Number(t);return isNaN(e)?(t=new Date(String(t)),isNaN(t.getTime())?null:t):e<1e10?new Date(1e3*e):new Date(e)}$Q(e),e.default={compareNumbers(t,e,n){if(null==t||null==e)return!1;var i=Number(t),s=Number(e);if(isNaN(i)||isNaN(s))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},s=((t,e)=>{var n=t.split(".").map(t=>parseInt(t)),i=e.split(".").map(t=>parseInt(t));let s=0;for(;s<Math.max(n.length,i.length);){var r=s<n.length?n[s]:0,l=s<i.length?i[s]:0;if(r<l)return-1;if(l<r)return 1;s++}return 0})(i(t),i(e));switch(n){case"version_gt":return 0<s;case"version_gte":return 0<=s;case"version_lt":return s<0;case"version_lte":return s<=0;case"version_eq":return 0===s;case"version_neq":return 0!==s;default:return!1}},compareStringInArray(s,t,r){if(!Array.isArray(t))return!1;const l="any_case_sensitive"!==r&&"none_case_sensitive"!==r;var e=-1!==t.findIndex(t=>{var e=String(s),t=String(t),n=l?e.toLowerCase():e,i=l?t.toLowerCase():t;switch(r){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(r){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(t,e,n){if(null==t||null==e)return!1;try{var i=o(t),s=o(e);if(null===i||null===s)return!1;var r=i.getTime(),l=s.getTime();switch(n){case"before":return r<l;case"after":return l<r;case"on":return u(i)===u(s);default:return!1}}catch(t){return!1}},arrayHasValue(t,e){var n=new Set(t);for(let t=0;t<e.length;t++)if(n.has(e[t])||n.has(parseFloat(e[t])))return!0;return!1},arrayHasAllValues(t,e){var n=new Set(t);for(let t=0;t<e.length;t++)if(!n.has(e[t])&&!n.has(parseFloat(e[t])))return!1;return!0}}},5079:(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,version:null==(e=t.version)?void 0:e.toString()}},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,version:null==(n=t.version)?void 0:n.toString(),passed:e.bool_value}},e.resultToLayerEval=function(t,e,n){var i;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!=(i=n.allocated_experiment_name)?i:"",explicit_parameters:null!=(i=n.explicit_parameters)?i:[],group:null!=(i=n.group_name)?i:"",group_name:null!=(i=n.group_name)?i:void 0,is_device_based:!1,is_experiment_active:null==e?void 0:e.isActive,is_user_in_experiment:n.is_experiment_group,version:null==(i=t.version)?void 0:i.toString()}}},5007:(t,e,n)=>{$Q(e),e.Evaluator=void 0;const h=n(6914),i=n(5680),d=n(6535),v=n(5079);function f(t){return(0,i.SHA256)(t).dataView().getBigUint64(0,!1)}function c(t){return null!=t&&"object"==typeof t}e.Evaluator=class{constructor(t){this.Oi=t}evaluateGate(t,e){var{spec:t,details:n}=this.nn("gate",t);return t?(e=this.evaluateSpec(t,e),t=(0,v.resultToGateEval)(t,e),this.sn(e,n),{evaluation:t,details:n}):{evaluation:null,details:n}}evaluateConfig(t,e){var{spec:t,details:n}=this.nn("config",t);return t?(e=this.evaluateSpec(t,e),t=(0,v.resultToConfigEval)(t,e),this.sn(e,n),{evaluation:t,details:n}):{evaluation:null,details:n}}evaluateLayer(t,e){var n,{spec:t,details:i}=this.nn("layer",t);return t?(n=null!=(n=null==(e=this.evaluateSpec(t,e))?void 0:e.allocated_experiment_name)?n:"",n=this.Oi.getSpecAndSourceInfo("config",n).spec,t=(0,v.resultToLayerEval)(t,n,e),this.sn(e,i),{evaluation:t,details:i}):{evaluation:null,details:i}}sn(t,e){t.unsupported&&(e.reason="Unsupported")}getParamStoreConfig(t){var t=this.Oi.getParamStoreAndSourceInfo(t),e=this.ln(t);return{config:null!=(t=t.paramStoreConfig)?t:null,details:e}}evaluateSpec(t,e){var n=c(t.defaultValue)?t.defaultValue:void 0;if(!t.enabled)return(0,v.makeEvalResult)({json_value:n,rule_id:"disabled"});var i=[],s={};for(const o of t.rules){var r,l=this.un(o,e);if(l.unsupported)return l;for(const a of l.secondary_exposures){var u=`${a.gate}|${a.gateValue}|`+a.ruleID;s[u]||(s[u]=!0,i.push(a))}if(l.bool_value)return this.an(o.configDelegate,e,i)||(r=function(t,e,n){if(100===t.passPercentage)return!0;if(0===t.passPercentage)return!1;e=f(n.salt+"."+(null!=(n=t.salt)?n:t.id)+"."+(null!=(n=(0,h.Jn)(e,t.idType))?n:""));return Number(e%BigInt(1e4))<100*t.passPercentage}(o,e,t),(0,v.makeEvalResult)({rule_id:l.rule_id,bool_value:r,json_value:r?l.json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,is_experiment_group:l.is_experiment_group,group_name:l.group_name}))}return(0,v.makeEvalResult)({json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,rule_id:"default"})}nn(t,e){t=this.Oi.getSpecAndSourceInfo(t,e);return{details:this.ln(t),spec:t.spec}}ln(t){var{source:e,lcut:n,receivedAt:i}=t;return"Uninitialized"===e||"NoValues"===e?{reason:e}:{reason:e+":"+(null==("spec"in t?t.spec:t.paramStoreConfig)?"Unrecognized":"Recognized"),lcut:n,receivedAt:i}}un(t,e){var n=[];let i=!0;for(const r of t.conditions){var s=this.cn(r,e);if(s.unsupported)return s;n.push(...s.secondary_exposures),s.bool_value||(i=!1)}return(0,v.makeEvalResult)({rule_id:t.id,bool_value:i,json_value:c(t.returnValue)?t.returnValue:void 0,secondary_exposures:n,is_experiment_group:!0===t.isExperimentGroup,group_name:t.groupName})}cn(t,e){let n=null,i=!1;var s=t.field,r=t.targetValue,l=t.idType,u=t.type;switch(u){case"public":return(0,v.makeEvalResult)({bool_value:!0});case"pass_gate":case"fail_gate":var o=String(r),o=this.hn(o,e);return(0,v.makeEvalResult)({bool_value:"fail_gate"===u?!o.bool_value:o.bool_value,secondary_exposures:o.secondary_exposures});case"multi_pass_gate":case"multi_fail_gate":return this.dn(r,u,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,s);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,s);break;case"current_time":n=Date.now();break;case"user_bucket":o=f(String(null!=(o=null==(o=t.additionalValues)?void 0:o.salt)?o:"")+"."+(null!=(o=(0,h.Jn)(e,l))?o:""));n=Number(o%BigInt(1e3));break;case"unit_id":n=(0,h.Jn)(e,l);break;default:return(0,v.makeEvalResult)({unsupported:!0})}var a,c=t.operator;switch(c){case"gt":case"gte":case"lt":case"lte":i=d.default.compareNumbers(n,r,c);break;case"version_gt":case"version_gte":case"version_lt":case"version_lte":case"version_eq":case"version_neq":i=d.default.compareVersions(n,r,c);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,r,c);break;case"str_matches":i=d.default.compareStringWithRegEx(n,r);break;case"before":case"after":case"on":i=d.default.compareTime(n,r,c);break;case"eq":i=n==r;break;case"neq":i=n!=r;break;case"in_segment_list":case"not_in_segment_list":return(0,v.makeEvalResult)({unsupported:!0});case"array_contains_any":case"array_contains_none":Array.isArray(r)?i=!!Array.isArray(n)&&(a=d.default.arrayHasValue(n,r),"array_contains_any"===c?a:!a):i=!1;break;case"array_contains_all":case"not_array_contains_all":Array.isArray(r)?i=!!Array.isArray(n)&&(a=d.default.arrayHasAllValues(n,r),"array_contains_all"===c?a:!a):i=!1}return(0,v.makeEvalResult)({bool_value:i})}an(t,e,n){if(!t)return null;var i=this.Oi.getSpecAndSourceInfo("config",t)["spec"];if(!i)return null;var e=this.evaluateSpec(i,e),s={},r=[];for(const u of n.concat(e.secondary_exposures)){var l=`${u.gate}|${u.gateValue}|`+u.ruleID;s[l]||(s[l]=!0,r.push(u))}return(0,v.makeEvalResult)($P($P({},e),{allocated_experiment_name:t,explicit_parameters:i.explicitParameters,secondary_exposures:r,undelegated_secondary_exposures:n}))}hn(t,e){var n=[];let i=!1;var s=this.Oi.getSpecAndSourceInfo("gate",t)["spec"];if(s){s=this.evaluateSpec(s,e);if(s.unsupported)return s;i=s.bool_value,n.push(...s.secondary_exposures),t.startsWith("segment:")||n.push({gate:t,gateValue:String(i),ruleID:s.rule_id})}return(0,v.makeEvalResult)({bool_value:i,secondary_exposures:n})}dn(t,e,n){if(!Array.isArray(t))return(0,v.makeEvalResult)({unsupported:!0});var i="multi_pass_gate"===e,s=[];let r=!1;for(const u of t){if("string"!=typeof u)return(0,v.makeEvalResult)({unsupported:!0});var l=this.hn(u,n);if(l.unsupported)return l;if(s.push(...l.secondary_exposures),i?!0===l.bool_value:!1===l.bool_value){r=!0;break}}return(0,v.makeEvalResult)({bool_value:r,secondary_exposures:s})}}},8313:(t,e,n)=>{$Q(e),e.SpecStore=void 0;const i=n(6914);function s(t){return(0,i.P)(t,"has_updates","DownloadConfigSpecsResponse")}e.SpecStore=class{constructor(){this.Ze=null,this.ti=null,this.ei="Uninitialized",this.ii=0,this.ni=0,this.vn=null}getValues(){return this.Ze?s(this.Ze):null}getSource(){return this.ei}getDefaultEnvironment(){return this.vn}setValuesFromDataAdapter(t){var e,n;!t||!0!==(null==(n=s(t.data))?void 0:n.has_updates)||(null!=(e=n.time)?e:0)<this.ii||(this.ii=n.time,this.ni=t.receivedAt,this.ei=t.source,this.ti=n,this.Ze=t.data,this.vn=null!=(e=n.default_environment)?e:null)}reset(){this.ti=null,this.Ze=null,this.ei="Loading"}finalize(){this.ti||(this.ei="NoValues")}getSpecAndSourceInfo(t,e){var t=this.fn(t);return{spec:null!=(t=null==t?void 0:t.find(t=>t.name===e))?t:null,source:this.ei,lcut:this.ii,receivedAt:this.ni}}getParamStoreAndSourceInfo(t){var e=null==(e=this.ti)?void 0:e.param_stores;return{paramStoreConfig:null!=(t=null==(e=null==e?void 0:e[t])?void 0:e.parameters)?t:null,source:this.ei,lcut:this.ii,receivedAt:this.ni}}fn(t){var e;switch(t){case"gate":return null==(e=this.ti)?void 0:e.feature_gates;case"config":return null==(e=this.ti)?void 0:e.dynamic_configs;case"layer":return null==(e=this.ti)?void 0:e.layer_configs}}getAllSpecs(t){return this.fn(t)||[]}getLastUpdateTime(){return this.ii}}},3066:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var s=Object.getOwnPropertyDescriptor(e,n);s&&("get"in s?e.__esModule:!s.writable&&!s.configurable)||(s={enumerable:!0,get:function(){return e[n]}}),$Q2(t,i,s)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),s=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),s(n(5007),e),s(n(5079),e),s(n(8313),e)},725:(t,e)=>{$Q(e),e.Base64=void 0;const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.Base64=class{static encodeArrayBuffer(t){let e="";var n=new Uint8Array(t),i=n.byteLength;for(let t=0;t<i;t++)e+=String.fromCharCode(n[t]);return this.Dn(e)}static Dn(t){let e="";var n,i,s,r;let l,u,o=0;for(;o<t.length;)r=t.charCodeAt(o++),n=t.charCodeAt(o++),i=t.charCodeAt(o++),s=r>>2,r=(3&r)<<4|n>>4,l=(15&n)<<2|i>>6,u=63&i,isNaN(n)?l=u=64:isNaN(i)&&(u=64),e=e+a.charAt(s)+a.charAt(r)+a.charAt(l)+a.charAt(u);return e}}},5680:(t,e,n)=>{$Q(e),e.Base64=e.SHA256=void 0;const i=n(725),s=($Q2(e,"Base64",{enumerable:!0,get:function(){return i.Base64}}),n(7485));$Q2(e,"SHA256",{enumerable:!0,get:function(){return s.SHA256}})},7485:(t,e)=>{$Q(e),e.SHA256=void 0,e.SHA256=function(t){return(new i).update(t)};const n=[-2147483648,8388608,32768,128],l=[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 s=n.length,r=this.blocks;t<s;){for(this.hashed&&(this.hashed=!1,r[0]=this.block,r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0),e=this.start;t<s&&e<64;++t)(i=n.charCodeAt(t))<128?r[e>>2]|=i<<l[3&e++]:(i<2048?r[e>>2]|=(192|i>>6)<<l[3&e++]:(i<55296||57344<=i?r[e>>2]|=(224|i>>12)<<l[3&e++]:(i=65536+((1023&i)<<10|1023&n.charCodeAt(++t)),r[e>>2]|=(240|i>>18)<<l[3&e++],r[e>>2]|=(128|i>>12&63)<<l[3&e++]),r[e>>2]|=(128|i>>6&63)<<l[3&e++]),r[e>>2]|=(128|63&i)<<l[3&e++]);this.lastByteIndex=e,this.bytes+=e-this.start,64<=e?(this.block=r[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,s=this.h3,r=this.h4,l=this.h5,u=this.h6,o=this.h7,a,c,h,d,v,f,_,g,p,b,y;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],h=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,t[a]=t[a-16]+c+t[a-7]+h<<0;for(y=n&i,a=0;a<64;a+=4)this.first?(g=704751109,v=t[0]-210244248,o=v-1521486534<<0,s=v+143694565<<0,this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),h=(r>>>6|r<<26)^(r>>>11|r<<21)^(r>>>25|r<<7),g=e&n,d=g^e&i^y,_=r&l^~r&u,v=o+h+_+m[a]+t[a],f=c+d,o=s+v<<0,s=v+f<<0),c=(s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10),h=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),p=s&e,d=p^s&n^g,_=o&r^~o&l,v=u+h+_+m[a+1]+t[a+1],f=c+d,u=i+v<<0,i=v+f<<0,c=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),h=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),b=i&s,d=b^i&e^p,_=u&o^~u&r,v=l+h+_+m[a+2]+t[a+2],f=c+d,l=n+v<<0,n=v+f<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),h=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),y=n&i,d=y^n&s^b,_=l&u^~l&o,v=r+h+_+m[a+3]+t[a+3],f=c+d,r=e+v<<0,e=v+f<<0;this.h0=this.h0+e<<0,this.h1=this.h1+n<<0,this.h2=this.h2+i<<0,this.h3=this.h3+s<<0,this.h4=this.h4+r<<0,this.h5=this.h5+l<<0,this.h6=this.h6+u<<0,this.h7=this.h7+o<<0}arrayBuffer(){return this._n().buffer}dataView(){return this._n().dataView}_n(){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 s(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,s)),e.exports}return s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s(9638).default})());
1
+ var $Q=(e)=>Object.defineProperty(e,"__esModule",{value:!0});var $Q2=(a,b,c)=>Object.defineProperty(a,b,c);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())})});!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 i={1845:(t,i,e)=>{var n;$Q2(i,"__esModule",{value:!0}),i.t=i.i=i.l=void 0;const s=e(7512);i.l=()=>{try{return"undefined"!=typeof __STATSIG__?__STATSIG__:o}catch(t){return o}},i.i=t=>(0,i.l)()[t];i.t=t=>{var e=(0,i.l)();return t?e.instances&&e.instances[t]:(e.instances&&1<Object.keys(e.instances).length&&s.Log.warn("Call made to Statsig global instance without an SDK key but there is more than one client instance. If you are using mulitple clients, please specify the SDK key."),e.firstInstance)};var r="__STATSIG__",l="undefined"!=typeof window?window:{},e=void 0!==e.g?e.g:{},u="undefined"!=typeof globalThis?globalThis:{};const o=null!=(n=null!=(n=null!=(n=l[r])?n:e[r])?n:u[r])?n:{instance:i.t};l[r]=o,e[r]=o,u[r]=o},7463:(t,e,i)=>{$Q(e),e.BatchQueue=void 0;const s=i(1956),n=i(4309);e.BatchQueue=class{constructor(t=n.EventRetryConstants.DEFAULT_BATCH_SIZE){this.Fi=[],this.Ci=t}batchSize(){return this.Ci}requeueBatch(t){return this.Ai(t)}hasFullBatch(){return this.Fi.some(t=>t.events.length>=this.Ci)}takeNextBatch(){return this.Fi.shift()}takeAllBatches(){var t=this.Fi;return this.Fi=[],t}createBatches(t){let e=0,i=0;for(;e<t.length;){var n=t.slice(e,e+this.Ci);i+=this.Ai(new s.EventBatch(n)),e+=this.Ci}return i}Ai(t){this.Fi.push(t);let e=0;for(;this.Fi.length>n.EventRetryConstants.MAX_PENDING_BATCHES;){var i=this.Fi.shift();i&&(e+=i.events.length)}return e}}},2137:(t,e,i)=>{$Q(e),e.o=e.u=void 0;const s=i(1406);function n(t,e,i){if(i)return i(t,e);const n=e&&e.customIDs?e.customIDs:{};e=["uid:"+(null!=(i=null==e?void 0:e.userID)?i:""),"cids:"+Object.keys(n).sort((t,e)=>t.localeCompare(e)).map(t=>t+"-"+n[t]).join(","),"k:"+t];return(0,s.h)(e.join("|"))}e.u=n,e.o=function(t,e,i){return e?n(t,e,i):(0,s.h)("k:"+t)}},6427:(t,e,i)=>{$Q(e),e.PrecomputedEvaluationsContextHandle=void 0;const n=i(7512),s=i(6830),r=i(4143),l=i(9122);e.PrecomputedEvaluationsContextHandle=class{constructor(t,e,i,n,s,r){this.j=t,this.Ni=e,this.Ri=i,this.Ui=n,this.Pi=s,this.Li=r}get sdkKey(){return this.j}get options(){return this.Ni()}get errorBoundary(){return this.Ri()}get values(){return this.Ui()}get user(){let t=(0,s.Bi)("StatsigUser",this.Pi());return null==t&&(n.Log.error("Failed to clone user"),t={}),t}getSession(t=!0){return r.StatsigSession.get(this.j,t)}get stableID(){return l.StableID.get(this.j)}get sdkInstanceID(){return this.Li()}toContext(t=!0){return{sdkKey:this.sdkKey,options:this.options,values:this.values,user:this.user,errorBoundary:this.errorBoundary,session:this.getSession(t),stableID:this.stableID,sdkInstanceID:this.sdkInstanceID}}}},694:function(t,e,i){var s=this&&this.__awaiter||$A();$Q(e),e.v=e.DataAdapterCore=void 0;const o=i(7512),a=i(9122),r=i(8578),l=i(4534),c=i(3401);function h(t,e,i,n){return{source:t,data:e,receivedAt:Date.now(),stableID:i,fullUserHash:(0,r._)(n)}}e.DataAdapterCore=class{constructor(t,e){this.p=t,this.m=e,this.O=null,this.j=null,this.gn=10,this.S="statsig.last_modified_time."+e,this.k=new n}attach(t,e,i){this.j=t,this.O=e}getDataSync(t){var t=t&&(0,r.D)(t,this.O),e=this.I(t),i=this.k.get(e,t);return i&&this.M(i)?i:(i=this.T(e))&&this.M(i)?(this.k.add(e,i,this.gn),this.k.get(e,t)):null}setData(t,e){var e=e&&(0,r.D)(e,this.O),i=this.I(e);this.k.add(i,h("Bootstrap",t,null,e),this.gn)}M(t){return null==t.stableID||t.stableID===a.StableID.get(this.N())}C(e,i,n){return s(this,void 0,void 0,function*(){l.Storage.isReady()||(yield l.Storage.isReadyResolver());var t=null!=e?e:this.getDataSync(i),t=[this.R(t,i,n)];return null!=n&&n.timeoutMs&&t.push(new Promise(t=>setTimeout(t,n.timeoutMs)).then(()=>(o.Log.debug("Fetching latest value timed out"),null))),yield Promise.race(t)})}U(i,n){return s(this,void 0,void 0,function*(){var t=i&&(0,r.D)(i,this.O),e=this.I(t),t=yield this.C(null,t,n);t&&this.k.add(e,$P($P({},t),{source:"Prefetch"}),this.gn)})}R(r,l,u){return s(this,void 0,void 0,function*(){var t=null!=(t=null==r?void 0:r.data)?t:null,e=null!=r&&this.A(r,l),e=yield this.F(t,l,u,e);if(!e)return o.Log.debug("No response returned for latest value"),null;var i=(0,c.P)(e,"has_updates","Response"),n=this.N(),n=a.StableID.get(n);let s=null;if(!0===(null==i?void 0:i.has_updates))s=h("Network",e,n,l);else{if(!t||!1!==(null==i?void 0:i.has_updates))return null;s=h("NetworkNotModified",t,n,l)}e=this.I(l);return this.k.add(e,s,this.gn),this.L(e,s),s})}N(){return null!=this.j?this.j:(o.Log.error(this.p+" is not attached to a Client"),"")}T(t){var e=null==(e=l.Storage.getItem)?void 0:e.call(l.Storage,t);return null!=e&&(t=(0,c.P)(e,"source","Cached Result"))?$P($P({},t),{source:"Cache"}):null}L(e,t){var i=JSON.stringify(t);for(let t=0;t<8;t++)try{l.Storage.setItem(e,i);break}catch(t){if(!(t instanceof Error)||!t.toString().includes("QuotaExceededError")&&!t.toString().includes("QUOTA_EXCEEDED_ERR")||this.gn<=1)throw t;this.gn=Math.ceil(this.gn/2),this.q(e,this.gn-1)}this.q(e)}q(t,e=this.gn){var i=null!=(n=(0,l.K)(this.S))?n:{},n=(i[t]=Date.now(),u(i,e));for(const s of n)delete i[s],l.Storage.removeItem(s);(0,l.B)(this.S,i)}},e.v=h;class n{constructor(){this.$={}}get(t,e){var t=this.$[t],i=null==t?void 0:t.stableID,e=null==(e=null==e?void 0:e.customIDs)?void 0:e.stableID;return e&&i&&e!==i?(o.Log.warn("'StatsigUser.customIDs.stableID' mismatch"),null):t}add(t,e,i){for(const n of u(this.$,i-1))delete this.$[n];this.$[t]=e}merge(t){this.$=$P($P({},this.$),t)}}function u(i,t){var e=Object.keys(i);return e.length<=t?[]:0===t?e:e.sort((t,e)=>{t=i[t],e=i[e];return"object"==typeof t&&"object"==typeof e?t.receivedAt-e.receivedAt:t-e}).slice(0,e.length-t)}},8962:(t,l)=>{$Q2(l,"__esModule",{value:!0}),l.Diagnostics=void 0;const n=new Map,i="start";function s(t,e,i,n){return $P({key:i,action:e,step:n,timestamp:Date.now()},t)}function r(t,e){var i=null!=(i=n.get(t))?i:[];i.push(e),n.set(t,i)}function e(t,e){if(e in t)return t[e]}l.Diagnostics={V:t=>n.get(t),G:t=>{r(t,s({},i,"overall"))},J:(t,e,i)=>{r(t,s({success:e,error:e?void 0:{name:"InitializeError",message:"Failed to initialize"},evaluationDetails:i},"end","overall"))},W:(t,e)=>{r(t,s(e,i,"initialize","network_request"))},Y:(t,e)=>{r(t,s(e,"end","initialize","network_request"))},X:t=>{r(t,s({},i,"initialize","process"))},H:(t,e)=>{r(t,s(e,"end","initialize","process"))},Z:t=>{n.delete(t)},tt(t){if(t&&"object"==typeof t)return{code:e(t,"code"),name:e(t,"name"),message:e(t,"message")}},et(t,e,i,n){return{success:!0===(null==t?void 0:t.ok),statusCode:null==t?void 0:t.status,sdkRegion:null==(t=null==t?void 0:t.headers)?void 0:t.get("x-statsig-region"),isDelta:!0===i.includes('"is_delta":true')||void 0,attempt:e,error:l.Diagnostics.tt(n)}},it(t,e,i,n){var s,r=l.Diagnostics.V(i);return null==r||r.length<=0?-1:(s=r[r.length-1].timestamp-r[0].timestamp,l.Diagnostics.Z(i),i=function(t,e){t={eventName:"statsig::diagnostics",user:t,value:null,metadata:e,time:Date.now()};return t}(t,{context:"initialize",markers:r.slice(),statsigOptions:n}),e.enqueue(i),s)}}},8809:function(t,e){var i=this&&this.__awaiter||$A();$Q(e),e.nt=void 0;const s=new Uint8Array([0,0,1,0,0,1,0,0,0,0,0,0,13,102,101,97,116,117,114,101,97,115,115,101,116,115,3,111,114,103,0,0,16,0,1]),r="https://cloudflare-dns.com/dns-query",l=["i","e","d"],u=200;e.nt=function(e){return i(this,void 0,void 0,function*(){var i=yield e(r,{method:"POST",headers:{"Content-Type":"application/dns-message",Accept:"application/dns-message"},body:s});if(i.ok){var t,i=yield i.arrayBuffer(),i=new Uint8Array(i);{var n=i,i=n.findIndex((t,e)=>e<u&&"="===String.fromCharCode(t)&&l.includes(String.fromCharCode(n[e-1])));if(-1===i)throw(t=new Error("Failed to parse TXT records from DNS")).name="DnsTxtParseError",t;let e="";for(let t=i-1;t<n.length;t++)e+=String.fromCharCode(n[t]);return e.split(",")}}throw(t=new Error("Failed to fetch TXT records from DNS")).name="DnsTxtFetchError",t})}},3539:(t,e)=>{$Q(e)},5542:function(t,a,e){var i=this&&this.__awaiter||$A();$Q2(a,"__esModule",{value:!0}),a.ErrorBoundary=a.EXCEPTION_ENDPOINT=void 0;const n=e(7512),c=e(5902),h=e(8e3),d=(a.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception","[Statsig] UnknownError");function v(t){return t instanceof Error?t:"string"==typeof t?new Error(t):new Error("An unknown error occurred.")}a.ErrorBoundary=class{constructor(t,e,i,n){this.j=t,this.O=e,this.st=i,this.rt=n,this.lt=new Set}wrap(n,s){try{const t=n;!function(t){const e=new Set;let i=Object.getPrototypeOf(t);for(;i&&i!==Object.prototype;)Object.getOwnPropertyNames(i).filter(t=>"function"==typeof(null===i||void 0===i?void 0:i[t])).forEach(t=>e.add(t)),i=Object.getPrototypeOf(i);return Array.from(e)}(t).forEach(e=>{const i=t[e];"$EB"in i||(t[e]=(...t)=>this.ot(s?s+":"+e:e,()=>i.apply(n,t)),t[e].$EB=!0)})}catch(t){this.ut("eb:wrap",t)}}logError(t,e){this.ut(t,e)}logDroppedEvents(t,e,i){const n={eventCount:String(t),reason:e};i&&Object.keys(i).forEach(t=>{n[t]=String(i[t])}),this.ut("statsig::log_event_dropped_event_count",new Error(e),!0,n)}logEventRequestFailure(t,e,i,n,s){t={eventCount:String(t),flushType:i,statusCode:String(n),reason:e,retries:String(s)};this.ut("statsig::log_event_failed",new Error(e),!0,t)}getLastSeenErrorAndReset(){var t=this.rt;return this.rt=void 0,null!=t?t:null}attachErrorIfNoneExists(t){this.rt||(this.rt=v(t))}ot(e,t){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.ut(e,t)):i}catch(t){return this.ut(e,t),null}}ut(r,l,u=!1,o){try{n.Log.warn("Caught error in "+r,{error:l});i(this,void 0,void 0,function*(){var t,e=l||Error(d),i=e instanceof Error,n=i?e.name:"No Name",s=v(e);this.rt=s,!u&&this.lt.has(n)||(this.lt.add(n),null!=(s=null==(s=this.O)?void 0:s.networkConfig)&&s.preventAllNetworkTraffic?null!=(s=this.st)&&s.call(this,{name:"error",error:l,tag:r}):(s=c.SDKType.ct(this.j),t=h.StatsigMetadataProvider.get(),i=i?e.stack:function(t){try{return JSON.stringify(t)}catch(t){return d}}(e),e=$P($P({tag:r,exception:n,info:i,statsigOptions:function(n){if(!n)return{};const s={};return Object.keys(n).forEach(t=>{var e=t,i=n[e];switch(typeof i){case"number":case"bigint":case"boolean":s[String(e)]=i;break;case"string":i.length<50?s[String(e)]=i:s[String(e)]="set";break;case"object":"environment"===e?s.environment=i:"networkConfig"===e?s.networkConfig=i:s[String(e)]=null!=i?"set":"unset"}}),s}(this.O)},$P($P({},t),{sdkType:s})),null!=o?o:{}),yield(null!=(n=null==(i=null==(n=this.O)?void 0:n.networkConfig)?void 0:i.networkOverrideFunc)?n:fetch)(a.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.j,"STATSIG-SDK-TYPE":String(s),"STATSIG-SDK-VERSION":String(t.sdkVersion),"Content-Type":"application/json"},body:JSON.stringify(e)}),null!=(i=this.st)&&i.call(this,{name:"error",error:l,tag:r})))}).then(()=>{}).catch(()=>{})}catch(t){}}}},2922:(t,e)=>{$Q(e)},2417:(t,e)=>{$Q(e)},1956:(t,e)=>{$Q(e),e.EventBatch=void 0;e.EventBatch=class{constructor(t){this.attempts=0,this.createdAt=Date.now(),this.events=t}incrementAttempts(){this.attempts++}}},7770:function(t,e,i){var n=this&&this.__awaiter||$A();$Q(e),e.EventLogger=void 0;const s=i(7463),r=i(2137),l=i(4309),u=i(4312),o=i(1406),a=i(7512),c=i(7410),h=i(1228),d=i(6830),v=i(1637),f=i(586),_=i(4534),g=i(1881),p=i(2397),b={};class y{static ht(t){null!=(t=b[t])&&t.flush().catch(()=>{})}constructor(t,e,i,n,s){this.j=t,this.st=e,this.ft=i,this.O=n,this.te=s,this.zi=null,this.Ki=null,this.qi=null,this._t={},this.bt={},this.$i=!1,this.Gi=null,this.Vi=null,this.jt=null!=(t=null==n?void 0:n.loggingEnabled)?t:!0===(null==n?void 0:n.disableLogging)?f.LoggingEnabledOption.disabled:f.LoggingEnabledOption.browserOnly,null!=n&&n.loggingEnabled&&void 0!==n.disableLogging&&a.Log.warn("Detected both loggingEnabled and disableLogging options. loggingEnabled takes precedence - please remove disableLogging.");e=null==n?void 0:n.networkConfig;this.wt=new g.UrlConfiguration(c.Endpoint.kt,null==e?void 0:e.logEventUrl,null==e?void 0:e.api,null==e?void 0:e.logEventFallbackUrls)}setLogEventCompressionMode(t){this.qi?this.qi.setLogEventCompressionMode(t):this.Vi=t}setLoggingEnabled(t){var e="disabled"===this.jt,i="disabled"!==t;this.jt=t,this.qi&&this.qi.setLoggingEnabled(t),e&&i&&(t=this.Ji(),a.Log.debug(`Loaded ${t.length} stored event(s) from storage`),0<t.length)&&(t.forEach(t=>{this.Wi().addEvent(t)}),this.flush().catch(t=>{a.Log.warn("Failed to flush events after enabling logging:",t)}))}enqueue(t){this.Et(t)&&(t=this.Qi(t),"disabled"===this.jt?this.Xi(t):(this.Wi().addEvent(t),null!=(t=this.qi)&&t.checkQuickFlush()))}incrementNonExposureCount(t){var e=null!=(e=this.bt[t])?e:0;this.bt[t]=e+1}reset(){this.flush().catch(()=>{}),this._t={}}start(){var t,e=(0,d.Mt)();if(!e||"always"===(null==(t=this.O)?void 0:t.loggingEnabled)){const i=this.Wi();b[this.j]=this,e||(0,p.xt)(t=>{"background"===t?y.ht(this.j):"foreground"===t&&i.startScheduledFlushCycle()}),i.loadAndRetryShutdownFailedEvents().catch(t=>{a.Log.warn("Failed to load failed shutdown events:",t)}),i.startScheduledFlushCycle()}}stop(){return n(this,void 0,void 0,function*(){this.$i=!0,this.qi&&(yield this.qi.processShutdown()),delete b[this.j],this.qi=null,this.zi=null,this.Ki=null})}flush(){return n(this,void 0,void 0,function*(){if(this.qi)return this.qi.processManualFlush()})}appendAndResetNonExposedChecks(){var t;0!==Object.keys(this.bt).length&&(t=$P({},this.bt),this.bt={},t=this.Qi({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:t}}),this.qi)&&this.qi.addEvent(t)}Et(t){if("always"!==(null==(e=this.O)?void 0:e.loggingEnabled)&&(0,d.Mt)())return!1;if((0,v.Ut)(t)){var e=t.user||{statsigEnvironment:void 0},e=(0,r.u)(this.j,e),i=t.metadata||{},t=[t.eventName,e,i.gate,i.config,i.ruleID,i.allocatedExperiment,i.parameterName,String(i.isExplicitParameter),i.reason].join("|"),e=this._t[t],i=Date.now();if(e&&i-e<6e5)return!1;1e3<Object.keys(this._t).length&&(this._t={}),this._t[t]=i}return!0}qt(){var t;if(!1!==(null==(t=this.O)?void 0:t.includeCurrentPageUrlWithEvents))return(0,d.Kt)()}o(){return this.Gi||(this.Gi="statsig.pending_events."+(0,o.h)(this.j)),this.Gi}Wi(){var t;return this.qi||(t=null!=(t=null==(t=this.O)?void 0:t.loggingBufferMaxSize)?t:l.EventRetryConstants.DEFAULT_BATCH_SIZE,this.zi=new h.PendingEvents(t),this.Ki=new s.BatchQueue(t),this.qi=new u.FlushCoordinator(this.Ki,this.zi,()=>this.appendAndResetNonExposedChecks(),this.j,this.ft,this.st,this.wt,this.O,this.jt,this.te),this.Vi&&(this.qi.setLogEventCompressionMode(this.Vi),this.Vi=null)),this.qi}Xi(e){var i=this.o();try{let t=this.Hi(i);t.push(e),t.length>l.EventRetryConstants.MAX_LOCAL_STORAGE&&(t=t.slice(-l.EventRetryConstants.MAX_LOCAL_STORAGE)),(0,_.B)(i,t)}catch(t){a.Log.warn("Unable to save events to storage")}}Hi(t){try{var e=(0,_.K)(t);return Array.isArray(e)?e:[]}catch(t){return[]}}Ji(){var t=this.o(),e=this.Hi(t);return 0<e.length&&_.Storage.removeItem(t),e}Qi(t){t.user&&(t.user=$P({},t.user),delete t.user.privateAttributes);var e={},i=this.qt();return i&&(e.statsigMetadata={currentPage:i}),$P($P({},t),e)}}e.EventLogger=y},4309:(t,e)=>{$Q(e),e.EventRetryConstants=void 0,e.EventRetryConstants={MAX_RETRY_ATTEMPTS:5,DEFAULT_BATCH_SIZE:100,MAX_PENDING_BATCHES:30,TICK_INTERVAL_MS:1e3,QUICK_FLUSH_WINDOW_MS:200,MAX_LOCAL_STORAGE:500,get MAX_QUEUED_EVENTS(){return this.DEFAULT_BATCH_SIZE*this.MAX_PENDING_BATCHES}}},6351:function(t,e,i){var n=this&&this.__awaiter||$A();$Q(e),e.EventSender=void 0;const r=i(7512),s=i(7410),l=i(2397);e.EventSender=class{constructor(t,e,i,n,s){this.j=t,this.ft=e,this.st=i,this.O=s,this.wt=n}setLogEventCompressionMode(t){this.ft.setLogEventCompressionMode(t)}sendBatch(s){return n(this,void 0,void 0,function*(){var t,e;try{var i=(0,l.Ft)()&&this.ft.isBeaconSupported()&&null==(null==(e=null==(t=this.O)?void 0:t.networkConfig)?void 0:e.networkOverrideFunc),n=(this.st({name:"pre_logs_flushed",events:s.events}),i?this.Pt(s):yield this.Lt(s));return n.success?(this.st({name:"logs_flushed",events:s.events}),n):{success:!1,statusCode:n.statusCode}}catch(t){return r.Log.warn("Failed to send batch:",t),{success:!1,statusCode:-1}}})}Lt(e){return n(this,void 0,void 0,function*(){var t=yield this.ft.post(this.zt(e)),t=null!=(t=null==t?void 0:t.code)?t:-1;return{success:200<=t&&t<300,statusCode:t}})}Pt(t){t=this.ft.beacon(this.zt(t));return{success:t,statusCode:t?200:-1}}zt(t){return{sdkKey:this.j,data:{events:t.events},urlConfig:this.wt,retries:3,preserveFailedStatusCode:!0,isCompressable:!0,params:{[s.NetworkParam.EventCount]:String(t.events.length)},headers:{"statsig-event-count":String(t.events.length),"statsig-retry-count":String(t.attempts)},credentials:"same-origin"}}}},4312:function(t,e,i){var n=this&&this.__awaiter||$A();$Q(e),e.FlushCoordinator=void 0;const s=i(4309),c=i(6351),h=i(8153),r=i(323),l=i(1406),u=i(7512),o=i(7023),a=i(6830),d=i(4143),v=i(586),f=i(4534);e.FlushCoordinator=class{constructor(t,e,i,n,s,r,l,u,o,a){this.Yi=null,this.Zi=null,this.yt=!1,this.Mn=null,this.Ot=Date.now(),this.$i=!1,this.Gi=null,this.In=new h.FlushInterval,this.Ki=t,this.zi=e,this.Tn=i,this.te=a,this.j=n,this.jt=o,this.Fn=new c.EventSender(n,s,r,l,u)}setLoggingEnabled(t){this.jt=t}setLogEventCompressionMode(t){this.Fn.setLogEventCompressionMode(t)}startScheduledFlushCycle(){this.Cn()}stopScheduledFlushCycle(){this.An()}addEvent(t){this.zi.addToPendingEventsQueue(t),this.Mn||this.zi.hasEventsForFullBatch()&&this.processLimitFlush()}processManualFlush(){return n(this,void 0,void 0,function*(){return this.Mn&&(yield this.Mn),this.Mn=this.Nn(r.FlushType.Manual).finally(()=>{this.Mn=null,this.Cn()}),this.Mn})}processShutdown(){return n(this,void 0,void 0,function*(){return this.$i=!0,this.An(),this.Mn&&(yield this.Mn),this.Mn=this.Nn(r.FlushType.Shutdown).catch(t=>{u.Log.error("Error during shutdown flush: "+t)}).finally(()=>{this.Mn=null}),this.Mn})}Nn(e){return n(this,void 0,void 0,function*(){this.An();try{this.Rn(e);var t=this.Ki.takeAllBatches();0!==t.length&&(yield Promise.all(t.map(t=>this.Un(t,e))))}finally{this.$i||this.Cn()}})}checkQuickFlush(){this.yt||Date.now()-this.Ot>s.EventRetryConstants.QUICK_FLUSH_WINDOW_MS||(this.yt=!0,setTimeout(()=>{this.processManualFlush().catch(t=>{u.Log.warn("Quick flush failed:",t)})},s.EventRetryConstants.QUICK_FLUSH_WINDOW_MS))}Pn(){if(this.Mn)this.Cn();else{var e=this.containsAtLeastOneFullBatch(),t=this.In.hasReachedMaxInterval();if(e||t){this.In.markFlushAttempt();let t;t=e?r.FlushType.ScheduledFullBatch:r.FlushType.ScheduledMaxTime,this.Mn=this.Ln(t).then(()=>{}).catch(t=>{u.Log.error("Error during scheduled flush:",t)}).finally(()=>{this.Mn=null,this.Cn()})}else this.Bn()}}processLimitFlush(){!this.In.hasCompletelyRecoveredFromBackoff()||this.Mn||(this.Mn=this.zn().catch(t=>{u.Log.error("Error during limit flush",t)}).finally(()=>{this.Mn=null,this.Cn()}))}zn(){return n(this,void 0,void 0,function*(){const t=yield this.Ln(r.FlushType.Limit);if(t)for(;this.In.hasCompletelyRecoveredFromBackoff()&&this.containsAtLeastOneFullBatch();){const t=yield this.Ln(r.FlushType.Limit);if(!t)break}})}Cn(){var t;this.An(),this.$i||(t=Math.max(0,this.In.getTimeUntilNextFlush()),this.Yi=setTimeout(()=>{this.Yi=null,d.StatsigSession.checkForIdleSession(this.j),this.Pn()},t),t=Math.max(0,this.In.getTimeTillMaxInterval()),this.Zi=setTimeout(()=>{this.Zi=null,d.StatsigSession.checkForIdleSession(this.j),this.Pn()},t))}An(){null!==this.Yi&&(clearTimeout(this.Yi),this.Yi=null),null!==this.Zi&&(clearTimeout(this.Zi),this.Zi=null)}Bn(){var t;this.An(),this.$i||(this.Yi=setTimeout(()=>{this.Yi=null,d.StatsigSession.checkForIdleSession(this.j),this.Pn()},s.EventRetryConstants.TICK_INTERVAL_MS),t=Math.max(0,this.In.getTimeTillMaxInterval()),this.Zi=setTimeout(()=>{this.Zi=null,d.StatsigSession.checkForIdleSession(this.j),this.Pn()},t))}Ln(e){return n(this,void 0,void 0,function*(){this.Rn(e);var t=this.Ki.takeNextBatch();return!!t&&this.Un(t,e)})}Un(e,i){return n(this,void 0,void 0,function*(){var t;return this.jt!==v.LoggingEnabledOption.always&&(0,a.Mt)()||(t=yield this.Fn.sendBatch(e)).success?(this.In.adjustForSuccess(),!0):(this.In.adjustForFailure(),this.Kn(e,i,t.statusCode),!1)})}Rn(t){this.Tn();var e=this.convertPendingEventsToBatches();0<e&&(u.Log.warn(`Dropped ${e} events`),this.te.logDroppedEvents(e,"Batch queue limit reached during batching",{loggingInterval:this.In.getCurrentIntervalMs(),batchSize:this.Ki.batchSize(),maxPendingBatches:s.EventRetryConstants.MAX_PENDING_BATCHES,flushType:t,retries:"dropped before batching"}))}containsAtLeastOneFullBatch(){return this.zi.hasEventsForFullBatch()||this.Ki.hasFullBatch()}convertPendingEventsToBatches(){var t;return this.zi.isEmpty()?0:(t=this.zi.takeAll(),this.Ki.createBatches(t))}Kn(t,e,i){var n;e===r.FlushType.Shutdown?(u.Log.warn(e+" flush failed during shutdown. "+t.events.length+" event(s) will be saved to storage for retry in next session."),this.qn(t.events)):o.RETRYABLE_CODES.has(i)?t.attempts>=s.EventRetryConstants.MAX_RETRY_ATTEMPTS?(u.Log.warn(`${e} flush failed after ${t.attempts} attempt(s). `+t.events.length+" event(s) will be dropped."),this.te.logEventRequestFailure(t.events.length,"max retry attempts exceeded",e,i,t.attempts)):(t.incrementAttempts(),0<(n=this.Ki.requeueBatch(t))&&(u.Log.warn(`Failed to requeue batch : dropped ${n} events due to full queue`),this.te.logDroppedEvents(n,"Batch queue limit reached during requeue",{loggingInterval:this.In.getCurrentIntervalMs(),batchSize:this.Ki.batchSize(),maxPendingBatches:s.EventRetryConstants.MAX_PENDING_BATCHES,flushType:e,retries:t.attempts}))):(u.Log.warn(`${e} flush failed after ${t.attempts} attempt(s). `+t.events.length+" event(s) will be dropped. Non-retryable error: "+i),this.te.logEventRequestFailure(t.events.length,"non-retryable error",e,i,t.attempts))}loadAndRetryShutdownFailedEvents(){return n(this,void 0,void 0,function*(){var t=this.o();try{f.Storage.isReady()||(yield f.Storage.isReadyResolver());var e=this.$n(t);0!==e.length&&(u.Log.debug(`Loading ${e.length} failed shutdown event(s) from storage for retry`),f.Storage.removeItem(t),e.forEach(t=>{this.addEvent(t)}),yield this.processManualFlush())}catch(t){u.Log.warn("Failed to load and retry failed shutdown events:",t)}})}o(){return this.Gi||(this.Gi="statsig.failed_shutdown_events."+(0,l.h)(this.j)),this.Gi}qn(e){var i=this.o();try{let t=[...this.$n(i),...e];t.length>s.EventRetryConstants.MAX_LOCAL_STORAGE&&(t=t.slice(-s.EventRetryConstants.MAX_LOCAL_STORAGE)),(0,f.B)(i,t),u.Log.debug(`Saved ${e.length} failed shutdown event(s) to storage (total stored: ${t.length})`)}catch(t){u.Log.warn("Unable to save failed shutdown events to storage:",t)}}$n(t){try{var e=(0,f.K)(t);return Array.isArray(e)?e:[]}catch(t){return[]}}}},8153:(t,e)=>{$Q(e),e.FlushInterval=void 0;e.FlushInterval=class{constructor(){this.Gn=1e3,this.Vn=Date.now()}getCurrentIntervalMs(){return this.Gn}markFlushAttempt(){this.Vn=Date.now()}getTimeSinceLastAttempt(){return Date.now()-this.Vn}hasReachedMaxInterval(){return 6e4<=this.getTimeSinceLastAttempt()}getTimeTillMaxInterval(){return 6e4-this.getTimeSinceLastAttempt()}hasCompletelyRecoveredFromBackoff(){return this.Gn<=1e3}adjustForSuccess(){var t=this.Gn;1e3!==t&&(this.Gn=Math.max(1e3,Math.floor(t/2)))}adjustForFailure(){var t=this.Gn;this.Gn=Math.min(6e4,2*t)}getTimeUntilNextFlush(){return this.getCurrentIntervalMs()-this.getTimeSinceLastAttempt()}}},323:(t,e)=>{$Q(e),e.FlushType=void 0,e.FlushType={ScheduledMaxTime:"scheduled:max_time",ScheduledFullBatch:"scheduled:full_batch",Limit:"limit",Manual:"manual",Shutdown:"shutdown"}},1406:(t,r,e)=>{$Q2(r,"__esModule",{value:!0}),r.Bt=r.$t=r.h=void 0;const l=e(6634);r.h=e=>{let i=0;for(let t=0;t<e.length;t++){var n=e.charCodeAt(t);i=(i<<5)-i+n,i&=i}return String(i>>>0)},r.$t=(t,e)=>(0,r.h)(JSON.stringify((0,r.Bt)(t,e)));r.Bt=(i,n)=>{if(null==i)return null;var t=Object.keys(i).sort();const s={};return t.forEach(t=>{var e=i[t];0===n||"object"!==(0,l.Vt)(e)?s[t]=e:s[t]=(0,r.Bt)(e,null!=n?n-1:n)}),s}},1333:(t,e)=>{$Q(e)},7512:(t,e)=>{$Q(e),e.Log=e.LogLevel=void 0;function i(t){return t.unshift("[Statsig]"),t}e.LogLevel={None:0,Error:1,Warn:2,Info:3,Debug:4};class n{static info(...t){n.level>=e.LogLevel.Info&&console.info(" INFO ",...i(t))}static debug(...t){n.level>=e.LogLevel.Debug&&console.debug(" DEBUG ",...i(t))}static warn(...t){n.level>=e.LogLevel.Warn&&console.warn(" WARN ",...i(t))}static error(...t){n.level>=e.LogLevel.Error&&console.error(" ERROR ",...i(t))}}(e.Log=n).level=e.LogLevel.Warn},7787:(t,e)=>{$Q(e),e.createMemoKey=e.MemoPrefix=void 0,e.MemoPrefix={Gt:"g",Jt:"c",Wt:"e",Yt:"cl",Xt:"l",Ht:"p"};const r=new Set([]),l=new Set(["userPersistedValues"]);e.createMemoKey=function(t,e,i){let n=t+"|"+e;if(i)for(const s of Object.keys(i)){if(l.has(s))return;r.has(s)?n+=`|${s}=true`:n+=`|${s}=`+i[s]}return n}},7410:(t,e)=>{$Q(e),e.NetworkParam=e.NetworkDefault=e.Endpoint=void 0,e.Endpoint={Qt:"initialize",kt:"rgstr",Zt:"download_config_specs"},e.NetworkDefault={[e.Endpoint.kt]:"https://prodregistryv2.org/v1",[e.Endpoint.Qt]:"https://featureassets.org/v1",[e.Endpoint.Zt]:"https://api.statsigcdn.com/v1"},e.NetworkParam={EventCount:"ec",SdkKey:"k",SdkType:"st",SdkVersion:"sv",Time:"t",SessionID:"sid",StatsigEncoded:"se",IsGzipped:"gz"}},7023:function(t,y,e){var m=this&&this.__awaiter||$A();$Q2(y,"__esModule",{value:!0}),y.NetworkCore=y.RETRYABLE_CODES=void 0,e(1845);const v=e(1845),O=e(8962),j=e(7512),S=e(7410),i=e(308),f=e(3091),l=e(5902),s=e(6830),u=e(4143),o=e(9122),w=e(2636),a=e(8e3),_=e(586),E=e(2397),k=500,x=3e4;y.RETRYABLE_CODES=new Set([408,500,502,503,504,522,524,599]);y.NetworkCore=class{constructor(t,e){this.st=e,this.te=null,this.ee=1e4,this.ie={},this.O={},this.ne={},this.se=null,t&&(this.O=t),this.O.networkConfig&&(this.ie=this.O.networkConfig),this.ie.networkTimeoutMs&&(this.ee=this.ie.networkTimeoutMs),this.re=new i.NetworkFallbackResolver(this.O),this.setLogEventCompressionMode(this.le(t))}setLogEventCompressionMode(t){this.O.logEventCompressionMode=t}setErrorBoundary(t){this.te=t,this.te.wrap(this),this.te.wrap(this.re),this.re.setErrorBoundary(t)}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon}getLastUsedInitUrlAndReset(){var t=this.se;return this.se=null,t}beacon(t){var e,i;return!!D(t)&&(t=this.oe("POST",t),e=this.ue(t),(i=navigator).sendBeacon.bind(i)(e,t.body))}post(e){return m(this,void 0,void 0,function*(){var t=this.oe("POST",e);return this.ae(t),yield this.ce(t),this.he(t)})}get(t){t=this.oe("GET",t);return this.he(t)}he(b){return m(this,void 0,void 0,function*(){var e;if(!D(b))return null;if(this.ie.preventAllNetworkTraffic)return null;var{method:n,body:s,retries:i,attempt:r}=b,l=b.urlConfig.endpoint;if(this.de(l))return j.Log.warn(`Request to ${l} was blocked because you are making requests too frequently.`),null;r=null!=r?r:1;let u=!1;var o=this.ue(b);let a=null;var c,h=(0,E.Ft)();try{var t,d,v,f={method:n,body:s,headers:$P({},b.headers),priority:b.priority,keepalive:h},_=(c=r,(p=b).urlConfig.endpoint===S.Endpoint.Qt&&O.Diagnostics.W(p.sdkKey,{attempt:c}),this.ne[l]),g=(_&&(_.lastRequestTime=Date.now(),this.ne[l]=_),null!=(e=this.ie.networkOverrideFunc)?e:fetch);let i;if((a=yield Promise.race([g(o,f).finally(()=>clearTimeout(i)),new Promise((t,e)=>{i=setTimeout(()=>{u=!0,e(new Error(`Timeout of ${this.ee}ms expired.`))},this.ee)})])).ok)return v=yield a.text(),M(b,a,r,v),this.re.tryBumpExpiryTime(b.sdkKey,b.urlConfig),{body:v,code:a.status};throw t=yield a.text().catch(()=>"No Text"),(d=new Error(`NetworkError: ${o} `+t)).name="NetworkError",d}catch(t){var s=function(t){if("string"==typeof t)return t;if(t instanceof Error)return t.name+": "+t.message;return"Unknown Error"}(t),h=function(t,e){t=t.includes("Timeout");return t||e}(null!=s?s:"",u),p=(M(b,a,r,"",t),yield this.re.tryFetchUpdatedFallbackInfo(b.sdkKey,b.urlConfig,s,h));return(p&&(b.fallbackUrl=this.re.getActiveFallbackUrl(b.sdkKey,b.urlConfig)),!i||i<r||!y.RETRYABLE_CODES.has(null!=(c=null===a||void 0===a?void 0:a.status)?c:500))?(null!=(l=this.st)&&l.call(this,{name:"error",error:t,tag:w.ErrorTag.NetworkError,requestArgs:b}),_=`A networking error occurred during ${n} request to ${o}.`,j.Log.error(_,s,t),null!=(e=this.te)&&e.attachErrorIfNoneExists(_),b.preserveFailedStatusCode&&null!=a?{body:null,code:a.status}:null):(yield function(e){return m(this,void 0,void 0,function*(){yield new Promise(t=>setTimeout(t,Math.min(k*(e*e),x)))})}(r),this.he($P($P({},b),{retries:i,attempt:r+1})))}})}le(t){let e=null==t?void 0:t.logEventCompressionMode;return e=(e=e||!0!==(null==t?void 0:t.disableCompression)?e:_.LogEventCompressionMode.Disabled)||_.LogEventCompressionMode.Enabled}de(t){var e=Date.now(),i=null!=(i=this.ne[t])?i:{count:0,lastRequestTime:e},n=e-i.lastRequestTime,n=Math.floor(.05*n);return i.count=Math.max(0,i.count-n),50<=i.count||(i.count+=1,i.lastRequestTime=e,this.ne[t]=i,!1)}ue(t){var e=null!=(e=t.fallbackUrl)?e:t.urlConfig.getUrl();t.urlConfig.endpoint!==S.Endpoint.Qt&&t.urlConfig.endpoint!==S.Endpoint.Zt||(this.se=e);const i=$P({[S.NetworkParam.SdkKey]:t.sdkKey,[S.NetworkParam.SdkType]:l.SDKType.ct(t.sdkKey),[S.NetworkParam.SdkVersion]:a.SDK_VERSION,[S.NetworkParam.Time]:String(Date.now()),[S.NetworkParam.SessionID]:u.SessionID.get(t.sdkKey)},t.params);t=Object.keys(i).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(i[t])).join("&");return e+(t?"?"+t:"")}ae(e){var t,i=(0,s.ve)(),n=e.body;if(e.isStatsigEncodable&&!this.O.disableStatsigEncoding&&"string"==typeof n&&null==(0,v.i)("no-encode")&&null!=i&&i.btoa)try{e.body=i.btoa(n).split("").reverse().join(""),e.params=$P($P({},null!=(t=e.params)?t:{}),{[S.NetworkParam.StatsigEncoded]:"1"})}catch(t){j.Log.warn("Request encoding failed for "+e.urlConfig.getUrl(),t)}}ce(d){return m(this,void 0,void 0,function*(){var e,i=d.body;if("string"==typeof i&&function(t,e){if(!t.isCompressable)return;if(null!=(0,v.i)("no-compress")||"undefined"==typeof CompressionStream||"undefined"==typeof TextEncoder)return;var i=null!=t.urlConfig.customUrl||null!=t.urlConfig.fallbackUrls,n=!0===f.SDKFlags.get(t.sdkKey,"enable_log_event_compression");switch(e.logEventCompressionMode){case _.LogEventCompressionMode.Disabled:return;case _.LogEventCompressionMode.Enabled:return i&&!n?void 0:1;case _.LogEventCompressionMode.Forced:return 1;default:return}}(d,this.O))try{for(var n,s=(new TextEncoder).encode(i),r=new CompressionStream("gzip"),l=r.writable.getWriter(),u=(l.write(s).catch(j.Log.error),l.close().catch(j.Log.error),r.readable.getReader()),o=[];!(n=yield u.read()).done;)o.push(n.value);var a=o.reduce((t,e)=>t+e.length,0),c=new Uint8Array(a);let t=0;for(const h of o)c.set(h,t),t+=h.length;d.body=c,d.params=$P($P({},null!=(e=d.params)?e:{}),{[S.NetworkParam.IsGzipped]:"1"})}catch(t){j.Log.warn("Request compression failed for "+d.urlConfig.getUrl(),t)}})}oe(t,e){var i=this.re.getActiveFallbackUrl(e.sdkKey,e.urlConfig),t=$P($P({},e),{method:t,fallbackUrl:i});return"data"in e&&n(t,e.data),t}};const D=t=>!!t.sdkKey||(j.Log.warn("Unable to make request without an SDK key"),!1),n=(t,e)=>{var{sdkKey:i,fallbackUrl:n}=t,s=o.StableID.get(i),r=u.SessionID.get(i),i=l.SDKType.ct(i);t.body=JSON.stringify($P($P({},e),{statsigMetadata:$P($P({},a.StatsigMetadataProvider.get()),{stableID:s,sessionID:r,sdkType:i,fallbackUrl:n})}))};function M(t,e,i,n,s){t.urlConfig.endpoint===S.Endpoint.Qt&&O.Diagnostics.Y(t.sdkKey,O.Diagnostics.et(e,i,n,s))}},308:function(t,e,i){var u=this&&this.__awaiter||$A();$Q(e),e.fe=e.NetworkFallbackResolver=void 0;const l=i(8809),n=i(1406),r=i(7512),o=i(4534);function a(t,e){t=null!=(t=null==t?void 0:t.toLowerCase())?t:"";return e||t.includes("uncaught exception")||t.includes("failed to fetch")||t.includes("networkerror when attempting to fetch resource")}function c(t){return"statsig.network_fallback."+(0,n.h)(t)}function h(t,e){t=c(t);e&&0!==Object.keys(e).length?o.Storage.setItem(t,JSON.stringify(e)):o.Storage.removeItem(t)}e.NetworkFallbackResolver=class{constructor(t){this.ge=null,this.te=null,this._e={},this.pe=null==(t=t.networkConfig)?void 0:t.networkOverrideFunc}setErrorBoundary(t){this.te=t}tryBumpExpiryTime(t,e){var i=null==(i=this.ge)?void 0:i[e.endpoint];i&&(i.expiryTime=Date.now()+6048e5,h(t,$P($P({},this.ge),{[e.endpoint]:i})))}getActiveFallbackUrl(t,e){var i;if(null!=e.customUrl&&null!=e.fallbackUrls)return null;let n=this.ge;null==n&&(n=null!=(s=function(t){t=c(t),t=o.Storage.getItem(t);if(!t)return null;try{return JSON.parse(t)}catch(t){return r.Log.error("Failed to parse FallbackInfo"),null}}(t))?s:{},this.ge=n);var s=n[e.endpoint];return!s||Date.now()>(null!=(i=s.expiryTime)?i:0)||e.getChecksum()!==s.urlConfigChecksum?(delete n[e.endpoint],this.ge=n,h(t,this.ge),null):s.url||null}tryFetchUpdatedFallbackInfo(n,s,r,l){return u(this,void 0,void 0,function*(){var e,t,i;try{return a(r,l)?(t=null==s.customUrl&&null==s.fallbackUrls?yield this.be(s):s.fallbackUrls,!!(i=this.ye(null==(e=this.ge)?void 0:e[s.endpoint],t))&&(this.me(n,s,i),!0)):!1}catch(t){return null!=(e=this.te)&&e.logError("tryFetchUpdatedFallbackInfo",t),!1}})}me(t,e,i){var i={urlConfigChecksum:e.getChecksum(),url:i,expiryTime:Date.now()+6048e5,previous:[]},e=e.endpoint,n=null==(n=this.ge)?void 0:n[e],n=(n&&i.previous.push(...n.previous),10<i.previous.length&&(i.previous=[]),null==(n=null==(n=this.ge)?void 0:n[e])?void 0:n.url);null!=n&&i.previous.push(n),this.ge=$P($P({},this.ge),{[e]:i}),h(t,this.ge)}be(r){return u(this,void 0,void 0,function*(){var t=this._e[r.endpoint];if(t&&Date.now()<t)return null;this._e[r.endpoint]=Date.now()+144e5;var e=[],t=yield(0,l.nt)(null!=(t=this.pe)?t:fetch),i=function(t){try{return new URL(t).pathname}catch(t){return null}}(r.defaultUrl);for(const s of t)if(s.startsWith(r.endpointDnsKey+"=")){var n=s.split("=");if(1<n.length){let t=n[1];t.endsWith("/")&&(t=t.slice(0,-1)),e.push("https://"+t+i)}}return e})}ye(t,e){var i;if(null==e)return null;var n=new Set(null!=(i=null==t?void 0:t.previous)?i:[]),s=null==t?void 0:t.url;let r=null;for(const u of e){var l=u.endsWith("/")?u.slice(0,-1):u;if(!n.has(u)&&l!==s){r=l;break}}return r}},e.fe=a},1405:(t,e)=>{$Q(e)},1361:(t,e)=>{$Q(e)},1228:(t,e,i)=>{$Q(e),e.PendingEvents=void 0;const n=i(7512);e.PendingEvents=class{constructor(t){this.zi=[],this.Ci=t}addToPendingEventsQueue(t){this.zi.push(t),n.Log.debug("Enqueued Event:",t)}hasEventsForFullBatch(){return this.zi.length>=this.Ci}takeAll(){var t=this.zi;return this.zi=[],t}isEmpty(){return 0===this.zi.length}}},3091:(t,e)=>{$Q(e),e.SDKFlags=void 0;const i={};e.SDKFlags={setFlags:(t,e)=>{i[t]=e},get:(t,e)=>{return null!=(t=null==(t=i[t])?void 0:t[e])&&t}}},5902:(t,e)=>{$Q(e),e.SDKType=void 0;const i={};let n;e.SDKType={ct:t=>{return(null!=(t=i[t])?t:"js-mono")+(null!==n&&void 0!==n?n:"")},Oe(t,e){i[t]=e},je(t){n&&"-react"!==n||(n="-"+t)}}},6830:(t,n,e)=>{$Q2(n,"__esModule",{value:!0}),n.Bi=n.Se=n.Kt=n.we=n.ke=n.Mt=n.Ee=n.ve=void 0;const i=e(7512);n.ve=()=>"undefined"!=typeof window?window:null,n.Ee=()=>{var t=(0,n.ve)();return null!=(t=null==t?void 0:t.document)?t:null},n.Mt=()=>{var t;return null===(0,n.Ee)()&&(t="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,"string"==typeof EdgeRuntime||t)},n.ke=(t,e)=>{var i=(0,n.ve)();"function"==typeof(null==i?void 0:i.addEventListener)&&i.addEventListener(t,e)},n.we=(t,e)=>{var i=(0,n.Ee)();"function"==typeof(null==i?void 0:i.addEventListener)&&i.addEventListener(t,e)},n.Kt=()=>{var t;try{return null==(t=(0,n.ve)())?void 0:t.location.href.split(/[?#]/)[0]}catch(t){}},n.Se=()=>{var t=(0,n.ve)();return t&&"onpagehide"in t?"pagehide":"beforeunload"};n.Bi=(e,t)=>{try{return JSON.parse(JSON.stringify(t))}catch(t){return i.Log.error("Failed to clone object "+e),null}}},4143:(t,e,i)=>{$Q(e),e.StatsigSession=e.SessionID=void 0;const n=i(2137),s=i(7512),r=i(4534),l=i(8023);i=i(2397);const u=18e5,o=144e5,a=15e3,c={};function h(t){var e,i=t.data,i=(e=[i["lastUpdate"]][0],Date.now()-e>u||(e=[i["startTime"]][0],Date.now()-e>o));return i&&(t.data=f(),null!=(e=null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.instance(t.sdkKey)))&&e.$emt({name:"session_expired"}),i}function d(t){return"statsig.session_id."+(0,n.o)(t)}function v(t){try{(0,r.B)(t.storageKey,t.data),t.lastPersistedAt=Date.now()}catch(t){s.Log.warn("Failed to save SessionID")}}function f(){return{sessionID:(0,l.getUUID)(),startTime:Date.now(),lastUpdate:Date.now()}}(0,i.xt)(t=>{"background"===t&&Object.values(c).forEach(t=>v(t))}),e.SessionID={get:t=>e.StatsigSession.get(t).data.sessionID},e.StatsigSession={get:(t,e=!0)=>{null==c[t]&&(c[t]=function(t){var e=d(t),i=function(t){t=(0,r.K)(t);return t}(e);if(i&&i.sessionID&&i.startTime&&i.lastUpdate)return{data:i,sdkKey:t,lastPersistedAt:0,storageKey:e};return{data:f(),sdkKey:t,lastPersistedAt:0,storageKey:e}}(t));var t=c[t],i=Date.now(),n=h(t);n?v(t):e&&(t.data.lastUpdate=i,n=t,(e=Date.now())-n.lastPersistedAt>a)&&v(n);return t},overrideInitialSessionID:(t,e)=>{var i=Date.now(),t={data:{sessionID:t,startTime:i,lastUpdate:i},sdkKey:e,lastPersistedAt:Date.now(),storageKey:d(e)};v(t),c[e]=t},checkForIdleSession:t=>{t=c[t];t&&h(t)&&v(t)}}},2176:(t,u)=>{$Q2(u,"__esModule",{value:!0}),u.De=void 0;u.De=(e,i)=>{let n=0;var s=Object.keys(e);for(let t=0;t<s.length;t++){var r=s[t],l=e[r];if((n=(n+=r.length)+("object"==typeof l&&null!==l?(0,u.De)(l,i)+2:String(l).length+1))>=i)return n}return n}},9122:(t,e,i)=>{$Q(e),e.getCookieName=e.StableID=void 0;const n=i(2137),s=i(7512),r=i(6830),l=i(4534),u=i(8023),o={},a={},c={};function h(t){return"statsig.stable_id."+(0,n.o)(t)}function d(t,e){e=h(e);try{(0,l.B)(e,t)}catch(t){s.Log.warn("Failed to save StableID to storage")}}function v(t,e){var i;a[e]&&null!=(0,r.Ee)()&&((i=new Date).setFullYear(i.getFullYear()+1),document.cookie=`${f(e)}=${encodeURIComponent(t)}; expires=${i.toUTCString()}; path=/`)}function f(t){return"statsig.stable_id."+(0,n.o)(t)}e.StableID={cookiesEnabled:!1,randomID:Math.random().toString(36),get:t=>{if(c[t])return null;if(null!=o[t])return o[t];let e=null;return null!=(e=function(t){if(a[t]&&null!=(0,r.Ee)())for(const n of document.cookie.split(";")){var[e,i]=n.trim().split("=");if(e===f(t))return decodeURIComponent(i)}return null}(t))?d(o[t]=e,t):(d(e=null==(e=function(t){t=h(t);return(0,l.K)(t)}(t))?(0,u.getUUID)():e,t),v(e,t),o[t]=e),e},setOverride:(t,e)=>{d(o[e]=t,e),v(t,e)},Ie:(t,e)=>{a[t]=e},Me:(t,e)=>{c[t]=e}},e.getCookieName=f},1375:function(t,e,i){var n=this&&this.__awaiter||$A();$Q(e),e.StatsigClientBase=void 0,i(1845);const l=i(1845),u=i(5542),o=i(7770),a=i(7512),r=i(7787),c=i(6830),h=i(4143),d=i(9122),s=i(586),v=i(4534);e.StatsigClientBase=class{constructor(t,e,i,n){this.loadingStatus="Uninitialized",this.xe=null,this.Te={};var s,r=this.$emt.bind(this);null!=(null==n?void 0:n.logLevel)&&(a.Log.level=n.logLevel),null!=n&&n.disableStorage&&v.Storage.Me(!0),null!=n&&n.initialSessionID&&h.StatsigSession.overrideInitialSessionID(n.initialSessionID,t),null!=n&&n.storageProvider&&v.Storage.Ne(n.storageProvider),null!=n&&n.enableCookies&&d.StableID.Ie(t,n.enableCookies),null!=n&&n.disableStableID&&d.StableID.Me(t,!0),this.j=t,this.O=null!=n?n:{},this.Ce={},this.overrideAdapter=null!=(s=null==n?void 0:n.overrideAdapter)?s:null,this.te=new u.ErrorBoundary(t,n,r),this.Re=new o.EventLogger(t,r,i,n,this.te),this.te.wrap(this),this.te.wrap(e),this.te.wrap(this.Re),i.setErrorBoundary(this.te),this.dataAdapter=e,this.dataAdapter.attach(t,n,i),this.storageProvider=v.Storage,null!=(e=null==(r=null==(s=this.overrideAdapter)?void 0:s.loadFromStorage)?void 0:r.call(s))&&e.catch(t=>this.te.logError("OA::loadFromStorage",t)),this.Ue(),n=t,i=this,(0,c.Mt)()||(r=(0,l.l)(),s=null!=(s=r.instances)?s:{},i=i,null!=s[n]&&a.Log.warn("Creating multiple Statsig clients with the same SDK key can lead to unexpected behavior. Multi-instance support requires different SDK keys."),s[n]=i,r.firstInstance||(r.firstInstance=i),r.instances=s,__STATSIG__=r)}updateRuntimeOptions(t){t.loggingEnabled?(this.O.loggingEnabled=t.loggingEnabled,this.Re.setLoggingEnabled(t.loggingEnabled)):null!=t.disableLogging&&(this.O.disableLogging=t.disableLogging,this.Re.setLoggingEnabled(t.disableLogging?"disabled":"browser-only")),null!=t.disableStorage&&(this.O.disableStorage=t.disableStorage,v.Storage.Me(t.disableStorage)),null!=t.enableCookies&&(this.O.enableCookies=t.enableCookies,d.StableID.Ie(this.j,t.enableCookies)),t.logEventCompressionMode?this.Re.setLogEventCompressionMode(t.logEventCompressionMode):t.disableCompression&&this.Re.setLogEventCompressionMode(s.LogEventCompressionMode.Disabled)}flush(){return this.Re.flush()}shutdown(){return n(this,void 0,void 0,function*(){this.$emt({name:"pre_shutdown"}),this.Ae("Uninitialized",null),this.xe=null,yield this.Re.stop()})}on(t,e){this.Te[t]||(this.Te[t]=[]),this.Te[t].push(e)}off(t,e){this.Te[t]&&-1!==(e=this.Te[t].indexOf(e))&&this.Te[t].splice(e,1)}$on(t,e){e.__isInternal=!0,this.on(t,e)}$emt(i){var t;const e=e=>{try{e(i)}catch(t){!0===e.__isInternal?this.te.logError("__emit:"+i.name,t):a.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",i)}};this.Te[i.name]&&this.Te[i.name].forEach(t=>e(t)),null!=(t=this.Te["*"])&&t.forEach(e)}Ae(t,e){this.loadingStatus=t,this.Ce={},this.$emt({name:"values_updated",status:t,values:e})}Fe(t,e,i){!0===(null==i?void 0:i.disableExposureLog)?this.Re.incrementNonExposureCount(t):this.Re.enqueue(e)}Pe(n,s){return(t,e)=>{var i;return!this.O.disableEvaluationMemoization&&(i=(0,r.createMemoKey)(n,t,e))?(i in this.Ce||(3e3<=Object.keys(this.Ce).length&&(this.Ce={}),this.Ce[i]=s(t,e)),this.Ce[i]):s(t,e)}}}},2636:(t,e)=>{$Q(e),e.ErrorTag=void 0,e.ErrorTag={NetworkError:"NetworkError"}},3206:(t,e)=>{$Q(e),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},1637:(t,e)=>{$Q(e),e.Le=e.ze=e.qe=e.Ke=e.Ut=void 0;const r="statsig::config_exposure",l="statsig::gate_exposure",a="statsig::layer_exposure",c=(t,e,i,n,s)=>(i.bootstrapMetadata&&(n.bootstrapMetadata=i.bootstrapMetadata),{eventName:t,user:e,value:null,metadata:u(i,n),secondaryExposures:s,time:Date.now()});e.Ut=({eventName:t})=>t===l||t===r||t===a;function h(t,e){return t.map(t=>"string"==typeof t?(null!=e?e:{})[t]:t).filter(t=>null!=t)}e.Ke=(t,e,i)=>{var n,s={gate:e.name,gateValue:String(e.value),ruleID:e.ruleID};return null!=(null==(n=e.__evaluation)?void 0:n.version)&&(s.configVersion=e.__evaluation.version),c(l,t,e.details,s,h(null!=(t=null==(n=e.__evaluation)?void 0:n.secondary_exposures)?t:[],i))},e.qe=h;e.ze=(t,e,i)=>{var n,s={config:e.name,ruleID:e.ruleID};return null!=(null==(n=e.__evaluation)?void 0:n.version)&&(s.configVersion=e.__evaluation.version),null!=(null==(n=e.__evaluation)?void 0:n.passed)&&(s.rulePassed=String(e.__evaluation.passed)),c(r,t,e.details,s,h(null!=(t=null==(n=e.__evaluation)?void 0:n.secondary_exposures)?t:[],i))};e.Le=(t,e,i,n)=>{var s=e.__evaluation,r=!0===(null==(r=null==s?void 0:s.explicit_parameters)?void 0:r.includes(i));let l="",u=null!=(o=null==s?void 0:s.undelegated_secondary_exposures)?o:[];r&&(l=null!=(o=s.allocated_experiment_name)?o:"",u=null!=(o=s.secondary_exposures)?o:[]);var o=null==(s=e.__evaluation)?void 0:s.parameter_rule_ids,o={config:e.name,parameterName:i,ruleID:null!=(s=null==o?void 0:o[i])?s:e.ruleID,allocatedExperiment:l,isExplicitParameter:String(r)};return null!=(null==(i=e.__evaluation)?void 0:i.version)&&(o.configVersion=e.__evaluation.version),c(a,t,e.details,o,h(u,n))};const u=(t,e)=>(e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut)),t.receivedAt&&(e.receivedAt=String(t.receivedAt)),e)},8e3:(t,e)=>{$Q(e),e.StatsigMetadataProvider=e.SDK_VERSION=void 0,e.SDK_VERSION="3.32.2";let i={sdkVersion:e.SDK_VERSION,sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>i,add:t=>{i=$P($P({},i),t)}}},586:(t,e)=>{$Q(e),e.LoggingEnabledOption=e.LogEventCompressionMode=void 0,e.LogEventCompressionMode={Disabled:"d",Enabled:"e",Forced:"f"},e.LoggingEnabledOption={disabled:"disabled",browserOnly:"browser-only",always:"always"}},1098:(t,e)=>{$Q(e)},2059:(t,e,i)=>{$Q(e),e.Be=e.$e=e.Ve=e.Ge=e.Je=e.We=void 0;const l=i(7512),u=i(6634);function s(t,e,i,n){return{name:t,details:e,ruleID:null!=(t=null==i?void 0:i.rule_id)?t:"",__evaluation:i,value:n}}function n(t,e,i){var n=null!=(n=null==i?void 0:i.value)?n:{};return $P($P({},s(t,e,i,n)),{idType:null!=(e=null==i?void 0:i.id_type)?e:null,get:r(t,null==i?void 0:i.value)})}function r(n,s,r){return(t,e)=>{var i=null!=(i=null==s?void 0:s[t])?i:null;return null==i?null!=e?e:null:null==e||(0,u.Ye)(i,e)?(null!=r&&r(t),i):(l.Log.warn(`Parameter type mismatch. '${n}.${t}' was found to be type '${typeof i}' but fallback/return type is '${typeof e}'. See https://docs.statsig.com/client/javascript-sdk/#typed-getters`),null!=e?e:null)}}e.We=function(t,e,i){return $P($P({},s(t,e,i,!0===(null==i?void 0:i.value))),{idType:null!=(t=null==i?void 0:i.id_type)?t:null})},e.Je=n,e.Ge=function(t,e,i){return t=n(t,e,i),$P($P({},t),{groupName:null!=(e=null==i?void 0:i.group_name)?e:null})},e.Ve=function(t,e,i,n){return $P($P({},s(t,e,i,void 0)),{get:r(t,null==i?void 0:i.value,n),groupName:null!=(e=null==i?void 0:i.group_name)?e:null,__value:null!=(t=null==i?void 0:i.value)?t:{}})},e.$e=function(t,e,i,n){return $P($P($P({},t),e),{get:r(t.name,i,n)})},e.Be=r},1812:(t,e)=>{$Q(e)},3932:(t,e)=>{$Q(e),e.UPDATE_DETAIL_ERROR_MESSAGES=e.createUpdateDetails=void 0;e.createUpdateDetails=(t,e,i,n,s,r)=>({duration:i,source:e,success:t,error:n,sourceUrl:s,warnings:r}),e.UPDATE_DETAIL_ERROR_MESSAGES={NO_NETWORK_DATA:"No data was returned from the network. This may be due to a network timeout if a timeout value was specified in the options or ad blocker error."}},8578:(t,e,i)=>{$Q(e),e.Jn=e._=e.D=void 0;const n=i(1406),s=i(7512),r=i(6830);e.D=function(t,e,i){return null==(t=(0,r.Bi)("StatsigUser",t))?(s.Log.error("Failed to clone user"),{statsigEnvironment:void 0}):(null!=e&&null!=e.environment?t.statsigEnvironment=e.environment:null!=i&&(t.statsigEnvironment={tier:i}),t)},e._=function(t){return t?(0,n.$t)(t):null},e.Jn=function(t,e){var i,n;return"string"==typeof e&&"userid"!==(n=e.toLowerCase())?null!=(i=null==(i=t.customIDs)?void 0:i[e])?i:null==(e=t.customIDs)?void 0:e[n]:t.userID}},4534:(t,i,e)=>{$Q2(i,"__esModule",{value:!0}),i.B=i.K=i.Storage=void 0;const n=e(7512);e=e(6830);const s={},r={isReady:()=>!0,isReadyResolver:()=>null,getProviderName:()=>"InMemory",getItem:t=>s[t]||null,setItem:(t,e)=>{s[t]=e},removeItem:t=>{delete s[t]},getAllKeys:()=>Object.keys(s)};let l=null;try{const c=(0,e.ve)();c&&c.localStorage&&"function"==typeof c.localStorage.getItem&&(l={isReady:()=>!0,isReadyResolver:()=>null,getProviderName:()=>"LocalStorage",getItem:t=>c.localStorage.getItem(t),setItem:(t,e)=>c.localStorage.setItem(t,e),removeItem:t=>c.localStorage.removeItem(t),getAllKeys:()=>Object.keys(c.localStorage)})}catch(t){n.Log.warn("Failed to setup localStorageProvider.")}let u=null!==l&&void 0!==l?l:r,o=u;function a(t){try{return t()}catch(t){if(t instanceof Error&&"SecurityError"===t.name)return i.Storage.Ne(r),null;throw t}}i.Storage={isReady:()=>o.isReady(),isReadyResolver:()=>o.isReadyResolver(),getProviderName:()=>o.getProviderName(),getItem:t=>a(()=>o.getItem(t)),setItem:(t,e)=>a(()=>o.setItem(t,e)),removeItem:t=>o.removeItem(t),getAllKeys:()=>o.getAllKeys(),Ne:t=>{u=t,o=t},Me:t=>{o=t?r:u}},i.K=function(e){var t=i.Storage.getItem(e);try{return JSON.parse(null!=t?t:"null")}catch(t){return n.Log.error(`Failed to parse value for key "${e}"`),null}},i.B=function(t,e){i.Storage.setItem(t,JSON.stringify(e))}},3401:(t,e,i)=>{$Q(e),e.P=void 0;const s=i(7512);e.P=function(t,e,i){try{var n=JSON.parse(t);if(n&&"object"==typeof n&&e in n)return n}catch(t){}return s.Log.error("Failed to parse "+i),null}},6634:(t,e)=>{$Q(e),e.Ye=e.Vt=void 0,e.Vt=function(t){return Array.isArray(t)?"array":typeof t},e.Ye=function(t,e){var i=t=>Array.isArray(t)?"array":null===t?"null":typeof t;return i(t)===i(e)}},8023:(t,e)=>{$Q(e),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let i=(new Date).getTime(),n="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<i?(e=(i+e)%16|0,i=Math.floor(i/16)):(e=(n+e)%16|0,n=Math.floor(n/16)),("x"===t?e:7&e|8).toString(16)})}},1881:(t,e,i)=>{$Q(e),e.UrlConfiguration=void 0;const n=i(1406),s=i(7410),r={[s.Endpoint.Qt]:"i",[s.Endpoint.kt]:"e",[s.Endpoint.Zt]:"d"};e.UrlConfiguration=class{constructor(t,e,i,n){this.customUrl=null,this.fallbackUrls=null,this.endpoint=t,this.endpointDnsKey=r[t],e&&(this.customUrl=e),!e&&i&&(this.customUrl=i.endsWith("/")?""+i+t:i+"/"+t),n&&(this.fallbackUrls=n);e=s.NetworkDefault[t];this.defaultUrl=e+"/"+t}getUrl(){var t;return null!=(t=this.customUrl)?t:this.defaultUrl}getChecksum(){var t=(null!=(t=this.fallbackUrls)?t:[]).sort().join(",");return(0,n.h)(this.customUrl+t)}}},2397:(t,e,i)=>{$Q(e),e.Xe=e.xt=e.Ft=e.He=void 0;i=i(6830);const n="foreground",s="background",r=[];let l=n,u=!1;e.He=()=>l===n,e.Ft=()=>u,e.xt=t=>{r.unshift(t)};e.Xe=e=>{e!==l&&(l=e,r.forEach(t=>t(e)))},(0,i.ke)("focus",()=>{(u=!1,e.Xe)(n)}),(0,i.ke)("blur",()=>(0,e.Xe)(s)),(0,i.we)("visibilitychange",()=>{(0,e.Xe)("visible"===document.visibilityState?n:s)}),(0,i.ke)((0,i.Se)(),()=>{u=!0,(0,e.Xe)(s)})},6914:function(t,e,i){var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&("get"in s?e.__esModule:!s.writable&&!s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),$Q2(t,n,s)}:function(t,e,i,n){t[n=void 0===n?i:n]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)},r=($Q(e),e.Storage=e.Log=e.EventLogger=e.Diagnostics=void 0,i(1845),i(1845));const l=i(8962),u=($Q2(e,"Diagnostics",{enumerable:!0,get:function(){return l.Diagnostics}}),i(7770)),o=($Q2(e,"EventLogger",{enumerable:!0,get:function(){return u.EventLogger}}),i(7512));$Q2(e,"Log",{enumerable:!0,get:function(){return o.Log}});var a=i(8e3);const c=i(4534);$Q2(e,"Storage",{enumerable:!0,get:function(){return c.Storage}}),s(i(1845),e),s(i(2137),e),s(i(6427),e),s(i(694),e),s(i(8962),e),s(i(3539),e),s(i(5542),e),s(i(2922),e),s(i(2417),e),s(i(1406),e),s(i(1333),e),s(i(7512),e),s(i(7787),e),s(i(7410),e),s(i(7023),e),s(i(1405),e),s(i(1361),e),s(i(6830),e),s(i(5902),e),s(i(4143),e),s(i(2176),e),s(i(9122),e),s(i(1375),e),s(i(2636),e),s(i(3206),e),s(i(1637),e),s(i(8e3),e),s(i(586),e),s(i(1098),e),s(i(2059),e),s(i(1812),e),s(i(8578),e),s(i(4534),e),s(i(3401),e),s(i(6634),e),s(i(1881),e),s(i(8023),e),s(i(2397),e),s(i(3932),e),s(i(3091),e),$P((0,r.l)(),{Log:o.Log,SDK_VERSION:a.SDK_VERSION})},9638:function(t,e,i){var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&("get"in s?e.__esModule:!s.writable&&!s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),$Q2(t,n,s)}:function(t,e,i,n){t[n=void 0===n?i:n]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},r=($Q(e),r(i(600)));s(i(600),e),e.default=r.default},1241:(t,e,i)=>{$Q(e),e.GCIRFormatter=void 0;const h=i(6914),d=i(3260);e.GCIRFormatter=class{constructor(t,e,i){this.en=t,this.Oi=e,this.O=i}getClientInitializeResponse(t,e){var t=(0,h.D)(t,this.O,this.Oi.getDefaultEnvironment()),i=null!=(i=null==e?void 0:e.hash)?i:"djb2";let n=null,s=null;var r=null==e?void 0:e.clientSDKKey,l=null!=(l=null==(l=this.Oi.getValues())?void 0:l.sdk_keys_to_app_ids)?l:{},u=null!=(u=null==(u=this.Oi.getValues())?void 0:u.hashed_sdk_keys_to_app_ids)?u:{},o=null!=(o=null==(o=this.Oi.getValues())?void 0:o.hashed_sdk_keys_to_entities)?o:{},a=(r&&(a=(0,d.hashString)(r,"djb2"),n=null!=(u=u[a])?u:null,s=null!=(u=o[a])?u:null,null==n)&&(n=null!=(o=l[r])?o:null),this.bn(t,e,n,s,i)),u=this.yn(t,e,n,s,i),l=this.mn(t,e,n,i),r={};t.userID&&(r.userID=t.userID),t.customIDs&&0<Object.keys(t.customIDs).length&&(r.customIDs=t.customIDs);let c=void 0;t.privateAttributes&&0<Object.keys(t.privateAttributes).length&&(c=(0,d.hashPrivateAttributes)(t.privateAttributes));o=$P({},t),delete o.privateAttributes,this.jn(o),e=this.On(n,i),a={feature_gates:a,dynamic_configs:u,layer_configs:l,param_stores:e,sdkParams:{},has_updates:!0,generator:"js-on-device-eval-client",sdkInfo:{sdkType:"js-on-device-eval-client",sdkVersion:"1.0.0"},time:this.Oi.getLastUpdateTime(),evaluated_keys:r,hash_used:i,user:o};return this.Zn(a,t,i,null==(u=this.Oi.getValues())?void 0:u.session_replay_info),e&&0<Object.keys(e).length&&(a.param_stores=e),void 0!==c&&(a.pa_hash=c),a}Zn(i,n,s,r){if(null!=r){let t=!0;var l=r.recording_blocked;!0===l&&(t=!1);let e=void 0;r.targeting_gate&&(u=this.Oi.getAllSpecs("gate").find(t=>t.name===r.targeting_gate),!1===(e=!!u&&!0===this.wn(u,n).bool_value))&&(t=!1);var u=Math.random(),n=r.sampling_rate,l=("number"==typeof n&&n<u&&(t=!1),i.can_record_session=t,void 0!==l&&(i.recording_blocked=l),void 0!==e&&(i.passes_session_recording_targeting=e),"number"==typeof n&&(i.session_recording_rate=n),this.ts(r.session_recording_event_triggers,u,t=>t)),n=(l&&(i.session_recording_event_triggers=l),this.ts(r.session_recording_exposure_triggers,u,t=>(0,d.hashString)(t,s)));n&&(i.session_recording_exposure_triggers=n),r.session_recording_privacy_settings&&(i.session_recording_privacy_settings=r.session_recording_privacy_settings)}}ts(t,e,i){if(null==t)return null;var n,s,r={};for([n,s]of Object.entries(t)){var l={},u=(Array.isArray(null===s||void 0===s?void 0:s.values)&&(l.values=s.values),null===s||void 0===s?void 0:s.sampling_rate);"number"==typeof u&&(l.passes_sampling=e<=u),r[i(n)]=l}return r}bn(t,e,i,n,s){var r,l,u={};for(const o of this.Oi.getAllSpecs("gate"))"segment"===o.entity||"holdout"===o.entity||null!=n&&!n.gates.includes(o.name)||null!=i&&!(null!=(r=o.targetAppIDs)?r:[]).includes(i)||(r=this.wn(o,t),u[(l=this.Sn(o.name,r,o,null!=s?s:"djb2")).name]=l);return u}yn(t,e,i,n,s){var r={};for(const c of this.Oi.getAllSpecs("config"))if((null==n||n.configs.includes(c.name))&&(null==i||(null!=(o=c.targetAppIDs)?o:[]).includes(i))){var l,u,o=this.wn(c,t),a=this.Sn(c.name,o,c,null!=s?s:"djb2");if("dynamic_config"===c.entity&&(a.passed=o.bool_value),"dynamic_config"!==c.entity&&"autotune"!==c.entity&&(a.is_user_in_experiment=o.is_experiment_group,a.is_experiment_active=!0===c.isActive,c.hasSharedParams)){a.is_in_layer=!0,a.explicit_parameters=c.explicitParameters||[];const h=this.kn(c.name);h&&(l=this.Oi.getAllSpecs("layer").find(t=>t.name===h))&&(l=l.defaultValue||{},u=a.value||{},a.value=$P($P({},l),u))}r[a.name]=a}return r}mn(t,e,i,n){var s={};for(const o of this.Oi.getAllSpecs("layer"))if(null==i||(null!=(u=o.targetAppIDs)?u:[]).includes(i)){const a=this.wn(o,t);var r,l,u=this.Sn(o.name,a,o,null!=n?n:"djb2");u.explicit_parameters=null!=(r=o.explicitParameters)?r:[],a.allocated_experiment_name?(r=this.Oi.getAllSpecs("config").find(t=>t.name===a.allocated_experiment_name))&&((l=this.wn(r,t)).group_name&&(u.group_name=l.group_name),u.allocated_experiment_name=(0,d.hashString)(a.allocated_experiment_name,null!=n?n:"djb2"),u.is_experiment_active=!0===r.isActive,u.is_user_in_experiment=l.is_experiment_group,u.explicit_parameters=r.explicitParameters||[],l.undelegated_secondary_exposures)&&(u.undelegated_secondary_exposures=this.xn(l.undelegated_secondary_exposures,null!=n?n:"djb2")):u.undelegated_secondary_exposures=this.xn(a.undelegated_secondary_exposures||[],null!=n?n:"djb2"),s[u.name]=u}return s}Sn(t,e,i,n){var s="feature_gate"===i.entity?e.bool_value:!e.unsupported&&e.json_value||{},t={name:(0,d.hashString)(t,n),value:s,rule_id:e.rule_id||"default",secondary_exposures:this.xn(e.secondary_exposures||[],n),id_type:null==i?void 0:i.idType};return e.group_name&&(t.group_name=e.group_name),"feature_gate"!==i.entity&&(t.group=e.group_name||"",t.is_device_based=!1,"dynamic_config"!==i.entity&&"autotune"!==i.entity&&"layer"!==i.entity&&(t.is_experiment_active=i.isActive,t.is_user_in_experiment=e.is_experiment_group),t.passed=e.bool_value),t}wn(t,e){return this.en.evaluateSpec(t,e)}On(t,e){var i=null==(i=this.Oi.getValues())?void 0:i.param_stores;if(i){var n,s,r={};for([n,s]of Object.entries(i))if(!t||s.targetAppIDs&&s.targetAppIDs.includes(t)){var l,u,o={};for([l,u]of Object.entries(s.parameters||{})){var a=$P({},u);a.gate_name&&(a.gate_name=(0,d.hashString)(a.gate_name,e)),a.config_name&&(a.config_name=(0,d.hashString)(a.config_name,e)),a.layer_name&&(a.layer_name=(0,d.hashString)(a.layer_name,e)),a.experiment_name&&(a.experiment_name=(0,d.hashString)(a.experiment_name,e)),o[l]=a}r[(0,d.hashString)(n,e)]=o}return 0<Object.keys(r).length?r:void 0}}xn(t,e){return"none"===e?t:t.map(t=>$P($P({},t),{gate:(0,d.hashString)(t.gate,e)}))}jn(t){for(const e in t)void 0===t[e]?delete t[e]:"object"!=typeof t[e]||null===t[e]||Array.isArray(t[e])||this.jn(t[e])}kn(t){var e=this.Oi.getValues();if(null!=e&&e.layers)for(var[i,n]of Object.entries(e.layers))if(n.includes(t))return i;return null}}},3260:(t,e,i)=>{$Q(e),e.hashPrivateAttributes=e.hashString=void 0;const s=i(6914),n=i(5680),r=i(5680);e.hashString=(t,e)=>{return"none"===e?t:"djb2"===e?(0,s.h)(t):"sha256"===e?(e=(0,n.SHA256)(t).arrayBuffer(),r.Base64.encodeArrayBuffer(e)):t};e.hashPrivateAttributes=t=>{let e=0;for(const n in t){var i;Object.prototype.hasOwnProperty.call(t,n)&&(i=t[n],i=n+":"+(null==i?"":String(i)),i=parseInt((0,s.h)(i),10),e=e+i&4294967295)}return e.toString()}},8494:function(t,e,i){var n=this&&this.__awaiter||$A();$Q(e);const s=i(6914);class r extends s.NetworkCore{constructor(t=null){super(t);t=null==t?void 0:t.networkConfig;this.tn=new s.UrlConfiguration(s.Endpoint.Zt,null==t?void 0:t.downloadConfigSpecsUrl,null==t?void 0:t.api,null==t?void 0:t.downloadConfigSpecsFallbackUrls)}fetchConfigSpecs(e,i){return n(this,void 0,void 0,function*(){var t=yield this.get({sdkKey:e,urlConfig:this.tn,priority:i});return null!=(t=null==t?void 0:t.body)?t:null})}}e.default=r},6217:function(t,e,i){var n=this&&this.__awaiter||$A();$Q(e);const u=i(6914),s=i(3066),r=i(1241),l=i(8494),o=i(2660);class a extends u.StatsigClientBase{static instance(t){var e=(0,u.l)().instance(t);return e instanceof a?e:(u.Log.warn((0,u.Mt)()?"StatsigOnDeviceEvalClient.instance is not supported in server environments":"Unable to find StatsigOnDeviceEvalClient instance"),new a(null!=t?t:""))}constructor(t,e=null){u.SDKType.Oe(t,"js-on-device-eval-client");var i=new l.default(e);super(t,null!=(t=null==e?void 0:e.dataAdapter)?t:new o.StatsigSpecsDataAdapter,i,e),this.ft=i,this.Oi=new s.SpecStore,this.en=new s.Evaluator(this.Oi),this.wi=(0,u.getUUID)(),this.En=new r.GCIRFormatter(this.en,this.Oi,this.O)}initializeSync(t){return"Uninitialized"!==this.loadingStatus?{success:!0,duration:0,source:this.Oi.getSource(),sourceUrl:null,error:null}:(this.Re.start(),this.updateSync(t))}initializeAsync(t){return n(this,void 0,void 0,function*(){return this.xe||(this.xe=this.ki(t)),this.xe})}updateSync(t){var e=performance.now(),i=(this.Oi.reset(),this.dataAdapter.getDataSync());return this.Oi.setValuesFromDataAdapter(i),this.Oi.finalize(),this.Ae("Ready",i),null!=t&&t.disableBackgroundCacheRefresh||this.xi(i),(0,u.createUpdateDetails)(!0,this.Oi.getSource(),performance.now()-e,this.te.getLastSeenErrorAndReset(),this.ft.getLastUsedInitUrlAndReset())}updateAsync(i){return n(this,void 0,void 0,function*(){var t=performance.now(),e=(this.Oi.reset(),this.Ae("Loading",null),this.dataAdapter.getDataSync());return this.Oi.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,i),this.Oi.setValuesFromDataAdapter(e),this.Oi.finalize(),this.Ae("Ready",e),(0,u.createUpdateDetails)(!0,this.Oi.getSource(),performance.now()-t,this.te.getLastSeenErrorAndReset(),this.ft.getLastUsedInitUrlAndReset())})}getContext(){return{sdkKey:this.j,options:this.O,values:this.Oi.getValues(),errorBoundary:this.te,session:u.StatsigSession.get(this.j),stableID:u.StableID.get(this.j),sdkInstanceID:this.wi}}checkGate(t,e,i){return this.getFeatureGate(t,e,i).value}getFeatureGate(t,e,i){var e=this.D(e),{evaluation:n,details:s}=this.en.evaluateGate(t,e),s=(0,u.We)(t,s,n),r=null==(r=null==(n=this.overrideAdapter)?void 0:n.getGateOverride)?void 0:r.call(n,s,e,i),n=null!=r?r:s;return this.Fe(t,(0,u.Ke)(e,n),i),this.$emt({name:"gate_evaluation",gate:s}),n}getDynamicConfig(t,e,i){var e=this.D(e),{evaluation:n,details:s}=this.en.evaluateConfig(t,e),s=(0,u.Je)(t,s,n),r=null==(r=null==(n=this.overrideAdapter)?void 0:n.getDynamicConfigOverride)?void 0:r.call(n,s,e,i),n=null!=r?r:s;return this.Fe(t,(0,u.ze)(e,n),i),this.$emt({name:"dynamic_config_evaluation",dynamicConfig:n}),n}getExperiment(t,e,i){var e=this.D(e),{evaluation:n,details:s}=this.en.evaluateConfig(t,e),s=(0,u.Ge)(t,s,n),r=null==(r=null==(n=this.overrideAdapter)?void 0:n.getExperimentOverride)?void 0:r.call(n,s,e,i),n=null!=r?r:s;return this.Fe(t,(0,u.ze)(e,n),i),this.$emt({name:"experiment_evaluation",experiment:n}),n}getLayer(e,t,i){const n=this.D(t);var{evaluation:t,details:s}=this.en.evaluateLayer(e,n),s=(0,u.Ve)(e,s,t),r=null==(r=null==(t=this.overrideAdapter)?void 0:t.getLayerOverride)?void 0:r.call(t,s,n,i);const l=null!=r?r:s;return l.get=(0,u.Be)(l.name,l.__value,t=>{this.Fe(e,(0,u.Le)(n,l,t),i)}),this.$emt({name:"layer_evaluation",layer:l}),l}logEvent(t,e,i,n){this.Re.enqueue($P($P({},"string"==typeof t?{eventName:t,value:i,metadata:n}:t),{user:this.D(e),time:Date.now()}))}Ue(){this.$on("error",()=>{"Loading"===this.loadingStatus&&this.Mi(null)})}ki(t){return n(this,void 0,void 0,function*(){return u.Storage.isReady()||(yield u.Storage.isReadyResolver()),this.Re.start(),this.updateAsync(t)})}Mi(t){this.Oi.finalize(),this.Ae("Ready",t)}D(t){return(0,u.D)(t,this.O,this.Oi.getDefaultEnvironment())}xi(t){this.dataAdapter.getDataAsync(t,{priority:"low"}).catch(t=>{u.Log.error("An error occurred after update.",t)})}getClientInitializeResponse(t,e){return"Ready"!==this.loadingStatus?null:this.En.getClientInitializeResponse(t,e)}}e.default=a},2660:function(t,e,i){var n=this&&this.__awaiter||$A();$Q(e),e.StatsigSpecsDataAdapter=void 0;const s=i(6914),r=i(8494);class l extends s.DataAdapterCore{constructor(){super("SpecsDataAdapter","specs"),this.ft=null}attach(t,e,i){super.attach(t,e,i),null!==i&&i instanceof r.default?this.ft=i:this.ft=new r.default(null!=e?e:{})}getDataAsync(t,e){return this.C(t,void 0,e)}prefetchData(t){return this.U(void 0,t)}F(t,e,i){return n(this,void 0,void 0,function*(){var t;return null!=(t=yield null==(t=this.ft)?void 0:t.fetchConfigSpecs(this.N(),null==i?void 0:i.priority))?t:null})}I(){var t=(0,s.o)(this.N());return`${s.DataAdapterCachePrefix}.${this.m}.`+t}A(t,e){return 0<t.data.length}}e.StatsigSpecsDataAdapter=l},600:(t,e,i)=>{$Q(e),e.StatsigSpecsDataAdapter=e.StatsigOnDeviceEvalClient=void 0;var n=i(6914),s=i(6217);e.StatsigOnDeviceEvalClient=s.default;const r=i(2660);$Q2(e,"StatsigSpecsDataAdapter",{enumerable:!0,get:function(){return r.StatsigSpecsDataAdapter}});i=$P((0,n.l)(),{StatsigSpecsDataAdapter:r.StatsigSpecsDataAdapter,StatsigOnDeviceEvalClient:s.default});e.default=i},6535:(t,e)=>{function u(t){return t.setUTCHours(0,0,0,0),t.getTime()}function o(t){var e=Number(t);return isNaN(e)?(t=new Date(String(t)),isNaN(t.getTime())?null:t):e<1e10?new Date(1e3*e):new Date(e)}$Q(e),e.default={compareNumbers(t,e,i){if(null==t||null==e)return!1;var n=Number(t),s=Number(e);if(isNaN(n)||isNaN(s))return!1;switch(i){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,i){if(null==t||null==e)return!1;var t=String(t),e=String(e),n=t=>{var e=t.indexOf("-");return-1!==e?t.substring(0,e):t},s=((t,e)=>{var i=t.split(".").map(t=>parseInt(t)),n=e.split(".").map(t=>parseInt(t));let s=0;for(;s<Math.max(i.length,n.length);){var r=s<i.length?i[s]:0,l=s<n.length?n[s]:0;if(r<l)return-1;if(l<r)return 1;s++}return 0})(n(t),n(e));switch(i){case"version_gt":return 0<s;case"version_gte":return 0<=s;case"version_lt":return s<0;case"version_lte":return s<=0;case"version_eq":return 0===s;case"version_neq":return 0!==s;default:return!1}},compareStringInArray(s,t,r){if(!Array.isArray(t))return!1;const l="any_case_sensitive"!==r&&"none_case_sensitive"!==r;var e=-1!==t.findIndex(t=>{var e=String(s),t=String(t),i=l?e.toLowerCase():e,n=l?t.toLowerCase():t;switch(r){case"any":case"none":case"any_case_sensitive":case"none_case_sensitive":return i===n;case"str_starts_with_any":return i.startsWith(n);case"str_ends_with_any":return i.endsWith(n);case"str_contains_any":case"str_contains_none":return i.includes(n);default:return!1}});switch(r){case"none":case"none_case_sensitive":case"str_contains_none":return!e;default:return e}},compareStringWithRegEx(t,e){try{var i=String(t);if(i.length<1e3)return new RegExp(String(e)).test(i)}catch(t){}return!1},compareTime(t,e,i){if(null==t||null==e)return!1;try{var n=o(t),s=o(e);if(null===n||null===s)return!1;var r=n.getTime(),l=s.getTime();switch(i){case"before":return r<l;case"after":return l<r;case"on":return u(n)===u(s);default:return!1}}catch(t){return!1}},arrayHasValue(t,e){var i=new Set(t);for(let t=0;t<e.length;t++)if(i.has(e[t])||i.has(parseFloat(e[t])))return!0;return!1},arrayHasAllValues(t,e){var i=new Set(t);for(let t=0;t<e.length;t++)if(!i.has(e[t])&&!i.has(parseFloat(e[t])))return!1;return!0}}},5079:(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,version:null==(e=t.version)?void 0:e.toString()}},e.resultToConfigEval=function(t,e){var i;return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.json_value,secondary_exposures:e.secondary_exposures,group:null!=(i=e.group_name)?i:"",group_name:null!=(i=e.group_name)?i:void 0,is_device_based:!1,is_experiment_active:t.isActive,is_user_in_experiment:e.is_experiment_group,version:null==(i=t.version)?void 0:i.toString(),passed:e.bool_value}},e.resultToLayerEval=function(t,e,i){var n;return{name:t.name,rule_id:i.rule_id,value:i.json_value,secondary_exposures:i.secondary_exposures,undelegated_secondary_exposures:i.undelegated_secondary_exposures,allocated_experiment_name:null!=(n=i.allocated_experiment_name)?n:"",explicit_parameters:null!=(n=i.explicit_parameters)?n:[],group:null!=(n=i.group_name)?n:"",group_name:null!=(n=i.group_name)?n:void 0,is_device_based:!1,is_experiment_active:null==e?void 0:e.isActive,is_user_in_experiment:i.is_experiment_group,version:null==(n=t.version)?void 0:n.toString()}}},5007:(t,e,i)=>{$Q(e),e.Evaluator=void 0;const h=i(6914),n=i(5680),d=i(6535),v=i(5079);function f(t){return(0,n.SHA256)(t).dataView().getBigUint64(0,!1)}function c(t){return null!=t&&"object"==typeof t}e.Evaluator=class{constructor(t){this.Oi=t}evaluateGate(t,e){var{spec:t,details:i}=this.nn("gate",t);return t?(e=this.evaluateSpec(t,e),t=(0,v.resultToGateEval)(t,e),this.sn(e,i),{evaluation:t,details:i}):{evaluation:null,details:i}}evaluateConfig(t,e){var{spec:t,details:i}=this.nn("config",t);return t?(e=this.evaluateSpec(t,e),t=(0,v.resultToConfigEval)(t,e),this.sn(e,i),{evaluation:t,details:i}):{evaluation:null,details:i}}evaluateLayer(t,e){var i,{spec:t,details:n}=this.nn("layer",t);return t?(i=null!=(i=null==(e=this.evaluateSpec(t,e))?void 0:e.allocated_experiment_name)?i:"",i=this.Oi.getSpecAndSourceInfo("config",i).spec,t=(0,v.resultToLayerEval)(t,i,e),this.sn(e,n),{evaluation:t,details:n}):{evaluation:null,details:n}}sn(t,e){t.unsupported&&(e.reason="Unsupported")}getParamStoreConfig(t){var t=this.Oi.getParamStoreAndSourceInfo(t),e=this.ln(t);return{config:null!=(t=t.paramStoreConfig)?t:null,details:e}}evaluateSpec(t,e){var i=c(t.defaultValue)?t.defaultValue:void 0;if(!t.enabled)return(0,v.makeEvalResult)({json_value:i,rule_id:"disabled"});var n=[],s={};for(const o of t.rules){var r,l=this.un(o,e);if(l.unsupported)return l;for(const a of l.secondary_exposures){var u=`${a.gate}|${a.gateValue}|`+a.ruleID;s[u]||(s[u]=!0,n.push(a))}if(l.bool_value)return this.an(o.configDelegate,e,n)||(r=function(t,e,i){if(100===t.passPercentage)return!0;if(0===t.passPercentage)return!1;e=f(i.salt+"."+(null!=(i=t.salt)?i:t.id)+"."+(null!=(i=(0,h.Jn)(e,t.idType))?i:""));return Number(e%BigInt(1e4))<100*t.passPercentage}(o,e,t),(0,v.makeEvalResult)({rule_id:l.rule_id,bool_value:r,json_value:r?l.json_value:i,secondary_exposures:n,undelegated_secondary_exposures:n,is_experiment_group:l.is_experiment_group,group_name:l.group_name}))}return(0,v.makeEvalResult)({json_value:i,secondary_exposures:n,undelegated_secondary_exposures:n,rule_id:"default"})}nn(t,e){t=this.Oi.getSpecAndSourceInfo(t,e);return{details:this.ln(t),spec:t.spec}}ln(t){var{source:e,lcut:i,receivedAt:n}=t;return"Uninitialized"===e||"NoValues"===e?{reason:e}:{reason:e+":"+(null==("spec"in t?t.spec:t.paramStoreConfig)?"Unrecognized":"Recognized"),lcut:i,receivedAt:n}}un(t,e){var i=[];let n=!0;for(const r of t.conditions){var s=this.cn(r,e);if(s.unsupported)return s;i.push(...s.secondary_exposures),s.bool_value||(n=!1)}return(0,v.makeEvalResult)({rule_id:t.id,bool_value:n,json_value:c(t.returnValue)?t.returnValue:void 0,secondary_exposures:i,is_experiment_group:!0===t.isExperimentGroup,group_name:t.groupName})}cn(t,e){let i=null,n=!1;var s=t.field,r=t.targetValue,l=t.idType,u=t.type;switch(u){case"public":return(0,v.makeEvalResult)({bool_value:!0});case"pass_gate":case"fail_gate":var o=String(r),o=this.hn(o,e);return(0,v.makeEvalResult)({bool_value:"fail_gate"===u?!o.bool_value:o.bool_value,secondary_exposures:o.secondary_exposures});case"multi_pass_gate":case"multi_fail_gate":return this.dn(r,u,e);case"user_field":case"ip_based":case"ua_based":i=function(t,e){var i;if(null==e||"object"!=typeof t||null==t)return null;var n=t;return null!=(i=null!=(i=null!=(i=null!=(i=null!=(i=n[e])?i:n[e.toLowerCase()])?i:null==(n=null==t?void 0:t.custom)?void 0:n[e])?i:null==(n=null==t?void 0:t.custom)?void 0:n[e.toLowerCase()])?i:null==(n=null==t?void 0:t.privateAttributes)?void 0:n[e])?i:null==(n=null==t?void 0:t.privateAttributes)?void 0:n[e.toLowerCase()]}(e,s);break;case"environment_field":i=function(t,e){if(null==e)return null;t=t.statsigEnvironment;if(null!=t){const i=e.toLowerCase(),n=Object.keys(t).find(t=>t.toLowerCase()===i);return void 0!==n?t[n]:void 0}}(e,s);break;case"current_time":i=Date.now();break;case"user_bucket":o=f(String(null!=(o=null==(o=t.additionalValues)?void 0:o.salt)?o:"")+"."+(null!=(o=(0,h.Jn)(e,l))?o:""));i=Number(o%BigInt(1e3));break;case"unit_id":i=(0,h.Jn)(e,l);break;default:return(0,v.makeEvalResult)({unsupported:!0})}var a,c=t.operator;switch(c){case"gt":case"gte":case"lt":case"lte":n=d.default.compareNumbers(i,r,c);break;case"version_gt":case"version_gte":case"version_lt":case"version_lte":case"version_eq":case"version_neq":n=d.default.compareVersions(i,r,c);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":n=d.default.compareStringInArray(i,r,c);break;case"str_matches":n=d.default.compareStringWithRegEx(i,r);break;case"before":case"after":case"on":n=d.default.compareTime(i,r,c);break;case"eq":n=i==r;break;case"neq":n=i!=r;break;case"in_segment_list":case"not_in_segment_list":return(0,v.makeEvalResult)({unsupported:!0});case"array_contains_any":case"array_contains_none":Array.isArray(r)?n=!!Array.isArray(i)&&(a=d.default.arrayHasValue(i,r),"array_contains_any"===c?a:!a):n=!1;break;case"array_contains_all":case"not_array_contains_all":Array.isArray(r)?n=!!Array.isArray(i)&&(a=d.default.arrayHasAllValues(i,r),"array_contains_all"===c?a:!a):n=!1}return(0,v.makeEvalResult)({bool_value:n})}an(t,e,i){if(!t)return null;var n=this.Oi.getSpecAndSourceInfo("config",t)["spec"];if(!n)return null;var e=this.evaluateSpec(n,e),s={},r=[];for(const u of i.concat(e.secondary_exposures)){var l=`${u.gate}|${u.gateValue}|`+u.ruleID;s[l]||(s[l]=!0,r.push(u))}return(0,v.makeEvalResult)($P($P({},e),{allocated_experiment_name:t,explicit_parameters:n.explicitParameters,secondary_exposures:r,undelegated_secondary_exposures:i}))}hn(t,e){var i=[];let n=!1;var s=this.Oi.getSpecAndSourceInfo("gate",t)["spec"];if(s){s=this.evaluateSpec(s,e);if(s.unsupported)return s;n=s.bool_value,i.push(...s.secondary_exposures),t.startsWith("segment:")||i.push({gate:t,gateValue:String(n),ruleID:s.rule_id})}return(0,v.makeEvalResult)({bool_value:n,secondary_exposures:i})}dn(t,e,i){if(!Array.isArray(t))return(0,v.makeEvalResult)({unsupported:!0});var n="multi_pass_gate"===e,s=[];let r=!1;for(const u of t){if("string"!=typeof u)return(0,v.makeEvalResult)({unsupported:!0});var l=this.hn(u,i);if(l.unsupported)return l;if(s.push(...l.secondary_exposures),n?!0===l.bool_value:!1===l.bool_value){r=!0;break}}return(0,v.makeEvalResult)({bool_value:r,secondary_exposures:s})}}},8313:(t,e,i)=>{$Q(e),e.SpecStore=void 0;const n=i(6914);function s(t){return(0,n.P)(t,"has_updates","DownloadConfigSpecsResponse")}e.SpecStore=class{constructor(){this.Ze=null,this.ti=null,this.ei="Uninitialized",this.ii=0,this.ni=0,this.vn=null}getValues(){return this.Ze?s(this.Ze):null}getSource(){return this.ei}getDefaultEnvironment(){return this.vn}setValuesFromDataAdapter(t){var e,i;!t||!0!==(null==(i=s(t.data))?void 0:i.has_updates)||(null!=(e=i.time)?e:0)<this.ii||(this.ii=i.time,this.ni=t.receivedAt,this.ei=t.source,this.ti=i,this.Ze=t.data,this.vn=null!=(e=i.default_environment)?e:null)}reset(){this.ti=null,this.Ze=null,this.ei="Loading"}finalize(){this.ti||(this.ei="NoValues")}getSpecAndSourceInfo(t,e){var t=this.fn(t);return{spec:null!=(t=null==t?void 0:t.find(t=>t.name===e))?t:null,source:this.ei,lcut:this.ii,receivedAt:this.ni}}getParamStoreAndSourceInfo(t){var e=null==(e=this.ti)?void 0:e.param_stores;return{paramStoreConfig:null!=(t=null==(e=null==e?void 0:e[t])?void 0:e.parameters)?t:null,source:this.ei,lcut:this.ii,receivedAt:this.ni}}fn(t){var e;switch(t){case"gate":return null==(e=this.ti)?void 0:e.feature_gates;case"config":return null==(e=this.ti)?void 0:e.dynamic_configs;case"layer":return null==(e=this.ti)?void 0:e.layer_configs}}getAllSpecs(t){return this.fn(t)||[]}getLastUpdateTime(){return this.ii}}},3066:function(t,e,i){var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&("get"in s?e.__esModule:!s.writable&&!s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),$Q2(t,n,s)}:function(t,e,i,n){t[n=void 0===n?i:n]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};$Q(e),s(i(5007),e),s(i(5079),e),s(i(8313),e)},725:(t,e)=>{$Q(e),e.Base64=void 0;const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.Base64=class{static encodeArrayBuffer(t){let e="";var i=new Uint8Array(t),n=i.byteLength;for(let t=0;t<n;t++)e+=String.fromCharCode(i[t]);return this.Dn(e)}static Dn(t){let e="";var i,n,s,r;let l,u,o=0;for(;o<t.length;)r=t.charCodeAt(o++),i=t.charCodeAt(o++),n=t.charCodeAt(o++),s=r>>2,r=(3&r)<<4|i>>4,l=(15&i)<<2|n>>6,u=63&n,isNaN(i)?l=u=64:isNaN(n)&&(u=64),e=e+a.charAt(s)+a.charAt(r)+a.charAt(l)+a.charAt(u);return e}}},5680:(t,e,i)=>{$Q(e),e.Base64=e.SHA256=void 0;const n=i(725),s=($Q2(e,"Base64",{enumerable:!0,get:function(){return n.Base64}}),i(7485));$Q2(e,"SHA256",{enumerable:!0,get:function(){return s.SHA256}})},7485:(t,e)=>{$Q(e),e.SHA256=void 0,e.SHA256=function(t){return(new n).update(t)};const i=[-2147483648,8388608,32768,128],l=[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 n{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(i){if(!this.finalized){if("string"!=typeof i)throw new Error('Must be of type "string"');var n;let t=0,e;for(var s=i.length,r=this.blocks;t<s;){for(this.hashed&&(this.hashed=!1,r[0]=this.block,r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0),e=this.start;t<s&&e<64;++t)(n=i.charCodeAt(t))<128?r[e>>2]|=n<<l[3&e++]:(n<2048?r[e>>2]|=(192|n>>6)<<l[3&e++]:(n<55296||57344<=n?r[e>>2]|=(224|n>>12)<<l[3&e++]:(n=65536+((1023&n)<<10|1023&i.charCodeAt(++t)),r[e>>2]|=(240|n>>18)<<l[3&e++],r[e>>2]|=(128|n>>12&63)<<l[3&e++]),r[e>>2]|=(128|n>>6&63)<<l[3&e++]),r[e>>2]|=(128|63&n)<<l[3&e++]);this.lastByteIndex=e,this.bytes+=e-this.start,64<=e?(this.block=r[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]|=i[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,i=this.h1,n=this.h2,s=this.h3,r=this.h4,l=this.h5,u=this.h6,o=this.h7,a,c,h,d,v,f,_,g,p,b,y;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],h=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,t[a]=t[a-16]+c+t[a-7]+h<<0;for(y=i&n,a=0;a<64;a+=4)this.first?(g=704751109,v=t[0]-210244248,o=v-1521486534<<0,s=v+143694565<<0,this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),h=(r>>>6|r<<26)^(r>>>11|r<<21)^(r>>>25|r<<7),g=e&i,d=g^e&n^y,_=r&l^~r&u,v=o+h+_+m[a]+t[a],f=c+d,o=s+v<<0,s=v+f<<0),c=(s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10),h=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),p=s&e,d=p^s&i^g,_=o&r^~o&l,v=u+h+_+m[a+1]+t[a+1],f=c+d,u=n+v<<0,n=v+f<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),h=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),b=n&s,d=b^n&e^p,_=u&o^~u&r,v=l+h+_+m[a+2]+t[a+2],f=c+d,l=i+v<<0,i=v+f<<0,c=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),h=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),y=i&n,d=y^i&s^b,_=l&u^~l&o,v=r+h+_+m[a+3]+t[a+3],f=c+d,r=e+v<<0,e=v+f<<0;this.h0=this.h0+e<<0,this.h1=this.h1+i<<0,this.h2=this.h2+n<<0,this.h3=this.h3+s<<0,this.h4=this.h4+r<<0,this.h5=this.h5+l<<0,this.h6=this.h6+u<<0,this.h7=this.h7+o<<0}arrayBuffer(){return this._n().buffer}dataView(){return this._n().dataView}_n(){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}}}}},n={};function s(t){var e=n[t];return void 0!==e||(e=n[t]={exports:{}},i[t].call(e.exports,e,e.exports,s)),e.exports}return s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s(9638).default})());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/js-on-device-eval-client",
3
- "version": "3.32.0",
3
+ "version": "3.32.2",
4
4
  "license": "ISC",
5
5
  "homepage": "https://github.com/statsig-io/js-client-monorepo",
6
6
  "repository": {
@@ -9,12 +9,12 @@
9
9
  "directory": "packages/js-on-device-eval-client"
10
10
  },
11
11
  "dependencies": {
12
- "@statsig/client-core": "3.32.0",
13
- "@statsig/on-device-eval-core": "3.32.0",
14
- "@statsig/sha256": "3.32.0"
12
+ "@statsig/client-core": "3.32.2",
13
+ "@statsig/on-device-eval-core": "3.32.2",
14
+ "@statsig/sha256": "3.32.2"
15
15
  },
16
16
  "devDependencies": {
17
- "@statsig/js-local-overrides": "3.32.0"
17
+ "@statsig/js-local-overrides": "3.32.2"
18
18
  },
19
19
  "jsdelivr": "./build/statsig-js-on-device-eval-client.min.js",
20
20
  "type": "commonjs",
@@ -6,6 +6,8 @@ export declare class GCIRFormatter {
6
6
  private _options;
7
7
  constructor(_evaluator: Evaluator, _store: SpecStore, _options: AnyStatsigOptions);
8
8
  getClientInitializeResponse(user: StatsigUser, options?: ClientInitializeResponseOptions): InitializeResponseV1WithUpdates | null;
9
+ private _addSessionReplayFieldsToResponse;
10
+ private _formatSessionReplayTriggers;
9
11
  private _evaluateAllGates;
10
12
  private _evaluateAllConfigs;
11
13
  private _evaluateAllLayers;
@@ -10,7 +10,7 @@ class GCIRFormatter {
10
10
  this._options = _options;
11
11
  }
12
12
  getClientInitializeResponse(user, options) {
13
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
13
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
14
14
  const normalizedUser = (0, client_core_1._normalizeUser)(user, this._options, this._store.getDefaultEnvironment());
15
15
  const hashAlgo = (_a = options === null || options === void 0 ? void 0 : options.hash) !== null && _a !== void 0 ? _a : 'djb2';
16
16
  let targetAppID = null;
@@ -61,6 +61,7 @@ class GCIRFormatter {
61
61
  hash_used: hashAlgo,
62
62
  user: cleanUser,
63
63
  };
64
+ this._addSessionReplayFieldsToResponse(response, normalizedUser, hashAlgo, (_l = this._store.getValues()) === null || _l === void 0 ? void 0 : _l.session_replay_info);
64
65
  if (paramStores && Object.keys(paramStores).length > 0) {
65
66
  response.param_stores = paramStores;
66
67
  }
@@ -69,6 +70,79 @@ class GCIRFormatter {
69
70
  }
70
71
  return response;
71
72
  }
73
+ _addSessionReplayFieldsToResponse(response, user, hashAlgo, sessionReplayInfo) {
74
+ if (sessionReplayInfo == null) {
75
+ return;
76
+ }
77
+ let canRecord = true;
78
+ const recordingBlocked = sessionReplayInfo.recording_blocked;
79
+ if (recordingBlocked === true) {
80
+ canRecord = false;
81
+ }
82
+ let passesTargeting = undefined;
83
+ if (sessionReplayInfo.targeting_gate) {
84
+ const targetingGateSpec = this._store
85
+ .getAllSpecs('gate')
86
+ .find((s) => s.name === sessionReplayInfo.targeting_gate);
87
+ if (targetingGateSpec) {
88
+ const targetingResult = this._evaluateSpecForInitResponse(targetingGateSpec, user);
89
+ passesTargeting = targetingResult.bool_value === true;
90
+ }
91
+ else {
92
+ passesTargeting = false;
93
+ }
94
+ if (passesTargeting === false) {
95
+ canRecord = false;
96
+ }
97
+ }
98
+ const random = Math.random();
99
+ const samplingRate = sessionReplayInfo.sampling_rate;
100
+ if (typeof samplingRate === 'number') {
101
+ if (random > samplingRate) {
102
+ canRecord = false;
103
+ }
104
+ }
105
+ response.can_record_session = canRecord;
106
+ if (recordingBlocked !== undefined) {
107
+ response.recording_blocked = recordingBlocked;
108
+ }
109
+ if (passesTargeting !== undefined) {
110
+ response.passes_session_recording_targeting = passesTargeting;
111
+ }
112
+ if (typeof samplingRate === 'number') {
113
+ response.session_recording_rate = samplingRate;
114
+ }
115
+ const eventTriggers = this._formatSessionReplayTriggers(sessionReplayInfo.session_recording_event_triggers, random, (key) => key);
116
+ if (eventTriggers) {
117
+ response.session_recording_event_triggers = eventTriggers;
118
+ }
119
+ const exposureTriggers = this._formatSessionReplayTriggers(sessionReplayInfo.session_recording_exposure_triggers, random, (key) => (0, Hashing_1.hashString)(key, hashAlgo));
120
+ if (exposureTriggers) {
121
+ response.session_recording_exposure_triggers = exposureTriggers;
122
+ }
123
+ if (sessionReplayInfo.session_recording_privacy_settings) {
124
+ response.session_recording_privacy_settings =
125
+ sessionReplayInfo.session_recording_privacy_settings;
126
+ }
127
+ }
128
+ _formatSessionReplayTriggers(triggers, random, keyTransform) {
129
+ if (triggers == null) {
130
+ return null;
131
+ }
132
+ const formatted = {};
133
+ for (const [key, trigger] of Object.entries(triggers)) {
134
+ const out = {};
135
+ if (Array.isArray(trigger === null || trigger === void 0 ? void 0 : trigger.values)) {
136
+ out.values = trigger.values;
137
+ }
138
+ const rate = trigger === null || trigger === void 0 ? void 0 : trigger.sampling_rate;
139
+ if (typeof rate === 'number') {
140
+ out.passes_sampling = random <= rate;
141
+ }
142
+ formatted[keyTransform(key)] = out;
143
+ }
144
+ return formatted;
145
+ }
72
146
  _evaluateAllGates(user, _options, targetAppID, targetEntities, hashAlgo) {
73
147
  var _a;
74
148
  const specs = this._store.getAllSpecs('gate');