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