@launchdarkly/react-sdk 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0](https://github.com/launchdarkly/js-core/compare/react-sdk-v0.0.1...react-sdk-v0.1.0) (2026-03-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * pre-release of `@launchdarkly/react-sdk` ([#1201](https://github.com/launchdarkly/js-core/issues/1201)) ([69f4790](https://github.com/launchdarkly/js-core/commit/69f47902f5327d3d7c7f1bbca66a3d0ff95e7452))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency next to v16.1.5 [security] ([#1164](https://github.com/launchdarkly/js-core/issues/1164)) ([929a385](https://github.com/launchdarkly/js-core/commit/929a385568b7b25e2340c5e7b4f654e6b6d8d907))
14
+ * **deps:** update dependency next to v16.1.7 [security] ([#1196](https://github.com/launchdarkly/js-core/issues/1196)) ([1572be1](https://github.com/launchdarkly/js-core/commit/1572be1adbb25eb12102e5f03dd058d62423afb3))
15
+
16
+
17
+ ### Dependencies
18
+
19
+ * The following workspace dependencies were updated
20
+ * dependencies
21
+ * @launchdarkly/js-client-sdk bumped from ^4.4.0 to ^4.4.1
22
+ * @launchdarkly/js-server-sdk-common bumped from ^2.18.2 to ^2.18.3
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2026 Catamorphic, Co.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # LaunchDarkly React SDK
2
+
3
+ > [!CAUTION]
4
+ > This [SDK|feature] is experimental and should NOT be considered ready for production use.
5
+ > It may change or be removed without notice and is not subject to backwards
6
+ > compatibility guarantees.
7
+
8
+ ## About LaunchDarkly
9
+
10
+ - LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
11
+ - Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
12
+ - Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
13
+ - Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
14
+ - Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
15
+ - Disable parts of your application to facilitate maintenance, without taking everything offline.
16
+ - LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
17
+ - Explore LaunchDarkly
18
+ - [launchdarkly.com](https://www.launchdarkly.com/ 'LaunchDarkly Main Website') for more information
19
+ - [docs.launchdarkly.com](https://docs.launchdarkly.com/ 'LaunchDarkly Documentation') for our documentation and SDK reference guides
20
+ - [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ 'LaunchDarkly API Documentation') for our API documentation
21
+ - [blog.launchdarkly.com](https://blog.launchdarkly.com/ 'LaunchDarkly Blog Documentation') for the latest product updates
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ "use strict";var Ei=Object.create;var q=Object.defineProperty,xi=Object.defineProperties,Ci=Object.getOwnPropertyDescriptor,Si=Object.getOwnPropertyDescriptors,Ri=Object.getOwnPropertyNames,At=Object.getOwnPropertySymbols,Oi=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty,Ii=Object.prototype.propertyIsEnumerable;var Vt=(t,e,i)=>e in t?q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,A=(t,e)=>{for(var i in e||(e={}))Mt.call(e,i)&&Vt(t,i,e[i]);if(At)for(var i of At(e))Ii.call(e,i)&&Vt(t,i,e[i]);return t},V=(t,e)=>xi(t,Si(e));var Li=(t,e)=>{for(var i in e)q(t,i,{get:e[i],enumerable:!0})},Ft=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ri(e))!Mt.call(t,r)&&r!==i&&q(t,r,{get:()=>e[r],enumerable:!(n=Ci(e,r))||n.enumerable});return t};var $i=(t,e,i)=>(i=t!=null?Ei(Oi(t)):{},Ft(e||!t||!t.__esModule?q(i,"default",{value:t,enumerable:!0}):i,t)),Ti=t=>Ft(q({},"__esModule",{value:!0}),t);var qa={};Li(qa,{LDReactContext:()=>R,createClient:()=>ht,createLDReactProvider:()=>li,createLDReactProviderWithClient:()=>jt,initLDReactContext:()=>dt,useBoolVariation:()=>pi,useBoolVariationDetail:()=>wi,useFlags:()=>ci,useInitializationStatus:()=>di,useJsonVariation:()=>yi,useJsonVariationDetail:()=>Di,useLDClient:()=>gi,useNumberVariation:()=>mi,useNumberVariationDetail:()=>ki,useStringVariation:()=>vi,useStringVariationDetail:()=>bi});module.exports=Ti(qa);var Ut=require("react");function dt(){return(0,Ut.createContext)(null)}var R=dt();var H=$i(require("react"),1);var Pi=Object.defineProperty,Ni=Object.defineProperties,ji=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,zt=(t,e,i)=>e in t?Pi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,v=(t,e)=>{for(var i in e||(e={}))de.call(e,i)&&zt(t,i,e[i]);if(et)for(var i of et(e))fe.call(e,i)&&zt(t,i,e[i]);return t},T=(t,e)=>Ni(t,ji(e)),ge=(t,e)=>{var i={};for(var n in t)de.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(t!=null&&et)for(var n of et(t))e.indexOf(n)<0&&fe.call(t,n)&&(i[n]=t[n]);return i};function Ai(t){return`/${t.replace(/~/g,"~0").replace(/\//g,"~1")}`}function pe(t){return t.indexOf("~")?t.replace(/~1/g,"/").replace(/~0/g,"~"):t}function Vi(t){return(t.startsWith("/")?t.substring(1):t).split("/").map(e=>pe(e))}function Mi(t){return!t.startsWith("/")}function Fi(t){return!t.match(/\/\/|(^\/.*~[^0|^1])|~$/)}var z=class{constructor(t,e=!1){if(e){let i=t;this.g=[i],this.isValid=i!=="",this.redactionName=i.startsWith("/")?Ai(i):i}else{if(this.redactionName=t,t===""||t==="/"||!Fi(t)){this.isValid=!1,this.g=[];return}Mi(t)?this.g=[t]:t.indexOf("/",1)<0?this.g=[pe(t.slice(1))]:this.g=Vi(t),this.g[0]==="_meta"?this.isValid=!1:this.isValid=!0}}get(t){let{g:e,isValid:i}=this;if(!i)return;let n=t;for(let r=0;r<e.length;r+=1){let a=e[r];if(n!=null&&Object.prototype.hasOwnProperty.call(n,a)&&typeof n=="object"&&!Array.isArray(n))n=n[a];else return}return n}getComponent(t){return this.g[t]}get depth(){return this.g.length}get isKind(){return this.g.length===1&&this.g[0]==="kind"}compare(t){return this.depth===t.depth&&this.g.every((e,i)=>e===t.getComponent(i))}get components(){return[...this.g]}};z.InvalidReference=new z("");var Ui=class{is(t){if(Array.isArray(t))return!1;let e=typeof t;return e==="function"||e==="object"}getType(){return"factory method or object"}},B=class{constructor(t,e){this.mt=t,this.typeOf=typeof e}is(t){return Array.isArray(t)?!1:typeof t===this.typeOf}getType(){return this.mt}},ve=class{constructor(t,e){this.mt=t,this.typeOf=typeof e}is(t){return Array.isArray(t)?t.length>0?t.every(e=>typeof e===this.typeOf):!0:!1}getType(){return this.mt}},me=class extends B{constructor(t){super(`number with minimum value of ${t}`,0),this.min=t}is(t){return typeof t===this.typeOf&&t>=this.min}},ye=class extends B{constructor(t){super(`string matching ${t}`,""),this.expression=t}is(t){return typeof t=="string"&&!!t.match(this.expression)}},zi=class{is(t){return typeof t=="function"}getType(){return"function"}},Ki=class{is(t){return typeof t=="boolean"||typeof t=="undefined"||t===null}getType(){return"boolean | undefined | null"}},Ji=/^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d\d*)?(Z|[-+]\d\d(:\d\d)?)/,Bi=class{is(t){return typeof t=="number"||typeof t=="string"&&Ji.test(t)}getType(){return"date"}},Hi=class extends ye{constructor(){super(/^(\w|\.|-)+$/)}is(t){return super.is(t)&&t!=="kind"}},qi=class{constructor(t){this.Yt=t}is(t){return typeof t=="string"&&this.Yt.includes(t)}getType(){return this.Yt.join(" | ")}};function N(t){return t==null}var d=class{static createTypeArray(t,e){return new ve(t,e)}static numberWithMin(t){return new me(t)}static stringMatchingRegex(t){return new ye(t)}static oneOf(...t){return new qi(t)}};d.String=new B("string","");d.Number=new B("number",0);d.ObjectOrFactory=new Ui;d.Object=new B("object",{});d.StringArray=new ve("string[]","");d.Boolean=new B("boolean",!0);d.Function=new zi;d.Date=new Bi;d.Kind=new Hi;d.NullableBoolean=new Ki;function we(t){return"kind"in t?d.String.is(t.kind)&&t.kind!=="multi":!1}function be(t){return"kind"in t?d.String.is(t.kind)&&t.kind==="multi":!1}function ke(t){return!("kind"in t)||t.kind===null||t.kind===void 0}function it(t,e=[]){if(t===null||typeof t!="object")return JSON.stringify(t);if(e.includes(t))throw new Error("Cycle detected");return Array.isArray(t)?`[${t.map(i=>it(i,[...e,t])).map(i=>i===void 0?"null":i).join(",")}]`:`{${Object.keys(t).sort().map(i=>{let n=it(t[i],[...e,t]);if(n!==void 0)return`${JSON.stringify(i)}:${n}`}).filter(i=>i!==void 0).join(",")}}`}var Dt="user";function Kt(t){return t.includes("%")||t.includes(":")?t.replace(/%/g,"%25").replace(/:/g,"%3A"):t}function _i(t){return t&&d.Object.is(t)}function Jt(t){return d.Kind.is(t)}function Bt(t){return d.String.is(t)&&t!==""}function ft(t,e=!1){return t?t.map(i=>new z(i,e)):[]}function Wi(t){return t!=null}function Gi(t){let e=T(v({},t.custom||[]),{kind:"user",key:String(t.key)});if(Wi(t.anonymous)){let i=!!t.anonymous;delete e.anonymous,e.anonymous=i}return t.name!==null&&t.name!==void 0&&(e.name=t.name),t.ip!==null&&t.ip!==void 0&&(e.ip=t.ip),t.firstName!==null&&t.firstName!==void 0&&(e.firstName=t.firstName),t.lastName!==null&&t.lastName!==void 0&&(e.lastName=t.lastName),t.email!==null&&t.email!==void 0&&(e.email=t.email),t.avatar!==null&&t.avatar!==void 0&&(e.avatar=t.avatar),t.country!==null&&t.country!==void 0&&(e.country=t.country),t.privateAttributeNames!==null&&t.privateAttributeNames!==void 0&&(e._meta={privateAttributes:t.privateAttributeNames}),e}var U=class y{constructor(e,i,n){this.P=!1,this.Q=!1,this.Zt=!1,this.$={},this.kind=i,this.valid=e,this.message=n}static D(e,i){return new y(!1,e,i)}static Re(e,i){if(!(!i||!e.isValid))return e.depth===1&&e.getComponent(0)==="anonymous"?!!(i!=null&&i.anonymous):e.get(i)}Xt(e){if(this.P)return this.$[e];if(this.kind===e)return this.v}static Ne(e){let i=Object.keys(e).filter(l=>l!=="kind"),n=i.every(Jt);if(!i.length)return y.D("multi","A multi-kind context must contain at least one kind");if(!n)return y.D("multi","Context contains invalid kinds");let r={},a=!0,o=i.reduce((l,u)=>{var c;let h=e[u];return _i(h)?(l[u]=h,r[u]=ft((c=h._meta)==null?void 0:c.privateAttributes)):a=!1,l},{});if(!a)return y.D("multi","Context contained contexts that were not objects");if(!Object.values(o).every(l=>Bt(l.key)))return y.D("multi","Context contained invalid keys");if(i.length===1){let l=i[0],u=new y(!0,l);return u.v=T(v({},o[l]),{kind:l}),u.tt=r,u.Q=l==="user",u}let s=new y(!0,e.kind);return s.$=o,s.tt=r,s.P=!0,s}static Me(e){var i;let{key:n,kind:r}=e,a=Jt(r),o=Bt(n);if(!a)return y.D(r!=null?r:"unknown","The kind was not valid for the context");if(!o)return y.D(r,"The key for the context was not valid");let s=ft((i=e._meta)==null?void 0:i.privateAttributes),l=new y(!0,r);return l.Q=r==="user",l.v=e,l.tt={[r]:s},l}static Fe(e){if(!(e.key!==void 0&&e.key!==null))return y.D("user","The key for the context was not valid");let i=new y(!0,"user");return i.Q=!0,i.Zt=!0,i.v=Gi(e),i.tt={user:ft(e.privateAttributeNames,!0)},i}static fromLDContext(e){return e?we(e)?y.Me(e):be(e)?y.Ne(e):ke(e)?y.Fe(e):y.D("unknown","Context was not of a valid kind"):y.D("unknown","No context specified. Returning default value")}static toLDContext(e){if(!e.valid)return;let i=e.getContexts();if(!e.P)return i[0][1];let n={kind:"multi"};return i.forEach(r=>{let a=r[0],o=r[1];n[a]=o}),n}valueForKind(e,i=Dt){return e.isKind?this.kinds:y.Re(e,this.Xt(i))}key(e=Dt){var i;return(i=this.Xt(e))==null?void 0:i.key}get isMultiKind(){return this.P}get canonicalKey(){return this.Q?this.v.key:this.P?Object.keys(this.$).sort().map(e=>`${e}:${Kt(this.$[e].key)}`).join(":"):`${this.kind}:${Kt(this.v.key)}`}get kinds(){return this.P?Object.keys(this.$):[this.kind]}get kindsAndKeys(){return this.P?Object.entries(this.$).reduce((e,[i,n])=>(e[i]=n.key,e),{}):{[this.kind]:this.v.key}}privateAttributes(e){var i;return((i=this.tt)==null?void 0:i[e])||[]}getContexts(){return this.P?Object.entries(this.$):[[this.kind,this.v]]}get legacy(){return this.Zt}canonicalUnfilteredJson(){if(this.valid){if(this.gt)return this.gt;try{this.gt=it(y.toLDContext(this))}catch(e){}return this.gt}}};U.UserKind=Dt;var Zi=["key","kind","_meta","anonymous"].map(t=>new z(t,!0)),Yi=["name","ip","firstName","lastName","email","avatar","country"];function Qi(t,e){return t.depth===e.length&&e.every((i,n)=>i===t.getComponent(n))}function Xi(t,e){let i=[],n={},r=[];for(i.push(...Object.keys(t).map(a=>({key:a,ptr:[a],source:t,parent:n,visited:[t]})));i.length;){let a=i.pop(),o=e.find(s=>Qi(s,a.ptr));if(o)r.push(o.redactionName);else{let s=a.source[a.key];s===null?a.parent[a.key]=s:Array.isArray(s)?a.parent[a.key]=[...s]:typeof s=="object"?a.visited.includes(s)||(a.parent[a.key]={},i.push(...Object.keys(s).map(l=>({key:l,ptr:[...a.ptr,l],source:s,parent:a.parent[a.key],visited:[...a.visited,s]})))):a.parent[a.key]=s}}return{cloned:n,excluded:r.sort()}}var tn=class{constructor(t,e){this.Ue=t,this.je=e}filter(t,e=!1){let i=t.getContexts();if(i.length===1)return this.Qt(t,i[0][1],i[0][0],e);let n={kind:"multi"};return i.forEach(([r,a])=>{n[r]=this.Qt(t,a,r,e)}),n}p(t,e,i,n){return(n?Object.keys(e).map(r=>new z(r,!0)):[...this.je,...t.privateAttributes(i)]).filter(r=>!Zi.some(a=>a.compare(r)))}Qt(t,e,i,n){let r=this.Ue||n&&e.anonymous===!0,{cloned:a,excluded:o}=Xi(e,this.p(t,e,i,r));return t.legacy&&Yi.forEach(s=>{s in a&&(a[s]=String(a[s]))}),o.length&&(a._meta||(a._meta={}),a._meta.redactedAttributes=o),a._meta&&(delete a._meta.privateAttributes,Object.keys(a._meta).length===0&&delete a._meta),a}},Ht=30*1e3,en=.5,nn=class{constructor(t,e,i=Math.random){this.Ve=e,this.He=i,this.yt=0,this.te=Math.max(1,t),this.ze=Math.ceil(Math.log2(Ht/this.te))}C(){let t=Math.min(this.yt,this.ze),e=this.te*2**t;return Math.min(e,Ht)}Be(t){return t-Math.trunc(this.He()*en*t)}success(t=Date.now()){this.vt=t}fail(t=Date.now()){this.vt!==void 0&&t-this.vt>this.Ve&&(this.yt=0),this.vt=void 0;let e=this.Be(this.C());return this.yt+=1,e}},qt;(function(t){t[t.Valid=0]="Valid",t[t.Initializing=1]="Initializing",t[t.Interrupted=2]="Interrupted",t[t.Closed=3]="Closed"})(qt||(qt={}));var nt=class extends Error{constructor(t,e,i,n=!0){super(e),this.kind=t,this.status=i,this.name="LaunchDarklyPollingError",this.recoverable=n}},Et=class extends Error{constructor(t,e,i,n=!0){super(e),this.kind=t,this.code=i,this.name="LaunchDarklyStreamingError",this.recoverable=n}},Ga=120*1e3,Za=300*1e3,E;(function(t){t.Unknown="UNKNOWN",t.NetworkError="NETWORK_ERROR",t.ErrorResponse="ERROR_RESPONSE",t.InvalidData="INVALID_DATA"})(E||(E={}));var rt;(function(t){t[t.Disabled=0]="Disabled",t[t.Enabled=1]="Enabled"})(rt||(rt={}));var K;(function(t){t[t.AnalyticsEvents=0]="AnalyticsEvents",t[t.DiagnosticEvent=1]="DiagnosticEvent"})(K||(K={}));var j;(function(t){t[t.Succeeded=0]="Succeeded",t[t.Failed=1]="Failed",t[t.FailedAndMustShutDown=2]="FailedAndMustShutDown"})(j||(j={}));function F(t){if(typeof t=="string")return t;if(t===void 0)return"undefined";if(t===null)return"null";if(Object.prototype.hasOwnProperty.call(t,"toString"))try{return t.toString()}catch(e){}if(typeof t=="bigint")return`${t}n`;try{return JSON.stringify(t)}catch(e){return e instanceof TypeError&&e.message.indexOf("circular")>=0?"[Circular]":"[Not Stringifiable]"}}function rn(t){return typeof t=="symbol"?"NaN":typeof t=="bigint"?`${t}n`:String(Number(t))}function an(t){return typeof t=="symbol"?"NaN":typeof t=="bigint"?`${t}n`:String(parseInt(t,10))}function sn(t){return typeof t=="symbol"?"NaN":String(parseFloat(t))}var gt={s:t=>F(t),d:t=>rn(t),i:t=>an(t),f:t=>sn(t),j:t=>F(t),o:t=>F(t),O:t=>F(t),c:()=>""};function xt(...t){var e;let i=t.shift();if(d.String.is(i)){let n="",r=0;for(;r<i.length;){let a=i.charAt(r);if(a==="%"){if(r+1<i.length){let o=i.charAt(r+1);if(o in gt&&t.length){let s=t.shift();n+=(e=gt[o])==null?void 0:e.call(gt,s)}else o==="%"?n+="%":n+=`%${o}`;r+=2}}else n+=a,r+=1}return t.length&&(n.length&&(n+=" "),n+=t.map(F).join(" ")),n}return t.map(F).join(" ")}var b;(function(t){t[t.debug=0]="debug",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error",t[t.none=4]="none"})(b||(b={}));var on=["debug","info","warn","error","none"],De=class Ee{static get(){return new Ee({})}constructor(e){var i,n,r;if(this.Xe=(n=b[(i=e.level)!=null?i:"info"])!=null?n:b.info,this.Qe=(r=e.name)!=null?r:"LaunchDarkly",this.se=e.formatter,typeof e.destination=="object")this.ae={[b.debug]:e.destination.debug,[b.info]:e.destination.info,[b.warn]:e.destination.warn,[b.error]:e.destination.error};else if(typeof e.destination=="function"){let{destination:a}=e;this.ae={[b.debug]:a,[b.info]:a,[b.warn]:a,[b.error]:a}}}tn(...e){var i;try{return this.se?(i=this.se)==null?void 0:i.call(this,...e):xt(...e)}catch(n){return xt(...e)}}en(e,i){try{e(i)}catch(n){console.error(i)}}k(e,i){var n;if(e>=this.Xe){let r=`${on[e]}: [${this.Qe}]`;try{let a=(n=this.ae)==null?void 0:n[e];a?this.en(a,`${r} ${this.tn(...i)}`):console.error(...i)}catch(a){console.error(...i)}}}error(...e){this.k(b.error,e)}warn(...e){this.k(b.warn,e)}info(...e){this.k(b.info,e)}debug(...e){this.k(b.debug,e)}},ln={error:d.Function,warn:d.Function,info:d.Function,debug:d.Function},xe=class{constructor(t,e){Object.entries(ln).forEach(([i,n])=>{if(!n.is(t[i]))throw new Error(`Provided logger instance must support logger.${i}(...) method`)}),this.t=t,this.nn=e}k(t,e){try{this.t[t](...e)}catch(i){this.nn[t](...e)}}error(...t){this.k("error",t)}warn(...t){this.k("warn",t)}info(...t){this.k("info",t)}debug(...t){this.k("debug",t)}},Ce=t=>{let e=new De({level:"info",destination:console.error,formatter:xt});return t?new xe(t,e):e},k=class{static deprecated(t,e){return`"${t}" is deprecated, please use "${e}"`}static optionBelowMinimum(t,e,i){return`Config option "${t}" had invalid value of ${e}, using minimum of ${i} instead`}static unknownOption(t){return`Ignoring unknown config option "${t}"`}static wrongOptionType(t,e,i){return`Config option "${t}" should be of type ${e}, got ${i}, using default value`}static wrongOptionTypeBoolean(t,e){return`Config option "${t}" should be a boolean, got ${e}, converting to boolean`}static invalidTagValue(t){return`Config option "${t}" must only contain letters, numbers, ., _ or -.`}static tagValueTooLong(t){return`Value of "${t}" was longer than 64 characters and was discarded.`}static partialEndpoint(t){return`You have set custom uris without specifying the ${t} URI; connections may not work properly`}},un=/^(\w|\.|-)+$/,cn=d.stringMatchingRegex(un),hn={is:(t,e)=>cn.is(t)?t.length>64?{valid:!1,message:k.tagValueTooLong(e)}:{valid:!0}:{valid:!1,message:k.invalidTagValue(e)}},dn=class{constructor(t){let e={},i=t==null?void 0:t.application,n=t==null?void 0:t.logger;i&&Object.entries(i).forEach(([a,o])=>{if(o!=null){let{valid:s,message:l}=hn.is(o,`application.${a}`);s?a==="versionName"?e["application-version-name"]=[o]:e[`application-${a}`]=[o]:n==null||n.warn(l)}});let r=Object.keys(e);r.length&&(this.value=r.sort().flatMap(a=>e[a].sort().map(o=>`${a}/${o}`)).join(" "))}},fn=class{constructor(t,e,i){this.platform=i,this.basicConfiguration={tags:e.tags,logger:e.logger,offline:e.offline,serviceEndpoints:e.serviceEndpoints,sdkKey:t}}};function pt(t){return t.replace(/\/+$/,"")}function Ot(t){return t.replace(/^\/+/,"").replace(/\?$/,"")}var at=class Se{constructor(e,i,n=Se.DEFAULT_EVENTS,r="/bulk",a="/diagnostic",o=!0,s){this.streaming=pt(e),this.polling=pt(i),this.events=pt(n),this.analyticsEventPath=r,this.diagnosticEventPath=a,this.includeAuthorizationHeader=o,this.payloadFilterKey=s}};at.DEFAULT_EVENTS="https://events.launchdarkly.com";function It(t,e=[]){if(e.length===0)return t;let i=e.map(({key:n,value:r})=>`${n}=${r}`);return`${t}?${i.join("&")}`}function gn(t,e,i){let n=Ot(e),r=[...i];return t.payloadFilterKey&&r.push({key:"filter",value:t.payloadFilterKey}),It(`${t.streaming}/${n}`,r)}function pn(t,e,i=[]){let n=Ot(e),r=[...i];return t.payloadFilterKey&&r.push({key:"filter",value:t.payloadFilterKey}),It(`${t.polling}/${n}`,r)}function _t(t,e,i=[]){let n=Ot(e);return It(`${t.events}/${n}`,i)}var Re=class extends Error{constructor(t){super(t),this.name="LaunchDarklyUnexpectedResponseError"}},vn=class extends Error{constructor(t){super(t),this.name="LaunchDarklyClientError"}},Oe=class extends Error{constructor(t){super(t),this.name="LaunchDarklyTimeoutError"}};function lt(t){return t>=400&&t<500?t===400||t===408||t===429:!0}function mn(t){return t===413?!0:lt(t)}function yn(t,e){let i,n;return{promise:new Promise((r,a)=>{n=r,i=setTimeout(()=>{let o=`${e} timed out after ${t} seconds.`;a(new Oe(o))},t*1e3)}),cancel:()=>{n(),clearTimeout(i)}}}function Ie(t){return t==null?t:JSON.parse(JSON.stringify(t))}function vt(t){return Math.trunc(t*1e3)}var wn=t=>JSON.stringify(t)==="{}",Lt=(t,e)=>t&&Object.entries(t).reduce((i,[n,r])=>(r&&!wn(r)&&!(e!=null&&e.includes(n))&&(i[n]=typeof r=="object"?Lt(r,e):r),i),{});function X(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;var i,n,r;if(Array.isArray(t)){if(i=t.length,i!=e.length)return!1;for(n=i;n--!==0;)if(!X(t[n],e[n]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(n of t.entries())if(!e.has(n[0]))return!1;for(n of t.entries())if(!X(n[1],e.get(n[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(n of t.entries())if(!e.has(n[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(i=t.length,i!=e.length)return!1;for(n=i;n--!==0;)if(t[n]!==e[n])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if(r=Object.keys(t),i=r.length,i!==Object.keys(e).length)return!1;for(n=i;n--!==0;)if(!Object.prototype.hasOwnProperty.call(e,r[n]))return!1;for(n=i;n--!==0;){var a=r[n];if(!X(t[a],e[a]))return!1}return!0}return t!==t&&e!==e}function bn(t,e,i,n=!0,r="user-agent"){let{userAgentBase:a,version:o,wrapperName:s,wrapperVersion:l}=e.sdkData(),u={[r]:`${a!=null?a:"NodeJSClient"}/${o}`};return n&&(u.authorization=t),s&&(u["x-launchdarkly-wrapper"]=l?`${s}/${l}`:s),i!=null&&i.value&&(u["x-launchdarkly-tags"]=i.value),u}function J(t,e,i){let n;t.status?n=`error ${t.status}${t.status===401?" (invalid SDK key)":""}`:n=`I/O error (${t.message||"unknown error"})`;let r=i!=null?i:"giving up permanently";return`Received ${n} for ${e} - ${r}`}function Le({status:t}){return t?lt(t):!0}var Wt=(t,e)=>e.btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),$e=async(t=1e3)=>new Promise(e=>{setTimeout(e,t)}),kn=class{constructor(t,e,i){this.a=e,this.rn=i,this.bt=[],this.oe=Date.now(),this.ce=this.oe,this.ue={diagnosticId:e.crypto.randomUUID(),sdkKeySuffix:t.length>6?t.substring(t.length-6):t}}createInitEvent(){var t,e,i;let n=this.a.info.sdkData(),r=this.a.info.platformData();return{kind:"diagnostic-init",id:this.ue,creationDate:this.oe,sdk:n,configuration:this.rn,platform:v({name:r.name,osArch:(t=r.os)==null?void 0:t.arch,osName:(e=r.os)==null?void 0:e.name,osVersion:(i=r.os)==null?void 0:i.version},r.additional||{})}}recordStreamInit(t,e,i){let n={timestamp:t,failed:e,durationMillis:i};this.bt.push(n)}createStatsEventAndReset(t,e,i){let n=Date.now(),r={kind:"diagnostic",id:this.ue,creationDate:n,dataSinceDate:this.ce,droppedEvents:t,deduplicatedUsers:e,eventsInLastBatch:i,streamInits:this.bt};return this.bt=[],this.ce=n,r}},Ct;(function(t){t.MalformedFlag="MALFORMED_FLAG",t.UserNotSpecified="USER_NOT_SPECIFIED",t.FlagNotFound="FLAG_NOT_FOUND",t.ClientNotReady="CLIENT_NOT_READY",t.WrongType="WRONG_TYPE"})(Ct||(Ct={}));var Dn=Ct,Te=class{static invalidMetricValue(t){return`The track function was called with a non-numeric "metricValue" (${t}), only numeric metric values are supported.`}};Te.MissingContextKeyNoEvent="Context was unspecified or had no key; event will not be sent";var En=class{constructor(t,e){let{basicConfiguration:i,platform:n}=t,{serviceEndpoints:{analyticsEventPath:r,diagnosticEventPath:a}}=i,{crypto:o,requests:s}=n;this.sn=v({},e),this.le=_t(i.serviceEndpoints,r,[]),this.an=_t(i.serviceEndpoints,a,[]),this._=s,this.cn=o}async et(t,e,i,n){let r={status:j.Succeeded},a=T(v({},this.sn),{"content-type":"application/json"});i&&(a["x-launchdarkly-payload-id"]=i,a["x-launchDarkly-event-schema"]="4");let o;try{let{status:s,headers:l}=await this._.fetch(e,{headers:a,body:JSON.stringify(t),compressBodyIfPossible:!0,method:"POST",keepalive:!0}),u=Date.parse(l.get("date")||"");if(u&&(r.serverTime=u),s<=204)return r;if(o=new Re(J({status:s,message:"some events were dropped"},"event posting")),!lt(s))return mn(s)?r.status=j.Failed:r.status=j.FailedAndMustShutDown,r.error=o,r}catch(s){o=s}return o&&!n?(r.status=j.Failed,r.error=o,r):(await $e(),this.et(t,this.le,i,!1))}async sendEventData(t,e){let i=t===K.AnalyticsEvents?this.cn.randomUUID():void 0,n=t===K.AnalyticsEvents?this.le:this.an;return this.et(e,n,i,!0)}};function st(t){return t.kind==="feature"}function xn(t){return t.kind==="identify"}function Cn(t){return t.kind==="migration_op"}var Sn=class{constructor(t,e,i,n,r,a){this.count=t,this.key=e,this.value=i,this.version=r,this.variation=a,this.default=n}increment(){this.count+=1}};function Rn(t){return`${t.key}:${t.variation!==null&&t.variation!==void 0?t.variation:""}:${t.version!==null&&t.version!==void 0?t.version:""}`}var Pe=class{constructor(t=!1,e){this.un=t,this.S=e,this.q=0,this.nt=0,this.it={},this.rt={}}summarizeEvent(t){if(st(t)&&!t.excludeFromSummaries){this.v||(this.v=t.context);let e=Rn(t),i=this.it[e],n=this.rt[t.key];n||(n=new Set,this.rt[t.key]=n),t.context.kinds.forEach(r=>n.add(r)),i?i.increment():this.it[e]=new Sn(1,t.key,t.value,t.default,t.version,t.variation),(this.q===0||t.creationDate<this.q)&&(this.q=t.creationDate),t.creationDate>this.nt&&(this.nt=t.creationDate)}}getSummary(){var t;let e=Object.values(this.it).reduce((n,r)=>{let a=n[r.key];a||(a={default:r.default,counters:[],contextKinds:[...this.rt[r.key]]},n[r.key]=a);let o={value:r.value,count:r.count};return r.variation!==void 0&&r.variation!==null&&(o.variation=r.variation),r.version!==void 0&&r.version!==null?o.version=r.version:o.unknown=!0,a.counters.push(o),n},{}),i={startDate:this.q,endDate:this.nt,features:e,kind:"summary",context:this.v!==void 0&&this.un?(t=this.S)==null?void 0:t.filter(this.v):void 0};return this.ln(),i}ln(){this.q=0,this.nt=0,this.it={},this.rt={}}},On=class extends Error{constructor(t){super(t),this.name="LaunchDarklyInvalidSDKKeyError"}},In=class{constructor(t,e){this.S=t,this.t=e,this.W={}}summarizeEvent(t){var e;if(st(t)){let i=t.context.canonicalUnfilteredJson();if(!i){t.context.valid&&((e=this.t)==null||e.error("Unable to serialize context, likely the context contains a cycle."));return}let n=this.W[i];n||(this.W[i]=new Pe(!0,this.S),n=this.W[i]),n.summarizeEvent(t)}}getSummaries(){let t=this.W;return this.W={},Object.values(t).map(e=>e.getSummary())}};function tt(t){let e=Math.trunc(t);return e===1?!0:e===0?!1:Math.floor(Math.random()*e)===0}function Ln(t){return t.getSummaries!==void 0}var $n=class{constructor(t,e,i,n,r,a=!0,o=!1){this.e=t,this.st=n,this.x=r,this.at=[],this.de=0,this.Dt=0,this.kt=0,this.St=!1,this.he=0,this.xt=!1,this.Lt=null,this.dn=t.eventsCapacity,this.t=e.basicConfiguration.logger,this.fe=new En(e,i),this.S=new tn(t.allAttributesPrivate,t.privateAttributes.map(s=>new z(s))),o?this.J=new In(this.S,this.t):this.J=new Pe,a&&this.start()}start(){var t,e;if(((t=this.st)==null?void 0:t.flushInterval)!==void 0&&(this.Lt=setInterval(()=>{var i;(i=this.st)==null||i.flush()},this.st.flushInterval*1e3)),this.hn=setInterval(async()=>{var i;try{await this.flush()}catch(n){(i=this.t)==null||i.debug(`Flush failed: ${n}`)}},this.e.flushInterval*1e3),this.x){let i=this.x.createInitEvent();this.pe(i),this.me=setInterval(()=>{let n=this.x.createStatsEventAndReset(this.Dt,this.kt,this.he);this.Dt=0,this.kt=0,this.pe(n)},this.e.diagnosticRecordingInterval*1e3)}(e=this.t)==null||e.debug("Started EventProcessor.")}pe(t){this.fe.sendEventData(K.DiagnosticEvent,t)}close(){clearInterval(this.hn),this.Lt&&clearInterval(this.Lt),this.me&&clearInterval(this.me)}async flush(){var t;if(this.xt)throw new On("Events cannot be posted because a permanent error has been encountered. This is most likely an invalid SDK key. The specific error information is logged independently.");let e=this.at;if(this.at=[],Ln(this.J))this.J.getSummaries().forEach(i=>{Object.keys(i.features).length&&e.push(i)});else{let i=this.J.getSummary();Object.keys(i.features).length&&e.push(i)}e.length&&(this.he=e.length,(t=this.t)==null||t.debug("Flushing %d events",e.length),await this.et(e))}sendEvent(t){var e;if(this.xt)return;if(Cn(t)){if(tt(t.samplingRatio)){let s=T(v({},t),{context:t.context?this.S.filter(t.context):void 0});s.samplingRatio===1&&delete s.samplingRatio,this.ot(s)}return}this.J.summarizeEvent(t);let i=st(t),n=i&&t.trackEvents||!i,r=this.fn(t),a=xn(t),o=(e=this.st)==null?void 0:e.processContext(t.context);o||a||(this.kt+=1),o&&!a&&this.ot(this.Ot({kind:"index",creationDate:t.creationDate,context:t.context,samplingRatio:1},!1)),n&&tt(t.samplingRatio)&&this.ot(this.Ot(t,!1)),r&&tt(t.samplingRatio)&&this.ot(this.Ot(t,!0))}Ot(t,e){switch(t.kind){case"feature":{let i={kind:e?"debug":"feature",creationDate:t.creationDate,context:this.S.filter(t.context,!e),key:t.key,value:t.value,default:t.default};return t.samplingRatio!==1&&(i.samplingRatio=t.samplingRatio),t.prereqOf&&(i.prereqOf=t.prereqOf),t.variation!==void 0&&(i.variation=t.variation),t.version!==void 0&&(i.version=t.version),t.reason&&(i.reason=t.reason),i}case"index":case"identify":{let i={kind:t.kind,creationDate:t.creationDate,context:this.S.filter(t.context)};return t.samplingRatio!==1&&(i.samplingRatio=t.samplingRatio),i}case"custom":{let i={kind:"custom",creationDate:t.creationDate,key:t.key,context:this.S.filter(t.context)};return t.samplingRatio!==1&&(i.samplingRatio=t.samplingRatio),t.data!==void 0&&(i.data=t.data),t.metricValue!==void 0&&(i.metricValue=t.metricValue),t.url!==void 0&&(i.url=t.url),i}case"click":return{kind:"click",creationDate:t.creationDate,contextKeys:t.context.kindsAndKeys,key:t.key,url:t.url,selector:t.selector};case"pageview":return{kind:"pageview",creationDate:t.creationDate,contextKeys:t.context.kindsAndKeys,key:t.key,url:t.url};default:return t}}ot(t){var e;this.at.length<this.dn?(this.at.push(t),this.St=!1):(this.St||(this.St=!0,(e=this.t)==null||e.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),this.Dt+=1)}fn(t){return st(t)&&t.debugEventsUntilDate&&t.debugEventsUntilDate>this.de&&t.debugEventsUntilDate>Date.now()}async et(t){let e=await this.fe.sendEventData(K.AnalyticsEvents,t);if(e.status===j.FailedAndMustShutDown&&(this.xt=!0),e.serverTime&&(this.de=e.serverTime),e.error)throw e.error}},Ne=class{constructor(t,e,i,n,r=1,a){this.context=t,this.key=e,this.data=i,this.metricValue=n,this.samplingRatio=r,this.url=a,this.kind="custom",this.creationDate=Date.now(),this.context=t}},St=class{constructor(t,e,i,n,r,a,o,s,l,u,c,h,g=1){this.withReasons=t,this.context=e,this.key=i,this.samplingRatio=g,this.kind="feature",this.creationDate=Date.now(),this.value=n,this.default=r,a!==void 0&&(this.version=a),o!==void 0&&(this.variation=o),s!==void 0&&(this.trackEvents=s),l!==void 0&&(this.prereqOf=l),u!==void 0&&(this.reason=u),c!==void 0&&(this.debugEventsUntilDate=c),h!==void 0&&(this.excludeFromSummaries=h)}},je=class{constructor(t,e=1){this.context=t,this.samplingRatio=e,this.kind="identify",this.creationDate=Date.now()}},Tn=class{close(){}async flush(){}sendEvent(){}},Pn=class{constructor(t){this.Pt=t}evalEvent(t){var e;return new St(this.Pt,t.context,t.flagKey,t.value,t.defaultVal,t.version,(e=t.variation)!=null?e:void 0,t.trackEvents||t.addExperimentData,t.prereqOfFlagKey,this.Pt||t.addExperimentData?t.reason:void 0,t.debugEventsUntilDate,t.excludeFromSummaries,t.samplingRatio)}unknownFlagEvent(t,e,i){return new St(this.Pt,i,t,e,e,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0)}identifyEvent(t){return new je(t,1)}customEvent(t,e,i,n,r=1){return new Ne(e,t,i!=null?i:void 0,n!=null?n:void 0,r)}},Gt="FDv1Fallback";function Nn(t){return{pn:t,ge:"",useSelector(e){return this.ge=e,this},processFullTransfer(e){let i=[{event:"server-intent",data:{payloads:[{id:Gt,target:1,intentCode:"xfer-full",reason:"payload-missing"}]}}];Object.entries((e==null?void 0:e.flags)||[]).forEach(([n,r])=>{i.push({event:"put-object",data:{kind:"flag",key:n,version:r.version||1,object:r}})}),Object.entries((e==null?void 0:e.segments)||[]).forEach(([n,r])=>{i.push({event:"put-object",data:{kind:"segment",key:n,version:r.version||1,object:r}})}),i.push({event:"payload-transferred",data:{state:this.ge,version:1,id:Gt}}),this.pn.processEvents(i)}}}var S={type:"none"};function Ae(t,e){let i="inactive",n,r="partial",a=[];function o(f,x){var C;return(C=t[f])==null?void 0:C.call(t,x)}function s(){i="inactive",n=void 0,r="partial",a=[]}function l(){i="changes",r="partial",a=[]}function u(){a=[]}function c(f){return!f.id||N(f.target)?(e==null||e.warn(`Ignoring 'none' intent with missing fields: id=${f.id}, target=${f.target}`),S):{type:"payload",payload:{id:f.id,version:f.target,type:"none",updates:[]}}}function h(f){var x;if(!((x=f.payloads)!=null&&x.length))return{type:"error",kind:"MISSING_PAYLOAD",message:"No payload present in server-intent"};let C=f.payloads[0];switch(C==null?void 0:C.intentCode){case"xfer-full":return i="full",a=[],r="full",n=C.id,S;case"xfer-changes":return i="changes",a=[],r="partial",n=C.id,S;case"none":return i="changes",a=[],r="partial",n=C.id,c(C);default:return e==null||e.warn(`Unable to process intent code '${C==null?void 0:C.intentCode}'.`),S}}function g(f){if(i==="inactive"||!n)return e==null||e.warn("Received put-object before server-intent was established. Ignoring."),S;if(!f.kind||!f.key||N(f.version)||!f.object)return e==null||e.warn(`Ignoring put-object with missing fields: kind=${f.kind}, key=${f.key}, version=${f.version}`),S;let x=o(f.kind,f.object);return x?(a.push({kind:f.kind,key:f.key,version:f.version,object:x}),S):(e==null||e.warn(`Unable to process object for kind: '${f.kind}'`),S)}function p(f){return i==="inactive"||!n?(e==null||e.warn("Received delete-object before server-intent was established. Ignoring."),S):!f.kind||!f.key||N(f.version)?(e==null||e.warn(`Ignoring delete-object with missing fields: kind=${f.kind}, key=${f.key}, version=${f.version}`),S):(a.push({kind:f.kind,key:f.key,version:f.version,deleted:!0}),S)}function m(f){if(i==="inactive")return{type:"error",kind:"PROTOCOL_ERROR",message:"A payload transferred has been received without an intent having been established."};if(!n||N(f.state)||N(f.version))return e==null||e.warn(`Ignoring payload-transferred with missing fields: state=${f.state}, version=${f.version}`),s(),S;let x={type:"payload",payload:{id:n,version:f.version,state:f.state,type:r,updates:a}};return l(),x}function w(f){return e==null||e.info(`Goodbye was received from the LaunchDarkly connection with reason: ${f.reason}.`),s(),{type:"goodbye",reason:f.reason}}function D(f){return e==null||e.info(`An issue was encountered receiving updates for payload ${n} with reason: ${f.reason}.`),u(),{type:"serverError",id:f.payload_id,reason:f.reason}}return{get state(){return i},processEvent(f){switch(f.event){case"server-intent":return h(f.data);case"put-object":return g(f.data);case"delete-object":return p(f.data);case"payload-transferred":return m(f.data);case"goodbye":return w(f.data);case"error":return D(f.data);case"heart-beat":return S;default:return{type:"error",kind:"UNKNOWN_EVENT",message:`Received an unknown event of type '${f.event}'`}}},reset(){s()}}}function jn(t){return t==="MISSING_PAYLOAD"||t==="PROTOCOL_ERROR"}var Ve=class{constructor(t,e,i){this.m=e,this.t=i,this.n=[],this.mn=Ae(t,i)}addPayloadListener(t){this.n.push(t)}removePayloadListener(t){let e=this.n.indexOf(t,0);e>-1&&this.n.splice(e,1)}processEvents(t){t.forEach(e=>{var i,n;let r=this.mn.processEvent(e);switch(r.type){case"payload":this.n.forEach(a=>a(r.payload));break;case"error":jn(r.kind)?(i=this.m)==null||i.call(this,E.InvalidData,r.message):(n=this.t)==null||n.warn(r.message);break}})}},An=class{constructor(t,e,i,n){this.m=i,this.t=n,this.V(t,"server-intent"),this.V(t,"put-object"),this.V(t,"delete-object"),this.V(t,"payload-transferred"),this.V(t,"goodbye"),this.V(t,"error"),this.Ct=new Ve(e,i,n)}addPayloadListener(t){this.Ct.addPayloadListener(t)}removePayloadListener(t){this.Ct.removePayloadListener(t)}V(t,e){t.addEventListener(e,async i=>{var n,r,a,o,s;if(i!=null&&i.data){(n=this.t)==null||n.debug(`Received ${e} event. Data is ${i.data}`);try{this.Ct.processEvents([{event:e,data:JSON.parse(i.data)}])}catch(l){(r=this.t)==null||r.error(`Stream received data that was unable to be processed in "${e}" message`),(a=this.t)==null||a.debug(`Data follows: ${i.data}`),(o=this.m)==null||o.call(this,E.InvalidData,"Malformed data in EventStream.")}}else(s=this.m)==null||s.call(this,E.Unknown,"Event from EventStream missing data.")})}};function Vn(t){if(t){let e=Object.keys(t).find(i=>i.toLowerCase()==="x-ld-envid");if(e)return{environmentId:t[e]}}}var Zt="unknown plugin";function ot(t,e){try{return e.getMetadata().name||Zt}catch(i){return t.error("Exception thrown getting metadata for plugin. Unable to get plugin name."),Zt}}function Mn(t,e,i){let n=[];return i.forEach(r=>{var a;try{let o=(a=r.getHooks)==null?void 0:a.call(r,e);o===void 0?t.error(`Plugin ${ot(t,r)} returned undefined from getHooks.`):o&&o.length>0&&n.push(...o)}catch(o){t.error(`Exception thrown getting hooks for plugin ${ot(t,r)}. Unable to get hooks.`)}}),n}function Fn(t,e,i,n){n.forEach(r=>{try{r.register(i,e)}catch(a){t.error(`Exception thrown registering plugin ${ot(t,r)}.`)}})}var L=Object.freeze({__proto__:null,ClientMessages:Te,DiagnosticsManager:kn,ErrorKinds:Dn,EventFactoryBase:Pn,EventProcessor:$n,FDv1PayloadAdaptor:Nn,InputCustomEvent:Ne,InputEvalEvent:St,InputIdentifyEvent:je,NullEventProcessor:Tn,PayloadProcessor:Ve,PayloadStreamReader:An,canonicalize:it,createProtocolHandler:Ae,initMetadataFromHeaders:Vn,isLegacyUser:ke,isMultiKind:be,isSingleKind:we,safeGetHooks:Mn,safeGetName:ot,safeRegisterPlugins:Fn,shouldSample:tt}),Yt={Initializing:"INITIALIZING",Valid:"VALID",Interrupted:"INTERRUPTED",SetOffline:"SET_OFFLINE",Closed:"CLOSED"};function Un(t){return t>=200&&t<=299}var Qt=class extends Error{constructor(t,e){super(t),this.status=e,this.name="LaunchDarklyRequestError"}};function Xt(t,e,i,n,r,a,o,s,l,u){let c,h="GET",g=v({},a);l&&(h="REPORT",g["content-type"]="application/json",c=t);let p=l?i.pathReport(r,t):i.pathGet(r,t),m=[...o!=null?o:[]];s&&m.push({key:"withReasons",value:"true"}),u&&m.push({key:"h",value:u});let w=pn(e,p,m);return{async requestPayload(){let D;try{let f=await n.fetch(w,{method:h,headers:g,body:c});if(Un(f.status))return await f.text();D=f.status}catch(f){throw new Qt(f==null?void 0:f.message)}throw new Qt(`Unexpected status code: ${D}`,D)}}}var te=new Error("Task has already been executed or shed. This is likely an implementation error. The task will not be executed again.");function zn(t,e,i=!1){let n,r=new Promise(s=>{n=(l,u)=>{var c;try{(c=t.after)==null||c.call(t,l,u)}catch(h){e==null||e.error(`Error in after callback: ${h}`)}s(l)}}),a=t.before?t.before():Promise.resolve(void 0),o=!1;return{execute:()=>{o&&(e==null||e.error(te)),o=!0,a.then(s=>{t.execute(s).then(l=>n({status:"complete",result:l},s)).catch(l=>n({status:"error",error:l},s))}).catch(s=>{e==null||e.error(s),n({status:"error",error:s},void 0)})},shed:()=>{o&&(e==null||e.error(te)),o=!0,a.then(s=>{n({status:"shed"},s)})},promise:r,sheddable:i}}function Kn(t){let e,i=[];function n(){if(!e&&i.length>0){let r=i.shift();e=r.promise.finally(()=>{e=void 0,n()}),r.execute()}}return{execute(r,a=!1){var o,s;let l=zn(r,t,a);return e?((o=i[i.length-1])!=null&&o.sheddable&&((s=i.pop())==null||s.shed()),i.push(l)):(e=l.promise.finally(()=>{e=void 0,n()}),l.execute()),l.promise},pendingCount(){return i.length}}}function Me(t){return"validate"in t}function ut(t,e,i,n,r){let a=v({},i);return N(t)?a:d.Object.is(t)?(Object.entries(t).forEach(([o,s])=>{let l=e[o],u=r?`${r}.${o}`:o;if(!l){n==null||n.warn(k.unknownOption(u));return}if(N(s))return;if(Me(l)){let h=l.validate(s,u,n,i[o]);h!==void 0&&(a[o]=h.value);return}if(l.is(s)){a[o]=s;return}let c=l.getType();c==="boolean"?(n==null||n.warn(k.wrongOptionTypeBoolean(u,typeof s)),a[o]=!!s):c==="boolean | undefined | null"?(n==null||n.warn(k.wrongOptionTypeBoolean(u,typeof s)),typeof s!="boolean"&&typeof s!="undefined"&&s!==null&&(a[o]=!!s)):l instanceof me&&d.Number.is(s)?(n==null||n.warn(k.optionBelowMinimum(u,s,l.min)),a[o]=l.min):n==null||n.warn(k.wrongOptionType(u,c,typeof s))}),a):(n==null||n.warn(k.wrongOptionType(r!=null?r:"config","object",typeof t)),a)}function W(t,e){return{is:i=>d.Object.is(i),getType:()=>"object",validate(i,n,r,a){if(!d.Object.is(i)){r==null||r.warn(k.wrongOptionType(n,"object",typeof i));return}let o=e!=null?e:d.Object.is(a)?a:{},s=ut(i,t,o,r,n);return Object.keys(s).length>0?{value:s}:void 0}}}function Fe(t,e){return{is:i=>Array.isArray(i),getType:()=>"array",validate(i,n,r){if(!Array.isArray(i)){r==null||r.warn(k.wrongOptionType(n,"array",typeof i));return}let a=[];return i.forEach((o,s)=>{let l=`${n}[${s}]`;if(N(o)||!d.Object.is(o)){r==null||r.warn(k.wrongOptionType(l,"object",typeof o));return}let u=o,c=u[t],h=typeof c=="string"?e[c]:void 0;if(!h){let g=Object.keys(e).join(" | "),p=typeof c=="string"?c:typeof c;r==null||r.warn(k.wrongOptionType(`${l}.${t}`,g,p));return}a.push(ut(u,h,{},r,l))}),{value:a}}}}function Jn(...t){return{is:e=>t.some(i=>i.is(e)),getType:()=>t.map(e=>e.getType()).join(" | "),validate(e,i,n,r){let a=t.find(o=>o.is(e));if(a)return Me(a)?a.validate(e,i,n,r):{value:e};n==null||n.warn(k.wrongOptionType(i,this.getType(),typeof e))}}}function Bn(t,e){return{is:i=>d.Object.is(i),getType:()=>"object",validate(i,n,r,a){if(N(i))return;if(!d.Object.is(i)){r==null||r.warn(k.wrongOptionType(n,"object",typeof i));return}let o=i,s={},l={};Object.keys(o).forEach(c=>{t.is(c)?(s[c]=o[c],l[c]=e):r==null||r.warn(k.wrongOptionType(n,t.getType(),c))});let u=d.Object.is(a)?a:{};return{value:ut(s,l,u,r,n)}}}}var $t=d.oneOf("cache","polling","streaming"),Rt=d.oneOf("streaming","polling","offline","one-shot","background"),Ue={pollingBaseUri:d.String,streamingBaseUri:d.String},Hn={type:$t},ze={type:$t,pollInterval:d.numberWithMin(30),endpoints:W(Ue)},Ke={type:$t,initialReconnectDelay:d.numberWithMin(1),endpoints:W(Ue)},qn=Fe("type",{cache:Hn,polling:ze,streaming:Ke}),_n=Fe("type",{polling:ze,streaming:Ke}),Wn={initializers:qn,synchronizers:_n},Gn=Bn(Rt,W(Wn)),Zn={lifecycle:d.Boolean,network:d.Boolean},Yn={initialConnectionMode:Rt,backgroundConnectionMode:Rt,automaticModeSwitching:Jn(d.Boolean,W(Zn)),connectionModes:Gn},Qn={initialConnectionMode:"one-shot",backgroundConnectionMode:void 0,automaticModeSwitching:!1};function Xn(t){return{logger:d.Object,maxCachedContexts:d.numberWithMin(0),baseUri:d.String,streamUri:d.String,eventsUri:d.String,capacity:d.numberWithMin(1),diagnosticRecordingInterval:d.numberWithMin(2),flushInterval:d.numberWithMin(2),streamInitialReconnectDelay:d.numberWithMin(0),allAttributesPrivate:d.Boolean,debug:d.Boolean,diagnosticOptOut:d.Boolean,withReasons:d.Boolean,sendEvents:d.Boolean,pollInterval:d.numberWithMin(30),useReport:d.Boolean,privateAttributes:d.StringArray,disableCache:d.Boolean,applicationInfo:d.Object,wrapperName:d.String,wrapperVersion:d.String,payloadFilterKey:d.stringMatchingRegex(/^[a-zA-Z0-9](\w|\.|-)*$/),hooks:d.createTypeArray("Hook[]",{}),inspectors:d.createTypeArray("LDInspection",{}),cleanOldPersistentData:d.Boolean,dataSystem:t!=null&&t.dataSystemDefaults?W(Yn,t.dataSystemDefaults):d.Object}}var tr=300,Je="https://clientsdk.launchdarkly.com",Be="https://clientstream.launchdarkly.com";function er(t){return t instanceof xe?t:Ce(t)}var ir=class{constructor(t={},e={getImplementationHooks:()=>[],credentialType:"mobileKey"}){var i,n,r;this.logger=Ce(),this.baseUri=Je,this.eventsUri=at.DEFAULT_EVENTS,this.streamUri=Be,this.maxCachedContexts=5,this.disableCache=!1,this.capacity=100,this.diagnosticRecordingInterval=900,this.flushInterval=30,this.streamInitialReconnectDelay=1,this.allAttributesPrivate=!1,this.debug=!1,this.diagnosticOptOut=!1,this.sendEvents=!0,this.sendLDHeaders=!0,this.useReport=!1,this.withReasons=!1,this.privateAttributes=[],this.pollInterval=tr,this.hooks=[],this.inspectors=[],this.logger=er(t.logger);let a=Xn({dataSystemDefaults:e.dataSystemDefaults}),o=ut(t,a,{},this.logger);Object.entries(o).forEach(([s,l])=>{s!=="logger"&&(this[s]=l)}),this.serviceEndpoints=new at(this.streamUri,this.baseUri,this.eventsUri,e.analyticsEventPath,e.diagnosticEventPath,e.includeAuthorizationHeader,t.payloadFilterKey),this.useReport=(i=t.useReport)!=null?i:!1,this.tags=new dn({application:this.applicationInfo,logger:this.logger}),this.userAgentHeaderName=(n=e.userAgentHeaderName)!=null?n:"user-agent",this.trackEventModifier=(r=e.trackEventModifier)!=null?r:(s=>s),this.credentialType=e.credentialType,this.getImplementationHooks=e.getImplementationHooks}};async function Tt(t,e){if(t.digest)return t.digest(e);if(t.asyncDigest)return t.asyncDigest(e);throw new Error("Platform must implement digest or asyncDigest")}var He=async(t,{crypto:e,storage:i})=>{let n=await(i==null?void 0:i.get(t));return n||(n=e.randomUUID(),await(i==null?void 0:i.set(t,n))),n};function qe(t){return async e=>Tt(t.createHash("sha256").update(e),"base64")}var $=async t=>t;async function G(t){return(await Promise.all(t.map(e=>e.transform(e.value)))).join("_")}async function nr(t,e){return G([{value:"LaunchDarkly",transform:$},{value:e,transform:qe(t)}])}async function rr(t){return G([{value:"LaunchDarkly",transform:$},{value:"AnonymousKeys",transform:$},{value:t,transform:$}])}async function ar(t){return G([{value:"LaunchDarkly",transform:$},{value:"ContextKeys",transform:$},{value:t,transform:$}])}async function sr(t){return G([{value:t,transform:$},{value:"ContextIndex",transform:$}])}async function _e(t,e,i){return G([{value:e,transform:$},{value:i.canonicalKey,transform:qe(t)}])}var{isLegacyUser:or,isSingleKind:mt,isMultiKind:ee}=L,We="1.0",lr=t=>{let e=t,{kind:i}=e,n=ge(e,["kind"]);return{kind:"multi",[i]:n}},ur=async({crypto:t,info:e},{applicationInfo:i})=>{var n;let{ld_application:r}=e.platformData(),a=(n=Lt(r))!=null?n:{},o=(i==null?void 0:i.id)||(a==null?void 0:a.id);if(o){let s=(i==null?void 0:i.version)||(a==null?void 0:a.version),l=(i==null?void 0:i.name)||(a==null?void 0:a.name),u=(i==null?void 0:i.versionName)||(a==null?void 0:a.versionName);return a=v(v(v(T(v({},a),{id:o}),s?{version:s}:{}),l?{name:l}:{}),u?{versionName:u}:{}),a.key=await Tt(t.createHash("sha256").update(o),"base64"),a.envAttributesVersion=a.envAttributesVersion||We,a}},cr=async t=>{var e,i,n,r;let{ld_device:a,os:o}=t.info.platformData(),s=(e=Lt(a))!=null?e:{},l=(o==null?void 0:o.name)||((i=s.os)==null?void 0:i.name),u=(o==null?void 0:o.version)||((n=s.os)==null?void 0:n.version),c=(r=s.os)==null?void 0:r.family;if((l||u||c)&&(s.os=v(v(v({},l?{name:l}:{}),u?{version:u}:{}),c?{family:c}:{})),Object.keys(s).filter(h=>h!=="key"&&h!=="envAttributesVersion").length){let h=await ar("ld_device");return s.key=await He(h,t),s.envAttributesVersion=s.envAttributesVersion||We,s}},hr=async(t,e,i)=>{if(or(t))return t;let n,r;if(mt(t)&&t.kind!=="ld_application"||ee(t)&&!t.ld_application?n=await ur(e,i):i.logger.warn("Not adding ld_application environment attributes because it already exists."),mt(t)&&t.kind!=="ld_device"||ee(t)&&!t.ld_device?r=await cr(e):i.logger.warn("Not adding ld_device environment attributes because it already exists."),n||r){let a=mt(t)?lr(t):t;return v(v(v({},a),n?{ld_application:n}:{}),r?{ld_device:r}:{})}return t};function dr(){let t,e;return{set(i,n){t=i,e=n},getContext(){return e},getUnwrappedContext(){return t},newIdentificationPromise(){let i,n;return{identifyPromise:new Promise((r,a)=>{i=r,n=a}),identifyResolve:i,identifyReject:n}},hasContext(){return e!==void 0},hasValidContext(){return this.hasContext()&&e.valid}}}var{isLegacyUser:fr,isMultiKind:gr,isSingleKind:pr}=L,Pt=async(t,e,i)=>{let{anonymous:n,key:r}=e;if(n&&!r){let a=await rr(t);e.key=await He(a,i)}},vr=async(t,e)=>{await Pt(t.kind,t,e)},mr=async(t,e)=>{let i=t,{kind:n}=i,r=ge(i,["kind"]);return Promise.all(Object.entries(r).map(([a,o])=>Pt(a,o,e)))},yr=async(t,e)=>{await Pt("user",t,e)},wr=async(t,e)=>{let i=Ie(t);return pr(i)&&await vr(i,e),gr(i)&&await mr(i,e),fr(i)&&await yr(i,e),i},br=t=>({customBaseURI:t.serviceEndpoints.polling!==Je,customStreamURI:t.serviceEndpoints.streaming!==Be,customEventsURI:t.serviceEndpoints.events!==at.DEFAULT_EVENTS,eventsCapacity:t.capacity,eventsFlushIntervalMillis:vt(t.flushInterval),reconnectTimeMillis:vt(t.streamInitialReconnectDelay),diagnosticRecordingIntervalMillis:vt(t.diagnosticRecordingInterval),allAttributesPrivate:t.allAttributesPrivate,usingSecureMode:!1,bootstrapMode:!1}),kr=(t,e,i)=>{if(e.sendEvents&&!e.diagnosticOptOut)return new L.DiagnosticsManager(t,i,br(e))};function ie(t,e){return{value:e!=null?e:null,variationIndex:null,reason:{kind:"ERROR",errorKind:t}}}function ne(t,e,i){return v({value:t,variationIndex:e!=null?e:null},i!==void 0&&{reason:i})}var Dr=(t,e,i,n,r)=>{if(e.sendEvents)return new L.EventProcessor(T(v({},e),{eventsCapacity:e.capacity}),new fn(t,e,i),n,void 0,r,!1,!0)},re=class extends L.EventFactoryBase{evalEventClient(t,e,i,n,r,a){let{trackEvents:o,debugEventsUntilDate:s,trackReason:l,flagVersion:u,version:c,variation:h}=n;return super.evalEvent({addExperimentData:l,context:r,debugEventsUntilDate:s,defaultVal:i,flagKey:t,reason:a,trackEvents:!!o,value:e,variation:h,version:u!=null?u:c})}},ae="_freshness";async function Er(t,e){let i=e.canonicalUnfilteredJson();if(i)return Tt(t.createHash("sha256").update(i),"base64")}function xr(t){return t!==null&&typeof t=="object"&&typeof t.version=="number"}async function Cr(t,e,i,n,r){let a=await _e(e,i,n),o=await t.get(a),s=!1;if(o==null){if(o=await t.get(n.canonicalKey),o==null)return;s=!0}try{let l=JSON.parse(o);if(l===null||typeof l!="object"){r==null||r.warn("Cached flag data is not a valid object");return}let u=Object.entries(l),c=u.find(([,h])=>!xr(h));if(c){r==null||r.warn(`Discarding cached flags due to invalid entry: ${c[0]}`);return}return{flags:u.reduce((h,[g,p])=>(h[g]=p,h),{}),storageKey:a,fromLegacyKey:s}}catch(l){r==null||r.warn(`Could not parse cached flag evaluations from persistent storage: ${l.message}`);return}}var yt=class Ge{constructor(){this.container={index:new Array}}static fromJson(e){let i=new Ge;try{i.container=JSON.parse(e)}catch(n){}return i}toJson(){return JSON.stringify(this.container)}notice(e,i){let n=this.container.index.find(r=>r.id===e);n===void 0?this.container.index.push({id:e,timestamp:i}):n.timestamp=i}prune(e){let i=Math.max(e,0);return this.container.index.length>i?(this.container.index.sort((n,r)=>n.timestamp-r.timestamp),this.container.index.splice(0,this.container.index.length-i)):[]}},Sr=class{constructor(t,e,i,n,r,a,o,s=()=>Date.now()){this.a=t,this.It=e,this.ct=i,this.ye=n,this.A=r,this.y=a,this.t=o,this.gn=s,this.ve=sr(this.It)}async init(t,e){this.y.init(t,e),await this.At(t)}async upsert(t,e,i){return this.y.upsert(t,e,i)?(await this.At(t),!0):!1}async applyChanges(t,e,i){this.y.applyChanges(t,e,i),await this.At(t)}async loadCached(t){if(this.ye||this.ct<=0||!this.a.storage)return!1;let e=await Cr(this.a.storage,this.a.crypto,this.It,t,this.t);if(!e)return!1;e.fromLegacyKey&&(await this.a.storage.set(e.storageKey,JSON.stringify(e.flags)),await this.a.storage.clear(t.canonicalKey));let i=Object.entries(e.flags).reduce((n,[r,a])=>(n[r]={version:a.version,flag:a},n),{});return this.y.initCached(t,i),this.t.debug("Loaded cached flag evaluations from persistent storage"),!0}async yn(t,e,i){var n;let r=await Er(this.a.crypto,e);if(r===void 0){this.t.error("Could not serialize context for freshness tracking");return}let a={timestamp:i,contextHash:r};await((n=this.a.storage)==null?void 0:n.set(`${t}${ae}`,JSON.stringify(a)))}async vn(){var t;if(this.H!==void 0)return this.H;let e=await((t=this.a.storage)==null?void 0:t.get(await this.ve));if(!e)return this.H=new yt,this.H;try{this.H=yt.fromJson(e),this.t.debug("Loaded context index from persistent storage")}catch(i){this.t.warn(`Could not load index from persistent storage: ${i.message}`),this.H=new yt}return this.H}async At(t){var e,i;if(this.ye)return;let n=this.gn(),r=await this.vn(),a=await _e(this.a.crypto,this.It,t);this.ct>0&&r.notice(a,n);let o=r.prune(this.ct),s=this.ct<=0||o.some(h=>h.id===a);if(await Promise.all(o.flatMap(h=>{var g,p;return[(g=this.a.storage)==null?void 0:g.clear(h.id),(p=this.a.storage)==null?void 0:p.clear(`${h.id}${ae}`)]})),await((e=this.a.storage)==null?void 0:e.set(await this.ve,r.toJson())),s)return;let l=this.A.getAll(),u=Object.entries(l).reduce((h,[g,p])=>(p.flag!==null&&p.flag!==void 0&&(h[g]=p.flag),h),{}),c=JSON.stringify(u);await((i=this.a.storage)==null?void 0:i.set(a,c));try{await this.yn(a,t,n)}catch(h){this.t.warn(`Failed to store freshness data: ${h.message}`)}}};function Rr(){let t={};return{init(e){t=Object.entries(e).reduce((i,[n,r])=>(i[n]=r,i),{})},insertOrUpdate(e,i){t[e]=i},get(e){if(Object.prototype.hasOwnProperty.call(t,e))return t[e]},getAll(){return t},applyChanges(e,i){i==="full"?this.init(e):i==="partial"&&Object.entries(e).forEach(([n,r])=>{t[n]=r})}}}function se(t,e){let i=[];return Object.entries(t).forEach(([n,r])=>{let a=e[n];(!a||!X(r,a))&&i.push(n)}),Object.keys(e).forEach(n=>{t[n]||i.push(n)}),i}function Or(t,e){let i=t,n=e,r,a=new Array;return{handleFlagChanges(o,s){r?a.forEach(l=>{try{l(r,o,s)}catch(u){}}):n.warn("Received a change event without an active context. Changes will not be propagated.")},init(o,s){r=o;let l=i.getAll();i.init(s);let u=se(l,s);u.length>0&&this.handleFlagChanges(u,"init")},initCached(o,s){(r==null?void 0:r.canonicalKey)!==o.canonicalKey&&this.init(o,s)},applyChanges(o,s,l){r=o;let u=i.getAll();if(i.applyChanges(s,l),l==="full"){let c=se(u,s);c.length>0&&this.handleFlagChanges(c,"init")}else if(l==="partial"){let c=Object.keys(s);c.length>0&&this.handleFlagChanges(c,"patch")}},upsert(o,s,l){if((r==null?void 0:r.canonicalKey)!==o.canonicalKey)return n.warn("Received an update for an inactive context."),!1;let u=i.get(s);return u!==void 0&&u.version>=l.version?!1:(i.insertOrUpdate(s,l),this.handleFlagChanges([s],"patch"),!0)},on(o){a.push(o)},off(o){let s=a.indexOf(o);s>-1&&a.splice(s,1)}}}var Ir=class{constructor(t,e,i,n,r,a=()=>Date.now()){this.A=Rr(),this.y=Or(this.A,r),this.ut=this.wn(t,e,i,n,r,a)}async wn(t,e,i,n,r,a=()=>Date.now()){let o=await nr(t.crypto,e);return new Sr(t,o,i,n,this.A,this.y,r,a)}get(t){return this.r&&Object.prototype.hasOwnProperty.call(this.r,t)?this.Tt(this.r[t]):this.A.get(t)}getAll(){return this.r?v(v({},this.A.getAll()),Object.entries(this.r).reduce((t,[e,i])=>(t[e]=this.Tt(i),t),{})):this.A.getAll()}presetFlags(t){this.A.init(t)}setBootstrap(t,e){this.y.init(t,e)}async init(t,e){return(await this.ut).init(t,e)}async upsert(t,e,i){return(await this.ut).upsert(t,e,i)}async loadCached(t){return(await this.ut).loadCached(t)}async applyChanges(t,e,i){return(await this.ut).applyChanges(t,e,i)}on(t){this.y.on(t)}off(t){this.y.off(t)}Tt(t){return{flag:{value:t,version:0},version:0}}setOverride(t,e){this.r||(this.r={}),this.r[t]=e,this.y.handleFlagChanges([t],"override")}removeOverride(t){!this.r||!Object.prototype.hasOwnProperty.call(this.r,t)||(delete this.r[t],Object.keys(this.r).length===0&&(this.r=void 0),this.y.handleFlagChanges([t],"override"))}clearAllOverrides(){if(this.r){let t=v({},this.r);this.r=void 0,this.y.handleFlagChanges(Object.keys(t),"override")}}getAllOverrides(){if(!this.r)return{};let t={};return Object.entries(this.r).forEach(([e,i])=>{t[e]=this.Tt(i)}),t}getDebugOverride(){return{setOverride:this.setOverride.bind(this),removeOverride:this.removeOverride.bind(this),clearAllOverrides:this.clearAllOverrides.bind(this),getAllOverrides:this.getAllOverrides.bind(this)}}},oe="unknown hook",Ze="beforeEvaluation",Ye="afterEvaluation",Lr="afterTrack";function Z(t,e,i,n,r){try{return n()}catch(a){return t==null||t.error(`An error was encountered in "${e}" of the "${i}" hook: ${a}`),r}}function Y(t,e){try{return e.getMetadata().name||oe}catch(i){return t.error("Exception thrown getting metadata for hook. Unable to get hook name."),oe}}function $r(t,e,i){return e.map(n=>Z(t,Ze,Y(t,n),()=>{var r,a;return(a=(r=n==null?void 0:n.beforeEvaluation)==null?void 0:r.call(n,i,{}))!=null?a:{}},{}))}function Tr(t,e,i,n,r){for(let a=e.length-1;a>=0;a-=1){let o=e[a],s=n[a];Z(t,Ye,Y(t,o),()=>{var l,u;return(u=(l=o==null?void 0:o.afterEvaluation)==null?void 0:l.call(o,i,s,r))!=null?u:{}},{})}}function Pr(t,e,i){return e.map(n=>Z(t,Ze,Y(t,n),()=>{var r,a;return(a=(r=n==null?void 0:n.beforeIdentify)==null?void 0:r.call(n,i,{}))!=null?a:{}},{}))}function Nr(t,e,i,n,r){for(let a=e.length-1;a>=0;a-=1){let o=e[a],s=n[a];Z(t,Ye,Y(t,o),()=>{var l,u;return(u=(l=o==null?void 0:o.afterIdentify)==null?void 0:l.call(o,i,s,r))!=null?u:{}},{})}}function jr(t,e,i){for(let n=e.length-1;n>=0;n-=1){let r=e[n];Z(t,Lr,Y(t,r),()=>{var a;return(a=r==null?void 0:r.afterTrack)==null?void 0:a.call(r,i)},void 0)}}var Ar=class{constructor(t,e){this.t=t,this.R=[],this.R.push(...e)}withEvaluation(t,e,i,n){if(this.R.length===0)return n();let r=[...this.R],a={flagKey:t,context:e,defaultValue:i},o=$r(this.t,r,a),s=n();return Tr(this.t,r,a,o,s),s}identify(t,e){let i=[...this.R],n={context:t,timeout:e},r=Pr(this.t,i,n);return a=>{Nr(this.t,i,n,r,a)}}addHook(t){this.R.push(t)}afterTrack(t){if(this.R.length===0)return;let e=[...this.R];jr(this.t,e,t)}};function Vr(t){return{getMetadata(){return{name:"LaunchDarkly-Inspector-Adapter"}},afterEvaluation:(e,i,n)=>(t.onFlagUsed(e.flagKey,n,e.context),i),afterIdentify(e,i,n){return t.onIdentityChanged(e.context),i}}}function Mr(t,e){return`an inspector: "${e}" of an invalid type (${t}) was configured`}function Fr(t,e){return`an inspector: "${e}" of type: "${t}" generated an exception`}function Ur(t,e){let i=!1,n={method:(...r)=>{try{t.method(...r)}catch(a){i||(i=!0,e.warn(Fr(n.type,n.name)))}},type:t.type,name:t.name,synchronous:t.synchronous};return n}var Qe="flag-used",Xe="flag-details-changed",ti="flag-detail-changed",ei="client-identity-changed",zr=[Qe,Xe,ti,ei];function Kr(t,e){let i=zr.includes(t.type)&&t.method&&typeof t.method=="function";return i||e.warn(Mr(t.type,t.name)),i}var Jr=class{constructor(t,e){this.z=[];let i=t.filter(n=>Kr(n,e));this.z=i.map(n=>Ur(n,e))}hasInspectors(){return this.z.length!==0}onFlagUsed(t,e,i){this.z.forEach(n=>{n.type===Qe&&n.method(t,e,i)})}onFlagsChanged(t){this.z.forEach(e=>{e.type===Xe&&e.method(t)})}onFlagChanged(t,e){this.z.forEach(i=>{i.type===ti&&i.method(t,e)})}onIdentityChanged(t){this.z.forEach(e=>{e.type===ei&&e.method(t)})}},Br=class{constructor(t){this.t=t,this.n=new Map}on(t,e){var i,n;if(typeof t!="string"){(i=this.t)==null||i.warn("Only string event names are supported.");return}this.n.has(t)?(n=this.n.get(t))==null||n.push(e):this.n.set(t,[e])}off(t,e){let i=this.n.get(t);if(i){if(e){let n=i.filter(r=>r!==e);n.length===0?this.n.delete(t):this.n.set(t,n);return}this.n.delete(t)}}En(t,e,...i){var n;try{t(...i)}catch(r){(n=this.t)==null||n.error(`Encountered error invoking handler for "${e}", detail: "${r}"`)}}emit(t,...e){let i=this.n.get(t);i==null||i.forEach(n=>this.En(n,t,...e))}eventNames(){return[...this.n.keys()]}listenerCount(t){var e,i;return(i=(e=this.n.get(t))==null?void 0:e.length)!=null?i:0}};function Hr(t,e,i){let n=e.info.sdkData(),r;i.applicationInfo&&(i.applicationInfo.id&&(r=r!=null?r:{},r.id=i.applicationInfo.id),i.applicationInfo.version&&(r=r!=null?r:{},r.version=i.applicationInfo.version),i.applicationInfo.name&&(r=r!=null?r:{},r.name=i.applicationInfo.name),i.applicationInfo.versionName&&(r=r!=null?r:{},r.versionName=i.applicationInfo.versionName));let a={name:n.userAgentBase,version:n.version};n.wrapperName&&(a.wrapperName=n.wrapperName),n.wrapperVersion&&(a.wrapperVersion=n.wrapperVersion);let o={sdk:a,[i.credentialType]:t};return r&&(o.application=r),o}var{ClientMessages:le,ErrorKinds:ue}=L,qr=5,_r=class{constructor(t,e,i,n,r,a){var o;if(this.sdkKey=t,this.autoEnvAttributes=e,this.platform=i,this.u=dr(),this.$t=15,this.T=new re(!1),this.lt=new re(!0),this.Rt=!1,this.bn=Kn(),!t)throw new Error("You must configure the client with a client-side SDK key");if(!i.encoding)throw new Error("Platform must implement Encoding because btoa is required.");this.e=new ir(n,a),this.logger=this.e.logger,this.we=bn(this.sdkKey,this.platform.info,this.e.tags,this.e.serviceEndpoints.includeAuthorizationHeader,this.e.userAgentHeaderName),this.N=new Ir(this.platform,t,this.e.maxCachedContexts,(o=this.e.disableCache)!=null?o:!1,this.e.logger),this.x=kr(t,this.e,i),this.E=Dr(t,this.e,i,this.we,this.x),this.emitter=new Br,this.emitter.on("error",(l,u)=>{this.logger.error(`error: ${u}, context: ${JSON.stringify(l)}`)}),this.N.on((l,u,c)=>{this.Dn(u,c);let h=U.toLDContext(l);this.emitter.emit("change",h,u),u.forEach(g=>{this.emitter.emit(`change:${g}`,h)})}),this.dataManager=r(this.N,this.e,this.we,this.emitter,this.x);let s=[...this.e.hooks];if(this.environmentMetadata=Hr(this.sdkKey,this.platform,this.e),this.e.getImplementationHooks(this.environmentMetadata).forEach(l=>{s.push(l)}),this.M=new Ar(this.logger,s),this.Y=new Jr(this.e.inspectors,this.logger),this.Y.hasInspectors()&&this.M.addHook(Vr(this.Y)),n.cleanOldPersistentData&&a!=null&&a.getLegacyStorageKeys&&this.platform.storage)try{this.logger.debug("Cleaning old persistent data."),Promise.all(a.getLegacyStorageKeys().map(l=>{var u;return(u=this.platform.storage)==null?void 0:u.clear(l)})).catch(l=>{this.logger.error(`Error cleaning old persistent data: ${l}`)}).finally(()=>{this.logger.debug("Cleaned old persistent data.")})}catch(l){this.logger.error(`Error cleaning old persistent data: ${l}`)}}allFlags(){return Object.entries(this.N.getAll()).reduce((t,[e,i])=>(i.flag!==null&&i.flag!==void 0&&!i.flag.deleted&&(t[e]=i.flag.value),t),{})}async close(){var t;await this.flush(),(t=this.E)==null||t.close(),this.dataManager.close(),this.logger.debug("Closed event processor and data source.")}async flush(){var t;try{await((t=this.E)==null?void 0:t.flush()),this.logger.debug("Successfully flushed event processor.")}catch(e){return this.logger.error(`Error flushing event processor: ${e}.`),{error:e,result:!1}}return{result:!0}}getContext(){return this.u.hasContext()?Ie(this.u.getUnwrappedContext()):void 0}getInternalContext(){return this.u.getContext()}presetFlags(t){this.N.presetFlags(t)}async identify(t,e){let i=await this.identifyResult(t,e);if(i.status==="error")throw i.error;if(i.status==="timeout"){let n=new Oe(`identify timed out after ${i.timeout} seconds.`);throw this.logger.error(n.message),n}}async identifyResult(t,e){var i,n;let r=(i=e==null?void 0:e.timeout)!=null?i:qr,a=(e==null?void 0:e.timeout)===void 0&&(e==null?void 0:e.noTimeout)===!0;r>this.$t&&this.logger.warn(`The identify function was called with a timeout greater than ${this.$t} seconds. We recommend a timeout of less than ${this.$t} seconds.`);let o=this.bn.execute({before:async()=>{let l=await wr(t,this.platform);this.autoEnvAttributes===rt.Enabled&&(l=await hr(l,this.platform,this.e));let u=U.fromLDContext(l);if(u.valid){let c=this.M.identify(l,e==null?void 0:e.timeout);return{context:l,checkedContext:u,afterIdentify:c}}return{context:l,checkedContext:u}},execute:async l=>{var u;let{context:c,checkedContext:h}=l;if(!h.valid){let w=new Error("Context was unspecified or had no key");return this.emitter.emit("error",c,w),Promise.reject(w)}this.u.set(c,h),(u=this.E)==null||u.sendEvent(this.T.identifyEvent(h));let{identifyPromise:g,identifyResolve:p,identifyReject:m}=this.u.newIdentificationPromise();return this.logger.debug(`Identifying ${JSON.stringify(h)}`),await this.dataManager.identify(p,m,h,e),g},after:async(l,u)=>{var c,h,g;l.status==="complete"?(c=u==null?void 0:u.afterIdentify)==null||c.call(u,{status:"completed"}):l.status==="shed"?(h=u==null?void 0:u.afterIdentify)==null||h.call(u,{status:"shed"}):l.status==="error"&&((g=u==null?void 0:u.afterIdentify)==null||g.call(u,{status:"error"}))}},(n=e==null?void 0:e.sheddable)!=null?n:!1).then(l=>{if(l.status==="error"){let c={status:"error",error:l.error};return this.maybeSetInitializationResult({status:"failed",error:l.error}),c}if(l.status==="shed")return{status:"shed"};let u={status:"completed"};return this.maybeSetInitializationResult({status:"complete"}),u});if(a)return o;let s=new Promise(l=>{setTimeout(()=>{l({status:"timeout",timeout:r})},r*1e3)});return Promise.race([o,s])}maybeSetInitializationResult(t){this.initializeResult===void 0&&(this.initializeResult=t,this.emitter.emit("ready"),t.status==="complete"&&this.emitter.emit("initialized"),this.initResolve&&(this.initResolve(t),this.initResolve=void 0))}waitForInitialization(t){var e;let i=(e=t==null?void 0:t.timeout)!=null?e:5;return this.initializeResult?Promise.resolve(this.initializeResult):this.initializedPromise?this.promiseWithTimeout(this.initializedPromise,i):(this.initializedPromise||(this.initializedPromise=new Promise(n=>{this.initResolve=n})),this.promiseWithTimeout(this.initializedPromise,i))}promiseWithTimeout(t,e){let i=yn(e,"waitForInitialization");return Promise.race([t.then(n=>(i.cancel(),n)),i.promise.then(()=>({status:"complete"})).catch(()=>({status:"timeout"}))]).catch(n=>{var r;return(r=this.logger)==null||r.error(n.message),{status:"failed",error:n}})}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}track(t,e,i){var n,r;if(!this.u.hasValidContext()){this.logger.warn(le.MissingContextKeyNoEvent);return}i!==void 0&&!d.Number.is(i)&&((n=this.logger)==null||n.warn(le.invalidMetricValue(typeof i))),(r=this.E)==null||r.sendEvent(this.e.trackEventModifier(this.T.customEvent(t,this.u.getContext(),e,i))),this.M.afterTrack({key:t,context:this.u.getUnwrappedContext(),data:e,metricValue:i})}dt(t,e,i,n){var r,a,o,s,l;let u=this.u.hasContext();u||(r=this.logger)==null||r.warn("Flag evaluation called before client is fully initialized, data from this evaulation could be stale.");let c=this.u.getContext(),h=this.N.get(t);if(h===void 0||h.flag.deleted){let f=e!=null?e:null;return(a=this.logger)==null||a.warn(`Unknown feature flag "${t}"; returning default value ${f}.`),u&&((o=this.E)==null||o.sendEvent(this.T.unknownFlagEvent(t,f,c))),ie(ue.FlagNotFound,e)}let{reason:g,value:p,variation:m,prerequisites:w}=h.flag;if(n){let[f,x]=n(p);if(!f){u&&((s=this.E)==null||s.sendEvent(i.evalEventClient(t,e,e,h.flag,c,g)));let C=new vn(`Wrong type "${x}" for feature flag "${t}"; returning default value`);return this.emitter.emit("error",this.u.getUnwrappedContext(),C),ie(ue.WrongType,e)}}let D=ne(p,m,g);return p==null&&(this.logger.debug("Result value is null. Providing default value."),D.value=e),w==null||w.forEach(f=>{this.dt(f,void 0,this.T)}),u&&((l=this.E)==null||l.sendEvent(i.evalEventClient(t,p,e,h.flag,c,g))),D}variation(t,e){let{value:i}=this.M.withEvaluation(t,this.u.getUnwrappedContext(),e,()=>this.dt(t,e,this.T));return i}variationDetail(t,e){return this.M.withEvaluation(t,this.u.getUnwrappedContext(),e,()=>this.dt(t,e,this.lt))}B(t,e,i,n){return this.M.withEvaluation(t,this.u.getUnwrappedContext(),e,()=>this.dt(t,e,i,n))}boolVariation(t,e){return this.B(t,e,this.T,i=>[d.Boolean.is(i),d.Boolean.getType()]).value}jsonVariation(t,e){return this.variation(t,e)}numberVariation(t,e){return this.B(t,e,this.T,i=>[d.Number.is(i),d.Number.getType()]).value}stringVariation(t,e){return this.B(t,e,this.T,i=>[d.String.is(i),d.String.getType()]).value}boolVariationDetail(t,e){return this.B(t,e,this.lt,i=>[d.Boolean.is(i),d.Boolean.getType()])}numberVariationDetail(t,e){return this.B(t,e,this.lt,i=>[d.Number.is(i),d.Number.getType()])}stringVariationDetail(t,e){return this.B(t,e,this.lt,i=>[d.String.is(i),d.String.getType()])}jsonVariationDetail(t,e){return this.variationDetail(t,e)}addHook(t){this.M.addHook(t)}setEventSendingEnabled(t,e){var i,n,r,a;this.Rt!==t&&(this.Rt=t,t?(this.logger.debug("Starting event processor"),(i=this.E)==null||i.start()):e?((n=this.logger)==null||n.debug("Flushing event processor before disabling."),this.flush().then(()=>{var o,s;this.Rt||((o=this.logger)==null||o.debug("Stopping event processor."),(s=this.E)==null||s.close())})):((r=this.logger)==null||r.debug("Stopping event processor."),(a=this.E)==null||a.close()))}sendEvent(t){var e;(e=this.E)==null||e.sendEvent(t)}getDebugOverrides(){var t,e;return(e=(t=this.N).getDebugOverride)==null?void 0:e.call(t)}Dn(t,e){if(!this.Y.hasInspectors())return;let i={};t.forEach(n=>{let r=this.N.get(n);if(r!=null&&r.flag&&!r.flag.deleted){let{reason:a,value:o,variation:s}=r.flag;i[n]=ne(o,s,a)}else i[n]={value:void 0,variationIndex:null}}),e==="init"?this.Y.onFlagsChanged(i):e==="patch"&&Object.entries(i).forEach(([n,r])=>{this.Y.onFlagChanged(n,r)})}};function Wr(t,e,i){i.forEach(n=>{var r;try{(r=n.registerDebug)==null||r.call(n,e)}catch(a){t.error(`Exception thrown registering plugin ${L.safeGetName(t,n)}.`)}})}function ii(t,e){let i=Object.keys(e),n="$flagsState",r="$valid",a=e[n];!a&&i.length&&t.warn("LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."),e[r]===!1&&t.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");let o={};return i.forEach(s=>{if(s!==n&&s!==r){let l;a&&a[s]?l=v({value:e[s]},a[s]):l={value:e[s],version:0},o[s]={version:l.version,flag:l}}}),o}function Gr(t){return{polling:()=>({pathGet(e,i){return`/sdk/evalx/${t}/contexts/${Wt(i,e)}`},pathReport(e,i){return`/sdk/evalx/${t}/context`},pathPost(e,i){throw new Error("Post for FDv1 unsupported.")},pathPing(e,i){throw new Error("Ping for polling unsupported.")}}),streaming:()=>({pathGet(e,i){return`/eval/${t}/${Wt(i,e)}`},pathReport(e,i){return`/eval/${t}`},pathPost(e,i){throw new Error("Post for FDv1 unsupported.")},pathPing(e,i){return`/ping/${t}`}})}}function Zr(t,e,i){return{async handlePut(n,r){i.debug(`Got PUT: ${Object.keys(r)}`);let a=Object.entries(r).reduce((o,[s,l])=>(o[s]={version:l.version,flag:l},o),{});await t.init(n,a),e.requestStateUpdate("VALID")},async handlePatch(n,r){i.debug(`Got PATCH ${JSON.stringify(r,null,2)}`),t.upsert(n,r.key,{version:r.version,flag:r})},async handleDelete(n,r){i.debug(`Got DELETE ${JSON.stringify(r,null,2)}`),t.upsert(n,r.key,{version:r.version,flag:T(v({},r),{deleted:!0,flagVersion:0,value:void 0,variation:0,trackEvents:!1})})},handleStreamingError(n){e.reportError(n.kind,n.message,n.code,n.recoverable)},handlePollingError(n){e.reportError(n.kind,n.message,n.status,n.recoverable)}}}function Yr(t,e=()=>Date.now()){let i="CLOSED",n=e(),r;function a(){return{state:i,stateSince:n,lastError:r}}function o(s,l=!1){let u=s==="INTERRUPTED"&&i==="INITIALIZING"?"INITIALIZING":s,c=i!==u;c&&(i=u,n=e()),(c||l)&&t.emit("dataSourceStatus",a())}return{get status(){return a()},requestStateUpdate(s){o(s)},reportError(s,l,u,c=!1){r={kind:s,message:l,statusCode:u,time:e()},o(c?"INTERRUPTED":"CLOSED",!0)}}}function ce(t){t==null||t.debug("Poll completed after the processor was closed. Skipping processing.")}var Qr=class{constructor(t,e,i,n,r){this.kn=t,this.Sn=e,this.xn=i,this.m=n,this.t=r,this.h=!1}async Ee(){var t,e,i,n,r,a,o;if(this.h)return;let s=h=>{var g,p,m;(g=this.t)==null||g.error("Polling received invalid data"),(p=this.t)==null||p.debug(`Invalid JSON follows: ${h}`),(m=this.m)==null||m.call(this,new nt(E.InvalidData,"Malformed JSON data in polling response"))};(t=this.t)==null||t.debug("Polling LaunchDarkly for feature flag updates");let l=Date.now();try{let h=await this.kn.requestPayload();try{if(this.h){ce(this.t);return}let g=JSON.parse(h);try{(e=this.xn)==null||e.call(this,g)}catch(p){(i=this.t)==null||i.error(`Exception from data handler: ${p}`)}}catch(g){s(h)}}catch(h){if(this.h){ce(this.t);return}let g=h;if(g.status!==void 0&&!lt(g.status)){(n=this.t)==null||n.error(J(h,"polling request")),(r=this.m)==null||r.call(this,new nt(E.ErrorResponse,g.message,g.status));return}(a=this.t)==null||a.error(J(h,"polling request","will retry"))}let u=Date.now()-l,c=Math.max(this.Sn*1e3-u,0);(o=this.t)==null||o.debug("Elapsed: %d ms, sleeping for %d ms",u,c),this.Nt=setTimeout(()=>{this.Ee()},c)}start(){this.Ee()}stop(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0),this.h=!0}close(){this.stop()}},Xr=(t,e,i,n)=>{i==null||i.error(`Stream received invalid data in "${t}" message`),i==null||i.debug(`Invalid JSON follows: ${e}`),n==null||n(new Et(E.InvalidData,"Malformed JSON data in event stream"))};function ta(t,e){e==null||e.debug(`Received ${t} event after processor was closed. Skipping processing.`)}function he(t){t==null||t.debug("Ping completed after processor was closed. Skipping processing.")}var ea=class{constructor(t,e,i,n,r,a,o,s,l){var u;this.Ln=t,this.Mt=e,this.n=i,this._=n,this.On=a,this.x=o,this.m=s,this.t=l,this.h=!1;let c;e.useReport&&!n.getEventSourceCapabilities().customMethod?c=e.paths.pathPing(r,t):c=e.useReport?e.paths.pathReport(r,t):e.paths.pathGet(r,t);let h=[...(u=e.queryParameters)!=null?u:[]];this.Mt.withReasons&&h.push({key:"withReasons",value:"true"}),this._=n,this.be=v({},e.baseHeaders),this.t=l,this.Pn=gn(e.serviceEndpoints,c,h)}De(){this.ht=Date.now()}Ft(t){this.ht&&this.x&&this.x.recordStreamInit(this.ht,!t,Date.now()-this.ht),this.ht=void 0}Cn(t){var e,i,n;return Le(t)?((n=this.t)==null||n.warn(J(t,"streaming request","will retry")),this.Ft(!1),this.De(),!0):(this.Ft(!1),(e=this.m)==null||e.call(this,new Et(E.ErrorResponse,t.message,t.status,!1)),(i=this.t)==null||i.error(J(t,"streaming request")),!1)}start(){this.De();let t;this.Mt.useReport?(this.be["content-type"]="application/json",t={method:"REPORT",body:this.Ln}):t={};let e=this._.createEventSource(this.Pn,T(v({headers:this.be},t),{errorFilter:i=>this.Cn(i),initialRetryDelayMillis:this.Mt.initialRetryDelayMillis,readTimeoutMillis:300*1e3,retryResetIntervalMillis:60*1e3}));this.ke=e,e.onclose=()=>{var i;(i=this.t)==null||i.info("Closed LaunchDarkly stream connection")},e.onerror=()=>{},e.onopen=()=>{var i;(i=this.t)==null||i.info("Opened LaunchDarkly stream connection")},e.onretrying=i=>{var n;(n=this.t)==null||n.info(`Will retry stream connection in ${i.delayMillis} milliseconds`)},this.n.forEach(({deserializeData:i,processJson:n},r)=>{e.addEventListener(r,a=>{var o,s;if(this.h){ta(r,this.t);return}if((o=this.t)==null||o.debug(`Received ${r} event`),a!=null&&a.data){this.Ft(!0);let{data:l}=a,u=i(l);if(!u){Xr(r,l,this.t,this.m);return}n(u)}else(s=this.m)==null||s.call(this,new Et(E.InvalidData,"Unexpected payload from event stream"))})}),e.addEventListener("ping",async()=>{var i,n,r,a,o,s,l;(i=this.t)==null||i.debug("Got PING, going to poll LaunchDarkly for feature flag updates");try{let u=await this.On.requestPayload();try{if(this.h){he(this.t);return}let c=JSON.parse(u);try{(n=this.n.get("put"))==null||n.processJson(c)}catch(h){(r=this.t)==null||r.error(`Exception from data handler: ${h}`)}}catch(c){(a=this.t)==null||a.error("Polling after ping received invalid data"),(o=this.t)==null||o.debug(`Invalid JSON follows: ${u}`),(s=this.m)==null||s.call(this,new nt(E.InvalidData,"Malformed JSON data in ping polling response"))}}catch(u){if(this.h){he(this.t);return}let c=u;(l=this.m)==null||l.call(this,new nt(E.ErrorResponse,c.message,c.status))}})}stop(){var t;(t=this.ke)==null||t.close(),this.ke=void 0,this.h=!0}close(){this.stop()}},ia=class{constructor(t,e,i,n,r,a,o,s,l){this.platform=t,this.flagManager=e,this.credential=i,this.config=n,this.getPollingPaths=r,this.getStreamingPaths=a,this.baseHeaders=o,this.emitter=s,this.diagnosticsManager=l,this.closed=!1,this.logger=n.logger,this.dataSourceStatusManager=Yr(s),this.G=Zr(e,this.dataSourceStatusManager,this.config.logger)}setConnectionParams(t){this.In=t}createPollingProcessor(t,e,i,n,r){let a=new Qr(i,this.config.pollInterval,async o=>{await this.G.handlePut(e,o),n==null||n()},o=>{this.emitter.emit("error",t,o),this.G.handlePollingError(o),r==null||r(o)},this.logger);this.updateProcessor=this.Se(a,this.dataSourceStatusManager)}createStreamingProcessor(t,e,i,n,r){var a;let o=new ea(JSON.stringify(t),{credential:this.credential,serviceEndpoints:this.config.serviceEndpoints,paths:this.getStreamingPaths(),baseHeaders:this.baseHeaders,initialRetryDelayMillis:this.config.streamInitialReconnectDelay*1e3,withReasons:this.config.withReasons,useReport:this.config.useReport,queryParameters:(a=this.In)==null?void 0:a.queryParameters},this.createStreamListeners(e,n),this.platform.requests,this.platform.encoding,i,this.diagnosticsManager,s=>{this.emitter.emit("error",t,s),this.G.handleStreamingError(s),r==null||r(s)},this.logger);this.updateProcessor=this.Se(o,this.dataSourceStatusManager)}createStreamListeners(t,e){let i=new Map;return i.set("put",{deserializeData:JSON.parse,processJson:async n=>{await this.G.handlePut(t,n),e==null||e()}}),i.set("patch",{deserializeData:JSON.parse,processJson:async n=>{this.G.handlePatch(t,n)}}),i.set("delete",{deserializeData:JSON.parse,processJson:async n=>{this.G.handleDelete(t,n)}}),i}Se(t,e){return{start:()=>{e.requestStateUpdate("INITIALIZING"),t.start()},stop:()=>{t.stop(),e.requestStateUpdate("CLOSED")},close:()=>{t.close(),e.requestStateUpdate("CLOSED")}}}close(){var t;(t=this.updateProcessor)==null||t.close(),this.closed=!0}};function ct(){return typeof document!==void 0}function Nt(){return typeof window!==void 0}function ni(t,e,i){return ct()?(document.addEventListener(t,e,i),()=>{document.removeEventListener(t,e,i)}):()=>{}}function ri(t,e,i){return ct()?(window.addEventListener(t,e,i),()=>{window.removeEventListener(t,e,i)}):()=>{}}function _(){return Nt()?window.location.href:""}function na(){return Nt()?window.location.search:""}function ra(){return Nt()?window.location.hash:""}function aa(){if(typeof crypto!==void 0)return crypto;throw Error("Access to a web crypto API is required")}function sa(){return ct()?document.visibilityState:"visibile"}function oa(t){if(ct())return document.querySelectorAll(t)}var la="[BrowserDataManager]",ua=class extends ia{constructor(t,e,i,n,r,a,o,s,l,u){super(t,e,i,n,a,o,s,l,u),this.Hn=r,this.Z=void 0,this.Ut=!1,this.Z=r.streaming}L(t,...e){this.logger.debug(`${la} ${t}`,...e)}async identify(t,e,i,n){if(this.closed){this.L("Identify called after data manager was closed.");return}this.context=i;let r=n;r!=null&&r.hash?this.setConnectionParams({queryParameters:[{key:"h",value:r.hash}]}):this.setConnectionParams(),this.jt=r==null?void 0:r.hash,r!=null&&r.bootstrap?this.An(i,r,t):(await this.flagManager.loadCached(i)&&this.L("Identify - Flags loaded from cache. Continuing to initialize via a poll."),await this.Tn(i,t,e)),this.xe(),this.l()}async $n(t){let e=JSON.stringify(U.toLDContext(t)),i=Xt(e,this.config.serviceEndpoints,this.getPollingPaths(),this.platform.requests,this.platform.encoding,this.baseHeaders,[],this.config.withReasons,this.config.useReport,this.jt),n=3,r;for(let a=0;a<=n;a+=1)try{return await i.requestPayload()}catch(o){if(!Le(o))throw o;r=o,a<n&&(this.L(J(o,"initial poll request","will retry")),await $e(1e3))}throw r}async Tn(t,e,i){var n,r;try{this.dataSourceStatusManager.requestStateUpdate(Yt.Initializing);let a=await this.$n(t);try{let o=this.createStreamListeners(t,e).get("put");o.processJson(o.deserializeData(a))}catch(o){this.dataSourceStatusManager.reportError(E.InvalidData,(n=o.message)!=null?n:"Could not parse poll response")}}catch(a){this.dataSourceStatusManager.reportError(E.NetworkError,(r=a.message)!=null?r:"unexpected network error",a.status),i(a)}}An(t,e,i){let{bootstrapParsed:n}=e;n||(n=ii(this.logger,e.bootstrap)),this.flagManager.setBootstrap(t,n),this.dataSourceStatusManager.requestStateUpdate(Yt.Valid),this.L("Identify - Initialization completed from bootstrap"),i()}setForcedStreaming(t){this.Z=t,this.l()}setAutomaticStreamingState(t){this.Ut=t,this.l()}l(){let t=this.Z||this.Ut&&this.Z===void 0;this.L(`Updating streaming state. forced(${this.Z}) automatic(${this.Ut})`),t?this.Rn():this.xe()}xe(){var t;this.updateProcessor&&this.L("Stopping update processor."),(t=this.updateProcessor)==null||t.close(),this.updateProcessor=void 0}Rn(){if(this.updateProcessor){this.L("Update processor already active. Not changing state.");return}if(!this.context){this.L("Context not set, not starting update processor.");return}this.L("Starting update processor."),this.Nn(this.context)}Nn(t,e,i){var n;let r=U.toLDContext(t);(n=this.updateProcessor)==null||n.close();let a=JSON.stringify(U.toLDContext(t)),o=Xt(a,this.config.serviceEndpoints,this.getPollingPaths(),this.platform.requests,this.platform.encoding,this.baseHeaders,[],this.config.withReasons,this.config.useReport,this.jt);this.createStreamingProcessor(r,t,o,e,i),this.updateProcessor.start()}};function ca(t){let e=ni("visibilitychange",()=>{sa()==="hidden"&&t()}),i=ri("pagehide",t);return()=>{e(),i()}}function wt(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function ha(t,e,i,n){let r=((t.kind==="substring"||t.kind==="regex")&&n.includes("/")?e:e.replace(n,"")).replace(i,"");switch(t.kind){case"exact":return new RegExp(`^${wt(t.url)}/?$`).test(e);case"canonical":return new RegExp(`^${wt(t.url)}/?$`).test(r);case"substring":return new RegExp(`.*${wt(t.substring)}.*$`).test(r);case"regex":return new RegExp(t.pattern).test(r);default:return!1}}function da(t,e){let i=[];return e.forEach(n=>{let r=t.target,{selector:a}=n,o=oa(a);for(;r&&o!=null&&o.length;){for(let s=0;s<o.length;s+=1)if(r===o[s]){i.push(n);break}r=r.parentNode}}),i}var fa=class{constructor(t,e){let i=t.filter(a=>{var o;return(o=a.urls)==null?void 0:o.some(s=>ha(s,_(),na(),ra()))}),n=i.filter(a=>a.kind==="pageview"),r=i.filter(a=>a.kind==="click");if(n.forEach(a=>e(a)),r.length){let a=o=>{da(o,r).forEach(s=>{e(s)})};this.Le=ni("click",a)}}close(){var t;(t=this.Le)==null||t.call(this)}},ga=300,pa=class{constructor(t){this.Vt=_();let e=()=>{let n=_();n!==this.Vt&&(this.Vt=n,t())};this.Ht=setInterval(e,ga);let i=ri("popstate",e);this.Oe=()=>{i()}}close(){var t;this.Ht&&clearInterval(this.Ht),(t=this.Oe)==null||t.call(this)}},va=class{constructor(t,e,i,n,r,a=o=>new pa(o)){this._=e,this.Un=n,this.Fn=r,this.ft=[],this.Ce=!1,this.pt=`${i}/sdk/goals/${t}`,this.Pe=a(()=>{this.Bt()})}async initialize(){await this.Mn(),this.Bt()}startTracking(){this.Ce=!0,this.Bt()}Bt(){var t;this.Ce&&((t=this.zt)==null||t.close(),this.ft&&this.ft.length&&(this.zt=new fa(this.ft,e=>{this.Fn(_(),e)})))}async Mn(){try{let t=await this._.fetch(this.pt);this.ft=await t.json()}catch(t){this.Un(new Re(`Encountered error fetching goals: ${t}`))}}close(){var t,e;(t=this.Pe)==null||t.close(),(e=this.zt)==null||e.close()}};function ma(t){return t.kind==="click"}var ya=2,ai={fetchGoals:!0,eventUrlTransformer:t=>t,streaming:void 0,plugins:[]},wa={fetchGoals:d.Boolean,eventUrlTransformer:d.Function,streaming:d.Boolean,plugins:d.createTypeArray("LDPlugin",{})};function ba(t){var e;let i=v({},t);return(e=i.flushInterval)!=null||(i.flushInterval=ya),i}function ka(t){let e=ba(t);return Object.keys(ai).forEach(i=>{delete e[i]}),e}function Da(t,e){let i=v({},ai);return Object.entries(wa).forEach(n=>{let[r,a]=n,o=t[r];o!==void 0&&(a.is(o)?i[r]=o:e.warn(k.wrongOptionType(r,a.getType(),typeof o)))}),i}var Ea=class{constructor(t,e){switch(this.jn=t,this.Ie=[],e){case"sha1":this.Gt="SHA-1";break;case"sha256":this.Gt="SHA-256";break;default:throw new Error(`Algorithm is not supported ${e}`)}}async asyncDigest(t){let e=this.Ie.join(""),i=new TextEncoder().encode(e),n=await this.jn.subtle.digest(this.Gt,i);switch(t){case"base64":return btoa(String.fromCharCode(...new Uint8Array(n)));case"hex":return[...new Uint8Array(n)].map(r=>r.toString(16).padStart(2,"0")).join("");default:throw new Error(`Encoding is not supported ${t}`)}}update(t){return this.Ie.push(t),this}},xa={start:0,end:3},Ca={start:4,end:5},bt={start:6,end:7},kt={start:8,end:8},Sa={start:9,end:9},Ra={start:10,end:15};function Oa(){if(crypto&&crypto.getRandomValues){let e=new Uint8Array(16);return crypto.getRandomValues(e),[...e.values()]}let t=[];for(let e=0;e<16;e+=1)t.push(Math.floor(Math.random()*256));return t}function M(t,e){let i="";for(let n=e.start;n<=e.end;n+=1)i+=t[n].toString(16).padStart(2,"0");return i}function Ia(t){return t[kt.start]=(t[kt.start]|128)&191,t[bt.start]=t[bt.start]&15|64,`${M(t,xa)}-${M(t,Ca)}-${M(t,bt)}-${M(t,kt)}${M(t,Sa)}-${M(t,Ra)}`}function La(){let t=Oa();return Ia(t)}function $a(){return typeof crypto!==void 0&&typeof crypto.randomUUID=="function"?crypto.randomUUID():La()}var Ta=class{createHash(t){return new Ea(aa(),t)}randomUUID(){return $a()}};function Pa(t){let e=Array.from(t,i=>String.fromCodePoint(i)).join("");return btoa(e)}var Na=class{btoa(t){return Pa(new TextEncoder().encode(t))}},ja=class{constructor(t){this.e=t}platformData(){return{name:"JS"}}sdkData(){let t={name:"@launchdarkly/js-client-sdk",version:"4.4.1",userAgentBase:"JSClient"};return this.e.wrapperName&&(t.wrapperName=this.e.wrapperName),this.e.wrapperVersion&&(t.wrapperVersion=this.e.wrapperVersion),t}},Aa=class{constructor(t,e){this.pt=t,this.n={},this.C=new nn(e.initialRetryDelayMillis,e.retryResetIntervalMillis),this.Ae=e.errorFilter,this.Te()}Te(){this.K=new EventSource(this.pt),this.K.onopen=()=>{var t;this.C.success(),(t=this.onopen)==null||t.call(this)},this.K.onerror=t=>{var e;this.w(t),(e=this.onerror)==null||e.call(this,t)},Object.entries(this.n).forEach(([t,e])=>{e.forEach(i=>{var n;(n=this.K)==null||n.addEventListener(t,i)})})}addEventListener(t,e){var i,n,r;(n=(i=this.n)[t])!=null||(i[t]=[]),this.n[t].push(e),(r=this.K)==null||r.addEventListener(t,e)}close(){var t,e;clearTimeout(this.Kt),this.Kt=void 0,(t=this.K)==null||t.close(),(e=this.onclose)==null||e.call(this)}Vn(t){var e;(e=this.onretrying)==null||e.call(this,{delayMillis:t}),this.Kt=setTimeout(()=>{this.Te()},t)}w(t){this.close(),!(typeof t.status=="number"&&!this.Ae(t))&&this.Vn(this.C.fail())}},Va=class{fetch(t,e){return fetch(t,e)}createEventSource(t,e){return new Aa(t,e)}getEventSourceCapabilities(){return{customMethod:!1,readTimeout:!1,headers:!1}}};function si(){return typeof localStorage!="undefined"}function Ma(){if(!si())return[];let t=[];for(let e=0;e<localStorage.length;e+=1){let i=localStorage.key(e);i&&t.push(i)}return t}var Fa=class{constructor(t){this.t=t}async clear(t){var e;try{localStorage.removeItem(t)}catch(i){(e=this.t)==null||e.error(`Error clearing key from localStorage: ${t}, reason: ${i}`)}}async get(t){var e;try{let i=localStorage.getItem(t);return i!=null?i:null}catch(i){return(e=this.t)==null||e.error(`Error getting key from localStorage: ${t}, reason: ${i}`),null}}async set(t,e){var i;try{localStorage.setItem(t,e)}catch(n){(i=this.t)==null||i.error(`Error setting key in localStorage: ${t}, reason: ${n}`)}}},Ua=class{constructor(t,e){this.encoding=new Na,this.crypto=new Ta,this.requests=new Va,si()&&(this.storage=new Fa(t)),this.info=new ja(e)}},za=class extends _r{constructor(t,e,i={},n){var r;let{logger:a,debug:o}=i,s=a!=null?a:new De({destination:{debug:console.debug,info:console.info,warn:console.warn,error:console.error},level:o?"debug":"info"}),l=(r=i.baseUri)!=null?r:"https://clientsdk.launchdarkly.com",u=n!=null?n:new Ua(s,i),c=Da(i,s),h=ka(T(v({},i),{logger:s})),{eventUrlTransformer:g}=c,p=Gr(t);super(t,e,u,h,(m,w,D,f,x)=>new ua(u,m,t,w,c,p.polling,p.streaming,D,f,x),{getLegacyStorageKeys:()=>Ma().filter(m=>m.startsWith(`ld:${t}:`)),analyticsEventPath:`/events/bulk/${t}`,diagnosticEventPath:`/events/diagnostic/${t}`,includeAuthorizationHeader:!1,highTimeoutThreshold:5,userAgentHeaderName:"x-launchdarkly-user-agent",dataSystemDefaults:Qn,trackEventModifier:m=>new L.InputCustomEvent(m.context,m.key,m.data,m.metricValue,m.samplingRatio,g(_())),getImplementationHooks:m=>L.safeGetHooks(s,m,c.plugins),credentialType:"clientSideId"}),this.setEventSendingEnabled(!0,!1),this.Wt=c.plugins,c.fetchGoals&&(this.qt=new va(t,u.requests,l,m=>{s.error(m.message)},(m,w)=>{let D=this.getInternalContext();if(!D)return;let f=g(m);ma(w)?this.sendEvent({kind:"click",url:f,samplingRatio:1,key:w.key,creationDate:Date.now(),context:D,selector:w.selector}):this.sendEvent({kind:"pageview",url:f,samplingRatio:1,key:w.key,creationDate:Date.now(),context:D})}),this.qt.initialize(),c.automaticBackgroundHandling&&ca(()=>this.flush()))}registerPlugins(t){L.safeRegisterPlugins(this.logger,this.environmentMetadata,t,this.Wt||[]);let e=this.getDebugOverrides();e&&Wr(this.logger,e,this.Wt||[])}setInitialContext(t){this.Jt=t}async identify(t,e){return super.identify(t,e)}async identifyResult(t,e){var i;if(!this.X)return this.logger.error("Client must be started before it can identify a context, did you forget to call start()?"),{status:"error",error:new Error("Identify called before start")};let n=v({},e);(e==null?void 0:e.sheddable)===void 0&&(n.sheddable=!0);let r=await super.identifyResult(t,n);return(i=this.qt)==null||i.startTracking(),r}start(t){var e,i;if(this.initializeResult)return Promise.resolve(this.initializeResult);if(this.X)return this.X;if(!this.Jt)return this.logger.error("Initial context not set"),Promise.resolve({status:"failed",error:new Error("Initial context not set")});let n=T(v({},(e=t==null?void 0:t.identifyOptions)!=null?e:{}),{sheddable:!1});if(t!=null&&t.bootstrap&&!n.bootstrap&&(n.bootstrap=t.bootstrap),n!=null&&n.bootstrap)try{n.bootstrapParsed||(n.bootstrapParsed=ii(this.logger,n.bootstrap)),this.presetFlags(n.bootstrapParsed)}catch(r){this.logger.error("Failed to bootstrap data",r)}return this.initializedPromise||(this.initializedPromise=new Promise(r=>{this.initResolve=r})),this.X=this.promiseWithTimeout(this.initializedPromise,(i=t==null?void 0:t.timeout)!=null?i:5),this.identifyResult(this.Jt,n),this.X}setStreaming(t){this.dataManager.setForcedStreaming(t)}$e(){let t=this.dataManager,e=this.emitter.eventNames().some(i=>i.startsWith("change:")||i==="change");t.setAutomaticStreamingState(e)}on(t,e){super.on(t,e),this.$e()}off(t,e){super.off(t,e),this.$e()}};function Ka(t,e,i,n={},r){let a=new za(t,i,n,r);a.setInitialContext(e);let o={variation:(s,l)=>a.variation(s,l),variationDetail:(s,l)=>a.variationDetail(s,l),boolVariation:(s,l)=>a.boolVariation(s,l),boolVariationDetail:(s,l)=>a.boolVariationDetail(s,l),numberVariation:(s,l)=>a.numberVariation(s,l),numberVariationDetail:(s,l)=>a.numberVariationDetail(s,l),stringVariation:(s,l)=>a.stringVariation(s,l),stringVariationDetail:(s,l)=>a.stringVariationDetail(s,l),jsonVariation:(s,l)=>a.jsonVariation(s,l),jsonVariationDetail:(s,l)=>a.jsonVariationDetail(s,l),track:(s,l,u)=>a.track(s,l,u),on:(s,l)=>a.on(s,l),off:(s,l)=>a.off(s,l),flush:()=>a.flush(),setStreaming:s=>a.setStreaming(s),identify:(s,l)=>a.identifyResult(s,l),getContext:()=>a.getContext(),close:()=>a.close(),allFlags:()=>a.allFlags(),addHook:s=>a.addHook(s),waitForInitialization:s=>a.waitForInitialization(s),logger:a.logger,start:s=>a.start(s)};return a.registerPlugins(o),o}function oi(t,e,i){return Ka(t,e,rt.Disabled,i)}function Ja(){return typeof window=="undefined"}function Q(t){return{value:t,kind:"NO Evaluation Reason"}}function Ba(){return{allFlags:()=>({}),boolVariation:(t,e)=>e,boolVariationDetail:(t,e)=>Q(e),close:()=>Promise.resolve(),flush:()=>Promise.resolve({result:!0}),getContext:()=>{},getInitializationState:()=>"unknown",getInitializationError:()=>{},identify:()=>Promise.resolve({status:"completed"}),jsonVariation:(t,e)=>e,jsonVariationDetail:(t,e)=>Q(e),logger:{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},numberVariation:(t,e)=>e,numberVariationDetail:(t,e)=>Q(e),off:()=>{},on:()=>{},onContextChange:()=>()=>{},onInitializationStatusChange:()=>()=>{},setStreaming:()=>{},start:()=>Promise.resolve({status:"failed",error:new Error("Server-side client cannot be used to start")}),stringVariation:(t,e)=>e,stringVariationDetail:(t,e)=>Q(e),track:()=>{},variation:(t,e)=>e!=null?e:null,variationDetail:(t,e)=>{let i=e!=null?e:null;return Q(i)},waitForInitialization:()=>Promise.resolve({status:"failed",error:new Error("Server-side client cannot be used to wait for initialization")}),addHook:()=>{},shouldUseCamelCaseFlagKeys:()=>!0}}function ht(t,e,i){var u;if(Ja())return Ba();let n=(u=i==null?void 0:i.useCamelCaseFlagKeys)!=null?u:!0,r=oi(t,e,i),a="unknown",o=new Set,s=new Set,l;return V(A({},r),{start:c=>a!=="unknown"?r.start(c):(a="initializing",r.start(c).then(h=>(a=h.status,l=h,s.forEach(g=>g(h)),h))),identify:(...c)=>r.identify(...c).then(h=>{if(h.status==="completed"){let g=r.getContext();g&&o.forEach(p=>p(g))}return h}),getInitializationState:()=>a,getInitializationError:()=>(l==null?void 0:l.status)==="failed"?l.error:void 0,onContextChange:c=>(o.add(c),()=>{o.delete(c)}),onInitializationStatusChange:c=>(l&&c(l),s.add(c),()=>{s.delete(c)}),shouldUseCamelCaseFlagKeys:()=>n})}function jt(t,e){var r;let i=(r=e==null?void 0:e.Provider)!=null?r:R.Provider;return({children:a})=>{var l;let[o,s]=(0,H.useState)({client:t,context:(l=t.getContext())!=null?l:void 0,initializedState:t.getInitializationState(),error:t.getInitializationError()});return(0,H.useEffect)(()=>{let u=!0,c=t.onInitializationStatusChange(g=>{u&&s(p=>p.initializedState===g.status?p:V(A({},p),{initializedState:g.status,error:g.status==="failed"?g.error:void 0}))}),h=t.onContextChange(g=>{u&&s(p=>V(A({},p),{context:g}))});return()=>{u=!1,c(),h()}},[]),H.default.createElement(i,{value:o},a)}}function li(t,e,i){let{deferInitialization:n,startOptions:r,reactContext:a,ldOptions:o,bootstrap:s}=i!=null?i:{},l=ht(t,e,o);if(!n){let u=s?V(A({},r),{bootstrap:s}):r;l.start(u)}return jt(l,a)}var O=require("react");function ui(t){return t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[-._\s]+/).filter(Boolean).map((e,i)=>{let n=e.toLowerCase();return i===0?n:n.charAt(0).toUpperCase()+n.slice(1)}).join("")}function Ha(t,e){let i=new Map,n=t.shouldUseCamelCaseFlagKeys(),r={},a={};return Object.keys(e).filter(o=>o.indexOf("$")!==0).forEach(o=>{if(n){let s=ui(o);r[s]=e[o],a[s]=o}else r[o]=e[o]}),new Proxy(r,{get(o,s,l){var g;let u=Reflect.get(o,s,l);if(typeof s=="symbol"||!Object.prototype.hasOwnProperty.call(o,s))return u;if(u===void 0)return;if(i.has(s))return i.get(s);let c=n&&(g=a[s])!=null?g:s,h=t.variation(c,u);return i.set(s,h),h}})}function ci(t){let{client:e,context:i}=(0,O.useContext)(t!=null?t:R);(0,O.useEffect)(()=>{e.logger.warn("[LaunchDarkly] useFlags is deprecated and will be removed in a future major version.")},[]);let[n,r]=(0,O.useState)(()=>e.allFlags()),a=(0,O.useRef)(!1);return(0,O.useEffect)(()=>{a.current&&r(e.allFlags()),a.current=!0;let o=()=>r(e.allFlags());return e.on("change",o),()=>e.off("change",o)},[e,i]),(0,O.useMemo)(()=>Ha(e,n),[e,n,i])}var hi=require("react");function di(t){let{initializedState:e,error:i}=(0,hi.useContext)(t!=null?t:R);return e==="failed"?{status:"failed",error:i}:{status:e}}var fi=require("react");function gi(t){let{client:e}=(0,fi.useContext)(t!=null?t:R);return e}var P=require("react");function I(t,e,i,n){let{client:r,context:a}=(0,P.useContext)(n!=null?n:R),o=(0,P.useRef)(e);o.current=e;let s=(0,P.useRef)(i);s.current=i;let l=(0,P.useRef)(!1),[u,c]=(0,P.useState)(()=>i(r,t,e));return(0,P.useEffect)(()=>{l.current&&c(s.current(r,t,o.current)),l.current=!0;let h=()=>c(s.current(r,t,o.current));return r.on(`change:${t}`,h),()=>r.off(`change:${t}`,h)},[r,t,a]),u}function pi(t,e,i){return I(t,e,(n,r,a)=>n.boolVariation(r,a),i)}function vi(t,e,i){return I(t,e,(n,r,a)=>n.stringVariation(r,a),i)}function mi(t,e,i){return I(t,e,(n,r,a)=>n.numberVariation(r,a),i)}function yi(t,e,i){return I(t,e,(n,r,a)=>n.jsonVariation(r,a),i)}function wi(t,e,i){return I(t,e,(n,r,a)=>n.boolVariationDetail(r,a),i)}function bi(t,e,i){return I(t,e,(n,r,a)=>n.stringVariationDetail(r,a),i)}function ki(t,e,i){return I(t,e,(n,r,a)=>n.numberVariationDetail(r,a),i)}function Di(t,e,i){return I(t,e,(n,r,a)=>n.jsonVariationDetail(r,a),i)}0&&(module.exports={LDReactContext,createClient,createLDReactProvider,createLDReactProviderWithClient,initLDReactContext,useBoolVariation,useBoolVariationDetail,useFlags,useInitializationStatus,useJsonVariation,useJsonVariationDetail,useLDClient,useNumberVariation,useNumberVariationDetail,useStringVariation,useStringVariationDetail});