Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

launchdarkly-js-sdk-common

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

launchdarkly-js-sdk-common - npm Package Compare versions

Comparing version 3.5.0 to 4.0.0

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Change log

## [4.0.0] - 2022-01-14
### Changed:
- Updated `uuid` package to 8.x.
- In TypeScript, the property `LDEvaluationDetail.reason` is now nullable, which correctly reflects the fact that evaluation reasons may not always be available.
### Removed:
- Removed the type `NonNullableLDEvaluationReason`, which was a side effect of the `LDEvaluationDetail.reason` being incorrectly defined before.
- Removed all types, properties, and functions that were deprecated as of the last 3.x release.
## [3.5.0] - 2022-01-14

@@ -7,0 +16,0 @@ ### Added:

2

dist/ldclient-common.cjs.js

@@ -1,2 +0,2 @@

"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ownKeys(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function _objectSpread2(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function createCustomError(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var n,t=e.length,r=t%3,o=[],i=16383,a=0,s=t-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(n=e[t-1],o.push(lookup[n>>2]+lookup[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(lookup[n>>10]+lookup[n>>4&63]+lookup[n<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=isArray(n),s=isArray(t);if(a&&s){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=s)return!1;var u=n instanceof Date,c=t instanceof Date;if(u!=c)return!1;if(u&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var d=keyList(n);if((o=d.length)!==keyList(t).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(t,d[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=d[r]],t[i]))return!1;return!0}return n!=n&&t!=t},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var n=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(n))}function stringToBytes(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,n){return fastDeepEqual(e,n)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function transformValuesToVersionedValues(e){var n={};for(var t in e)objectHasOwnProperty(e,t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var t in e)objectHasOwnProperty(e,t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function getLDUserAgentString(e){var n=e.version||"3.5.0";return e.userAgent+"/"+n}function getLDHeaders(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function transformHeaders(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(_objectSpread2({},e)):e}function extend(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return _objectSpread2({},e,{},n)},{})}function objectHasOwnProperty(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function sanitizeUser(e){if(!e)return e;var n;for(var t in userAttrsToStringify){var r=userAttrsToStringify[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||_objectSpread2({},e))[r]=String(o))}return n||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,transformHeaders:transformHeaders,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,n){return e(n={exports:{}},n.exports),n.exports}for(var rngBrowser=createCommonjsModule(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var t=n||0,r=byteToHex;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var s=rngBrowser();null==i&&(i=_nodeId=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=_clockseq=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=u-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||_lastMSecs<u)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=u,_clockseq=a;var f=(1e4*(268435455&(u+=122192928e5))+(_lastNSecs=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=u/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return n||bytesToUuid_1(o)}var v1_1=v1,MAX_URL_LENGTH=2e3;function EventSender(s,e,u){var t="/a/"+e+".gif",c=extend({"Content-Type":"application/json"},getLDHeaders(s,u)),l=s.httpFallbackPing,f={};return f.sendChunk=function(e,r,o,n){var i=JSON.stringify(e),a=o?null:v1_1();return n?function n(t){var e=o?c:extend({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return s.httpRequest("POST",r,transformHeaders(e,u),i).promise.then(function(e){if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+base64URLEncode(i)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!s.httpRequest)return Promise.resolve();var r,o=s.httpAllowsPost();r=o?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(f.sendChunk(r[a],n,t,o));return Promise.all(i)},f}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:s,features:e}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var n={},u=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,o){return Object.keys(r).reduce(function(e,n){var t=e;return o(n)&&(!function(e){return!l[e]&&(u||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],o=extend({},o,a[1])}var s=Object.keys(o);return s.length&&(s.sort(),r.privateAttrs=s),r},n}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(e){return"local storage is unavailable: "+errorString(e)},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(isHttpErrorRecoverable(e)?t:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,n){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+n+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},wrongOptionTypeBoolean=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},optionBelowMinimum=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent});function EventProcessor(e,n,t){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,t,n),u=n.eventsUrl+"/events/bulk/"+t,c=EventSummarizer(),l=UserFilter(n),f=n.inlineUsersInEvents,d=n.samplingInterval,v=n.eventCapacity,g=n.flushInterval,p=n.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===d||0===Math.floor(Math.random()*d)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){if(!h){var n=!1,t=!1;if(c.summarizeEvent(e),"feature"===e.kind?E()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>y&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=E(),n&&k(function(e){var n=extend({},e);return"alias"===e.kind||(f||"identify"===e.kind?n.user=l.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=extend({},e,{kind:"debug"});r.user=l.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,k(r)}}},a.flush=function(){if(h)return Promise.resolve();var e=m,n=c.getSummary();return c.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(m=[],p.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=o[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!o[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(r){var n=!1,t=!1,o=null,e=null,i=new Promise(function(n){r.on(readyEvent,function e(){r.off(readyEvent,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(o):e=new Promise(function(n,t){r.on(successEvent,function e(){r.off(successEvent,e),n()}),r.on(failureEvent,function e(n){r.off(failureEvent,e),t(n)})}))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,r.emit(successEvent),r.emit(readyEvent))},signalFailure:function(e){n||t||(t=!0,o=e,r.emit(failureEvent,e),r.emit(readyEvent)),r.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function PersistentFlagStore(t,r,o,i){var a={};function s(){var e="",n=i.getUser();return n&&(e=o||btoa(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=extend({},e,{$schema:1});return t.set(s(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(s())},a}function PersistentStorage(r,n){function o(e){t||(t=!0,n.warn(localStorageUnavailable(e)))}var e={},t=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(n){r?r.get(e).then(n).catch(function(e){o(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){r?r.set(e,t).then(function(){return n(!0)}).catch(function(e){o(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){r?r.clear(e).then(function(){return n(!0)}).catch(function(e){o(e),n(!1)}):n(!1)})},e}var streamReadTimeoutMillis=3e5;function Stream(o,i,a,n){var s,u=i.streamUrl,c=i.logger,e={},l=u+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=getLDHeaders(o,i),g=!1,p=null,m=null,y=null,h=null,b=null;function E(e){g||(c.warn(streamError(e,t)),g=!0),S(!1),D(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:streamReadTimeoutMillis};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(y)):(e=u+"/ping/"+a,n=""):e=l+"/"+base64URLEncode(JSON.stringify(y)),t.headers=transformHeaders(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,D(),c.info(streamConnecting(e)),s=(new Date).getTime(),p=o.eventSourceFactory(e,t),b)objectHasOwnProperty(b,r)&&p.addEventListener(r,b[r]);p.onerror=E}}function D(){p&&(c.info(streamClosing()),p.close(),p=null)}function S(e){s&&n&&n.recordStreamInit(s,!e,(new Date).getTime()-s),s=null}return e.connect=function(e,n,t){y=e,h=n,b={};function r(n){b[n]=function(e){S(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,D()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function promiseCoalescer(t){var r,o,i,a,e={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){i=e,a=n}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(s,u,a){var c=u.baseUrl,l=u.useReport,f=u.evaluationReasons,d=u.logger,e={},v={};function g(e,n){if(!s.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var t=n?"REPORT":"GET",r=getLDHeaders(s,u);n&&(r["Content-Type"]=jsonContentType);var o=v[e];o||(o=promiseCoalescer(function(){delete v[e]}),v[e]=o);var i=s.httpRequest(t,e,transformHeaders(r,u),n),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&e.header("content-type").substring(0,jsonContentType.length)===jsonContentType)return JSON.parse(e.body);var n=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(n))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=base64URLEncode(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(debugPolling(r)),g(r,o)},e}function Identity(e,t){var r,n={};return n.setUser=function(e){var n=r&&clone(r);(r=sanitizeUser(e))&&t&&t(clone(r),n)},n.getUser=function(){return r?clone(r):null},e&&n.setUser(e),n}var ldUserIdKey="ld:$anonUserId";function UserValidator(r){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?r.get(ldUserIdKey).then(function(e){if(e)return t.key=e,t;var n=v1_1();return function(e){return r.set(ldUserIdKey,e)}(t.key=n).then(function(){return t})}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var logLevels=["debug","info","warn","error","none"];function commonBasicLogger(e,a){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],u=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<logLevels.length;t++)logLevels[t]===e.level&&(r=t);for(var o={},i=function(e){var n=logLevels[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=u?n+": "+c:c;if(1!==t.length&&a){var i=_toConsumableArray(t);i[0]=o+i[0],r=a.apply(void 0,_toConsumableArray(i))}else r=o+t[0];try{s[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<logLevels.length;l++)i(l);return o}function validateLogger(n){logLevels.forEach(function(e){if("none"!==e&&(!n[e]||"function"!=typeof n[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}function createConsoleLogger(e,n){return commonBasicLogger({level:e,prefix:n})}var baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function validate(e,n,t,r){var a=extend({logger:{default:r}},baseOptionDefs,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var i,u,c,l,f=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=_typeof(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var n=o[e];r&&r.warn(deprecated(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e])}}),u=extend({},f),Object.keys(a).forEach(function(e){void 0!==u[e]&&null!==u[e]||(u[e]=a[e]&&a[e].default)}),l=extend({},c=f=u),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)s(unknownOption(e));else{var r=t.type||d(t.default);if("any"!==r){var o=r.split("|"),i=d(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,s(wrongOptionTypeBoolean(e,i))):(s(wrongOptionType(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(s(optionBelowMinimum(e,n,t.minimum)),l[e]=t.minimum)}}}}),validateLogger((f=l).logger),f}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate}),baseOptionDefs$1=configuration.baseOptionDefs;function DiagnosticId(e){var n={diagnosticId:v1_1()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n}function DiagnosticsAccumulator(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}}function DiagnosticsManager(n,r,e,t,o,i,a){var s,u,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=_objectSpread2({},n.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:i.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:i.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function y(e){i.logger&&i.logger.debug(messages.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){y(function(){var e=(new Date).getTime(),n=_objectSpread2({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps());return c&&(n=_objectSpread2({},n,{},m())),v.reset(e),n}()),u=setTimeout(h,d),s=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=_objectSpread2({},v.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),s=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,d)}):(y(_objectSpread2({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},m())),u=setTimeout(h,d))},p.stop=function(){u&&clearTimeout(u)},p.setStreaming=function(e){g=e},p}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager,changeEvent="change",internalChangeEvent="internal-change";function initialize(e,n,t,i,r){var a,o,s,u=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||createConsoleLogger("warn")}(),c=EventEmitter(u),l=InitializationState(c),f=validate(t,c,r,u),d=f.sendEvents,v=e,g=f.hash,p=PersistentStorage(i.localStorage,u),m=EventSender(i,v,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?diagnosticEvents_1(v):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(i,p,b,m,v,f,h):null,k=Stream(i,f,v,b),D=f.eventProcessor||EventProcessor(i,f,v,b,c,m),S=Requestor(i,f,v),w={},P={},U=f.streaming,O=!1,L=!1,I=!0,T=f.stateProvider,C=Identity(null,function(e,n){(function(e){if(T)return;e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&V(e,n)}),_=UserValidator(p),j=p.isEnabled()?new PersistentFlagStore(p,v,g,C,u):null;function F(e){if(v&&!(T&&T.enqueueEvent&&T.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(I&&(u.warn(eventWithoutUser()),I=!1));I=!1}!d||L||i.isDoNotTrack()||(u.debug(debugEnqueueingEvent(e.kind)),D.enqueue(e))}}function R(e,n,t,r){var o=C.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=w[s];if(u&&i-u<3e5)return;w[s]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=N(o));var l=P[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),F(c)}function x(e,n,t,r){var o;if(P&&objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){var i=P[e];o=A(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&R(e,o,n,r),o}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function N(e){return e.anonymous?"anonymousUser":"user"}function V(e,n){T||e&&n&&F({kind:"alias",key:e.key,contextKind:N(e),previousKey:n.key,previousContextKind:N(n),creationDate:(new Date).getTime()})}function H(){o=!0,C.getUser()&&k.connect(C.getUser(),g,{ping:function(){u.debug(debugStreamPing());var n=C.getUser();S.fetchFlagSettings(n,g).then(function(e){deepEquals(n,C.getUser())&&M(e||{})}).catch(function(e){c.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);u.debug(debugStreamPut()),M(n)},patch:function(e){var n=JSON.parse(e.data),t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){u.debug(debugStreamPatch(n.key));var r={},o=extend({},n);delete o.key;var i=A(P[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},z(r)}else u.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!P[n.key]||P[n.key].version<n.version){u.debug(debugStreamDelete(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},z(t)}else u.debug(debugStreamDeleteIgnored(n.key))}})}function q(){o&&(k.disconnect(),o=!1)}function M(e){var n={};if(!e)return Promise.resolve();for(var t in P)objectHasOwnProperty(P,t)&&P[t]&&(e[t]&&!deepEquals(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:A(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var r in e)objectHasOwnProperty(e,r)&&e[r]&&(!P[r]||P[r].deleted)&&(n[r]={current:A(e[r])});return P=_objectSpread2({},e),z(n).catch(function(){})}function z(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;c.emit(changeEvent+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),c.emit(changeEvent,i),c.emit(internalChangeEvent,P),f.sendEventsOnlyForVariation||T||e.forEach(function(e){R(e,o[e].current)})}return a&&j?j.saveFlags(P):Promise.resolve()}function K(){var e=U||s&&void 0===U;e&&!o?H():!e&&o&&q(),E&&E.setStreaming(e)}function B(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(j?a=!0:u.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",o=t[r];!o&&e.length&&u.warn(bootstrapOldFormat()),!1===t.$valid&&u.warn(bootstrapInvalid());var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};o&&o[e]?n=extend(n,o[e]):n.version=0,i[e]=n}}),i}(f.bootstrap)),T){var J=T.getInitialState();J?$(J):T.on("init",$),T.on("update",function(e){e.user&&C.setUser(e.user);e.flags&&M(e.flags)})}else(e?_.validateUser(n).then(function(e){return C.setUser(e),"object"===_typeof(f.bootstrap)?G():a?j.loadFlags().then(function(e){return null==e?(P={},S.fetchFlagSettings(C.getUser(),g).then(function(e){return M(e||{})}).then(G).catch(function(e){W(new LDFlagFetchError(errorFetchingFlags(e)))})):(P=e,onNextTick(G),S.fetchFlagSettings(C.getUser(),g).then(function(e){return M(e)}).catch(function(e){return c.maybeReportError(e)}))}):S.fetchFlagSettings(C.getUser(),g).then(function(e){P=e||{},G()}).catch(function(e){P={},W(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(W);function $(e){v=e.environment,C.setUser(e.user),P=_objectSpread2({},e.flags),onNextTick(G)}function G(){u.info(clientInitialized()),O=!0,K(),l.signalSuccess()}function W(e){l.signalFailure(e)}return{client:{waitForInitialization:function(){return l.getInitializationPromise()},waitUntilReady:function(){return l.getReadyPromise()},identify:function(e,r,n){return L?wrapPromiseCallback(Promise.resolve({}),n):T?(u.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(P)),n)):wrapPromiseCallback((a&&j?j.clearFlags():Promise.resolve()).then(function(){return _.validateUser(e)}).then(function(t){return S.fetchFlagSettings(t,r).then(function(e){var n=transformVersionedValuesToValues(e);return C.setUser(t),g=r,e?M(e).then(function(){return n}):n})}).then(function(e){return o&&H(),e}).catch(function(e){return c.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return C.getUser()},variation:function(e,n){return x(e,n,!0,!1).value},variationDetail:function(e,n){return x(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&u.warn(unknownCustomEventKey(e));var r=C.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=N(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),F(o)}else c.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},alias:V,on:function(e,n,t){B(e)?(s=!0,O&&K(),c.on(e,n,t)):c.on.apply(c,arguments)},off:function(e){if(c.off.apply(c,arguments),B(e)){var n=!1;c.getEvents().forEach(function(e){B(e)&&0<c.getEventListenerCount(e)&&(n=!0)}),n||(s=!1,o&&void 0===U&&q())}},setStreaming:function(e){var n=null===e?void 0:e;n!==U&&(U=n,K())},flush:function(e){return wrapPromiseCallback(d?D.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)objectHasOwnProperty(P,n)&&(e[n]=x(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(L)return wrapPromiseCallback(Promise.resolve(),e);function n(){L=!0,P={}}return wrapPromiseCallback(Promise.resolve().then(function(){if(q(),E&&E.stop(),d)return D.stop(),D.flush()}).then(n).catch(n),e)}},options:f,emitter:c,ident:C,logger:u,requestor:S,start:function(){d&&(E&&E.start(),D.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:function(){return v},internalChangeEventName:internalChangeEvent}}var version="3.5.0";exports.commonBasicLogger=commonBasicLogger,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version;
"use strict";function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function createCustomError(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return(t.prototype=new Error).name=e,t.prototype.constructor=t}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(t=e[n-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i=isArray(t),a=isArray(n);if(i&&a){if((s=t.length)!=n.length)return!1;for(r=s;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(i!=a)return!1;i=t instanceof Date,a=n instanceof Date;if(i!=a)return!1;if(i&&a)return t.getTime()==n.getTime();i=t instanceof RegExp,a=n instanceof RegExp;if(i!=a)return!1;if(i&&a)return t.toString()==n.toString();var s,u=keyList(t);if((s=u.length)!==keyList(n).length)return!1;for(r=s;0!=r--;)if(!hasProp.call(n,u[r]))return!1;for(r=s;0!=r--;)if(!e(t[o=u[r]],n[o]))return!1;return!0}return t!=t&&n!=n},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){e=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(e))}function stringToBytes(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,t){return fastDeepEqual(e,t)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,t){e=e.then(function(e){return t&&setTimeout(function(){t(null,e)},0),e},function(e){return t?void setTimeout(function(){t(e,null)},0):Promise.reject(e)});return t?void 0:e}function transformValuesToVersionedValues(e){var t,n={};for(t in e)objectHasOwnProperty(e,t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var t,n={};for(t in e)objectHasOwnProperty(e,t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,t){for(var n,r=t.slice(0),o=[],i=e;0<r.length;){for(n=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<n.length?r.unshift(a):n.push(a)}i=e,o.push(n)}return o}function getLDUserAgentString(e){var t=e.version||"4.0.0";return e.userAgent+"/"+t}function getLDHeaders(e,t){if(t&&!t.sendLDHeaders)return{};e={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)};return t&&t.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName),e}function transformHeaders(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(_objectSpread2({},e)):e}function extend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(function(e,t){return _objectSpread2(_objectSpread2({},e),t)},{})}function objectHasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sanitizeUser(e){if(!e)return e;var t,n;for(n in userAttrsToStringify){var r=userAttrsToStringify[n],o=e[r];void 0!==o&&"string"!=typeof o&&((t=t||_objectSpread2({},e))[r]=String(o))}return t||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,transformHeaders:transformHeaders,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser}),_require=require("uuid"),uuidv1=_require.v1,MAX_URL_LENGTH=2e3;function EventSender(s,e,u){var c="/a/"+e+".gif",l=extend({"Content-Type":"application/json"},getLDHeaders(s,u)),d=s.httpFallbackPing,f={};return f.sendChunk=function(e,t,r,n){var o=JSON.stringify(e),i=r?null:uuidv1();function a(n){var e=r?l:extend({},l,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":i});return s.httpRequest("POST",t,transformHeaders(e,u),o).promise.then(function(e){var t;if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&n?a(!1):(e={status:(t=e).status},!(t=t.header("date"))||(t=Date.parse(t))&&(e.serverTime=t),e)}).catch(function(){return n?a(!1):Promise.reject()})}return n?a(!0).catch(function(){}):(d&&d(t+c+"?d="+base64URLEncode(o)),Promise.resolve())},f.sendEvents=function(e,t,n){if(!s.httpRequest)return Promise.resolve();for(var r=s.httpAllowsPost(),o=r?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-t.length,e),i=[],a=0;a<o.length;a++)i.push(f.sendChunk(o[a],t,n,r));return Promise.all(i)},f}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){var t,n;"feature"===e.kind&&(t=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(n=u[t])?n.count=n.count+1:u[t]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate))},e.getSummary=function(){var e,t={},n=!0;for(e in u){var r=u[e],o=t[r.key];o||(o={default:r.default,counters:[]},t[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:s,features:t}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var t={},a=e.allAttributesPrivate,s=e.privateAttributeNames||[],u={key:!0,custom:!0,anonymous:!0},c={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return t.filterUser=function(e){if(!e)return null;function t(n,r){return Object.keys(n).reduce(function(e,t){return r(t)&&(o(t)?e[1][t]=!0:e[0][t]=n[t]),e},[{},{}])}var n=e.privateAttributeNames||[],o=function(e){return!u[e]&&(a||-1!==n.indexOf(e)||-1!==s.indexOf(e))},r=t(e,function(e){return c[e]}),i=r[0],r=r[1];e.custom&&(e=t(e.custom,function(){return 1}),i.custom=e[0],r=extend({},r,e[1]));r=Object.keys(r);return r.length&&(r.sort(),i.privateAttrs=r),i},t}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(e){return"local storage is unavailable: "+errorString(e)},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,t){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+t+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,t,n){return'Config option "'+e+'" should be of type '+t+", got "+n+", using default value"},wrongOptionTypeBoolean=function(e,t){return'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"},optionBelowMinimum=function(e,t,n){return'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent});function EventProcessor(e,t,n){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,n,t),u=t.eventsUrl+"/events/bulk/"+n,c=EventSummarizer(),l=UserFilter(t),d=t.inlineUsersInEvents,f=t.samplingInterval,v=t.eventCapacity,g=t.flushInterval,m=t.logger,p=[],y=0,h=!1,b=!1;function E(){return 0===f||0===Math.floor(Math.random()*f)}function k(e){p.length<v?(p.push(e),b=!1):(b||(b=!0,m.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){var t,n,r;h||(t=r=!1,c.summarizeEvent(e),"feature"===e.kind?E()&&(r=!!e.trackEvents,t=!!(n=e).debugEventsUntilDate&&(n.debugEventsUntilDate>y&&n.debugEventsUntilDate>(new Date).getTime())):r=E(),r&&k((r=extend({},n=e),"alias"===n.kind||(d||"identify"===n.kind?r.user=l.filterUser(n.user):(r.userKey=n.user.key,delete r.user),"feature"===n.kind&&(delete r.trackEvents,delete r.debugEventsUntilDate)),r)),t&&((e=extend({},e,{kind:"debug"})).user=l.filterUser(e.user),delete e.trackEvents,delete e.debugEventsUntilDate,k(e)))},a.flush=function(){if(h)return Promise.resolve();var e=p,t=c.getSummary();return c.clearSummary(),t&&(t.kind="summary",e.push(t)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(p=[],m.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(t){var e={},o={};return e.on=function(e,t,n){o[e]=o[e]||[],o[e]=o[e].concat({handler:t,context:n})},e.off=function(e,t,n){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===t&&o[e][r].context===n&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var t=o[e].slice(0),n=0;n<t.length;n++)t[n].handler.apply(t[n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o["error"]?this.emit("error",e):(t||console).error(e.message))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(o){var t=!1,n=!1,r=null,e=null,i=new Promise(function(t){o.on(readyEvent,function e(){o.off(readyEvent,e),t()})}).catch(function(){});return{getInitializationPromise:function(){return e||(t?Promise.resolve():n?Promise.reject(r):e=new Promise(function(t,n){function r(e){o.off(failureEvent,r),n(e)}o.on(successEvent,function e(){o.off(successEvent,e),t()}),o.on(failureEvent,r)}))},getReadyPromise:function(){return i},signalSuccess:function(){t||n||(t=!0,o.emit(successEvent),o.emit(readyEvent))},signalFailure:function(e){t||n||(n=!0,r=e,o.emit(failureEvent,e),o.emit(readyEvent)),o.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function PersistentFlagStore(t,n,r,o){var i={};function a(){var e="",t=o.getUser();return t&&(e=r||btoa(JSON.stringify(t))),"ld:"+n+":"+e}return i.loadFlags=function(){return t.get(a()).then(function(e){if(null==e)return null;try{var t,n=JSON.parse(e);return n&&(void 0===(t=n.$schema)||t<1?n=transformValuesToVersionedValues(n):delete n.$schema),n}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=extend({},e,{$schema:1});return t.set(a(),JSON.stringify(e))},i.clearFlags=function(){return t.clear(a())},i}function PersistentStorage(r,t){function o(e){n||(n=!0,t.warn(localStorageUnavailable(e)))}var e={},n=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(t){r?r.get(e).then(t).catch(function(e){o(e),t(void 0)}):t(void 0)})},e.set=function(e,n){return new Promise(function(t){r?r.set(e,n).then(function(){return t(!0)}).catch(function(e){o(e),t(!1)}):t(!1)})},e.clear=function(e){return new Promise(function(t){r?r.clear(e).then(function(){return t(!0)}).catch(function(e){o(e),t(!1)}):t(!1)})},e}var streamReadTimeoutMillis=3e5;function Stream(o,i,a,t){var s,u=i.streamUrl,c=i.logger,e={},l=u+"/eval/"+a,d=i.useReport,f=i.evaluationReasons,n=i.streamReconnectDelay,v=getLDHeaders(o,i),g=!1,m=null,p=null,y=null,h=null,b=null;function E(e){g||(c.warn(streamError(e,n)),g=!0),D(!1),S(),k(n)}function k(e){p||(e?p=setTimeout(r,e):r())}function r(){var e;p=null;var t="",n={headers:v,readTimeoutMillis:streamReadTimeoutMillis};if(o.eventSourceFactory){for(var r in null!=h&&(t="h="+h),d?o.eventSourceAllowsReport?(e=l,n.method="REPORT",n.headers["Content-Type"]="application/json",n.body=JSON.stringify(y)):(e=u+"/ping/"+a,t=""):e=l+"/"+base64URLEncode(JSON.stringify(y)),n.headers=transformHeaders(n.headers,i),e=e+((t=f?t+(t?"&":"")+"withReasons=true":t)?"?":"")+t,S(),c.info(streamConnecting(e)),s=(new Date).getTime(),m=o.eventSourceFactory(e,n),b)objectHasOwnProperty(b,r)&&m.addEventListener(r,b[r]);m.onerror=E}}function S(){m&&(c.info(streamClosing()),m.close(),m=null)}function D(e){s&&t&&t.recordStreamInit(s,!e,(new Date).getTime()-s),s=null}return e.connect=function(e,t,n){y=e,h=t,b={};for(var r in n||{})!function(t){b[t]=function(e){D(!(g=!1)),n[t]&&n[t](e)}}(r);k()},e.disconnect=function(){clearTimeout(p),p=null,S()},e.isConnected=function(){return!!(m&&o.eventSourceIsActive&&o.eventSourceIsActive(m))},e}function promiseCoalescer(n){var r,o,i,a,e={addPromise:function(t,e){r=t,o&&o(),o=e,t.then(function(e){r===t&&(i(e),n&&n())},function(e){r===t&&(a(e),n&&n())})}};return e.resultPromise=new Promise(function(e,t){i=e,a=t}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(a,s,i){var u=s.baseUrl,c=s.useReport,l=s.evaluationReasons,d=s.logger,e={},f={};function v(e,t){if(!a.httpRequest)return new Promise(function(e,t){t(new LDFlagFetchError(httpUnavailable()))});var n=t?"REPORT":"GET",r=getLDHeaders(a,s);t&&(r["Content-Type"]=jsonContentType);var o=f[e];o||(o=promiseCoalescer(function(){delete f[e]}),f[e]=o);var i=a.httpRequest(n,e,transformHeaders(r,s),t),t=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&e.header("content-type").substring(0,jsonContentType.length)===jsonContentType)return JSON.parse(e.body);e=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(t,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return v(u+e,null)},e.fetchFlagSettings=function(e,t){var n,r,o="";return c?(n=[u,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=base64URLEncode(JSON.stringify(e)),n=[u,"/sdk/evalx/",i,"/users/",e].join("")),t&&(o="h="+t),d.debug(debugPolling(n=n+((o=l?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),v(n,r)},e}function Identity(e,n){var r,t={setUser:function(e){var t=r&&clone(r);(r=sanitizeUser(e))&&n&&n(clone(r),t)},getUser:function(){return r?clone(r):null}};return e&&t.setUser(e),t}var _require$1=require("uuid"),uuidv1$1=_require$1.v1,ldUserIdKey="ld:$anonUserId";function UserValidator(n){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?n.get(ldUserIdKey).then(function(e){if(e)return t.key=e,t;e=uuidv1$1();return t.key=e,n.set(ldUserIdKey,e).then(function(){return t})}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var logLevels=["debug","info","warn","error","none"];function commonBasicLogger(e,i){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(t){return function(e){console&&console[t]&&console[t].call(console,e)}}var a=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],s=!(!e||!e.destination),u=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var n=0;n<logLevels.length;n++)logLevels[n]===e.level&&(r=n);for(var o={},c=function(e){var t,n=logLevels[e];"none"!==n&&(e<r?o[n]=function(){}:(t=e,o[n]=function(){!function(e,t,n){if(!(n.length<1)){var r,o=s?t+": "+u:u,n=1!==n.length&&i?((r=_toConsumableArray(n))[0]=o+r[0],i.apply(void 0,_toConsumableArray(r))):o+n[0];try{a[e](n)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}(t,n,arguments)}))},l=0;l<logLevels.length;l++)c(l);return o}function validateLogger(t){logLevels.forEach(function(e){if("none"!==e&&(!t[e]||"function"!=typeof t[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}var baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function validate(e,t,n,r){var a=extend({logger:{default:r}},baseOptionDefs,n),o={};function s(e){onNextTick(function(){t&&t.maybeReportError(new LDInvalidArgumentError(e))})}var i,u,c,l,e=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=_typeof(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}return i=e,Object.keys(o).forEach(function(e){var t;void 0!==i[e]&&(t=o[e],r&&r.warn(deprecated(e,t)),t&&(void 0===i[t]&&(i[t]=i[e]),delete i[e]))}),u=extend({},e),Object.keys(a).forEach(function(e){void 0!==u[e]&&null!==u[e]||(u[e]=a[e]&&a[e].default)}),l=extend({},c=e=u),Object.keys(c).forEach(function(e){var t,n,r,o,i=c[e];null!=i&&(void 0===(t=a[e])?s(unknownOption(e)):"any"!==(n=t.type||d(t.default))&&(r=n.split("|"),o=d(i),r.indexOf(o)<0?"boolean"===n?(l[e]=!!i,s(wrongOptionTypeBoolean(e,o))):(s(wrongOptionType(e,n,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&i<t.minimum&&(s(optionBelowMinimum(e,i,t.minimum)),l[e]=t.minimum)))}),validateLogger((e=l).logger),e}var getRandomValues,configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate}),rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&!(getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}var REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate$1(e){return"string"==typeof e&&REGEX.test(e)}for(var _nodeId,_clockseq,byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex.push((i$1+256).toString(16).substr(1));function stringify(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,t=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();if(!validate$1(t))throw TypeError("Stringified UUID is invalid");return t}var _lastMSecs=0,_lastNSecs=0;function v1(e,t,n){var r=t&&n||0,o=t||new Array(16),i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;null!=i&&null!=a||(u=e.random||(e.rng||rng)(),null==i&&(i=_nodeId=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=_clockseq=16383&(u[6]<<8|u[7])));var s=void 0!==e.msecs?e.msecs:Date.now(),n=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,u=s-_lastMSecs+(n-_lastNSecs)/1e4;if(u<0&&void 0===e.clockseq&&(a=a+1&16383),1e4<=(n=(u<0||_lastMSecs<s)&&void 0===e.nsecs?0:n))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_clockseq=a;n=(1e4*(268435455&(s+=122192928e5))+(_lastNSecs=n))%4294967296;o[r++]=n>>>24&255,o[r++]=n>>>16&255,o[r++]=n>>>8&255,o[r++]=255&n;s=s/4294967296*1e4&268435455;o[r++]=s>>>8&255,o[r++]=255&s,o[r++]=s>>>24&15|16,o[r++]=s>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var c=0;c<6;++c)o[r+c]=i[c];return t||stringify(o)}function parse(e){if(!validate$1(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}function stringToBytes$1(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}var DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function v35(e,a,s){function t(e,t,n,r){if("string"==typeof e&&(e=stringToBytes$1(e)),16!==(t="string"==typeof t?parse(t):t).length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var o=new Uint8Array(16+e.length);if(o.set(t),o.set(e,t.length),(o=s(o))[6]=15&o[6]|a,o[8]=63&o[8]|128,n){r=r||0;for(var i=0;i<16;++i)n[r+i]=o[i];return n}return stringify(o)}try{t.name=e}catch(e){}return t.DNS=DNS,t.URL=URL,t}function md5(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return md5ToHexEncodedArray(wordsToMd5(bytesToWords(e),8*e.length))}function md5ToHexEncodedArray(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,i=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(i)}return t}function getOutputLength(e){return 14+(e+64>>>9<<4)+1}function wordsToMd5(e,t){e[t>>5]|=128<<t%32,e[getOutputLength(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,u=r,c=o,l=i,n=md5ff(n,r,o,i,e[a],7,-680876936),i=md5ff(i,n,r,o,e[a+1],12,-389564586),o=md5ff(o,i,n,r,e[a+2],17,606105819),r=md5ff(r,o,i,n,e[a+3],22,-1044525330);n=md5ff(n,r,o,i,e[a+4],7,-176418897),i=md5ff(i,n,r,o,e[a+5],12,1200080426),o=md5ff(o,i,n,r,e[a+6],17,-1473231341),r=md5ff(r,o,i,n,e[a+7],22,-45705983),n=md5ff(n,r,o,i,e[a+8],7,1770035416),i=md5ff(i,n,r,o,e[a+9],12,-1958414417),o=md5ff(o,i,n,r,e[a+10],17,-42063),r=md5ff(r,o,i,n,e[a+11],22,-1990404162),n=md5ff(n,r,o,i,e[a+12],7,1804603682),i=md5ff(i,n,r,o,e[a+13],12,-40341101),o=md5ff(o,i,n,r,e[a+14],17,-1502002290),n=md5gg(n,r=md5ff(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=md5gg(i,n,r,o,e[a+6],9,-1069501632),o=md5gg(o,i,n,r,e[a+11],14,643717713),r=md5gg(r,o,i,n,e[a],20,-373897302),n=md5gg(n,r,o,i,e[a+5],5,-701558691),i=md5gg(i,n,r,o,e[a+10],9,38016083),o=md5gg(o,i,n,r,e[a+15],14,-660478335),r=md5gg(r,o,i,n,e[a+4],20,-405537848),n=md5gg(n,r,o,i,e[a+9],5,568446438),i=md5gg(i,n,r,o,e[a+14],9,-1019803690),o=md5gg(o,i,n,r,e[a+3],14,-187363961),r=md5gg(r,o,i,n,e[a+8],20,1163531501),n=md5gg(n,r,o,i,e[a+13],5,-1444681467),i=md5gg(i,n,r,o,e[a+2],9,-51403784),o=md5gg(o,i,n,r,e[a+7],14,1735328473),n=md5hh(n,r=md5gg(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=md5hh(i,n,r,o,e[a+8],11,-2022574463),o=md5hh(o,i,n,r,e[a+11],16,1839030562),r=md5hh(r,o,i,n,e[a+14],23,-35309556),n=md5hh(n,r,o,i,e[a+1],4,-1530992060),i=md5hh(i,n,r,o,e[a+4],11,1272893353),o=md5hh(o,i,n,r,e[a+7],16,-155497632),r=md5hh(r,o,i,n,e[a+10],23,-1094730640),n=md5hh(n,r,o,i,e[a+13],4,681279174),i=md5hh(i,n,r,o,e[a],11,-358537222),o=md5hh(o,i,n,r,e[a+3],16,-722521979),r=md5hh(r,o,i,n,e[a+6],23,76029189),n=md5hh(n,r,o,i,e[a+9],4,-640364487),i=md5hh(i,n,r,o,e[a+12],11,-421815835),o=md5hh(o,i,n,r,e[a+15],16,530742520),n=md5ii(n,r=md5hh(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=md5ii(i,n,r,o,e[a+7],10,1126891415),o=md5ii(o,i,n,r,e[a+14],15,-1416354905),r=md5ii(r,o,i,n,e[a+5],21,-57434055),n=md5ii(n,r,o,i,e[a+12],6,1700485571),i=md5ii(i,n,r,o,e[a+3],10,-1894986606),o=md5ii(o,i,n,r,e[a+10],15,-1051523),r=md5ii(r,o,i,n,e[a+1],21,-2054922799),n=md5ii(n,r,o,i,e[a+8],6,1873313359),i=md5ii(i,n,r,o,e[a+15],10,-30611744),o=md5ii(o,i,n,r,e[a+6],15,-1560198380),r=md5ii(r,o,i,n,e[a+13],21,1309151649),n=md5ii(n,r,o,i,e[a+4],6,-145523070),i=md5ii(i,n,r,o,e[a+11],10,-1120210379),o=md5ii(o,i,n,r,e[a+2],15,718787259),r=md5ii(r,o,i,n,e[a+9],21,-343485551),n=safeAdd(n,s),r=safeAdd(r,u),o=safeAdd(o,c),i=safeAdd(i,l)}return[n,r,o,i]}function bytesToWords(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(getOutputLength(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}function safeAdd(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function bitRotateLeft(e,t){return e<<t|e>>>32-t}function md5cmn(e,t,n,r,o,i){return safeAdd(bitRotateLeft(safeAdd(safeAdd(t,e),safeAdd(r,i)),o),n)}function md5ff(e,t,n,r,o,i,a){return md5cmn(t&n|~t&r,e,t,o,i,a)}function md5gg(e,t,n,r,o,i,a){return md5cmn(t&r|n&~r,e,t,o,i,a)}function md5hh(e,t,n,r,o,i,a){return md5cmn(t^n^r,e,t,o,i,a)}function md5ii(e,t,n,r,o,i,a){return md5cmn(n^(t|~r),e,t,o,i,a)}var v3=v35("v3",48,md5);function v4(e,t,n){var r=(e=e||{}).random||(e.rng||rng)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return stringify(r)}function f(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function ROTL(e,t){return e<<t|e>>>32-t}function sha1(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),s=new Array(a),u=0;u<a;++u){for(var c=new Uint32Array(16),l=0;l<16;++l)c[l]=e[64*u+4*l]<<24|e[64*u+4*l+1]<<16|e[64*u+4*l+2]<<8|e[64*u+4*l+3];s[u]=c}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var v=new Uint32Array(80),g=0;g<16;++g)v[g]=s[d][g];for(var m=16;m<80;++m)v[m]=ROTL(v[m-3]^v[m-8]^v[m-14]^v[m-16],1);for(var p=n[0],y=n[1],h=n[2],b=n[3],E=n[4],k=0;k<80;++k)var S=Math.floor(k/20),S=ROTL(p,5)+f(S,y,h,b)+E+t[S]+v[k]>>>0,E=b,b=h,h=ROTL(y,30)>>>0,y=p,p=S;n[0]=n[0]+p>>>0,n[1]=n[1]+y>>>0,n[2]=n[2]+h>>>0,n[3]=n[3]+b>>>0,n[4]=n[4]+E>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}var v5=v35("v5",80,sha1),nil="00000000-0000-0000-0000-000000000000";function version(e){if(!validate$1(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}var esmBrowser=Object.freeze({__proto__:null,v1:v1,v3:v3,v4:v4,v5:v5,NIL:nil,version:version,validate:validate$1,stringify:stringify,parse:parse}),uuidv1$2=esmBrowser.v1,baseOptionDefs$1=configuration.baseOptionDefs;function DiagnosticId(e){var t={diagnosticId:uuidv1$2()};return e&&(t.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),t}function DiagnosticsAccumulator(e){var t,n,r,o;function i(e){t=e,r=n=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}},setProps:function(e){t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){n++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,t,n){o.push({timestamp:e,failed:t,durationMillis:n})},reset:i}}function DiagnosticsManager(t,r,e,n,o,i,a){var s,u,c=!!t.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",d=i.eventsUrl+"/events/diagnostic/"+o,f=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,e={};function m(){return{sdk:function(){var e=_objectSpread2({},t.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:i.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:i.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},platform:t.diagnosticPlatformData}}function p(e){i.logger&&i.logger.debug(messages.debugPostingDiagnosticEvent(e)),n.sendEvents(e,d,!0).then(function(){}).catch(function(){})}function y(){var e,t;p((e=(new Date).getTime(),t=_objectSpread2({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps()),c&&(t=_objectSpread2(_objectSpread2({},t),m())),v.reset(e),t)),u=setTimeout(y,f),s=(new Date).getTime(),c&&r.isEnabled()&&(t=_objectSpread2({},v.getProps()),r.set(l,JSON.stringify(t)))}return e.start=function(){c?function(n){if(!r.isEnabled())return n(!1);r.get(l).then(function(e){if(e)try{var t=JSON.parse(e);v.setProps(t),s=t.dataSinceDate}catch(e){}n(!0)}).catch(function(){n(!1)})}(function(e){var t;e?(t=(s||0)+f)<=(e=(new Date).getTime())?y():u=setTimeout(y,t-e):0===Math.floor(4*Math.random())?y():u=setTimeout(y,f)}):(p(_objectSpread2({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},m())),u=setTimeout(y,f))},e.stop=function(){u&&clearTimeout(u)},e.setStreaming=function(e){g=e},e}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager,changeEvent="change",internalChangeEvent="internal-change";function initialize(e,t,n,i,r){var a,o,s,u=function(){if(n&&n.logger)return n.logger;return r&&r.logger&&r.logger.default||commonBasicLogger("warn")}(),c=EventEmitter(u),l=InitializationState(c),d=validate(n,c,r,u),f=d.sendEvents,v=e,g=d.hash,m=PersistentStorage(i.localStorage,u),p=EventSender(i,v,d),y=d.sendEvents&&!d.diagnosticOptOut,h=y?diagnosticEvents_1(v):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(i,m,b,p,v,d,h):null,k=Stream(i,d,v,b),S=d.eventProcessor||EventProcessor(i,d,v,b,c,p),D=Requestor(i,d,v),w={},U={},T=d.streaming,P=!1,O=!1,I=!0,L=d.stateProvider,A=Identity(null,function(e,t){(function(e){L||e&&_({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!d.autoAliasingOptOut&&t&&t.anonymous&&e&&!e.anonymous&&H(e,t)}),R=UserValidator(m),C=m.isEnabled()?new PersistentFlagStore(m,v,g,A,u):null;function _(e){if(v&&!(L&&L.enqueueEvent&&L.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(I&&(u.warn(eventWithoutUser()),I=!1));I=!1}!f||O||i.isDoNotTrack()||(u.debug(debugEnqueueingEvent(e.kind)),S.enqueue(e))}}function j(e,t,n,r){var o=A.getUser(),i=new Date,a=t?t.value:null;if(!d.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=w[s];if(u&&i-u<3e5)return;w[s]=i}i={kind:"feature",key:e,user:o,value:a,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()};o&&o.anonymous&&(i.contextKind=N(o));e=U[e];e&&(i.version=e.flagVersion||e.version,i.trackEvents=e.trackEvents,i.debugEventsUntilDate=e.debugEventsUntilDate),(r||e&&e.trackReason)&&t&&(i.reason=t.reason),_(i)}function x(e,t,n,r){var o,i;return U&&objectHasOwnProperty(U,e)&&U[e]&&!U[e].deleted?(i=F(o=U[e]),null!==o.value&&void 0!==o.value||(i.value=t)):i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},n&&j(e,i,t,r),i}function F(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function N(e){return e.anonymous?"anonymousUser":"user"}function H(e,t){L||e&&t&&_({kind:"alias",key:e.key,contextKind:N(e),previousKey:t.key,previousContextKind:N(t),creationDate:(new Date).getTime()})}function V(){o=!0,A.getUser()&&k.connect(A.getUser(),g,{ping:function(){u.debug(debugStreamPing());var t=A.getUser();D.fetchFlagSettings(t,g).then(function(e){deepEquals(t,A.getUser())&&M(e||{})}).catch(function(e){c.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){e=JSON.parse(e.data);u.debug(debugStreamPut()),M(e)},patch:function(e){var t,n=JSON.parse(e.data),r=U[n.key];!r||!r.version||!n.version||r.version<n.version?(u.debug(debugStreamPatch(n.key)),t={},delete(e=extend({},n)).key,e=F(U[n.key]=e),t[n.key]=r?{previous:r.value,current:e}:{current:e},z(t)):u.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var t=JSON.parse(e.data);!U[t.key]||U[t.key].version<t.version?(u.debug(debugStreamDelete(t.key)),e={},U[t.key]&&!U[t.key].deleted&&(e[t.key]={previous:U[t.key].value}),U[t.key]={version:t.version,deleted:!0},z(e)):u.debug(debugStreamDeleteIgnored(t.key))}})}function q(){o&&(k.disconnect(),o=!1)}function M(e){var t,n,r={};if(!e)return Promise.resolve();for(t in U)objectHasOwnProperty(U,t)&&U[t]&&(e[t]&&!deepEquals(e[t].value,U[t].value)?r[t]={previous:U[t].value,current:F(e[t])}:e[t]&&!e[t].deleted||(r[t]={previous:U[t].value}));for(n in e)objectHasOwnProperty(e,n)&&e[n]&&(!U[n]||U[n].deleted)&&(r[n]={current:F(e[n])});return U=_objectSpread2({},e),z(r).catch(function(){})}function z(o){var i,e=Object.keys(o);return 0<e.length&&(i={},e.forEach(function(e){var t=o[e].current,n=t?t.value:void 0,r=o[e].previous;c.emit(changeEvent+":"+e,n,r),i[e]=t?{current:n,previous:r}:{previous:r}}),c.emit(changeEvent,i),c.emit(internalChangeEvent,U),d.sendEventsOnlyForVariation||L||e.forEach(function(e){j(e,o[e].current)})),a&&C?C.saveFlags(U):Promise.resolve()}function $(){var e=T||s&&void 0===T;e&&!o?V():!e&&o&&q(),E&&E.setStreaming(e)}function B(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}function K(e){v=e.environment,A.setUser(e.user),U=_objectSpread2({},e.flags),onNextTick(J)}function J(){u.info(clientInitialized()),P=!0,$(),l.signalSuccess()}function G(e){l.signalFailure(e)}return"string"==typeof d.bootstrap&&"LOCALSTORAGE"===d.bootstrap.toUpperCase()&&(C?a=!0:u.warn(localStorageUnavailable())),"object"===_typeof(d.bootstrap)&&(U=function(n){var e=Object.keys(n),r="$flagsState",o=n[r];!o&&e.length&&u.warn(bootstrapOldFormat()),!1===n.$valid&&u.warn(bootstrapInvalid());var i={};return e.forEach(function(e){var t;e!==r&&"$valid"!==e&&(t={value:n[e]},o&&o[e]?t=extend(t,o[e]):t.version=0,i[e]=t)}),i}(d.bootstrap)),L?((m=L.getInitialState())?K(m):L.on("init",K),L.on("update",function(e){e.user&&A.setUser(e.user);e.flags&&M(e.flags)})):(e?R.validateUser(t).then(function(e){return A.setUser(e),"object"===_typeof(d.bootstrap)?J():a?C.loadFlags().then(function(e){return null==e?(U={},D.fetchFlagSettings(A.getUser(),g).then(function(e){return M(e||{})}).then(J).catch(function(e){G(new LDFlagFetchError(errorFetchingFlags(e)))})):(U=e,onNextTick(J),D.fetchFlagSettings(A.getUser(),g).then(M).catch(function(e){return c.maybeReportError(e)}))}):D.fetchFlagSettings(A.getUser(),g).then(function(e){U=e||{},J()}).catch(function(e){U={},G(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(G),{client:{waitForInitialization:function(){return l.getInitializationPromise()},waitUntilReady:function(){return l.getReadyPromise()},identify:function(e,r,t){return O?wrapPromiseCallback(Promise.resolve({}),t):L?(u.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(U)),t)):wrapPromiseCallback((a&&C?C.clearFlags():Promise.resolve()).then(function(){return R.validateUser(e)}).then(function(n){return D.fetchFlagSettings(n,r).then(function(e){var t=transformVersionedValuesToValues(e);return A.setUser(n),g=r,e?M(e).then(function(){return t}):t})}).then(function(e){return o&&V(),e}).catch(function(e){return c.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return A.getUser()},variation:function(e,t){return x(e,t,!0,!1).value},variationDetail:function(e,t){return x(e,t,!0,!0)},track:function(e,t,n){var r,o;"string"==typeof e?(i.customEventFilter&&!i.customEventFilter(e)&&u.warn(unknownCustomEventKey(e)),o={kind:"custom",key:e,user:r=A.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},r&&r.anonymous&&(o.contextKind=N(r)),null!=t&&(o.data=t),null!=n&&(o.metricValue=n),_(o)):c.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},alias:H,on:function(e,t,n){B(e)?(s=!0,P&&$(),c.on(e,t,n)):c.on.apply(c,arguments)},off:function(e){var t;c.off.apply(c,arguments),B(e)&&(t=!1,c.getEvents().forEach(function(e){B(e)&&0<c.getEventListenerCount(e)&&(t=!0)}),t||(s=!1,o&&void 0===T&&q()))},setStreaming:function(e){(e=null===e?void 0:e)!==T&&(T=e,$())},flush:function(e){return wrapPromiseCallback(f?S.flush():Promise.resolve(),e)},allFlags:function(){var e,t={};if(!U)return t;for(e in U)objectHasOwnProperty(U,e)&&(t[e]=x(e,null,!d.sendEventsOnlyForVariation).value);return t},close:function(e){return wrapPromiseCallback(O?Promise.resolve():Promise.resolve().then(function(){if(q(),E&&E.stop(),f)return S.stop(),S.flush()}).then(t).catch(t),e);function t(){O=!0,U={}}}},options:d,emitter:c,ident:A,logger:u,requestor:D,start:function(){f&&(E&&E.start(),S.start())},enqueueEvent:_,getFlagsInternal:function(){return U},getEnvironmentId:function(){return v},internalChangeEventName:internalChangeEvent}}var version$1="4.0.0";exports.commonBasicLogger=commonBasicLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version$1;
//# sourceMappingURL=ldclient-common.cjs.js.map

@@ -1,2 +0,2 @@

function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(i,!0).forEach((function(t){n(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(i).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(i,n))}))}return e}function i(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var a=o("LaunchDarklyUnexpectedResponseError"),u=o("LaunchDarklyInvalidEnvironmentIdError"),s=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),l=o("LaunchDarklyInvalidArgumentError"),f=o("LaunchDarklyFlagFetchError");function v(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var d=Object.freeze({__proto__:null,LDUnexpectedResponseError:a,LDInvalidEnvironmentIdError:u,LDInvalidUserError:s,LDInvalidEventKeyError:c,LDInvalidArgumentError:l,LDFlagFetchError:f,isHttpErrorRecoverable:v}),g=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(k(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(p[n>>2]+p[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(p[n>>10]+p[n>>4&63]+p[n<<2&63]+"="));return i.join("")},p=[],m=[],y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,b=y.length;h<b;++h)p[h]=y[h],m[y.charCodeAt(h)]=h;function k(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(p[(i=r)>>18&63]+p[i>>12&63]+p[i>>6&63]+p[63&i]);return o.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var E=Array.isArray,w=Object.keys,D=Object.prototype.hasOwnProperty,O=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return g(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function I(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=E(n),u=E(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=w(n);if((i=v.length)!==w(t).length)return!1;for(r=i;0!=r--;)if(!D.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function j(e){setTimeout(e,0)}function T(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function R(e){var n={};for(var t in e)q(e,t)&&(n[t]={value:e[t],version:0});return n}function N(e){var n={};for(var t in e)q(e,t)&&(n[t]=e[t].value);return n}function F(e,n){for(var t,r=n.slice(0),i=[],o=e;r.length>0;){for(t=[];o>0;){var a=r.shift();if(!a)break;(o-=P(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function A(e){var n=e.version||"3.5.0";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":A(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(r({},e)):e}function x(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function q(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function V(e){if(!e)return e;var n;for(var t in O){var i=O[t],o=e[i];void 0!==o&&"string"!=typeof o&&((n=n||r({},e))[i]=String(o))}return n||e}var _=Object.freeze({__proto__:null,btoa:S,base64URLEncode:P,clone:U,deepEquals:I,onNextTick:j,wrapPromiseCallback:T,transformValuesToVersionedValues:R,transformVersionedValuesToValues:N,chunkUserEventsForUrl:F,getLDUserAgentString:A,getLDHeaders:C,transformHeaders:L,extend:x,objectHasOwnProperty:q,sanitizeUser:V});for(var J=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}})),z=[],M=0;M<256;++M)z[M]=(M+256).toString(16).substr(1);var K,H,B=function(e,n){var t=n||0,r=z;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},$=0,G=0;var X=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||K,a=void 0!==e.clockseq?e.clockseq:H;if(null==o||null==a){var u=J();null==o&&(o=K=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=H=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:G+1,l=s-$+(c-G)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>$)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");$=s,G=c,H=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||B(i)};function W(e,n,t){var r="/a/"+n+".gif",i=x({"Content-Type":"application/json"},C(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,a,u,s){var c=JSON.stringify(n),l=u?null:X();return s?function n(r){var o=u?i:x({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,L(o,t),c).promise.then((function(e){if(e)return e.status>=400&&v(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(a+r+"?d="+P(c)),Promise.resolve())},a.sendEvents=function(n,t,r){if(!e.httpRequest)return Promise.resolve();var i,o=e.httpAllowsPost();i=o?[n]:F(2e3-t.length,n);for(var u=[],s=0;s<i.length;s++)u.push(a.sendChunk(i[s],t,r,o));return Promise.all(u)},a}function Q(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),o=r[i];o?o.count=o.count+1:r[i]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},i=!0;for(var o in r){var a=r[o],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),i=!1}return i?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function Y(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],i={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,o){return Object.keys(e).reduce((function(a,u){var s=a;return o(u)&&(!function(e){return!i[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s}),[{},{}])},u=a(e,(function(e){return o[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=x({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function Z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ee=function(){return"LaunchDarkly client initialized"},ne=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",te=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},re=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},ie=function(e){return'Expected application/json content type but got "'+e+'"'},oe=function(e){return"local storage is unavailable: "+Z(e)},ae=function(e){return"network error"+(e?" ("+e+")":"")},ue=function(e){return'Custom event "'+e+'" does not exist'},se=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ne},ce=function(){return"No environment/client-side ID was specified."+ne},le=function(e){return"Error fetching flag settings: "+Z(e)},fe=function(){return"No user specified."+ne},ve=function(){return"Invalid user specified."+ne},de=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ne},ge=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},pe=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},me=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(v(e)?t:"giving up permanently")},ye=function(){return"Cannot make HTTP requests in this environment."+ne},he=function(){return"identify() has no effect here; it must be called on the main client instance"},be=function(){return"Closing stream connection"},ke=function(e){return"Opening stream connection to "+e},Ee=function(e,n){return"Error on stream connection: "+Z(e)+", will continue retrying every "+n+" milliseconds."},we=function(e){return'Ignoring unknown config option "'+e+'"'},De=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Oe=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Se=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Pe=function(e){return"polling for feature flags at "+e},Ue=function(){return"received ping message from stream"},Ie=function(){return"received streaming update for all flags"},je=function(e){return'received streaming update for flag "'+e+'"'},Te=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Re=function(e){return'received streaming deletion for flag "'+e+'"'},Ne=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'enqueueing "'+e+'" event'},Ae=function(e){return"sending "+e+" events"},Ce=Object.freeze({__proto__:null,clientInitialized:ee,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:te,eventWithoutUser:re,invalidContentType:ie,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:oe,networkError:ae,unknownCustomEventKey:ue,environmentNotFound:se,environmentNotSpecified:ce,errorFetchingFlags:le,userNotSpecified:fe,invalidUser:ve,bootstrapOldFormat:de,bootstrapInvalid:ge,deprecated:pe,httpErrorMessage:me,httpUnavailable:ye,identifyDisabled:he,streamClosing:be,streamConnecting:ke,streamError:Ee,unknownOption:we,wrongOptionType:De,wrongOptionTypeBoolean:Oe,optionBelowMinimum:Se,debugPolling:Pe,debugStreamPing:Ue,debugStreamPut:Ie,debugStreamPatch:je,debugStreamPatchIgnored:Te,debugStreamDelete:Re,debugStreamDeleteIgnored:Ne,debugEnqueueingEvent:Fe,debugPostingEvents:Ae,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Le(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var xe=function(e){var n=!1,t=!1,r=null,i=null,o=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return i||(n?Promise.resolve():t?Promise.reject(r):i=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(i){n||t||(t=!0,r=i,e.emit("failed",i),e.emit("ready")),e.maybeReportError(i)}}};function qe(e,n,t,r){var i={};function o(){var e="",i=r.getUser();return i&&(e=t||S(JSON.stringify(i))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(o()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=R(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return null}))}}))},i.saveFlags=function(n){var t=x({},n,{$schema:1});return e.set(o(),JSON.stringify(t))},i.clearFlags=function(){return e.clear(o())},i}function Ve(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=o+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=C(e,n),d=!1,g=null,p=null,m=null,y=null,h=null;function b(e){d||(a.warn(Ee(e,f)),d=!0),D(!1),w(),k(f)}function k(e){p||(e?p=setTimeout(E,e):E())}function E(){var r;p=null;var u="",f={headers:v,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var d in null!=y&&(u="h="+y),c?e.eventSourceAllowsReport?(r=s,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(m)):(r=o+"/ping/"+t,u=""):r=s+"/"+P(JSON.stringify(m)),f.headers=L(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,w(),a.info(ke(r)),i=(new Date).getTime(),g=e.eventSourceFactory(r,f),h)q(h,d)&&g.addEventListener(d,h[d]);g.onerror=b}}function w(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(e){i&&r&&r.recordStreamInit(i,!e,(new Date).getTime()-i),i=null}return u.connect=function(e,n,t){m=e,y=n,h={};var r=function(e){h[e]=function(n){d=!1,D(!0),t[e]&&t[e](n)}};for(var i in t||{})r(i);k()},u.disconnect=function(){clearTimeout(p),p=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function _e(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,a=n.logger,s={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new f(ye()))}));var i=r?"REPORT":"GET",o=C(e,n);r&&(o["Content-Type"]="application/json");var a=c[t];a||(a=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=a);var s=e.httpRequest(i,t,L(o,n),r),l=s.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=ie(e.header("content-type")||"");return Promise.reject(new f(n))}return Promise.reject(function(e){return 404===e.status?new u(se()):new f(le(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new f(ae(e)))}));return a.addPromise(l,(function(){s.cancel&&s.cancel()})),a.resultPromise}return s.fetchJSON=function(e){return l(r+e,null)},s.fetchFlagSettings=function(e,n){var u,s,c,f="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=P(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),o&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(Pe(s)),l(s,c)},s}function Je(e){var n={};return n.validateUser=function(n){if(!n)return Promise.reject(new s(fe()));var t=U(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=X();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new s(ve()))},n}var ze=["debug","info","warn","error","none"];function Me(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],o=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var s=0;s<ze.length;s++)ze[s]===e.level&&(u=s);function c(e,t,u){if(!(u.length<1)){var s,c=o?t+": "+a:a;if(1!==u.length&&n){var l=i(u);l[0]=c+l[0],s=n.apply(void 0,i(l))}else s=c+u[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=ze[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},v=0;v<ze.length;v++)f(v);return l}function Ke(e,n){return Me({level:e,prefix:n})}var He={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function Be(n,t,r,i){var o=x({logger:{default:i}},He,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){j((function(){t&&t.maybeReportError(new l(e))}))}var s=x({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(pe(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){ze.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(n){var t=x({},n),r=function(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}};return Object.keys(n).forEach((function(e){var i=n[e];if(null!=i){var a=o[e];if(void 0===a)u(we(e));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(i);c.indexOf(l)<0?"boolean"===s?(t[e]=!!i,u(Oe(e,l))):(u(De(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&i<a.minimum&&(u(Se(e,i,a.minimum)),t[e]=a.minimum)}}}})),t}(s=function(e){var n=x({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))).logger),s}var $e=Object.freeze({__proto__:null,baseOptionDefs:He,validate:Be}).baseOptionDefs;var Ge=function(e){var n={diagnosticId:X()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Xe=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},We=function(e,n,t,i,o,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+o+":$diagnostics",v=a.eventsUrl+"/events/diagnostic/"+o,d=a.diagnosticRecordingInterval,g=t,p=!!a.streaming,m={};function y(){return{sdk:k(),configuration:(n={customBaseURI:a.baseUrl!==$e.baseUrl.default,customStreamURI:a.streamUrl!==$e.streamUrl.default,customEventsURI:a.eventsUrl!==$e.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function h(e){a.logger&&a.logger.debug(Ce.debugPostingDiagnosticEvent(e)),i.sendEvents(e,v,!0).then((function(){})).catch((function(){}))}function b(){var e,t;h((e=(new Date).getTime(),t=r({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(t=r({},t,{},y())),g.reset(e),t)),c=setTimeout(b,d),s=(new Date).getTime(),l&&function(){if(n.isEnabled()){var e=r({},g.getProps());n.set(f,JSON.stringify(e))}}()}function k(){var n=r({},e.diagnosticSdkData);return a.wrapperName&&(n.wrapperName=a.wrapperName),a.wrapperVersion&&(n.wrapperVersion=a.wrapperVersion),n}return m.start=function(){l?function(e){if(!n.isEnabled())return e(!1);n.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();t>=n?b():c=setTimeout(b,n-t)}else 0===Math.floor(4*Math.random())?b():c=setTimeout(b,d)})):(h(r({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},y())),c=setTimeout(b,d))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m};function Qe(n,t,i,o,s){var l,d,g,p=function(){if(i&&i.logger)return i.logger;return s&&s.logger&&s.logger.default||Ke("warn")}(),m=Le(p),y=xe(m),h=Be(i,m,s,p),b=h.sendEvents,k=n,E=h.hash,w=function(e,n){var t={},r=!1,i=function(e){r||(r=!0,n.warn(oe(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){i(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){i(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){i(e),t(!1)})):t(!1)}))},t}(o.localStorage,p),D=W(o,k,h),O=h.sendEvents&&!h.diagnosticOptOut,S=O?Ge(k):null,P=O?Xe((new Date).getTime()):null,R=O?We(o,w,P,D,k,h,S):null,F=Ve(o,h,k,P),A=h.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||W(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,f=Q(),d=Y(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function O(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function S(e){var n=x({},e);return"alias"===e.kind?n:(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n)}function P(e){b.length<m?(b.push(e),w=!1):(w||(w=!0,h.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),i&&i.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=O(e)):n=D(),n&&P(S(e)),t){var r=x({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Ae(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),v(e.status)||(E=!0),e.status>=400&&j((function(){o.maybeReportError(new a(me(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,y)}),y)},s.stop=function(){clearTimeout(r)},s}(o,h,k,P,m,D),C=_e(o,h,k),L={},_={},J=h.streaming,z=!1,M=!1,K=!0,H=h.stateProvider,B=function(e,n){var t,r={};return r.setUser=function(e){var r=t&&U(t);(t=V(e))&&n&&n(U(t),r)},r.getUser=function(){return t?U(t):null},e&&r.setUser(e),r}(null,(function(e,n){(function(e){if(H)return;e&&X({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!h.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&re(e,n)})),$=Je(w),G=w.isEnabled()?new qe(w,k,E,B,p):null;function X(e){if(k&&!(H&&H.enqueueEvent&&H.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(K&&(p.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),K=!1));K=!1}!b||M||o.isDoNotTrack()||(p.debug(Fe(e.kind)),A.enqueue(e))}}function Z(e,n,t,r){var i=B.getUser(),o=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=L[u];if(s&&o-s<3e5)return;L[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(c.contextKind=te(i));var l=_[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),X(c)}function ee(e,n,t,r){var i;if(_&&q(_,e)&&_[e]&&!_[e].deleted){var o=_[e];i=ne(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Z(e,i,n,r),i}function ne(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function te(e){return e.anonymous?"anonymousUser":"user"}function re(e,n){H||e&&n&&X({kind:"alias",key:e.key,contextKind:te(e),previousKey:n.key,previousContextKind:te(n),creationDate:(new Date).getTime()})}function ie(){d=!0,B.getUser()&&F.connect(B.getUser(),E,{ping:function(){p.debug("received ping message from stream");var e=B.getUser();C.fetchFlagSettings(e,E).then((function(n){I(e,B.getUser())&&se(n||{})})).catch((function(e){m.maybeReportError(new f(le(e)))}))},put:function(e){var n=JSON.parse(e.data);p.debug("received streaming update for all flags"),se(n)},patch:function(e){var n=JSON.parse(e.data),t=_[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(je(n.key));var r={},i=x({},n);delete i.key,_[n.key]=i;var o=ne(i);r[n.key]=t?{previous:t.value,current:o}:{current:o},fe(r)}else p.debug(Te(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!_[n.key]||_[n.key].version<n.version){p.debug(Re(n.key));var t={};_[n.key]&&!_[n.key].deleted&&(t[n.key]={previous:_[n.key].value}),_[n.key]={version:n.version,deleted:!0},fe(t)}else p.debug(Ne(n.key))}})}function ae(){d&&(F.disconnect(),d=!1)}function se(e){var n={};if(!e)return Promise.resolve();for(var t in _)q(_,t)&&_[t]&&(e[t]&&!I(e[t].value,_[t].value)?n[t]={previous:_[t].value,current:ne(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:_[t].value}));for(var i in e)q(e,i)&&e[i]&&(!_[i]||_[i].deleted)&&(n[i]={current:ne(e[i])});return _=r({},e),fe(n).catch((function(){}))}function fe(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,i=r?r.value:void 0,o=e[n].previous;m.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),m.emit("change",t),m.emit("internal-change",_),h.sendEventsOnlyForVariation||H||n.forEach((function(n){Z(n,e[n].current)}))}return l&&G?G.saveFlags(_):Promise.resolve()}function ve(){var e=J||g&&void 0===J;e&&!d?ie():!e&&d&&ae(),R&&R.setStreaming(e)}function ge(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(G?l=!0:p.warn(oe())),"object"===e(h.bootstrap)&&(_=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(de()),!1===e.$valid&&p.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=x(i,t[n]):i.version=0,r[n]=i}})),r}(h.bootstrap)),H){var pe=H.getInitialState();pe?ye(pe):H.on("init",ye),H.on("update",(function(e){e.user&&B.setUser(e.user);e.flags&&se(e.flags)}))}else(function(){if(!n)return Promise.reject(new u(ce()));return $.validateUser(t).then((function(n){return B.setUser(n),"object"===e(h.bootstrap)?he():l?G.loadFlags().then((function(e){return null==e?(_={},C.fetchFlagSettings(B.getUser(),E).then((function(e){return se(e||{})})).then(he).catch((function(e){be(new f(le(e)))}))):(_=e,j(he),C.fetchFlagSettings(B.getUser(),E).then((function(e){return se(e)})).catch((function(e){return m.maybeReportError(e)})))})):C.fetchFlagSettings(B.getUser(),E).then((function(e){_=e||{},he()})).catch((function(e){_={},be(e)}))}))})().catch(be);function ye(e){k=e.environment,B.setUser(e.user),_=r({},e.flags),j(he)}function he(){p.info("LaunchDarkly client initialized"),z=!0,ve(),y.signalSuccess()}function be(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return M?T(Promise.resolve({}),t):H?(p.warn("identify() has no effect here; it must be called on the main client instance"),T(Promise.resolve(N(_)),t)):T((l&&G?G.clearFlags():Promise.resolve()).then((function(){return $.validateUser(e)})).then((function(e){return C.fetchFlagSettings(e,n).then((function(t){var r=N(t);return B.setUser(e),E=n,t?se(t).then((function(){return r})):r}))})).then((function(e){return d&&ie(),e})).catch((function(e){return m.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return B.getUser()},variation:function(e,n){return ee(e,n,!0,!1).value},variationDetail:function(e,n){return ee(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&p.warn(ue(e));var r=B.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=te(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),X(i)}else m.maybeReportError(new c(ue(e)))},alias:re,on:function(e,n,t){ge(e)?(g=!0,z&&ve(),m.on(e,n,t)):m.on.apply(m,arguments)},off:function(e){if(m.off.apply(m,arguments),ge(e)){var n=!1;m.getEvents().forEach((function(e){ge(e)&&m.getEventListenerCount(e)>0&&(n=!0)})),n||(g=!1,d&&void 0===J&&ae())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,ve())},flush:function(e){return T(b?A.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!_)return e;for(var n in _)q(_,n)&&(e[n]=ee(n,null,!h.sendEventsOnlyForVariation).value);return e},close:function(e){if(M)return T(Promise.resolve(),e);var n=function(){M=!0,_={}};return T(Promise.resolve().then((function(){if(ae(),R&&R.stop(),b)return A.stop(),A.flush()})).then(n).catch(n),e)}},options:h,emitter:m,ident:B,logger:p,requestor:C,start:function(){b&&(R&&R.start(),A.start())},enqueueEvent:X,getFlagsInternal:function(){return _},getEnvironmentId:function(){return k},internalChangeEventName:"internal-change"}}var Ye="3.5.0";export{Me as commonBasicLogger,Ke as createConsoleLogger,d as errors,Qe as initialize,Ce as messages,_ as utils,Ye as version};
function e(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function n(n){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?e(Object(i),!0).forEach((function(e){r(n,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"==typeof e)return o(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function a(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),v=a("LaunchDarklyFlagFetchError");function d(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var g=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:v,isHttpErrorRecoverable:d}),p=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(E(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(m[n>>2]+m[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(m[n>>10]+m[n>>4&63]+m[n<<2&63]+"="));return i.join("")},m=[],h=[],y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=0,k=y.length;b<k;++b)m[b]=y[b],h[y.charCodeAt(b)]=b;function E(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(m[(i=r)>>18&63]+m[i>>12&63]+m[i>>6&63]+m[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var w=Array.isArray,D=Object.keys,O=Object.prototype.hasOwnProperty,S=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function U(e){var n=unescape(encodeURIComponent(e));return p(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return U(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=w(n),u=w(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=D(n);if((i=v.length)!==D(t).length)return!1;for(r=i;0!=r--;)if(!O.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function R(e){setTimeout(e,0)}function T(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function A(e){var n={};for(var t in e)V(e,t)&&(n[t]={value:e[t],version:0});return n}function C(e){var n={};for(var t in e)V(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),i=[],o=e;r.length>0;){for(t=[];o>0;){var a=r.shift();if(!a)break;(o-=P(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function L(e){var n=e.version||"4.0.0";return e.userAgent+"/"+n}function F(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":L(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function x(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function q(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t){return n(n({},e),t)}),{})}function V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var t;for(var r in S){var i=S[r],o=e[i];void 0!==o&&"string"!=typeof o&&((t=t||n({},e))[i]=String(o))}return t||e}var z=Object.freeze({__proto__:null,btoa:U,base64URLEncode:P,clone:I,deepEquals:j,onNextTick:R,wrapPromiseCallback:T,transformValuesToVersionedValues:A,transformVersionedValuesToValues:C,chunkUserEventsForUrl:N,getLDUserAgentString:L,getLDHeaders:F,transformHeaders:x,extend:q,objectHasOwnProperty:V,sanitizeUser:_}),J=require("uuid").v1;function M(e,n,t){var r="/a/"+n+".gif",i=q({"Content-Type":"application/json"},F(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,a,u,s){var c=JSON.stringify(n),l=u?null:J();return s?function n(r){var o=u?i:q({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,x(o,t),c).promise.then((function(e){if(e)return e.status>=400&&d(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(a+r+"?d="+P(c)),Promise.resolve())},a.sendEvents=function(n,t,r){if(!e.httpRequest)return Promise.resolve();var i,o=e.httpAllowsPost();i=o?[n]:N(2e3-t.length,n);for(var u=[],s=0;s<i.length;s++)u.push(a.sendChunk(i[s],t,r,o));return Promise.all(u)},a}function K(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),o=r[i];o?o.count=o.count+1:r[i]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},i=!0;for(var o in r){var a=r[o],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),i=!1}return i?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function $(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],i={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,o){return Object.keys(e).reduce((function(a,u){var s=a;return o(u)&&(!function(e){return!i[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s}),[{},{}])},u=a(e,(function(e){return o[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=q({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function H(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var B=function(){return"LaunchDarkly client initialized"},G=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",X=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},W=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},Q=function(e){return'Expected application/json content type but got "'+e+'"'},Y=function(e){return"local storage is unavailable: "+H(e)},Z=function(e){return"network error"+(e?" ("+e+")":"")},ee=function(e){return'Custom event "'+e+'" does not exist'},ne=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+G},te=function(){return"No environment/client-side ID was specified."+G},re=function(e){return"Error fetching flag settings: "+H(e)},ie=function(){return"No user specified."+G},oe=function(){return"Invalid user specified."+G},ae=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+G},ue=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},se=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ce=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(d(e)?t:"giving up permanently")},le=function(){return"Cannot make HTTP requests in this environment."+G},fe=function(){return"identify() has no effect here; it must be called on the main client instance"},ve=function(){return"Closing stream connection"},de=function(e){return"Opening stream connection to "+e},ge=function(e,n){return"Error on stream connection: "+H(e)+", will continue retrying every "+n+" milliseconds."},pe=function(e){return'Ignoring unknown config option "'+e+'"'},me=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},he=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},ye=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},be=function(e){return"polling for feature flags at "+e},ke=function(){return"received ping message from stream"},Ee=function(){return"received streaming update for all flags"},we=function(e){return'received streaming update for flag "'+e+'"'},De=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Oe=function(e){return'received streaming deletion for flag "'+e+'"'},Se=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ue=function(e){return'enqueueing "'+e+'" event'},Pe=function(e){return"sending "+e+" events"},Ie=Object.freeze({__proto__:null,clientInitialized:B,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:X,eventWithoutUser:W,invalidContentType:Q,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Y,networkError:Z,unknownCustomEventKey:ee,environmentNotFound:ne,environmentNotSpecified:te,errorFetchingFlags:re,userNotSpecified:ie,invalidUser:oe,bootstrapOldFormat:ae,bootstrapInvalid:ue,deprecated:se,httpErrorMessage:ce,httpUnavailable:le,identifyDisabled:fe,streamClosing:ve,streamConnecting:de,streamError:ge,unknownOption:pe,wrongOptionType:me,wrongOptionTypeBoolean:he,optionBelowMinimum:ye,debugPolling:be,debugStreamPing:ke,debugStreamPut:Ee,debugStreamPatch:we,debugStreamPatchIgnored:De,debugStreamDelete:Oe,debugStreamDeleteIgnored:Se,debugEnqueueingEvent:Ue,debugPostingEvents:Pe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function je(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var Re=function(e){var n=!1,t=!1,r=null,i=null,o=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return i||(n?Promise.resolve():t?Promise.reject(r):i=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(i){n||t||(t=!0,r=i,e.emit("failed",i),e.emit("ready")),e.maybeReportError(i)}}};function Te(e,n,t,r){var i={};function o(){var e="",i=r.getUser();return i&&(e=t||U(JSON.stringify(i))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(o()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=A(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return null}))}}))},i.saveFlags=function(n){var t=q({},n,{$schema:1});return e.set(o(),JSON.stringify(t))},i.clearFlags=function(){return e.clear(o())},i}function Ae(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=o+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=F(e,n),d=!1,g=null,p=null,m=null,h=null,y=null;function b(e){d||(a.warn(ge(e,f)),d=!0),D(!1),w(),k(f)}function k(e){p||(e?p=setTimeout(E,e):E())}function E(){var r;p=null;var u="",f={headers:v,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var d in null!=h&&(u="h="+h),c?e.eventSourceAllowsReport?(r=s,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(m)):(r=o+"/ping/"+t,u=""):r=s+"/"+P(JSON.stringify(m)),f.headers=x(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,w(),a.info(de(r)),i=(new Date).getTime(),g=e.eventSourceFactory(r,f),y)V(y,d)&&g.addEventListener(d,y[d]);g.onerror=b}}function w(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(e){i&&r&&r.recordStreamInit(i,!e,(new Date).getTime()-i),i=null}return u.connect=function(e,n,t){m=e,h=n,y={};var r=function(e){y[e]=function(n){d=!1,D(!0),t[e]&&t[e](n)}};for(var i in t||{})r(i);k()},u.disconnect=function(){clearTimeout(p),p=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function Ce(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,a=n.logger,u={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new v(le()))}));var i=r?"REPORT":"GET",o=F(e,n);r&&(o["Content-Type"]="application/json");var a=c[t];a||(a=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=a);var u=e.httpRequest(i,t,x(o,n),r),l=u.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=Q(e.header("content-type")||"");return Promise.reject(new v(n))}return Promise.reject(function(e){return 404===e.status?new s(ne()):new v(re(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new v(Z(e)))}));return a.addPromise(l,(function(){u.cancel&&u.cancel()})),a.resultPromise}return u.fetchJSON=function(e){return l(r+e,null)},u.fetchFlagSettings=function(e,n){var u,s,c,f="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=P(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),o&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(be(s)),l(s,c)},u}var Ne=require("uuid").v1;function Le(e){var n={};return n.validateUser=function(n){if(!n)return Promise.reject(new c(ie()));var t=I(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=Ne();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new c(oe()))},n}var Fe=["debug","info","warn","error","none"];function xe(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],o=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var s=0;s<Fe.length;s++)Fe[s]===e.level&&(u=s);function c(e,t,u){if(!(u.length<1)){var s,c=o?t+": "+a:a;if(1!==u.length&&n){var l=i(u);l[0]=c+l[0],s=n.apply(void 0,i(l))}else s=c+u[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=Fe[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},v=0;v<Fe.length;v++)f(v);return l}var qe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function Ve(e,n,r,i){var o=q({logger:{default:i}},qe,r),a={};function u(e){R((function(){n&&n.maybeReportError(new f(e))}))}var s=q({},e||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(se(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){Fe.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(e){var n=q({},e),r=function(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=t(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}};return Object.keys(e).forEach((function(t){var i=e[t];if(null!=i){var a=o[t];if(void 0===a)u(pe(t));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(i);c.indexOf(l)<0?"boolean"===s?(n[t]=!!i,u(he(t,l))):(u(me(t,s,l)),n[t]=a.default):"number"===l&&void 0!==a.minimum&&i<a.minimum&&(u(ye(t,i,a.minimum)),n[t]=a.minimum)}}}})),n}(s=function(e){var n=q({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))).logger),s}var _e,ze=Object.freeze({__proto__:null,baseOptionDefs:qe,validate:Ve}),Je=new Uint8Array(16);function Me(){if(!_e&&!(_e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _e(Je)}var Ke=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function $e(e){return"string"==typeof e&&Ke.test(e)}for(var He,Be,Ge=[],Xe=0;Xe<256;++Xe)Ge.push((Xe+256).toString(16).substr(1));function We(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=(Ge[e[n+0]]+Ge[e[n+1]]+Ge[e[n+2]]+Ge[e[n+3]]+"-"+Ge[e[n+4]]+Ge[e[n+5]]+"-"+Ge[e[n+6]]+Ge[e[n+7]]+"-"+Ge[e[n+8]]+Ge[e[n+9]]+"-"+Ge[e[n+10]]+Ge[e[n+11]]+Ge[e[n+12]]+Ge[e[n+13]]+Ge[e[n+14]]+Ge[e[n+15]]).toLowerCase();if(!$e(t))throw TypeError("Stringified UUID is invalid");return t}var Qe=0,Ye=0;function Ze(e){if(!$e(e))throw TypeError("Invalid UUID");var n,t=new Uint8Array(16);return t[0]=(n=parseInt(e.slice(0,8),16))>>>24,t[1]=n>>>16&255,t[2]=n>>>8&255,t[3]=255&n,t[4]=(n=parseInt(e.slice(9,13),16))>>>8,t[5]=255&n,t[6]=(n=parseInt(e.slice(14,18),16))>>>8,t[7]=255&n,t[8]=(n=parseInt(e.slice(19,23),16))>>>8,t[9]=255&n,t[10]=(n=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=n/4294967296&255,t[12]=n>>>24&255,t[13]=n>>>16&255,t[14]=n>>>8&255,t[15]=255&n,t}function en(e,n,t){function r(e,r,i,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var n=[],t=0;t<e.length;++t)n.push(e.charCodeAt(t));return n}(e)),"string"==typeof r&&(r=Ze(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=t(a))[6]=15&a[6]|n,a[8]=63&a[8]|128,i){o=o||0;for(var u=0;u<16;++u)i[o+u]=a[u];return i}return We(a)}try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function nn(e){return 14+(e+64>>>9<<4)+1}function tn(e,n){var t=(65535&e)+(65535&n);return(e>>16)+(n>>16)+(t>>16)<<16|65535&t}function rn(e,n,t,r,i,o){return tn((a=tn(tn(n,e),tn(r,o)))<<(u=i)|a>>>32-u,t);var a,u}function on(e,n,t,r,i,o,a){return rn(n&t|~n&r,e,n,i,o,a)}function an(e,n,t,r,i,o,a){return rn(n&r|t&~r,e,n,i,o,a)}function un(e,n,t,r,i,o,a){return rn(n^t^r,e,n,i,o,a)}function sn(e,n,t,r,i,o,a){return rn(t^(n|~r),e,n,i,o,a)}var cn=en("v3",48,(function(e){if("string"==typeof e){var n=unescape(encodeURIComponent(e));e=new Uint8Array(n.length);for(var t=0;t<n.length;++t)e[t]=n.charCodeAt(t)}return function(e){for(var n=[],t=32*e.length,r=0;r<t;r+=8){var i=e[r>>5]>>>r%32&255,o=parseInt("0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i),16);n.push(o)}return n}(function(e,n){e[n>>5]|=128<<n%32,e[nn(n)-1]=n;for(var t=1732584193,r=-271733879,i=-1732584194,o=271733878,a=0;a<e.length;a+=16){var u=t,s=r,c=i,l=o;t=on(t,r,i,o,e[a],7,-680876936),o=on(o,t,r,i,e[a+1],12,-389564586),i=on(i,o,t,r,e[a+2],17,606105819),r=on(r,i,o,t,e[a+3],22,-1044525330),t=on(t,r,i,o,e[a+4],7,-176418897),o=on(o,t,r,i,e[a+5],12,1200080426),i=on(i,o,t,r,e[a+6],17,-1473231341),r=on(r,i,o,t,e[a+7],22,-45705983),t=on(t,r,i,o,e[a+8],7,1770035416),o=on(o,t,r,i,e[a+9],12,-1958414417),i=on(i,o,t,r,e[a+10],17,-42063),r=on(r,i,o,t,e[a+11],22,-1990404162),t=on(t,r,i,o,e[a+12],7,1804603682),o=on(o,t,r,i,e[a+13],12,-40341101),i=on(i,o,t,r,e[a+14],17,-1502002290),r=on(r,i,o,t,e[a+15],22,1236535329),t=an(t,r,i,o,e[a+1],5,-165796510),o=an(o,t,r,i,e[a+6],9,-1069501632),i=an(i,o,t,r,e[a+11],14,643717713),r=an(r,i,o,t,e[a],20,-373897302),t=an(t,r,i,o,e[a+5],5,-701558691),o=an(o,t,r,i,e[a+10],9,38016083),i=an(i,o,t,r,e[a+15],14,-660478335),r=an(r,i,o,t,e[a+4],20,-405537848),t=an(t,r,i,o,e[a+9],5,568446438),o=an(o,t,r,i,e[a+14],9,-1019803690),i=an(i,o,t,r,e[a+3],14,-187363961),r=an(r,i,o,t,e[a+8],20,1163531501),t=an(t,r,i,o,e[a+13],5,-1444681467),o=an(o,t,r,i,e[a+2],9,-51403784),i=an(i,o,t,r,e[a+7],14,1735328473),r=an(r,i,o,t,e[a+12],20,-1926607734),t=un(t,r,i,o,e[a+5],4,-378558),o=un(o,t,r,i,e[a+8],11,-2022574463),i=un(i,o,t,r,e[a+11],16,1839030562),r=un(r,i,o,t,e[a+14],23,-35309556),t=un(t,r,i,o,e[a+1],4,-1530992060),o=un(o,t,r,i,e[a+4],11,1272893353),i=un(i,o,t,r,e[a+7],16,-155497632),r=un(r,i,o,t,e[a+10],23,-1094730640),t=un(t,r,i,o,e[a+13],4,681279174),o=un(o,t,r,i,e[a],11,-358537222),i=un(i,o,t,r,e[a+3],16,-722521979),r=un(r,i,o,t,e[a+6],23,76029189),t=un(t,r,i,o,e[a+9],4,-640364487),o=un(o,t,r,i,e[a+12],11,-421815835),i=un(i,o,t,r,e[a+15],16,530742520),r=un(r,i,o,t,e[a+2],23,-995338651),t=sn(t,r,i,o,e[a],6,-198630844),o=sn(o,t,r,i,e[a+7],10,1126891415),i=sn(i,o,t,r,e[a+14],15,-1416354905),r=sn(r,i,o,t,e[a+5],21,-57434055),t=sn(t,r,i,o,e[a+12],6,1700485571),o=sn(o,t,r,i,e[a+3],10,-1894986606),i=sn(i,o,t,r,e[a+10],15,-1051523),r=sn(r,i,o,t,e[a+1],21,-2054922799),t=sn(t,r,i,o,e[a+8],6,1873313359),o=sn(o,t,r,i,e[a+15],10,-30611744),i=sn(i,o,t,r,e[a+6],15,-1560198380),r=sn(r,i,o,t,e[a+13],21,1309151649),t=sn(t,r,i,o,e[a+4],6,-145523070),o=sn(o,t,r,i,e[a+11],10,-1120210379),i=sn(i,o,t,r,e[a+2],15,718787259),r=sn(r,i,o,t,e[a+9],21,-343485551),t=tn(t,u),r=tn(r,s),i=tn(i,c),o=tn(o,l)}return[t,r,i,o]}(function(e){if(0===e.length)return[];for(var n=8*e.length,t=new Uint32Array(nn(n)),r=0;r<n;r+=8)t[r>>5]|=(255&e[r/8])<<r%32;return t}(e),8*e.length))}));function ln(e,n,t,r){switch(e){case 0:return n&t^~n&r;case 1:return n^t^r;case 2:return n&t^n&r^t&r;case 3:return n^t^r}}function fn(e,n){return e<<n|e>>>32-n}var vn=en("v5",80,(function(e){var n=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,a=Math.ceil(o/16),u=new Array(a),s=0;s<a;++s){for(var c=new Uint32Array(16),l=0;l<16;++l)c[l]=e[64*s+4*l]<<24|e[64*s+4*l+1]<<16|e[64*s+4*l+2]<<8|e[64*s+4*l+3];u[s]=c}u[a-1][14]=8*(e.length-1)/Math.pow(2,32),u[a-1][14]=Math.floor(u[a-1][14]),u[a-1][15]=8*(e.length-1)&4294967295;for(var f=0;f<a;++f){for(var v=new Uint32Array(80),d=0;d<16;++d)v[d]=u[f][d];for(var g=16;g<80;++g)v[g]=fn(v[g-3]^v[g-8]^v[g-14]^v[g-16],1);for(var p=t[0],m=t[1],h=t[2],y=t[3],b=t[4],k=0;k<80;++k){var E=Math.floor(k/20),w=fn(p,5)+ln(E,m,h,y)+b+n[E]+v[k]>>>0;b=y,y=h,h=fn(m,30)>>>0,m=p,p=w}t[0]=t[0]+p>>>0,t[1]=t[1]+m>>>0,t[2]=t[2]+h>>>0,t[3]=t[3]+y>>>0,t[4]=t[4]+b>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,255&t[0],t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,255&t[1],t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,255&t[2],t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,255&t[3],t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,255&t[4]]}));var dn=Object.freeze({__proto__:null,v1:function(e,n,t){var r=n&&t||0,i=n||new Array(16),o=(e=e||{}).node||He,a=void 0!==e.clockseq?e.clockseq:Be;if(null==o||null==a){var u=e.random||(e.rng||Me)();null==o&&(o=He=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Be=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:Date.now(),c=void 0!==e.nsecs?e.nsecs:Ye+1,l=s-Qe+(c-Ye)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>Qe)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Qe=s,Ye=c,Be=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||We(i)},v3:cn,v4:function(e,n,t){var r=(e=e||{}).random||(e.rng||Me)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,n){t=t||0;for(var i=0;i<16;++i)n[t+i]=r[i];return n}return We(r)},v5:vn,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!$e(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:$e,stringify:We,parse:Ze}).v1,gn=ze.baseOptionDefs;var pn=function(e){var n={diagnosticId:dn()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},mn=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},hn=function(e,t,r,i,o,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+o+":$diagnostics",v=a.eventsUrl+"/events/diagnostic/"+o,d=a.diagnosticRecordingInterval,g=r,p=!!a.streaming,m={};function h(){return{sdk:k(),configuration:(n={customBaseURI:a.baseUrl!==gn.baseUrl.default,customStreamURI:a.streamUrl!==gn.streamUrl.default,customEventsURI:a.eventsUrl!==gn.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function y(e){a.logger&&a.logger.debug(Ie.debugPostingDiagnosticEvent(e)),i.sendEvents(e,v,!0).then((function(){})).catch((function(){}))}function b(){var e,r;y((e=(new Date).getTime(),r=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(r=n(n({},r),h())),g.reset(e),r)),c=setTimeout(b,d),s=(new Date).getTime(),l&&function(){if(t.isEnabled()){var e=n({},g.getProps());t.set(f,JSON.stringify(e))}}()}function k(){var t=n({},e.diagnosticSdkData);return a.wrapperName&&(t.wrapperName=a.wrapperName),a.wrapperVersion&&(t.wrapperVersion=a.wrapperVersion),t}return m.start=function(){l?function(e){if(!t.isEnabled())return e(!1);t.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();t>=n?b():c=setTimeout(b,n-t)}else 0===Math.floor(4*Math.random())?b():c=setTimeout(b,d)})):(y(n({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},h())),c=setTimeout(b,d))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m};function yn(e,r,i,o,a){var c,f,g,p=function(){if(i&&i.logger)return i.logger;return a&&a.logger&&a.logger.default||xe("warn")}(),m=je(p),h=Re(m),y=Ve(i,m,a,p),b=y.sendEvents,k=e,E=y.hash,w=function(e,n){var t={},r=!1,i=function(e){r||(r=!0,n.warn(Y(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){i(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){i(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){i(e),t(!1)})):t(!1)}))},t}(o.localStorage,p),D=M(o,k,y),O=y.sendEvents&&!y.diagnosticOptOut,S=O?pn(k):null,U=O?mn((new Date).getTime()):null,P=O?hn(o,w,U,D,k,y,S):null,A=Ae(o,y,k,U),N=y.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=a||M(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,f=K(),v=$(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function O(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function S(e){var n=q({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}function U(e){b.length<m?(b.push(e),w=!1):(w||(w=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),i&&i.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=O(e)):n=D(),n&&U(S(e)),t){var r=q({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,U(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],y.debug(Pe(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),d(e.status)||(E=!0),e.status>=400&&R((function(){o.maybeReportError(new u(ce(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,h)}),h)},s.stop=function(){clearTimeout(r)},s}(o,y,k,U,m,D),L=Ce(o,y,k),F={},x={},z=y.streaming,J=!1,H=!1,B=!0,G=y.stateProvider,X=function(e,n){var t,r={};return r.setUser=function(e){var r=t&&I(t);(t=_(e))&&n&&n(I(t),r)},r.getUser=function(){return t?I(t):null},e&&r.setUser(e),r}(null,(function(e,n){(function(e){if(G)return;e&&Z({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!y.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&se(e,n)})),W=Le(w),Q=w.isEnabled()?new Te(w,k,E,X,p):null;function Z(e){if(k&&!(G&&G.enqueueEvent&&G.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(B&&(p.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),B=!1));B=!1}!b||H||o.isDoNotTrack()||(p.debug(Ue(e.kind)),N.enqueue(e))}}function ne(e,n,t,r){var i=X.getUser(),o=new Date,a=n?n.value:null;if(!y.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=F[u];if(s&&o-s<3e5)return;F[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(c.contextKind=ue(i));var l=x[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),Z(c)}function ie(e,n,t,r){var i;if(x&&V(x,e)&&x[e]&&!x[e].deleted){var o=x[e];i=oe(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&ne(e,i,n,r),i}function oe(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ue(e){return e.anonymous?"anonymousUser":"user"}function se(e,n){G||e&&n&&Z({kind:"alias",key:e.key,contextKind:ue(e),previousKey:n.key,previousContextKind:ue(n),creationDate:(new Date).getTime()})}function le(){f=!0,X.getUser()&&A.connect(X.getUser(),E,{ping:function(){p.debug("received ping message from stream");var e=X.getUser();L.fetchFlagSettings(e,E).then((function(n){j(e,X.getUser())&&ve(n||{})})).catch((function(e){m.maybeReportError(new v(re(e)))}))},put:function(e){var n=JSON.parse(e.data);p.debug("received streaming update for all flags"),ve(n)},patch:function(e){var n=JSON.parse(e.data),t=x[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(we(n.key));var r={},i=q({},n);delete i.key,x[n.key]=i;var o=oe(i);r[n.key]=t?{previous:t.value,current:o}:{current:o},de(r)}else p.debug(De(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!x[n.key]||x[n.key].version<n.version){p.debug(Oe(n.key));var t={};x[n.key]&&!x[n.key].deleted&&(t[n.key]={previous:x[n.key].value}),x[n.key]={version:n.version,deleted:!0},de(t)}else p.debug(Se(n.key))}})}function fe(){f&&(A.disconnect(),f=!1)}function ve(e){var t={};if(!e)return Promise.resolve();for(var r in x)V(x,r)&&x[r]&&(e[r]&&!j(e[r].value,x[r].value)?t[r]={previous:x[r].value,current:oe(e[r])}:e[r]&&!e[r].deleted||(t[r]={previous:x[r].value}));for(var i in e)V(e,i)&&e[i]&&(!x[i]||x[i].deleted)&&(t[i]={current:oe(e[i])});return x=n({},e),de(t).catch((function(){}))}function de(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,i=r?r.value:void 0,o=e[n].previous;m.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),m.emit("change",t),m.emit("internal-change",x),y.sendEventsOnlyForVariation||G||n.forEach((function(n){ne(n,e[n].current)}))}return c&&Q?Q.saveFlags(x):Promise.resolve()}function ge(){var e=z||g&&void 0===z;e&&!f?le():!e&&f&&fe(),P&&P.setStreaming(e)}function pe(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof y.bootstrap&&"LOCALSTORAGE"===y.bootstrap.toUpperCase()&&(Q?c=!0:p.warn(Y())),"object"===t(y.bootstrap)&&(x=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(ae()),!1===e.$valid&&p.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=q(i,t[n]):i.version=0,r[n]=i}})),r}(y.bootstrap)),G){var me=G.getInitialState();me?he(me):G.on("init",he),G.on("update",(function(e){e.user&&X.setUser(e.user);e.flags&&ve(e.flags)}))}else(function(){if(!e)return Promise.reject(new s(te()));return W.validateUser(r).then((function(e){return X.setUser(e),"object"===t(y.bootstrap)?ye():c?Q.loadFlags().then((function(e){return null==e?(x={},L.fetchFlagSettings(X.getUser(),E).then((function(e){return ve(e||{})})).then(ye).catch((function(e){be(new v(re(e)))}))):(x=e,R(ye),L.fetchFlagSettings(X.getUser(),E).then((function(e){return ve(e)})).catch((function(e){return m.maybeReportError(e)})))})):L.fetchFlagSettings(X.getUser(),E).then((function(e){x=e||{},ye()})).catch((function(e){x={},be(e)}))}))})().catch(be);function he(e){k=e.environment,X.setUser(e.user),x=n({},e.flags),R(ye)}function ye(){p.info("LaunchDarkly client initialized"),J=!0,ge(),h.signalSuccess()}function be(e){h.signalFailure(e)}return{client:{waitForInitialization:function(){return h.getInitializationPromise()},waitUntilReady:function(){return h.getReadyPromise()},identify:function(e,n,t){return H?T(Promise.resolve({}),t):G?(p.warn("identify() has no effect here; it must be called on the main client instance"),T(Promise.resolve(C(x)),t)):T((c&&Q?Q.clearFlags():Promise.resolve()).then((function(){return W.validateUser(e)})).then((function(e){return L.fetchFlagSettings(e,n).then((function(t){var r=C(t);return X.setUser(e),E=n,t?ve(t).then((function(){return r})):r}))})).then((function(e){return f&&le(),e})).catch((function(e){return m.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return X.getUser()},variation:function(e,n){return ie(e,n,!0,!1).value},variationDetail:function(e,n){return ie(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&p.warn(ee(e));var r=X.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=ue(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),Z(i)}else m.maybeReportError(new l(ee(e)))},alias:se,on:function(e,n,t){pe(e)?(g=!0,J&&ge(),m.on(e,n,t)):m.on.apply(m,arguments)},off:function(e){if(m.off.apply(m,arguments),pe(e)){var n=!1;m.getEvents().forEach((function(e){pe(e)&&m.getEventListenerCount(e)>0&&(n=!0)})),n||(g=!1,f&&void 0===z&&fe())}},setStreaming:function(e){var n=null===e?void 0:e;n!==z&&(z=n,ge())},flush:function(e){return T(b?N.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!x)return e;for(var n in x)V(x,n)&&(e[n]=ie(n,null,!y.sendEventsOnlyForVariation).value);return e},close:function(e){if(H)return T(Promise.resolve(),e);var n=function(){H=!0,x={}};return T(Promise.resolve().then((function(){if(fe(),P&&P.stop(),b)return N.stop(),N.flush()})).then(n).catch(n),e)}},options:y,emitter:m,ident:X,logger:p,requestor:L,start:function(){b&&(P&&P.start(),N.start())},enqueueEvent:Z,getFlagsInternal:function(){return x},getEnvironmentId:function(){return k},internalChangeEventName:"internal-change"}}var bn="4.0.0";export{xe as commonBasicLogger,g as errors,yn as initialize,Ie as messages,z as utils,bn as version};
//# sourceMappingURL=ldclient-common.es.js.map

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["LDClient-Common"]={})}(this,function(e){"use strict";function W(e){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function Q(i){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(o,!0).forEach(function(e){var n,t,r;n=i,r=o[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(o)):n(o).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})}return i}function f(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var P=t("LaunchDarklyUnexpectedResponseError"),Y=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),Z=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),ee=t("LaunchDarklyFlagFetchError");function S(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var r=Object.freeze({__proto__:null,LDUnexpectedResponseError:P,LDInvalidEnvironmentIdError:Y,LDInvalidUserError:i,LDInvalidEventKeyError:Z,LDInvalidArgumentError:d,LDFlagFetchError:ee,isHttpErrorRecoverable:S}),o=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(v(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],a=[],s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=s.length;c<l;++c)u[c]=s[c],a[s.charCodeAt(c)]=c;function v(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(u[(i=r)>>18&63]+u[i>>12&63]+u[i>>6&63]+u[63&i]);return o.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var g=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,y=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=g(n),u=g(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=p(n);if((i=v.length)!==p(t).length)return!1;for(r=i;0!=r--;)if(!m.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t},h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function b(e){var n=unescape(encodeURIComponent(e));return o(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function O(e){return b(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function ne(e){return JSON.parse(JSON.stringify(e))}function te(e,n){return y(e,n)}function re(e){setTimeout(e,0)}function ie(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function k(e){var n={};for(var t in e)ue(e,t)&&(n[t]={value:e[t],version:0});return n}function oe(e){var n={};for(var t in e)ue(e,t)&&(n[t]=e[t].value);return n}function E(e,n){for(var t,r=n.slice(0),i=[],o=e;0<r.length;){for(t=[];0<o;){var a=r.shift();if(!a)break;(o-=O(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function w(e){var n=e.version||"3.5.0";return e.userAgent+"/"+n}function U(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":w(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function I(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(Q({},e)):e}function ae(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return Q({},e,{},n)},{})}function ue(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function se(e){if(!e)return e;var n;for(var t in h){var r=h[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||Q({},e))[r]=String(i))}return n||e}var D=Object.freeze({__proto__:null,btoa:b,base64URLEncode:O,clone:ne,deepEquals:te,onNextTick:re,wrapPromiseCallback:ie,transformValuesToVersionedValues:k,transformVersionedValuesToValues:oe,chunkUserEventsForUrl:E,getLDUserAgentString:w,getLDHeaders:U,transformHeaders:I,extend:ae,objectHasOwnProperty:ue,sanitizeUser:se});for(var j,T=(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(j={exports:{}},j.exports),j.exports),R=[],N=0;N<256;++N)R[N]=(N+256).toString(16).substr(1);var L,C,F=function(e,n){var t=n||0,r=R;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},A=0,x=0;var q=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||L,a=void 0!==e.clockseq?e.clockseq:C;if(null==o||null==a){var u=T();null==o&&(o=L=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=C=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:x+1,l=s-A+(c-x)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||A<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");A=s,C=a;var f=(1e4*(268435455&(s+=122192928e5))+(x=c))%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||F(i)},_=2e3;function ce(u,e,s){var t="/a/"+e+".gif",c=ae({"Content-Type":"application/json"},U(u,s)),l=u.httpFallbackPing,f={};return f.sendChunk=function(e,r,i,n){var o=JSON.stringify(e),a=i?null:q();return n?function n(t){var e=i?c:ae({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,I(e,s),o).promise.then(function(e){if(e)return 400<=e.status&&S(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+O(o)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,i=u.httpAllowsPost();r=i?[e]:E(_-n.length,e);for(var o=[],a=0;a<r.length;a++)o.push(f.sendChunk(r[a],n,t,i));return Promise.all(o)},f}function V(e){var n={},s=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,i){return Object.keys(r).reduce(function(e,n){var t=e;return i(n)&&(!function(e){return!l[e]&&(s||-1!==o.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var o=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],i=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],i=ae({},i,a[1])}var u=Object.keys(i);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function J(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function z(){return"LaunchDarkly client initialized"}function M(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"}function le(e){return'Custom event "'+e+'" does not exist'}function fe(){return"No environment/client-side ID was specified."+G}function ve(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+G}function K(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function B(){return"identify() has no effect here; it must be called on the main client instance"}function H(){return"received ping message from stream"}function $(){return"received streaming update for all flags"}function de(e){return'received streaming update for flag "'+e+'"'}function ge(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function pe(e){return'received streaming deletion for flag "'+e+'"'}function me(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function ye(e){return'enqueueing "'+e+'" event'}var G=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",X=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},he=function(e){return'Expected application/json content type but got "'+e+'"'},be=function(e){return"local storage is unavailable: "+J(e)},ke=function(e){return"network error"+(e?" ("+e+")":"")},Ee=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+G},we=function(e){return"Error fetching flag settings: "+J(e)},De=function(){return"No user specified."+G},Oe=function(){return"Invalid user specified."+G},Pe=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},Se=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(S(e)?t:"giving up permanently")},Ue=function(){return"Cannot make HTTP requests in this environment."+G},Ie=function(){return"Closing stream connection"},je=function(e){return"Opening stream connection to "+e},Te=function(e,n){return"Error on stream connection: "+J(e)+", will continue retrying every "+n+" milliseconds."},Re=function(e){return'Ignoring unknown config option "'+e+'"'},Ne=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Le=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ce=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Fe=function(e){return"polling for feature flags at "+e},Ae=function(e){return"sending "+e+" events"},xe=Object.freeze({__proto__:null,clientInitialized:z,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:X,eventWithoutUser:M,invalidContentType:he,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:be,networkError:ke,unknownCustomEventKey:le,environmentNotFound:Ee,environmentNotSpecified:fe,errorFetchingFlags:we,userNotSpecified:De,invalidUser:Oe,bootstrapOldFormat:ve,bootstrapInvalid:K,deprecated:Pe,httpErrorMessage:Se,httpUnavailable:Ue,identifyDisabled:B,streamClosing:Ie,streamConnecting:je,streamError:Te,unknownOption:Re,wrongOptionType:Ne,wrongOptionTypeBoolean:Le,optionBelowMinimum:Ce,debugPolling:Fe,debugStreamPing:H,debugStreamPut:$,debugStreamPatch:de,debugStreamPatchIgnored:ge,debugStreamDelete:pe,debugStreamDeleteIgnored:me,debugEnqueueingEvent:ye,debugPostingEvents:Ae,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function qe(e,n,t,r,i,o){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==i?i:null,c={},l=(5<arguments.length&&void 0!==o?o:null)||ce(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var o={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}(),d=V(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function O(e){b.length<m?(b.push(e),w=!1):(w||(w=!0,h.warn(X())),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=D(),n&&O(function(e){var n=ae({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=ae({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,O(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Ae(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(k=e.serverTime),S(e.status)||(E=!0),400<=e.status&&re(function(){s.maybeReportError(new P(Se(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,y)},y)},c.stop=function(){clearTimeout(a)},c}function _e(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!i[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var Ve="ready",Je="initialized",ze="failed";var Me=function(r){var n=!1,t=!1,i=null,e=null,o=new Promise(function(n){r.on(Ve,function e(){r.off(Ve,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(i):e=new Promise(function(n,t){r.on(Je,function e(){r.off(Je,e),n()}),r.on(ze,function e(n){r.off(ze,e),t(n)})}))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,r.emit(Je),r.emit(Ve))},signalFailure:function(e){n||t||(t=!0,i=e,r.emit(ze,e),r.emit(Ve)),r.maybeReportError(e)}}};function Ke(t,r,i,o){var a={};function u(){var e="",n=o.getUser();return n&&(e=i||b(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=k(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=ae({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function Be(r,n){function i(e){t||(t=!0,n.warn(be(e)))}var e={},t=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(n){r?r.get(e).then(n).catch(function(e){i(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){r?r.set(e,t).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){r?r.clear(e).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e}var He=3e5;function $e(i,o,a,n){var u,s=o.streamUrl,c=o.logger,e={},l=s+"/eval/"+a,f=o.useReport,v=o.evaluationReasons,t=o.streamReconnectDelay,d=U(i,o),g=!1,p=null,m=null,y=null,h=null,b=null;function k(e){g||(c.warn(Te(e,t)),g=!0),D(!1),w(),E(t)}function E(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:d,readTimeoutMillis:He};if(i.eventSourceFactory){for(var r in null!=h&&(n="h="+h),f?i.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(y)):(e=s+"/ping/"+a,n=""):e=l+"/"+O(JSON.stringify(y)),t.headers=I(t.headers,o),v&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,w(),c.info(je(e)),u=(new Date).getTime(),p=i.eventSourceFactory(e,t),b)ue(b,r)&&p.addEventListener(r,b[r]);p.onerror=k}}function w(){p&&(c.info(Ie()),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){y=e,h=n,b={};function r(n){b[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}for(var i in t||{})r(i);E()},e.disconnect=function(){clearTimeout(m),m=null,w()},e.isConnected=function(){return!!(p&&i.eventSourceIsActive&&i.eventSourceIsActive(p))},e}var Ge="application/json";function Xe(u,s,a){var c=s.baseUrl,l=s.useReport,f=s.evaluationReasons,v=s.logger,e={},d={};function g(e,n){if(!u.httpRequest)return new Promise(function(e,n){n(new ee(Ue()))});var t=n?"REPORT":"GET",r=U(u,s);n&&(r["Content-Type"]=Ge);var i=d[e];i||(i=function(t){var r,i,o,a,e={addPromise:function(n,e){r=n,i&&i(),i=e,n.then(function(e){r===n&&(o(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){o=e,a=n}),e}(function(){delete d[e]}),d[e]=i);var o=u.httpRequest(t,e,I(r,s),n),a=o.promise.then(function(e){if(200!==e.status)return Promise.reject(function(e){return 404===e.status?new Y(Ee()):new ee(we(e.statusText||String(e.status)))}(e));if(e.header("content-type")&&e.header("content-type").substring(0,Ge.length)===Ge)return JSON.parse(e.body);var n=he(e.header("content-type")||"");return Promise.reject(new ee(n))},function(e){return Promise.reject(new ee(ke(e)))});return i.addPromise(a,function(){o.cancel&&o.cancel()}),i.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,i,o="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),i=JSON.stringify(e)):(t=O(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(o="h="+n),f&&(o=o+(o?"&":"")+"withReasons=true"),r=r+(o?"?":"")+o,v.debug(Fe(r)),g(r,i)},e}var We="ld:$anonUserId";function Qe(r){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(De()));var t=ne(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?r.get(We).then(function(e){if(e)return t.key=e,t;var n=q();return function(e){return r.set(We,e)}(t.key=n).then(function(){return t})}):Promise.reject(new i(Oe()))},e}var Ye=["debug","info","warn","error","none"];function Ze(e,a){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],s=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Ye.length;t++)Ye[t]===e.level&&(r=t);for(var i={},o=function(e){var n=Ye[e];if("none"!==n)if(e<r)i[n]=function(){};else{var t=e;i[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,i=s?n+": "+c:c;if(1!==t.length&&a){var o=f(t);o[0]=i+o[0],r=a.apply(void 0,f(o))}else r=i+t[0];try{u[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<Ye.length;l++)o(l);return i}function en(e,n){return Ze({level:e,prefix:n})}var nn={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function tn(e,n,t,r){var a=ae({logger:{default:r}},nn,t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){re(function(){n&&n.maybeReportError(new d(e))})}var o,s,c,l,f=ae({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=W(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return o=f,Object.keys(i).forEach(function(e){if(void 0!==o[e]){var n=i[e];r&&r.warn(Pe(e,n)),n&&(void 0===o[n]&&(o[n]=o[e]),delete o[e])}}),s=ae({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=ae({},c=f=s),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)u(Re(e));else{var r=t.type||v(t.default);if("any"!==r){var i=r.split("|"),o=v(n);i.indexOf(o)<0?"boolean"===r?(l[e]=!!n,u(Le(e,o))):(u(Ne(e,r,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&n<t.minimum&&(u(Ce(e,n,t.minimum)),l[e]=t.minimum)}}}}),function(n){Ye.forEach(function(e){if("none"!==e&&(!n[e]||"function"!=typeof n[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}((f=l).logger),f}var rn=Object.freeze({__proto__:null,baseOptionDefs:nn,validate:tn}).baseOptionDefs;var on=function(e){var n={diagnosticId:q()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},an=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},un=function(n,r,e,t,i,o,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=o.eventsUrl+"/events/diagnostic/"+i,v=o.diagnosticRecordingInterval,d=e,g=!!o.streaming,p={};function m(){return{sdk:function(){var e=Q({},n.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==rn.baseUrl.default,customStreamURI:o.streamUrl!==rn.streamUrl.default,customEventsURI:o.eventsUrl!==rn.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation,autoAliasingOptOut:!!o.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function y(e){o.logger&&o.logger.debug(xe.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){y(function(){var e=(new Date).getTime(),n=Q({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},d.getProps());return c&&(n=Q({},n,{},m())),d.reset(e),n}()),s=setTimeout(h,v),u=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=Q({},d.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);d.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();n<=t?h():s=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():s=setTimeout(h,v)}):(y(Q({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(h,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p},sn="change",cn="internal-change";e.commonBasicLogger=Ze,e.createConsoleLogger=en,e.errors=r,e.initialize=function(e,n,t,o,r){var a,i,u,s=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||en("warn")}(),c=_e(s),l=Me(c),f=tn(t,c,r,s),v=f.sendEvents,d=e,g=f.hash,p=Be(o.localStorage,s),m=ce(o,d,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?on(d):null,b=y?an((new Date).getTime()):null,k=y?un(o,p,b,m,d,f,h):null,E=$e(o,f,d,b),w=f.eventProcessor||qe(o,f,d,b,c,m),D=Xe(o,f,d),O={},P={},S=f.streaming,U=!1,I=!1,j=!0,T=f.stateProvider,R=function(e,t){var r,n={};return n.setUser=function(e){var n=r&&ne(r);(r=se(e))&&t&&t(ne(r),n)},n.getUser=function(){return r?ne(r):null},e&&n.setUser(e),n}(null,function(e,n){(function(e){if(T)return;e&&C({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&_(e,n)}),N=Qe(p),L=p.isEnabled()?new Ke(p,d,g,R,s):null;function C(e){if(d&&!(T&&T.enqueueEvent&&T.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(j&&(s.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),j=!1));j=!1}!v||I||o.isDoNotTrack()||(s.debug(ye(e.kind)),w.enqueue(e))}}function F(e,n,t,r){var i=R.getUser(),o=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=O[u];if(s&&o-s<3e5)return;O[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(c.contextKind=q(i));var l=P[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),C(c)}function A(e,n,t,r){var i;if(P&&ue(P,e)&&P[e]&&!P[e].deleted){var o=P[e];i=x(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&F(e,i,n,r),i}function x(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function q(e){return e.anonymous?"anonymousUser":"user"}function _(e,n){T||e&&n&&C({kind:"alias",key:e.key,contextKind:q(e),previousKey:n.key,previousContextKind:q(n),creationDate:(new Date).getTime()})}function V(){i=!0,R.getUser()&&E.connect(R.getUser(),g,{ping:function(){s.debug("received ping message from stream");var n=R.getUser();D.fetchFlagSettings(n,g).then(function(e){te(n,R.getUser())&&z(e||{})}).catch(function(e){c.maybeReportError(new ee(we(e)))})},put:function(e){var n=JSON.parse(e.data);s.debug("received streaming update for all flags"),z(n)},patch:function(e){var n=JSON.parse(e.data),t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){s.debug(de(n.key));var r={},i=ae({},n);delete i.key;var o=x(P[n.key]=i);r[n.key]=t?{previous:t.value,current:o}:{current:o},M(r)}else s.debug(ge(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!P[n.key]||P[n.key].version<n.version){s.debug(pe(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},M(t)}else s.debug(me(n.key))}})}function J(){i&&(E.disconnect(),i=!1)}function z(e){var n={};if(!e)return Promise.resolve();for(var t in P)ue(P,t)&&P[t]&&(e[t]&&!te(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:x(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var r in e)ue(e,r)&&e[r]&&(!P[r]||P[r].deleted)&&(n[r]={current:x(e[r])});return P=Q({},e),M(n).catch(function(){})}function M(i){var e=Object.keys(i);if(0<e.length){var o={};e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;c.emit(sn+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),c.emit(sn,o),c.emit(cn,P),f.sendEventsOnlyForVariation||T||e.forEach(function(e){F(e,i[e].current)})}return a&&L?L.saveFlags(P):Promise.resolve()}function K(){var e=S||u&&void 0===S;e&&!i?V():!e&&i&&J(),k&&k.setStreaming(e)}function B(e){return e===sn||e.substr(0,sn.length+1)===sn+":"}if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(L?a=!0:s.warn(be())),"object"===W(f.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",i=t[r];!i&&e.length&&s.warn(ve()),!1===t.$valid&&s.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};i&&i[e]?n=ae(n,i[e]):n.version=0,o[e]=n}}),o}(f.bootstrap)),T){var H=T.getInitialState();H?$(H):T.on("init",$),T.on("update",function(e){e.user&&R.setUser(e.user);e.flags&&z(e.flags)})}else(e?N.validateUser(n).then(function(e){return R.setUser(e),"object"===W(f.bootstrap)?G():a?L.loadFlags().then(function(e){return null==e?(P={},D.fetchFlagSettings(R.getUser(),g).then(function(e){return z(e||{})}).then(G).catch(function(e){X(new ee(we(e)))})):(P=e,re(G),D.fetchFlagSettings(R.getUser(),g).then(function(e){return z(e)}).catch(function(e){return c.maybeReportError(e)}))}):D.fetchFlagSettings(R.getUser(),g).then(function(e){P=e||{},G()}).catch(function(e){P={},X(e)})}):Promise.reject(new Y(fe()))).catch(X);function $(e){d=e.environment,R.setUser(e.user),P=Q({},e.flags),re(G)}function G(){s.info("LaunchDarkly client initialized"),U=!0,K(),l.signalSuccess()}function X(e){l.signalFailure(e)}return{client:{waitForInitialization:function(){return l.getInitializationPromise()},waitUntilReady:function(){return l.getReadyPromise()},identify:function(e,r,n){return I?ie(Promise.resolve({}),n):T?(s.warn("identify() has no effect here; it must be called on the main client instance"),ie(Promise.resolve(oe(P)),n)):ie((a&&L?L.clearFlags():Promise.resolve()).then(function(){return N.validateUser(e)}).then(function(t){return D.fetchFlagSettings(t,r).then(function(e){var n=oe(e);return R.setUser(t),g=r,e?z(e).then(function(){return n}):n})}).then(function(e){return i&&V(),e}).catch(function(e){return c.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return R.getUser()},variation:function(e,n){return A(e,n,!0,!1).value},variationDetail:function(e,n){return A(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&s.warn(le(e));var r=R.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=q(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),C(i)}else c.maybeReportError(new Z(le(e)))},alias:_,on:function(e,n,t){B(e)?(u=!0,U&&K(),c.on(e,n,t)):c.on.apply(c,arguments)},off:function(e){if(c.off.apply(c,arguments),B(e)){var n=!1;c.getEvents().forEach(function(e){B(e)&&0<c.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===S&&J())}},setStreaming:function(e){var n=null===e?void 0:e;n!==S&&(S=n,K())},flush:function(e){return ie(v?w.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)ue(P,n)&&(e[n]=A(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return ie(Promise.resolve(),e);function n(){I=!0,P={}}return ie(Promise.resolve().then(function(){if(J(),k&&k.stop(),v)return w.stop(),w.flush()}).then(n).catch(n),e)}},options:f,emitter:c,ident:R,logger:s,requestor:D,start:function(){v&&(k&&k.start(),w.start())},enqueueEvent:C,getFlagsInternal:function(){return P},getEnvironmentId:function(){return d},internalChangeEventName:cn}},e.messages=xe,e.utils=D,e.version="3.5.0",Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["LDClient-Common"]={})}(this,function(e){"use strict";function n(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function Q(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(Object(o),!0).forEach(function(e){var n,t;n=r,e=o[t=e],t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function Y(e){return(Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var I=t("LaunchDarklyUnexpectedResponseError"),Z=t("LaunchDarklyInvalidEnvironmentIdError"),o=t("LaunchDarklyInvalidUserError"),ee=t("LaunchDarklyInvalidEventKeyError"),v=t("LaunchDarklyInvalidArgumentError"),ne=t("LaunchDarklyFlagFetchError");function j(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var i=Object.freeze({__proto__:null,LDUnexpectedResponseError:I,LDInvalidEnvironmentIdError:Z,LDInvalidUserError:o,LDInvalidEventKeyError:ee,LDInvalidArgumentError:v,LDFlagFetchError:ne,isHttpErrorRecoverable:j}),a=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(function(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(function(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}(r));return o.join("")}(e,i,a<i+16383?a:i+16383));1==r?(n=e[t-1],o.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return o.join("")},u=[],s=[],c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,d=c.length;l<d;++l)u[l]=c[l],s[c.charCodeAt(l)]=l;s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63;function g(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){var t,r,o=p(e),i=p(n);if(o&&i){if((a=e.length)!=n.length)return!1;for(t=a;0!=t--;)if(!g(e[t],n[t]))return!1;return!0}if(o!=i)return!1;o=e instanceof Date,i=n instanceof Date;if(o!=i)return!1;if(o&&i)return e.getTime()==n.getTime();o=e instanceof RegExp,i=n instanceof RegExp;if(o!=i)return!1;if(o&&i)return e.toString()==n.toString();var a,u=m(e);if((a=u.length)!==m(n).length)return!1;for(t=a;0!=t--;)if(!h.call(n,u[t]))return!1;for(t=a;0!=t--;)if(!g(e[r=u[t]],n[r]))return!1;return!0}return e!=e&&n!=n}var p=Array.isArray,m=Object.keys,h=Object.prototype.hasOwnProperty,y=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function b(e){e=unescape(encodeURIComponent(e));return a(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(e))}function O(e){return b(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function te(e){return JSON.parse(JSON.stringify(e))}function re(e,n){return g(e,n)}function oe(e){setTimeout(e,0)}function ie(e,n){e=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){return n?void setTimeout(function(){n(e,null)},0):Promise.reject(e)});return n?void 0:e}function E(e){var n,t={};for(n in e)se(e,n)&&(t[n]={value:e[n],version:0});return t}function ae(e){var n,t={};for(n in e)se(e,n)&&(t[n]=e[n].value);return t}function k(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=O(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function w(e){var n=e.version||"4.0.0";return e.userAgent+"/"+n}function S(e,n){if(n&&!n.sendLDHeaders)return{};e={"X-LaunchDarkly-User-Agent":w(e)};return n&&n.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),e}function U(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(Q({},e)):e}function ue(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return Q(Q({},e),n)},{})}function se(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ce(e){if(!e)return e;var n,t;for(t in y){var r=y[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||Q({},e))[r]=String(o))}return n||e}var D=Object.freeze({__proto__:null,btoa:b,base64URLEncode:O,clone:te,deepEquals:re,onNextTick:oe,wrapPromiseCallback:ie,transformValuesToVersionedValues:E,transformVersionedValuesToValues:ae,chunkUserEventsForUrl:k,getLDUserAgentString:w,getLDHeaders:S,transformHeaders:U,extend:ue,objectHasOwnProperty:se,sanitizeUser:ce}),P=require("uuid").v1,R=2e3;function le(u,e,s){var c="/a/"+e+".gif",l=ue({"Content-Type":"application/json"},S(u,s)),f=u.httpFallbackPing,d={};return d.sendChunk=function(e,n,r,t){var o=JSON.stringify(e),i=r?null:P();function a(t){var e=r?l:ue({},l,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":i});return u.httpRequest("POST",n,U(e,s),o).promise.then(function(e){var n;if(e)return 400<=e.status&&j(e.status)&&t?a(!1):(e={status:(n=e).status},!(n=n.header("date"))||(n=Date.parse(n))&&(e.serverTime=n),e)}).catch(function(){return t?a(!1):Promise.reject()})}return t?a(!0).catch(function(){}):(f&&f(n+c+"?d="+O(o)),Promise.resolve())},d.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();for(var r=u.httpAllowsPost(),o=r?[e]:k(R-n.length,e),i=[],a=0;a<o.length;a++)i.push(d.sendChunk(o[a],n,t,r));return Promise.all(i)},d}function T(e){var n={},a=e.allAttributesPrivate,u=e.privateAttributeNames||[],s={key:!0,custom:!0,anonymous:!0},c={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(t,r){return Object.keys(t).reduce(function(e,n){return r(n)&&(o(n)?e[1][n]=!0:e[0][n]=t[n]),e},[{},{}])}var t=e.privateAttributeNames||[],o=function(e){return!s[e]&&(a||-1!==t.indexOf(e)||-1!==u.indexOf(e))},r=n(e,function(e){return c[e]}),i=r[0],r=r[1];e.custom&&(e=n(e.custom,function(){return 1}),i.custom=e[0],r=ue({},r,e[1]));r=Object.keys(r);return r.length&&(r.sort(),i.privateAttrs=r),i},n}function A(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function fe(){return"LaunchDarkly client initialized"}function de(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"}function ve(e){return'Custom event "'+e+'" does not exist'}function C(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+_}function ge(){return"No environment/client-side ID was specified."+_}function pe(e){return"Error fetching flag settings: "+A(e)}function me(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+_}function he(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function N(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'}function ye(){return"identify() has no effect here; it must be called on the main client instance"}function F(e){return'Ignoring unknown config option "'+e+'"'}function L(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"}function x(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"}function q(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t}function be(){return"received ping message from stream"}function Ee(){return"received streaming update for all flags"}function ke(e){return'received streaming update for flag "'+e+'"'}function we(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function De(e){return'received streaming deletion for flag "'+e+'"'}function Oe(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function Se(e){return'enqueueing "'+e+'" event'}var _=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",V=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},J=function(e){return'Expected application/json content type but got "'+e+'"'},Ue=function(e){return"local storage is unavailable: "+A(e)},M=function(e){return"network error"+(e?" ("+e+")":"")},z=function(){return"No user specified."+_},K=function(){return"Invalid user specified."+_},H=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(j(e)?t:"giving up permanently")},B=function(){return"Cannot make HTTP requests in this environment."+_},$=function(){return"Closing stream connection"},G=function(e){return"Opening stream connection to "+e},X=function(e,n){return"Error on stream connection: "+A(e)+", will continue retrying every "+n+" milliseconds."},W=function(e){return"polling for feature flags at "+e},Pe=function(e){return"sending "+e+" events"},Ie=Object.freeze({__proto__:null,clientInitialized:fe,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:V,eventWithoutUser:de,invalidContentType:J,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Ue,networkError:M,unknownCustomEventKey:ve,environmentNotFound:C,environmentNotSpecified:ge,errorFetchingFlags:pe,userNotSpecified:z,invalidUser:K,bootstrapOldFormat:me,bootstrapInvalid:he,deprecated:N,httpErrorMessage:H,httpUnavailable:B,identifyDisabled:ye,streamClosing:$,streamConnecting:G,streamError:X,unknownOption:F,wrongOptionType:L,wrongOptionTypeBoolean:x,optionBelowMinimum:q,debugPolling:W,debugStreamPing:be,debugStreamPut:Ee,debugStreamPatch:ke,debugStreamPatchIgnored:we,debugStreamDelete:De,debugStreamDeleteIgnored:Oe,debugEnqueueingEvent:Se,debugPostingEvents:Pe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function je(e,n,t,r,o,i){var a,u,s,c,l=3<arguments.length&&void 0!==r?r:null,f=4<arguments.length&&void 0!==o?o:null,d={},v=(5<arguments.length&&void 0!==i?i:null)||le(e,t,n),g=n.eventsUrl+"/events/bulk/"+t,p=(u=a=0,s={},(t={}).summarizeEvent=function(e){var n,t;"feature"===e.kind&&(n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(t=s[n])?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate))},t.getSummary=function(){var e,n={},t=!0;for(e in s){var r=s[e],o=n[r.key];o||(o={default:r.default,counters:[]},n[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),t=!1}return t?null:{startDate:a,endDate:u,features:n}},t.clearSummary=function(){u=a=0,s={}},t),m=T(n),h=n.inlineUsersInEvents,y=n.samplingInterval,b=n.eventCapacity,E=n.flushInterval,k=n.logger,w=[],D=0,O=!1,S=!1;function U(){return 0===y||0===Math.floor(Math.random()*y)}function P(e){w.length<b?(w.push(e),S=!1):(S||(S=!0,k.warn(V())),l&&l.incrementDroppedEvents())}return d.enqueue=function(e){var n,t,r;O||(n=r=!1,p.summarizeEvent(e),"feature"===e.kind?U()&&(r=!!e.trackEvents,n=!!(t=e).debugEventsUntilDate&&(t.debugEventsUntilDate>D&&t.debugEventsUntilDate>(new Date).getTime())):r=U(),r&&P((r=ue({},t=e),"alias"===t.kind||(h||"identify"===t.kind?r.user=m.filterUser(t.user):(r.userKey=t.user.key,delete r.user),"feature"===t.kind&&(delete r.trackEvents,delete r.debugEventsUntilDate)),r)),n&&((e=ue({},e,{kind:"debug"})).user=m.filterUser(e.user),delete e.trackEvents,delete e.debugEventsUntilDate,P(e)))},d.flush=function(){if(O)return Promise.resolve();var e=w,n=p.getSummary();return p.clearSummary(),n&&(n.kind="summary",e.push(n)),l&&l.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],k.debug(Pe(e.length)),v.sendEvents(e,g).then(function(e){e&&(e.serverTime&&(D=e.serverTime),j(e.status)||(O=!0),400<=e.status&&oe(function(){f.maybeReportError(new I(H(e.status,"event posting","some events were dropped")))}))}))},d.start=function(){c=setTimeout(function e(){d.flush(),c=setTimeout(e,E)},E)},d.stop=function(){clearTimeout(c)},d}function Re(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=o[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o["error"]?this.emit("error",e):(n||console).error(e.message))},e}var Te="ready",Ae="initialized",Ce="failed";var Ne=function(o){var n=!1,t=!1,r=null,e=null,i=new Promise(function(n){o.on(Te,function e(){o.off(Te,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(r):e=new Promise(function(n,t){function r(e){o.off(Ce,r),t(e)}o.on(Ae,function e(){o.off(Ae,e),n()}),o.on(Ce,r)}))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,o.emit(Ae),o.emit(Te))},signalFailure:function(e){n||t||(t=!0,r=e,o.emit(Ce,e),o.emit(Te)),o.maybeReportError(e)}}};function Fe(n,t,r,o){var i={};function a(){var e="",n=o.getUser();return n&&(e=r||b(JSON.stringify(n))),"ld:"+t+":"+e}return i.loadFlags=function(){return n.get(a()).then(function(e){if(null==e)return null;try{var n,t=JSON.parse(e);return t&&(void 0===(n=t.$schema)||n<1?t=E(t):delete t.$schema),t}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=ue({},e,{$schema:1});return n.set(a(),JSON.stringify(e))},i.clearFlags=function(){return n.clear(a())},i}function Le(r,n){function o(e){t||(t=!0,n.warn(Ue(e)))}var e={},t=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(n){r?r.get(e).then(n).catch(function(e){o(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){r?r.set(e,t).then(function(){return n(!0)}).catch(function(e){o(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){r?r.clear(e).then(function(){return n(!0)}).catch(function(e){o(e),n(!1)}):n(!1)})},e}var xe=3e5;function qe(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=s+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=S(o,i),g=!1,p=null,m=null,h=null,y=null,b=null;function E(e){g||(c.warn(X(e,t)),g=!0),D(!1),w(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:xe};if(o.eventSourceFactory){for(var r in null!=y&&(n="h="+y),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(h)):(e=s+"/ping/"+a,n=""):e=l+"/"+O(JSON.stringify(h)),t.headers=U(t.headers,i),e=e+((n=d?n+(n?"&":"")+"withReasons=true":n)?"?":"")+n,w(),c.info(G(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),b)se(b,r)&&p.addEventListener(r,b[r]);p.onerror=E}}function w(){p&&(c.info($()),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){h=e,y=n,b={};for(var r in t||{})!function(n){b[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}(r);k()},e.disconnect=function(){clearTimeout(m),m=null,w()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}var _e="application/json";function Ve(d,v,i){var a=v.baseUrl,u=v.useReport,s=v.evaluationReasons,c=v.logger,e={},g={};function l(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ne(B()))});var t=n?"REPORT":"GET",r=S(d,v);n&&(r["Content-Type"]=_e);var o,i,a,u,s,c,l=g[e];l||(o=function(){delete g[e]},(c={addPromise:function(n,e){i=n,a&&a(),a=e,n.then(function(e){i===n&&(u(e),o&&o())},function(e){i===n&&(s(e),o&&o())})}}).resultPromise=new Promise(function(e,n){u=e,s=n}),g[e]=l=c);var f=d.httpRequest(t,e,U(r,v),n),n=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new Z(C()):new ne(pe(n.statusText||String(n.status))));if(e.header("content-type")&&e.header("content-type").substring(0,_e.length)===_e)return JSON.parse(e.body);var n,e=J(e.header("content-type")||"");return Promise.reject(new ne(e))},function(e){return Promise.reject(new ne(M(e)))});return l.addPromise(n,function(){f.cancel&&f.cancel()}),l.resultPromise}return e.fetchJSON=function(e){return l(a+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o="";return u?(t=[a,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=O(JSON.stringify(e)),t=[a,"/sdk/evalx/",i,"/users/",e].join("")),n&&(o="h="+n),c.debug(W(t=t+((o=s?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),l(t,r)},e}var Je=require("uuid").v1,Me="ld:$anonUserId";function ze(t){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new o(z()));var n=te(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?t.get(Me).then(function(e){if(e)return n.key=e,n;e=Je();return n.key=e,t.set(Me,e).then(function(){return n})}):Promise.reject(new o(K()))},e}var Ke=["debug","info","warn","error","none"];function He(e,i){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var a=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],u=!(!e||!e.destination),s=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Ke.length;t++)Ke[t]===e.level&&(r=t);for(var o={},c=function(e){var n,t=Ke[e];"none"!==t&&(e<r?o[t]=function(){}:(n=e,o[t]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=u?n+": "+s:s,t=1!==t.length&&i?((r=f(t))[0]=o+r[0],i.apply(void 0,f(r))):o+t[0];try{a[e](t)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(n,t,arguments)}))},l=0;l<Ke.length;l++)c(l);return o}var Be={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function $e(e,n,t,r){var a=ue({logger:{default:r}},Be,t),o={};function u(e){oe(function(){n&&n.maybeReportError(new v(e))})}var i,s,c,l,f,e=ue({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=Y(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}return i=e,Object.keys(o).forEach(function(e){var n;void 0!==i[e]&&(n=o[e],r&&r.warn(N(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e]))}),s=ue({},e),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=ue({},c=e=s),Object.keys(c).forEach(function(e){var n,t,r,o,i=c[e];null!=i&&(void 0===(n=a[e])?u(F(e)):"any"!==(t=n.type||d(n.default))&&(r=t.split("|"),o=d(i),r.indexOf(o)<0?"boolean"===t?(l[e]=!!i,u(x(e,o))):(u(L(e,t,o)),l[e]=n.default):"number"===o&&void 0!==n.minimum&&i<n.minimum&&(u(q(e,i,n.minimum)),l[e]=n.minimum)))}),f=(e=l).logger,Ke.forEach(function(e){if("none"!==e&&(!f[e]||"function"!=typeof f[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),e}var Ge,Xe=Object.freeze({__proto__:null,baseOptionDefs:Be,validate:$e}),We=new Uint8Array(16);function Qe(){if(!Ge&&!(Ge="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ge(We)}var Ye=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Ze(e){return"string"==typeof e&&Ye.test(e)}for(var en,nn,tn=[],rn=0;rn<256;++rn)tn.push((rn+256).toString(16).substr(1));function on(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=(tn[e[n+0]]+tn[e[n+1]]+tn[e[n+2]]+tn[e[n+3]]+"-"+tn[e[n+4]]+tn[e[n+5]]+"-"+tn[e[n+6]]+tn[e[n+7]]+"-"+tn[e[n+8]]+tn[e[n+9]]+"-"+tn[e[n+10]]+tn[e[n+11]]+tn[e[n+12]]+tn[e[n+13]]+tn[e[n+14]]+tn[e[n+15]]).toLowerCase();if(!Ze(n))throw TypeError("Stringified UUID is invalid");return n}var an=0,un=0;function sn(e){if(!Ze(e))throw TypeError("Invalid UUID");var n,t=new Uint8Array(16);return t[0]=(n=parseInt(e.slice(0,8),16))>>>24,t[1]=n>>>16&255,t[2]=n>>>8&255,t[3]=255&n,t[4]=(n=parseInt(e.slice(9,13),16))>>>8,t[5]=255&n,t[6]=(n=parseInt(e.slice(14,18),16))>>>8,t[7]=255&n,t[8]=(n=parseInt(e.slice(19,23),16))>>>8,t[9]=255&n,t[10]=(n=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=n/4294967296&255,t[12]=n>>>24&255,t[13]=n>>>16&255,t[14]=n>>>8&255,t[15]=255&n,t}function cn(e,a,u){function n(e,n,t,r){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var n=[],t=0;t<e.length;++t)n.push(e.charCodeAt(t));return n}(e)),16!==(n="string"==typeof n?sn(n):n).length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var o=new Uint8Array(16+e.length);if(o.set(n),o.set(e,n.length),(o=u(o))[6]=15&o[6]|a,o[8]=63&o[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=o[i];return t}return on(o)}try{n.name=e}catch(e){}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}function ln(e){return 14+(e+64>>>9<<4)+1}function fn(e,n){var t=(65535&e)+(65535&n);return(e>>16)+(n>>16)+(t>>16)<<16|65535&t}function dn(e,n,t,r,o,i){return fn((i=fn(fn(n,e),fn(r,i)))<<o|i>>>32-o,t)}function vn(e,n,t,r,o,i,a){return dn(n&t|~n&r,e,n,o,i,a)}function gn(e,n,t,r,o,i,a){return dn(n&r|t&~r,e,n,o,i,a)}function pn(e,n,t,r,o,i,a){return dn(n^t^r,e,n,o,i,a)}function mn(e,n,t,r,o,i,a){return dn(t^(n|~r),e,n,o,i,a)}var hn=cn("v3",48,function(e){if("string"==typeof e){var n=unescape(encodeURIComponent(e));e=new Uint8Array(n.length);for(var t=0;t<n.length;++t)e[t]=n.charCodeAt(t)}return function(e){for(var n=[],t=32*e.length,r="0123456789abcdef",o=0;o<t;o+=8){var i=e[o>>5]>>>o%32&255,i=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);n.push(i)}return n}(function(e,n){e[n>>5]|=128<<n%32,e[ln(n)-1]=n;for(var t=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var u=t,s=r,c=o,l=i;t=vn(t,r,o,i,e[a],7,-680876936),i=vn(i,t,r,o,e[a+1],12,-389564586),o=vn(o,i,t,r,e[a+2],17,606105819),r=vn(r,o,i,t,e[a+3],22,-1044525330),t=vn(t,r,o,i,e[a+4],7,-176418897),i=vn(i,t,r,o,e[a+5],12,1200080426),o=vn(o,i,t,r,e[a+6],17,-1473231341),r=vn(r,o,i,t,e[a+7],22,-45705983),t=vn(t,r,o,i,e[a+8],7,1770035416),i=vn(i,t,r,o,e[a+9],12,-1958414417),o=vn(o,i,t,r,e[a+10],17,-42063),r=vn(r,o,i,t,e[a+11],22,-1990404162),t=vn(t,r,o,i,e[a+12],7,1804603682),i=vn(i,t,r,o,e[a+13],12,-40341101),o=vn(o,i,t,r,e[a+14],17,-1502002290),r=vn(r,o,i,t,e[a+15],22,1236535329),t=gn(t,r,o,i,e[a+1],5,-165796510),i=gn(i,t,r,o,e[a+6],9,-1069501632),o=gn(o,i,t,r,e[a+11],14,643717713),r=gn(r,o,i,t,e[a],20,-373897302),t=gn(t,r,o,i,e[a+5],5,-701558691),i=gn(i,t,r,o,e[a+10],9,38016083),o=gn(o,i,t,r,e[a+15],14,-660478335),r=gn(r,o,i,t,e[a+4],20,-405537848),t=gn(t,r,o,i,e[a+9],5,568446438),i=gn(i,t,r,o,e[a+14],9,-1019803690),o=gn(o,i,t,r,e[a+3],14,-187363961),r=gn(r,o,i,t,e[a+8],20,1163531501),t=gn(t,r,o,i,e[a+13],5,-1444681467),i=gn(i,t,r,o,e[a+2],9,-51403784),o=gn(o,i,t,r,e[a+7],14,1735328473),r=gn(r,o,i,t,e[a+12],20,-1926607734),t=pn(t,r,o,i,e[a+5],4,-378558),i=pn(i,t,r,o,e[a+8],11,-2022574463),o=pn(o,i,t,r,e[a+11],16,1839030562),r=pn(r,o,i,t,e[a+14],23,-35309556),t=pn(t,r,o,i,e[a+1],4,-1530992060),i=pn(i,t,r,o,e[a+4],11,1272893353),o=pn(o,i,t,r,e[a+7],16,-155497632),r=pn(r,o,i,t,e[a+10],23,-1094730640),t=pn(t,r,o,i,e[a+13],4,681279174),i=pn(i,t,r,o,e[a],11,-358537222),o=pn(o,i,t,r,e[a+3],16,-722521979),r=pn(r,o,i,t,e[a+6],23,76029189),t=pn(t,r,o,i,e[a+9],4,-640364487),i=pn(i,t,r,o,e[a+12],11,-421815835),o=pn(o,i,t,r,e[a+15],16,530742520),r=pn(r,o,i,t,e[a+2],23,-995338651),t=mn(t,r,o,i,e[a],6,-198630844),i=mn(i,t,r,o,e[a+7],10,1126891415),o=mn(o,i,t,r,e[a+14],15,-1416354905),r=mn(r,o,i,t,e[a+5],21,-57434055),t=mn(t,r,o,i,e[a+12],6,1700485571),i=mn(i,t,r,o,e[a+3],10,-1894986606),o=mn(o,i,t,r,e[a+10],15,-1051523),r=mn(r,o,i,t,e[a+1],21,-2054922799),t=mn(t,r,o,i,e[a+8],6,1873313359),i=mn(i,t,r,o,e[a+15],10,-30611744),o=mn(o,i,t,r,e[a+6],15,-1560198380),r=mn(r,o,i,t,e[a+13],21,1309151649),t=mn(t,r,o,i,e[a+4],6,-145523070),i=mn(i,t,r,o,e[a+11],10,-1120210379),o=mn(o,i,t,r,e[a+2],15,718787259),r=mn(r,o,i,t,e[a+9],21,-343485551),t=fn(t,u),r=fn(r,s),o=fn(o,c),i=fn(i,l)}return[t,r,o,i]}(function(e){if(0===e.length)return[];for(var n=8*e.length,t=new Uint32Array(ln(n)),r=0;r<n;r+=8)t[r>>5]|=(255&e[r/8])<<r%32;return t}(e),8*e.length))});function yn(e,n){return e<<n|e>>>32-n}var bn=cn("v5",80,function(e){var n=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),u=new Array(a),s=0;s<a;++s){for(var c=new Uint32Array(16),l=0;l<16;++l)c[l]=e[64*s+4*l]<<24|e[64*s+4*l+1]<<16|e[64*s+4*l+2]<<8|e[64*s+4*l+3];u[s]=c}u[a-1][14]=8*(e.length-1)/Math.pow(2,32),u[a-1][14]=Math.floor(u[a-1][14]),u[a-1][15]=8*(e.length-1)&4294967295;for(var f=0;f<a;++f){for(var d=new Uint32Array(80),v=0;v<16;++v)d[v]=u[f][v];for(var g=16;g<80;++g)d[g]=yn(d[g-3]^d[g-8]^d[g-14]^d[g-16],1);for(var p=t[0],m=t[1],h=t[2],y=t[3],b=t[4],E=0;E<80;++E)var k=Math.floor(E/20),k=yn(p,5)+function(e,n,t,r){switch(e){case 0:return n&t^~n&r;case 1:return n^t^r;case 2:return n&t^n&r^t&r;case 3:return n^t^r}}(k,m,h,y)+b+n[k]+d[E]>>>0,b=y,y=h,h=yn(m,30)>>>0,m=p,p=k;t[0]=t[0]+p>>>0,t[1]=t[1]+m>>>0,t[2]=t[2]+h>>>0,t[3]=t[3]+y>>>0,t[4]=t[4]+b>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,255&t[0],t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,255&t[1],t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,255&t[2],t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,255&t[3],t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,255&t[4]]});var En=Object.freeze({__proto__:null,v1:function(e,n,t){var r=n&&t||0,o=n||new Array(16),i=(e=e||{}).node||en,a=void 0!==e.clockseq?e.clockseq:nn;null!=i&&null!=a||(s=e.random||(e.rng||Qe)(),null==i&&(i=en=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=nn=16383&(s[6]<<8|s[7])));var u=void 0!==e.msecs?e.msecs:Date.now(),t=void 0!==e.nsecs?e.nsecs:un+1,s=u-an+(t-un)/1e4;if(s<0&&void 0===e.clockseq&&(a=a+1&16383),1e4<=(t=(s<0||an<u)&&void 0===e.nsecs?0:t))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");an=u,nn=a,t=(1e4*(268435455&(u+=122192928e5))+(un=t))%4294967296,o[r++]=t>>>24&255,o[r++]=t>>>16&255,o[r++]=t>>>8&255,o[r++]=255&t,u=u/4294967296*1e4&268435455,o[r++]=u>>>8&255,o[r++]=255&u,o[r++]=u>>>24&15|16,o[r++]=u>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var c=0;c<6;++c)o[r+c]=i[c];return n||on(o)},v3:hn,v4:function(e,n,t){var r=(e=e||{}).random||(e.rng||Qe)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,n){t=t||0;for(var o=0;o<16;++o)n[t+o]=r[o];return n}return on(r)},v5:bn,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!Ze(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:Ze,stringify:on,parse:sn}).v1,kn=Xe.baseOptionDefs;var wn=function(e){var n={diagnosticId:En()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Dn=function(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){o.push({timestamp:e,failed:n,durationMillis:t})},reset:i}},On=function(n,r,e,t,o,i,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming;function p(){return{sdk:function(){var e=Q({},n.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==kn.baseUrl.default,customStreamURI:i.streamUrl!==kn.streamUrl.default,customEventsURI:i.eventsUrl!==kn.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function m(e){i.logger&&i.logger.debug(Ie.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){var e,n;m((e=(new Date).getTime(),n=Q({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps()),c&&(n=Q(Q({},n),p())),v.reset(e),n)),s=setTimeout(h,d),u=(new Date).getTime(),c&&r.isEnabled()&&(n=Q({},v.getProps()),r.set(l,JSON.stringify(n)))}return(e={}).start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){var n;e?(n=(u||0)+d)<=(e=(new Date).getTime())?h():s=setTimeout(h,n-e):0===Math.floor(4*Math.random())?h():s=setTimeout(h,d)}):(m(Q({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),s=setTimeout(h,d))},e.stop=function(){s&&clearTimeout(s)},e.setStreaming=function(e){g=e},e},Sn="change",Un="internal-change";e.commonBasicLogger=He,e.errors=i,e.initialize=function(e,n,t,i,r){var a,o,u,s,c,l=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||He("warn")}(),f=Re(l),d=Ne(f),v=$e(t,f,r,l),g=v.sendEvents,p=e,m=v.hash,h=Le(i.localStorage,l),y=le(i,p,v),b=v.sendEvents&&!v.diagnosticOptOut,E=b?wn(p):null,k=b?Dn((new Date).getTime()):null,w=b?On(i,h,k,y,p,v,E):null,D=qe(i,v,p,k),O=v.eventProcessor||je(i,v,p,k,f,y),S=Ve(i,v,p),U={},P={},I=v.streaming,j=!1,R=!1,T=!0,A=v.stateProvider,C=(s=function(e,n){(function(e){A||e&&L({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!v.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&J(e,n)},k={setUser:function(e){var n=c&&te(c);(c=ce(e))&&s&&s(te(c),n)},getUser:function(){return c?te(c):null}},(y=null)&&k.setUser(y),k),N=ze(h),F=h.isEnabled()?new Fe(h,p,m,C):null;function L(e){if(p&&!(A&&A.enqueueEvent&&A.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(T&&(l.warn(de()),T=!1));T=!1}!g||R||i.isDoNotTrack()||(l.debug(Se(e.kind)),O.enqueue(e))}}function x(e,n,t,r){var o=C.getUser(),i=new Date,a=n?n.value:null;if(!v.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=U[u];if(s&&i-s<3e5)return;U[u]=i}i={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(i.contextKind=V(o));e=P[e];e&&(i.version=e.flagVersion||e.version,i.trackEvents=e.trackEvents,i.debugEventsUntilDate=e.debugEventsUntilDate),(r||e&&e.trackReason)&&n&&(i.reason=n.reason),L(i)}function q(e,n,t,r){var o,i;return P&&se(P,e)&&P[e]&&!P[e].deleted?(i=_(o=P[e]),null!==o.value&&void 0!==o.value||(i.value=n)):i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},t&&x(e,i,n,r),i}function _(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function V(e){return e.anonymous?"anonymousUser":"user"}function J(e,n){A||e&&n&&L({kind:"alias",key:e.key,contextKind:V(e),previousKey:n.key,previousContextKind:V(n),creationDate:(new Date).getTime()})}function M(){o=!0,C.getUser()&&D.connect(C.getUser(),m,{ping:function(){l.debug(be());var n=C.getUser();S.fetchFlagSettings(n,m).then(function(e){re(n,C.getUser())&&K(e||{})}).catch(function(e){f.maybeReportError(new ne(pe(e)))})},put:function(e){e=JSON.parse(e.data);l.debug(Ee()),K(e)},patch:function(e){var n,t=JSON.parse(e.data),r=P[t.key];!r||!r.version||!t.version||r.version<t.version?(l.debug(ke(t.key)),n={},delete(e=ue({},t)).key,e=_(P[t.key]=e),n[t.key]=r?{previous:r.value,current:e}:{current:e},H(n)):l.debug(we(t.key))},delete:function(e){var n=JSON.parse(e.data);!P[n.key]||P[n.key].version<n.version?(l.debug(De(n.key)),e={},P[n.key]&&!P[n.key].deleted&&(e[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},H(e)):l.debug(Oe(n.key))}})}function z(){o&&(D.disconnect(),o=!1)}function K(e){var n,t,r={};if(!e)return Promise.resolve();for(n in P)se(P,n)&&P[n]&&(e[n]&&!re(e[n].value,P[n].value)?r[n]={previous:P[n].value,current:_(e[n])}:e[n]&&!e[n].deleted||(r[n]={previous:P[n].value}));for(t in e)se(e,t)&&e[t]&&(!P[t]||P[t].deleted)&&(r[t]={current:_(e[t])});return P=Q({},e),H(r).catch(function(){})}function H(o){var i,e=Object.keys(o);return 0<e.length&&(i={},e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;f.emit(Sn+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),f.emit(Sn,i),f.emit(Un,P),v.sendEventsOnlyForVariation||A||e.forEach(function(e){x(e,o[e].current)})),a&&F?F.saveFlags(P):Promise.resolve()}function B(){var e=I||u&&void 0===I;e&&!o?M():!e&&o&&z(),w&&w.setStreaming(e)}function $(e){return e===Sn||e.substr(0,Sn.length+1)===Sn+":"}function G(e){p=e.environment,C.setUser(e.user),P=Q({},e.flags),oe(X)}function X(){l.info(fe()),j=!0,B(),d.signalSuccess()}function W(e){d.signalFailure(e)}return"string"==typeof v.bootstrap&&"LOCALSTORAGE"===v.bootstrap.toUpperCase()&&(F?a=!0:l.warn(Ue())),"object"===Y(v.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",o=t[r];!o&&e.length&&l.warn(me()),!1===t.$valid&&l.warn(he());var i={};return e.forEach(function(e){var n;e!==r&&"$valid"!==e&&(n={value:t[e]},o&&o[e]?n=ue(n,o[e]):n.version=0,i[e]=n)}),i}(v.bootstrap)),A?((h=A.getInitialState())?G(h):A.on("init",G),A.on("update",function(e){e.user&&C.setUser(e.user);e.flags&&K(e.flags)})):(e?N.validateUser(n).then(function(e){return C.setUser(e),"object"===Y(v.bootstrap)?X():a?F.loadFlags().then(function(e){return null==e?(P={},S.fetchFlagSettings(C.getUser(),m).then(function(e){return K(e||{})}).then(X).catch(function(e){W(new ne(pe(e)))})):(P=e,oe(X),S.fetchFlagSettings(C.getUser(),m).then(K).catch(function(e){return f.maybeReportError(e)}))}):S.fetchFlagSettings(C.getUser(),m).then(function(e){P=e||{},X()}).catch(function(e){P={},W(e)})}):Promise.reject(new Z(ge()))).catch(W),{client:{waitForInitialization:function(){return d.getInitializationPromise()},waitUntilReady:function(){return d.getReadyPromise()},identify:function(e,r,n){return R?ie(Promise.resolve({}),n):A?(l.warn(ye()),ie(Promise.resolve(ae(P)),n)):ie((a&&F?F.clearFlags():Promise.resolve()).then(function(){return N.validateUser(e)}).then(function(t){return S.fetchFlagSettings(t,r).then(function(e){var n=ae(e);return C.setUser(t),m=r,e?K(e).then(function(){return n}):n})}).then(function(e){return o&&M(),e}).catch(function(e){return f.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return C.getUser()},variation:function(e,n){return q(e,n,!0,!1).value},variationDetail:function(e,n){return q(e,n,!0,!0)},track:function(e,n,t){var r,o;"string"==typeof e?(i.customEventFilter&&!i.customEventFilter(e)&&l.warn(ve(e)),o={kind:"custom",key:e,user:r=C.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},r&&r.anonymous&&(o.contextKind=V(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),L(o)):f.maybeReportError(new ee(ve(e)))},alias:J,on:function(e,n,t){$(e)?(u=!0,j&&B(),f.on(e,n,t)):f.on.apply(f,arguments)},off:function(e){var n;f.off.apply(f,arguments),$(e)&&(n=!1,f.getEvents().forEach(function(e){$(e)&&0<f.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,o&&void 0===I&&z()))},setStreaming:function(e){(e=null===e?void 0:e)!==I&&(I=e,B())},flush:function(e){return ie(g?O.flush():Promise.resolve(),e)},allFlags:function(){var e,n={};if(!P)return n;for(e in P)se(P,e)&&(n[e]=q(e,null,!v.sendEventsOnlyForVariation).value);return n},close:function(e){return ie(R?Promise.resolve():Promise.resolve().then(function(){if(z(),w&&w.stop(),g)return O.stop(),O.flush()}).then(n).catch(n),e);function n(){R=!0,P={}}}},options:v,emitter:f,ident:C,logger:l,requestor:S,start:function(){g&&(w&&w.start(),O.start())},enqueueEvent:L,getFlagsInternal:function(){return P},getEnvironmentId:function(){return p},internalChangeEventName:Un}},e.messages=Ie,e.utils=D,e.version="4.0.0",Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ldclient-common.min.js.map
{
"name": "launchdarkly-js-sdk-common",
"version": "3.5.0",
"version": "4.0.0",
"description": "LaunchDarkly SDK for JavaScript - common code",

@@ -76,3 +76,3 @@ "author": "LaunchDarkly <team@launchdarkly.com>",

"fast-deep-equal": "^2.0.1",
"uuid": "^3.3.2"
"uuid": "^8.0.0"
},

@@ -79,0 +79,0 @@ "repository": {

@@ -50,14 +50,2 @@ /**

/**
* A basic implementation of logging that uses the global `console` object. This is used by
* default in the browser SDK. It sends messages of "debug", "info", "warn", or "error"
* level (if enable) to `console.log()`, `console.info()`, `console.warn()`, and `console.error()`
* respectively.
*
* To make LDClient use this logger, put it in the `logger` property of [[LDOptions]].
*
* @deprecated Please use `basicLogger` instead.
*/
export function createConsoleLogger(minimumLevel: string): LDLogger;
/**
* LaunchDarkly initialization options that are supported by all variants of the JS client.

@@ -228,13 +216,2 @@ * The browser SDK and Electron SDK may support additional options.

/**
* If specified, enables event sampling so that only some fraction of analytics events will be
* sent pseudo-randomly.
*
* When set to greater than zero, there is a 1 in `samplingInterval` chance that events will be
* sent: for example, a value of 20 means that on average 1 in 20, or 5%, of all events will be sent.
*
* @deprecated This feature will be removed in a future version.
*/
samplingInterval?: number;
/**
* How long (in milliseconds) to wait after a failure of the stream connection before trying to

@@ -379,8 +356,4 @@ * reconnect.

* part of the [[LDEvaluationDetail]] object returned by [[LDClient.variationDetail]].
*
* This type is separate from `[[LDEvaluationReason]]` for backwards compatibility. In
* earlier versions of this SDK, `[[LDEvaluationReason]]` was incorrectly defined as
* being non-nullable.
*/
interface NonNullableLDEvaluationReason {
interface LDEvaluationReason {
/**

@@ -422,10 +395,2 @@ * The general category of the reason:

/**
* Describes the reason that a flag evaluation produced a particular value. This is
* part of the [[LDEvaluationDetail]] object returned by [[LDClient.variationDetail]].
*
* Will be null when `[[LDOptions.evaluationReasons]]` is `false`.
*/
export type LDEvaluationReason = NonNullableLDEvaluationReason | null;
/**
* An object that combines the result of a feature flag evaluation with information about

@@ -453,4 +418,6 @@ * how it was calculated.

* An object describing the main factor that influenced the flag evaluation value.
* This will be `null`/`undefined` if the SDK was not configured to get evaluation
* reasons.
*/
reason: LDEvaluationReason;
reason?: LDEvaluationReason;
}

@@ -457,0 +424,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc