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