launchdarkly-js-sdk-common
Advanced tools
Comparing version 3.5.1 to 3.6.0
@@ -5,2 +5,9 @@ # Change log | ||
## [3.6.0] - 2022-04-21 | ||
### Added: | ||
- `LDOptionsBase.application`, for configuration of application metadata that may be used in LaunchDarkly analytics or other product features. This does not affect feature flag evaluations. | ||
### Fixed: | ||
- The `baseUrl`, `streamUrl`, and `eventsUrl` properties now work properly regardless of whether the URL string has a trailing slash. Previously, a trailing slash would cause request URL paths to have double slashes. | ||
## [3.5.1] - 2022-02-17 | ||
@@ -7,0 +14,0 @@ ### Fixed: |
@@ -1,2 +0,2 @@ | ||
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ownKeys(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function _objectSpread2(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function createCustomError(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError"),LDInvalidDataError=createCustomError("LaunchDarklyInvalidDataError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,LDInvalidDataError:LDInvalidDataError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var n,t=e.length,r=t%3,o=[],i=16383,a=0,s=t-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(n=e[t-1],o.push(lookup[n>>2]+lookup[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(lookup[n>>10]+lookup[n>>4&63]+lookup[n<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=isArray(n),s=isArray(t);if(a&&s){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=s)return!1;var u=n instanceof Date,c=t instanceof Date;if(u!=c)return!1;if(u&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var d=keyList(n);if((o=d.length)!==keyList(t).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(t,d[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=d[r]],t[i]))return!1;return!0}return n!=n&&t!=t},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var n=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(n))}function stringToBytes(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,n){return fastDeepEqual(e,n)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function transformValuesToVersionedValues(e){var n={};for(var t in e)objectHasOwnProperty(e,t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var t in e)objectHasOwnProperty(e,t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function getLDUserAgentString(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function getLDHeaders(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function transformHeaders(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(_objectSpread2({},e)):e}function extend(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return _objectSpread2({},e,{},n)},{})}function objectHasOwnProperty(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function sanitizeUser(e){if(!e)return e;var n;for(var t in userAttrsToStringify){var r=userAttrsToStringify[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||_objectSpread2({},e))[r]=String(o))}return n||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,transformHeaders:transformHeaders,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,n){return e(n={exports:{}},n.exports),n.exports}for(var rngBrowser=createCommonjsModule(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var t=n||0,r=byteToHex;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var s=rngBrowser();null==i&&(i=_nodeId=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=_clockseq=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=u-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||_lastMSecs<u)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=u,_clockseq=a;var f=(1e4*(268435455&(u+=122192928e5))+(_lastNSecs=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=u/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return n||bytesToUuid_1(o)}var v1_1=v1,MAX_URL_LENGTH=2e3;function EventSender(s,e,u){var t="/a/"+e+".gif",c=extend({"Content-Type":"application/json"},getLDHeaders(s,u)),l=s.httpFallbackPing,f={};return f.sendChunk=function(e,r,o,n){var i=JSON.stringify(e),a=o?null:v1_1();return n?function n(t){var e=o?c:extend({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return s.httpRequest("POST",r,transformHeaders(e,u),i).promise.then(function(e){if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+base64URLEncode(i)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!s.httpRequest)return Promise.resolve();var r,o=s.httpAllowsPost();r=o?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(f.sendChunk(r[a],n,t,o));return Promise.all(i)},f}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:s,features:e}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var n={},u=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,o){return Object.keys(r).reduce(function(e,n){var t=e;return o(n)&&(!function(e){return!l[e]&&(u||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],o=extend({},o,a[1])}var s=Object.keys(o);return s.length&&(s.sort(),r.privateAttrs=s),r},n}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(e){return"local storage is unavailable: "+errorString(e)},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},invalidData=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(isHttpErrorRecoverable(e)?t:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,n){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+n+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},wrongOptionTypeBoolean=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},optionBelowMinimum=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,invalidData:invalidData,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent});function EventProcessor(e,n,t){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,t,n),u=n.eventsUrl+"/events/bulk/"+t,c=EventSummarizer(),l=UserFilter(n),f=n.inlineUsersInEvents,d=n.samplingInterval,v=n.eventCapacity,g=n.flushInterval,p=n.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===d||0===Math.floor(Math.random()*d)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){if(!h){var n=!1,t=!1;if(c.summarizeEvent(e),"feature"===e.kind?E()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>y&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=E(),n&&k(function(e){var n=extend({},e);return"alias"===e.kind||(f||"identify"===e.kind?n.user=l.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=extend({},e,{kind:"debug"});r.user=l.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,k(r)}}},a.flush=function(){if(h)return Promise.resolve();var e=m,n=c.getSummary();return c.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(m=[],p.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=o[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!o[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(r){var n=!1,t=!1,o=null,e=null,i=new Promise(function(n){r.on(readyEvent,function e(){r.off(readyEvent,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(o):e=new Promise(function(n,t){r.on(successEvent,function e(){r.off(successEvent,e),n()}),r.on(failureEvent,function e(n){r.off(failureEvent,e),t(n)})}))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,r.emit(successEvent),r.emit(readyEvent))},signalFailure:function(e){n||t||(t=!0,o=e,r.emit(failureEvent,e),r.emit(readyEvent)),r.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function PersistentFlagStore(t,r,o,i){var a={};function s(){var e="",n=i.getUser();return n&&(e=o||btoa(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=extend({},e,{$schema:1});return t.set(s(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(s())},a}function PersistentStorage(r,n){function o(e){t||(t=!0,n.warn(localStorageUnavailable(e)))}var e={},t=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(n){r?r.get(e).then(n).catch(function(e){o(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){r?r.set(e,t).then(function(){return n(!0)}).catch(function(e){o(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){r?r.clear(e).then(function(){return n(!0)}).catch(function(e){o(e),n(!1)}):n(!1)})},e}var streamReadTimeoutMillis=3e5;function Stream(o,i,a,n){var s,u=i.streamUrl,c=i.logger,e={},l=u+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=getLDHeaders(o,i),g=!1,p=null,m=null,y=null,h=null,b=null;function E(e){g||(c.warn(streamError(e,t)),g=!0),S(!1),D(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:streamReadTimeoutMillis};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(y)):(e=u+"/ping/"+a,n=""):e=l+"/"+base64URLEncode(JSON.stringify(y)),t.headers=transformHeaders(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,D(),c.info(streamConnecting(e)),s=(new Date).getTime(),p=o.eventSourceFactory(e,t),b)objectHasOwnProperty(b,r)&&p.addEventListener(r,b[r]);p.onerror=E}}function D(){p&&(c.info(streamClosing()),p.close(),p=null)}function S(e){s&&n&&n.recordStreamInit(s,!e,(new Date).getTime()-s),s=null}return e.connect=function(e,n,t){y=e,h=n,b={};function r(n){b[n]=function(e){S(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,D()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function promiseCoalescer(t){var r,o,i,a,e={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){i=e,a=n}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(s,u,a){var c=u.baseUrl,l=u.useReport,f=u.evaluationReasons,d=u.logger,e={},v={};function g(e,n){if(!s.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var t=n?"REPORT":"GET",r=getLDHeaders(s,u);n&&(r["Content-Type"]=jsonContentType);var o=v[e];o||(o=promiseCoalescer(function(){delete v[e]}),v[e]=o);var i=s.httpRequest(t,e,transformHeaders(r,u),n),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&e.header("content-type").substring(0,jsonContentType.length)===jsonContentType)return JSON.parse(e.body);var n=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(n))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=base64URLEncode(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(debugPolling(r)),g(r,o)},e}function Identity(e,t){var r,n={};return n.setUser=function(e){var n=r&&clone(r);(r=sanitizeUser(e))&&t&&t(clone(r),n)},n.getUser=function(){return r?clone(r):null},e&&n.setUser(e),n}var ldUserIdKey="ld:$anonUserId";function UserValidator(r){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?r.get(ldUserIdKey).then(function(e){if(e)return t.key=e,t;var n=v1_1();return function(e){return r.set(ldUserIdKey,e)}(t.key=n).then(function(){return t})}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var logLevels=["debug","info","warn","error","none"];function commonBasicLogger(e,a){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],u=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<logLevels.length;t++)logLevels[t]===e.level&&(r=t);for(var o={},i=function(e){var n=logLevels[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=u?n+": "+c:c;if(1!==t.length&&a){var i=_toConsumableArray(t);i[0]=o+i[0],r=a.apply(void 0,_toConsumableArray(i))}else r=o+t[0];try{s[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<logLevels.length;l++)i(l);return o}function validateLogger(n){logLevels.forEach(function(e){if("none"!==e&&(!n[e]||"function"!=typeof n[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}function createConsoleLogger(e,n){return commonBasicLogger({level:e,prefix:n})}var baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function validate(e,n,t,r){var a=extend({logger:{default:r}},baseOptionDefs,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var i,u,c,l,f=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=_typeof(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var n=o[e];r&&r.warn(deprecated(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e])}}),u=extend({},f),Object.keys(a).forEach(function(e){void 0!==u[e]&&null!==u[e]||(u[e]=a[e]&&a[e].default)}),l=extend({},c=f=u),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)s(unknownOption(e));else{var r=t.type||d(t.default);if("any"!==r){var o=r.split("|"),i=d(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,s(wrongOptionTypeBoolean(e,i))):(s(wrongOptionType(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(s(optionBelowMinimum(e,n,t.minimum)),l[e]=t.minimum)}}}}),validateLogger((f=l).logger),f}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate}),baseOptionDefs$1=configuration.baseOptionDefs;function DiagnosticId(e){var n={diagnosticId:v1_1()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n}function DiagnosticsAccumulator(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}}function DiagnosticsManager(n,r,e,t,o,i,a){var s,u,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=_objectSpread2({},n.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:i.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:i.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function y(e){i.logger&&i.logger.debug(messages.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){y(function(){var e=(new Date).getTime(),n=_objectSpread2({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps());return c&&(n=_objectSpread2({},n,{},m())),v.reset(e),n}()),u=setTimeout(h,d),s=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=_objectSpread2({},v.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),s=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,d)}):(y(_objectSpread2({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},m())),u=setTimeout(h,d))},p.stop=function(){u&&clearTimeout(u)},p.setStreaming=function(e){g=e},p}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager,changeEvent="change",internalChangeEvent="internal-change";function initialize(e,n,t,i,r){var a,o,s,u=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||createConsoleLogger("warn")}(),c=EventEmitter(u),l=InitializationState(c),f=validate(t,c,r,u),d=f.sendEvents,v=e,g=f.hash,p=PersistentStorage(i.localStorage,u),m=EventSender(i,v,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?diagnosticEvents_1(v):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(i,p,b,m,v,f,h):null,k=Stream(i,f,v,b),D=f.eventProcessor||EventProcessor(i,f,v,b,c,m),S=Requestor(i,f,v),w={},P={},U=f.streaming,L=!1,O=!1,I=!0,T=f.stateProvider,C=Identity(null,function(e,n){(function(e){if(T)return;e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&V(e,n)}),_=UserValidator(p),j=p.isEnabled()?new PersistentFlagStore(p,v,g,C,u):null;function F(e){if(v&&!(T&&T.enqueueEvent&&T.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(I&&(u.warn(eventWithoutUser()),I=!1));I=!1}!d||O||i.isDoNotTrack()||(u.debug(debugEnqueueingEvent(e.kind)),D.enqueue(e))}}function R(e,n,t,r){var o=C.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=w[s];if(u&&i-u<3e5)return;w[s]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=N(o));var l=P[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),F(c)}function x(e,n,t,r){var o;if(P&&objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){var i=P[e];o=A(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&R(e,o,n,r),o}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function N(e){return e.anonymous?"anonymousUser":"user"}function V(e,n){T||e&&n&&F({kind:"alias",key:e.key,contextKind:N(e),previousKey:n.key,previousContextKind:N(n),creationDate:(new Date).getTime()})}function H(){if(o=!0,C.getUser()){var a=function(e){try{return JSON.parse(e)}catch(e){return void c.maybeReportError(new LDInvalidDataError(invalidData()))}};k.connect(C.getUser(),g,{ping:function(){u.debug(debugStreamPing());var n=C.getUser();S.fetchFlagSettings(n,g).then(function(e){deepEquals(n,C.getUser())&&M(e||{})}).catch(function(e){c.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=a(e.data);n&&(u.debug(debugStreamPut()),M(n))},patch:function(e){var n=a(e.data);if(n){var t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){u.debug(debugStreamPatch(n.key));var r={},o=extend({},n);delete o.key;var i=A(P[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},z(r)}else u.debug(debugStreamPatchIgnored(n.key))}},delete:function(e){var n=a(e.data);if(n)if(!P[n.key]||P[n.key].version<n.version){u.debug(debugStreamDelete(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},z(t)}else u.debug(debugStreamDeleteIgnored(n.key))}})}}function q(){o&&(k.disconnect(),o=!1)}function M(e){var n={};if(!e)return Promise.resolve();for(var t in P)objectHasOwnProperty(P,t)&&P[t]&&(e[t]&&!deepEquals(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:A(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var r in e)objectHasOwnProperty(e,r)&&e[r]&&(!P[r]||P[r].deleted)&&(n[r]={current:A(e[r])});return P=_objectSpread2({},e),z(n).catch(function(){})}function z(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;c.emit(changeEvent+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),c.emit(changeEvent,i),c.emit(internalChangeEvent,P),f.sendEventsOnlyForVariation||T||e.forEach(function(e){R(e,o[e].current)})}return a&&j?j.saveFlags(P):Promise.resolve()}function K(){var e=U||s&&void 0===U;e&&!o?H():!e&&o&&q(),E&&E.setStreaming(e)}function B(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(j?a=!0:u.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",o=t[r];!o&&e.length&&u.warn(bootstrapOldFormat()),!1===t.$valid&&u.warn(bootstrapInvalid());var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};o&&o[e]?n=extend(n,o[e]):n.version=0,i[e]=n}}),i}(f.bootstrap)),T){var J=T.getInitialState();J?$(J):T.on("init",$),T.on("update",function(e){e.user&&C.setUser(e.user);e.flags&&M(e.flags)})}else(e?_.validateUser(n).then(function(e){return C.setUser(e),"object"===_typeof(f.bootstrap)?G():a?j.loadFlags().then(function(e){return null==e?(P={},S.fetchFlagSettings(C.getUser(),g).then(function(e){return M(e||{})}).then(G).catch(function(e){W(new LDFlagFetchError(errorFetchingFlags(e)))})):(P=e,onNextTick(G),S.fetchFlagSettings(C.getUser(),g).then(function(e){return M(e)}).catch(function(e){return c.maybeReportError(e)}))}):S.fetchFlagSettings(C.getUser(),g).then(function(e){P=e||{},G()}).catch(function(e){P={},W(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(W);function $(e){v=e.environment,C.setUser(e.user),P=_objectSpread2({},e.flags),onNextTick(G)}function G(){u.info(clientInitialized()),L=!0,K(),l.signalSuccess()}function W(e){l.signalFailure(e)}return{client:{waitForInitialization:function(){return l.getInitializationPromise()},waitUntilReady:function(){return l.getReadyPromise()},identify:function(e,r,n){return O?wrapPromiseCallback(Promise.resolve({}),n):T?(u.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(P)),n)):wrapPromiseCallback((a&&j?j.clearFlags():Promise.resolve()).then(function(){return _.validateUser(e)}).then(function(t){return S.fetchFlagSettings(t,r).then(function(e){var n=transformVersionedValuesToValues(e);return C.setUser(t),g=r,e?M(e).then(function(){return n}):n})}).then(function(e){return o&&H(),e}).catch(function(e){return c.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return C.getUser()},variation:function(e,n){return x(e,n,!0,!1).value},variationDetail:function(e,n){return x(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&u.warn(unknownCustomEventKey(e));var r=C.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=N(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),F(o)}else c.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},alias:V,on:function(e,n,t){B(e)?(s=!0,L&&K(),c.on(e,n,t)):c.on.apply(c,arguments)},off:function(e){if(c.off.apply(c,arguments),B(e)){var n=!1;c.getEvents().forEach(function(e){B(e)&&0<c.getEventListenerCount(e)&&(n=!0)}),n||(s=!1,o&&void 0===U&&q())}},setStreaming:function(e){var n=null===e?void 0:e;n!==U&&(U=n,K())},flush:function(e){return wrapPromiseCallback(d?D.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)objectHasOwnProperty(P,n)&&(e[n]=x(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(O)return wrapPromiseCallback(Promise.resolve(),e);function n(){O=!0,P={}}return wrapPromiseCallback(Promise.resolve().then(function(){if(q(),E&&E.stop(),d)return D.stop(),D.flush()}).then(n).catch(n),e)}},options:f,emitter:c,ident:C,logger:u,requestor:S,start:function(){d&&(E&&E.start(),D.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:function(){return v},internalChangeEventName:internalChangeEvent}}var version="3.5.1";exports.commonBasicLogger=commonBasicLogger,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version; | ||
"use strict";function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function createCustomError(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return(t.prototype=new Error).name=e,t.prototype.constructor=t}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError"),LDInvalidDataError=createCustomError("LaunchDarklyInvalidDataError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,LDInvalidDataError:LDInvalidDataError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(t=e[n-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i=isArray(t),a=isArray(n);if(i&&a){if((s=t.length)!=n.length)return!1;for(r=s;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(i!=a)return!1;i=t instanceof Date,a=n instanceof Date;if(i!=a)return!1;if(i&&a)return t.getTime()==n.getTime();i=t instanceof RegExp,a=n instanceof RegExp;if(i!=a)return!1;if(i&&a)return t.toString()==n.toString();var s,u=keyList(t);if((s=u.length)!==keyList(n).length)return!1;for(r=s;0!=r--;)if(!hasProp.call(n,u[r]))return!1;for(r=s;0!=r--;)if(!e(t[o=u[r]],n[o]))return!1;return!0}return t!=t&&n!=n},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function appendUrlPath(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t}function btoa(e){e=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(e))}function stringToBytes(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,t){return fastDeepEqual(e,t)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,t){e=e.then(function(e){return t&&setTimeout(function(){t(null,e)},0),e},function(e){if(!t)return Promise.reject(e);setTimeout(function(){t(e,null)},0)});return t?void 0:e}function transformValuesToVersionedValues(e){var t,n={};for(t in e)objectHasOwnProperty(e,t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var t,n={};for(t in e)objectHasOwnProperty(e,t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,t){for(var n,r=t.slice(0),o=[],i=e;0<r.length;){for(n=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<n.length?r.unshift(a):n.push(a)}i=e,o.push(n)}return o}function getLDUserAgentString(e){var t=e.version||"3.6.0";return e.userAgent+"/"+t}function extend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(function(e,t){return _objectSpread2(_objectSpread2({},e),t)},{})}function objectHasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sanitizeUser(e){if(!e)return e;var t,n;for(n in userAttrsToStringify){var r=userAttrsToStringify[n],o=e[r];void 0!==o&&"string"!=typeof o&&((t=t||_objectSpread2({},e))[r]=String(o))}return t||e}var utils=Object.freeze({__proto__:null,appendUrlPath:appendUrlPath,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}for(var rngBrowser=createCommonjsModule(function(e){var t,n,r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);r?(t=new Uint8Array(16),e.exports=function(){return r(t),t}):(n=new Array(16),e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n})}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,t){var t=t||0,n=byteToHex;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[+t]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,t,n){var r=t&&n||0,o=t||[],i=(e=e||{}).node||_nodeId,n=void 0!==e.clockseq?e.clockseq:_clockseq,a=(null!=i&&null!=n||(a=rngBrowser(),null==i&&(i=_nodeId=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==n&&(n=_clockseq=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),s=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,u=a-_lastMSecs+(s-_lastNSecs)/1e4;if(u<0&&void 0===e.clockseq&&(n=n+1&16383),1e4<=(s=(u<0||_lastMSecs<a)&&void 0===e.nsecs?0:s))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=a,_clockseq=n;u=(1e4*(268435455&(a+=122192928e5))+(_lastNSecs=s))%4294967296,o[r++]=u>>>24&255,o[r++]=u>>>16&255,o[r++]=u>>>8&255,o[r++]=255&u,e=a/4294967296*1e4&268435455;o[r++]=e>>>8&255,o[r++]=255&e,o[r++]=e>>>24&15|16,o[r++]=e>>>16&255,o[r++]=n>>>8|128,o[r++]=255&n;for(var c=0;c<6;++c)o[r+c]=i[c];return t||bytesToUuid_1(o)}var v1_1=v1,logLevels=["debug","info","warn","error","none"];function commonBasicLogger(e,s){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(t){return function(e){console&&console[t]&&console[t].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",n=1;if(e&&e.level)for(var r=0;r<logLevels.length;r++)logLevels[r]===e.level&&(n=r);for(var o={},i=function(e){var i,a=logLevels[e];"none"!==a&&(e<n?o[a]=function(){}:(i=e,o[a]=function(){var e=i,t=a,n=arguments;if(!(n.length<1)){var r=c?t+": "+l:l,o=1!==n.length&&s?((o=_toConsumableArray(n))[0]=r+o[0],s.apply(void 0,_toConsumableArray(o))):r+n[0];try{u[e](o)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}))},a=0;a<logLevels.length;a++)i(a);return o}function validateLogger(t){logLevels.forEach(function(e){if("none"!==e&&(!t[e]||"function"!=typeof t[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}function createConsoleLogger(e,t){return commonBasicLogger({level:e,prefix:t})}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(e){return"local storage is unavailable: "+errorString(e)},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},invalidData=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,t){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+t+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,t,n){return'Config option "'+e+'" should be of type '+t+", got "+n+", using default value"},wrongOptionTypeBoolean=function(e,t){return'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"},optionBelowMinimum=function(e,t,n){return'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,invalidData:invalidData,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent,invalidTagValue:invalidTagValue}),baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:applicationConfigValidator}},allowedTagCharacters=/^(\w|\.|-)+$/;function validateTagValue(e,t,n,r){if("string"==typeof n&&n.match(allowedTagCharacters))return n;r.warn(invalidTagValue(e))}function applicationConfigValidator(e,t,n,r){var o={};return n.id&&(o.id=validateTagValue("".concat(e,".id"),t,n.id,r)),n.version&&(o.version=validateTagValue("".concat(e,".version"),t,n.version,r)),o}function validate(e,t,n,a){var s=extend({logger:{default:a}},baseOptionDefs,n),r={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){onNextTick(function(){t&&t.maybeReportError(new LDInvalidArgumentError(e))})}var o,i,c,l,n=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=_typeof(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}return o=n,Object.keys(r).forEach(function(e){var t;void 0!==o[e]&&(t=r[e],a&&a.warn(deprecated(e,t)),t&&(void 0===o[t]&&(o[t]=o[e]),delete o[e]))}),i=extend({},n),Object.keys(s).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=s[e]&&s[e].default)}),l=extend({},c=n=i),Object.keys(c).forEach(function(e){var t,n,r,o,i=c[e];null!=i&&(void 0===(t=s[e])?u(unknownOption(e)):(n=t.type||d(t.default),(r=t.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==n&&(r=n.split("|"),o=d(i),r.indexOf(o)<0?"boolean"===n?(l[e]=!!i,u(wrongOptionTypeBoolean(e,o))):(u(wrongOptionType(e,n,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&i<t.minimum&&(u(optionBelowMinimum(e,i,t.minimum)),l[e]=t.minimum))))}),validateLogger((n=l).logger),n}function getTags(e){var t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate,getTags:getTags});function getLDHeaders(e,t){if(t&&!t.sendLDHeaders)return{};var e={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)},n=(t&&t.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName),getTags(t)),t=Object.keys(n);return t.length&&(e["x-launchdarkly-tags"]=t.sort().flatMap(function(t){return Array.isArray(n[t])?n[t].sort().map(function(e){return"".concat(t,"/").concat(e)}):["".concat(t,"/").concat(n[t])]}).join(" ")),e}function transformHeaders(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(_objectSpread2({},e)):e}var MAX_URL_LENGTH=2e3;function EventSender(s,e,u){var c="/a/"+e+".gif",l=extend({"Content-Type":"application/json"},getLDHeaders(s,u)),d=s.httpFallbackPing,f={};return f.sendChunk=function(e,t,r,n){var o=JSON.stringify(e),i=r?null:v1_1();function a(n){var e=r?l:extend({},l,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":i});return s.httpRequest("POST",t,transformHeaders(e,u),o).promise.then(function(e){var t;if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&n?a(!1):(t={status:(e=e).status},(e=e.header("date"))&&(e=Date.parse(e))&&(t.serverTime=e),t)}).catch(function(){return n?a(!1):Promise.reject()})}return n?a(!0).catch(function(){}):(d&&d(t+c+"?d="+base64URLEncode(o)),Promise.resolve())},f.sendEvents=function(e,t,n){if(!s.httpRequest)return Promise.resolve();for(var r=s.httpAllowsPost(),o=r?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-t.length,e),i=[],a=0;a<o.length;a++)i.push(f.sendChunk(o[a],t,n,r));return Promise.all(i)},f}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){var t,n;"feature"===e.kind&&(t=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(n=u[t])?n.count=n.count+1:u[t]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate))},e.getSummary=function(){var e,t={},n=!0;for(e in u){var r=u[e],o=t[r.key],i=(o||(o={default:r.default,counters:[]},t[r.key]=o),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:s,features:t}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var t={},a=e.allAttributesPrivate,s=e.privateAttributeNames||[],u={key:!0,custom:!0,anonymous:!0},c={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return t.filterUser=function(e){if(!e)return null;function t(n,r){return Object.keys(n).reduce(function(e,t){return r(t)&&(o(t)?e[1][t]=!0:e[0][t]=n[t]),e},[{},{}])}var n=e.privateAttributeNames||[],o=function(e){return!u[e]&&(a||-1!==n.indexOf(e)||-1!==s.indexOf(e))},r=t(e,function(e){return c[e]}),i=r[0],r=r[1],e=(e.custom&&(e=t(e.custom,function(){return 1}),i.custom=e[0],r=extend({},r,e[1])),Object.keys(r));return e.length&&(e.sort(),i.privateAttrs=e),i},t}function EventProcessor(e,t,n){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,n,t),u=appendUrlPath(t.eventsUrl,"/events/bulk/"+n),c=EventSummarizer(),l=UserFilter(t),d=t.inlineUsersInEvents,f=t.samplingInterval,v=t.eventCapacity,g=t.flushInterval,p=t.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===f||0===Math.floor(Math.random()*f)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){var t,n,r;h||(t=r=!1,c.summarizeEvent(e),"feature"===e.kind?E()&&(r=!!e.trackEvents,t=!!(n=e).debugEventsUntilDate&&(n.debugEventsUntilDate>y&&n.debugEventsUntilDate>(new Date).getTime())):r=E(),r&&k((r=extend({},n=e),"alias"!==n.kind&&(d||"identify"===n.kind?r.user=l.filterUser(n.user):(r.userKey=n.user.key,delete r.user),"feature"===n.kind&&(delete r.trackEvents,delete r.debugEventsUntilDate)),r)),t&&((r=extend({},e,{kind:"debug"})).user=l.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,k(r)))},a.flush=function(){if(h)return Promise.resolve();var e=m,t=c.getSummary();return c.clearSummary(),t&&(t.kind="summary",e.push(t)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(m=[],p.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(t){var e={},o={};return e.on=function(e,t,n){o[e]=o[e]||[],o[e]=o[e].concat({handler:t,context:n})},e.off=function(e,t,n){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===t&&o[e][r].context===n&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var t=o[e].slice(0),n=0;n<t.length;n++)t[n].handler.apply(t[n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o["error"]?this.emit("error",e):(t||console).error(e.message))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(o){var t=!1,n=!1,r=null,e=null,i=new Promise(function(t){o.on(readyEvent,function e(){o.off(readyEvent,e),t()})}).catch(function(){});return{getInitializationPromise:function(){return e||(t?Promise.resolve():n?Promise.reject(r):e=new Promise(function(t,n){function r(e){o.off(failureEvent,r),n(e)}o.on(successEvent,function e(){o.off(successEvent,e),t()}),o.on(failureEvent,r)}))},getReadyPromise:function(){return i},signalSuccess:function(){t||n||(t=!0,o.emit(successEvent),o.emit(readyEvent))},signalFailure:function(e){t||n||(n=!0,r=e,o.emit(failureEvent,e),o.emit(readyEvent)),o.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function PersistentFlagStore(t,n,r,o){var i={};function a(){var e="",t=o.getUser();return t&&(e=r||btoa(JSON.stringify(t))),"ld:"+n+":"+e}return i.loadFlags=function(){return t.get(a()).then(function(e){if(null==e)return null;try{var t,n=JSON.parse(e);return n&&(void 0===(t=n.$schema)||t<1?n=transformValuesToVersionedValues(n):delete n.$schema),n}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=extend({},e,{$schema:1});return t.set(a(),JSON.stringify(e))},i.clearFlags=function(){return t.clear(a())},i}function PersistentStorage(r,t){function o(e){n||(n=!0,t.warn(localStorageUnavailable(e)))}var e={},n=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(t){r?r.get(e).then(t).catch(function(e){o(e),t(void 0)}):t(void 0)})},e.set=function(e,n){return new Promise(function(t){r?r.set(e,n).then(function(){return t(!0)}).catch(function(e){o(e),t(!1)}):t(!1)})},e.clear=function(e){return new Promise(function(t){r?r.clear(e).then(function(){return t(!0)}).catch(function(e){o(e),t(!1)}):t(!1)})},e}var streamReadTimeoutMillis=3e5;function Stream(o,i,a,t){var s,u=i.streamUrl,c=i.logger,e={},l=appendUrlPath(u,"/eval/"+a),d=i.useReport,f=i.evaluationReasons,n=i.streamReconnectDelay,v=getLDHeaders(o,i),g=!1,p=null,m=null,y=null,h=null,b=null;function E(e){g||(c.warn(streamError(e,n)),g=!0),S(!1),D(),k(n)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){m=null;var e,t="",n={headers:v,readTimeoutMillis:streamReadTimeoutMillis};if(o.eventSourceFactory){for(var r in null!=h&&(t="h="+h),d?o.eventSourceAllowsReport?(e=l,n.method="REPORT",n.headers["Content-Type"]="application/json",n.body=JSON.stringify(y)):(e=appendUrlPath(u,"/ping/"+a),t=""):e=l+"/"+base64URLEncode(JSON.stringify(y)),n.headers=transformHeaders(n.headers,i),e=e+((t=f?t+(t?"&":"")+"withReasons=true":t)?"?":"")+t,D(),c.info(streamConnecting(e)),s=(new Date).getTime(),p=o.eventSourceFactory(e,n),b)objectHasOwnProperty(b,r)&&p.addEventListener(r,b[r]);p.onerror=E}}function D(){p&&(c.info(streamClosing()),p.close(),p=null)}function S(e){s&&t&&t.recordStreamInit(s,!e,(new Date).getTime()-s),s=null}return e.connect=function(e,t,n){y=e,h=t,b={};for(var r in n||{})!function(t){b[t]=function(e){S(!(g=!1)),n[t]&&n[t](e)}}(r);k()},e.disconnect=function(){clearTimeout(m),m=null,D()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function promiseCoalescer(n){var r,o,i,a,e={addPromise:function(t,e){r=t,o&&o(),o=e,t.then(function(e){r===t&&(i(e),n&&n())},function(e){r===t&&(a(e),n&&n())})}};return e.resultPromise=new Promise(function(e,t){i=e,a=t}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(a,s,i){var u=s.baseUrl,c=s.useReport,l=s.evaluationReasons,d=s.logger,e={},f={};function v(e,t){if(!a.httpRequest)return new Promise(function(e,t){t(new LDFlagFetchError(httpUnavailable()))});var n=t?"REPORT":"GET",r=getLDHeaders(a,s),o=(t&&(r["Content-Type"]=jsonContentType),f[e]),i=(o||(o=promiseCoalescer(function(){delete f[e]}),f[e]=o),a.httpRequest(n,e,transformHeaders(r,s),t)),n=i.promise.then(function(e){var t;return 200===e.status?e.header("content-type")&&e.header("content-type").substring(0,jsonContentType.length)===jsonContentType?JSON.parse(e.body):(t=invalidContentType(e.header("content-type")||""),Promise.reject(new LDFlagFetchError(t))):Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(n,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return v(appendUrlPath(u,e),null)},e.fetchFlagSettings=function(e,t){var n,r,o="";return c?(n=[u,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=base64URLEncode(JSON.stringify(e)),n=[u,"/sdk/evalx/",i,"/users/",e].join("")),t&&(o="h="+t),d.debug(debugPolling(n=n+((o=l?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),v(n,r)},e}function Identity(e,n){var r,t={setUser:function(e){var t=r&&clone(r);(r=sanitizeUser(e))&&n&&n(clone(r),t)},getUser:function(){return r?clone(r):null}};return e&&t.setUser(e),t}var ldUserIdKey="ld:$anonUserId";function UserValidator(n){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?n.get(ldUserIdKey).then(function(e){return e?(t.key=e,t):(e=v1_1(),t.key=e,n.set(ldUserIdKey,e).then(function(){return t}))}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var baseOptionDefs$1=configuration.baseOptionDefs,appendUrlPath$1=utils.appendUrlPath;function DiagnosticId(e){var t={diagnosticId:v1_1()};return e&&(t.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),t}function DiagnosticsAccumulator(e){var t,n,r,o;function i(e){t=e,r=n=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}},setProps:function(e){t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){n++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,t,n){o.push({timestamp:e,failed:t,durationMillis:n})},reset:i}}function DiagnosticsManager(t,r,e,n,o,i,a){var s,u,c=!!t.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",d=appendUrlPath$1(i.eventsUrl,"/events/diagnostic/"+o),f=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,o={};function p(){return{sdk:function(){var e=_objectSpread2({},t.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:i.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:i.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},platform:t.diagnosticPlatformData}}function m(e){i.logger&&i.logger.debug(messages.debugPostingDiagnosticEvent(e)),n.sendEvents(e,d,!0).then(function(){}).catch(function(){})}function y(){var e,t;m((t=(new Date).getTime(),e=_objectSpread2({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:t},v.getProps()),c&&(e=_objectSpread2(_objectSpread2({},e),p())),v.reset(t),e)),u=setTimeout(y,f),s=(new Date).getTime(),c&&r.isEnabled()&&(t=_objectSpread2({},v.getProps()),r.set(l,JSON.stringify(t)))}return o.start=function(){var n;c?(n=function(e){var t;e?(e=(s||0)+f)<=(t=(new Date).getTime())?y():u=setTimeout(y,e-t):0===Math.floor(4*Math.random())?y():u=setTimeout(y,f)},r.isEnabled()?r.get(l).then(function(e){if(e)try{var t=JSON.parse(e);v.setProps(t),s=t.dataSinceDate}catch(e){}n(!0)}).catch(function(){n(!1)}):n(!1)):(m(_objectSpread2({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),u=setTimeout(y,f))},o.stop=function(){u&&clearTimeout(u)},o.setStreaming=function(e){g=e},o}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager,changeEvent="change",internalChangeEvent="internal-change";function initialize(A,x,e,o,t){var n,i,r,a,N,s,u,c=function(){if(e&&e.logger)return e.logger;return t&&t.logger&&t.logger.default||createConsoleLogger("warn")}(),l=EventEmitter(c),d=InitializationState(l),f=validate(e,l,t,c),v=f.sendEvents,g=A,p=f.hash,m=PersistentStorage(o.localStorage,c),V=EventSender(o,g,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?diagnosticEvents_1(g):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(o,m,b,V,g,f,h):null,q=Stream(o,f,g,b),k=f.eventProcessor||EventProcessor(o,f,g,b,l,V),D=Requestor(o,f,g),M={},S={},w=f.streaming,H=!1,P=!1,U=!0,T=f.stateProvider,O=Identity(null,function(e,t){(function(e){T||e&&I({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&t&&t.anonymous&&e&&!e.anonymous&&B(e,t)}),z=UserValidator(m),L=m.isEnabled()?new PersistentFlagStore(m,g,p,O,c):null;function I(e){if(g&&!(T&&T.enqueueEvent&&T.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(U&&(c.warn(eventWithoutUser()),U=!1));U=!1}!v||P||o.isDoNotTrack()||(c.debug(debugEnqueueingEvent(e.kind)),k.enqueue(e))}}function K(e,t,n,r){var o=O.getUser(),i=new Date,a=t?t.value:null;if(!f.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=M[s];if(u&&i-u<3e5)return;M[s]=i}u={kind:"feature",key:e,user:o,value:a,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},o&&o.anonymous&&(u.contextKind=j(o)),s=S[e];s&&(u.version=s.flagVersion||s.version,u.trackEvents=s.trackEvents,u.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(u.reason=t.reason),I(u)}function C(e,t,n,r){var o,i;return S&&objectHasOwnProperty(S,e)&&S[e]&&!S[e].deleted?(i=_(o=S[e]),null!==o.value&&void 0!==o.value||(i.value=t)):i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},n&&K(e,i,t,r),i}function _(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function j(e){return e.anonymous?"anonymousUser":"user"}function B(e,t){T||e&&t&&I({kind:"alias",key:e.key,contextKind:j(e),previousKey:t.key,previousContextKind:j(t),creationDate:(new Date).getTime()})}function $(){var o;i=!0,O.getUser()&&(o=function(e){try{return JSON.parse(e)}catch(e){return void l.maybeReportError(new LDInvalidDataError(invalidData()))}},q.connect(O.getUser(),p,{ping:function(){c.debug(debugStreamPing());var t=O.getUser();D.fetchFlagSettings(t,p).then(function(e){deepEquals(t,O.getUser())&&F(e||{})}).catch(function(e){l.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){e=o(e.data);e&&(c.debug(debugStreamPut()),F(e))},patch:function(e){var t,n,r,e=o(e.data);e&&(!(t=S[e.key])||!t.version||!e.version||t.version<e.version?(c.debug(debugStreamPatch(e.key)),n={},delete(r=extend({},e)).key,r=_(S[e.key]=r),n[e.key]=t?{previous:t.value,current:r}:{current:r},W(n)):c.debug(debugStreamPatchIgnored(e.key)))},delete:function(e){var t,e=o(e.data);e&&(!S[e.key]||S[e.key].version<e.version?(c.debug(debugStreamDelete(e.key)),t={},S[e.key]&&!S[e.key].deleted&&(t[e.key]={previous:S[e.key].value}),S[e.key]={version:e.version,deleted:!0},W(t)):c.debug(debugStreamDeleteIgnored(e.key)))}}))}function J(){i&&(q.disconnect(),i=!1)}function F(e){var t,n,r={};if(!e)return Promise.resolve();for(t in S)objectHasOwnProperty(S,t)&&S[t]&&(e[t]&&!deepEquals(e[t].value,S[t].value)?r[t]={previous:S[t].value,current:_(e[t])}:e[t]&&!e[t].deleted||(r[t]={previous:S[t].value}));for(n in e)objectHasOwnProperty(e,n)&&e[n]&&(!S[n]||S[n].deleted)&&(r[n]={current:_(e[n])});return S=_objectSpread2({},e),W(r).catch(function(){})}function W(o){var i,e=Object.keys(o);return 0<e.length&&(i={},e.forEach(function(e){var t=o[e].current,n=t?t.value:void 0,r=o[e].previous;l.emit(changeEvent+":"+e,n,r),i[e]=t?{current:n,previous:r}:{previous:r}}),l.emit(changeEvent,i),l.emit(internalChangeEvent,S),f.sendEventsOnlyForVariation||T||e.forEach(function(e){K(e,o[e].current)})),n&&L?L.saveFlags(S):Promise.resolve()}function G(){var e=w||r&&void 0===w;e&&!i?$():!e&&i&&J(),E&&E.setStreaming(e)}function X(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}function Q(e){g=e.environment,O.setUser(e.user),S=_objectSpread2({},e.flags),onNextTick(R)}function R(){c.info(clientInitialized()),H=!0,G(),d.signalSuccess()}function Y(e){d.signalFailure(e)}return"string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(L?n=!0:c.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(a=f.bootstrap,y=Object.keys(a),!(s=a[N="$flagsState"])&&y.length&&c.warn(bootstrapOldFormat()),!1===a.$valid&&c.warn(bootstrapInvalid()),u={},y.forEach(function(e){var t;e!==N&&"$valid"!==e&&(t={value:a[e]},s&&s[e]?t=extend(t,s[e]):t.version=0,u[e]=t)}),S=u),T?((h=T.getInitialState())?Q(h):T.on("init",Q),T.on("update",function(e){e.user&&O.setUser(e.user);e.flags&&F(e.flags)})):(A?z.validateUser(x).then(function(e){return O.setUser(e),"object"===_typeof(f.bootstrap)?R():n?L.loadFlags().then(function(e){return null==e?(S={},D.fetchFlagSettings(O.getUser(),p).then(function(e){return F(e||{})}).then(R).catch(function(e){Y(new LDFlagFetchError(errorFetchingFlags(e)))})):(S=e,onNextTick(R),D.fetchFlagSettings(O.getUser(),p).then(F).catch(function(e){return l.maybeReportError(e)}))}):D.fetchFlagSettings(O.getUser(),p).then(function(e){S=e||{},R()}).catch(function(e){S={},Y(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(Y),{client:{waitForInitialization:function(){return d.getInitializationPromise()},waitUntilReady:function(){return d.getReadyPromise()},identify:function(e,r,t){return P?wrapPromiseCallback(Promise.resolve({}),t):T?(c.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(S)),t)):wrapPromiseCallback((n&&L?L.clearFlags():Promise.resolve()).then(function(){return z.validateUser(e)}).then(function(n){return D.fetchFlagSettings(n,r).then(function(e){var t=transformVersionedValuesToValues(e);return O.setUser(n),p=r,e?F(e).then(function(){return t}):t})}).then(function(e){return i&&$(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return O.getUser()},variation:function(e,t){return C(e,t,!0,!1).value},variationDetail:function(e,t){return C(e,t,!0,!0)},track:function(e,t,n){var r;"string"!=typeof e?l.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e))):(o.customEventFilter&&!o.customEventFilter(e)&&c.warn(unknownCustomEventKey(e)),r={kind:"custom",key:e,user:e=O.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()},e&&e.anonymous&&(r.contextKind=j(e)),null!=t&&(r.data=t),null!=n&&(r.metricValue=n),I(r))},alias:B,on:function(e,t,n){X(e)?(r=!0,H&&G(),l.on(e,t,n)):l.on.apply(l,arguments)},off:function(e){var t;l.off.apply(l,arguments),X(e)&&(t=!1,l.getEvents().forEach(function(e){X(e)&&0<l.getEventListenerCount(e)&&(t=!0)}),t||(r=!1,i&&void 0===w&&J()))},setStreaming:function(e){(e=null===e?void 0:e)!==w&&(w=e,G())},flush:function(e){return wrapPromiseCallback(v?k.flush():Promise.resolve(),e)},allFlags:function(){var e,t={};if(!S)return t;for(e in S)objectHasOwnProperty(S,e)&&(t[e]=C(e,null,!f.sendEventsOnlyForVariation).value);return t},close:function(e){return wrapPromiseCallback(P?Promise.resolve():Promise.resolve().then(function(){if(J(),E&&E.stop(),v)return k.stop(),k.flush()}).then(t).catch(t),e);function t(){P=!0,S={}}}},options:f,emitter:l,ident:O,logger:c,requestor:D,start:function(){v&&(E&&E.start(),k.start())},enqueueEvent:I,getFlagsInternal:function(){return S},getEnvironmentId:function(){return g},internalChangeEventName:internalChangeEvent}}var version="3.6.0";exports.commonBasicLogger=commonBasicLogger,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version; | ||
//# sourceMappingURL=ldclient-common.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(i,!0).forEach((function(t){n(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(i).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(i,n))}))}return e}function i(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var a=o("LaunchDarklyUnexpectedResponseError"),u=o("LaunchDarklyInvalidEnvironmentIdError"),s=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),l=o("LaunchDarklyInvalidArgumentError"),f=o("LaunchDarklyFlagFetchError"),v=o("LaunchDarklyInvalidDataError");function d(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var g=Object.freeze({__proto__:null,LDUnexpectedResponseError:a,LDInvalidEnvironmentIdError:u,LDInvalidUserError:s,LDInvalidEventKeyError:c,LDInvalidArgumentError:l,LDFlagFetchError:f,LDInvalidDataError:v,isHttpErrorRecoverable:d}),p=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(E(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(m[n>>2]+m[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(m[n>>10]+m[n>>4&63]+m[n<<2&63]+"="));return i.join("")},m=[],y=[],h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=0,k=h.length;b<k;++b)m[b]=h[b],y[h.charCodeAt(b)]=b;function E(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(m[(i=r)>>18&63]+m[i>>12&63]+m[i>>6&63]+m[63&i]);return o.join("")}y["-".charCodeAt(0)]=62,y["_".charCodeAt(0)]=63;var w=Array.isArray,D=Object.keys,O=Object.prototype.hasOwnProperty,P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return p(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function U(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=w(n),u=w(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=D(n);if((i=v.length)!==D(t).length)return!1;for(r=i;0!=r--;)if(!O.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function R(e){setTimeout(e,0)}function T(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function L(e){var n={};for(var t in e)V(e,t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)V(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),i=[],o=e;r.length>0;){for(t=[];o>0;){var a=r.shift();if(!a)break;(o-=U(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function A(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":A(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function x(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(r({},e)):e}function q(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var n;for(var t in P){var i=P[t],o=e[i];void 0!==o&&"string"!=typeof o&&((n=n||r({},e))[i]=String(o))}return n||e}var z=Object.freeze({__proto__:null,btoa:S,base64URLEncode:U,clone:I,deepEquals:j,onNextTick:R,wrapPromiseCallback:T,transformValuesToVersionedValues:L,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:A,getLDHeaders:C,transformHeaders:x,extend:q,objectHasOwnProperty:V,sanitizeUser:_});for(var J=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}})),M=[],K=0;K<256;++K)M[K]=(K+256).toString(16).substr(1);var H,B,$=function(e,n){var t=n||0,r=M;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("")},G=0,X=0;var W=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||H,a=void 0!==e.clockseq?e.clockseq:B;if(null==o||null==a){var u=J();null==o&&(o=H=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=B=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:X+1,l=s-G+(c-X)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>G)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=s,X=c,B=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||$(i)};function Q(e,n,t){var r="/a/"+n+".gif",i=q({"Content-Type":"application/json"},C(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,a,u,s){var c=JSON.stringify(n),l=u?null:W();return s?function n(r){var o=u?i:q({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,x(o,t),c).promise.then((function(e){if(e)return e.status>=400&&d(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(a+r+"?d="+U(c)),Promise.resolve())},a.sendEvents=function(n,t,r){if(!e.httpRequest)return Promise.resolve();var i,o=e.httpAllowsPost();i=o?[n]:N(2e3-t.length,n);for(var u=[],s=0;s<i.length;s++)u.push(a.sendChunk(i[s],t,r,o));return Promise.all(u)},a}function Y(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),o=r[i];o?o.count=o.count+1:r[i]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},i=!0;for(var o in r){var a=r[o],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),i=!1}return i?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function Z(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],i={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,o){return Object.keys(e).reduce((function(a,u){var s=a;return o(u)&&(!function(e){return!i[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s}),[{},{}])},u=a(e,(function(e){return o[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=q({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=function(){return"LaunchDarkly client initialized"},te=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",re=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ie=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},oe=function(e){return'Expected application/json content type but got "'+e+'"'},ae=function(e){return"local storage is unavailable: "+ee(e)},ue=function(e){return"network error"+(e?" ("+e+")":"")},se=function(e){return'Custom event "'+e+'" does not exist'},ce=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+te},le=function(){return"No environment/client-side ID was specified."+te},fe=function(e){return"Error fetching flag settings: "+ee(e)},ve=function(){return"No user specified."+te},de=function(){return"Invalid user specified."+te},ge=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+te},me=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ye=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},he=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(d(e)?t:"giving up permanently")},be=function(){return"Cannot make HTTP requests in this environment."+te},ke=function(){return"identify() has no effect here; it must be called on the main client instance"},Ee=function(){return"Closing stream connection"},we=function(e){return"Opening stream connection to "+e},De=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying every "+n+" milliseconds."},Oe=function(e){return'Ignoring unknown config option "'+e+'"'},Pe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Se=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ue=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ie=function(e){return"polling for feature flags at "+e},je=function(){return"received ping message from stream"},Re=function(){return"received streaming update for all flags"},Te=function(e){return'received streaming update for flag "'+e+'"'},Le=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'received streaming deletion for flag "'+e+'"'},Ne=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ae=function(e){return'enqueueing "'+e+'" event'},Ce=function(e){return"sending "+e+" events"},xe=Object.freeze({__proto__:null,clientInitialized:ne,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:re,eventWithoutUser:ie,invalidContentType:oe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ae,networkError:ue,unknownCustomEventKey:se,environmentNotFound:ce,environmentNotSpecified:le,errorFetchingFlags:fe,userNotSpecified:ve,invalidUser:de,invalidData:ge,bootstrapOldFormat:pe,bootstrapInvalid:me,deprecated:ye,httpErrorMessage:he,httpUnavailable:be,identifyDisabled:ke,streamClosing:Ee,streamConnecting:we,streamError:De,unknownOption:Oe,wrongOptionType:Pe,wrongOptionTypeBoolean:Se,optionBelowMinimum:Ue,debugPolling:Ie,debugStreamPing:je,debugStreamPut:Re,debugStreamPatch:Te,debugStreamPatchIgnored:Le,debugStreamDelete:Fe,debugStreamDeleteIgnored:Ne,debugEnqueueingEvent:Ae,debugPostingEvents:Ce,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function qe(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var Ve=function(e){var n=!1,t=!1,r=null,i=null,o=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return i||(n?Promise.resolve():t?Promise.reject(r):i=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(i){n||t||(t=!0,r=i,e.emit("failed",i),e.emit("ready")),e.maybeReportError(i)}}};function _e(e,n,t,r){var i={};function o(){var e="",i=r.getUser();return i&&(e=t||S(JSON.stringify(i))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(o()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=L(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return null}))}}))},i.saveFlags=function(n){var t=q({},n,{$schema:1});return e.set(o(),JSON.stringify(t))},i.clearFlags=function(){return e.clear(o())},i}function ze(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=o+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=C(e,n),d=!1,g=null,p=null,m=null,y=null,h=null;function b(e){d||(a.warn(De(e,f)),d=!0),D(!1),w(),k(f)}function k(e){p||(e?p=setTimeout(E,e):E())}function E(){var r;p=null;var u="",f={headers:v,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var d in null!=y&&(u="h="+y),c?e.eventSourceAllowsReport?(r=s,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(m)):(r=o+"/ping/"+t,u=""):r=s+"/"+U(JSON.stringify(m)),f.headers=x(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,w(),a.info(we(r)),i=(new Date).getTime(),g=e.eventSourceFactory(r,f),h)V(h,d)&&g.addEventListener(d,h[d]);g.onerror=b}}function w(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(e){i&&r&&r.recordStreamInit(i,!e,(new Date).getTime()-i),i=null}return u.connect=function(e,n,t){m=e,y=n,h={};var r=function(e){h[e]=function(n){d=!1,D(!0),t[e]&&t[e](n)}};for(var i in t||{})r(i);k()},u.disconnect=function(){clearTimeout(p),p=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function Je(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,a=n.logger,s={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new f(be()))}));var i=r?"REPORT":"GET",o=C(e,n);r&&(o["Content-Type"]="application/json");var a=c[t];a||(a=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=a);var s=e.httpRequest(i,t,x(o,n),r),l=s.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=oe(e.header("content-type")||"");return Promise.reject(new f(n))}return Promise.reject(function(e){return 404===e.status?new u(ce()):new f(fe(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new f(ue(e)))}));return a.addPromise(l,(function(){s.cancel&&s.cancel()})),a.resultPromise}return s.fetchJSON=function(e){return l(r+e,null)},s.fetchFlagSettings=function(e,n){var u,s,c,f="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=U(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),o&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(Ie(s)),l(s,c)},s}function Me(e){var n={};return n.validateUser=function(n){if(!n)return Promise.reject(new s(ve()));var t=I(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=W();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new s(de()))},n}var Ke=["debug","info","warn","error","none"];function He(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],o=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var s=0;s<Ke.length;s++)Ke[s]===e.level&&(u=s);function c(e,t,u){if(!(u.length<1)){var s,c=o?t+": "+a:a;if(1!==u.length&&n){var l=i(u);l[0]=c+l[0],s=n.apply(void 0,i(l))}else s=c+u[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=Ke[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},v=0;v<Ke.length;v++)f(v);return l}function Be(e,n){return He({level:e,prefix:n})}var $e={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function Ge(n,t,r,i){var o=q({logger:{default:i}},$e,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){R((function(){t&&t.maybeReportError(new l(e))}))}var s=q({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(ye(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){Ke.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(n){var t=q({},n),r=function(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}};return Object.keys(n).forEach((function(e){var i=n[e];if(null!=i){var a=o[e];if(void 0===a)u(Oe(e));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(i);c.indexOf(l)<0?"boolean"===s?(t[e]=!!i,u(Se(e,l))):(u(Pe(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&i<a.minimum&&(u(Ue(e,i,a.minimum)),t[e]=a.minimum)}}}})),t}(s=function(e){var n=q({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))).logger),s}var Xe=Object.freeze({__proto__:null,baseOptionDefs:$e,validate:Ge}).baseOptionDefs;var We=function(e){var n={diagnosticId:W()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Qe=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},Ye=function(e,n,t,i,o,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+o+":$diagnostics",v=a.eventsUrl+"/events/diagnostic/"+o,d=a.diagnosticRecordingInterval,g=t,p=!!a.streaming,m={};function y(){return{sdk:k(),configuration:(n={customBaseURI:a.baseUrl!==Xe.baseUrl.default,customStreamURI:a.streamUrl!==Xe.streamUrl.default,customEventsURI:a.eventsUrl!==Xe.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function h(e){a.logger&&a.logger.debug(xe.debugPostingDiagnosticEvent(e)),i.sendEvents(e,v,!0).then((function(){})).catch((function(){}))}function b(){var e,t;h((e=(new Date).getTime(),t=r({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(t=r({},t,{},y())),g.reset(e),t)),c=setTimeout(b,d),s=(new Date).getTime(),l&&function(){if(n.isEnabled()){var e=r({},g.getProps());n.set(f,JSON.stringify(e))}}()}function k(){var n=r({},e.diagnosticSdkData);return a.wrapperName&&(n.wrapperName=a.wrapperName),a.wrapperVersion&&(n.wrapperVersion=a.wrapperVersion),n}return m.start=function(){l?function(e){if(!n.isEnabled())return e(!1);n.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();t>=n?b():c=setTimeout(b,n-t)}else 0===Math.floor(4*Math.random())?b():c=setTimeout(b,d)})):(h(r({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},y())),c=setTimeout(b,d))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m};function Ze(n,t,i,o,s){var l,g,p,m=function(){if(i&&i.logger)return i.logger;return s&&s.logger&&s.logger.default||Be("warn")}(),y=qe(m),h=Ve(y),b=Ge(i,y,s,m),k=b.sendEvents,E=n,w=b.hash,D=function(e,n){var t={},r=!1,i=function(e){r||(r=!0,n.warn(ae(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){i(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){i(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){i(e),t(!1)})):t(!1)}))},t}(o.localStorage,m),O=Q(o,E,b),P=b.sendEvents&&!b.diagnosticOptOut,S=P?We(E):null,U=P?Qe((new Date).getTime()):null,L=P?Ye(o,D,U,O,E,b,S):null,N=ze(o,b,E,U),A=b.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||Q(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,f=Y(),v=Z(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function O(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function P(e){var n=q({},e);return"alias"===e.kind?n:(g||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n)}function S(e){b.length<m?(b.push(e),w=!1):(w||(w=!0,h.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),i&&i.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=O(e)):n=D(),n&&S(P(e)),t){var r=q({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,S(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Ce(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),d(e.status)||(E=!0),e.status>=400&&R((function(){o.maybeReportError(new a(he(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,y)}),y)},s.stop=function(){clearTimeout(r)},s}(o,b,E,U,y,O),C=Je(o,b,E),x={},z={},J=b.streaming,M=!1,K=!1,H=!0,B=b.stateProvider,$=function(e,n){var t,r={};return r.setUser=function(e){var r=t&&I(t);(t=_(e))&&n&&n(I(t),r)},r.getUser=function(){return t?I(t):null},e&&r.setUser(e),r}(null,(function(e,n){(function(e){if(B)return;e&&W({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!b.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&ie(e,n)})),G=Me(D),X=D.isEnabled()?new _e(D,E,w,$,m):null;function W(e){if(E&&!(B&&B.enqueueEvent&&B.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(H&&(m.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),H=!1));H=!1}!k||K||o.isDoNotTrack()||(m.debug(Ae(e.kind)),A.enqueue(e))}}function ee(e,n,t,r){var i=$.getUser(),o=new Date,a=n?n.value:null;if(!b.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=x[u];if(s&&o-s<3e5)return;x[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(c.contextKind=re(i));var l=z[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),W(c)}function ne(e,n,t,r){var i;if(z&&V(z,e)&&z[e]&&!z[e].deleted){var o=z[e];i=te(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&ee(e,i,n,r),i}function te(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function re(e){return e.anonymous?"anonymousUser":"user"}function ie(e,n){B||e&&n&&W({kind:"alias",key:e.key,contextKind:re(e),previousKey:n.key,previousContextKind:re(n),creationDate:(new Date).getTime()})}function oe(){if(g=!0,$.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void y.maybeReportError(new v("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};N.connect($.getUser(),w,{ping:function(){m.debug("received ping message from stream");var e=$.getUser();C.fetchFlagSettings(e,w).then((function(n){j(e,$.getUser())&&ce(n||{})})).catch((function(e){y.maybeReportError(new f(fe(e)))}))},put:function(n){var t=e(n.data);t&&(m.debug("received streaming update for all flags"),ce(t))},patch:function(n){var t=e(n.data);if(t){var r=z[t.key];if(!r||!r.version||!t.version||r.version<t.version){m.debug(Te(t.key));var i={},o=q({},t);delete o.key,z[t.key]=o;var a=te(o);i[t.key]=r?{previous:r.value,current:a}:{current:a},ve(i)}else m.debug(Le(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!z[t.key]||z[t.key].version<t.version){m.debug(Fe(t.key));var r={};z[t.key]&&!z[t.key].deleted&&(r[t.key]={previous:z[t.key].value}),z[t.key]={version:t.version,deleted:!0},ve(r)}else m.debug(Ne(t.key))}})}}function ue(){g&&(N.disconnect(),g=!1)}function ce(e){var n={};if(!e)return Promise.resolve();for(var t in z)V(z,t)&&z[t]&&(e[t]&&!j(e[t].value,z[t].value)?n[t]={previous:z[t].value,current:te(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:z[t].value}));for(var i in e)V(e,i)&&e[i]&&(!z[i]||z[i].deleted)&&(n[i]={current:te(e[i])});return z=r({},e),ve(n).catch((function(){}))}function ve(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,i=r?r.value:void 0,o=e[n].previous;y.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),y.emit("change",t),y.emit("internal-change",z),b.sendEventsOnlyForVariation||B||n.forEach((function(n){ee(n,e[n].current)}))}return l&&X?X.saveFlags(z):Promise.resolve()}function de(){var e=J||p&&void 0===J;e&&!g?oe():!e&&g&&ue(),L&&L.setStreaming(e)}function ge(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof b.bootstrap&&"LOCALSTORAGE"===b.bootstrap.toUpperCase()&&(X?l=!0:m.warn(ae())),"object"===e(b.bootstrap)&&(z=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(pe()),!1===e.$valid&&m.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=q(i,t[n]):i.version=0,r[n]=i}})),r}(b.bootstrap)),B){var me=B.getInitialState();me?ye(me):B.on("init",ye),B.on("update",(function(e){e.user&&$.setUser(e.user);e.flags&&ce(e.flags)}))}else(function(){if(!n)return Promise.reject(new u(le()));return G.validateUser(t).then((function(n){return $.setUser(n),"object"===e(b.bootstrap)?be():l?X.loadFlags().then((function(e){return null==e?(z={},C.fetchFlagSettings($.getUser(),w).then((function(e){return ce(e||{})})).then(be).catch((function(e){ke(new f(fe(e)))}))):(z=e,R(be),C.fetchFlagSettings($.getUser(),w).then((function(e){return ce(e)})).catch((function(e){return y.maybeReportError(e)})))})):C.fetchFlagSettings($.getUser(),w).then((function(e){z=e||{},be()})).catch((function(e){z={},ke(e)}))}))})().catch(ke);function ye(e){E=e.environment,$.setUser(e.user),z=r({},e.flags),R(be)}function be(){m.info("LaunchDarkly client initialized"),M=!0,de(),h.signalSuccess()}function ke(e){h.signalFailure(e)}return{client:{waitForInitialization:function(){return h.getInitializationPromise()},waitUntilReady:function(){return h.getReadyPromise()},identify:function(e,n,t){return K?T(Promise.resolve({}),t):B?(m.warn("identify() has no effect here; it must be called on the main client instance"),T(Promise.resolve(F(z)),t)):T((l&&X?X.clearFlags():Promise.resolve()).then((function(){return G.validateUser(e)})).then((function(e){return C.fetchFlagSettings(e,n).then((function(t){var r=F(t);return $.setUser(e),w=n,t?ce(t).then((function(){return r})):r}))})).then((function(e){return g&&oe(),e})).catch((function(e){return y.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return $.getUser()},variation:function(e,n){return ne(e,n,!0,!1).value},variationDetail:function(e,n){return ne(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&m.warn(se(e));var r=$.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=re(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),W(i)}else y.maybeReportError(new c(se(e)))},alias:ie,on:function(e,n,t){ge(e)?(p=!0,M&&de(),y.on(e,n,t)):y.on.apply(y,arguments)},off:function(e){if(y.off.apply(y,arguments),ge(e)){var n=!1;y.getEvents().forEach((function(e){ge(e)&&y.getEventListenerCount(e)>0&&(n=!0)})),n||(p=!1,g&&void 0===J&&ue())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,de())},flush:function(e){return T(k?A.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!z)return e;for(var n in z)V(z,n)&&(e[n]=ne(n,null,!b.sendEventsOnlyForVariation).value);return e},close:function(e){if(K)return T(Promise.resolve(),e);var n=function(){K=!0,z={}};return T(Promise.resolve().then((function(){if(ue(),L&&L.stop(),k)return A.stop(),A.flush()})).then(n).catch(n),e)}},options:b,emitter:y,ident:$,logger:m,requestor:C,start:function(){k&&(L&&L.start(),A.start())},enqueueEvent:W,getFlagsInternal:function(){return z},getEnvironmentId:function(){return E},internalChangeEventName:"internal-change"}}var en="3.5.1";export{He as commonBasicLogger,Be as createConsoleLogger,g as errors,Ze as initialize,xe as messages,z as utils,en as version}; | ||
function e(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function n(n){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?e(Object(i),!0).forEach((function(e){r(n,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"==typeof e)return o(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function a(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),v=a("LaunchDarklyFlagFetchError"),d=a("LaunchDarklyInvalidDataError");function g(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var p=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:v,LDInvalidDataError:d,isHttpErrorRecoverable:g}),m=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(w(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(y[n>>2]+y[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(y[n>>10]+y[n>>4&63]+y[n<<2&63]+"="));return i.join("")},y=[],h=[],b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=0,E=b.length;k<E;++k)y[k]=b[k],h[b.charCodeAt(k)]=k;function w(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(y[(i=r)>>18&63]+y[i>>12&63]+y[i>>6&63]+y[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var D=Array.isArray,O=Object.keys,S=Object.prototype.hasOwnProperty,P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function U(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function I(e){var n=unescape(encodeURIComponent(e));return m(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function j(e){return I(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function T(e){return JSON.parse(JSON.stringify(e))}function R(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=D(n),u=D(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=O(n);if((i=v.length)!==O(t).length)return!1;for(r=i;0!=r--;)if(!S.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function A(e){setTimeout(e,0)}function L(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 C(e){var n={};for(var t in e)V(e,t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)V(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),i=[],o=e;r.length>0;){for(t=[];o>0;){var a=r.shift();if(!a)break;(o-=j(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function x(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function q(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t){return n(n({},e),t)}),{})}function V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var t;for(var r in P){var i=P[r],o=e[i];void 0!==o&&"string"!=typeof o&&((t=t||n({},e))[i]=String(o))}return t||e}var z=Object.freeze({__proto__:null,appendUrlPath:U,btoa:I,base64URLEncode:j,clone:T,deepEquals:R,onNextTick:A,wrapPromiseCallback:L,transformValuesToVersionedValues:C,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:x,extend:q,objectHasOwnProperty:V,sanitizeUser:_});for(var J=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}})),M=[],K=0;K<256;++K)M[K]=(K+256).toString(16).substr(1);var $,B,H=function(e,n){var t=n||0,r=M;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("")},G=0,W=0;var X=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||$,a=void 0!==e.clockseq?e.clockseq:B;if(null==o||null==a){var u=J();null==o&&(o=$=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=B=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:W+1,l=s-G+(c-W)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>G)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=s,W=c,B=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||H(i)},Q=["debug","info","warn","error","none"];function Y(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],o=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var s=0;s<Q.length;s++)Q[s]===e.level&&(u=s);function c(e,t,u){if(!(u.length<1)){var s,c=o?t+": "+a:a;if(1!==u.length&&n){var l=i(u);l[0]=c+l[0],s=n.apply(void 0,i(l))}else s=c+u[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=Q[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},v=0;v<Q.length;v++)f(v);return l}function Z(e,n){return Y({level:e,prefix:n})}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=function(){return"LaunchDarkly client initialized"},te=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",re=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ie=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},oe=function(e){return'Expected application/json content type but got "'+e+'"'},ae=function(e){return"local storage is unavailable: "+ee(e)},ue=function(e){return"network error"+(e?" ("+e+")":"")},se=function(e){return'Custom event "'+e+'" does not exist'},ce=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+te},le=function(){return"No environment/client-side ID was specified."+te},fe=function(e){return"Error fetching flag settings: "+ee(e)},ve=function(){return"No user specified."+te},de=function(){return"Invalid user specified."+te},ge=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+te},me=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ye=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},he=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(g(e)?t:"giving up permanently")},be=function(){return"Cannot make HTTP requests in this environment."+te},ke=function(){return"identify() has no effect here; it must be called on the main client instance"},Ee=function(){return"Closing stream connection"},we=function(e){return"Opening stream connection to "+e},De=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying every "+n+" milliseconds."},Oe=function(e){return'Ignoring unknown config option "'+e+'"'},Se=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Pe=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ue=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ie=function(e){return"polling for feature flags at "+e},je=function(){return"received ping message from stream"},Te=function(){return"received streaming update for all flags"},Re=function(e){return'received streaming update for flag "'+e+'"'},Ae=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Le=function(e){return'received streaming deletion for flag "'+e+'"'},Ce=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'enqueueing "'+e+'" event'},Ne=function(e){return"sending "+e+" events"},xe=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},qe=Object.freeze({__proto__:null,clientInitialized:ne,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:re,eventWithoutUser:ie,invalidContentType:oe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ae,networkError:ue,unknownCustomEventKey:se,environmentNotFound:ce,environmentNotSpecified:le,errorFetchingFlags:fe,userNotSpecified:ve,invalidUser:de,invalidData:ge,bootstrapOldFormat:pe,bootstrapInvalid:me,deprecated:ye,httpErrorMessage:he,httpUnavailable:be,identifyDisabled:ke,streamClosing:Ee,streamConnecting:we,streamError:De,unknownOption:Oe,wrongOptionType:Se,wrongOptionTypeBoolean:Pe,optionBelowMinimum:Ue,debugPolling:Ie,debugStreamPing:je,debugStreamPut:Te,debugStreamPatch:Re,debugStreamPatchIgnored:Ae,debugStreamDelete:Le,debugStreamDeleteIgnored:Ce,debugEnqueueingEvent:Fe,debugPostingEvents:Ne,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:xe}),Ve={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var i={};t.id&&(i.id=ze("".concat(e,".id"),n,t.id,r));t.version&&(i.version=ze("".concat(e,".version"),n,t.version,r));return i}}},_e=/^(\w|\.|-)+$/;function ze(e,n,t,r){if("string"==typeof t&&t.match(_e))return t;r.warn(xe(e))}function Je(e,n,r,i){var o=q({logger:{default:i}},Ve,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){A((function(){n&&n.maybeReportError(new f(e))}))}var s=q({},e||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(ye(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){Q.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(e){var n=q({},e),r=function(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=t(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}};return Object.keys(e).forEach((function(t){var a=e[t];if(null!=a){var s=o[t];if(void 0===s)u(Oe(t));else{var c=s.type||r(s.default),l=s.validator;if(l){var f=l(t,e,e[t],i);void 0!==f?n[t]=f:delete n[t]}else if("any"!==c){var v=c.split("|"),d=r(a);v.indexOf(d)<0?"boolean"===c?(n[t]=!!a,u(Pe(t,d))):(u(Se(t,c,d)),n[t]=s.default):"number"===d&&void 0!==s.minimum&&a<s.minimum&&(u(Ue(t,a,s.minimum)),n[t]=s.minimum)}}}})),n}(s=function(e){var n=q({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))).logger),s}function Me(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Ke(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":x(e)};n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName);var r=Me(n),i=Object.keys(r);return i.length&&(t["x-launchdarkly-tags"]=i.sort().flatMap((function(e){return Array.isArray(r[e])?r[e].sort().map((function(n){return"".concat(e,"/").concat(n)})):["".concat(e,"/").concat(r[e])]})).join(" ")),t}function $e(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function Be(e,n,t){var r="/a/"+n+".gif",i=q({"Content-Type":"application/json"},Ke(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,a,u,s){var c=JSON.stringify(n),l=u?null:X();return s?function n(r){var o=u?i:q({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,$e(o,t),c).promise.then((function(e){if(e)return e.status>=400&&g(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(a+r+"?d="+j(c)),Promise.resolve())},a.sendEvents=function(n,t,r){if(!e.httpRequest)return Promise.resolve();var i,o=e.httpAllowsPost();i=o?[n]:N(2e3-t.length,n);for(var u=[],s=0;s<i.length;s++)u.push(a.sendChunk(i[s],t,r,o));return Promise.all(u)},a}function He(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),o=r[i];o?o.count=o.count+1:r[i]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},i=!0;for(var o in r){var a=r[o],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),i=!1}return i?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function Ge(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],i={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,o){return Object.keys(e).reduce((function(a,u){var s=a;return o(u)&&(!function(e){return!i[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s}),[{},{}])},u=a(e,(function(e){return o[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=q({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function We(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var Xe=function(e){var n=!1,t=!1,r=null,i=null,o=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return i||(n?Promise.resolve():t?Promise.reject(r):i=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(i){n||t||(t=!0,r=i,e.emit("failed",i),e.emit("ready")),e.maybeReportError(i)}}};function Qe(e,n,t,r){var i={};function o(){var e="",i=r.getUser();return i&&(e=t||I(JSON.stringify(i))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(o()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=C(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return null}))}}))},i.saveFlags=function(n){var t=q({},n,{$schema:1});return e.set(o(),JSON.stringify(t))},i.clearFlags=function(){return e.clear(o())},i}function Ye(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=U(o,"/eval/"+t),c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=Ke(e,n),d=!1,g=null,p=null,m=null,y=null,h=null;function b(e){d||(a.warn(De(e,f)),d=!0),D(!1),w(),k(f)}function k(e){p||(e?p=setTimeout(E,e):E())}function E(){var r;p=null;var u="",f={headers:v,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var d in null!=y&&(u="h="+y),c?e.eventSourceAllowsReport?(r=s,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(m)):(r=U(o,"/ping/"+t),u=""):r=s+"/"+j(JSON.stringify(m)),f.headers=$e(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,w(),a.info(we(r)),i=(new Date).getTime(),g=e.eventSourceFactory(r,f),h)V(h,d)&&g.addEventListener(d,h[d]);g.onerror=b}}function w(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(e){i&&r&&r.recordStreamInit(i,!e,(new Date).getTime()-i),i=null}return u.connect=function(e,n,t){m=e,y=n,h={};var r=function(e){h[e]=function(n){d=!1,D(!0),t[e]&&t[e](n)}};for(var i in t||{})r(i);k()},u.disconnect=function(){clearTimeout(p),p=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function Ze(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,a=n.logger,u={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new v(be()))}));var i=r?"REPORT":"GET",o=Ke(e,n);r&&(o["Content-Type"]="application/json");var a=c[t];a||(a=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=a);var u=e.httpRequest(i,t,$e(o,n),r),l=u.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=oe(e.header("content-type")||"");return Promise.reject(new v(n))}return Promise.reject(function(e){return 404===e.status?new s(ce()):new v(fe(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new v(ue(e)))}));return a.addPromise(l,(function(){u.cancel&&u.cancel()})),a.resultPromise}return u.fetchJSON=function(e){return l(U(r,e),null)},u.fetchFlagSettings=function(e,n){var u,s,c,f="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=j(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),o&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(Ie(s)),l(s,c)},u}function en(e){var n={};return n.validateUser=function(n){if(!n)return Promise.reject(new c(ve()));var t=T(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=X();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new c(de()))},n}var nn=Object.freeze({__proto__:null,baseOptionDefs:Ve,validate:Je,getTags:Me}).baseOptionDefs,tn=z.appendUrlPath;var rn=function(e){var n={diagnosticId:X()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},on=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},an=function(e,t,r,i,o,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+o+":$diagnostics",v=tn(a.eventsUrl,"/events/diagnostic/"+o),d=a.diagnosticRecordingInterval,g=r,p=!!a.streaming,m={};function y(){return{sdk:k(),configuration:(n={customBaseURI:a.baseUrl!==nn.baseUrl.default,customStreamURI:a.streamUrl!==nn.streamUrl.default,customEventsURI:a.eventsUrl!==nn.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function h(e){a.logger&&a.logger.debug(qe.debugPostingDiagnosticEvent(e)),i.sendEvents(e,v,!0).then((function(){})).catch((function(){}))}function b(){var e,r;h((e=(new Date).getTime(),r=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(r=n(n({},r),y())),g.reset(e),r)),c=setTimeout(b,d),s=(new Date).getTime(),l&&function(){if(t.isEnabled()){var e=n({},g.getProps());t.set(f,JSON.stringify(e))}}()}function k(){var t=n({},e.diagnosticSdkData);return a.wrapperName&&(t.wrapperName=a.wrapperName),a.wrapperVersion&&(t.wrapperVersion=a.wrapperVersion),t}return m.start=function(){l?function(e){if(!t.isEnabled())return e(!1);t.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();t>=n?b():c=setTimeout(b,n-t)}else 0===Math.floor(4*Math.random())?b():c=setTimeout(b,d)})):(h(n({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},y())),c=setTimeout(b,d))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m};function un(e,r,i,o,a){var c,f,p,m=function(){if(i&&i.logger)return i.logger;return a&&a.logger&&a.logger.default||Z("warn")}(),y=We(m),h=Xe(y),b=Je(i,y,a,m),k=b.sendEvents,E=e,w=b.hash,D=function(e,n){var t={},r=!1,i=function(e){r||(r=!0,n.warn(ae(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){i(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){i(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){i(e),t(!1)})):t(!1)}))},t}(o.localStorage,m),O=Be(o,E,b),S=b.sendEvents&&!b.diagnosticOptOut,P=S?rn(E):null,I=S?on((new Date).getTime()):null,j=S?an(o,D,I,O,E,b,P):null,C=Ye(o,b,E,I),N=b.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=a||Be(e,t,n),l=U(n.eventsUrl,"/events/bulk/"+t),f=He(),v=Ge(n),d=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function O(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function S(e){var n=q({},e);return"alias"===e.kind||(d||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}function P(e){b.length<m?(b.push(e),w=!1):(w||(w=!0,h.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),i&&i.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=O(e)):n=D(),n&&P(S(e)),t){var r=q({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Ne(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),g(e.status)||(E=!0),e.status>=400&&A((function(){o.maybeReportError(new u(he(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,y)}),y)},s.stop=function(){clearTimeout(r)},s}(o,b,E,I,y,O),x=Ze(o,b,E),z={},J={},M=b.streaming,K=!1,$=!1,B=!0,H=b.stateProvider,G=function(e,n){var t,r={};return r.setUser=function(e){var r=t&&T(t);(t=_(e))&&n&&n(T(t),r)},r.getUser=function(){return t?T(t):null},e&&r.setUser(e),r}(null,(function(e,n){(function(e){if(H)return;e&&Q({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!b.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&re(e,n)})),W=en(D),X=D.isEnabled()?new Qe(D,E,w,G,m):null;function Q(e){if(E&&!(H&&H.enqueueEvent&&H.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(B&&(m.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),B=!1));B=!1}!k||$||o.isDoNotTrack()||(m.debug(Fe(e.kind)),N.enqueue(e))}}function Y(e,n,t,r){var i=G.getUser(),o=new Date,a=n?n.value:null;if(!b.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=z[u];if(s&&o-s<3e5)return;z[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(c.contextKind=te(i));var l=J[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),Q(c)}function ee(e,n,t,r){var i;if(J&&V(J,e)&&J[e]&&!J[e].deleted){var o=J[e];i=ne(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Y(e,i,n,r),i}function ne(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function te(e){return e.anonymous?"anonymousUser":"user"}function re(e,n){H||e&&n&&Q({kind:"alias",key:e.key,contextKind:te(e),previousKey:n.key,previousContextKind:te(n),creationDate:(new Date).getTime()})}function ie(){if(f=!0,G.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void y.maybeReportError(new d("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};C.connect(G.getUser(),w,{ping:function(){m.debug("received ping message from stream");var e=G.getUser();x.fetchFlagSettings(e,w).then((function(n){R(e,G.getUser())&&ue(n||{})})).catch((function(e){y.maybeReportError(new v(fe(e)))}))},put:function(n){var t=e(n.data);t&&(m.debug("received streaming update for all flags"),ue(t))},patch:function(n){var t=e(n.data);if(t){var r=J[t.key];if(!r||!r.version||!t.version||r.version<t.version){m.debug(Re(t.key));var i={},o=q({},t);delete o.key,J[t.key]=o;var a=ne(o);i[t.key]=r?{previous:r.value,current:a}:{current:a},ce(i)}else m.debug(Ae(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!J[t.key]||J[t.key].version<t.version){m.debug(Le(t.key));var r={};J[t.key]&&!J[t.key].deleted&&(r[t.key]={previous:J[t.key].value}),J[t.key]={version:t.version,deleted:!0},ce(r)}else m.debug(Ce(t.key))}})}}function oe(){f&&(C.disconnect(),f=!1)}function ue(e){var t={};if(!e)return Promise.resolve();for(var r in J)V(J,r)&&J[r]&&(e[r]&&!R(e[r].value,J[r].value)?t[r]={previous:J[r].value,current:ne(e[r])}:e[r]&&!e[r].deleted||(t[r]={previous:J[r].value}));for(var i in e)V(e,i)&&e[i]&&(!J[i]||J[i].deleted)&&(t[i]={current:ne(e[i])});return J=n({},e),ce(t).catch((function(){}))}function ce(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,i=r?r.value:void 0,o=e[n].previous;y.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),y.emit("change",t),y.emit("internal-change",J),b.sendEventsOnlyForVariation||H||n.forEach((function(n){Y(n,e[n].current)}))}return c&&X?X.saveFlags(J):Promise.resolve()}function ve(){var e=M||p&&void 0===M;e&&!f?ie():!e&&f&&oe(),j&&j.setStreaming(e)}function de(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof b.bootstrap&&"LOCALSTORAGE"===b.bootstrap.toUpperCase()&&(X?c=!0:m.warn(ae())),"object"===t(b.bootstrap)&&(J=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(pe()),!1===e.$valid&&m.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=q(i,t[n]):i.version=0,r[n]=i}})),r}(b.bootstrap)),H){var ge=H.getInitialState();ge?me(ge):H.on("init",me),H.on("update",(function(e){e.user&&G.setUser(e.user);e.flags&&ue(e.flags)}))}else(function(){if(!e)return Promise.reject(new s(le()));return W.validateUser(r).then((function(e){return G.setUser(e),"object"===t(b.bootstrap)?ye():c?X.loadFlags().then((function(e){return null==e?(J={},x.fetchFlagSettings(G.getUser(),w).then((function(e){return ue(e||{})})).then(ye).catch((function(e){be(new v(fe(e)))}))):(J=e,A(ye),x.fetchFlagSettings(G.getUser(),w).then((function(e){return ue(e)})).catch((function(e){return y.maybeReportError(e)})))})):x.fetchFlagSettings(G.getUser(),w).then((function(e){J=e||{},ye()})).catch((function(e){J={},be(e)}))}))})().catch(be);function me(e){E=e.environment,G.setUser(e.user),J=n({},e.flags),A(ye)}function ye(){m.info("LaunchDarkly client initialized"),K=!0,ve(),h.signalSuccess()}function be(e){h.signalFailure(e)}return{client:{waitForInitialization:function(){return h.getInitializationPromise()},waitUntilReady:function(){return h.getReadyPromise()},identify:function(e,n,t){return $?L(Promise.resolve({}),t):H?(m.warn("identify() has no effect here; it must be called on the main client instance"),L(Promise.resolve(F(J)),t)):L((c&&X?X.clearFlags():Promise.resolve()).then((function(){return W.validateUser(e)})).then((function(e){return x.fetchFlagSettings(e,n).then((function(t){var r=F(t);return G.setUser(e),w=n,t?ue(t).then((function(){return r})):r}))})).then((function(e){return f&&ie(),e})).catch((function(e){return y.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return G.getUser()},variation:function(e,n){return ee(e,n,!0,!1).value},variationDetail:function(e,n){return ee(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&m.warn(se(e));var r=G.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=te(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),Q(i)}else y.maybeReportError(new l(se(e)))},alias:re,on:function(e,n,t){de(e)?(p=!0,K&&ve(),y.on(e,n,t)):y.on.apply(y,arguments)},off:function(e){if(y.off.apply(y,arguments),de(e)){var n=!1;y.getEvents().forEach((function(e){de(e)&&y.getEventListenerCount(e)>0&&(n=!0)})),n||(p=!1,f&&void 0===M&&oe())}},setStreaming:function(e){var n=null===e?void 0:e;n!==M&&(M=n,ve())},flush:function(e){return L(k?N.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!J)return e;for(var n in J)V(J,n)&&(e[n]=ee(n,null,!b.sendEventsOnlyForVariation).value);return e},close:function(e){if($)return L(Promise.resolve(),e);var n=function(){$=!0,J={}};return L(Promise.resolve().then((function(){if(oe(),j&&j.stop(),k)return N.stop(),N.flush()})).then(n).catch(n),e)}},options:b,emitter:y,ident:G,logger:m,requestor:x,start:function(){k&&(j&&j.start(),N.start())},enqueueEvent:Q,getFlagsInternal:function(){return J},getEnvironmentId:function(){return E},internalChangeEventName:"internal-change"}}var sn="3.6.0";export{Y as commonBasicLogger,Z as createConsoleLogger,p as errors,un as initialize,qe as messages,z as utils,sn as version}; | ||
//# sourceMappingURL=ldclient-common.es.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["LDClient-Common"]={})}(this,function(e){"use strict";function W(e){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function Q(i){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(o,!0).forEach(function(e){var n,t,r;n=i,r=o[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(o)):n(o).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})}return i}function f(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var P=t("LaunchDarklyUnexpectedResponseError"),Y=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),Z=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),ee=t("LaunchDarklyFlagFetchError"),ne=t("LaunchDarklyInvalidDataError");function S(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var r=Object.freeze({__proto__:null,LDUnexpectedResponseError:P,LDInvalidEnvironmentIdError:Y,LDInvalidUserError:i,LDInvalidEventKeyError:Z,LDInvalidArgumentError:d,LDFlagFetchError:ee,LDInvalidDataError:ne,isHttpErrorRecoverable:S}),o=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(v(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],a=[],s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=s.length;c<l;++c)u[c]=s[c],a[s.charCodeAt(c)]=c;function v(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(u[(i=r)>>18&63]+u[i>>12&63]+u[i>>6&63]+u[63&i]);return o.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var g=Array.isArray,m=Object.keys,p=Object.prototype.hasOwnProperty,y=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=g(n),u=g(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=m(n);if((i=v.length)!==m(t).length)return!1;for(r=i;0!=r--;)if(!p.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t},h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function b(e){var n=unescape(encodeURIComponent(e));return o(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function O(e){return b(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function te(e){return JSON.parse(JSON.stringify(e))}function re(e,n){return y(e,n)}function ie(e){setTimeout(e,0)}function oe(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function k(e){var n={};for(var t in e)se(e,t)&&(n[t]={value:e[t],version:0});return n}function ae(e){var n={};for(var t in e)se(e,t)&&(n[t]=e[t].value);return n}function E(e,n){for(var t,r=n.slice(0),i=[],o=e;0<r.length;){for(t=[];0<o;){var a=r.shift();if(!a)break;(o-=O(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function w(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function U(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":w(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function I(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(Q({},e)):e}function ue(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return Q({},e,{},n)},{})}function se(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ce(e){if(!e)return e;var n;for(var t in h){var r=h[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||Q({},e))[r]=String(i))}return n||e}var D=Object.freeze({__proto__:null,btoa:b,base64URLEncode:O,clone:te,deepEquals:re,onNextTick:ie,wrapPromiseCallback:oe,transformValuesToVersionedValues:k,transformVersionedValuesToValues:ae,chunkUserEventsForUrl:E,getLDUserAgentString:w,getLDHeaders:U,transformHeaders:I,extend:ue,objectHasOwnProperty:se,sanitizeUser:ce});for(var j,R=(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(j={exports:{}},j.exports),j.exports),T=[],L=0;L<256;++L)T[L]=(L+256).toString(16).substr(1);var C,F,N=function(e,n){var t=n||0,r=T;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},A=0,x=0;var q=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||C,a=void 0!==e.clockseq?e.clockseq:F;if(null==o||null==a){var u=R();null==o&&(o=C=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=F=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:x+1,l=s-A+(c-x)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||A<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");A=s,F=a;var f=(1e4*(268435455&(s+=122192928e5))+(x=c))%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||N(i)},_=2e3;function le(u,e,s){var t="/a/"+e+".gif",c=ue({"Content-Type":"application/json"},U(u,s)),l=u.httpFallbackPing,f={};return f.sendChunk=function(e,r,i,n){var o=JSON.stringify(e),a=i?null:q();return n?function n(t){var e=i?c:ue({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,I(e,s),o).promise.then(function(e){if(e)return 400<=e.status&&S(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+O(o)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,i=u.httpAllowsPost();r=i?[e]:E(_-n.length,e);for(var o=[],a=0;a<r.length;a++)o.push(f.sendChunk(r[a],n,t,i));return Promise.all(o)},f}function V(e){var n={},s=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,i){return Object.keys(r).reduce(function(e,n){var t=e;return i(n)&&(!function(e){return!l[e]&&(s||-1!==o.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var o=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],i=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],i=ue({},i,a[1])}var u=Object.keys(i);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function J(){return"LaunchDarkly client initialized"}function M(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"}function fe(e){return'Custom event "'+e+'" does not exist'}function ve(){return"No environment/client-side ID was specified."+X}function K(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"}function de(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+X}function B(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function H(){return"identify() has no effect here; it must be called on the main client instance"}function $(){return"received ping message from stream"}function G(){return"received streaming update for all flags"}function ge(e){return'received streaming update for flag "'+e+'"'}function me(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function pe(e){return'received streaming deletion for flag "'+e+'"'}function ye(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function he(e){return'enqueueing "'+e+'" event'}var X=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",be=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ke=function(e){return'Expected application/json content type but got "'+e+'"'},Ee=function(e){return"local storage is unavailable: "+z(e)},we=function(e){return"network error"+(e?" ("+e+")":"")},De=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+X},Oe=function(e){return"Error fetching flag settings: "+z(e)},Pe=function(){return"No user specified."+X},Se=function(){return"Invalid user specified."+X},Ue=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},Ie=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(S(e)?t:"giving up permanently")},je=function(){return"Cannot make HTTP requests in this environment."+X},Re=function(){return"Closing stream connection"},Te=function(e){return"Opening stream connection to "+e},Le=function(e,n){return"Error on stream connection: "+z(e)+", will continue retrying every "+n+" milliseconds."},Ce=function(e){return'Ignoring unknown config option "'+e+'"'},Fe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Ne=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ae=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},xe=function(e){return"polling for feature flags at "+e},qe=function(e){return"sending "+e+" events"},_e=Object.freeze({__proto__:null,clientInitialized:J,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:be,eventWithoutUser:M,invalidContentType:ke,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Ee,networkError:we,unknownCustomEventKey:fe,environmentNotFound:De,environmentNotSpecified:ve,errorFetchingFlags:Oe,userNotSpecified:Pe,invalidUser:Se,invalidData:K,bootstrapOldFormat:de,bootstrapInvalid:B,deprecated:Ue,httpErrorMessage:Ie,httpUnavailable:je,identifyDisabled:H,streamClosing:Re,streamConnecting:Te,streamError:Le,unknownOption:Ce,wrongOptionType:Fe,wrongOptionTypeBoolean:Ne,optionBelowMinimum:Ae,debugPolling:xe,debugStreamPing:$,debugStreamPut:G,debugStreamPatch:ge,debugStreamPatchIgnored:me,debugStreamDelete:pe,debugStreamDeleteIgnored:ye,debugEnqueueingEvent:he,debugPostingEvents:qe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Ve(e,n,t,r,i,o){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==i?i:null,c={},l=(5<arguments.length&&void 0!==o?o:null)||le(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var o={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}(),d=V(n),g=n.inlineUsersInEvents,m=n.samplingInterval,p=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===m||0===Math.floor(Math.random()*m)}function O(e){b.length<p?(b.push(e),w=!1):(w||(w=!0,h.warn(be())),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=D(),n&&O(function(e){var n=ue({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=ue({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,O(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(qe(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(k=e.serverTime),S(e.status)||(E=!0),400<=e.status&&ie(function(){s.maybeReportError(new P(Ie(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,y)},y)},c.stop=function(){clearTimeout(a)},c}function ze(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!i[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var Je="ready",Me="initialized",Ke="failed";var Be=function(r){var n=!1,t=!1,i=null,e=null,o=new Promise(function(n){r.on(Je,function e(){r.off(Je,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(i):e=new Promise(function(n,t){r.on(Me,function e(){r.off(Me,e),n()}),r.on(Ke,function e(n){r.off(Ke,e),t(n)})}))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,r.emit(Me),r.emit(Je))},signalFailure:function(e){n||t||(t=!0,i=e,r.emit(Ke,e),r.emit(Je)),r.maybeReportError(e)}}};function He(t,r,i,o){var a={};function u(){var e="",n=o.getUser();return n&&(e=i||b(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=k(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=ue({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function $e(r,n){function i(e){t||(t=!0,n.warn(Ee(e)))}var e={},t=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(n){r?r.get(e).then(n).catch(function(e){i(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){r?r.set(e,t).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){r?r.clear(e).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e}var Ge=3e5;function Xe(i,o,a,n){var u,s=o.streamUrl,c=o.logger,e={},l=s+"/eval/"+a,f=o.useReport,v=o.evaluationReasons,t=o.streamReconnectDelay,d=U(i,o),g=!1,m=null,p=null,y=null,h=null,b=null;function k(e){g||(c.warn(Le(e,t)),g=!0),D(!1),w(),E(t)}function E(e){p||(e?p=setTimeout(r,e):r())}function r(){var e;p=null;var n="",t={headers:d,readTimeoutMillis:Ge};if(i.eventSourceFactory){for(var r in null!=h&&(n="h="+h),f?i.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(y)):(e=s+"/ping/"+a,n=""):e=l+"/"+O(JSON.stringify(y)),t.headers=I(t.headers,o),v&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,w(),c.info(Te(e)),u=(new Date).getTime(),m=i.eventSourceFactory(e,t),b)se(b,r)&&m.addEventListener(r,b[r]);m.onerror=k}}function w(){m&&(c.info(Re()),m.close(),m=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){y=e,h=n,b={};function r(n){b[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}for(var i in t||{})r(i);E()},e.disconnect=function(){clearTimeout(p),p=null,w()},e.isConnected=function(){return!!(m&&i.eventSourceIsActive&&i.eventSourceIsActive(m))},e}var We="application/json";function Qe(u,s,a){var c=s.baseUrl,l=s.useReport,f=s.evaluationReasons,v=s.logger,e={},d={};function g(e,n){if(!u.httpRequest)return new Promise(function(e,n){n(new ee(je()))});var t=n?"REPORT":"GET",r=U(u,s);n&&(r["Content-Type"]=We);var i=d[e];i||(i=function(t){var r,i,o,a,e={addPromise:function(n,e){r=n,i&&i(),i=e,n.then(function(e){r===n&&(o(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){o=e,a=n}),e}(function(){delete d[e]}),d[e]=i);var o=u.httpRequest(t,e,I(r,s),n),a=o.promise.then(function(e){if(200!==e.status)return Promise.reject(function(e){return 404===e.status?new Y(De()):new ee(Oe(e.statusText||String(e.status)))}(e));if(e.header("content-type")&&e.header("content-type").substring(0,We.length)===We)return JSON.parse(e.body);var n=ke(e.header("content-type")||"");return Promise.reject(new ee(n))},function(e){return Promise.reject(new ee(we(e)))});return i.addPromise(a,function(){o.cancel&&o.cancel()}),i.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,i,o="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),i=JSON.stringify(e)):(t=O(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(o="h="+n),f&&(o=o+(o?"&":"")+"withReasons=true"),r=r+(o?"?":"")+o,v.debug(xe(r)),g(r,i)},e}var Ye="ld:$anonUserId";function Ze(r){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(Pe()));var t=te(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?r.get(Ye).then(function(e){if(e)return t.key=e,t;var n=q();return function(e){return r.set(Ye,e)}(t.key=n).then(function(){return t})}):Promise.reject(new i(Se()))},e}var en=["debug","info","warn","error","none"];function nn(e,a){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],s=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<en.length;t++)en[t]===e.level&&(r=t);for(var i={},o=function(e){var n=en[e];if("none"!==n)if(e<r)i[n]=function(){};else{var t=e;i[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,i=s?n+": "+c:c;if(1!==t.length&&a){var o=f(t);o[0]=i+o[0],r=a.apply(void 0,f(o))}else r=i+t[0];try{u[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<en.length;l++)o(l);return i}function tn(e,n){return nn({level:e,prefix:n})}var rn={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function on(e,n,t,r){var a=ue({logger:{default:r}},rn,t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){ie(function(){n&&n.maybeReportError(new d(e))})}var o,s,c,l,f=ue({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=W(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return o=f,Object.keys(i).forEach(function(e){if(void 0!==o[e]){var n=i[e];r&&r.warn(Ue(e,n)),n&&(void 0===o[n]&&(o[n]=o[e]),delete o[e])}}),s=ue({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=ue({},c=f=s),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)u(Ce(e));else{var r=t.type||v(t.default);if("any"!==r){var i=r.split("|"),o=v(n);i.indexOf(o)<0?"boolean"===r?(l[e]=!!n,u(Ne(e,o))):(u(Fe(e,r,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&n<t.minimum&&(u(Ae(e,n,t.minimum)),l[e]=t.minimum)}}}}),function(n){en.forEach(function(e){if("none"!==e&&(!n[e]||"function"!=typeof n[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}((f=l).logger),f}var an=Object.freeze({__proto__:null,baseOptionDefs:rn,validate:on}).baseOptionDefs;var un=function(e){var n={diagnosticId:q()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},sn=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},cn=function(n,r,e,t,i,o,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=o.eventsUrl+"/events/diagnostic/"+i,v=o.diagnosticRecordingInterval,d=e,g=!!o.streaming,m={};function p(){return{sdk:function(){var e=Q({},n.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==an.baseUrl.default,customStreamURI:o.streamUrl!==an.streamUrl.default,customEventsURI:o.eventsUrl!==an.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation,autoAliasingOptOut:!!o.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function y(e){o.logger&&o.logger.debug(_e.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){y(function(){var e=(new Date).getTime(),n=Q({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},d.getProps());return c&&(n=Q({},n,{},p())),d.reset(e),n}()),s=setTimeout(h,v),u=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=Q({},d.getProps());r.set(l,JSON.stringify(e))}}()}return m.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);d.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();n<=t?h():s=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():s=setTimeout(h,v)}):(y(Q({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},p())),s=setTimeout(h,v))},m.stop=function(){s&&clearTimeout(s)},m.setStreaming=function(e){g=e},m},ln="change",fn="internal-change";e.commonBasicLogger=nn,e.createConsoleLogger=tn,e.errors=r,e.initialize=function(e,n,t,o,r){var a,i,u,s=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||tn("warn")}(),c=ze(s),l=Be(c),f=on(t,c,r,s),v=f.sendEvents,d=e,g=f.hash,m=$e(o.localStorage,s),p=le(o,d,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?un(d):null,b=y?sn((new Date).getTime()):null,k=y?cn(o,m,b,p,d,f,h):null,E=Xe(o,f,d,b),w=f.eventProcessor||Ve(o,f,d,b,c,p),D=Qe(o,f,d),O={},P={},S=f.streaming,U=!1,I=!1,j=!0,R=f.stateProvider,T=function(e,t){var r,n={};return n.setUser=function(e){var n=r&&te(r);(r=ce(e))&&t&&t(te(r),n)},n.getUser=function(){return r?te(r):null},e&&n.setUser(e),n}(null,function(e,n){(function(e){if(R)return;e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&_(e,n)}),L=Ze(m),C=m.isEnabled()?new He(m,d,g,T,s):null;function F(e){if(d&&!(R&&R.enqueueEvent&&R.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(j&&(s.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),j=!1));j=!1}!v||I||o.isDoNotTrack()||(s.debug(he(e.kind)),w.enqueue(e))}}function N(e,n,t,r){var i=T.getUser(),o=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=O[u];if(s&&o-s<3e5)return;O[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(c.contextKind=q(i));var l=P[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),F(c)}function A(e,n,t,r){var i;if(P&&se(P,e)&&P[e]&&!P[e].deleted){var o=P[e];i=x(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&N(e,i,n,r),i}function x(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function q(e){return e.anonymous?"anonymousUser":"user"}function _(e,n){R||e&&n&&F({kind:"alias",key:e.key,contextKind:q(e),previousKey:n.key,previousContextKind:q(n),creationDate:(new Date).getTime()})}function V(){if(i=!0,T.getUser()){var a=function(e){try{return JSON.parse(e)}catch(e){return void c.maybeReportError(new ne("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};E.connect(T.getUser(),g,{ping:function(){s.debug("received ping message from stream");var n=T.getUser();D.fetchFlagSettings(n,g).then(function(e){re(n,T.getUser())&&J(e||{})}).catch(function(e){c.maybeReportError(new ee(Oe(e)))})},put:function(e){var n=a(e.data);n&&(s.debug("received streaming update for all flags"),J(n))},patch:function(e){var n=a(e.data);if(n){var t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){s.debug(ge(n.key));var r={},i=ue({},n);delete i.key;var o=x(P[n.key]=i);r[n.key]=t?{previous:t.value,current:o}:{current:o},M(r)}else s.debug(me(n.key))}},delete:function(e){var n=a(e.data);if(n)if(!P[n.key]||P[n.key].version<n.version){s.debug(pe(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},M(t)}else s.debug(ye(n.key))}})}}function z(){i&&(E.disconnect(),i=!1)}function J(e){var n={};if(!e)return Promise.resolve();for(var t in P)se(P,t)&&P[t]&&(e[t]&&!re(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:x(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var r in e)se(e,r)&&e[r]&&(!P[r]||P[r].deleted)&&(n[r]={current:x(e[r])});return P=Q({},e),M(n).catch(function(){})}function M(i){var e=Object.keys(i);if(0<e.length){var o={};e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;c.emit(ln+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),c.emit(ln,o),c.emit(fn,P),f.sendEventsOnlyForVariation||R||e.forEach(function(e){N(e,i[e].current)})}return a&&C?C.saveFlags(P):Promise.resolve()}function K(){var e=S||u&&void 0===S;e&&!i?V():!e&&i&&z(),k&&k.setStreaming(e)}function B(e){return e===ln||e.substr(0,ln.length+1)===ln+":"}if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(C?a=!0:s.warn(Ee())),"object"===W(f.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",i=t[r];!i&&e.length&&s.warn(de()),!1===t.$valid&&s.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};i&&i[e]?n=ue(n,i[e]):n.version=0,o[e]=n}}),o}(f.bootstrap)),R){var H=R.getInitialState();H?$(H):R.on("init",$),R.on("update",function(e){e.user&&T.setUser(e.user);e.flags&&J(e.flags)})}else(e?L.validateUser(n).then(function(e){return T.setUser(e),"object"===W(f.bootstrap)?G():a?C.loadFlags().then(function(e){return null==e?(P={},D.fetchFlagSettings(T.getUser(),g).then(function(e){return J(e||{})}).then(G).catch(function(e){X(new ee(Oe(e)))})):(P=e,ie(G),D.fetchFlagSettings(T.getUser(),g).then(function(e){return J(e)}).catch(function(e){return c.maybeReportError(e)}))}):D.fetchFlagSettings(T.getUser(),g).then(function(e){P=e||{},G()}).catch(function(e){P={},X(e)})}):Promise.reject(new Y(ve()))).catch(X);function $(e){d=e.environment,T.setUser(e.user),P=Q({},e.flags),ie(G)}function G(){s.info("LaunchDarkly client initialized"),U=!0,K(),l.signalSuccess()}function X(e){l.signalFailure(e)}return{client:{waitForInitialization:function(){return l.getInitializationPromise()},waitUntilReady:function(){return l.getReadyPromise()},identify:function(e,r,n){return I?oe(Promise.resolve({}),n):R?(s.warn("identify() has no effect here; it must be called on the main client instance"),oe(Promise.resolve(ae(P)),n)):oe((a&&C?C.clearFlags():Promise.resolve()).then(function(){return L.validateUser(e)}).then(function(t){return D.fetchFlagSettings(t,r).then(function(e){var n=ae(e);return T.setUser(t),g=r,e?J(e).then(function(){return n}):n})}).then(function(e){return i&&V(),e}).catch(function(e){return c.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return T.getUser()},variation:function(e,n){return A(e,n,!0,!1).value},variationDetail:function(e,n){return A(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&s.warn(fe(e));var r=T.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=q(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),F(i)}else c.maybeReportError(new Z(fe(e)))},alias:_,on:function(e,n,t){B(e)?(u=!0,U&&K(),c.on(e,n,t)):c.on.apply(c,arguments)},off:function(e){if(c.off.apply(c,arguments),B(e)){var n=!1;c.getEvents().forEach(function(e){B(e)&&0<c.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===S&&z())}},setStreaming:function(e){var n=null===e?void 0:e;n!==S&&(S=n,K())},flush:function(e){return oe(v?w.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)se(P,n)&&(e[n]=A(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return oe(Promise.resolve(),e);function n(){I=!0,P={}}return oe(Promise.resolve().then(function(){if(z(),k&&k.stop(),v)return w.stop(),w.flush()}).then(n).catch(n),e)}},options:f,emitter:c,ident:T,logger:s,requestor:D,start:function(){v&&(k&&k.start(),w.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:function(){return d},internalChangeEventName:fn}},e.messages=_e,e.utils=D,e.version="3.5.1",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["LDClient-Common"]={})}(this,function(e){"use strict";function b(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function ne(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?b(Object(i),!0).forEach(function(e){var n,t;n=r,t=i[e=e],e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):b(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function te(e){return(te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function n(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var T=n("LaunchDarklyUnexpectedResponseError"),re=n("LaunchDarklyInvalidEnvironmentIdError"),i=n("LaunchDarklyInvalidUserError"),pe=n("LaunchDarklyInvalidEventKeyError"),E=n("LaunchDarklyInvalidArgumentError"),ie=n("LaunchDarklyFlagFetchError"),me=n("LaunchDarklyInvalidDataError");function I(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var w=Object.freeze({__proto__:null,LDUnexpectedResponseError:T,LDInvalidEnvironmentIdError:re,LDInvalidUserError:i,LDInvalidEventKeyError:pe,LDInvalidArgumentError:E,LDFlagFetchError:ie,LDInvalidDataError:me,isHttpErrorRecoverable:I}),D=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(function(e,n,t){for(var r,i=[],o=n;o<t;o+=3)r=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(function(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}(r));return i.join("")}(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],t=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,P=o.length;a<P;++a)u[a]=o[a],t[o.charCodeAt(a)]=a;t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63;function s(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){var t,r,i=S(e),o=S(n);if(i&&o){if((a=e.length)!=n.length)return!1;for(t=a;0!=t--;)if(!s(e[t],n[t]))return!1;return!0}if(i!=o)return!1;i=e instanceof Date,o=n instanceof Date;if(i!=o)return!1;if(i&&o)return e.getTime()==n.getTime();i=e instanceof RegExp,o=n instanceof RegExp;if(i!=o)return!1;if(i&&o)return e.toString()==n.toString();var a,u=U(e);if((a=u.length)!==U(n).length)return!1;for(t=a;0!=t--;)if(!R.call(n,u[t]))return!1;for(t=a;0!=t--;)if(!s(e[r=u[t]],n[r]))return!1;return!0}return e!=e&&n!=n}var S=Array.isArray,U=Object.keys,R=Object.prototype.hasOwnProperty,A=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function j(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function c(e){e=unescape(encodeURIComponent(e));return D(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(e))}function O(e){return c(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function oe(e){return JSON.parse(JSON.stringify(e))}function ae(e,n){return s(e,n)}function ue(e){setTimeout(e,0)}function se(e,n){e=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:e}function C(e){var n,t={};for(n in e)fe(e,n)&&(t[n]={value:e[n],version:0});return t}function ce(e){var n,t={};for(n in e)fe(e,n)&&(t[n]=e[n].value);return t}function F(e,n){for(var t,r=n.slice(0),i=[],o=e;0<r.length;){for(t=[];0<o;){var a=r.shift();if(!a)break;(o-=O(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function L(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function le(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return ne(ne({},e),n)},{})}function fe(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ye(e){if(!e)return e;var n,t;for(t in A){var r=A[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||ne({},e))[r]=String(i))}return n||e}var N=Object.freeze({__proto__:null,appendUrlPath:j,btoa:c,base64URLEncode:O,clone:oe,deepEquals:ae,onNextTick:ue,wrapPromiseCallback:se,transformValuesToVersionedValues:C,transformVersionedValuesToValues:ce,chunkUserEventsForUrl:F,getLDUserAgentString:L,extend:le,objectHasOwnProperty:fe,sanitizeUser:ye});(function(e){var n,t,r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);r?(n=new Uint8Array(16),e.exports=function(){return r(n),n}):(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})})(x={exports:{}});for(var x,_=x.exports,q=[],l=0;l<256;++l)q[l]=(l+256).toString(16).substr(1);var V,f,J=function(e,n){var n=n||0,t=q;return[t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[+n]]].join("")},d=0,v=0;var g=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||V,t=void 0!==e.clockseq?e.clockseq:f,a=(null!=o&&null!=t||(a=_(),null==o&&(o=V=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==t&&(t=f=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),u=void 0!==e.nsecs?e.nsecs:v+1,s=a-d+(u-v)/1e4;if(s<0&&void 0===e.clockseq&&(t=t+1&16383),1e4<=(u=(s<0||d<a)&&void 0===e.nsecs?0:u))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");d=a,f=t,s=(1e4*(268435455&(a+=122192928e5))+(v=u))%4294967296,i[r++]=s>>>24&255,i[r++]=s>>>16&255,i[r++]=s>>>8&255,i[r++]=255&s,e=a/4294967296*1e4&268435455,i[r++]=e>>>8&255,i[r++]=255&e,i[r++]=e>>>24&15|16,i[r++]=e>>>16&255,i[r++]=t>>>8|128,i[r++]=255&t;for(var c=0;c<6;++c)i[r+c]=o[c];return n||J(i)},p=["debug","info","warn","error","none"];function M(e,u){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",t=1;if(e&&e.level)for(var r=0;r<p.length;r++)p[r]===e.level&&(t=r);for(var i={},o=function(e){var o,a=p[e];"none"!==a&&(e<t?i[a]=function(){}:(o=e,i[a]=function(){var e=o,n=a,t=arguments;if(!(t.length<1)){var r=c?n+": "+l:l,i=1!==t.length&&u?((i=k(t))[0]=r+i[0],u.apply(void 0,k(i))):r+t[0];try{s[e](i)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}))},a=0;a<p.length;a++)o(a);return i}function he(e,n){return M({level:e,prefix:n})}function m(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function be(){return"LaunchDarkly client initialized"}function ke(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"}function de(e){return'Custom event "'+e+'" does not exist'}function z(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+y}function Ee(){return"No environment/client-side ID was specified."+y}function ve(e){return"Error fetching flag settings: "+m(e)}function we(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"}function De(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+y}function Oe(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function K(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'}function Pe(){return"identify() has no effect here; it must be called on the main client instance"}function B(e){return'Ignoring unknown config option "'+e+'"'}function $(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"}function H(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"}function G(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t}function Se(){return"received ping message from stream"}function Ue(){return"received streaming update for all flags"}function Ie(e){return'received streaming update for flag "'+e+'"'}function je(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function Te(e){return'received streaming deletion for flag "'+e+'"'}function Re(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function Ae(e){return'enqueueing "'+e+'" event'}var y=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",W=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},X=function(e){return'Expected application/json content type but got "'+e+'"'},Ce=function(e){return"local storage is unavailable: "+m(e)},Q=function(e){return"network error"+(e?" ("+e+")":"")},Y=function(){return"No user specified."+y},Z=function(){return"Invalid user specified."+y},ee=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(I(e)?t:"giving up permanently")},Fe=function(){return"Cannot make HTTP requests in this environment."+y},Le=function(){return"Closing stream connection"},Ne=function(e){return"Opening stream connection to "+e},xe=function(e,n){return"Error on stream connection: "+m(e)+", will continue retrying every "+n+" milliseconds."},_e=function(e){return"polling for feature flags at "+e},qe=function(e){return"sending "+e+" events"},Ve=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},Je=Object.freeze({__proto__:null,clientInitialized:be,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:W,eventWithoutUser:ke,invalidContentType:X,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Ce,networkError:Q,unknownCustomEventKey:de,environmentNotFound:z,environmentNotSpecified:Ee,errorFetchingFlags:ve,userNotSpecified:Y,invalidUser:Z,invalidData:we,bootstrapOldFormat:De,bootstrapInvalid:Oe,deprecated:K,httpErrorMessage:ee,httpUnavailable:Fe,identifyDisabled:Pe,streamClosing:Le,streamConnecting:Ne,streamError:xe,unknownOption:B,wrongOptionType:$,wrongOptionTypeBoolean:H,optionBelowMinimum:G,debugPolling:_e,debugStreamPing:Se,debugStreamPut:Ue,debugStreamPatch:Ie,debugStreamPatchIgnored:je,debugStreamDelete:Te,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Ae,debugPostingEvents:qe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:Ve}),Me={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var i={};t.id&&(i.id=Ke("".concat(e,".id"),0,t.id,r));t.version&&(i.version=Ke("".concat(e,".version"),0,t.version,r));return i}}},ze=/^(\w|\.|-)+$/;function Ke(e,n,t,r){if("string"==typeof t&&t.match(ze))return t;r.warn(Ve(e))}function Be(e,n,t,a){var u=le({logger:{default:a}},Me,t),r={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){ue(function(){n&&n.maybeReportError(new E(e))})}var i,o,c,l,f,t=le({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=te(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}return i=t,Object.keys(r).forEach(function(e){var n;void 0!==i[e]&&(n=r[e],a&&a.warn(K(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e]))}),o=le({},t),Object.keys(u).forEach(function(e){void 0!==o[e]&&null!==o[e]||(o[e]=u[e]&&u[e].default)}),l=le({},c=t=o),Object.keys(c).forEach(function(e){var n,t,r,i,o=c[e];null!=o&&(void 0===(n=u[e])?s(B(e)):(t=n.type||d(n.default),(r=n.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==t&&(r=t.split("|"),i=d(o),r.indexOf(i)<0?"boolean"===t?(l[e]=!!o,s(H(e,i))):(s($(e,t,i)),l[e]=n.default):"number"===i&&void 0!==n.minimum&&o<n.minimum&&(s(G(e,o,n.minimum)),l[e]=n.minimum))))}),f=(t=l).logger,p.forEach(function(e){if("none"!==e&&(!f[e]||"function"!=typeof f[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),t}function $e(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function He(e,n){if(n&&!n.sendLDHeaders)return{};var e={"X-LaunchDarkly-User-Agent":L(e)},t=(n&&n.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),$e(n)),n=Object.keys(t);return n.length&&(e["x-launchdarkly-tags"]=n.sort().flatMap(function(n){return Array.isArray(t[n])?t[n].sort().map(function(e){return"".concat(n,"/").concat(e)}):["".concat(n,"/").concat(t[n])]}).join(" ")),e}function Ge(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(ne({},e)):e}var We=2e3;function Xe(u,e,s){var c="/a/"+e+".gif",l=le({"Content-Type":"application/json"},He(u,s)),f=u.httpFallbackPing,d={};return d.sendChunk=function(e,n,r,t){var i=JSON.stringify(e),o=r?null:g();function a(t){var e=r?l:le({},l,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":o});return u.httpRequest("POST",n,Ge(e,s),i).promise.then(function(e){var n;if(e)return 400<=e.status&&I(e.status)&&t?a(!1):(n={status:(e=e).status},(e=e.header("date"))&&(e=Date.parse(e))&&(n.serverTime=e),n)}).catch(function(){return t?a(!1):Promise.reject()})}return t?a(!0).catch(function(){}):(f&&f(n+c+"?d="+O(i)),Promise.resolve())},d.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();for(var r=u.httpAllowsPost(),i=r?[e]:F(We-n.length,e),o=[],a=0;a<i.length;a++)o.push(d.sendChunk(i[a],n,t,r));return Promise.all(o)},d}function Qe(e){var n={},a=e.allAttributesPrivate,u=e.privateAttributeNames||[],s={key:!0,custom:!0,anonymous:!0},c={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(t,r){return Object.keys(t).reduce(function(e,n){return r(n)&&(i(n)?e[1][n]=!0:e[0][n]=t[n]),e},[{},{}])}var t=e.privateAttributeNames||[],i=function(e){return!s[e]&&(a||-1!==t.indexOf(e)||-1!==u.indexOf(e))},r=n(e,function(e){return c[e]}),o=r[0],r=r[1],e=(e.custom&&(e=n(e.custom,function(){return 1}),o.custom=e[0],r=le({},r,e[1])),Object.keys(r));return e.length&&(e.sort(),o.privateAttrs=e),o},n}function Ye(e,n,t,r,i,o){var a,u,s,c,l=3<arguments.length&&void 0!==r?r:null,f=4<arguments.length&&void 0!==i?i:null,d={},v=(5<arguments.length&&void 0!==o?o:null)||Xe(e,t,n),g=j(n.eventsUrl,"/events/bulk/"+t),p=(u=a=0,s={},(r={}).summarizeEvent=function(e){var n,t;"feature"===e.kind&&(n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(t=s[n])?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate))},r.getSummary=function(){var e,n={},t=!0;for(e in s){var r=s[e],i=n[r.key],o=(i||(i={default:r.default,counters:[]},n[r.key]=i),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),t=!1}return t?null:{startDate:a,endDate:u,features:n}},r.clearSummary=function(){u=a=0,s={}},r),m=Qe(n),y=n.inlineUsersInEvents,h=n.samplingInterval,b=n.eventCapacity,k=n.flushInterval,E=n.logger,w=[],D=0,O=!1,P=!1;function S(){return 0===h||0===Math.floor(Math.random()*h)}function U(e){w.length<b?(w.push(e),P=!1):(P||(P=!0,E.warn(W())),l&&l.incrementDroppedEvents())}return d.enqueue=function(e){var n,t,r;O||(n=r=!1,p.summarizeEvent(e),"feature"===e.kind?S()&&(r=!!e.trackEvents,n=!!(t=e).debugEventsUntilDate&&(t.debugEventsUntilDate>D&&t.debugEventsUntilDate>(new Date).getTime())):r=S(),r&&U((r=le({},t=e),"alias"!==t.kind&&(y||"identify"===t.kind?r.user=m.filterUser(t.user):(r.userKey=t.user.key,delete r.user),"feature"===t.kind&&(delete r.trackEvents,delete r.debugEventsUntilDate)),r)),n&&((r=le({},e,{kind:"debug"})).user=m.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,U(r)))},d.flush=function(){if(O)return Promise.resolve();var e=w,n=p.getSummary();return p.clearSummary(),n&&(n.kind="summary",e.push(n)),l&&l.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],E.debug(qe(e.length)),v.sendEvents(e,g).then(function(e){e&&(e.serverTime&&(D=e.serverTime),I(e.status)||(O=!0),400<=e.status&&ue(function(){f.maybeReportError(new T(ee(e.status,"event posting","some events were dropped")))}))}))},d.start=function(){c=setTimeout(function e(){d.flush(),c=setTimeout(e,k)},k)},d.stop=function(){clearTimeout(c)},d}function Ze(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(i["error"]?this.emit("error",e):(n||console).error(e.message))},e}var h="ready",en="initialized",nn="failed";var tn=function(i){var n=!1,t=!1,r=null,e=null,o=new Promise(function(n){i.on(h,function e(){i.off(h,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(r):e=new Promise(function(n,t){function r(e){i.off(nn,r),t(e)}i.on(en,function e(){i.off(en,e),n()}),i.on(nn,r)}))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,i.emit(en),i.emit(h))},signalFailure:function(e){n||t||(t=!0,r=e,i.emit(nn,e),i.emit(h)),i.maybeReportError(e)}}};function rn(n,t,r,i){var o={};function a(){var e="",n=i.getUser();return n&&(e=r||c(JSON.stringify(n))),"ld:"+t+":"+e}return o.loadFlags=function(){return n.get(a()).then(function(e){if(null==e)return null;try{var n,t=JSON.parse(e);return t&&(void 0===(n=t.$schema)||n<1?t=C(t):delete t.$schema),t}catch(e){return o.clearFlags().then(function(){return null})}})},o.saveFlags=function(e){e=le({},e,{$schema:1});return n.set(a(),JSON.stringify(e))},o.clearFlags=function(){return n.clear(a())},o}function on(r,n){function i(e){t||(t=!0,n.warn(Ce(e)))}var e={},t=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(n){r?r.get(e).then(n).catch(function(e){i(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){r?r.set(e,t).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){r?r.clear(e).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e}var an=3e5;function un(i,o,a,n){var u,s=o.streamUrl,c=o.logger,e={},l=j(s,"/eval/"+a),f=o.useReport,d=o.evaluationReasons,t=o.streamReconnectDelay,v=He(i,o),g=!1,p=null,m=null,y=null,h=null,b=null;function k(e){g||(c.warn(xe(e,t)),g=!0),D(!1),w(),E(t)}function E(e){m||(e?m=setTimeout(r,e):r())}function r(){m=null;var e,n="",t={headers:v,readTimeoutMillis:an};if(i.eventSourceFactory){for(var r in null!=h&&(n="h="+h),f?i.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(y)):(e=j(s,"/ping/"+a),n=""):e=l+"/"+O(JSON.stringify(y)),t.headers=Ge(t.headers,o),e=e+((n=d?n+(n?"&":"")+"withReasons=true":n)?"?":"")+n,w(),c.info(Ne(e)),u=(new Date).getTime(),p=i.eventSourceFactory(e,t),b)fe(b,r)&&p.addEventListener(r,b[r]);p.onerror=k}}function w(){p&&(c.info(Le()),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){y=e,h=n,b={};for(var r in t||{})!function(n){b[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}(r);E()},e.disconnect=function(){clearTimeout(m),m=null,w()},e.isConnected=function(){return!!(p&&i.eventSourceIsActive&&i.eventSourceIsActive(p))},e}var sn="application/json";function cn(d,v,o){var a=v.baseUrl,u=v.useReport,s=v.evaluationReasons,c=v.logger,e={},g={};function l(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ie(Fe()))});var t,r,i,o,a,u=n?"REPORT":"GET",s=He(d,v),c=(n&&(s["Content-Type"]=sn),g[e]),l=(c||(t=function(){delete g[e]},(f={addPromise:function(n,e){r=n,i&&i(),i=e,n.then(function(e){r===n&&(o(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}}).resultPromise=new Promise(function(e,n){o=e,a=n}),c=f,g[e]=c),d.httpRequest(u,e,Ge(s,v),n)),f=l.promise.then(function(e){var n;return 200===e.status?e.header("content-type")&&e.header("content-type").substring(0,sn.length)===sn?JSON.parse(e.body):(n=X(e.header("content-type")||""),Promise.reject(new ie(n))):Promise.reject(404===(n=e).status?new re(z()):new ie(ve(n.statusText||String(n.status))))},function(e){return Promise.reject(new ie(Q(e)))});return c.addPromise(f,function(){l.cancel&&l.cancel()}),c.resultPromise}return e.fetchJSON=function(e){return l(j(a,e),null)},e.fetchFlagSettings=function(e,n){var t,r,i="";return u?(t=[a,"/sdk/evalx/",o,"/user"].join(""),r=JSON.stringify(e)):(e=O(JSON.stringify(e)),t=[a,"/sdk/evalx/",o,"/users/",e].join("")),n&&(i="h="+n),c.debug(_e(t=t+((i=s?i+(i?"&":"")+"withReasons=true":i)?"?":"")+i)),l(t,r)},e}var ln="ld:$anonUserId";function fn(t){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(Y()));var n=oe(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?t.get(ln).then(function(e){return e?(n.key=e,n):(e=g(),n.key=e,t.set(ln,e).then(function(){return n}))}):Promise.reject(new i(Z()))},e}var dn=Object.freeze({__proto__:null,baseOptionDefs:Me,validate:Be,getTags:$e}).baseOptionDefs,vn=N.appendUrlPath;var gn=function(e){var n={diagnosticId:g()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},pn=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){i.push({timestamp:e,failed:n,durationMillis:t})},reset:o}},mn=function(n,r,e,t,i,o,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=vn(o.eventsUrl,"/events/diagnostic/"+i),d=o.diagnosticRecordingInterval,v=e,g=!!o.streaming;function p(){return{sdk:function(){var e=ne({},n.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==dn.baseUrl.default,customStreamURI:o.streamUrl!==dn.streamUrl.default,customEventsURI:o.eventsUrl!==dn.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation,autoAliasingOptOut:!!o.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function m(e){o.logger&&o.logger.debug(Je.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;m((n=(new Date).getTime(),e=ne({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},v.getProps()),c&&(e=ne(ne({},e),p())),v.reset(n),e)),s=setTimeout(y,d),u=(new Date).getTime(),c&&r.isEnabled()&&(n=ne({},v.getProps()),r.set(l,JSON.stringify(n)))}return(i={}).start=function(){var t;c?(t=function(e){var n;e?(e=(u||0)+d)<=(n=(new Date).getTime())?y():s=setTimeout(y,e-n):0===Math.floor(4*Math.random())?y():s=setTimeout(y,d)},r.isEnabled()?r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)}):t(!1)):(m(ne({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),s=setTimeout(y,d))},i.stop=function(){s&&clearTimeout(s)},i.setStreaming=function(e){g=e},i},ge="change",yn="internal-change";e.commonBasicLogger=M,e.createConsoleLogger=he,e.errors=w,e.initialize=function(N,x,e,i,n){var t,o,r,a,u,s,_,c,l,f=function(){if(e&&e.logger)return e.logger;return n&&n.logger&&n.logger.default||he("warn")}(),d=Ze(f),v=tn(d),g=Be(e,d,n,f),p=g.sendEvents,m=N,y=g.hash,h=on(i.localStorage,f),b=Xe(i,m,g),k=g.sendEvents&&!g.diagnosticOptOut,q=k?gn(m):null,E=k?pn((new Date).getTime()):null,w=k?mn(i,h,E,b,m,g,q):null,V=un(i,g,m,E),D=g.eventProcessor||Ye(i,g,m,E,d,b),O=cn(i,g,m),J={},P={},S=g.streaming,M=!1,U=!1,z=!0,I=g.stateProvider,j=(a=function(e,n){(function(e){I||e&&R({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!g.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&H(e,n)},k={setUser:function(e){var n=u&&oe(u);(u=ye(e))&&a&&a(oe(u),n)},getUser:function(){return u?oe(u):null}},(q=null)&&k.setUser(q),k),K=fn(h),T=h.isEnabled()?new rn(h,m,y,j):null;function R(e){if(m&&!(I&&I.enqueueEvent&&I.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(z&&(f.warn(ke()),z=!1));z=!1}!p||U||i.isDoNotTrack()||(f.debug(Ae(e.kind)),D.enqueue(e))}}function B(e,n,t,r){var i=j.getUser(),o=new Date,a=n?n.value:null;if(!g.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=J[u];if(s&&o-s<3e5)return;J[u]=o}s={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()},i&&i.anonymous&&(s.contextKind=C(i)),u=P[e];u&&(s.version=u.flagVersion||u.version,s.trackEvents=u.trackEvents,s.debugEventsUntilDate=u.debugEventsUntilDate),(r||u&&u.trackReason)&&n&&(s.reason=n.reason),R(s)}function $(e,n,t,r){var i,o;return P&&fe(P,e)&&P[e]&&!P[e].deleted?(o=A(i=P[e]),null!==i.value&&void 0!==i.value||(o.value=n)):o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},t&&B(e,o,n,r),o}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function C(e){return e.anonymous?"anonymousUser":"user"}function H(e,n){I||e&&n&&R({kind:"alias",key:e.key,contextKind:C(e),previousKey:n.key,previousContextKind:C(n),creationDate:(new Date).getTime()})}function G(){var i;o=!0,j.getUser()&&(i=function(e){try{return JSON.parse(e)}catch(e){return void d.maybeReportError(new me(we()))}},V.connect(j.getUser(),y,{ping:function(){f.debug(Se());var n=j.getUser();O.fetchFlagSettings(n,y).then(function(e){ae(n,j.getUser())&&F(e||{})}).catch(function(e){d.maybeReportError(new ie(ve(e)))})},put:function(e){e=i(e.data);e&&(f.debug(Ue()),F(e))},patch:function(e){var n,t,r,e=i(e.data);e&&(!(n=P[e.key])||!n.version||!e.version||n.version<e.version?(f.debug(Ie(e.key)),t={},delete(r=le({},e)).key,r=A(P[e.key]=r),t[e.key]=n?{previous:n.value,current:r}:{current:r},X(t)):f.debug(je(e.key)))},delete:function(e){var n,e=i(e.data);e&&(!P[e.key]||P[e.key].version<e.version?(f.debug(Te(e.key)),n={},P[e.key]&&!P[e.key].deleted&&(n[e.key]={previous:P[e.key].value}),P[e.key]={version:e.version,deleted:!0},X(n)):f.debug(Re(e.key)))}}))}function W(){o&&(V.disconnect(),o=!1)}function F(e){var n,t,r={};if(!e)return Promise.resolve();for(n in P)fe(P,n)&&P[n]&&(e[n]&&!ae(e[n].value,P[n].value)?r[n]={previous:P[n].value,current:A(e[n])}:e[n]&&!e[n].deleted||(r[n]={previous:P[n].value}));for(t in e)fe(e,t)&&e[t]&&(!P[t]||P[t].deleted)&&(r[t]={current:A(e[t])});return P=ne({},e),X(r).catch(function(){})}function X(i){var o,e=Object.keys(i);return 0<e.length&&(o={},e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;d.emit(ge+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),d.emit(ge,o),d.emit(yn,P),g.sendEventsOnlyForVariation||I||e.forEach(function(e){B(e,i[e].current)})),t&&T?T.saveFlags(P):Promise.resolve()}function Q(){var e=S||r&&void 0===S;e&&!o?G():!e&&o&&W(),w&&w.setStreaming(e)}function Y(e){return e===ge||e.substr(0,ge.length+1)===ge+":"}function Z(e){m=e.environment,j.setUser(e.user),P=ne({},e.flags),ue(L)}function L(){f.info(be()),M=!0,Q(),v.signalSuccess()}function ee(e){v.signalFailure(e)}return"string"==typeof g.bootstrap&&"LOCALSTORAGE"===g.bootstrap.toUpperCase()&&(T?t=!0:f.warn(Ce())),"object"===te(g.bootstrap)&&(s=g.bootstrap,E=Object.keys(s),!(c=s[_="$flagsState"])&&E.length&&f.warn(De()),!1===s.$valid&&f.warn(Oe()),l={},E.forEach(function(e){var n;e!==_&&"$valid"!==e&&(n={value:s[e]},c&&c[e]?n=le(n,c[e]):n.version=0,l[e]=n)}),P=l),I?((b=I.getInitialState())?Z(b):I.on("init",Z),I.on("update",function(e){e.user&&j.setUser(e.user);e.flags&&F(e.flags)})):(N?K.validateUser(x).then(function(e){return j.setUser(e),"object"===te(g.bootstrap)?L():t?T.loadFlags().then(function(e){return null==e?(P={},O.fetchFlagSettings(j.getUser(),y).then(function(e){return F(e||{})}).then(L).catch(function(e){ee(new ie(ve(e)))})):(P=e,ue(L),O.fetchFlagSettings(j.getUser(),y).then(F).catch(function(e){return d.maybeReportError(e)}))}):O.fetchFlagSettings(j.getUser(),y).then(function(e){P=e||{},L()}).catch(function(e){P={},ee(e)})}):Promise.reject(new re(Ee()))).catch(ee),{client:{waitForInitialization:function(){return v.getInitializationPromise()},waitUntilReady:function(){return v.getReadyPromise()},identify:function(e,r,n){return U?se(Promise.resolve({}),n):I?(f.warn(Pe()),se(Promise.resolve(ce(P)),n)):se((t&&T?T.clearFlags():Promise.resolve()).then(function(){return K.validateUser(e)}).then(function(t){return O.fetchFlagSettings(t,r).then(function(e){var n=ce(e);return j.setUser(t),y=r,e?F(e).then(function(){return n}):n})}).then(function(e){return o&&G(),e}).catch(function(e){return d.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return j.getUser()},variation:function(e,n){return $(e,n,!0,!1).value},variationDetail:function(e,n){return $(e,n,!0,!0)},track:function(e,n,t){var r;"string"!=typeof e?d.maybeReportError(new pe(de(e))):(i.customEventFilter&&!i.customEventFilter(e)&&f.warn(de(e)),r={kind:"custom",key:e,user:e=j.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},e&&e.anonymous&&(r.contextKind=C(e)),null!=n&&(r.data=n),null!=t&&(r.metricValue=t),R(r))},alias:H,on:function(e,n,t){Y(e)?(r=!0,M&&Q(),d.on(e,n,t)):d.on.apply(d,arguments)},off:function(e){var n;d.off.apply(d,arguments),Y(e)&&(n=!1,d.getEvents().forEach(function(e){Y(e)&&0<d.getEventListenerCount(e)&&(n=!0)}),n||(r=!1,o&&void 0===S&&W()))},setStreaming:function(e){(e=null===e?void 0:e)!==S&&(S=e,Q())},flush:function(e){return se(p?D.flush():Promise.resolve(),e)},allFlags:function(){var e,n={};if(!P)return n;for(e in P)fe(P,e)&&(n[e]=$(e,null,!g.sendEventsOnlyForVariation).value);return n},close:function(e){return se(U?Promise.resolve():Promise.resolve().then(function(){if(W(),w&&w.stop(),p)return D.stop(),D.flush()}).then(n).catch(n),e);function n(){U=!0,P={}}}},options:g,emitter:d,ident:j,logger:f,requestor:O,start:function(){p&&(w&&w.start(),D.start())},enqueueEvent:R,getFlagsInternal:function(){return P},getEnvironmentId:function(){return m},internalChangeEventName:yn}},e.messages=Je,e.utils=N,e.version="3.6.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient-common.min.js.map |
{ | ||
"name": "launchdarkly-js-sdk-common", | ||
"version": "3.5.1", | ||
"version": "3.6.0", | ||
"description": "LaunchDarkly SDK for JavaScript - common code", | ||
@@ -5,0 +5,0 @@ "author": "LaunchDarkly <team@launchdarkly.com>", |
@@ -136,6 +136,10 @@ /** | ||
* | ||
* Currently these are used to track what version of the SDK is active. This defaults to true | ||
* (custom headers will be sent). One reason you might want to set it to false is that the presence | ||
* of custom headers causes browsers to make an extra OPTIONS request (a CORS preflight check) | ||
* before each flag request, which could affect performance. | ||
* These are used to send metadata about the SDK (such as the version). They | ||
* are also used to send the application.id and application.version set in | ||
* the options. | ||
* | ||
* This defaults to true (custom headers will be sent). One reason you might | ||
* want to set it to false is that the presence of custom headers causes | ||
* browsers to make an extra OPTIONS request (a CORS preflight check) before | ||
* each flag request, which could affect performance. | ||
*/ | ||
@@ -288,2 +292,27 @@ sendLDHeaders?: boolean; | ||
autoAliasingOptOut?: boolean; | ||
/** | ||
* Information about the application where the LaunchDarkly SDK is running. | ||
*/ | ||
application?: { | ||
/** | ||
* A unique identifier representing the application where the LaunchDarkly SDK is running. | ||
* | ||
* This can be specified as any string value as long as it only uses the following characters: ASCII letters, | ||
* ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored. | ||
* | ||
* Example: `authentication-service` | ||
*/ | ||
id?: string; | ||
/** | ||
* A unique identifier representing the version of the application where the LaunchDarkly SDK is running. | ||
* | ||
* This can be specified as any string value as long as it only uses the following characters: ASCII letters, | ||
* ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored. | ||
* | ||
* Example: `1.0.0` (standard version string) or `abcdef` (sha prefix) | ||
*/ | ||
version?: string; | ||
} | ||
} | ||
@@ -290,0 +319,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
627218
1213