configcat-js
Version:
ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.
1 lines • 127 kB
JavaScript
var configcat;(()=>{"use strict";var e={4474:(e,t,r)=>{r.r(t),r.d(t,{ClientCacheState:()=>z,DataGovernance:()=>ke,FormattableLogMessage:()=>me,LogLevel:()=>J,OverrideBehaviour:()=>Ue,PollingMode:()=>Le,PrerequisiteFlagComparator:()=>W,RefreshResult:()=>H,SegmentComparator:()=>_,SettingKeyValue:()=>Dt,SettingType:()=>V,User:()=>ut,UserComparator:()=>q,createConsoleLogger:()=>_t,createFlagOverridesFromMap:()=>Kt,default:()=>Yt,disposeAllClients:()=>Wt,getClient:()=>Jt});var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return i=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},i.apply(this,arguments)};function s(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))}function a(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function u(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}function c(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var l=function(){function e(e,t,r,n){this.configJson=e,this.config=t,this.timestamp=r,this.httpETag=n}return e.contentEquals=function(e,t){return e.httpETag&&t.httpETag?e.httpETag===t.httpETag:e.configJson===t.configJson},e.prototype.with=function(t){return new e(this.configJson,this.config,t,this.httpETag)},Object.defineProperty(e.prototype,"isEmpty",{get:function(){return!this.config},enumerable:!1,configurable:!0}),e.prototype.isExpired=function(t){return this===e.empty||this.timestamp+t<e.generateTimestamp()},e.generateTimestamp=function(){return(new Date).getTime()},e.serialize=function(e){var t,r;return e.timestamp+"\n"+(null!==(t=e.httpETag)&&void 0!==t?t:"")+"\n"+(null!==(r=e.configJson)&&void 0!==r?r:"")},e.deserialize=function(t){for(var r=Array(2),n=0,o=0;o<r.length;o++){if((n=t.indexOf("\n",n))<0)throw new Error("Number of values is fewer than expected.");r[o]=n++}var i=r[0],s=t.substring(0,i),a=parseInt(s);if(isNaN(a))throw new Error("Invalid fetch time: "+s);n=i+1,i=r[1];var u,c,l=(s=t.substring(n,i)).length>0?s:void 0;return n=i+1,(s=t.substring(n)).length>0&&(u=f.deserialize(s),c=s),new e(c,u,a,l)},e.serializationFormatVersion="v2",e.empty=new e(void 0,void 0,0,void 0),e}(),f=function(){function e(e){var t,r,n=this;this.preferences=null!=e.p?new h(e.p):void 0,this.segments=null!==(r=null===(t=e.s)||void 0===t?void 0:t.map((function(e){return new p(e)})))&&void 0!==r?r:[],this.settings=null!=e.f?Object.fromEntries(Object.entries(e.f).map((function(e){var t=e[0],r=e[1];return[t,new d(r,n)]}))):{}}return e.deserialize=function(t){var r=JSON.parse(t);if("object"!=typeof r||!r)throw new Error("Invalid config JSON content:"+t);return new e(r)},Object.defineProperty(e.prototype,"salt",{get:function(){var e;return null===(e=this.preferences)||void 0===e?void 0:e.salt},enumerable:!1,configurable:!0}),e}(),h=function(e){this.baseUrl=e.u,this.redirectMode=e.r,this.salt=e.s},p=function(e){var t,r;this.name=e.n,this.conditions=null!==(r=null===(t=e.r)||void 0===t?void 0:t.map((function(e){return new m(e)})))&&void 0!==r?r:[]},g=function(e,t){void 0===t&&(t=!1),this.value=t?e.v:b(e.v),this.variationId=e.i},d=function(e){function t(t,r){var n,o,i,s,a,u,c=e.call(this,t,t.t<0)||this;return c.type=t.t,c.percentageOptionsAttribute=null!==(n=t.a)&&void 0!==n?n:"Identifier",c.targetingRules=null!==(i=null===(o=t.r)||void 0===o?void 0:o.map((function(e){return new v(e,r)})))&&void 0!==i?i:[],c.percentageOptions=null!==(a=null===(s=t.p)||void 0===s?void 0:s.map((function(e){return new y(e)})))&&void 0!==a?a:[],c.configJsonSalt=null!==(u=null==r?void 0:r.salt)&&void 0!==u?u:"",c}return o(t,e),t.fromValue=function(e){return new t({t:-1,v:e})},t}(g),v=function(e,t){var r,n;this.conditions=null!==(n=null===(r=e.c)||void 0===r?void 0:r.map((function(e){return null!=e.u?new m(e.u):null!=e.p?new O(e.p):null!=e.s?new E(e.s,t):void 0})))&&void 0!==n?n:[],this.then=null!=e.p?e.p.map((function(e){return new y(e)})):new g(e.s)},y=function(e){function t(t){var r=e.call(this,t)||this;return r.percentage=t.p,r}return o(t,e),t}(g),m=function(e){var t,r;this.type="UserCondition",this.comparisonAttribute=e.a,this.comparator=e.c,this.comparisonValue=null!==(r=null!==(t=e.s)&&void 0!==t?t:e.d)&&void 0!==r?r:e.l},O=function(e){this.type="PrerequisiteFlagCondition",this.prerequisiteFlagKey=e.f,this.comparator=e.c,this.comparisonValue=b(e.v)},E=function(e,t){this.type="SegmentCondition",this.segment=t.segments[e.s],this.comparator=e.c};function b(e){var t,r,n;return null!==(n=null!==(r=null!==(t=e.b)&&void 0!==t?t:e.s)&&void 0!==r?r:e.i)&&void 0!==n?n:e.d}var S=function(){function e(){this.callbacks=[]}return Object.defineProperty(e.prototype,"aborted",{get:function(){return!this.callbacks},enumerable:!1,configurable:!0}),e.prototype.abort=function(){if(!this.aborted){var e=this.callbacks;this.callbacks=null;for(var t=0,r=e;t<r.length;t++)(0,r[t])()}},e.prototype.registerCallback=function(e){var t=this;return this.aborted?(e(),function(){}):(this.callbacks.push(e),function(){var r,n=t.callbacks;n&&(r=n.indexOf(e))>=0&&n.splice(r,1)})},e}();function T(e,t){var r;return new Promise((function(n){var o=null==t?void 0:t.registerCallback((function(){clearTimeout(r),n(!1)}));r=setTimeout((function(){null==o||o(),n(!0)}),e)}))}var w="undefined"!=typeof performance&&"function"==typeof performance.now?function(){return performance.now()}:function(){return(new Date).getTime()};function A(e,t){return void 0===t&&(t=!1),e instanceof Error?function e(r,n,o){var i=r.toString(),s=(n?n.substring(4)+"--\x3e ":n)+i;if(t&&r.stack){var a=r.stack.trim();0===a.lastIndexOf(i,0)&&(a=a.substring(i.length).trim()),s+="\n"+a.replace(/^\s*(?:at\s)?/gm,n+" at ")}if("undefined"!=typeof AggregateError&&r instanceof AggregateError){(null!=o?o:o=[]).push(r);for(var u=0,c=r.errors;u<c.length;u++){var l=c[u];if(l instanceof Error){if(o.indexOf(l)>=0)continue;s+="\n"+e(l,n+" ",o)}else s+="\n"+n+"--\x3e "+l}o.pop()}return s}(e,""):""+e}function C(e){throw e}function I(e){return null!==e&&"object"==typeof e&&!x(e)}function x(e){return Array.isArray(e)}function N(e){return x(e)&&!e.some((function(e){return"string"!=typeof e}))}function R(e,t,r,n){void 0===t&&(t=0),void 0===n&&(n=", ");var o=e.length;if(!o)return"";var i="";return t>0&&o>t&&(e=e.slice(0,t),r&&(i=r(o-t))),"'"+e.join("'"+n+"'")+"'"+i}function L(e){var t;return"function"==typeof(null===(t=e)||void 0===t?void 0:t.then)}function k(e){function t(e,t){var r=e.charCodeAt(t);if(55296<=r&&r<56320){var n=e.charCodeAt(t+1);if(56320<=n&&n<=57343)return(r<<10)+n-56613888}return r}var r,n="",o=0,i=String.fromCharCode;for(r=0;r<e.length;r++){var s=t(e,r);s<=127||(n+=e.slice(o,r),s<=2047?(n+=i(192|s>>6),n+=i(128|63&s)):s<=65535?(n+=i(224|s>>12),n+=i(128|s>>6&63),n+=i(128|63&s)):(n+=i(240|s>>18),n+=i(128|s>>12&63),n+=i(128|s>>6&63),n+=i(128|63&s),++r),o=r+1)}return n+e.slice(o,r)}function P(e){return"number"==typeof e?e:"string"!=typeof e||!e.length||/^\s*$|^\s*0[^\d.eE]/.test(e)?NaN:+e}function U(e,t){var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=e[n];r[n]=t?t(n,o):o}return r}var j,D=function(){function e(){this.cachedConfig=l.empty}return e.prototype.set=function(e,t){this.cachedConfig=t},e.prototype.get=function(e){return this.cachedConfig},e.prototype.getInMemory=function(){return this.cachedConfig},e}(),F=function(){function e(e,t){this.cache=e,this.logger=t,this.cachedConfig=l.empty}return e.prototype.set=function(e,t){return s(this,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t.isEmpty?(this.cachedSerializedConfig=void 0,this.cachedConfig=t,[2]):(this.cachedSerializedConfig=l.serialize(t),this.cachedConfig=t,[4,this.cache.set(e,this.cachedSerializedConfig)]);case 1:return n.sent(),[3,3];case 2:return r=n.sent(),this.logger.configServiceCacheWriteError(r),[3,3];case 3:return[2]}}))}))},e.prototype.updateCachedConfig=function(e){if(null==e||e===this.cachedSerializedConfig)return this.cachedConfig;var t=l.deserialize(e),r=!l.contentEquals(t,this.cachedConfig);return this.cachedConfig=t,this.cachedSerializedConfig=e,r?[this.cachedConfig]:this.cachedConfig},e.prototype.get=function(e){var t,r;try{var n=this.cache.get(e);if(L(n))return r=n,s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this.updateCachedConfig,[4,r];case 1:return e=t.apply(this,[o.sent()]),[3,3];case 2:return n=o.sent(),e=this.cachedConfig,this.logger.configServiceCacheReadError(n),[3,3];case 3:return[2,e]}}))}));t=this.updateCachedConfig(n)}catch(e){t=this.cachedConfig,this.logger.configServiceCacheReadError(e)}return t},e.prototype.getInMemory=function(){return this.cachedConfig},e}();!function(e){e[e.Fetched=0]="Fetched",e[e.NotModified=1]="NotModified",e[e.Errored=2]="Errored"}(j||(j={}));var M,V,q,W,_,K=function(){function e(e,t,r,n){this.status=e,this.config=t,this.errorMessage=r,this.errorException=n}return e.success=function(t){return new e(j.Fetched,t)},e.notModified=function(t){return new e(j.NotModified,t)},e.error=function(t,r,n){return new e(j.Errored,t,null!=r?r:"Unknown error.",n)},e}(),B=function(e){function t(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var i=e.call(this,function(e,t){switch(e){case"abort":return"Request was aborted.";case"timeout":return"Request timed out. Timeout value: "+t[0]+"ms";case"failure":var r=t[0],n="Request failed due to a network or protocol error.";return r?n+" "+(r instanceof Error?r.message:r+""):n}}(r,n))||this;return i.cause=r,i.name=t.name,i instanceof t||(Object.setPrototypeOf||function(e,t){return e.__proto__=t})(i,t.prototype),i.args=n,i}return o(t,e),t}(Error);!function(e){e[e.No=0]="No",e[e.Should=1]="Should",e[e.Force=2]="Force"}(M||(M={})),function(e){e[e.Boolean=0]="Boolean",e[e.String=1]="String",e[e.Int=2]="Int",e[e.Double=3]="Double"}(V||(V={})),function(e){e[e.TextIsOneOf=0]="TextIsOneOf",e[e.TextIsNotOneOf=1]="TextIsNotOneOf",e[e.TextContainsAnyOf=2]="TextContainsAnyOf",e[e.TextNotContainsAnyOf=3]="TextNotContainsAnyOf",e[e.SemVerIsOneOf=4]="SemVerIsOneOf",e[e.SemVerIsNotOneOf=5]="SemVerIsNotOneOf",e[e.SemVerLess=6]="SemVerLess",e[e.SemVerLessOrEquals=7]="SemVerLessOrEquals",e[e.SemVerGreater=8]="SemVerGreater",e[e.SemVerGreaterOrEquals=9]="SemVerGreaterOrEquals",e[e.NumberEquals=10]="NumberEquals",e[e.NumberNotEquals=11]="NumberNotEquals",e[e.NumberLess=12]="NumberLess",e[e.NumberLessOrEquals=13]="NumberLessOrEquals",e[e.NumberGreater=14]="NumberGreater",e[e.NumberGreaterOrEquals=15]="NumberGreaterOrEquals",e[e.SensitiveTextIsOneOf=16]="SensitiveTextIsOneOf",e[e.SensitiveTextIsNotOneOf=17]="SensitiveTextIsNotOneOf",e[e.DateTimeBefore=18]="DateTimeBefore",e[e.DateTimeAfter=19]="DateTimeAfter",e[e.SensitiveTextEquals=20]="SensitiveTextEquals",e[e.SensitiveTextNotEquals=21]="SensitiveTextNotEquals",e[e.SensitiveTextStartsWithAnyOf=22]="SensitiveTextStartsWithAnyOf",e[e.SensitiveTextNotStartsWithAnyOf=23]="SensitiveTextNotStartsWithAnyOf",e[e.SensitiveTextEndsWithAnyOf=24]="SensitiveTextEndsWithAnyOf",e[e.SensitiveTextNotEndsWithAnyOf=25]="SensitiveTextNotEndsWithAnyOf",e[e.SensitiveArrayContainsAnyOf=26]="SensitiveArrayContainsAnyOf",e[e.SensitiveArrayNotContainsAnyOf=27]="SensitiveArrayNotContainsAnyOf",e[e.TextEquals=28]="TextEquals",e[e.TextNotEquals=29]="TextNotEquals",e[e.TextStartsWithAnyOf=30]="TextStartsWithAnyOf",e[e.TextNotStartsWithAnyOf=31]="TextNotStartsWithAnyOf",e[e.TextEndsWithAnyOf=32]="TextEndsWithAnyOf",e[e.TextNotEndsWithAnyOf=33]="TextNotEndsWithAnyOf",e[e.ArrayContainsAnyOf=34]="ArrayContainsAnyOf",e[e.ArrayNotContainsAnyOf=35]="ArrayNotContainsAnyOf"}(q||(q={})),function(e){e[e.Equals=0]="Equals",e[e.NotEquals=1]="NotEquals"}(W||(W={})),function(e){e[e.IsIn=0]="IsIn",e[e.IsNotIn=1]="IsNotIn"}(_||(_={}));var z,G,H=function(){function e(e,t){this.errorMessage=e,this.errorException=t}return Object.defineProperty(e.prototype,"isSuccess",{get:function(){return null===this.errorMessage},enumerable:!1,configurable:!0}),e.from=function(t){return t.status!==j.Errored?e.success():e.failure(t.errorMessage,t.errorException)},e.success=function(){return new e(null)},e.failure=function(t,r){return new e(t,r)},e}();!function(e){e[e.NoFlagData=0]="NoFlagData",e[e.HasLocalOverrideFlagDataOnly=1]="HasLocalOverrideFlagDataOnly",e[e.HasCachedFlagDataOnly=2]="HasCachedFlagDataOnly",e[e.HasUpToDateFlagData=3]="HasUpToDateFlagData"}(z||(z={})),function(e){e[e.Online=0]="Online",e[e.Offline=1]="Offline",e[e.Disposed=2]="Disposed"}(G||(G={}));var J,Y=function(){function e(e,t){this.configFetcher=e,this.options=t,this.pendingCacheSyncUp=null,this.pendingConfigRefresh=null,this.cacheKey=t.getCacheKey(),this.configFetcher=e,this.options=t,this.status=t.offline?G.Offline:G.Online}return e.prototype.dispose=function(){this.status=G.Disposed},Object.defineProperty(e.prototype,"disposed",{get:function(){return this.status===G.Disposed},enumerable:!1,configurable:!0}),e.prototype.refreshConfigAsync=function(){return s(this,void 0,void 0,(function(){var e,t,r,n,o;return a(this,(function(i){switch(i.label){case 0:return[4,this.syncUpWithCache()];case 1:return e=i.sent(),this.isOffline?[3,3]:[4,this.refreshConfigCoreAsync(e)];case 2:return t=i.sent(),r=t[0],n=t[1],[2,[H.from(r),n]];case 3:return this.options.cache instanceof F?[2,[H.success(),e]]:(o=this.options.logger.configServiceCannotInitiateHttpCalls().toString(),[2,[H.failure(o),e]]);case 4:return[2]}}))}))},e.prototype.refreshConfigCoreAsync=function(e){var t=this;if(this.pendingConfigRefresh)return this.pendingConfigRefresh;var r=function(e){return s(t,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,this.fetchAsync(e)];case 1:return(t=r.sent()).status===j.Fetched||t.status===j.NotModified||t.config.timestamp>e.timestamp&&(!t.config.isEmpty||this.options.cache.getInMemory().isEmpty)?[4,this.options.cache.set(this.cacheKey,t.config)]:[3,3];case 2:r.sent(),e=t.config,r.label=3;case 3:return this.onConfigFetched(t.config),t.status===j.Fetched&&this.onConfigChanged(t.config),[2,[t,e]]}}))}))}(e);this.pendingConfigRefresh=r;try{r.finally((function(){return t.pendingConfigRefresh=null}))}catch(e){throw this.pendingConfigRefresh=null,e}return r},e.prototype.onConfigFetched=function(e){},e.prototype.onConfigChanged=function(e){var t;this.options.logger.debug("config changed"),this.options.hooks.emit("configChanged",null!==(t=e.config)&&void 0!==t?t:new f({}))},e.prototype.fetchAsync=function(e){var t;return s(this,void 0,void 0,(function(){var r,n,o,i,s,u;return a(this,(function(a){switch(a.label){case 0:(r=this.options).logger.debug("ConfigServiceBase.fetchAsync() - called."),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.fetchRequestAsync(null!==(t=e.httpETag)&&void 0!==t?t:null)];case 2:switch(o=a.sent(),i=o[0],s=o[1],i.statusCode){case 200:return s instanceof f?(r.logger.debug("ConfigServiceBase.fetchAsync(): fetch was successful. Returning new config."),[2,K.success(new l(i.body,s,l.generateTimestamp(),i.eTag))]):(n=r.logger.fetchReceived200WithInvalidBody(s).toString(),r.logger.debug("ConfigServiceBase.fetchAsync(): "+i.statusCode+" "+i.reasonPhrase+" was received but the HTTP response content was invalid. Returning null."),[2,K.error(e,n,s)]);case 304:return e.isEmpty?(n=r.logger.fetchReceived304WhenLocalCacheIsEmpty(i.statusCode,i.reasonPhrase).toString(),r.logger.debug("ConfigServiceBase.fetchAsync(): "+i.statusCode+" "+i.reasonPhrase+" was received when no config is cached locally. Returning null."),[2,K.error(e,n)]):(r.logger.debug("ConfigServiceBase.fetchAsync(): content was not modified. Returning last config with updated timestamp."),[2,K.notModified(e.with(l.generateTimestamp()))]);case 403:case 404:return n=r.logger.fetchFailedDueToInvalidSdkKey(r.sdkKey).toString(),r.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning last config (if any) with updated timestamp."),[2,K.error(e.with(l.generateTimestamp()),n)];default:return n=r.logger.fetchFailedDueToUnexpectedHttpResponse(i.statusCode,i.reasonPhrase).toString(),r.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning null."),[2,K.error(e,n)]}return[3,4];case 3:return u=a.sent(),n=(u instanceof B&&"timeout"===u.cause?r.logger.fetchFailedDueToRequestTimeout(u.args[0],u):r.logger.fetchFailedDueToUnexpectedError(u)).toString(),r.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning null."),[2,K.error(e,n,u)];case 4:return[2]}}))}))},e.prototype.fetchRequestAsync=function(e,t){return void 0===t&&(t=2),s(this,void 0,void 0,(function(){var r,n,o,i,s,u,c;return a(this,(function(a){switch(a.label){case 0:(r=this.options).logger.debug("ConfigServiceBase.fetchRequestAsync() - called."),n=0,a.label=1;case 1:return r.logger.debug("ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()"+(n>0?", retry "+n+"/"+t:"")),[4,this.configFetcher.fetchLogic(r,e)];case 2:if(200!==(o=a.sent()).statusCode)return[2,[o]];if(!o.body)return r.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."),[2,[o,new Error("No response body.")]];i=void 0;try{i=f.deserialize(o.body)}catch(e){return r.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."),[2,[o,e]]}if(!(s=i.preferences))return r.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences is empty."),[2,[o,i]];if(!(u=s.baseUrl)||u===r.baseUrl)return r.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."),[2,[o,i]];if(c=s.redirectMode,r.baseUrlOverriden&&c!==M.Force)return r.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."),[2,[o,i]];if(r.baseUrl=u,c===M.No)return[2,[o,i]];if(c===M.Should&&r.logger.dataGovernanceIsOutOfSync(),n>=t)return r.logger.fetchFailedDueToRedirectLoop(),[2,[o,i]];a.label=3;case 3:return n++,[3,1];case 4:return[2]}}))}))},Object.defineProperty(e.prototype,"isOfflineExactly",{get:function(){return this.status===G.Offline},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isOffline",{get:function(){return this.status!==G.Online},enumerable:!1,configurable:!0}),e.prototype.goOnline=function(){},e.prototype.setOnline=function(){this.status===G.Offline?(this.goOnline(),this.status=G.Online,this.options.logger.configServiceStatusChanged(G[this.status])):this.disposed&&this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline")},e.prototype.setOffline=function(){this.status===G.Online?(this.status=G.Offline,this.options.logger.configServiceStatusChanged(G[this.status])):this.disposed&&this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline")},e.prototype.syncUpWithCache=function(){var e=this,t=this.options.cache;if(t instanceof D)return t.get(this.cacheKey);if(this.pendingCacheSyncUp)return this.pendingCacheSyncUp;var r=t.get(this.cacheKey);if(!L(r))return this.onCacheSynced(r);var n=r.then((function(t){return e.onCacheSynced(t)}));this.pendingCacheSyncUp=n;try{n.finally((function(){return e.pendingCacheSyncUp=null}))}catch(e){throw this.pendingCacheSyncUp=null,e}return n},e.prototype.onCacheSynced=function(e){if(!Array.isArray(e))return e;var t=e[0];return t.isEmpty||this.onConfigChanged(t),t},e.prototype.getReadyPromise=function(e,t){return s(this,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:return[4,t(e)];case 1:return r=n.sent(),this.options.hooks.emit("clientReady",r),[2,r]}}))}))},e}(),$=function(e){function t(t,r){var n=e.call(this,t,r)||this;n.signalInitialization=function(){},n.stopToken=new S,n.pollIntervalMs=1e3*r.pollIntervalSeconds,n.pollExpirationMs=n.pollIntervalMs-500;var o=n.syncUpWithCache();if(0!==r.maxInitWaitTimeSeconds){n.initialized=!1;var i=new Promise((function(e){return n.signalInitialization=e}));n.initializationPromise=n.waitForInitializationAsync(i).then((function(e){return n.initialized=!0,e}))}else n.initialized=!0,n.initializationPromise=Promise.resolve(!1);return n.readyPromise=n.getReadyPromise(n.initializationPromise,(function(e){return s(n,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e];case 1:return t.sent(),[2,this.getCacheState(this.options.cache.getInMemory())]}}))}))})),n.startRefreshWorker(o,n.stopToken),n}return o(t,e),t.prototype.waitForInitializationAsync=function(e){return s(this,void 0,void 0,(function(){var t,r;return a(this,(function(n){switch(n.label){case 0:return this.options.maxInitWaitTimeSeconds<0?[4,e]:[3,2];case 1:return n.sent(),[2,!0];case 2:return t=new S,[4,Promise.race([e.then((function(){return!0})),T(1e3*this.options.maxInitWaitTimeSeconds,t).then((function(){return!1}))])];case 3:return r=n.sent(),t.abort(),[2,r]}}))}))},t.prototype.getConfig=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return this.options.logger.debug("AutoPollConfigService.getConfig() called."),[4,this.syncUpWithCache()];case 1:return(e=t.sent()).isExpired(this.pollIntervalMs)?[3,2]:(this.signalInitialization(),[3,5]);case 2:return this.isOffline||this.initialized?[3,4]:(this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired, waiting for initialization."),[4,this.initializationPromise]);case 3:return t.sent(),e=this.options.cache.getInMemory(),[3,5];case 4:return this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired."),[2,e];case 5:return this.options.logger.debug("AutoPollConfigService.getConfig() - returning value from cache."),[2,e]}}))}))},t.prototype.refreshConfigAsync=function(){return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."),e.prototype.refreshConfigAsync.call(this)},t.prototype.dispose=function(){this.options.logger.debug("AutoPollConfigService.dispose() called."),e.prototype.dispose.call(this),this.stopToken.aborted||this.stopRefreshWorker()},t.prototype.onConfigFetched=function(t){e.prototype.onConfigFetched.call(this,t),this.signalInitialization()},t.prototype.goOnline=function(){this.stopRefreshWorker(),this.stopToken=new S,this.startRefreshWorker(null,this.stopToken)},t.prototype.startRefreshWorker=function(e,t){return s(this,void 0,void 0,(function(){var r,n,o,i;return a(this,(function(s){switch(s.label){case 0:this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called."),s.label=1;case 1:if(t.aborted)return[3,11];s.label=2;case 2:s.trys.push([2,9,,10]),r=w()+this.pollIntervalMs,s.label=3;case 3:return s.trys.push([3,5,,6]),[4,this.refreshWorkerLogic(e)];case 4:return s.sent(),[3,6];case 5:return n=s.sent(),this.options.logger.autoPollConfigServiceErrorDuringPolling(n),[3,6];case 6:return(o=r-w())>0?[4,T(o,t)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:return i=s.sent(),this.options.logger.autoPollConfigServiceErrorDuringPolling(i),[3,10];case 10:return e=null,[3,1];case 11:return[2]}}))}))},t.prototype.stopRefreshWorker=function(){this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() called."),this.stopToken.abort()},t.prototype.refreshWorkerLogic=function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - called."),[4,null!=e?e:this.syncUpWithCache()];case 1:return(t=r.sent()).isExpired(this.pollExpirationMs)?(e?this.isOfflineExactly:this.isOffline)?[3,3]:[4,this.refreshConfigCoreAsync(t)]:[3,3];case 2:return r.sent(),[2];case 3:return this.signalInitialization(),[2]}}))}))},t.prototype.getCacheState=function(e){return e.isEmpty?z.NoFlagData:e.isExpired(this.pollIntervalMs)?z.HasCachedFlagDataOnly:z.HasUpToDateFlagData},t}(Y);!function(e){e[e.Debug=4]="Debug",e[e.Info=3]="Info",e[e.Warn=2]="Warn",e[e.Error=1]="Error",e[e.Off=-1]="Off"}(J||(J={}));var Q,X,Z,ee,te,re,ne,oe,ie,se,ae,ue,ce,le,fe,he,pe,ge,de,ve,ye,me=function(){function e(e,t,r){this.strings=e,this.argNames=t,this.argValues=r}return e.from=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return function(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return new e(r,t,n)}},Object.defineProperty(e.prototype,"defaultFormattedMessage",{get:function(){var e=this.cachedDefaultFormattedMessage;if(void 0===e){e="";for(var t=this.strings,r=this.argValues,n=0;n<t.length-1;n++)e+=t[n],e+=r[n];e+=t[n],this.cachedDefaultFormattedMessage=e}return e},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.defaultFormattedMessage},e}(),Oe=function(){function e(e,t){this.logger=e,this.hooks=t}return Object.defineProperty(e.prototype,"level",{get:function(){var e;return null!==(e=this.logger.level)&&void 0!==e?e:J.Warn},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eol",{get:function(){var e;return null!==(e=this.logger.eol)&&void 0!==e?e:"\n"},enumerable:!1,configurable:!0}),e.prototype.isEnabled=function(e){return this.level>=e},e.prototype.log=function(e,t,r,n){var o;return this.isEnabled(e)&&this.logger.log(e,t,r,n),e===J.Error&&(null===(o=this.hooks)||void 0===o||o.emit("clientError",r.toString(),n)),r},e.prototype.debug=function(e){this.log(J.Debug,0,e)},e.prototype.configJsonIsNotPresent=function(e){return this.log(J.Error,1e3,me.from("DEFAULT_RETURN_VALUE")(Q||(Q=c(["Config JSON is not present. Returning ","."],["Config JSON is not present. Returning ","."])),e))},e.prototype.configJsonIsNotPresentSingle=function(e,t,r){return this.log(J.Error,1e3,me.from("KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE")(X||(X=c(["Config JSON is not present when evaluating setting '","'. Returning the `","` parameter that you specified in your application: '","'."],["Config JSON is not present when evaluating setting '","'. Returning the \\`","\\` parameter that you specified in your application: '","'."])),e,t,r))},e.prototype.settingEvaluationFailedDueToMissingKey=function(e,t,r,n){return this.log(J.Error,1001,me.from("KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE","AVAILABLE_KEYS")(Z||(Z=c(["Failed to evaluate setting '","' (the key was not found in config JSON). Returning the `","` parameter that you specified in your application: '","'. Available keys: [","]."],["Failed to evaluate setting '","' (the key was not found in config JSON). Returning the \\`","\\` parameter that you specified in your application: '","'. Available keys: [","]."])),e,t,r,n))},e.prototype.settingEvaluationError=function(e,t,r){return this.log(J.Error,1002,me.from("METHOD_NAME","DEFAULT_RETURN_VALUE")(ee||(ee=c(["Error occurred in the `","` method. Returning ","."],["Error occurred in the \\`","\\` method. Returning ","."])),e,t),r)},e.prototype.settingEvaluationErrorSingle=function(e,t,r,n,o){return this.log(J.Error,1002,me.from("METHOD_NAME","KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE")(te||(te=c(["Error occurred in the `","` method while evaluating setting '","'. Returning the `","` parameter that you specified in your application: '","'."],["Error occurred in the \\`","\\` method while evaluating setting '","'. Returning the \\`","\\` parameter that you specified in your application: '","'."])),e,t,r,n),o)},e.prototype.forceRefreshError=function(e,t){return this.log(J.Error,1003,me.from("METHOD_NAME")(re||(re=c(["Error occurred in the `","` method."],["Error occurred in the \\`","\\` method."])),e),t)},e.prototype.fetchFailedDueToInvalidSdkKey=function(e){return e=be(e),this.log(J.Error,1100,me.from("SDK_KEY")(ne||(ne=c(["Your SDK Key seems to be wrong: '","'. You can find the valid SDK Key at https://app.configcat.com/sdkkey"],["Your SDK Key seems to be wrong: '","'. You can find the valid SDK Key at https://app.configcat.com/sdkkey"])),e))},e.prototype.fetchFailedDueToUnexpectedHttpResponse=function(e,t){return this.log(J.Error,1101,me.from("STATUS_CODE","REASON_PHRASE")(oe||(oe=c(["Unexpected HTTP response was received while trying to fetch config JSON: "," ",""],["Unexpected HTTP response was received while trying to fetch config JSON: "," ",""])),e,t))},e.prototype.fetchFailedDueToRequestTimeout=function(e,t){return this.log(J.Error,1102,me.from("TIMEOUT")(ie||(ie=c(["Request timed out while trying to fetch config JSON. Timeout value: ","ms"],["Request timed out while trying to fetch config JSON. Timeout value: ","ms"])),e),t)},e.prototype.fetchFailedDueToUnexpectedError=function(e){return this.log(J.Error,1103,"Unexpected error occurred while trying to fetch config JSON. It is most likely due to a local network issue. Please make sure your application can reach the ConfigCat CDN servers (or your proxy server) over HTTP.",e)},e.prototype.fetchFailedDueToRedirectLoop=function(){return this.log(J.Error,1104,"Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/")},e.prototype.fetchReceived200WithInvalidBody=function(e){return this.log(J.Error,1105,"Fetching config JSON was successful but the HTTP response content was invalid.",e)},e.prototype.fetchReceived304WhenLocalCacheIsEmpty=function(e,t){return this.log(J.Error,1106,me.from("STATUS_CODE","REASON_PHRASE")(se||(se=c(["Unexpected HTTP response was received when no config JSON is cached locally: "," ",""],["Unexpected HTTP response was received when no config JSON is cached locally: "," ",""])),e,t))},e.prototype.autoPollConfigServiceErrorDuringPolling=function(e){return this.log(J.Error,1200,"Error occurred during auto polling.",e)},e.prototype.settingForVariationIdIsNotPresent=function(e){return this.log(J.Error,2011,me.from("VARIATION_ID")(ae||(ae=c(["Could not find the setting for the specified variation ID: '","'."],["Could not find the setting for the specified variation ID: '","'."])),e))},e.prototype.configServiceCacheReadError=function(e){return this.log(J.Error,2200,"Error occurred while reading the cache.",e)},e.prototype.configServiceCacheWriteError=function(e){return this.log(J.Error,2201,"Error occurred while writing the cache.",e)},e.prototype.clientIsAlreadyCreated=function(e){return e=be(e),this.log(J.Warn,3e3,me.from("SDK_KEY")(ue||(ue=c(["There is an existing client instance for the specified SDK Key. No new client instance will be created and the specified options are ignored. Returning the existing client instance. SDK Key: '","'."],["There is an existing client instance for the specified SDK Key. No new client instance will be created and the specified options are ignored. Returning the existing client instance. SDK Key: '","'."])),e))},e.prototype.userObjectIsMissing=function(e){return this.log(J.Warn,3001,me.from("KEY")(ce||(ce=c(["Cannot evaluate targeting rules and % options for setting '","' (User Object is missing). You should pass a User Object to the evaluation methods like `getValueAsync()` in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"],["Cannot evaluate targeting rules and % options for setting '","' (User Object is missing). You should pass a User Object to the evaluation methods like \\`getValueAsync()\\` in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"])),e))},e.prototype.dataGovernanceIsOutOfSync=function(){return this.log(J.Warn,3002,"The `dataGovernance` parameter specified at the client initialization is not in sync with the preferences on the ConfigCat Dashboard. Read more: https://configcat.com/docs/advanced/data-governance/")},e.prototype.userObjectAttributeIsMissingPercentage=function(e,t){return this.log(J.Warn,3003,me.from("KEY","ATTRIBUTE_NAME","ATTRIBUTE_NAME")(le||(le=c(["Cannot evaluate % options for setting '","' (the User."," attribute is missing). You should set the User."," attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"],["Cannot evaluate % options for setting '","' (the User."," attribute is missing). You should set the User."," attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"])),e,t,t))},e.prototype.userObjectAttributeIsMissingCondition=function(e,t,r){return this.log(J.Warn,3003,me.from("CONDITION","KEY","ATTRIBUTE_NAME","ATTRIBUTE_NAME")(fe||(fe=c(["Cannot evaluate condition (",") for setting '","' (the User."," attribute is missing). You should set the User."," attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"],["Cannot evaluate condition (",") for setting '","' (the User."," attribute is missing). You should set the User."," attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"])),e,t,r,r))},e.prototype.userObjectAttributeIsInvalid=function(e,t,r,n){return this.log(J.Warn,3004,me.from("CONDITION","KEY","REASON","ATTRIBUTE_NAME")(he||(he=c(["Cannot evaluate condition (",") for setting '","' (","). Please check the User."," attribute and make sure that its value corresponds to the comparison operator."],["Cannot evaluate condition (",") for setting '","' (","). Please check the User."," attribute and make sure that its value corresponds to the comparison operator."])),e,t,r,n))},e.prototype.userObjectAttributeIsAutoConverted=function(e,t,r,n){return this.log(J.Warn,3005,me.from("CONDITION","KEY","ATTRIBUTE_NAME","ATTRIBUTE_VALUE")(pe||(pe=c(["Evaluation of condition (",") for setting '","' may not produce the expected result (the User."," attribute is not a string value, thus it was automatically converted to the string value '","'). Please make sure that using a non-string value was intended."],["Evaluation of condition (",") for setting '","' may not produce the expected result (the User."," attribute is not a string value, thus it was automatically converted to the string value '","'). Please make sure that using a non-string value was intended."])),e,t,r,n))},e.prototype.configServiceCannotInitiateHttpCalls=function(){return this.log(J.Warn,3200,"Client is in offline mode, it cannot initiate HTTP calls.")},e.prototype.configServiceMethodHasNoEffectDueToDisposedClient=function(e){return this.log(J.Warn,3201,me.from("METHOD_NAME")(ge||(ge=c(["The client object is already disposed, thus `","()` has no effect."],["The client object is already disposed, thus \\`","()\\` has no effect."])),e))},e.prototype.configServiceMethodHasNoEffectDueToOverrideBehavior=function(e,t){return this.log(J.Warn,3202,me.from("OVERRIDE_BEHAVIOR","METHOD_NAME")(de||(de=c(["Client is configured to use the `","` override behavior, thus `","()` has no effect."],["Client is configured to use the \\`","\\` override behavior, thus \\`","()\\` has no effect."])),e,t))},e.prototype.settingEvaluated=function(e){return this.log(J.Info,5e3,me.from("EVALUATE_LOG")(ve||(ve=c(["",""],["",""])),e))},e.prototype.configServiceStatusChanged=function(e){return this.log(J.Info,5200,me.from("MODE")(ye||(ye=c(["Switched to "," mode."],["Switched to "," mode."])),e.toUpperCase()))},e}(),Ee=function(){function e(e,t){void 0===e&&(e=J.Warn),void 0===t&&(t="\n"),this.level=e,this.eol=t,this.SOURCE="ConfigCat"}return e.prototype.log=function(e,t,r,n){var o=e===J.Debug?[console.info,"DEBUG"]:e===J.Info?[console.info,"INFO"]:e===J.Warn?[console.warn,"WARN"]:e===J.Error?[console.error,"ERROR"]:[console.log,J[e].toUpperCase()],i=o[0],s=o[1],a=void 0!==n?this.eol+A(n,!0):"";i(this.SOURCE+" - "+s+" - ["+t+"] "+r+a)},e}();function be(e){return e.substring(0,e.length-6).replace(/[^/]/g,"*")+e.substring(e.length-6)}function Se(e){return!!e.fn}var Te=function(){function e(){this.events={},this.eventCount=0,this.addListener=this.on,this.off=this.removeListener}return e.prototype.addListenerCore=function(e,t,r){if("function"!=typeof t)throw new TypeError("Listener must be a function");var n=this.events[e],o={fn:t,once:r};return n?Se(n)?this.events[e]=[n,o]:n.push(o):(this.events[e]=o,this.eventCount++),this},e.prototype.removeListenerCore=function(e,t,r){var n=this.events[e];if(!n)return this;if(Se(n))r(n,t)&&this.removeEvent(e);else for(var o=n.length-1;o>=0;o--)if(r(n[o],t)){n.splice(o,1),n.length?1===n.length&&(this.events[e]=n[0]):this.removeEvent(e);break}return this},e.prototype.removeEvent=function(e){0==--this.eventCount?this.events={}:delete this.events[e]},e.prototype.on=function(e,t){return this.addListenerCore(e,t,!1)},e.prototype.once=function(e,t){return this.addListenerCore(e,t,!0)},e.prototype.removeListener=function(e,t){if("function"!=typeof t)throw new TypeError("Listener must be a function");return this.removeListenerCore(e,t,(function(e,t){return e.fn===t}))},e.prototype.removeAllListeners=function(e){return e?this.events[e]&&this.removeEvent(e):(this.events={},this.eventCount=0),this},e.prototype.listeners=function(e){var t=this.events[e];if(!t)return[];if(Se(t))return[t.fn];for(var r=t.length,n=new Array(r),o=0;o<r;o++)n[o]=t[o].fn;return n},e.prototype.listenerCount=function(e){var t=this.events[e];return t?Se(t)?1:t.length:0},e.prototype.eventNames=function(){var e=[];if(0===this.eventCount)return e;var t=this.events;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},e.prototype.emit=function(e,t,r,n,o){for(var i,s,a=[],u=5;u<arguments.length;u++)a[u-5]=arguments[u];var c,l,f=this.events[e];if(!f)return!1;Se(f)?(c=(i=[f,1])[0],l=i[1]):(c=(s=[(f=f.slice())[0],f.length])[0],l=s[1]);for(var h=arguments.length-1,p=0;;){switch(c.once&&this.removeListenerCore(e,c,(function(e,t){return e===t})),h){case 0:c.fn.call(this);break;case 1:c.fn.call(this,t);break;case 2:c.fn.call(this,t,r);break;case 3:c.fn.call(this,t,r,n);break;case 4:c.fn.call(this,t,r,n,o);break;default:for(var g=new Array(h),d=0;d<h;d++)g[d]=arguments[d+1];c.fn.apply(this,g)}if(++p>=l)break;c=f[p]}return!0},e}(),we=function(){function e(){this.addListener=this.on,this.off=this.removeListener}return e.prototype.on=function(){return this},e.prototype.once=function(){return this},e.prototype.removeListener=function(){return this},e.prototype.removeAllListeners=function(){return this},e.prototype.listeners=function(){return[]},e.prototype.listenerCount=function(){return 0},e.prototype.eventNames=function(){return[]},e.prototype.emit=function(){return!1},e}();function Ae(e){function t(e,t){return e<<t|e>>>32-t}var r,n,o,i,s,a,u,c,l,f=new Array(80),h=1732584193,p=4023233417,g=2562383102,d=271733878,v=3285377520,y=(e=k(e)).length,m=new Array;for(n=0;n<y-3;n+=4)o=e.charCodeAt(n)<<24|e.charCodeAt(n+1)<<16|e.charCodeAt(n+2)<<8|e.charCodeAt(n+3),m.push(o);switch(y%4){case 0:n=2147483648;break;case 1:n=e.charCodeAt(y-1)<<24|8388608;break;case 2:n=e.charCodeAt(y-2)<<24|e.charCodeAt(y-1)<<16|32768;break;case 3:n=e.charCodeAt(y-3)<<24|e.charCodeAt(y-2)<<16|e.charCodeAt(y-1)<<8|128}for(m.push(n);m.length%16!=14;)m.push(0);for(m.push(y>>>29),m.push(y<<3&4294967295),r=0;r<m.length;r+=16){for(n=0;n<16;n++)f[n]=m[r+n];for(n=16;n<=79;n++)f[n]=t(f[n-3]^f[n-8]^f[n-14]^f[n-16],1);for(i=h,s=p,a=g,u=d,c=v,n=0;n<=19;n++)l=t(i,5)+(s&a|~s&u)+c+f[n]+1518500249&4294967295,c=u,u=a,a=t(s,30),s=i,i=l;for(n=20;n<=39;n++)l=t(i,5)+(s^a^u)+c+f[n]+1859775393&4294967295,c=u,u=a,a=t(s,30),s=i,i=l;for(n=40;n<=59;n++)l=t(i,5)+(s&a|s&u|a&u)+c+f[n]+2400959708&4294967295,c=u,u=a,a=t(s,30),s=i,i=l;for(n=60;n<=79;n++)l=t(i,5)+(s^a^u)+c+f[n]+3395469782&4294967295,c=u,u=a,a=t(s,30),s=i,i=l;h=h+i&4294967295,p=p+s&4294967295,g=g+a&4294967295,d=d+u&4294967295,v=v+c&4294967295}return Ie([h,p,g,d,v])}function Ce(e){function t(e,t){return e>>>t|e<<32-t}var r,n,o="length",i=Math.pow,s=i(2,32),a=Ce,u=a.h,c=a.k;if(!c){u=[],c=[];for(var l={},f=2,h=0;h<64;f++)if(!l[f]){for(r=0;r<313;r+=f)l[r]=f;u[h]=i(f,.5)*s|0,c[h++]=i(f,1/3)*s|0}a.h=u=u.slice(0,8),a.k=c}var p=8*e[o];e+="";for(var g=[];e[o]%64-56;)e+="\0";for(r=0;r<e[o];r++)n=e.charCodeAt(r),g[r>>2]|=n<<(3-r)%4*8;for(g[g[o]]=p/s|0,g[g[o]]=p,n=0;n<g[o];){var d=g.slice(n,n+=16),v=u;for(u=u.slice(0,8),r=0;r<64;r++){var y=d[r-15],m=d[r-2],O=u[0],E=u[4],b=u[7]+(t(E,6)^t(E,11)^t(E,25))+(E&u[5]^~E&u[6])+c[r]+(d[r]=r<16?d[r]:d[r-16]+(t(y,7)^t(y,18)^y>>>3)+d[r-7]+(t(m,17)^t(m,19)^m>>>10)|0);(u=[b+((t(O,2)^t(O,13)^t(O,22))+(O&u[1]^O&u[2]^u[1]&u[2]))|0].concat(u))[4]=u[4]+b|0}for(r=0;r<8;r++)u[r]=u[r]+v[r]|0}return Ie(u,8)}function Ie(e,t){var r="0123456789abcdef",n="";null!=t||(t=e.length);for(var o=0;o<t;o++)for(var i=3;i>=0;i--){var s=e[o]>>(i<<3)&255;n+=r[s>>4],n+=r[15&s]}return n}var xe=new we,Ne=function(){function e(e){this.addListener=this.on,this.off=this.removeListener,this.eventEmitter=e}return e.prototype.tryDisconnect=function(){var e=this.eventEmitter;return this.eventEmitter=xe,e!==xe},e.prototype.on=function(e,t){return this.eventEmitter.on(e,t),this},e.prototype.once=function(e,t){return this.eventEmitter.once(e,t),this},e.prototype.removeListener=function(e,t){return this.eventEmitter.removeListener(e,t),this},e.prototype.removeAllListeners=function(e){return this.eventEmitter.removeAllListeners(e),this},e.prototype.listeners=function(e){return this.eventEmitter.listeners(e)},e.prototype.listenerCount=function(e){return this.eventEmitter.listenerCount(e)},e.prototype.eventNames=function(){return this.eventEmitter.eventNames()},e.prototype.emit=function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return(t=this.eventEmitter).emit.apply(t,u([e],r))},e}();function Re(){var e=function(e){this.target=e};return e.prototype.deref=function(){return this.target},e.isFallback=!0,e}var Le,ke,Pe=function(){return"function"==typeof WeakRef};!function(e){e[e.AutoPoll=0]="AutoPoll",e[e.LazyLoad=1]="LazyLoad",e[e.ManualPoll=2]="ManualPoll"}(Le||(Le={})),function(e){e[e.Global=0]="Global",e[e.EuOnly=1]="EuOnly"}(ke||(ke={}));var Ue,je=function(){function e(e,t,r,n,o){var i,s,a;if(this.requestTimeoutMs=3e4,this.baseUrlOverriden=!1,this.proxy="",this.offline=!1,!e)throw new Error("Invalid 'sdkKey' value");this.sdkKey=e,this.clientVersion=t,this.dataGovernance=null!==(i=null==r?void 0:r.dataGovernance)&&void 0!==i?i:ke.Global,this.dataGovernance===ke.EuOnly?this.baseUrl="https://cdn-eu.configcat.com":this.baseUrl="https://cdn-global.configcat.com";var c,l,f=null!==(s=null==o?void 0:o())&&void 0!==s?s:new Te,h=new Ne(f),p=new(Pe()?WeakRef:Re())(h);if(this.hooks={hooks:h,hooksWeakRef:p,emit:function(e){for(var t,r,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return null!==(r=null===(t=this.hooksWeakRef.deref())||void 0===t?void 0:t.emit.apply(t,u([e],n)))&&void 0!==r&&r}},r){if(c=r.logger,l=r.cache,r.requestTimeoutMs){if(r.requestTimeoutMs<0)throw new Error("Invalid 'requestTimeoutMs' value");this.requestTimeoutMs=r.requestTimeoutMs}r.baseUrl&&(this.baseUrl=r.baseUrl,this.baseUrlOverriden=!0),r.proxy&&(this.proxy=r.proxy),r.flagOverrides&&(this.flagOverrides=r.flagOverrides),r.defaultUser&&(this.defaultUser=r.defaultUser),r.offline&&(this.offline=r.offline),null===(a=r.setupHooks)||void 0===a||a.call(r,h)}this.logger=new Oe(null!=c?c:new Ee,this.hooks),this.cache=l?new F(l,this.logger):n?n(this):new D}return e.prototype.yieldHooks=function(){var e=this.hooks,t=e.hooks;return delete e.hooks,null!=t?t:new Ne(new we)},e.prototype.getUrl=function(){return this.baseUrl+"/configuration-files/"+this.sdkKey+"/"+e.configFileName+"?sdk="+this.clientVersion},e.prototype.getCacheKey=function(){return Ae(this.sdkKey+"_"+e.configFileName+"_"+l.serializationFormatVersion)},e.configFileName="config_v6.json",e}(),De=function(e){function t(t,r,n,o,i,s){var a=e.call(this,t,r+"/a-"+n,o,i,s)||this;a.pollIntervalSeconds=60,a.maxInitWaitTimeSeconds=5,o&&(null!=o.pollIntervalSeconds&&(a.pollIntervalSeconds=o.pollIntervalSeconds),null!=o.maxInitWaitTimeSeconds&&(a.maxInitWaitTimeSeconds=o.maxInitWaitTimeSeconds));var u=2147483;if(!("number"==typeof a.pollIntervalSeconds&&1<=a.pollIntervalSeconds&&a.pollIntervalSeconds<=u))throw new Error("Invalid 'pollIntervalSeconds' value");if(!("number"==typeof a.maxInitWaitTimeSeconds&&a.maxInitWaitTimeSeconds<=u))throw new Error("Invalid 'maxInitWaitTimeSeconds' value");return a}return o(t,e),t}(je),Fe=function(e){function t(t,r,n,o,i,s){return e.call(this,t,r+"/m-"+n,o,i,s)||this}return o(t,e),t}(je),Me=function(e){function t(t,r,n,o,i,s){var a=e.call(this,t,r+"/l-"+n,o,i,s)||this;if(a.cacheTimeToLiveSeconds=60,o&&null!=o.cacheTimeToLiveSeconds&&(a.cacheTimeToLiveSeconds=o.cacheTimeToLiveSeconds),!("number"==typeof a.cacheTimeToLiveSeconds&&1<=a.cacheTimeToLiveSeconds&&a.cacheTimeToLiveSeconds<=2147483647))throw new Error("Invalid 'cacheTimeToLiveSeconds' value");return a}return o(t,e),t}(je);!function(e){e[e.LocalOnly=0]="LocalOnly",e[e.LocalOverRemote=1]="LocalOverRemote",e[e.RemoteOverLocal=2]="RemoteOverLocal"}(Ue||(Ue={}));var Ve=function(){function e(e,t){this.initialSettings=this.constructor.getCurrentSettings(e),t&&(this.map=e)}return e.getCurrentSettings=function(e){return Object.fromEntries(Object.entries(e).map((function(e){var t=e[0],r=e[1];return[t,d.fromValue(r)]})))},e.prototype.getOverrides=function(){return Promise.resolve(this.getOverridesSync())},e.prototype.getOverridesSync=function(){return this.map?this.constructor.getCurrentSettings(this.map):this.initialSettings},e}(),qe=function(e,t){this.dataSource=e,this.behaviour=t},We=function(e){function t(t,r){var n=e.call(this,t,r)||this;n.cacheTimeToLiveMs=1e3*r.cacheTimeToLiveSeconds;var o=n.syncUpWithCache();return n.readyPromise=n.getReadyPromise(o,(function(e){return s(n,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return t=this.getCacheState,[4,e];case 1:return[2,t.apply(this,[r.sent()])]}}))}))})),n}return o(t,e),t.prototype.getConfig=function(){return s(this,void 0,void 0,(function(){function e(e,t){void 0===t&&(t=""),e.debug("LazyLoadConfigService.getConfig(): cache is empty or expired"+t+".")}var t,r;return a(this,(function(n){switch(n.label){case 0:return this.options.logger.debug("LazyLoadConfigService.getConfig() called."),[4,this.syncUpWithCache()];case 1:return(t=n.sent()).isExpired(this.cacheTimeToLiveMs)?this.isOffline?[3,3]:(e(this.options.logger,", calling refreshConfigCoreAsync()"),[4,this.refreshConfigCoreAsync(t)]):[3,5];case 2:return r=n.sent(),t=r[1],[3,4];case 3:e(this.options.logger),n.label=4;case 4:return[2,t];case 5:return this.options.logger.debug("LazyLoadConfigService.getConfig(): cache is valid, returning from cache."),[2,t]}}))}))},t.prototype.refreshConfigAsync=function(){return this.options.logger.debug("LazyLoadConfigService.refreshConfigAsync() called."),e.prototype.refreshConfigAsync.call(this)},t.prototype.getCacheState=function(e){return e.isEmpty?z.NoFlagData:e.isExpired(this.cacheTimeToLiveMs)?z.HasCachedFlagDataOnly:z.HasUpToDateFlagData},t}(Y),_e=function(e){function t(t,r){var n=e.call(this,t,r)||this,o=n.syncUpWithCache();return n.readyPromise=n.getReadyPromise(o,(function(e){return s(n,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return t=this.getCacheState,[4,e];case 1:return[2,t.apply(this,[r.sent()])]}}))}))})),n}return o(t,e),t.prototype.getCacheState=function(e){return e.isEmpty?z.NoFlagData:z.HasCachedFlagDataOnly},t.prototype.getConfig=function(){return s(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return this.options.logger.debug("ManualPollService.getConfig() called."),[4,this.syncUpWithCache()];case 1:return[2,e.sent()]}}))}))},t.prototype.refreshConfigAsync=function(){return this.options.logger.debug("ManualPollService.refreshConfigAsync() called."),e.prototype.refreshConfigAsync.call(this)},t}(Y),Ke="<invalid value>",Be="<invalid name>",ze="<invalid operator>",Ge="<invalid reference>",He=function(){function e(e){this.eol=e,this.log="",this.indent=""}return e.prototype.resetIndent=function(){return this.indent="",this},e.prototype.increaseIndent=function(){return this.indent+=" ",this},e.prototype.decreaseIndent=function(){return this.indent=this.indent.slice(0,-2),this},e.prototype.newLine=function(e){return this.log+=this.eol+this.indent+(null!=e?e:""),this},e.prototype.append=function(e){return this.log+=e