@atlassian/aui
Version:
Atlassian User Interface library
1 lines • 182 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("@atlassian/aui",[],t):"object"==typeof exports?exports["@atlassian/aui"]=t():(e.AJS=e.AJS||{},e.AJS.DesignTokens=t())}(window,()=>(()=>{var e={6572(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.bindAll=void 0;var o=r(1634);function a(e){if(void 0!==e)return"boolean"==typeof e?{capture:e}:e}t.bindAll=function(e,t,r){var i=t.map(function(t){var i=null==r?t:n(n({},t),{options:n(n({},a(r)),a(t.options))});return(0,o.bind)(e,i)});return function(){i.forEach(function(e){return e()})}}},1634(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bind=void 0,t.bind=function(e,t){var r=t.type,n=t.listener,o=t.options;return e.addEventListener(r,n,o),function(){e.removeEventListener(r,n,o)}}},1833(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bindAll=t.bind=void 0;var n=r(1634);Object.defineProperty(t,"bind",{enumerable:!0,get:function(){return n.bind}});var o=r(6572);Object.defineProperty(t,"bindAll",{enumerable:!0,get:function(){return o.bindAll}})},2646(e){"use strict";var t=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,n,a,i){if("function"!=typeof n)throw TypeError("The listener must be a function");var s=new o(n,a||e,i),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,o=[];if(0===this._eventsCount)return o;for(n in e=this._events)t.call(e,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,a=n.length,i=Array(a);o<a;o++)i[o]=n[o].fn;return i},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,o,a,i){var s=r?r+e:e;if(!this._events[s])return!1;var l,c,u=this._events[s],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,o),!0;case 5:return u.fn.call(u.context,t,n,o,a),!0;case 6:return u.fn.call(u.context,t,n,o,a,i),!0}for(c=1,l=Array(d-1);c<d;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var g,h=u.length;for(c=0;c<h;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),d){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,n);break;case 4:u[c].fn.call(u[c].context,t,n,o);break;default:if(!l)for(g=1,l=Array(d-1);g<d;g++)l[g-1]=arguments[g];u[c].fn.apply(u[c].context,l)}}return!0},s.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,o){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||n&&s.context!==n||i(this,a);else{for(var l=0,c=[],u=s.length;l<u;l++)(s[l].fn!==t||o&&!s[l].once||n&&s[l].context!==n)&&c.push(s[l]);c.length?this._events[a]=1===c.length?c[0]:c:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&i(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s},7861(){},5632(e){e.exports=function(e,t){this.v=e,this.k=t},e.exports.__esModule=!0,e.exports.default=e.exports},2125(e,t,r){var n=r(8590);function o(){var t,r,a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.toStringTag||"@@toStringTag";function l(e,o,a,i){var s=Object.create((o&&o.prototype instanceof u?o:u).prototype);return n(s,"_invoke",function(e,n,o){var a,i,s,l=0,u=o||[],d=!1,g={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,r){return a=e,i=0,s=t,g.n=r,c}};function h(e,n){for(i=e,s=n,r=0;!d&&l&&!o&&r<u.length;r++){var o,a=u[r],h=g.p,p=a[2];e>3?(o=p===n)&&(s=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=t):a[0]<=h&&((o=e<2&&h<a[1])?(i=0,g.v=n,g.n=a[1]):h<p&&(o=e<3||a[0]>n||n>p)&&(a[4]=e,a[5]=n,g.n=p,i=0))}if(o||e>1)return c;throw d=!0,n}return function(o,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,p),i=u,s=p;(r=i<2?t:s)||!d;){a||(i?i<3?(i>1&&(g.n=-1),h(i,s)):g.n=s:g.v=s);try{if(l=2,a){if(i||(o="next"),r=a[o]){if(!(r=r.call(a,s)))throw TypeError("iterator result is not an object");if(!r.done)return r;s=r.value,i<2&&(i=0)}else 1===i&&(r=a.return)&&r.call(a),i<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),i=1);a=t}else if((r=(d=g.n<0)?s:e.call(n,g))!==c)break}catch(e){a=t,i=1,s=e}finally{l=1}}return{value:r,done:d}}}(e,a,i),!0),s}var c={};function u(){}function d(){}function g(){}r=Object.getPrototypeOf;var h=g.prototype=u.prototype=Object.create([][i]?r(r([][i]())):(n(r={},i,function(){return this}),r));function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,n(e,s,"GeneratorFunction")),e.prototype=Object.create(h),e}return d.prototype=g,n(h,"constructor",g),n(g,"constructor",d),d.displayName="GeneratorFunction",n(g,s,"GeneratorFunction"),n(h),n(h,s,"Generator"),n(h,i,function(){return this}),n(h,"toString",function(){return"[object Generator]"}),(e.exports=o=function(){return{w:l,m:p}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},4857(e,t,r){var n=r(8691);e.exports=function(e,t,r,o,a){var i=n(e,t,r,o,a);return i.next().then(function(e){return e.done?e.value:i.next()})},e.exports.__esModule=!0,e.exports.default=e.exports},8691(e,t,r){var n=r(2125),o=r(8251);e.exports=function(e,t,r,a,i){return new o(n().w(e,t,r,a),i||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports},8251(e,t,r){var n=r(5632),o=r(8590);e.exports=function e(t,r){var a;this.next||(o(e.prototype),o(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),o(this,"_invoke",function(e,o,i){function s(){return new r(function(o,a){!function e(o,a,i,s){try{var l=t[o](a),c=l.value;return c instanceof n?r.resolve(c.v).then(function(t){e("next",t,i,s)},function(t){e("throw",t,i,s)}):r.resolve(c).then(function(e){l.value=e,i(l)},function(t){return e("throw",t,i,s)})}catch(e){s(e)}}(e,i,o,a)})}return a=a?a.then(s,s):s()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports},8590(e){function t(r,n,o,a){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}e.exports=t=function(e,r,n,o){function a(r,n){t(e,r,function(e){return this._invoke(r,n,e)})}r?i?i(e,r,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[r]=n:(a("next",0),a("throw",1),a("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,o,a)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},9769(e){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports},9541(e,t,r){var n=r(5632),o=r(2125),a=r(4857),i=r(8691),s=r(8251),l=r(9769),c=r(1423);function u(){"use strict";var t=o(),r=t.m(u),d=(Object.getPrototypeOf?Object.getPrototypeOf(r):r.__proto__).constructor;function g(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))}var h={throw:1,return:2,break:3,continue:3};function p(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,h[e],t)},delegateYield:function(e,o,a){return t.resultName=o,r(n.d,c(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=u=function(){return{wrap:function(e,r,n,o){return t.w(p(e),r,n,o&&o.reverse())},isGeneratorFunction:g,mark:t.m,awrap:function(e,t){return new n(e,t)},AsyncIterator:s,async:function(e,t,r,n,o){return(g(t)?i:a)(p(e),t,r,n,o)},keys:l,values:c}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=u,e.exports.__esModule=!0,e.exports.default=e.exports},1423(e,t,r){var n=r(998).default;e.exports=function(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw TypeError(n(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports},998(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},6192(e,t,r){var n=r(9541)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},8657(e,t,r){"use strict";var n,o,a;Object.defineProperty(t,"__esModule",{value:!0}),t._getInstance=t._getStatsigGlobalFlag=t._getStatsigGlobal=void 0;let i=r(2132);t._getStatsigGlobal=()=>{try{return"u">typeof __STATSIG__?__STATSIG__:d}catch(e){return d}},t._getStatsigGlobalFlag=e=>(0,t._getStatsigGlobal)()[e],t._getInstance=e=>{let r=(0,t._getStatsigGlobal)();return e?r.instances&&r.instances[e]:(r.instances&&Object.keys(r.instances).length>1&&i.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."),r.firstInstance)};let s="__STATSIG__",l="u">typeof window?window:{},c=void 0!==r.g?r.g:{},u="u">typeof globalThis?globalThis:{},d=null!=(a=null!=(o=null!=(n=l[s])?n:c[s])?o:u[s])?a:{instance:t._getInstance};l[s]=d,c[s]=d,u[s]=d},981(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._getStorageKey=t._getUserStorageKey=void 0;let n=r(8210);function o(e,t,r){var o;if(r)return r(e,t);let a=t&&t.customIDs?t.customIDs:{},i=[`uid:${null!=(o=null==t?void 0:t.userID)?o:""}`,`cids:${Object.keys(a).sort((e,t)=>e.localeCompare(t)).map(e=>`${e}-${a[e]}`).join(",")}`,`k:${e}`];return(0,n._DJB2)(i.join("|"))}t._getUserStorageKey=o,t._getStorageKey=function(e,t,r){return t?o(e,t,r):(0,n._DJB2)(`k:${e}`)}},4399(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},8562(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t._makeDataAdapterResult=t.DataAdapterCore=void 0;let o=r(2132),a=r(6286),i=r(4830),s=r(6346),l=r(1829);function c(e,t,r,n){return{source:e,data:t,receivedAt:Date.now(),stableID:r,fullUserHash:(0,i._getFullUserHash)(n)}}t.DataAdapterCore=class{constructor(e,t){this._adapterName=e,this._cacheSuffix=t,this._options=null,this._sdkKey=null,this._cacheLimit=10,this._lastModifiedStoreKey=`statsig.last_modified_time.${t}`,this._inMemoryCache=new u}attach(e,t,r){this._sdkKey=e,this._options=t}getDataSync(e){let t=e&&(0,i._normalizeUser)(e,this._options),r=this._getCacheKey(t),n=this._inMemoryCache.get(r,t);if(n&&this._getIsCacheValueValid(n))return n;let o=this._loadFromCache(r);return o&&this._getIsCacheValueValid(o)?(this._inMemoryCache.add(r,o,this._cacheLimit),this._inMemoryCache.get(r,t)):null}setData(e,t){let r=t&&(0,i._normalizeUser)(t,this._options),n=this._getCacheKey(r);this._inMemoryCache.add(n,c("Bootstrap",e,null,r),this._cacheLimit)}_getIsCacheValueValid(e){return null==e.stableID||e.stableID===a.StableID.get(this._getSdkKey())}_getDataAsyncImpl(e,t,r){return n(this,void 0,void 0,function*(){s.Storage.isReady()||(yield s.Storage.isReadyResolver());let n=null!=e?e:this.getDataSync(t),a=[this._fetchAndPrepFromNetwork(n,t,r)];return(null==r?void 0:r.timeoutMs)&&a.push(new Promise(e=>setTimeout(e,r.timeoutMs)).then(()=>(o.Log.debug("Fetching latest value timed out"),null))),yield Promise.race(a)})}_prefetchDataImpl(e,t){return n(this,void 0,void 0,function*(){let r=e&&(0,i._normalizeUser)(e,this._options),n=this._getCacheKey(r),o=yield this._getDataAsyncImpl(null,r,t);o&&this._inMemoryCache.add(n,Object.assign(Object.assign({},o),{source:"Prefetch"}),this._cacheLimit)})}_fetchAndPrepFromNetwork(e,t,r){return n(this,void 0,void 0,function*(){var n;let i=null!=(n=null==e?void 0:e.data)?n:null,s=null!=e&&this._isCachedResultValidFor204(e,t),u=yield this._fetchFromNetwork(i,t,r,s);if(!u)return o.Log.debug("No response returned for latest value"),null;let d=(0,l._typedJsonParse)(u,"has_updates","Response"),g=this._getSdkKey(),h=a.StableID.get(g),p=null;if((null==d?void 0:d.has_updates)===!0)p=c("Network",u,h,t);else{if(!i||(null==d?void 0:d.has_updates)!==!1)return null;p=c("NetworkNotModified",i,h,t)}let f=this._getCacheKey(t);return this._inMemoryCache.add(f,p,this._cacheLimit),this._writeToCache(f,p),p})}_getSdkKey(){return null!=this._sdkKey?this._sdkKey:(o.Log.error(`${this._adapterName} is not attached to a Client`),"")}_loadFromCache(e){var t;let r=null==(t=s.Storage.getItem)?void 0:t.call(s.Storage,e);if(null==r)return null;let n=(0,l._typedJsonParse)(r,"source","Cached Result");return n?Object.assign(Object.assign({},n),{source:"Cache"}):null}_writeToCache(e,t){let r=JSON.stringify(t);for(let t=0;t<8;t++)try{s.Storage.setItem(e,r);break}catch(t){if(!(t instanceof Error)||"QuotaExceededError"!==t.name||this._cacheLimit<=1)throw t;this._cacheLimit=Math.ceil(this._cacheLimit/2),this._runLocalStorageCacheEviction(e,this._cacheLimit-1)}this._runLocalStorageCacheEviction(e)}_runLocalStorageCacheEviction(e,t=this._cacheLimit){var r;let n=null!=(r=(0,s._getObjectFromStorage)(this._lastModifiedStoreKey))?r:{};for(let r of(n[e]=Date.now(),d(n,t)))delete n[r],s.Storage.removeItem(r);(0,s._setObjectInStorage)(this._lastModifiedStoreKey,n)}},t._makeDataAdapterResult=c;class u{constructor(){this._data={}}get(e,t){var r;let n=this._data[e],a=null==n?void 0:n.stableID,i=null==(r=null==t?void 0:t.customIDs)?void 0:r.stableID;return i&&a&&i!==a?(o.Log.warn("'StatsigUser.customIDs.stableID' mismatch"),null):n}add(e,t,r){for(let e of d(this._data,r-1))delete this._data[e];this._data[e]=t}merge(e){this._data=Object.assign(Object.assign({},this._data),e)}}function d(e,t){let r=Object.keys(e);return r.length<=t?[]:0===t?r:r.sort((t,r)=>{let n=e[t],o=e[r];return"object"==typeof n&&"object"==typeof o?n.receivedAt-o.receivedAt:n-o}).slice(0,r.length-t)}},2798(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Diagnostics=void 0;let r=new Map,n="start";function o(e,t,r,n){return Object.assign({key:r,action:t,step:n,timestamp:Date.now()},e)}function a(e,t){var n;let o=null!=(n=r.get(e))?n:[];o.push(t),r.set(e,o)}function i(e,t){if(t in e)return e[t]}t.Diagnostics={_getMarkers:e=>r.get(e),_markInitOverallStart:e=>{a(e,o({},n,"overall"))},_markInitOverallEnd:(e,t,r)=>{a(e,o({success:t,error:t?void 0:{name:"InitializeError",message:"Failed to initialize"},evaluationDetails:r},"end","overall"))},_markInitNetworkReqStart:(e,t)=>{a(e,o(t,n,"initialize","network_request"))},_markInitNetworkReqEnd:(e,t)=>{a(e,o(t,"end","initialize","network_request"))},_markInitProcessStart:e=>{a(e,o({},n,"initialize","process"))},_markInitProcessEnd:(e,t)=>{a(e,o(t,"end","initialize","process"))},_clearMarkers:e=>{r.delete(e)},_formatError(e){if(e&&"object"==typeof e)return{code:i(e,"code"),name:i(e,"name"),message:i(e,"message")}},_getDiagnosticsData(e,r,n,o){var a;return{success:(null==e?void 0:e.ok)===!0,statusCode:null==e?void 0:e.status,sdkRegion:null==(a=null==e?void 0:e.headers)?void 0:a.get("x-statsig-region"),isDelta:!0===n.includes('"is_delta":true')||void 0,attempt:r,error:t.Diagnostics._formatError(o)}},_enqueueDiagnosticsEvent(e,r,n,o){let a=t.Diagnostics._getMarkers(n);if(null==a||a.length<=0)return -1;let i=a[a.length-1].timestamp-a[0].timestamp;t.Diagnostics._clearMarkers(n);let s={eventName:"statsig::diagnostics",user:e,value:null,metadata:{context:"initialize",markers:a.slice(),statsigOptions:o},time:Date.now()};return r.enqueue(s),i}}},6413(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t._fetchTxtRecords=void 0;let n=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]),o=["i","e","d"];t._fetchTxtRecords=function(e){return r(this,void 0,void 0,function*(){let t=yield e("https://cloudflare-dns.com/dns-query",{method:"POST",headers:{"Content-Type":"application/dns-message",Accept:"application/dns-message"},body:n});if(!t.ok){let e=Error("Failed to fetch TXT records from DNS");throw e.name="DnsTxtFetchError",e}return function(e){let t=e.findIndex((t,r)=>r<200&&"="===String.fromCharCode(t)&&o.includes(String.fromCharCode(e[r-1])));if(-1===t){let e=Error("Failed to parse TXT records from DNS");throw e.name="DnsTxtParseError",e}let r="";for(let n=t-1;n<e.length;n++)r+=String.fromCharCode(e[n]);return r.split(",")}(new Uint8Array((yield t.arrayBuffer())))})}},6663(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1290(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorBoundary=t.EXCEPTION_ENDPOINT=void 0;let o=r(2132),a=r(2442),i=r(2452);t.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";let s="[Statsig] UnknownError";function l(e){return e instanceof Error?e:"string"==typeof e?Error(e):Error("An unknown error occurred.")}t.ErrorBoundary=class{constructor(e,t,r,n){this._sdkKey=e,this._options=t,this._emitter=r,this._lastSeenError=n,this._seen=new Set}wrap(e,t){try{(function(e){let t=new Set,r=Object.getPrototypeOf(e);for(;r&&r!==Object.prototype;)Object.getOwnPropertyNames(r).filter(e=>"function"==typeof(null==r?void 0:r[e])).forEach(e=>t.add(e)),r=Object.getPrototypeOf(r);return Array.from(t)})(e).forEach(r=>{let n=e[r];"$EB"in n||(e[r]=(...o)=>this._capture(t?`${t}:${r}`:r,()=>n.apply(e,o)),e[r].$EB=!0)})}catch(e){this._onError("eb:wrap",e)}}logError(e,t){this._onError(e,t)}getLastSeenErrorAndReset(){let e=this._lastSeenError;return this._lastSeenError=void 0,null!=e?e:null}attachErrorIfNoneExists(e){this._lastSeenError||(this._lastSeenError=l(e))}_capture(e,t){try{let r=t();if(r&&r instanceof Promise)return r.catch(t=>this._onError(e,t));return r}catch(t){return this._onError(e,t),null}}_onError(e,r){try{o.Log.warn(`Caught error in ${e}`,{error:r}),n(this,void 0,void 0,function*(){var n,o,c,u,d,g,h;let p=r||Error(s),f=p instanceof Error,b=f?p.name:"No Name",v=l(p);if(this._lastSeenError=v,this._seen.has(b))return;if(this._seen.add(b),null==(o=null==(n=this._options)?void 0:n.networkConfig)?void 0:o.preventAllNetworkTraffic){null==(c=this._emitter)||c.call(this,{name:"error",error:r,tag:e});return}let m=a.SDKType._get(this._sdkKey),y=i.StatsigMetadataProvider.get(),_=f?p.stack:function(e){try{return JSON.stringify(e)}catch(e){return s}}(p),k=Object.assign({tag:e,exception:b,info:_,statsigOptions:function(e){if(!e)return{};let t={};return Object.keys(e).forEach(r=>{let n=e[r];switch(typeof n){case"number":case"bigint":case"boolean":t[String(r)]=n;break;case"string":n.length<50?t[String(r)]=n:t[String(r)]="set";break;case"object":"environment"===r?t.environment=n:"networkConfig"===r?t.networkConfig=n:t[String(r)]=null!=n?"set":"unset"}}),t}(this._options)},Object.assign(Object.assign({},y),{sdkType:m})),w=null!=(g=null==(d=null==(u=this._options)?void 0:u.networkConfig)?void 0:d.networkOverrideFunc)?g:fetch;yield w(t.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this._sdkKey,"STATSIG-SDK-TYPE":String(m),"STATSIG-SDK-VERSION":String(y.sdkVersion),"Content-Type":"application/json"},body:JSON.stringify(k)}),null==(h=this._emitter)||h.call(this,{name:"error",error:r,tag:e})}).then(()=>{}).catch(()=>{})}catch(e){}}}},118(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3725(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},638(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.EventLogger=void 0;let o=r(981),a=r(8210),i=r(2132),s=r(3582),l=r(6650),c=r(1217),u=r(5910),d=r(6346),g=r(5445),h=r(5873),p={},f="startup",b="gained_focus";class v{static _safeFlushAndForget(e){var t;null==(t=p[e])||t.flush().catch(()=>{})}static _safeRetryFailedLogs(e){var t;null==(t=p[e])||t._retryFailedLogs(b)}constructor(e,t,r,n){var o,a;this._sdkKey=e,this._emitter=t,this._network=r,this._options=n,this._queue=[],this._lastExposureTimeMap={},this._nonExposedChecks={},this._hasRunQuickFlush=!1,this._creationTime=Date.now(),this._loggingEnabled=null!=(o=null==n?void 0:n.loggingEnabled)?o:(null==n?void 0:n.disableLogging)===!0?u.LoggingEnabledOption.disabled:u.LoggingEnabledOption.browserOnly,(null==n?void 0:n.loggingEnabled)&&void 0!==n.disableLogging&&i.Log.warn("Detected both loggingEnabled and disableLogging options. loggingEnabled takes precedence - please remove disableLogging."),this._maxQueueSize=null!=(a=null==n?void 0:n.loggingBufferMaxSize)?a:100;const l=null==n?void 0:n.networkConfig;this._logEventUrlConfig=new g.UrlConfiguration(s.Endpoint._rgstr,null==l?void 0:l.logEventUrl,null==l?void 0:l.api,null==l?void 0:l.logEventFallbackUrls)}setLogEventCompressionMode(e){this._network.setLogEventCompressionMode(e)}setLoggingEnabled(e){if("disabled"===this._loggingEnabled&&"disabled"!==e){let e=this._getStorageKey(),t=(0,d._getObjectFromStorage)(e);t&&this._queue.push(...t),d.Storage.removeItem(e)}this._loggingEnabled=e}enqueue(e){this._shouldLogEvent(e)&&(this._normalizeAndAppendEvent(e),this._quickFlushIfNeeded(),this._queue.length>this._maxQueueSize&&v._safeFlushAndForget(this._sdkKey))}incrementNonExposureCount(e){var t;let r=null!=(t=this._nonExposedChecks[e])?t:0;this._nonExposedChecks[e]=r+1}reset(){this.flush().catch(()=>{}),this._lastExposureTimeMap={}}start(){var e;let t=(0,l._isServerEnv)();t&&(null==(e=this._options)?void 0:e.loggingEnabled)!=="always"||(p[this._sdkKey]=this,t||(0,h._subscribeToVisiblityChanged)(e=>{"background"===e?v._safeFlushAndForget(this._sdkKey):"foreground"===e&&v._safeRetryFailedLogs(this._sdkKey)}),this._retryFailedLogs(f),this._startBackgroundFlushInterval())}stop(){return n(this,void 0,void 0,function*(){this._flushIntervalId&&(clearInterval(this._flushIntervalId),this._flushIntervalId=null),delete p[this._sdkKey],yield this.flush()})}flush(){return n(this,void 0,void 0,function*(){if(this._appendAndResetNonExposedChecks(),0===this._queue.length)return;let e=this._queue;this._queue=[],yield this._sendEvents(e)})}_quickFlushIfNeeded(){this._hasRunQuickFlush||(this._hasRunQuickFlush=!0,Date.now()-this._creationTime>200||setTimeout(()=>v._safeFlushAndForget(this._sdkKey),200))}_shouldLogEvent(e){var t;if((null==(t=this._options)?void 0:t.loggingEnabled)!=="always"&&(0,l._isServerEnv)())return!1;if(!(0,c._isExposureEvent)(e))return!0;let r=e.user?e.user:{statsigEnvironment:void 0},n=(0,o._getUserStorageKey)(this._sdkKey,r),a=e.metadata?e.metadata:{},i=[e.eventName,n,a.gate,a.config,a.ruleID,a.allocatedExperiment,a.parameterName,String(a.isExplicitParameter),a.reason].join("|"),s=this._lastExposureTimeMap[i],u=Date.now();return(!s||!(u-s<6e5))&&(Object.keys(this._lastExposureTimeMap).length>1e3&&(this._lastExposureTimeMap={}),this._lastExposureTimeMap[i]=u,!0)}_sendEvents(e){return n(this,void 0,void 0,function*(){var t,r;if("disabled"===this._loggingEnabled)return this._saveFailedLogsToStorage(e),!1;try{let n=(0,h._isUnloading)()&&this._network.isBeaconSupported()&&(null==(r=null==(t=this._options)?void 0:t.networkConfig)?void 0:r.networkOverrideFunc)==null;if(this._emitter({name:"pre_logs_flushed",events:e}),(n?this._sendEventsViaBeacon(e):yield this._sendEventsViaPost(e)).success)return this._emitter({name:"logs_flushed",events:e}),!0;return i.Log.warn("Failed to flush events."),this._saveFailedLogsToStorage(e),!1}catch(e){return i.Log.warn("Failed to flush events."),!1}})}_sendEventsViaPost(e){return n(this,void 0,void 0,function*(){var t;let r=yield this._network.post(this._getRequestData(e)),n=null!=(t=null==r?void 0:r.code)?t:-1;return{success:n>=200&&n<300}})}_sendEventsViaBeacon(e){return{success:this._network.beacon(this._getRequestData(e))}}_getRequestData(e){return{sdkKey:this._sdkKey,data:{events:e},urlConfig:this._logEventUrlConfig,retries:3,isCompressable:!0,params:{[s.NetworkParam.EventCount]:String(e.length)},credentials:"same-origin"}}_saveFailedLogsToStorage(e){for(;e.length>500;)e.shift();let t=this._getStorageKey();try{let r=this._getFailedLogsFromStorage(t);(0,d._setObjectInStorage)(t,[...r,...e])}catch(e){i.Log.warn("Unable to save failed logs to storage")}}_getFailedLogsFromStorage(e){let t=[];try{let r=(0,d._getObjectFromStorage)(e);return Array.isArray(r)&&(t=r),t}catch(e){return[]}}_retryFailedLogs(e){let t=this._getStorageKey();n(this,void 0,void 0,function*(){d.Storage.isReady()||(yield d.Storage.isReadyResolver());let r=(0,d._getObjectFromStorage)(t);!r||(e===f&&d.Storage.removeItem(t),(yield this._sendEvents(r))&&e===b&&d.Storage.removeItem(t))}).catch(()=>{i.Log.warn("Failed to flush stored logs")})}_getStorageKey(){return`statsig.failed_logs.${(0,a._DJB2)(this._sdkKey)}`}_normalizeAndAppendEvent(e){e.user&&(e.user=Object.assign({},e.user),delete e.user.privateAttributes);let t={},r=this._getCurrentPageUrl();r&&(t.statsigMetadata={currentPage:r});let n=Object.assign(Object.assign({},e),t);i.Log.debug("Enqueued Event:",n),this._queue.push(n)}_appendAndResetNonExposedChecks(){0!==Object.keys(this._nonExposedChecks).length&&(this._normalizeAndAppendEvent({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this._nonExposedChecks)}}),this._nonExposedChecks={})}_getCurrentPageUrl(){var e;if((null==(e=this._options)?void 0:e.includeCurrentPageUrlWithEvents)!==!1)return(0,l._getCurrentPageUrlSafe)()}_startBackgroundFlushInterval(){var e,t;let r=setInterval(()=>{let e=p[this._sdkKey];e&&e._flushIntervalId===r?v._safeFlushAndForget(this._sdkKey):clearInterval(r)},null!=(t=null==(e=this._options)?void 0:e.loggingIntervalMs)?t:1e4);this._flushIntervalId=r}}t.EventLogger=v},8210(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._getSortedObject=t._DJB2Object=t._DJB2=void 0;let n=r(8062);t._DJB2=e=>{let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return String(t>>>0)},t._DJB2Object=(e,r)=>(0,t._DJB2)(JSON.stringify((0,t._getSortedObject)(e,r))),t._getSortedObject=(e,r)=>{if(null==e)return null;let o=Object.keys(e).sort(),a={};return o.forEach(o=>{let i=e[o];if(0===r||"object"!==(0,n._typeOf)(i)){a[o]=i;return}a[o]=(0,t._getSortedObject)(i,null!=r?r-1:r)}),a}},2849(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2132(e,t){"use strict";function r(e){return e.unshift("[Statsig]"),e}Object.defineProperty(t,"__esModule",{value:!0}),t.Log=t.LogLevel=void 0,t.LogLevel={None:0,Error:1,Warn:2,Info:3,Debug:4};class n{static info(...e){n.level>=t.LogLevel.Info&&console.info(" INFO ",...r(e))}static debug(...e){n.level>=t.LogLevel.Debug&&console.debug(" DEBUG ",...r(e))}static warn(...e){n.level>=t.LogLevel.Warn&&console.warn(" WARN ",...r(e))}static error(...e){n.level>=t.LogLevel.Error&&console.error(" ERROR ",...r(e))}}t.Log=n,n.level=t.LogLevel.Warn},6375(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createMemoKey=t.MemoPrefix=void 0,t.MemoPrefix={_gate:"g",_dynamicConfig:"c",_experiment:"e",_configList:"cl",_layer:"l",_paramStore:"p"};let r=new Set([]),n=new Set(["userPersistedValues"]);t.createMemoKey=function(e,t,o){let a=`${e}|${t}`;if(!o)return a;for(let e of Object.keys(o)){if(n.has(e))return;r.has(e)?a+=`|${e}=true`:a+=`|${e}=${o[e]}`}return a}},3582(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkParam=t.NetworkDefault=t.Endpoint=void 0,t.Endpoint={_initialize:"initialize",_rgstr:"rgstr",_download_config_specs:"download_config_specs"},t.NetworkDefault={[t.Endpoint._rgstr]:"https://prodregistryv2.org/v1",[t.Endpoint._initialize]:"https://featureassets.org/v1",[t.Endpoint._download_config_specs]:"https://api.statsigcdn.com/v1"},t.NetworkParam={EventCount:"ec",SdkKey:"k",SdkType:"st",SdkVersion:"sv",Time:"t",SessionID:"sid",StatsigEncoded:"se",IsGzipped:"gz"}},6555(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkCore=void 0,r(8657);let o=r(8657),a=r(2798),i=r(2132),s=r(3582),l=r(2064),c=r(4175),u=r(2442),d=r(6650),g=r(4899),h=r(6286),p=r(3528),f=r(2452),b=r(5910),v=r(5873),m=new Set([408,500,502,503,504,522,524,599]);t.NetworkCore=class{constructor(e,t){this._emitter=t,this._errorBoundary=null,this._timeout=1e4,this._netConfig={},this._options={},this._leakyBucket={},this._lastUsedInitUrl=null,e&&(this._options=e),this._options.networkConfig&&(this._netConfig=this._options.networkConfig),this._netConfig.networkTimeoutMs&&(this._timeout=this._netConfig.networkTimeoutMs),this._fallbackResolver=new l.NetworkFallbackResolver(this._options),this.setLogEventCompressionMode(this._getLogEventCompressionMode(e))}setLogEventCompressionMode(e){this._options.logEventCompressionMode=e}setErrorBoundary(e){this._errorBoundary=e,this._errorBoundary.wrap(this),this._errorBoundary.wrap(this._fallbackResolver),this._fallbackResolver.setErrorBoundary(e)}isBeaconSupported(){return"u">typeof navigator&&"function"==typeof navigator.sendBeacon}getLastUsedInitUrlAndReset(){let e=this._lastUsedInitUrl;return this._lastUsedInitUrl=null,e}beacon(e){if(!y(e))return!1;let t=this._getInternalRequestArgs("POST",e),r=this._getPopulatedURL(t),n=navigator;return n.sendBeacon.bind(n)(r,t.body)}post(e){return n(this,void 0,void 0,function*(){let t=this._getInternalRequestArgs("POST",e);return this._tryEncodeBody(t),yield this._tryToCompressBody(t),this._sendRequest(t)})}get(e){let t=this._getInternalRequestArgs("GET",e);return this._sendRequest(t)}_sendRequest(e){return n(this,void 0,void 0,function*(){var t,r,o,l,c,u,d,g,h;if(!y(e)||this._netConfig.preventAllNetworkTraffic)return null;let{method:f,body:b,retries:_,attempt:w}=e,O=e.urlConfig.endpoint;if(this._isRateLimited(O))return i.Log.warn(`Request to ${O} was blocked because you are making requests too frequently.`),null;let x=null!=w?w:1,E=!1,S=this._getPopulatedURL(e),C=null,j=(0,v._isUnloading)();try{let r,n={method:f,body:b,headers:Object.assign({},e.headers),priority:e.priority,keepalive:j};c=e,u=x,c.urlConfig.endpoint===s.Endpoint._initialize&&a.Diagnostics._markInitNetworkReqStart(c.sdkKey,{attempt:u});let o=this._leakyBucket[O];o&&(o.lastRequestTime=Date.now(),this._leakyBucket[O]=o);let i=null!=(t=this._netConfig.networkOverrideFunc)?t:fetch;if(!(C=yield Promise.race([i(S,n).finally(()=>clearTimeout(r)),new Promise((e,t)=>{r=setTimeout(()=>{E=!0,t(Error(`Timeout of ${this._timeout}ms expired.`))},this._timeout)})])).ok){let e=yield C.text().catch(()=>"No Text"),t=Error(`NetworkError: ${S} ${e}`);throw t.name="NetworkError",t}let l=yield C.text();return k(e,C,x,l),this._fallbackResolver.tryBumpExpiryTime(e.sdkKey,e.urlConfig),{body:l,code:C.status}}catch(s){let t="string"==typeof(d=s)?d:d instanceof Error?`${d.name}: ${d.message}`:"Unknown Error",a=(g=null!=t?t:"",h=E,g.includes("Timeout")||h);if(k(e,C,x,"",s),(yield this._fallbackResolver.tryFetchUpdatedFallbackInfo(e.sdkKey,e.urlConfig,t,a))&&(e.fallbackUrl=this._fallbackResolver.getActiveFallbackUrl(e.sdkKey,e.urlConfig)),!_||x>_||!m.has(null!=(r=null==C?void 0:C.status)?r:500)){null==(o=this._emitter)||o.call(this,{name:"error",error:s,tag:p.ErrorTag.NetworkError,requestArgs:e});let r=`A networking error occurred during ${f} request to ${S}.`;return i.Log.error(r,t,s),null==(l=this._errorBoundary)||l.attachErrorIfNoneExists(r),null}return yield function(e){return n(this,void 0,void 0,function*(){yield new Promise(t=>setTimeout(t,Math.min(e*e*500,3e4)))})}(x),this._sendRequest(Object.assign(Object.assign({},e),{retries:_,attempt:x+1}))}})}_getLogEventCompressionMode(e){let t=null==e?void 0:e.logEventCompressionMode;return t||(null==e?void 0:e.disableCompression)!==!0||(t=b.LogEventCompressionMode.Disabled),t||(t=b.LogEventCompressionMode.Enabled),t}_isRateLimited(e){var t;let r=Date.now(),n=null!=(t=this._leakyBucket[e])?t:{count:0,lastRequestTime:r},o=Math.floor((r-n.lastRequestTime)*.05);return n.count=Math.max(0,n.count-o),n.count>=50||(n.count+=1,n.lastRequestTime=r,this._leakyBucket[e]=n,!1)}_getPopulatedURL(e){var t;let r=null!=(t=e.fallbackUrl)?t:e.urlConfig.getUrl();(e.urlConfig.endpoint===s.Endpoint._initialize||e.urlConfig.endpoint===s.Endpoint._download_config_specs)&&(this._lastUsedInitUrl=r);let n=Object.assign({[s.NetworkParam.SdkKey]:e.sdkKey,[s.NetworkParam.SdkType]:u.SDKType._get(e.sdkKey),[s.NetworkParam.SdkVersion]:f.SDK_VERSION,[s.NetworkParam.Time]:String(Date.now()),[s.NetworkParam.SessionID]:g.SessionID.get(e.sdkKey)},e.params),o=Object.keys(n).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(n[e])}`).join("&");return`${r}${o?`?${o}`:""}`}_tryEncodeBody(e){var t;let r=(0,d._getWindowSafe)(),n=e.body;if(e.isStatsigEncodable&&!this._options.disableStatsigEncoding&&"string"==typeof n&&null==(0,o._getStatsigGlobalFlag)("no-encode")&&(null==r?void 0:r.btoa))try{e.body=r.btoa(n).split("").reverse().join(""),e.params=Object.assign(Object.assign({},null!=(t=e.params)?t:{}),{[s.NetworkParam.StatsigEncoded]:"1"})}catch(t){i.Log.warn(`Request encoding failed for ${e.urlConfig.getUrl()}`,t)}}_tryToCompressBody(e){return n(this,void 0,void 0,function*(){var t;let r=e.body;if("string"==typeof r&&function(e,t){if(!e.isCompressable||null!=(0,o._getStatsigGlobalFlag)("no-compress")||"u"<typeof CompressionStream||"u"<typeof TextEncoder)return!1;let r=null!=e.urlConfig.customUrl||null!=e.urlConfig.fallbackUrls,n=!0===c.SDKFlags.get(e.sdkKey,"enable_log_event_compression");switch(t.logEventCompressionMode){case b.LogEventCompressionMode.Disabled:return!1;case b.LogEventCompressionMode.Enabled:if(r&&!n)return!1;return!0;case b.LogEventCompressionMode.Forced:return!0;default:return!1}}(e,this._options))try{let n,o=new TextEncoder().encode(r),a=new CompressionStream("gzip"),l=a.writable.getWriter();l.write(o).catch(i.Log.error),l.close().catch(i.Log.error);let c=a.readable.getReader(),u=[];for(;!(n=yield c.read()).done;)u.push(n.value);let d=u.reduce((e,t)=>e+t.length,0),g=new Uint8Array(d),h=0;for(let e of u)g.set(e,h),h+=e.length;e.body=g,e.params=Object.assign(Object.assign({},null!=(t=e.params)?t:{}),{[s.NetworkParam.IsGzipped]:"1"})}catch(t){i.Log.warn(`Request compression failed for ${e.urlConfig.getUrl()}`,t)}})}_getInternalRequestArgs(e,t){let r=this._fallbackResolver.getActiveFallbackUrl(t.sdkKey,t.urlConfig),n=Object.assign(Object.assign({},t),{method:e,fallbackUrl:r});return"data"in t&&_(n,t.data),n}};let y=e=>!!e.sdkKey||(i.Log.warn("Unable to make request without an SDK key"),!1),_=(e,t)=>{let{sdkKey:r,fallbackUrl:n}=e,o=h.StableID.get(r),a=g.SessionID.get(r),i=u.SDKType._get(r);e.body=JSON.stringify(Object.assign(Object.assign({},t),{statsigMetadata:Object.assign(Object.assign({},f.StatsigMetadataProvider.get()),{stableID:o,sessionID:a,sdkType:i,fallbackUrl:n})}))};function k(e,t,r,n,o){e.urlConfig.endpoint===s.Endpoint._initialize&&a.Diagnostics._markInitNetworkReqEnd(e.sdkKey,a.Diagnostics._getDiagnosticsData(t,r,n,o))}},2064(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t._isDomainFailure=t.NetworkFallbackResolver=void 0;let o=r(6413),a=r(8210),i=r(2132),s=r(6346);function l(e,t){var r;let n=null!=(r=null==e?void 0:e.toLowerCase())?r:"";return t||n.includes("uncaught exception")||n.includes("failed to fetch")||n.includes("networkerror when attempting to fetch resource")}function c(e){return`statsig.network_fallback.${(0,a._DJB2)(e)}`}function u(e,t){let r=c(e);t&&0!==Object.keys(t).length?s.Storage.setItem(r,JSON.stringify(t)):s.Storage.removeItem(r)}t.NetworkFallbackResolver=class{constructor(e){var t;this._fallbackInfo=null,this._errorBoundary=null,this._dnsQueryCooldowns={},this._networkOverrideFunc=null==(t=e.networkConfig)?void 0:t.networkOverrideFunc}setErrorBoundary(e){this._errorBoundary=e}tryBumpExpiryTime(e,t){var r;let n=null==(r=this._fallbackInfo)?void 0:r[t.endpoint];n&&(n.expiryTime=Date.now()+6048e5,u(e,Object.assign(Object.assign({},this._fallbackInfo),{[t.endpoint]:n})))}getActiveFallbackUrl(e,t){var r,n;if(null!=t.customUrl&&null!=t.fallbackUrls)return null;let o=this._fallbackInfo;null==o&&(o=null!=(r=function(e){let t=c(e),r=s.Storage.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return i.Log.error("Failed to parse FallbackInfo"),null}}(e))?r:{},this._fallbackInfo=o);let a=o[t.endpoint];return!a||Date.now()>(null!=(n=a.expiryTime)?n:0)||t.getChecksum()!==a.urlConfigChecksum?(delete o[t.endpoint],this._fallbackInfo=o,u(e,this._fallbackInfo),null):a.url?a.url:null}tryFetchUpdatedFallbackInfo(e,t,r,o){return n(this,void 0,void 0,function*(){var n,a;try{if(!l(r,o))return!1;let a=null==t.customUrl&&null==t.fallbackUrls?yield this._tryFetchFallbackUrlsFromNetwork(t):t.fallbackUrls,i=this._pickNewFallbackUrl(null==(n=this._fallbackInfo)?void 0:n[t.endpoint],a);if(!i)return!1;return this._updateFallbackInfoWithNewUrl(e,t,i),!0}catch(e){return null==(a=this._errorBoundary)||a.logError("tryFetchUpdatedFallbackInfo",e),!1}})}_updateFallbackInfoWithNewUrl(e,t,r){var n,o,a;let i={urlConfigChecksum:t.getChecksum(),url:r,expiryTime:Date.now()+6048e5,previous:[]},s=t.endpoint,l=null==(n=this._fallbackInfo)?void 0:n[s];l&&i.previous.push(...l.previous),i.previous.length>10&&(i.previous=[]);let c=null==(a=null==(o=this._fallbackInfo)?void 0:o[s])?void 0:a.url;null!=c&&i.previous.push(c),this._fallbackInfo=Object.assign(Object.assign({},this._fallbackInfo),{[s]:i}),u(e,this._fallbackInfo)}_tryFetchFallbackUrlsFromNetwork(e){return n(this,void 0,void 0,function*(){var t;let r=this._dnsQueryCooldowns[e.endpoint];if(r&&Date.now()<r)return null;this._dnsQueryCooldowns[e.endpoint]=Date.now()+144e5;let n=[],a=yield(0,o._fetchTxtRecords)(null!=(t=this._networkOverrideFunc)?t:fetch),i=function(e){try{return new URL(e).pathname}catch(e){return null}}(e.defaultUrl);for(let t of a){if(!t.startsWith(e.endpointDnsKey+"="))continue;let r=t.split("=");if(r.length>1){let e=r[1];e.endsWith("/")&&(e=e.slice(0,-1)),n.push(`https://${e}${i}`)}}return n})}_pickNewFallbackUrl(e,t){var r;if(null==t)return null;let n=new Set(null!=(r=null==e?void 0:e.previous)?r:[]),o=null==e?void 0:e.url,a=null;for(let e of t){let t=e.endsWith("/")?e.slice(0,-1):e;if(!n.has(e)&&t!==o){a=t;break}}return a}},t._isDomainFailure=l},5377(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},6037(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4175(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SDKFlags=void 0;let r={};t.SDKFlags={setFlags:(e,t)=>{r[e]=t},get:(e,t)=>{var n,o;return null!=(o=null==(n=r[e])?void 0:n[t])&&o}}},2442(e,t){"use strict";let r;Object.defineProperty(t,"__esModule",{value:!0}),t.SDKType=void 0;let n={};t.SDKType={_get:e=>{var t;return(null!=(t=n[e])?t:"js-mono")+(null!=r?r:"")},_setClientType(e,t){n[e]=t},_setBindingType(e){r&&"-react"!==r||(r="-"+e)}}},6650(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._getUnloadEvent=t._getCurrentPageUrlSafe=t._addDocumentEventListenerSafe=t._addWindowEventListenerSafe=t._isServerEnv=t._getDocumentSafe=t._getWindowSafe=void 0,t._getWindowSafe=()=>"u">typeof window?window:null,t._getDocumentSafe=()=>{var e;let r=(0,t._getWindowSafe)();return null!=(e=null==r?void 0:r.document)?e:null},t._isServerEnv=()=>{if(null!==(0,t._getDocumentSafe)())return!1;let e="u">typeof process&&null!=process.versions&&null!=process.versions.node;return"string"==typeof EdgeRuntime||e},t._addWindowEventListenerSafe=(e,r)=>{let n=(0,t._getWindowSafe)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(e,r)},t._addDocumentEventListenerSafe=(e,r)=>{let n=(0,t._getDocumentSafe)();"function"==typeof(null==n?void 0:n.addEventListener)&&n.addEventListener(e,r)},t._getCurrentPageUrlSafe=()=>{var e;try{return null==(e=(0,t._getWindowSafe)())?void 0:e.location.href.split(/[?#]/)[0]}catch(e){return}},t._getUnloadEvent=()=>{let e=(0,t._getWindowSafe)();return e&&"onpagehide"in e?"pagehide":"beforeunload"}},4899(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StatsigSession=t.SessionID=void 0;let n=r(8657),o=r(981),a=r(2132),i=r(6346),s=r(2555),l={};function c(e,t){return setTimeout(()=>{var t;let r=null==(t=(0,n._getStatsigGlobal)())?void 0:t.instance(e);r&&r.$emt({name:"session_expired"})},t)}function u(e){return`statsig.session_id.${(0,o._getStorageKey)(e)}`}t.SessionID={get:e=>t.StatsigSession.get(e).data.sessionID},t.StatsigSession={get:e=>{var t;let r,n,o;return null==l[e]&&(l[e]=(n=(r=u(t=e),(0,i._getObjectFromStorage)(r)),o=Date.now(),n||(n={sessionID:(0,s.getUUID)(),startTime:o,lastUpdate:o}),{data:n,sdkKey:t})),function(e){let t=Date.now(),r=e.data,n=e.sdkKey;if(function({lastUpdate:e}){return Date.now()-e>18e5}(r)||function({startTime:e}){return Date.now()-e>144e5}(r)){r.sessionID=(0,s.getUUID)(),r.startTime=t;let e=null==__STATSIG__?void 0:__STATSIG__.instance(n);e&&e.$emt({name:"session_expired"})}r.lastUpdate=t,function(e,t){let r=u(t);try{(0,i._setObjectInStorage)(r,e)}catch(e){a.Log.warn("Failed to save SessionID")}}(r,e.sdkKey),clearTimeout(e.idleTimeoutID),clearTimeout(e.ageTimeoutID);let o=t-r.startTime;return e.idleTimeoutID=c(n,18e5),e.ageTimeoutID=c(n,144e5-o),e}(l[e])},overrideInitialSessionID:(e,t)=>{var r,n;let o;l[t]=(r=e,n=t,{data:{sessionID:r,startTime:o=Date.now(),lastUpdate:o},sdkKey:n})}}},5940(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._fastApproxSizeOf=void 0,t._fastApproxSizeOf=(e,r)=>{let n=0,o=Object.keys(e);for(let a=0;a<o.length;a++){let i=o[a],s=e[i];if(n+=i.length,"object"==typeof s&&null!==s?n+=(0,t._fastApproxSizeOf)(s,r)+2:n+=String(s).length+1,n>=r)break}return n}},6286(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getCookieName=t.StableID=void 0;let n=r(981),o=r(2132),a=r(6650),i=r(6346),s=r(2555),l={},c={},u={};function d(e){return`statsig.stable_id.${(0,n._getStorageKey)(e)}`}function g(e,t){let r=d(t);try{(0,i._setObjectInStorage)(r,e)}catch(e){o.Log.warn("Failed to save StableID to storage")}}function h(e,t){if(!c[t]||null==(0,a._getDocumentSafe)())return;let r=new Date;r.setFullYear(r.getFullYear()+1),document.cookie=`${p(t)}=${encodeURIComponent(e)}; expires=${r.toUTCString()}; path=/`}function p(e){return`statsig.stable_id.${(0,n._getStorageKey)(e)}`}t.StableID={cookiesEnabled:!1,randomID:Math.random().toString(36),get:e=>{let t;if(u[e])return null;if(null!=l[e])return l[e];let r=null;return null!=(r=function(e){if(!c[e]||null==(0,a._getDocumentSafe)())return null;for(let t of document.cookie.split(";")){let[r,n]=t.trim().split("=");if(r===p(e))return decodeURIComponent(n)}return null}(e))?(l[e]=r,g(r,e)):(null==(t=d(e),r=(0,i._getObjectFromStorage)(t))&&(r=(0,s.getUUID)()),g(r,e),h(r,e),l[e]=r),r},setOverride:(e,t)=>{l[t]=e,g(e,t),h(e,t)},_setCookiesEnabled:(e,t)=>{c[e]=t},_setDisabled:(e,t)=>{u[e]=t}},t.getCookieName=p},5939(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.StatsigClientBase=void 0,r(8657);let o=r(8657),a=r(1290),i=r(638),s=r(2132),l=r(6375),c=r(6650),u=r(4899),d=r(6286),g=r(5910),h=r(6346);t.StatsigClientBase=class{constructor(e,t,r,n){var l,g,p,f;this.loadingStatus="Uninitialized",this._initializePromise=null,this._listeners={};const b=this.$emt.bind(this);(null==n?void 0:n.logLevel)!=null&&(s.Log.level=n.logLevel),(null==n?void 0:n.disableStorage)&&h.Storage._setDisabled(!0),(null==n?void 0:n.initialSessionID)&&u.StatsigSession.overrideInitialSessionID(n.initialSessionID,e),(null==n?void 0:n.storageProvider)&&h.Storage._setProvider(n.storageProvider),(null==n?void 0:n.enableCookies)&&d.StableID._setCookiesEnabled(e,n.enableCookies),(null==n?void 0:n.disableStableID)&&d.StableID._setDisabled(e,!0),this._sdkKey=e,this._options=null!=n?n:{},this._memoCache={},this.overrideAdapter=null!=(l=null==n?void 0:n.overrideAdapter)?l:null,this._logger=new i.EventLogger(e,b,r,n),this._errorBoundary=new a.ErrorBoundary(e,n,b),this._errorBoundary.wrap(this),this._errorBoundary.wrap(t),this._errorBoundary.wrap(this._logger),r.setErrorBoundary(this._errorBoundary),this.dataAdapter=t,this.dataAdapter.attach(e,n,r),this.storageProvider=h.Storage,null==(f=null==(p=null==(g=this.overrideAdapter)?void 0:g.loadFromStorage)?void 0:p.call(g))||f.catch(e=>this._errorBoundary.logError("OA::loadFromStorage",e)),this._primeReadyRipcord(),function(e,t){var r;if((0,c._isServerEnv)())return;let n=(0,o._getStatsigGlobal)(),a=null!=(r=n.instances)?r:{};null!=a[e]&&s.Log.warn("Creating multiple Statsig clients with the same SDK key can lead to unexpected behavior. Multi-instance support requires different SDK keys."),a[e]=t,n.firstInstance||(n.firstInstance=t),n.instances=a,__STATSIG__=n}(e,this)}updateRuntimeOptions(e){e.loggingEnabled?(this._options.loggingEnabled=e.loggingEnabled,this._logger.setLoggingEnabled(e.loggingEnabled)):null!=e.disableLogging&&(this._options.disableLogging=e.disableLogging,this._logger.setLoggingEnabled(e.disableLogging?"disabled":"browser-only")),null!=e.disableStorage&&(this._options.disableStorage=e.disableStorage,h.Storage._setDisabled(e.disableStorage)),null!=e.enableCookies&&(this._options.enableCookies=e.enableCookies,d.StableID._setCookiesEnabled(this._sdkKey,e.enableCookies)),e.logEventCompressionMode?this._logger.setLogEventCompressionMode(e.logEventCompressionMode):e.disableCompression&&this._logger.setLogEventCompressionMode(g.LogEventCompressionMode.Disabled)}flush(){return this._logger.flush()}shutdown(){return n(this,void 0,void 0,function*(){this.$emt({name:"pre_shutdown"}),this._setStatus("Uninitialized",null),this._initializePromise=null,yield this._logger.stop()})}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){if(this._listeners[e]){let r=this._listeners[e].indexOf(t);-1!==r&&this._listeners[e].splice(r,1)}}$on(e,t){t.__isInternal=!0,this.on(e,t)}$emt(e){var t;let r=t=>{try{t(e)}catch(r){if(!0===t.__isInternal)return void this._errorBoundary.logError(`__emit:${e.name}`,r);s.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",e)}};this._listeners[e.name]&&this._listeners[e.name].forEach(e=>r(e)),null==(t=this._listeners["*"])||t.forEach(r)}_setStatus(e,t){this.loadingStatus=e,this._memoCache={},this.$emt({name:"values_updated",status:e,values:t})}_enqueueExposure(e,t,r){(null==r?void 0:r.disableExposureLog)===!0?this._logger.incrementNonExposureCount(e):this._logger.enqueue(t)}_memoize(e,t){return(r,n)=>{if(this._options.disableEvaluationMemoization)return t(r,n);let o=(0,l.createMemoKey)(e,r,n);return o?(o in this._memoCache||(Object.keys(this._memoCache).length>=3e3&&(thi