launchdarkly-js-client-sdk
Advanced tools
Comparing version 2.18.0 to 2.18.1
@@ -5,2 +5,6 @@ # Change log | ||
## [2.18.1] - 2020-09-14 | ||
### Fixed: | ||
- In streaming mode, when connecting to the Relay Proxy rather than directly to the LaunchDarkly streaming service, if the current user was changed twice within a short time it was possible for the SDK to revert to flag values from the previous user. | ||
## [2.18.0] - 2020-07-16 | ||
@@ -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){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 o=i("LaunchDarklyUnexpectedResponseError"),a=i("LaunchDarklyInvalidEnvironmentIdError"),u=i("LaunchDarklyInvalidUserError"),s=i("LaunchDarklyInvalidEventKeyError"),c=i("LaunchDarklyInvalidArgumentError"),l=i("LaunchDarklyFlagFetchError");function f(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:o,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=m.length;h<y;++h)g[h]=m[h],p[m.charCodeAt(h)]=h;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function O(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=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function I(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 R(e){var n={};for(var t in e)A(e,t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)A(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-=P(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function F(e){var n=e.version||"3.2.9";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":F(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return r({},e,{},n)},{})}function A(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function x(e){if(!e)return e;var n;for(var t in D){var o=D[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}for(var V=Object.freeze({__proto__:null,btoa:S,base64URLEncode:P,clone:O,deepEquals:U,onNextTick:I,wrapPromiseCallback:j,transformValuesToVersionedValues:R,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:F,getLDHeaders:C,extend:L,objectHasOwnProperty:A,sanitizeUser:x}),q=function(e,n){return function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(n={exports:{}}),n.exports}(),_=[],J=0;J<256;++J)_[J]=(J+256).toString(16).substr(1);var z,M,B=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("")},K=0,$=0,H=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=q();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:$+1,l=s-K+(c-$)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||K<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");K=s,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 v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||B(o)};function G(u,e,n){var t="/a/"+e+".gif",s=L({"Content-Type":"application/json"},C(u,n)),c=u.httpFallbackPing,l={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:H();return n?function n(t){var e=o?s:L({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&f(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(c&&c(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]:N(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],n,t,o));return Promise.all(i)}};return l}function X(){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 W(e){var n={},s=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(o,i){return Object.keys(o).reduce(function(e,n){var t,r=e;return i(n)&&(l[t=n]||!s&&-1===a.indexOf(t)&&-1===c.indexOf(t)?r[0][n]=o[n]:r[1][n]=!0),r},[{},{}])}var a=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var i=n(e.custom,function(){return!0});r.custom=i[0],o=L({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function Q(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var Y=function(){return"LaunchDarkly client initialized"},Z=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",ee=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ne=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},te=function(e){return'Expected application/json content type but got "'+e+'"'},re=function(){return"localStorage is unavailable"},ie=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},oe=function(e){return"network error"+(e?" ("+e+")":"")},ae=function(e){return'Custom event "'+e+'" does not exist'},ue=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+Z},se=function(){return"No environment/client-side ID was specified."+Z},ce=function(e){return"Error fetching flag settings: "+Q(e)},le=function(){return"No user specified."+Z},fe=function(){return"Invalid user specified."+Z},ve=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+Z},de=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ge=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},pe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},me=function(){return"Cannot make HTTP requests in this environment."+Z},he=function(){return"identify() has no effect here; it must be called on the main client instance"},ye=function(){return"Closing stream connection"},be=function(e){return"Opening stream connection to "+e},ke=function(e,n){return"Error on stream connection: "+Q(e)+", will continue retrying every "+n+" milliseconds."},Ee=function(e){return'Ignoring unknown config option "'+e+'"'},we=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},De=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},Oe=function(){return"received ping message from stream"},Ue=function(){return"received streaming update for all flags"},Ie=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'},Re=function(e){return'received streaming deletion for flag "'+e+'"'},Te=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ne=function(e){return'enqueueing "'+e+'" event'},Fe=function(e){return"sending "+e+" events"},Ce=Object.freeze({__proto__:null,clientInitialized:Y,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:ee,eventWithoutUser:ne,invalidContentType:te,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:re,localStorageUnavailableForUserId:ie,networkError:oe,unknownCustomEventKey:ae,environmentNotFound:ue,environmentNotSpecified:se,errorFetchingFlags:ce,userNotSpecified:le,invalidUser:fe,bootstrapOldFormat:ve,bootstrapInvalid:de,deprecated:ge,httpErrorMessage:pe,httpUnavailable:me,identifyDisabled:he,streamClosing:ye,streamConnecting:be,streamError:ke,unknownOption:Ee,wrongOptionType:we,wrongOptionTypeBoolean:De,optionBelowMinimum:Se,debugPolling:Pe,debugStreamPing:Oe,debugStreamPut:Ue,debugStreamPatch:Ie,debugStreamPatchIgnored:je,debugStreamDelete:Re,debugStreamDeleteIgnored:Te,debugEnqueueingEvent:Ne,debugPostingEvents:Fe,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 Ae=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,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||S(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=R(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.saveFlags=function(e){var n=L({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u}function Ve(o,e,i,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=C(o,e),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(s.warn(ke(e,r)),d=!0),S(!1),E(),b(r)}function b(e){p||(e?p=setTimeout(k,e):k())}function k(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),l?o.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(m)):(e=u+"/ping/"+i,n=""):e=c+"/"+P(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),s.info(be(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,t),y)A(y,r)&&g.addEventListener(r,y[r]);g.onerror=w}}function E(){g&&(s.info("Closing stream connection"),g.close(),g=null)}function S(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){m=e,h=n,y={};function r(n){y[n]=function(e){S(!(d=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);b()},t.disconnect=function(){clearTimeout(p),p=null,E()},t.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},t}function qe(p,m,u){var s=m.baseUrl,c=m.useReport,f=m.evaluationReasons,v=m.logger,e={},h={};function d(e,n){if(!p.httpRequest)return new Promise(function(e,n){n(new l(me()))});var t=n?"REPORT":"GET",r=C(p,m);n&&(r["Content-Type"]="application/json");var o,i,u,s,c,f,v=h[e];v||(o=function(){delete h[e]},(f={addPromise:function(n,e){i=n,u&&u(),u=e,n.then(function(e){i===n&&(s(e),o())},function(e){i===n&&(c(e),o())})}}).resultPromise=new Promise(function(e,n){s=e,c=n}),v=f,h[e]=v);var d=p.httpRequest(t,e,r,n),g=d.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new a(ue()):new l(ce(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=te(e.header("content-type")||"");return Promise.reject(new l(t))},function(e){return Promise.reject(new l(oe(e)))});return v.addPromise(g,function(){d.cancel&&d.cancel()}),v.resultPromise}return e.fetchJSON=function(e){return d(s+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[s,"/sdk/evalx/",u,"/user"].join(""),o=JSON.stringify(e)):(t=P(JSON.stringify(e)),r=[s,"/sdk/evalx/",u,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(Pe(r)),d(r,o)},e}function _e(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new u(le()));var r=O(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get("ld:$anonUserId").catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=H();return r.key=t,(n=t,o?o.set("ld:$anonUserId",n).catch(function(){i.warn("localStorage is unavailable, so anonymous user ID cannot be cached")}):Promise.resolve()).then(function(){return r})}):Promise.reject(new u(fe()))},e}var Je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function ze(n,t,r,o){var a=L({logger:{default:o}},Je,r),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){I(function(){t&&t.maybeReportError(new c(e))})}var s,l,f,v,d=L({},n||{});return v=d,Object.keys(i).forEach(function(e){if(void 0!==v[e]){var n=i[e];o&&o.warn(ge(e,n)),n&&(void 0===v[n]&&(v[n]=v[e]),delete v[e])}}),f=L({},d),Object.keys(a).forEach(function(e){void 0!==f[e]&&null!==f[e]||(f[e]=a[e]&&a[e].default)}),s=d=f,l=L({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(Ee(e));else{var r=t.type||g(t.default);if("any"!==r){var o=r.split("|"),i=g(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,u(De(e,i))):(u(we(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(Se(e,n,t.minimum)),l[e]=t.minimum)}}}}),l;function g(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 Me=Object.freeze({__proto__:null,baseOptionDefs:Je,validate:ze}).baseOptionDefs,Be=function(e){var n={diagnosticId:H()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Ke=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}},$e=function(o,e,n,t,i,a){var u,s,c=!!o.diagnosticUseCombinedEvent,l="ld:"+t+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+t,v=i.diagnosticRecordingInterval,d=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=r({},o.diagnosticSdkData);return i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e}(),configuration:(e={customBaseURI:i.baseUrl!==Me.baseUrl.default,customStreamURI:i.streamUrl!==Me.streamUrl.default,customEventsURI:i.eventsUrl!==Me.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},e),platform:o.diagnosticPlatformData};var e}function h(e){i.logger&&i.logger.debug(Ce.debugPostingDiagnosticEvent(e)),n.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;h((e=(new Date).getTime(),n=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},d.getProps()),c&&(n=r({},n,{},m())),d.reset(e),n)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(o.localStorage){var e=r({},d.getProps());o.localStorage.set(l,JSON.stringify(e),function(){})}}()}return p.start=function(){c?function(t){if(!o.localStorage)return t(!1);o.localStorage.get(l).then(function(e){if(e)try{var n=JSON.parse(e);d.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();n<=t?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)}):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(y,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function He(e,n){var i,a=["debug","info","warn","error"];i=null!=n?""===n?"":n+" ":"LD: ";var u=0;e&&(u="none"===e?100:a.indexOf(e));var t={};function r(e,n,t){if(u<=e&&console){var r=console[n];if(r){var o=e<a.length?a[e]:"?";r.call(console,i+"["+o+"] "+t)}}}return t.debug=function(e){return r(0,"log",e)},t.info=function(e){return r(1,"info",e)},t.warn=function(e){return r(2,"warn",e)},t.error=function(e){return r(3,"error",e)},t}function Ge(n,t,i,u,c){var v,d,g,p,m,h,y=i&&i.logger?i.logger:c&&c.logger&&c.logger.default||He("warn"),w=Le(y),b=Ae(w),k=ze(i,w,c,y),E=k.sendEvents,S=n,P=k.hash,D=G(u,S,k),R=k.sendEvents&&!k.diagnosticOptOut,N=R?Be(S):null,C=R?Ke((new Date).getTime()):null,F=R?$e(u,C,D,S,k,N):null,q=Ve(u,k,S,C),_=k.eventProcessor||function(e,n,t,r,i,a){var u,s=3<arguments.length&&void 0!==r?r:null,c=4<arguments.length&&void 0!==i?i:null,l={},v=(5<arguments.length&&void 0!==a?a:null)||G(e,t,n),d=n.eventsUrl+"/events/bulk/"+t,g=X(),p=W(n),m=n.inlineUsersInEvents,h=n.samplingInterval,y=n.eventCapacity,w=n.flushInterval,b=n.logger,k=[],E=0,S=!1,P=!1;function D(){return 0===h||0===Math.floor(Math.random()*h)}function O(e){k.length<y?(k.push(e),P=!1):(P||(P=!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?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>E&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=D(),n&&O(function(e){var n=L({},e);return m||"identify"===e.kind?n.user=p.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=L({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(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(Fe(e.length)),v.sendEvents(e,d).then(function(e){e&&(e.serverTime&&(E=e.serverTime),f(e.status)||(S=!0),400<=e.status&&I(function(){c.maybeReportError(new o(pe(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}(u,k,S,C,w,D),z=qe(u,k,S),J={},M={},V=k.streaming,H=!1,K=!1,$=!0,B=k.stateProvider,Z=(m=function(e){B||e&&Y({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(h=x(e))&&m&&m(O(h))},getUser:function(){return h?O(h):null}}),Q=_e(u.localStorage,y);function Y(e){S&&(B&&B.enqueueEvent&&B.enqueueEvent(e)||(e.user?($=!1,!E||K||u.isDoNotTrack()||(y.debug(Ne(e.kind)),_.enqueue(e))):$&&(y.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),$=!1)))}function ee(e,n,t,r){var o=Z.getUser(),i=new Date,a=n?n.value:null;if(!k.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=J[u];if(s&&i-s<3e5)return;J[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=M[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 ne(e,n,t,r){var o;if(M&&A(M,e)&&M[e]&&!M[e].deleted){var i=M[e];o=te(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 te(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function re(){d=!0,Z.getUser()&&q.connect(Z.getUser(),P,{ping:function(){y.debug("received ping message from stream"),z.fetchFlagSettings(Z.getUser(),P).then(function(e){return ie(e||{})}).catch(function(e){w.maybeReportError(new l(ce(e)))})},put:function(e){var n=JSON.parse(e.data);y.debug("received streaming update for all flags"),ie(n)},patch:function(e){var n=JSON.parse(e.data),t=M[n.key];if(!t||!t.version||!n.version||t.version<n.version){y.debug(Ie(n.key));var r={},o=L({},n);delete o.key;var i=te(M[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ue(r)}else y.debug(je(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!M[n.key]||M[n.key].version<n.version){y.debug(Re(n.key));var t={};M[n.key]&&!M[n.key].deleted&&(t[n.key]={previous:M[n.key].value}),M[n.key]={version:n.version,deleted:!0},ue(t)}else y.debug(Te(n.key))}})}function oe(){d&&(q.disconnect(),d=!1)}function ie(e){var n={};if(!e)return Promise.resolve();for(var t in M)A(M,t)&&M[t]&&(e[t]&&!U(e[t].value,M[t].value)?n[t]={previous:M[t].value,current:te(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:M[t].value}));for(var o in e)A(e,o)&&e[o]&&(!M[o]||M[o].deleted)&&(n[o]={current:te(e[o])});return M=r({},e),ue(n).catch(function(){})}function ue(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;w.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),w.emit("change",i),w.emit("internal-change",M),k.sendEventsOnlyForVariation||B||e.forEach(function(e){ee(e,o[e].current)})}return v&&p?p.saveFlags(M).catch(function(){return null}):Promise.resolve()}function le(){var e=V||g&&void 0===V;e&&!d?re():!e&&d&&oe(),F&&F.setStreaming(e)}function fe(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(p=new xe(u.localStorage,S,P,Z,y)),"string"==typeof k.bootstrap&&"LOCALSTORAGE"===k.bootstrap.toUpperCase()&&(p?v=!0:y.warn("localStorage is unavailable")),"object"===e(k.bootstrap)&&(M=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&y.warn(ve()),!1===t.$valid&&y.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=L(n,r[e]):n.version=0,o[e]=n}}),o}(k.bootstrap)),B){var de=B.getInitialState();de?ge(de):B.on("init",ge),B.on("update",function(e){e.user&&Z.setUser(e.user),e.flags&&ie(e.flags)})}else(n?Q.validateUser(t).then(function(n){return Z.setUser(n),"object"===e(k.bootstrap)?me():v?p.loadFlags().catch(function(){return null}).then(function(e){return null==e?(M={},z.fetchFlagSettings(Z.getUser(),P).then(function(e){return ie(e||{})}).then(me).catch(function(e){he(new l(ce(e)))})):(M=e,I(me),z.fetchFlagSettings(Z.getUser(),P).then(function(e){return ie(e)}).catch(function(e){return w.maybeReportError(e)}))}):z.fetchFlagSettings(Z.getUser(),P).then(function(e){M=e||{},me()}).catch(function(e){M={},he(e)})}):Promise.reject(new a(se()))).catch(he);function ge(e){S=e.environment,Z.setUser(e.user),M=r({},e.flags),I(me)}function me(){y.info("LaunchDarkly client initialized"),H=!0,le(),b.signalSuccess()}function he(e){b.signalFailure(e)}return{client:{waitForInitialization:function(){return b.getInitializationPromise()},waitUntilReady:function(){return b.getReadyPromise()},identify:function(e,r,n){return K?j(Promise.resolve({}),n):B?(y.warn("identify() has no effect here; it must be called on the main client instance"),j(Promise.resolve(T(M)),n)):j((v&&p?p.clearFlags():Promise.resolve()).then(function(){return Q.validateUser(e)}).then(function(t){return z.fetchFlagSettings(t,r).then(function(e){var n=T(e);return Z.setUser(t),P=r,e?ie(e).then(function(){return n}):n})}).then(function(e){return d&&re(),e}).catch(function(e){return w.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return Z.getUser()},variation:function(e,n){return ne(e,n,!0,!1).value},variationDetail:function(e,n){return ne(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&y.warn(ae(e));var r={kind:"custom",key:e,user:Z.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Y(r)}else w.maybeReportError(new s(ae(e)))},on:function(e,n,t){fe(e)?(g=!0,H&&le(),w.on(e,n,t)):w.on.apply(w,arguments)},off:function(e){if(w.off.apply(w,arguments),fe(e)){var n=!1;w.getEvents().forEach(function(e){fe(e)&&0<w.getEventListenerCount(e)&&(n=!0)}),n||(g=!1,d&&void 0===V&&oe())}},setStreaming:function(e){var n=null===e?void 0:e;n!==V&&(V=n,le())},flush:function(e){return j(E?_.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!M)return e;for(var n in M)A(M,n)&&(e[n]=ne(n,null,!k.sendEventsOnlyForVariation).value);return e},close:function(e){if(K)return j(Promise.resolve(),e);function n(){K=!0,M={}}return j(Promise.resolve().then(function(){if(oe(),F&&F.stop(),E)return _.stop(),_.flush()}).then(n).catch(n),e)}},options:k,emitter:w,ident:Z,logger:y,requestor:z,start:function(){E&&(F&&F.start(),_.start())},enqueueEvent:Y,getFlagsInternal:function(){return M},getEnvironmentId:function(){return S},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({},{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.18.0",i.diagnosticSdkData={name:"js-client-sdk",version:"2.18.0"},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=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=findGoalsForClick(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var locationWatcherInterval=300;function GoalManager(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=GoalTracker(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=GoalTracker(t=e,a),u(locationWatcherInterval,i)),n()}).catch(function(e){r.emitter.maybeReportError(new v.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var goalsEvent="goalsReady",extraOptionDefs={fetchGoals:{default:!0},hash:{type:"string"},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=Ge(e,n,t,r,extraOptionDefs),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var createConsoleLogger=He,version="2.18.0";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){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 o=i("LaunchDarklyUnexpectedResponseError"),a=i("LaunchDarklyInvalidEnvironmentIdError"),u=i("LaunchDarklyInvalidUserError"),s=i("LaunchDarklyInvalidEventKeyError"),c=i("LaunchDarklyInvalidArgumentError"),l=i("LaunchDarklyFlagFetchError");function f(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:o,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=m.length;h<y;++h)g[h]=m[h],p[m.charCodeAt(h)]=h;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function O(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=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function I(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 R(e){var n={};for(var t in e)A(e,t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)A(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-=P(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function F(e){var n=e.version||"3.2.10";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":F(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return r({},e,{},n)},{})}function A(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function x(e){if(!e)return e;var n;for(var t in D){var o=D[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}for(var V=Object.freeze({__proto__:null,btoa:S,base64URLEncode:P,clone:O,deepEquals:U,onNextTick:I,wrapPromiseCallback:j,transformValuesToVersionedValues:R,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:F,getLDHeaders:C,extend:L,objectHasOwnProperty:A,sanitizeUser:x}),q=function(e,n){return function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(n={exports:{}}),n.exports}(),_=[],J=0;J<256;++J)_[J]=(J+256).toString(16).substr(1);var z,M,B=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("")},K=0,$=0,H=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=q();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:$+1,l=s-K+(c-$)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||K<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");K=s,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 v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||B(o)};function G(u,e,n){var t="/a/"+e+".gif",s=L({"Content-Type":"application/json"},C(u,n)),c=u.httpFallbackPing,l={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:H();return n?function n(t){var e=o?s:L({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&f(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(c&&c(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]:N(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],n,t,o));return Promise.all(i)}};return l}function X(){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 W(e){var n={},s=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(o,i){return Object.keys(o).reduce(function(e,n){var t,r=e;return i(n)&&(l[t=n]||!s&&-1===a.indexOf(t)&&-1===c.indexOf(t)?r[0][n]=o[n]:r[1][n]=!0),r},[{},{}])}var a=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var i=n(e.custom,function(){return!0});r.custom=i[0],o=L({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function Q(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var Y=function(){return"LaunchDarkly client initialized"},Z=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",ee=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ne=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},te=function(e){return'Expected application/json content type but got "'+e+'"'},re=function(){return"localStorage is unavailable"},ie=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},oe=function(e){return"network error"+(e?" ("+e+")":"")},ae=function(e){return'Custom event "'+e+'" does not exist'},ue=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+Z},se=function(){return"No environment/client-side ID was specified."+Z},ce=function(e){return"Error fetching flag settings: "+Q(e)},le=function(){return"No user specified."+Z},fe=function(){return"Invalid user specified."+Z},ve=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+Z},de=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ge=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},pe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},me=function(){return"Cannot make HTTP requests in this environment."+Z},he=function(){return"identify() has no effect here; it must be called on the main client instance"},ye=function(){return"Closing stream connection"},be=function(e){return"Opening stream connection to "+e},ke=function(e,n){return"Error on stream connection: "+Q(e)+", will continue retrying every "+n+" milliseconds."},Ee=function(e){return'Ignoring unknown config option "'+e+'"'},we=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},De=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},Oe=function(){return"received ping message from stream"},Ue=function(){return"received streaming update for all flags"},Ie=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'},Re=function(e){return'received streaming deletion for flag "'+e+'"'},Te=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ne=function(e){return'enqueueing "'+e+'" event'},Fe=function(e){return"sending "+e+" events"},Ce=Object.freeze({__proto__:null,clientInitialized:Y,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:ee,eventWithoutUser:ne,invalidContentType:te,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:re,localStorageUnavailableForUserId:ie,networkError:oe,unknownCustomEventKey:ae,environmentNotFound:ue,environmentNotSpecified:se,errorFetchingFlags:ce,userNotSpecified:le,invalidUser:fe,bootstrapOldFormat:ve,bootstrapInvalid:de,deprecated:ge,httpErrorMessage:pe,httpUnavailable:me,identifyDisabled:he,streamClosing:ye,streamConnecting:be,streamError:ke,unknownOption:Ee,wrongOptionType:we,wrongOptionTypeBoolean:De,optionBelowMinimum:Se,debugPolling:Pe,debugStreamPing:Oe,debugStreamPut:Ue,debugStreamPatch:Ie,debugStreamPatchIgnored:je,debugStreamDelete:Re,debugStreamDeleteIgnored:Te,debugEnqueueingEvent:Ne,debugPostingEvents:Fe,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 Ae=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,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||S(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=R(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.saveFlags=function(e){var n=L({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u}function Ve(o,e,i,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=C(o,e),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(s.warn(ke(e,r)),d=!0),S(!1),E(),b(r)}function b(e){p||(e?p=setTimeout(k,e):k())}function k(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),l?o.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(m)):(e=u+"/ping/"+i,n=""):e=c+"/"+P(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),s.info(be(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,t),y)A(y,r)&&g.addEventListener(r,y[r]);g.onerror=w}}function E(){g&&(s.info("Closing stream connection"),g.close(),g=null)}function S(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){m=e,h=n,y={};function r(n){y[n]=function(e){S(!(d=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);b()},t.disconnect=function(){clearTimeout(p),p=null,E()},t.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},t}function qe(p,m,u){var s=m.baseUrl,c=m.useReport,f=m.evaluationReasons,v=m.logger,e={},h={};function d(e,n){if(!p.httpRequest)return new Promise(function(e,n){n(new l(me()))});var t=n?"REPORT":"GET",r=C(p,m);n&&(r["Content-Type"]="application/json");var o,i,u,s,c,f,v=h[e];v||(o=function(){delete h[e]},(f={addPromise:function(n,e){i=n,u&&u(),u=e,n.then(function(e){i===n&&(s(e),o())},function(e){i===n&&(c(e),o())})}}).resultPromise=new Promise(function(e,n){s=e,c=n}),v=f,h[e]=v);var d=p.httpRequest(t,e,r,n),g=d.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new a(ue()):new l(ce(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=te(e.header("content-type")||"");return Promise.reject(new l(t))},function(e){return Promise.reject(new l(oe(e)))});return v.addPromise(g,function(){d.cancel&&d.cancel()}),v.resultPromise}return e.fetchJSON=function(e){return d(s+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[s,"/sdk/evalx/",u,"/user"].join(""),o=JSON.stringify(e)):(t=P(JSON.stringify(e)),r=[s,"/sdk/evalx/",u,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(Pe(r)),d(r,o)},e}function _e(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new u(le()));var r=O(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get("ld:$anonUserId").catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=H();return r.key=t,(n=t,o?o.set("ld:$anonUserId",n).catch(function(){i.warn("localStorage is unavailable, so anonymous user ID cannot be cached")}):Promise.resolve()).then(function(){return r})}):Promise.reject(new u(fe()))},e}var Je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function ze(n,t,r,o){var a=L({logger:{default:o}},Je,r),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){I(function(){t&&t.maybeReportError(new c(e))})}var s,l,f,v,d=L({},n||{});return v=d,Object.keys(i).forEach(function(e){if(void 0!==v[e]){var n=i[e];o&&o.warn(ge(e,n)),n&&(void 0===v[n]&&(v[n]=v[e]),delete v[e])}}),f=L({},d),Object.keys(a).forEach(function(e){void 0!==f[e]&&null!==f[e]||(f[e]=a[e]&&a[e].default)}),s=d=f,l=L({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(Ee(e));else{var r=t.type||g(t.default);if("any"!==r){var o=r.split("|"),i=g(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,u(De(e,i))):(u(we(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(Se(e,n,t.minimum)),l[e]=t.minimum)}}}}),l;function g(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 Me=Object.freeze({__proto__:null,baseOptionDefs:Je,validate:ze}).baseOptionDefs,Be=function(e){var n={diagnosticId:H()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Ke=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}},$e=function(o,e,n,t,i,a){var u,s,c=!!o.diagnosticUseCombinedEvent,l="ld:"+t+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+t,v=i.diagnosticRecordingInterval,d=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=r({},o.diagnosticSdkData);return i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e}(),configuration:(e={customBaseURI:i.baseUrl!==Me.baseUrl.default,customStreamURI:i.streamUrl!==Me.streamUrl.default,customEventsURI:i.eventsUrl!==Me.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},e),platform:o.diagnosticPlatformData};var e}function h(e){i.logger&&i.logger.debug(Ce.debugPostingDiagnosticEvent(e)),n.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;h((e=(new Date).getTime(),n=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},d.getProps()),c&&(n=r({},n,{},m())),d.reset(e),n)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(o.localStorage){var e=r({},d.getProps());o.localStorage.set(l,JSON.stringify(e),function(){})}}()}return p.start=function(){c?function(t){if(!o.localStorage)return t(!1);o.localStorage.get(l).then(function(e){if(e)try{var n=JSON.parse(e);d.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();n<=t?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)}):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(y,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function He(e,n){var i,a=["debug","info","warn","error"];i=null!=n?""===n?"":n+" ":"LD: ";var u=0;e&&(u="none"===e?100:a.indexOf(e));var t={};function r(e,n,t){if(u<=e&&console){var r=console[n];if(r){var o=e<a.length?a[e]:"?";r.call(console,i+"["+o+"] "+t)}}}return t.debug=function(e){return r(0,"log",e)},t.info=function(e){return r(1,"info",e)},t.warn=function(e){return r(2,"warn",e)},t.error=function(e){return r(3,"error",e)},t}function Ge(n,t,i,u,c){var v,d,g,p,m,h,y=i&&i.logger?i.logger:c&&c.logger&&c.logger.default||He("warn"),w=Le(y),b=Ae(w),k=ze(i,w,c,y),E=k.sendEvents,S=n,P=k.hash,D=G(u,S,k),R=k.sendEvents&&!k.diagnosticOptOut,N=R?Be(S):null,C=R?Ke((new Date).getTime()):null,F=R?$e(u,C,D,S,k,N):null,q=Ve(u,k,S,C),_=k.eventProcessor||function(e,n,t,r,i,a){var u,s=3<arguments.length&&void 0!==r?r:null,c=4<arguments.length&&void 0!==i?i:null,l={},v=(5<arguments.length&&void 0!==a?a:null)||G(e,t,n),d=n.eventsUrl+"/events/bulk/"+t,g=X(),p=W(n),m=n.inlineUsersInEvents,h=n.samplingInterval,y=n.eventCapacity,w=n.flushInterval,b=n.logger,k=[],E=0,S=!1,P=!1;function D(){return 0===h||0===Math.floor(Math.random()*h)}function O(e){k.length<y?(k.push(e),P=!1):(P||(P=!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?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>E&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=D(),n&&O(function(e){var n=L({},e);return m||"identify"===e.kind?n.user=p.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=L({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(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(Fe(e.length)),v.sendEvents(e,d).then(function(e){e&&(e.serverTime&&(E=e.serverTime),f(e.status)||(S=!0),400<=e.status&&I(function(){c.maybeReportError(new o(pe(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}(u,k,S,C,w,D),z=qe(u,k,S),J={},M={},V=k.streaming,H=!1,K=!1,$=!0,B=k.stateProvider,Z=(m=function(e){B||e&&Y({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(h=x(e))&&m&&m(O(h))},getUser:function(){return h?O(h):null}}),Q=_e(u.localStorage,y);function Y(e){S&&(B&&B.enqueueEvent&&B.enqueueEvent(e)||(e.user?($=!1,!E||K||u.isDoNotTrack()||(y.debug(Ne(e.kind)),_.enqueue(e))):$&&(y.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),$=!1)))}function ee(e,n,t,r){var o=Z.getUser(),i=new Date,a=n?n.value:null;if(!k.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=J[u];if(s&&i-s<3e5)return;J[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=M[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 ne(e,n,t,r){var o;if(M&&A(M,e)&&M[e]&&!M[e].deleted){var i=M[e];o=te(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 te(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function re(){d=!0,Z.getUser()&&q.connect(Z.getUser(),P,{ping:function(){y.debug("received ping message from stream");var n=Z.getUser();z.fetchFlagSettings(n,P).then(function(e){U(n,Z.getUser())&&ie(e||{})}).catch(function(e){w.maybeReportError(new l(ce(e)))})},put:function(e){var n=JSON.parse(e.data);y.debug("received streaming update for all flags"),ie(n)},patch:function(e){var n=JSON.parse(e.data),t=M[n.key];if(!t||!t.version||!n.version||t.version<n.version){y.debug(Ie(n.key));var r={},o=L({},n);delete o.key;var i=te(M[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ue(r)}else y.debug(je(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!M[n.key]||M[n.key].version<n.version){y.debug(Re(n.key));var t={};M[n.key]&&!M[n.key].deleted&&(t[n.key]={previous:M[n.key].value}),M[n.key]={version:n.version,deleted:!0},ue(t)}else y.debug(Te(n.key))}})}function oe(){d&&(q.disconnect(),d=!1)}function ie(e){var n={};if(!e)return Promise.resolve();for(var t in M)A(M,t)&&M[t]&&(e[t]&&!U(e[t].value,M[t].value)?n[t]={previous:M[t].value,current:te(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:M[t].value}));for(var o in e)A(e,o)&&e[o]&&(!M[o]||M[o].deleted)&&(n[o]={current:te(e[o])});return M=r({},e),ue(n).catch(function(){})}function ue(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;w.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),w.emit("change",i),w.emit("internal-change",M),k.sendEventsOnlyForVariation||B||e.forEach(function(e){ee(e,o[e].current)})}return v&&p?p.saveFlags(M).catch(function(){return null}):Promise.resolve()}function le(){var e=V||g&&void 0===V;e&&!d?re():!e&&d&&oe(),F&&F.setStreaming(e)}function fe(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(p=new xe(u.localStorage,S,P,Z,y)),"string"==typeof k.bootstrap&&"LOCALSTORAGE"===k.bootstrap.toUpperCase()&&(p?v=!0:y.warn("localStorage is unavailable")),"object"===e(k.bootstrap)&&(M=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&y.warn(ve()),!1===t.$valid&&y.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=L(n,r[e]):n.version=0,o[e]=n}}),o}(k.bootstrap)),B){var de=B.getInitialState();de?ge(de):B.on("init",ge),B.on("update",function(e){e.user&&Z.setUser(e.user),e.flags&&ie(e.flags)})}else(n?Q.validateUser(t).then(function(n){return Z.setUser(n),"object"===e(k.bootstrap)?me():v?p.loadFlags().catch(function(){return null}).then(function(e){return null==e?(M={},z.fetchFlagSettings(Z.getUser(),P).then(function(e){return ie(e||{})}).then(me).catch(function(e){he(new l(ce(e)))})):(M=e,I(me),z.fetchFlagSettings(Z.getUser(),P).then(function(e){return ie(e)}).catch(function(e){return w.maybeReportError(e)}))}):z.fetchFlagSettings(Z.getUser(),P).then(function(e){M=e||{},me()}).catch(function(e){M={},he(e)})}):Promise.reject(new a(se()))).catch(he);function ge(e){S=e.environment,Z.setUser(e.user),M=r({},e.flags),I(me)}function me(){y.info("LaunchDarkly client initialized"),H=!0,le(),b.signalSuccess()}function he(e){b.signalFailure(e)}return{client:{waitForInitialization:function(){return b.getInitializationPromise()},waitUntilReady:function(){return b.getReadyPromise()},identify:function(e,r,n){return K?j(Promise.resolve({}),n):B?(y.warn("identify() has no effect here; it must be called on the main client instance"),j(Promise.resolve(T(M)),n)):j((v&&p?p.clearFlags():Promise.resolve()).then(function(){return Q.validateUser(e)}).then(function(t){return z.fetchFlagSettings(t,r).then(function(e){var n=T(e);return Z.setUser(t),P=r,e?ie(e).then(function(){return n}):n})}).then(function(e){return d&&re(),e}).catch(function(e){return w.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return Z.getUser()},variation:function(e,n){return ne(e,n,!0,!1).value},variationDetail:function(e,n){return ne(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&y.warn(ae(e));var r={kind:"custom",key:e,user:Z.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Y(r)}else w.maybeReportError(new s(ae(e)))},on:function(e,n,t){fe(e)?(g=!0,H&&le(),w.on(e,n,t)):w.on.apply(w,arguments)},off:function(e){if(w.off.apply(w,arguments),fe(e)){var n=!1;w.getEvents().forEach(function(e){fe(e)&&0<w.getEventListenerCount(e)&&(n=!0)}),n||(g=!1,d&&void 0===V&&oe())}},setStreaming:function(e){var n=null===e?void 0:e;n!==V&&(V=n,le())},flush:function(e){return j(E?_.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!M)return e;for(var n in M)A(M,n)&&(e[n]=ne(n,null,!k.sendEventsOnlyForVariation).value);return e},close:function(e){if(K)return j(Promise.resolve(),e);function n(){K=!0,M={}}return j(Promise.resolve().then(function(){if(oe(),F&&F.stop(),E)return _.stop(),_.flush()}).then(n).catch(n),e)}},options:k,emitter:w,ident:Z,logger:y,requestor:z,start:function(){E&&(F&&F.start(),_.start())},enqueueEvent:Y,getFlagsInternal:function(){return M},getEnvironmentId:function(){return S},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.18.1",i.diagnosticSdkData={name:"js-client-sdk",version:"2.18.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=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=findGoalsForClick(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var locationWatcherInterval=300;function GoalManager(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=GoalTracker(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=GoalTracker(t=e,a),u(locationWatcherInterval,i)),n()}).catch(function(e){r.emitter.maybeReportError(new v.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var goalsEvent="goalsReady",extraOptionDefs={fetchGoals:{default:!0},hash:{type:"string"},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=Ge(e,n,t,r,extraOptionDefs),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var createConsoleLogger=He,version="2.18.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; | ||
//# sourceMappingURL=ldclient.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),s=o("LaunchDarklyInvalidEventKeyError"),c=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(w(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=m.length;h<y;++h)g[h]=m[h],p[m.charCodeAt(h)]=h;function w(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var b=Array.isArray,E=Object.keys,k=Object.prototype.hasOwnProperty,S=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function D(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return D(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function O(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 v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!k.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function j(e){setTimeout(e,0)}function R(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function I(e){var n={};for(var t in e)x(e,t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)x(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 L(e){var n=e.version||"3.2.9";return e.userAgent+"/"+n}function F(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 C(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function x(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function A(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:D,base64URLEncode:P,clone:O,deepEquals:U,onNextTick:j,wrapPromiseCallback:R,transformValuesToVersionedValues:I,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:L,getLDHeaders:F,extend:C,objectHasOwnProperty:x,sanitizeUser:A});for(var q=function(e,n){return function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(n={exports:{}}),n.exports}(),V=[],_=0;_<256;++_)V[_]=(_+256).toString(16).substr(1);var J,z,M=0,$=0,H=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||J,a=void 0!==e.clockseq?e.clockseq:z;if(null==i||null==a){var u=q();null==i&&(i=J=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=z=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-M+(c-$)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>M)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");M=s,$=c,z=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=V;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 K(e,n,t){var r="/a/"+n+".gif",o=C({"Content-Type":"application/json"},F(e,t)),i=e.httpFallbackPing,a={sendChunk:function(n,t,a,u){var s=JSON.stringify(n),c=a?null:H();return u?function n(r){var i=a?o:C({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":c});return e.httpRequest("POST",t,i,s).promise.then((function(e){if(e)return e.status>=400&&f(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(t+r+"?d="+P(s)),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 B(){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 G(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 X(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var W=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",Q=function(e){return'Expected application/json content type but got "'+e+'"'},Y=function(e){return"network error"+(e?" ("+e+")":"")},Z=function(e){return'Custom event "'+e+'" does not exist'},ee=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+W},ne=function(){return"No environment/client-side ID was specified."+W},te=function(e){return"Error fetching flag settings: "+X(e)},re=function(){return"No user specified."+W},oe=function(){return"Invalid user specified."+W},ie=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+W},ae=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ue=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},se=function(){return"Cannot make HTTP requests in this environment."+W},ce=function(e){return"Opening stream connection to "+e},le=function(e,n){return"Error on stream connection: "+X(e)+", will continue retrying every "+n+" milliseconds."},fe=function(e){return'Ignoring unknown config option "'+e+'"'},ve=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},de=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},ge=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},me=function(e){return'received streaming update for flag "'+e+'"'},he=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},ye=function(e){return'received streaming deletion for flag "'+e+'"'},we=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},be=function(e){return'enqueueing "'+e+'" event'},Ee=function(e){return"sending "+e+" events"},ke=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/docs/js-sdk-reference#section-analytics-events"},invalidContentType:Q,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:function(){return"localStorage is unavailable"},localStorageUnavailableForUserId:function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError:Y,unknownCustomEventKey:Z,environmentNotFound:ee,environmentNotSpecified:ne,errorFetchingFlags:te,userNotSpecified:re,invalidUser:oe,bootstrapOldFormat:ie,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:ae,httpErrorMessage:ue,httpUnavailable:se,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:ce,streamError:le,unknownOption:fe,wrongOptionType:ve,wrongOptionTypeBoolean:de,optionBelowMinimum:ge,debugPolling:pe,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:me,debugStreamPatchIgnored:he,debugStreamDelete:ye,debugStreamDeleteIgnored:we,debugEnqueueingEvent:be,debugPostingEvents:Ee,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Se=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)}}};function De(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||D(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=I(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return o.warn("localStorage is unavailable"),Promise.reject(e)}))},i.saveFlags=function(n){var t=C({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch((function(e){return o.warn("localStorage is unavailable"),Promise.reject(e)}))},i.clearFlags=function(){return e.clear(a()).catch((function(e){return o.warn("localStorage is unavailable"),Promise.reject(e)}))},i}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,v=F(e,n),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(a.warn(le(e,f)),d=!0),S(!1),k(),b(f)}function b(e){p||(e?p=setTimeout(E,e):E())}function E(){var n;p=null;var r="",u={headers:v};if(e.eventSourceFactory){for(var f in null!=h&&(r="h="+h),c?e.eventSourceAllowsReport?(n=s,u.method="REPORT",u.headers["Content-Type"]="application/json",u.body=JSON.stringify(m)):(n=i+"/ping/"+t,r=""):n=s+"/"+P(JSON.stringify(m)),l&&(r=r+(r?"&":"")+"withReasons=true"),n=n+(r?"?":"")+r,k(),a.info(ce(n)),o=(new Date).getTime(),g=e.eventSourceFactory(n,u),y)x(y,f)&&g.addEventListener(f,y[f]);g.onerror=w}}function k(){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){d=!1,S(!0),t[e]&&t[e](n)}};for(var o in t||{})r(o);b()},u.disconnect=function(){clearTimeout(p),p=null,k()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function Oe(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.logger,s={},c={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(se()))}));var o=r?"REPORT":"GET",i=F(e,n);r&&(i["Content-Type"]="application/json");var u=c[t];u||(u=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then((function(t){n===i&&(r(t),e&&e())}),(function(t){n===i&&(o(t),e&&e())}))}};return i.resultPromise=new Promise((function(e,n){r=e,o=n})),i}((function(){delete c[t]})),c[t]=u);var s=e.httpRequest(o,t,i,r),f=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=Q(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(ee()):new l(te(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(Y(e)))}));return u.addPromise(f,(function(){s.cancel&&s.cancel()})),u.resultPromise}return s.fetchJSON=function(e){return f(r+e,null)},s.fetchFlagSettings=function(e,n){var a,s,c,l="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=P(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),s=s+(l?"?":"")+l,u.debug(pe(s)),f(s,c)},s}function Ue(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new u(re()));var r=O(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get("ld:$anonUserId").catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var o=H();return r.key=o,function(t){return e?e.set("ld:$anonUserId",t).catch((function(){n.warn("localStorage is unavailable, so anonymous user ID cannot be cached")})):Promise.resolve()}(o).then((function(){return r}))})):Promise.reject(new u(oe()))}};return t}var je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Re(n,t,r,o){var i=C({logger:{default:o}},je,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){j((function(){t&&t.maybeReportError(new c(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(ae(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(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(fe(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(de(e,l))):(u(ve(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&o<a.minimum&&(u(ge(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))}var Ie=Object.freeze({__proto__:null,baseOptionDefs:je,validate:Re}).baseOptionDefs,Te=function(e){var n={diagnosticId:H()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Ne=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}},Le=function(e,n,t,o,i,a){var u,s,c=!!e.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,v=i.diagnosticRecordingInterval,d=n,g=!!i.streaming,p={};function m(){return{sdk:w(),configuration:(n={customBaseURI:i.baseUrl!==Ie.baseUrl.default,customStreamURI:i.streamUrl!==Ie.streamUrl.default,customEventsURI:i.eventsUrl!==Ie.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},n),platform:e.diagnosticPlatformData};var n}function h(e){i.logger&&i.logger.debug(ke.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then((function(){})).catch((function(){}))}function y(){var n,t;h((n=(new Date).getTime(),t=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},d.getProps()),c&&(t=r({},t,{},m())),d.reset(n),t)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(e.localStorage){var n=r({},d.getProps());e.localStorage.set(l,JSON.stringify(n),(function(){}))}}()}function w(){var n=r({},e.diagnosticSdkData);return i.wrapperName&&(n.wrapperName=i.wrapperName),i.wrapperVersion&&(n.wrapperVersion=i.wrapperVersion),n}return p.start=function(){c?function(n){if(!e.localStorage)return n(!1);e.localStorage.get(l).then((function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),u=t.dataSinceDate}catch(e){}n(!0)})).catch((function(){n(!1)}))}((function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();t>=n?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)})):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(y,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function Fe(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o&&console){var a=console[n];if(a){var u=e<r.length?r[e]:"?";a.call(console,t+"["+u+"] "+i)}}}return i.debug=function(e){return a(0,"log",e)},i.info=function(e){return a(1,"info",e)},i.warn=function(e){return a(2,"warn",e)},i.error=function(e){return a(3,"error",e)},i}function Ce(n,t,o,u,c){var v,d,g,p,m=o&&o.logger?o.logger:c&&c.logger&&c.logger.default||Fe("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=Se(h),w=Re(o,h,c,m),b=w.sendEvents,E=n,k=w.hash,S=K(u,E,w),D=w.sendEvents&&!w.diagnosticOptOut,P=D?Te(E):null,I=D?Ne((new Date).getTime()):null,N=D?Le(u,I,S,E,w,P):null,L=Pe(u,w,E,I),F=w.eventProcessor||function(e,n,t){var r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||K(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,v=B(),d=G(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,E=!1,k=!1;function S(){return 0===p||0===Math.floor(Math.random()*p)}function D(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}function P(e){var n=C({},e);return 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 O(e){w.length<m?(w.push(e),k=!1):(k||(k=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),o&&o.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?S()&&(n=!!e.trackEvents,t=D(e)):n=S(),n&&O(P(e)),t){var r=C({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=w,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(Ee(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(b=e.serverTime),f(e.status)||(E=!0),e.status>=400&&j((function(){a.maybeReportError(new i(ue(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}(u,w,E,I,h,S),q=Oe(u,w,E),V={},_={},J=w.streaming,z=!1,M=!1,$=!0,H=w.stateProvider,X=function(e,n){var t,r={setUser:function(e){(t=A(e))&&n&&n(O(t))},getUser:function(){return t?O(t):null}};return r}(0,(function(e){H||e&&Q({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),W=Ue(u.localStorage,m);function Q(e){E&&(H&&H.enqueueEvent&&H.enqueueEvent(e)||(e.user?($=!1,!b||M||u.isDoNotTrack()||(m.debug(be(e.kind)),F.enqueue(e))):$&&(m.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),$=!1)))}function Y(e,n,t,r){var o=X.getUser(),i=new Date,a=n?n.value:null;if(!w.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()},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),Q(c)}function ee(e,n,t,r){var o;if(_&&x(_,e)&&_[e]&&!_[e].deleted){var i=_[e];o=re(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Y(e,o,n,r),o}function re(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function oe(){d=!0,X.getUser()&&L.connect(X.getUser(),k,{ping:function(){m.debug("received ping message from stream"),q.fetchFlagSettings(X.getUser(),k).then((function(e){return se(e||{})})).catch((function(e){h.maybeReportError(new l(te(e)))}))},put:function(e){var n=JSON.parse(e.data);m.debug("received streaming update for all flags"),se(n)},patch:function(e){var n=JSON.parse(e.data),t=_[n.key];if(!t||!t.version||!n.version||t.version<n.version){m.debug(me(n.key));var r={},o=C({},n);delete o.key,_[n.key]=o;var i=re(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ce(r)}else m.debug(he(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!_[n.key]||_[n.key].version<n.version){m.debug(ye(n.key));var t={};_[n.key]&&!_[n.key].deleted&&(t[n.key]={previous:_[n.key].value}),_[n.key]={version:n.version,deleted:!0},ce(t)}else m.debug(we(n.key))}})}function ae(){d&&(L.disconnect(),d=!1)}function se(e){var n={};if(!e)return Promise.resolve();for(var t in _)x(_,t)&&_[t]&&(e[t]&&!U(e[t].value,_[t].value)?n[t]={previous:_[t].value,current:re(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:_[t].value}));for(var o in e)x(e,o)&&e[o]&&(!_[o]||_[o].deleted)&&(n[o]={current:re(e[o])});return _=r({},e),ce(n).catch((function(){}))}function ce(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",_),w.sendEventsOnlyForVariation||H||n.forEach((function(n){Y(n,e[n].current)}))}return v&&p?p.saveFlags(_).catch((function(){return null})):Promise.resolve()}function le(){var e=J||g&&void 0===J;e&&!d?oe():!e&&d&&ae(),N&&N.setStreaming(e)}function fe(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(p=new De(u.localStorage,E,k,X,m)),"string"==typeof w.bootstrap&&"LOCALSTORAGE"===w.bootstrap.toUpperCase()&&(p?v=!0:m.warn("localStorage is unavailable")),"object"===e(w.bootstrap)&&(_=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(ie()),!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)),H){var ve=H.getInitialState();ve?de(ve):H.on("init",de),H.on("update",(function(e){e.user&&X.setUser(e.user),e.flags&&se(e.flags)}))}else(n?W.validateUser(t).then((function(n){return X.setUser(n),"object"===e(w.bootstrap)?ge():v?p.loadFlags().catch((function(){return null})).then((function(e){return null==e?(_={},q.fetchFlagSettings(X.getUser(),k).then((function(e){return se(e||{})})).then(ge).catch((function(e){pe(new l(te(e)))}))):(_=e,j(ge),q.fetchFlagSettings(X.getUser(),k).then((function(e){return se(e)})).catch((function(e){return h.maybeReportError(e)})))})):q.fetchFlagSettings(X.getUser(),k).then((function(e){_=e||{},ge()})).catch((function(e){_={},pe(e)}))})):Promise.reject(new a(ne()))).catch(pe);function de(e){E=e.environment,X.setUser(e.user),_=r({},e.flags),j(ge)}function ge(){m.info("LaunchDarkly client initialized"),z=!0,le(),y.signalSuccess()}function pe(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return M?R(Promise.resolve({}),t):H?(m.warn("identify() has no effect here; it must be called on the main client instance"),R(Promise.resolve(T(_)),t)):R((v&&p?p.clearFlags():Promise.resolve()).then((function(){return W.validateUser(e)})).then((function(e){return q.fetchFlagSettings(e,n).then((function(t){var r=T(t);return X.setUser(e),k=n,t?se(t).then((function(){return r})):r}))})).then((function(e){return d&&oe(),e})).catch((function(e){return h.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return X.getUser()},variation:function(e,n){return ee(e,n,!0,!1).value},variationDetail:function(e,n){return ee(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&m.warn(Z(e));var r={kind:"custom",key:e,user:X.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Q(r)}else h.maybeReportError(new s(Z(e)))},on:function(e,n,t){fe(e)?(g=!0,z&&le(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),fe(e)){var n=!1;h.getEvents().forEach((function(e){fe(e)&&h.getEventListenerCount(e)>0&&(n=!0)})),n||(g=!1,d&&void 0===J&&ae())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,le())},flush:function(e){return R(b?F.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!_)return e;for(var n in _)x(_,n)&&(e[n]=ee(n,null,!w.sendEventsOnlyForVariation).value);return e},close:function(e){if(M)return R(Promise.resolve(),e);var n=function(){M=!0,_={}};return R(Promise.resolve().then((function(){if(ae(),N&&N.stop(),b)return F.stop(),F.flush()})).then(n).catch(n),e)}},options:w,emitter:h,ident:X,logger:m,requestor:q,start:function(){b&&(N&&N.start(),F.start())},enqueueEvent:Q,getFlagsInternal:function(){return _},getEnvironmentId:function(){return E},internalChangeEventName:"internal-change"}}function xe(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Ae(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}var qe={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ve(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 qe;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),qe;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 _e(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,Ve(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){t.eventSourceFactory=function(e,n){var t=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ae(Object(t),!0).forEach((function(n){xe(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ae(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},{heartbeatTimeout:3e5,silentTimeout:3e5,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.18.0",t.diagnosticSdkData={name:"js-client-sdk",version:"2.18.0"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var Je=/[|\\{}()[\]^$+*?.]/g,ze=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Je,"\\$&")};function Me(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+ze(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+ze(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+ze(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(Me(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var He=300;function Ke(e,n){var t,r,o={};function i(){r&&r.dispose(),t&&t.length&&(r=$e(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=$e(t=e,a),function(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout((function(){e(n,t)}),t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(He,i)),n()})).catch((function(t){e.emitter.maybeReportError(new v.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),o}var Be="goalsReady",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=_e(t),o=Ce(e,n,t,r,Ge),i=o.client,a=o.options,u=o.emitter,s=new Promise((function(e){var n=u.on(Be,(function(){u.off(Be,n),e()}))}));if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=Ke(o,(function(){return u.emit(Be)}));r.customEventFilter=c.goalKeyExists}else u.emit(Be);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var We=Fe,Qe="2.18.0";var Ye={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(ke.deprecated("default export","named LDClient export")),Xe(e,n,t)},version:"2.18.0"};export default Ye;export{We as createConsoleLogger,Xe as initialize,Qe as version}; | ||
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),s=o("LaunchDarklyInvalidEventKeyError"),c=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=[],g=[],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m=0,h=p.length;m<h;++m)d[m]=p[m],g[p.charCodeAt(m)]=m;function y(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(d[(o=r)>>18&63]+d[o>>12&63]+d[o>>6&63]+d[63&o]);return i.join("")}g["-".charCodeAt(0)]=62,g["_".charCodeAt(0)]=63;var w=Array.isArray,b=Object.keys,E=Object.prototype.hasOwnProperty,k=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(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(y(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(d[n>>2]+d[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(d[n>>10]+d[n>>4&63]+d[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 S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function P(e){return JSON.parse(JSON.stringify(e))}function O(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 v=b(n);if((o=v.length)!==b(t).length)return!1;for(r=o;0!=r--;)if(!E.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function U(e){setTimeout(e,0)}function R(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function j(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 T(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function N(e){var n=e.version||"3.2.10";return e.userAgent+"/"+n}function L(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":N(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function F(){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 x(e){if(!e)return e;var n;for(var t in k){var o=k[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:S,base64URLEncode:D,clone:P,deepEquals:O,onNextTick:U,wrapPromiseCallback:R,transformValuesToVersionedValues:j,transformVersionedValuesToValues:I,chunkUserEventsForUrl:T,getLDUserAgentString:N,getLDHeaders:L,extend:F,objectHasOwnProperty:C,sanitizeUser:x});for(var A=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}(),q=[],V=0;V<256;++V)q[V]=(V+256).toString(16).substr(1);var _,J,z=0,M=0,$=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_,a=void 0!==e.clockseq?e.clockseq:J;if(null==i||null==a){var u=A();null==i&&(i=_=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=J=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:M+1,l=s-z+(c-M)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>z)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");z=s,M=c,J=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=q;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 H(e,n,t){var r="/a/"+n+".gif",o=F({"Content-Type":"application/json"},L(e,t)),i=e.httpFallbackPing,a={sendChunk:function(n,t,a,u){var s=JSON.stringify(n),c=a?null:$();return u?function n(r){var i=a?o:F({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":c});return e.httpRequest("POST",t,i,s).promise.then((function(e){if(e)return e.status>=400&&f(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(t+r+"?d="+D(s)),Promise.resolve())},sendEvents:function(n,t,r){if(!e.httpRequest)return Promise.resolve();var o,i=e.httpAllowsPost();o=i?[n]:T(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 K(){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 B(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=F({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function G(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var X=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",W=function(e){return'Expected application/json content type but got "'+e+'"'},Q=function(e){return"network error"+(e?" ("+e+")":"")},Y=function(e){return'Custom event "'+e+'" does not exist'},Z=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+X},ee=function(){return"No environment/client-side ID was specified."+X},ne=function(e){return"Error fetching flag settings: "+G(e)},te=function(){return"No user specified."+X},re=function(){return"Invalid user specified."+X},oe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+X},ie=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ae=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ue=function(){return"Cannot make HTTP requests in this environment."+X},se=function(e){return"Opening stream connection to "+e},ce=function(e,n){return"Error on stream connection: "+G(e)+", will continue retrying every "+n+" milliseconds."},le=function(e){return'Ignoring unknown config option "'+e+'"'},fe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},ve=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},de=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},ge=function(e){return"polling for feature flags at "+e},pe=function(e){return'received streaming update for flag "'+e+'"'},me=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},he=function(e){return'received streaming deletion for flag "'+e+'"'},ye=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},we=function(e){return'enqueueing "'+e+'" event'},be=function(e){return"sending "+e+" events"},Ee=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/docs/js-sdk-reference#section-analytics-events"},invalidContentType:W,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:function(){return"localStorage is unavailable"},localStorageUnavailableForUserId:function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError:Q,unknownCustomEventKey:Y,environmentNotFound:Z,environmentNotSpecified:ee,errorFetchingFlags:ne,userNotSpecified:te,invalidUser:re,bootstrapOldFormat:oe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:ie,httpErrorMessage:ae,httpUnavailable:ue,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:se,streamError:ce,unknownOption:le,wrongOptionType:fe,wrongOptionTypeBoolean:ve,optionBelowMinimum:de,debugPolling:ge,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:pe,debugStreamPatchIgnored:me,debugStreamDelete:he,debugStreamDeleteIgnored:ye,debugEnqueueingEvent:we,debugPostingEvents:be,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function ke(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||S(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=j(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return o.warn("localStorage is unavailable"),Promise.reject(e)}))},i.saveFlags=function(n){var t=F({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch((function(e){return o.warn("localStorage is unavailable"),Promise.reject(e)}))},i.clearFlags=function(){return e.clear(a()).catch((function(e){return o.warn("localStorage is unavailable"),Promise.reject(e)}))},i}function Se(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,v=L(e,n),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(a.warn(ce(e,f)),d=!0),S(!1),k(),b(f)}function b(e){p||(e?p=setTimeout(E,e):E())}function E(){var n;p=null;var r="",u={headers:v};if(e.eventSourceFactory){for(var f in null!=h&&(r="h="+h),c?e.eventSourceAllowsReport?(n=s,u.method="REPORT",u.headers["Content-Type"]="application/json",u.body=JSON.stringify(m)):(n=i+"/ping/"+t,r=""):n=s+"/"+D(JSON.stringify(m)),l&&(r=r+(r?"&":"")+"withReasons=true"),n=n+(r?"?":"")+r,k(),a.info(se(n)),o=(new Date).getTime(),g=e.eventSourceFactory(n,u),y)C(y,f)&&g.addEventListener(f,y[f]);g.onerror=w}}function k(){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){d=!1,S(!0),t[e]&&t[e](n)}};for(var o in t||{})r(o);b()},u.disconnect=function(){clearTimeout(p),p=null,k()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function De(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.logger,s={},c={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(ue()))}));var o=r?"REPORT":"GET",i=L(e,n);r&&(i["Content-Type"]="application/json");var u=c[t];u||(u=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then((function(t){n===i&&(r(t),e&&e())}),(function(t){n===i&&(o(t),e&&e())}))}};return i.resultPromise=new Promise((function(e,n){r=e,o=n})),i}((function(){delete c[t]})),c[t]=u);var s=e.httpRequest(o,t,i,r),f=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=W(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(Z()):new l(ne(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(Q(e)))}));return u.addPromise(f,(function(){s.cancel&&s.cancel()})),u.resultPromise}return s.fetchJSON=function(e){return f(r+e,null)},s.fetchFlagSettings=function(e,n){var a,s,c,l="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=D(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),s=s+(l?"?":"")+l,u.debug(ge(s)),f(s,c)},s}function Pe(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new u(te()));var r=P(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get("ld:$anonUserId").catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var o=$();return r.key=o,function(t){return e?e.set("ld:$anonUserId",t).catch((function(){n.warn("localStorage is unavailable, so anonymous user ID cannot be cached")})):Promise.resolve()}(o).then((function(){return r}))})):Promise.reject(new u(re()))}};return t}var Oe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Ue(n,t,r,o){var i=F({logger:{default:o}},Oe,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){U((function(){t&&t.maybeReportError(new c(e))}))}var s=F({},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(ie(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(n){var t=F({},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(le(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(ve(e,l))):(u(fe(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&o<a.minimum&&(u(de(e,o,a.minimum)),t[e]=a.minimum)}}}})),t}(s=function(e){var n=F({},e);return Object.keys(i).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=i[e]&&i[e].default)})),n}(s))}var Re=Object.freeze({__proto__:null,baseOptionDefs:Oe,validate:Ue}).baseOptionDefs,je=function(e){var n={diagnosticId:$()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n};function Ie(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o&&console){var a=console[n];if(a){var u=e<r.length?r[e]:"?";a.call(console,t+"["+u+"] "+i)}}}return i.debug=function(e){return a(0,"log",e)},i.info=function(e){return a(1,"info",e)},i.warn=function(e){return a(2,"warn",e)},i.error=function(e){return a(3,"error",e)},i}function Te(n,t,o,u,c){var v,d,g,p,m=o&&o.logger?o.logger:c&&c.logger&&c.logger.default||Ie("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=Ue(o,h,c,m),b=w.sendEvents,E=n,k=w.hash,S=H(u,E,w),D=w.sendEvents&&!w.diagnosticOptOut,j=D?je(E):null,T=D?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=D?function(e,n,t,o,i,a){var u,s,c=!!e.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,v=i.diagnosticRecordingInterval,d=n,g=!!i.streaming,p={};function m(){return{sdk:w(),configuration:(n={customBaseURI:i.baseUrl!==Re.baseUrl.default,customStreamURI:i.streamUrl!==Re.streamUrl.default,customEventsURI:i.eventsUrl!==Re.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},n),platform:e.diagnosticPlatformData};var n}function h(e){i.logger&&i.logger.debug(Ee.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then((function(){})).catch((function(){}))}function y(){var n,t;h((n=(new Date).getTime(),t=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},d.getProps()),c&&(t=r({},t,{},m())),d.reset(n),t)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(e.localStorage){var n=r({},d.getProps());e.localStorage.set(l,JSON.stringify(n),(function(){}))}}()}function w(){var n=r({},e.diagnosticSdkData);return i.wrapperName&&(n.wrapperName=i.wrapperName),i.wrapperVersion&&(n.wrapperVersion=i.wrapperVersion),n}return p.start=function(){c?function(n){if(!e.localStorage)return n(!1);e.localStorage.get(l).then((function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),u=t.dataSinceDate}catch(e){}n(!0)})).catch((function(){n(!1)}))}((function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();t>=n?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)})):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(y,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p}(u,T,S,E,w,j):null,L=Se(u,w,E,T),A=w.eventProcessor||function(e,n,t){var r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||H(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,v=K(),d=B(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,E=!1,k=!1;function S(){return 0===p||0===Math.floor(Math.random()*p)}function D(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}function P(e){var n=F({},e);return 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 O(e){w.length<m?(w.push(e),k=!1):(k||(k=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),o&&o.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?S()&&(n=!!e.trackEvents,t=D(e)):n=S(),n&&O(P(e)),t){var r=F({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=w,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(be(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(b=e.serverTime),f(e.status)||(E=!0),e.status>=400&&U((function(){a.maybeReportError(new i(ae(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}(u,w,E,T,h,S),q=De(u,w,E),V={},_={},J=w.streaming,z=!1,M=!1,$=!0,G=w.stateProvider,X=function(e,n){var t,r={setUser:function(e){(t=x(e))&&n&&n(P(t))},getUser:function(){return t?P(t):null}};return r}(0,(function(e){G||e&&Q({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),W=Pe(u.localStorage,m);function Q(e){E&&(G&&G.enqueueEvent&&G.enqueueEvent(e)||(e.user?($=!1,!b||M||u.isDoNotTrack()||(m.debug(we(e.kind)),A.enqueue(e))):$&&(m.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),$=!1)))}function Z(e,n,t,r){var o=X.getUser(),i=new Date,a=n?n.value:null;if(!w.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()},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),Q(c)}function te(e,n,t,r){var o;if(_&&C(_,e)&&_[e]&&!_[e].deleted){var i=_[e];o=re(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Z(e,o,n,r),o}function re(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ie(){d=!0,X.getUser()&&L.connect(X.getUser(),k,{ping:function(){m.debug("received ping message from stream");var e=X.getUser();q.fetchFlagSettings(e,k).then((function(n){O(e,X.getUser())&&se(n||{})})).catch((function(e){h.maybeReportError(new l(ne(e)))}))},put:function(e){var n=JSON.parse(e.data);m.debug("received streaming update for all flags"),se(n)},patch:function(e){var n=JSON.parse(e.data),t=_[n.key];if(!t||!t.version||!n.version||t.version<n.version){m.debug(pe(n.key));var r={},o=F({},n);delete o.key,_[n.key]=o;var i=re(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ce(r)}else m.debug(me(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!_[n.key]||_[n.key].version<n.version){m.debug(he(n.key));var t={};_[n.key]&&!_[n.key].deleted&&(t[n.key]={previous:_[n.key].value}),_[n.key]={version:n.version,deleted:!0},ce(t)}else m.debug(ye(n.key))}})}function ue(){d&&(L.disconnect(),d=!1)}function se(e){var n={};if(!e)return Promise.resolve();for(var t in _)C(_,t)&&_[t]&&(e[t]&&!O(e[t].value,_[t].value)?n[t]={previous:_[t].value,current:re(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:re(e[o])});return _=r({},e),ce(n).catch((function(){}))}function ce(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",_),w.sendEventsOnlyForVariation||G||n.forEach((function(n){Z(n,e[n].current)}))}return v&&p?p.saveFlags(_).catch((function(){return null})):Promise.resolve()}function le(){var e=J||g&&void 0===J;e&&!d?ie():!e&&d&&ue(),N&&N.setStreaming(e)}function fe(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(p=new ke(u.localStorage,E,k,X,m)),"string"==typeof w.bootstrap&&"LOCALSTORAGE"===w.bootstrap.toUpperCase()&&(p?v=!0:m.warn("localStorage is unavailable")),"object"===e(w.bootstrap)&&(_=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(oe()),!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=F(o,t[n]):o.version=0,r[n]=o}})),r}(w.bootstrap)),G){var ve=G.getInitialState();ve?de(ve):G.on("init",de),G.on("update",(function(e){e.user&&X.setUser(e.user),e.flags&&se(e.flags)}))}else(n?W.validateUser(t).then((function(n){return X.setUser(n),"object"===e(w.bootstrap)?ge():v?p.loadFlags().catch((function(){return null})).then((function(e){return null==e?(_={},q.fetchFlagSettings(X.getUser(),k).then((function(e){return se(e||{})})).then(ge).catch((function(e){Oe(new l(ne(e)))}))):(_=e,U(ge),q.fetchFlagSettings(X.getUser(),k).then((function(e){return se(e)})).catch((function(e){return h.maybeReportError(e)})))})):q.fetchFlagSettings(X.getUser(),k).then((function(e){_=e||{},ge()})).catch((function(e){_={},Oe(e)}))})):Promise.reject(new a(ee()))).catch(Oe);function de(e){E=e.environment,X.setUser(e.user),_=r({},e.flags),U(ge)}function ge(){m.info("LaunchDarkly client initialized"),z=!0,le(),y.signalSuccess()}function Oe(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return M?R(Promise.resolve({}),t):G?(m.warn("identify() has no effect here; it must be called on the main client instance"),R(Promise.resolve(I(_)),t)):R((v&&p?p.clearFlags():Promise.resolve()).then((function(){return W.validateUser(e)})).then((function(e){return q.fetchFlagSettings(e,n).then((function(t){var r=I(t);return X.setUser(e),k=n,t?se(t).then((function(){return r})):r}))})).then((function(e){return d&&ie(),e})).catch((function(e){return h.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return X.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){u.customEventFilter&&!u.customEventFilter(e)&&m.warn(Y(e));var r={kind:"custom",key:e,user:X.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Q(r)}else h.maybeReportError(new s(Y(e)))},on:function(e,n,t){fe(e)?(g=!0,z&&le(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),fe(e)){var n=!1;h.getEvents().forEach((function(e){fe(e)&&h.getEventListenerCount(e)>0&&(n=!0)})),n||(g=!1,d&&void 0===J&&ue())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,le())},flush:function(e){return R(b?A.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!_)return e;for(var n in _)C(_,n)&&(e[n]=te(n,null,!w.sendEventsOnlyForVariation).value);return e},close:function(e){if(M)return R(Promise.resolve(),e);var n=function(){M=!0,_={}};return R(Promise.resolve().then((function(){if(ue(),N&&N.stop(),b)return A.stop(),A.flush()})).then(n).catch(n),e)}},options:w,emitter:h,ident:X,logger:m,requestor:q,start:function(){b&&(N&&N.start(),A.start())},enqueueEvent:Q,getFlagsInternal:function(){return _},getEnvironmentId:function(){return E},internalChangeEventName:"internal-change"}}function Ne(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Le(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 Fe(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Le(Object(t),!0).forEach((function(n){Ne(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Le(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Ce={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function xe(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 Ce;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),Ce;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 Ae(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,xe(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=Fe(Fe({},{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.18.1",t.diagnosticSdkData={name:"js-client-sdk",version:"2.18.1"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var qe=/[|\\{}()[\]^$+*?.]/g,Ve=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(qe,"\\$&")};function _e(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Ve(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Ve(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Ve(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Je(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(_e(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}function ze(e,n){var t,r,o={};function i(){r&&r.dispose(),t&&t.length&&(r=Je(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Je(t=e,a),function(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout((function(){e(n,t)}),t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(300,i)),n()})).catch((function(t){e.emitter.maybeReportError(new v.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),o}var Me={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function $e(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Ae(t),o=Te(e,n,t,r,Me),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()}))}));if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=ze(o,(function(){return u.emit("goalsReady")}));r.customEventFilter=c.goalKeyExists}else u.emit("goalsReady");"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var He=Ie,Ke="2.18.1";var Be={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Ee.deprecated("default export","named LDClient export")),$e(e,n,t)},version:"2.18.1"};export default Be;export{He as createConsoleLogger,$e as initialize,Ke 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 X(e){return(X="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 W(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(i,!0).forEach(function(e){var n,t,r;n=o,r=i[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):n(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var Q=t("LaunchDarklyUnexpectedResponseError"),Y=t("LaunchDarklyInvalidEnvironmentIdError"),a=t("LaunchDarklyInvalidUserError"),Z=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),ee=t("LaunchDarklyFlagFetchError");function ne(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:Q,LDInvalidEnvironmentIdError:Y,LDInvalidUserError:a,LDInvalidEventKeyError:Z,LDInvalidArgumentError:d,LDFlagFetchError:ee,isHttpErrorRecoverable:ne}),r=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(f(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"=")),o.join("")},u=[],o=[],i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=i.length;c<l;++c)u[c]=i[c],o[i.charCodeAt(c)]=c;function f(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(u[(o=r)>>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63;var g=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,v=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function h(e){var n=unescape(encodeURIComponent(e));return r(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function te(e){return JSON.parse(JSON.stringify(e))}function re(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=g(n),u=g(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=p(n);if((o=v.length)!==p(t).length)return!1;for(r=o;0!=r--;)if(!m.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function oe(e){setTimeout(e,0)}function ie(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function y(e){var n={};for(var t in e)se(e,t)&&(n[t]={value:e[t],version:0});return n}function ae(e){var n={};for(var t in e)se(e,t)&&(n[t]=e[t].value);return n}function w(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function b(e){var n=e.version||"3.2.9";return e.userAgent+"/"+n}function P(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":b(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function ue(){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 W({},e,{},n)},{})}function se(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ce(e){if(!e)return e;var n;for(var t in v){var r=v[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||W({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:h,base64URLEncode:D,clone:te,deepEquals:re,onNextTick:oe,wrapPromiseCallback:ie,transformValuesToVersionedValues:y,transformVersionedValuesToValues:ae,chunkUserEventsForUrl:w,getLDUserAgentString:b,getLDHeaders:P,extend:ue,objectHasOwnProperty:se,sanitizeUser:ce});for(var E,k=(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),S=[],O=0;O<256;++O)S[O]=(O+256).toString(16).substr(1);var U,j,R=0,I=0,T=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||U,a=void 0!==e.clockseq?e.clockseq:j;if(null==i||null==a){var u=k();null==i&&(i=U=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=j=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:I+1,l=s-R+(c-I)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||R<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");R=s,j=a;var f=(1e4*(268435455&(s+=122192928e5))+(I=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=S;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(o)};function le(u,e,n){var t="/a/"+e+".gif",s=ue({"Content-Type":"application/json"},P(u,n)),c=u.httpFallbackPing,l={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:T();return n?function n(t){var e=o?s:ue({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&ne(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(){}):(c&&c(r+t+"?d="+D(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:w(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],n,t,o));return Promise.all(i)}};return l}function fe(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=ue({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function N(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var L=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",F=function(e){return'Expected application/json content type but got "'+e+'"'},C=function(e){return"network error"+(e?" ("+e+")":"")},ve=function(e){return'Custom event "'+e+'" does not exist'},x=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+L},de=function(){return"No environment/client-side ID was specified."+L},ge=function(e){return"Error fetching flag settings: "+N(e)},A=function(){return"No user specified."+L},q=function(){return"Invalid user specified."+L},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+L},_=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+" - "+(ne(e)?t:"giving up permanently")},V=function(){return"Cannot make HTTP requests in this environment."+L},J=function(e){return"Opening stream connection to "+e},z=function(e,n){return"Error on stream connection: "+N(e)+", will continue retrying every "+n+" milliseconds."},M=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"},H=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},K=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},B=function(e){return"polling for feature flags at "+e},he=function(e){return'received streaming update for flag "'+e+'"'},ye=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},we=function(e){return'received streaming deletion for flag "'+e+'"'},be=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ee=function(e){return'enqueueing "'+e+'" event'},ke=function(e){return"sending "+e+" events"},G=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/docs/js-sdk-reference#section-analytics-events"},invalidContentType:F,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:function(){return"localStorage is unavailable"},localStorageUnavailableForUserId:function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError:C,unknownCustomEventKey:ve,environmentNotFound:x,environmentNotSpecified:de,errorFetchingFlags:ge,userNotSpecified:A,invalidUser:q,bootstrapOldFormat:pe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:_,httpErrorMessage:me,httpUnavailable:V,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:J,streamError:z,unknownOption:M,wrongOptionType:$,wrongOptionTypeBoolean:H,optionBelowMinimum:K,debugPolling:B,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:he,debugStreamPatchIgnored:ye,debugStreamDelete:we,debugStreamDeleteIgnored:be,debugEnqueueingEvent:Ee,debugPostingEvents:ke,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Se=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 De(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||h(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=y(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.saveFlags=function(e){var n=ue({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u}function Pe(o,e,i,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=P(o,e),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(s.warn(z(e,r)),d=!0),S(!1),k(),b(r)}function b(e){p||(e?p=setTimeout(E,e):E())}function E(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),l?o.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(m)):(e=u+"/ping/"+i,n=""):e=c+"/"+D(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,k(),s.info(J(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,t),y)se(y,r)&&g.addEventListener(r,y[r]);g.onerror=w}}function k(){g&&(s.info("Closing stream connection"),g.close(),g=null)}function S(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){m=e,h=n,y={};function r(n){y[n]=function(e){S(!(d=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);b()},t.disconnect=function(){clearTimeout(p),p=null,k()},t.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},t}function Oe(d,g,a){var u=g.baseUrl,s=g.useReport,c=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ee(V()))});var t=n?"REPORT":"GET",r=P(d,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=d.httpRequest(t,e,r,n),v=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new Y(x()):new ee(ge(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 ee(t))},function(e){return Promise.reject(new ee(C(e)))});return l.addPromise(v,function(){f.cancel&&f.cancel()}),l.resultPromise}return e.fetchJSON=function(e){return f(u+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return s?(r=[u,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=D(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(B(r)),f(r,o)},e}function Ue(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new a(A()));var r=te(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get("ld:$anonUserId").catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=T();return r.key=t,(n=t,o?o.set("ld:$anonUserId",n).catch(function(){i.warn("localStorage is unavailable, so anonymous user ID cannot be cached")}):Promise.resolve()).then(function(){return r})}):Promise.reject(new a(q()))},e}var je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Re(e,n,t,r){var a=ue({logger:{default:r}},je,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){oe(function(){n&&n.maybeReportError(new d(e))})}var s,c,i,l,f=ue({},e||{});return l=f,Object.keys(o).forEach(function(e){if(void 0!==l[e]){var n=o[e];r&&r.warn(_(e,n)),n&&(void 0===l[n]&&(l[n]=l[e]),delete l[e])}}),i=ue({},f),Object.keys(a).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=a[e]&&a[e].default)}),s=f=i,c=ue({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(M(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(H(e,i))):(u($(e,r,i)),c[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(K(e,n,t.minimum)),c[e]=t.minimum)}}}}),c;function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=X(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}}var Ie=Object.freeze({__proto__:null,baseOptionDefs:je,validate:Re}).baseOptionDefs,Te=function(e){var n={diagnosticId:T()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Ne=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}},Le=function(r,e,n,t,o,i){var a,u,s=!!r.diagnosticUseCombinedEvent,c="ld:"+t+":$diagnostics",l=o.eventsUrl+"/events/diagnostic/"+t,f=o.diagnosticRecordingInterval,v=e,d=!!o.streaming,g={};function p(){return{sdk:function(){var e=W({},r.diagnosticSdkData);return o.wrapperName&&(e.wrapperName=o.wrapperName),o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion),e}(),configuration:(e={customBaseURI:o.baseUrl!==Ie.baseUrl.default,customStreamURI:o.streamUrl!==Ie.streamUrl.default,customEventsURI:o.eventsUrl!==Ie.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!d,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation},e),platform:r.diagnosticPlatformData};var e}function m(e){o.logger&&o.logger.debug(G.debugPostingDiagnosticEvent(e)),n.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function h(){var e,n;m((e=(new Date).getTime(),n=W({kind:s?"diagnostic-combined":"diagnostic",id:i,creationDate:e},v.getProps()),s&&(n=W({},n,{},p())),v.reset(e),n)),u=setTimeout(h,f),a=(new Date).getTime(),s&&function(){if(r.localStorage){var e=W({},v.getProps());r.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){s?function(t){if(!r.localStorage)return t(!1);r.localStorage.get(c).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),a=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(a||0)+f,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,f)}):(m(W({kind:"diagnostic-init",id:i,creationDate:v.getProps().dataSinceDate},p())),u=setTimeout(h,f))},g.stop=function(){u&&clearTimeout(u)},g.setStreaming=function(e){d=e},g};function Fe(e,n){var i,a=["debug","info","warn","error"];i=null!=n?""===n?"":n+" ":"LD: ";var u=0;e&&(u="none"===e?100:a.indexOf(e));var t={};function r(e,n,t){if(u<=e&&console){var r=console[n];if(r){var o=e<a.length?a[e]:"?";r.call(console,i+"["+o+"] "+t)}}}return t.debug=function(e){return r(0,"log",e)},t.info=function(e){return r(1,"info",e)},t.warn=function(e){return r(2,"warn",e)},t.error=function(e){return r(3,"error",e)},t}function Ce(e,n,t,o,r){var a,i,u,s,c,l,f=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||Fe("warn"),v=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}(f),d=Se(v),g=Re(t,v,r,f),p=g.sendEvents,m=e,h=g.hash,y=le(o,m,g),w=g.sendEvents&&!g.diagnosticOptOut,b=w?Te(m):null,E=w?Ne((new Date).getTime()):null,k=w?Le(o,E,y,m,g,b):null,S=Pe(o,g,m,E),D=g.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)||le(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=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}(),d=fe(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,E=!1,k=!1;function S(){return 0===p||0===Math.floor(Math.random()*p)}function D(e){w.length<m?(w.push(e),k=!1):(k||(k=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.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&&D(function(e){var n=ue({},e);return 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}(e)),t){var r=ue({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,D(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=w,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(ke(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(b=e.serverTime),ne(e.status)||(E=!0),400<=e.status&&oe(function(){s.maybeReportError(new Q(me(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}(o,g,m,E,v,y),P=Oe(o,g,m),O={},U={},j=g.streaming,R=!1,I=!1,T=!0,N=g.stateProvider,L=(c=function(e){N||e&&C({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(l=ce(e))&&c&&c(te(l))},getUser:function(){return l?te(l):null}}),F=Ue(o.localStorage,f);function C(e){m&&(N&&N.enqueueEvent&&N.enqueueEvent(e)||(e.user?(T=!1,!p||I||o.isDoNotTrack()||(f.debug(Ee(e.kind)),D.enqueue(e))):T&&(f.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),T=!1)))}function x(e,n,t,r){var o=L.getUser(),i=new Date,a=n?n.value:null;if(!g.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=O[u];if(s&&i-s<3e5)return;O[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=U[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),C(c)}function A(e,n,t,r){var o;if(U&&se(U,e)&&U[e]&&!U[e].deleted){var i=U[e];o=q(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&&x(e,o,n,r),o}function q(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function _(){i=!0,L.getUser()&&S.connect(L.getUser(),h,{ping:function(){f.debug("received ping message from stream"),P.fetchFlagSettings(L.getUser(),h).then(function(e){return J(e||{})}).catch(function(e){v.maybeReportError(new ee(ge(e)))})},put:function(e){var n=JSON.parse(e.data);f.debug("received streaming update for all flags"),J(n)},patch:function(e){var n=JSON.parse(e.data),t=U[n.key];if(!t||!t.version||!n.version||t.version<n.version){f.debug(he(n.key));var r={},o=ue({},n);delete o.key;var i=q(U[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},z(r)}else f.debug(ye(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!U[n.key]||U[n.key].version<n.version){f.debug(we(n.key));var t={};U[n.key]&&!U[n.key].deleted&&(t[n.key]={previous:U[n.key].value}),U[n.key]={version:n.version,deleted:!0},z(t)}else f.debug(be(n.key))}})}function V(){i&&(S.disconnect(),i=!1)}function J(e){var n={};if(!e)return Promise.resolve();for(var t in U)se(U,t)&&U[t]&&(e[t]&&!re(e[t].value,U[t].value)?n[t]={previous:U[t].value,current:q(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:U[t].value}));for(var r in e)se(e,r)&&e[r]&&(!U[r]||U[r].deleted)&&(n[r]={current:q(e[r])});return U=W({},e),z(n).catch(function(){})}function z(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;v.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),v.emit("change",i),v.emit("internal-change",U),g.sendEventsOnlyForVariation||N||e.forEach(function(e){x(e,o[e].current)})}return a&&s?s.saveFlags(U).catch(function(){return null}):Promise.resolve()}function M(){var e=j||u&&void 0===j;e&&!i?_():!e&&i&&V(),k&&k.setStreaming(e)}function $(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(o.localStorage&&(s=new De(o.localStorage,m,h,L,f)),"string"==typeof g.bootstrap&&"LOCALSTORAGE"===g.bootstrap.toUpperCase()&&(s?a=!0:f.warn("localStorage is unavailable")),"object"===X(g.bootstrap)&&(U=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&f.warn(pe()),!1===t.$valid&&f.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=ue(n,r[e]):n.version=0,o[e]=n}}),o}(g.bootstrap)),N){var H=N.getInitialState();H?K(H):N.on("init",K),N.on("update",function(e){e.user&&L.setUser(e.user),e.flags&&J(e.flags)})}else(e?F.validateUser(n).then(function(e){return L.setUser(e),"object"===X(g.bootstrap)?B():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(U={},P.fetchFlagSettings(L.getUser(),h).then(function(e){return J(e||{})}).then(B).catch(function(e){G(new ee(ge(e)))})):(U=e,oe(B),P.fetchFlagSettings(L.getUser(),h).then(function(e){return J(e)}).catch(function(e){return v.maybeReportError(e)}))}):P.fetchFlagSettings(L.getUser(),h).then(function(e){U=e||{},B()}).catch(function(e){U={},G(e)})}):Promise.reject(new Y(de()))).catch(G);function K(e){m=e.environment,L.setUser(e.user),U=W({},e.flags),oe(B)}function B(){f.info("LaunchDarkly client initialized"),R=!0,M(),d.signalSuccess()}function G(e){d.signalFailure(e)}return{client:{waitForInitialization:function(){return d.getInitializationPromise()},waitUntilReady:function(){return d.getReadyPromise()},identify:function(e,r,n){return I?ie(Promise.resolve({}),n):N?(f.warn("identify() has no effect here; it must be called on the main client instance"),ie(Promise.resolve(ae(U)),n)):ie((a&&s?s.clearFlags():Promise.resolve()).then(function(){return F.validateUser(e)}).then(function(t){return P.fetchFlagSettings(t,r).then(function(e){var n=ae(e);return L.setUser(t),h=r,e?J(e).then(function(){return n}):n})}).then(function(e){return i&&_(),e}).catch(function(e){return v.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return L.getUser()},variation:function(e,n){return A(e,n,!0,!1).value},variationDetail:function(e,n){return A(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&f.warn(ve(e));var r={kind:"custom",key:e,user:L.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),C(r)}else v.maybeReportError(new Z(ve(e)))},on:function(e,n,t){$(e)?(u=!0,R&&M(),v.on(e,n,t)):v.on.apply(v,arguments)},off:function(e){if(v.off.apply(v,arguments),$(e)){var n=!1;v.getEvents().forEach(function(e){$(e)&&0<v.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===j&&V())}},setStreaming:function(e){var n=null===e?void 0:e;n!==j&&(j=n,M())},flush:function(e){return ie(p?D.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!U)return e;for(var n in U)se(U,n)&&(e[n]=A(n,null,!g.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return ie(Promise.resolve(),e);function n(){I=!0,U={}}return ie(Promise.resolve().then(function(){if(V(),k&&k.stop(),p)return D.stop(),D.flush()}).then(n).catch(n),e)}},options:g,emitter:v,ident:L,logger:f,requestor:P,start:function(){p&&(k&&k.start(),D.start())},enqueueEvent:C,getFlagsInternal:function(){return U},getEnvironmentId:function(){return m},internalChangeEventName:"internal-change"}}function xe(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 Ae(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?xe(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)):xe(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var qe={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 qe;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),qe;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 Ve=/[|\\{}()[\]^$+*?.]/g,Je=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Ve,"\\$&")};function ze(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Je(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Je(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Je(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Me(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(ze(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 $e=300;function He(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=Me(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=Me(t=e,a),u($e,i)),n()}).catch(function(e){r.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var Ke="goalsReady",Be={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function Ge(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,_e(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=Ae({},{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.18.0",i.diagnosticSdkData={name:"js-client-sdk",version:"2.18.0"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}(t),o=Ce(e,n,t,r,Be),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(Ke,function(){u.off(Ke,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=He(o,function(){return u.emit(Ke)});r.customEventFilter=c.goalKeyExists}else u.emit(Ke);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var Xe=Fe;var We={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(G.deprecated("default export","named LDClient export")),Ge(e,n,t)},version:"2.18.0"};e.createConsoleLogger=Xe,e.default=We,e.initialize=Ge,e.version="2.18.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).LDClient={})}(this,function(e){"use strict";function X(e){return(X="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 W(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(i,!0).forEach(function(e){var n,t,r;n=o,r=i[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):n(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var Q=t("LaunchDarklyUnexpectedResponseError"),Y=t("LaunchDarklyInvalidEnvironmentIdError"),a=t("LaunchDarklyInvalidUserError"),Z=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),ee=t("LaunchDarklyFlagFetchError");function ne(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:Q,LDInvalidEnvironmentIdError:Y,LDInvalidUserError:a,LDInvalidEventKeyError:Z,LDInvalidArgumentError:d,LDFlagFetchError:ee,isHttpErrorRecoverable:ne}),r=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(f(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"=")),o.join("")},u=[],o=[],i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=i.length;c<l;++c)u[c]=i[c],o[i.charCodeAt(c)]=c;function f(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(u[(o=r)>>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63;var g=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,v=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function h(e){var n=unescape(encodeURIComponent(e));return r(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function te(e){return JSON.parse(JSON.stringify(e))}function re(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=g(n),u=g(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=p(n);if((o=v.length)!==p(t).length)return!1;for(r=o;0!=r--;)if(!m.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function oe(e){setTimeout(e,0)}function ie(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function y(e){var n={};for(var t in e)se(e,t)&&(n[t]={value:e[t],version:0});return n}function ae(e){var n={};for(var t in e)se(e,t)&&(n[t]=e[t].value);return n}function w(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function b(e){var n=e.version||"3.2.10";return e.userAgent+"/"+n}function P(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":b(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function ue(){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 W({},e,{},n)},{})}function se(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ce(e){if(!e)return e;var n;for(var t in v){var r=v[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||W({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:h,base64URLEncode:D,clone:te,deepEquals:re,onNextTick:oe,wrapPromiseCallback:ie,transformValuesToVersionedValues:y,transformVersionedValuesToValues:ae,chunkUserEventsForUrl:w,getLDUserAgentString:b,getLDHeaders:P,extend:ue,objectHasOwnProperty:se,sanitizeUser:ce});for(var E,k=(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),S=[],O=0;O<256;++O)S[O]=(O+256).toString(16).substr(1);var U,j,R=0,I=0,T=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||U,a=void 0!==e.clockseq?e.clockseq:j;if(null==i||null==a){var u=k();null==i&&(i=U=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=j=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:I+1,l=s-R+(c-I)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||R<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");R=s,j=a;var f=(1e4*(268435455&(s+=122192928e5))+(I=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=S;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(o)};function le(u,e,n){var t="/a/"+e+".gif",s=ue({"Content-Type":"application/json"},P(u,n)),c=u.httpFallbackPing,l={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:T();return n?function n(t){var e=o?s:ue({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&ne(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(){}):(c&&c(r+t+"?d="+D(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:w(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],n,t,o));return Promise.all(i)}};return l}function fe(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=ue({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function N(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var L=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",F=function(e){return'Expected application/json content type but got "'+e+'"'},C=function(e){return"network error"+(e?" ("+e+")":"")},ve=function(e){return'Custom event "'+e+'" does not exist'},x=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+L},de=function(){return"No environment/client-side ID was specified."+L},ge=function(e){return"Error fetching flag settings: "+N(e)},A=function(){return"No user specified."+L},q=function(){return"Invalid user specified."+L},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+L},_=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+" - "+(ne(e)?t:"giving up permanently")},V=function(){return"Cannot make HTTP requests in this environment."+L},J=function(e){return"Opening stream connection to "+e},z=function(e,n){return"Error on stream connection: "+N(e)+", will continue retrying every "+n+" milliseconds."},M=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"},H=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},K=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},B=function(e){return"polling for feature flags at "+e},he=function(e){return'received streaming update for flag "'+e+'"'},ye=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},we=function(e){return'received streaming deletion for flag "'+e+'"'},be=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ee=function(e){return'enqueueing "'+e+'" event'},ke=function(e){return"sending "+e+" events"},G=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/docs/js-sdk-reference#section-analytics-events"},invalidContentType:F,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:function(){return"localStorage is unavailable"},localStorageUnavailableForUserId:function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError:C,unknownCustomEventKey:ve,environmentNotFound:x,environmentNotSpecified:de,errorFetchingFlags:ge,userNotSpecified:A,invalidUser:q,bootstrapOldFormat:pe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:_,httpErrorMessage:me,httpUnavailable:V,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:J,streamError:z,unknownOption:M,wrongOptionType:$,wrongOptionTypeBoolean:H,optionBelowMinimum:K,debugPolling:B,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:he,debugStreamPatchIgnored:ye,debugStreamDelete:we,debugStreamDeleteIgnored:be,debugEnqueueingEvent:Ee,debugPostingEvents:ke,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Se=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 De(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||h(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=y(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.saveFlags=function(e){var n=ue({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u}function Pe(o,e,i,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=P(o,e),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(s.warn(z(e,r)),d=!0),S(!1),k(),b(r)}function b(e){p||(e?p=setTimeout(E,e):E())}function E(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),l?o.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(m)):(e=u+"/ping/"+i,n=""):e=c+"/"+D(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,k(),s.info(J(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,t),y)se(y,r)&&g.addEventListener(r,y[r]);g.onerror=w}}function k(){g&&(s.info("Closing stream connection"),g.close(),g=null)}function S(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){m=e,h=n,y={};function r(n){y[n]=function(e){S(!(d=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);b()},t.disconnect=function(){clearTimeout(p),p=null,k()},t.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},t}function Oe(d,g,a){var u=g.baseUrl,s=g.useReport,c=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ee(V()))});var t=n?"REPORT":"GET",r=P(d,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=d.httpRequest(t,e,r,n),v=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new Y(x()):new ee(ge(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 ee(t))},function(e){return Promise.reject(new ee(C(e)))});return l.addPromise(v,function(){f.cancel&&f.cancel()}),l.resultPromise}return e.fetchJSON=function(e){return f(u+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return s?(r=[u,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=D(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(B(r)),f(r,o)},e}function Ue(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new a(A()));var r=te(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get("ld:$anonUserId").catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=T();return r.key=t,(n=t,o?o.set("ld:$anonUserId",n).catch(function(){i.warn("localStorage is unavailable, so anonymous user ID cannot be cached")}):Promise.resolve()).then(function(){return r})}):Promise.reject(new a(q()))},e}var je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Re(e,n,t,r){var a=ue({logger:{default:r}},je,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){oe(function(){n&&n.maybeReportError(new d(e))})}var s,c,i,l,f=ue({},e||{});return l=f,Object.keys(o).forEach(function(e){if(void 0!==l[e]){var n=o[e];r&&r.warn(_(e,n)),n&&(void 0===l[n]&&(l[n]=l[e]),delete l[e])}}),i=ue({},f),Object.keys(a).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=a[e]&&a[e].default)}),s=f=i,c=ue({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(M(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(H(e,i))):(u($(e,r,i)),c[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(K(e,n,t.minimum)),c[e]=t.minimum)}}}}),c;function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=X(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}}var Ie=Object.freeze({__proto__:null,baseOptionDefs:je,validate:Re}).baseOptionDefs,Te=function(e){var n={diagnosticId:T()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Ne=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}},Le=function(r,e,n,t,o,i){var a,u,s=!!r.diagnosticUseCombinedEvent,c="ld:"+t+":$diagnostics",l=o.eventsUrl+"/events/diagnostic/"+t,f=o.diagnosticRecordingInterval,v=e,d=!!o.streaming,g={};function p(){return{sdk:function(){var e=W({},r.diagnosticSdkData);return o.wrapperName&&(e.wrapperName=o.wrapperName),o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion),e}(),configuration:(e={customBaseURI:o.baseUrl!==Ie.baseUrl.default,customStreamURI:o.streamUrl!==Ie.streamUrl.default,customEventsURI:o.eventsUrl!==Ie.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!d,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation},e),platform:r.diagnosticPlatformData};var e}function m(e){o.logger&&o.logger.debug(G.debugPostingDiagnosticEvent(e)),n.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function h(){var e,n;m((e=(new Date).getTime(),n=W({kind:s?"diagnostic-combined":"diagnostic",id:i,creationDate:e},v.getProps()),s&&(n=W({},n,{},p())),v.reset(e),n)),u=setTimeout(h,f),a=(new Date).getTime(),s&&function(){if(r.localStorage){var e=W({},v.getProps());r.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){s?function(t){if(!r.localStorage)return t(!1);r.localStorage.get(c).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),a=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(a||0)+f,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,f)}):(m(W({kind:"diagnostic-init",id:i,creationDate:v.getProps().dataSinceDate},p())),u=setTimeout(h,f))},g.stop=function(){u&&clearTimeout(u)},g.setStreaming=function(e){d=e},g};function Fe(e,n){var i,a=["debug","info","warn","error"];i=null!=n?""===n?"":n+" ":"LD: ";var u=0;e&&(u="none"===e?100:a.indexOf(e));var t={};function r(e,n,t){if(u<=e&&console){var r=console[n];if(r){var o=e<a.length?a[e]:"?";r.call(console,i+"["+o+"] "+t)}}}return t.debug=function(e){return r(0,"log",e)},t.info=function(e){return r(1,"info",e)},t.warn=function(e){return r(2,"warn",e)},t.error=function(e){return r(3,"error",e)},t}function Ce(e,n,t,o,r){var a,i,u,s,c,l,f=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||Fe("warn"),v=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}(f),d=Se(v),g=Re(t,v,r,f),p=g.sendEvents,m=e,h=g.hash,y=le(o,m,g),w=g.sendEvents&&!g.diagnosticOptOut,b=w?Te(m):null,E=w?Ne((new Date).getTime()):null,k=w?Le(o,E,y,m,g,b):null,S=Pe(o,g,m,E),D=g.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)||le(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=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}(),d=fe(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,E=!1,k=!1;function S(){return 0===p||0===Math.floor(Math.random()*p)}function D(e){w.length<m?(w.push(e),k=!1):(k||(k=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.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&&D(function(e){var n=ue({},e);return 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}(e)),t){var r=ue({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,D(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=w,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(ke(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(b=e.serverTime),ne(e.status)||(E=!0),400<=e.status&&oe(function(){s.maybeReportError(new Q(me(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}(o,g,m,E,v,y),P=Oe(o,g,m),O={},U={},j=g.streaming,R=!1,I=!1,T=!0,N=g.stateProvider,L=(c=function(e){N||e&&C({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(l=ce(e))&&c&&c(te(l))},getUser:function(){return l?te(l):null}}),F=Ue(o.localStorage,f);function C(e){m&&(N&&N.enqueueEvent&&N.enqueueEvent(e)||(e.user?(T=!1,!p||I||o.isDoNotTrack()||(f.debug(Ee(e.kind)),D.enqueue(e))):T&&(f.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),T=!1)))}function x(e,n,t,r){var o=L.getUser(),i=new Date,a=n?n.value:null;if(!g.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=O[u];if(s&&i-s<3e5)return;O[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=U[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),C(c)}function A(e,n,t,r){var o;if(U&&se(U,e)&&U[e]&&!U[e].deleted){var i=U[e];o=q(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&&x(e,o,n,r),o}function q(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function _(){i=!0,L.getUser()&&S.connect(L.getUser(),h,{ping:function(){f.debug("received ping message from stream");var n=L.getUser();P.fetchFlagSettings(n,h).then(function(e){re(n,L.getUser())&&J(e||{})}).catch(function(e){v.maybeReportError(new ee(ge(e)))})},put:function(e){var n=JSON.parse(e.data);f.debug("received streaming update for all flags"),J(n)},patch:function(e){var n=JSON.parse(e.data),t=U[n.key];if(!t||!t.version||!n.version||t.version<n.version){f.debug(he(n.key));var r={},o=ue({},n);delete o.key;var i=q(U[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},z(r)}else f.debug(ye(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!U[n.key]||U[n.key].version<n.version){f.debug(we(n.key));var t={};U[n.key]&&!U[n.key].deleted&&(t[n.key]={previous:U[n.key].value}),U[n.key]={version:n.version,deleted:!0},z(t)}else f.debug(be(n.key))}})}function V(){i&&(S.disconnect(),i=!1)}function J(e){var n={};if(!e)return Promise.resolve();for(var t in U)se(U,t)&&U[t]&&(e[t]&&!re(e[t].value,U[t].value)?n[t]={previous:U[t].value,current:q(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:U[t].value}));for(var r in e)se(e,r)&&e[r]&&(!U[r]||U[r].deleted)&&(n[r]={current:q(e[r])});return U=W({},e),z(n).catch(function(){})}function z(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;v.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),v.emit("change",i),v.emit("internal-change",U),g.sendEventsOnlyForVariation||N||e.forEach(function(e){x(e,o[e].current)})}return a&&s?s.saveFlags(U).catch(function(){return null}):Promise.resolve()}function M(){var e=j||u&&void 0===j;e&&!i?_():!e&&i&&V(),k&&k.setStreaming(e)}function $(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(o.localStorage&&(s=new De(o.localStorage,m,h,L,f)),"string"==typeof g.bootstrap&&"LOCALSTORAGE"===g.bootstrap.toUpperCase()&&(s?a=!0:f.warn("localStorage is unavailable")),"object"===X(g.bootstrap)&&(U=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&f.warn(pe()),!1===t.$valid&&f.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=ue(n,r[e]):n.version=0,o[e]=n}}),o}(g.bootstrap)),N){var H=N.getInitialState();H?K(H):N.on("init",K),N.on("update",function(e){e.user&&L.setUser(e.user),e.flags&&J(e.flags)})}else(e?F.validateUser(n).then(function(e){return L.setUser(e),"object"===X(g.bootstrap)?B():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(U={},P.fetchFlagSettings(L.getUser(),h).then(function(e){return J(e||{})}).then(B).catch(function(e){G(new ee(ge(e)))})):(U=e,oe(B),P.fetchFlagSettings(L.getUser(),h).then(function(e){return J(e)}).catch(function(e){return v.maybeReportError(e)}))}):P.fetchFlagSettings(L.getUser(),h).then(function(e){U=e||{},B()}).catch(function(e){U={},G(e)})}):Promise.reject(new Y(de()))).catch(G);function K(e){m=e.environment,L.setUser(e.user),U=W({},e.flags),oe(B)}function B(){f.info("LaunchDarkly client initialized"),R=!0,M(),d.signalSuccess()}function G(e){d.signalFailure(e)}return{client:{waitForInitialization:function(){return d.getInitializationPromise()},waitUntilReady:function(){return d.getReadyPromise()},identify:function(e,r,n){return I?ie(Promise.resolve({}),n):N?(f.warn("identify() has no effect here; it must be called on the main client instance"),ie(Promise.resolve(ae(U)),n)):ie((a&&s?s.clearFlags():Promise.resolve()).then(function(){return F.validateUser(e)}).then(function(t){return P.fetchFlagSettings(t,r).then(function(e){var n=ae(e);return L.setUser(t),h=r,e?J(e).then(function(){return n}):n})}).then(function(e){return i&&_(),e}).catch(function(e){return v.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return L.getUser()},variation:function(e,n){return A(e,n,!0,!1).value},variationDetail:function(e,n){return A(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&f.warn(ve(e));var r={kind:"custom",key:e,user:L.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),C(r)}else v.maybeReportError(new Z(ve(e)))},on:function(e,n,t){$(e)?(u=!0,R&&M(),v.on(e,n,t)):v.on.apply(v,arguments)},off:function(e){if(v.off.apply(v,arguments),$(e)){var n=!1;v.getEvents().forEach(function(e){$(e)&&0<v.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===j&&V())}},setStreaming:function(e){var n=null===e?void 0:e;n!==j&&(j=n,M())},flush:function(e){return ie(p?D.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!U)return e;for(var n in U)se(U,n)&&(e[n]=A(n,null,!g.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return ie(Promise.resolve(),e);function n(){I=!0,U={}}return ie(Promise.resolve().then(function(){if(V(),k&&k.stop(),p)return D.stop(),D.flush()}).then(n).catch(n),e)}},options:g,emitter:v,ident:L,logger:f,requestor:P,start:function(){p&&(k&&k.start(),D.start())},enqueueEvent:C,getFlagsInternal:function(){return U},getEnvironmentId:function(){return m},internalChangeEventName:"internal-change"}}function xe(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 Ae(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?xe(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)):xe(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var qe={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 qe;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),qe;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 Ve=/[|\\{}()[\]^$+*?.]/g,Je=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Ve,"\\$&")};function ze(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Je(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Je(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Je(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Me(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(ze(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 $e=300;function He(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=Me(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=Me(t=e,a),u($e,i)),n()}).catch(function(e){r.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var Ke="goalsReady",Be={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function Ge(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,_e(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=Ae(Ae({},{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.18.1",i.diagnosticSdkData={name:"js-client-sdk",version:"2.18.1"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}(t),o=Ce(e,n,t,r,Be),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(Ke,function(){u.off(Ke,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=He(o,function(){return u.emit(Ke)});r.customEventFilter=c.goalKeyExists}else u.emit(Ke);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var Xe=Fe;var We={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(G.deprecated("default export","named LDClient export")),Ge(e,n,t)},version:"2.18.1"};e.createConsoleLogger=Xe,e.default=We,e.initialize=Ge,e.version="2.18.1",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient.min.js.map |
{ | ||
"name": "launchdarkly-js-client-sdk", | ||
"version": "2.18.0", | ||
"version": "2.18.1", | ||
"description": "LaunchDarkly SDK for JavaScript", | ||
@@ -44,12 +44,12 @@ "author": "LaunchDarkly <team@launchdarkly.com>", | ||
"devDependencies": { | ||
"@babel/cli": "^7.6.4", | ||
"@babel/core": "^7.6.4", | ||
"@babel/plugin-transform-regenerator": "7.4.5", | ||
"@babel/plugin-transform-runtime": "7.6.2", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/runtime": "^7.6.3", | ||
"@babel/cli": "^7.11.6", | ||
"@babel/core": "^7.11.6", | ||
"@babel/plugin-transform-regenerator": "7.10.4", | ||
"@babel/plugin-transform-runtime": "7.11.5", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/runtime": "^7.11.2", | ||
"@rollup/plugin-node-resolve": "^6.0.0", | ||
"@rollup/plugin-replace": "^2.2.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-jest": "^24.9.0", | ||
"babel-jest": "^26.3.0", | ||
"chai": "^4.1.2", | ||
@@ -63,5 +63,5 @@ "cross-env": "^5.1.4", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"jest": "^24.9.0", | ||
"jest-junit": "^9.0.0", | ||
"jest-localstorage-mock": "^2.4.0", | ||
"jest": "^26.4.2", | ||
"jest-junit": "^11.1.0", | ||
"jest-localstorage-mock": "^2.4.3", | ||
"jsdom": "^11.12.0", | ||
@@ -76,4 +76,4 @@ "prettier": "1.11.1", | ||
"rollup-plugin-node-globals": "^1.4.0", | ||
"rollup-plugin-terser": "^5.1.2", | ||
"rollup-plugin-uglify": "^6.0.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-uglify": "^6.0.4", | ||
"semver": "^7.1.3", | ||
@@ -86,3 +86,3 @@ "semver-compare": "^1.0.0", | ||
"escape-string-regexp": "^1.0.5", | ||
"launchdarkly-js-sdk-common": "3.2.9" | ||
"launchdarkly-js-sdk-common": "3.2.10" | ||
}, | ||
@@ -89,0 +89,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
461400
+ Addedlaunchdarkly-js-sdk-common@3.2.10(transitive)
- Removedlaunchdarkly-js-sdk-common@3.2.9(transitive)