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

launchdarkly-js-client-sdk

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 2.16.1 to 2.16.2

4

CHANGELOG.md

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

## [2.16.2] - 2020-01-27
### Fixed:
- If the user started to navigate away from the page, but then did not actually do so (for instance, if the application cancelled the `beforeunload` event, or if a nonstandard URL scheme caused the browser to launch an external app), the SDK could be left in a state where all of its HTTP requests would be made synchronously. This has been fixed so the only synchronous request the SDK makes is when it needs to flush events during a `beforeunload`. (Thanks, [edvinerikson](https://github.com/launchdarkly/js-client-sdk/pull/199)!)
## [2.16.1] - 2020-01-15

@@ -7,0 +11,0 @@ **Note:** If you use the Relay Proxy, and have configured it to forward events, please update it to version 5.9.4 or later before using this version of the browser SDK. Otherwise you may encounter CORS errors in the browser.

2

dist/ldclient.cjs.js

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

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc