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 2.12.2 to 2.12.3

2

dist/ldclient-common.cjs.js

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

"use strict";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,n.prototype.name=e,n.prototype.constructor=n,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!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({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,r){for(var t,o=[],i=n;i<r;i+=3)t=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(t));return o.join("")}function fromByteArray(e){for(var n,r=e.length,t=r%3,o=[],i=0,a=r-t;i<a;i+=16383)o.push(encodeChunk(e,i,i+16383>a?a:i+16383));return 1===t?(n=e[r-1],o.push(lookup[n>>2]+lookup[n<<4&63]+"==")):2===t&&(n=(e[r-2]<<8)+e[r-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 _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},isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,r){if(n===r)return!0;if(n&&r&&"object"==(void 0===n?"undefined":_typeof(n))&&"object"==(void 0===r?"undefined":_typeof(r))){var t,o,i,a=isArray(n),u=isArray(r);if(a&&u){if((o=n.length)!=r.length)return!1;for(t=o;0!=t--;)if(!e(n[t],r[t]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=r instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==r.getTime();var l=n instanceof RegExp,v=r instanceof RegExp;if(l!=v)return!1;if(l&&v)return n.toString()==r.toString();var f=keyList(n);if((o=f.length)!==keyList(r).length)return!1;for(t=o;0!=t--;)if(!hasProp.call(r,f[t]))return!1;for(t=o;0!=t--;)if(!e(n[i=f[t]],r[i]))return!1;return!0}return n!=n&&r!=r},_extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},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=[],r=0;r<e.length;r++)n.push(e.charCodeAt(r));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 r=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:r}function transformValuesToVersionedValues(e){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]={value:e[r],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r].value);return n}function chunkUserEventsForUrl(e,n){for(var r=n.slice(0),t=[],o=e,i=void 0;r.length>0;){for(i=[];o>0;){var a=r.shift();if(!a)break;(o-=base64URLEncode(JSON.stringify(a)).length)<0&&i.length>0?r.unshift(a):i.push(a)}o=e,t.push(i)}return t}function getLDUserAgentString(e){var n=e.version||"2.12.2";return e.userAgent+"/"+n}function getLDHeaders(e){return{"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)}}function extend(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return n.reduce(function(e,n){return _extends({},e,n)},{})}function sanitizeUser(e){if(!e)return e;var n=void 0;for(var r in userAttrsToStringify){var t=userAttrsToStringify[r],o=e[t];void 0!==o&&"string"!=typeof o&&((n=n||Object.assign({},e))[t]=String(o))}return n||e}var utils=Object.freeze({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(e,n,r,t){var o=n+"/events/bulk/"+r,i=n+"/a/"+r+".gif",a={};function u(e){(new window.Image).src=e}function s(n,r){var a=t||u,s=JSON.stringify(n);return r?function n(r){var t=extend({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},getLDHeaders(e));return e.httpRequest("POST",o,t,s).promise.then(function(e){if(e)return e.status>=400&&isHttpErrorRecoverable(e.status)&&r?n(!1):function(e){var n={status:e.status},r=e.header("date");if(r){var t=Date.parse(r);t&&(n.serverTime=t)}return n}(e)}).catch(function(){return r?n(!1):Promise.reject()})}(!0).catch(function(){}):(a(i+"?d="+base64URLEncode(s)),Promise.resolve())}return a.sendEvents=function(r){if(!e.httpRequest)return Promise.resolve();var t=e.httpAllowsPost(),o=void 0;o=t?[r]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,r);for(var i=[],a=0;a<o.length;a++)i.push(s(o[a],t));return Promise.all(i)},a}function EventSummarizer(){var e={},n=0,r=0,t={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=t[o];i?i.count=i.count+1:t[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>r&&(r=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in t){var a=t[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:r,features:e}},e.clearSummary=function(){n=0,r=0,t={}},e}function UserFilter(e){var n={},r=e.allAttributesPrivate,t=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 s=a;return i(u)&&(!function(e){return!o[e]&&(r||-1!==n.indexOf(e)||-1!==t.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s},[{},{}])},u=a(e,function(e){return i[e]}),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,function(){return!0});s.custom=l[0],c=extend({},c,l[1])}var v=Object.keys(c);return v.length&&(v.sort(),s.privateAttrs=v),s},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"},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: http://docs.launchdarkly.com/docs/running-an-ab-test#include-the-client-side-snippet"},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."+docLink},environmentNotSpecified=function(){return"No environment 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'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"'},httpErrorMessage=function(e,n,r){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(isHttpErrorRecoverable(e)?r:"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){return"Error on stream connection: "+errorString(e)},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({clientInitialized:clientInitialized,clientNotReady:clientNotReady,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,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents});function EventProcessor(e,n,r){var t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i={},a=o||EventSender(e,n.eventsUrl,r),u=EventSummarizer(),s=UserFilter(n),c=n.inlineUsersInEvents,l=n.samplingInterval,v=n.flushInterval,f=n.logger,d=[],g=0,m=!1,p=void 0;function y(){return 0===l||0===Math.floor(Math.random()*l)}return i.enqueue=function(e){if(!m){var n,r=!1,t=!1;if(u.summarizeEvent(e),"feature"===e.kind?y()&&(r=!!e.trackEvents,t=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>g&&n.debugEventsUntilDate>(new Date).getTime()):r=y(),r&&d.push(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 o=extend({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,d.push(o)}}},i.flush=function(){if(m)return Promise.resolve();var e=d,n=u.getSummary();return u.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(d=[],f.debug(debugPostingEvents(e.length)),a.sendEvents(e).then(function(e){e&&(e.serverTime&&(g=e.serverTime),isHttpErrorRecoverable(e.status)||(m=!0),e.status>=400&&onNextTick(function(){t.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},i.start=function(){p=setTimeout(function e(){i.flush(),p=setTimeout(e,v)},v)},i.stop=function(){clearTimeout(p)},i}function EventEmitter(e){var n={},r={};return n.on=function(e,n,t){r[e]=r[e]||[],r[e]=r[e].concat({handler:n,context:t})},n.off=function(e,n,t){if(r[e])for(var o=0;o<r[e].length;o++)r[e][o].handler===n&&r[e][o].context===t&&(r[e]=r[e].slice(0,o).concat(r[e].slice(o+1)))},n.emit=function(e){if(r[e])for(var n=0;n<r[e].length;n++)r[e][n].handler.apply(r[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(r)},n.getEventListenerCount=function(e){return r[e]?r[e].length:0},n.maybeReportError=function(n){n&&(r["error"]?this.emit("error",n):(e||console).error(n.message))},n}function Store(e,n,r,t,o){var i={};function a(){var e="",o=t.getUser();return o&&(e=r||btoa(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 r=n.$schema;void 0===r||r<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.saveFlags=function(n){var r=extend({},n,{$schema:1});return e.set(a(),JSON.stringify(r)).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i}function Stream(e,n,r,t){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+r,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,v=null,f=null,d=null,g=null;function m(e){i.warn(streamError(e)),h(),p(l)}function p(e){f||(e?f=setTimeout(y,e):y())}function y(){f=null;var n=void 0,a="",l={};if(e.eventSourceFactory){for(var p in null!=t&&(a="h="+t),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(d)):(n=o+"/ping/"+r,a=""):n=u+"/"+base64URLEncode(JSON.stringify(d)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,h(),i.info(streamConnecting(n)),v=e.eventSourceFactory(n,l),g)g.hasOwnProperty(p)&&v.addEventListener(p,g[p]);v.onerror=m}}function h(){v&&(i.info(streamClosing()),v.close(),v=null)}return a.connect=function(e,n){d=e,g=n,p()},a.disconnect=function(){clearTimeout(f),f=null,h()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}function promiseCoalescer(e){var n=void 0,r=void 0,t=void 0,o=void 0,i={addPromise:function(i,a){n=i,r&&r(),r=a,i.then(function(r){n===i&&(t(r),e&&e())},function(r){n===i&&(o(r),e&&e())})}};return i.resultPromise=new Promise(function(e,n){t=e,o=n}),i}var json="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(e,n,r){var t=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.sendLDHeaders,u=n.logger,s={},c={};function l(n,r){if(!e.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var t=r?"REPORT":"GET",o=a?getLDHeaders(e):{};r&&(o["Content-Type"]="application/json");var i=c[n];i||(i=promiseCoalescer(function(){delete c[n]}),c[n]=i);var u=e.httpRequest(t,n,o,r),s=u.promise.then(function(e){if(200===e.status){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))}return Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return i.addPromise(s,function(){u.cancel&&u.cancel()}),i.resultPromise}return s.fetchJSON=function(e){return l(t+e,null)},s.fetchFlagSettings=function(e,n){var a=void 0,s=void 0,c="",v=void 0;return o?(s=[t,"/sdk/evalx/",r,"/user"].join(""),v=JSON.stringify(e)):(a=base64URLEncode(JSON.stringify(e)),s=[t,"/sdk/evalx/",r,"/users/",a].join("")),n&&(c="h="+n),i&&(c=c+(c?"&":"")+"withReasons=true"),s=s+(c?"?":"")+c,u.debug(debugPolling(s)),l(s,v)},s}function Identity(e,n){var r={},t=void 0;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 r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var t=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),t[n]=e>>>((3&n)<<3)&255;return t}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var r=n||0,t=byteToHex;return[t[e[r++]],t[e[r++]],t[e[r++]],t[e[r++]],"-",t[e[r++]],t[e[r++]],"-",t[e[r++]],t[e[r++]],"-",t[e[r++]],t[e[r++]],"-",t[e[r++]],t[e[r++]],t[e[r++]],t[e[r++]],t[e[r++]],t[e[r++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,r){var t=n&&r||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||s>_lastMSecs)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_lastNSecs=c,_clockseq=a;var v=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[t++]=v>>>24&255,o[t++]=v>>>16&255,o[t++]=v>>>8&255,o[t++]=255&v;var f=s/4294967296*1e4&268435455;o[t++]=f>>>8&255,o[t++]=255&f,o[t++]=f>>>24&15|16,o[t++]=f>>>16&255,o[t++]=a>>>8|128,o[t++]=255&a;for(var d=0;d<6;++d)o[t+d]=i[d];return n||bytesToUuid_1(o)}var v1_1=v1,ldUserIdKey="ld:$anonUserId";function UserValidator(e,n){var r={};return r.validateUser=function(r){if(!r)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(r);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(e?e.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(r){if(r)return t.key=r,t;var o=v1_1();return t.key=o,function(r){return e?e.set(ldUserIdKey,r).catch(function(){n.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(o).then(function(){return t})}):Promise.reject(new LDInvalidUserError(invalidUser()))},r}function validate(e,n,r,t){var o=extend({logger:t},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},r),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames"};function a(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var u=extend({},e||{});return function(e){var n=e;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var r=i[e];t.warn(deprecated(e,r)),void 0===n[r]&&(n[r]=n[e]),delete n[e]}})}(u),u=function(e,n){var r=extend({},e);return Object.keys(n).forEach(function(e){void 0!==r[e]&&null!==r[e]||(r[e]=n[e])}),r}(u,o),(isNaN(u.flushInterval)||u.flushInterval<2e3)&&(u.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(u.samplingInterval)||u.samplingInterval<0)&&(u.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),u}function createConsoleLogger(e){var n=0;e&&(n="none"===e?100:["debug","info","warn","error"].indexOf(e));var r={};function t(e,r,t){e>=n&&r(t)}return r.debug=function(e){return t(0,console.log,e)},r.info=function(e){return t(1,console.info,e)},r.warn=function(e){return t(2,console.warn,e)},r.error=function(e){return t(3,console.error,e)},r}var _typeof$1="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},readyEvent="ready",successEvent="initialized",failedEvent="failed",changeEvent="change",internalChangeEvent="internal-change";function initialize(e,n,r,t,o){var i=function(){if(r&&r.logger)return r.logger;return o&&o.logger||createConsoleLogger("warn")}(),a=EventEmitter(i),u=validate(r,a,o,i),s=u.hash,c=u.sendEvents,l=e,v=Stream(t,u,l,s),f=u.eventProcessor||EventProcessor(t,u,l,a),d=Requestor(t,u,l),g={},m={},p=void 0,y=void 0,h=u.streaming,E=void 0,b=!1,k=!1,S=!0,U=u.stateProvider,D=Identity(null,function(e){if(U)return;e&&L({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),P=UserValidator(t.localStorage,i),w=void 0;function L(e){l&&(U&&U.enqueueEvent&&U.enqueueEvent(e)||(e.user?(S=!1,!c||k||t.isDoNotTrack()||(i.debug(debugEnqueueingEvent(e.kind)),f.enqueue(e))):S&&(i.warn(eventWithoutUser()),S=!1)))}function I(e,n,r){var t=D.getUser(),o=new Date,i=n?n.value:null;if(!u.allowFrequentDuplicateEvents){var a=JSON.stringify(i)+(t&&t.key?t.key:"")+e,s=g[a];if(s&&o-s<3e5)return;g[a]=o}var c={kind:"feature",key:e,user:t,value:i,variation:n?n.variationIndex:null,default:r,creationDate:o.getTime(),reason:n?n.reason:null},l=m[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),L(c)}function F(e,n,r){var t=void 0;if(m&&m.hasOwnProperty(e)&&m[e]&&!m[e].deleted){var o=m[e];t=C(o),null!==o.value&&void 0!==o.value||(t.value=n)}else t={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return r&&I(e,t,n),t}function C(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function T(){y=!0,D.getUser()&&v.connect(D.getUser(),{ping:function(){i.debug(debugStreamPing()),d.fetchFlagSettings(D.getUser(),s).then(function(e){return N(e||{})}).catch(function(e){a.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);i.debug(debugStreamPut()),N(n)},patch:function(e){var n=JSON.parse(e.data),r=m[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(debugStreamPatch(n.key));var t={},o=extend({},n);delete o.key,m[n.key]=o;var a=C(o);t[n.key]=r?{previous:r.value,current:a}:{current:a},O(t)}else i.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!m[n.key]||m[n.key].version<n.version){i.debug(debugStreamDelete(n.key));var r={};m[n.key]&&!m[n.key].deleted&&(r[n.key]={previous:m[n.key].value}),m[n.key]={version:n.version,deleted:!0},O(r)}else i.debug(debugStreamDeleteIgnored(n.key))}})}function R(){y&&(v.disconnect(),y=!1)}function N(e){var n={};if(!e)return Promise.resolve();for(var r in m)m.hasOwnProperty(r)&&m[r]&&(e[r]&&!deepEquals(e[r].value,m[r].value)?n[r]={previous:m[r].value,current:C(e[r])}:e[r]&&!e[r].deleted||(n[r]={previous:m[r].value}));for(var t in e)e.hasOwnProperty(t)&&e[t]&&(!m[t]||m[t].deleted)&&(n[t]={current:C(e[t])});return m=e,O(n).catch(function(){})}function O(e){var n=Object.keys(e);if(n.length>0){var r={};n.forEach(function(n){var t=e[n].current,o=t?t.value:void 0,i=e[n].previous;a.emit(changeEvent+":"+n,o,i),r[n]=t?{current:o,previous:i}:{previous:i}}),a.emit(changeEvent,r),a.emit(internalChangeEvent,m),u.sendEventsOnlyForVariation||U||n.forEach(function(n){I(n,e[n].current)})}return p&&w?w.saveFlags(m).catch(function(){return null}):Promise.resolve()}function x(){var e=h||E&&void 0===h;e&&!y?T():!e&&y&&R()}function A(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}t.localStorage&&(w=new Store(t.localStorage,l,s,D,i));var j=new Promise(function(e){var n=a.on(readyEvent,function(){a.off(readyEvent,n),e()})}),_=new Promise(function(e,n){var r=a.on(successEvent,function(){a.off(successEvent,r),e()}),t=a.on(failedEvent,function(e){a.off(failedEvent,t),n(e)})});if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(w?p=!0:i.warn(localStorageUnavailable())),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&&N(e.flags)})}else(function(){if(!e)return Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()));return P.validateUser(n).then(function(e){return D.setUser(e),"object"===_typeof$1(u.bootstrap)?(m=function(e){var n=Object.keys(e),r=e.$flagsState;!r&&n.length&&i.warn(bootstrapOldFormat()),!1===e.$valid&&i.warn(bootstrapInvalid());var t={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};r&&r[n]?o=extend(o,r[n]):o.version=0,t[n]=o}}),t}(u.bootstrap),z()):p?w.loadFlags().catch(function(){return null}).then(function(e){return null==e?(m={},d.fetchFlagSettings(D.getUser(),s).then(function(e){return N(e||{})}).then(z).catch(function(e){var n=new LDFlagFetchError(errorFetchingFlags(e));K(n)})):(m=e,onNextTick(z),d.fetchFlagSettings(D.getUser(),s).then(function(e){return N(e)}).catch(function(e){return a.maybeReportError(e)}))}):d.fetchFlagSettings(D.getUser(),s).then(function(e){m=e||{},z()}).catch(function(e){m={},K(e)})})})().catch(function(e){return a.maybeReportError(e)});function q(e){l=e.environment,D.setUser(e.user),m=e.flags,onNextTick(z)}function z(){i.info(clientInitialized()),b=!0,x(),a.emit(readyEvent),a.emit(successEvent)}function K(e){a.maybeReportError(e),a.emit(failedEvent,e),a.emit(readyEvent)}return{client:{waitForInitialization:function(){return _},waitUntilReady:function(){return j},identify:function(e,n,r){return k?wrapPromiseCallback(Promise.resolve({}),r):U?(i.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(m)),r)):wrapPromiseCallback((p&&w?w.clearFlags():Promise.resolve()).then(function(){return P.validateUser(e)}).then(function(e){return D.setUser(e)}).then(function(){return d.fetchFlagSettings(D.getUser(),n)}).then(function(e){var n=transformVersionedValuesToValues(e);return e?N(e).then(function(){return n}):n}).then(function(e){return y&&T(),e}).catch(function(e){return a.maybeReportError(e),Promise.reject(e)}),r)},getUser:function(){return D.getUser()},variation:function(e,n){return F(e,n,!0).value},variationDetail:function(e,n){return F(e,n,!0)},track:function(e,n){"string"==typeof e?(t.customEventFilter&&!t.customEventFilter(e)&&i.warn(unknownCustomEventKey(e)),L({kind:"custom",key:e,data:n,user:D.getUser(),url:t.getCurrentUrl(),creationDate:(new Date).getTime()})):a.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,n,r){A(e)?(E=!0,b&&x(),a.on(e,n,r)):a.on.apply(a,arguments)},off:function(e){if(a.off.apply(a,arguments),A(e)){var n=!1;a.getEvents().forEach(function(e){A(e)&&a.getEventListenerCount(e)>0&&(n=!0)}),n||(E=!1,y&&void 0===h&&R())}},setStreaming:function(e){var n=null===e?void 0:e;n!==h&&(h=n,x())},flush:function(e){return wrapPromiseCallback(c?f.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!m)return e;for(var n in m)m.hasOwnProperty(n)&&(e[n]=F(n,null,!u.sendEventsOnlyForVariation).value);return e},close:function(e){if(k)return wrapPromiseCallback(Promise.resolve(),e);var n=function(){k=!0,m={}};return wrapPromiseCallback(Promise.resolve().then(function(){if(R(),c)return f.stop(),f.flush()}).then(n).catch(n),e)}},options:u,emitter:a,ident:D,logger:i,requestor:d,start:function(){c&&f.start()},enqueueEvent:L,getFlagsInternal:function(){return m},getEnvironmentId:function(){return l},internalChangeEventName:internalChangeEvent}}var version="2.12.2";exports.initialize=initialize,exports.version=version,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.messages=messages,exports.utils=utils;
"use strict";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,n.prototype.name=e,n.prototype.constructor=n,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!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({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,r){for(var t,o=[],i=n;i<r;i+=3)t=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(t));return o.join("")}function fromByteArray(e){for(var n,r=e.length,t=r%3,o=[],i=0,a=r-t;i<a;i+=16383)o.push(encodeChunk(e,i,i+16383>a?a:i+16383));return 1===t?(n=e[r-1],o.push(lookup[n>>2]+lookup[n<<4&63]+"==")):2===t&&(n=(e[r-2]<<8)+e[r-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 _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},isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,r){if(n===r)return!0;if(n&&r&&"object"==(void 0===n?"undefined":_typeof(n))&&"object"==(void 0===r?"undefined":_typeof(r))){var t,o,i,a=isArray(n),u=isArray(r);if(a&&u){if((o=n.length)!=r.length)return!1;for(t=o;0!=t--;)if(!e(n[t],r[t]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=r instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==r.getTime();var l=n instanceof RegExp,v=r instanceof RegExp;if(l!=v)return!1;if(l&&v)return n.toString()==r.toString();var f=keyList(n);if((o=f.length)!==keyList(r).length)return!1;for(t=o;0!=t--;)if(!hasProp.call(r,f[t]))return!1;for(t=o;0!=t--;)if(!e(n[i=f[t]],r[i]))return!1;return!0}return n!=n&&r!=r},_extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},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=[],r=0;r<e.length;r++)n.push(e.charCodeAt(r));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 r=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:r}function transformValuesToVersionedValues(e){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]={value:e[r],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r].value);return n}function chunkUserEventsForUrl(e,n){for(var r=n.slice(0),t=[],o=e,i=void 0;r.length>0;){for(i=[];o>0;){var a=r.shift();if(!a)break;(o-=base64URLEncode(JSON.stringify(a)).length)<0&&i.length>0?r.unshift(a):i.push(a)}o=e,t.push(i)}return t}function getLDUserAgentString(e){var n=e.version||"2.12.3";return e.userAgent+"/"+n}function getLDHeaders(e){return{"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)}}function extend(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return n.reduce(function(e,n){return _extends({},e,n)},{})}function sanitizeUser(e){if(!e)return e;var n=void 0;for(var r in userAttrsToStringify){var t=userAttrsToStringify[r],o=e[t];void 0!==o&&"string"!=typeof o&&((n=n||Object.assign({},e))[t]=String(o))}return n||e}var utils=Object.freeze({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(e,n,r,t){var o=n+"/events/bulk/"+r,i=n+"/a/"+r+".gif",a={};function u(e){(new window.Image).src=e}function s(n,r){var a=t||u,s=JSON.stringify(n);return r?function n(r){var t=extend({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},getLDHeaders(e));return e.httpRequest("POST",o,t,s).promise.then(function(e){if(e)return e.status>=400&&isHttpErrorRecoverable(e.status)&&r?n(!1):function(e){var n={status:e.status},r=e.header("date");if(r){var t=Date.parse(r);t&&(n.serverTime=t)}return n}(e)}).catch(function(){return r?n(!1):Promise.reject()})}(!0).catch(function(){}):(a(i+"?d="+base64URLEncode(s)),Promise.resolve())}return a.sendEvents=function(r){if(!e.httpRequest)return Promise.resolve();var t=e.httpAllowsPost(),o=void 0;o=t?[r]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,r);for(var i=[],a=0;a<o.length;a++)i.push(s(o[a],t));return Promise.all(i)},a}function EventSummarizer(){var e={},n=0,r=0,t={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=t[o];i?i.count=i.count+1:t[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>r&&(r=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in t){var a=t[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:r,features:e}},e.clearSummary=function(){n=0,r=0,t={}},e}function UserFilter(e){var n={},r=e.allAttributesPrivate,t=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 s=a;return i(u)&&(!function(e){return!o[e]&&(r||-1!==n.indexOf(e)||-1!==t.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s},[{},{}])},u=a(e,function(e){return i[e]}),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,function(){return!0});s.custom=l[0],c=extend({},c,l[1])}var v=Object.keys(c);return v.length&&(v.sort(),s.privateAttrs=v),s},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"},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: http://docs.launchdarkly.com/docs/running-an-ab-test#include-the-client-side-snippet"},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."+docLink},environmentNotSpecified=function(){return"No environment 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'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"'},httpErrorMessage=function(e,n,r){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(isHttpErrorRecoverable(e)?r:"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){return"Error on stream connection: "+errorString(e)},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({clientInitialized:clientInitialized,clientNotReady:clientNotReady,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,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents});function EventProcessor(e,n,r){var t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i={},a=o||EventSender(e,n.eventsUrl,r),u=EventSummarizer(),s=UserFilter(n),c=n.inlineUsersInEvents,l=n.samplingInterval,v=n.flushInterval,f=n.logger,d=[],g=0,m=!1,p=void 0;function y(){return 0===l||0===Math.floor(Math.random()*l)}return i.enqueue=function(e){if(!m){var n,r=!1,t=!1;if(u.summarizeEvent(e),"feature"===e.kind?y()&&(r=!!e.trackEvents,t=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>g&&n.debugEventsUntilDate>(new Date).getTime()):r=y(),r&&d.push(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 o=extend({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,d.push(o)}}},i.flush=function(){if(m)return Promise.resolve();var e=d,n=u.getSummary();return u.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(d=[],f.debug(debugPostingEvents(e.length)),a.sendEvents(e).then(function(e){e&&(e.serverTime&&(g=e.serverTime),isHttpErrorRecoverable(e.status)||(m=!0),e.status>=400&&onNextTick(function(){t.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},i.start=function(){p=setTimeout(function e(){i.flush(),p=setTimeout(e,v)},v)},i.stop=function(){clearTimeout(p)},i}function EventEmitter(e){var n={},r={};return n.on=function(e,n,t){r[e]=r[e]||[],r[e]=r[e].concat({handler:n,context:t})},n.off=function(e,n,t){if(r[e])for(var o=0;o<r[e].length;o++)r[e][o].handler===n&&r[e][o].context===t&&(r[e]=r[e].slice(0,o).concat(r[e].slice(o+1)))},n.emit=function(e){if(r[e])for(var n=0;n<r[e].length;n++)r[e][n].handler.apply(r[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(r)},n.getEventListenerCount=function(e){return r[e]?r[e].length:0},n.maybeReportError=function(n){n&&(r["error"]?this.emit("error",n):(e||console).error(n.message))},n}function Store(e,n,r,t,o){var i={};function a(){var e="",o=t.getUser();return o&&(e=r||btoa(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 r=n.$schema;void 0===r||r<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.saveFlags=function(n){var r=extend({},n,{$schema:1});return e.set(a(),JSON.stringify(r)).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i}function Stream(e,n,r,t){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+r,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,v=null,f=null,d=null,g=null;function m(e){i.warn(streamError(e)),h(),p(l)}function p(e){f||(e?f=setTimeout(y,e):y())}function y(){f=null;var n=void 0,a="",l={};if(e.eventSourceFactory){for(var p in null!=t&&(a="h="+t),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(d)):(n=o+"/ping/"+r,a=""):n=u+"/"+base64URLEncode(JSON.stringify(d)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,h(),i.info(streamConnecting(n)),v=e.eventSourceFactory(n,l),g)g.hasOwnProperty(p)&&v.addEventListener(p,g[p]);v.onerror=m}}function h(){v&&(i.info(streamClosing()),v.close(),v=null)}return a.connect=function(e,n){d=e,g=n,p()},a.disconnect=function(){clearTimeout(f),f=null,h()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}function promiseCoalescer(e){var n=void 0,r=void 0,t=void 0,o=void 0,i={addPromise:function(i,a){n=i,r&&r(),r=a,i.then(function(r){n===i&&(t(r),e&&e())},function(r){n===i&&(o(r),e&&e())})}};return i.resultPromise=new Promise(function(e,n){t=e,o=n}),i}var json="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(e,n,r){var t=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.sendLDHeaders,u=n.logger,s={},c={};function l(n,r){if(!e.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var t=r?"REPORT":"GET",o=a?getLDHeaders(e):{};r&&(o["Content-Type"]="application/json");var i=c[n];i||(i=promiseCoalescer(function(){delete c[n]}),c[n]=i);var u=e.httpRequest(t,n,o,r),s=u.promise.then(function(e){if(200===e.status){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))}return Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return i.addPromise(s,function(){u.cancel&&u.cancel()}),i.resultPromise}return s.fetchJSON=function(e){return l(t+e,null)},s.fetchFlagSettings=function(e,n){var a=void 0,s=void 0,c="",v=void 0;return o?(s=[t,"/sdk/evalx/",r,"/user"].join(""),v=JSON.stringify(e)):(a=base64URLEncode(JSON.stringify(e)),s=[t,"/sdk/evalx/",r,"/users/",a].join("")),n&&(c="h="+n),i&&(c=c+(c?"&":"")+"withReasons=true"),s=s+(c?"?":"")+c,u.debug(debugPolling(s)),l(s,v)},s}function Identity(e,n){var r={},t=void 0;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 r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var t=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),t[n]=e>>>((3&n)<<3)&255;return t}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var r=n||0,t=byteToHex;return[t[e[r++]],t[e[r++]],t[e[r++]],t[e[r++]],"-",t[e[r++]],t[e[r++]],"-",t[e[r++]],t[e[r++]],"-",t[e[r++]],t[e[r++]],"-",t[e[r++]],t[e[r++]],t[e[r++]],t[e[r++]],t[e[r++]],t[e[r++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,r){var t=n&&r||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||s>_lastMSecs)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_lastNSecs=c,_clockseq=a;var v=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[t++]=v>>>24&255,o[t++]=v>>>16&255,o[t++]=v>>>8&255,o[t++]=255&v;var f=s/4294967296*1e4&268435455;o[t++]=f>>>8&255,o[t++]=255&f,o[t++]=f>>>24&15|16,o[t++]=f>>>16&255,o[t++]=a>>>8|128,o[t++]=255&a;for(var d=0;d<6;++d)o[t+d]=i[d];return n||bytesToUuid_1(o)}var v1_1=v1,ldUserIdKey="ld:$anonUserId";function UserValidator(e,n){var r={};return r.validateUser=function(r){if(!r)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(r);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(e?e.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(r){if(r)return t.key=r,t;var o=v1_1();return t.key=o,function(r){return e?e.set(ldUserIdKey,r).catch(function(){n.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(o).then(function(){return t})}):Promise.reject(new LDInvalidUserError(invalidUser()))},r}function validate(e,n,r,t){var o=extend({logger:t},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},r),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames"};function a(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var u=extend({},e||{});return function(e){var n=e;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var r=i[e];t.warn(deprecated(e,r)),void 0===n[r]&&(n[r]=n[e]),delete n[e]}})}(u),u=function(e,n){var r=extend({},e);return Object.keys(n).forEach(function(e){void 0!==r[e]&&null!==r[e]||(r[e]=n[e])}),r}(u,o),(isNaN(u.flushInterval)||u.flushInterval<2e3)&&(u.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(u.samplingInterval)||u.samplingInterval<0)&&(u.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),u}function createConsoleLogger(e){var n=0;e&&(n="none"===e?100:["debug","info","warn","error"].indexOf(e));var r={};function t(e,r,t){e>=n&&r(t)}return r.debug=function(e){return t(0,console.log,e)},r.info=function(e){return t(1,console.info,e)},r.warn=function(e){return t(2,console.warn,e)},r.error=function(e){return t(3,console.error,e)},r}var _typeof$1="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},readyEvent="ready",successEvent="initialized",failedEvent="failed",changeEvent="change",internalChangeEvent="internal-change";function initialize(e,n,r,t,o){var i=function(){if(r&&r.logger)return r.logger;return o&&o.logger||createConsoleLogger("warn")}(),a=EventEmitter(i),u=validate(r,a,o,i),s=u.hash,c=u.sendEvents,l=e,v=Stream(t,u,l,s),f=u.eventProcessor||EventProcessor(t,u,l,a),d=Requestor(t,u,l),g={},m={},p=void 0,y=void 0,h=u.streaming,E=void 0,b=!1,k=!1,S=!0,U=u.stateProvider,D=Identity(null,function(e){if(U)return;e&&L({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),P=UserValidator(t.localStorage,i),w=void 0;function L(e){l&&(U&&U.enqueueEvent&&U.enqueueEvent(e)||(e.user?(S=!1,!c||k||t.isDoNotTrack()||(i.debug(debugEnqueueingEvent(e.kind)),f.enqueue(e))):S&&(i.warn(eventWithoutUser()),S=!1)))}function I(e,n,r){var t=D.getUser(),o=new Date,i=n?n.value:null;if(!u.allowFrequentDuplicateEvents){var a=JSON.stringify(i)+(t&&t.key?t.key:"")+e,s=g[a];if(s&&o-s<3e5)return;g[a]=o}var c={kind:"feature",key:e,user:t,value:i,variation:n?n.variationIndex:null,default:r,creationDate:o.getTime(),reason:n?n.reason:null},l=m[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),L(c)}function F(e,n,r){var t=void 0;if(m&&m.hasOwnProperty(e)&&m[e]&&!m[e].deleted){var o=m[e];t=C(o),null!==o.value&&void 0!==o.value||(t.value=n)}else t={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return r&&I(e,t,n),t}function C(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function T(){y=!0,D.getUser()&&v.connect(D.getUser(),{ping:function(){i.debug(debugStreamPing()),d.fetchFlagSettings(D.getUser(),s).then(function(e){return O(e||{})}).catch(function(e){a.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);i.debug(debugStreamPut()),O(n)},patch:function(e){var n=JSON.parse(e.data),r=m[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(debugStreamPatch(n.key));var t={},o=extend({},n);delete o.key,m[n.key]=o;var a=C(o);t[n.key]=r?{previous:r.value,current:a}:{current:a},N(t)}else i.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!m[n.key]||m[n.key].version<n.version){i.debug(debugStreamDelete(n.key));var r={};m[n.key]&&!m[n.key].deleted&&(r[n.key]={previous:m[n.key].value}),m[n.key]={version:n.version,deleted:!0},N(r)}else i.debug(debugStreamDeleteIgnored(n.key))}})}function R(){y&&(v.disconnect(),y=!1)}function O(e){var n={};if(!e)return Promise.resolve();for(var r in m)m.hasOwnProperty(r)&&m[r]&&(e[r]&&!deepEquals(e[r].value,m[r].value)?n[r]={previous:m[r].value,current:C(e[r])}:e[r]&&!e[r].deleted||(n[r]={previous:m[r].value}));for(var t in e)e.hasOwnProperty(t)&&e[t]&&(!m[t]||m[t].deleted)&&(n[t]={current:C(e[t])});return m=Object.assign({},e),N(n).catch(function(){})}function N(e){var n=Object.keys(e);if(n.length>0){var r={};n.forEach(function(n){var t=e[n].current,o=t?t.value:void 0,i=e[n].previous;a.emit(changeEvent+":"+n,o,i),r[n]=t?{current:o,previous:i}:{previous:i}}),a.emit(changeEvent,r),a.emit(internalChangeEvent,m),u.sendEventsOnlyForVariation||U||n.forEach(function(n){I(n,e[n].current)})}return p&&w?w.saveFlags(m).catch(function(){return null}):Promise.resolve()}function x(){var e=h||E&&void 0===h;e&&!y?T():!e&&y&&R()}function j(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}t.localStorage&&(w=new Store(t.localStorage,l,s,D,i));var A=new Promise(function(e){var n=a.on(readyEvent,function(){a.off(readyEvent,n),e()})}),_=new Promise(function(e,n){var r=a.on(successEvent,function(){a.off(successEvent,r),e()}),t=a.on(failedEvent,function(e){a.off(failedEvent,t),n(e)})});if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(w?p=!0:i.warn(localStorageUnavailable())),"object"===_typeof$1(u.bootstrap)&&(m=function(e){var n=Object.keys(e),r=e.$flagsState;!r&&n.length&&i.warn(bootstrapOldFormat()),!1===e.$valid&&i.warn(bootstrapInvalid());var t={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};r&&r[n]?o=extend(o,r[n]):o.version=0,t[n]=o}}),t}(u.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&&O(e.flags)})}else(function(){if(!e)return Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()));return P.validateUser(n).then(function(e){return D.setUser(e),"object"===_typeof$1(u.bootstrap)?z():p?w.loadFlags().catch(function(){return null}).then(function(e){return null==e?(m={},d.fetchFlagSettings(D.getUser(),s).then(function(e){return O(e||{})}).then(z).catch(function(e){var n=new LDFlagFetchError(errorFetchingFlags(e));K(n)})):(m=e,onNextTick(z),d.fetchFlagSettings(D.getUser(),s).then(function(e){return O(e)}).catch(function(e){return a.maybeReportError(e)}))}):d.fetchFlagSettings(D.getUser(),s).then(function(e){m=e||{},z()}).catch(function(e){m={},K(e)})})})().catch(function(e){return a.maybeReportError(e)});function q(e){l=e.environment,D.setUser(e.user),m=Object.assign({},e.flags),onNextTick(z)}function z(){i.info(clientInitialized()),b=!0,x(),a.emit(readyEvent),a.emit(successEvent)}function K(e){a.maybeReportError(e),a.emit(failedEvent,e),a.emit(readyEvent)}return{client:{waitForInitialization:function(){return _},waitUntilReady:function(){return A},identify:function(e,n,r){return k?wrapPromiseCallback(Promise.resolve({}),r):U?(i.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(m)),r)):wrapPromiseCallback((p&&w?w.clearFlags():Promise.resolve()).then(function(){return P.validateUser(e)}).then(function(e){return D.setUser(e)}).then(function(){return d.fetchFlagSettings(D.getUser(),n)}).then(function(e){var n=transformVersionedValuesToValues(e);return e?O(e).then(function(){return n}):n}).then(function(e){return y&&T(),e}).catch(function(e){return a.maybeReportError(e),Promise.reject(e)}),r)},getUser:function(){return D.getUser()},variation:function(e,n){return F(e,n,!0).value},variationDetail:function(e,n){return F(e,n,!0)},track:function(e,n){"string"==typeof e?(t.customEventFilter&&!t.customEventFilter(e)&&i.warn(unknownCustomEventKey(e)),L({kind:"custom",key:e,data:n,user:D.getUser(),url:t.getCurrentUrl(),creationDate:(new Date).getTime()})):a.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,n,r){j(e)?(E=!0,b&&x(),a.on(e,n,r)):a.on.apply(a,arguments)},off:function(e){if(a.off.apply(a,arguments),j(e)){var n=!1;a.getEvents().forEach(function(e){j(e)&&a.getEventListenerCount(e)>0&&(n=!0)}),n||(E=!1,y&&void 0===h&&R())}},setStreaming:function(e){var n=null===e?void 0:e;n!==h&&(h=n,x())},flush:function(e){return wrapPromiseCallback(c?f.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!m)return e;for(var n in m)m.hasOwnProperty(n)&&(e[n]=F(n,null,!u.sendEventsOnlyForVariation).value);return e},close:function(e){if(k)return wrapPromiseCallback(Promise.resolve(),e);var n=function(){k=!0,m={}};return wrapPromiseCallback(Promise.resolve().then(function(){if(R(),c)return f.stop(),f.flush()}).then(n).catch(n),e)}},options:u,emitter:a,ident:D,logger:i,requestor:d,start:function(){c&&f.start()},enqueueEvent:L,getFlagsInternal:function(){return m},getEnvironmentId:function(){return l},internalChangeEventName:internalChangeEvent}}var version="2.12.3";exports.initialize=initialize,exports.version=version,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.messages=messages,exports.utils=utils;
//# sourceMappingURL=ldclient-common.cjs.js.map

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

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

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

@@ -79,3 +79,5 @@ /**

* storage. Alternatively, an [[LDFlagSet]] can be specified which will be used as the initial
* source of flag values.
* source of flag values. In the latter case, the flag values will be available via [[variation]]
* immediately after calling `initialize()` (normally they would not be available until the
* client signals that it is ready).
*

@@ -82,0 +84,0 @@ * For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/docs/js-sdk-reference#section-bootstrapping).

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