launchdarkly-js-client-sdk 2.20.2 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !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 re(e){return(re="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 oe(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 f(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var ie=t("LaunchDarklyUnexpectedResponseError"),ae=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),ue=t("LaunchDarklyInvalidEventKeyError"),g=t("LaunchDarklyInvalidArgumentError"),se=t("LaunchDarklyFlagFetchError"),ce=t("LaunchDarklyInvalidDataError");function le(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:ie,LDInvalidEnvironmentIdError:ae,LDInvalidUserError:i,LDInvalidEventKeyError:ue,LDInvalidArgumentError:g,LDFlagFetchError:se,LDInvalidDataError:ce,isHttpErrorRecoverable:le}),r=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(d(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=[],a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=a.length;c<l;++c)u[c]=a[c],o[a.charCodeAt(c)]=c;function d(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 v=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function y(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 S(e){return y(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function fe(e){return JSON.parse(JSON.stringify(e))}function de(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=v(n),u=v(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 d=p(n);if((o=d.length)!==p(t).length)return!1;for(r=o;0!=r--;)if(!m.call(t,d[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=d[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function ve(e){setTimeout(e,0)}function ge(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 w(e){var n={};for(var t in e)he(e,t)&&(n[t]={value:e[t],version:0});return n}function pe(e){var n={};for(var t in e)he(e,t)&&(n[t]=e[t].value);return n}function b(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-=S(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function k(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function O(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":k(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function P(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(oe({},e)):e}function me(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return oe({},e,{},n)},{})}function he(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ye(e){if(!e)return e;var n;for(var t in h){var r=h[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||oe({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:y,base64URLEncode:S,clone:fe,deepEquals:de,onNextTick:ve,wrapPromiseCallback:ge,transformValuesToVersionedValues:w,transformVersionedValuesToValues:pe,chunkUserEventsForUrl:b,getLDUserAgentString:k,getLDHeaders:O,transformHeaders:P,extend:me,objectHasOwnProperty:he,sanitizeUser:ye});for(var E,D=(E=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}}}(E={exports:{}}),E.exports),U=[],j=0;j<256;++j)U[j]=(j+256).toString(16).substr(1);var I,R,T=0,L=0,N=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||I,a=void 0!==e.clockseq?e.clockseq:R;if(null==i||null==a){var u=D();null==i&&(i=I=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=R=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:L+1,l=s-T+(c-L)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||T<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");T=s,R=a;var f=(1e4*(268435455&(s+=122192928e5))+(L=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=s/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return n||function(e,n){var t=n||0,r=U;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)};function we(u,e,s){var t="/a/"+e+".gif",c=me({"Content-Type":"application/json"},O(u,s)),l=u.httpFallbackPing,f={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:N();return n?function n(t){var e=o?c:me({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,P(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&le(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+S(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:b(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(f.sendChunk(r[a],n,t,o));return Promise.all(i)}};return f}function be(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=me({},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 C=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",F=function(e){return'Expected application/json content type but got "'+e+'"'},ke=function(e){return"local storage is unavailable: "+x(e)},A=function(e){return"network error"+(e?" ("+e+")":"")},Ee=function(e){return'Custom event "'+e+'" does not exist'},q=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+C},De=function(){return"No environment/client-side ID was specified."+C},Se=function(e){return"Error fetching flag settings: "+x(e)},_=function(){return"No user specified."+C},V=function(){return"Invalid user specified."+C},Oe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+C},z=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+" - "+(le(e)?t:"giving up permanently")},J=function(){return"Cannot make HTTP requests in this environment."+C},M=function(e){return"Opening stream connection to "+e},H=function(e,n){return"Error on stream connection: "+x(e)+", will continue retrying every "+n+" milliseconds."},K=function(e){return'Ignoring unknown config option "'+e+'"'},$=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},B=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},G=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},X=function(e){return"polling for feature flags at "+e},Ue=function(e){return'received streaming update for flag "'+e+'"'},je=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+'"'},Re=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Te=function(e){return'enqueueing "'+e+'" event'},Le=function(e){return"sending "+e+" events"},W=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType:F,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ke,networkError:A,unknownCustomEventKey:Ee,environmentNotFound:q,environmentNotSpecified:De,errorFetchingFlags:Se,userNotSpecified:_,invalidUser:V,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:Oe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:z,httpErrorMessage:Pe,httpUnavailable:J,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:M,streamError:H,unknownOption:K,wrongOptionType:$,wrongOptionTypeBoolean:B,optionBelowMinimum:G,debugPolling:X,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:Ue,debugStreamPatchIgnored:je,debugStreamDelete:Ie,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Te,debugPostingEvents:Le,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Ne=function(r){var n=!1,t=!1,o=null,e=null,i=new Promise(function(n){r.on("ready",function e(){r.off("ready",e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(o):e=new Promise(function(n,t){r.on("initialized",function e(){r.off("initialized",e),n()}),r.on("failed",function e(n){r.off("failed",e),t(n)})}))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,r.emit("initialized"),r.emit("ready"))},signalFailure:function(e){n||t||(t=!0,o=e,r.emit("failed",e),r.emit("ready")),r.maybeReportError(e)}}};function xe(t,r,o,i){var a={};function u(){var e="",n=i.getUser();return n&&(e=o||y(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=w(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=me({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function Ce(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=s+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=O(o,i),g=!1,p=null,m=null,h=null,y=null,w=null;function b(e){g||(c.warn(H(e,t)),g=!0),D(!1),E(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:3e5};if(o.eventSourceFactory){for(var r in null!=y&&(n="h="+y),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(h)):(e=s+"/ping/"+a,n=""):e=l+"/"+S(JSON.stringify(h)),t.headers=P(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),c.info(M(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),w)he(w,r)&&p.addEventListener(r,w[r]);p.onerror=b}}function E(){p&&(c.info("Closing stream connection"),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){h=e,y=n,w={};function r(n){w[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function Fe(v,g,a){var u=g.baseUrl,s=g.useReport,c=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!v.httpRequest)return new Promise(function(e,n){n(new se(J()))});var t=n?"REPORT":"GET",r=O(v,g);n&&(r["Content-Type"]="application/json");var o,i,a,u,s,c,l=p[e];l||(o=function(){delete p[e]},(c={addPromise:function(n,e){i=n,a&&a(),a=e,n.then(function(e){i===n&&(u(e),o())},function(e){i===n&&(s(e),o())})}}).resultPromise=new Promise(function(e,n){u=e,s=n}),l=c,p[e]=l);var f=v.httpRequest(t,e,P(r,g),n),d=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new ae(q()):new se(Se(n.statusText||String(n.status))));if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n,t=F(e.header("content-type")||"");return Promise.reject(new se(t))},function(e){return Promise.reject(new se(A(e)))});return l.addPromise(d,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 s?(r=[u,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=S(JSON.stringify(e)),r=[u,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),c&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,l.debug(X(r)),f(r,o)},e}function Ae(o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(_()));var r=fe(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?o.get("ld:$anonUserId").then(function(e){if(e)return r.key=e,r;var n,t=N();return r.key=t,(n=t,o.set("ld:$anonUserId",n)).then(function(){return r})}):Promise.reject(new i(V()))},e}var Q=["debug","info","warn","error","none"];function Y(e,a){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],s=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Q.length;t++)Q[t]===e.level&&(r=t);for(var o={},i=function(e){var n=Q[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=s?n+": "+c:c;if(1!==t.length&&a){var i=f(t);i[0]=o+i[0],r=a.apply(void 0,f(i))}else r=o+t[0];try{u[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<Q.length;l++)i(l);return o}function qe(e,n){return Y({level:e,prefix:n})}var Z={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function _e(e,n,t,r){var a=me({logger:{default:r}},Z,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){ve(function(){n&&n.maybeReportError(new g(e))})}var i,s,c,l,f,d=me({},e||{});return f=d,Object.keys(o).forEach(function(e){if(void 0!==f[e]){var n=o[e];r&&r.warn(z(e,n)),n&&(void 0===f[n]&&(f[n]=f[e]),delete f[e])}}),i=(l=me({},d),Object.keys(a).forEach(function(e){void 0!==l[e]&&null!==l[e]||(l[e]=a[e]&&a[e].default)}),s=d=l,c=me({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(K(e));else{var r=t.type||v(t.default);if("any"!==r){var o=r.split("|"),i=v(n);o.indexOf(i)<0?"boolean"===r?(c[e]=!!n,u(B(e,i))):(u($(e,r,i)),c[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(G(e,n,t.minimum)),c[e]=t.minimum)}}}}),d=c).logger,Q.forEach(function(e){if("none"!==e&&(!i[e]||"function"!=typeof i[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),d;function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=re(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}}var ee=Object.freeze({__proto__:null,baseOptionDefs:Z,validate:_e}).baseOptionDefs,Ve=function(e){var n={diagnosticId:N()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},ze=function(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}},Je=function(n,r,e,t,o,i,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=oe({},n.diagnosticSdkData);return i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e}(),configuration:(e={customBaseURI:i.baseUrl!==ee.baseUrl.default,customStreamURI:i.streamUrl!==ee.streamUrl.default,customEventsURI:i.eventsUrl!==ee.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},e),platform:n.diagnosticPlatformData};var e}function h(e){i.logger&&i.logger.debug(W.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;h((e=(new Date).getTime(),n=oe({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps()),c&&(n=oe({},n,{},m())),v.reset(e),n)),s=setTimeout(y,d),u=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=oe({},v.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+d,t=(new Date).getTime();n<=t?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,d)}):(h(oe({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},m())),s=setTimeout(y,d))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function ne(e,n,t,i,r){var a,o,u,s,c,l,f,d,v,g=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||qe("warn"),p=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=o[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}(g),m=Ne(p),h=_e(t,p,r,g),y=h.sendEvents,w=e,b=h.hash,k=(l=i.localStorage,f=g,v=!(d={}),d.isEnabled=function(){return!!l},d.get=function(e){return new Promise(function(n){l?l.get(e).then(n).catch(function(e){V(e),n(void 0)}):n(void 0)})},d.set=function(e,t){return new Promise(function(n){l?l.set(e,t).then(function(){return n(!0)}).catch(function(e){V(e),n(!1)}):n(!1)})},d.clear=function(e){return new Promise(function(n){l?l.clear(e).then(function(){return n(!0)}).catch(function(e){V(e),n(!1)}):n(!1)})},d),E=we(i,w,h),D=h.sendEvents&&!h.diagnosticOptOut,S=D?Ve(w):null,O=D?ze((new Date).getTime()):null,P=D?Je(i,k,O,E,w,h,S):null,U=Ce(i,h,w,O),j=h.eventProcessor||function(e,n,t,r,o,i){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==o?o:null,c={},l=(5<arguments.length&&void 0!==i?i:null)||we(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,d=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],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}},e.clearSummary=function(){u=a=0,s={}},e}(),v=be(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,k=!1,E=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function S(e){w.length<m?(w.push(e),E=!1):(E||(E=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!k){var n=!1,t=!1;if(d.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=D(),n&&S(function(e){var n=me({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=me({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,S(r)}}},c.flush=function(){if(k)return Promise.resolve();var e=w,n=d.getSummary();return d.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(Le(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(b=e.serverTime),le(e.status)||(k=!0),400<=e.status&&ve(function(){s.maybeReportError(new ie(Pe(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,h)},h)},c.stop=function(){clearTimeout(a)},c}(i,h,w,O,p,E),I=Fe(i,h,w),R={},T={},L=h.streaming,N=!1,x=!1,C=!0,F=h.stateProvider,A=(s=function(e,n){var t;t=e,F||t&&z({kind:"identify",key:t.key,user:t,creationDate:(new Date).getTime()}),!h.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&$(e,n)},{setUser:function(e){var n=c&&fe(c);(c=ye(e))&&s&&s(fe(c),n)},getUser:function(){return c?fe(c):null}}),q=Ae(k),_=k.isEnabled()?new xe(k,w,b,A,g):null;function V(e){v||(v=!0,f.warn(ke(e)))}function z(e){if(w&&!(F&&F.enqueueEvent&&F.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(C&&(g.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),C=!1));C=!1}!y||x||i.isDoNotTrack()||(g.debug(Te(e.kind)),j.enqueue(e))}}function J(e,n,t,r){var o=A.getUser(),i=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=R[u];if(s&&i-s<3e5)return;R[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=K(o));var l=T[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),z(c)}function M(e,n,t,r){var o;if(T&&he(T,e)&&T[e]&&!T[e].deleted){var i=T[e];o=H(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&J(e,o,n,r),o}function H(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(e){return e.anonymous?"anonymousUser":"user"}function $(e,n){F||e&&n&&z({kind:"alias",key:e.key,contextKind:K(e),previousKey:n.key,previousContextKind:K(n),creationDate:(new Date).getTime()})}function B(){if(o=!0,A.getUser()){var a=function(e){try{return JSON.parse(e)}catch(e){return void p.maybeReportError(new ce("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};U.connect(A.getUser(),b,{ping:function(){g.debug("received ping message from stream");var n=A.getUser();I.fetchFlagSettings(n,b).then(function(e){de(n,A.getUser())&&X(e||{})}).catch(function(e){p.maybeReportError(new se(Se(e)))})},put:function(e){var n=a(e.data);n&&(g.debug("received streaming update for all flags"),X(n))},patch:function(e){var n=a(e.data);if(n){var t=T[n.key];if(!t||!t.version||!n.version||t.version<n.version){g.debug(Ue(n.key));var r={},o=me({},n);delete o.key;var i=H(T[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},W(r)}else g.debug(je(n.key))}},delete:function(e){var n=a(e.data);if(n)if(!T[n.key]||T[n.key].version<n.version){g.debug(Ie(n.key));var t={};T[n.key]&&!T[n.key].deleted&&(t[n.key]={previous:T[n.key].value}),T[n.key]={version:n.version,deleted:!0},W(t)}else g.debug(Re(n.key))}})}}function G(){o&&(U.disconnect(),o=!1)}function X(e){var n={};if(!e)return Promise.resolve();for(var t in T)he(T,t)&&T[t]&&(e[t]&&!de(e[t].value,T[t].value)?n[t]={previous:T[t].value,current:H(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:T[t].value}));for(var r in e)he(e,r)&&e[r]&&(!T[r]||T[r].deleted)&&(n[r]={current:H(e[r])});return T=oe({},e),W(n).catch(function(){})}function W(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;p.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),p.emit("change",i),p.emit("internal-change",T),h.sendEventsOnlyForVariation||F||e.forEach(function(e){J(e,o[e].current)})}return a&&_?_.saveFlags(T):Promise.resolve()}function Q(){var e=L||u&&void 0===L;e&&!o?B():!e&&o&&G(),P&&P.setStreaming(e)}function Y(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(_?a=!0:g.warn(ke())),"object"===re(h.bootstrap)&&(T=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&g.warn(Oe()),!1===t.$valid&&g.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=me(n,r[e]):n.version=0,o[e]=n}}),o}(h.bootstrap)),F){var Z=F.getInitialState();Z?ee(Z):F.on("init",ee),F.on("update",function(e){e.user&&A.setUser(e.user),e.flags&&X(e.flags)})}else(e?q.validateUser(n).then(function(e){return A.setUser(e),"object"===re(h.bootstrap)?ne():a?_.loadFlags().then(function(e){return null==e?(T={},I.fetchFlagSettings(A.getUser(),b).then(function(e){return X(e||{})}).then(ne).catch(function(e){te(new se(Se(e)))})):(T=e,ve(ne),I.fetchFlagSettings(A.getUser(),b).then(function(e){return X(e)}).catch(function(e){return p.maybeReportError(e)}))}):I.fetchFlagSettings(A.getUser(),b).then(function(e){T=e||{},ne()}).catch(function(e){T={},te(e)})}):Promise.reject(new ae(De()))).catch(te);function ee(e){w=e.environment,A.setUser(e.user),T=oe({},e.flags),ve(ne)}function ne(){g.info("LaunchDarkly client initialized"),N=!0,Q(),m.signalSuccess()}function te(e){m.signalFailure(e)}return{client:{waitForInitialization:function(){return m.getInitializationPromise()},waitUntilReady:function(){return m.getReadyPromise()},identify:function(e,r,n){return x?ge(Promise.resolve({}),n):F?(g.warn("identify() has no effect here; it must be called on the main client instance"),ge(Promise.resolve(pe(T)),n)):ge((a&&_?_.clearFlags():Promise.resolve()).then(function(){return q.validateUser(e)}).then(function(t){return I.fetchFlagSettings(t,r).then(function(e){var n=pe(e);return A.setUser(t),b=r,e?X(e).then(function(){return n}):n})}).then(function(e){return o&&B(),e}).catch(function(e){return p.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return A.getUser()},variation:function(e,n){return M(e,n,!0,!1).value},variationDetail:function(e,n){return M(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&g.warn(Ee(e));var r=A.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=K(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),z(o)}else p.maybeReportError(new ue(Ee(e)))},alias:$,on:function(e,n,t){Y(e)?(u=!0,N&&Q(),p.on(e,n,t)):p.on.apply(p,arguments)},off:function(e){if(p.off.apply(p,arguments),Y(e)){var n=!1;p.getEvents().forEach(function(e){Y(e)&&0<p.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,o&&void 0===L&&G())}},setStreaming:function(e){var n=null===e?void 0:e;n!==L&&(L=n,Q())},flush:function(e){return ge(y?j.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!T)return e;for(var n in T)he(T,n)&&(e[n]=M(n,null,!h.sendEventsOnlyForVariation).value);return e},close:function(e){if(x)return ge(Promise.resolve(),e);function n(){x=!0,T={}}return ge(Promise.resolve().then(function(){if(G(),P&&P.stop(),y)return j.stop(),j.flush()}).then(n).catch(n),e)}},options:h,emitter:p,ident:A,logger:g,requestor:I,start:function(){y&&(P&&P.start(),j.start())},enqueueEvent:z,getFlagsInternal:function(){return T},getEnvironmentId:function(){return w},internalChangeEventName:"internal-change"}}function te(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 Me(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?te(Object(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)):te(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var He={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ke(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return He;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),He;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 $e=/[|\\{}()[\]^$+*?.]/g,Be=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace($e,"\\$&")};function Ge(e,n,t,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Be(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Be(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Be(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Xe(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(Ge(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=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 s=0;s<u.length;s++)o===u[s]&&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 We=300;function Qe(o,n){var t,r;function i(){r&&r.dispose(),t&&t.length&&(r=Xe(t,a))}function a(e,n){var t=o.ident.getUser(),r={kind:e,key:n.key,data:null,url:window.location.href,user:t,creationDate:(new Date).getTime()};return t&&t.anonymous&&(r.contextKind="anonymousUser"),"click"===e&&(r.selector=n.selector),o.enqueueEvent(r)}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 o.requestor.fetchJSON("/sdk/goals/"+o.getEnvironmentId()).then(function(e){e&&0<e.length&&(r=Xe(t=e,a),u(We,i)),n()}).catch(function(e){o.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),{}}var Ye="goalsReady",Ze={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function en(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n,i={synchronousFlush:!1};if(window.XMLHttpRequest){var a=e&&e.disableSyncEventPost;i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush&!a;return i.synchronousFlush=!1,Ke(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=Me(Me({},{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.version="2.20.2",i.diagnosticSdkData={name:"js-client-sdk",version:"2.20.2"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}(t),o=ne(e,n,t,r,Ze),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(Ye,function(){u.off(Ye,n),e()})});i.waitUntilGoalsReady=function(){return s},a.fetchGoals?Qe(o,function(){return u.emit(Ye)}):u.emit(Ye),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function c(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",c),window.addEventListener("unload",c),i}var nn=qe;var tn={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(W.deprecated("default export","named LDClient export")),en(e,n,t)},version:"2.20.2"};e.createConsoleLogger=nn,e.default=tn,e.initialize=en,e.version="2.20.2",Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !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 re(e){return(re="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 oe(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 f(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var ie=t("LaunchDarklyUnexpectedResponseError"),ae=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),ue=t("LaunchDarklyInvalidEventKeyError"),g=t("LaunchDarklyInvalidArgumentError"),se=t("LaunchDarklyFlagFetchError"),ce=t("LaunchDarklyInvalidDataError");function le(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:ie,LDInvalidEnvironmentIdError:ae,LDInvalidUserError:i,LDInvalidEventKeyError:ue,LDInvalidArgumentError:g,LDFlagFetchError:se,LDInvalidDataError:ce,isHttpErrorRecoverable:le}),r=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(d(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=[],a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=a.length;c<l;++c)u[c]=a[c],o[a.charCodeAt(c)]=c;function d(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 v=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function y(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 O(e){return y(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function fe(e){return JSON.parse(JSON.stringify(e))}function de(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=v(n),u=v(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 d=p(n);if((o=d.length)!==p(t).length)return!1;for(r=o;0!=r--;)if(!m.call(t,d[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=d[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function ve(e){setTimeout(e,0)}function ge(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 w(e){var n={};for(var t in e)he(e,t)&&(n[t]={value:e[t],version:0});return n}function pe(e){var n={};for(var t in e)he(e,t)&&(n[t]=e[t].value);return n}function b(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=O(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function k(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function S(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":k(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function P(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(oe({},e)):e}function me(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return oe({},e,{},n)},{})}function he(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ye(e){if(!e)return e;var n;for(var t in h){var r=h[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||oe({},e))[r]=String(o))}return n||e}for(var E,D=Object.freeze({__proto__:null,btoa:y,base64URLEncode:O,clone:fe,deepEquals:de,onNextTick:ve,wrapPromiseCallback:ge,transformValuesToVersionedValues:w,transformVersionedValuesToValues:pe,chunkUserEventsForUrl:b,getLDUserAgentString:k,getLDHeaders:S,transformHeaders:P,extend:me,objectHasOwnProperty:he,sanitizeUser:ye}),U=(E=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}}}(E={exports:{}}),E.exports),j=[],I=0;I<256;++I)j[I]=(I+256).toString(16).substr(1);var R,T,L=0,N=0,x=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||R,a=void 0!==e.clockseq?e.clockseq:T;if(null==i||null==a){var u=U();null==i&&(i=R=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=T=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:N+1,l=s-L+(c-N)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||L<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");L=s,T=a;var f=(1e4*(268435455&(s+=122192928e5))+(N=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=s/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];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)};function we(u,e,s){var t="/a/"+e+".gif",c=me({"Content-Type":"application/json"},S(u,s)),l=u.httpFallbackPing,f={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:x();return n?function n(t){var e=o?c:me({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,P(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&le(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+O(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:b(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(f.sendChunk(r[a],n,t,o));return Promise.all(i)}};return f}function be(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=me({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function C(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var F=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",A=function(e){return'Expected application/json content type but got "'+e+'"'},ke=function(e){return"local storage is unavailable: "+C(e)},q=function(e){return"network error"+(e?" ("+e+")":"")},Ee=function(e){return'Custom event "'+e+'" does not exist'},_=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+F},De=function(){return"No environment/client-side ID was specified."+F},Oe=function(e){return"Error fetching flag settings: "+C(e)},V=function(){return"No user specified."+F},z=function(){return"Invalid user specified."+F},Se=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+F},J=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+" - "+(le(e)?t:"giving up permanently")},M=function(){return"Cannot make HTTP requests in this environment."+F},H=function(e){return"Opening stream connection to "+e},K=function(e,n){return"Error on stream connection: "+C(e)+", will continue retrying every "+n+" milliseconds."},$=function(e){return'Ignoring unknown config option "'+e+'"'},B=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},G=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},X=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},W=function(e){return"polling for feature flags at "+e},Ue=function(e){return'received streaming update for flag "'+e+'"'},je=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+'"'},Re=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Te=function(e){return'enqueueing "'+e+'" event'},Le=function(e){return"sending "+e+" events"},Q=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType:A,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ke,networkError:q,unknownCustomEventKey:Ee,environmentNotFound:_,environmentNotSpecified:De,errorFetchingFlags:Oe,userNotSpecified:V,invalidUser:z,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:Se,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:J,httpErrorMessage:Pe,httpUnavailable:M,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:H,streamError:K,unknownOption:$,wrongOptionType:B,wrongOptionTypeBoolean:G,optionBelowMinimum:X,debugPolling:W,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:Ue,debugStreamPatchIgnored:je,debugStreamDelete:Ie,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Te,debugPostingEvents:Le,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Ne=function(r){var n=!1,t=!1,o=null,e=null,i=new Promise(function(n){r.on("ready",function e(){r.off("ready",e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(o):e=new Promise(function(n,t){r.on("initialized",function e(){r.off("initialized",e),n()}),r.on("failed",function e(n){r.off("failed",e),t(n)})}))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,r.emit("initialized"),r.emit("ready"))},signalFailure:function(e){n||t||(t=!0,o=e,r.emit("failed",e),r.emit("ready")),r.maybeReportError(e)}}};function xe(t,r,o,i){var a={};function u(){var e="",n=i.getUser();return n&&(e=o||y(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=w(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=me({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function Ce(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=s+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=S(o,i),g=!1,p=null,m=null,h=null,y=null,w=null;function b(e){g||(c.warn(K(e,t)),g=!0),D(!1),E(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:3e5};if(o.eventSourceFactory){for(var r in null!=y&&(n="h="+y),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(h)):(e=s+"/ping/"+a,n=""):e=l+"/"+O(JSON.stringify(h)),t.headers=P(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),c.info(H(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),w)he(w,r)&&p.addEventListener(r,w[r]);p.onerror=b}}function E(){p&&(c.info("Closing stream connection"),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){h=e,y=n,w={};function r(n){w[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function Fe(v,g,a){var u=g.baseUrl,s=g.useReport,c=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!v.httpRequest)return new Promise(function(e,n){n(new se(M()))});var t=n?"REPORT":"GET",r=S(v,g);n&&(r["Content-Type"]="application/json");var o,i,a,u,s,c,l=p[e];l||(o=function(){delete p[e]},(c={addPromise:function(n,e){i=n,a&&a(),a=e,n.then(function(e){i===n&&(u(e),o())},function(e){i===n&&(s(e),o())})}}).resultPromise=new Promise(function(e,n){u=e,s=n}),l=c,p[e]=l);var f=v.httpRequest(t,e,P(r,g),n),d=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new ae(_()):new se(Oe(n.statusText||String(n.status))));if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n,t=A(e.header("content-type")||"");return Promise.reject(new se(t))},function(e){return Promise.reject(new se(q(e)))});return l.addPromise(d,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 s?(r=[u,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=O(JSON.stringify(e)),r=[u,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),c&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,l.debug(W(r)),f(r,o)},e}function Ae(o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(V()));var r=fe(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?o.get("ld:$anonUserId").then(function(e){if(e)return r.key=e,r;var n,t=x();return r.key=t,(n=t,o.set("ld:$anonUserId",n)).then(function(){return r})}):Promise.reject(new i(z()))},e}var Y=["debug","info","warn","error","none"];function Z(e,a){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],s=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Y.length;t++)Y[t]===e.level&&(r=t);for(var o={},i=function(e){var n=Y[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=s?n+": "+c:c;if(1!==t.length&&a){var i=f(t);i[0]=o+i[0],r=a.apply(void 0,f(i))}else r=o+t[0];try{u[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<Y.length;l++)i(l);return o}function qe(e,n){return Z({level:e,prefix:n})}var ee={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function _e(e,n,t,r){var a=me({logger:{default:r}},ee,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){ve(function(){n&&n.maybeReportError(new g(e))})}var i,s,c,l,f,d=me({},e||{});return f=d,Object.keys(o).forEach(function(e){if(void 0!==f[e]){var n=o[e];r&&r.warn(J(e,n)),n&&(void 0===f[n]&&(f[n]=f[e]),delete f[e])}}),i=(l=me({},d),Object.keys(a).forEach(function(e){void 0!==l[e]&&null!==l[e]||(l[e]=a[e]&&a[e].default)}),s=d=l,c=me({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u($(e));else{var r=t.type||v(t.default);if("any"!==r){var o=r.split("|"),i=v(n);o.indexOf(i)<0?"boolean"===r?(c[e]=!!n,u(G(e,i))):(u(B(e,r,i)),c[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(X(e,n,t.minimum)),c[e]=t.minimum)}}}}),d=c).logger,Y.forEach(function(e){if("none"!==e&&(!i[e]||"function"!=typeof i[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),d;function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=re(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}}var ne=Object.freeze({__proto__:null,baseOptionDefs:ee,validate:_e}).baseOptionDefs,Ve=function(e){var n={diagnosticId:x()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},ze=function(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}},Je=function(n,r,e,t,o,i,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=oe({},n.diagnosticSdkData);return i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e}(),configuration:(e={customBaseURI:i.baseUrl!==ne.baseUrl.default,customStreamURI:i.streamUrl!==ne.streamUrl.default,customEventsURI:i.eventsUrl!==ne.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},e),platform:n.diagnosticPlatformData};var e}function h(e){i.logger&&i.logger.debug(Q.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;h((e=(new Date).getTime(),n=oe({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps()),c&&(n=oe({},n,{},m())),v.reset(e),n)),s=setTimeout(y,d),u=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=oe({},v.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+d,t=(new Date).getTime();n<=t?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,d)}):(h(oe({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},m())),s=setTimeout(y,d))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function te(e,n,t,i,r){var a,o,u,s,c,l,f,d,v,g=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||qe("warn"),p=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=o[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}(g),m=Ne(p),h=_e(t,p,r,g),y=h.sendEvents,w=e,b=h.hash,k=(l=i.localStorage,f=g,v=!(d={}),d.isEnabled=function(){return!!l},d.get=function(e){return new Promise(function(n){l?l.get(e).then(n).catch(function(e){V(e),n(void 0)}):n(void 0)})},d.set=function(e,t){return new Promise(function(n){l?l.set(e,t).then(function(){return n(!0)}).catch(function(e){V(e),n(!1)}):n(!1)})},d.clear=function(e){return new Promise(function(n){l?l.clear(e).then(function(){return n(!0)}).catch(function(e){V(e),n(!1)}):n(!1)})},d),E=we(i,w,h),D=h.sendEvents&&!h.diagnosticOptOut,O=D?Ve(w):null,S=D?ze((new Date).getTime()):null,P=D?Je(i,k,S,E,w,h,O):null,U=Ce(i,h,w,S),j=h.eventProcessor||function(e,n,t,r,o,i){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==o?o:null,c={},l=(5<arguments.length&&void 0!==i?i:null)||we(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,d=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],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}},e.clearSummary=function(){u=a=0,s={}},e}(),v=be(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,k=!1,E=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function O(e){w.length<m?(w.push(e),E=!1):(E||(E=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!k){var n=!1,t=!1;if(d.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=D(),n&&O(function(e){var n=me({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=me({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,O(r)}}},c.flush=function(){if(k)return Promise.resolve();var e=w,n=d.getSummary();return d.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(Le(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(b=e.serverTime),le(e.status)||(k=!0),400<=e.status&&ve(function(){s.maybeReportError(new ie(Pe(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,h)},h)},c.stop=function(){clearTimeout(a)},c}(i,h,w,S,p,E),I=Fe(i,h,w),R={},T={},L=h.streaming,N=!1,x=!1,C=!0,F=h.stateProvider,A=(s=function(e,n){var t;t=e,F||t&&z({kind:"identify",key:t.key,user:t,creationDate:(new Date).getTime()}),!h.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&$(e,n)},{setUser:function(e){var n=c&&fe(c);(c=ye(e))&&s&&s(fe(c),n)},getUser:function(){return c?fe(c):null}}),q=Ae(k),_=k.isEnabled()?new xe(k,w,b,A,g):null;function V(e){v||(v=!0,f.warn(ke(e)))}function z(e){if(w&&!(F&&F.enqueueEvent&&F.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(C&&(g.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),C=!1));C=!1}!y||x||i.isDoNotTrack()||(g.debug(Te(e.kind)),j.enqueue(e))}}function J(e,n,t,r){var o=A.getUser(),i=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=R[u];if(s&&i-s<3e5)return;R[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=K(o));var l=T[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),z(c)}function M(e,n,t,r){var o;if(T&&he(T,e)&&T[e]&&!T[e].deleted){var i=T[e];o=H(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&J(e,o,n,r),o}function H(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(e){return e.anonymous?"anonymousUser":"user"}function $(e,n){F||e&&n&&z({kind:"alias",key:e.key,contextKind:K(e),previousKey:n.key,previousContextKind:K(n),creationDate:(new Date).getTime()})}function B(){if(o=!0,A.getUser()){var a=function(e){try{return JSON.parse(e)}catch(e){return void p.maybeReportError(new ce("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};U.connect(A.getUser(),b,{ping:function(){g.debug("received ping message from stream");var n=A.getUser();I.fetchFlagSettings(n,b).then(function(e){de(n,A.getUser())&&X(e||{})}).catch(function(e){p.maybeReportError(new se(Oe(e)))})},put:function(e){var n=a(e.data);n&&(g.debug("received streaming update for all flags"),X(n))},patch:function(e){var n=a(e.data);if(n){var t=T[n.key];if(!t||!t.version||!n.version||t.version<n.version){g.debug(Ue(n.key));var r={},o=me({},n);delete o.key;var i=H(T[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},W(r)}else g.debug(je(n.key))}},delete:function(e){var n=a(e.data);if(n)if(!T[n.key]||T[n.key].version<n.version){g.debug(Ie(n.key));var t={};T[n.key]&&!T[n.key].deleted&&(t[n.key]={previous:T[n.key].value}),T[n.key]={version:n.version,deleted:!0},W(t)}else g.debug(Re(n.key))}})}}function G(){o&&(U.disconnect(),o=!1)}function X(e){var n={};if(!e)return Promise.resolve();for(var t in T)he(T,t)&&T[t]&&(e[t]&&!de(e[t].value,T[t].value)?n[t]={previous:T[t].value,current:H(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:T[t].value}));for(var r in e)he(e,r)&&e[r]&&(!T[r]||T[r].deleted)&&(n[r]={current:H(e[r])});return T=oe({},e),W(n).catch(function(){})}function W(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;p.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),p.emit("change",i),p.emit("internal-change",T),h.sendEventsOnlyForVariation||F||e.forEach(function(e){J(e,o[e].current)})}return a&&_?_.saveFlags(T):Promise.resolve()}function Q(){var e=L||u&&void 0===L;e&&!o?B():!e&&o&&G(),P&&P.setStreaming(e)}function Y(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(_?a=!0:g.warn(ke())),"object"===re(h.bootstrap)&&(T=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&g.warn(Se()),!1===t.$valid&&g.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=me(n,r[e]):n.version=0,o[e]=n}}),o}(h.bootstrap)),F){var Z=F.getInitialState();Z?ee(Z):F.on("init",ee),F.on("update",function(e){e.user&&A.setUser(e.user),e.flags&&X(e.flags)})}else(e?q.validateUser(n).then(function(e){return A.setUser(e),"object"===re(h.bootstrap)?ne():a?_.loadFlags().then(function(e){return null==e?(T={},I.fetchFlagSettings(A.getUser(),b).then(function(e){return X(e||{})}).then(ne).catch(function(e){te(new se(Oe(e)))})):(T=e,ve(ne),I.fetchFlagSettings(A.getUser(),b).then(function(e){return X(e)}).catch(function(e){return p.maybeReportError(e)}))}):I.fetchFlagSettings(A.getUser(),b).then(function(e){T=e||{},ne()}).catch(function(e){T={},te(e)})}):Promise.reject(new ae(De()))).catch(te);function ee(e){w=e.environment,A.setUser(e.user),T=oe({},e.flags),ve(ne)}function ne(){g.info("LaunchDarkly client initialized"),N=!0,Q(),m.signalSuccess()}function te(e){m.signalFailure(e)}return{client:{waitForInitialization:function(){return m.getInitializationPromise()},waitUntilReady:function(){return m.getReadyPromise()},identify:function(e,r,n){return x?ge(Promise.resolve({}),n):F?(g.warn("identify() has no effect here; it must be called on the main client instance"),ge(Promise.resolve(pe(T)),n)):ge((a&&_?_.clearFlags():Promise.resolve()).then(function(){return q.validateUser(e)}).then(function(t){return I.fetchFlagSettings(t,r).then(function(e){var n=pe(e);return A.setUser(t),b=r,e?X(e).then(function(){return n}):n})}).then(function(e){return o&&B(),e}).catch(function(e){return p.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return A.getUser()},variation:function(e,n){return M(e,n,!0,!1).value},variationDetail:function(e,n){return M(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&g.warn(Ee(e));var r=A.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=K(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),z(o)}else p.maybeReportError(new ue(Ee(e)))},alias:$,on:function(e,n,t){Y(e)?(u=!0,N&&Q(),p.on(e,n,t)):p.on.apply(p,arguments)},off:function(e){if(p.off.apply(p,arguments),Y(e)){var n=!1;p.getEvents().forEach(function(e){Y(e)&&0<p.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,o&&void 0===L&&G())}},setStreaming:function(e){var n=null===e?void 0:e;n!==L&&(L=n,Q())},flush:function(e){return ge(y?j.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!T)return e;for(var n in T)he(T,n)&&(e[n]=M(n,null,!h.sendEventsOnlyForVariation).value);return e},close:function(e){if(x)return ge(Promise.resolve(),e);function n(){x=!0,T={}}return ge(Promise.resolve().then(function(){if(G(),P&&P.stop(),y)return j.stop(),j.flush()}).then(n).catch(n),e)}},options:h,emitter:p,ident:A,logger:g,requestor:I,start:function(){y&&(P&&P.start(),j.start())},enqueueEvent:z,getFlagsInternal:function(){return T},getEnvironmentId:function(){return w},internalChangeEventName:"internal-change"}}function Me(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 He(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Me(Object(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)):Me(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var Ke=Object.freeze({__proto__:null,commonBasicLogger:Z,createConsoleLogger:qe,errors:s,initialize:te,messages:Q,utils:D,version:"3.5.1"}).commonBasicLogger;function $e(e){return Ke(He({destination:console.log},e))}var Be={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ge(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 Be;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),Be;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 Xe=/[|\\{}()[\]^$+*?.]/g,We=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Xe,"\\$&")};function Qe(e,n,t,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+We(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+We(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+We(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Ye(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(Qe(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=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 s=0;s<u.length;s++)o===u[s]&&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 Ze=300;function en(o,n){var t,r;function i(){r&&r.dispose(),t&&t.length&&(r=Ye(t,a))}function a(e,n){var t=o.ident.getUser(),r={kind:e,key:n.key,data:null,url:window.location.href,user:t,creationDate:(new Date).getTime()};return t&&t.anonymous&&(r.contextKind="anonymousUser"),"click"===e&&(r.selector=n.selector),o.enqueueEvent(r)}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 o.requestor.fetchJSON("/sdk/goals/"+o.getEnvironmentId()).then(function(e){e&&0<e.length&&(r=Ye(t=e,a),u(Ze,i)),n()}).catch(function(e){o.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),{}}var nn="goalsReady",tn={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function rn(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n,i={synchronousFlush:!1};if(window.XMLHttpRequest){var a=e&&e.disableSyncEventPost;i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush&!a;return i.synchronousFlush=!1,Ge(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=He(He({},{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.version="2.21.0",i.diagnosticSdkData={name:"js-client-sdk",version:"2.21.0"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}(t),o=te(e,n,t,r,tn),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(nn,function(){u.off(nn,n),e()})});i.waitUntilGoalsReady=function(){return s},a.fetchGoals?en(o,function(){return u.emit(nn)}):u.emit(nn),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function c(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",c),window.addEventListener("unload",c),i}var on=$e,an=qe;var un={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Q.deprecated("default export","named LDClient export")),rn(e,n,t)},version:"2.21.0"};e.basicLogger=on,e.createConsoleLogger=an,e.default=un,e.initialize=rn,e.version="2.21.0",Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=ldclient.min.js.map