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

launchdarkly-js-sdk-common

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 3.0.0-beta2 to 3.0.0

13

CHANGELOG.md

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

## [3.0.0] - 2019-12-13
### Added:
- Configuration property `eventCapacity`: the maximum number of analytics events (not counting evaluation counters) that can be held at once, to prevent the SDK from consuming unexpected amounts of memory in case an application generates events unusually rapidly. In JavaScript code this would not normally be an issue, since the SDK flushes events every two seconds by default, but you may wish to increase this value if you will intentionally be generating a high volume of custom or identify events. The default value is 100.
### Changed:
- (Breaking change) The `extraDefaults` parameter to the internal common `initialize` method is now `extraOptionDefs` and has a different format, allowing for more flexible validation.
- The SDK now logs a warning if any configuration property has an inappropriate type, such as `baseUri:3` or `sendEvents:"no"`. For boolean properties, the SDK will still interpret the value in terms of truthiness, which was the previous behavior. For all other types, since there's no such commonly accepted way to coerce the type, it will fall back to the default setting for that property; previously, the behavior was undefined but most such mistakes would have caused the SDK to throw an exception at some later point.
- Removed or updated some development dependencies that were causing vulnerability warnings.
### Deprecated:
- The `samplingInterval` configuration property was deprecated in the code in the previous minor version release, and in the changelog, but the deprecation notice was accidentally omitted from the documentation comments. It is hereby deprecated again.
## [2.14.1] - 2019-11-04

@@ -7,0 +20,0 @@ ### Fixed:

2

dist/ldclient-common.cjs.js

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

