launchdarkly-js-client-sdk
Advanced tools
Comparing version 2.15.2 to 2.16.0
@@ -5,2 +5,17 @@ # Change log | ||
## [2.16.0] - 2019-12-16 | ||
### Added: | ||
- Configuration property `eventCapacity`: the maximum number of analytics events (not counting evaluation counters) that can be held at once, to prevent the SDK from consuming unexpected amounts of memory in case an application generates events unusually rapidly. In JavaScript code this would not normally be an issue, since the SDK flushes events every two seconds by default, but you may wish to increase this value if you will intentionally be generating a high volume of custom or identify events. The default value is 100. | ||
- Configuration properties `wrapperName` and `wrapperVersion`: used by the React SDK, and potentially by third-party libraries, to identify a JS SDK instance that is being used with a wrapper API. | ||
### Changed: | ||
- The SDK now logs a warning if any configuration property has an inappropriate type, such as `baseUri:3` or `sendEvents:"no"`. For boolean properties, the SDK will still interpret the value in terms of truthiness, which was the previous behavior. For all other types, since there's no such commonly accepted way to coerce the type, it will fall back to the default setting for that property; previously, the behavior was undefined but most such mistakes would have caused the SDK to throw an exception at some later point. | ||
- Removed or updated some development dependencies that were causing vulnerability warnings. | ||
### Fixed: | ||
- When calling `identify`, the current user (as reported by `getUser()`) was being updated before the SDK had received the new flag values for that user, causing the client to be temporarily in an inconsistent state where flag evaluations would be associated with the wrong user in analytics events. Now, the current-user state will stay in sync with the flags and change only when they have finished changing. (Thanks, [edvinerikson](https://github.com/launchdarkly/js-sdk-common/pull/3)!) | ||
### Deprecated: | ||
- The `samplingInterval` configuration property was deprecated in the code in the previous minor version release, and in the changelog, but the deprecation notice was accidentally omitted from the documentation comments. It is hereby deprecated again. | ||
## [2.15.2] - 2019-11-15 | ||
@@ -7,0 +22,0 @@ ### Fixed: |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function r(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?t(o,!0).forEach(function(e){n(r,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(o).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),s=o("LaunchDarklyInvalidEventKeyError"),c=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError: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=[],m=[],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=p.length;h<y;++h)g[h]=p[h],m[p.charCodeAt(h)]=h;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,S=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function O(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return O(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return S(e,n)}function I(e){setTimeout(e,0)}function R(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function N(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function T(e,n){for(var t,r=n.slice(0),o=[],i=e;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 L(e){var n=e.version||"2.14.1";return e.userAgent+"/"+n}function A(e){return{"X-LaunchDarkly-User-Agent":L(e)}}function C(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return r({},e,{},n)},{})}function x(e){if(!e)return e;var n;for(var t in P){var o=P[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}var q=Object.freeze({__proto__:null,btoa:O,base64URLEncode:D,clone:U,deepEquals:j,onNextTick:I,wrapPromiseCallback:R,transformValuesToVersionedValues:N,transformVersionedValuesToValues:F,chunkUserEventsForUrl:T,getLDUserAgentString:L,getLDHeaders:A,extend:C,sanitizeUser:x}),_=2e3;function J(c,l,e,v){var d=l+"/events/bulk/"+e,g=l+"/a/"+e+".gif",n={};function p(e){(new window.Image).src=e}return n.sendEvents=function(e){if(!c.httpRequest)return Promise.resolve();var n,t,r,o,i,a=c.httpAllowsPost();n=a?[e]:T(_-l.length,e);for(var u=[],s=0;s<n.length;s++)u.push((t=n[s],r=a,o=void 0,o=v||p,i=JSON.stringify(t),r?function n(t){var e=C({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},A(c));return c.httpRequest("POST",d,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(){}):(o(g+"?d="+D(i)),Promise.resolve())));return Promise.all(u)},n}function V(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=C({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var K=function(){return"LaunchDarkly client initialized"},$=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",M=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},H=function(e){return'Expected application/json content type but got "'+e+'"'},G=function(){return"localStorage is unavailable"},X=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},B=function(e){return"network error"+(e?" ("+e+")":"")},W=function(e){return'Custom event "'+e+'" does not exist'},Q=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},Y=function(){return"No environment/client-side ID was specified."+$},Z=function(e){return"Error fetching flag settings: "+z(e)},ee=function(){return"No user specified."+$},ne=function(){return"Invalid user specified."+$},te=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+$},re=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},oe=function(e,n){return n?'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"':'[LaunchDarkly] "'+e+'" is deprecated'},ie=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ae=function(){return"Cannot make HTTP requests in this environment."+$},ue=function(){return"identify() has no effect here; it must be called on the main client instance"},se=function(){return"Closing stream connection"},ce=function(e){return"Opening stream connection to "+e},le=function(e,n){return"Error on stream connection: "+z(e)+", will continue retrying every "+n+" milliseconds."},fe=function(e){return"polling for feature flags at "+e},ve=function(){return"received ping message from stream"},de=function(){return"received streaming update for all flags"},ge=function(e){return'received streaming update for flag "'+e+'"'},me=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},pe=function(e){return'received streaming deletion for flag "'+e+'"'},he=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},ye=function(e){return'enqueueing "'+e+'" event'},be=function(e){return"sending "+e+" events"},ke=Object.freeze({__proto__:null,clientInitialized:K,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventWithoutUser:M,invalidContentType:H,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:G,localStorageUnavailableForUserId:X,networkError:B,unknownCustomEventKey:W,environmentNotFound:Q,environmentNotSpecified:Y,errorFetchingFlags:Z,userNotSpecified:ee,invalidUser:ne,bootstrapOldFormat:te,bootstrapInvalid:re,deprecated:oe,httpErrorMessage:ie,httpUnavailable:ae,identifyDisabled:ue,streamClosing:se,streamConnecting:ce,streamError:le,debugPolling:fe,debugStreamPing:ve,debugStreamPut:de,debugStreamPatch:ge,debugStreamPatchIgnored:me,debugStreamDelete:pe,debugStreamDeleteIgnored:he,debugEnqueueingEvent:ye,debugPostingEvents:be});function Ee(e,n,t){var r,a,u,s,o,c=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,l={},v=(4<arguments.length&&void 0!==arguments[4]?arguments[4]:null)||J(e,n.eventsUrl,t),d=(u=a=0,s={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:u,features:e}},r.clearSummary=function(){u=a=0,s={}},r),g=V(n),p=n.inlineUsersInEvents,h=n.samplingInterval,m=n.flushInterval,y=n.logger,w=[],b=0,k=!1;function E(){return 0===h||0===Math.floor(Math.random()*h)}return l.enqueue=function(e){if(!k){var n,t=!1,r=!1;if(d.summarizeEvent(e),"feature"===e.kind?E()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>b&&n.debugEventsUntilDate>(new Date).getTime()):t=E(),t&&w.push((a=C({},i=e),p||"identify"===i.kind?a.user=g.filterUser(i.user):(a.userKey=i.user.key,delete a.user),"feature"===i.kind&&(delete a.trackEvents,delete a.debugEventsUntilDate),a)),r){var o=C({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,w.push(o)}}var i,a},l.flush=function(){if(k)return Promise.resolve();var e=w,n=d.getSummary();return d.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(w=[],y.debug(be(e.length)),v.sendEvents(e).then(function(e){e&&(e.serverTime&&(b=e.serverTime),f(e.status)||(k=!0),400<=e.status&&I(function(){c.maybeReportError(new i(ie(e.status,"event posting","some events were dropped")))}))}))},l.start=function(){o=setTimeout(function e(){l.flush(),o=setTimeout(e,m)},m)},l.stop=function(){clearTimeout(o)},l}function we(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=0;n<o[e].length;n++)o[e][n].handler.apply(o[e][n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}function Se(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||O(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=N(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(G()),Promise.reject(e)})},u.saveFlags=function(e){var n=C({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(G()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(G()),Promise.reject(e)})},u}var Pe="application/json";function Oe(p,e,u){var s=e.baseUrl,c=e.useReport,f=e.evaluationReasons,h=e.sendLDHeaders,v=e.logger,n={},m={};function d(e,n){if(!p.httpRequest)return new Promise(function(e,n){n(new l(ae()))});var t=n?"REPORT":"GET",r=h?A(p):{};n&&(r["Content-Type"]="application/json");var o,i,u,s,c,f,v=m[e];v||(o=function(){delete m[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,m[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(Q()):new l(Z(n.statusText||String(n.status))));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Pe))return JSON.parse(e.body);var n,t=H(e.header("content-type")||"");return Promise.reject(new l(t))},function(e){return Promise.reject(new l(B(e)))});return v.addPromise(g,function(){d.cancel&&d.cancel()}),v.resultPromise}return n.fetchJSON=function(e){return d(s+e,null)},n.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[s,"/sdk/evalx/",u,"/user"].join(""),o=JSON.stringify(e)):(t=D(JSON.stringify(e)),r=[s,"/sdk/evalx/",u,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(fe(r)),d(r,o)},n}for(var De=function(e,n){return function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(n={exports:{}}),n.exports}(),Ue=[],je=0;je<256;++je)Ue[je]=(je+256).toString(16).substr(1);var Ie,Re,Ne=function(e,n){var t=n||0,r=Ue;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},Fe=0,Te=0,Le=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ie,a=void 0!==e.clockseq?e.clockseq:Re;if(null==i||null==a){var u=De();null==i&&(i=Ie=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Re=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:Te+1,l=s-Fe+(c-Te)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||Fe<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Fe=s,Re=a;var f=(1e4*(268435455&(s+=122192928e5))+(Te=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||Ne(o)},Ae="ld:$anonUserId";function Ce(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new u(ee()));var r=U(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get(Ae).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=Le();return r.key=t,(n=t,o?o.set(Ae,n).catch(function(){i.warn(X())}):Promise.resolve()).then(function(){return r})}):Promise.reject(new u(ne()))},e}function xe(e,n){var o,i=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var a=0;e&&(a="none"===e?100:i.indexOf(e));var t={};function r(e,n,t){if(a<=e){var r=e<i.length?i[e]:"?";n(o+"["+r+"] "+t)}}return t.debug=function(e){return r(0,console.log,e)},t.info=function(e){return r(1,console.info,e)},t.warn=function(e){return r(2,console.warn,e)},t.error=function(e){return r(3,console.error,e)},t}var qe="ready",_e="initialized",Je="failed",Ve="change",ze="internal-change";function Ke(n,t,o,i,u){var f,v,d,g,p,h,m,y,w,b,k,E,S,P,O,T,N,L,A,q,_,z,J,V,$,H,X,B,Q,ee,ne,ie=o&&o.logger?o.logger:u&&u.logger||xe("warn"),ae=we(ie),fe=(J=o,V=ae,H=C({logger:$=ie},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},u),X={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null},ne=C({},J||{}),ee=ne,Object.keys(X).forEach(function(e){if(void 0!==ee[e]){var n=X[e];$&&$.warn(oe(e,n)),n&&(void 0===ee[n]&&(ee[n]=ee[e]),delete ee[e])}}),B=H,Q=C({},ne),Object.keys(B).forEach(function(e){void 0!==Q[e]&&null!==Q[e]||(Q[e]=B[e])}),ne=Q,(isNaN(ne.flushInterval)||ne.flushInterval<2e3)&&(ne.flushInterval=2e3,We("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(ne.samplingInterval)||ne.samplingInterval<0)&&(ne.samplingInterval=0,We("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),ne),be=fe.hash,ke=fe.sendEvents,Pe=n,De=(m=i,w=Pe,b=be,k=(y=fe).streamUrl,E=y.logger,S={},P=k+"/eval/"+w,O=y.useReport,T=y.evaluationReasons,N=y.streamReconnectDelay,L=!1,z=_=q=A=null,S.connect=function(e,t){function n(n){z[n]=function(e){L=!1,t[n]&&t[n](e)}}for(var r in _=e,z={},t||{})n(r);Me()},S.disconnect=function(){clearTimeout(q),q=null,Xe()},S.isConnected=function(){return!!(A&&m.eventSourceIsActive&&m.eventSourceIsActive(A))},S),Re=fe.eventProcessor||Ee(i,fe,Pe,ae),Ue=Oe(i,fe,Pe),je={},Ie={},Te=fe.streaming,Ne=!1,Le=!1,Fe=!0,Ae=fe.stateProvider,Ge=(p=function(e){Ae||e&&Be({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(h=x(e))&&p&&p(U(h))},getUser:function(){return h?U(h):null}}),$e=Ce(i.localStorage,ie);function Ke(e){L||(E.warn(le(e,N)),L=!0),Xe(),Me(N)}function Me(e){q||(e?q=setTimeout(He,e):He())}function He(){var e;q=null;var n="",t={};if(m.eventSourceFactory){for(var r in null!=b&&(n="h="+b),O?m.eventSourceAllowsReport?(e=P,t.method="REPORT",t.headers={"Content-Type":"application/json"},t.body=JSON.stringify(_)):(e=k+"/ping/"+w,n=""):e=P+"/"+D(JSON.stringify(_)),T&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,Xe(),E.info(ce(e)),A=m.eventSourceFactory(e,t),z)z.hasOwnProperty(r)&&A.addEventListener(r,z[r]);A.onerror=Ke}}function Xe(){A&&(E.info(se()),A.close(),A=null)}function We(e){I(function(){V&&V.maybeReportError(new c(e))})}function Be(e){Pe&&(Ae&&Ae.enqueueEvent&&Ae.enqueueEvent(e)||(e.user?(Fe=!1,!ke||Le||i.isDoNotTrack()||(ie.debug(ye(e.kind)),Re.enqueue(e))):Fe&&(ie.warn(M()),Fe=!1)))}function Ze(e,n,t,r){var o=Ge.getUser(),i=new Date,a=n?n.value:null;if(!fe.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=je[u];if(s&&i-s<3e5)return;je[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=Ie[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),Be(c)}function Qe(e,n,t,r){var o;if(Ie&&Ie.hasOwnProperty(e)&&Ie[e]&&!Ie[e].deleted){var i=Ie[e];o=Ye(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&&Ze(e,o,n,r),o}function Ye(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function en(){v=!0,Ge.getUser()&&De.connect(Ge.getUser(),{ping:function(){ie.debug(ve()),Ue.fetchFlagSettings(Ge.getUser(),be).then(function(e){return tn(e||{})}).catch(function(e){ae.maybeReportError(new l(Z(e)))})},put:function(e){var n=JSON.parse(e.data);ie.debug(de()),tn(n)},patch:function(e){var n=JSON.parse(e.data),t=Ie[n.key];if(!t||!t.version||!n.version||t.version<n.version){ie.debug(ge(n.key));var r={},o=C({},n);delete o.key;var i=Ye(Ie[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},rn(r)}else ie.debug(me(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!Ie[n.key]||Ie[n.key].version<n.version){ie.debug(pe(n.key));var t={};Ie[n.key]&&!Ie[n.key].deleted&&(t[n.key]={previous:Ie[n.key].value}),Ie[n.key]={version:n.version,deleted:!0},rn(t)}else ie.debug(he(n.key))}})}function nn(){v&&(De.disconnect(),v=!1)}function tn(e){var n={};if(!e)return Promise.resolve();for(var t in Ie)Ie.hasOwnProperty(t)&&Ie[t]&&(e[t]&&!j(e[t].value,Ie[t].value)?n[t]={previous:Ie[t].value,current:Ye(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:Ie[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!Ie[o]||Ie[o].deleted)&&(n[o]={current:Ye(e[o])});return Ie=r({},e),rn(n).catch(function(){})}function rn(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;ae.emit(Ve+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),ae.emit(Ve,i),ae.emit(ze,Ie),fe.sendEventsOnlyForVariation||Ae||e.forEach(function(e){Ze(e,o[e].current)})}return f&&g?g.saveFlags(Ie).catch(function(){return null}):Promise.resolve()}function on(){var e=Te||d&&void 0===Te;e&&!v?en():!e&&v&&nn()}function an(e){return e===Ve||e.substr(0,Ve.length+1)===Ve+":"}i.localStorage&&(g=new Se(i.localStorage,Pe,be,Ge,ie));var un=new Promise(function(e){var n=ae.on(qe,function(){ae.off(qe,n),e()})}),sn=new Promise(function(e,n){var t=ae.on(_e,function(){ae.off(_e,t),e()}),r=ae.on(Je,function(e){ae.off(Je,r),n(e)})});if("string"==typeof fe.bootstrap&&"LOCALSTORAGE"===fe.bootstrap.toUpperCase()&&(g?f=!0:ie.warn(G())),"object"===e(fe.bootstrap)&&(Ie=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&ie.warn(te()),!1===t.$valid&&ie.warn(re());var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=C(n,r[e]):n.version=0,o[e]=n}}),o}(fe.bootstrap)),Ae){var cn=Ae.getInitialState();cn?ln(cn):Ae.on("init",ln),Ae.on("update",function(e){e.user&&Ge.setUser(e.user),e.flags&&tn(e.flags)})}else(n?$e.validateUser(t).then(function(n){return Ge.setUser(n),"object"===e(fe.bootstrap)?fn():f?g.loadFlags().catch(function(){return null}).then(function(e){return null==e?(Ie={},Ue.fetchFlagSettings(Ge.getUser(),be).then(function(e){return tn(e||{})}).then(fn).catch(function(e){vn(new l(Z(e)))})):(Ie=e,I(fn),Ue.fetchFlagSettings(Ge.getUser(),be).then(function(e){return tn(e)}).catch(function(e){return ae.maybeReportError(e)}))}):Ue.fetchFlagSettings(Ge.getUser(),be).then(function(e){Ie=e||{},fn()}).catch(function(e){Ie={},vn(e)})}):Promise.reject(new a(Y()))).catch(function(e){return ae.maybeReportError(e)});function ln(e){Pe=e.environment,Ge.setUser(e.user),Ie=r({},e.flags),I(fn)}function fn(){ie.info(K()),Ne=!0,on(),ae.emit(qe),ae.emit(_e)}function vn(e){ae.maybeReportError(e),ae.emit(Je,e),ae.emit(qe)}return{client:{waitForInitialization:function(){return sn},waitUntilReady:function(){return un},identify:function(e,n,t){return Le?R(Promise.resolve({}),t):Ae?(ie.warn(ue()),R(Promise.resolve(F(Ie)),t)):R((f&&g?g.clearFlags():Promise.resolve()).then(function(){return $e.validateUser(e)}).then(function(e){return Ge.setUser(e)}).then(function(){return Ue.fetchFlagSettings(Ge.getUser(),n)}).then(function(e){var n=F(e);return e?tn(e).then(function(){return n}):n}).then(function(e){return v&&en(),e}).catch(function(e){return ae.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return Ge.getUser()},variation:function(e,n){return Qe(e,n,!0,!1).value},variationDetail:function(e,n){return Qe(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&ie.warn(W(e));var r={kind:"custom",key:e,user:Ge.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Be(r)}else ae.maybeReportError(new s(W(e)))},on:function(e,n,t){an(e)?(d=!0,Ne&&on(),ae.on(e,n,t)):ae.on.apply(ae,arguments)},off:function(e){if(ae.off.apply(ae,arguments),an(e)){var n=!1;ae.getEvents().forEach(function(e){an(e)&&0<ae.getEventListenerCount(e)&&(n=!0)}),n||(d=!1,v&&void 0===Te&&nn())}},setStreaming:function(e){var n=null===e?void 0:e;n!==Te&&(Te=n,on())},flush:function(e){return R(ke?Re.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!Ie)return e;for(var n in Ie)Ie.hasOwnProperty(n)&&(e[n]=Qe(n,null,!fe.sendEventsOnlyForVariation).value);return e},close:function(e){if(Le)return R(Promise.resolve(),e);function n(){Le=!0,Ie={}}return R(Promise.resolve().then(function(){if(nn(),ke)return Re.stop(),Re.flush()}).then(n).catch(n),e)}},options:fe,emitter:ae,ident:Ge,logger:ie,requestor:Ue,start:function(){ke&&Re.start()},enqueueEvent:Be,getFlagsInternal:function(){return Ie},getEnvironmentId:function(){return Pe},internalChangeEventName:ze}}function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ownKeys(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function _objectSpread2(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function isSyncXhrSupported(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}var emptyResult={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function newHttpRequest(e,n,t,r,o){if(o&&!isSyncXhrSupported())return emptyResult;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),emptyResult;var u;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}function makeBrowserPlatform(e){var n,i={};i.synchronousFlush=!1,window.XMLHttpRequest&&(i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush;return i.synchronousFlush=!1,newHttpRequest(e,n,t,r,o)}),i.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n};var r,t=e&&e.eventUrlTransformer;i.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},i.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(i.localStorage={get:function(n){return new Promise(function(e){e(window.localStorage.getItem(n))})},set:function(n,t){return new Promise(function(e){window.localStorage.setItem(n,t),e()})},clear:function(n){return new Promise(function(e){window.localStorage.removeItem(n),e()})}})}catch(e){i.localStorage=null}var o=e&&e.useReport;if(r=o&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(i.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(i.eventSourceAllowsReport=!1,window.EventSource),window.EventSource){i.eventSourceFactory=function(e,n){var t=_objectSpread2({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},i.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return i.userAgent="JSClient",i}var matchOperatorsRe=/[|\\{}()[\]^$+*?.]/g,escapeStringRegexp=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(matchOperatorsRe,"\\$&")};function doesUrlMatch(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=findGoalsForClick(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var locationWatcherInterval=300;function GoalManager(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=GoalTracker(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=GoalTracker(t=e,a),u(locationWatcherInterval,i)),n()}).catch(function(e){r.emitter.maybeReportError(new v.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var goalsEvent="goalsReady",extraDefaults={fetchGoals:!0};function initialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=Ke(e,n,t,r,extraDefaults),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){})}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var createConsoleLogger=xe,version="2.15.2";function deprecatedInitialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(ke.deprecated("default export","named LDClient export")),initialize(e,n,t)}var index={initialize:deprecatedInitialize,version:version};exports.createConsoleLogger=createConsoleLogger,exports.default=index,exports.initialize=initialize,exports.version=version; | ||
"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function r(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?t(o,!0).forEach(function(e){n(r,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(o).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),s=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:c,LDInvalidArgumentError:s,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,h=m.length;y<h;++y)g[y]=m[y],p[m.charCodeAt(y)]=y;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,O=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return O(e,n)}function R(e){setTimeout(e,0)}function N(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)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function F(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function C(e){var n=e.version||"3.1.0";return e.userAgent+"/"+n}function A(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":C(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function 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 x(e){if(!e)return e;var n;for(var t in P){var o=P[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}var q=Object.freeze({__proto__:null,btoa:S,base64URLEncode:D,clone:U,deepEquals:j,onNextTick:R,wrapPromiseCallback:N,transformValuesToVersionedValues:I,transformVersionedValuesToValues:T,chunkUserEventsForUrl:F,getLDUserAgentString:C,getLDHeaders:A,extend:L,sanitizeUser:x}),V=2e3;function _(s,c,e,l){var v=c+"/events/bulk/"+e,d=c+"/a/"+e+".gif",g=s.httpFallbackPing,n={};return n.sendEvents=function(e){if(!s.httpRequest)return Promise.resolve();var n,t,r,o,i=s.httpAllowsPost();n=i?[e]:F(V-c.length,e);for(var a=[],u=0;u<n.length;u++)a.push((t=n[u],r=i,void 0,o=JSON.stringify(t),r?function n(t){var e=L({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},A(s,l));return s.httpRequest("POST",v,e,o).promise.then(function(e){if(e)return 400<=e.status&&f(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(g&&g(d+"?d="+D(o)),Promise.resolve())));return Promise.all(a)},n}function J(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 z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var K=function(){return"LaunchDarkly client initialized"},$=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",M=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},H=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},B=function(e){return'Expected application/json content type but got "'+e+'"'},G=function(){return"localStorage is unavailable"},X=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},W=function(e){return"network error"+(e?" ("+e+")":"")},Q=function(e){return'Custom event "'+e+'" does not exist'},Y=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},Z=function(){return"No environment/client-side ID was specified."+$},ee=function(e){return"Error fetching flag settings: "+z(e)},ne=function(){return"No user specified."+$},te=function(){return"Invalid user specified."+$},re=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+$},oe=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},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."+$},ce=function(){return"identify() has no effect here; it must be called on the main client instance"},se=function(){return"Closing stream connection"},le=function(e){return"Opening stream connection to "+e},fe=function(e,n){return"Error on stream connection: "+z(e)+", will continue retrying every "+n+" milliseconds."},ve=function(e){return'Ignoring unknown config option "'+e+'"'},de=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},ge=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},pe=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},me=function(e){return"polling for feature flags at "+e},ye=function(){return"received ping message from stream"},he=function(){return"received streaming update for all flags"},be=function(e){return'received streaming update for flag "'+e+'"'},ke=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Ee=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'},Oe=function(e){return'enqueueing "'+e+'" event'},Pe=function(e){return"sending "+e+" events"},Se=Object.freeze({__proto__:null,clientInitialized:K,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:M,eventWithoutUser:H,invalidContentType:B,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:G,localStorageUnavailableForUserId:X,networkError:W,unknownCustomEventKey:Q,environmentNotFound:Y,environmentNotSpecified:Z,errorFetchingFlags:ee,userNotSpecified:ne,invalidUser:te,bootstrapOldFormat:re,bootstrapInvalid:oe,deprecated:ie,httpErrorMessage:ae,httpUnavailable:ue,identifyDisabled:ce,streamClosing:se,streamConnecting:le,streamError:fe,unknownOption:ve,wrongOptionType:de,wrongOptionTypeBoolean:ge,optionBelowMinimum:pe,debugPolling:me,debugStreamPing:ye,debugStreamPut:he,debugStreamPatch:be,debugStreamPatchIgnored:ke,debugStreamDelete:Ee,debugStreamDeleteIgnored:we,debugEnqueueingEvent:Oe,debugPostingEvents:Pe});function De(e,n,t){var r,a,u,s,o,c=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,l={},v=(4<arguments.length&&void 0!==arguments[4]?arguments[4]:null)||_(e,n.eventsUrl,t,n),d=(u=a=0,s={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:u,features:e}},r.clearSummary=function(){u=a=0,s={}},r),g=J(n),p=n.inlineUsersInEvents,m=n.samplingInterval,y=n.eventCapacity,h=n.flushInterval,w=n.logger,b=[],k=0,E=!1,S=!1;function O(){return 0===m||0===Math.floor(Math.random()*m)}function P(e){b.length<y?(b.push(e),S=!1):S||(S=!0,w.warn(M()))}return l.enqueue=function(e){if(!E){var n,t=!1,r=!1;if(d.summarizeEvent(e),"feature"===e.kind?O()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>k&&n.debugEventsUntilDate>(new Date).getTime()):t=O(),t&&P((a=L({},i=e),p||"identify"===i.kind?a.user=g.filterUser(i.user):(a.userKey=i.user.key,delete a.user),"feature"===i.kind&&(delete a.trackEvents,delete a.debugEventsUntilDate),a)),r){var o=L({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,P(o)}}var i,a},l.flush=function(){if(E)return Promise.resolve();var e=b,n=d.getSummary();return d.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(b=[],w.debug(Pe(e.length)),v.sendEvents(e).then(function(e){e&&(e.serverTime&&(k=e.serverTime),f(e.status)||(E=!0),400<=e.status&&R(function(){c.maybeReportError(new i(ae(e.status,"event posting","some events were dropped")))}))}))},l.start=function(){o=setTimeout(function e(){l.flush(),o=setTimeout(e,h)},h)},l.stop=function(){clearTimeout(o)},l}function Ue(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=0;n<o[e].length;n++)o[e][n].handler.apply(o[e][n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}function je(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=I(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(G()),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(G()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(G()),Promise.reject(e)})},u}var Re="application/json";function Ne(p,m,u){var s=m.baseUrl,c=m.useReport,f=m.evaluationReasons,v=m.logger,e={},y={};function d(e,n){if(!p.httpRequest)return new Promise(function(e,n){n(new l(ue()))});var t=n?"REPORT":"GET",r=A(p,m);n&&(r["Content-Type"]="application/json");var o,i,u,s,c,f,v=y[e];v||(o=function(){delete y[e]},(f={addPromise:function(n,e){i=n,u&&u(),u=e,n.then(function(e){i===n&&(s(e),o())},function(e){i===n&&(c(e),o())})}}).resultPromise=new Promise(function(e,n){s=e,c=n}),v=f,y[e]=v);var d=p.httpRequest(t,e,r,n),g=d.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new a(Y()):new l(ee(n.statusText||String(n.status))));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(Re))return JSON.parse(e.body);var n,t=B(e.header("content-type")||"");return Promise.reject(new l(t))},function(e){return Promise.reject(new l(W(e)))});return v.addPromise(g,function(){d.cancel&&d.cancel()}),v.resultPromise}return e.fetchJSON=function(e){return d(s+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[s,"/sdk/evalx/",u,"/user"].join(""),o=JSON.stringify(e)):(t=D(JSON.stringify(e)),r=[s,"/sdk/evalx/",u,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(me(r)),d(r,o)},e}for(var Ie=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}(),Te=[],Fe=0;Fe<256;++Fe)Te[Fe]=(Fe+256).toString(16).substr(1);var Ce,Ae,Le=function(e,n){var t=n||0,r=Te;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("")},xe=0,qe=0,Ve=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ce,a=void 0!==e.clockseq?e.clockseq:Ae;if(null==i||null==a){var u=Ie();null==i&&(i=Ce=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Ae=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:qe+1,l=s-xe+(c-qe)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||xe<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");xe=s,Ae=a;var f=(1e4*(268435455&(s+=122192928e5))+(qe=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||Le(o)},_e="ld:$anonUserId";function Je(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new u(ne()));var r=U(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get(_e).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=Ve();return r.key=t,(n=t,o?o.set(_e,n).catch(function(){i.warn(X())}):Promise.resolve()).then(function(){return r})}):Promise.reject(new u(te()))},e}var ze={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Ke(e,n){var o,i=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var a=0;e&&(a="none"===e?100:i.indexOf(e));var t={};function r(e,n,t){if(a<=e){var r=e<i.length?i[e]:"?";n(o+"["+r+"] "+t)}}return t.debug=function(e){return r(0,console.log,e)},t.info=function(e){return r(1,console.info,e)},t.warn=function(e){return r(2,console.warn,e)},t.error=function(e){return r(3,console.error,e)},t}var $e="ready",Me="initialized",He="failed",Be="change",Ge="internal-change";function Xe(n,t,o,i,u){var f,v,d,g,p,m,y,h,w,b,k,E,S,O,P,I,F,C,q,_,z,J,$,V,M,B,X,W,Y,ne,te,ae,ue,me=o&&o.logger?o.logger:u&&u.logger&&u.logger.default||Ke("warn"),Se=Ue(me),Pe=(V=o,M=Se,X=L({logger:{default:B=me}},ze,u),W={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null},ue=L({},V||{}),ae=ue,Object.keys(W).forEach(function(e){if(void 0!==ae[e]){var n=W[e];B&&B.warn(ie(e,n)),n&&(void 0===ae[n]&&(ae[n]=ae[e]),delete ae[e])}}),te=L({},ue),Object.keys(X).forEach(function(e){void 0!==te[e]&&null!==te[e]||(te[e]=X[e]&&X[e].default)}),Y=ue=te,ne=L({},Y),Object.keys(Y).forEach(function(e){var n=Y[e];if(null!=n){var t=X[e];if(void 0===t)rn(ve(e));else{var r=t.type||on(t.default);if("any"!==r){var o=r.split("|"),i=on(n);o.indexOf(i)<0?"boolean"===r?(ne[e]=!!n,rn(ge(e,i))):(rn(de(e,r,i)),ne[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(rn(pe(e,n,t.minimum)),ne[e]=t.minimum)}}}}),ne),Re=Pe.hash,Le=Pe.sendEvents,Te=n,xe=(y=i,w=Te,b=Re,k=(h=Pe).streamUrl,E=h.logger,S={},O=k+"/eval/"+w,P=h.useReport,I=h.evaluationReasons,F=h.streamReconnectDelay,C=A(y,h),q=!1,$=J=z=_=null,S.connect=function(e,t){function n(n){$[n]=function(e){q=!1,t[n]&&t[n](e)}}for(var r in J=e,$={},t||{})n(r);en()},S.disconnect=function(){clearTimeout(z),z=null,tn()},S.isConnected=function(){return!!(_&&y.eventSourceIsActive&&y.eventSourceIsActive(_))},S),Ie=Pe.eventProcessor||De(i,Pe,Te,Se),Fe=Ne(i,Pe,Te),Ce={},Ae={},qe=Pe.streaming,_e=!1,Ve=!1,Xe=!0,We=Pe.stateProvider,Qe=(p=function(e){We||e&&an({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(m=x(e))&&p&&p(U(m))},getUser:function(){return m?U(m):null}}),Ye=Je(i.localStorage,me);function Ze(e){q||(E.warn(fe(e,F)),q=!0),tn(),en(F)}function en(e){z||(e?z=setTimeout(nn,e):nn())}function nn(){var e;z=null;var n="",t={headers:C};if(y.eventSourceFactory){for(var r in null!=b&&(n="h="+b),P?y.eventSourceAllowsReport?(e=O,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(J)):(e=k+"/ping/"+w,n=""):e=O+"/"+D(JSON.stringify(J)),I&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,tn(),E.info(le(e)),_=y.eventSourceFactory(e,t),$)$.hasOwnProperty(r)&&_.addEventListener(r,$[r]);_.onerror=Ze}}function tn(){_&&(E.info(se()),_.close(),_=null)}function rn(e){R(function(){M&&M.maybeReportError(new s(e))})}function on(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}}function an(e){Te&&(We&&We.enqueueEvent&&We.enqueueEvent(e)||(e.user?(Xe=!1,!Le||Ve||i.isDoNotTrack()||(me.debug(Oe(e.kind)),Ie.enqueue(e))):Xe&&(me.warn(H()),Xe=!1)))}function un(e,n,t,r){var o=Qe.getUser(),i=new Date,a=n?n.value:null;if(!Pe.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=Ce[u];if(s&&i-s<3e5)return;Ce[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=Ae[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),an(c)}function sn(e,n,t,r){var o;if(Ae&&Ae.hasOwnProperty(e)&&Ae[e]&&!Ae[e].deleted){var i=Ae[e];o=cn(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&un(e,o,n,r),o}function cn(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ln(){v=!0,Qe.getUser()&&xe.connect(Qe.getUser(),{ping:function(){me.debug(ye()),Fe.fetchFlagSettings(Qe.getUser(),Re).then(function(e){return vn(e||{})}).catch(function(e){Se.maybeReportError(new l(ee(e)))})},put:function(e){var n=JSON.parse(e.data);me.debug(he()),vn(n)},patch:function(e){var n=JSON.parse(e.data),t=Ae[n.key];if(!t||!t.version||!n.version||t.version<n.version){me.debug(be(n.key));var r={},o=L({},n);delete o.key;var i=cn(Ae[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},dn(r)}else me.debug(ke(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!Ae[n.key]||Ae[n.key].version<n.version){me.debug(Ee(n.key));var t={};Ae[n.key]&&!Ae[n.key].deleted&&(t[n.key]={previous:Ae[n.key].value}),Ae[n.key]={version:n.version,deleted:!0},dn(t)}else me.debug(we(n.key))}})}function fn(){v&&(xe.disconnect(),v=!1)}function vn(e){var n={};if(!e)return Promise.resolve();for(var t in Ae)Ae.hasOwnProperty(t)&&Ae[t]&&(e[t]&&!j(e[t].value,Ae[t].value)?n[t]={previous:Ae[t].value,current:cn(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:Ae[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!Ae[o]||Ae[o].deleted)&&(n[o]={current:cn(e[o])});return Ae=r({},e),dn(n).catch(function(){})}function dn(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;Se.emit(Be+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),Se.emit(Be,i),Se.emit(Ge,Ae),Pe.sendEventsOnlyForVariation||We||e.forEach(function(e){un(e,o[e].current)})}return f&&g?g.saveFlags(Ae).catch(function(){return null}):Promise.resolve()}function gn(){var e=qe||d&&void 0===qe;e&&!v?ln():!e&&v&&fn()}function pn(e){return e===Be||e.substr(0,Be.length+1)===Be+":"}i.localStorage&&(g=new je(i.localStorage,Te,Re,Qe,me));var mn=new Promise(function(e){var n=Se.on($e,function(){Se.off($e,n),e()})}),yn=new Promise(function(e,n){var t=Se.on(Me,function(){Se.off(Me,t),e()}),r=Se.on(He,function(e){Se.off(He,r),n(e)})});if("string"==typeof Pe.bootstrap&&"LOCALSTORAGE"===Pe.bootstrap.toUpperCase()&&(g?f=!0:me.warn(G())),"object"===e(Pe.bootstrap)&&(Ae=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&me.warn(re()),!1===t.$valid&&me.warn(oe());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}(Pe.bootstrap)),We){var hn=We.getInitialState();hn?wn(hn):We.on("init",wn),We.on("update",function(e){e.user&&Qe.setUser(e.user),e.flags&&vn(e.flags)})}else(n?Ye.validateUser(t).then(function(n){return Qe.setUser(n),"object"===e(Pe.bootstrap)?bn():f?g.loadFlags().catch(function(){return null}).then(function(e){return null==e?(Ae={},Fe.fetchFlagSettings(Qe.getUser(),Re).then(function(e){return vn(e||{})}).then(bn).catch(function(e){kn(new l(ee(e)))})):(Ae=e,R(bn),Fe.fetchFlagSettings(Qe.getUser(),Re).then(function(e){return vn(e)}).catch(function(e){return Se.maybeReportError(e)}))}):Fe.fetchFlagSettings(Qe.getUser(),Re).then(function(e){Ae=e||{},bn()}).catch(function(e){Ae={},kn(e)})}):Promise.reject(new a(Z()))).catch(function(e){return Se.maybeReportError(e)});function wn(e){Te=e.environment,Qe.setUser(e.user),Ae=r({},e.flags),R(bn)}function bn(){me.info(K()),_e=!0,gn(),Se.emit($e),Se.emit(Me)}function kn(e){Se.maybeReportError(e),Se.emit(He,e),Se.emit($e)}return{client:{waitForInitialization:function(){return yn},waitUntilReady:function(){return mn},identify:function(e,n,t){return Ve?N(Promise.resolve({}),t):We?(me.warn(ce()),N(Promise.resolve(T(Ae)),t)):N((f&&g?g.clearFlags():Promise.resolve()).then(function(){return Ye.validateUser(e)}).then(function(t){return Fe.fetchFlagSettings(t,n).then(function(e){var n=T(e);return Qe.setUser(t),e?vn(e).then(function(){return n}):n})}).then(function(e){return v&&ln(),e}).catch(function(e){return Se.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return Qe.getUser()},variation:function(e,n){return sn(e,n,!0,!1).value},variationDetail:function(e,n){return sn(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&me.warn(Q(e));var r={kind:"custom",key:e,user:Qe.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),an(r)}else Se.maybeReportError(new c(Q(e)))},on:function(e,n,t){pn(e)?(d=!0,_e&&gn(),Se.on(e,n,t)):Se.on.apply(Se,arguments)},off:function(e){if(Se.off.apply(Se,arguments),pn(e)){var n=!1;Se.getEvents().forEach(function(e){pn(e)&&0<Se.getEventListenerCount(e)&&(n=!0)}),n||(d=!1,v&&void 0===qe&&fn())}},setStreaming:function(e){var n=null===e?void 0:e;n!==qe&&(qe=n,gn())},flush:function(e){return N(Le?Ie.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!Ae)return e;for(var n in Ae)Ae.hasOwnProperty(n)&&(e[n]=sn(n,null,!Pe.sendEventsOnlyForVariation).value);return e},close:function(e){if(Ve)return N(Promise.resolve(),e);function n(){Ve=!0,Ae={}}return N(Promise.resolve().then(function(){if(fn(),Le)return Ie.stop(),Ie.flush()}).then(n).catch(n),e)}},options:Pe,emitter:Se,ident:Qe,logger:me,requestor:Fe,start:function(){Le&&Ie.start()},enqueueEvent:an,getFlagsInternal:function(){return Ae},getEnvironmentId:function(){return Te},internalChangeEventName:Ge}}function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ownKeys(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function _objectSpread2(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function isSyncXhrSupported(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}var emptyResult={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function newHttpRequest(e,n,t,r,o){if(o&&!isSyncXhrSupported())return emptyResult;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),emptyResult;var u;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}function makeBrowserPlatform(e){var n,i={};i.synchronousFlush=!1,window.XMLHttpRequest&&(i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush;return i.synchronousFlush=!1,newHttpRequest(e,n,t,r,o)}),i.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n};var r,t=e&&e.eventUrlTransformer;i.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},i.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(i.localStorage={get:function(n){return new Promise(function(e){e(window.localStorage.getItem(n))})},set:function(n,t){return new Promise(function(e){window.localStorage.setItem(n,t),e()})},clear:function(n){return new Promise(function(e){window.localStorage.removeItem(n),e()})}})}catch(e){i.localStorage=null}var o=e&&e.useReport;if(r=o&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(i.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(i.eventSourceAllowsReport=!1,window.EventSource),window.EventSource){i.eventSourceFactory=function(e,n){var t=_objectSpread2({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},i.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return i.userAgent="JSClient",i}var matchOperatorsRe=/[|\\{}()[\]^$+*?.]/g,escapeStringRegexp=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(matchOperatorsRe,"\\$&")};function doesUrlMatch(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=findGoalsForClick(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var locationWatcherInterval=300;function GoalManager(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=GoalTracker(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=GoalTracker(t=e,a),u(locationWatcherInterval,i)),n()}).catch(function(e){r.emitter.maybeReportError(new v.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var goalsEvent="goalsReady",extraOptionDefs={fetchGoals:{default:!0},hash:{type:"string"},eventUrlTransformer:{type:"function"}};function initialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=Xe(e,n,t,r,extraOptionDefs),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){})}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var createConsoleLogger=Ke,version="2.16.0";function deprecatedInitialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Se.deprecated("default export","named LDClient export")),initialize(e,n,t)}var index={initialize:deprecatedInitialize,version:version};exports.createConsoleLogger=createConsoleLogger,exports.default=index,exports.initialize=initialize,exports.version=version; | ||
//# sourceMappingURL=ldclient.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),s=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:c,LDInvalidArgumentError:s,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(w(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"=")),o.join("")},g=[],p=[],h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m=0,y=h.length;m<y;++m)g[m]=h[m],p[h.charCodeAt(m)]=m;function w(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,S=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=b(n),u=b(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var c=n instanceof Date,s=t instanceof Date;if(c!=s)return!1;if(c&&s)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=k(n);if((o=v.length)!==k(t).length)return!1;for(r=o;0!=r--;)if(!E.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function O(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return O(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function R(e,n){return S(e,n)}function j(e){setTimeout(e,0)}function I(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function N(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function L(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function F(e){var n=e.version||"2.14.1";return e.userAgent+"/"+n}function x(e){return{"X-LaunchDarkly-User-Agent":F(e)}}function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function C(e){if(!e)return e;var n;for(var t in P){var o=P[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}Object.freeze({__proto__:null,btoa:O,base64URLEncode:D,clone:U,deepEquals:R,onNextTick:j,wrapPromiseCallback:I,transformValuesToVersionedValues:N,transformVersionedValuesToValues:T,chunkUserEventsForUrl:L,getLDUserAgentString:F,getLDHeaders:x,extend:A,sanitizeUser:C});var q=2e3;function J(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var _=function(){return"LaunchDarkly client initialized"},V=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",z=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},H=function(e){return'Expected application/json content type but got "'+e+'"'},$=function(){return"localStorage is unavailable"},K=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},M=function(e){return"network error"+(e?" ("+e+")":"")},G=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."+V},B=function(){return"No environment/client-side ID was specified."+V},W=function(e){return"Error fetching flag settings: "+J(e)},Q=function(){return"No user specified."+V},Y=function(){return"Invalid user specified."+V},Z=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+V},ee=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ne=function(e,n){return n?'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"':'[LaunchDarkly] "'+e+'" is deprecated'},te=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},re=function(){return"Cannot make HTTP requests in this environment."+V},oe=function(){return"identify() has no effect here; it must be called on the main client instance"},ie=function(){return"Closing stream connection"},ae=function(e){return"Opening stream connection to "+e},ue=function(e,n){return"Error on stream connection: "+J(e)+", will continue retrying every "+n+" milliseconds."},ce=function(e){return"polling for feature flags at "+e},se=function(){return"received ping message from stream"},le=function(){return"received streaming update for all flags"},fe=function(e){return'received streaming update for flag "'+e+'"'},ve=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},de=function(e){return'received streaming deletion for flag "'+e+'"'},ge=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},pe=function(e){return'enqueueing "'+e+'" event'},he=function(e){return"sending "+e+" events"},me=Object.freeze({__proto__:null,clientInitialized:_,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventWithoutUser:z,invalidContentType:H,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:$,localStorageUnavailableForUserId:K,networkError:M,unknownCustomEventKey:G,environmentNotFound:X,environmentNotSpecified:B,errorFetchingFlags:W,userNotSpecified:Q,invalidUser:Y,bootstrapOldFormat:Z,bootstrapInvalid:ee,deprecated:ne,httpErrorMessage:te,httpUnavailable:re,identifyDisabled:oe,streamClosing:ie,streamConnecting:ae,streamError:ue,debugPolling:ce,debugStreamPing:se,debugStreamPut:le,debugStreamPatch:fe,debugStreamPatchIgnored:ve,debugStreamDelete:de,debugStreamDeleteIgnored:ge,debugEnqueueingEvent:pe,debugPostingEvents:he});function ye(e,n,t){var r,o,a,u,c,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,v={},d=l||function(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a={};function u(e){(new window.Image).src=e}function c(n,t){var a=r||u,c=JSON.stringify(n);return t?function n(t){var r=A({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},x(e));return e.httpRequest("POST",o,r,c).promise.then((function(e){if(e)return e.status>=400&&f(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return t?n(!1):Promise.reject()}))}(!0).catch((function(){})):(a(i+"?d="+D(c)),Promise.resolve())}return a.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:L(q-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(c(r[a],o));return Promise.all(i)},a}(e,n.eventsUrl,t),g=(o=0,a=0,u={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===o||e.creationDate<o)&&(o=e.creationDate),e.creationDate>a&&(a=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var c={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(c.variation=r.variation),r.version?c.version=r.version:c.unknown=!0,i.counters.push(c),n=!1}return n?null:{startDate:o,endDate:a,features:e}},r.clearSummary=function(){o=0,a=0,u={}},r),p=function(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce((function(a,u){var c=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?c[1][u]=!0:c[0][u]=e[u]),c}),[{},{}])},u=a(e,(function(e){return i[e]})),c=u[0],s=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));c.custom=l[0],s=A({},s,l[1])}var f=Object.keys(s);return f.length&&(f.sort(),c.privateAttrs=f),c},n}(n),h=n.inlineUsersInEvents,m=n.samplingInterval,y=n.flushInterval,w=n.logger,b=[],k=0,E=!1;function S(){return 0===m||0===Math.floor(Math.random()*m)}return v.enqueue=function(e){if(!E){var n,t=!1,r=!1;if(g.summarizeEvent(e),"feature"===e.kind?S()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>k&&n.debugEventsUntilDate>(new Date).getTime()):t=S(),t&&b.push(function(e){var n=A({},e);return h||"identify"===e.kind?n.user=p.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=A({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,b.push(o)}}},v.flush=function(){if(E)return Promise.resolve();var e=b,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(b=[],w.debug(he(e.length)),d.sendEvents(e).then((function(e){e&&(e.serverTime&&(k=e.serverTime),f(e.status)||(E=!0),e.status>=400&&j((function(){s.maybeReportError(new i(te(e.status,"event posting","some events were dropped")))})))})))},v.start=function(){c=setTimeout((function e(){v.flush(),c=setTimeout(e,y)}),y)},v.stop=function(){clearTimeout(c)},v}function we(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||O(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=N(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return o.warn($()),Promise.reject(e)}))},i.saveFlags=function(n){var t=A({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch((function(e){return o.warn($()),Promise.reject(e)}))},i.clearFlags=function(){return e.clear(a()).catch((function(e){return o.warn($()),Promise.reject(e)}))},i}var be="application/json";function ke(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.sendLDHeaders,c=n.logger,s={},f={};function v(n,t){if(!e.httpRequest)return new Promise((function(e,n){n(new l(re()))}));var r=t?"REPORT":"GET",o=u?x(e):{};t&&(o["Content-Type"]="application/json");var i=f[n];i||(i=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then((function(t){n===i&&(r(t),e&&e())}),(function(t){n===i&&(o(t),e&&e())}))}};return i.resultPromise=new Promise((function(e,n){r=e,o=n})),i}((function(){delete f[n]})),f[n]=i);var c=e.httpRequest(r,n,o,t),s=c.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(be))return JSON.parse(e.body);var n=H(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(X()):new l(W(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(M(e)))}));return i.addPromise(s,(function(){c.cancel&&c.cancel()})),i.resultPromise}return s.fetchJSON=function(e){return v(r+e,null)},s.fetchFlagSettings=function(e,n){var a,u,s,l="";return o?(u=[r,"/sdk/evalx/",t,"/user"].join(""),s=JSON.stringify(e)):(a=D(JSON.stringify(e)),u=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),u=u+(l?"?":"")+l,c.debug(ce(u)),v(u,s)},s}for(var Ee=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}(),Se=[],Pe=0;Pe<256;++Pe)Se[Pe]=(Pe+256).toString(16).substr(1);var Oe,De,Ue=0,Re=0,je=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Oe,a=void 0!==e.clockseq?e.clockseq:De;if(null==i||null==a){var u=Ee();null==i&&(i=Oe=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=De=16383&(u[6]<<8|u[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:Re+1,l=c-Ue+(s-Re)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>Ue)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ue=c,Re=s,De=a;var f=(1e4*(268435455&(c+=122192928e5))+s)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=c/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=Se;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)},Ie="ld:$anonUserId";function Ne(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new u(Q()));var r=U(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(Ie).catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var o=je();return r.key=o,function(t){return e?e.set(Ie,t).catch((function(){n.warn(K())})):Promise.resolve()}(o).then((function(){return r}))})):Promise.reject(new u(Y()))}};return t}function Te(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<r.length?r[e]:"?";n(t+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var Le="ready",Fe="initialized",xe="failed",Ae="change",Ce="internal-change";function qe(n,t,o,i,u){var f,v,d,g,p=o&&o.logger?o.logger:u&&u.logger||Te("warn"),h=function(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}(p),m=function(e,n,t,r){var o=A({logger:r},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function a(e){j((function(){n&&n.maybeReportError(new s(e))}))}var u=A({},e||{});return function(e){var n=e;Object.keys(i).forEach((function(e){if(void 0!==n[e]){var t=i[e];r&&r.warn(ne(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(u),u=function(e,n){var t=A({},e);return Object.keys(n).forEach((function(e){void 0!==t[e]&&null!==t[e]||(t[e]=n[e])})),t}(u,o),(isNaN(u.flushInterval)||u.flushInterval<2e3)&&(u.flushInterval=2e3,a("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(u.samplingInterval)||u.samplingInterval<0)&&(u.samplingInterval=0,a("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),u}(o,h,u,p),y=m.hash,w=m.sendEvents,b=n,k=function(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,c=n.useReport,s=n.evaluationReasons,l=n.streamReconnectDelay,f=!1,v=null,d=null,g=null,p=null;function h(e){f||(i.warn(ue(e,l)),f=!0),w(),m(l)}function m(e){d||(e?d=setTimeout(y,e):y())}function y(){var n;d=null;var a="",l={};if(e.eventSourceFactory){for(var f in null!=r&&(a="h="+r),c?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(g)):(n=o+"/ping/"+t,a=""):n=u+"/"+D(JSON.stringify(g)),s&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,w(),i.info(ae(n)),v=e.eventSourceFactory(n,l),p)p.hasOwnProperty(f)&&v.addEventListener(f,p[f]);v.onerror=h}}function w(){v&&(i.info(ie()),v.close(),v=null)}return a.connect=function(e,n){g=e,p={};var t=function(e){p[e]=function(t){f=!1,n[e]&&n[e](t)}};for(var r in n||{})t(r);m()},a.disconnect=function(){clearTimeout(d),d=null,w()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}(i,m,b,y),E=m.eventProcessor||ye(i,m,b,h),S=ke(i,m,b),P={},O={},N=m.streaming,L=!1,F=!1,x=!0,q=m.stateProvider,J=function(e,n){var t,r={setUser:function(e){(t=C(e))&&n&&n(U(t))},getUser:function(){return t?U(t):null}};return r}(0,(function(e){q||e&&H({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),V=Ne(i.localStorage,p);function H(e){b&&(q&&q.enqueueEvent&&q.enqueueEvent(e)||(e.user?(x=!1,!w||F||i.isDoNotTrack()||(p.debug(pe(e.kind)),E.enqueue(e))):x&&(p.warn(z()),x=!1)))}function K(e,n,t,r){var o=J.getUser(),i=new Date,a=n?n.value:null;if(!m.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,c=P[u];if(c&&i-c<3e5)return;P[u]=i}var s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=O[e];l&&(s.version=l.flagVersion?l.flagVersion:l.version,s.trackEvents=l.trackEvents,s.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(s.reason=n.reason),H(s)}function M(e,n,t,r){var o;if(O&&O.hasOwnProperty(e)&&O[e]&&!O[e].deleted){var i=O[e];o=X(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&&K(e,o,n,r),o}function X(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function Q(){v=!0,J.getUser()&&k.connect(J.getUser(),{ping:function(){p.debug(se()),S.fetchFlagSettings(J.getUser(),y).then((function(e){return te(e||{})})).catch((function(e){h.maybeReportError(new l(W(e)))}))},put:function(e){var n=JSON.parse(e.data);p.debug(le()),te(n)},patch:function(e){var n=JSON.parse(e.data),t=O[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(fe(n.key));var r={},o=A({},n);delete o.key,O[n.key]=o;var i=X(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},re(r)}else p.debug(ve(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!O[n.key]||O[n.key].version<n.version){p.debug(de(n.key));var t={};O[n.key]&&!O[n.key].deleted&&(t[n.key]={previous:O[n.key].value}),O[n.key]={version:n.version,deleted:!0},re(t)}else p.debug(ge(n.key))}})}function Y(){v&&(k.disconnect(),v=!1)}function te(e){var n={};if(!e)return Promise.resolve();for(var t in O)O.hasOwnProperty(t)&&O[t]&&(e[t]&&!R(e[t].value,O[t].value)?n[t]={previous:O[t].value,current:X(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:O[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!O[o]||O[o].deleted)&&(n[o]={current:X(e[o])});return O=r({},e),re(n).catch((function(){}))}function re(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(Ae+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),h.emit(Ae,t),h.emit(Ce,O),m.sendEventsOnlyForVariation||q||n.forEach((function(n){K(n,e[n].current)}))}return f&&g?g.saveFlags(O).catch((function(){return null})):Promise.resolve()}function ce(){var e=N||d&&void 0===N;e&&!v?Q():!e&&v&&Y()}function he(e){return e===Ae||e.substr(0,Ae.length+1)===Ae+":"}i.localStorage&&(g=new we(i.localStorage,b,y,J,p));var me=new Promise((function(e){var n=h.on(Le,(function(){h.off(Le,n),e()}))})),be=new Promise((function(e,n){var t=h.on(Fe,(function(){h.off(Fe,t),e()})),r=h.on(xe,(function(e){h.off(xe,r),n(e)}))}));if("string"==typeof m.bootstrap&&"LOCALSTORAGE"===m.bootstrap.toUpperCase()&&(g?f=!0:p.warn($())),"object"===e(m.bootstrap)&&(O=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(Z()),!1===e.$valid&&p.warn(ee());var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=A(o,t[n]):o.version=0,r[n]=o}})),r}(m.bootstrap)),q){var Ee=q.getInitialState();Ee?Se(Ee):q.on("init",Se),q.on("update",(function(e){e.user&&J.setUser(e.user),e.flags&&te(e.flags)}))}else(n?V.validateUser(t).then((function(n){return J.setUser(n),"object"===e(m.bootstrap)?Pe():f?g.loadFlags().catch((function(){return null})).then((function(e){return null==e?(O={},S.fetchFlagSettings(J.getUser(),y).then((function(e){return te(e||{})})).then(Pe).catch((function(e){Oe(new l(W(e)))}))):(O=e,j(Pe),S.fetchFlagSettings(J.getUser(),y).then((function(e){return te(e)})).catch((function(e){return h.maybeReportError(e)})))})):S.fetchFlagSettings(J.getUser(),y).then((function(e){O=e||{},Pe()})).catch((function(e){O={},Oe(e)}))})):Promise.reject(new a(B()))).catch((function(e){return h.maybeReportError(e)}));function Se(e){b=e.environment,J.setUser(e.user),O=r({},e.flags),j(Pe)}function Pe(){p.info(_()),L=!0,ce(),h.emit(Le),h.emit(Fe)}function Oe(e){h.maybeReportError(e),h.emit(xe,e),h.emit(Le)}return{client:{waitForInitialization:function(){return be},waitUntilReady:function(){return me},identify:function(e,n,t){return F?I(Promise.resolve({}),t):q?(p.warn(oe()),I(Promise.resolve(T(O)),t)):I((f&&g?g.clearFlags():Promise.resolve()).then((function(){return V.validateUser(e)})).then((function(e){return J.setUser(e)})).then((function(){return S.fetchFlagSettings(J.getUser(),n)})).then((function(e){var n=T(e);return e?te(e).then((function(){return n})):n})).then((function(e){return v&&Q(),e})).catch((function(e){return h.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return J.getUser()},variation:function(e,n){return M(e,n,!0,!1).value},variationDetail:function(e,n){return M(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&p.warn(G(e));var r={kind:"custom",key:e,user:J.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),H(r)}else h.maybeReportError(new c(G(e)))},on:function(e,n,t){he(e)?(d=!0,L&&ce(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),he(e)){var n=!1;h.getEvents().forEach((function(e){he(e)&&h.getEventListenerCount(e)>0&&(n=!0)})),n||(d=!1,v&&void 0===N&&Y())}},setStreaming:function(e){var n=null===e?void 0:e;n!==N&&(N=n,ce())},flush:function(e){return I(w?E.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!O)return e;for(var n in O)O.hasOwnProperty(n)&&(e[n]=M(n,null,!m.sendEventsOnlyForVariation).value);return e},close:function(e){if(F)return I(Promise.resolve(),e);var n=function(){F=!0,O={}};return I(Promise.resolve().then((function(){if(Y(),w)return E.stop(),E.flush()})).then(n).catch(n),e)}},options:m,emitter:h,ident:J,logger:p,requestor:S,start:function(){w&&E.start()},enqueueEvent:H,getFlagsInternal:function(){return O},getEnvironmentId:function(){return b},internalChangeEventName:Ce}}function Je(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function _e(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 Ve={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function ze(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return Ve;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),Ve;var u;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 He(e){var n,t={};t.synchronousFlush=!1,window.XMLHttpRequest&&(t.httpRequest=function(e,n,r,o){var i=t.synchronousFlush;return t.synchronousFlush=!1,ze(e,n,r,o,i)}),t.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n};var r,o=e&&e.eventUrlTransformer;t.getCurrentUrl=function(){return o?o(window.location.href):window.location.href},t.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(t.localStorage={get:function(e){return new Promise((function(n){n(window.localStorage.getItem(e))}))},set:function(e,n){return new Promise((function(t){window.localStorage.setItem(e,n),t()}))},clear:function(e){return new Promise((function(n){window.localStorage.removeItem(e),n()}))}})}catch(e){t.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(t.eventSourceAllowsReport=!0,r=window.EventSourcePolyfill):(t.eventSourceAllowsReport=!1,r=window.EventSource),window.EventSource){t.eventSourceFactory=function(e,n){var t=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?_e(t,!0).forEach((function(n){Je(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):_e(t).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},t.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return t.userAgent="JSClient",t}var $e=/[|\\{}()[\]^$+*?.]/g,Ke=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace($e,"\\$&")};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("^"+Ke(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Ke(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Ke(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Ge(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],c=0;c<u.length;c++)if(Me(u[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var c=0;c<u.length;c++)o===u[c]&&t.push(i);o=o.parentNode}return t}(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var Xe=300;function Be(e,n){var t,r,o={};function i(){r&&r.dispose(),t&&t.length&&(r=Ge(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Ge(t=e,a),function(e,n){var t,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)}(Xe,i)),n()})).catch((function(t){e.emitter.maybeReportError(new v.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),o}var We="goalsReady",Qe={fetchGoals:!0};function Ye(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=He(t),o=qe(e,n,t,r,Qe),i=o.client,a=o.options,u=o.emitter,c=new Promise((function(e){var n=u.on(We,(function(){u.off(We,n),e()}))}));if(i.waitUntilGoalsReady=function(){return c},a.fetchGoals){var s=Be(o,(function(){return u.emit(We)}));r.customEventFilter=s.goalKeyExists}else u.emit(We);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch((function(){}))};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var Ze=Te,en="2.15.2";var nn={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(me.deprecated("default export","named LDClient export")),Ye(e,n,t)},version:"2.15.2"};export default nn;export{Ze as createConsoleLogger,Ye as initialize,en as version}; | ||
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),s=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:c,LDInvalidArgumentError:s,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(w(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=m.length;h<y;++h)g[h]=m[h],p[m.charCodeAt(h)]=h;function w(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,S=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=b(n),u=b(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var c=n instanceof Date,s=t instanceof Date;if(c!=s)return!1;if(c&&s)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=k(n);if((o=v.length)!==k(t).length)return!1;for(r=o;0!=r--;)if(!E.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},O=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function P(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return P(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function j(e,n){return S(e,n)}function R(e){setTimeout(e,0)}function T(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function N(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function I(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function L(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function F(e){var n=e.version||"3.1.0";return e.userAgent+"/"+n}function x(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":F(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function C(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function A(e){if(!e)return e;var n;for(var t in O){var o=O[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}Object.freeze({__proto__:null,btoa:P,base64URLEncode:D,clone:U,deepEquals:j,onNextTick:R,wrapPromiseCallback:T,transformValuesToVersionedValues:N,transformVersionedValuesToValues:I,chunkUserEventsForUrl:L,getLDUserAgentString:F,getLDHeaders:x,extend:C,sanitizeUser:A});var q=2e3;function J(e,n,t,r){var o=n+"/events/bulk/"+t,i=n+"/a/"+t+".gif",a=e.httpFallbackPing,u={};function c(n,t){var u=JSON.stringify(n);return t?function n(t){var i=C({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},x(e,r));return e.httpRequest("POST",o,i,u).promise.then((function(e){if(e)return e.status>=400&&f(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return t?n(!1):Promise.reject()}))}(!0).catch((function(){})):(a&&a(i+"?d="+D(u)),Promise.resolve())}return u.sendEvents=function(t){if(!e.httpRequest)return Promise.resolve();var r,o=e.httpAllowsPost();r=o?[t]:L(q-n.length,t);for(var i=[],a=0;a<r.length;a++)i.push(c(r[a],o));return Promise.all(i)},u}function _(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var V=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.",H=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},$=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},K=function(e){return'Expected application/json content type but got "'+e+'"'},M=function(){return"localStorage is unavailable"},G=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},X=function(e){return"network error"+(e?" ("+e+")":"")},B=function(e){return'Custom event "'+e+'" does not exist'},W=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+z},Q=function(){return"No environment/client-side ID was specified."+z},Y=function(e){return"Error fetching flag settings: "+_(e)},Z=function(){return"No user specified."+z},ee=function(){return"Invalid user specified."+z},ne=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+z},te=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},re=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},oe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ie=function(){return"Cannot make HTTP requests in this environment."+z},ae=function(){return"identify() has no effect here; it must be called on the main client instance"},ue=function(){return"Closing stream connection"},ce=function(e){return"Opening stream connection to "+e},se=function(e,n){return"Error on stream connection: "+_(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(){return"received ping message from stream"},me=function(){return"received streaming update for all flags"},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'},ke=function(e){return'enqueueing "'+e+'" event'},Ee=function(e){return"sending "+e+" events"},Se=Object.freeze({__proto__:null,clientInitialized:V,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:H,eventWithoutUser:$,invalidContentType:K,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:M,localStorageUnavailableForUserId:G,networkError:X,unknownCustomEventKey:B,environmentNotFound:W,environmentNotSpecified:Q,errorFetchingFlags:Y,userNotSpecified:Z,invalidUser:ee,bootstrapOldFormat:ne,bootstrapInvalid:te,deprecated:re,httpErrorMessage:oe,httpUnavailable:ie,identifyDisabled:ae,streamClosing:ue,streamConnecting:ce,streamError:se,unknownOption:le,wrongOptionType:fe,wrongOptionTypeBoolean:ve,optionBelowMinimum:de,debugPolling:ge,debugStreamPing:pe,debugStreamPut:me,debugStreamPatch:he,debugStreamPatchIgnored:ye,debugStreamDelete:we,debugStreamDeleteIgnored:be,debugEnqueueingEvent:ke,debugPostingEvents:Ee});function Oe(e,n,t){var r,o,a,u,c,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,v={},d=l||J(e,n.eventsUrl,t,n),g=(o=0,a=0,u={},(r={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===o||e.creationDate<o)&&(o=e.creationDate),e.creationDate>a&&(a=e.creationDate)}},r.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var c={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(c.variation=r.variation),r.version?c.version=r.version:c.unknown=!0,i.counters.push(c),n=!1}return n?null:{startDate:o,endDate:a,features:e}},r.clearSummary=function(){o=0,a=0,u={}},r),p=function(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce((function(a,u){var c=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?c[1][u]=!0:c[0][u]=e[u]),c}),[{},{}])},u=a(e,(function(e){return i[e]})),c=u[0],s=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));c.custom=l[0],s=C({},s,l[1])}var f=Object.keys(s);return f.length&&(f.sort(),c.privateAttrs=f),c},n}(n),m=n.inlineUsersInEvents,h=n.samplingInterval,y=n.eventCapacity,w=n.flushInterval,b=n.logger,k=[],E=0,S=!1,O=!1;function P(){return 0===h||0===Math.floor(Math.random()*h)}function D(e){k.length<y?(k.push(e),O=!1):O||(O=!0,b.warn(H()))}return v.enqueue=function(e){if(!S){var n,t=!1,r=!1;if(g.summarizeEvent(e),"feature"===e.kind?P()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>E&&n.debugEventsUntilDate>(new Date).getTime()):t=P(),t&&D(function(e){var n=C({},e);return m||"identify"===e.kind?n.user=p.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),r){var o=C({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,D(o)}}},v.flush=function(){if(S)return Promise.resolve();var e=k,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(k=[],b.debug(Ee(e.length)),d.sendEvents(e).then((function(e){e&&(e.serverTime&&(E=e.serverTime),f(e.status)||(S=!0),e.status>=400&&R((function(){s.maybeReportError(new i(oe(e.status,"event posting","some events were dropped")))})))})))},v.start=function(){c=setTimeout((function e(){v.flush(),c=setTimeout(e,w)}),w)},v.stop=function(){clearTimeout(c)},v}function Pe(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||P(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=N(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return o.warn(M()),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(M()),Promise.reject(e)}))},i.clearFlags=function(){return e.clear(a()).catch((function(e){return o.warn(M()),Promise.reject(e)}))},i}var De="application/json";function Ue(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.logger,c={},s={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(ie()))}));var o=r?"REPORT":"GET",i=x(e,n);r&&(i["Content-Type"]="application/json");var u=s[t];u||(u=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then((function(t){n===i&&(r(t),e&&e())}),(function(t){n===i&&(o(t),e&&e())}))}};return i.resultPromise=new Promise((function(e,n){r=e,o=n})),i}((function(){delete s[t]})),s[t]=u);var c=e.httpRequest(o,t,i,r),f=c.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(De))return JSON.parse(e.body);var n=K(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(W()):new l(Y(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(X(e)))}));return u.addPromise(f,(function(){c.cancel&&c.cancel()})),u.resultPromise}return c.fetchJSON=function(e){return f(r+e,null)},c.fetchFlagSettings=function(e,n){var a,c,s,l="";return o?(c=[r,"/sdk/evalx/",t,"/user"].join(""),s=JSON.stringify(e)):(a=D(JSON.stringify(e)),c=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),c=c+(l?"?":"")+l,u.debug(ge(c)),f(c,s)},c}for(var je=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}(),Re=[],Te=0;Te<256;++Te)Re[Te]=(Te+256).toString(16).substr(1);var Ne,Ie,Le=0,Fe=0,xe=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||Ne,a=void 0!==e.clockseq?e.clockseq:Ie;if(null==i||null==a){var u=je();null==i&&(i=Ne=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=Ie=16383&(u[6]<<8|u[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:Fe+1,l=c-Le+(s-Fe)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>Le)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Le=c,Fe=s,Ie=a;var f=(1e4*(268435455&(c+=122192928e5))+s)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=c/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=Re;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)},Ce="ld:$anonUserId";function Ae(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new u(Z()));var r=U(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get(Ce).catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var o=xe();return r.key=o,function(t){return e?e.set(Ce,t).catch((function(){n.warn(G())})):Promise.resolve()}(o).then((function(){return r}))})):Promise.reject(new u(ee()))}};return t}var qe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Je(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var o=0;e&&(o="none"===e?100:r.indexOf(e));var i={};function a(e,n,i){if(e>=o){var a=e<r.length?r[e]:"?";n(t+"["+a+"] "+i)}}return i.debug=function(e){return a(0,console.log,e)},i.info=function(e){return a(1,console.info,e)},i.warn=function(e){return a(2,console.warn,e)},i.error=function(e){return a(3,console.error,e)},i}var _e="ready",Ve="initialized",ze="failed",He="change",$e="internal-change";function Ke(n,t,o,i,u){var f,v,d,g,p=o&&o.logger?o.logger:u&&u.logger&&u.logger.default||Je("warn"),m=function(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=0;n<t[e].length;n++)t[e][n].handler.apply(t[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}(p),h=function(n,t,r,o){var i=C({logger:{default:o}},qe,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){R((function(){t&&t.maybeReportError(new s(e))}))}var c=C({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];o&&o.warn(re(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(c),function(n){var t=C({},n),r=function(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}};return Object.keys(n).forEach((function(e){var o=n[e];if(null!=o){var a=i[e];if(void 0===a)u(le(e));else{var c=a.type||r(a.default);if("any"!==c){var s=c.split("|"),l=r(o);s.indexOf(l)<0?"boolean"===c?(t[e]=!!o,u(ve(e,l))):(u(fe(e,c,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}(c=function(e){var n=C({},e);return Object.keys(i).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=i[e]&&i[e].default)})),n}(c))}(o,m,u,p),y=h.hash,w=h.sendEvents,b=n,k=function(e,n,t,r){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+t,c=n.useReport,s=n.evaluationReasons,l=n.streamReconnectDelay,f=x(e,n),v=!1,d=null,g=null,p=null,m=null;function h(e){v||(i.warn(se(e,l)),v=!0),b(),y(l)}function y(e){g||(e?g=setTimeout(w,e):w())}function w(){var n;g=null;var a="",l={headers:f};if(e.eventSourceFactory){for(var v in null!=r&&(a="h="+r),c?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(p)):(n=o+"/ping/"+t,a=""):n=u+"/"+D(JSON.stringify(p)),s&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,b(),i.info(ce(n)),d=e.eventSourceFactory(n,l),m)m.hasOwnProperty(v)&&d.addEventListener(v,m[v]);d.onerror=h}}function b(){d&&(i.info(ue()),d.close(),d=null)}return a.connect=function(e,n){p=e,m={};var t=function(e){m[e]=function(t){v=!1,n[e]&&n[e](t)}};for(var r in n||{})t(r);y()},a.disconnect=function(){clearTimeout(g),g=null,b()},a.isConnected=function(){return!!(d&&e.eventSourceIsActive&&e.eventSourceIsActive(d))},a}(i,h,b,y),E=h.eventProcessor||Oe(i,h,b,m),S=Ue(i,h,b),O={},P={},N=h.streaming,L=!1,F=!1,q=!0,J=h.stateProvider,_=function(e,n){var t,r={setUser:function(e){(t=A(e))&&n&&n(U(t))},getUser:function(){return t?U(t):null}};return r}(0,(function(e){J||e&&H({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),z=Ae(i.localStorage,p);function H(e){b&&(J&&J.enqueueEvent&&J.enqueueEvent(e)||(e.user?(q=!1,!w||F||i.isDoNotTrack()||(p.debug(ke(e.kind)),E.enqueue(e))):q&&(p.warn($()),q=!1)))}function K(e,n,t,r){var o=_.getUser(),i=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,c=O[u];if(c&&i-c<3e5)return;O[u]=i}var s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=P[e];l&&(s.version=l.flagVersion?l.flagVersion:l.version,s.trackEvents=l.trackEvents,s.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(s.reason=n.reason),H(s)}function G(e,n,t,r){var o;if(P&&P.hasOwnProperty(e)&&P[e]&&!P[e].deleted){var i=P[e];o=X(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&&K(e,o,n,r),o}function X(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function W(){v=!0,_.getUser()&&k.connect(_.getUser(),{ping:function(){p.debug(pe()),S.fetchFlagSettings(_.getUser(),y).then((function(e){return ee(e||{})})).catch((function(e){m.maybeReportError(new l(Y(e)))}))},put:function(e){var n=JSON.parse(e.data);p.debug(me()),ee(n)},patch:function(e){var n=JSON.parse(e.data),t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(he(n.key));var r={},o=C({},n);delete o.key,P[n.key]=o;var i=X(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},oe(r)}else p.debug(ye(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!P[n.key]||P[n.key].version<n.version){p.debug(we(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},oe(t)}else p.debug(be(n.key))}})}function Z(){v&&(k.disconnect(),v=!1)}function ee(e){var n={};if(!e)return Promise.resolve();for(var t in P)P.hasOwnProperty(t)&&P[t]&&(e[t]&&!j(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:X(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!P[o]||P[o].deleted)&&(n[o]={current:X(e[o])});return P=r({},e),oe(n).catch((function(){}))}function oe(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;m.emit(He+":"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),m.emit(He,t),m.emit($e,P),h.sendEventsOnlyForVariation||J||n.forEach((function(n){K(n,e[n].current)}))}return f&&g?g.saveFlags(P).catch((function(){return null})):Promise.resolve()}function ie(){var e=N||d&&void 0===N;e&&!v?W():!e&&v&&Z()}function ge(e){return e===He||e.substr(0,He.length+1)===He+":"}i.localStorage&&(g=new Pe(i.localStorage,b,y,_,p));var Ee=new Promise((function(e){var n=m.on(_e,(function(){m.off(_e,n),e()}))})),Se=new Promise((function(e,n){var t=m.on(Ve,(function(){m.off(Ve,t),e()})),r=m.on(ze,(function(e){m.off(ze,r),n(e)}))}));if("string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(g?f=!0:p.warn(M())),"object"===e(h.bootstrap)&&(P=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(ne()),!1===e.$valid&&p.warn(te());var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=C(o,t[n]):o.version=0,r[n]=o}})),r}(h.bootstrap)),J){var De=J.getInitialState();De?je(De):J.on("init",je),J.on("update",(function(e){e.user&&_.setUser(e.user),e.flags&&ee(e.flags)}))}else(n?z.validateUser(t).then((function(n){return _.setUser(n),"object"===e(h.bootstrap)?Re():f?g.loadFlags().catch((function(){return null})).then((function(e){return null==e?(P={},S.fetchFlagSettings(_.getUser(),y).then((function(e){return ee(e||{})})).then(Re).catch((function(e){Te(new l(Y(e)))}))):(P=e,R(Re),S.fetchFlagSettings(_.getUser(),y).then((function(e){return ee(e)})).catch((function(e){return m.maybeReportError(e)})))})):S.fetchFlagSettings(_.getUser(),y).then((function(e){P=e||{},Re()})).catch((function(e){P={},Te(e)}))})):Promise.reject(new a(Q()))).catch((function(e){return m.maybeReportError(e)}));function je(e){b=e.environment,_.setUser(e.user),P=r({},e.flags),R(Re)}function Re(){p.info(V()),L=!0,ie(),m.emit(_e),m.emit(Ve)}function Te(e){m.maybeReportError(e),m.emit(ze,e),m.emit(_e)}return{client:{waitForInitialization:function(){return Se},waitUntilReady:function(){return Ee},identify:function(e,n,t){return F?T(Promise.resolve({}),t):J?(p.warn(ae()),T(Promise.resolve(I(P)),t)):T((f&&g?g.clearFlags():Promise.resolve()).then((function(){return z.validateUser(e)})).then((function(e){return S.fetchFlagSettings(e,n).then((function(n){var t=I(n);return _.setUser(e),n?ee(n).then((function(){return t})):t}))})).then((function(e){return v&&W(),e})).catch((function(e){return m.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return _.getUser()},variation:function(e,n){return G(e,n,!0,!1).value},variationDetail:function(e,n){return G(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&p.warn(B(e));var r={kind:"custom",key:e,user:_.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),H(r)}else m.maybeReportError(new c(B(e)))},on:function(e,n,t){ge(e)?(d=!0,L&&ie(),m.on(e,n,t)):m.on.apply(m,arguments)},off:function(e){if(m.off.apply(m,arguments),ge(e)){var n=!1;m.getEvents().forEach((function(e){ge(e)&&m.getEventListenerCount(e)>0&&(n=!0)})),n||(d=!1,v&&void 0===N&&Z())}},setStreaming:function(e){var n=null===e?void 0:e;n!==N&&(N=n,ie())},flush:function(e){return T(w?E.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)P.hasOwnProperty(n)&&(e[n]=G(n,null,!h.sendEventsOnlyForVariation).value);return e},close:function(e){if(F)return T(Promise.resolve(),e);var n=function(){F=!0,P={}};return T(Promise.resolve().then((function(){if(Z(),w)return E.stop(),E.flush()})).then(n).catch(n),e)}},options:h,emitter:m,ident:_,logger:p,requestor:S,start:function(){w&&E.start()},enqueueEvent:H,getFlagsInternal:function(){return P},getEnvironmentId:function(){return b},internalChangeEventName:$e}}function Me(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Ge(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 Xe={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Be(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return Xe;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),Xe;var u;return{promise:new Promise((function(e,n){i.addEventListener("load",(function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){u||n(new Error)})),i.send(r)})),cancel:function(){u=!0,i.abort()}}}function We(e){var n,t={};t.synchronousFlush=!1,window.XMLHttpRequest&&(t.httpRequest=function(e,n,r,o){var i=t.synchronousFlush;return t.synchronousFlush=!1,Be(e,n,r,o,i)}),t.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n};var r,o=e&&e.eventUrlTransformer;t.getCurrentUrl=function(){return o?o(window.location.href):window.location.href},t.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(t.localStorage={get:function(e){return new Promise((function(n){n(window.localStorage.getItem(e))}))},set:function(e,n){return new Promise((function(t){window.localStorage.setItem(e,n),t()}))},clear:function(e){return new Promise((function(n){window.localStorage.removeItem(e),n()}))}})}catch(e){t.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(t.eventSourceAllowsReport=!0,r=window.EventSourcePolyfill):(t.eventSourceAllowsReport=!1,r=window.EventSource),window.EventSource){t.eventSourceFactory=function(e,n){var t=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ge(t,!0).forEach((function(n){Me(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ge(t).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},t.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return t.userAgent="JSClient",t}var Qe=/[|\\{}()[\]^$+*?.]/g,Ye=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Qe,"\\$&")};function Ze(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Ye(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Ye(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Ye(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function en(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],c=0;c<u.length;c++)if(Ze(u[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var c=0;c<u.length;c++)o===u[c]&&t.push(i);o=o.parentNode}return t}(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var nn=300;function tn(e,n){var t,r,o={};function i(){r&&r.dispose(),t&&t.length&&(r=en(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=en(t=e,a),function(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout((function(){e(n,t)}),t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(nn,i)),n()})).catch((function(t){e.emitter.maybeReportError(new v.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),o}var rn="goalsReady",on={fetchGoals:{default:!0},hash:{type:"string"},eventUrlTransformer:{type:"function"}};function an(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=We(t),o=Ke(e,n,t,r,on),i=o.client,a=o.options,u=o.emitter,c=new Promise((function(e){var n=u.on(rn,(function(){u.off(rn,n),e()}))}));if(i.waitUntilGoalsReady=function(){return c},a.fetchGoals){var s=tn(o,(function(){return u.emit(rn)}));r.customEventFilter=s.goalKeyExists}else u.emit(rn);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch((function(){}))};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var un=Je,cn="2.16.0";var sn={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Se.deprecated("default export","named LDClient export")),an(e,n,t)},version:"2.16.0"};export default sn;export{un as createConsoleLogger,an as initialize,cn as version}; | ||
//# sourceMappingURL=ldclient.es.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).LDClient={})}(this,function(e){"use strict";function ke(e){return(ke="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 Ee(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 S=t("LaunchDarklyUnexpectedResponseError"),Se=t("LaunchDarklyInvalidEnvironmentIdError"),a=t("LaunchDarklyInvalidUserError"),Pe=t("LaunchDarklyInvalidEventKeyError"),Oe=t("LaunchDarklyInvalidArgumentError"),De=t("LaunchDarklyFlagFetchError");function P(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:S,LDInvalidEnvironmentIdError:Se,LDInvalidUserError:a,LDInvalidEventKeyError:Pe,LDInvalidArgumentError:Oe,LDFlagFetchError:De,isHttpErrorRecoverable:P}),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 d=Array.isArray,g=Object.keys,p=Object.prototype.hasOwnProperty,v=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=d(n),u=d(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var 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=g(n);if((o=v.length)!==g(t).length)return!1;for(r=o;0!=r--;)if(!p.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function m(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 Ue(e){return m(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Re(e){return JSON.parse(JSON.stringify(e))}function je(e,n){return v(e,n)}function Ie(e){setTimeout(e,0)}function Ne(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function y(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function Te(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function w(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=Ue(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||"2.14.1";return e.userAgent+"/"+n}function k(e){return{"X-LaunchDarkly-User-Agent":b(e)}}function Le(){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 Ee({},e,{},n)},{})}function Fe(e){if(!e)return e;var n;for(var t in h){var r=h[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||Ee({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:m,base64URLEncode:Ue,clone:Re,deepEquals:je,onNextTick:Ie,wrapPromiseCallback:Ne,transformValuesToVersionedValues:y,transformVersionedValuesToValues:Te,chunkUserEventsForUrl:w,getLDUserAgentString:b,getLDHeaders:k,extend:Le,sanitizeUser:Fe});var E=2e3;function O(c,l,e,f){var v=l+"/events/bulk/"+e,d=l+"/a/"+e+".gif",n={};function g(e){(new window.Image).src=e}return n.sendEvents=function(e){if(!c.httpRequest)return Promise.resolve();var n,t,r,o,i,a=c.httpAllowsPost();n=a?[e]:w(E-l.length,e);for(var u=[],s=0;s<n.length;s++)u.push((t=n[s],r=a,o=void 0,o=f||g,i=JSON.stringify(t),r?function n(t){var e=Le({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},k(c));return c.httpRequest("POST",v,e,i).promise.then(function(e){if(e)return 400<=e.status&&P(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(){}):(o(d+"?d="+Ue(i)),Promise.resolve())));return Promise.all(u)},n}function D(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=Le({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function U(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var xe=function(){return"LaunchDarkly client initialized"},R=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",Ae=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},j=function(e){return'Expected application/json content type but got "'+e+'"'},Ce=function(){return"localStorage is unavailable"},I=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},N=function(e){return"network error"+(e?" ("+e+")":"")},qe=function(e){return'Custom event "'+e+'" does not exist'},T=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+R},_e=function(){return"No environment/client-side ID was specified."+R},Je=function(e){return"Error fetching flag settings: "+U(e)},L=function(){return"No user specified."+R},F=function(){return"Invalid user specified."+R},Ve=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+R},ze=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},He=function(e,n){return n?'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"':'[LaunchDarkly] "'+e+'" is deprecated'},x=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(P(e)?t:"giving up permanently")},A=function(){return"Cannot make HTTP requests in this environment."+R},$e=function(){return"identify() has no effect here; it must be called on the main client instance"},Me=function(){return"Closing stream connection"},Ke=function(e){return"Opening stream connection to "+e},Ge=function(e,n){return"Error on stream connection: "+U(e)+", will continue retrying every "+n+" milliseconds."},C=function(e){return"polling for feature flags at "+e},Xe=function(){return"received ping message from stream"},Be=function(){return"received streaming update for all flags"},We=function(e){return'received streaming update for flag "'+e+'"'},Qe=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+'"'},Ze=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},en=function(e){return'enqueueing "'+e+'" event'},q=function(e){return"sending "+e+" events"},_=Object.freeze({__proto__:null,clientInitialized:xe,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventWithoutUser:Ae,invalidContentType:j,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Ce,localStorageUnavailableForUserId:I,networkError:N,unknownCustomEventKey:qe,environmentNotFound:T,environmentNotSpecified:_e,errorFetchingFlags:Je,userNotSpecified:L,invalidUser:F,bootstrapOldFormat:Ve,bootstrapInvalid:ze,deprecated:He,httpErrorMessage:x,httpUnavailable:A,identifyDisabled:$e,streamClosing:Me,streamConnecting:Ke,streamError:Ge,debugPolling:C,debugStreamPing:Xe,debugStreamPut:Be,debugStreamPatch:We,debugStreamPatchIgnored:Qe,debugStreamDelete:Ye,debugStreamDeleteIgnored:Ze,debugEnqueueingEvent:en,debugPostingEvents:q});function nn(e,n,t,r,o){var i,a,u,s,c,l=3<arguments.length&&void 0!==r?r:null,f={},v=(4<arguments.length&&void 0!==o?o:null)||O(e,n.eventsUrl,t),d=(u=a=0,s={},(i={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=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)}},i.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}},i.clearSummary=function(){u=a=0,s={}},i),g=D(n),p=n.inlineUsersInEvents,h=n.samplingInterval,m=n.flushInterval,y=n.logger,w=[],b=0,k=!1;function E(){return 0===h||0===Math.floor(Math.random()*h)}return f.enqueue=function(e){if(!k){var n,t=!1,r=!1;if(d.summarizeEvent(e),"feature"===e.kind?E()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>b&&n.debugEventsUntilDate>(new Date).getTime()):t=E(),t&&w.push((a=Le({},i=e),p||"identify"===i.kind?a.user=g.filterUser(i.user):(a.userKey=i.user.key,delete a.user),"feature"===i.kind&&(delete a.trackEvents,delete a.debugEventsUntilDate),a)),r){var o=Le({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,w.push(o)}}var i,a},f.flush=function(){if(k)return Promise.resolve();var e=w,n=d.getSummary();return d.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(w=[],y.debug(q(e.length)),v.sendEvents(e).then(function(e){e&&(e.serverTime&&(b=e.serverTime),P(e.status)||(k=!0),400<=e.status&&Ie(function(){l.maybeReportError(new S(x(e.status,"event posting","some events were dropped")))}))}))},f.start=function(){c=setTimeout(function e(){f.flush(),c=setTimeout(e,m)},m)},f.stop=function(){clearTimeout(c)},f}function tn(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||m(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(Ce()),Promise.reject(e)})},u.saveFlags=function(e){var n=Le({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(Ce()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(Ce()),Promise.reject(e)})},u}var J,V="application/json";function rn(d,e,a){var u=e.baseUrl,s=e.useReport,c=e.evaluationReasons,g=e.sendLDHeaders,l=e.logger,n={},p={};function f(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new De(A()))});var t=n?"REPORT":"GET",r=g?k(d):{};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 Se(T()):new De(Je(n.statusText||String(n.status))));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(V))return JSON.parse(e.body);var n,t=j(e.header("content-type")||"");return Promise.reject(new De(t))},function(e){return Promise.reject(new De(N(e)))});return l.addPromise(v,function(){f.cancel&&f.cancel()}),l.resultPromise}return n.fetchJSON=function(e){return f(u+e,null)},n.fetchFlagSettings=function(e,n){var t,r,o,i="";return s?(r=[u,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=Ue(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(C(r)),f(r,o)},n}for(var z=(J=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}}}(J={exports:{}}),J.exports),H=[],$=0;$<256;++$)H[$]=($+256).toString(16).substr(1);var M,K,G=0,X=0,B=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||M,a=void 0!==e.clockseq?e.clockseq:K;if(null==i||null==a){var u=z();null==i&&(i=M=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=K=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:X+1,l=s-G+(c-X)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||G<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=s,K=a;var f=(1e4*(268435455&(s+=122192928e5))+(X=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var 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=H;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)},W="ld:$anonUserId";function on(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new a(L()));var r=Re(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get(W).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=B();return r.key=t,(n=t,o?o.set(W,n).catch(function(){i.warn(I())}):Promise.resolve()).then(function(){return r})}):Promise.reject(new a(F()))},e}function an(e,n){var o,i=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var a=0;e&&(a="none"===e?100:i.indexOf(e));var t={};function r(e,n,t){if(a<=e){var r=e<i.length?i[e]:"?";n(o+"["+r+"] "+t)}}return t.debug=function(e){return r(0,console.log,e)},t.info=function(e){return r(1,console.info,e)},t.warn=function(e){return r(2,console.warn,e)},t.error=function(e){return r(3,console.error,e)},t}var un="ready",sn="initialized",cn="failed",ln="change",fn="internal-change";function Q(e,n,t,o,r){var a,i,u,s,c,l,f,v,d,g,p,h,m,y,w,b,k,E,S,P,O,D,U,R,j,I,N,T,L,F,x,A=t&&t.logger?t.logger:r&&r.logger||an("warn"),C=function(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=0;n<o[e].length;n++)o[e][n].handler.apply(o[e][n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}(A),q=(U=t,R=C,I=Le({logger:j=A},{baseUrl:"https://app.launchdarkly.com",streamUrl:"https://clientstream.launchdarkly.com",eventsUrl:"https://events.launchdarkly.com",sendEvents:!0,sendLDHeaders:!0,inlineUsersInEvents:!1,allowFrequentDuplicateEvents:!1,sendEventsOnlyForVariation:!1,useReport:!1,evaluationReasons:!1,flushInterval:2e3,samplingInterval:0,streamReconnectDelay:1e3,allAttributesPrivate:!1,privateAttributeNames:[]},r),N={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null},x=Le({},U||{}),F=x,Object.keys(N).forEach(function(e){if(void 0!==F[e]){var n=N[e];j&&j.warn(He(e,n)),n&&(void 0===F[n]&&(F[n]=F[e]),delete F[e])}}),T=I,L=Le({},x),Object.keys(T).forEach(function(e){void 0!==L[e]&&null!==L[e]||(L[e]=T[e])}),x=L,(isNaN(x.flushInterval)||x.flushInterval<2e3)&&(x.flushInterval=2e3,oe("Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).")),(isNaN(x.samplingInterval)||x.samplingInterval<0)&&(x.samplingInterval=0,oe("Invalid sampling interval configured. Sampling interval must be an integer >= 0.")),x),_=q.hash,J=q.sendEvents,V=e,z=(f=o,d=V,g=_,p=(v=q).streamUrl,h=v.logger,m={},y=p+"/eval/"+d,w=v.useReport,b=v.evaluationReasons,k=v.streamReconnectDelay,E=!1,D=O=P=S=null,m.connect=function(e,t){function n(n){D[n]=function(e){E=!1,t[n]&&t[n](e)}}for(var r in O=e,D={},t||{})n(r);ne()},m.disconnect=function(){clearTimeout(P),P=null,re()},m.isConnected=function(){return!!(S&&f.eventSourceIsActive&&f.eventSourceIsActive(S))},m),H=q.eventProcessor||nn(o,q,V,C),$=rn(o,q,V),M={},K={},G=q.streaming,X=!1,B=!1,W=!0,Q=q.stateProvider,Y=(c=function(e){Q||e&&ie({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(l=Fe(e))&&c&&c(Re(l))},getUser:function(){return l?Re(l):null}}),Z=on(o.localStorage,A);function ee(e){E||(h.warn(Ge(e,k)),E=!0),re(),ne(k)}function ne(e){P||(e?P=setTimeout(te,e):te())}function te(){var e;P=null;var n="",t={};if(f.eventSourceFactory){for(var r in null!=g&&(n="h="+g),w?f.eventSourceAllowsReport?(e=y,t.method="REPORT",t.headers={"Content-Type":"application/json"},t.body=JSON.stringify(O)):(e=p+"/ping/"+d,n=""):e=y+"/"+Ue(JSON.stringify(O)),b&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,re(),h.info(Ke(e)),S=f.eventSourceFactory(e,t),D)D.hasOwnProperty(r)&&S.addEventListener(r,D[r]);S.onerror=ee}}function re(){S&&(h.info(Me()),S.close(),S=null)}function oe(e){Ie(function(){R&&R.maybeReportError(new Oe(e))})}function ie(e){V&&(Q&&Q.enqueueEvent&&Q.enqueueEvent(e)||(e.user?(W=!1,!J||B||o.isDoNotTrack()||(A.debug(en(e.kind)),H.enqueue(e))):W&&(A.warn(Ae()),W=!1)))}function ae(e,n,t,r){var o=Y.getUser(),i=new Date,a=n?n.value:null;if(!q.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=M[u];if(s&&i-s<3e5)return;M[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=K[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),ie(c)}function ue(e,n,t,r){var o;if(K&&K.hasOwnProperty(e)&&K[e]&&!K[e].deleted){var i=K[e];o=se(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&&ae(e,o,n,r),o}function se(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ce(){i=!0,Y.getUser()&&z.connect(Y.getUser(),{ping:function(){A.debug(Xe()),$.fetchFlagSettings(Y.getUser(),_).then(function(e){return fe(e||{})}).catch(function(e){C.maybeReportError(new De(Je(e)))})},put:function(e){var n=JSON.parse(e.data);A.debug(Be()),fe(n)},patch:function(e){var n=JSON.parse(e.data),t=K[n.key];if(!t||!t.version||!n.version||t.version<n.version){A.debug(We(n.key));var r={},o=Le({},n);delete o.key;var i=se(K[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ve(r)}else A.debug(Qe(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!K[n.key]||K[n.key].version<n.version){A.debug(Ye(n.key));var t={};K[n.key]&&!K[n.key].deleted&&(t[n.key]={previous:K[n.key].value}),K[n.key]={version:n.version,deleted:!0},ve(t)}else A.debug(Ze(n.key))}})}function le(){i&&(z.disconnect(),i=!1)}function fe(e){var n={};if(!e)return Promise.resolve();for(var t in K)K.hasOwnProperty(t)&&K[t]&&(e[t]&&!je(e[t].value,K[t].value)?n[t]={previous:K[t].value,current:se(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:K[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!K[r]||K[r].deleted)&&(n[r]={current:se(e[r])});return K=Ee({},e),ve(n).catch(function(){})}function ve(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;C.emit(ln+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),C.emit(ln,i),C.emit(fn,K),q.sendEventsOnlyForVariation||Q||e.forEach(function(e){ae(e,o[e].current)})}return a&&s?s.saveFlags(K).catch(function(){return null}):Promise.resolve()}function de(){var e=G||u&&void 0===G;e&&!i?ce():!e&&i&&le()}function ge(e){return e===ln||e.substr(0,ln.length+1)===ln+":"}o.localStorage&&(s=new tn(o.localStorage,V,_,Y,A));var pe=new Promise(function(e){var n=C.on(un,function(){C.off(un,n),e()})}),he=new Promise(function(e,n){var t=C.on(sn,function(){C.off(sn,t),e()}),r=C.on(cn,function(e){C.off(cn,r),n(e)})});if("string"==typeof q.bootstrap&&"LOCALSTORAGE"===q.bootstrap.toUpperCase()&&(s?a=!0:A.warn(Ce())),"object"===ke(q.bootstrap)&&(K=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&A.warn(Ve()),!1===t.$valid&&A.warn(ze());var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=Le(n,r[e]):n.version=0,o[e]=n}}),o}(q.bootstrap)),Q){var me=Q.getInitialState();me?ye(me):Q.on("init",ye),Q.on("update",function(e){e.user&&Y.setUser(e.user),e.flags&&fe(e.flags)})}else(e?Z.validateUser(n).then(function(e){return Y.setUser(e),"object"===ke(q.bootstrap)?we():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(K={},$.fetchFlagSettings(Y.getUser(),_).then(function(e){return fe(e||{})}).then(we).catch(function(e){be(new De(Je(e)))})):(K=e,Ie(we),$.fetchFlagSettings(Y.getUser(),_).then(function(e){return fe(e)}).catch(function(e){return C.maybeReportError(e)}))}):$.fetchFlagSettings(Y.getUser(),_).then(function(e){K=e||{},we()}).catch(function(e){K={},be(e)})}):Promise.reject(new Se(_e()))).catch(function(e){return C.maybeReportError(e)});function ye(e){V=e.environment,Y.setUser(e.user),K=Ee({},e.flags),Ie(we)}function we(){A.info(xe()),X=!0,de(),C.emit(un),C.emit(sn)}function be(e){C.maybeReportError(e),C.emit(cn,e),C.emit(un)}return{client:{waitForInitialization:function(){return he},waitUntilReady:function(){return pe},identify:function(e,n,t){return B?Ne(Promise.resolve({}),t):Q?(A.warn($e()),Ne(Promise.resolve(Te(K)),t)):Ne((a&&s?s.clearFlags():Promise.resolve()).then(function(){return Z.validateUser(e)}).then(function(e){return Y.setUser(e)}).then(function(){return $.fetchFlagSettings(Y.getUser(),n)}).then(function(e){var n=Te(e);return e?fe(e).then(function(){return n}):n}).then(function(e){return i&&ce(),e}).catch(function(e){return C.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return Y.getUser()},variation:function(e,n){return ue(e,n,!0,!1).value},variationDetail:function(e,n){return ue(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&A.warn(qe(e));var r={kind:"custom",key:e,user:Y.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),ie(r)}else C.maybeReportError(new Pe(qe(e)))},on:function(e,n,t){ge(e)?(u=!0,X&&de(),C.on(e,n,t)):C.on.apply(C,arguments)},off:function(e){if(C.off.apply(C,arguments),ge(e)){var n=!1;C.getEvents().forEach(function(e){ge(e)&&0<C.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===G&&le())}},setStreaming:function(e){var n=null===e?void 0:e;n!==G&&(G=n,de())},flush:function(e){return Ne(J?H.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!K)return e;for(var n in K)K.hasOwnProperty(n)&&(e[n]=ue(n,null,!q.sendEventsOnlyForVariation).value);return e},close:function(e){if(B)return Ne(Promise.resolve(),e);function n(){B=!0,K={}}return Ne(Promise.resolve().then(function(){if(le(),J)return H.stop(),H.flush()}).then(n).catch(n),e)}},options:q,emitter:C,ident:Y,logger:A,requestor:$,start:function(){J&&H.start()},enqueueEvent:ie,getFlagsInternal:function(){return K},getEnvironmentId:function(){return V},internalChangeEventName:fn}}function Y(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function Z(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Y(i,!0).forEach(function(e){var n,t,r;n=o,r=i[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):Y(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var ee={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function ne(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return ee;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),ee;var u;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}var te=/[|\\{}()[\]^$+*?.]/g,re=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(te,"\\$&")};function oe(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+re(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+re(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+re(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function ie(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(oe(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 ae=300;function ue(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=ie(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=ie(t=e,a),u(ae,i)),n()}).catch(function(e){r.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var se="goalsReady",ce={fetchGoals:!0};function le(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n,i={synchronousFlush:!1};window.XMLHttpRequest&&(i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush;return i.synchronousFlush=!1,ne(e,n,t,r,o)}),i.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n};var r,t=e&&e.eventUrlTransformer;i.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},i.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(i.localStorage={get:function(n){return new Promise(function(e){e(window.localStorage.getItem(n))})},set:function(n,t){return new Promise(function(e){window.localStorage.setItem(n,t),e()})},clear:function(n){return new Promise(function(e){window.localStorage.removeItem(n),e()})}})}catch(e){i.localStorage=null}var o=e&&e.useReport;if(r=o&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(i.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(i.eventSourceAllowsReport=!1,window.EventSource),window.EventSource){i.eventSourceFactory=function(e,n){var t=Z({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},i.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return i.userAgent="JSClient",i}(t),o=Q(e,n,t,r,ce),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(se,function(){u.off(se,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=ue(o,function(){return u.emit(se)});r.customEventFilter=c.goalKeyExists}else u.emit(se);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){})}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var fe=an;var ve={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(_.deprecated("default export","named LDClient export")),le(e,n,t)},version:"2.15.2"};e.createConsoleLogger=fe,e.default=ve,e.initialize=le,e.version="2.15.2",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).LDClient={})}(this,function(e){"use strict";function Oe(e){return(Oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function Pe(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(i,!0).forEach(function(e){var n,t,r;n=o,r=i[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):n(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var D=t("LaunchDarklyUnexpectedResponseError"),De=t("LaunchDarklyInvalidEnvironmentIdError"),a=t("LaunchDarklyInvalidUserError"),je=t("LaunchDarklyInvalidEventKeyError"),Ue=t("LaunchDarklyInvalidArgumentError"),Re=t("LaunchDarklyFlagFetchError");function j(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var c=Object.freeze({__proto__:null,LDUnexpectedResponseError:D,LDInvalidEnvironmentIdError:De,LDInvalidUserError:a,LDInvalidEventKeyError:je,LDInvalidArgumentError:Ue,LDFlagFetchError:Re,isHttpErrorRecoverable:j}),r=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(f(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"=")),o.join("")},u=[],o=[],i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=i.length;s<l;++s)u[s]=i[s],o[i.charCodeAt(s)]=s;function f(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(u[(o=r)>>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63;var d=Array.isArray,g=Object.keys,p=Object.prototype.hasOwnProperty,v=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=d(n),u=d(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var c=n instanceof Date,s=t instanceof Date;if(c!=s)return!1;if(c&&s)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=g(n);if((o=v.length)!==g(t).length)return!1;for(r=o;0!=r--;)if(!p.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t},m=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function h(e){var n=unescape(encodeURIComponent(e));return r(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function Te(e){return h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Ne(e){return JSON.parse(JSON.stringify(e))}function Le(e,n){return v(e,n)}function Ie(e){setTimeout(e,0)}function xe(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function y(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function Fe(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function w(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=Te(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function b(e){var n=e.version||"3.1.0";return e.userAgent+"/"+n}function Ce(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":b(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function Ae(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return Pe({},e,{},n)},{})}function qe(e){if(!e)return e;var n;for(var t in m){var r=m[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||Pe({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:h,base64URLEncode:Te,clone:Ne,deepEquals:Le,onNextTick:Ie,wrapPromiseCallback:xe,transformValuesToVersionedValues:y,transformVersionedValuesToValues:Fe,chunkUserEventsForUrl:w,getLDUserAgentString:b,getLDHeaders:Ce,extend:Ae,sanitizeUser:qe});var k=2e3;function U(c,s,e,l){var f=s+"/events/bulk/"+e,v=s+"/a/"+e+".gif",d=c.httpFallbackPing,n={};return n.sendEvents=function(e){if(!c.httpRequest)return Promise.resolve();var n,t,r,o,i=c.httpAllowsPost();n=i?[e]:w(k-s.length,e);for(var a=[],u=0;u<n.length;u++)a.push((t=n[u],r=i,void 0,o=JSON.stringify(t),r?function n(t){var e=Ae({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},Ce(c,l));return c.httpRequest("POST",f,e,o).promise.then(function(e){if(e)return 400<=e.status&&j(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(d&&d(v+"?d="+Te(o)),Promise.resolve())));return Promise.all(a)},n}function R(e){var n={},c=e.allAttributesPrivate,s=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(o,i){return Object.keys(o).reduce(function(e,n){var t,r=e;return i(n)&&(l[t=n]||!c&&-1===a.indexOf(t)&&-1===s.indexOf(t)?r[0][n]=o[n]:r[1][n]=!0),r},[{},{}])}var a=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var i=n(e.custom,function(){return!0});r.custom=i[0],o=Ae({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function E(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var _e=function(){return"LaunchDarkly client initialized"},S=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",T=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},Je=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},O=function(e){return'Expected application/json content type but got "'+e+'"'},Ve=function(){return"localStorage is unavailable"},P=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},N=function(e){return"network error"+(e?" ("+e+")":"")},ze=function(e){return'Custom event "'+e+'" does not exist'},L=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+S},He=function(){return"No environment/client-side ID was specified."+S},$e=function(e){return"Error fetching flag settings: "+E(e)},I=function(){return"No user specified."+S},x=function(){return"Invalid user specified."+S},Me=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+S},Ke=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'},F=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(j(e)?t:"giving up permanently")},C=function(){return"Cannot make HTTP requests in this environment."+S},Xe=function(){return"identify() has no effect here; it must be called on the main client instance"},Be=function(){return"Closing stream connection"},We=function(e){return"Opening stream connection to "+e},Qe=function(e,n){return"Error on stream connection: "+E(e)+", will continue retrying every "+n+" milliseconds."},Ye=function(e){return'Ignoring unknown config option "'+e+'"'},Ze=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},en=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},nn=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},A=function(e){return"polling for feature flags at "+e},tn=function(){return"received ping message from stream"},rn=function(){return"received streaming update for all flags"},on=function(e){return'received streaming update for flag "'+e+'"'},an=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},un=function(e){return'received streaming deletion for flag "'+e+'"'},cn=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},sn=function(e){return'enqueueing "'+e+'" event'},q=function(e){return"sending "+e+" events"},_=Object.freeze({__proto__:null,clientInitialized:_e,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:T,eventWithoutUser:Je,invalidContentType:O,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Ve,localStorageUnavailableForUserId:P,networkError:N,unknownCustomEventKey:ze,environmentNotFound:L,environmentNotSpecified:He,errorFetchingFlags:$e,userNotSpecified:I,invalidUser:x,bootstrapOldFormat:Me,bootstrapInvalid:Ke,deprecated:Ge,httpErrorMessage:F,httpUnavailable:C,identifyDisabled:Xe,streamClosing:Be,streamConnecting:We,streamError:Qe,unknownOption:Ye,wrongOptionType:Ze,wrongOptionTypeBoolean:en,optionBelowMinimum:nn,debugPolling:A,debugStreamPing:tn,debugStreamPut:rn,debugStreamPatch:on,debugStreamPatchIgnored:an,debugStreamDelete:un,debugStreamDeleteIgnored:cn,debugEnqueueingEvent:sn,debugPostingEvents:q});function ln(e,n,t,r,o){var i,a,u,c,s,l=3<arguments.length&&void 0!==r?r:null,f={},v=(4<arguments.length&&void 0!==o?o:null)||U(e,n.eventsUrl,t,n),d=(u=a=0,c={},(i={}).summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=c[n];t?t.count=t.count+1:c[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},i.getSummary=function(){var e={},n=!0;for(var t in c){var r=c[t],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:u,features:e}},i.clearSummary=function(){u=a=0,c={}},i),g=R(n),p=n.inlineUsersInEvents,m=n.samplingInterval,h=n.eventCapacity,y=n.flushInterval,w=n.logger,b=[],k=0,E=!1,S=!1;function O(){return 0===m||0===Math.floor(Math.random()*m)}function P(e){b.length<h?(b.push(e),S=!1):S||(S=!0,w.warn(T()))}return f.enqueue=function(e){if(!E){var n,t=!1,r=!1;if(d.summarizeEvent(e),"feature"===e.kind?O()&&(t=!!e.trackEvents,r=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>k&&n.debugEventsUntilDate>(new Date).getTime()):t=O(),t&&P((a=Ae({},i=e),p||"identify"===i.kind?a.user=g.filterUser(i.user):(a.userKey=i.user.key,delete a.user),"feature"===i.kind&&(delete a.trackEvents,delete a.debugEventsUntilDate),a)),r){var o=Ae({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,P(o)}}var i,a},f.flush=function(){if(E)return Promise.resolve();var e=b,n=d.getSummary();return d.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(b=[],w.debug(q(e.length)),v.sendEvents(e).then(function(e){e&&(e.serverTime&&(k=e.serverTime),j(e.status)||(E=!0),400<=e.status&&Ie(function(){l.maybeReportError(new D(F(e.status,"event posting","some events were dropped")))}))}))},f.start=function(){s=setTimeout(function e(){f.flush(),s=setTimeout(e,y)},y)},f.stop=function(){clearTimeout(s)},f}function fn(t,r,o,i,a){var u={};function c(){var e="",n=i.getUser();return n&&(e=o||h(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(c()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=y(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(Ve()),Promise.reject(e)})},u.saveFlags=function(e){var n=Ae({},e,{$schema:1});return t.set(c(),JSON.stringify(n)).catch(function(e){return a.warn(Ve()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(c()).catch(function(e){return a.warn(Ve()),Promise.reject(e)})},u}var J,V="application/json";function vn(d,g,a){var u=g.baseUrl,c=g.useReport,s=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new Re(C()))});var t=n?"REPORT":"GET",r=Ce(d,g);n&&(r["Content-Type"]="application/json");var o,i,a,u,c,s,l=p[e];l||(o=function(){delete p[e]},(s={addPromise:function(n,e){i=n,a&&a(),a=e,n.then(function(e){i===n&&(u(e),o())},function(e){i===n&&(c(e),o())})}}).resultPromise=new Promise(function(e,n){u=e,c=n}),l=s,p[e]=l);var f=d.httpRequest(t,e,r,n),v=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new De(L()):new Re($e(n.statusText||String(n.status))));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf(V))return JSON.parse(e.body);var n,t=O(e.header("content-type")||"");return Promise.reject(new Re(t))},function(e){return Promise.reject(new Re(N(e)))});return l.addPromise(v,function(){f.cancel&&f.cancel()}),l.resultPromise}return e.fetchJSON=function(e){return f(u+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[u,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=Te(JSON.stringify(e)),r=[u,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),s&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,l.debug(A(r)),f(r,o)},e}for(var z=(J=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}}}(J={exports:{}}),J.exports),H=[],$=0;$<256;++$)H[$]=($+256).toString(16).substr(1);var M,K,G=0,X=0,B=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||M,a=void 0!==e.clockseq?e.clockseq:K;if(null==i||null==a){var u=z();null==i&&(i=M=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=K=16383&(u[6]<<8|u[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:X+1,l=c-G+(s-X)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||G<c)&&void 0===e.nsecs&&(s=0),1e4<=s)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=c,K=a;var f=(1e4*(268435455&(c+=122192928e5))+(X=s))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=c/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=H;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)},W="ld:$anonUserId";function dn(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new a(I()));var r=Ne(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get(W).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=B();return r.key=t,(n=t,o?o.set(W,n).catch(function(){i.warn(P())}):Promise.resolve()).then(function(){return r})}):Promise.reject(new a(x()))},e}var gn={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function pn(e,n){var o,i=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var a=0;e&&(a="none"===e?100:i.indexOf(e));var t={};function r(e,n,t){if(a<=e){var r=e<i.length?i[e]:"?";n(o+"["+r+"] "+t)}}return t.debug=function(e){return r(0,console.log,e)},t.info=function(e){return r(1,console.info,e)},t.warn=function(e){return r(2,console.warn,e)},t.error=function(e){return r(3,console.error,e)},t}var mn="ready",hn="initialized",yn="failed",wn="change",bn="internal-change";function Q(e,n,t,o,r){var a,i,u,c,s,l,f,v,d,g,p,m,h,y,w,b,k,E,S,O,P,D,j,U,R,T,N,L,I,x,F,C,A,q=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||pn("warn"),_=function(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=0;n<o[e].length;n++)o[e][n].handler.apply(o[e][n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}(q),J=(U=t,R=_,N=Ae({logger:{default:T=q}},gn,r),L={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null},A=Ae({},U||{}),C=A,Object.keys(L).forEach(function(e){if(void 0!==C[e]){var n=L[e];T&&T.warn(Ge(e,n)),n&&(void 0===C[n]&&(C[n]=C[e]),delete C[e])}}),F=Ae({},A),Object.keys(N).forEach(function(e){void 0!==F[e]&&null!==F[e]||(F[e]=N[e]&&N[e].default)}),I=A=F,x=Ae({},I),Object.keys(I).forEach(function(e){var n=I[e];if(null!=n){var t=N[e];if(void 0===t)ae(Ye(e));else{var r=t.type||ue(t.default);if("any"!==r){var o=r.split("|"),i=ue(n);o.indexOf(i)<0?"boolean"===r?(x[e]=!!n,ae(en(e,i))):(ae(Ze(e,r,i)),x[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(ae(nn(e,n,t.minimum)),x[e]=t.minimum)}}}}),x),V=J.hash,z=J.sendEvents,H=e,$=(f=o,d=H,g=V,p=(v=J).streamUrl,m=v.logger,h={},y=p+"/eval/"+d,w=v.useReport,b=v.evaluationReasons,k=v.streamReconnectDelay,E=Ce(f,v),S=!1,j=D=P=O=null,h.connect=function(e,t){function n(n){j[n]=function(e){S=!1,t[n]&&t[n](e)}}for(var r in D=e,j={},t||{})n(r);re()},h.disconnect=function(){clearTimeout(P),P=null,ie()},h.isConnected=function(){return!!(O&&f.eventSourceIsActive&&f.eventSourceIsActive(O))},h),M=J.eventProcessor||ln(o,J,H,_),K=vn(o,J,H),G={},X={},B=J.streaming,W=!1,Q=!1,Y=!0,Z=J.stateProvider,ee=(s=function(e){Z||e&&ce({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(l=qe(e))&&s&&s(Ne(l))},getUser:function(){return l?Ne(l):null}}),ne=dn(o.localStorage,q);function te(e){S||(m.warn(Qe(e,k)),S=!0),ie(),re(k)}function re(e){P||(e?P=setTimeout(oe,e):oe())}function oe(){var e;P=null;var n="",t={headers:E};if(f.eventSourceFactory){for(var r in null!=g&&(n="h="+g),w?f.eventSourceAllowsReport?(e=y,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(D)):(e=p+"/ping/"+d,n=""):e=y+"/"+Te(JSON.stringify(D)),b&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,ie(),m.info(We(e)),O=f.eventSourceFactory(e,t),j)j.hasOwnProperty(r)&&O.addEventListener(r,j[r]);O.onerror=te}}function ie(){O&&(m.info(Be()),O.close(),O=null)}function ae(e){Ie(function(){R&&R.maybeReportError(new Ue(e))})}function ue(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=Oe(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}function ce(e){H&&(Z&&Z.enqueueEvent&&Z.enqueueEvent(e)||(e.user?(Y=!1,!z||Q||o.isDoNotTrack()||(q.debug(sn(e.kind)),M.enqueue(e))):Y&&(q.warn(Je()),Y=!1)))}function se(e,n,t,r){var o=ee.getUser(),i=new Date,a=n?n.value:null;if(!J.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,c=G[u];if(c&&i-c<3e5)return;G[u]=i}var s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=X[e];l&&(s.version=l.flagVersion?l.flagVersion:l.version,s.trackEvents=l.trackEvents,s.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(s.reason=n.reason),ce(s)}function le(e,n,t,r){var o;if(X&&X.hasOwnProperty(e)&&X[e]&&!X[e].deleted){var i=X[e];o=fe(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&se(e,o,n,r),o}function fe(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ve(){i=!0,ee.getUser()&&$.connect(ee.getUser(),{ping:function(){q.debug(tn()),K.fetchFlagSettings(ee.getUser(),V).then(function(e){return ge(e||{})}).catch(function(e){_.maybeReportError(new Re($e(e)))})},put:function(e){var n=JSON.parse(e.data);q.debug(rn()),ge(n)},patch:function(e){var n=JSON.parse(e.data),t=X[n.key];if(!t||!t.version||!n.version||t.version<n.version){q.debug(on(n.key));var r={},o=Ae({},n);delete o.key;var i=fe(X[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},pe(r)}else q.debug(an(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!X[n.key]||X[n.key].version<n.version){q.debug(un(n.key));var t={};X[n.key]&&!X[n.key].deleted&&(t[n.key]={previous:X[n.key].value}),X[n.key]={version:n.version,deleted:!0},pe(t)}else q.debug(cn(n.key))}})}function de(){i&&($.disconnect(),i=!1)}function ge(e){var n={};if(!e)return Promise.resolve();for(var t in X)X.hasOwnProperty(t)&&X[t]&&(e[t]&&!Le(e[t].value,X[t].value)?n[t]={previous:X[t].value,current:fe(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:X[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!X[r]||X[r].deleted)&&(n[r]={current:fe(e[r])});return X=Pe({},e),pe(n).catch(function(){})}function pe(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;_.emit(wn+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),_.emit(wn,i),_.emit(bn,X),J.sendEventsOnlyForVariation||Z||e.forEach(function(e){se(e,o[e].current)})}return a&&c?c.saveFlags(X).catch(function(){return null}):Promise.resolve()}function me(){var e=B||u&&void 0===B;e&&!i?ve():!e&&i&&de()}function he(e){return e===wn||e.substr(0,wn.length+1)===wn+":"}o.localStorage&&(c=new fn(o.localStorage,H,V,ee,q));var ye=new Promise(function(e){var n=_.on(mn,function(){_.off(mn,n),e()})}),we=new Promise(function(e,n){var t=_.on(hn,function(){_.off(hn,t),e()}),r=_.on(yn,function(e){_.off(yn,r),n(e)})});if("string"==typeof J.bootstrap&&"LOCALSTORAGE"===J.bootstrap.toUpperCase()&&(c?a=!0:q.warn(Ve())),"object"===Oe(J.bootstrap)&&(X=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&q.warn(Me()),!1===t.$valid&&q.warn(Ke());var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=Ae(n,r[e]):n.version=0,o[e]=n}}),o}(J.bootstrap)),Z){var be=Z.getInitialState();be?ke(be):Z.on("init",ke),Z.on("update",function(e){e.user&&ee.setUser(e.user),e.flags&&ge(e.flags)})}else(e?ne.validateUser(n).then(function(e){return ee.setUser(e),"object"===Oe(J.bootstrap)?Ee():a?c.loadFlags().catch(function(){return null}).then(function(e){return null==e?(X={},K.fetchFlagSettings(ee.getUser(),V).then(function(e){return ge(e||{})}).then(Ee).catch(function(e){Se(new Re($e(e)))})):(X=e,Ie(Ee),K.fetchFlagSettings(ee.getUser(),V).then(function(e){return ge(e)}).catch(function(e){return _.maybeReportError(e)}))}):K.fetchFlagSettings(ee.getUser(),V).then(function(e){X=e||{},Ee()}).catch(function(e){X={},Se(e)})}):Promise.reject(new De(He()))).catch(function(e){return _.maybeReportError(e)});function ke(e){H=e.environment,ee.setUser(e.user),X=Pe({},e.flags),Ie(Ee)}function Ee(){q.info(_e()),W=!0,me(),_.emit(mn),_.emit(hn)}function Se(e){_.maybeReportError(e),_.emit(yn,e),_.emit(mn)}return{client:{waitForInitialization:function(){return we},waitUntilReady:function(){return ye},identify:function(e,n,t){return Q?xe(Promise.resolve({}),t):Z?(q.warn(Xe()),xe(Promise.resolve(Fe(X)),t)):xe((a&&c?c.clearFlags():Promise.resolve()).then(function(){return ne.validateUser(e)}).then(function(t){return K.fetchFlagSettings(t,n).then(function(e){var n=Fe(e);return ee.setUser(t),e?ge(e).then(function(){return n}):n})}).then(function(e){return i&&ve(),e}).catch(function(e){return _.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return ee.getUser()},variation:function(e,n){return le(e,n,!0,!1).value},variationDetail:function(e,n){return le(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&q.warn(ze(e));var r={kind:"custom",key:e,user:ee.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),ce(r)}else _.maybeReportError(new je(ze(e)))},on:function(e,n,t){he(e)?(u=!0,W&&me(),_.on(e,n,t)):_.on.apply(_,arguments)},off:function(e){if(_.off.apply(_,arguments),he(e)){var n=!1;_.getEvents().forEach(function(e){he(e)&&0<_.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===B&&de())}},setStreaming:function(e){var n=null===e?void 0:e;n!==B&&(B=n,me())},flush:function(e){return xe(z?M.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!X)return e;for(var n in X)X.hasOwnProperty(n)&&(e[n]=le(n,null,!J.sendEventsOnlyForVariation).value);return e},close:function(e){if(Q)return xe(Promise.resolve(),e);function n(){Q=!0,X={}}return xe(Promise.resolve().then(function(){if(de(),z)return M.stop(),M.flush()}).then(n).catch(n),e)}},options:J,emitter:_,ident:ee,logger:q,requestor:K,start:function(){z&&M.start()},enqueueEvent:ce,getFlagsInternal:function(){return X},getEnvironmentId:function(){return H},internalChangeEventName:bn}}function Y(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function Z(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Y(i,!0).forEach(function(e){var n,t,r;n=o,r=i[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):Y(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var ee={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function ne(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return ee;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),ee;var u;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}var te=/[|\\{}()[\]^$+*?.]/g,re=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(te,"\\$&")};function oe(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+re(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+re(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+re(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function ie(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],c=0;c<u.length;c++)if(oe(u[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var c=0;c<u.length;c++)o===u[c]&&t.push(i);o=o.parentNode}return t}(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var ae=300;function ue(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=ie(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=ie(t=e,a),u(ae,i)),n()}).catch(function(e){r.emitter.maybeReportError(new c.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var ce="goalsReady",se={fetchGoals:{default:!0},hash:{type:"string"},eventUrlTransformer:{type:"function"}};function le(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n,i={synchronousFlush:!1};window.XMLHttpRequest&&(i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush;return i.synchronousFlush=!1,ne(e,n,t,r,o)}),i.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n};var r,t=e&&e.eventUrlTransformer;i.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},i.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(i.localStorage={get:function(n){return new Promise(function(e){e(window.localStorage.getItem(n))})},set:function(n,t){return new Promise(function(e){window.localStorage.setItem(n,t),e()})},clear:function(n){return new Promise(function(e){window.localStorage.removeItem(n),e()})}})}catch(e){i.localStorage=null}var o=e&&e.useReport;if(r=o&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(i.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(i.eventSourceAllowsReport=!1,window.EventSource),window.EventSource){i.eventSourceFactory=function(e,n){var t=Z({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},i.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return i.userAgent="JSClient",i}(t),o=Q(e,n,t,r,se),i=o.client,a=o.options,u=o.emitter,c=new Promise(function(e){var n=u.on(ce,function(){u.off(ce,n),e()})});if(i.waitUntilGoalsReady=function(){return c},a.fetchGoals){var s=ue(o,function(){return u.emit(ce)});r.customEventFilter=s.goalKeyExists}else u.emit(ce);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){})}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var fe=pn;var ve={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(_.deprecated("default export","named LDClient export")),le(e,n,t)},version:"2.16.0"};e.createConsoleLogger=fe,e.default=ve,e.initialize=le,e.version="2.16.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient.min.js.map |
{ | ||
"name": "launchdarkly-js-client-sdk", | ||
"version": "2.15.2", | ||
"version": "2.16.0", | ||
"description": "LaunchDarkly SDK for JavaScript", | ||
@@ -49,3 +49,4 @@ "author": "LaunchDarkly <team@launchdarkly.com>", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/runtime": "7.6.3", | ||
"@babel/runtime": "^7.6.3", | ||
"@rollup/plugin-node-resolve": "^6.0.0", | ||
"@rollup/plugin-replace": "^2.2.0", | ||
@@ -73,6 +74,3 @@ "babel-eslint": "10.0.3", | ||
"rollup-plugin-filesize": "^6.2.1", | ||
"rollup-plugin-includepaths": "^0.2.3", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"rollup-plugin-node-globals": "^1.4.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^5.1.2", | ||
@@ -87,3 +85,3 @@ "rollup-plugin-uglify": "^6.0.3", | ||
"escape-string-regexp": "1.0.5", | ||
"launchdarkly-js-sdk-common": "2.14.1" | ||
"launchdarkly-js-sdk-common": "3.1.0" | ||
}, | ||
@@ -90,0 +88,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
419699
36
490
+ Addedlaunchdarkly-js-sdk-common@3.1.0(transitive)
- Removedlaunchdarkly-js-sdk-common@2.14.1(transitive)