launchdarkly-js-client-sdk
Advanced tools
Comparing version 2.14.0 to 2.15.0
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof2="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};function createCustomError(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var errors=Object.freeze({LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(encodeChunk(e,i,i+16383>a?a:i+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 _typeof="function"==typeof Symbol&&"symbol"==_typeof2(Symbol.iterator)?function(e){return void 0===e?"undefined":_typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":_typeof2(e)},isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==(void 0===n?"undefined":_typeof(n))&&"object"==(void 0===t?"undefined":_typeof(t))){var r,o,i,a=isArray(n),u=isArray(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,d=t instanceof RegExp;if(l!=d)return!1;if(l&&d)return n.toString()==t.toString();var v=keyList(n);if((o=v.length)!==keyList(t).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},_extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var n=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(n))}function stringToBytes(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,n){return fastDeepEqual(e,n)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function transformValuesToVersionedValues(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,n){for(var t=n.slice(0),r=[],o=e,i=void 0;t.length>0;){for(i=[];o>0;){var a=t.shift();if(!a)break;(o-=base64URLEncode(JSON.stringify(a)).length)<0&&i.length>0?t.unshift(a):i.push(a)}o=e,r.push(i)}return r}function getLDUserAgentString(e){var n=e.version||"2.14.0";return e.userAgent+"/"+n}function getLDHeaders(e){return{"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)}}function extend(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return _extends({},e,n)},{})}function sanitizeUser(e){if(!e)return e;var n=void 0;for(var t in userAttrsToStringify){var r=userAttrsToStringify[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||Object.assign({},e))[r]=String(o))}return n||e}var utils=Object.freeze({btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,extend:extend,sanitizeUser:sanitizeUser}),MAX_URL_LENGTH=2e3;function EventSender(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a={};function u(e){(new window.Image).src=e}function s(n,t){var a=r||u,s=JSON.stringify(n);return t?function n(t){var r=extend({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},getLDHeaders(e));return e.httpRequest("POST",o,r,s).promise.then(function(e){if(e)return e.status>=400&&isHttpErrorRecoverable(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(a(i+"?d="+base64URLEncode(s)),Promise.resolve())}return a.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(s(r[a],o));return Promise.all(i)},a}function EventSummarizer(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=r[o];i?i.count=i.count+1:r[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in r){var a=r[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function UserFilter(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce(function(a,u){var s=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[1][u]=!0:s[0][u]=e[u]),s},[{},{}])},u=a(e,function(e){return i[e]}),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,function(){return!0});s.custom=l[0],c=extend({},c,l[1])}var d=Object.keys(c);return d.length&&(d.sort(),s.privateAttrs=d),s},n}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(){return"localStorage is unavailable"},localStorageUnavailableForUserId=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,n){return'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"'},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){return"Error on stream connection: "+errorString(e)},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},messages=Object.freeze({clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,localStorageUnavailableForUserId:localStorageUnavailableForUserId,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents});function EventProcessor(e,n,t){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i={},a=o||EventSender(e,n.eventsUrl,t),u=EventSummarizer(),s=UserFilter(n),c=n.inlineUsersInEvents,l=n.samplingInterval,d=n.flushInterval,v=n.logger,f=[],g=0,p=!1,m=void 0;function y(){return 0===l||0===Math.floor(Math.random()*l)}return i.enqueue=function(e){if(!p){var n,t=!1,r=!1;if(u.summarizeEvent(e),"feature"===e.kind?y()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>g&&n.debugEventsUntilDate>(new Date).getTime()):t=y(),t&&f.push(function(e){var n=extend({},e);return c||"identify"===e.kind?n.user=s.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=extend({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,f.push(o)}}},i.flush=function(){if(p)return Promise.resolve();var e=f,n=u.getSummary();return u.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(f=[],v.debug(debugPostingEvents(e.length)),a.sendEvents(e).then(function(e){e&&(e.serverTime&&(g=e.serverTime),isHttpErrorRecoverable(e.status)||(p=!0),e.status>=400&&onNextTick(function(){r.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},i.start=function(){m=setTimeout(function e(){i.flush(),m=setTimeout(e,d)},d)},i.stop=function(){clearTimeout(m)},i}function EventEmitter(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}function Store(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||btoa(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.saveFlags=function(n){var t=extend({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i}function Stream(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,d=null,v=null,f=null,g=null;function p(e){i.warn(streamError(e)),h(),m(l)}function m(e){v||(e?v=setTimeout(y,e):y())}function y(){v=null;var n=void 0,a="",l={};if(e.eventSourceFactory){for(var m in null!=r&&(a="h="+r),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(f)):(n=o+"/ping/"+t,a=""):n=u+"/"+base64URLEncode(JSON.stringify(f)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,h(),i.info(streamConnecting(n)),d=e.eventSourceFactory(n,l),g)g.hasOwnProperty(m)&&d.addEventListener(m,g[m]);d.onerror=p}}function h(){d&&(i.info(streamClosing()),d.close(),d=null)}return a.connect=function(e,n){f=e,g=n,m()},a.disconnect=function(){clearTimeout(v),v=null,h()},a.isConnected=function(){return!!(d&&e.eventSourceIsActive&&e.eventSourceIsActive(d))},a}function promiseCoalescer(e){var n=void 0,t=void 0,r=void 0,o=void 0,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then(function(t){n===i&&(r(t),e&&e())},function(t){n===i&&(o(t),e&&e())})}};return i.resultPromise=new Promise(function(e,n){r=e,o=n}),i}var json="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.sendLDHeaders,u=n.logger,s={},c={};function l(n,t){if(!e.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var r=t?"REPORT":"GET",o=a?getLDHeaders(e):{};t&&(o["Content-Type"]="application/json");var i=c[n];i||(i=promiseCoalescer(function(){delete c[n]}),c[n]=i);var u=e.httpRequest(r,n,o,t),s=u.promise.then(function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(json))return JSON.parse(e.body);var n=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(n))}return Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return i.addPromise(s,function(){u.cancel&&u.cancel()}),i.resultPromise}return s.fetchJSON=function(e){return l(r+e,null)},s.fetchFlagSettings=function(e,n){var a=void 0,s=void 0,c="",d=void 0;return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),d=JSON.stringify(e)):(a=base64URLEncode(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(c="h="+n),i&&(c=c+(c?"&":"")+"withReasons=true"),s=s+(c?"?":"")+c,u.debug(debugPolling(s)),l(s,d)},s}function Identity(e,n){var t={},r=void 0;return t.setUser=function(e){(r=sanitizeUser(e))&&n&&n(clone(r))},t.getUser=function(){return r?clone(r):null},e&&t.setUser(e),t}function createCommonjsModule(e,n){return e(n={exports:{}},n.exports),n.exports}for(var rngBrowser=createCommonjsModule(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var t=n||0,r=byteToHex;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var u=rngBrowser();null==i&&(i=_nodeId=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=_clockseq=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=s-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>_lastMSecs)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_lastNSecs=c,_clockseq=a;var d=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=255&d;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var f=0;f<6;++f)o[r+f]=i[f];return n||bytesToUuid_1(o)}var v1_1=v1,ldUserIdKey="ld:$anonUserId";function UserValidator(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var r=clone(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(t){if(t)return r.key=t,r;var o=v1_1();return r.key=o,function(t){return e?e.set(ldUserIdKey,t).catch(function(){n.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(o).then(function(){return r})}):Promise.reject(new LDInvalidUserError(invalidUser()))}};return t}function validate(e,n,t,r){var o=extend({logger:r},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames"};function a(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var u=extend({},e||{});return function(e){var n=u;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var t=i[e];r.warn(deprecated(e,t)),void 0===n[t]&&(n[t]=n[e]),delete n[e]}})}(),u=function(e,n){var t=extend({},u);return Object.keys(n).forEach(function(e){void 0!==t[e]&&null!==t[e]||(t[e]=n[e])}),t}(0,o),(isNaN(u.flushInterval)||u.flushInterval<2e3)&&(u.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(u.samplingInterval)||u.samplingInterval<0)&&(u.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),u}function createConsoleLogger(e,n){var t=["debug","info","warn","error"],r=void 0;r=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:t.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<t.length?t[e]:"?";n(r+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var _typeof$1="function"==typeof Symbol&&"symbol"==_typeof2(Symbol.iterator)?function(e){return void 0===e?"undefined":_typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":_typeof2(e)},readyEvent="ready",successEvent="initialized",failedEvent="failed",changeEvent="change",internalChangeEvent="internal-change";function initialize(e,n,t,r,o){var i=t&&t.logger?t.logger:o&&o.logger||createConsoleLogger("warn"),a=EventEmitter(i),u=validate(t,a,o,i),s=u.hash,c=u.sendEvents,l=e,d=Stream(r,u,l,s),v=u.eventProcessor||EventProcessor(r,u,l,a),f=Requestor(r,u,l),g={},p={},m=void 0,y=void 0,h=u.streaming,E=void 0,b=!1,w=!1,k=!0,S=u.stateProvider,U=Identity(null,function(e){S||e&&L({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),D=UserValidator(r.localStorage,i),P=void 0;function L(e){l&&(S&&S.enqueueEvent&&S.enqueueEvent(e)||(e.user?(k=!1,!c||w||r.isDoNotTrack()||(i.debug(debugEnqueueingEvent(e.kind)),v.enqueue(e))):k&&(i.warn(eventWithoutUser()),k=!1)))}function I(e,n,t,r){var o=U.getUser(),i=new Date,a=n?n.value:null;if(!u.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,c=g[s];if(c&&i-c<3e5)return;g[s]=i}var l={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},d=p[e];d&&(l.version=d.flagVersion?d.flagVersion:d.version,l.trackEvents=d.trackEvents,l.debugEventsUntilDate=d.debugEventsUntilDate),(r||d&&d.trackReason)&&n&&(l.reason=n.reason),L(l)}function R(e,n,t,r){var o=void 0;if(p&&p.hasOwnProperty(e)&&p[e]&&!p[e].deleted){var i=p[e];o=T(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&I(e,o,n,r),o}function T(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function C(){y=!0,U.getUser()&&d.connect(U.getUser(),{ping:function(){i.debug(debugStreamPing()),f.fetchFlagSettings(U.getUser(),s).then(function(e){return x(e||{})}).catch(function(e){a.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);i.debug(debugStreamPut()),x(n)},patch:function(e){var n=JSON.parse(e.data),t=p[n.key];if(!t||!t.version||!n.version||t.version<n.version){i.debug(debugStreamPatch(n.key));var r={},o=extend({},n);delete o.key,p[n.key]=o;var a=T(o);r[n.key]=t?{previous:t.value,current:a}:{current:a},N(r)}else i.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!p[n.key]||p[n.key].version<n.version){i.debug(debugStreamDelete(n.key));var t={};p[n.key]&&!p[n.key].deleted&&(t[n.key]={previous:p[n.key].value}),p[n.key]={version:n.version,deleted:!0},N(t)}else i.debug(debugStreamDeleteIgnored(n.key))}})}function F(){y&&(d.disconnect(),y=!1)}function x(e){var n={};if(!e)return Promise.resolve();for(var t in p)p.hasOwnProperty(t)&&p[t]&&(e[t]&&!deepEquals(e[t].value,p[t].value)?n[t]={previous:p[t].value,current:T(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:p[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!p[r]||p[r].deleted)&&(n[r]={current:T(e[r])});return p=Object.assign({},e),N(n).catch(function(){})}function N(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach(function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;a.emit(changeEvent+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}}),a.emit(changeEvent,t),a.emit(internalChangeEvent,p),u.sendEventsOnlyForVariation||S||n.forEach(function(n){I(n,e[n].current)})}return m&&P?P.saveFlags(p).catch(function(){return null}):Promise.resolve()}function O(){var e=h||E&&void 0===h;e&&!y?C():!e&&y&&F()}function A(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}r.localStorage&&(P=new Store(r.localStorage,l,s,U,i));var j=new Promise(function(e){var n=a.on(readyEvent,function(){a.off(readyEvent,n),e()})}),_=new Promise(function(e,n){var t=a.on(successEvent,function(){a.off(successEvent,t),e()}),r=a.on(failedEvent,function(e){a.off(failedEvent,r),n(e)})});if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(P?m=!0:i.warn(localStorageUnavailable())),"object"===_typeof$1(u.bootstrap)&&(p=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&i.warn(bootstrapOldFormat()),!1===e.$valid&&i.warn(bootstrapInvalid());var r={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=extend(o,t[n]):o.version=0,r[n]=o}}),r}(u.bootstrap)),S){var q=S.getInitialState();q?V(q):S.on("init",V),S.on("update",function(e){e.user&&U.setUser(e.user),e.flags&&x(e.flags)})}else(e?D.validateUser(n).then(function(e){return U.setUser(e),"object"===_typeof$1(u.bootstrap)?z():m?P.loadFlags().catch(function(){return null}).then(function(e){return null==e?(p={},f.fetchFlagSettings(U.getUser(),s).then(function(e){return x(e||{})}).then(z).catch(function(e){H(new LDFlagFetchError(errorFetchingFlags(e)))})):(p=e,onNextTick(z),f.fetchFlagSettings(U.getUser(),s).then(function(e){return x(e)}).catch(function(e){return a.maybeReportError(e)}))}):f.fetchFlagSettings(U.getUser(),s).then(function(e){p=e||{},z()}).catch(function(e){p={},H(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(function(e){return a.maybeReportError(e)});function V(e){l=e.environment,U.setUser(e.user),p=Object.assign({},e.flags),onNextTick(z)}function z(){i.info(clientInitialized()),b=!0,O(),a.emit(readyEvent),a.emit(successEvent)}function H(e){a.maybeReportError(e),a.emit(failedEvent,e),a.emit(readyEvent)}return{client:{waitForInitialization:function(){return _},waitUntilReady:function(){return j},identify:function(e,n,t){return w?wrapPromiseCallback(Promise.resolve({}),t):S?(i.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(p)),t)):wrapPromiseCallback((m&&P?P.clearFlags():Promise.resolve()).then(function(){return D.validateUser(e)}).then(function(e){return U.setUser(e)}).then(function(){return f.fetchFlagSettings(U.getUser(),n)}).then(function(e){var n=transformVersionedValuesToValues(e);return e?x(e).then(function(){return n}):n}).then(function(e){return y&&C(),e}).catch(function(e){return a.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return U.getUser()},variation:function(e,n){return R(e,n,!0,!1).value},variationDetail:function(e,n){return R(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){r.customEventFilter&&!r.customEventFilter(e)&&i.warn(unknownCustomEventKey(e));var o={kind:"custom",key:e,user:U.getUser(),url:r.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(o.data=n),null!=t&&(o.metricValue=t),L(o)}else a.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,n,t){A(e)?(E=!0,b&&O(),a.on(e,n,t)):a.on.apply(a,arguments)},off:function(e){if(a.off.apply(a,arguments),A(e)){var n=!1;a.getEvents().forEach(function(e){A(e)&&a.getEventListenerCount(e)>0&&(n=!0)}),n||(E=!1,y&&void 0===h&&F())}},setStreaming:function(e){var n=null===e?void 0:e;n!==h&&(h=n,O())},flush:function(e){return wrapPromiseCallback(c?v.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!p)return e;for(var n in p)p.hasOwnProperty(n)&&(e[n]=R(n,null,!u.sendEventsOnlyForVariation).value);return e},close:function(e){if(w)return wrapPromiseCallback(Promise.resolve(),e);var n=function(){w=!0,p={}};return wrapPromiseCallback(Promise.resolve().then(function(){if(F(),c)return v.stop(),v.flush()}).then(n).catch(n),e)}},options:u,emitter:a,ident:U,logger:i,requestor:f,start:function(){c&&v.start()},enqueueEvent:L,getFlagsInternal:function(){return p},getEnvironmentId:function(){return l},internalChangeEventName:internalChangeEvent}}var version="2.14.0";function isSyncXhrSupported(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}var emptyResult={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function newHttpRequest(e,n,t,r,o){if(o&&!isSyncXhrSupported())return emptyResult;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),emptyResult;var u=void 0;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}function makeBrowserPlatform(e){var n={pageIsClosing:!1};window.XMLHttpRequest&&(n.httpRequest=function(e,t,r,o){return newHttpRequest(e,t,r,o,n.pageIsClosing)});var t=void 0;n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t};var r=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return r?r(window.location.href):window.location.href},n.isDoNotTrack=function(){var e=void 0;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(n.localStorage={get:function(e){return new Promise(function(n){n(window.localStorage.getItem(e))})},set:function(e,n){return new Promise(function(t){window.localStorage.setItem(e,n),t()})},clear:function(e){return new Promise(function(n){window.localStorage.removeItem(e),n()})}})}catch(e){n.localStorage=null}var o=void 0;if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){n.eventSourceFactory=function(e,n){var t={heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},r=Object.assign({},t,n);return new o(e,r)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n}var matchOperatorsRe=/[|\\{}()[\]^$+*?.]/g,escapeStringRegexp=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(matchOperatorsRe,"\\$&")};function doesUrlMatch(e,n,t,r){var o=n.replace(t,"").replace(r,""),i=void 0,a=void 0;switch(e.kind){case"exact":a=n,i=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":a=o,i=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":a=o,i=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":a=o,i=new RegExp(e.pattern);break;default:return!1}return i.test(a)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=findGoalsForClick(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var locationWatcherInterval=300;function GoalManager(e,n){var t=void 0,r=void 0,o={};function i(){r&&r.dispose(),t&&t.length&&(r=GoalTracker(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then(function(e){e&&e.length>0&&(r=GoalTracker(t=e,a),function(e,n){var t=window.location.href,r=void 0;function o(){(r=window.location.href)!==t&&(t=r,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(locationWatcherInterval,i)),n()}).catch(function(t){e.emitter.maybeReportError(new errors.LDUnexpectedResponseError((t&&t.message,t.message))),n()}),o}var goalsEvent="goalsReady",extraDefaults={fetchGoals:!0};function initialize$1(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=initialize(e,n,t,r,extraDefaults),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);return"complete"!==document.readyState?window.addEventListener("load",o.start):o.start(),window.addEventListener("beforeunload",function(){r.pageIsClosing=!0,i.close()}),i}var createConsoleLogger$1=createConsoleLogger,version$1=version;function deprecatedInitialize(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(messages.deprecated("default export","named LDClient export")),initialize$1(e,n,t)}var index={initialize:deprecatedInitialize,version:version$1};exports.initialize=initialize$1,exports.createConsoleLogger=createConsoleLogger$1,exports.version=version$1,exports.default=index; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function e(n){return(e="function"==typeof Symbol&&"symbol"==_typeof(Symbol.iterator)?function(e){return void 0===e?"undefined":_typeof(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":_typeof(e)})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach(function(t){n(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))})}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),s=o("LaunchDarklyInvalidEventKeyError"),c=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"=")),o.join("")},g=[],m=[],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=p.length;h<y;++h)g[h]=p[h],m[p.charCodeAt(h)]=h;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,S=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==(void 0===n?"undefined":_typeof(n))&&"object"==(void 0===t?"undefined":_typeof(t))){var r,o,i,a=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function O(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return O(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return S(e,n)}function I(e){setTimeout(e,0)}function R(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function N(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function T(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function L(e){var n=e.version||"2.14.1";return e.userAgent+"/"+n}function A(e){return{"X-LaunchDarkly-User-Agent":L(e)}}function C(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return r({},e,{},n)},{})}function x(e){if(!e)return e;var n;for(var t in P){var o=P[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}var q=Object.freeze({__proto__:null,btoa:O,base64URLEncode:D,clone:U,deepEquals:j,onNextTick:I,wrapPromiseCallback:R,transformValuesToVersionedValues:N,transformVersionedValuesToValues:F,chunkUserEventsForUrl:T,getLDUserAgentString:L,getLDHeaders:A,extend:C,sanitizeUser:x}),_=2e3;function J(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a={};function u(e){(new window.Image).src=e}function s(n,t){var a=r||u,s=JSON.stringify(n);return t?function n(t){var r=C({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},A(e));return e.httpRequest("POST",o,r,s).promise.then(function(e){if(e)return e.status>=400&&f(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(a(i+"?d="+D(s)),Promise.resolve())}return a.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:T(_-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(s(r[a],o));return Promise.all(i)},a}function V(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce(function(a,u){var s=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[1][u]=!0:s[0][u]=e[u]),s},[{},{}])},u=a(e,function(e){return i[e]}),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,function(){return!0});s.custom=l[0],c=C({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var K=function(){return"LaunchDarkly client initialized"},$=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",M=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},H=function(e){return'Expected application/json content type but got "'+e+'"'},G=function(){return"localStorage is unavailable"},X=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},B=function(e){return"network error"+(e?" ("+e+")":"")},W=function(e){return'Custom event "'+e+'" does not exist'},Q=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},Y=function(){return"No environment/client-side ID was specified."+$},Z=function(e){return"Error fetching flag settings: "+z(e)},ee=function(){return"No user specified."+$},ne=function(){return"Invalid user specified."+$},te=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+$},re=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},oe=function(e,n){return n?'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"':'[LaunchDarkly] "'+e+'" is deprecated'},ie=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ae=function(){return"Cannot make HTTP requests in this environment."+$},ue=function(){return"identify() has no effect here; it must be called on the main client instance"},se=function(){return"Closing stream connection"},ce=function(e){return"Opening stream connection to "+e},le=function(e,n){return"Error on stream connection: "+z(e)+", will continue retrying every "+n+" milliseconds."},fe=function(e){return"polling for feature flags at "+e},ve=function(){return"received ping message from stream"},de=function(){return"received streaming update for all flags"},ge=function(e){return'received streaming update for flag "'+e+'"'},me=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},pe=function(e){return'received streaming deletion for flag "'+e+'"'},he=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},ye=function(e){return'enqueueing "'+e+'" event'},be=function(e){return"sending "+e+" events"},ke=Object.freeze({__proto__:null,clientInitialized:K,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventWithoutUser:M,invalidContentType:H,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:G,localStorageUnavailableForUserId:X,networkError:B,unknownCustomEventKey:W,environmentNotFound:Q,environmentNotSpecified:Y,errorFetchingFlags:Z,userNotSpecified:ee,invalidUser:ne,bootstrapOldFormat:te,bootstrapInvalid:re,deprecated:oe,httpErrorMessage:ie,httpUnavailable:ae,identifyDisabled:ue,streamClosing:se,streamConnecting:ce,streamError:le,debugPolling:fe,debugStreamPing:ve,debugStreamPut:de,debugStreamPatch:ge,debugStreamPatchIgnored:me,debugStreamDelete:pe,debugStreamDeleteIgnored:he,debugEnqueueingEvent:ye,debugPostingEvents:be});function Ee(e,n,t){var r,o,a,u,s,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,v={},d=l||J(e,n.eventsUrl,t),g=(o=0,a=0,u={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===o||e.creationDate<o)&&(o=e.creationDate),e.creationDate>a&&(a=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var s={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(s.variation=r.variation),r.version?s.version=r.version:s.unknown=!0,i.counters.push(s),n=!1}return n?null:{startDate:o,endDate:a,features:e}},r.clearSummary=function(){o=0,a=0,u={}},r),p=V(n),h=n.inlineUsersInEvents,m=n.samplingInterval,y=n.flushInterval,w=n.logger,b=[],k=0,E=!1;function S(){return 0===m||0===Math.floor(Math.random()*m)}return v.enqueue=function(e){if(!E){var n,t=!1,r=!1;if(g.summarizeEvent(e),"feature"===e.kind?S()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>k&&n.debugEventsUntilDate>(new Date).getTime()):t=S(),t&&b.push(function(e){var n=C({},e);return h||"identify"===e.kind?n.user=p.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=C({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,b.push(o)}}},v.flush=function(){if(E)return Promise.resolve();var e=b,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(b=[],w.debug(be(e.length)),d.sendEvents(e).then(function(e){e&&(e.serverTime&&(k=e.serverTime),f(e.status)||(E=!0),e.status>=400&&I(function(){c.maybeReportError(new i(ie(e.status,"event posting","some events were dropped")))}))}))},v.start=function(){s=setTimeout(function e(){v.flush(),s=setTimeout(e,y)},y)},v.stop=function(){clearTimeout(s)},v}function we(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}function Se(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||O(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=N(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(G()),Promise.reject(e)})},i.saveFlags=function(n){var t=C({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch(function(e){return o.warn(G()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(G()),Promise.reject(e)})},i}var Pe="application/json";function Oe(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.sendLDHeaders,s=n.logger,c={},f={};function v(n,t){if(!e.httpRequest)return new Promise(function(e,n){n(new l(ae()))});var r=t?"REPORT":"GET",o=u?A(e):{};t&&(o["Content-Type"]="application/json");var i=f[n];i||(i=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then(function(t){n===i&&(r(t),e&&e())},function(t){n===i&&(o(t),e&&e())})}};return i.resultPromise=new Promise(function(e,n){r=e,o=n}),i}(function(){delete f[n]}),f[n]=i);var s=e.httpRequest(r,n,o,t),c=s.promise.then(function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Pe))return JSON.parse(e.body);var n=H(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(Q()):new l(Z(e.statusText||String(e.status)))}(e))},function(e){return Promise.reject(new l(B(e)))});return i.addPromise(c,function(){s.cancel&&s.cancel()}),i.resultPromise}return c.fetchJSON=function(e){return v(r+e,null)},c.fetchFlagSettings=function(e,n){var a,u,c,l="";return o?(u=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=D(JSON.stringify(e)),u=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),u=u+(l?"?":"")+l,s.debug(fe(u)),v(u,c)},c}for(var De=function(e,n){return 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}}}(n={exports:{}}),n.exports}(),Ue=[],je=0;je<256;++je)Ue[je]=(je+256).toString(16).substr(1);var Ie,Re,Ne=function(e,n){var t=n||0,r=Ue;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},Fe=0,Te=0,Le=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ie,a=void 0!==e.clockseq?e.clockseq:Re;if(null==i||null==a){var u=De();null==i&&(i=Ie=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Re=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:Te+1,l=s-Fe+(c-Te)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>Fe)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Fe=s,Te=c,Re=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||Ne(o)},Ae="ld:$anonUserId";function Ce(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new u(ee()));var r=U(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(Ae).catch(function(){return null}):Promise.resolve(null)).then(function(t){if(t)return r.key=t,r;var o=Le();return r.key=o,function(t){return e?e.set(Ae,t).catch(function(){n.warn(X())}):Promise.resolve()}(o).then(function(){return r})}):Promise.reject(new u(ne()))}};return t}function xe(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<r.length?r[e]:"?";n(t+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var qe="ready",_e="initialized",Je="failed",Ve="change",ze="internal-change";function Ke(n,t,o,i,u){var f,v,d,g,p=o&&o.logger?o.logger:u&&u.logger||xe("warn"),h=we(p),m=function(e,n,t,r){var o=C({logger:r},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function a(e){I(function(){n&&n.maybeReportError(new c(e))})}var u=C({},e||{});return function(e){var n=u;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var t=i[e];r&&r.warn(oe(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}})}(),u=function(e,n){var t=C({},u);return Object.keys(n).forEach(function(e){void 0!==t[e]&&null!==t[e]||(t[e]=n[e])}),t}(0,o),(isNaN(u.flushInterval)||u.flushInterval<2e3)&&(u.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(u.samplingInterval)||u.samplingInterval<0)&&(u.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),u}(o,h,u,p),y=m.hash,w=m.sendEvents,b=n,k=function(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,f=!1,v=null,d=null,g=null,p=null;function h(e){f||(i.warn(le(e,l)),f=!0),w(),m(l)}function m(e){d||(e?d=setTimeout(y,e):y())}function y(){var n;d=null;var a="",l={};if(e.eventSourceFactory){for(var f in null!=r&&(a="h="+r),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(g)):(n=o+"/ping/"+t,a=""):n=u+"/"+D(JSON.stringify(g)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,w(),i.info(ce(n)),v=e.eventSourceFactory(n,l),p)p.hasOwnProperty(f)&&v.addEventListener(f,p[f]);v.onerror=h}}function w(){v&&(i.info(se()),v.close(),v=null)}return a.connect=function(e,n){g=e,p={};var t=function(e){p[e]=function(t){f=!1,n[e]&&n[e](t)}};for(var r in n||{})t(r);m()},a.disconnect=function(){clearTimeout(d),d=null,w()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}(i,m,b,y),E=m.eventProcessor||Ee(i,m,b,h),S=Oe(i,m,b),P={},O={},T=m.streaming,N=!1,L=!1,A=!0,q=m.stateProvider,_=function(e,n){var t,r={setUser:function(e){(t=x(e))&&n&&n(U(t))},getUser:function(){return t?U(t):null}};return r}(0,function(e){q||e&&J({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),z=Ce(i.localStorage,p);function J(e){b&&(q&&q.enqueueEvent&&q.enqueueEvent(e)||(e.user?(A=!1,!w||L||i.isDoNotTrack()||(p.debug(ye(e.kind)),E.enqueue(e))):A&&(p.warn(M()),A=!1)))}function V(e,n,t,r){var o=_.getUser(),i=new Date,a=n?n.value:null;if(!m.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=P[u];if(s&&i-s<3e5)return;P[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=O[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),J(c)}function $(e,n,t,r){var o;if(O&&O.hasOwnProperty(e)&&O[e]&&!O[e].deleted){var i=O[e];o=H(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&V(e,o,n,r),o}function H(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function X(){v=!0,_.getUser()&&k.connect(_.getUser(),{ping:function(){p.debug(ve()),S.fetchFlagSettings(_.getUser(),y).then(function(e){return Q(e||{})}).catch(function(e){h.maybeReportError(new l(Z(e)))})},put:function(e){var n=JSON.parse(e.data);p.debug(de()),Q(n)},patch:function(e){var n=JSON.parse(e.data),t=O[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(ge(n.key));var r={},o=C({},n);delete o.key,O[n.key]=o;var i=H(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ee(r)}else p.debug(me(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!O[n.key]||O[n.key].version<n.version){p.debug(pe(n.key));var t={};O[n.key]&&!O[n.key].deleted&&(t[n.key]={previous:O[n.key].value}),O[n.key]={version:n.version,deleted:!0},ee(t)}else p.debug(he(n.key))}})}function B(){v&&(k.disconnect(),v=!1)}function Q(e){var n={};if(!e)return Promise.resolve();for(var t in O)O.hasOwnProperty(t)&&O[t]&&(e[t]&&!j(e[t].value,O[t].value)?n[t]={previous:O[t].value,current:H(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:O[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!O[o]||O[o].deleted)&&(n[o]={current:H(e[o])});return O=r({},e),ee(n).catch(function(){})}function ee(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach(function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;h.emit(Ve+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}}),h.emit(Ve,t),h.emit(ze,O),m.sendEventsOnlyForVariation||q||n.forEach(function(n){V(n,e[n].current)})}return f&&g?g.saveFlags(O).catch(function(){return null}):Promise.resolve()}function ne(){var e=T||d&&void 0===T;e&&!v?X():!e&&v&&B()}function ie(e){return e===Ve||e.substr(0,Ve.length+1)===Ve+":"}i.localStorage&&(g=new Se(i.localStorage,b,y,_,p));var ae=new Promise(function(e){var n=h.on(qe,function(){h.off(qe,n),e()})}),fe=new Promise(function(e,n){var t=h.on(_e,function(){h.off(_e,t),e()}),r=h.on(Je,function(e){h.off(Je,r),n(e)})});if("string"==typeof m.bootstrap&&"LOCALSTORAGE"===m.bootstrap.toUpperCase()&&(g?f=!0:p.warn(G())),"object"===e(m.bootstrap)&&(O=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(te()),!1===e.$valid&&p.warn(re());var r={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=C(o,t[n]):o.version=0,r[n]=o}}),r}(m.bootstrap)),q){var be=q.getInitialState();be?ke(be):q.on("init",ke),q.on("update",function(e){e.user&&_.setUser(e.user),e.flags&&Q(e.flags)})}else(n?z.validateUser(t).then(function(n){return _.setUser(n),"object"===e(m.bootstrap)?Pe():f?g.loadFlags().catch(function(){return null}).then(function(e){return null==e?(O={},S.fetchFlagSettings(_.getUser(),y).then(function(e){return Q(e||{})}).then(Pe).catch(function(e){De(new l(Z(e)))})):(O=e,I(Pe),S.fetchFlagSettings(_.getUser(),y).then(function(e){return Q(e)}).catch(function(e){return h.maybeReportError(e)}))}):S.fetchFlagSettings(_.getUser(),y).then(function(e){O=e||{},Pe()}).catch(function(e){O={},De(e)})}):Promise.reject(new a(Y()))).catch(function(e){return h.maybeReportError(e)});function ke(e){b=e.environment,_.setUser(e.user),O=r({},e.flags),I(Pe)}function Pe(){p.info(K()),N=!0,ne(),h.emit(qe),h.emit(_e)}function De(e){h.maybeReportError(e),h.emit(Je,e),h.emit(qe)}return{client:{waitForInitialization:function(){return fe},waitUntilReady:function(){return ae},identify:function(e,n,t){return L?R(Promise.resolve({}),t):q?(p.warn(ue()),R(Promise.resolve(F(O)),t)):R((f&&g?g.clearFlags():Promise.resolve()).then(function(){return z.validateUser(e)}).then(function(e){return _.setUser(e)}).then(function(){return S.fetchFlagSettings(_.getUser(),n)}).then(function(e){var n=F(e);return e?Q(e).then(function(){return n}):n}).then(function(e){return v&&X(),e}).catch(function(e){return h.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return _.getUser()},variation:function(e,n){return $(e,n,!0,!1).value},variationDetail:function(e,n){return $(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&p.warn(W(e));var r={kind:"custom",key:e,user:_.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),J(r)}else h.maybeReportError(new s(W(e)))},on:function(e,n,t){ie(e)?(d=!0,N&&ne(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),ie(e)){var n=!1;h.getEvents().forEach(function(e){ie(e)&&h.getEventListenerCount(e)>0&&(n=!0)}),n||(d=!1,v&&void 0===T&&B())}},setStreaming:function(e){var n=null===e?void 0:e;n!==T&&(T=n,ne())},flush:function(e){return R(w?E.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!O)return e;for(var n in O)O.hasOwnProperty(n)&&(e[n]=$(n,null,!m.sendEventsOnlyForVariation).value);return e},close:function(e){if(L)return R(Promise.resolve(),e);var n=function(){L=!0,O={}};return R(Promise.resolve().then(function(){if(B(),w)return E.stop(),E.flush()}).then(n).catch(n),e)}},options:m,emitter:h,ident:_,logger:p,requestor:S,start:function(){w&&E.start()},enqueueEvent:J,getFlagsInternal:function(){return O},getEnvironmentId:function(){return b},internalChangeEventName:ze}}var $e="2.14.1";function isSyncXhrSupported(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}var emptyResult={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function newHttpRequest(e,n,t,r,o){if(o&&!isSyncXhrSupported())return emptyResult;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),emptyResult;var u=void 0;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}var _extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};function makeBrowserPlatform(e){var n={synchronousFlush:!1};window.XMLHttpRequest&&(n.httpRequest=function(e,t,r,o){var i=n.synchronousFlush;return n.synchronousFlush=!1,newHttpRequest(e,t,r,o,i)});var t=void 0;n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t};var r=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return r?r(window.location.href):window.location.href},n.isDoNotTrack=function(){var e=void 0;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(n.localStorage={get:function(e){return new Promise(function(n){n(window.localStorage.getItem(e))})},set:function(e,n){return new Promise(function(t){window.localStorage.setItem(e,n),t()})},clear:function(e){return new Promise(function(n){window.localStorage.removeItem(e),n()})}})}catch(e){n.localStorage=null}var o=void 0;if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){n.eventSourceFactory=function(e,n){var t=_extends({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},n);return new o(e,t)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n}var matchOperatorsRe=/[|\\{}()[\]^$+*?.]/g,escapeStringRegexp=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(matchOperatorsRe,"\\$&")};function doesUrlMatch(e,n,t,r){var o=n.replace(t,"").replace(r,""),i=void 0,a=void 0;switch(e.kind){case"exact":a=n,i=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":a=o,i=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":a=o,i=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":a=o,i=new RegExp(e.pattern);break;default:return!1}return i.test(a)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=findGoalsForClick(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var locationWatcherInterval=300;function GoalManager(e,n){var t=void 0,r=void 0,o={};function i(){r&&r.dispose(),t&&t.length&&(r=GoalTracker(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then(function(e){e&&e.length>0&&(r=GoalTracker(t=e,a),function(e,n){var t=window.location.href,r=void 0;function o(){(r=window.location.href)!==t&&(t=r,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(locationWatcherInterval,i)),n()}).catch(function(t){e.emitter.maybeReportError(new v.LDUnexpectedResponseError((t&&t.message,t.message))),n()}),o}var goalsEvent="goalsReady",extraDefaults={fetchGoals:!0};function initialize(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=Ke(e,n,t,r,extraDefaults),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch(function(){})};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var createConsoleLogger=xe,version=$e;function deprecatedInitialize(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(ke.deprecated("default export","named LDClient export")),initialize(e,n,t)}var index={initialize:deprecatedInitialize,version:version};exports.initialize=initialize,exports.createConsoleLogger=createConsoleLogger,exports.version=version,exports.default=index; | ||
//# sourceMappingURL=ldclient.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
var _typeof2="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};function createCustomError(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var errors=Object.freeze({LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(encodeChunk(e,i,i+16383>a?a:i+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 _typeof="function"==typeof Symbol&&"symbol"==_typeof2(Symbol.iterator)?function(e){return void 0===e?"undefined":_typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":_typeof2(e)},isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==(void 0===n?"undefined":_typeof(n))&&"object"==(void 0===t?"undefined":_typeof(t))){var r,o,i,a=isArray(n),u=isArray(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,v=t instanceof RegExp;if(l!=v)return!1;if(l&&v)return n.toString()==t.toString();var d=keyList(n);if((o=d.length)!==keyList(t).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(t,d[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=d[r]],t[i]))return!1;return!0}return n!=n&&t!=t},_extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var n=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(n))}function stringToBytes(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,n){return fastDeepEqual(e,n)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function transformValuesToVersionedValues(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,n){for(var t=n.slice(0),r=[],o=e,i=void 0;t.length>0;){for(i=[];o>0;){var a=t.shift();if(!a)break;(o-=base64URLEncode(JSON.stringify(a)).length)<0&&i.length>0?t.unshift(a):i.push(a)}o=e,r.push(i)}return r}function getLDUserAgentString(e){var n=e.version||"2.14.0";return e.userAgent+"/"+n}function getLDHeaders(e){return{"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)}}function extend(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return _extends({},e,n)},{})}function sanitizeUser(e){if(!e)return e;var n=void 0;for(var t in userAttrsToStringify){var r=userAttrsToStringify[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||Object.assign({},e))[r]=String(o))}return n||e}var utils=Object.freeze({btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,extend:extend,sanitizeUser:sanitizeUser}),MAX_URL_LENGTH=2e3;function EventSender(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a={};function u(e){(new window.Image).src=e}function s(n,t){var a=r||u,s=JSON.stringify(n);return t?function n(t){var r=extend({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},getLDHeaders(e));return e.httpRequest("POST",o,r,s).promise.then(function(e){if(e)return e.status>=400&&isHttpErrorRecoverable(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(a(i+"?d="+base64URLEncode(s)),Promise.resolve())}return a.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(s(r[a],o));return Promise.all(i)},a}function EventSummarizer(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=r[o];i?i.count=i.count+1:r[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in r){var a=r[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function UserFilter(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce(function(a,u){var s=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[1][u]=!0:s[0][u]=e[u]),s},[{},{}])},u=a(e,function(e){return i[e]}),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,function(){return!0});s.custom=l[0],c=extend({},c,l[1])}var v=Object.keys(c);return v.length&&(v.sort(),s.privateAttrs=v),s},n}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(){return"localStorage is unavailable"},localStorageUnavailableForUserId=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,n){return'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"'},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){return"Error on stream connection: "+errorString(e)},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},messages=Object.freeze({clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,localStorageUnavailableForUserId:localStorageUnavailableForUserId,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents});function EventProcessor(e,n,t){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i={},a=o||EventSender(e,n.eventsUrl,t),u=EventSummarizer(),s=UserFilter(n),c=n.inlineUsersInEvents,l=n.samplingInterval,v=n.flushInterval,d=n.logger,f=[],g=0,p=!1,m=void 0;function y(){return 0===l||0===Math.floor(Math.random()*l)}return i.enqueue=function(e){if(!p){var n,t=!1,r=!1;if(u.summarizeEvent(e),"feature"===e.kind?y()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>g&&n.debugEventsUntilDate>(new Date).getTime()):t=y(),t&&f.push(function(e){var n=extend({},e);return c||"identify"===e.kind?n.user=s.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=extend({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,f.push(o)}}},i.flush=function(){if(p)return Promise.resolve();var e=f,n=u.getSummary();return u.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(f=[],d.debug(debugPostingEvents(e.length)),a.sendEvents(e).then(function(e){e&&(e.serverTime&&(g=e.serverTime),isHttpErrorRecoverable(e.status)||(p=!0),e.status>=400&&onNextTick(function(){r.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},i.start=function(){m=setTimeout(function e(){i.flush(),m=setTimeout(e,v)},v)},i.stop=function(){clearTimeout(m)},i}function EventEmitter(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}function Store(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||btoa(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.saveFlags=function(n){var t=extend({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i}function Stream(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,v=null,d=null,f=null,g=null;function p(e){i.warn(streamError(e)),h(),m(l)}function m(e){d||(e?d=setTimeout(y,e):y())}function y(){d=null;var n=void 0,a="",l={};if(e.eventSourceFactory){for(var m in null!=r&&(a="h="+r),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(f)):(n=o+"/ping/"+t,a=""):n=u+"/"+base64URLEncode(JSON.stringify(f)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,h(),i.info(streamConnecting(n)),v=e.eventSourceFactory(n,l),g)g.hasOwnProperty(m)&&v.addEventListener(m,g[m]);v.onerror=p}}function h(){v&&(i.info(streamClosing()),v.close(),v=null)}return a.connect=function(e,n){f=e,g=n,m()},a.disconnect=function(){clearTimeout(d),d=null,h()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}function promiseCoalescer(e){var n=void 0,t=void 0,r=void 0,o=void 0,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then(function(t){n===i&&(r(t),e&&e())},function(t){n===i&&(o(t),e&&e())})}};return i.resultPromise=new Promise(function(e,n){r=e,o=n}),i}var json="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.sendLDHeaders,u=n.logger,s={},c={};function l(n,t){if(!e.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var r=t?"REPORT":"GET",o=a?getLDHeaders(e):{};t&&(o["Content-Type"]="application/json");var i=c[n];i||(i=promiseCoalescer(function(){delete c[n]}),c[n]=i);var u=e.httpRequest(r,n,o,t),s=u.promise.then(function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(json))return JSON.parse(e.body);var n=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(n))}return Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return i.addPromise(s,function(){u.cancel&&u.cancel()}),i.resultPromise}return s.fetchJSON=function(e){return l(r+e,null)},s.fetchFlagSettings=function(e,n){var a=void 0,s=void 0,c="",v=void 0;return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),v=JSON.stringify(e)):(a=base64URLEncode(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(c="h="+n),i&&(c=c+(c?"&":"")+"withReasons=true"),s=s+(c?"?":"")+c,u.debug(debugPolling(s)),l(s,v)},s}function Identity(e,n){var t={},r=void 0;return t.setUser=function(e){(r=sanitizeUser(e))&&n&&n(clone(r))},t.getUser=function(){return r?clone(r):null},e&&t.setUser(e),t}function createCommonjsModule(e,n){return e(n={exports:{}},n.exports),n.exports}for(var rngBrowser=createCommonjsModule(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var t=n||0,r=byteToHex;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var u=rngBrowser();null==i&&(i=_nodeId=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=_clockseq=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=s-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>_lastMSecs)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_lastNSecs=c,_clockseq=a;var v=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=v>>>24&255,o[r++]=v>>>16&255,o[r++]=v>>>8&255,o[r++]=255&v;var d=s/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var f=0;f<6;++f)o[r+f]=i[f];return n||bytesToUuid_1(o)}var v1_1=v1,ldUserIdKey="ld:$anonUserId";function UserValidator(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var r=clone(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(t){if(t)return r.key=t,r;var o=v1_1();return r.key=o,function(t){return e?e.set(ldUserIdKey,t).catch(function(){n.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(o).then(function(){return r})}):Promise.reject(new LDInvalidUserError(invalidUser()))}};return t}function validate(e,n,t,r){var o=extend({logger:r},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames"};function a(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var u=extend({},e||{});return function(e){var n=u;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var t=i[e];r.warn(deprecated(e,t)),void 0===n[t]&&(n[t]=n[e]),delete n[e]}})}(),u=function(e,n){var t=extend({},u);return Object.keys(n).forEach(function(e){void 0!==t[e]&&null!==t[e]||(t[e]=n[e])}),t}(0,o),(isNaN(u.flushInterval)||u.flushInterval<2e3)&&(u.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(u.samplingInterval)||u.samplingInterval<0)&&(u.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),u}function createConsoleLogger(e,n){var t=["debug","info","warn","error"],r=void 0;r=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:t.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<t.length?t[e]:"?";n(r+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var _typeof$1="function"==typeof Symbol&&"symbol"==_typeof2(Symbol.iterator)?function(e){return void 0===e?"undefined":_typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":_typeof2(e)},readyEvent="ready",successEvent="initialized",failedEvent="failed",changeEvent="change",internalChangeEvent="internal-change";function initialize(e,n,t,r,o){var i=t&&t.logger?t.logger:o&&o.logger||createConsoleLogger("warn"),a=EventEmitter(i),u=validate(t,a,o,i),s=u.hash,c=u.sendEvents,l=e,v=Stream(r,u,l,s),d=u.eventProcessor||EventProcessor(r,u,l,a),f=Requestor(r,u,l),g={},p={},m=void 0,y=void 0,h=u.streaming,E=void 0,b=!1,w=!1,k=!0,S=u.stateProvider,U=Identity(null,function(e){S||e&&L({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),D=UserValidator(r.localStorage,i),P=void 0;function L(e){l&&(S&&S.enqueueEvent&&S.enqueueEvent(e)||(e.user?(k=!1,!c||w||r.isDoNotTrack()||(i.debug(debugEnqueueingEvent(e.kind)),d.enqueue(e))):k&&(i.warn(eventWithoutUser()),k=!1)))}function I(e,n,t,r){var o=U.getUser(),i=new Date,a=n?n.value:null;if(!u.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,c=g[s];if(c&&i-c<3e5)return;g[s]=i}var l={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},v=p[e];v&&(l.version=v.flagVersion?v.flagVersion:v.version,l.trackEvents=v.trackEvents,l.debugEventsUntilDate=v.debugEventsUntilDate),(r||v&&v.trackReason)&&n&&(l.reason=n.reason),L(l)}function R(e,n,t,r){var o=void 0;if(p&&p.hasOwnProperty(e)&&p[e]&&!p[e].deleted){var i=p[e];o=T(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&I(e,o,n,r),o}function T(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function C(){y=!0,U.getUser()&&v.connect(U.getUser(),{ping:function(){i.debug(debugStreamPing()),f.fetchFlagSettings(U.getUser(),s).then(function(e){return N(e||{})}).catch(function(e){a.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);i.debug(debugStreamPut()),N(n)},patch:function(e){var n=JSON.parse(e.data),t=p[n.key];if(!t||!t.version||!n.version||t.version<n.version){i.debug(debugStreamPatch(n.key));var r={},o=extend({},n);delete o.key,p[n.key]=o;var a=T(o);r[n.key]=t?{previous:t.value,current:a}:{current:a},x(r)}else i.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!p[n.key]||p[n.key].version<n.version){i.debug(debugStreamDelete(n.key));var t={};p[n.key]&&!p[n.key].deleted&&(t[n.key]={previous:p[n.key].value}),p[n.key]={version:n.version,deleted:!0},x(t)}else i.debug(debugStreamDeleteIgnored(n.key))}})}function F(){y&&(v.disconnect(),y=!1)}function N(e){var n={};if(!e)return Promise.resolve();for(var t in p)p.hasOwnProperty(t)&&p[t]&&(e[t]&&!deepEquals(e[t].value,p[t].value)?n[t]={previous:p[t].value,current:T(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:p[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!p[r]||p[r].deleted)&&(n[r]={current:T(e[r])});return p=Object.assign({},e),x(n).catch(function(){})}function x(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach(function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;a.emit(changeEvent+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}}),a.emit(changeEvent,t),a.emit(internalChangeEvent,p),u.sendEventsOnlyForVariation||S||n.forEach(function(n){I(n,e[n].current)})}return m&&P?P.saveFlags(p).catch(function(){return null}):Promise.resolve()}function O(){var e=h||E&&void 0===h;e&&!y?C():!e&&y&&F()}function A(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}r.localStorage&&(P=new Store(r.localStorage,l,s,U,i));var j=new Promise(function(e){var n=a.on(readyEvent,function(){a.off(readyEvent,n),e()})}),_=new Promise(function(e,n){var t=a.on(successEvent,function(){a.off(successEvent,t),e()}),r=a.on(failedEvent,function(e){a.off(failedEvent,r),n(e)})});if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(P?m=!0:i.warn(localStorageUnavailable())),"object"===_typeof$1(u.bootstrap)&&(p=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&i.warn(bootstrapOldFormat()),!1===e.$valid&&i.warn(bootstrapInvalid());var r={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=extend(o,t[n]):o.version=0,r[n]=o}}),r}(u.bootstrap)),S){var q=S.getInitialState();q?V(q):S.on("init",V),S.on("update",function(e){e.user&&U.setUser(e.user),e.flags&&N(e.flags)})}else(e?D.validateUser(n).then(function(e){return U.setUser(e),"object"===_typeof$1(u.bootstrap)?z():m?P.loadFlags().catch(function(){return null}).then(function(e){return null==e?(p={},f.fetchFlagSettings(U.getUser(),s).then(function(e){return N(e||{})}).then(z).catch(function(e){H(new LDFlagFetchError(errorFetchingFlags(e)))})):(p=e,onNextTick(z),f.fetchFlagSettings(U.getUser(),s).then(function(e){return N(e)}).catch(function(e){return a.maybeReportError(e)}))}):f.fetchFlagSettings(U.getUser(),s).then(function(e){p=e||{},z()}).catch(function(e){p={},H(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(function(e){return a.maybeReportError(e)});function V(e){l=e.environment,U.setUser(e.user),p=Object.assign({},e.flags),onNextTick(z)}function z(){i.info(clientInitialized()),b=!0,O(),a.emit(readyEvent),a.emit(successEvent)}function H(e){a.maybeReportError(e),a.emit(failedEvent,e),a.emit(readyEvent)}return{client:{waitForInitialization:function(){return _},waitUntilReady:function(){return j},identify:function(e,n,t){return w?wrapPromiseCallback(Promise.resolve({}),t):S?(i.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(p)),t)):wrapPromiseCallback((m&&P?P.clearFlags():Promise.resolve()).then(function(){return D.validateUser(e)}).then(function(e){return U.setUser(e)}).then(function(){return f.fetchFlagSettings(U.getUser(),n)}).then(function(e){var n=transformVersionedValuesToValues(e);return e?N(e).then(function(){return n}):n}).then(function(e){return y&&C(),e}).catch(function(e){return a.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return U.getUser()},variation:function(e,n){return R(e,n,!0,!1).value},variationDetail:function(e,n){return R(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){r.customEventFilter&&!r.customEventFilter(e)&&i.warn(unknownCustomEventKey(e));var o={kind:"custom",key:e,user:U.getUser(),url:r.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(o.data=n),null!=t&&(o.metricValue=t),L(o)}else a.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,n,t){A(e)?(E=!0,b&&O(),a.on(e,n,t)):a.on.apply(a,arguments)},off:function(e){if(a.off.apply(a,arguments),A(e)){var n=!1;a.getEvents().forEach(function(e){A(e)&&a.getEventListenerCount(e)>0&&(n=!0)}),n||(E=!1,y&&void 0===h&&F())}},setStreaming:function(e){var n=null===e?void 0:e;n!==h&&(h=n,O())},flush:function(e){return wrapPromiseCallback(c?d.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!p)return e;for(var n in p)p.hasOwnProperty(n)&&(e[n]=R(n,null,!u.sendEventsOnlyForVariation).value);return e},close:function(e){if(w)return wrapPromiseCallback(Promise.resolve(),e);var n=function(){w=!0,p={}};return wrapPromiseCallback(Promise.resolve().then(function(){if(F(),c)return d.stop(),d.flush()}).then(n).catch(n),e)}},options:u,emitter:a,ident:U,logger:i,requestor:f,start:function(){c&&d.start()},enqueueEvent:L,getFlagsInternal:function(){return p},getEnvironmentId:function(){return l},internalChangeEventName:internalChangeEvent}}var version="2.14.0";function isSyncXhrSupported(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}var emptyResult={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function newHttpRequest(e,n,t,r,o){if(o&&!isSyncXhrSupported())return emptyResult;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),emptyResult;var u=void 0;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}function makeBrowserPlatform(e){var n={pageIsClosing:!1};window.XMLHttpRequest&&(n.httpRequest=function(e,t,r,o){return newHttpRequest(e,t,r,o,n.pageIsClosing)});var t=void 0;n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t};var r=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return r?r(window.location.href):window.location.href},n.isDoNotTrack=function(){var e=void 0;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(n.localStorage={get:function(e){return new Promise(function(n){n(window.localStorage.getItem(e))})},set:function(e,n){return new Promise(function(t){window.localStorage.setItem(e,n),t()})},clear:function(e){return new Promise(function(n){window.localStorage.removeItem(e),n()})}})}catch(e){n.localStorage=null}var o=void 0;if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){n.eventSourceFactory=function(e,n){var t={heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},r=Object.assign({},t,n);return new o(e,r)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n}var matchOperatorsRe=/[|\\{}()[\]^$+*?.]/g,escapeStringRegexp=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(matchOperatorsRe,"\\$&")};function doesUrlMatch(e,n,t,r){var o=n.replace(t,"").replace(r,""),i=void 0,a=void 0;switch(e.kind){case"exact":a=n,i=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":a=o,i=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":a=o,i=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":a=o,i=new RegExp(e.pattern);break;default:return!1}return i.test(a)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=findGoalsForClick(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var locationWatcherInterval=300;function GoalManager(e,n){var t=void 0,r=void 0,o={};function i(){r&&r.dispose(),t&&t.length&&(r=GoalTracker(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then(function(e){e&&e.length>0&&(r=GoalTracker(t=e,a),function(e,n){var t=window.location.href,r=void 0;function o(){(r=window.location.href)!==t&&(t=r,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(locationWatcherInterval,i)),n()}).catch(function(t){e.emitter.maybeReportError(new errors.LDUnexpectedResponseError((t&&t.message,t.message))),n()}),o}var goalsEvent="goalsReady",extraDefaults={fetchGoals:!0};function initialize$1(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=initialize(e,n,t,r,extraDefaults),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);return"complete"!==document.readyState?window.addEventListener("load",o.start):o.start(),window.addEventListener("beforeunload",function(){r.pageIsClosing=!0,i.close()}),i}var createConsoleLogger$1=createConsoleLogger,version$1=version;function deprecatedInitialize(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(messages.deprecated("default export","named LDClient export")),initialize$1(e,n,t)}var index={initialize:deprecatedInitialize,version:version};export default index;export{initialize$1 as initialize,createConsoleLogger$1 as createConsoleLogger,version$1 as version}; | ||
var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function e(n){return(e="function"==typeof Symbol&&"symbol"==_typeof(Symbol.iterator)?function(e){return void 0===e?"undefined":_typeof(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":_typeof(e)})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach(function(t){n(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))})}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),s=o("LaunchDarklyInvalidEventKeyError"),c=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"=")),o.join("")},g=[],m=[],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=p.length;h<y;++h)g[h]=p[h],m[p.charCodeAt(h)]=h;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,S=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==(void 0===n?"undefined":_typeof(n))&&"object"==(void 0===t?"undefined":_typeof(t))){var r,o,i,a=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function O(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return O(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return S(e,n)}function I(e){setTimeout(e,0)}function R(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function N(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function T(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function L(e){var n=e.version||"2.14.1";return e.userAgent+"/"+n}function A(e){return{"X-LaunchDarkly-User-Agent":L(e)}}function C(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return r({},e,{},n)},{})}function x(e){if(!e)return e;var n;for(var t in P){var o=P[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}var q=Object.freeze({__proto__:null,btoa:O,base64URLEncode:D,clone:U,deepEquals:j,onNextTick:I,wrapPromiseCallback:R,transformValuesToVersionedValues:N,transformVersionedValuesToValues:F,chunkUserEventsForUrl:T,getLDUserAgentString:L,getLDHeaders:A,extend:C,sanitizeUser:x}),_=2e3;function J(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a={};function u(e){(new window.Image).src=e}function s(n,t){var a=r||u,s=JSON.stringify(n);return t?function n(t){var r=C({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},A(e));return e.httpRequest("POST",o,r,s).promise.then(function(e){if(e)return e.status>=400&&f(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(a(i+"?d="+D(s)),Promise.resolve())}return a.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:T(_-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(s(r[a],o));return Promise.all(i)},a}function V(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce(function(a,u){var s=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[1][u]=!0:s[0][u]=e[u]),s},[{},{}])},u=a(e,function(e){return i[e]}),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,function(){return!0});s.custom=l[0],c=C({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var K=function(){return"LaunchDarkly client initialized"},$=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",M=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},H=function(e){return'Expected application/json content type but got "'+e+'"'},G=function(){return"localStorage is unavailable"},X=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},B=function(e){return"network error"+(e?" ("+e+")":"")},W=function(e){return'Custom event "'+e+'" does not exist'},Q=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},Y=function(){return"No environment/client-side ID was specified."+$},Z=function(e){return"Error fetching flag settings: "+z(e)},ee=function(){return"No user specified."+$},ne=function(){return"Invalid user specified."+$},te=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+$},re=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},oe=function(e,n){return n?'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"':'[LaunchDarkly] "'+e+'" is deprecated'},ie=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ae=function(){return"Cannot make HTTP requests in this environment."+$},ue=function(){return"identify() has no effect here; it must be called on the main client instance"},se=function(){return"Closing stream connection"},ce=function(e){return"Opening stream connection to "+e},le=function(e,n){return"Error on stream connection: "+z(e)+", will continue retrying every "+n+" milliseconds."},fe=function(e){return"polling for feature flags at "+e},ve=function(){return"received ping message from stream"},de=function(){return"received streaming update for all flags"},ge=function(e){return'received streaming update for flag "'+e+'"'},me=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},pe=function(e){return'received streaming deletion for flag "'+e+'"'},he=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},ye=function(e){return'enqueueing "'+e+'" event'},be=function(e){return"sending "+e+" events"},ke=Object.freeze({__proto__:null,clientInitialized:K,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventWithoutUser:M,invalidContentType:H,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:G,localStorageUnavailableForUserId:X,networkError:B,unknownCustomEventKey:W,environmentNotFound:Q,environmentNotSpecified:Y,errorFetchingFlags:Z,userNotSpecified:ee,invalidUser:ne,bootstrapOldFormat:te,bootstrapInvalid:re,deprecated:oe,httpErrorMessage:ie,httpUnavailable:ae,identifyDisabled:ue,streamClosing:se,streamConnecting:ce,streamError:le,debugPolling:fe,debugStreamPing:ve,debugStreamPut:de,debugStreamPatch:ge,debugStreamPatchIgnored:me,debugStreamDelete:pe,debugStreamDeleteIgnored:he,debugEnqueueingEvent:ye,debugPostingEvents:be});function Ee(e,n,t){var r,o,a,u,s,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,v={},d=l||J(e,n.eventsUrl,t),g=(o=0,a=0,u={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===o||e.creationDate<o)&&(o=e.creationDate),e.creationDate>a&&(a=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var s={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(s.variation=r.variation),r.version?s.version=r.version:s.unknown=!0,i.counters.push(s),n=!1}return n?null:{startDate:o,endDate:a,features:e}},r.clearSummary=function(){o=0,a=0,u={}},r),p=V(n),h=n.inlineUsersInEvents,m=n.samplingInterval,y=n.flushInterval,w=n.logger,b=[],k=0,E=!1;function S(){return 0===m||0===Math.floor(Math.random()*m)}return v.enqueue=function(e){if(!E){var n,t=!1,r=!1;if(g.summarizeEvent(e),"feature"===e.kind?S()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>k&&n.debugEventsUntilDate>(new Date).getTime()):t=S(),t&&b.push(function(e){var n=C({},e);return h||"identify"===e.kind?n.user=p.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=C({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,b.push(o)}}},v.flush=function(){if(E)return Promise.resolve();var e=b,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(b=[],w.debug(be(e.length)),d.sendEvents(e).then(function(e){e&&(e.serverTime&&(k=e.serverTime),f(e.status)||(E=!0),e.status>=400&&I(function(){c.maybeReportError(new i(ie(e.status,"event posting","some events were dropped")))}))}))},v.start=function(){s=setTimeout(function e(){v.flush(),s=setTimeout(e,y)},y)},v.stop=function(){clearTimeout(s)},v}function we(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}function Se(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||O(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=N(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(G()),Promise.reject(e)})},i.saveFlags=function(n){var t=C({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch(function(e){return o.warn(G()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(G()),Promise.reject(e)})},i}var Pe="application/json";function Oe(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.sendLDHeaders,s=n.logger,c={},f={};function v(n,t){if(!e.httpRequest)return new Promise(function(e,n){n(new l(ae()))});var r=t?"REPORT":"GET",o=u?A(e):{};t&&(o["Content-Type"]="application/json");var i=f[n];i||(i=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then(function(t){n===i&&(r(t),e&&e())},function(t){n===i&&(o(t),e&&e())})}};return i.resultPromise=new Promise(function(e,n){r=e,o=n}),i}(function(){delete f[n]}),f[n]=i);var s=e.httpRequest(r,n,o,t),c=s.promise.then(function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Pe))return JSON.parse(e.body);var n=H(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(Q()):new l(Z(e.statusText||String(e.status)))}(e))},function(e){return Promise.reject(new l(B(e)))});return i.addPromise(c,function(){s.cancel&&s.cancel()}),i.resultPromise}return c.fetchJSON=function(e){return v(r+e,null)},c.fetchFlagSettings=function(e,n){var a,u,c,l="";return o?(u=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=D(JSON.stringify(e)),u=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),u=u+(l?"?":"")+l,s.debug(fe(u)),v(u,c)},c}for(var De=function(e,n){return 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}}}(n={exports:{}}),n.exports}(),Ue=[],je=0;je<256;++je)Ue[je]=(je+256).toString(16).substr(1);var Ie,Re,Ne=function(e,n){var t=n||0,r=Ue;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},Fe=0,Te=0,Le=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ie,a=void 0!==e.clockseq?e.clockseq:Re;if(null==i||null==a){var u=De();null==i&&(i=Ie=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Re=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:Te+1,l=s-Fe+(c-Te)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>Fe)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Fe=s,Te=c,Re=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||Ne(o)},Ae="ld:$anonUserId";function Ce(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new u(ee()));var r=U(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(Ae).catch(function(){return null}):Promise.resolve(null)).then(function(t){if(t)return r.key=t,r;var o=Le();return r.key=o,function(t){return e?e.set(Ae,t).catch(function(){n.warn(X())}):Promise.resolve()}(o).then(function(){return r})}):Promise.reject(new u(ne()))}};return t}function xe(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<r.length?r[e]:"?";n(t+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var qe="ready",_e="initialized",Je="failed",Ve="change",ze="internal-change";function Ke(n,t,o,i,u){var f,v,d,g,p=o&&o.logger?o.logger:u&&u.logger||xe("warn"),h=we(p),m=function(e,n,t,r){var o=C({logger:r},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function a(e){I(function(){n&&n.maybeReportError(new c(e))})}var u=C({},e||{});return function(e){var n=u;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var t=i[e];r&&r.warn(oe(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}})}(),u=function(e,n){var t=C({},u);return Object.keys(n).forEach(function(e){void 0!==t[e]&&null!==t[e]||(t[e]=n[e])}),t}(0,o),(isNaN(u.flushInterval)||u.flushInterval<2e3)&&(u.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(u.samplingInterval)||u.samplingInterval<0)&&(u.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),u}(o,h,u,p),y=m.hash,w=m.sendEvents,b=n,k=function(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,f=!1,v=null,d=null,g=null,p=null;function h(e){f||(i.warn(le(e,l)),f=!0),w(),m(l)}function m(e){d||(e?d=setTimeout(y,e):y())}function y(){var n;d=null;var a="",l={};if(e.eventSourceFactory){for(var f in null!=r&&(a="h="+r),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(g)):(n=o+"/ping/"+t,a=""):n=u+"/"+D(JSON.stringify(g)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,w(),i.info(ce(n)),v=e.eventSourceFactory(n,l),p)p.hasOwnProperty(f)&&v.addEventListener(f,p[f]);v.onerror=h}}function w(){v&&(i.info(se()),v.close(),v=null)}return a.connect=function(e,n){g=e,p={};var t=function(e){p[e]=function(t){f=!1,n[e]&&n[e](t)}};for(var r in n||{})t(r);m()},a.disconnect=function(){clearTimeout(d),d=null,w()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}(i,m,b,y),E=m.eventProcessor||Ee(i,m,b,h),S=Oe(i,m,b),P={},O={},T=m.streaming,N=!1,L=!1,A=!0,q=m.stateProvider,_=function(e,n){var t,r={setUser:function(e){(t=x(e))&&n&&n(U(t))},getUser:function(){return t?U(t):null}};return r}(0,function(e){q||e&&z({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),J=Ce(i.localStorage,p);function z(e){b&&(q&&q.enqueueEvent&&q.enqueueEvent(e)||(e.user?(A=!1,!w||L||i.isDoNotTrack()||(p.debug(ye(e.kind)),E.enqueue(e))):A&&(p.warn(M()),A=!1)))}function V(e,n,t,r){var o=_.getUser(),i=new Date,a=n?n.value:null;if(!m.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=P[u];if(s&&i-s<3e5)return;P[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=O[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),z(c)}function $(e,n,t,r){var o;if(O&&O.hasOwnProperty(e)&&O[e]&&!O[e].deleted){var i=O[e];o=H(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&V(e,o,n,r),o}function H(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function X(){v=!0,_.getUser()&&k.connect(_.getUser(),{ping:function(){p.debug(ve()),S.fetchFlagSettings(_.getUser(),y).then(function(e){return Q(e||{})}).catch(function(e){h.maybeReportError(new l(Z(e)))})},put:function(e){var n=JSON.parse(e.data);p.debug(de()),Q(n)},patch:function(e){var n=JSON.parse(e.data),t=O[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(ge(n.key));var r={},o=C({},n);delete o.key,O[n.key]=o;var i=H(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ee(r)}else p.debug(me(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!O[n.key]||O[n.key].version<n.version){p.debug(pe(n.key));var t={};O[n.key]&&!O[n.key].deleted&&(t[n.key]={previous:O[n.key].value}),O[n.key]={version:n.version,deleted:!0},ee(t)}else p.debug(he(n.key))}})}function B(){v&&(k.disconnect(),v=!1)}function Q(e){var n={};if(!e)return Promise.resolve();for(var t in O)O.hasOwnProperty(t)&&O[t]&&(e[t]&&!j(e[t].value,O[t].value)?n[t]={previous:O[t].value,current:H(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:O[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!O[o]||O[o].deleted)&&(n[o]={current:H(e[o])});return O=r({},e),ee(n).catch(function(){})}function ee(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach(function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;h.emit(Ve+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}}),h.emit(Ve,t),h.emit(ze,O),m.sendEventsOnlyForVariation||q||n.forEach(function(n){V(n,e[n].current)})}return f&&g?g.saveFlags(O).catch(function(){return null}):Promise.resolve()}function ne(){var e=T||d&&void 0===T;e&&!v?X():!e&&v&&B()}function ie(e){return e===Ve||e.substr(0,Ve.length+1)===Ve+":"}i.localStorage&&(g=new Se(i.localStorage,b,y,_,p));var ae=new Promise(function(e){var n=h.on(qe,function(){h.off(qe,n),e()})}),fe=new Promise(function(e,n){var t=h.on(_e,function(){h.off(_e,t),e()}),r=h.on(Je,function(e){h.off(Je,r),n(e)})});if("string"==typeof m.bootstrap&&"LOCALSTORAGE"===m.bootstrap.toUpperCase()&&(g?f=!0:p.warn(G())),"object"===e(m.bootstrap)&&(O=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(te()),!1===e.$valid&&p.warn(re());var r={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=C(o,t[n]):o.version=0,r[n]=o}}),r}(m.bootstrap)),q){var be=q.getInitialState();be?ke(be):q.on("init",ke),q.on("update",function(e){e.user&&_.setUser(e.user),e.flags&&Q(e.flags)})}else(n?J.validateUser(t).then(function(n){return _.setUser(n),"object"===e(m.bootstrap)?Pe():f?g.loadFlags().catch(function(){return null}).then(function(e){return null==e?(O={},S.fetchFlagSettings(_.getUser(),y).then(function(e){return Q(e||{})}).then(Pe).catch(function(e){De(new l(Z(e)))})):(O=e,I(Pe),S.fetchFlagSettings(_.getUser(),y).then(function(e){return Q(e)}).catch(function(e){return h.maybeReportError(e)}))}):S.fetchFlagSettings(_.getUser(),y).then(function(e){O=e||{},Pe()}).catch(function(e){O={},De(e)})}):Promise.reject(new a(Y()))).catch(function(e){return h.maybeReportError(e)});function ke(e){b=e.environment,_.setUser(e.user),O=r({},e.flags),I(Pe)}function Pe(){p.info(K()),N=!0,ne(),h.emit(qe),h.emit(_e)}function De(e){h.maybeReportError(e),h.emit(Je,e),h.emit(qe)}return{client:{waitForInitialization:function(){return fe},waitUntilReady:function(){return ae},identify:function(e,n,t){return L?R(Promise.resolve({}),t):q?(p.warn(ue()),R(Promise.resolve(F(O)),t)):R((f&&g?g.clearFlags():Promise.resolve()).then(function(){return J.validateUser(e)}).then(function(e){return _.setUser(e)}).then(function(){return S.fetchFlagSettings(_.getUser(),n)}).then(function(e){var n=F(e);return e?Q(e).then(function(){return n}):n}).then(function(e){return v&&X(),e}).catch(function(e){return h.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return _.getUser()},variation:function(e,n){return $(e,n,!0,!1).value},variationDetail:function(e,n){return $(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&p.warn(W(e));var r={kind:"custom",key:e,user:_.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),z(r)}else h.maybeReportError(new s(W(e)))},on:function(e,n,t){ie(e)?(d=!0,N&&ne(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),ie(e)){var n=!1;h.getEvents().forEach(function(e){ie(e)&&h.getEventListenerCount(e)>0&&(n=!0)}),n||(d=!1,v&&void 0===T&&B())}},setStreaming:function(e){var n=null===e?void 0:e;n!==T&&(T=n,ne())},flush:function(e){return R(w?E.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!O)return e;for(var n in O)O.hasOwnProperty(n)&&(e[n]=$(n,null,!m.sendEventsOnlyForVariation).value);return e},close:function(e){if(L)return R(Promise.resolve(),e);var n=function(){L=!0,O={}};return R(Promise.resolve().then(function(){if(B(),w)return E.stop(),E.flush()}).then(n).catch(n),e)}},options:m,emitter:h,ident:_,logger:p,requestor:S,start:function(){w&&E.start()},enqueueEvent:z,getFlagsInternal:function(){return O},getEnvironmentId:function(){return b},internalChangeEventName:ze}}var $e="2.14.1";function isSyncXhrSupported(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}var emptyResult={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function newHttpRequest(e,n,t,r,o){if(o&&!isSyncXhrSupported())return emptyResult;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),emptyResult;var u=void 0;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}var _extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};function makeBrowserPlatform(e){var n={synchronousFlush:!1};window.XMLHttpRequest&&(n.httpRequest=function(e,t,r,o){var i=n.synchronousFlush;return n.synchronousFlush=!1,newHttpRequest(e,t,r,o,i)});var t=void 0;n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t};var r=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return r?r(window.location.href):window.location.href},n.isDoNotTrack=function(){var e=void 0;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(n.localStorage={get:function(e){return new Promise(function(n){n(window.localStorage.getItem(e))})},set:function(e,n){return new Promise(function(t){window.localStorage.setItem(e,n),t()})},clear:function(e){return new Promise(function(n){window.localStorage.removeItem(e),n()})}})}catch(e){n.localStorage=null}var o=void 0;if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){n.eventSourceFactory=function(e,n){var t=_extends({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},n);return new o(e,t)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n}var matchOperatorsRe=/[|\\{}()[\]^$+*?.]/g,escapeStringRegexp=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(matchOperatorsRe,"\\$&")};function doesUrlMatch(e,n,t,r){var o=n.replace(t,"").replace(r,""),i=void 0,a=void 0;switch(e.kind){case"exact":a=n,i=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":a=o,i=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":a=o,i=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":a=o,i=new RegExp(e.pattern);break;default:return!1}return i.test(a)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=findGoalsForClick(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var locationWatcherInterval=300;function GoalManager(e,n){var t=void 0,r=void 0,o={};function i(){r&&r.dispose(),t&&t.length&&(r=GoalTracker(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then(function(e){e&&e.length>0&&(r=GoalTracker(t=e,a),function(e,n){var t=window.location.href,r=void 0;function o(){(r=window.location.href)!==t&&(t=r,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(locationWatcherInterval,i)),n()}).catch(function(t){e.emitter.maybeReportError(new v.LDUnexpectedResponseError((t&&t.message,t.message))),n()}),o}var goalsEvent="goalsReady",extraDefaults={fetchGoals:!0};function initialize(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=Ke(e,n,t,r,extraDefaults),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch(function(){})};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var createConsoleLogger=xe,version=$e;function deprecatedInitialize(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(ke.deprecated("default export","named LDClient export")),initialize(e,n,t)}var index={initialize:deprecatedInitialize,version:$e};export default index;export{initialize,createConsoleLogger,version}; | ||
//# sourceMappingURL=ldclient.es.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.LDClient={})}(this,function(e){"use strict";var n="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};function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var r=t("LaunchDarklyUnexpectedResponseError"),o=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),a=t("LaunchDarklyInvalidEventKeyError"),u=t("LaunchDarklyInvalidArgumentError"),s=t("LaunchDarklyFlagFetchError");function c(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var l=Object.freeze({LDUnexpectedResponseError:r,LDInvalidEnvironmentIdError:o,LDInvalidUserError:i,LDInvalidEventKeyError:a,LDInvalidArgumentError:u,LDFlagFetchError:s,isHttpErrorRecoverable:c}),f=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(y(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(v[n>>2]+v[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(v[n>>10]+v[n>>4&63]+v[n<<2&63]+"=")),o.join("")},v=[],d=[],g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,m=g.length;p<m;++p)v[p]=g[p],d[g.charCodeAt(p)]=p;function h(e){return v[e>>18&63]+v[e>>12&63]+v[e>>6&63]+v[63&e]}function y(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(h(r));return o.join("")}d["-".charCodeAt(0)]=62,d["_".charCodeAt(0)]=63;var w="function"==typeof Symbol&&"symbol"==n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)},b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,S=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==(void 0===n?"undefined":w(n))&&"object"==(void 0===t?"undefined":w(t))){var r,o,i,a=b(n),u=b(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=k(n);if((o=v.length)!==k(t).length)return!1;for(r=o;0!=r--;)if(!E.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},P=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function O(e){var n=unescape(encodeURIComponent(e));return f(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function U(e){return O(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function R(e){return JSON.parse(JSON.stringify(e))}function I(e,n){return S(e,n)}function N(e){setTimeout(e,0)}function T(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function j(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function L(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function x(e,n){for(var t=n.slice(0),r=[],o=e,i=void 0;t.length>0;){for(i=[];o>0;){var a=t.shift();if(!a)break;(o-=U(JSON.stringify(a)).length)<0&&i.length>0?t.unshift(a):i.push(a)}o=e,r.push(i)}return r}function C(e){var n=e.version||"2.14.0";return e.userAgent+"/"+n}function F(e){return{"X-LaunchDarkly-User-Agent":C(e)}}function A(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return P({},e,n)},{})}function q(e){if(!e)return e;var n=void 0;for(var t in D){var r=D[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||Object.assign({},e))[r]=String(o))}return n||e}Object.freeze({btoa:O,base64URLEncode:U,clone:R,deepEquals:I,onNextTick:N,wrapPromiseCallback:T,transformValuesToVersionedValues:j,transformVersionedValuesToValues:L,chunkUserEventsForUrl:x,getLDUserAgentString:C,getLDHeaders:F,extend:A,sanitizeUser:q});var J=2e3;function V(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var z=function(){return"LaunchDarkly client initialized"},H=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",$=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},M=function(e){return'Expected application/json content type but got "'+e+'"'},K=function(){return"localStorage is unavailable"},_=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},G=function(e){return"network error"+(e?" ("+e+")":"")},X=function(e){return'Custom event "'+e+'" does not exist'},B=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+H},W=function(){return"No environment/client-side ID was specified."+H},Q=function(e){return"Error fetching flag settings: "+V(e)},Y=function(){return"No user specified."+H},Z=function(){return"Invalid user specified."+H},ee=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+H},ne=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},te=function(e,n){return'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"'},re=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(c(e)?t:"giving up permanently")},oe=function(){return"Cannot make HTTP requests in this environment."+H},ie=function(){return"identify() has no effect here; it must be called on the main client instance"},ae=function(){return"Closing stream connection"},ue=function(e){return"Opening stream connection to "+e},se=function(e){return"Error on stream connection: "+V(e)},ce=function(e){return"polling for feature flags at "+e},le=function(){return"received ping message from stream"},fe=function(){return"received streaming update for all flags"},ve=function(e){return'received streaming update for flag "'+e+'"'},de=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},ge=function(e){return'received streaming deletion for flag "'+e+'"'},pe=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},me=function(e){return'enqueueing "'+e+'" event'},he=function(e){return"sending "+e+" events"},ye=Object.freeze({clientInitialized:z,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventWithoutUser:$,invalidContentType:M,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:K,localStorageUnavailableForUserId:_,networkError:G,unknownCustomEventKey:X,environmentNotFound:B,environmentNotSpecified:W,errorFetchingFlags:Q,userNotSpecified:Y,invalidUser:Z,bootstrapOldFormat:ee,bootstrapInvalid:ne,deprecated:te,httpErrorMessage:re,httpUnavailable:oe,identifyDisabled:ie,streamClosing:ae,streamConnecting:ue,streamError:se,debugPolling:ce,debugStreamPing:le,debugStreamPut:fe,debugStreamPatch:ve,debugStreamPatchIgnored:de,debugStreamDelete:ge,debugStreamDeleteIgnored:pe,debugEnqueueingEvent:me,debugPostingEvents:he});function we(e,n,t){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a={},u=i||function(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a={};function u(e){(new window.Image).src=e}function s(n,t){var a=r||u,s=JSON.stringify(n);return t?function n(t){var r=A({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},F(e));return e.httpRequest("POST",o,r,s).promise.then(function(e){if(e)return e.status>=400&&c(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(a(i+"?d="+U(s)),Promise.resolve())}return a.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:x(J-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(s(r[a],o));return Promise.all(i)},a}(e,n.eventsUrl,t),s=function(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=r[o];i?i.count=i.count+1:r[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in r){var a=r[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}(),l=function(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce(function(a,u){var s=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[1][u]=!0:s[0][u]=e[u]),s},[{},{}])},u=a(e,function(e){return i[e]}),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,function(){return!0});s.custom=l[0],c=A({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}(n),f=n.inlineUsersInEvents,v=n.samplingInterval,d=n.flushInterval,g=n.logger,p=[],m=0,h=!1,y=void 0;function w(){return 0===v||0===Math.floor(Math.random()*v)}return a.enqueue=function(e){if(!h){var n,t=!1,r=!1;if(s.summarizeEvent(e),"feature"===e.kind?w()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>m&&n.debugEventsUntilDate>(new Date).getTime()):t=w(),t&&p.push(function(e){var n=A({},e);return f||"identify"===e.kind?n.user=l.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=A({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,p.push(o)}}},a.flush=function(){if(h)return Promise.resolve();var e=p,n=s.getSummary();return s.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(p=[],g.debug(he(e.length)),u.sendEvents(e).then(function(e){e&&(e.serverTime&&(m=e.serverTime),c(e.status)||(h=!0),e.status>=400&&N(function(){o.maybeReportError(new r(re(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){y=setTimeout(function e(){a.flush(),y=setTimeout(e,d)},d)},a.stop=function(){clearTimeout(y)},a}var be,ke,Ee="application/json";function Se(e,n,t){var r=n.baseUrl,i=n.useReport,a=n.evaluationReasons,u=n.sendLDHeaders,c=n.logger,l={},f={};function v(n,t){if(!e.httpRequest)return new Promise(function(e,n){n(new s(oe()))});var r=t?"REPORT":"GET",i=u?F(e):{};t&&(i["Content-Type"]="application/json");var a=f[n];a||(a=function(e){var n=void 0,t=void 0,r=void 0,o=void 0,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then(function(t){n===i&&(r(t),e&&e())},function(t){n===i&&(o(t),e&&e())})}};return i.resultPromise=new Promise(function(e,n){r=e,o=n}),i}(function(){delete f[n]}),f[n]=a);var c=e.httpRequest(r,n,i,t),l=c.promise.then(function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Ee))return JSON.parse(e.body);var n=M(e.header("content-type")||"");return Promise.reject(new s(n))}return Promise.reject(function(e){return 404===e.status?new o(B()):new s(Q(e.statusText||String(e.status)))}(e))},function(e){return Promise.reject(new s(G(e)))});return a.addPromise(l,function(){c.cancel&&c.cancel()}),a.resultPromise}return l.fetchJSON=function(e){return v(r+e,null)},l.fetchFlagSettings=function(e,n){var o=void 0,u=void 0,s="",l=void 0;return i?(u=[r,"/sdk/evalx/",t,"/user"].join(""),l=JSON.stringify(e)):(o=U(JSON.stringify(e)),u=[r,"/sdk/evalx/",t,"/users/",o].join("")),n&&(s="h="+n),a&&(s=s+(s?"&":"")+"withReasons=true"),u=u+(s?"?":"")+s,c.debug(ce(u)),v(u,l)},l}for(var Pe=(be=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}}},ke=void 0,be(ke={exports:{}},ke.exports),ke.exports),De=[],Oe=0;Oe<256;++Oe)De[Oe]=(Oe+256).toString(16).substr(1);var Ue,Re,Ie=function(e,n){var t=n||0,r=De;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},Ne=0,Te=0;var je=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ue,a=void 0!==e.clockseq?e.clockseq:Re;if(null==i||null==a){var u=Pe();null==i&&(i=Ue=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Re=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:Te+1,l=s-Ne+(c-Te)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>Ne)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ne=s,Te=c,Re=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||Ie(o)},Le="ld:$anonUserId";function xe(e,n){var t=["debug","info","warn","error"],r=void 0;r=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:t.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<t.length?t[e]:"?";n(r+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var Ce="function"==typeof Symbol&&"symbol"==n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)},Fe="ready",Ae="initialized",qe="failed",Je="change",Ve="internal-change";function ze(e,n,t,r,c){var l=t&&t.logger?t.logger:c&&c.logger||xe("warn"),f=function(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}(l),v=function(e,n,t,r){var o=A({logger:r},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames"};function a(e){N(function(){n&&n.maybeReportError(new u(e))})}var s=A({},e||{});return function(e){var n=s;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var t=i[e];r.warn(te(e,t)),void 0===n[t]&&(n[t]=n[e]),delete n[e]}})}(),s=function(e,n){var t=A({},s);return Object.keys(n).forEach(function(e){void 0!==t[e]&&null!==t[e]||(t[e]=n[e])}),t}(0,o),(isNaN(s.flushInterval)||s.flushInterval<2e3)&&(s.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(s.samplingInterval)||s.samplingInterval<0)&&(s.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),s}(t,f,c,l),d=v.hash,g=v.sendEvents,p=e,m=function(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,f=null,v=null,d=null,g=null;function p(e){i.warn(se(e)),y(),m(l)}function m(e){v||(e?v=setTimeout(h,e):h())}function h(){v=null;var n=void 0,a="",l={};if(e.eventSourceFactory){for(var m in null!=r&&(a="h="+r),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(d)):(n=o+"/ping/"+t,a=""):n=u+"/"+U(JSON.stringify(d)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,y(),i.info(ue(n)),f=e.eventSourceFactory(n,l),g)g.hasOwnProperty(m)&&f.addEventListener(m,g[m]);f.onerror=p}}function y(){f&&(i.info(ae()),f.close(),f=null)}return a.connect=function(e,n){d=e,g=n,m()},a.disconnect=function(){clearTimeout(v),v=null,y()},a.isConnected=function(){return!!(f&&e.eventSourceIsActive&&e.eventSourceIsActive(f))},a}(r,v,p,d),h=v.eventProcessor||we(r,v,p,f),y=Se(r,v,p),w={},b={},k=void 0,E=void 0,S=v.streaming,P=void 0,D=!1,x=!1,C=!0,F=v.stateProvider,J=function(e,n){var t={},r=void 0;return t.setUser=function(e){(r=q(e))&&n&&n(R(r))},t.getUser=function(){return r?R(r):null},e&&t.setUser(e),t}(null,function(e){F||e&&M({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),V=function(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new i(Y()));var r=R(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(Le).catch(function(){return null}):Promise.resolve(null)).then(function(t){if(t)return r.key=t,r;var o=je();return r.key=o,function(t){return e?e.set(Le,t).catch(function(){n.warn(_())}):Promise.resolve()}(o).then(function(){return r})}):Promise.reject(new i(Z()))}};return t}(r.localStorage,l),H=void 0;function M(e){p&&(F&&F.enqueueEvent&&F.enqueueEvent(e)||(e.user?(C=!1,!g||x||r.isDoNotTrack()||(l.debug(me(e.kind)),h.enqueue(e))):C&&(l.warn($()),C=!1)))}function G(e,n,t,r){var o=J.getUser(),i=new Date,a=n?n.value:null;if(!v.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=w[u];if(s&&i-s<3e5)return;w[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=b[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),M(c)}function B(e,n,t,r){var o=void 0;if(b&&b.hasOwnProperty(e)&&b[e]&&!b[e].deleted){var i=b[e];o=re(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&G(e,o,n,r),o}function re(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function oe(){E=!0,J.getUser()&&m.connect(J.getUser(),{ping:function(){l.debug(le()),y.fetchFlagSettings(J.getUser(),d).then(function(e){return he(e||{})}).catch(function(e){f.maybeReportError(new s(Q(e)))})},put:function(e){var n=JSON.parse(e.data);l.debug(fe()),he(n)},patch:function(e){var n=JSON.parse(e.data),t=b[n.key];if(!t||!t.version||!n.version||t.version<n.version){l.debug(ve(n.key));var r={},o=A({},n);delete o.key,b[n.key]=o;var i=re(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ye(r)}else l.debug(de(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!b[n.key]||b[n.key].version<n.version){l.debug(ge(n.key));var t={};b[n.key]&&!b[n.key].deleted&&(t[n.key]={previous:b[n.key].value}),b[n.key]={version:n.version,deleted:!0},ye(t)}else l.debug(pe(n.key))}})}function ce(){E&&(m.disconnect(),E=!1)}function he(e){var n={};if(!e)return Promise.resolve();for(var t in b)b.hasOwnProperty(t)&&b[t]&&(e[t]&&!I(e[t].value,b[t].value)?n[t]={previous:b[t].value,current:re(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:b[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!b[r]||b[r].deleted)&&(n[r]={current:re(e[r])});return b=Object.assign({},e),ye(n).catch(function(){})}function ye(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach(function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;f.emit(Je+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}}),f.emit(Je,t),f.emit(Ve,b),v.sendEventsOnlyForVariation||F||n.forEach(function(n){G(n,e[n].current)})}return k&&H?H.saveFlags(b).catch(function(){return null}):Promise.resolve()}function be(){var e=S||P&&void 0===S;e&&!E?oe():!e&&E&&ce()}function ke(e){return e===Je||e.substr(0,Je.length+1)===Je+":"}r.localStorage&&(H=new function(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||O(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=j(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(K()),Promise.reject(e)})},i.saveFlags=function(n){var t=A({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch(function(e){return o.warn(K()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(K()),Promise.reject(e)})},i}(r.localStorage,p,d,J,l));var Ee=new Promise(function(e){var n=f.on(Fe,function(){f.off(Fe,n),e()})}),Pe=new Promise(function(e,n){var t=f.on(Ae,function(){f.off(Ae,t),e()}),r=f.on(qe,function(e){f.off(qe,r),n(e)})});if("string"==typeof v.bootstrap&&"LOCALSTORAGE"===v.bootstrap.toUpperCase()&&(H?k=!0:l.warn(K())),"object"===Ce(v.bootstrap)&&(b=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&l.warn(ee()),!1===e.$valid&&l.warn(ne());var r={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=A(o,t[n]):o.version=0,r[n]=o}}),r}(v.bootstrap)),F){var De=F.getInitialState();De?Oe(De):F.on("init",Oe),F.on("update",function(e){e.user&&J.setUser(e.user),e.flags&&he(e.flags)})}else(e?V.validateUser(n).then(function(e){return J.setUser(e),"object"===Ce(v.bootstrap)?Ue():k?H.loadFlags().catch(function(){return null}).then(function(e){return null==e?(b={},y.fetchFlagSettings(J.getUser(),d).then(function(e){return he(e||{})}).then(Ue).catch(function(e){Re(new s(Q(e)))})):(b=e,N(Ue),y.fetchFlagSettings(J.getUser(),d).then(function(e){return he(e)}).catch(function(e){return f.maybeReportError(e)}))}):y.fetchFlagSettings(J.getUser(),d).then(function(e){b=e||{},Ue()}).catch(function(e){b={},Re(e)})}):Promise.reject(new o(W()))).catch(function(e){return f.maybeReportError(e)});function Oe(e){p=e.environment,J.setUser(e.user),b=Object.assign({},e.flags),N(Ue)}function Ue(){l.info(z()),D=!0,be(),f.emit(Fe),f.emit(Ae)}function Re(e){f.maybeReportError(e),f.emit(qe,e),f.emit(Fe)}return{client:{waitForInitialization:function(){return Pe},waitUntilReady:function(){return Ee},identify:function(e,n,t){return x?T(Promise.resolve({}),t):F?(l.warn(ie()),T(Promise.resolve(L(b)),t)):T((k&&H?H.clearFlags():Promise.resolve()).then(function(){return V.validateUser(e)}).then(function(e){return J.setUser(e)}).then(function(){return y.fetchFlagSettings(J.getUser(),n)}).then(function(e){var n=L(e);return e?he(e).then(function(){return n}):n}).then(function(e){return E&&oe(),e}).catch(function(e){return f.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return J.getUser()},variation:function(e,n){return B(e,n,!0,!1).value},variationDetail:function(e,n){return B(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){r.customEventFilter&&!r.customEventFilter(e)&&l.warn(X(e));var o={kind:"custom",key:e,user:J.getUser(),url:r.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(o.data=n),null!=t&&(o.metricValue=t),M(o)}else f.maybeReportError(new a(X(e)))},on:function(e,n,t){ke(e)?(P=!0,D&&be(),f.on(e,n,t)):f.on.apply(f,arguments)},off:function(e){if(f.off.apply(f,arguments),ke(e)){var n=!1;f.getEvents().forEach(function(e){ke(e)&&f.getEventListenerCount(e)>0&&(n=!0)}),n||(P=!1,E&&void 0===S&&ce())}},setStreaming:function(e){var n=null===e?void 0:e;n!==S&&(S=n,be())},flush:function(e){return T(g?h.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!b)return e;for(var n in b)b.hasOwnProperty(n)&&(e[n]=B(n,null,!v.sendEventsOnlyForVariation).value);return e},close:function(e){if(x)return T(Promise.resolve(),e);var n=function(){x=!0,b={}};return T(Promise.resolve().then(function(){if(ce(),g)return h.stop(),h.flush()}).then(n).catch(n),e)}},options:v,emitter:f,ident:J,logger:l,requestor:y,start:function(){g&&h.start()},enqueueEvent:M,getFlagsInternal:function(){return b},getEnvironmentId:function(){return p},internalChangeEventName:Ve}}var He={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function $e(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return He;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),He;var u=void 0;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}var Me=/[|\\{}()[\]^$+*?.]/g,Ke=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Me,"\\$&")};function _e(e,n,t,r){var o=n.replace(t,"").replace(r,""),i=void 0,a=void 0;switch(e.kind){case"exact":a=n,i=new RegExp("^"+Ke(e.url)+"/?$");break;case"canonical":a=o,i=new RegExp("^"+Ke(e.url)+"/?$");break;case"substring":a=o,i=new RegExp(".*"+Ke(e.substring)+".*$");break;case"regex":a=o,i=new RegExp(e.pattern);break;default:return!1}return i.test(a)}function Ge(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(_e(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var Xe=300;function Be(e,n){var t=void 0,r=void 0,o={};function i(){r&&r.dispose(),t&&t.length&&(r=Ge(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then(function(e){e&&e.length>0&&(r=Ge(t=e,a),function(e,n){var t=window.location.href,r=void 0;function o(){(r=window.location.href)!==t&&(t=r,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(Xe,i)),n()}).catch(function(t){e.emitter.maybeReportError(new l.LDUnexpectedResponseError((t&&t.message,t.message))),n()}),o}var We="goalsReady",Qe={fetchGoals:!0};function Ye(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n={pageIsClosing:!1};window.XMLHttpRequest&&(n.httpRequest=function(e,t,r,o){return $e(e,t,r,o,n.pageIsClosing)});var t=void 0;n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t};var r=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return r?r(window.location.href):window.location.href},n.isDoNotTrack=function(){var e=void 0;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(n.localStorage={get:function(e){return new Promise(function(n){n(window.localStorage.getItem(e))})},set:function(e,n){return new Promise(function(t){window.localStorage.setItem(e,n),t()})},clear:function(e){return new Promise(function(n){window.localStorage.removeItem(e),n()})}})}catch(e){n.localStorage=null}var o=void 0;e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource&&(n.eventSourceFactory=function(e,n){var t={heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},r=Object.assign({},t,n);return new o(e,r)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING});return n.userAgent="JSClient",n}(t),o=ze(e,n,t,r,Qe),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(We,function(){u.off(We,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=Be(o,function(){return u.emit(We)});r.customEventFilter=c.goalKeyExists}else u.emit(We);return"complete"!==document.readyState?window.addEventListener("load",o.start):o.start(),window.addEventListener("beforeunload",function(){r.pageIsClosing=!0,i.close()}),i}var Ze=xe;var en={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(ye.deprecated("default export","named LDClient export")),Ye(e,n,t)},version:"2.14.0"};e.initialize=Ye,e.createConsoleLogger=Ze,e.version="2.14.0",e.default=en,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.LDClient={})}(this,function(e){"use strict";var n="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};function t(e){return(t="function"==typeof Symbol&&"symbol"==n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(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 o(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 i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?o(t,!0).forEach(function(n){r(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(t).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function a(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),v=a("LaunchDarklyFlagFetchError");function d(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var g=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:v,isHttpErrorRecoverable:d}),p=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(k(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(m[n>>2]+m[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(m[n>>10]+m[n>>4&63]+m[n<<2&63]+"=")),o.join("")},m=[],h=[],y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=0,b=y.length;w<b;++w)m[w]=y[w],h[y.charCodeAt(w)]=w;function k(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(m[(o=r)>>18&63]+m[o>>12&63]+m[o>>6&63]+m[63&o]);return i.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var E=Array.isArray,S=Object.keys,P=Object.prototype.hasOwnProperty,O=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==(void 0===t?"undefined":n(t))&&"object"==(void 0===r?"undefined":n(r))){var o,i,a,u=E(t),s=E(r);if(u&&s){if((i=t.length)!=r.length)return!1;for(o=i;0!=o--;)if(!e(t[o],r[o]))return!1;return!0}if(u!=s)return!1;var c=t instanceof Date,l=r instanceof Date;if(c!=l)return!1;if(c&&l)return t.getTime()==r.getTime();var f=t instanceof RegExp,v=r instanceof RegExp;if(f!=v)return!1;if(f&&v)return t.toString()==r.toString();var d=S(t);if((i=d.length)!==S(r).length)return!1;for(o=i;0!=o--;)if(!P.call(r,d[o]))return!1;for(o=i;0!=o--;)if(!e(t[a=d[o]],r[a]))return!1;return!0}return t!=t&&r!=r},D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function U(e){var n=unescape(encodeURIComponent(e));return p(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function R(e){return U(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function j(e){return JSON.parse(JSON.stringify(e))}function I(e,n){return O(e,n)}function N(e){setTimeout(e,0)}function T(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function L(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function x(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=R(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function A(e){var n=e.version||"2.14.1";return e.userAgent+"/"+n}function C(e){return{"X-LaunchDarkly-User-Agent":A(e)}}function q(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return i({},e,{},n)},{})}function _(e){if(!e)return e;var n;for(var t in D){var r=D[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||i({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:U,base64URLEncode:R,clone:j,deepEquals:I,onNextTick:N,wrapPromiseCallback:T,transformValuesToVersionedValues:L,transformVersionedValuesToValues:F,chunkUserEventsForUrl:x,getLDUserAgentString:A,getLDHeaders:C,extend:q,sanitizeUser:_});var J=2e3;function V(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var z=function(){return"LaunchDarkly client initialized"},H=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",$=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},M=function(e){return'Expected application/json content type but got "'+e+'"'},K=function(){return"localStorage is unavailable"},G=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},X=function(e){return"network error"+(e?" ("+e+")":"")},B=function(e){return'Custom event "'+e+'" does not exist'},W=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+H},Q=function(){return"No environment/client-side ID was specified."+H},Y=function(e){return"Error fetching flag settings: "+V(e)},Z=function(){return"No user specified."+H},ee=function(){return"Invalid user specified."+H},ne=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+H},te=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},re=function(e,n){return n?'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"':'[LaunchDarkly] "'+e+'" is deprecated'},oe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(d(e)?t:"giving up permanently")},ie=function(){return"Cannot make HTTP requests in this environment."+H},ae=function(){return"identify() has no effect here; it must be called on the main client instance"},ue=function(){return"Closing stream connection"},se=function(e){return"Opening stream connection to "+e},ce=function(e,n){return"Error on stream connection: "+V(e)+", will continue retrying every "+n+" milliseconds."},le=function(e){return"polling for feature flags at "+e},fe=function(){return"received ping message from stream"},ve=function(){return"received streaming update for all flags"},de=function(e){return'received streaming update for flag "'+e+'"'},ge=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},pe=function(e){return'received streaming deletion for flag "'+e+'"'},me=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},he=function(e){return'enqueueing "'+e+'" event'},ye=function(e){return"sending "+e+" events"},we=Object.freeze({__proto__:null,clientInitialized:z,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventWithoutUser:$,invalidContentType:M,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:K,localStorageUnavailableForUserId:G,networkError:X,unknownCustomEventKey:B,environmentNotFound:W,environmentNotSpecified:Q,errorFetchingFlags:Y,userNotSpecified:Z,invalidUser:ee,bootstrapOldFormat:ne,bootstrapInvalid:te,deprecated:re,httpErrorMessage:oe,httpUnavailable:ie,identifyDisabled:ae,streamClosing:ue,streamConnecting:se,streamError:ce,debugPolling:le,debugStreamPing:fe,debugStreamPut:ve,debugStreamPatch:de,debugStreamPatchIgnored:ge,debugStreamDelete:pe,debugStreamDeleteIgnored:me,debugEnqueueingEvent:he,debugPostingEvents:ye});function be(e,n,t){var r,o,i,a,s,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,f={},v=l||function(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a={};function u(e){(new window.Image).src=e}function s(n,t){var a=r||u,s=JSON.stringify(n);return t?function n(t){var r=q({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},C(e));return e.httpRequest("POST",o,r,s).promise.then(function(e){if(e)return e.status>=400&&d(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(a(i+"?d="+R(s)),Promise.resolve())}return a.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:x(J-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(s(r[a],o));return Promise.all(i)},a}(e,n.eventsUrl,t),g=(o=0,i=0,a={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=a[n];t?t.count=t.count+1:a[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===o||e.creationDate<o)&&(o=e.creationDate),e.creationDate>i&&(i=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in a){var r=a[t],u=e[r.key];u||(u={default:r.default,counters:[]},e[r.key]=u);var s={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(s.variation=r.variation),r.version?s.version=r.version:s.unknown=!0,u.counters.push(s),n=!1}return n?null:{startDate:o,endDate:i,features:e}},r.clearSummary=function(){o=0,i=0,a={}},r),p=function(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce(function(a,u){var s=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[1][u]=!0:s[0][u]=e[u]),s},[{},{}])},u=a(e,function(e){return i[e]}),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,function(){return!0});s.custom=l[0],c=q({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}(n),m=n.inlineUsersInEvents,h=n.samplingInterval,y=n.flushInterval,w=n.logger,b=[],k=0,E=!1;function S(){return 0===h||0===Math.floor(Math.random()*h)}return f.enqueue=function(e){if(!E){var n,t=!1,r=!1;if(g.summarizeEvent(e),"feature"===e.kind?S()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>k&&n.debugEventsUntilDate>(new Date).getTime()):t=S(),t&&b.push(function(e){var n=q({},e);return m||"identify"===e.kind?n.user=p.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=q({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,b.push(o)}}},f.flush=function(){if(E)return Promise.resolve();var e=b,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(b=[],w.debug(ye(e.length)),v.sendEvents(e).then(function(e){e&&(e.serverTime&&(k=e.serverTime),d(e.status)||(E=!0),e.status>=400&&N(function(){c.maybeReportError(new u(oe(e.status,"event posting","some events were dropped")))}))}))},f.start=function(){s=setTimeout(function e(){f.flush(),s=setTimeout(e,y)},y)},f.stop=function(){clearTimeout(s)},f}function ke(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||U(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=L(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(K()),Promise.reject(e)})},i.saveFlags=function(n){var t=q({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch(function(e){return o.warn(K()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(K()),Promise.reject(e)})},i}var Ee="application/json";function Se(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.sendLDHeaders,u=n.logger,c={},l={};function f(n,t){if(!e.httpRequest)return new Promise(function(e,n){n(new v(ie()))});var r=t?"REPORT":"GET",o=a?C(e):{};t&&(o["Content-Type"]="application/json");var i=l[n];i||(i=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then(function(t){n===i&&(r(t),e&&e())},function(t){n===i&&(o(t),e&&e())})}};return i.resultPromise=new Promise(function(e,n){r=e,o=n}),i}(function(){delete l[n]}),l[n]=i);var u=e.httpRequest(r,n,o,t),c=u.promise.then(function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Ee))return JSON.parse(e.body);var n=M(e.header("content-type")||"");return Promise.reject(new v(n))}return Promise.reject(function(e){return 404===e.status?new s(W()):new v(Y(e.statusText||String(e.status)))}(e))},function(e){return Promise.reject(new v(X(e)))});return i.addPromise(c,function(){u.cancel&&u.cancel()}),i.resultPromise}return c.fetchJSON=function(e){return f(r+e,null)},c.fetchFlagSettings=function(e,n){var a,s,c,l="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=R(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),s=s+(l?"?":"")+l,u.debug(le(s)),f(s,c)},c}for(var Pe=function(e,n){return 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}}}(n={exports:{}}),n.exports}(),Oe=[],De=0;De<256;++De)Oe[De]=(De+256).toString(16).substr(1);var Ue,Re,je=0,Ie=0,Ne=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ue,a=void 0!==e.clockseq?e.clockseq:Re;if(null==i||null==a){var u=Pe();null==i&&(i=Ue=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Re=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:Ie+1,l=s-je+(c-Ie)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>je)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");je=s,Ie=c,Re=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=Oe;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(o)},Te="ld:$anonUserId";function Le(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new c(Z()));var r=j(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(Te).catch(function(){return null}):Promise.resolve(null)).then(function(t){if(t)return r.key=t,r;var o=Ne();return r.key=o,function(t){return e?e.set(Te,t).catch(function(){n.warn(G())}):Promise.resolve()}(o).then(function(){return r})}):Promise.reject(new c(ee()))}};return t}function Fe(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<r.length?r[e]:"?";n(t+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var xe="ready",Ae="initialized",Ce="failed",qe="change",_e="internal-change";function Je(e,n,r,o,a){var u,c,d,g,p=r&&r.logger?r.logger:a&&a.logger||Fe("warn"),m=function(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}(p),h=function(e,n,t,r){var o=q({logger:r},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function a(e){N(function(){n&&n.maybeReportError(new f(e))})}var u=q({},e||{});return function(e){var n=u;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var t=i[e];r&&r.warn(re(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}})}(),u=function(e,n){var t=q({},u);return Object.keys(n).forEach(function(e){void 0!==t[e]&&null!==t[e]||(t[e]=n[e])}),t}(0,o),(isNaN(u.flushInterval)||u.flushInterval<2e3)&&(u.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(u.samplingInterval)||u.samplingInterval<0)&&(u.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),u}(r,m,a,p),y=h.hash,w=h.sendEvents,b=e,k=function(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,f=!1,v=null,d=null,g=null,p=null;function m(e){f||(i.warn(ce(e,l)),f=!0),w(),h(l)}function h(e){d||(e?d=setTimeout(y,e):y())}function y(){var n;d=null;var a="",l={};if(e.eventSourceFactory){for(var f in null!=r&&(a="h="+r),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(g)):(n=o+"/ping/"+t,a=""):n=u+"/"+R(JSON.stringify(g)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,w(),i.info(se(n)),v=e.eventSourceFactory(n,l),p)p.hasOwnProperty(f)&&v.addEventListener(f,p[f]);v.onerror=m}}function w(){v&&(i.info(ue()),v.close(),v=null)}return a.connect=function(e,n){g=e,p={};var t=function(e){p[e]=function(t){f=!1,n[e]&&n[e](t)}};for(var r in n||{})t(r);h()},a.disconnect=function(){clearTimeout(d),d=null,w()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}(o,h,b,y),E=h.eventProcessor||be(o,h,b,m),S=Se(o,h,b),P={},O={},D=h.streaming,U=!1,L=!1,x=!0,A=h.stateProvider,C=function(e,n){var t,r={setUser:function(e){(t=_(e))&&n&&n(j(t))},getUser:function(){return t?j(t):null}};return r}(0,function(e){A||e&&V({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),J=Le(o.localStorage,p);function V(e){b&&(A&&A.enqueueEvent&&A.enqueueEvent(e)||(e.user?(x=!1,!w||L||o.isDoNotTrack()||(p.debug(he(e.kind)),E.enqueue(e))):x&&(p.warn($()),x=!1)))}function H(e,n,t,r){var o=C.getUser(),i=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=P[u];if(s&&i-s<3e5)return;P[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=O[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),V(c)}function M(e,n,t,r){var o;if(O&&O.hasOwnProperty(e)&&O[e]&&!O[e].deleted){var i=O[e];o=G(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&H(e,o,n,r),o}function G(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function X(){c=!0,C.getUser()&&k.connect(C.getUser(),{ping:function(){p.debug(fe()),S.fetchFlagSettings(C.getUser(),y).then(function(e){return Z(e||{})}).catch(function(e){m.maybeReportError(new v(Y(e)))})},put:function(e){var n=JSON.parse(e.data);p.debug(ve()),Z(n)},patch:function(e){var n=JSON.parse(e.data),t=O[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(de(n.key));var r={},o=q({},n);delete o.key,O[n.key]=o;var i=G(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ee(r)}else p.debug(ge(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!O[n.key]||O[n.key].version<n.version){p.debug(pe(n.key));var t={};O[n.key]&&!O[n.key].deleted&&(t[n.key]={previous:O[n.key].value}),O[n.key]={version:n.version,deleted:!0},ee(t)}else p.debug(me(n.key))}})}function W(){c&&(k.disconnect(),c=!1)}function Z(e){var n={};if(!e)return Promise.resolve();for(var t in O)O.hasOwnProperty(t)&&O[t]&&(e[t]&&!I(e[t].value,O[t].value)?n[t]={previous:O[t].value,current:G(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:O[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!O[r]||O[r].deleted)&&(n[r]={current:G(e[r])});return O=i({},e),ee(n).catch(function(){})}function ee(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach(function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;m.emit(qe+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}}),m.emit(qe,t),m.emit(_e,O),h.sendEventsOnlyForVariation||A||n.forEach(function(n){H(n,e[n].current)})}return u&&g?g.saveFlags(O).catch(function(){return null}):Promise.resolve()}function oe(){var e=D||d&&void 0===D;e&&!c?X():!e&&c&&W()}function ie(e){return e===qe||e.substr(0,qe.length+1)===qe+":"}o.localStorage&&(g=new ke(o.localStorage,b,y,C,p));var le=new Promise(function(e){var n=m.on(xe,function(){m.off(xe,n),e()})}),ye=new Promise(function(e,n){var t=m.on(Ae,function(){m.off(Ae,t),e()}),r=m.on(Ce,function(e){m.off(Ce,r),n(e)})});if("string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(g?u=!0:p.warn(K())),"object"===t(h.bootstrap)&&(O=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(ne()),!1===e.$valid&&p.warn(te());var r={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=q(o,t[n]):o.version=0,r[n]=o}}),r}(h.bootstrap)),A){var we=A.getInitialState();we?Ee(we):A.on("init",Ee),A.on("update",function(e){e.user&&C.setUser(e.user),e.flags&&Z(e.flags)})}else(e?J.validateUser(n).then(function(e){return C.setUser(e),"object"===t(h.bootstrap)?Pe():u?g.loadFlags().catch(function(){return null}).then(function(e){return null==e?(O={},S.fetchFlagSettings(C.getUser(),y).then(function(e){return Z(e||{})}).then(Pe).catch(function(e){Oe(new v(Y(e)))})):(O=e,N(Pe),S.fetchFlagSettings(C.getUser(),y).then(function(e){return Z(e)}).catch(function(e){return m.maybeReportError(e)}))}):S.fetchFlagSettings(C.getUser(),y).then(function(e){O=e||{},Pe()}).catch(function(e){O={},Oe(e)})}):Promise.reject(new s(Q()))).catch(function(e){return m.maybeReportError(e)});function Ee(e){b=e.environment,C.setUser(e.user),O=i({},e.flags),N(Pe)}function Pe(){p.info(z()),U=!0,oe(),m.emit(xe),m.emit(Ae)}function Oe(e){m.maybeReportError(e),m.emit(Ce,e),m.emit(xe)}return{client:{waitForInitialization:function(){return ye},waitUntilReady:function(){return le},identify:function(e,n,t){return L?T(Promise.resolve({}),t):A?(p.warn(ae()),T(Promise.resolve(F(O)),t)):T((u&&g?g.clearFlags():Promise.resolve()).then(function(){return J.validateUser(e)}).then(function(e){return C.setUser(e)}).then(function(){return S.fetchFlagSettings(C.getUser(),n)}).then(function(e){var n=F(e);return e?Z(e).then(function(){return n}):n}).then(function(e){return c&&X(),e}).catch(function(e){return m.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return C.getUser()},variation:function(e,n){return M(e,n,!0,!1).value},variationDetail:function(e,n){return M(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&p.warn(B(e));var r={kind:"custom",key:e,user:C.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),V(r)}else m.maybeReportError(new l(B(e)))},on:function(e,n,t){ie(e)?(d=!0,U&&oe(),m.on(e,n,t)):m.on.apply(m,arguments)},off:function(e){if(m.off.apply(m,arguments),ie(e)){var n=!1;m.getEvents().forEach(function(e){ie(e)&&m.getEventListenerCount(e)>0&&(n=!0)}),n||(d=!1,c&&void 0===D&&W())}},setStreaming:function(e){var n=null===e?void 0:e;n!==D&&(D=n,oe())},flush:function(e){return T(w?E.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!O)return e;for(var n in O)O.hasOwnProperty(n)&&(e[n]=M(n,null,!h.sendEventsOnlyForVariation).value);return e},close:function(e){if(L)return T(Promise.resolve(),e);var n=function(){L=!0,O={}};return T(Promise.resolve().then(function(){if(W(),w)return E.stop(),E.flush()}).then(n).catch(n),e)}},options:h,emitter:m,ident:C,logger:p,requestor:S,start:function(){w&&E.start()},enqueueEvent:V,getFlagsInternal:function(){return O},getEnvironmentId:function(){return b},internalChangeEventName:_e}}var Ve={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function ze(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return Ve;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),Ve;var u=void 0;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}var He=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};var $e=/[|\\{}()[\]^$+*?.]/g,Me=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace($e,"\\$&")};function Ke(e,n,t,r){var o=n.replace(t,"").replace(r,""),i=void 0,a=void 0;switch(e.kind){case"exact":a=n,i=new RegExp("^"+Me(e.url)+"/?$");break;case"canonical":a=o,i=new RegExp("^"+Me(e.url)+"/?$");break;case"substring":a=o,i=new RegExp(".*"+Me(e.substring)+".*$");break;case"regex":a=o,i=new RegExp(e.pattern);break;default:return!1}return i.test(a)}function Ge(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(Ke(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var Xe=300;function Be(e,n){var t=void 0,r=void 0,o={};function i(){r&&r.dispose(),t&&t.length&&(r=Ge(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then(function(e){e&&e.length>0&&(r=Ge(t=e,a),function(e,n){var t=window.location.href,r=void 0;function o(){(r=window.location.href)!==t&&(t=r,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(Xe,i)),n()}).catch(function(t){e.emitter.maybeReportError(new g.LDUnexpectedResponseError((t&&t.message,t.message))),n()}),o}var We="goalsReady",Qe={fetchGoals:!0};function Ye(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n={synchronousFlush:!1};window.XMLHttpRequest&&(n.httpRequest=function(e,t,r,o){var i=n.synchronousFlush;return n.synchronousFlush=!1,ze(e,t,r,o,i)});var t=void 0;n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t};var r=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return r?r(window.location.href):window.location.href},n.isDoNotTrack=function(){var e=void 0;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(n.localStorage={get:function(e){return new Promise(function(n){n(window.localStorage.getItem(e))})},set:function(e,n){return new Promise(function(t){window.localStorage.setItem(e,n),t()})},clear:function(e){return new Promise(function(n){window.localStorage.removeItem(e),n()})}})}catch(e){n.localStorage=null}var o=void 0;e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource&&(n.eventSourceFactory=function(e,n){var t=He({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},n);return new o(e,t)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING});return n.userAgent="JSClient",n}(t),o=Je(e,n,t,r,Qe),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(We,function(){u.off(We,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=Be(o,function(){return u.emit(We)});r.customEventFilter=c.goalKeyExists}else u.emit(We);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch(function(){})};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var Ze=Fe;var en={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(we.deprecated("default export","named LDClient export")),Ye(e,n,t)},version:"2.14.1"};e.initialize=Ye,e.createConsoleLogger=Ze,e.version="2.14.1",e.default=en,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient.min.js.map |
{ | ||
"name": "launchdarkly-js-client-sdk", | ||
"version": "2.14.0", | ||
"version": "2.15.0", | ||
"description": "LaunchDarkly SDK for JavaScript", | ||
@@ -27,4 +27,4 @@ "author": "LaunchDarkly <team@launchdarkly.com>", | ||
"scripts": { | ||
"lint": "eslint --format 'node_modules/eslint-formatter-pretty' --ignore-path ../../.eslintignore", | ||
"lint:all": "eslint --format 'node_modules/eslint-formatter-pretty' --ignore-path ../../.eslintignore src", | ||
"lint": "eslint --format 'node_modules/eslint-formatter-pretty' --ignore-path ./.eslintignore", | ||
"lint:all": "eslint --format 'node_modules/eslint-formatter-pretty' --ignore-path ./.eslintignore src", | ||
"format": "npm run format:md && npm run format:js", | ||
@@ -49,2 +49,4 @@ "format:md": "prettier --parser markdown --ignore-path ../../.prettierignore --write '*.md'", | ||
"babel-polyfill": "6.26.0", | ||
"babel-preset-env": "1.6.1", | ||
"babel-preset-stage-1": "6.24.1", | ||
"chai": "4.1.2", | ||
@@ -65,3 +67,12 @@ "cross-env": "5.1.4", | ||
"rimraf": "2.6.2", | ||
"rollup": "0.57.1", | ||
"rollup": "0.66.6", | ||
"rollup-plugin-babel": "3.0.3", | ||
"rollup-plugin-commonjs": "9.1.0", | ||
"rollup-plugin-filesize": "5.0.1", | ||
"rollup-plugin-includepaths": "0.2.2", | ||
"rollup-plugin-node-builtins": "2.1.2", | ||
"rollup-plugin-node-globals": "1.2.0", | ||
"rollup-plugin-node-resolve": "3.3.0", | ||
"rollup-plugin-replace": "2.0.0", | ||
"rollup-plugin-uglify": "3.0.0", | ||
"semver": "5.5.0", | ||
@@ -74,3 +85,4 @@ "semver-compare": "1.0.0", | ||
"escape-string-regexp": "1.0.5", | ||
"launchdarkly-js-sdk-common": "^2.14.0" | ||
"launchdarkly-js-sdk-common": "2.14.1", | ||
"typedoc": "0.15.0" | ||
}, | ||
@@ -77,0 +89,0 @@ "repository": { |
@@ -1,5 +0,58 @@ | ||
# LaunchDarkly SDK for JavaScript - Main Package | ||
# LaunchDarkly SDK for Browser JavaScript | ||
This file contains the `launchdarkly-js-client-sdk` package, which is the standard interface for the LaunchDarkly SDK for browser JavaScript. It is described in the [main README](https://github.com/launchdarkly/js-client-sdk/blob/master/README.md). | ||
[![Circle CI](https://circleci.com/gh/launchdarkly/js-client-sdk/tree/master.svg?style=svg)](https://circleci.com/gh/launchdarkly/js-client-sdk/tree/master) | ||
This package automatically imports `launchdarkly-js-sdk-common`, which provides much of the underlying implementation. | ||
## LaunchDarkly overview | ||
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/docs/getting-started) using LaunchDarkly today! | ||
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly) | ||
## Getting started | ||
Refer to the [SDK documentation](https://docs.launchdarkly.com/docs/js-sdk-reference#section-getting-started) for instructions on getting started with using the SDK. | ||
Note: _If you are using JavaScript in a non-browser environment,_ please see our [server-side Node.js SDK](https://github.com/launchdarkly/node-server-sdk), [client-side Node.js SDK](https://github.com/launchdarkly/node-client-sdk), and [Electron SDK](https://github.com/launchdarkly/electron-client-sdk). | ||
Please note that the JavaScript SDK has two special requirements in terms of your LaunchDarkly environment. First, in terms of the credentials for your environment that appear on your [Account Settings](https://app.launchdarkly.com/settings/projects) dashboard, the JavaScript SDK uses the "Client-side ID"-- not the "SDK key" or the "Mobile key". Second, for any feature flag that you will be using in JavaScript code, you must check the "Make this flag available to client-side SDKs" box on that flag's Settings page. | ||
### ReactJS | ||
The SDK does not require any particular JavaScript framework. However, if you are using [React](https://reactjs.org/), there is an add-on to simplify use of the SDK. See [`react-client-sdk`](https://github.com/launchdarkly/react-client-sdk). | ||
## Browser compatibility | ||
The LaunchDarkly SDK can be used in all major browsers. However, web browsers vary widely in their support of specific features and standards. Three features that are used by the LaunchDarkly SDK that may not be available on every browser are `Promise`, `EventSource`, and `document.querySelectorAll()`. For more information on whether you may need to use a polyfill to ensure compatibility, and how to do so, see ["JS SDK requirements and polyfills"](https://docs.launchdarkly.com/docs/js-sdk-requirements-and-polyfills). | ||
### Logging | ||
By default, the SDK sends log output to the browser console. There are four logging levels: `debug`, `info`, `warn`, and `error`; by default, `debug` and `info` messages are hidden. See [`LDOptions.logger`](https://launchdarkly.github.io/js-client-sdk/interfaces/_launchdarkly_js_client_sdk_.ldoptions.html#logger) and [`createConsoleLogger`](https://launchdarkly.github.io/js-client-sdk/index.html#createconsolelogger) for more details. | ||
## Learn more | ||
Check out our [documentation](https://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/docs/js-sdk-reference). Additionally, the authoritative full description of all properties, types, and methods is the [online TypeScript documentation](https://launchdarkly.github.io/js-client-sdk/). If you are not using TypeScript, then the types are only for your information and are not enforced, although the properties and methods are still the same as described in the documentation. | ||
For examples of using the SDK in a simple JavaScript application, see [`hello-js`](https://github.com/launchdarkly/hello-js) and [`hello-bootstrap`](https://github.com/launchdarkly/hello-bootstrap). | ||
## Testing | ||
We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly. | ||
## Contributing | ||
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK. | ||
## About LaunchDarkly | ||
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can: | ||
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases. | ||
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?). | ||
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file. | ||
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline. | ||
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list. | ||
* Explore LaunchDarkly | ||
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information | ||
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides | ||
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation | ||
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates | ||
* [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
393726
11
58
3
35
473
+ Addedtypedoc@0.15.0
+ Added@types/minimatch@3.0.3(transitive)
+ Addedbackbone@1.6.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs-extra@8.1.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhandlebars@4.7.8(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhighlight.js@9.18.5(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinterpret@1.4.0(transitive)
+ Addedis-core-module@2.16.1(transitive)
+ Addedjquery@3.7.1(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlunr@2.3.9(transitive)
+ Addedmarked@0.7.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedprogress@2.0.3(transitive)
+ Addedrechoir@0.6.2(transitive)
+ Addedresolve@1.22.10(transitive)
+ Addedshelljs@0.8.5(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtypedoc@0.15.0(transitive)
+ Addedtypedoc-default-themes@0.6.3(transitive)
+ Addedtypescript@3.5.3(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedunderscore@1.13.7(transitive)
+ Addeduniversalify@0.1.2(transitive)
+ Addedwordwrap@1.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)