"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ownKeys(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function _objectSpread2(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function createCustomError(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var n,t=e.length,r=t%3,o=[],i=16383,a=0,u=t-r;a<u;a+=i)o.push(encodeChunk(e,a,u<a+i?u:a+i));return 1==r?(n=e[t-1],o.push(lookup[n>>2]+lookup[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(lookup[n>>10]+lookup[n>>4&63]+lookup[n<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=isArray(n),u=isArray(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=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=keyList(n);if((o=v.length)!==keyList(t).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var n=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(n))}function stringToBytes(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,n){return fastDeepEqual(e,n)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function transformValuesToVersionedValues(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function getLDUserAgentString(e){var n=e.version||"3.0.0-beta2";return e.userAgent+"/"+n}function getLDHeaders(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function extend(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return _objectSpread2({},e,{},n)},{})}function sanitizeUser(e){if(!e)return e;var n;for(var t in userAttrsToStringify){var r=userAttrsToStringify[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||_objectSpread2({},e))[r]=String(o))}return n||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,extend:extend,sanitizeUser:sanitizeUser}),MAX_URL_LENGTH=2e3;function EventSender(i,a,e,o){var u=a+"/events/bulk/"+e,t=a+"/a/"+e+".gif",s=i.httpFallbackPing,n={};function c(e,n){var r=JSON.stringify(e);return n?function n(t){var e=extend({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},getLDHeaders(i,o));return i.httpRequest("POST",u,e,r).promise.then(function(e){if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(s&&s(t+"?d="+base64URLEncode(r)),Promise.resolve())}return n.sendEvents=function(e){if(!i.httpRequest)return Promise.resolve();var n,t=i.httpAllowsPost();n=t?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-a.length,e);for(var r=[],o=0;o<n.length;o++)r.push(c(n[o],t));return Promise.all(r)},n}function EventSummarizer(){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],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}function UserFilter(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,o){return Object.keys(r).reduce(function(e,n){var t=e;return o(n)&&(!function(e){return!l[e]&&(s||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],o=extend({},o,a[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-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/docs/js-sdk-reference#section-analytics-events"},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,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(isHttpErrorRecoverable(e)?t:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,n){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+n+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},wrongOptionTypeBoolean=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},optionBelowMinimum=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},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});function EventProcessor(e,n,t){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i={},a=(4<arguments.length&&void 0!==arguments[4]?arguments[4]:null)||EventSender(e,n.eventsUrl,t,n),u=EventSummarizer(),s=UserFilter(n),c=n.inlineUsersInEvents,l=n.samplingInterval,f=n.eventCapacity,v=n.flushInterval,d=n.logger,g=[],p=0,m=!1,y=!1;function h(){return 0===l||0===Math.floor(Math.random()*l)}function b(e){g.length<f?(g.push(e),y=!1):y||(y=!0,d.warn(eventCapacityExceeded()))}return i.enqueue=function(e){if(!m){var n=!1,t=!1;if(u.summarizeEvent(e),"feature"===e.kind?h()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>p&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=h(),n&&b(function(e){var n=extend({},e);return c||"identify"===e.kind?n.user=s.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=extend({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,b(r)}}},i.flush=function(){if(m)return Promise.resolve();var e=g,n=u.getSummary();return u.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(g=[],d.debug(debugPostingEvents(e.length)),a.sendEvents(e).then(function(e){e&&(e.serverTime&&(p=e.serverTime),isHttpErrorRecoverable(e.status)||(m=!0),400<=e.status&&onNextTick(function(){o.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},i.start=function(){r=setTimeout(function e(){i.flush(),r=setTimeout(e,v)},v)},i.stop=function(){clearTimeout(r)},i}function EventEmitter(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=0;n<o[e].length;n++)o[e][n].handler.apply(o[e][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")?(n||console).error(e.message):this.emit("error",e))},e}function Store(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||btoa(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=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},u.saveFlags=function(e){var n=extend({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},u}function Stream(o,e,i,a){var u=e.streamUrl,s=e.logger,n={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,t=e.streamReconnectDelay,v=getLDHeaders(o,e),d=!1,g=null,p=null,m=null,y=null;function h(e){d||(s.warn(streamError(e,t)),d=!0),E(),b(t)}function b(e){p||(e?p=setTimeout(r,e):r())}function r(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=a&&(n="h="+a),l?o.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(m)):(e=u+"/ping/"+i,n=""):e=c+"/"+base64URLEncode(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),s.info(streamConnecting(e)),g=o.eventSourceFactory(e,t),y)y.hasOwnProperty(r)&&g.addEventListener(r,y[r]);g.onerror=h}}function E(){g&&(s.info(streamClosing()),g.close(),g=null)}return n.connect=function(e,t){m=e,y={};function n(n){y[n]=function(e){d=!1,t[n]&&t[n](e)}}for(var r in t||{})n(r);b()},n.disconnect=function(){clearTimeout(p),p=null,E()},n.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},n}function promiseCoalescer(t){var r,o,i,a,e={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){i=e,a=n}),e}var json="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(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 LDFlagFetchError(httpUnavailable()))});var t=n?"REPORT":"GET",r=getLDHeaders(u,s);n&&(r["Content-Type"]="application/json");var o=d[e];o||(o=promiseCoalescer(function(){delete d[e]}),d[e]=o);var i=u.httpRequest(t,e,r,n),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(json))return JSON.parse(e.body);var n=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(n))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=base64URLEncode(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(debugPolling(r)),g(r,o)},e}function Identity(e,n){var t,r={};return r.setUser=function(e){(t=sanitizeUser(e))&&n&&n(clone(t))},r.getUser=function(){return t?clone(t):null},e&&r.setUser(e),r}function createCommonjsModule(e,n){return e(n={exports:{}},n.exports),n.exports}for(var rngBrowser=createCommonjsModule(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var t=n||0,r=byteToHex;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var u=rngBrowser();null==i&&(i=_nodeId=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=_clockseq=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=s-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||_lastMSecs<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_clockseq=a;var f=(1e4*(268435455&(s+=122192928e5))+(_lastNSecs=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||bytesToUuid_1(o)}var v1_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 t=clone(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(r?r.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return t.key=e,t;var n=v1_1();return function(e){return r?r.set(ldUserIdKey,e).catch(function(){o.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(t.key=n).then(function(){return t})}):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},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"},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function validate(e,n,t,r){var a=extend({logger:{default:r}},baseOptionDefs,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var i,s,c,l,f=extend({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=_typeof(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var n=o[e];r&&r.warn(deprecated(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e])}}),s=extend({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=extend({},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(unknownOption(e));else{var r=t.type||v(t.default);if("any"!==r){var o=r.split("|"),i=v(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,u(wrongOptionTypeBoolean(e,i))):(u(wrongOptionType(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(optionBelowMinimum(e,n,t.minimum)),l[e]=t.minimum)}}}}),f=l}function createConsoleLogger(e,n){var o,i=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var a=0;e&&(a="none"===e?100:i.indexOf(e));var t={};function r(e,n,t){if(a<=e){var r=e<i.length?i[e]:"?";n(o+"["+r+"] "+t)}}return t.debug=function(e){return r(0,console.log,e)},t.info=function(e){return r(1,console.info,e)},t.warn=function(e){return r(2,console.warn,e)},t.error=function(e){return r(3,console.error,e)},t}var readyEvent="ready",successEvent="initialized",failedEvent="failed",changeEvent="change",internalChangeEvent="internal-change";function initialize(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||createConsoleLogger("warn")}(),l=EventEmitter(c),f=validate(t,l,r,c),v=f.hash,d=f.sendEvents,g=e,p=Stream(o,f,g,v),m=f.eventProcessor||EventProcessor(o,f,g,l),y=Requestor(o,f,g),h={},b={},E=f.streaming,k=!1,S=!1,w=!0,U=f.stateProvider,D=Identity(null,function(e){if(U)return;e&&L({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),P=UserValidator(o.localStorage,c);function L(e){g&&(U&&U.enqueueEvent&&U.enqueueEvent(e)||(e.user?(w=!1,!d||S||o.isDoNotTrack()||(c.debug(debugEnqueueingEvent(e.kind)),m.enqueue(e))):w&&(c.warn(eventWithoutUser()),w=!1)))}function O(e,n,t,r){var o=D.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=h[u];if(s&&i-s<3e5)return;h[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=b[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),L(c)}function I(e,n,t,r){var o;if(b&&b.hasOwnProperty(e)&&b[e]&&!b[e].deleted){var i=b[e];o=C(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&O(e,o,n,r),o}function C(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function F(){i=!0,D.getUser()&&p.connect(D.getUser(),{ping:function(){c.debug(debugStreamPing()),y.fetchFlagSettings(D.getUser(),v).then(function(e){return R(e||{})}).catch(function(e){l.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);c.debug(debugStreamPut()),R(n)},patch:function(e){var n=JSON.parse(e.data),t=b[n.key];if(!t||!t.version||!n.version||t.version<n.version){c.debug(debugStreamPatch(n.key));var r={},o=extend({},n);delete o.key;var i=C(b[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},j(r)}else c.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!b[n.key]||b[n.key].version<n.version){c.debug(debugStreamDelete(n.key));var t={};b[n.key]&&!b[n.key].deleted&&(t[n.key]={previous:b[n.key].value}),b[n.key]={version:n.version,deleted:!0},j(t)}else c.debug(debugStreamDeleteIgnored(n.key))}})}function T(){i&&(p.disconnect(),i=!1)}function R(e){var n={};if(!e)return Promise.resolve();for(var t in b)b.hasOwnProperty(t)&&b[t]&&(e[t]&&!deepEquals(e[t].value,b[t].value)?n[t]={previous:b[t].value,current:C(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:b[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!b[r]||b[r].deleted)&&(n[r]={current:C(e[r])});return b=_objectSpread2({},e),j(n).catch(function(){})}function j(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;l.emit(changeEvent+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),l.emit(changeEvent,i),l.emit(internalChangeEvent,b),f.sendEventsOnlyForVariation||U||e.forEach(function(e){O(e,o[e].current)})}return a&&s?s.saveFlags(b).catch(function(){return null}):Promise.resolve()}function x(){var e=E||u&&void 0===E;e&&!i?F():!e&&i&&T()}function N(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}o.localStorage&&(s=new Store(o.localStorage,g,v,D,c));var _=new Promise(function(e){var n=l.on(readyEvent,function(){l.off(readyEvent,n),e()})}),A=new Promise(function(e,n){var t=l.on(successEvent,function(){l.off(successEvent,t),e()}),r=l.on(failedEvent,function(e){l.off(failedEvent,r),n(e)})});if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(s?a=!0:c.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(b=function(t){var e=Object.keys(t),r="$flagsState",o=t[r];!o&&e.length&&c.warn(bootstrapOldFormat()),!1===t.$valid&&c.warn(bootstrapInvalid());var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};o&&o[e]?n=extend(n,o[e]):n.version=0,i[e]=n}}),i}(f.bootstrap)),U){var V=U.getInitialState();V?q(V):U.on("init",q),U.on("update",function(e){e.user&&D.setUser(e.user);e.flags&&R(e.flags)})}else(e?P.validateUser(n).then(function(e){return D.setUser(e),"object"===_typeof(f.bootstrap)?z():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(b={},y.fetchFlagSettings(D.getUser(),v).then(function(e){return R(e||{})}).then(z).catch(function(e){K(new LDFlagFetchError(errorFetchingFlags(e)))})):(b=e,onNextTick(z),y.fetchFlagSettings(D.getUser(),v).then(function(e){return R(e)}).catch(function(e){return l.maybeReportError(e)}))}):y.fetchFlagSettings(D.getUser(),v).then(function(e){b=e||{},z()}).catch(function(e){b={},K(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(function(e){return l.maybeReportError(e)});function q(e){g=e.environment,D.setUser(e.user),b=_objectSpread2({},e.flags),onNextTick(z)}function z(){c.info(clientInitialized()),k=!0,x(),l.emit(readyEvent),l.emit(successEvent)}function K(e){l.maybeReportError(e),l.emit(failedEvent,e),l.emit(readyEvent)}return{client:{waitForInitialization:function(){return A},waitUntilReady:function(){return _},identify:function(e,n,t){return S?wrapPromiseCallback(Promise.resolve({}),t):U?(c.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(b)),t)):wrapPromiseCallback((a&&s?s.clearFlags():Promise.resolve()).then(function(){return P.validateUser(e)}).then(function(e){return D.setUser(e)}).then(function(){return y.fetchFlagSettings(D.getUser(),n)}).then(function(e){var n=transformVersionedValuesToValues(e);return e?R(e).then(function(){return n}):n}).then(function(e){return i&&F(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return D.getUser()},variation:function(e,n){return I(e,n,!0,!1).value},variationDetail:function(e,n){return I(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&c.warn(unknownCustomEventKey(e));var r={kind:"custom",key:e,user:D.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),L(r)}else l.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,n,t){N(e)?(u=!0,k&&x(),l.on(e,n,t)):l.on.apply(l,arguments)},off:function(e){if(l.off.apply(l,arguments),N(e)){var n=!1;l.getEvents().forEach(function(e){N(e)&&0<l.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===E&&T())}},setStreaming:function(e){var n=null===e?void 0:e;n!==E&&(E=n,x())},flush:function(e){return wrapPromiseCallback(d?m.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!b)return e;for(var n in b)b.hasOwnProperty(n)&&(e[n]=I(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(S)return wrapPromiseCallback(Promise.resolve(),e);function n(){S=!0,b={}}return wrapPromiseCallback(Promise.resolve().then(function(){if(T(),d)return m.stop(),m.flush()}).then(n).catch(n),e)}},options:f,emitter:l,ident:D,logger:c,requestor:y,start:function(){d&&m.start()},enqueueEvent:L,getFlagsInternal:function(){return b},getEnvironmentId:function(){return g},internalChangeEventName:internalChangeEvent}}var version="3.0.0-beta2";exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version;
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ownKeys(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function _objectSpread2(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function createCustomError(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var n,t=e.length,r=t%3,o=[],i=16383,a=0,u=t-r;a<u;a+=i)o.push(encodeChunk(e,a,u<a+i?u:a+i));return 1==r?(n=e[t-1],o.push(lookup[n>>2]+lookup[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(lookup[n>>10]+lookup[n>>4&63]+lookup[n<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=isArray(n),u=isArray(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=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=keyList(n);if((o=v.length)!==keyList(t).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var n=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(n))}function stringToBytes(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,n){return fastDeepEqual(e,n)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function transformValuesToVersionedValues(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function getLDUserAgentString(e){var n=e.version||"3.0.0";return e.userAgent+"/"+n}function getLDHeaders(e){return{"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)}}function extend(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return _objectSpread2({},e,{},n)},{})}function sanitizeUser(e){if(!e)return e;var n;for(var t in userAttrsToStringify){var r=userAttrsToStringify[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||_objectSpread2({},e))[r]=String(o))}return n||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,extend:extend,sanitizeUser:sanitizeUser}),MAX_URL_LENGTH=2e3;function EventSender(i,a,e,o){var u=a+"/events/bulk/"+e,s=a+"/a/"+e+".gif",n={};function c(e){(new window.Image).src=e}function l(e,n){var t=o||c,r=JSON.stringify(e);return n?function n(t){var e=extend({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},getLDHeaders(i));return i.httpRequest("POST",u,e,r).promise.then(function(e){if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(t(s+"?d="+base64URLEncode(r)),Promise.resolve())}return n.sendEvents=function(e){if(!i.httpRequest)return Promise.resolve();var n,t=i.httpAllowsPost();n=t?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-a.length,e);for(var r=[],o=0;o<n.length;o++)r.push(l(n[o],t));return Promise.all(r)},n}function EventSummarizer(){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],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}function UserFilter(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,o){return Object.keys(r).reduce(function(e,n){var t=e;return o(n)&&(!function(e){return!l[e]&&(s||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],o=extend({},o,a[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-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/docs/js-sdk-reference#section-analytics-events"},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,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(isHttpErrorRecoverable(e)?t:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,n){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+n+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},wrongOptionTypeBoolean=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},optionBelowMinimum=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},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});function EventProcessor(e,n,t){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i={},a=(4<arguments.length&&void 0!==arguments[4]?arguments[4]:null)||EventSender(e,n.eventsUrl,t),u=EventSummarizer(),s=UserFilter(n),c=n.inlineUsersInEvents,l=n.samplingInterval,f=n.eventCapacity,v=n.flushInterval,d=n.logger,g=[],p=0,m=!1,y=!1;function h(){return 0===l||0===Math.floor(Math.random()*l)}function b(e){g.length<f?(g.push(e),y=!1):y||(y=!0,d.warn(eventCapacityExceeded()))}return i.enqueue=function(e){if(!m){var n=!1,t=!1;if(u.summarizeEvent(e),"feature"===e.kind?h()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>p&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=h(),n&&b(function(e){var n=extend({},e);return c||"identify"===e.kind?n.user=s.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=extend({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,b(r)}}},i.flush=function(){if(m)return Promise.resolve();var e=g,n=u.getSummary();return u.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(g=[],d.debug(debugPostingEvents(e.length)),a.sendEvents(e).then(function(e){e&&(e.serverTime&&(p=e.serverTime),isHttpErrorRecoverable(e.status)||(m=!0),400<=e.status&&onNextTick(function(){o.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},i.start=function(){r=setTimeout(function e(){i.flush(),r=setTimeout(e,v)},v)},i.stop=function(){clearTimeout(r)},i}function EventEmitter(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=0;n<o[e].length;n++)o[e][n].handler.apply(o[e][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")?(n||console).error(e.message):this.emit("error",e))},e}function Store(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||btoa(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=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},u.saveFlags=function(e){var n=extend({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},u}function Stream(o,e,i,a){var u=e.streamUrl,s=e.logger,n={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,t=e.streamReconnectDelay,v=!1,d=null,g=null,p=null,m=null;function y(e){v||(s.warn(streamError(e,t)),v=!0),b(),h(t)}function h(e){g||(e?g=setTimeout(r,e):r())}function r(){var e;g=null;var n="",t={};if(o.eventSourceFactory){for(var r in null!=a&&(n="h="+a),l?o.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers={"Content-Type":"application/json"},t.body=JSON.stringify(p)):(e=u+"/ping/"+i,n=""):e=c+"/"+base64URLEncode(JSON.stringify(p)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,b(),s.info(streamConnecting(e)),d=o.eventSourceFactory(e,t),m)m.hasOwnProperty(r)&&d.addEventListener(r,m[r]);d.onerror=y}}function b(){d&&(s.info(streamClosing()),d.close(),d=null)}return n.connect=function(e,t){p=e,m={};function n(n){m[n]=function(e){v=!1,t[n]&&t[n](e)}}for(var r in t||{})n(r);h()},n.disconnect=function(){clearTimeout(g),g=null,b()},n.isConnected=function(){return!!(d&&o.eventSourceIsActive&&o.eventSourceIsActive(d))},n}function promiseCoalescer(t){var r,o,i,a,e={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){i=e,a=n}),e}var json="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(u,e,a){var s=e.baseUrl,c=e.useReport,l=e.evaluationReasons,f=e.sendLDHeaders,v=e.logger,n={},d={};function g(e,n){if(!u.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var t=n?"REPORT":"GET",r=f?getLDHeaders(u):{};n&&(r["Content-Type"]="application/json");var o=d[e];o||(o=promiseCoalescer(function(){delete d[e]}),d[e]=o);var i=u.httpRequest(t,e,r,n),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(json))return JSON.parse(e.body);var n=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(n))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return n.fetchJSON=function(e){return g(s+e,null)},n.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[s,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=base64URLEncode(JSON.stringify(e)),r=[s,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),l&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(debugPolling(r)),g(r,o)},n}function Identity(e,n){var t,r={};return r.setUser=function(e){(t=sanitizeUser(e))&&n&&n(clone(t))},r.getUser=function(){return t?clone(t):null},e&&r.setUser(e),r}function createCommonjsModule(e,n){return e(n={exports:{}},n.exports),n.exports}for(var rngBrowser=createCommonjsModule(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var t=n||0,r=byteToHex;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var u=rngBrowser();null==i&&(i=_nodeId=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=_clockseq=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=s-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||_lastMSecs<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_clockseq=a;var f=(1e4*(268435455&(s+=122192928e5))+(_lastNSecs=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||bytesToUuid_1(o)}var v1_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 t=clone(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(r?r.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return t.key=e,t;var n=v1_1();return function(e){return r?r.set(ldUserIdKey,e).catch(function(){o.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(t.key=n).then(function(){return t})}):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},sendLDHeaders:{default:!0},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"},stateProvider:{type:"object"}};function validate(e,n,t,r){var a=extend({logger:{default:r}},baseOptionDefs,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var i,s,c,l,f=extend({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=_typeof(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var n=o[e];r&&r.warn(deprecated(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e])}}),s=extend({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=extend({},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(unknownOption(e));else{var r=t.type||v(t.default);if("any"!==r){var o=r.split("|"),i=v(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,u(wrongOptionTypeBoolean(e,i))):(u(wrongOptionType(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(optionBelowMinimum(e,n,t.minimum)),l[e]=t.minimum)}}}}),f=l}function createConsoleLogger(e,n){var o,i=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var a=0;e&&(a="none"===e?100:i.indexOf(e));var t={};function r(e,n,t){if(a<=e){var r=e<i.length?i[e]:"?";n(o+"["+r+"] "+t)}}return t.debug=function(e){return r(0,console.log,e)},t.info=function(e){return r(1,console.info,e)},t.warn=function(e){return r(2,console.warn,e)},t.error=function(e){return r(3,console.error,e)},t}var readyEvent="ready",successEvent="initialized",failedEvent="failed",changeEvent="change",internalChangeEvent="internal-change";function initialize(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||createConsoleLogger("warn")}(),l=EventEmitter(c),f=validate(t,l,r,c),v=f.hash,d=f.sendEvents,g=e,p=Stream(o,f,g,v),m=f.eventProcessor||EventProcessor(o,f,g,l),y=Requestor(o,f,g),h={},b={},E=f.streaming,k=!1,S=!1,w=!0,U=f.stateProvider,D=Identity(null,function(e){if(U)return;e&&L({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),P=UserValidator(o.localStorage,c);function L(e){g&&(U&&U.enqueueEvent&&U.enqueueEvent(e)||(e.user?(w=!1,!d||S||o.isDoNotTrack()||(c.debug(debugEnqueueingEvent(e.kind)),m.enqueue(e))):w&&(c.warn(eventWithoutUser()),w=!1)))}function O(e,n,t,r){var o=D.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=h[u];if(s&&i-s<3e5)return;h[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=b[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),L(c)}function I(e,n,t,r){var o;if(b&&b.hasOwnProperty(e)&&b[e]&&!b[e].deleted){var i=b[e];o=C(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&O(e,o,n,r),o}function C(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function F(){i=!0,D.getUser()&&p.connect(D.getUser(),{ping:function(){c.debug(debugStreamPing()),y.fetchFlagSettings(D.getUser(),v).then(function(e){return R(e||{})}).catch(function(e){l.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);c.debug(debugStreamPut()),R(n)},patch:function(e){var n=JSON.parse(e.data),t=b[n.key];if(!t||!t.version||!n.version||t.version<n.version){c.debug(debugStreamPatch(n.key));var r={},o=extend({},n);delete o.key;var i=C(b[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},j(r)}else c.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!b[n.key]||b[n.key].version<n.version){c.debug(debugStreamDelete(n.key));var t={};b[n.key]&&!b[n.key].deleted&&(t[n.key]={previous:b[n.key].value}),b[n.key]={version:n.version,deleted:!0},j(t)}else c.debug(debugStreamDeleteIgnored(n.key))}})}function T(){i&&(p.disconnect(),i=!1)}function R(e){var n={};if(!e)return Promise.resolve();for(var t in b)b.hasOwnProperty(t)&&b[t]&&(e[t]&&!deepEquals(e[t].value,b[t].value)?n[t]={previous:b[t].value,current:C(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:b[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!b[r]||b[r].deleted)&&(n[r]={current:C(e[r])});return b=_objectSpread2({},e),j(n).catch(function(){})}function j(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;l.emit(changeEvent+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),l.emit(changeEvent,i),l.emit(internalChangeEvent,b),f.sendEventsOnlyForVariation||U||e.forEach(function(e){O(e,o[e].current)})}return a&&s?s.saveFlags(b).catch(function(){return null}):Promise.resolve()}function x(){var e=E||u&&void 0===E;e&&!i?F():!e&&i&&T()}function N(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}o.localStorage&&(s=new Store(o.localStorage,g,v,D,c));var _=new Promise(function(e){var n=l.on(readyEvent,function(){l.off(readyEvent,n),e()})}),A=new Promise(function(e,n){var t=l.on(successEvent,function(){l.off(successEvent,t),e()}),r=l.on(failedEvent,function(e){l.off(failedEvent,r),n(e)})});if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(s?a=!0:c.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(b=function(t){var e=Object.keys(t),r="$flagsState",o=t[r];!o&&e.length&&c.warn(bootstrapOldFormat()),!1===t.$valid&&c.warn(bootstrapInvalid());var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};o&&o[e]?n=extend(n,o[e]):n.version=0,i[e]=n}}),i}(f.bootstrap)),U){var V=U.getInitialState();V?q(V):U.on("init",q),U.on("update",function(e){e.user&&D.setUser(e.user);e.flags&&R(e.flags)})}else(e?P.validateUser(n).then(function(e){return D.setUser(e),"object"===_typeof(f.bootstrap)?z():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(b={},y.fetchFlagSettings(D.getUser(),v).then(function(e){return R(e||{})}).then(z).catch(function(e){K(new LDFlagFetchError(errorFetchingFlags(e)))})):(b=e,onNextTick(z),y.fetchFlagSettings(D.getUser(),v).then(function(e){return R(e)}).catch(function(e){return l.maybeReportError(e)}))}):y.fetchFlagSettings(D.getUser(),v).then(function(e){b=e||{},z()}).catch(function(e){b={},K(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(function(e){return l.maybeReportError(e)});function q(e){g=e.environment,D.setUser(e.user),b=_objectSpread2({},e.flags),onNextTick(z)}function z(){c.info(clientInitialized()),k=!0,x(),l.emit(readyEvent),l.emit(successEvent)}function K(e){l.maybeReportError(e),l.emit(failedEvent,e),l.emit(readyEvent)}return{client:{waitForInitialization:function(){return A},waitUntilReady:function(){return _},identify:function(e,n,t){return S?wrapPromiseCallback(Promise.resolve({}),t):U?(c.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(b)),t)):wrapPromiseCallback((a&&s?s.clearFlags():Promise.resolve()).then(function(){return P.validateUser(e)}).then(function(e){return D.setUser(e)}).then(function(){return y.fetchFlagSettings(D.getUser(),n)}).then(function(e){var n=transformVersionedValuesToValues(e);return e?R(e).then(function(){return n}):n}).then(function(e){return i&&F(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return D.getUser()},variation:function(e,n){return I(e,n,!0,!1).value},variationDetail:function(e,n){return I(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&c.warn(unknownCustomEventKey(e));var r={kind:"custom",key:e,user:D.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),L(r)}else l.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,n,t){N(e)?(u=!0,k&&x(),l.on(e,n,t)):l.on.apply(l,arguments)},off:function(e){if(l.off.apply(l,arguments),N(e)){var n=!1;l.getEvents().forEach(function(e){N(e)&&0<l.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===E&&T())}},setStreaming:function(e){var n=null===e?void 0:e;n!==E&&(E=n,x())},flush:function(e){return wrapPromiseCallback(d?m.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!b)return e;for(var n in b)b.hasOwnProperty(n)&&(e[n]=I(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(S)return wrapPromiseCallback(Promise.resolve(),e);function n(){S=!0,b={}}return wrapPromiseCallback(Promise.resolve().then(function(){if(T(),d)return m.stop(),m.flush()}).then(n).catch(n),e)}},options:f,emitter:l,ident:D,logger:c,requestor:y,start:function(){d&&m.start()},enqueueEvent:L,getFlagsInternal:function(){return b},getEnvironmentId:function(){return g},internalChangeEventName:internalChangeEvent}}var version="3.0.0";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 o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),s=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:c,LDInvalidArgumentError:s,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,i+16383>a?a:i+16383));1===r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"="));return o.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,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,O=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var c=n instanceof Date,s=t instanceof Date;if(c!=s)return!1;if(c&&s)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((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},P=["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 D(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return O(e,n)}function R(e){setTimeout(e,0)}function N(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 I(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function F(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function C(e){var n=e.version||"3.0.0-beta2";return e.userAgent+"/"+n}function A(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":C(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}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){if(!e)return e;var n;for(var t in P){var o=P[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}var q=Object.freeze({__proto__:null,btoa:S,base64URLEncode:D,clone:U,deepEquals:j,onNextTick:R,wrapPromiseCallback:N,transformValuesToVersionedValues:I,transformVersionedValuesToValues:T,chunkUserEventsForUrl:F,getLDUserAgentString:C,getLDHeaders:A,extend:L,sanitizeUser:x}),V=2e3;function _(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a=e.httpFallbackPing,u={};function c(n,t){var u=JSON.stringify(n);return t?function n(t){var i=L({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},A(e,r));return e.httpRequest("POST",o,i,u).promise.then((function(e){if(e)return e.status>=400&&f(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(){})):(a&&a(i+"?d="+D(u)),Promise.resolve())}return u.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:F(V-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(c(r[a],o));return Promise.all(i)},u}function J(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce((function(a,u){var c=a;return i(u)&&(!function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?c[0][u]=e[u]:c[1][u]=!0),c}),[{},{}])},u=a(e,(function(e){return i[e]})),c=u[0],s=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));c.custom=l[0],s=L({},s,l[1])}var f=Object.keys(s);return f.length&&(f.sort(),c.privateAttrs=f),c},n}function z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var K=function(){return"LaunchDarkly client initialized"},$=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",M=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},H=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},B=function(e){return'Expected application/json content type but got "'+e+'"'},G=function(){return"localStorage is unavailable"},X=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},W=function(e){return"network error"+(e?" ("+e+")":"")},Q=function(e){return'Custom event "'+e+'" does not exist'},Y=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},Z=function(){return"No environment/client-side ID was specified."+$},ee=function(e){return"Error fetching flag settings: "+z(e)},ne=function(){return"No user specified."+$},te=function(){return"Invalid user specified."+$},re=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."},ie=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ae=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ue=function(){return"Cannot make HTTP requests in this environment."+$},ce=function(){return"identify() has no effect here; it must be called on the main client instance"},se=function(){return"Closing stream connection"},le=function(e){return"Opening stream connection to "+e},fe=function(e,n){return"Error on stream connection: "+z(e)+", will continue retrying every "+n+" milliseconds."},ve=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"},ge=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},pe=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},me=function(e){return"polling for feature flags at "+e},ye=function(){return"received ping message from stream"},he=function(){return"received streaming update for all flags"},be=function(e){return'received streaming update for flag "'+e+'"'},ke=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Ee=function(e){return'received streaming deletion for flag "'+e+'"'},we=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Oe=function(e){return'enqueueing "'+e+'" event'},Pe=function(e){return"sending "+e+" events"},Se=Object.freeze({__proto__:null,clientInitialized:K,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:M,eventWithoutUser:H,invalidContentType:B,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:G,localStorageUnavailableForUserId:X,networkError:W,unknownCustomEventKey:Q,environmentNotFound:Y,environmentNotSpecified:Z,errorFetchingFlags:ee,userNotSpecified:ne,invalidUser:te,bootstrapOldFormat:re,bootstrapInvalid:oe,deprecated:ie,httpErrorMessage:ae,httpUnavailable:ue,identifyDisabled:ce,streamClosing:se,streamConnecting:le,streamError:fe,unknownOption:ve,wrongOptionType:de,wrongOptionTypeBoolean:ge,optionBelowMinimum:pe,debugPolling:me,debugStreamPing:ye,debugStreamPut:he,debugStreamPatch:be,debugStreamPatchIgnored:ke,debugStreamDelete:Ee,debugStreamDeleteIgnored:we,debugEnqueueingEvent:Oe,debugPostingEvents:Pe});function De(e,n,t){var r,o,a,u,c,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,v={},d=l||_(e,n.eventsUrl,t,n),g=(o=0,a=0,u={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===o||e.creationDate<o)&&(o=e.creationDate),e.creationDate>a&&(a=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var c={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(c.variation=r.variation),r.version?c.version=r.version:c.unknown=!0,i.counters.push(c),n=!1}return n?null:{startDate:o,endDate:a,features:e}},r.clearSummary=function(){o=0,a=0,u={}},r),p=J(n),m=n.inlineUsersInEvents,y=n.samplingInterval,h=n.eventCapacity,b=n.flushInterval,k=n.logger,E=[],w=0,O=!1,P=!1;function S(){return 0===y||0===Math.floor(Math.random()*y)}function D(e){E.length<h?(E.push(e),P=!1):P||(P=!0,k.warn(M()))}return v.enqueue=function(e){if(!O){var n,t=!1,r=!1;if(g.summarizeEvent(e),"feature"===e.kind?S()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>w&&n.debugEventsUntilDate>(new Date).getTime()):t=S(),t&&D(function(e){var n=L({},e);return m||"identify"===e.kind?n.user=p.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=L({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,D(o)}}},v.flush=function(){if(O)return Promise.resolve();var e=E,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(E=[],k.debug(Pe(e.length)),d.sendEvents(e).then((function(e){e&&(e.serverTime&&(w=e.serverTime),f(e.status)||(O=!0),e.status>=400&&R((function(){s.maybeReportError(new i(ae(e.status,"event posting","some events were dropped")))})))})))},v.start=function(){c=setTimeout((function e(){v.flush(),c=setTimeout(e,b)}),b)},v.stop=function(){clearTimeout(c)},v}function Ue(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 o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].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}function je(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||S(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).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=I(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return o.warn(G()),Promise.reject(e)}))},i.saveFlags=function(n){var t=L({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch((function(e){return o.warn(G()),Promise.reject(e)}))},i.clearFlags=function(){return e.clear(a()).catch((function(e){return o.warn(G()),Promise.reject(e)}))},i}var Re="application/json";function Ne(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.logger,c={},s={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(ue()))}));var o=r?"REPORT":"GET",i=A(e,n);r&&(i["Content-Type"]="application/json");var u=s[t];u||(u=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then((function(t){n===i&&(r(t),e&&e())}),(function(t){n===i&&(o(t),e&&e())}))}};return i.resultPromise=new Promise((function(e,n){r=e,o=n})),i}((function(){delete s[t]})),s[t]=u);var c=e.httpRequest(o,t,i,r),f=c.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Re))return JSON.parse(e.body);var n=B(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(Y()):new l(ee(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(W(e)))}));return u.addPromise(f,(function(){c.cancel&&c.cancel()})),u.resultPromise}return c.fetchJSON=function(e){return f(r+e,null)},c.fetchFlagSettings=function(e,n){var a,c,s,l="";return o?(c=[r,"/sdk/evalx/",t,"/user"].join(""),s=JSON.stringify(e)):(a=D(JSON.stringify(e)),c=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),c=c+(l?"?":"")+l,u.debug(me(c)),f(c,s)},c}for(var Ie=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}}})),Te=[],Fe=0;Fe<256;++Fe)Te[Fe]=(Fe+256).toString(16).substr(1);var Ce,Ae,Le=function(e,n){var t=n||0,r=Te;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("")},xe=0,qe=0;var Ve=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ce,a=void 0!==e.clockseq?e.clockseq:Ae;if(null==i||null==a){var u=Ie();null==i&&(i=Ce=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Ae=16383&(u[6]<<8|u[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:qe+1,l=c-xe+(s-qe)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>xe)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");xe=c,qe=s,Ae=a;var f=(1e4*(268435455&(c+=122192928e5))+s)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=c/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||Le(o)},_e="ld:$anonUserId";function Je(e,n){var t={};return t.validateUser=function(t){if(!t)return Promise.reject(new u(ne()));var r=U(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(_e).catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var o=Ve();return r.key=o,function(t){return e?e.set(_e,t).catch((function(){n.warn(X())})):Promise.resolve()}(o).then((function(){return r}))})):Promise.reject(new u(te()))},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},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"},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Ke(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<r.length?r[e]:"?";n(t+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var $e="ready",Me="initialized",He="failed",Be="change",Ge="internal-change";function Xe(n,t,o,i,u){var f,v,d,g,p=function(){if(o&&o.logger)return o.logger;return u&&u.logger&&u.logger.default||Ke("warn")}(),m=Ue(p),y=function(n,t,r,o){var i=L({logger:{default:o}},ze,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){R((function(){t&&t.maybeReportError(new s(e))}))}var c=L({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];o&&o.warn(ie(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(c),c=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 o=n[e];if(null!=o){var a=i[e];if(void 0===a)u(ve(e));else{var c=a.type||r(a.default);if("any"!==c){var s=c.split("|"),l=r(o);s.indexOf(l)<0?"boolean"===c?(t[e]=!!o,u(ge(e,l))):(u(de(e,c,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&o<a.minimum&&(u(pe(e,o,a.minimum)),t[e]=a.minimum)}}}})),t}(c=function(e){var n=L({},e);return Object.keys(i).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=i[e]&&i[e].default)})),n}(c))}(o,m,u,p),h=y.hash,b=y.sendEvents,k=n,E=function(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,c=n.useReport,s=n.evaluationReasons,l=n.streamReconnectDelay,f=A(e,n),v=!1,d=null,g=null,p=null,m=null;function y(e){v||(i.warn(fe(e,l)),v=!0),k(),h(l)}function h(e){g||(e?g=setTimeout(b,e):b())}function b(){var n;g=null;var a="",l={headers:f};if(e.eventSourceFactory){for(var v in null!=r&&(a="h="+r),c?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(p)):(n=o+"/ping/"+t,a=""):n=u+"/"+D(JSON.stringify(p)),s&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,k(),i.info(le(n)),d=e.eventSourceFactory(n,l),m)m.hasOwnProperty(v)&&d.addEventListener(v,m[v]);d.onerror=y}}function k(){d&&(i.info(se()),d.close(),d=null)}return a.connect=function(e,n){p=e,m={};var t=function(e){m[e]=function(t){v=!1,n[e]&&n[e](t)}};for(var r in n||{})t(r);h()},a.disconnect=function(){clearTimeout(g),g=null,k()},a.isConnected=function(){return!!(d&&e.eventSourceIsActive&&e.eventSourceIsActive(d))},a}(i,y,k,h),w=y.eventProcessor||De(i,y,k,m),O=Ne(i,y,k),P={},S={},I=y.streaming,F=!1,C=!1,q=!0,V=y.stateProvider,_=function(e,n){var t,r={};return r.setUser=function(e){(t=x(e))&&n&&n(U(t))},r.getUser=function(){return t?U(t):null},e&&r.setUser(e),r}(null,(function(e){if(V)return;e&&z({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),J=Je(i.localStorage,p);function z(e){k&&(V&&V.enqueueEvent&&V.enqueueEvent(e)||(e.user?(q=!1,!b||C||i.isDoNotTrack()||(p.debug(Oe(e.kind)),w.enqueue(e))):q&&(p.warn(H()),q=!1)))}function $(e,n,t,r){var o=_.getUser(),i=new Date,a=n?n.value:null;if(!y.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,c=P[u];if(c&&i-c<3e5)return;P[u]=i}var s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=S[e];l&&(s.version=l.flagVersion?l.flagVersion:l.version,s.trackEvents=l.trackEvents,s.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(s.reason=n.reason),z(s)}function M(e,n,t,r){var o;if(S&&S.hasOwnProperty(e)&&S[e]&&!S[e].deleted){var i=S[e];o=B(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&$(e,o,n,r),o}function B(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function X(){v=!0,_.getUser()&&E.connect(_.getUser(),{ping:function(){p.debug(ye()),O.fetchFlagSettings(_.getUser(),h).then((function(e){return Y(e||{})})).catch((function(e){m.maybeReportError(new l(ee(e)))}))},put:function(e){var n=JSON.parse(e.data);p.debug(he()),Y(n)},patch:function(e){var n=JSON.parse(e.data),t=S[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(be(n.key));var r={},o=L({},n);delete o.key,S[n.key]=o;var i=B(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ne(r)}else p.debug(ke(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!S[n.key]||S[n.key].version<n.version){p.debug(Ee(n.key));var t={};S[n.key]&&!S[n.key].deleted&&(t[n.key]={previous:S[n.key].value}),S[n.key]={version:n.version,deleted:!0},ne(t)}else p.debug(we(n.key))}})}function W(){v&&(E.disconnect(),v=!1)}function Y(e){var n={};if(!e)return Promise.resolve();for(var t in S)S.hasOwnProperty(t)&&S[t]&&(e[t]&&!j(e[t].value,S[t].value)?n[t]={previous:S[t].value,current:B(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:S[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!S[o]||S[o].deleted)&&(n[o]={current:B(e[o])});return S=r({},e),ne(n).catch((function(){}))}function ne(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;m.emit(Be+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),m.emit(Be,t),m.emit(Ge,S),y.sendEventsOnlyForVariation||V||n.forEach((function(n){$(n,e[n].current)}))}return f&&g?g.saveFlags(S).catch((function(){return null})):Promise.resolve()}function te(){var e=I||d&&void 0===I;e&&!v?X():!e&&v&&W()}function ae(e){return e===Be||e.substr(0,Be.length+1)===Be+":"}i.localStorage&&(g=new je(i.localStorage,k,h,_,p));var ue=new Promise((function(e){var n=m.on($e,(function(){m.off($e,n),e()}))})),me=new Promise((function(e,n){var t=m.on(Me,(function(){m.off(Me,t),e()})),r=m.on(He,(function(e){m.off(He,r),n(e)}))}));if("string"==typeof y.bootstrap&&"LOCALSTORAGE"===y.bootstrap.toUpperCase()&&(g?f=!0:p.warn(G())),"object"===e(y.bootstrap)&&(S=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(re()),!1===e.$valid&&p.warn(oe());var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=L(o,t[n]):o.version=0,r[n]=o}})),r}(y.bootstrap)),V){var Pe=V.getInitialState();Pe?Se(Pe):V.on("init",Se),V.on("update",(function(e){e.user&&_.setUser(e.user);e.flags&&Y(e.flags)}))}else(function(){if(!n)return Promise.reject(new a(Z()));return J.validateUser(t).then((function(n){return _.setUser(n),"object"===e(y.bootstrap)?Re():f?g.loadFlags().catch((function(){return null})).then((function(e){return null==e?(S={},O.fetchFlagSettings(_.getUser(),h).then((function(e){return Y(e||{})})).then(Re).catch((function(e){Ie(new l(ee(e)))}))):(S=e,R(Re),O.fetchFlagSettings(_.getUser(),h).then((function(e){return Y(e)})).catch((function(e){return m.maybeReportError(e)})))})):O.fetchFlagSettings(_.getUser(),h).then((function(e){S=e||{},Re()})).catch((function(e){S={},Ie(e)}))}))})().catch((function(e){return m.maybeReportError(e)}));function Se(e){k=e.environment,_.setUser(e.user),S=r({},e.flags),R(Re)}function Re(){p.info(K()),F=!0,te(),m.emit($e),m.emit(Me)}function Ie(e){m.maybeReportError(e),m.emit(He,e),m.emit($e)}return{client:{waitForInitialization:function(){return me},waitUntilReady:function(){return ue},identify:function(e,n,t){return C?N(Promise.resolve({}),t):V?(p.warn(ce()),N(Promise.resolve(T(S)),t)):N((f&&g?g.clearFlags():Promise.resolve()).then((function(){return J.validateUser(e)})).then((function(e){return _.setUser(e)})).then((function(){return O.fetchFlagSettings(_.getUser(),n)})).then((function(e){var n=T(e);return e?Y(e).then((function(){return n})):n})).then((function(e){return v&&X(),e})).catch((function(e){return m.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return _.getUser()},variation:function(e,n){return M(e,n,!0,!1).value},variationDetail:function(e,n){return M(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&p.warn(Q(e));var r={kind:"custom",key:e,user:_.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),z(r)}else m.maybeReportError(new c(Q(e)))},on:function(e,n,t){ae(e)?(d=!0,F&&te(),m.on(e,n,t)):m.on.apply(m,arguments)},off:function(e){if(m.off.apply(m,arguments),ae(e)){var n=!1;m.getEvents().forEach((function(e){ae(e)&&m.getEventListenerCount(e)>0&&(n=!0)})),n||(d=!1,v&&void 0===I&&W())}},setStreaming:function(e){var n=null===e?void 0:e;n!==I&&(I=n,te())},flush:function(e){return N(b?w.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!S)return e;for(var n in S)S.hasOwnProperty(n)&&(e[n]=M(n,null,!y.sendEventsOnlyForVariation).value);return e},close:function(e){if(C)return N(Promise.resolve(),e);var n=function(){C=!0,S={}};return N(Promise.resolve().then((function(){if(W(),b)return w.stop(),w.flush()})).then(n).catch(n),e)}},options:y,emitter:m,ident:_,logger:p,requestor:O,start:function(){b&&w.start()},enqueueEvent:z,getFlagsInternal:function(){return S},getEnvironmentId:function(){return k},internalChangeEventName:Ge}}var We="3.0.0-beta2";export{Ke as createConsoleLogger,v as errors,Xe as initialize,Se as messages,q as utils,We 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 o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),s=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:c,LDInvalidArgumentError:s,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,i+16383>a?a:i+16383));1===r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"="));return o.join("")},g=[],m=[],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,h=p.length;y<h;++y)g[y]=p[y],m[p.charCodeAt(y)]=y;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,O=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var c=n instanceof Date,s=t instanceof Date;if(c!=s)return!1;if(c&&s)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((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},S=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function P(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 D(e){return P(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return O(e,n)}function R(e){setTimeout(e,0)}function I(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 T(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function C(e){var n=e.version||"3.0.0";return e.userAgent+"/"+n}function A(e){return{"X-LaunchDarkly-User-Agent":C(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){if(!e)return e;var n;for(var t in S){var o=S[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}var q=Object.freeze({__proto__:null,btoa:P,base64URLEncode:D,clone:U,deepEquals:j,onNextTick:R,wrapPromiseCallback:I,transformValuesToVersionedValues:T,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:C,getLDHeaders:A,extend:L,sanitizeUser:x}),_=2e3;function J(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a={};function u(e){(new window.Image).src=e}function c(n,t){var a=r||u,c=JSON.stringify(n);return t?function n(t){var r=L({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},A(e));return e.httpRequest("POST",o,r,c).promise.then((function(e){if(e)return e.status>=400&&f(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(){})):(a(i+"?d="+D(c)),Promise.resolve())}return a.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:N(_-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(c(r[a],o));return Promise.all(i)},a}function V(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce((function(a,u){var c=a;return i(u)&&(!function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?c[0][u]=e[u]:c[1][u]=!0),c}),[{},{}])},u=a(e,(function(e){return i[e]})),c=u[0],s=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));c.custom=l[0],s=L({},s,l[1])}var f=Object.keys(s);return f.length&&(f.sort(),c.privateAttrs=f),c},n}function z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var K=function(){return"LaunchDarkly client initialized"},$=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",M=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},H=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},B=function(e){return'Expected application/json content type but got "'+e+'"'},G=function(){return"localStorage is unavailable"},X=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},W=function(e){return"network error"+(e?" ("+e+")":"")},Q=function(e){return'Custom event "'+e+'" does not exist'},Y=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},Z=function(){return"No environment/client-side ID was specified."+$},ee=function(e){return"Error fetching flag settings: "+z(e)},ne=function(){return"No user specified."+$},te=function(){return"Invalid user specified."+$},re=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."},ie=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ae=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ue=function(){return"Cannot make HTTP requests in this environment."+$},ce=function(){return"identify() has no effect here; it must be called on the main client instance"},se=function(){return"Closing stream connection"},le=function(e){return"Opening stream connection to "+e},fe=function(e,n){return"Error on stream connection: "+z(e)+", will continue retrying every "+n+" milliseconds."},ve=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"},ge=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},me=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},ye=function(){return"received ping message from stream"},he=function(){return"received streaming update for all flags"},be=function(e){return'received streaming update for flag "'+e+'"'},ke=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Ee=function(e){return'received streaming deletion for flag "'+e+'"'},we=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Oe=function(e){return'enqueueing "'+e+'" event'},Se=function(e){return"sending "+e+" events"},Pe=Object.freeze({__proto__:null,clientInitialized:K,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:M,eventWithoutUser:H,invalidContentType:B,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:G,localStorageUnavailableForUserId:X,networkError:W,unknownCustomEventKey:Q,environmentNotFound:Y,environmentNotSpecified:Z,errorFetchingFlags:ee,userNotSpecified:ne,invalidUser:te,bootstrapOldFormat:re,bootstrapInvalid:oe,deprecated:ie,httpErrorMessage:ae,httpUnavailable:ue,identifyDisabled:ce,streamClosing:se,streamConnecting:le,streamError:fe,unknownOption:ve,wrongOptionType:de,wrongOptionTypeBoolean:ge,optionBelowMinimum:me,debugPolling:pe,debugStreamPing:ye,debugStreamPut:he,debugStreamPatch:be,debugStreamPatchIgnored:ke,debugStreamDelete:Ee,debugStreamDeleteIgnored:we,debugEnqueueingEvent:Oe,debugPostingEvents:Se});function De(e,n,t){var r,o,a,u,c,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,v={},d=l||J(e,n.eventsUrl,t),g=(o=0,a=0,u={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===o||e.creationDate<o)&&(o=e.creationDate),e.creationDate>a&&(a=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var c={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(c.variation=r.variation),r.version?c.version=r.version:c.unknown=!0,i.counters.push(c),n=!1}return n?null:{startDate:o,endDate:a,features:e}},r.clearSummary=function(){o=0,a=0,u={}},r),m=V(n),p=n.inlineUsersInEvents,y=n.samplingInterval,h=n.eventCapacity,b=n.flushInterval,k=n.logger,E=[],w=0,O=!1,S=!1;function P(){return 0===y||0===Math.floor(Math.random()*y)}function D(e){E.length<h?(E.push(e),S=!1):S||(S=!0,k.warn(M()))}return v.enqueue=function(e){if(!O){var n,t=!1,r=!1;if(g.summarizeEvent(e),"feature"===e.kind?P()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>w&&n.debugEventsUntilDate>(new Date).getTime()):t=P(),t&&D(function(e){var n=L({},e);return p||"identify"===e.kind?n.user=m.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=L({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,D(o)}}},v.flush=function(){if(O)return Promise.resolve();var e=E,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(E=[],k.debug(Se(e.length)),d.sendEvents(e).then((function(e){e&&(e.serverTime&&(w=e.serverTime),f(e.status)||(O=!0),e.status>=400&&R((function(){s.maybeReportError(new i(ae(e.status,"event posting","some events were dropped")))})))})))},v.start=function(){c=setTimeout((function e(){v.flush(),c=setTimeout(e,b)}),b)},v.stop=function(){clearTimeout(c)},v}function Ue(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 o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].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}function je(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||P(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).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=T(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return o.warn(G()),Promise.reject(e)}))},i.saveFlags=function(n){var t=L({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch((function(e){return o.warn(G()),Promise.reject(e)}))},i.clearFlags=function(){return e.clear(a()).catch((function(e){return o.warn(G()),Promise.reject(e)}))},i}var Re="application/json";function Ie(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.sendLDHeaders,c=n.logger,s={},f={};function v(n,t){if(!e.httpRequest)return new Promise((function(e,n){n(new l(ue()))}));var r=t?"REPORT":"GET",o=u?A(e):{};t&&(o["Content-Type"]="application/json");var i=f[n];i||(i=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then((function(t){n===i&&(r(t),e&&e())}),(function(t){n===i&&(o(t),e&&e())}))}};return i.resultPromise=new Promise((function(e,n){r=e,o=n})),i}((function(){delete f[n]})),f[n]=i);var c=e.httpRequest(r,n,o,t),s=c.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Re))return JSON.parse(e.body);var n=B(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(Y()):new l(ee(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(W(e)))}));return i.addPromise(s,(function(){c.cancel&&c.cancel()})),i.resultPromise}return s.fetchJSON=function(e){return v(r+e,null)},s.fetchFlagSettings=function(e,n){var a,u,s,l="";return o?(u=[r,"/sdk/evalx/",t,"/user"].join(""),s=JSON.stringify(e)):(a=D(JSON.stringify(e)),u=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),u=u+(l?"?":"")+l,c.debug(pe(u)),v(u,s)},s}for(var Te=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}}})),Fe=[],Ne=0;Ne<256;++Ne)Fe[Ne]=(Ne+256).toString(16).substr(1);var Ce,Ae,Le=function(e,n){var t=n||0,r=Fe;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("")},xe=0,qe=0;var _e=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ce,a=void 0!==e.clockseq?e.clockseq:Ae;if(null==i||null==a){var u=Te();null==i&&(i=Ce=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Ae=16383&(u[6]<<8|u[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:qe+1,l=c-xe+(s-qe)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>xe)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");xe=c,qe=s,Ae=a;var f=(1e4*(268435455&(c+=122192928e5))+s)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=c/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||Le(o)},Je="ld:$anonUserId";function Ve(e,n){var t={};return t.validateUser=function(t){if(!t)return Promise.reject(new u(ne()));var r=U(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(Je).catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var o=_e();return r.key=o,function(t){return e?e.set(Je,t).catch((function(){n.warn(X())})):Promise.resolve()}(o).then((function(){return r}))})):Promise.reject(new u(te()))},t}var ze={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},sendLDHeaders:{default:!0},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"},stateProvider:{type:"object"}};function Ke(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<r.length?r[e]:"?";n(t+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var $e="ready",Me="initialized",He="failed",Be="change",Ge="internal-change";function Xe(n,t,o,i,u){var f,v,d,g,m=function(){if(o&&o.logger)return o.logger;return u&&u.logger&&u.logger.default||Ke("warn")}(),p=Ue(m),y=function(n,t,r,o){var i=L({logger:{default:o}},ze,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){R((function(){t&&t.maybeReportError(new s(e))}))}var c=L({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];o&&o.warn(ie(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(c),c=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 o=n[e];if(null!=o){var a=i[e];if(void 0===a)u(ve(e));else{var c=a.type||r(a.default);if("any"!==c){var s=c.split("|"),l=r(o);s.indexOf(l)<0?"boolean"===c?(t[e]=!!o,u(ge(e,l))):(u(de(e,c,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&o<a.minimum&&(u(me(e,o,a.minimum)),t[e]=a.minimum)}}}})),t}(c=function(e){var n=L({},e);return Object.keys(i).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=i[e]&&i[e].default)})),n}(c))}(o,p,u,m),h=y.hash,b=y.sendEvents,k=n,E=function(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,c=n.useReport,s=n.evaluationReasons,l=n.streamReconnectDelay,f=!1,v=null,d=null,g=null,m=null;function p(e){f||(i.warn(fe(e,l)),f=!0),b(),y(l)}function y(e){d||(e?d=setTimeout(h,e):h())}function h(){var n;d=null;var a="",l={};if(e.eventSourceFactory){for(var f in null!=r&&(a="h="+r),c?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(g)):(n=o+"/ping/"+t,a=""):n=u+"/"+D(JSON.stringify(g)),s&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,b(),i.info(le(n)),v=e.eventSourceFactory(n,l),m)m.hasOwnProperty(f)&&v.addEventListener(f,m[f]);v.onerror=p}}function b(){v&&(i.info(se()),v.close(),v=null)}return a.connect=function(e,n){g=e,m={};var t=function(e){m[e]=function(t){f=!1,n[e]&&n[e](t)}};for(var r in n||{})t(r);y()},a.disconnect=function(){clearTimeout(d),d=null,b()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}(i,y,k,h),w=y.eventProcessor||De(i,y,k,p),O=Ie(i,y,k),S={},P={},T=y.streaming,N=!1,C=!1,A=!0,q=y.stateProvider,_=function(e,n){var t,r={};return r.setUser=function(e){(t=x(e))&&n&&n(U(t))},r.getUser=function(){return t?U(t):null},e&&r.setUser(e),r}(null,(function(e){if(q)return;e&&V({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),J=Ve(i.localStorage,m);function V(e){k&&(q&&q.enqueueEvent&&q.enqueueEvent(e)||(e.user?(A=!1,!b||C||i.isDoNotTrack()||(m.debug(Oe(e.kind)),w.enqueue(e))):A&&(m.warn(H()),A=!1)))}function z(e,n,t,r){var o=_.getUser(),i=new Date,a=n?n.value:null;if(!y.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,c=S[u];if(c&&i-c<3e5)return;S[u]=i}var s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=P[e];l&&(s.version=l.flagVersion?l.flagVersion:l.version,s.trackEvents=l.trackEvents,s.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(s.reason=n.reason),V(s)}function $(e,n,t,r){var o;if(P&&P.hasOwnProperty(e)&&P[e]&&!P[e].deleted){var i=P[e];o=M(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&z(e,o,n,r),o}function M(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function B(){v=!0,_.getUser()&&E.connect(_.getUser(),{ping:function(){m.debug(ye()),O.fetchFlagSettings(_.getUser(),h).then((function(e){return W(e||{})})).catch((function(e){p.maybeReportError(new l(ee(e)))}))},put:function(e){var n=JSON.parse(e.data);m.debug(he()),W(n)},patch:function(e){var n=JSON.parse(e.data),t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){m.debug(be(n.key));var r={},o=L({},n);delete o.key,P[n.key]=o;var i=M(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},Y(r)}else m.debug(ke(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!P[n.key]||P[n.key].version<n.version){m.debug(Ee(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},Y(t)}else m.debug(we(n.key))}})}function X(){v&&(E.disconnect(),v=!1)}function W(e){var n={};if(!e)return Promise.resolve();for(var t in P)P.hasOwnProperty(t)&&P[t]&&(e[t]&&!j(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:M(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!P[o]||P[o].deleted)&&(n[o]={current:M(e[o])});return P=r({},e),Y(n).catch((function(){}))}function Y(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;p.emit(Be+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),p.emit(Be,t),p.emit(Ge,P),y.sendEventsOnlyForVariation||q||n.forEach((function(n){z(n,e[n].current)}))}return f&&g?g.saveFlags(P).catch((function(){return null})):Promise.resolve()}function ne(){var e=T||d&&void 0===T;e&&!v?B():!e&&v&&X()}function te(e){return e===Be||e.substr(0,Be.length+1)===Be+":"}i.localStorage&&(g=new je(i.localStorage,k,h,_,m));var ae=new Promise((function(e){var n=p.on($e,(function(){p.off($e,n),e()}))})),ue=new Promise((function(e,n){var t=p.on(Me,(function(){p.off(Me,t),e()})),r=p.on(He,(function(e){p.off(He,r),n(e)}))}));if("string"==typeof y.bootstrap&&"LOCALSTORAGE"===y.bootstrap.toUpperCase()&&(g?f=!0:m.warn(G())),"object"===e(y.bootstrap)&&(P=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(re()),!1===e.$valid&&m.warn(oe());var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=L(o,t[n]):o.version=0,r[n]=o}})),r}(y.bootstrap)),q){var pe=q.getInitialState();pe?Se(pe):q.on("init",Se),q.on("update",(function(e){e.user&&_.setUser(e.user);e.flags&&W(e.flags)}))}else(function(){if(!n)return Promise.reject(new a(Z()));return J.validateUser(t).then((function(n){return _.setUser(n),"object"===e(y.bootstrap)?Pe():f?g.loadFlags().catch((function(){return null})).then((function(e){return null==e?(P={},O.fetchFlagSettings(_.getUser(),h).then((function(e){return W(e||{})})).then(Pe).catch((function(e){Re(new l(ee(e)))}))):(P=e,R(Pe),O.fetchFlagSettings(_.getUser(),h).then((function(e){return W(e)})).catch((function(e){return p.maybeReportError(e)})))})):O.fetchFlagSettings(_.getUser(),h).then((function(e){P=e||{},Pe()})).catch((function(e){P={},Re(e)}))}))})().catch((function(e){return p.maybeReportError(e)}));function Se(e){k=e.environment,_.setUser(e.user),P=r({},e.flags),R(Pe)}function Pe(){m.info(K()),N=!0,ne(),p.emit($e),p.emit(Me)}function Re(e){p.maybeReportError(e),p.emit(He,e),p.emit($e)}return{client:{waitForInitialization:function(){return ue},waitUntilReady:function(){return ae},identify:function(e,n,t){return C?I(Promise.resolve({}),t):q?(m.warn(ce()),I(Promise.resolve(F(P)),t)):I((f&&g?g.clearFlags():Promise.resolve()).then((function(){return J.validateUser(e)})).then((function(e){return _.setUser(e)})).then((function(){return O.fetchFlagSettings(_.getUser(),n)})).then((function(e){var n=F(e);return e?W(e).then((function(){return n})):n})).then((function(e){return v&&B(),e})).catch((function(e){return p.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return _.getUser()},variation:function(e,n){return $(e,n,!0,!1).value},variationDetail:function(e,n){return $(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&m.warn(Q(e));var r={kind:"custom",key:e,user:_.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),V(r)}else p.maybeReportError(new c(Q(e)))},on:function(e,n,t){te(e)?(d=!0,N&&ne(),p.on(e,n,t)):p.on.apply(p,arguments)},off:function(e){if(p.off.apply(p,arguments),te(e)){var n=!1;p.getEvents().forEach((function(e){te(e)&&p.getEventListenerCount(e)>0&&(n=!0)})),n||(d=!1,v&&void 0===T&&X())}},setStreaming:function(e){var n=null===e?void 0:e;n!==T&&(T=n,ne())},flush:function(e){return I(b?w.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)P.hasOwnProperty(n)&&(e[n]=$(n,null,!y.sendEventsOnlyForVariation).value);return e},close:function(e){if(C)return I(Promise.resolve(),e);var n=function(){C=!0,P={}};return I(Promise.resolve().then((function(){if(X(),b)return w.stop(),w.flush()})).then(n).catch(n),e)}},options:y,emitter:p,ident:_,logger:m,requestor:O,start:function(){b&&w.start()},enqueueEvent:V,getFlagsInternal:function(){return P},getEnvironmentId:function(){return k},internalChangeEventName:Ge}}var We="3.0.0";export{Ke as createConsoleLogger,v as errors,Xe as initialize,Pe as messages,q 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 K(e){return(K="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 M(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(i,!0).forEach(function(e){var n,t,r;n=o,r=i[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):n(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}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 w=t("LaunchDarklyUnexpectedResponseError"),$=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),H=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),B=t("LaunchDarklyFlagFetchError");function O(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var r=Object.freeze({__proto__:null,LDUnexpectedResponseError:w,LDInvalidEnvironmentIdError:$,LDInvalidUserError:i,LDInvalidEventKeyError:H,LDInvalidArgumentError:d,LDFlagFetchError:B,isHttpErrorRecoverable:O}),o=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(f(e,i,a<i+16383?a:i+16383));1==r?(n=e[t-1],o.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return o.join("")},u=[],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,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(u[(o=r)>>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.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,o,i,a=g(n),u=g(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=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((o=v.length)!==p(t).length)return!1;for(r=o;0!=r--;)if(!m.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))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 o(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function E(e){return h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function G(e){return JSON.parse(JSON.stringify(e))}function X(e,n){return v(e,n)}function W(e){setTimeout(e,0)}function Q(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)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function Y(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function k(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=E(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function P(e){var n=e.version||"3.0.0-beta2";return e.userAgent+"/"+n}function D(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":P(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function Z(){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 M({},e,{},n)},{})}function ee(e){if(!e)return e;var n;for(var t in y){var r=y[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||M({},e))[r]=String(o))}return n||e}var S=Object.freeze({__proto__:null,btoa:h,base64URLEncode:E,clone:G,deepEquals:X,onNextTick:W,wrapPromiseCallback:Q,transformValuesToVersionedValues:b,transformVersionedValuesToValues:Y,chunkUserEventsForUrl:k,getLDUserAgentString:P,getLDHeaders:D,extend:Z,sanitizeUser:ee}),U=2e3;function j(i,a,e,o){var u=a+"/events/bulk/"+e,t=a+"/a/"+e+".gif",s=i.httpFallbackPing,n={};function c(e,n){var r=JSON.stringify(e);return n?function n(t){var e=Z({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},D(i,o));return i.httpRequest("POST",u,e,r).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(){}):(s&&s(t+"?d="+E(r)),Promise.resolve())}return n.sendEvents=function(e){if(!i.httpRequest)return Promise.resolve();var n,t=i.httpAllowsPost();n=t?[e]:k(U-a.length,e);for(var r=[],o=0;o<n.length;o++)r.push(c(n[o],t));return Promise.all(r)},n}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,o){return Object.keys(r).reduce(function(e,n){var t=e;return o(n)&&(!function(e){return!l[e]&&(s||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],o=Z({},o,a[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function N(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function I(){return"LaunchDarkly client initialized"}function T(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"}function ne(e){return'Custom event "'+e+'" does not exist'}function te(){return"No environment/client-side ID was specified."+A}function re(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+A}function F(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function C(){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 oe(e){return'received streaming update for flag "'+e+'"'}function ie(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function ae(e){return'received streaming deletion for flag "'+e+'"'}function ue(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function se(e){return'enqueueing "'+e+'" event'}var A=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",_=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},q=function(e){return'Expected application/json content type but got "'+e+'"'},ce=function(){return"localStorage is unavailable"},V=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},J=function(e){return"network error"+(e?" ("+e+")":"")},z=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+A},le=function(e){return"Error fetching flag settings: "+N(e)},fe=function(){return"No user specified."+A},ve=function(){return"Invalid user specified."+A},de=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ge=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(O(e)?t:"giving up permanently")},pe=function(){return"Cannot make HTTP requests in this environment."+A},me=function(){return"Closing stream connection"},ye=function(e){return"Opening stream connection to "+e},he=function(e,n){return"Error on stream connection: "+N(e)+", will continue retrying every "+n+" milliseconds."},be=function(e){return'Ignoring unknown config option "'+e+'"'},ke=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Ee=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},we=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"},De=Object.freeze({__proto__:null,clientInitialized:I,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:_,eventWithoutUser:T,invalidContentType:q,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ce,localStorageUnavailableForUserId:V,networkError:J,unknownCustomEventKey:ne,environmentNotFound:z,environmentNotSpecified:te,errorFetchingFlags:le,userNotSpecified:fe,invalidUser:ve,bootstrapOldFormat:re,bootstrapInvalid:F,deprecated:de,httpErrorMessage:ge,httpUnavailable:pe,identifyDisabled:C,streamClosing:me,streamConnecting:ye,streamError:he,unknownOption:be,wrongOptionType:ke,wrongOptionTypeBoolean:Ee,optionBelowMinimum:we,debugPolling:Oe,debugStreamPing:L,debugStreamPut:x,debugStreamPatch:oe,debugStreamPatchIgnored:ie,debugStreamDelete:ae,debugStreamDeleteIgnored:ue,debugEnqueueingEvent:se,debugPostingEvents:Pe});function Se(e,n,t,r,o){var i,a=3<arguments.length&&void 0!==r?r:null,u={},s=(4<arguments.length&&void 0!==o?o:null)||j(e,n.eventsUrl,t,n),c=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],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}(),l=R(n),f=n.inlineUsersInEvents,v=n.samplingInterval,d=n.eventCapacity,g=n.flushInterval,p=n.logger,m=[],y=0,h=!1,b=!1;function k(){return 0===v||0===Math.floor(Math.random()*v)}function E(e){m.length<d?(m.push(e),b=!1):b||(b=!0,p.warn(_()))}return u.enqueue=function(e){if(!h){var n=!1,t=!1;if(c.summarizeEvent(e),"feature"===e.kind?k()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>y&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=k(),n&&E(function(e){var n=Z({},e);return f||"identify"===e.kind?n.user=l.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=Z({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,E(r)}}},u.flush=function(){if(h)return Promise.resolve();var e=m,n=c.getSummary();return c.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(m=[],p.debug(Pe(e.length)),s.sendEvents(e).then(function(e){e&&(e.serverTime&&(y=e.serverTime),O(e.status)||(h=!0),400<=e.status&&W(function(){a.maybeReportError(new w(ge(e.status,"event posting","some events were dropped")))}))}))},u.start=function(){i=setTimeout(function e(){u.flush(),i=setTimeout(e,g)},g)},u.stop=function(){clearTimeout(i)},u}function Ue(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=0;n<o[e].length;n++)o[e][n].handler.apply(o[e][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")?(n||console).error(e.message):this.emit("error",e))},e}function je(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||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(ce()),Promise.reject(e)})},u.saveFlags=function(e){var n=Z({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(ce()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(ce()),Promise.reject(e)})},u}function Re(o,e,i,a){var u=e.streamUrl,s=e.logger,n={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,t=e.streamReconnectDelay,v=D(o,e),d=!1,g=null,p=null,m=null,y=null;function h(e){d||(s.warn(he(e,t)),d=!0),k(),b(t)}function b(e){p||(e?p=setTimeout(r,e):r())}function r(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=a&&(n="h="+a),l?o.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(m)):(e=u+"/ping/"+i,n=""):e=c+"/"+E(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,k(),s.info(ye(e)),g=o.eventSourceFactory(e,t),y)y.hasOwnProperty(r)&&g.addEventListener(r,y[r]);g.onerror=h}}function k(){g&&(s.info(me()),g.close(),g=null)}return n.connect=function(e,t){m=e,y={};function n(n){y[n]=function(e){d=!1,t[n]&&t[n](e)}}for(var r in t||{})n(r);b()},n.disconnect=function(){clearTimeout(p),p=null,k()},n.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},n}var Ne="application/json";function Ie(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 B(pe()))});var t=n?"REPORT":"GET",r=D(u,s);n&&(r["Content-Type"]="application/json");var o=d[e];o||(o=function(t){var r,o,i,a,e={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){i=e,a=n}),e}(function(){delete d[e]}),d[e]=o);var i=u.httpRequest(t,e,r,n),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(function(e){return 404===e.status?new $(z()):new B(le(e.statusText||String(e.status)))}(e));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Ne))return JSON.parse(e.body);var n=q(e.header("content-type")||"");return Promise.reject(new B(n))},function(e){return Promise.reject(new B(J(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=E(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(Oe(r)),g(r,o)},e}for(var Te,Fe=(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}}}(Te={exports:{}},Te.exports),Te.exports),Ce=[],Le=0;Le<256;++Le)Ce[Le]=(Le+256).toString(16).substr(1);var xe,Ae,_e=function(e,n){var t=n||0,r=Ce;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("")},qe=0,Ve=0;var Je=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||xe,a=void 0!==e.clockseq?e.clockseq:Ae;if(null==i||null==a){var u=Fe();null==i&&(i=xe=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Ae=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:Ve+1,l=s-qe+(c-Ve)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||qe<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");qe=s,Ae=a;var f=(1e4*(268435455&(s+=122192928e5))+(Ve=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||_e(o)},ze="ld:$anonUserId";function Ke(r,o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(fe()));var t=G(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(r?r.get(ze).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return t.key=e,t;var n=Je();return function(e){return r?r.set(ze,e).catch(function(){o.warn(V())}):Promise.resolve()}(t.key=n).then(function(){return t})}):Promise.reject(new i(ve()))},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},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"},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function $e(e,n,t,r){var a=Z({logger:{default:r}},Me,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){W(function(){n&&n.maybeReportError(new d(e))})}var i,s,c,l,f=Z({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=K(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var n=o[e];r&&r.warn(de(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e])}}),s=Z({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=Z({},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(be(e));else{var r=t.type||v(t.default);if("any"!==r){var o=r.split("|"),i=v(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,u(Ee(e,i))):(u(ke(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(we(e,n,t.minimum)),l[e]=t.minimum)}}}}),f=l}function He(e,n){var o,i=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var a=0;e&&(a="none"===e?100:i.indexOf(e));var t={};function r(e,n,t){if(a<=e){var r=e<i.length?i[e]:"?";n(o+"["+r+"] "+t)}}return t.debug=function(e){return r(0,console.log,e)},t.info=function(e){return r(1,console.info,e)},t.warn=function(e){return r(2,console.warn,e)},t.error=function(e){return r(3,console.error,e)},t}var Be="ready",Ge="initialized",Xe="failed",We="change",Qe="internal-change";e.createConsoleLogger=He,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||He("warn")}(),l=Ue(c),f=$e(t,l,r,c),v=f.hash,d=f.sendEvents,g=e,p=Re(o,f,g,v),m=f.eventProcessor||Se(o,f,g,l),y=Ie(o,f,g),h={},b={},k=f.streaming,E=!1,w=!1,O=!0,P=f.stateProvider,D=function(e,n){var t,r={};return r.setUser=function(e){(t=ee(e))&&n&&n(G(t))},r.getUser=function(){return t?G(t):null},e&&r.setUser(e),r}(null,function(e){if(P)return;e&&U({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),S=Ke(o.localStorage,c);function U(e){g&&(P&&P.enqueueEvent&&P.enqueueEvent(e)||(e.user?(O=!1,!d||w||o.isDoNotTrack()||(c.debug(se(e.kind)),m.enqueue(e))):O&&(c.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),O=!1)))}function j(e,n,t,r){var o=D.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=h[u];if(s&&i-s<3e5)return;h[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=b[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),U(c)}function R(e,n,t,r){var o;if(b&&b.hasOwnProperty(e)&&b[e]&&!b[e].deleted){var i=b[e];o=N(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&j(e,o,n,r),o}function N(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function I(){i=!0,D.getUser()&&p.connect(D.getUser(),{ping:function(){c.debug("received ping message from stream"),y.fetchFlagSettings(D.getUser(),v).then(function(e){return F(e||{})}).catch(function(e){l.maybeReportError(new B(le(e)))})},put:function(e){var n=JSON.parse(e.data);c.debug("received streaming update for all flags"),F(n)},patch:function(e){var n=JSON.parse(e.data),t=b[n.key];if(!t||!t.version||!n.version||t.version<n.version){c.debug(oe(n.key));var r={},o=Z({},n);delete o.key;var i=N(b[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},C(r)}else c.debug(ie(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!b[n.key]||b[n.key].version<n.version){c.debug(ae(n.key));var t={};b[n.key]&&!b[n.key].deleted&&(t[n.key]={previous:b[n.key].value}),b[n.key]={version:n.version,deleted:!0},C(t)}else c.debug(ue(n.key))}})}function T(){i&&(p.disconnect(),i=!1)}function F(e){var n={};if(!e)return Promise.resolve();for(var t in b)b.hasOwnProperty(t)&&b[t]&&(e[t]&&!X(e[t].value,b[t].value)?n[t]={previous:b[t].value,current:N(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:b[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!b[r]||b[r].deleted)&&(n[r]={current:N(e[r])});return b=M({},e),C(n).catch(function(){})}function C(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;l.emit(We+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),l.emit(We,i),l.emit(Qe,b),f.sendEventsOnlyForVariation||P||e.forEach(function(e){j(e,o[e].current)})}return a&&s?s.saveFlags(b).catch(function(){return null}):Promise.resolve()}function L(){var e=k||u&&void 0===k;e&&!i?I():!e&&i&&T()}function x(e){return e===We||e.substr(0,We.length+1)===We+":"}o.localStorage&&(s=new je(o.localStorage,g,v,D,c));var A=new Promise(function(e){var n=l.on(Be,function(){l.off(Be,n),e()})}),_=new Promise(function(e,n){var t=l.on(Ge,function(){l.off(Ge,t),e()}),r=l.on(Xe,function(e){l.off(Xe,r),n(e)})});if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(s?a=!0:c.warn(ce())),"object"===K(f.bootstrap)&&(b=function(t){var e=Object.keys(t),r="$flagsState",o=t[r];!o&&e.length&&c.warn(re()),!1===t.$valid&&c.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};o&&o[e]?n=Z(n,o[e]):n.version=0,i[e]=n}}),i}(f.bootstrap)),P){var q=P.getInitialState();q?V(q):P.on("init",V),P.on("update",function(e){e.user&&D.setUser(e.user);e.flags&&F(e.flags)})}else(e?S.validateUser(n).then(function(e){return D.setUser(e),"object"===K(f.bootstrap)?J():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(b={},y.fetchFlagSettings(D.getUser(),v).then(function(e){return F(e||{})}).then(J).catch(function(e){z(new B(le(e)))})):(b=e,W(J),y.fetchFlagSettings(D.getUser(),v).then(function(e){return F(e)}).catch(function(e){return l.maybeReportError(e)}))}):y.fetchFlagSettings(D.getUser(),v).then(function(e){b=e||{},J()}).catch(function(e){b={},z(e)})}):Promise.reject(new $(te()))).catch(function(e){return l.maybeReportError(e)});function V(e){g=e.environment,D.setUser(e.user),b=M({},e.flags),W(J)}function J(){c.info("LaunchDarkly client initialized"),E=!0,L(),l.emit(Be),l.emit(Ge)}function z(e){l.maybeReportError(e),l.emit(Xe,e),l.emit(Be)}return{client:{waitForInitialization:function(){return _},waitUntilReady:function(){return A},identify:function(e,n,t){return w?Q(Promise.resolve({}),t):P?(c.warn("identify() has no effect here; it must be called on the main client instance"),Q(Promise.resolve(Y(b)),t)):Q((a&&s?s.clearFlags():Promise.resolve()).then(function(){return S.validateUser(e)}).then(function(e){return D.setUser(e)}).then(function(){return y.fetchFlagSettings(D.getUser(),n)}).then(function(e){var n=Y(e);return e?F(e).then(function(){return n}):n}).then(function(e){return i&&I(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return D.getUser()},variation:function(e,n){return R(e,n,!0,!1).value},variationDetail:function(e,n){return R(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&c.warn(ne(e));var r={kind:"custom",key:e,user:D.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),U(r)}else l.maybeReportError(new H(ne(e)))},on:function(e,n,t){x(e)?(u=!0,E&&L(),l.on(e,n,t)):l.on.apply(l,arguments)},off:function(e){if(l.off.apply(l,arguments),x(e)){var n=!1;l.getEvents().forEach(function(e){x(e)&&0<l.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===k&&T())}},setStreaming:function(e){var n=null===e?void 0:e;n!==k&&(k=n,L())},flush:function(e){return Q(d?m.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!b)return e;for(var n in b)b.hasOwnProperty(n)&&(e[n]=R(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(w)return Q(Promise.resolve(),e);function n(){w=!0,b={}}return Q(Promise.resolve().then(function(){if(T(),d)return m.stop(),m.flush()}).then(n).catch(n),e)}},options:f,emitter:l,ident:D,logger:c,requestor:y,start:function(){d&&m.start()},enqueueEvent:U,getFlagsInternal:function(){return b},getEnvironmentId:function(){return g},internalChangeEventName:Qe}},e.messages=De,e.utils=S,e.version="3.0.0-beta2",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 K(e){return(K="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 M(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(i,!0).forEach(function(e){var n,t,r;n=o,r=i[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):n(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}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 w=t("LaunchDarklyUnexpectedResponseError"),$=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),H=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),B=t("LaunchDarklyFlagFetchError");function O(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var r=Object.freeze({__proto__:null,LDUnexpectedResponseError:w,LDInvalidEnvironmentIdError:$,LDInvalidUserError:i,LDInvalidEventKeyError:H,LDInvalidArgumentError:d,LDFlagFetchError:B,isHttpErrorRecoverable:O}),o=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(f(e,i,a<i+16383?a:i+16383));1==r?(n=e[t-1],o.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return o.join("")},u=[],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,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(u[(o=r)>>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.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,o,i,a=g(n),u=g(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=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((o=v.length)!==m(t).length)return!1;for(r=o;0!=r--;)if(!p.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))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 o(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function k(e){return h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function G(e){return JSON.parse(JSON.stringify(e))}function X(e,n){return v(e,n)}function W(e){setTimeout(e,0)}function Q(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)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function Y(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function E(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=k(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function P(e){var n=e.version||"3.0.0";return e.userAgent+"/"+n}function S(e){return{"X-LaunchDarkly-User-Agent":P(e)}}function Z(){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 M({},e,{},n)},{})}function ee(e){if(!e)return e;var n;for(var t in y){var r=y[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||M({},e))[r]=String(o))}return n||e}var D=Object.freeze({__proto__:null,btoa:h,base64URLEncode:k,clone:G,deepEquals:X,onNextTick:W,wrapPromiseCallback:Q,transformValuesToVersionedValues:b,transformVersionedValuesToValues:Y,chunkUserEventsForUrl:E,getLDUserAgentString:P,getLDHeaders:S,extend:Z,sanitizeUser:ee}),U=2e3;function j(i,a,e,o){var u=a+"/events/bulk/"+e,s=a+"/a/"+e+".gif",n={};function c(e){(new window.Image).src=e}function l(e,n){var t=o||c,r=JSON.stringify(e);return n?function n(t){var e=Z({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},S(i));return i.httpRequest("POST",u,e,r).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(){}):(t(s+"?d="+k(r)),Promise.resolve())}return n.sendEvents=function(e){if(!i.httpRequest)return Promise.resolve();var n,t=i.httpAllowsPost();n=t?[e]:E(U-a.length,e);for(var r=[],o=0;o<n.length;o++)r.push(l(n[o],t));return Promise.all(r)},n}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,o){return Object.keys(r).reduce(function(e,n){var t=e;return o(n)&&(!function(e){return!l[e]&&(s||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],o=Z({},o,a[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function I(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function T(){return"LaunchDarkly client initialized"}function C(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"}function ne(e){return'Custom event "'+e+'" does not exist'}function te(){return"No environment/client-side ID was specified."+A}function re(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+A}function F(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function N(){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 oe(e){return'received streaming update for flag "'+e+'"'}function ie(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function ae(e){return'received streaming deletion for flag "'+e+'"'}function ue(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function se(e){return'enqueueing "'+e+'" event'}var A=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",_=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},q=function(e){return'Expected application/json content type but got "'+e+'"'},ce=function(){return"localStorage is unavailable"},J=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},V=function(e){return"network error"+(e?" ("+e+")":"")},z=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+A},le=function(e){return"Error fetching flag settings: "+I(e)},fe=function(){return"No user specified."+A},ve=function(){return"Invalid user specified."+A},de=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ge=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(O(e)?t:"giving up permanently")},me=function(){return"Cannot make HTTP requests in this environment."+A},pe=function(){return"Closing stream connection"},ye=function(e){return"Opening stream connection to "+e},he=function(e,n){return"Error on stream connection: "+I(e)+", will continue retrying every "+n+" milliseconds."},be=function(e){return'Ignoring unknown config option "'+e+'"'},ke=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Ee=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},we=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"},Se=Object.freeze({__proto__:null,clientInitialized:T,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:_,eventWithoutUser:C,invalidContentType:q,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ce,localStorageUnavailableForUserId:J,networkError:V,unknownCustomEventKey:ne,environmentNotFound:z,environmentNotSpecified:te,errorFetchingFlags:le,userNotSpecified:fe,invalidUser:ve,bootstrapOldFormat:re,bootstrapInvalid:F,deprecated:de,httpErrorMessage:ge,httpUnavailable:me,identifyDisabled:N,streamClosing:pe,streamConnecting:ye,streamError:he,unknownOption:be,wrongOptionType:ke,wrongOptionTypeBoolean:Ee,optionBelowMinimum:we,debugPolling:Oe,debugStreamPing:L,debugStreamPut:x,debugStreamPatch:oe,debugStreamPatchIgnored:ie,debugStreamDelete:ae,debugStreamDeleteIgnored:ue,debugEnqueueingEvent:se,debugPostingEvents:Pe});function De(e,n,t,r,o){var i,a=3<arguments.length&&void 0!==r?r:null,u={},s=(4<arguments.length&&void 0!==o?o:null)||j(e,n.eventsUrl,t),c=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],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}(),l=R(n),f=n.inlineUsersInEvents,v=n.samplingInterval,d=n.eventCapacity,g=n.flushInterval,m=n.logger,p=[],y=0,h=!1,b=!1;function k(){return 0===v||0===Math.floor(Math.random()*v)}function E(e){p.length<d?(p.push(e),b=!1):b||(b=!0,m.warn(_()))}return u.enqueue=function(e){if(!h){var n=!1,t=!1;if(c.summarizeEvent(e),"feature"===e.kind?k()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>y&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=k(),n&&E(function(e){var n=Z({},e);return f||"identify"===e.kind?n.user=l.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=Z({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,E(r)}}},u.flush=function(){if(h)return Promise.resolve();var e=p,n=c.getSummary();return c.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(p=[],m.debug(Pe(e.length)),s.sendEvents(e).then(function(e){e&&(e.serverTime&&(y=e.serverTime),O(e.status)||(h=!0),400<=e.status&&W(function(){a.maybeReportError(new w(ge(e.status,"event posting","some events were dropped")))}))}))},u.start=function(){i=setTimeout(function e(){u.flush(),i=setTimeout(e,g)},g)},u.stop=function(){clearTimeout(i)},u}function Ue(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=0;n<o[e].length;n++)o[e][n].handler.apply(o[e][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")?(n||console).error(e.message):this.emit("error",e))},e}function je(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||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(ce()),Promise.reject(e)})},u.saveFlags=function(e){var n=Z({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(ce()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(ce()),Promise.reject(e)})},u}function Re(o,e,i,a){var u=e.streamUrl,s=e.logger,n={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,t=e.streamReconnectDelay,v=!1,d=null,g=null,m=null,p=null;function y(e){v||(s.warn(he(e,t)),v=!0),b(),h(t)}function h(e){g||(e?g=setTimeout(r,e):r())}function r(){var e;g=null;var n="",t={};if(o.eventSourceFactory){for(var r in null!=a&&(n="h="+a),l?o.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers={"Content-Type":"application/json"},t.body=JSON.stringify(m)):(e=u+"/ping/"+i,n=""):e=c+"/"+k(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,b(),s.info(ye(e)),d=o.eventSourceFactory(e,t),p)p.hasOwnProperty(r)&&d.addEventListener(r,p[r]);d.onerror=y}}function b(){d&&(s.info(pe()),d.close(),d=null)}return n.connect=function(e,t){m=e,p={};function n(n){p[n]=function(e){v=!1,t[n]&&t[n](e)}}for(var r in t||{})n(r);h()},n.disconnect=function(){clearTimeout(g),g=null,b()},n.isConnected=function(){return!!(d&&o.eventSourceIsActive&&o.eventSourceIsActive(d))},n}var Ie="application/json";function Te(u,e,a){var s=e.baseUrl,c=e.useReport,l=e.evaluationReasons,f=e.sendLDHeaders,v=e.logger,n={},d={};function g(e,n){if(!u.httpRequest)return new Promise(function(e,n){n(new B(me()))});var t=n?"REPORT":"GET",r=f?S(u):{};n&&(r["Content-Type"]="application/json");var o=d[e];o||(o=function(t){var r,o,i,a,e={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){i=e,a=n}),e}(function(){delete d[e]}),d[e]=o);var i=u.httpRequest(t,e,r,n),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(function(e){return 404===e.status?new $(z()):new B(le(e.statusText||String(e.status)))}(e));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Ie))return JSON.parse(e.body);var n=q(e.header("content-type")||"");return Promise.reject(new B(n))},function(e){return Promise.reject(new B(V(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return n.fetchJSON=function(e){return g(s+e,null)},n.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[s,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=k(JSON.stringify(e)),r=[s,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),l&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(Oe(r)),g(r,o)},n}for(var Ce,Fe=(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}}}(Ce={exports:{}},Ce.exports),Ce.exports),Ne=[],Le=0;Le<256;++Le)Ne[Le]=(Le+256).toString(16).substr(1);var xe,Ae,_e=function(e,n){var t=n||0,r=Ne;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("")},qe=0,Je=0;var Ve=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||xe,a=void 0!==e.clockseq?e.clockseq:Ae;if(null==i||null==a){var u=Fe();null==i&&(i=xe=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Ae=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:Je+1,l=s-qe+(c-Je)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||qe<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");qe=s,Ae=a;var f=(1e4*(268435455&(s+=122192928e5))+(Je=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||_e(o)},ze="ld:$anonUserId";function Ke(r,o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(fe()));var t=G(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(r?r.get(ze).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(ze,e).catch(function(){o.warn(J())}):Promise.resolve()}(t.key=n).then(function(){return t})}):Promise.reject(new i(ve()))},e}var Me={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},sendLDHeaders:{default:!0},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"},stateProvider:{type:"object"}};function $e(e,n,t,r){var a=Z({logger:{default:r}},Me,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){W(function(){n&&n.maybeReportError(new d(e))})}var i,s,c,l,f=Z({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=K(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var n=o[e];r&&r.warn(de(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e])}}),s=Z({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=Z({},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(be(e));else{var r=t.type||v(t.default);if("any"!==r){var o=r.split("|"),i=v(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,u(Ee(e,i))):(u(ke(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(we(e,n,t.minimum)),l[e]=t.minimum)}}}}),f=l}function He(e,n){var o,i=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var a=0;e&&(a="none"===e?100:i.indexOf(e));var t={};function r(e,n,t){if(a<=e){var r=e<i.length?i[e]:"?";n(o+"["+r+"] "+t)}}return t.debug=function(e){return r(0,console.log,e)},t.info=function(e){return r(1,console.info,e)},t.warn=function(e){return r(2,console.warn,e)},t.error=function(e){return r(3,console.error,e)},t}var Be="ready",Ge="initialized",Xe="failed",We="change",Qe="internal-change";e.createConsoleLogger=He,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||He("warn")}(),l=Ue(c),f=$e(t,l,r,c),v=f.hash,d=f.sendEvents,g=e,m=Re(o,f,g,v),p=f.eventProcessor||De(o,f,g,l),y=Te(o,f,g),h={},b={},k=f.streaming,E=!1,w=!1,O=!0,P=f.stateProvider,S=function(e,n){var t,r={};return r.setUser=function(e){(t=ee(e))&&n&&n(G(t))},r.getUser=function(){return t?G(t):null},e&&r.setUser(e),r}(null,function(e){if(P)return;e&&U({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),D=Ke(o.localStorage,c);function U(e){g&&(P&&P.enqueueEvent&&P.enqueueEvent(e)||(e.user?(O=!1,!d||w||o.isDoNotTrack()||(c.debug(se(e.kind)),p.enqueue(e))):O&&(c.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),O=!1)))}function j(e,n,t,r){var o=S.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=h[u];if(s&&i-s<3e5)return;h[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=b[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),U(c)}function R(e,n,t,r){var o;if(b&&b.hasOwnProperty(e)&&b[e]&&!b[e].deleted){var i=b[e];o=I(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&j(e,o,n,r),o}function I(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function T(){i=!0,S.getUser()&&m.connect(S.getUser(),{ping:function(){c.debug("received ping message from stream"),y.fetchFlagSettings(S.getUser(),v).then(function(e){return F(e||{})}).catch(function(e){l.maybeReportError(new B(le(e)))})},put:function(e){var n=JSON.parse(e.data);c.debug("received streaming update for all flags"),F(n)},patch:function(e){var n=JSON.parse(e.data),t=b[n.key];if(!t||!t.version||!n.version||t.version<n.version){c.debug(oe(n.key));var r={},o=Z({},n);delete o.key;var i=I(b[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},N(r)}else c.debug(ie(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!b[n.key]||b[n.key].version<n.version){c.debug(ae(n.key));var t={};b[n.key]&&!b[n.key].deleted&&(t[n.key]={previous:b[n.key].value}),b[n.key]={version:n.version,deleted:!0},N(t)}else c.debug(ue(n.key))}})}function C(){i&&(m.disconnect(),i=!1)}function F(e){var n={};if(!e)return Promise.resolve();for(var t in b)b.hasOwnProperty(t)&&b[t]&&(e[t]&&!X(e[t].value,b[t].value)?n[t]={previous:b[t].value,current:I(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:b[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!b[r]||b[r].deleted)&&(n[r]={current:I(e[r])});return b=M({},e),N(n).catch(function(){})}function N(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;l.emit(We+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),l.emit(We,i),l.emit(Qe,b),f.sendEventsOnlyForVariation||P||e.forEach(function(e){j(e,o[e].current)})}return a&&s?s.saveFlags(b).catch(function(){return null}):Promise.resolve()}function L(){var e=k||u&&void 0===k;e&&!i?T():!e&&i&&C()}function x(e){return e===We||e.substr(0,We.length+1)===We+":"}o.localStorage&&(s=new je(o.localStorage,g,v,S,c));var A=new Promise(function(e){var n=l.on(Be,function(){l.off(Be,n),e()})}),_=new Promise(function(e,n){var t=l.on(Ge,function(){l.off(Ge,t),e()}),r=l.on(Xe,function(e){l.off(Xe,r),n(e)})});if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(s?a=!0:c.warn(ce())),"object"===K(f.bootstrap)&&(b=function(t){var e=Object.keys(t),r="$flagsState",o=t[r];!o&&e.length&&c.warn(re()),!1===t.$valid&&c.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};o&&o[e]?n=Z(n,o[e]):n.version=0,i[e]=n}}),i}(f.bootstrap)),P){var q=P.getInitialState();q?J(q):P.on("init",J),P.on("update",function(e){e.user&&S.setUser(e.user);e.flags&&F(e.flags)})}else(e?D.validateUser(n).then(function(e){return S.setUser(e),"object"===K(f.bootstrap)?V():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(b={},y.fetchFlagSettings(S.getUser(),v).then(function(e){return F(e||{})}).then(V).catch(function(e){z(new B(le(e)))})):(b=e,W(V),y.fetchFlagSettings(S.getUser(),v).then(function(e){return F(e)}).catch(function(e){return l.maybeReportError(e)}))}):y.fetchFlagSettings(S.getUser(),v).then(function(e){b=e||{},V()}).catch(function(e){b={},z(e)})}):Promise.reject(new $(te()))).catch(function(e){return l.maybeReportError(e)});function J(e){g=e.environment,S.setUser(e.user),b=M({},e.flags),W(V)}function V(){c.info("LaunchDarkly client initialized"),E=!0,L(),l.emit(Be),l.emit(Ge)}function z(e){l.maybeReportError(e),l.emit(Xe,e),l.emit(Be)}return{client:{waitForInitialization:function(){return _},waitUntilReady:function(){return A},identify:function(e,n,t){return w?Q(Promise.resolve({}),t):P?(c.warn("identify() has no effect here; it must be called on the main client instance"),Q(Promise.resolve(Y(b)),t)):Q((a&&s?s.clearFlags():Promise.resolve()).then(function(){return D.validateUser(e)}).then(function(e){return S.setUser(e)}).then(function(){return y.fetchFlagSettings(S.getUser(),n)}).then(function(e){var n=Y(e);return e?F(e).then(function(){return n}):n}).then(function(e){return i&&T(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return S.getUser()},variation:function(e,n){return R(e,n,!0,!1).value},variationDetail:function(e,n){return R(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&c.warn(ne(e));var r={kind:"custom",key:e,user:S.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),U(r)}else l.maybeReportError(new H(ne(e)))},on:function(e,n,t){x(e)?(u=!0,E&&L(),l.on(e,n,t)):l.on.apply(l,arguments)},off:function(e){if(l.off.apply(l,arguments),x(e)){var n=!1;l.getEvents().forEach(function(e){x(e)&&0<l.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===k&&C())}},setStreaming:function(e){var n=null===e?void 0:e;n!==k&&(k=n,L())},flush:function(e){return Q(d?p.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!b)return e;for(var n in b)b.hasOwnProperty(n)&&(e[n]=R(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(w)return Q(Promise.resolve(),e);function n(){w=!0,b={}}return Q(Promise.resolve().then(function(){if(C(),d)return p.stop(),p.flush()}).then(n).catch(n),e)}},options:f,emitter:l,ident:S,logger:c,requestor:y,start:function(){d&&p.start()},enqueueEvent:U,getFlagsInternal:function(){return b},getEnvironmentId:function(){return g},internalChangeEventName:Qe}},e.messages=Se,e.utils=D,e.version="3.0.0",Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ldclient-common.min.js.map
{
"name": "launchdarkly-js-sdk-common",
"version": "3.0.0-beta2",
"version": "3.0.0",
"description": "LaunchDarkly SDK for JavaScript - common code",

@@ -5,0 +5,0 @@ "author": "LaunchDarkly <team@launchdarkly.com>",

@@ -228,17 +228,2 @@ /**

streamReconnectDelay?: number;
/**
* For use by wrapper libraries to set an identifying name for the wrapper being used.
*
* This will be sent as diagnostic information to the LaunchDarkly servers to allow recording
* metrics on the usage of these wrapper libraries.
*/
wrapperName?: string;
/**
* For use by wrapper libraries to set version to be included alongside `wrapperName`.
*
* If `wrapperName` is unset, this field will be ignored.
*/
wrapperVersion?: string;
}

@@ -245,0 +230,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc