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