launchdarkly-js-client-sdk 2.24.2 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -15
- package/dist/ldclient.cjs.js +1 -1
- package/dist/ldclient.cjs.js.map +1 -1
- package/dist/ldclient.es.js +1 -1
- package/dist/ldclient.es.js.map +1 -1
- package/dist/ldclient.min.js +1 -1
- package/dist/ldclient.min.js.map +1 -1
- package/package.json +2 -2
- package/typings.d.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,21 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the LaunchDarkly client-side JavaScript SDKs will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
|
|
4
4
|
|
|
5
|
-
## [2.24.0] - 2022-10-18
|
|
6
|
-
### Changed:
|
|
7
|
-
- Upgrade to `js-sdk-common` `3.8.1` which added support for `Inspectors` that can be used for collecting information for monitoring, analytics, and debugging.
|
|
8
|
-
|
|
9
|
-
## [2.23.0] - 2022-10-05
|
|
10
|
-
### Changed:
|
|
11
|
-
- Updated `js-sdk-common` version which removed event de-duplication functionality which was made redundant by support of summary events. This will improve the default event behavior when using experimentation.
|
|
12
|
-
|
|
13
|
-
- Updated `escape-string-regexp` to version 4.
|
|
14
|
-
|
|
15
|
-
- Updated development dependencies to recent versions.
|
|
16
|
-
|
|
17
|
-
### Deprecated:
|
|
18
|
-
- Deprecated the `allowFrequentDuplicateEvents` configuration option. Setting the option will no longer have any effect, and it will be removed in a future version.
|
|
19
|
-
|
|
20
5
|
## [2.22.1] - 2022-04-27
|
|
21
6
|
This release is functionally identical to the 2.22.0 release. Due to an oversight the release process re-introduced the `package-lock.json`.
|
|
22
7
|
|
package/dist/ldclient.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";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}function n(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach((function(e){r(n,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}))}return n}function t(e){return(t="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 r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i=[],a=!0,u=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==t.return||t.return()}finally{if(u)throw o}}return i}}(e,n)||a(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||a(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,n){if(e){if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,n):void 0}}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function c(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}Object.defineProperty(exports,"__esModule",{value:!0});var s=c("LaunchDarklyUnexpectedResponseError"),l=c("LaunchDarklyInvalidEnvironmentIdError"),f=c("LaunchDarklyInvalidUserError"),d=c("LaunchDarklyInvalidEventKeyError"),v=c("LaunchDarklyInvalidArgumentError"),g=c("LaunchDarklyFlagFetchError"),p=c("LaunchDarklyInvalidDataError");function m(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var h=Object.freeze({__proto__:null,LDUnexpectedResponseError:s,LDInvalidEnvironmentIdError:l,LDInvalidUserError:f,LDInvalidEventKeyError:d,LDInvalidArgumentError:v,LDFlagFetchError:g,LDInvalidDataError:p,isHttpErrorRecoverable:m}),y=[],w=[],b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",E=0,k=b.length;E<k;++E)y[E]=b[E],w[b.charCodeAt(E)]=E;function D(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(y[(o=r)>>18&63]+y[o>>12&63]+y[o>>6&63]+y[63&o]);return i.join("")}w["-".charCodeAt(0)]=62,w["_".charCodeAt(0)]=63;var O=Array.isArray,S=Object.keys,P=Object.prototype.hasOwnProperty,U=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function I(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function j(e){return function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(D(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(y[n>>2]+y[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(y[n>>10]+y[n>>4&63]+y[n<<2&63]+"=")),o.join("")}(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(unescape(encodeURIComponent(e))))}function R(e){return j(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function T(e){return JSON.parse(JSON.stringify(e))}function C(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=O(n),u=O(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 d=S(n);if((o=d.length)!==S(t).length)return!1;for(r=o;0!=r--;)if(!P.call(t,d[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=d[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function L(e){setTimeout(e,0)}function x(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 A(e){var n={};for(var t in e)V(e,t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)V(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=R(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function q(e){var n=e.version||"3.8.2";return e.userAgent+"/"+n}function _(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t){return n(n({},e),t)}),{})}function V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function M(e){if(!e)return e;var t;for(var r in U){var o=U[r],i=e[o];void 0!==i&&"string"!=typeof i&&((t=t||n({},e))[o]=String(i))}return t||e}for(var z=Object.freeze({__proto__:null,appendUrlPath:I,btoa:j,base64URLEncode:R,clone:T,deepEquals:C,onNextTick:L,wrapPromiseCallback:x,transformValuesToVersionedValues:A,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:q,extend:_,objectHasOwnProperty:V,sanitizeUser:M}),J=function(e,n){return function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(n={exports:{}}),n.exports}(),$=[],H=0;H<256;++H)$[H]=(H+256).toString(16).substr(1);var K,B,G=0,X=0,W=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||K,a=void 0!==e.clockseq?e.clockseq:B;if(null==i||null==a){var u=J();null==i&&(i=K=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=B=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||c>G)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=c,X=s,B=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 d=c/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return n||function(e,n){var t=n||0,r=$;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(o)},Q=["debug","info","warn","error","none"];function Y(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],o=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var c=0;c<Q.length;c++)Q[c]===e.level&&(u=c);function s(e,t,u){if(!(u.length<1)){var c,s=o?t+": "+a:a;if(1!==u.length&&n){var l=i(u);l[0]=s+l[0],c=n.apply(void 0,i(l))}else c=s+u[0];try{r[e](c)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=Q[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){s(t,n,arguments)}}},d=0;d<Q.length;d++)f(d);return l}function Z(e,n){return Y({level:e,prefix:n})}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",te=function(e){return'Expected application/json content type but got "'+e+'"'},re=function(e){return"local storage is unavailable: "+ee(e)},oe=function(e){return"network error"+(e?" ("+e+")":"")},ie=function(e){return'Custom event "'+e+'" does not exist'},ae=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ne},ue=function(){return"No environment/client-side ID was specified."+ne},ce=function(e){return"Error fetching flag settings: "+ee(e)},se=function(){return"No user specified."+ne},le=function(){return"Invalid user specified."+ne},fe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ne},de=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ve=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(m(e)?t:"giving up permanently")},ge=function(){return"Cannot make HTTP requests in this environment."+ne},pe=function(e){return"Opening stream connection to "+e},me=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying after "+n+" milliseconds."},he=function(e){return"Error on stream connection ".concat(ee(e),", giving up permanently")},ye=function(e){return'Ignoring unknown config option "'+e+'"'},we=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},be=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ee=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},ke=function(e){return"polling for feature flags at "+e},De=function(e){return'received streaming update for flag "'+e+'"'},Oe=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Se=function(e){return'received streaming deletion for flag "'+e+'"'},Pe=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ue=function(e){return'enqueueing "'+e+'" event'},Ie=function(e){return"sending "+e+" events"},je=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},Re=function(e,n){return'an inspector: "'.concat(n,'" of an invalid type (').concat(e,") was configured")},Te=function(e,n){return'an inspector: "'.concat(n,'" of type: "').concat(e,'" generated an exception')},Ce=function(e){return'Value of "'.concat(e,'" was longer than 64 characters and was discarded.')},Le=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType:te,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:re,networkError:oe,unknownCustomEventKey:ie,environmentNotFound:ae,environmentNotSpecified:ue,errorFetchingFlags:ce,userNotSpecified:se,invalidUser:le,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:fe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:de,httpErrorMessage:ve,httpUnavailable:ge,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:pe,streamError:me,unrecoverableStreamError:he,unknownOption:ye,wrongOptionType:we,wrongOptionTypeBoolean:be,optionBelowMinimum:Ee,debugPolling:ke,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:De,debugStreamPatchIgnored:Oe,debugStreamDelete:Se,debugStreamDeleteIgnored:Pe,debugEnqueueingEvent:Ue,debugPostingEvents:Ie,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:je,invalidInspector:Re,inspectorMethodError:Te,tagValueTooLong:Ce}),xe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t){var r={};return n.id&&(r.id=Fe("".concat(e,".id"),n.id,t)),n.version&&(r.version=Fe("".concat(e,".version"),n.version,t)),r}},inspectors:{default:[]}},Ae=/^(\w|\.|-)+$/;function Fe(e,n,t){if("string"==typeof n&&n.match(Ae)){if(!(n.length>64))return n;t.warn(Ce(e))}else t.warn(je(e))}function Ne(e,n,r,o){var i=_({logger:{default:o}},xe,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null,allowFrequentDuplicateEvents:void 0};function u(e){L((function(){n&&n.maybeReportError(new v(e))}))}var c=_({},e||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];o&&o.warn(de(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(c),function(e){Q.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((c=function(e){var n=_({},e),r=function(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=t(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}};return Object.keys(e).forEach((function(t){var a=e[t];if(null!=a){var c=i[t];if(void 0===c)u(ye(t));else{var s=c.type||r(c.default),l=c.validator;if(l){var f=l(t,e[t],o);void 0!==f?n[t]=f:delete n[t]}else if("any"!==s){var d=s.split("|"),v=r(a);d.indexOf(v)<0?"boolean"===s?(n[t]=!!a,u(be(t,v))):(u(we(t,s,v)),n[t]=c.default):"number"===v&&void 0!==c.minimum&&a<c.minimum&&(u(Ee(t,a,c.minimum)),n[t]=c.minimum)}}}})),n}(c=function(e){var n=_({},e);return Object.keys(i).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=i[e]&&i[e].default)})),n}(c))).logger),c}function qe(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function _e(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":q(e)};n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName);var r=qe(n),o=Object.keys(r);return o.length&&(t["x-launchdarkly-tags"]=o.sort().map((function(e){return Array.isArray(r[e])?r[e].sort().map((function(n){return"".concat(e,"/").concat(n)})):["".concat(e,"/").concat(r[e])]})).reduce((function(e,n){return e.concat(n)}),[]).join(" ")),t}function Ve(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function Me(e,n,t){var r="/a/"+n+".gif",o=_({"Content-Type":"application/json"},_e(e,t)),i=e.httpFallbackPing,a={sendChunk:function(n,a,u,c){var s=JSON.stringify(n),l=u?null:W();return c?function n(r){var i=u?o:_({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,Ve(i,t),s).promise.then((function(e){if(e)return e.status>=400&&m(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(i&&i(a+r+"?d="+R(s)),Promise.resolve())},sendEvents:function(n,t,r){if(!e.httpRequest)return Promise.resolve();var o,i=e.httpAllowsPost();o=i?[n]:N(2e3-t.length,n);for(var u=[],c=0;c<o.length;c++)u.push(a.sendChunk(o[c],t,r,i));return Promise.all(u)}};return a}function ze(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=r[o];i?i.count=i.count+1:r[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in r){var a=r[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var c={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(c.variation=a.variation),a.version?c.version=a.version:c.unknown=!0,u.counters.push(c),o=!1}return o?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function Je(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=_({},s,l[1])}var f=Object.keys(s);return f.length&&(f.sort(),c.privateAttrs=f),c},n}function $e(e,n,t,r){var o={};function i(){var e="",o=r.getUser();return o&&(e=t||j(JSON.stringify(o))),"ld:"+n+":"+e}return o.loadFlags=function(){return e.get(i()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=A(n):delete n.$schema}return n}catch(e){return o.clearFlags().then((function(){return null}))}}))},o.saveFlags=function(n){var t=_({},n,{$schema:1});return e.set(i(),JSON.stringify(t))},o.clearFlags=function(){return e.clear(i())},o}function He(e,n,t,r){var o,i=n.streamUrl,a=n.logger,u={},c=I(i,"/eval/"+t),s=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,d=_e(e,n),v=!1,g=null,p=null,h=null,y=null,w=null,b=0;function E(e){if(e.status&&"number"==typeof e.status&&!m(e.status))return O(),a.error(he(e)),void(p&&(clearTimeout(p),p=null));var n=function(){var e,n=(e=function(){var e=f*Math.pow(2,b);return e>3e4?3e4:e}())-Math.trunc(.5*Math.random()*e);return b+=1,n}();v||(a.warn(me(e,n)),v=!0),S(!1),O(),k(n)}function k(e){p||(e?p=setTimeout(D,e):D())}function D(){var r;p=null;var u="",f={headers:d,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var v in null!=y&&(u="h="+y),s?e.eventSourceAllowsReport?(r=c,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(h)):(r=I(i,"/ping/"+t),u=""):r=c+"/"+R(JSON.stringify(h)),f.headers=Ve(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,O(),a.info(pe(r)),o=(new Date).getTime(),g=e.eventSourceFactory(r,f),w)V(w,v)&&g.addEventListener(v,w[v]);g.onerror=E,g.onopen=function(){b=0}}}function O(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function S(e){o&&r&&r.recordStreamInit(o,!e,(new Date).getTime()-o),o=null}return u.connect=function(e,n,t){h=e,y=n,w={};var r=function(e){w[e]=function(n){v=!1,S(!0),t[e]&&t[e](n)}};for(var o in t||{})r(o);k()},u.disconnect=function(){clearTimeout(p),p=null,O()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function Ke(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.logger,u={},c={};function s(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new g(ge()))}));var o=r?"REPORT":"GET",i=_e(e,n);r&&(i["Content-Type"]="application/json");var a=c[t];a||(a=function(e){var n,t,r,o,i={addPromise:function(i,a){n=i,t&&t(),t=a,i.then((function(t){n===i&&(r(t),e&&e())}),(function(t){n===i&&(o(t),e&&e())}))}};return i.resultPromise=new Promise((function(e,n){r=e,o=n})),i}((function(){delete c[t]})),c[t]=a);var u=e.httpRequest(o,t,Ve(i,n),r),s=u.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=te(e.header("content-type")||"");return Promise.reject(new g(n))}return Promise.reject(function(e){return 404===e.status?new l(ae()):new g(ce(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new g(oe(e)))}));return a.addPromise(s,(function(){u.cancel&&u.cancel()})),a.resultPromise}return u.fetchJSON=function(e){return s(I(r,e),null)},u.fetchFlagSettings=function(e,n){var u,c,l,f="";return o?(c=[r,"/sdk/evalx/",t,"/user"].join(""),l=JSON.stringify(e)):(u=R(JSON.stringify(e)),c=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),i&&(f=f+(f?"&":"")+"withReasons=true"),c=c+(f?"?":"")+f,a.debug(ke(c)),s(c,l)},u}function Be(e){var n={validateUser:function(n){if(!n)return Promise.reject(new f(se()));var t=T(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=W();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new f(le()))}};return n}var Ge=Object.freeze({__proto__:null,baseOptionDefs:xe,validate:Ne,getTags:qe}).baseOptionDefs,Xe=z.appendUrlPath,We=function(e){var n={diagnosticId:W()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Qe={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};function Ye(e,n){var t,o={},i=(r(t={},Qe.flagUsed,[]),r(t,Qe.flagDetailsChanged,[]),r(t,Qe.flagDetailChanged,[]),r(t,Qe.clientIdentityChanged,[]),t);return(null==e?void 0:e.map((function(e){return function(e,n){var t=!1,r={type:e.type,name:e.name,method:function(){try{e.method.apply(e,arguments)}catch(e){t||(t=!0,n.warn(Te(r.type,r.name)))}}};return r}(e,n)}))).forEach((function(e){Object.prototype.hasOwnProperty.call(i,e.type)?i[e.type].push(e):n.warn(Re(e.type,e.name))})),o.hasListeners=function(e){var n;return null===(n=i[e])||void 0===n?void 0:n.length},o.onFlagUsed=function(e,n,t){i[Qe.flagUsed].length&&L((function(){i[Qe.flagUsed].forEach((function(r){return r.method(e,n,t)}))}))},o.onFlags=function(e){i[Qe.flagDetailsChanged].length&&L((function(){i[Qe.flagDetailsChanged].forEach((function(n){return n.method(e)}))}))},o.onFlagChanged=function(e,n){i[Qe.flagDetailChanged].length&&L((function(){i[Qe.flagDetailChanged].forEach((function(t){return t.method(e,n)}))}))},o.onIdentityChanged=function(e){i[Qe.clientIdentityChanged].length&&L((function(){i[Qe.clientIdentityChanged].forEach((function(n){return n.method(e)}))}))},o}function Ze(e,r,i,a,u){var c,f,v,h=i&&i.logger?i.logger:u&&u.logger&&u.logger.default||Z("warn"),y=function(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var o=0;o<t[e].length;o++)t[e][o].handler===n&&t[e][o].context===r&&(t[e]=t[e].slice(0,o).concat(t[e].slice(o+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}(h),w=function(e){var n=!1,t=!1,r=null,o=null,i=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return o||(n?Promise.resolve():t?Promise.reject(r):o=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(o){n||t||(t=!0,r=o,e.emit("failed",o),e.emit("ready")),e.maybeReportError(o)}}}(y),b=Ne(i,y,u,h),E=Ye(b.inspectors,h),k=b.sendEvents,D=e,O=b.hash,S=function(e,n){var t={},r=!1,o=function(e){r||(r=!0,n.warn(re(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){o(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){o(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){o(e),t(!1)})):t(!1)}))},t}(a.localStorage,h),P=Me(a,D,b),U=b.sendEvents&&!b.diagnosticOptOut,j=U?We(D):null,R=U?function(e){var n,t,r,o;function i(e){n=e,t=0,r=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}}((new Date).getTime()):null,A=U?function(e,t,r,o,i,a,u){var c,s,l=!!e.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=Xe(a.eventsUrl,"/events/diagnostic/"+i),v=a.diagnosticRecordingInterval,g=r,p=!!a.streaming,m={};function h(){return{sdk:b(),configuration:(n={customBaseURI:a.baseUrl!==Ge.baseUrl.default,customStreamURI:a.streamUrl!==Ge.streamUrl.default,customEventsURI:a.eventsUrl!==Ge.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function y(e){a.logger&&a.logger.debug(Le.debugPostingDiagnosticEvent(e)),o.sendEvents(e,d,!0).then((function(){})).catch((function(){}))}function w(){var e,r;y((e=(new Date).getTime(),r=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(r=n(n({},r),h())),g.reset(e),r)),s=setTimeout(w,v),c=(new Date).getTime(),l&&function(){if(t.isEnabled()){var e=n({},g.getProps());t.set(f,JSON.stringify(e))}}()}function b(){var t=n({},e.diagnosticSdkData);return a.wrapperName&&(t.wrapperName=a.wrapperName),a.wrapperVersion&&(t.wrapperVersion=a.wrapperVersion),t}return m.start=function(){l?function(e){if(!t.isEnabled())return e(!1);t.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),c=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(c||0)+v,t=(new Date).getTime();t>=n?w():s=setTimeout(w,n-t)}else 0===Math.floor(4*Math.random())?w():s=setTimeout(w,v)})):(y(n({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},h())),s=setTimeout(w,v))},m.stop=function(){s&&clearTimeout(s)},m.setStreaming=function(e){p=e},m}(a,S,R,P,D,b,j):null,N=He(a,b,D,R),q=b.eventProcessor||function(e,n,t){var r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,u={},c=a||Me(e,t,n),l=I(n.eventsUrl,"/events/bulk/"+t),f=ze(),d=Je(n),v=n.inlineUsersInEvents,g=n.samplingInterval,p=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,E=!1,k=!1;function D(){return 0===g||0===Math.floor(Math.random()*g)}function O(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}function S(e){var n=_({},e);return"alias"===e.kind||(v||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}function P(e){w.length<p?(w.push(e),k=!1):(k||(k=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),o&&o.incrementDroppedEvents())}return u.enqueue=function(e){if(!E){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=O(e)):n=D(),n&&P(S(e)),t){var r=_({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(r)}}},u.flush=function(){if(E)return Promise.resolve();var e=w,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(Ie(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(b=e.serverTime),m(e.status)||(E=!0),e.status>=400&&L((function(){i.maybeReportError(new s(ve(e.status,"event posting","some events were dropped")))})))})))},u.start=function(){r=setTimeout((function e(){u.flush(),r=setTimeout(e,h)}),h)},u.stop=function(){clearTimeout(r)},u}(a,b,D,R,y,P),z=Ke(a,b,D),J={},$=b.streaming,H=!1,K=!1,B=!0,G=b.stateProvider,X=function(e,n){var t,r={setUser:function(e){var r=t&&T(t);(t=M(e))&&n&&n(T(t),r)},getUser:function(){return t?T(t):null}};return r}(0,(function(e,n){(function(e){G||e&&Y({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!b.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&le(e,n),E.hasListeners(Qe.clientIdentityChanged)&&E.onIdentityChanged(X.getUser())})),W=Be(S),Q=S.isEnabled()?new $e(S,D,O,X):null;function Y(e){if(D&&!(G&&G.enqueueEvent&&G.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(B&&(h.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),B=!1));B=!1}!k||K||a.isDoNotTrack()||(h.debug(Ue(e.kind)),q.enqueue(e))}}function ee(e,n){E.hasListeners(Qe.flagDetailChanged)&&E.onFlagChanged(e.key,ae(n))}function ne(){E.hasListeners(Qe.flagDetailsChanged)&&E.onFlags(Object.entries(J).map((function(e){var n=o(e,2);return{key:n[0],detail:ae(n[1])}})).reduce((function(e,n){return e[n.key]=n.detail,e}),{}))}function te(e,n,t,r){var o=X.getUser(),i=new Date,a={kind:"feature",key:e,user:o,value:n?n.value:null,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(a.contextKind=se(o));var u=J[e];u&&(a.version=u.flagVersion?u.flagVersion:u.version,a.trackEvents=u.trackEvents,a.debugEventsUntilDate=u.debugEventsUntilDate),(r||u&&u.trackReason)&&n&&(a.reason=n.reason),Y(a)}function oe(e,n,t,r,o){var i;if(J&&V(J,e)&&J[e]&&!J[e].deleted){var a=J[e];i=ae(a),null!==a.value&&void 0!==a.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&te(e,i,n,r),o||function(e,n){E.hasListeners(Qe.flagUsed)&&E.onFlagUsed(e,n,X.getUser())}(e,i),i}function ae(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function se(e){return e.anonymous?"anonymousUser":"user"}function le(e,n){G||e&&n&&Y({kind:"alias",key:e.key,contextKind:se(e),previousKey:n.key,previousContextKind:se(n),creationDate:(new Date).getTime()})}function de(){if(f=!0,X.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void y.maybeReportError(new p("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};N.connect(X.getUser(),O,{ping:function(){h.debug("received ping message from stream");var e=X.getUser();z.fetchFlagSettings(e,O).then((function(n){C(e,X.getUser())&&pe(n||{})})).catch((function(e){y.maybeReportError(new g(ce(e)))}))},put:function(n){var t=e(n.data);t&&(h.debug("received streaming update for all flags"),pe(t))},patch:function(n){var t=e(n.data);if(t){var r=J[t.key];if(!r||!r.version||!t.version||r.version<t.version){h.debug(De(t.key));var o={},i=_({},t);delete i.key,J[t.key]=i;var a=ae(i);o[t.key]=r?{previous:r.value,current:a}:{current:a},me(o),ee(t,i)}else h.debug(Oe(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!J[t.key]||J[t.key].version<t.version){h.debug(Se(t.key));var r={};J[t.key]&&!J[t.key].deleted&&(r[t.key]={previous:J[t.key].value}),J[t.key]={version:t.version,deleted:!0},ee(t,J[t.key]),me(r)}else h.debug(Pe(t.key))}})}}function ge(){f&&(N.disconnect(),f=!1)}function pe(e){var t={};if(!e)return Promise.resolve();for(var r in J)V(J,r)&&J[r]&&(e[r]&&!C(e[r].value,J[r].value)?t[r]={previous:J[r].value,current:ae(e[r])}:e[r]&&!e[r].deleted||(t[r]={previous:J[r].value}));for(var o in e)V(e,o)&&e[o]&&(!J[o]||J[o].deleted)&&(t[o]={current:ae(e[o])});return J=n({},e),ne(),me(t).catch((function(){}))}function me(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;y.emit("change:"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),y.emit("change",t),y.emit("internal-change",J),b.sendEventsOnlyForVariation||G||n.forEach((function(n){te(n,e[n].current)}))}return c&&Q?Q.saveFlags(J):Promise.resolve()}function he(){var e=$||v&&void 0===$;e&&!f?de():!e&&f&&ge(),A&&A.setStreaming(e)}function ye(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof b.bootstrap&&"LOCALSTORAGE"===b.bootstrap.toUpperCase()&&(Q?c=!0:h.warn(re())),"object"===t(b.bootstrap)&&(J=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&h.warn(fe()),!1===e.$valid&&h.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=_(o,t[n]):o.version=0,r[n]=o}})),r}(b.bootstrap)),G){var we=G.getInitialState();we?be(we):G.on("init",be),G.on("update",(function(e){e.user&&X.setUser(e.user),e.flags&&pe(e.flags)}))}else(e?W.validateUser(r).then((function(e){return X.setUser(e),"object"===t(b.bootstrap)?Ee():c?Q.loadFlags().then((function(e){return null==e?(J={},z.fetchFlagSettings(X.getUser(),O).then((function(e){return pe(e||{})})).then(Ee).catch((function(e){ke(new g(ce(e)))}))):(J=e,L(Ee),z.fetchFlagSettings(X.getUser(),O).then((function(e){return pe(e)})).catch((function(e){return y.maybeReportError(e)})))})):z.fetchFlagSettings(X.getUser(),O).then((function(e){J=e||{},ne(),Ee()})).catch((function(e){J={},ke(e)}))})):Promise.reject(new l(ue()))).catch(ke);function be(e){D=e.environment,X.setUser(e.user),J=n({},e.flags),L(Ee)}function Ee(){h.info("LaunchDarkly client initialized"),H=!0,he(),w.signalSuccess()}function ke(e){w.signalFailure(e)}return{client:{waitForInitialization:function(){return w.getInitializationPromise()},waitUntilReady:function(){return w.getReadyPromise()},identify:function(e,n,t){return K?x(Promise.resolve({}),t):G?(h.warn("identify() has no effect here; it must be called on the main client instance"),x(Promise.resolve(F(J)),t)):x((c&&Q?Q.clearFlags():Promise.resolve()).then((function(){return W.validateUser(e)})).then((function(e){return z.fetchFlagSettings(e,n).then((function(t){var r=F(t);return X.setUser(e),O=n,t?pe(t).then((function(){return r})):r}))})).then((function(e){return f&&de(),e})).catch((function(e){return y.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return X.getUser()},variation:function(e,n){return oe(e,n,!0,!1,!1).value},variationDetail:function(e,n){return oe(e,n,!0,!0,!1)},track:function(e,n,t){if("string"==typeof e){a.customEventFilter&&!a.customEventFilter(e)&&h.warn(ie(e));var r=X.getUser(),o={kind:"custom",key:e,user:r,url:a.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=se(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),Y(o)}else y.maybeReportError(new d(ie(e)))},alias:le,on:function(e,n,t){ye(e)?(v=!0,H&&he(),y.on(e,n,t)):y.on.apply(y,arguments)},off:function(e){if(y.off.apply(y,arguments),ye(e)){var n=!1;y.getEvents().forEach((function(e){ye(e)&&y.getEventListenerCount(e)>0&&(n=!0)})),n||(v=!1,f&&void 0===$&&ge())}},setStreaming:function(e){var n=null===e?void 0:e;n!==$&&($=n,he())},flush:function(e){return x(k?q.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!J)return e;for(var n in J)V(J,n)&&!J[n].deleted&&(e[n]=oe(n,null,!b.sendEventsOnlyForVariation,!1,!0).value);return e},close:function(e){if(K)return x(Promise.resolve(),e);var n=function(){K=!0,J={}};return x(Promise.resolve().then((function(){if(ge(),A&&A.stop(),k)return q.stop(),q.flush()})).then(n).catch(n),e)}},options:b,emitter:y,ident:X,logger:h,requestor:z,start:function(){k&&(A&&A.start(),q.start())},enqueueEvent:Y,getFlagsInternal:function(){return J},getEnvironmentId:function(){return D},internalChangeEventName:"internal-change"}}Object.freeze(Qe);function en(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 nn(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?en(Object(t),!0).forEach((function(n){tn(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):en(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function tn(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var rn=Object.freeze({__proto__:null,commonBasicLogger:Y,createConsoleLogger:Z,get errors(){return h},initialize:Ze,messages:Le,utils:z,version:"3.8.2"}).commonBasicLogger;var on=function(e){return rn(nn({destination:console.log},e))};var an={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function un(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 an;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),an;var u,c=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)}));return{promise:c,cancel:function(){u=!0,i.abort()}}}function cn(e){var n,t={synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;t.httpRequest=function(e,n,o,i){var a=t.synchronousFlush&!r;return t.synchronousFlush=!1,un(e,n,o,i,a)}}t.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n},t.httpFallbackPing=function(e){(new window.Image).src=e};var o,i=e&&e.eventUrlTransformer;t.getCurrentUrl=function(){return i?i(window.location.href):window.location.href},t.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(t.localStorage={get:function(e){return new Promise((function(n){n(window.localStorage.getItem(e))}))},set:function(e,n){return new Promise((function(t){window.localStorage.setItem(e,n),t()}))},clear:function(e){return new Promise((function(n){window.localStorage.removeItem(e),n()}))}})}catch(e){t.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(t.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(t.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;t.eventSourceFactory=function(e,n){var t=nn(nn({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),n);return new o(e,t)},t.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return t.userAgent="JSClient",t.version="2.24.2",t.diagnosticSdkData={name:"js-client-sdk",version:"2.24.2"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var sn=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function ln(e,n,t,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+sn(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+sn(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+sn(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function fn(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(ln(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}function dn(e,n){var t,r;function o(){r&&r.dispose(),t&&t.length&&(r=fn(t,i))}function i(n,t){var r=e.ident.getUser(),o={kind:n,key:t.key,data:null,url:window.location.href,user:r,creationDate:(new Date).getTime()};return r&&r.anonymous&&(o.contextKind="anonymousUser"),"click"===n&&(o.selector=t.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=fn(t=e,i),function(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout((function(){e(n,t)}),t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(300,o)),n()})).catch((function(t){e.emitter.maybeReportError(new h.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),{}}var vn={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function gn(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=cn(t),o=Ze(e,n,t,r,vn),i=o.client,a=o.options,u=o.emitter,c=new Promise((function(e){var n=u.on("goalsReady",(function(){u.off("goalsReady",n),e()}))}));i.waitUntilGoalsReady=function(){return c},a.fetchGoals?dn(o,(function(){return u.emit("goalsReady")})):u.emit("goalsReady"),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var s=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return window.addEventListener("beforeunload",s),window.addEventListener("unload",s),i}var pn=on,mn=Z;var hn={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Le.deprecated("default export","named LDClient export")),gn(e,n,t)},version:"2.24.2"};exports.basicLogger=pn,exports.createConsoleLogger=mn,exports.default=hn,exports.initialize=gn,exports.version="2.24.2";
|
|
1
|
+
"use strict";function e(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return t.prototype=new Error,t.prototype.name=e,t.prototype.constructor=t,t}Object.defineProperty(exports,"__esModule",{value:!0});const t=e("LaunchDarklyUnexpectedResponseError"),n=e("LaunchDarklyInvalidEnvironmentIdError"),r=e("LaunchDarklyInvalidUserError"),o=e("LaunchDarklyInvalidEventKeyError"),i=e("LaunchDarklyInvalidArgumentError"),a=e("LaunchDarklyFlagFetchError");var s={LDUnexpectedResponseError:t,LDInvalidEnvironmentIdError:n,LDInvalidUserError:r,LDInvalidEventKeyError:o,LDInvalidArgumentError:i,LDInvalidDataError:e("LaunchDarklyInvalidDataError"),LDFlagFetchError:a,isHttpErrorRecoverable:function(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}};s.LDUnexpectedResponseError,s.LDInvalidEnvironmentIdError,s.LDInvalidUserError,s.LDInvalidEventKeyError,s.LDInvalidArgumentError,s.LDInvalidDataError,s.LDFlagFetchError,s.isHttpErrorRecoverable;for(var c=function(e){var t=h(e),n=t[0],r=t[1];return 3*(n+r)/4-r},u=function(e){var t,n,r=h(e),o=r[0],i=r[1],a=new g(function(e,t,n){return 3*(t+n)/4-n}(0,o,i)),s=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)t=f[e.charCodeAt(n)]<<18|f[e.charCodeAt(n+1)]<<12|f[e.charCodeAt(n+2)]<<6|f[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===i&&(t=f[e.charCodeAt(n)]<<2|f[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===i&&(t=f[e.charCodeAt(n)]<<10|f[e.charCodeAt(n+1)]<<4|f[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},l=function(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(y(e,a,a+i>s?s:a+i));1===r?(t=e[n-1],o.push(d[t>>2]+d[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(d[t>>10]+d[t>>4&63]+d[t<<2&63]+"="));return o.join("")},d=[],f=[],g="undefined"!=typeof Uint8Array?Uint8Array:Array,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,m=v.length;p<m;++p)d[p]=v[p],f[v.charCodeAt(p)]=p;function h(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function y(e,t,n){for(var r,o,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(d[(o=r)>>18&63]+d[o>>12&63]+d[o>>6&63]+d[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63;var w={byteLength:c,toByteArray:u,fromByteArray:l},b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,D=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=b(t),s=b(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var c=t instanceof Date,u=n instanceof Date;if(c!=u)return!1;if(c&&u)return t.getTime()==n.getTime();var l=t instanceof RegExp,d=n instanceof RegExp;if(l!=d)return!1;if(l&&d)return t.toString()==n.toString();var f=k(t);if((o=f.length)!==k(n).length)return!1;for(r=o;0!=r--;)if(!E.call(n,f[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=f[r]],n[i]))return!1;return!0}return t!=t&&n!=n};const C=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function P(e){const t=unescape(encodeURIComponent(e));return w.fromByteArray(function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}(t))}function x(e){return P(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var I,L={appendUrlPath:function(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t},base64URLEncode:x,btoa:P,chunkEventsForUrl:function(e,t){const n=t.slice(0),r=[];let o,i=e;for(;n.length>0;){for(o=[];i>0;){const e=n.shift();if(!e)break;i-=x(JSON.stringify(e)).length,i<0&&o.length>0?n.unshift(e):o.push(e)}i=e,r.push(o)}return r},clone:function(e){return JSON.parse(JSON.stringify(e))},deepEquals:function(e,t){return D(e,t)},extend:function(...e){return e.reduce(((e,t)=>({...e,...t})),{})},getLDUserAgentString:function(e){const t=e.version||"?";return e.userAgent+"/"+t},objectHasOwnProperty:S,onNextTick:function(e){setTimeout(e,0)},sanitizeContext:function(e){if(!e)return e;let t;return null!==e.kind&&void 0!==e.kind||C.forEach((n=>{const r=e[n];void 0!==r&&"string"!=typeof r&&(t=t||{...e},t[n]=String(r))})),t||e},transformValuesToVersionedValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]={value:e[n],version:0});return t},transformVersionedValuesToValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]=e[n].value);return t},wrapPromiseCallback:function(e,t){const n=e.then((e=>(t&&setTimeout((()=>{t(null,e)}),0),e)),(e=>{if(!t)return Promise.reject(e);setTimeout((()=>{t(e,null)}),0)}));return t?void 0:n}};L.appendUrlPath,L.base64URLEncode,L.btoa,L.chunkEventsForUrl,L.clone,L.deepEquals,L.extend,L.getLDUserAgentString,L.objectHasOwnProperty,L.onNextTick,L.sanitizeContext,L.transformValuesToVersionedValues,L.transformVersionedValuesToValues,L.wrapPromiseCallback;var O=new Uint8Array(16);function U(){if(!I&&!(I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(O)}var T=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function R(e){return"string"==typeof e&&T.test(e)}for(var A,j,F=[],N=0;N<256;++N)F.push((N+256).toString(16).substr(1));function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase();if(!R(n))throw TypeError("Stringified UUID is invalid");return n}var $=0,H=0;function q(e){if(!R(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}function M(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=q(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var s=0;s<16;++s)o[i+s]=a[s];return o}return V(a)}try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function _(e){return 14+(e+64>>>9<<4)+1}function z(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function J(e,t,n,r,o,i){return z((a=z(z(t,e),z(r,i)))<<(s=o)|a>>>32-s,n);var a,s}function K(e,t,n,r,o,i,a){return J(t&n|~t&r,e,t,o,i,a)}function B(e,t,n,r,o,i,a){return J(t&r|n&~r,e,t,o,i,a)}function G(e,t,n,r,o,i,a){return J(t^n^r,e,t,o,i,a)}function W(e,t,n,r,o,i,a){return J(n^(t|~r),e,t,o,i,a)}var X=M("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,a=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[_(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,c=r,u=o,l=i;n=K(n,r,o,i,e[a],7,-680876936),i=K(i,n,r,o,e[a+1],12,-389564586),o=K(o,i,n,r,e[a+2],17,606105819),r=K(r,o,i,n,e[a+3],22,-1044525330),n=K(n,r,o,i,e[a+4],7,-176418897),i=K(i,n,r,o,e[a+5],12,1200080426),o=K(o,i,n,r,e[a+6],17,-1473231341),r=K(r,o,i,n,e[a+7],22,-45705983),n=K(n,r,o,i,e[a+8],7,1770035416),i=K(i,n,r,o,e[a+9],12,-1958414417),o=K(o,i,n,r,e[a+10],17,-42063),r=K(r,o,i,n,e[a+11],22,-1990404162),n=K(n,r,o,i,e[a+12],7,1804603682),i=K(i,n,r,o,e[a+13],12,-40341101),o=K(o,i,n,r,e[a+14],17,-1502002290),n=B(n,r=K(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=B(i,n,r,o,e[a+6],9,-1069501632),o=B(o,i,n,r,e[a+11],14,643717713),r=B(r,o,i,n,e[a],20,-373897302),n=B(n,r,o,i,e[a+5],5,-701558691),i=B(i,n,r,o,e[a+10],9,38016083),o=B(o,i,n,r,e[a+15],14,-660478335),r=B(r,o,i,n,e[a+4],20,-405537848),n=B(n,r,o,i,e[a+9],5,568446438),i=B(i,n,r,o,e[a+14],9,-1019803690),o=B(o,i,n,r,e[a+3],14,-187363961),r=B(r,o,i,n,e[a+8],20,1163531501),n=B(n,r,o,i,e[a+13],5,-1444681467),i=B(i,n,r,o,e[a+2],9,-51403784),o=B(o,i,n,r,e[a+7],14,1735328473),n=G(n,r=B(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=G(i,n,r,o,e[a+8],11,-2022574463),o=G(o,i,n,r,e[a+11],16,1839030562),r=G(r,o,i,n,e[a+14],23,-35309556),n=G(n,r,o,i,e[a+1],4,-1530992060),i=G(i,n,r,o,e[a+4],11,1272893353),o=G(o,i,n,r,e[a+7],16,-155497632),r=G(r,o,i,n,e[a+10],23,-1094730640),n=G(n,r,o,i,e[a+13],4,681279174),i=G(i,n,r,o,e[a],11,-358537222),o=G(o,i,n,r,e[a+3],16,-722521979),r=G(r,o,i,n,e[a+6],23,76029189),n=G(n,r,o,i,e[a+9],4,-640364487),i=G(i,n,r,o,e[a+12],11,-421815835),o=G(o,i,n,r,e[a+15],16,530742520),n=W(n,r=G(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=W(i,n,r,o,e[a+7],10,1126891415),o=W(o,i,n,r,e[a+14],15,-1416354905),r=W(r,o,i,n,e[a+5],21,-57434055),n=W(n,r,o,i,e[a+12],6,1700485571),i=W(i,n,r,o,e[a+3],10,-1894986606),o=W(o,i,n,r,e[a+10],15,-1051523),r=W(r,o,i,n,e[a+1],21,-2054922799),n=W(n,r,o,i,e[a+8],6,1873313359),i=W(i,n,r,o,e[a+15],10,-30611744),o=W(o,i,n,r,e[a+6],15,-1560198380),r=W(r,o,i,n,e[a+13],21,1309151649),n=W(n,r,o,i,e[a+4],6,-145523070),i=W(i,n,r,o,e[a+11],10,-1120210379),o=W(o,i,n,r,e[a+2],15,718787259),r=W(r,o,i,n,e[a+9],21,-343485551),n=z(n,s),r=z(r,c),o=z(o,u),i=z(i,l)}return[n,r,o,i]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(_(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),Q=X;function Y(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function Z(e,t){return e<<t|e>>>32-t}var ee=M("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),s=new Array(a),c=0;c<a;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];s[c]=u}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var f=new Uint32Array(80),g=0;g<16;++g)f[g]=s[d][g];for(var v=16;v<80;++v)f[v]=Z(f[v-3]^f[v-8]^f[v-14]^f[v-16],1);for(var p=n[0],m=n[1],h=n[2],y=n[3],w=n[4],b=0;b<80;++b){var k=Math.floor(b/20),E=Z(p,5)+Y(k,m,h,y)+w+t[k]+f[b]>>>0;w=y,y=h,h=Z(m,30)>>>0,m=p,p=E}n[0]=n[0]+p>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+h>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),te=ee;var ne=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,o=t||new Array(16),i=(e=e||{}).node||A,a=void 0!==e.clockseq?e.clockseq:j;if(null==i||null==a){var s=e.random||(e.rng||U)();null==i&&(i=A=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=j=16383&(s[6]<<8|s[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:H+1,l=c-$+(u-H)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>$)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");$=c,H=u,j=a;var d=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=255&d;var f=c/4294967296*1e4&268435455;o[r++]=f>>>8&255,o[r++]=255&f,o[r++]=f>>>24&15|16,o[r++]=f>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var g=0;g<6;++g)o[r+g]=i[g];return t||V(o)},v3:Q,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||U)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return V(r)},v5:te,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!R(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:R,stringify:V,parse:q});const re=["debug","info","warn","error","none"];var oe={commonBasicLogger:function(e,t){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(e){return function(t){console&&console[e]&&console[e].call(console,t)}}const r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],o=!(!e||!e.destination),i=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ";let a=1;if(e&&e.level)for(let t=0;t<re.length;t++)re[t]===e.level&&(a=t);function s(e,n,a){if(a.length<1)return;let s;const c=o?n+": "+i:i;if(1!==a.length&&t){const e=[...a];e[0]=c+e[0],s=t(...e)}else s=c+a[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}const c={};for(let e=0;e<re.length;e++){const t=re[e];if("none"!==t)if(e<a)c[t]=()=>{};else{const n=e;c[t]=function(){s(n,t,arguments)}}}return c},validateLogger:function(e){re.forEach((t=>{if("none"!==t&&(!e[t]||"function"!=typeof e[t]))throw new Error("Provided logger instance must support logger."+t+"(...) method")}))}};function ie(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}const ae=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.";var se={bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},bootstrapOldFormat:function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ae},clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},debugEnqueueingEvent:function(e){return'enqueueing "'+e+'" event'},debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},debugPostingEvents:function(e){return"sending "+e+" events"},debugStreamDelete:function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored:function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugStreamPatch:function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored:function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamPing:function(){return"received ping message from stream"},debugPolling:function(e){return"polling for feature flags at "+e},debugStreamPut:function(){return"received streaming update for all flags"},deprecated:function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},environmentNotFound:function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ae},environmentNotSpecified:function(){return"No environment/client-side ID was specified."+ae},errorFetchingFlags:function(e){return"Error fetching flag settings: "+ie(e)},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutContext:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},httpErrorMessage:function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(s.isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable:function(){return"Cannot make HTTP requests in this environment."+ae},identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},inspectorMethodError:(e,t)=>`an inspector: "${t}" of type: "${e}" generated an exception`,invalidContentType:function(e){return'Expected application/json content type but got "'+e+'"'},invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},invalidInspector:(e,t)=>`an inspector: "${t}" of an invalid type (${e}) was configured`,invalidKey:function(){return"Event key must be a string"},invalidContext:function(){return"Invalid context specified."+ae},invalidTagValue:e=>`Config option "${e}" must only contain letters, numbers, ., _ or -.`,localStorageUnavailable:function(e){return"local storage is unavailable: "+ie(e)},networkError:e=>"network error"+(e?" ("+e+")":""),optionBelowMinimum:(e,t,n)=>'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n,streamClosing:function(){return"Closing stream connection"},streamConnecting:function(e){return"Opening stream connection to "+e},streamError:function(e,t){return"Error on stream connection: "+ie(e)+", will continue retrying after "+t+" milliseconds."},tagValueTooLong:e=>`Value of "${e}" was longer than 64 characters and was discarded.`,unknownCustomEventKey:function(e){return'Custom event "'+e+'" does not exist'},unknownOption:e=>'Ignoring unknown config option "'+e+'"',contextNotSpecified:function(){return"No context specified."+ae},unrecoverableStreamError:e=>`Error on stream connection ${ie(e)}, giving up permanently`,wrongOptionType:(e,t,n)=>'Config option "'+e+'" should be of type '+t+", got "+n+", using default value",wrongOptionTypeBoolean:(e,t)=>'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"};const{validateLogger:ce}=oe,ue={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},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},privateAttributes:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},application:{validator:function(e,t,n){const r={};t.id&&(r.id=de(`${e}.id`,t.id,n));t.version&&(r.version=de(`${e}.version`,t.version,n));return r}},inspectors:{default:[]}},le=/^(\w|\.|-)+$/;function de(e,t,n){if("string"==typeof t&&t.match(le)){if(!(t.length>64))return t;n.warn(se.tagValueTooLong(e))}else n.warn(se.invalidTagValue(e))}var fe={baseOptionDefs:ue,validate:function(e,t,n,r){const o=L.extend({logger:{default:r}},ue,n),i={};function a(e){L.onNextTick((()=>{t&&t.maybeReportError(new s.LDInvalidArgumentError(e))}))}let c=L.extend({},e||{});return function(e){const t=e;Object.keys(i).forEach((e=>{if(void 0!==t[e]){const n=i[e];r&&r.warn(se.deprecated(e,n)),n&&(void 0===t[n]&&(t[n]=t[e]),delete t[e])}}))}(c),c=function(e){const t=L.extend({},e);return Object.keys(o).forEach((e=>{void 0!==t[e]&&null!==t[e]||(t[e]=o[e]&&o[e].default)})),t}(c),c=function(e){const t=L.extend({},e),n=e=>{if(null===e)return"any";if(void 0===e)return;if(Array.isArray(e))return"array";const t=typeof e;return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"};return Object.keys(e).forEach((i=>{const s=e[i];if(null!=s){const c=o[i];if(void 0===c)a(se.unknownOption(i));else{const o=c.type||n(c.default),u=c.validator;if(u){const n=u(i,e[i],r);void 0!==n?t[i]=n:delete t[i]}else if("any"!==o){const e=o.split("|"),r=n(s);e.indexOf(r)<0?"boolean"===o?(t[i]=!!s,a(se.wrongOptionTypeBoolean(i,r))):(a(se.wrongOptionType(i,o,r)),t[i]=c.default):"number"===r&&void 0!==c.minimum&&s<c.minimum&&(a(se.optionBelowMinimum(i,s,c.minimum)),t[i]=c.minimum)}}}})),t}(c),ce(c.logger),c},getTags:function(e){const t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}};const{getLDUserAgentString:ge}=L;var ve={getLDHeaders:function(e,t){if(t&&!t.sendLDHeaders)return{};const n={};n[e.userAgentHeaderName||"User-Agent"]=ge(e),t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName);const r=fe.getTags(t),o=Object.keys(r);return o.length&&(n["x-launchdarkly-tags"]=o.sort().map((e=>Array.isArray(r[e])?r[e].sort().map((t=>`${e}/${t}`)):[`${e}/${r[e]}`])).reduce(((e,t)=>e.concat(t)),[]).join(" ")),n},transformHeaders:function(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform({...e}):e}};const{v1:pe}=ne,{getLDHeaders:me,transformHeaders:he}=ve;var ye=function(e,t,n){const r="/a/"+t+".gif",o=L.extend({"Content-Type":"application/json"},me(e,n)),i=e.httpFallbackPing,a={};return a.sendChunk=(t,a,c,u)=>{const l=JSON.stringify(t),d=c?null:pe();return u?function t(r){const i=c?o:L.extend({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":d});return e.httpRequest("POST",a,he(i,n),l).promise.then((e=>{if(e)return e.status>=400&&s.isHttpErrorRecoverable(e.status)&&r?t(!1):function(e){const t={status:e.status},n=e.header("date");if(n){const e=Date.parse(n);e&&(t.serverTime=e)}return t}(e)})).catch((()=>r?t(!1):Promise.reject()))}(!0).catch((()=>{})):(i&&i(a+r+"?d="+L.base64URLEncode(l)),Promise.resolve())},a.sendEvents=function(t,n,r){if(!e.httpRequest)return Promise.resolve();const o=e.httpAllowsPost();let i;i=o?[t]:L.chunkEventsForUrl(2e3-n.length,t);const s=[];for(let e=0;e<i.length;e++)s.push(a.sendChunk(i[e],n,r,o));return Promise.all(s)},a};var we=function(){const e={};let t=0,n=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){const o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=r[o];i?i.count=i.count+1:r[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===t||e.creationDate<t)&&(t=e.creationDate),e.creationDate>n&&(n=e.creationDate)}},e.getSummary=function(){const e={};let o=!0;for(const t in r){const n=r[t];let i=e[n.key];i||(i={default:n.default,counters:[]},e[n.key]=i);const a={value:n.value,count:n.count};void 0!==n.variation&&null!==n.variation&&(a.variation=n.variation),n.version?a.version=n.version:a.unknown=!0,i.counters.push(a),o=!1}return o?null:{startDate:t,endDate:n,features:e}},e.clearSummary=function(){t=0,n=0,r={}},e};function be(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ke(e){return(e.startsWith("/")?e.substring(1):e).split("/").map((e=>e.indexOf("~")>=0?e.replace(/~1/g,"/").replace(/~0/g,"~"):e))}function Ee(e){return!e.startsWith("/")}function De(e,t){const n=Ee(e),r=Ee(t);if(n&&r)return e===t;if(n){const n=ke(t);return 1===n.length&&e===n[0]}if(r){const n=ke(e);return 1===n.length&&t===n[0]}return e===t}function Ce(e){return`/${be(e)}`}var Pe={cloneExcluding:function(e,t){const n=[],r={},o=[];for(n.push(...Object.keys(e).map((t=>({key:t,ptr:Ce(t),source:e,parent:r,visited:[e]}))));n.length;){const e=n.pop();if(t.some((t=>De(t,e.ptr))))o.push(e.ptr);else{const t=e.source[e.key];if(null===t)e.parent[e.key]=t;else if(Array.isArray(t))e.parent[e.key]=[...t];else if("object"==typeof t){if(e.visited.includes(t))continue;e.parent[e.key]={},n.push(...Object.keys(t).map((n=>{return{key:n,ptr:(r=e.ptr,o=be(n),`${r}/${o}`),source:t,parent:e.parent[e.key],visited:[...e.visited,t]};var r,o})))}else e.parent[e.key]=t}}return{cloned:r,excluded:o.sort()}},compare:De,literalToReference:Ce};var xe=function(e){const t={},n=e.allAttributesPrivate,r=e.privateAttributes||[],o=["key","kind","_meta","anonymous"],i=["name","ip","firstName","lastName","email","avatar","country"],a=e=>{if("object"!=typeof e||null===e||Array.isArray(e))return;const{cloned:t,excluded:i}=Pe.cloneExcluding(e,(e=>(n?Object.keys(e):[...r,...e._meta&&e._meta.privateAttributes||[]]).filter((e=>!o.some((t=>Pe.compare(e,t))))))(e));return t.key=String(t.key),i.length&&(t._meta||(t._meta={}),t._meta.redactedAttributes=i),t._meta&&(null===t._meta.secondary&&delete t._meta.secondary,void 0!==t._meta.secondary&&(t._meta.secondary=String(t._meta.secondary)),delete t._meta.privateAttributes,0===Object.keys(t._meta).length&&delete t._meta),void 0!==t.anonymous&&(t.anonymous=!!t.anonymous),t};return t.filter=e=>void 0===e.kind||null===e.kind?a((e=>{const t={...e.custom||{},kind:"user",key:e.key};void 0!==e.anonymous&&(t.anonymous=!!e.anonymous);for(const n of i)delete t[n],void 0!==e[n]&&null!==e[n]&&(t[n]=String(e[n]));return void 0!==e.privateAttributeNames&&null!==e.privateAttributeNames&&(t._meta=t._meta||{},t._meta.privateAttributes=e.privateAttributeNames.map((e=>e.startsWith("/")?Pe.literalToReference(e):e))),void 0!==e.secondary&&null!==e.secondary&&(t._meta=t._meta||{},t._meta.secondary=String(e.secondary)),t})(e)):"multi"===e.kind?(e=>{const t={kind:e.kind},n=Object.keys(e);for(const r of n)if("kind"!==r){const n=a(e[r]);n&&(t[r]=n)}return t})(e):a(e),t};var Se=function(e,t,n,r=null,o=null,i=null){const a={},c=i||ye(e,n,t),u=L.appendUrlPath(t.eventsUrl,"/events/bulk/"+n),l=we(),d=xe(t),f=t.samplingInterval,g=t.eventCapacity,v=t.flushInterval,p=t.logger;let m,h=[],y=0,w=!1,b=!1;function k(){return 0===f||0===Math.floor(Math.random()*f)}function E(e){const t=L.extend({},e);return"identify"===e.kind?t.context=d.filter(e.context):(t.contextKeys=function(e){const t={},n=e.context;if(void 0!==n)return void 0===n.kind?t.user=String(n.key):"multi"===n.kind?Object.entries(n).filter((([e])=>"kind"!==e)).forEach((([e,n])=>{void 0!==n&&void 0!==n.key&&(t[e]=n.key)})):t[n.kind]=String(n.key),t;return}(e),delete t.context),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}function D(e){h.length<g?(h.push(e),b=!1):(b||(b=!0,p.warn(se.eventCapacityExceeded())),r&&r.incrementDroppedEvents())}return a.enqueue=function(e){if(w)return;let t=!1,n=!1;var r;if(l.summarizeEvent(e),"feature"===e.kind?k()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>y&&r.debugEventsUntilDate>(new Date).getTime()):t=k(),t&&D(E(e)),n){const t=L.extend({},e,{kind:"debug"});t.context=d.filter(t.context),delete t.trackEvents,delete t.debugEventsUntilDate,D(t)}},a.flush=function(){if(w)return Promise.resolve();const e=h,t=l.getSummary();return l.clearSummary(),t&&(t.kind="summary",e.push(t)),r&&r.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(h=[],p.debug(se.debugPostingEvents(e.length)),c.sendEvents(e,u).then((e=>{e&&(e.serverTime&&(y=e.serverTime),s.isHttpErrorRecoverable(e.status)||(w=!0),e.status>=400&&L.onNextTick((()=>{o.maybeReportError(new s.LDUnexpectedResponseError(se.httpErrorMessage(e.status,"event posting","some events were dropped")))})))})))},a.start=function(){const e=()=>{a.flush(),m=setTimeout(e,v)};m=setTimeout(e,v)},a.stop=function(){clearTimeout(m)},a};var Ie=function(e){const t={},n={};return t.on=function(e,t,r){n[e]=n[e]||[],n[e]=n[e].concat({handler:t,context:r})},t.off=function(e,t,r){if(n[e])for(let o=0;o<n[e].length;o++)n[e][o].handler===t&&n[e][o].context===r&&(n[e]=n[e].slice(0,o).concat(n[e].slice(o+1)))},t.emit=function(e){if(!n[e])return;const t=n[e].slice(0);for(let e=0;e<t.length;e++)t[e].handler.apply(t[e].context,Array.prototype.slice.call(arguments,1))},t.getEvents=function(){return Object.keys(n)},t.getEventListenerCount=function(e){return n[e]?n[e].length:0},t.maybeReportError=function(t){t&&(n["error"]?this.emit("error",t):(e||console).error(t.message))},t};var Le=function(e){let t=!1,n=!1,r=null,o=null;const i=new Promise((t=>{const n=()=>{e.off("ready",n),t()};e.on("ready",n)})).catch((()=>{}));return{getInitializationPromise:()=>o||(t?Promise.resolve():n?Promise.reject(r):(o=new Promise(((t,n)=>{const r=()=>{e.off("initialized",r),t()},o=t=>{e.off("failed",o),n(t)};e.on("initialized",r),e.on("failed",o)})),o)),getReadyPromise:()=>i,signalSuccess:()=>{t||n||(t=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:o=>{t||n||(n=!0,r=o,e.emit("failed",o),e.emit("ready")),e.maybeReportError(o)}}};var Oe=function(e,t,n,r){const o={};function i(){let e="";const o=r.getContext();return o&&(e=n||L.btoa(JSON.stringify(o))),"ld:"+t+":"+e}return o.loadFlags=()=>e.get(i()).then((e=>{if(null==e)return null;try{let t=JSON.parse(e);if(t){const e=t.$schema;void 0===e||e<1?t=L.transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return o.clearFlags().then((()=>null))}})),o.saveFlags=t=>{const n=L.extend({},t,{$schema:1});return e.set(i(),JSON.stringify(n))},o.clearFlags=()=>e.clear(i()),o};var Ue=function(e,t){const n={};let r=!1;const o=e=>{r||(r=!0,t.warn(se.localStorageUnavailable(e)))};return n.isEnabled=()=>!!e,n.get=t=>new Promise((n=>{e?e.get(t).then(n).catch((e=>{o(e),n(void 0)})):n(void 0)})),n.set=(t,n)=>new Promise((r=>{e?e.set(t,n).then((()=>r(!0))).catch((e=>{o(e),r(!1)})):r(!1)})),n.clear=t=>new Promise((n=>{e?e.clear(t).then((()=>n(!0))).catch((e=>{o(e),n(!1)})):n(!1)})),n};const{appendUrlPath:Te,base64URLEncode:Re,objectHasOwnProperty:Ae}=L,{getLDHeaders:je,transformHeaders:Fe}=ve,{isHttpErrorRecoverable:Ne}=s;var Ve=function(e,t,n,r){const o=t.streamUrl,i=t.logger,a={},s=Te(o,"/eval/"+n),c=t.useReport,u=t.evaluationReasons,l=t.streamReconnectDelay,d=je(e,t);let f,g=!1,v=null,p=null,m=null,h=null,y=null,w=0;function b(){const e=(t=function(){const e=l*Math.pow(2,w);return e>3e4?3e4:e}(),t-Math.trunc(.5*Math.random()*t));var t;return w+=1,e}function k(e){if(e.status&&"number"==typeof e.status&&!Ne(e.status))return C(),i.error(se.unrecoverableStreamError(e)),void(p&&(clearTimeout(p),p=null));const t=b();g||(i.warn(se.streamError(e,t)),g=!0),P(!1),C(),E(t)}function E(e){p||(e?p=setTimeout(D,e):D())}function D(){let r;p=null;let a="";const l={headers:d,readTimeoutMillis:3e5};if(e.eventSourceFactory){null!=h&&(a="h="+h),c?e.eventSourceAllowsReport?(r=s,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(m)):(r=Te(o,"/ping/"+n),a=""):r=s+"/"+Re(JSON.stringify(m)),l.headers=Fe(l.headers,t),u&&(a=a+(a?"&":"")+"withReasons=true"),r=r+(a?"?":"")+a,C(),i.info(se.streamConnecting(r)),f=(new Date).getTime(),v=e.eventSourceFactory(r,l);for(const e in y)Ae(y,e)&&v.addEventListener(e,y[e]);v.onerror=k,v.onopen=()=>{w=0}}}function C(){v&&(i.info(se.streamClosing()),v.close(),v=null)}function P(e){f&&r&&r.recordStreamInit(f,!e,(new Date).getTime()-f),f=null}return a.connect=function(e,t,n){m=e,h=t,y={};for(const e in n||{})y[e]=function(t){g=!1,P(!0),n[e]&&n[e](t)};E()},a.disconnect=function(){clearTimeout(p),p=null,C()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a};var $e=function(e){let t,n,r,o;const i={addPromise:(i,a)=>{t=i,n&&n(),n=a,i.then((n=>{t===i&&(r(n),e&&e())}),(n=>{t===i&&(o(n),e&&e())}))}};return i.resultPromise=new Promise(((e,t)=>{r=e,o=t})),i};const{transformHeaders:He,getLDHeaders:qe}=ve;var Me=function(e,t,n){const r=t.baseUrl,o=t.useReport,i=t.evaluationReasons,a=t.logger,c={},u={};function l(n,r){if(!e.httpRequest)return new Promise(((e,t)=>{t(new s.LDFlagFetchError(se.httpUnavailable()))}));const o=r?"REPORT":"GET",i=qe(e,t);r&&(i["Content-Type"]="application/json");let a=u[n];a||(a=$e((()=>{delete u[n]})),u[n]=a);const c=e.httpRequest(o,n,He(i,t),r),l=c.promise.then((e=>{if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);{const t=se.invalidContentType(e.header("content-type")||"");return Promise.reject(new s.LDFlagFetchError(t))}}return Promise.reject(function(e){return 404===e.status?new s.LDInvalidEnvironmentIdError(se.environmentNotFound()):new s.LDFlagFetchError(se.errorFetchingFlags(e.statusText||String(e.status)))}(e))}),(e=>Promise.reject(new s.LDFlagFetchError(se.networkError(e)))));return a.addPromise(l,(()=>{c.cancel&&c.cancel()})),a.resultPromise}return c.fetchJSON=function(e){return l(L.appendUrlPath(r,e),null)},c.fetchFlagSettings=function(e,t){let s,c,u,d="";return o?(c=[r,"/sdk/evalx/",n,"/user"].join(""),u=JSON.stringify(e)):(s=L.base64URLEncode(JSON.stringify(e)),c=[r,"/sdk/evalx/",n,"/users/",s].join("")),t&&(d="h="+t),i&&(d=d+(d?"&":"")+"withReasons=true"),c=c+(d?"?":"")+d,a.debug(se.debugPolling(c)),l(c,u)},c};var _e=function(e,t){const n={};let r;return n.setContext=function(e){r=L.sanitizeContext(e),r&&t&&t(L.clone(r))},n.getContext=function(){return r?L.clone(r):null},e&&n.setContext(e),n};function ze(e){return"string"==typeof e&&"kind"!==e&&e.match(/^(\w|\.|-)+$/)}function Je(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}var Ke={checkContext:function(e,t){if(e){if(t&&(void 0===e.kind||null===e.kind))return void 0!==e.key&&null!==e.key;const n=e.key,r=void 0===e.kind?"user":e.kind,o=ze(r),i="multi"===r||null!=n&&""!==n;if("multi"===r){const t=Object.keys(e).filter((e=>"kind"!==e));return i&&t.every((e=>ze(e)))&&t.every((t=>{const n=e[t].key;return null!=n&&""!==n}))}return i&&o}return!1},getContextKinds:function(e){return e?null===e.kind||void 0===e.kind?["user"]:"multi"!==e.kind?[e.kind]:Object.keys(e).filter((e=>"kind"!==e)):[]},getCanonicalKey:function(e){if(e){if((void 0===e.kind||null===e.kind||"user"===e.kind)&&e.key)return e.key;if("multi"!==e.kind&&e.key)return`${e.kind}:${Je(e.key)}`;if("multi"===e.kind)return Object.keys(e).sort().filter((e=>"kind"!==e)).map((t=>`${t}:${Je(e[t].key)}`)).join(":")}}};const{v1:Be}=ne,{getContextKinds:Ge}=Ke;var We=function(e){function t(e){return null==e||"user"===e?"ld:$anonUserId":`ld:$contextKey:${e}`}function n(n,r){return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?function(n){return e.get(t(n))}(n).then((o=>{if(o)return r.key=o,r;{const o=Be();return r.key=o,function(n,r){return e.set(t(r),n)}(o,n).then((()=>r))}})):Promise.reject(new s.LDInvalidUserError(se.invalidContext()))}this.processContext=e=>{if(!e)return Promise.reject(new s.LDInvalidUserError(se.contextNotSpecified()));const t=L.clone(e);if("multi"===e.kind){const e=Ge(t);return Promise.all(e.map((e=>n(e,t[e])))).then((()=>t))}return n(e.kind,t)}};const{v1:Xe}=ne,{baseOptionDefs:Qe}=fe,{appendUrlPath:Ye}=L;var Ze={DiagnosticId:function(e){const t={diagnosticId:Xe()};return e&&(t.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),t},DiagnosticsAccumulator:function(e){let t,n,r,o;function i(e){t=e,n=0,r=0,o=[]}return i(e),{getProps:()=>({dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}),setProps:e=>{t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:()=>{n++},setEventsInLastBatch:e=>{r=e},recordStreamInit:(e,t,n)=>{const r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}},DiagnosticsManager:function(e,t,n,r,o,i,a){const s=!!e.diagnosticUseCombinedEvent,c="ld:"+o+":$diagnostics",u=Ye(i.eventsUrl,"/events/diagnostic/"+o),l=i.diagnosticRecordingInterval,d=n;let f,g,v=!!i.streaming;const p={};function m(){return{sdk:w(),configuration:b(),platform:e.diagnosticPlatformData}}function h(e){i.logger&&i.logger.debug(se.debugPostingDiagnosticEvent(e)),r.sendEvents(e,u,!0).then((()=>{})).catch((()=>{}))}function y(){h(function(){const e=(new Date).getTime();let t={kind:s?"diagnostic-combined":"diagnostic",id:a,creationDate:e,...d.getProps()};return s&&(t={...t,...m()}),d.reset(e),t}()),g=setTimeout(y,l),f=(new Date).getTime(),s&&function(){if(t.isEnabled()){const e={...d.getProps()};t.set(c,JSON.stringify(e))}}()}function w(){const t={...e.diagnosticSdkData};return i.wrapperName&&(t.wrapperName=i.wrapperName),i.wrapperVersion&&(t.wrapperVersion=i.wrapperVersion),t}function b(){return{customBaseURI:i.baseUrl!==Qe.baseUrl.default,customStreamURI:i.streamUrl!==Qe.streamUrl.default,customEventsURI:i.eventsUrl!==Qe.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!i.allAttributesPrivate,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation}}return p.start=()=>{s?function(e){if(!t.isEnabled())return e(!1);t.get(c).then((t=>{if(t)try{const e=JSON.parse(t);d.setProps(e),f=e.dataSinceDate}catch(e){}e(!0)})).catch((()=>{e(!1)}))}((e=>{if(e){const e=(f||0)+l,t=(new Date).getTime();t>=e?y():g=setTimeout(y,e-t)}else 0===Math.floor(4*Math.random())?y():g=setTimeout(y,l)})):(h({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate,...m()}),g=setTimeout(y,l))},p.stop=()=>{g&&clearTimeout(g)},p.setStreaming=e=>{v=e},p}},et=dt;const{messages:tt}=et;var nt=function(e,t){let n=!1;const r={type:e.type,name:e.name,method:(...o)=>{try{e.method(...o)}catch{n||(n=!0,t.warn(tt.inspectorMethodError(r.type,r.name)))}}};return r};const{messages:rt}=et,{onNextTick:ot}=L,it={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};Object.freeze(it);var at={InspectorTypes:it,InspectorManager:function(e,t){const n={},r={[it.flagUsed]:[],[it.flagDetailsChanged]:[],[it.flagDetailChanged]:[],[it.clientIdentityChanged]:[]},o=e?.map((e=>nt(e,t)));return o.forEach((e=>{Object.prototype.hasOwnProperty.call(r,e.type)?r[e.type].push(e):t.warn(rt.invalidInspector(e.type,e.name))})),n.hasListeners=e=>r[e]?.length,n.onFlagUsed=(e,t,n)=>{r[it.flagUsed].length&&ot((()=>{r[it.flagUsed].forEach((r=>r.method(e,t,n)))}))},n.onFlags=e=>{r[it.flagDetailsChanged].length&&ot((()=>{r[it.flagDetailsChanged].forEach((t=>t.method(e)))}))},n.onFlagChanged=(e,t)=>{r[it.flagDetailChanged].length&&ot((()=>{r[it.flagDetailChanged].forEach((n=>n.method(e,t)))}))},n.onIdentityChanged=e=>{r[it.clientIdentityChanged].length&&ot((()=>{r[it.clientIdentityChanged].forEach((t=>t.method(e)))}))},n}};const{commonBasicLogger:st}=oe,{checkContext:ct}=Ke,{InspectorTypes:ut,InspectorManager:lt}=at;var dt={initialize:function(e,t,n,r,o){const i=function(){if(n&&n.logger)return n.logger;return o&&o.logger&&o.logger.default||st("warn")}(),a=Ie(i),c=Le(a),u=fe.validate(n,a,o,i),l=lt(u.inspectors,i),d=u.sendEvents;let f=e,g=u.hash;const v=Ue(r.localStorage,i),p=ye(r,f,u),m=u.sendEvents&&!u.diagnosticOptOut,h=m?Ze.DiagnosticId(f):null,y=m?Ze.DiagnosticsAccumulator((new Date).getTime()):null,w=m?Ze.DiagnosticsManager(r,v,y,p,f,u,h):null,b=Ve(r,u,f,y),k=u.eventProcessor||Se(r,u,f,y,a,p),E=Me(r,u,f);let D,C,P,x={},S=u.streaming,I=!1,O=!1,U=!0;const T=u.stateProvider,R=_e(null,(function(e){(function(e){if(T)return;e&&F({kind:"identify",context:e,creationDate:(new Date).getTime()})})(e),l.hasListeners(ut.clientIdentityChanged)&&l.onIdentityChanged(R.getContext())})),A=new We(v),j=v.isEnabled()?Oe(v,f,g,R):null;function F(e){f&&(T&&T.enqueueEvent&&T.enqueueEvent(e)||(e.context?(U=!1,!d||O||r.isDoNotTrack()||(i.debug(se.debugEnqueueingEvent(e.kind)),k.enqueue(e))):U&&(i.warn(se.eventWithoutContext()),U=!1)))}function N(e,t){l.hasListeners(ut.flagDetailChanged)&&l.onFlagChanged(e.key,M(t))}function V(){l.hasListeners(ut.flagDetailsChanged)&&l.onFlags(Object.entries(x).map((([e,t])=>({key:e,detail:M(t)}))).reduce(((e,t)=>(e[t.key]=t.detail,e)),{}))}function $(e,t,n,r){const o=R.getContext(),i=new Date,a={kind:"feature",key:e,context:o,value:t?t.value:null,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},s=x[e];s&&(a.version=s.flagVersion?s.flagVersion:s.version,a.trackEvents=s.trackEvents,a.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(a.reason=t.reason),F(a)}function H(e){return ct(e,!1)?Promise.resolve(e):Promise.reject(new s.LDInvalidUserError(se.invalidContext()))}function q(e,t,n,r,o){let i;if(x&&L.objectHasOwnProperty(x,e)&&x[e]&&!x[e].deleted){const n=x[e];i=M(n),null!==n.value&&void 0!==n.value||(i.value=t)}else i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&$(e,i,t,r),o||function(e,t){l.hasListeners(ut.flagUsed)&&l.onFlagUsed(e,t,R.getContext())}(e,i),i}function M(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function _(){if(C=!0,!R.getContext())return;const e=e=>{try{return JSON.parse(e)}catch(e){return void a.maybeReportError(new s.LDInvalidDataError(se.invalidData()))}};b.connect(R.getContext(),g,{ping:function(){i.debug(se.debugStreamPing());const e=R.getContext();E.fetchFlagSettings(e,g).then((t=>{L.deepEquals(e,R.getContext())&&J(t||{})})).catch((e=>{a.maybeReportError(new s.LDFlagFetchError(se.errorFetchingFlags(e)))}))},put:function(t){const n=e(t.data);n&&(i.debug(se.debugStreamPut()),J(n))},patch:function(t){const n=e(t.data);if(!n)return;const r=x[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(se.debugStreamPatch(n.key));const e={},t=L.extend({},n);delete t.key,x[n.key]=t;const o=M(t);e[n.key]=r?{previous:r.value,current:o}:{current:o},K(e),N(n,t)}else i.debug(se.debugStreamPatchIgnored(n.key))},delete:function(t){const n=e(t.data);if(n)if(!x[n.key]||x[n.key].version<n.version){i.debug(se.debugStreamDelete(n.key));const e={};x[n.key]&&!x[n.key].deleted&&(e[n.key]={previous:x[n.key].value}),x[n.key]={version:n.version,deleted:!0},N(n,x[n.key]),K(e)}else i.debug(se.debugStreamDeleteIgnored(n.key))}})}function z(){C&&(b.disconnect(),C=!1)}function J(e){const t={};if(!e)return Promise.resolve();for(const n in x)L.objectHasOwnProperty(x,n)&&x[n]&&(e[n]&&!L.deepEquals(e[n].value,x[n].value)?t[n]={previous:x[n].value,current:M(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:x[n].value}));for(const n in e)L.objectHasOwnProperty(e,n)&&e[n]&&(!x[n]||x[n].deleted)&&(t[n]={current:M(e[n])});return x={...e},V(),K(t).catch((()=>{}))}function K(e){const t=Object.keys(e);if(t.length>0){const n={};t.forEach((t=>{const r=e[t].current,o=r?r.value:void 0,i=e[t].previous;a.emit("change:"+t,o,i),n[t]=r?{current:o,previous:i}:{previous:i}})),a.emit("change",n),a.emit("internal-change",x),u.sendEventsOnlyForVariation||T||t.forEach((t=>{$(t,e[t].current)}))}return D&&j?j.saveFlags(x):Promise.resolve()}function B(){const e=S||P&&void 0===S;e&&!C?_():!e&&C&&z(),w&&w.setStreaming(e)}function G(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(j?D=!0:i.warn(se.localStorageUnavailable())),"object"==typeof u.bootstrap&&(x=function(e){const t=Object.keys(e),n="$flagsState",r="$valid",o=e.$flagsState;!o&&t.length&&i.warn(se.bootstrapOldFormat()),!1===e.$valid&&i.warn(se.bootstrapInvalid());const a={};return t.forEach((t=>{if(t!==n&&t!==r){let n={value:e[t]};o&&o[t]?n=L.extend(n,o[t]):n.version=0,a[t]=n}})),a}(u.bootstrap)),T){const e=T.getInitialState();e?W(e):T.on("init",W),T.on("update",(function(e){e.context&&R.setContext(e.context);e.flags&&J(e.flags)}))}else(function(){if(!e)return Promise.reject(new s.LDInvalidEnvironmentIdError(se.environmentNotSpecified()));return A.processContext(t).then(H).then((e=>(R.setContext(e),"object"==typeof u.bootstrap?X():D?j.loadFlags().then((e=>null==e?(x={},E.fetchFlagSettings(R.getContext(),g).then((e=>J(e||{}))).then(X).catch((e=>{Q(new s.LDFlagFetchError(se.errorFetchingFlags(e)))}))):(x=e,L.onNextTick(X),E.fetchFlagSettings(R.getContext(),g).then((e=>J(e))).catch((e=>a.maybeReportError(e)))))):E.fetchFlagSettings(R.getContext(),g).then((e=>{x=e||{},V(),X()})).catch((e=>{x={},Q(e)})))))})().catch(Q);function W(e){f=e.environment,R.setContext(e.context),x={...e.flags},L.onNextTick(X)}function X(){i.info(se.clientInitialized()),I=!0,B(),c.signalSuccess()}function Q(e){c.signalFailure(e)}const Y={waitForInitialization:()=>c.getInitializationPromise(),waitUntilReady:()=>c.getReadyPromise(),identify:function(e,t,n){if(O)return L.wrapPromiseCallback(Promise.resolve({}),n);if(T)return i.warn(se.identifyDisabled()),L.wrapPromiseCallback(Promise.resolve(L.transformVersionedValuesToValues(x)),n);const r=D&&j?j.clearFlags():Promise.resolve();return L.wrapPromiseCallback(r.then((()=>A.processContext(e))).then(H).then((e=>E.fetchFlagSettings(e,t).then((n=>{const r=L.transformVersionedValuesToValues(n);return R.setContext(e),g=t,n?J(n).then((()=>r)):r})))).then((e=>(C&&_(),e))).catch((e=>(a.maybeReportError(e),Promise.reject(e)))),n)},getContext:function(){return R.getContext()},variation:function(e,t){return q(e,t,!0,!1,!1).value},variationDetail:function(e,t){return q(e,t,!0,!0,!1)},track:function(e,t,n){if("string"!=typeof e)return void a.maybeReportError(new s.LDInvalidEventKeyError(se.unknownCustomEventKey(e)));r.customEventFilter&&!r.customEventFilter(e)&&i.warn(se.unknownCustomEventKey(e));const o=R.getContext(),c={kind:"custom",key:e,context:o,url:r.getCurrentUrl(),creationDate:(new Date).getTime()};o&&o.anonymous&&(c.contextKind=o.anonymous?"anonymousUser":"user"),null!=t&&(c.data=t),null!=n&&(c.metricValue=n),F(c)},on:function(e,t,n){G(e)?(P=!0,I&&B(),a.on(e,t,n)):a.on(...arguments)},off:function(e){if(a.off(...arguments),G(e)){let e=!1;a.getEvents().forEach((t=>{G(t)&&a.getEventListenerCount(t)>0&&(e=!0)})),e||(P=!1,C&&void 0===S&&z())}},setStreaming:function(e){const t=null===e?void 0:e;t!==S&&(S=t,B())},flush:function(e){return L.wrapPromiseCallback(d?k.flush():Promise.resolve(),e)},allFlags:function(){const e={};if(!x)return e;for(const t in x)L.objectHasOwnProperty(x,t)&&!x[t].deleted&&(e[t]=q(t,null,!u.sendEventsOnlyForVariation,!1,!0).value);return e},close:function(e){if(O)return L.wrapPromiseCallback(Promise.resolve(),e);const t=()=>{O=!0,x={}},n=Promise.resolve().then((()=>{if(z(),w&&w.stop(),d)return k.stop(),k.flush()})).then(t).catch(t);return L.wrapPromiseCallback(n,e)}};return{client:Y,options:u,emitter:a,ident:R,logger:i,requestor:E,start:function(){d&&(w&&w.start(),k.start())},enqueueEvent:F,getFlagsInternal:function(){return x},getEnvironmentId:()=>f,internalChangeEventName:"internal-change"}},commonBasicLogger:st,errors:s,messages:se,utils:L},ft=dt.initialize,gt=dt.errors,vt=dt.messages;function pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function mt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pt(Object(n),!0).forEach((function(t){ht(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ht(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var yt=et.commonBasicLogger;var wt=function(e){return yt(mt({destination:console.log},e))};var bt={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function kt(e,t,n,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var t=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(t)return parseInt(t[2],10)<73}return!0}())return bt;var i=new window.XMLHttpRequest;for(var a in i.open(e,t,!o),n||{})Object.prototype.hasOwnProperty.call(n,a)&&i.setRequestHeader(a,n[a]);if(o)return i.send(r),bt;var s,c=new Promise((function(e,t){i.addEventListener("load",(function(){s||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){s||t(new Error)})),i.send(r)}));return{promise:c,cancel:function(){s=!0,i.abort()}}}function Et(e){var t,n={userAgentHeaderName:"X-LaunchDarkly-User-Agent",synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;n.httpRequest=function(e,t,o,i){var a=n.synchronousFlush&!r;return n.synchronousFlush=!1,kt(e,t,o,i,a)}}n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t},n.httpFallbackPing=function(e){(new window.Image).src=e};var o,i=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return i?i(window.location.href):window.location.href},n.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&&(n.localStorage={get:function(e){return new Promise((function(t){t(window.localStorage.getItem(e))}))},set:function(e,t){return new Promise((function(n){window.localStorage.setItem(e,t),n()}))},clear:function(e){return new Promise((function(t){window.localStorage.removeItem(e),t()}))}})}catch(e){n.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;n.eventSourceFactory=function(e,t){var n=mt(mt({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),t);return new o(e,n)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n.version="3.0.0-alpha.1",n.diagnosticSdkData={name:"js-client-sdk",version:"3.0.0-alpha.1"},n.diagnosticPlatformData={name:"JS"},n.diagnosticUseCombinedEvent=!0,n}var Dt=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function Ct(e,t,n,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?t:t.replace(r,"")).replace(n,"");switch(e.kind){case"exact":i=t,o=new RegExp("^"+Dt(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Dt(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Dt(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Pt(e,t){for(var n={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],s=a.urls||[],c=0;c<s.length;c++)if(Ct(s[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?t("pageview",a):(o.push(a),t("click_pageview",a));break}return o.length>0&&(r=function(e){for(var n=function(e,t){for(var n=[],r=0;r<t.length;r++)for(var o=e.target,i=t[r],a=i.selector,s=document.querySelectorAll(a);o&&s.length>0;){for(var c=0;c<s.length;c++)o===s[c]&&n.push(i);o=o.parentNode}return n}(e,o),r=0;r<n.length;r++)t("click",n[r])},document.addEventListener("click",r)),n.dispose=function(){document.removeEventListener("click",r)},n}function xt(e,t){var n,r;function o(){r&&r.dispose(),n&&n.length&&(r=Pt(n,i))}function i(t,n){var r=e.ident.getUser(),o={kind:t,key:n.key,data:null,url:window.location.href,user:r,creationDate:(new Date).getTime()};return r&&r.anonymous&&(o.contextKind="anonymousUser"),"click"===t&&(o.selector=n.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Pt(n=e,i),function(e,t){var n,r=window.location.href;function o(){(n=window.location.href)!==r&&(r=n,t())}!function e(t,n){t(),setTimeout((function(){e(t,n)}),n)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(300,o)),t()})).catch((function(n){e.emitter.maybeReportError(new gt.LDUnexpectedResponseError((n&&n.message,n.message))),t()})),{}}var St={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function It(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Et(n),o=ft(e,t,n,r,St),i=o.client,a=o.options,s=o.emitter,c=new Promise((function(e){var t=s.on("goalsReady",(function(){s.off("goalsReady",t),e()}))}));i.waitUntilGoalsReady=function(){return c},a.fetchGoals?xt(o,(function(){return s.emit("goalsReady")})):s.emit("goalsReady"),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var u=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return window.addEventListener("beforeunload",u),window.addEventListener("unload",u),i}var Lt=wt;var Ot={initialize:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(vt.deprecated("default export","named LDClient export")),It(e,t,n)},version:"3.0.0-alpha.1"};exports.basicLogger=Lt,exports.createConsoleLogger=undefined,exports.default=Ot,exports.initialize=It,exports.version="3.0.0-alpha.1";
|
|
2
2
|
//# sourceMappingURL=ldclient.cjs.js.map
|