UNPKG

ibm-appconfiguration-js-client-sdk

Version:
1 lines 49.9 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AppConfiguration=t():e.AppConfiguration=t()}(self,(()=>{return e={228:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,i||e,a),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,i,a){var s=n?n+e:e;if(!this._events[s])return!1;var u,c,l=this._events[s],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,i),!0;case 6:return l.fn.call(l.context,t,r,o,i,a),!0}for(c=1,u=new Array(f-1);c<f;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var p,d=l.length;for(c=0;c<d;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),f){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,r);break;case 4:l[c].fn.call(l[c].context,t,r,o);break;default:if(!u)for(p=1,u=new Array(f-1);p<f;p++)u[p-1]=arguments[p];l[c].fn.apply(l[c].context,u)}}return!0},s.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||a(this,i);else{for(var u=0,c=[],l=s.length;u<l;u++)(s[u].fn!==t||o&&!s[u].once||r&&s[u].context!==r)&&c.push(s[u]);c.length?this._events[i]=1===c.length?c[0]:c:a(this,i)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s},5:e=>{!function(){const t=e=>(new TextEncoder).encode(e);function n(e,n){let r,o,i,a,s,u,c,l;for("string"==typeof e&&(e=t(e)),r=3&e.length,o=e.length-r,i=n,s=3432918353,u=461845907,l=0;l<o;)c=255&e[l]|(255&e[++l])<<8|(255&e[++l])<<16|(255&e[++l])<<24,++l,c=(65535&c)*s+(((c>>>16)*s&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(65535&c)*u+(((c>>>16)*u&65535)<<16)&4294967295,i^=c,i=i<<13|i>>>19,a=5*(65535&i)+((5*(i>>>16)&65535)<<16)&4294967295,i=27492+(65535&a)+((58964+(a>>>16)&65535)<<16);switch(c=0,r){case 3:c^=(255&e[l+2])<<16;case 2:c^=(255&e[l+1])<<8;case 1:c^=255&e[l],c=(65535&c)*s+(((c>>>16)*s&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(65535&c)*u+(((c>>>16)*u&65535)<<16)&4294967295,i^=c}return i^=e.length,i^=i>>>16,i=2246822507*(65535&i)+((2246822507*(i>>>16)&65535)<<16)&4294967295,i^=i>>>13,i=3266489909*(65535&i)+((3266489909*(i>>>16)&65535)<<16)&4294967295,i^=i>>>16,i>>>0}const r=n;r.v2=function(e,n){"string"==typeof e&&(e=t(e));let r,o=e.length,i=n^o,a=0;for(;o>=4;)r=255&e[a]|(255&e[++a])<<8|(255&e[++a])<<16|(255&e[++a])<<24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),r^=r>>>24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^r,o-=4,++a;switch(o){case 3:i^=(255&e[a+2])<<16;case 2:i^=(255&e[a+1])<<8;case 1:i^=255&e[a],i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)}return i^=i>>>13,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>15,i>>>0},r.v3=n,e.exports=r}()},184:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c=n(501),l=u(n(521)),f=u(n(922)),p=u(n(846)),d=n(623),h=i(n(139)),v=u(n(876)),_=u(n(103)),y=u(n(392)),g=n(628),b=y.default.getInstance(),E=_.default.getInstance(),m=new g.Logger(h.APP_CONFIGURATION),O=function(){function e(){}return e.prototype.init=function(e,t,n,r){this.region=e,this.guid=t,this.apikey=n,this.overrideServiceUrl=r},e.prototype.setContext=function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return b.init({region:this.region,guid:this.guid,apikey:this.apikey,overrideServiceUrl:this.overrideServiceUrl,collectionId:e,environmentId:t}),E.init(e,t),[4,this.connectEventSource()];case 1:return n.sent(),[2]}}))}))},e.prototype.saveInCache=function(e){var t={};Object.keys(e.environments[0].features).length&&e.environments[0].features.forEach((function(e){t[e.feature_id]=new l.default(e)}));var n={};Object.keys(e.environments[0].properties).length&&e.environments[0].properties.forEach((function(e){n[e.property_id]=new f.default(e)}));var r={};Object.keys(e.segments).length&&e.segments.forEach((function(e){r[e.segment_id]=new p.default(e)})),(0,c.setCache)(t,n,r)},e.prototype.connectEventSource=function(){var e=this,t=b.getEventSourceUrl(),n=b.getEventSourceHeaders(),r=new d.EventSourcePolyfill(t,n);return r.addEventListener("SSEConfig_payload",(function(t){var n=JSON.parse(t.data);m.log("Update event received."),e.saveInCache(n),v.default.emit(h.CONFIGURATION_UPDATE_EVENT)})),new Promise((function(t,n){r.addEventListener("error",(function(e){n(e)})),r.addEventListener("Registration",(function(n){var r=JSON.parse(n.data);m.log("Client registration complete."),e.saveInCache(r),v.default.emit(h.REGISTRATION_EVENT),t()}))}))},e.prototype.getFeature=function(e){if(Object.prototype.hasOwnProperty.call((0,c.getCacheInstance)().features,e))return(0,c.getCacheInstance)().features[e];throw new Error("".concat(h.APP_CONFIGURATION,"Invalid feature flag id: ",e))},e.prototype.getFeatures=function(){return(0,c.getCacheInstance)().features},e.prototype.getProperty=function(e){if(Object.prototype.hasOwnProperty.call((0,c.getCacheInstance)().properties,e))return(0,c.getCacheInstance)().properties[e];throw new Error("".concat(h.APP_CONFIGURATION,"Invalid property id: ",e))},e.prototype.getProperties=function(){return(0,c.getCacheInstance)().properties},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e}();t.default=O},156:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c,l=u(n(184)),f=n(439),p=i(n(139)),d=u(n(876)),h=u(n(103)),v=l.default.getInstance(),_=h.default.getInstance(),y=function(){function e(){if(this.isInitialized=!1,this.isInitializedContext=!1,this.emitter=d.default,!(0,f.fetchAvailable)())throw new Error("".concat(p.APP_CONFIGURATION,'Either provide your own "fetch" implementation or run in an environment where "fetch" is available.'));window.addEventListener("beforeunload",(function(){_.sendMetering(!0)}))}return e.prototype.init=function(e,t,n){if(!e||!t||!n)throw e?t?new Error("".concat(p.APP_CONFIGURATION,"apikey is required")):new Error("".concat(p.APP_CONFIGURATION,"guid is required")):new Error("".concat(p.APP_CONFIGURATION,"region is required"));v.init(e,t,n,c),this.isInitialized=!0},e.prototype.setContext=function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:if(!this.isInitialized)throw new Error("".concat(p.APP_CONFIGURATION,"init should be called first"));if(!e)throw new Error("".concat(p.APP_CONFIGURATION,"collectionId is required"));if(!t)throw new Error("".concat(p.APP_CONFIGURATION,"environmentId is required"));return this.isInitializedContext=!0,[4,v.setContext(e,t)];case 1:return n.sent(),[2]}}))}))},e.prototype.getFeature=function(e){if(this.isInitialized&&this.isInitializedContext)return v.getFeature(e);throw new Error("".concat(p.APP_CONFIGURATION,"getFeature: SDK not initialised."))},e.prototype.getFeatures=function(){if(this.isInitialized&&this.isInitializedContext)return v.getFeatures();throw new Error("".concat(p.APP_CONFIGURATION,"getFeatures: SDK not initialised."))},e.prototype.getProperty=function(e){if(this.isInitialized&&this.isInitializedContext)return v.getProperty(e);throw new Error("".concat(p.APP_CONFIGURATION,"getProperty: SDK not initialised."))},e.prototype.getProperties=function(){if(this.isInitialized&&this.isInitializedContext)return v.getProperties();throw new Error("".concat(p.APP_CONFIGURATION,"getProperties: SDK not initialised."))},e.overrideServiceUrl=function(e){if(!e)throw new Error("".concat(p.APP_CONFIGURATION,"Unexpected url passed to overrideServiceUrl()"));c=e},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.REGION_US_SOUTH="us-south",e.REGION_EU_GB="eu-gb",e.REGION_AU_SYD="au-syd",e.REGION_US_EAST="us-east",e.REGION_EU_DE="eu-de",e.REGION_CA_TOR="ca-tor",e.REGION_JP_TOK="jp-tok",e.REGION_JP_OSA="jp-osa",e}();t.default=y},501:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.getCacheInstance=t.setCache=void 0,t.setCache=function(e,t,r){var o={features:{},properties:{},segments:{}};o.features=e,o.properties=t,o.segments=r,n=o},t.getCacheInstance=function(){return n}},521:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var s=i(n(139)),u=n(54),c=a(n(103)),l=n(501),f=a(n(302)),p=new(n(628).Logger)(s.APP_CONFIGURATION),d=function(){function e(e){var t=e.name,n=e.feature_id,r=e.type,o=e.format,i=void 0===o?void 0:o,a=e.enabled_value,s=e.disabled_value,u=e.segment_rules,c=e.enabled,l=e.rollout_percentage,p=void 0===l?100:l;this.name=t,this.feature_id=n,this.type=r,this.format=i,this.enabled_value=a,this.disabled_value=s,this.enabled=c,this.rollout_percentage=p,this.segment_rules=[];for(var d=0,h=u;d<h.length;d++){var v=h[d];this.segment_rules.push(new f.default(v))}}return e.prototype.getFeatureName=function(){return this.name},e.prototype.getFeatureId=function(){return this.feature_id},e.prototype.getFeatureDataType=function(){return this.type},e.prototype.getFeatureDataFormat=function(){return this.format||"STRING"!==this.type||(this.format="TEXT"),this.format},e.prototype.isEnabled=function(){return this.enabled},e.prototype.getCurrentValue=function(e,t){return void 0===t&&(t={}),e?this.featureEvaluation(e,t).current_value:(p.log("".concat("Feature flag evaluation: ",s.INVALID_ENTITY_ID," getCurrentValue")),null)},e.prototype.featureEvaluation=function(e,t){var n={evaluated_segment_id:s.DEFAULT_SEGMENT_ID,value:void 0,is_enabled:!1};try{if(this.enabled){if(this.segment_rules.length>0&&Object.keys(t).length>0){var r=this.parseRules(this.segment_rules);return{current_value:(n=this.evaluateRules(r,e,t)).value,is_enabled:n.is_enabled}}return 100===this.rollout_percentage||(0,u.getNormalizedValue)("".concat(e,":",this.feature_id))<this.rollout_percentage?{current_value:this.enabled_value,is_enabled:!0}:{current_value:this.disabled_value,is_enabled:!1}}return{current_value:this.disabled_value,is_enabled:!1}}finally{c.default.getInstance().addMetering(e,n.evaluated_segment_id,this.feature_id,null)}},e.prototype.parseRules=function(e){var t={};return e.forEach((function(e){t[e.order]=e})),t},e.prototype.evaluateRules=function(e,t,n){var r={evaluated_segment_id:s.DEFAULT_SEGMENT_ID,value:void 0,is_enabled:!1};try{for(var o=1;o<=Object.keys(e).length;o+=1){var i=e[o];if(i.rules.length>0)for(var a=0,c=i.rules;a<c.length;a++){var l=c[a].segments;if(l.length>0)for(var f=0,p=l;f<p.length;f++){var d=p[f];if(this.evaluateSegment(d,n)){r.evaluated_segment_id=d;var h=i.rollout_percentage===s.DEFAULT_ROLLOUT_PERCENTAGE?this.rollout_percentage:i.rollout_percentage;return 100===h||(0,u.getNormalizedValue)("".concat(t,":",this.feature_id))<h?(i.value===s.DEFAULT_FEATURE_VALUE?r.value=this.enabled_value:r.value=i.value,r.is_enabled=!0):(r.value=this.disabled_value,r.is_enabled=!1),r}}}}}catch(e){console.error("".concat(s.APP_CONFIGURATION,"FeatureFlagRuleEvaluation",e.message))}return 100===this.rollout_percentage||(0,u.getNormalizedValue)("".concat(t,":",this.feature_id))<this.rollout_percentage?(r.value=this.enabled_value,r.is_enabled=!0):(r.value=this.disabled_value,r.is_enabled=!1),r},e.prototype.evaluateSegment=function(e,t){var n=(0,l.getCacheInstance)().segments;return!!Object.prototype.hasOwnProperty.call(n,e)&&n[e].evaluateRule(t)},e}();t.default=d},302:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){var t=e.rules,n=e.value,r=e.order,o=e.rollout_percentage,i=void 0===o?100:o;this.rules=t,this.value=n,this.order=r,this.rollout_percentage=i}return e.prototype.getRules=function(){return this.rules},e.prototype.getValue=function(){return this.value},e.prototype.getOrder=function(){return this.order},e.prototype.getRolloutPercentage=function(){return this.rollout_percentage},e}();t.default=n},922:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var s=i(n(139)),u=a(n(103)),c=n(501),l=a(n(427)),f=new(n(628).Logger)(s.APP_CONFIGURATION),p=function(){function e(e){var t=e.name,n=e.property_id,r=e.type,o=e.format,i=void 0===o?void 0:o,a=e.value,s=e.segment_rules;this.name=t,this.property_id=n,this.type=r,this.format=i,this.value=a,this.segment_rules=[];for(var u=0,c=s;u<c.length;u++){var f=c[u];this.segment_rules.push(new l.default(f))}}return e.prototype.getPropertyName=function(){return this.name},e.prototype.getPropertyId=function(){return this.property_id},e.prototype.getPropertyDataType=function(){return this.type},e.prototype.getPropertyDataFormat=function(){return this.format||"STRING"!==this.type||(this.format="TEXT"),this.format},e.prototype.getCurrentValue=function(e,t){return void 0===t&&(t={}),e?this.propertyEvaluation(e,t):(f.log("".concat("Property evaluation: ",s.INVALID_ENTITY_ID," getCurrentValue")),null)},e.prototype.propertyEvaluation=function(e,t){var n={evaluated_segment_id:s.DEFAULT_SEGMENT_ID,value:null};try{if(this.segment_rules.length>0&&Object.keys(t).length>0){var r=this.parseRules(this.segment_rules);return(n=this.evaluateRules(r,e,t)).value}return this.value}finally{u.default.getInstance().addMetering(e,n.evaluated_segment_id,null,this.property_id)}},e.prototype.parseRules=function(e){var t={};return e.forEach((function(e){t[e.order]=e})),t},e.prototype.evaluateRules=function(e,t,n){var r={evaluated_segment_id:s.DEFAULT_SEGMENT_ID,value:null};try{for(var o=1;o<=Object.keys(e).length;o+=1){var i=e[o];if(i.rules.length>0)for(var a=0,u=i.rules;a<u.length;a++){var c=u[a].segments;if(c.length>0)for(var l=0,f=c;l<f.length;l++){var p=f[l];if(this.evaluateSegment(p,n))return r.evaluated_segment_id=p,i.value===s.DEFAULT_PROPERTY_VALUE?r.value=this.value:r.value=i.value,r}}}}catch(e){console.error("".concat(s.APP_CONFIGURATION,"PropertyRuleEvaluation",e.message))}return r.value=this.value,r},e.prototype.evaluateSegment=function(e,t){var n=(0,c.getCacheInstance)().segments;return!!Object.prototype.hasOwnProperty.call(n,e)&&n[e].evaluateRule(t)},e}();t.default=p},427:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){var t=e.rules,n=e.value,r=e.order;this.rules=t,this.value=n,this.order=r}return e.prototype.getRules=function(){return this.rules},e.prototype.getValue=function(){return this.value},e.prototype.getOrder=function(){return this.order},e}();t.default=n},9:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){var t=e.attribute_name,n=e.operator,r=e.values;this.attribute_name=t,this.operator=n,this.values=r}return e.prototype.operatorCheck=function(e,t){var n=!1;if(null==e||""===t)return n;switch(this.operator){case"endsWith":n=new RegExp("".concat(t,"$"),"i").test(e);break;case"notEndsWith":n=!new RegExp("".concat(t,"$"),"i").test(e);break;case"startsWith":n=new RegExp("^".concat(t),"i").test(e);break;case"notStartsWith":n=!new RegExp("^".concat(t),"i").test(e);break;case"contains":n=e.includes(t);break;case"notContains":n=!e.includes(t);break;case"is":n="number"==typeof e?e===parseFloat(t):e.toString()===t.toString();break;case"isNot":n="number"==typeof e?e!==parseFloat(t):e.toString()!==t.toString();break;case"greaterThan":n=parseFloat(e)>parseFloat(t);break;case"lesserThan":n=parseFloat(e)<parseFloat(t);break;case"greaterThanEquals":n=parseFloat(e)>=parseFloat(t);break;case"lesserThanEquals":n=parseFloat(e)<=parseFloat(t);break;default:n=!1}return n},e.prototype.evaluateRule=function(e){var t,n=!1;if(!Object.prototype.hasOwnProperty.call(e,this.attribute_name))return n;if(t=e[this.attribute_name],["isNot","notContains","notStartsWith","notEndsWith"].includes(this.operator)){n=!0;for(var r=0;r<this.values.length;r+=1){var o=this.values[r];this.operatorCheck(t,o)||(n=!1)}}else for(r=0;r<this.values.length;r+=1)o=this.values[r],this.operatorCheck(t,o)&&(n=!0);return n},e}();t.default=n},846:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(9)),i=function(){function e(e){var t=e.name,n=e.segment_id,r=e.rules;this.name=t,this.segment_id=n,this.rules=r}return e.prototype.evaluateRule=function(e){for(var t=0,n=this.rules;t<n.length;t++){var r=n[t];if(!new o.default(r).evaluateRule(e))return!1}return!0},e}();t.default=i},439:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.retryablePostMetering=t.fetchAvailable=void 0;var c=i(n(139)),l=n(908),f=u(n(392)).default.getInstance();t.fetchAvailable=function(){return"fetch"in window},t.retryablePostMetering=function e(t,n,r){return void 0===r&&(r=c.NUMBER_OF_RETRIES),a(this,void 0,void 0,(function(){var o,i,u=this;return s(this,(function(c){return o=f.getMeteringUrl(),i={method:"POST",headers:f.getAPICallHeaders(!0),body:JSON.stringify(t)},n&&(i.keepalive=!0),[2,fetch(o,i).then((function(o){return a(u,void 0,void 0,(function(){var i;return s(this,(function(a){switch(a.label){case 0:return o.ok?[2]:(o.status>=500&&o.status<=599||429===o.status)&&r>1?[2,e(t,n,r-1)]:(i=l.APIError.bind,[4,o.text()]);case 1:throw new(i.apply(l.APIError,[void 0,a.sent(),o.status]))}}))}))}))]}))}))}},139:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.INVALID_ENTITY_ID=t.REGISTRATION_EVENT=t.CONFIGURATION_UPDATE_EVENT=t.EVENT_SOURCE_HEARTBEAT_TIMEOUT=t.NORMALIZER=t.MAX_HASH_VALUE=t.NUMBER_OF_RETRIES=t.DEFAULT_USAGE_LIMIT=t.DEFAULT_ROLLOUT_PERCENTAGE=t.DEFAULT_PROPERTY_VALUE=t.DEFAULT_FEATURE_VALUE=t.DEFAULT_SEGMENT_ID=t.DEFAULT_ENTITY_ID=t.APP_CONFIGURATION=void 0,t.APP_CONFIGURATION="App Configuration: ",t.DEFAULT_ENTITY_ID="$$null$$",t.DEFAULT_SEGMENT_ID="$$null$$",t.DEFAULT_FEATURE_VALUE="$default",t.DEFAULT_PROPERTY_VALUE="$default",t.DEFAULT_ROLLOUT_PERCENTAGE="$default",t.DEFAULT_USAGE_LIMIT=25,t.NUMBER_OF_RETRIES=3,t.MAX_HASH_VALUE=Math.pow(2,32),t.NORMALIZER=100,t.EVENT_SOURCE_HEARTBEAT_TIMEOUT=216e5,t.CONFIGURATION_UPDATE_EVENT="configurationUpdate",t.REGISTRATION_EVENT="registration",t.INVALID_ENTITY_ID="Invalid entityId passed to"},908:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.APIError=void 0;var o=function(e){function t(n,r){var o=e.call(this,n)||this;return o.statusCode=r,Object.setPrototypeOf(o,t.prototype),o}return r(t,e),t}(Error);t.APIError=o},876:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=new(r(n(228)).default),i={on:function(e,t){return o.on(e,t)},emit:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return o.emit(e)}};Object.freeze(i),t.default=i},54:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getNormalizedValue=void 0;var o=r(n(5)),i=n(139);t.getNormalizedValue=function(e){return Math.floor(function(e){return o.default.v3(e,0)}(e)/i.MAX_HASH_VALUE*i.NORMALIZER)}},628:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=void 0;var n=function(){function e(e){this.logPrefix=e}return e.prototype.log=function(e){var t="".concat(this.logPrefix).concat(e);console.log(t)},e}();t.Logger=n},103:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(439),c=i(n(139)),l=n(908),f=function(){function e(){this.meteringInterval=3e5,this.startMetering=!1,this.meteringFeatureData={},this.meteringPropertyData={}}return e.prototype.stopTimer=function(){this.timer&&(clearInterval(this.timer),delete this.timer)},e.prototype.init=function(e,t){this.collectionId=e,this.environmentId=t},e.prototype.addMetering=function(e,t,n,r){var o=this;this.startMetering||(this.timer=setInterval((function(){o.sendMetering(!1)}),this.meteringInterval),this.startMetering=!0);var i=null!==n?this.meteringFeatureData:this.meteringPropertyData,a=null!==n?n:r,s="".concat((new Date).toISOString().split(".")[0],"Z"),u={count:1,evaluation_time:s};Object.prototype.hasOwnProperty.call(i,a)?Object.prototype.hasOwnProperty.call(i[a],e)?Object.prototype.hasOwnProperty.call(i[a][e],t)&&(i[a][e][t].evaluation_time=s,i[a][e][t].count+=1):(i[a][e]={},i[a][e][t]=u):(i[a]={},i[a][e]={},i[a][e][t]=u)},e.prototype.buildRequestBody=function(e,t,n){var r=this,o={},i=[],a=e;Object.keys(a).forEach((function(e){Object.keys(a[e]).forEach((function(t){Object.keys(a[e][t]).forEach((function(s){var u,l=((u={})[n]=e,u.entity_id=t===c.DEFAULT_ENTITY_ID?null:t,u.segment_id=s===c.DEFAULT_SEGMENT_ID?null:s,u.evaluation_time=a[e][t][s].evaluation_time,u.count=a[e][t][s].count,u);i.push(l),o.collection_id=r.collectionId,o.environment_id=r.environmentId,o.usages=i}))}))})),t.push(o)},e.prototype.sendToServer=function(e,t){return a(this,void 0,void 0,(function(){var n,r=this;return s(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,(0,u.retryablePostMetering)(e,t)];case 1:return o.sent(),[3,3];case 2:return(n=o.sent())instanceof l.APIError&&(n.statusCode>=500&&n.statusCode<=599||429===n.statusCode)?setTimeout((function(){r.sendToServer(e,t)}),this.meteringInterval):console.error("Unexpected error: ",n),[3,3];case 3:return[2]}}))}))},e.prototype.sendSplitMetering=function(e,t,n){for(var r=0,o=e.usages;r<t;){for(var i=r+c.DEFAULT_USAGE_LIMIT>=t?t:r+c.DEFAULT_USAGE_LIMIT,a={},s=[],u=r;u<i;u+=1)s.push(o[u]);a.collection_id=e.collection_id,a.environment_id=e.environment_id,a.usages=s,this.sendToServer(a,n),r+=c.DEFAULT_USAGE_LIMIT}},e.prototype.sendMetering=function(e){return a(this,void 0,void 0,(function(){var t,n,r,o=this;return s(this,(function(i){try{if(t=this.meteringFeatureData,n=this.meteringPropertyData,this.meteringFeatureData={},this.meteringPropertyData={},Object.keys(t).length<=0&&Object.keys(n).length<=0)return[2];r=[],Object.keys(t).length>0&&this.buildRequestBody(t,r,"feature_id"),Object.keys(n).length>0&&this.buildRequestBody(n,r,"property_id"),r.forEach((function(t){var n=t.usages.length;n>c.DEFAULT_USAGE_LIMIT?o.sendSplitMetering(t,n,e):o.sendToServer(t,e)}))}catch(e){console.error(e)}return[2]}))}))},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e}();t.default=f},392:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});var a=n(330),s=i(n(139)),u=function(){function e(){}return e.prototype.init=function(e){this.region=e.region,this.guid=e.guid,this.apikey=e.apikey,this.collectionId=e.collectionId,this.environmentId=e.environmentId,this.overrideServiceUrl=e.overrideServiceUrl},e.prototype.getAPICallHeaders=function(e){void 0===e&&(e=!1);var t=new Headers;return t.append("Authorization",this.apikey),t.append("User-Agent","".concat("appconfiguration-js-client-sdk/v",a.version," (",navigator.userAgent,")")),e&&t.append("Content-Type","application/json"),t},e.prototype.getEventSourceHeaders=function(){return{headers:{Authorization:this.apikey,"User-Agent":"".concat("appconfiguration-js-client-sdk/v",a.version," (",navigator.userAgent,")")},heartbeatTimeout:s.EVENT_SOURCE_HEARTBEAT_TIMEOUT}},e.prototype.getBaseServiceUrl=function(){return this.overrideServiceUrl?this.overrideServiceUrl:"".concat("https://",this.region,".apprapp.cloud.ibm.com")},e.prototype.getMeteringUrl=function(){return"".concat(this.getBaseServiceUrl(),"/apprapp/events/v1/instances/",this.guid,"/usage")},e.prototype.getEventSourceUrl=function(){return"".concat(this.getBaseServiceUrl(),"/apprapp/feature/v1/instances/",this.guid,"/environments/",this.environmentId,"/sse/subscribe?collection_id=",this.collectionId)},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e}();t.default=u},623:function(e,t){var n,r,o;!function(i){"use strict";var a=i.setTimeout,s=i.clearTimeout,u=i.XMLHttpRequest,c=i.XDomainRequest,l=i.ActiveXObject,f=i.EventSource,p=i.document,d=i.Promise,h=i.fetch,v=i.Response,_=i.TextDecoder,y=i.TextEncoder,g=i.AbortController;if("undefined"==typeof window||void 0===p||"readyState"in p||null!=p.body||(p.readyState="loading",window.addEventListener("load",(function(e){p.readyState="complete"}),!1)),null==u&&null!=l&&(u=function(){return new l("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==g){var b=h;h=function(e,t){var n=t.signal;return b(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return n._reader=t,n._aborted&&n._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},g=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function E(){this.bitsNeeded=0,this.codePoint=0}E.prototype.decode=function(e){function t(e,t,n){if(1===n)return e>=128>>t&&e<<t<=2047;if(2===n)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===n)return e>=65536>>t&&e<<t<=1114111;throw new Error}function n(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var r=65533,o="",i=this.bitsNeeded,a=this.codePoint,s=0;s<e.length;s+=1){var u=e[s];0!==i&&(u<128||u>191||!t(a<<6|63&u,i-6,n(i,a)))&&(i=0,a=r,o+=String.fromCharCode(a)),0===i?(u>=0&&u<=127?(i=0,a=u):u>=192&&u<=223?(i=6,a=31&u):u>=224&&u<=239?(i=12,a=15&u):u>=240&&u<=247?(i=18,a=7&u):(i=0,a=r),0===i||t(a,i,n(i,a))||(i=0,a=r)):(i-=6,a=a<<6|63&u),0===i&&(a<=65535?o+=String.fromCharCode(a):(o+=String.fromCharCode(55296+(a-65535-1>>10)),o+=String.fromCharCode(56320+(a-65535-1&1023))))}return this.bitsNeeded=i,this.codePoint=a,o},null!=_&&null!=y&&function(){try{return"test"===(new _).decode((new y).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(_=E);var m=function(){};function O(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=m,this.onload=m,this.onerror=m,this.onreadystatechange=m,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=m}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function T(e){for(var t=Object.create(null),n=e.split("\r\n"),r=0;r<n.length;r+=1){var o=n[r].split(": "),i=o.shift(),a=o.join(": ");t[w(i)]=a}this._map=t}function I(){}function A(e){this._headers=e}function P(){}function S(){this._listeners=Object.create(null)}function C(e){a((function(){throw e}),0)}function R(e){this.type=e,this.target=void 0}function N(e,t){R.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function j(e,t){R.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function U(e,t){R.call(this,e),this.error=t.error}O.prototype.open=function(e,t){this._abort(!0);var n=this,r=this._xhr,o=1,i=0;this._abort=function(e){0!==n._sendTimeout&&(s(n._sendTimeout),n._sendTimeout=0),1!==o&&2!==o&&3!==o||(o=4,r.onload=m,r.onerror=m,r.onabort=m,r.onprogress=m,r.onreadystatechange=m,r.abort(),0!==i&&(s(i),i=0),e||(n.readyState=4,n.onabort(null),n.onreadystatechange())),o=0};var c=function(){if(1===o){var e=0,t="",i=void 0;if("contentType"in r)e=200,t="OK",i=r.contentType;else try{e=r.status,t=r.statusText,i=r.getResponseHeader("Content-Type")}catch(n){e=0,t="",i=void 0}0!==e&&(o=2,n.readyState=2,n.status=e,n.statusText=t,n._contentType=i,n.onreadystatechange())}},l=function(){if(c(),2===o||3===o){o=3;var e="";try{e=r.responseText}catch(e){}n.readyState=3,n.responseText=e,n.onprogress()}},f=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:m}),l(),1===o||2===o||3===o){if(o=4,0!==i&&(s(i),i=0),n.readyState=4,"load"===e)n.onload(t);else if("error"===e)n.onerror(t);else{if("abort"!==e)throw new TypeError;n.onabort(t)}n.onreadystatechange()}},p=function(){i=a((function(){p()}),500),3===r.readyState&&l()};"onload"in r&&(r.onload=function(e){f("load",e)}),"onerror"in r&&(r.onerror=function(e){f("error",e)}),"onabort"in r&&(r.onabort=function(e){f("abort",e)}),"onprogress"in r&&(r.onprogress=l),"onreadystatechange"in r&&(r.onreadystatechange=function(e){!function(e){null!=r&&(4===r.readyState?"onload"in r&&"onerror"in r&&"onabort"in r||f(""===r.responseText?"error":"load",e):3===r.readyState?"onprogress"in r||l():2===r.readyState&&c())}(e)}),!("contentType"in r)&&"ontimeout"in u.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),r.open(e,t,!0),"readyState"in r&&(i=a((function(){p()}),0))},O.prototype.abort=function(){this._abort(!1)},O.prototype.getResponseHeader=function(e){return this._contentType},O.prototype.setRequestHeader=function(e,t){var n=this._xhr;"setRequestHeader"in n&&n.setRequestHeader(e,t)},O.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},O.prototype.send=function(){if("ontimeout"in u.prototype&&("sendAsBinary"in u.prototype||"mozAnon"in u.prototype)||null==p||null==p.readyState||"complete"===p.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=a((function(){t._sendTimeout=0,t.send()}),4)}},T.prototype.get=function(e){return this._map[w(e)]},null!=u&&null==u.HEADERS_RECEIVED&&(u.HEADERS_RECEIVED=2),I.prototype.open=function(e,t,n,r,o,i,a){e.open("GET",o);var s=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(s);s+=t.length,n(t)},e.onerror=function(e){e.preventDefault(),r(new Error("NetworkError"))},e.onload=function(){r(null)},e.onabort=function(){r(null)},e.onreadystatechange=function(){if(e.readyState===u.HEADERS_RECEIVED){var n=e.status,r=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(n,r,o,new T(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,c)&&e.setRequestHeader(c,a[c]);return e.send(),e},A.prototype.get=function(e){return this._headers.get(e)},P.prototype.open=function(e,t,n,r,o,i,a){var s=null,u=new g,c=u.signal,l=new _;return h(o,{headers:a,credentials:i?"include":"same-origin",signal:c,cache:"no-store"}).then((function(e){return s=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new A(e.headers)),new d((function(e,t){var r=function(){s.read().then((function(t){if(t.done)e(void 0);else{var o=l.decode(t.value,{stream:!0});n(o),r()}})).catch((function(e){t(e)}))};r()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){r(e)})),{abort:function(){null!=s&&s.cancel(),u.abort()}}},S.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var n=t.length,r=0;r<n;r+=1){var o=t[r];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){C(e)}}},S.prototype.addEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];null==r&&(r=[],n[e]=r);for(var o=!1,i=0;i<r.length;i+=1)r[i]===t&&(o=!0);o||r.push(t)},S.prototype.removeEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];if(null!=r){for(var o=[],i=0;i<r.length;i+=1)r[i]!==t&&o.push(r[i]);0===o.length?delete n[e]:n[e]=o}},N.prototype=Object.create(R.prototype),j.prototype=Object.create(R.prototype),U.prototype=Object.create(R.prototype);var D=/^text\/event\-stream(;.*)?$/i,x=function(e,t){var n=null==e?t:parseInt(e,10);return n!=n&&(n=t),M(n)},M=function(e){return Math.min(Math.max(e,1e3),18e6)},F=function(e,t,n){try{"function"==typeof t&&t.call(e,n)}catch(e){C(e)}};function k(e,t){S.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,n){t=String(t);var r=Boolean(n.withCredentials),o=n.lastEventIdQueryParameterName||"lastEventId",i=M(1e3),l=x(n.heartbeatTimeout,45e3),f="",p=i,d=!1,h=0,v=n.headers||{},_=n.Transport,y=L&&null==_?void 0:new O(null!=_?new _:null!=u&&"withCredentials"in u.prototype||null==c?new u:new c),g=null!=_&&"string"!=typeof _?new _:null==y?new P:new I,b=void 0,E=0,m=-1,w="",T="",A="",S="",C=0,R=0,k=0,G=function(t,n,r,o){if(0===m)if(200===t&&null!=r&&D.test(r)){m=1,d=Date.now(),p=i,e.readyState=1;var a=new j("open",{status:t,statusText:n,headers:o});e.dispatchEvent(a),F(e,e.onopen,a)}else{var s="";200!==t?(n&&(n=n.replace(/\s+/g," ")),s="EventSource's response has a status "+t+" "+n+" that is not 200. Aborting the connection."):s="EventSource's response has a Content-Type specifying an unsupported type: "+(null==r?"-":r.replace(/\s+/g," "))+". Aborting the connection.",B(),a=new j("error",{status:t,statusText:n,headers:o}),e.dispatchEvent(a),F(e,e.onerror,a),console.error(s)}},V=function(t){if(1===m){for(var n=-1,r=0;r<t.length;r+=1)(c=t.charCodeAt(r))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(n=r);var o=(-1!==n?S:"")+t.slice(0,n+1);S=(-1===n?S:"")+t.slice(n+1),""!==t&&(d=Date.now(),h+=t.length);for(var u=0;u<o.length;u+=1){var c=o.charCodeAt(u);if(-1===C&&c==="\n".charCodeAt(0))C=0;else if(-1===C&&(C=0),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(0!==C){1===C&&(k=u+1);var v=o.slice(R,k-1),_=o.slice(k+(k<u&&o.charCodeAt(k)===" ".charCodeAt(0)?1:0),u);"data"===v?(w+="\n",w+=_):"id"===v?T=_:"event"===v?A=_:"retry"===v?(i=x(_,i),p=i):"heartbeatTimeout"===v&&(l=x(_,l),0!==E&&(s(E),E=a((function(){z()}),l)))}if(0===C){if(""!==w){f=T,""===A&&(A="message");var y=new N(A,{data:w.slice(1),lastEventId:T});if(e.dispatchEvent(y),"open"===A?F(e,e.onopen,y):"message"===A?F(e,e.onmessage,y):"error"===A&&F(e,e.onerror,y),2===m)return}w="",A=""}C=c==="\r".charCodeAt(0)?-1:0}else 0===C&&(R=u,C=1),1===C?c===":".charCodeAt(0)&&(k=u+1,C=2):2===C&&(C=3)}}},H=function(t){if(1===m||0===m){m=-1,0!==E&&(s(E),E=0),E=a((function(){z()}),p),p=M(Math.min(16*i,2*p)),e.readyState=0;var n=new U("error",{error:t});e.dispatchEvent(n),F(e,e.onerror,n)}},B=function(){m=2,null!=b&&(b.abort(),b=void 0),0!==E&&(s(E),E=0),e.readyState=2},z=function(){if(E=0,-1===m){d=!1,h=0,E=a((function(){z()}),l),m=0,w="",A="",T=f,S="",R=0,k=0,C=0;var n=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==f){var r=t.indexOf("?");n=-1===r?t:t.slice(0,r+1)+t.slice(r+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===o?"":e})),n+=(-1===t.indexOf("?")?"?":"&")+o+"="+encodeURIComponent(f)}var i=e.withCredentials,s={Accept:"text/event-stream"},u=e.headers;if(null!=u)for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(s[c]=u[c]);try{b=g.open(y,G,V,H,n,i,s)}catch(e){throw B(),e}}else if(d||null==b){var p=Math.max((d||Date.now())+l-Date.now(),1);d=!1,E=a((function(){z()}),p)}else H(new Error("No activity within "+l+" milliseconds. "+(0===m?"No response received.":h+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};e.url=t,e.readyState=0,e.withCredentials=r,e.headers=v,e._close=B,z()}(this,e,t)}var L=null!=h&&null!=v&&"body"in v.prototype;k.prototype=Object.create(S.prototype),k.prototype.CONNECTING=0,k.prototype.OPEN=1,k.prototype.CLOSED=2,k.prototype.close=function(){this._close()},k.CONNECTING=0,k.OPEN=1,k.CLOSED=2,k.prototype.withCredentials=void 0;var G=f;null==u||null!=f&&"withCredentials"in f.prototype||(G=k),function(i){if("object"==typeof e.exports){var a=i(t);void 0!==a&&(e.exports=a)}else r=[t],void 0===(o="function"==typeof(n=i)?n.apply(t,r):n)||(e.exports=o)}((function(e){e.EventSourcePolyfill=k,e.NativeEventSource=f,e.EventSource=G}))}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:this:globalThis)},330:e=>{"use strict";e.exports=JSON.parse('{"name":"ibm-appconfiguration-js-client-sdk","version":"0.1.4","description":"IBM Cloud App Configuration JavaScript Client SDK","keywords":["client-sdk","appconfiguration"],"homepage":"https://github.com/IBM/appconfiguration-js-client-sdk#readme","bugs":{"url":"https://github.com/IBM/appconfiguration-js-client-sdk/issues"},"repository":{"type":"git","url":"git+https://github.com/IBM/appconfiguration-js-client-sdk.git"},"license":"Apache-2.0","author":"IBM","main":"dist/src/index.js","unpkg":"dist/appconfiguration.js","files":["dist"],"scripts":{"build":"npm run clean && npm run build:tsc && npm run build:webpack","build:tsc":"tsc","build:webpack":"webpack","clean":"del-cli dist/*","lint:check":"eslint .","lint:fix":"eslint . --fix","test":"jest"},"dependencies":{"eventemitter3":"^4.0.7","murmurhash":"^2.0.0"},"devDependencies":{"@types/jest":"^28.1.1","@typescript-eslint/eslint-plugin":"^5.27.1","@typescript-eslint/parser":"^5.27.1","del-cli":"^4.0.1","eslint":"^8.17.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-airbnb-typescript":"^17.0.0","eslint-config-prettier":"^8.5.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","prettier":"^2.6.2","ts-jest":"^28.0.8","ts-loader":"^9.3.0","typedoc":"^0.23.5","typescript":"^4.7.3","webpack":"^5.87.0","webpack-cli":"^4.10.0"}}')}},t={},function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(156).default;var e,t}));