1"use strict";(self.webpackChunkshell=self.webpackChunkshell||[]).push([["609"],{93e3(t,e,n){let r;n.r(e),n.d(e,{LDIsomorphicClientProvider:()=>rk,LDReactContext:()=>y,createClient:()=>rm,createLDReactProvider:()=>rb,createLDReactProviderWithClient:()=>rw,initLDReactContext:()=>v,useBoolVariation:()=>rO,useBoolVariationDetail:()=>rR,useFlags:()=>rE,useInitializationStatus:()=>rS,useJsonVariation:()=>r$,useJsonVariationDetail:()=>rA,useLDClient:()=>rx,useNumberVariation:()=>rP,useNumberVariationDetail:()=>rN,useStringVariation:()=>rI,useStringVariationDetail:()=>rM});var i,a,s=n(67464),o=n.n(s),l=Object.defineProperty,u=Object.defineProperties,c=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,p=(t,e,n)=>e in t?l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,f=(t,e)=>{for(var n in e||(e={}))h.call(e,n)&&p(t,n,e[n]);if(d)for(var n of d(e))g.call(e,n)&&p(t,n,e[n]);return t};function v(){return(0,s.createContext)(null)}var y=v(),m=Object.defineProperty,w=Object.defineProperties,b=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,E=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,x=(t,e,n)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,D=(t,e)=>{for(var n in e||(e={}))E.call(e,n)&&x(t,n,e[n]);if(k)for(var n of k(e))S.call(e,n)&&x(t,n,e[n]);return t},O=(t,e)=>{var n={};for(var r in t)E.call(t,r)&&0>e.indexOf(r)&&(n[r]=t[r]);if(null!=t&&k)for(var r of k(t))0>e.indexOf(r)&&S.call(t,r)&&(n[r]=t[r]);return n};function I(t){return t.indexOf("~")?t.replace(/~1/g,"/").replace(/~0/g,"~"):t}var P=class{constructor(t,e=!1){if(e)this.y=[t],this.isValid=""!==t,this.redactionName=t.startsWith("/")?function(t){return`/${t.replace(/~/g,"~0").replace(/\//g,"~1")}`}(t):t;else{if(this.redactionName=t,""===t||"/"===t||!function(t){return!t.match(/\/\/|(^\/.*~[^0|^1])|~$/)}(t)){this.isValid=!1,this.y=[];return}!function(t){return!t.startsWith("/")}(t)?0>t.indexOf("/",1)?this.y=[I(t.slice(1))]:this.y=function(t){return(t.startsWith("/")?t.substring(1):t).split("/").map(t=>I(t))}(t):this.y=[t],"_meta"===this.y[0]?this.isValid=!1:this.isValid=!0}}get(t){let{y:e,isValid:n}=this;if(!n)return;let r=t;for(let t=0;t<e.length;t+=1){let n=e[t];if(!(null!=r&&Object.prototype.hasOwnProperty.call(r,n))||"object"!=typeof r||Array.isArray(r))return;r=r[n]}return r}getComponent(t){return this.y[t]}get depth(){return this.y.length}get isKind(){return 1===this.y.length&&"kind"===this.y[0]}compare(t){return this.depth===t.depth&&this.y.every((e,n)=>e===t.getComponent(n))}get components(){return[...this.y]}};P.InvalidReference=new P("");var $=class{is(t){if(Array.isArray(t))return!1;let e=typeof t;return"function"===e||"object"===e}getType(){return"factory method or object"}},C=class{constructor(t,e){this.mt=t,this.typeOf=typeof e}is(t){return!Array.isArray(t)&&typeof t===this.typeOf}getType(){return this.mt}},R=class{constructor(t,e){this.mt=t,this.typeOf=typeof e}is(t){return!!Array.isArray(t)&&(!(t.length>0)||t.every(t=>typeof t===this.typeOf))}getType(){return this.mt}},M=class extends C{constructor(t){super(`number with minimum value of ${t}`,0),this.min=t}is(t){return typeof t===this.typeOf&&t>=this.min}},N=class extends C{constructor(t){super(`string matching ${t}`,""),this.expression=t}is(t){return"string"==typeof t&&!!t.match(this.expression)}},A=/^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d\d*)?(Z|[-+]\d\d(:\d\d)?)/,j=class{is(t){return"number"==typeof t||"string"==typeof t&&A.test(t)}getType(){return"date"}},T=class extends N{constructor(){super(/^(\w|\.|-)+$/)}is(t){return super.is(t)&&"kind"!==t}},F=class{constructor(t){this.Xt=t}is(t){return"string"==typeof t&&this.Xt.includes(t)}getType(){return this.Xt.join(" | ")}};function z(t){return null==t}var U=class{static createTypeArray(t,e){return new R(t,e)}static numberWithMin(t){return new M(t)}static stringMatchingRegex(t){return new N(t)}static oneOf(...t){return new F(t)}};function V(t){return"kind"in t&&U.String.is(t.kind)&&"multi"!==t.kind}function q(t){return"kind"in t&&U.String.is(t.kind)&&"multi"===t.kind}function K(t){return!("kind"in t)||null===t.kind||void 0===t.kind}function H(t,e=[]){if(null===t||"object"!=typeof t)return JSON.stringify(t);if(e.includes(t))throw Error("Cycle detected");return Array.isArray(t)?`[${t.map(n=>H(n,[...e,t])).map(t=>void 0===t?"null":t).join(",")}]`:`{${Object.keys(t).sort().map(n=>{let r=H(t[n],[...e,t]);if(void 0!==r)return`${JSON.stringify(n)}:${r}`}).filter(t=>void 0!==t).join(",")}}`}U.String=new C("string",""),U.Number=new C("number",0),U.ObjectOrFactory=new $,U.Object=ne
1w C("object",{}),U.StringArray=new R("string[]",""),U.Boolean=new C("boolean",!0),U.Function=new class{is(t){return"function"==typeof t}getType(){return"function"}},U.Date=new j,U.Kind=new T,U.NullableBoolean=new class{is(t){return"boolean"==typeof t||null==t}getType(){return"boolean | undefined | null"}};var _="user";function B(t){return t.includes("%")||t.includes(":")?t.replace(/%/g,"%25").replace(/:/g,"%3A"):t}function J(t){return U.Kind.is(t)}function G(t){return U.String.is(t)&&""!==t}function W(t,e=!1){return t?t.map(t=>new P(t,e)):[]}var Z=class L{constructor(t,e,n){this.P=!1,this.Q=!1,this.Qt=!1,this.M={},this.kind=e,this.valid=t,this.message=n}static D(t,e){return new L(!1,t,e)}static Re(t,e){if(!(!e||!t.isValid))return 1===t.depth&&"anonymous"===t.getComponent(0)?!!(null!=e&&e.anonymous):t.get(e)}te(t){return this.P?this.M[t]:this.kind===t?this.v:void 0}static Ne(t){let e=Object.keys(t).filter(t=>"kind"!==t),n=e.every(J);if(!e.length)return L.D("multi","A multi-kind context must contain at least one kind");if(!n)return L.D("multi","Context contains invalid kinds");let r={},i=!0,a=e.reduce((e,n)=>{var a;let s=t[n];return s&&U.Object.is(s)?(e[n]=s,r[n]=W(null==(a=s._meta)?void 0:a.privateAttributes)):i=!1,e},{});if(!i)return L.D("multi","Context contained contexts that were not objects");if(!Object.values(a).every(t=>G(t.key)))return L.D("multi","Context contained invalid keys");if(1===e.length){let t=e[0],n=new L(!0,t);return n.v=w(D({},a[t]),b({kind:t})),n.tt=r,n.Q="user"===t,n}let s=new L(!0,t.kind);return s.M=a,s.tt=r,s.P=!0,s}static Ue(t){var e;let{key:n,kind:r}=t,i=J(r),a=G(n);if(!i)return L.D(null!=r?r:"unknown","The kind was not valid for the context");if(!a)return L.D(r,"The key for the context was not valid");let s=W(null==(e=t._meta)?void 0:e.privateAttributes),o=new L(!0,r);return o.Q="user"===r,o.v=t,o.tt={[r]:s},o}static ze(t){if(void 0===t.key||null===t.key)return L.D("user","The key for the context was not valid");let e=new L(!0,"user");return e.Q=!0,e.Qt=!0,e.v=function(t){let e=w(D({},t.custom||[]),b({kind:"user",key:String(t.key)}));if(null!=t.anonymous){let n=!!t.anonymous;delete e.anonymous,e.anonymous=n}return null!==t.name&&void 0!==t.name&&(e.name=t.name),null!==t.ip&&void 0!==t.ip&&(e.ip=t.ip),null!==t.firstName&&void 0!==t.firstName&&(e.firstName=t.firstName),null!==t.lastName&&void 0!==t.lastName&&(e.lastName=t.lastName),null!==t.email&&void 0!==t.email&&(e.email=t.email),null!==t.avatar&&void 0!==t.avatar&&(e.avatar=t.avatar),null!==t.country&&void 0!==t.country&&(e.country=t.country),null!==t.privateAttributeNames&&void 0!==t.privateAttributeNames&&(e._meta={privateAttributes:t.privateAttributeNames}),e}(t),e.tt={user:W(t.privateAttributeNames,!0)},e}static fromLDContext(t){return t?V(t)?L.Ue(t):q(t)?L.Ne(t):K(t)?L.ze(t):L.D("unknown","Context was not of a valid kind"):L.D("unknown","No context specified. Returning default value")}static toLDContext(t){if(!t.valid)return;let e=t.getContexts();if(!t.P)return e[0][1];let n={kind:"multi"};return e.forEach(t=>{let e=t[0],r=t[1];n[e]=r}),n}valueForKind(t,e=_){return t.isKind?this.kinds:L.Re(t,this.te(e))}key(t=_){var e;return null==(e=this.te(t))?void 0:e.key}get isMultiKind(){return this.P}get canonicalKey(){return this.Q?this.v.key:this.P?Object.keys(this.M).sort().map(t=>`${t}:${B(this.M[t].key)}`).join(":"):`${this.kind}:${B(this.v.key)}`}get kinds(){return this.P?Object.keys(this.M):[this.kind]}get kindsAndKeys(){return this.P?Object.entries(this.M).reduce((t,[e,n])=>(t[e]=n.key,t),{}):{[this.kind]:this.v.key}}privateAttributes(t){var e;return(null==(e=this.tt)?void 0:e[t])||[]}getContexts(){return this.P?Object.entries(this.M):[[this.kind,this.v]]}get legacy(){return this.Qt}canonicalUnfilteredJson(){if(this.valid){if(this.yt)return this.yt;try{this.yt=H(L.toLDContext(this))}catch(t){}return this.yt}}};Z.UserKind=_;var Y,Q=["key","kind","_meta","anonymous"].map(t=>new P(t,!0)),X=["name","ip","firstName","lastName","email","avatar","country"],tt=class{constructor(t,e){this.je=t,this.p=e}filter(t,e=!1){let n=t.getContexts();if(1===n.length)return this.ee(t,n[0][1],n[0][0],e);let r={kind:"multi"};
1return n.forEach(([n,i])=>{r[n]=this.ee(t,i,n,e)}),r}Ve(t,e,n,r){return(r?Object.keys(e).map(t=>new P(t,!0)):[...this.p,...t.privateAttributes(n)]).filter(t=>!Q.some(e=>e.compare(t)))}ee(t,e,n,r){let i=this.je||r&&!0===e.anonymous,{cloned:a,excluded:s}=function(t,e){let n=[],r={},i=[];for(n.push(...Object.keys(t).map(e=>({key:e,ptr:[e],source:t,parent:r,visited:[t]})));n.length;){let t=n.pop(),r=e.find(e=>(function(t,e){return t.depth===e.length&&e.every((e,n)=>e===t.getComponent(n))})(e,t.ptr));if(r)i.push(r.redactionName);else{let e=t.source[t.key];null===e?t.parent[t.key]=e:Array.isArray(e)?t.parent[t.key]=[...e]:"object"==typeof e?t.visited.includes(e)||(t.parent[t.key]={},n.push(...Object.keys(e).map(n=>({key:n,ptr:[...t.ptr,n],source:e,parent:t.parent[t.key],visited:[...t.visited,e]})))):t.parent[t.key]=e}}return{cloned:r,excluded:i.sort()}}(e,this.Ve(t,e,n,i));return t.legacy&&X.forEach(t=>{t in a&&(a[t]=String(a[t]))}),s.length&&(a._meta||(a._meta={}),a._meta.redactedAttributes=s),a._meta&&(delete a._meta.privateAttributes,0===Object.keys(a._meta).length&&delete a._meta),a}},te=class{constructor(t,e,n=Math.random){this.Be=e,this.He=n,this.gt=0,this.ne=Math.max(1,t),this.qe=Math.ceil(Math.log2(3e4/this.ne))}x(){let t=Math.min(this.gt,this.qe);return Math.min(this.ne*2**t,3e4)}Ge(t){return t-Math.trunc(.5*this.He()*t)}success(t=Date.now()){this.vt=t}fail(t=Date.now()){void 0!==this.vt&&t-this.vt>this.Be&&(this.gt=0),this.vt=void 0;let e=this.Ge(this.x());return this.gt+=1,e}};(tn=Y||(Y={}))[tn.Valid=0]="Valid",tn[tn.Initializing=1]="Initializing",tn[tn.Interrupted=2]="Interrupted",tn[tn.Closed=3]="Closed";var tn,tr,ti=class extends Error{constructor(t,e,n,r=!0){super(e),this.kind=t,this.status=n,this.name="LaunchDarklyPollingError",this.recoverable=r}},ta=class extends Error{constructor(t,e,n,r=!0){super(e),this.kind=t,this.code=n,this.name="LaunchDarklyStreamingError",this.recoverable=r}};function ts(t){if("string"==typeof t)return t;if(void 0===t)return"undefined";if(null===t)return"null";if(Object.prototype.hasOwnProperty.call(t,"toString"))try{return t.toString()}catch(t){}if("bigint"==typeof t)return`${t}n`;try{return JSON.stringify(t)}catch(t){return t instanceof TypeError&&t.message.indexOf("circular")>=0?"[Circular]":"[Not Stringifiable]"}}(tA=tr||(tr={})).Unknown="UNKNOWN",tA.NetworkError="NETWORK_ERROR",tA.ErrorResponse="ERROR_RESPONSE",tA.InvalidData="INVALID_DATA",(tj=tz||(tz={}))[tj.Disabled=0]="Disabled",tj[tj.Enabled=1]="Enabled",(tT=tU||(tU={}))[tT.AnalyticsEvents=0]="AnalyticsEvents",tT[tT.DiagnosticEvent=1]="DiagnosticEvent",(tF=tV||(tV={}))[tF.Succeeded=0]="Succeeded",tF[tF.Failed=1]="Failed",tF[tF.FailedAndMustShutDown=2]="FailedAndMustShutDown";var to={s:t=>ts(t),d:t=>"symbol"==typeof t?"NaN":"bigint"==typeof t?`${t}n`:String(Number(t)),i:t=>"symbol"==typeof t?"NaN":"bigint"==typeof t?`${t}n`:String(parseInt(t,10)),f:t=>"symbol"==typeof t?"NaN":String(parseFloat(t)),j:t=>ts(t),o:t=>ts(t),O:t=>ts(t),c:()=>""};function tl(...t){var e;let n=t.shift();if(U.String.is(n)){let r="",i=0;for(;i<n.length;){let a=n.charAt(i);if("%"===a){if(i+1<n.length){let a=n.charAt(i+1);if(a in to&&t.length){let n=t.shift();r+=null==(e=to[a])?void 0:e.call(to,n)}else"%"===a?r+="%":r+=`%${a}`;i+=2}}else r+=a,i+=1}return t.length&&(r.length&&(r+=" "),r+=t.map(ts).join(" ")),r}return t.map(ts).join(" ")}(tL=tq||(tq={}))[tL.debug=0]="debug",tL[tL.info=1]="info",tL[tL.warn=2]="warn",tL[tL.error=3]="error",tL[tL.none=4]="none";var tu=["debug","info","warn","error","none"],tc=class $r{static get(){return new $r({})}constructor(t){var e,n,r;if(this.tn=null!=(n=tq[null!=(e=t.level)?e:"info"])?n:tq.info,this.en=null!=(r=t.name)?r:"LaunchDarkly",this.ae=t.formatter,"object"==typeof t.destination)this.oe={[tq.debug]:t.destination.debug,[tq.info]:t.destination.info,[tq.warn]:t.destination.warn,[tq.error]:t.destination.error};else if("function"==typeof t.destination){let{destination:e}=t;this.oe={[tq.debug]:e,[tq.info]:e,[tq.warn]:e,[tq.error]:e}}}nn(...t){var e;try{return this.ae?null==(e=this.ae)?void 0:e.call(this,...t):tl(...t)}catch(e){return tl(...t)}}rn(t,e){try{t(e)}catch(t){console.error(e)}}S(t,e){var n;if(t>=this.tn){let r=`${tu[t]}: [${this.en}]`;try{let i=null==(n=this.oe)?void 0:n[t];i?this.rn(i,`${r} ${this.nn(...e)}`):console.error(...e)}catch(t){console.error(...e)}}}error(...t){this.S(tq.error,t)}warn(...t){this.S(tq.warn,t)}info(...t){this.S(tq.info,t)}debug(...t){this.S(tq.debug,t)}},td={error:U.Function,warn:U.Function,info:U.Function,debug:U.Function}
1,th=class{constructor(t,e){Object.entries(td).forEach(([e,n])=>{if(!n.is(t[e]))throw Error(`Provided logger instance must support logger.${e}(...) method`)}),this.t=t,this.sn=e}S(t,e){try{this.t[t](...e)}catch(n){this.sn[t](...e)}}error(...t){this.S("error",t)}warn(...t){this.S("warn",t)}info(...t){this.S("info",t)}debug(...t){this.S("debug",t)}},tg=t=>{let e=new tc({level:"info",destination:console.error,formatter:tl});return t?new th(t,e):e},tp=class{static deprecated(t,e){return`"${t}" is deprecated, please use "${e}"`}static optionBelowMinimum(t,e,n){return`Config option "${t}" had invalid value of ${e}, using minimum of ${n} instead`}static unknownOption(t){return`Ignoring unknown config option "${t}"`}static wrongOptionType(t,e,n){return`Config option "${t}" should be of type ${e}, got ${n}, 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`}},tf=U.stringMatchingRegex(/^(\w|\.|-)+$/),tv=class{constructor(t){let e={},n=null==t?void 0:t.application,r=null==t?void 0:t.logger;n&&Object.entries(n).forEach(([t,n])=>{if(null!=n){let i,a,{valid:s,message:o}=(i=n,a=`application.${t}`,tf.is(i)?i.length>64?{valid:!1,message:tp.tagValueTooLong(a)}:{valid:!0}:{valid:!1,message:tp.invalidTagValue(a)});s?"versionName"===t?e["application-version-name"]=[n]:e[`application-${t}`]=[n]:null==r||r.warn(o)}});let i=Object.keys(e);i.length&&(this.value=i.sort().flatMap(t=>e[t].sort().map(e=>`${t}/${e}`)).join(" "))}},ty=class{constructor(t,e,n){this.platform=n,this.basicConfiguration={tags:e.tags,logger:e.logger,offline:e.offline,serviceEndpoints:e.serviceEndpoints,sdkKey:t}}};function tm(t){return t.replace(/\/+$/,"")}function tw(t){return t.replace(/^\/+/,"").replace(/\?$/,"")}var tb=class Mr{constructor(t,e,n=Mr.DEFAULT_EVENTS,r="/bulk",i="/diagnostic",a=!0,s){this.streaming=tm(t),this.polling=tm(e),this.events=tm(n),this.analyticsEventPath=r,this.diagnosticEventPath=i,this.includeAuthorizationHeader=a,this.payloadFilterKey=s}};function tk(t,e=[]){if(0===e.length)return t;let n=e.map(({key:t,value:e})=>`${t}=${e}`);return`${t}?${n.join("&")}`}function tE(t,e,n){let r=tw(e),i=[...n];return t.payloadFilterKey&&i.push({key:"filter",value:t.payloadFilterKey}),tk(`${t.streaming}/${r}`,i)}function tS(t,e,n=[]){let r=tw(e),i=[...n];return t.payloadFilterKey&&i.push({key:"filter",value:t.payloadFilterKey}),tk(`${t.polling}/${r}`,i)}function tx(t,e,n=[]){let r=tw(e);return tk(`${t.events}/${r}`,n)}tb.DEFAULT_EVENTS="https://events.launchdarkly.com";var tD=class extends Error{constructor(t){super(t),this.name="LaunchDarklyUnexpectedResponseError"}},tO=class extends Error{constructor(t){super(t),this.name="LaunchDarklyClientError"}},tI=class extends Error{constructor(t){super(t),this.name="LaunchDarklyTimeoutError"}};function tP(t){return!(t>=400)||!(t<500)||400===t||408===t||429===t}function t$(t,e){let n,r;return{promise:new Promise((i,a)=>{r=i,n=setTimeout(()=>{a(new tI(`${e} timed out after ${t} seconds.`))},1e3*t)}),cancel:()=>{r(),clearTimeout(n)}}}function tC(t){return null==t?t:JSON.parse(JSON.stringify(t))}function tR(t){return Math.trunc(1e3*t)}var tM=(t,e)=>t&&Object.entries(t).reduce((t,[n,r])=>(!r||"{}"===JSON.stringify(r)||null!=e&&e.includes(n)||(t[n]="object"==typeof r?tM(r,e):r),t),{});function tN(t,e,n){let r;return r=t.status?`error ${t.status}${401===t.status?" (invalid SDK key)":""}`:`I/O error (${t.message||"unknown error"})`,`Received ${r} for ${e} - ${null!=n?n:"giving up permanently"}`}var tA,tj,tT,tF,tL,tz,tU,tV,tq,tK,tH=(t,e)=>e.btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),t_=async(t=1e3)=>new Promise(e=>{setTimeout(e,t)}),tB=class{constructor(t,e,n){this.a=e,this.an=n,this.Dt=[],this.ce=Date.now(),this.ue=this.ce,this.le={diagnosticId:e.crypto.randomUUID(),sdkKeySuffix:t.length>6?t.substring(t.length-6):t}}createInitEvent(){var t,e,n;let r=this.a.info.sdkData(),i=this.a.info.platformData();return{kind:"diagnostic-init",id:this.le,creationDate:this.ce,sdk:r,configuration:this.an,platform:D({name:i.name,osArch:null==(t=i.os)?void 0:t.arch,osName:null==(e=i.os)?void 0:e.name,osVersion:null==(n=i.os)?void 0:n.version},i.additional||{})}}recordStreamInit(t,e,n){this.Dt.push({timestamp:t,failed:e,durationMillis:n})}createStatsEventAndReset(t,e,n){let r=Date.now(),i={kind:"diagnostic",id:this.le,creationDate:r,dataSinceDate:this.ue,droppedEvents:t,deduplicatedUsers:e,eventsInLastBatch:n,streamInits:this.Dt};return this.Dt=[],this.ue=r,i}};(i=tK||(tK={})).MalformedFlag="MALFORMED_FLAG",i.UserNotSpecified="USER_NOT_SPECIFIED",i.FlagNotFound="FLAG_NOT_FOUND",i.ClientNotReady="CLIENT_NOT_READY",i.WrongType="WRONG_TYPE";
1var tJ=tK,tG=class{static invalidMetricValue(t){return`The track function was called with a non-numeric "metricValue" (${t}), only numeric metric values are supported.`}};tG.MissingContextKeyNoEvent="Context was unspecified or had no key; event will not be sent";var tW=class{constructor(t,e){let{basicConfiguration:n,platform:r}=t,{serviceEndpoints:{analyticsEventPath:i,diagnosticEventPath:a}}=n,{crypto:s,requests:o}=r;this.cn=D({},e),this.de=tx(n.serviceEndpoints,i,[]),this.un=tx(n.serviceEndpoints,a,[]),this.z=o,this.ln=s}async nt(t,e,n,r){let i,a={status:tV.Succeeded},s=w(D({},this.cn),b({"content-type":"application/json"}));n&&(s["x-launchdarkly-payload-id"]=n,s["x-launchDarkly-event-schema"]="4");try{let{status:n,headers:r}=await this.z.fetch(e,{headers:s,body:JSON.stringify(t),compressBodyIfPossible:!0,method:"POST",keepalive:!0}),o=Date.parse(r.get("date")||"");if(o&&(a.serverTime=o),n<=204)return a;if(i=new tD(tN({status:n,message:"some events were dropped"},"event posting")),!tP(n))return 413===n||tP(n)?a.status=tV.Failed:a.status=tV.FailedAndMustShutDown,a.error=i,a}catch(t){i=t}return i&&!r?(a.status=tV.Failed,a.error=i,a):(await t_(),this.nt(t,this.de,n,!1))}async sendEventData(t,e){let n=t===tU.AnalyticsEvents?this.ln.randomUUID():void 0,r=t===tU.AnalyticsEvents?this.de:this.un;return this.nt(e,r,n,!0)}};function tZ(t){return"feature"===t.kind}var tY=class{constructor(t,e,n,r,i,a){this.count=t,this.key=e,this.value=n,this.version=i,this.variation=a,this.default=r}increment(){this.count+=1}},tQ=class{constructor(t=!1,e){this.dn=t,this.k=e,this.K=0,this.it=0,this.rt={},this.st={}}summarizeEvent(t){if(tZ(t)&&!t.excludeFromSummaries){this.v||(this.v=t.context);let e=`${t.key}:${null!==t.variation&&void 0!==t.variation?t.variation:""}:${null!==t.version&&void 0!==t.version?t.version:""}`,n=this.rt[e],r=this.st[t.key];
1r||(r=new Set,this.st[t.key]=r),t.context.kinds.forEach(t=>r.add(t)),n?n.increment():this.rt[e]=new tY(1,t.key,t.value,t.default,t.version,t.variation),(0===this.K||t.creationDate<this.K)&&(this.K=t.creationDate),t.creationDate>this.it&&(this.it=t.creationDate)}}getSummary(){var t;let e=Object.values(this.rt).reduce((t,e)=>{let n=t[e.key];n||(n={default:e.default,counters:[],contextKinds:[...this.st[e.key]]},t[e.key]=n);let r={value:e.value,count:e.count};return void 0!==e.variation&&null!==e.variation&&(r.variation=e.variation),void 0!==e.version&&null!==e.version?r.version=e.version:r.unknown=!0,n.counters.push(r),t},{}),n={startDate:this.K,endDate:this.it,features:e,kind:"summary",context:void 0!==this.v&&this.dn?null==(t=this.k)?void 0:t.filter(this.v):void 0};return this.hn(),n}hn(){this.K=0,this.it=0,this.rt={},this.st={}}},tX=class extends Error{constructor(t){super(t),this.name="LaunchDarklyInvalidSDKKeyError"}},t0=class{constructor(t,e){this.k=t,this.t=e,this.J={}}summarizeEvent(t){var e;if(tZ(t)){let n=t.context.canonicalUnfilteredJson();if(!n){t.context.valid&&(null==(e=this.t)||e.error("Unable to serialize context, likely the context contains a cycle."));return}let r=this.J[n];r||(this.J[n]=new tQ(!0,this.k),r=this.J[n]),r.summarizeEvent(t)}}getSummaries(){let t=this.J;return this.J={},Object.values(t).map(t=>t.getSummary())}};function t1(t){let e=Math.trunc(t);return 1===e||0!==e&&0===Math.floor(Math.random()*e)}var t3=class{constructor(t,e,n,r,i,a=!0,s=!1){this.e=t,this.at=r,this.C=i,this.ot=[],this.he=0,this.St=0,this.kt=0,this.Ct=!1,this.fe=0,this.It=!1,this.Pt=null,this.fn=t.eventsCapacity,this.t=e.basicConfiguration.logger,this.pe=new tW(e,n),this.k=new tt(t.allAttributesPrivate,t.privateAttributes.map(t=>new P(t))),s?this.W=new t0(this.k,this.t):this.W=new tQ,a&&this.start()}start(){var t,e;if((null==(t=this.at)?void 0:t.flushInterval)!==void 0&&(this.Pt=setInterval(()=>{var t;null==(t=this.at)||t.flush()},1e3*this.at.flushInterval)),this.pn=setInterval(async()=>{var t;try{await this.flush()}catch(e){null==(t=this.t)||t.debug(`Flush failed: ${e}`)}},1e3*this.e.flushInterval),this.C){let t=this.C.createInitEvent();this.me(t),this.ye=setInterval(()=>{let t=this.C.createStatsEventAndReset(this.St,this.kt,this.fe);this.St=0,this.kt=0,this.me(t)},1e3*this.e.diagnosticRecordingInterval)}null==(e=this.t)||e.debug("Started EventProcessor.")}me(t){this.pe.sendEventData(tU.DiagnosticEvent,t)}close(){clearInterval(this.pn),this.Pt&&clearInterval(this.Pt),this.ye&&clearInterval(this.ye)}async flush(){var t;if(this.It)throw new tX("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.ot;if(this.ot=[],void 0!==this.W.getSummaries)this.W.getSummaries().forEach(t=>{Object.keys(t.features).length&&e.push(t)});else{let t=this.W.getSummary();Object.keys(t.features).length&&e.push(t)}e.length&&(this.fe=e.length,null==(t=this.t)||t.debug("Flushing %d events",e.length),await this.nt(e))}sendEvent(t){var e;if(this.It)return;if("migration_op"===t.kind){if(t1(t.samplingRatio)){let e=w(D({},t),b({context:t.context?this.k.filter(t.context):void 0}));1===e.samplingRatio&&delete e.samplingRatio,this.ct(e)}return}this.W.summarizeEvent(t);let n=tZ(t),r=n&&t.trackEvents||!n,i=this.mn(t),a="identify"===t.kind,s=null==(e=this.at)?void 0:e.processContext(t.context);s||a||(this.kt+=1),s&&!a&&this.ct(this.xt({kind:"index",creationDate:t.creationDate,context:t.context,samplingRatio:1},!1)),r&&t1(t.samplingRatio)&&this.ct(this.xt(t,!1)),i&&t1(t.samplingRatio)&&this.ct(this.xt(t,!0))}xt(t,e){switch(t.kind){case"feature":{let n={kind:e?"debug":"feature",creationDate:t.creationDate,context:this.k.filter(t.context,!e),key:t.key,value:t.value,default:t.default};return 1!==t.samplingRatio&&(n.samplingRatio=t.samplingRatio),t.prereqOf&&(n.prereqOf=t.prereqOf),void 0!==t.variation&&(n.variation=t.variation),void 0!==t.version&&(n.version=t.version),t.reason&&(n.reason=t.reason),n}case"index":case"identify":{let e={kind:t.kind,creationDate:t.creationDate,context:this.k.filter(t.context)};return 1!==t.samplingRatio&&(e.samplingRatio=t.samplingRatio),e}
1case"custom":{let e={kind:"custom",creationDate:t.creationDate,key:t.key,context:this.k.filter(t.context)};return 1!==t.samplingRatio&&(e.samplingRatio=t.samplingRatio),void 0!==t.data&&(e.data=t.data),void 0!==t.metricValue&&(e.metricValue=t.metricValue),void 0!==t.url&&(e.url=t.url),e}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}}ct(t){var e;this.ot.length<this.fn?(this.ot.push(t),this.Ct=!1):(this.Ct||(this.Ct=!0,null==(e=this.t)||e.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),this.St+=1)}mn(t){return tZ(t)&&t.debugEventsUntilDate&&t.debugEventsUntilDate>this.he&&t.debugEventsUntilDate>Date.now()}async nt(t){let e=await this.pe.sendEventData(tU.AnalyticsEvents,t);if(e.status===tV.FailedAndMustShutDown&&(this.It=!0),e.serverTime&&(this.he=e.serverTime),e.error)throw e.error}},t2=class{constructor(t,e,n,r,i=1,a){this.context=t,this.key=e,this.data=n,this.metricValue=r,this.samplingRatio=i,this.url=a,this.kind="custom",this.creationDate=Date.now(),this.context=t}},t4=class{constructor(t,e,n,r,i,a,s,o,l,u,c,d,h=1){this.withReasons=t,this.context=e,this.key=n,this.samplingRatio=h,this.kind="feature",this.creationDate=Date.now(),this.value=r,this.default=i,void 0!==a&&(this.version=a),void 0!==s&&(this.variation=s),void 0!==o&&(this.trackEvents=o),void 0!==l&&(this.prereqOf=l),void 0!==u&&(this.reason=u),void 0!==c&&(this.debugEventsUntilDate=c),void 0!==d&&(this.excludeFromSummaries=d)}},t6=class{constructor(t,e=1){this.context=t,this.samplingRatio=e,this.kind="identify",this.creationDate=Date.now()}},t5=class{constructor(t){this.Lt=t}evalEvent(t){var e;return new t4(this.Lt,t.context,t.flagKey,t.value,t.defaultVal,t.version,null!=(e=t.variation)?e:void 0,t.trackEvents||t.addExperimentData,t.prereqOfFlagKey,this.Lt||t.addExperimentData?t.reason:void 0,t.debugEventsUntilDate,t.excludeFromSummaries,t.samplingRatio)}unknownFlagEvent(t,e,n){return new t4(this.Lt,n,t,e,e,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0)}identifyEvent(t){return new t6(t,1)}customEvent(t,e,n,r,i=1){return new t2(e,t,null!=n?n:void 0,null!=r?r:void 0,i)}},t9="FDv1Fallback",t8={type:"none"};function t7(t,e){let n="inactive",r="partial",i=[];function a(){n="inactive",r="partial",i=[]}return{get state(){return n},processEvent(s){switch(s.event){case"server-intent":return function(t){var a;if(!(null!=(a=t.payloads)&&a.length))return{type:"error",kind:"MISSING_PAYLOAD",message:"No payload present in server-intent"};let s=t.payloads[0];switch(null==s?void 0:s.intentCode){case"xfer-full":return n="full",i=[],r="full",t8;case"xfer-changes":return n="changes",i=[],r="partial",t8;case"none":return n="changes",i=[],r="partial",z(s.target)?(null==e||e.warn(`Ignoring 'none' intent with missing fields: target=${s.target}`),t8):{type:"payload",payload:{version:s.target,type:"none",updates:[]}};default:return null==e||e.warn(`Unable to process intent code '${null==s?void 0:s.intentCode}'.`),t8}}(s.data);case"put-object":return function(r){var a,s,o;if("inactive"===n)return null==e||e.warn("Received put-object before server-intent was established. Ignoring."),t8;if(!r.kind||!r.key||z(r.version)||!r.object)return null==e||e.warn(`Ignoring put-object with missing fields: kind=${r.kind}, key=${r.key}, version=${r.version}`),t8;let l=(a=r.kind,s=r.object,null==(o=t[a])?void 0:o.call(t,s));return l?i.push({kind:r.kind,key:r.key,version:r.version,object:l}):null==e||e.warn(`Unable to process object for kind: '${r.kind}'`),t8}(s.data);case"delete-object":return o=s.data,"inactive"===n?null==e||e.warn("Received delete-object before server-intent was established. Ignoring."):!o.kind||!o.key||z(o.version)?null==e||e.warn(`Ignoring delete-object with missing fields: kind=${o.kind}, key=${o.key}, version=${o.version}`):i.push({kind:o.kind,key:o.key,version:o.version,deleted:!0}),t8;case"payload-transferred":var o,l,u,c=s.data;if("inactive"===n)return{type:"error",kind:"PROTOCOL_ERROR",message:"A payload transferred has been received without an intent having been established."};if(z(c.state)||z(c.version))return null==e||e.warn(`Ignoring payload-transferred with missing fields: state=${c.state}, version=${c.version}`),a(),t8;let d={type:"payload",payload:{version:c.version,state:c.state,type:r,updates:i}};return n="changes",r="partial",i=[],d;case"goodbye":return l=s.data,null==e||e.info(`Goodbye was received from the LaunchDarkly connection with reason: ${l.reason}.`),a(),{type:"goodbye",reason:l.reason};case"error":return u=s.data,null==e||e.info(`An issue was encountered receiving updates with reason: ${u.reason}.`),i=[],{type:"serverError",id:u.payload_id,reason:u.reason};case"heart-beat":return t8;default:return{type:"error",kind:"UNKNOWN_EVENT",message:`Received an unknown event of type '${s.event}'`}}},reset(){a()}}}var et=class{constructor(t,e,n){this.m=e,this.t=n,this.n=[],this.gn=t7(t,n)}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(t=>{var e,n,r;let i=this.gn.processEvent(t);
1switch(i.type){case"payload":this.n.forEach(t=>t(i.payload));break;case"error":"MISSING_PAYLOAD"===(r=i.kind)||"PROTOCOL_ERROR"===r?null==(e=this.m)||e.call(this,tr.InvalidData,i.message):null==(n=this.t)||n.warn(i.message)}})}},ee=class{constructor(t,e,n,r){this.m=n,this.t=r,this._(t,"server-intent"),this._(t,"put-object"),this._(t,"delete-object"),this._(t,"payload-transferred"),this._(t,"goodbye"),this._(t,"error"),this.At=new et(e,n,r)}addPayloadListener(t){this.At.addPayloadListener(t)}removePayloadListener(t){this.At.removePayloadListener(t)}_(t,e){t.addEventListener(e,async t=>{var n,r,i,a,s;if(null!=t&&t.data){null==(n=this.t)||n.debug(`Received ${e} event. Data is ${t.data}`);try{this.At.processEvents([{event:e,data:JSON.parse(t.data)}])}catch(n){null==(r=this.t)||r.error(`Stream received data that was unable to be processed in "${e}" message`),null==(i=this.t)||i.debug(`Data follows: ${t.data}`),null==(a=this.m)||a.call(this,tr.InvalidData,"Malformed data in EventStream.")}}else null==(s=this.m)||s.call(this,tr.Unknown,"Event from EventStream missing data.")})}},en="unknown plugin";function er(t,e){try{return e.getMetadata().name||en}catch(e){return t.error("Exception thrown getting metadata for plugin. Unable to get plugin name."),en}}var ei=Object.freeze({__proto__:null,ClientMessages:tG,DiagnosticsManager:tB,ErrorKinds:tJ,EventFactoryBase:t5,EventProcessor:t3,FDv1PayloadAdaptor:function(t){return{yn:t,ge:"",useSelector(t){return this.ge=t,this},processFullTransfer(t){let e=[{event:"server-intent",data:{payloads:[{id:t9,target:1,intentCode:"xfer-full",reason:"payload-missing"}]}}];Object.entries((null==t?void 0:t.flags)||[]).forEach(([t,n])=>{e.push({event:"put-object",data:{kind:"flag",key:t,version:n.version||
11,object:n}})}),Object.entries((null==t?void 0:t.segments)||[]).forEach(([t,n])=>{e.push({event:"put-object",data:{kind:"segment",key:t,version:n.version||1,object:n}})}),e.push({event:"payload-transferred",data:{state:this.ge,version:1,id:t9}}),this.yn.processEvents(e)}}},InputCustomEvent:t2,InputEvalEvent:t4,InputIdentifyEvent:t6,NullEventProcessor:class{close(){}async flush(){}sendEvent(){}},PayloadProcessor:et,PayloadStreamReader:ee,canonicalize:H,createProtocolHandler:t7,initMetadataFromHeaders:function(t){if(t){let e=Object.keys(t).find(t=>"x-ld-envid"===t.toLowerCase());if(e)return{environmentId:t[e]}}},isLegacyUser:K,isMultiKind:q,isSingleKind:V,safeGetHooks:function(t,e,n){let r=[];return n.forEach(n=>{var i;try{let a=null==(i=n.getHooks)?void 0:i.call(n,e);void 0===a?t.error(`Plugin ${er(t,n)} returned undefined from getHooks.`):a&&a.length>0&&r.push(...a)}catch(e){t.error(`Exception thrown getting hooks for plugin ${er(t,n)}. Unable to get hooks.`)}}),r},safeGetName:er,safeRegisterPlugins:function(t,e,n,r){r.forEach(r=>{try{r.register(n,e)}catch(e){t.error(`Exception thrown registering plugin ${er(t,r)}.`)}})},shouldSample:t1}),ea=class extends Error{constructor(t,e){super(t),this.status=e,this.name="LaunchDarklyRequestError"}};function es(t,e,n,r,i,a,s,o,l,u){let c,d="GET",h=D({},a);l&&(d="REPORT",h["content-type"]="application/json",c=t);let g=l?n.pathReport(i,t):n.pathGet(i,t),p=[...null!=s?s:[]];o&&p.push({key:"withReasons",value:"true"}),u&&p.push({key:"h",value:u});let f=tS(e,g,p);return{async requestPayload(){let t;try{var e;let n=await r.fetch(f,{method:d,headers:h,body:c});if((e=n.status)>=200&&e<=299)return await n.text();t=n.status}catch(t){throw new ea(null==t?void 0:t.message)}throw new ea(`Unexpected status code: ${t}`,t)}}}var eo=Error("Task has already been executed or shed. This is likely an implementation error. The task will not be executed again.");function el(t){return"validate"in t}function eu(t,e,n,r,i){let a=D({},n);return z(t)||(U.Object.is(t)?Object.entries(t).forEach(([t,s])=>{let o=e[t],l=i?`${i}.${t}`:t;if(!o){null==r||r.warn(tp.unknownOption(l));return}if(z(s))return;if(el(o)){let e=o.validate(s,l,r,n[t]);void 0!==e&&(a[t]=e.value);return}if(o.is(s)){a[t]=s;return}let u=o.getType();"boolean"===u?(null==r||r.warn(tp.wrongOptionTypeBoolean(l,typeof s)),a[t]=!!s):"boolean | undefined | null"===u?(null==r||r.warn(tp.wrongOptionTypeBoolean(l,typeof s)),"boolean"!=typeof s&&null!=s&&(a[t]=!!s)):o instanceof M&&U.Number.is(s)?(null==r||r.warn(tp.optionBelowMinimum(l,s,o.min)),a[t]=o.min):null==r||r.warn(tp.wrongOptionType(l,u,typeof s))}):null==r||r.warn(tp.wrongOptionType(null!=i?i:"config","object",typeof t))),a}function ec(t,e){var n;let r=null==e?void 0:e.defaults;return{is:null!=(n=null==e?void 0:e.is)?n:t=>U.Object.is(t),getType:()=>"object",validate(e,n,i,a){if(!U.Object.is(e)){null==i||i.warn(tp.wrongOptionType(n,"object",typeof e));return}let s=eu(e,t,null!=r?r:U.Object.is(a)?a:{},i,n);return Object.keys(s).length>0?{value:s}:void 0}}}function ed(t,e){return{is:t=>Array.isArray(t),getType:()=>"array",validate(n,r,i){if(!Array.isArray(n)){null==i||i.warn(tp.wrongOptionType(r,"array",typeof n));return}let a=[];return n.forEach((n,s)=>{let o=`${r}[${s}]`;if(z(n)||!U.Object.is(n)){null==i||i.warn(tp.wrongOptionType(o,"object",typeof n));return}let l=n[t],u="string"==typeof l?e[l]:void 0;if(!u){let n=Object.keys(e).join(" | ");null==i||i.warn(tp.wrongOptionType(`${o}.${t}`,n,"string"==typeof l?l:typeof l));return}a.push(eu(n,u,{},i,o))}),{value:a}}}}var eh=U.oneOf("cache","polling","streaming"),eg=U.oneOf("streaming","polling","offline","one-shot","background"),ep={pollingBaseUri:U.String,streamingBaseUri:U.String},ef={type:eh,pollInterval:U.numberWithMin(30),endpoints:ec(ep)},ev={type:eh,initialReconnectDelay:U.numberWithMin(1),endpoints:ec(ep)},ey=ed("type",{cache:{type:eh},polling:ef,streaming:ev}),em=ed("type",{polling:ef,streaming:ev}),ew={pollInterval:U.numberWithMin(30),endpoints:ec(ep)},eb={initializers:ey,synchronizers:em,fdv1Fallback:ec(ew)},ek={streaming:{initializers:[{type:"cache"},{type:"polling"}],synchronizers:[{type:"streaming"},{type:"polling"}],fdv1Fallback:{pollInterval:300}}
1,polling:{initializers:[{type:"cache"}],synchronizers:[{type:"polling"}],fdv1Fallback:{pollInterval:300}},offline:{initializers:[{type:"cache"}],synchronizers:[]},"one-shot":{initializers:[{type:"cache"},{type:"polling"},{type:"streaming"}],synchronizers:[]},background:{initializers:[{type:"cache"}],synchronizers:[{type:"polling",pollInterval:3600}],fdv1Fallback:{pollInterval:3600}}},eE=(a=ec(eb),r=void 0,{is:t=>U.Object.is(t),getType:()=>"object",validate(t,e,n,i){if(z(t))return;if(!U.Object.is(t)){null==n||n.warn(tp.wrongOptionType(e,"object",typeof t));return}let s={},o={};return Object.keys(t).forEach(r=>{eg.is(r)?(s[r]=t[r],o[r]=a):null==n||n.warn(tp.wrongOptionType(e,eg.getType(),r))}),{value:eu(s,o,null!=r?r:U.Object.is(i)?i:{},n,e)}}});function eS(t,e){return U.Object.is(t)&&t.type===e}var ex={type:U.oneOf("automatic"),lifecycle:U.Boolean,network:U.Boolean},eD={type:U.oneOf("manual"),initialConnectionMode:eg},eO={backgroundConnectionMode:eg,automaticModeSwitching:function(...t){return{is:e=>t.some(t=>t.is(e)),getType:()=>t.map(t=>t.getType()).join(" | "),validate(e,n,r,i){let a=t.find(t=>t.is(e));if(a)return el(a)?a.validate(e,n,r,i):{value:e};null==r||r.warn(tp.wrongOptionType(n,this.getType(),typeof e))}}}(U.Boolean,ec(ex,{is:t=>eS(t,"automatic")}),ec(eD,{is:t=>eS(t,"manual")})),connectionModes:eE},eI={foregroundConnectionMode:"one-shot",backgroundConnectionMode:void 0,automaticModeSwitching:!1},eP="https://clientsdk.launchdarkly.com",e$="https://clientstream.launchdarkly.com",eC=class{constructor(t={},e={getImplementationHooks:()=>[],credentialType:"mobileKey"}){var n,r,i;this.logger=tg(),this.baseUri=eP,this.eventsUri=tb.DEFAULT_EVENTS,this.streamUri=e$,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=300,this.hooks=[],this.inspectors=[],this.logger=function(t){return t instanceof th?t:tg(t)}(t.logger),Object.entries(eu(t,function(t){return{logger:U.Object,maxCachedContexts:U.numberWithMin(0),baseUri:U.String,streamUri:U.String,eventsUri:U.String,capacity:U.numberWithMin(1),diagnosticRecordingInterval:U.numberWithMin(2),flushInterval:U.numberWithMin(2),streamInitialReconnectDelay:U.numberWithMin(0),allAttributesPrivate:U.Boolean,debug:U.Boolean,diagnosticOptOut:U.Boolean,withReasons:U.Boolean,sendEvents:U.Boolean,pollInterval:U.numberWithMin(30),useReport:U.Boolean,privateAttributes:U.StringArray,disableCache:U.Boolean,applicationInfo:U.Object,wrapperName:U.String,wrapperVersion:U.String,payloadFilterKey:U.stringMatchingRegex(/^[a-zA-Z0-9](\w|\.|-)*$/),hooks:U.createTypeArray("Hook[]",{}),inspectors:U.createTypeArray("LDInspection",{}),cleanOldPersistentData:U.Boolean,dataSystem:null!=t&&t.dataSystemDefaults?ec(eO,{defaults:w(D({},t.dataSystemDefaults),b({connectionModes:ek}))}):U.Object}}({dataSystemDefaults:e.dataSystemDefaults}),{},this.logger)).forEach(([t,e])=>{"logger"!==t&&(this[t]=e)}),this.serviceEndpoints=new tb(this.streamUri,this.baseUri,this.eventsUri,e.analyticsEventPath,e.diagnosticEventPath,e.includeAuthorizationHeader,t.payloadFilterKey),this.useReport=null!=(n=t.useReport)&&n,this.tags=new tv({application:this.applicationInfo,logger:this.logger}),this.userAgentHeaderName=null!=(r=e.userAgentHeaderName)?r:"user-agent",this.trackEventModifier=null!=(i=e.trackEventModifier)?i:t=>t,this.credentialType=e.credentialType,this.getImplementationHooks=e.getImplementationHooks}};async function eR(t,e){if(t.digest)return t.digest(e);if(t.asyncDigest)return t.asyncDigest(e);throw Error("Platform must implement digest or asyncDigest")}var eM=async(t,{crypto:e,storage:n},r)=>{let i=await (null==n?void 0:n.get(t));return null==i&&(r&&null!=(i=await (null==n?void 0:n.get(r)))&&(await (null==n?void 0:n.set(t,i)),await (null==n?void 0:n.get(t))!=null&&await (null==n?void 0:n.clear(r))),null==i&&(i=e.randomUUID(),await (null==n?void 0:n.set(t,i)))),i};function eN(t){return async e=>eR(t.createHash("sha256").update(e),"base64")}var eA=async t=>t;async function ej(t){return(await Promise.all(t.map(t=>t.transform(t.value)))).join("_")}async function eT(t,e){return ej([{value:"LaunchDarkly",transform:eA},{value:e,transform:eN(t)}])}async function eF(t){return ej([{value:"LaunchDarkly",transform:eA},{value:"AnonymousKeys",transform:eA},{value:t,transform:eA}])}async function eL(t){return ej([{value:"LaunchDarkly",transform:eA},{value:"ContextKeys",transform:eA},{value:t,transform:eA}])}async function ez(t){return ej([{value:t,transform:eA},{value:"ContextIndex",transform:eA}])}async function eU(t,e,n){return ej([{value:e,transform:eA},{value:n.canonicalKey,transform:eN(t)}])}var{isLegacyUser:eV,isSingleKind:eq,isMultiKind:eK}=ei,eH=async({crypto:t,info:e},{applicationInfo:n})=>{var r;let{ld_application:i}=e.platformData(),a=null!=(r=tM(i))?r:{},s=(null==n?void 0:n.id)||(null==a?void 0:a.id);if(s){let e=(null==n?void 0:n.version)||(null==a?void 0:a.version),r=(null==n?void 0:n.name)||(null==a?void 0:a.name),i=(null==n?void 0:n.versionName)||(null==a?void 0:a.versionName);return(a=D(D(D(w(D({},a),b({id:s})),e?{version:e}:{}),r?{name:r}:{}),i?{versionName:i}:{})).key=await eR(t.createHash("sha256").update(s),"base64"),a.envAttributesVersion=a.envAttributesVersion||"1.0",a}},e_=async t=>{var e,n,r,i;let{ld_device:a,os:s}=t.info.platformData(),o=null!=(e=tM(a))?e:{},l=(null==s?void 0:s.name)||(null==(n=o.os)?void 0:n.name),u=(null==s?void 0:s.version)||(null==(r=o.os)?void 0:r.version),c=null==(i=o.os)?void 0:i.family;if((l||u||c)&&(o.os=D(D(D({},l?{name:l}:{}),u?{version:u}:{}),c?{family:c}:{})),Object.keys(o).filter(t=>"key"!==t&&"envAttributesVersion"!==t).length){let e=await eL("ld_device");return o.key=await eM(e,t),o.envAttributesVersion=o.envAttributesVersion||"1.0",o}},eB=async(t,e,n)=>{let r,i;return eV(t)?t:(eq(t)&&"ld_application"!==t.kind||eK(t)&&!t.ld_a
1pplication?r=await eH(e,n):n.logger.warn("Not adding ld_application environment attributes because it already exists."),eq(t)&&"ld_device"!==t.kind||eK(t)&&!t.ld_device?i=await e_(e):n.logger.warn("Not adding ld_device environment attributes because it already exists."),r||i)?D(D(D({},eq(t)?(t=>{let{kind:e}=t;return{kind:"multi",[e]:O(t,["kind"])}})(t):t),r?{ld_application:r}:{}),i?{ld_device:i}:{}):t},{isLegacyUser:eJ,isMultiKind:eG,isSingleKind:eW}=ei,eZ=async(t,e,n)=>{let{anonymous:r,key:i}=e;if(r&&!i){let r=await eL(t),i=await eF(t);e.key=await eM(r,n,i)}},eY=async(t,e)=>{await eZ(t.kind,t,e)},eQ=async(t,e)=>{let{kind:n}=t;return Promise.all(Object.entries(O(t,["kind"])).map(([t,n])=>eZ(t,n,e)))},eX=async(t,e)=>{await eZ("user",t,e)},e0=async(t,e)=>{let n=tC(t);return eW(n)&&await eY(n,e),eG(n)&&await eQ(n,e),eJ(n)&&await eX(n,e),n};function e1(t,e){return{value:null!=e?e:null,variationIndex:null,reason:{kind:"ERROR",errorKind:t}}}function e3(t,e,n){return D({value:t,variationIndex:null!=e?e:null},void 0!==n&&{reason:n})}var e2=class extends ei.EventFactoryBase{evalEventClient(t,e,n,r,i,a){let{trackEvents:s,debugEventsUntilDate:o,trackReason:l,flagVersion:u,version:c,variation:d}=r;return super.evalEvent({addExperimentData:l,context:i,debugEventsUntilDate:o,defaultVal:n,flagKey:t,reason:a,trackEvents:!!s,value:e,variation:d,version:null!=u?u:c})}};function e4(t,e){let n=Object.keys(e),r="$flagsState",i="$valid",a=e[r];!a&&n.length&&t.warn("LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."),!1===e[i]&&t.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");let s={};return n.forEach(t=>{if(t!==r&&t!==i){let n;n=a&&a[t]?D({value:e[t]},a[t]):{value:e[t],version:0},s[t]={version:n.version,flag:n}}}),s}var e6="_freshness";async function e5(t,e){let n=e.canonicalUnfilteredJson();if(n)return eR(t.createHash("sha256").update(n),"base64")}async function e9(t,e,n,r,i){let a=await eU(e,n,r),s=await t.get(`${a}${e6}`);if(null!=s)try{let t=JSON.parse(s),n=await e5(e,r);return void 0===n||t.contextHash!==n||"number"!=typeof t.timestamp||Number.isNaN(t.timestamp)?void 0:t.timestamp}catch(t){null==i||i.warn(`Could not read freshness data from persistent storage: ${t.message}`);return}}async function e8(t,e,n,r,i){let a=await eU(e,n,r),s=await t.get(a),o=!1;if(null==s){if(null==(s=await t.get(r.canonicalKey)))return;o=!0}try{let t=JSON.parse(s);if(null===t||"object"!=typeof t){null==i||i.warn("Cached flag data is not a valid object");return}let e=Object.entries(t),n=e.find(([,t])=>null===t||"object"!=typeof t||"number"!=typeof t.version);if(n){null==i||i.warn(`Discarding cached flags due to invalid entry: ${n[0]}`);return}return{flags:e.reduce((t,[e,n])=>(t[e]=n,t),{}),storageKey:a,fromLegacyKey:o}}catch(t){null==i||i.warn(`Could not parse cached flag evaluations from persistent storage: ${t.message}`);return}}var e7=class ln{constructor(){this.container={index:[]}}static fromJson(t){let e=new ln;try{e.container=JSON.parse(t)}catch(t){}return e}toJson(){return JSON.stringify(this.container)}notice(t,e){let n=this.container.index.find(e=>e.id===t);void 0===n?this.container.index.push({id:t,timestamp:e}):n.timestamp=e}prune(t){let e=Math.max(t,0);return this.container.index.length>e?(this.container.index.sort((t,e)=>t.timestamp-e.timestamp),this.container.index.splice(0,this.container.index.length-e)):[]}},nt=class{constructor(t,e,n,r,i,a,s,o=()=>Date.now()){this.a=t,this.Tt=e,this.ut=n,this.ve=r,this.A=i,this.g=a,this.t=s,this.vn=o,this.we=ez(this.Tt)}async init(t,e){this.g.init(t,e),await this.Ot(t)}async upsert(t,e,n){return!!this.g.upsert(t,e,n)&&(await this.Ot(t),!0)}async applyChanges(t,e,n){this.g.applyChanges(t,e,n),await this.Ot(t)}async loadCached(t){if(this.ve||this.ut<=0||!this.a.storage)return!1;let e=await e8(this.a.storage,this.a.crypto,this.Tt,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 n=Object.entries(e.flags).reduce((t,[e,n])=>(t[e]={version:n.version,flag:n},t),{});return this.g.initCached(t,n),this.t.debug("Loaded cached flag evaluations from persistent storage"),!0}async wn(t,e,n){var r;let i=await e5(this.a.crypto,e);void 0===i?this.t.error("Could not serialize context for freshness tracking"):await (null==(r=this.a.storage)?void 0:r.set(`${t}${e6}`,JSON.stringify({timestamp:n,contextHash:i})))}async En(){var t;if(void 0!==this.V)return this.V;let e=await (null==(t=this.a.storage)?void 0:t.get(await this.we));if(!e)return this.V=new e7,this.V;try{this.V=e7.fromJson(e),this.t.debug("Loaded context index from persistent storage")}catch(t){this.t.warn(`Could not load index from persistent storage: ${t.message}`),this.V=new e7}return this.V}async Ot(t){var e,n;if(this.ve)return;let r=this.vn(),i=await this.En(),a=await eU(this.a.crypto,this.Tt,t);this.ut>0&&i.notice(a,r);let s=i.prune(this.ut),o=this.ut<=0||s.some(t=>t.id===a);if(await Promise.all(s.flatMap(t=>{var e,n;return[null==(e=this.a.storage)?void 0:e.clear(t.id),null==(n=this.a.storage)?void 0:n.clear(`${t.id}${e6}`)]})),await (null==(e=this.a.storage)?void 0:e.set(await this.we,i.toJson())),o)return;let l=JSON.stringify(Object.entries(this.A.getAll()).reduce((t,[e,n])=>(null!==n.flag&&void 0!==n.flag&&(t[e]=n.flag),t),{}));await (null==(n=this.a.storage)?void 0:n.set(a,l));try{await this.wn(a,t,r)}catch(t){this.t.warn(`Failed to store freshness data: ${t.message}`)}}};function ne(t,e){let n=[];return Object.entries(t).forEach(([t,r])=>{let i=e[t];i&&function t(e,n){if(e===n)return!0;
1if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;if(Array.isArray(e)){if((r=e.length)!=n.length)return!1;for(i=r;0!=i--;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if((r=e.length)!=n.length)return!1;for(i=r;0!=i--;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((r=(a=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;0!=i--;){var r,i,a,s=a[i];if(!t(e[s],n[s]))return!1}return!0}return e!=e&&n!=n}(r,i)||n.push(t)}),Object.keys(e).forEach(e=>{t[e]||n.push(e)}),n}var nn=class{constructor(t,e,n,r,i,a=()=>Date.now()){this.A=function(){let t={};return{init(e){t=Object.entries(e).reduce((t,[e,n])=>(t[e]=n,t),{})},insertOrUpdate(e,n){t[e]=n},get(e){if(Object.prototype.hasOwnProperty.call(t,e))return t[e]},getAll:()=>t,applyChanges(e,n){"full"===n?this.init(e):"partial"===n&&Object.entries(e).forEach(([e,n])=>{t[e]=n})}}}(),this.g=function(t,e){let n,r=[];return{handleFlagChanges(t,i){n?r.forEach(e=>{try{e(n,t,i)}catch(t){}}):e.warn("Received a change event without an active context. Changes will not be propagated.")},init(e,r){n=e;let i=t.getAll();t.init(r);let a=ne(i,r);a.length>0&&this.handleFlagChanges(a,"init")},initCached(t,e){(null==n?void 0:n.canonicalKey)!==t.canonicalKey&&this.init(t,e)},applyChanges(e,r,i){n=e;let a=t.getAll();if(t.applyChanges(r,i),"full"===i){let t=ne(a,r);t.length>0&&this.handleFlagChanges(t,"init")}else if("partial"===i){let t=Object.keys(r);t.length>0&&this.handleFlagChanges(t,"patch")}},upsert(r,i,a){if((null==n?void 0:n.canonicalKey)!==r.canonicalKey)return e.warn("Received an update for an inactive context."),!1;let s=t.get(i);return(void 0===s||!(s.version>=a.version))&&(t.insertOrUpdate(i,a),this.handleFlagChanges([i],"patch"),!0)},on(t){r.push(t)},off(t){let e=r.indexOf(t);e>-1&&r.splice(e,1)}}}(this.A,i),this.lt=this.bn(t,e,n,r,i,a)}async bn(t,e,n,r,i,a=()=>Date.now()){let s=await eT(t.crypto,e);return new nt(t,s,n,r,this.A,this.g,i,a)}get(t){return this.r&&Object.prototype.hasOwnProperty.call(this.r,t)?this.Mt(this.r[t]):this.A.get(t)}getAll(){return this.r?D(D({},this.A.getAll()),Object.entries(this.r).reduce((t,[e,n])=>(t[e]=this.Mt(n),t),{})):this.A.getAll()}presetFlags(t){this.A.init(t)}setBootstrap(t,e){this.g.init(t,e)}async init(t,e){return(await this.lt).init(t,e)}async upsert(t,e,n){return(await this.lt).upsert(t,e,n)}async loadCached(t){return(await this.lt).loadCached(t)}async applyChanges(t,e,n){return(await this.lt).applyChanges(t,e,n)}on(t){this.g.on(t)}off(t){this.g.off(t)}Mt(t){return{flag:{value:t,version:0},version:0}}setOverride(t,e){this.r||(this.r={}),this.r[t]=e,this.g.handleFlagChanges([t],"override")}removeOverride(t){this.r&&Object.prototype.hasOwnProperty.call(this.r,t)&&(delete this.r[t],0===Object.keys(this.r).length&&(this.r=void 0),this.g.handleFlagChanges([t],"override"))}clearAllOverrides(){if(this.r){let t=D({},this.r);this.r=void 0,this.g.handleFlagChanges(Object.keys(t),"override")}}getAllOverrides(){if(!this.r)return{};let t={};return Object.entries(this.r).forEach(([e,n])=>{t[e]=this.Mt(n)}),t}getDebugOverride(){return{setOverride:this.setOverride.bind(this),removeOverride:this.removeOverride.bind(this),clearAllOverrides:this.clearAllOverrides.bind(this),getAllOverrides:this.getAllOverrides.bind(this)}}},nr="unknown hook",ni="beforeEvaluation",na="afterEvaluation";function ns(t,e,n,r,i){try{return r()}catch(r){return null==t||t.error(`An error was encountered in "${e}" of the "${n}" hook: ${r}`),i}}function no(t,e){try{return e.getMetadata().name||nr}catch(e){return t.error("Exception thrown getting metadata for hook. Unable to get hook name."),nr}}var nl=class{constructor(t,e){this.t=t,this.$=[],this.$.push(...e)}withEvaluation(t,e,n,r){var i;if(0===this.$.length)return r();let a=[...this.$],s={flagKey:t,context:e,defaultValue:n},o=(i=this.t,a.map(t=>ns(i,ni,no(i,t),()=>{var e,n;return null!=(n=null==(e=null==t?void 0:t.beforeEvaluation)?void 0:e.call(t,s,{}))?n:{}},{}))),l=r();return function(t,e,n,r,i){for(let a=e.length-1;a>=0;a-=1){let s=e[a],o=r[a];ns(t,na,no(t,s),()=>{var t,e;
1return null!=(e=null==(t=null==s?void 0:s.afterEvaluation)?void 0:t.call(s,n,o,i))?e:{}},{})}}(this.t,a,s,o,l),l}identify(t,e){var n;let r=[...this.$],i={context:t,timeout:e},a=(n=this.t,r.map(t=>ns(n,ni,no(n,t),()=>{var e,n;return null!=(n=null==(e=null==t?void 0:t.beforeIdentify)?void 0:e.call(t,i,{}))?n:{}},{})));return t=>{!function(t,e,n,r,i){for(let a=e.length-1;a>=0;a-=1){let s=e[a],o=r[a];ns(t,na,no(t,s),()=>{var t,e;return null!=(e=null==(t=null==s?void 0:s.afterIdentify)?void 0:t.call(s,n,o,i))?e:{}},{})}}(this.t,r,i,a,t)}}addHook(t){this.$.push(t)}afterTrack(t){if(0===this.$.length)return;let e=[...this.$];var n=this.t;for(let r=e.length-1;r>=0;r-=1){let i=e[r];ns(n,"afterTrack",no(n,i),()=>{var e;return null==(e=null==i?void 0:i.afterTrack)?void 0:e.call(i,t)},void 0)}}},nu="flag-used",nc="flag-details-changed",nd="flag-detail-changed",nh="client-identity-changed",ng=[nu,nc,nd,nh],np=class{constructor(t,e){this.B=[];let n=t.filter(t=>{var n,r;let i;return(i=ng.includes(t.type)&&t.method&&"function"==typeof t.method)||e.warn((n=t.type,r=t.name,`an inspector: "${r}" of an invalid type (${n}) was configured`)),i});this.B=n.map(t=>{let n,r;return n=!1,r={method:(...i)=>{try{t.method(...i)}catch(t){var a,s;n||(n=!0,e.warn((a=r.type,s=r.name,`an inspector: "${s}" of type: "${a}" generated an exception`)))}},type:t.type,name:t.name,synchronous:t.synchronous}})}hasInspectors(){return 0!==this.B.length}onFlagUsed(t,e,n){this.B.forEach(r=>{r.type===nu&&r.method(t,e,n)})}onFlagsChanged(t){this.B.forEach(e=>{e.type===nc&&e.method(t)})}onFlagChanged(t,e){this.B.forEach(n=>{n.type===nd&&n.method(t,e)})}onIdentityChanged(t){this.B.forEach(e=>{e.type===nh&&e.method(t)})}},nf=class{constructor(t){this.t=t,this.n=new Map}on(t,e){var n,r;if("string"!=typeof t){null==(n=this.t)||n.warn("Only string event names are supported.");return}this.n.has(t)?null==(r=this.n.get(t))||r.push(e):this.n.set(t,[e])}off(t,e){let n=this.n.get(t);if(n){if(e){let r=n.filter(t=>t!==e);0===r.length?this.n.delete(t):this.n.set(t,r);return}this.n.delete(t)}}Dn(t,e,...n){var r;try{t(...n)}catch(t){null==(r=this.t)||r.error(`Encountered error invoking handler for "${e}", detail: "${t}"`)}}emit(t,...e){let n=this.n.get(t);null==n||n.forEach(n=>this.Dn(n,t,...e))}eventNames(){return[...this.n.keys()]}listenerCount(t){var e,n;return null!=(n=null==(e=this.n.get(t))?void 0:e.length)?n:0}},{ClientMessages:nv,ErrorKinds:ny}=ei,nm=class{constructor(t,e,n,r,i,a){var s,o;if(this.sdkKey=t,this.autoEnvAttributes=e,this.platform=n,this.u=function(){let t,e;return{set(n,r){t=n,e=r},getContext:()=>e,getUnwrappedContext:()=>t,newIdentificationPromise(){let t,e;return{identifyPromise:new Promise((n,r)=>{t=n,e=r}),identifyResolve:t,identifyReject:e}},hasContext:()=>void 0!==e,hasValidContext(){return this.hasContext()&&e.valid}}}(),this.Ft=15,this.T=new e2(!1),this.dt=new e2(!0),this.$t=!1,this.Sn=function(){let t,e=[];return{execute(n,r=!1){var i,a;let s=function(t,e,n=!1){let r,i=new Promise(n=>{r=(r,i)=>{var a;try{null==(a=t.after)||a.call(t,r,i)}catch(t){null==e||e.error(`Error in after callback: ${t}`)}n(r)}}),a=t.before?t.before():Promise.resolve(void 0),s=!1;return{execute:()=>{s&&(null==e||e.error(eo)),s=!0,a.then(e=>{t.execute(e).then(t=>r({status:"complete",result:t},e)).catch(t=>r({status:"error",error:t},e))}).catch(t=>{null==e||e.error(t),r({status:"error",error:t},void 0)})},shed:()=>{s&&(null==e||e.error(eo)),s=!0,a.then(t=>{r({status:"shed"},t)})},promise:i,sheddable:n}}(n,void 0,r);return t?(null!=(i=e[e.length-1])&&i.sheddable&&(null==(a=e.pop())||a.shed()),e.push(s)):(t=s.promise.finally(()=>{t=void 0,function n(){if(!t&&e.length>0){let r=e.shift();t=r.promise.finally(()=>{t=void 0,n()}),r.execute()}}()}),s.execute()),s.promise},pendingCount:()=>e.length}}(),this.Ee=!1,!t)throw Error("You must configure the client with a client-side SDK key");if(!n.encoding)throw Error("Platform must implement Encoding because btoa is required.");this.e=new eC(r,a),this.logger=this.e.logger,this.Ee=null!=(s=null==a?void 0:a.requiresStart)&&s,this.initialContext=null==a?void 0:a.initialContext,this.be=function(t,e,n,r=!0,i="user-agent"){let{userAgentBase:a,version:s,wrapperName:o,wrapperVersion:l}=e.sdkData(),u={[i]:`${null!=a?a:"NodeJSClient"}/${s}`};return r&&(u.authorization=t),o&&(u["x-launchdarkly-wrapper"]=l?`${o}/${l}`:o),null!=n&&n.value&&(u["x-launchdarkly-tags"]=n.value),u}(this.sdkKey,this.platform.info,this.e.tags,this.e.serviceEndpoints.includeAuthorizationHeader,this.e.userAgentHeaderName),this.R=new nn(this.platform,t,this.e.maxCachedContexts,null!=(o=this.e.disableCache)&&o,this.e.logger),this.C=((t,e,n)=>{if(e.sendEvents&&!e.diagnosticOptOut)return new ei.DiagnosticsManager(t,n,{customBaseURI:e.serviceEndpoints.polling!==eP,customStreamURI:e.serviceEndpoints.streaming!==e$,customEventsURI:e.serviceEndpoints.events!==tb.DEFAULT_EVENTS,eventsCapacity:e.capacity,eventsFlushIntervalMillis:tR(e.flushInterval),reconnectTimeMillis:tR(e.streamInitialReconnectDelay),diagnosticRecordingIntervalMillis:tR(e.diagnosticRecordingInterval),allAttributesPrivate:e.allAttributesPrivate,usingSecureMode:!1,bootstrapMode:!1})})(t,this.e,n),this.E=((t,e,n,r,i)=>{if(e.sendEvents)return new ei.EventProcessor(w(D({},e),b({eventsCapacity:e.capacity})),new ty(t,e,n),r,void 0,i,!1,!0)})(t,this.e,n,this.be,this.C),this.emitter=new nf,this.emitter.on("error",(t,e)=>{this.logger.error(`error: ${e}, context: ${JSON.stringify(t)}`)}),this.R.on((t,e,n)=>{this.kn(e,n);let r=Z.toLDContext(t);this.emitter.emit("change",r,e),e.forEach(t=>{this.emitter.emit(`change:${t}`,r)})}),this.dataManager=i(this.R,this.e,this.be,this.emitter,this.C),this.isFDv2=!!this.e.dataSystem,this.dataSystemConfig=this.e.dataSystem;let l=[...this.e.hooks];if(this.environmentMetadata=function(t,e,n){let r=e.info.sdkData(),i;n.applicationInfo&&(n.applicationInfo.id&&((i=null!=i?i:{}).id=n.applicationInfo.id),n.applicationInfo.version&&((i=null!=i?i:{}).version=n.applicationInfo.version),n.applicationInfo.name&&((i=null!=i?i:{}).name=n.applicationInfo.name),n.applicationInfo.versionName&&((i=null!=i?i:{}).versionName=n.applicationInfo.versionName));let a={name:r.userAgentBase,version:r.version};r.wrapperName&&(a.wrapperName=r.wrapperName),r.wrapperVersion&&(a.wrapperVersion=r.wrapperVersion);let s={sdk:a,[n.credentialType]:t};return i&&(s.application=i),s}(this.sdkKey,this.platform,this.e),this.e.getImplementationHooks(this.environmentMetadata).forEac
1h(t=>{l.push(t)}),this.N=new nl(this.logger,l),this.Y=new np(this.e.inspectors,this.logger),this.Y.hasInspectors()&&this.N.addHook(function(t){return{getMetadata:()=>({name:"LaunchDarkly-Inspector-Adapter"}),afterEvaluation:(e,n,r)=>(t.onFlagUsed(e.flagKey,r,e.context),n),afterIdentify:(e,n,r)=>(t.onIdentityChanged(e.context),n)}}(this.Y)),r.cleanOldPersistentData&&null!=a&&a.getLegacyStorageKeys&&this.platform.storage)try{this.logger.debug("Cleaning old persistent data."),Promise.all(a.getLegacyStorageKeys().map(t=>{var e;return null==(e=this.platform.storage)?void 0:e.clear(t)})).catch(t=>{this.logger.error(`Error cleaning old persistent data: ${t}`)}).finally(()=>{this.logger.debug("Cleaned old persistent data.")})}catch(t){this.logger.error(`Error cleaning old persistent data: ${t}`)}}allFlags(){return Object.entries(this.R.getAll()).reduce((t,[e,n])=>(null===n.flag||void 0===n.flag||n.flag.deleted||(t[e]=n.flag.value),t),{})}async close(){var t;await this.flush(),null==(t=this.E)||t.close(),this.dataManager.close(),this.logger.debug("Closed event processor and data source.")}async flush(){var t;try{await (null==(t=this.E)?void 0:t.flush()),this.logger.debug("Successfully flushed event processor.")}catch(t){return this.logger.error(`Error flushing event processor: ${t}.`),{error:t,result:!1}}return{result:!0}}getContext(){return this.u.hasContext()?tC(this.u.getUnwrappedContext()):void 0}getInternalContext(){return this.u.getContext()}presetFlags(t){this.R.presetFlags(t)}start(t){var e,n;if(this.initializeResult)return Promise.resolve(this.initializeResult);if(this.startPromise)return this.startPromise;if(!this.initialContext)return this.logger.error("Initial context not set"),Promise.resolve({status:"failed",error:Error("Initial context not set")});let r=w(D({},null!=(e=null==t?void 0:t.identifyOptions)?e:{}),b({sheddable:!1}));if(null!=t&&t.bootstrap&&!r.bootstrap&&(r.bootstrap=t.bootstrap),r.bootstrap)try{r.bootstrapParsed||(r.bootstrapParsed=e4(this.logger,r.bootstrap)),r.bootstrapParsed&&this.presetFlags(r.bootstrapParsed)}catch(t){this.logger.error("Failed to bootstrap data",t)}return this.initializedPromise||(this.initializedPromise=new Promise(t=>{this.initResolve=t})),this.startPromise=this.Rt(this.initializedPromise,null!=(n=null==t?void 0:t.timeout)?n:5,"start"),this.identifyResult(this.initialContext,r),this.startPromise}async identify(t,e){let n=await this.identifyResult(t,e);if("error"===n.status)throw n.error;if("timeout"===n.status){let t=new tI(`identify timed out after ${n.timeout} seconds.`);throw this.logger.error(t.message),t}}async identifyResult(t,e){var n,r;if(this.Ee&&!this.startPromise)return this.logger.error("The client must be started before a context can be identified. Call start() prior to identifying a context."),{status:"error",error:Error("Identify called before start")};let i=null!=(n=null==e?void 0:e.timeout)?n:5,a=(null==e?void 0:e.timeout)===void 0&&(null==e?void 0:e.noTimeout)===!0;i>this.Ft&&this.logger.warn(`The identify function was called with a timeout greater than ${this.Ft} seconds. We recommend a timeout of less than ${this.Ft} seconds.`);let s=this.Sn.execute({before:async()=>{let n=await e0(t,this.platform);this.autoEnvAttributes===tz.Enabled&&(n=await eB(n,this.platform,this.e));let r=Z.fromLDContext(n);if(r.valid){let t=this.N.identify(n,null==e?void 0:e.timeout);return{context:n,checkedContext:r,afterIdentify:t}}return{context:n,checkedContext:r}},execute:async t=>{var n;let{context:r,checkedContext:i}=t;if(!i.valid){let t=Error("Context was unspecified or had no key");return this.emitter.emit("error",r,t),Promise.reject(t)}this.u.set(r,i),null==(n=this.E)||n.sendEvent(this.T.identifyEvent(i));let{identifyPromise:a,identifyResolve:s,identifyReject:o}=this.u.newIdentificationPromise();return this.logger.debug(`Identifying ${JSON.stringify(i)}`),await this.dataManager.identify(s,o,i,e),a},after:async(t,e)=>{var n,r,i;"complete"===t.status?null==(n=null==e?void 0:e.afterIdentify)||n.call(e,{status:"completed"}):"shed"===t.status?null==(r=null==e?void 0:e.afterIdentify)||r.call(e,{status:"shed"}):"error"===t.status&&(null==(i=null==e?void 0:e.afterIdentify)||i.call(e,{status:"error"}))}},null!=(r=null==e?void 0:e.sheddable)&&r).then(t=>{if("error"===t.status){let e={status:"error",error:t.error};return this.maybeSetInitializationResult({status:"failed",error:t.error}),e}return"shed"===t.status?{status:"shed"}:(this.maybeSetInitializationResult({status:"complete"}),{status:"completed"})});return a?s:Promise.race([s,new Promise(t=>{setTimeout(()=>{t({status:"timeout",timeout:i})},1e3*i)})])}maybeSetInitializationResult(t){void 0===this.initializeResult&&(this.initializeResult=t,this.emitter.emit("ready"),"complete"===t.status&&this.emitter.emit("initialized"),this.initResolve&&(this.initResolve(t),this.initResolve=void 0))}waitForInitialization(t){var e;
1let n=null!=(e=null==t?void 0:t.timeout)?e:5;return this.initializeResult?Promise.resolve(this.initializeResult):(this.initializedPromise||this.initializedPromise||(this.initializedPromise=new Promise(t=>{this.initResolve=t})),this.Rt(this.initializedPromise,n))}Rt(t,e,n="waitForInitialization"){let r=t$(e,n);return Promise.race([t.then(t=>(r.cancel(),t)),r.promise.then(()=>({status:"complete"})).catch(()=>({status:"timeout"}))]).catch(t=>{var e;return null==(e=this.logger)||e.error(t.message),{status:"failed",error:t}})}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}track(t,e,n){var r,i;this.u.hasValidContext()?(void 0===n||U.Number.is(n)||null==(r=this.logger)||r.warn(nv.invalidMetricValue(typeof n)),null==(i=this.E)||i.sendEvent(this.e.trackEventModifier(this.T.customEvent(t,this.u.getContext(),e,n))),this.N.afterTrack({key:t,context:this.u.getUnwrappedContext(),data:e,metricValue:n})):this.logger.warn(nv.MissingContextKeyNoEvent)}ht(t,e,n,r){var i,a,s,o,l;let u=this.u.hasContext();u||null==(i=this.logger)||i.warn("Flag evaluation called before client is fully initialized, data from this evaulation could be stale.");let c=this.u.getContext(),d=this.R.get(t);if(void 0===d||d.flag.deleted){let n=null!=e?e:null;return null==(a=this.logger)||a.warn(`Unknown feature flag "${t}"; returning default value ${n}.`),u&&(null==(s=this.E)||s.sendEvent(this.T.unknownFlagEvent(t,n,c))),e1(ny.FlagNotFound,e)}let{reason:h,value:g,variation:p,prerequisites:f}=d.flag;if(r){let[i,a]=r(g);if(!i){u&&(null==(o=this.E)||o.sendEvent(n.evalEventClient(t,e,e,d.flag,c,h)));let r=new tO(`Wrong type "${a}" for feature flag "${t}"; returning default value`);return this.emitter.emit("error",this.u.getUnwrappedContext(),r),e1(ny.WrongType,e)}}let v=e3(g,p,h);return null==g&&(this.logger.debug("Result value is null. Providing default value."),v.value=e),null==f||f.forEach(t=>{this.ht(t,void 0,this.T)}),u&&(null==(l=this.E)||l.sendEvent(n.evalEventClient(t,g,e,d.flag,c,h))),v}variation(t,e){let{value:n}=this.N.withEvaluation(t,this.u.getUnwrappedContext(),e,()=>this.ht(t,e,this.T));return n}variationDetail(t,e){return this.N.withEvaluation(t,this.u.getUnwrappedContext(),e,()=>this.ht(t,e,this.dt))}H(t,e,n,r){return this.N.withEvaluation(t,this.u.getUnwrappedContext(),e,()=>this.ht(t,e,n,r))}boolVariation(t,e){return this.H(t,e,this.T,t=>[U.Boolean.is(t),U.Boolean.getType()]).value}jsonVariation(t,e){return this.variation(t,e)}numberVariation(t,e){return this.H(t,e,this.T,t=>[U.Number.is(t),U.Number.getType()]).value}stringVariation(t,e){return this.H(t,e,this.T,t=>[U.String.is(t),U.String.getType()]).value}boolVariationDetail(t,e){return this.H(t,e,this.dt,t=>[U.Boolean.is(t),U.Boolean.getType()])}numberVariationDetail(t,e){return this.H(t,e,this.dt,t=>[U.Number.is(t),U.Number.getType()])}stringVariationDetail(t,e){return this.H(t,e,this.dt,t=>[U.String.is(t),U.String.getType()])}jsonVariationDetail(t,e){return this.variationDetail(t,e)}addHook(t){this.N.addHook(t)}setEventSendingEnabled(t,e){var n,r,i,a;this.$t!==t&&(this.$t=t,t?(this.logger.debug("Starting event processor"),null==(n=this.E)||n.start()):e?(null==(r=this.logger)||r.debug("Flushing event processor before disabling."),this.flush().then(()=>{var t,e;this.$t||(null==(t=this.logger)||t.debug("Stopping event processor."),null==(e=this.E)||e.close())})):(null==(i=this.logger)||i.debug("Stopping event processor."),null==(a=this.E)||a.close()))}sendEvent(t){var e;null==(e=this.E)||e.sendEvent(t)}getDebugOverrides(){var t,e;return null==(e=(t=this.R).getDebugOverride)?void 0:e.call(t)}kn(t,e){if(!this.Y.hasInspectors())return;let n={};t.forEach(t=>{let e=this.R.get(t);if(null!=e&&e.flag&&!e.flag.deleted){let{reason:r,value:i,variation:a}=e.flag;n[t]=e3(i,a,r)}else n[t]={value:void 0,variationIndex:null}}),"init"===e?this.Y.onFlagsChanged(n):"patch"===e&&Object.entries(n).forEach(([t,e])=>{this.Y.onFlagChanged(t,e)})}};function nw(t){return{polling:()=>({pathGet:(e,n)=>`/sdk/evalx/${t}/contexts/${tH(n,e)}`,pathReport:(e,n)=>`/sdk/evalx/${t}/context`,pathPost(t,e){throw Error("Post for FDv1 unsupported.")},pathPing(t,e){throw Error("Ping for polling unsupported.")}}),streaming:()=>({pathGet:(e,n)=>`/eval/${t}/${tH(n,e)}`,pathReport:(e,n)=>`/eval/${t}`,pathPost(t,e){throw Error("Post for FDv1 unsupported.")}
1,pathPing:(e,n)=>`/ping/${t}`})}}function nb(t,e=()=>Date.now()){let n="CLOSED",r=e(),i;function a(){return{state:n,stateSince:r,lastError:i}}function s(i,o=!1){let l="INTERRUPTED"===i&&"INITIALIZING"===n?"INITIALIZING":i,u=n!==l;u&&(n=l,r=e()),(u||o)&&t.emit("dataSourceStatus",a())}return{get status(){return a()},requestStateUpdate(t){s(t)},reportError(t,n,r,a=!1){i={kind:t,message:n,statusCode:r,time:e()},s(a?"INTERRUPTED":"CLOSED",!0)}}}function nk(t){null==t||t.debug("Poll completed after the processor was closed. Skipping processing.")}var nE=class{constructor(t,e,n,r,i){this.Cn=t,this.In=e,this.Pn=n,this.m=r,this.t=i,this.h=!1}async De(){var t,e,n,r,i,a,s;if(this.h)return;let o=t=>{var e,n,r;null==(e=this.t)||e.error("Polling received invalid data"),null==(n=this.t)||n.debug(`Invalid JSON follows: ${t}`),null==(r=this.m)||r.call(this,new ti(tr.InvalidData,"Malformed JSON data in polling response"))};null==(t=this.t)||t.debug("Polling LaunchDarkly for feature flag updates");let l=Date.now();try{let t=await this.Cn.requestPayload();try{if(this.h)return void nk(this.t);let r=JSON.parse(t);try{null==(e=this.Pn)||e.call(this,r)}catch(t){null==(n=this.t)||n.error(`Exception from data handler: ${t}`)}}catch(e){o(t)}}catch(t){if(this.h)return void nk(this.t);if(void 0!==t.status&&!tP(t.status)){null==(r=this.t)||r.error(tN(t,"polling request")),null==(i=this.m)||i.call(this,new ti(tr.ErrorResponse,t.message,t.status));return}null==(a=this.t)||a.error(tN(t,"polling request","will retry"))}let u=Date.now()-l,c=Math.max(1e3*this.In-u,0);null==(s=this.t)||s.debug("Elapsed: %d ms, sleeping for %d ms",u,c),this.Nt=setTimeout(()=>{this.De()},c)}start(){this.De()}stop(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0),this.h=!0}close(){this.stop()}};function nS(t){null==t||t.debug("Ping completed after processor was closed. Skipping processing.")}var nx=class{constructor(t,e,n,r,i,a,s,o,l){var u;let c;this.xn=t,this.Ut=e,this.n=n,this.z=r,this.Ln=a,this.C=s,this.m=o,this.t=l,this.h=!1,c=e.useReport&&!r.getEventSourceCapabilities().customMethod?e.paths.pathPing(i,t):e.useReport?e.paths.pathReport(i,t):e.paths.pathGet(i,t);let d=[...null!=(u=e.queryParameters)?u:[]];this.Ut.withReasons&&d.push({key:"withReasons",value:"true"}),this.z=r,this.Se=D({},e.baseHeaders),this.t=l,this.An=tE(e.serviceEndpoints,c,d)}ke(){this.ft=Date.now()}zt(t){this.ft&&this.C&&this.C.recordStreamInit(this.ft,!t,Date.now()-this.ft),this.ft=void 0}Tn(t){var e,n,r;return!function({status:t}){return!t||tP(t)}(t)?(this.zt(!1),null==(e=this.m)||e.call(this,new ta(tr.ErrorResponse,t.message,t.status,!1)),null==(n=this.t)||n.error(tN(t,"streaming request")),!1):(null==(r=this.t)||r.warn(tN(t,"streaming request","will retry")),this.zt(!1),this.ke(),!0)}start(){let t;this.ke(),this.Ut.useReport?(this.Se["content-type"]="application/json",t={method:"REPORT",body:this.xn}):t={};let e=this.z.createEventSource(this.An,w(D({headers:this.Se},t),b({errorFilter:t=>this.Tn(t),initialRetryDelayMillis:this.Ut.initialRetryDelayMillis,readTimeoutMillis:3e5,retryResetIntervalMillis:6e4})));this.Ce=e,e.onclose=()=>{var t;null==(t=this.t)||t.info("Closed LaunchDarkly stream connection")},e.onerror=()=>{},e.onopen=()=>{var t;null==(t=this.t)||t.info("Opened LaunchDarkly stream connection")},e.onretrying=t=>{var e;null==(e=this.t)||e.info(`Will retry stream connection in ${t.delayMillis} milliseconds`)},this.n.forEach(({deserializeData:t,processJson:n},r)=>{e.addEventListener(r,e=>{var i,a,s,o,l;if(this.h)return void(null==(s=this.t)||s.debug(`Received ${r} event after processor was closed. Skipping processing.`));if(null==(i=this.t)||i.debug(`Received ${r} event`),null!=e&&e.data){this.zt(!0);let{data:i}=e,a=t(i);if(!a)return void(o=this.t,l=this.m,null==o||o.error(`Stream received invalid data in "${r}" message`),null==o||o.debug(`Invalid JSON follows: ${i}`),null==l||l(new ta(tr.InvalidData,"Malformed JSON data in event stream")));n(a)}else null==(a=this.m)||a.call(this,new ta(tr.InvalidData,"Unexpected payload from event stream"))})}),e.addEventListener("ping",async()=>{var t,e,n,r,i,a,s;null==(t=this.t)||t.debug("Got PING, going to poll LaunchDarkly for feature flag updates");try{let t=await this.Ln.requestPayload();try{if(this.h)return void nS(this.t);let r=JSON.parse(t);try{null==(e=this.n.get("put"))||e.processJson(r)}
1catch(t){null==(n=this.t)||n.error(`Exception from data handler: ${t}`)}}catch(e){null==(r=this.t)||r.error("Polling after ping received invalid data"),null==(i=this.t)||i.debug(`Invalid JSON follows: ${t}`),null==(a=this.m)||a.call(this,new ti(tr.InvalidData,"Malformed JSON data in ping polling response"))}}catch(t){if(this.h)return void nS(this.t);null==(s=this.m)||s.call(this,new ti(tr.ErrorResponse,t.message,t.status))}})}stop(){var t;null==(t=this.Ce)||t.close(),this.Ce=void 0,this.h=!0}close(){this.stop()}},nD=class{constructor(t,e,n,r,i,a,s,o,l){this.platform=t,this.flagManager=e,this.credential=n,this.config=r,this.getPollingPaths=i,this.getStreamingPaths=a,this.baseHeaders=s,this.emitter=o,this.diagnosticsManager=l,this.closed=!1,this.logger=r.logger,this.dataSourceStatusManager=nb(o),this.q=function(t,e,n){return{async handlePut(r,i){n.debug(`Got PUT: ${Object.keys(i)}`);let a=Object.entries(i).reduce((t,[e,n])=>(t[e]={version:n.version,flag:n},t),{});await t.init(r,a),e.requestStateUpdate("VALID")},async handlePatch(e,r){n.debug(`Got PATCH ${JSON.stringify(r,null,2)}`),t.upsert(e,r.key,{version:r.version,flag:r})},async handleDelete(e,r){n.debug(`Got DELETE ${JSON.stringify(r,null,2)}`),t.upsert(e,r.key,{version:r.version,flag:w(D({},r),b({deleted:!0,flagVersion:0,value:void 0,variation:0,trackEvents:!1}))})},handleStreamingError(t){e.reportError(t.kind,t.message,t.code,t.recoverable)},handlePollingError(t){e.reportError(t.kind,t.message,t.status,t.recoverable)}}}(e,this.dataSourceStatusManager,this.config.logger)}setConnectionParams(t){this.On=t}createPollingProcessor(t,e,n,r,i){let a=new nE(n,this.config.pollInterval,async t=>{await this.q.handlePut(e,t),null==r||r()},e=>{this.emitter.emit("error",t,e),this.q.handlePollingError(e),null==i||i(e)},this.logger);this.updateProcessor=this.Ie(a,this.dataSourceStatusManager)}createStreamingProcessor(t,e,n,r,i){var a;let s=new nx(JSON.stringify(t),{credential:this.credential,serviceEndpoints:this.config.serviceEndpoints,paths:this.getStreamingPaths(),baseHeaders:this.baseHeaders,initialRetryDelayMillis:1e3*this.config.streamInitialReconnectDelay,withReasons:this.config.withReasons,useReport:this.config.useReport,queryParameters:null==(a=this.On)?void 0:a.queryParameters},this.createStreamListeners(e,r),this.platform.requests,this.platform.encoding,n,this.diagnosticsManager,e=>{this.emitter.emit("error",t,e),this.q.handleStreamingError(e),null==i||i(e)},this.logger);this.updateProcessor=this.Ie(s,this.dataSourceStatusManager)}createStreamListeners(t,e){let n=new Map;return n.set("put",{deserializeData:JSON.parse,processJson:async n=>{await this.q.handlePut(t,n),null==e||e()}}),n.set("patch",{deserializeData:JSON.parse,processJson:async e=>{this.q.handlePatch(t,e)}}),n.set("delete",{deserializeData:JSON.parse,processJson:async e=>{this.q.handleDelete(t,e)}}),n}Ie(t,e){return{start:()=>{e.requestStateUpdate("INITIALIZING"),t.start()},stop:()=>{t.stop(),e.requestStateUpdate("CLOSED")},close:()=>{t.close(),e.requestStateUpdate("CLOSED")}}}close(){var t;null==(t=this.updateProcessor)||t.close(),this.closed=!0}},nO={foreground:"foregroundMode",background:"backgroundMode"},nI=[{conditions:{networkAvailable:!1},mode:"offline"},{conditions:{},mode:{configured:"foreground"}}];function nP(t,e,n,r){return{type:"changeSet",payload:t,fdv1Fallback:e,environmentId:n,freshness:r}}function n$(t,e){return{type:"status",state:"interrupted",errorInfo:t,fdv1Fallback:e}}function nC(){return{type:"status",state:"shutdown",fdv1Fallback:!1}}function nR(t,e){return{type:"status",state:"terminal_error",errorInfo:t,fdv1Fallback:e}}function nM(t,e){return{type:"status",state:"goodbye",reason:t,fdv1Fallback:e}}function nN(t){return{kind:tr.ErrorResponse,message:`Unexpected status code: ${t}`,statusCode:t,time:Date.now()}}function nA(t){return{kind:tr.NetworkError,message:t,time:Date.now()}}function nj(t){return{kind:tr.InvalidData,message:t,time:Date.now()}}function nT(t){return{kind:tr.Unknown,message:t,time:Date.now()}}async function nF(t){let{storage:e,crypto:n,environmentNamespace:r,context:i,logger:a}=t;if(!e)return null==a||a.debug("No storage available for cache initializer"),nP({version:0,type:"none",updates:[]},!1);let s=await e8(e,n,r,i,a);
1if(!s)return null==a||a.debug("Cache miss for context"),nP({version:0,type:"none",updates:[]},!1);let o={version:0,type:"full",updates:Object.entries(s.flags).map(([t,e])=>({kind:"flag-eval",key:t,version:e.version,object:function(t){let{version:e}=t;return O(t,["version"])}(e)}))},l=await e9(e,n,r,i,a);return null==a||a.debug("Loaded cached flag evaluations via cache initializer"),nP(o,!1,void 0,l)}function nL(t,e,n,r,i,a,s,o){let l=D({},a),u,c="GET",d;return o?(c="POST",l["content-type"]="application/json",u=t,d=n.pathPost(i,t)):d=n.pathGet(i,t),{async poll(t){let n=[...null!=s?s:[]];t&&n.push({key:"basis",value:t});let i=tS(e,d,n),a=await r.fetch(i,{method:c,headers:l,body:u}),o=304===a.status?null:await a.text();return{status:a.status,headers:a.headers,body:o}}}}function nz(t){return t}async function nU(t,e,n){var r,i,a;let s=!1,o;try{let r,l,u=await t.poll(e);if(r=u.headers.get("x-ld-fd-fallback"),s=null!==r&&"true"===r.toLowerCase(),i=u.headers,o=null!=(a=i.get("x-ld-envid"))?a:void 0,304===u.status)return nP({version:0,type:"none",updates:[]},s,o);if(u.status<200||u.status>=300){let t=nN(u.status);return null==n||n.error(`Polling request failed with HTTP error: ${u.status}`),u.status<=0||tP(u.status)?n$(t,s):nR(t,s)}if(!u.body){let t=nj("Empty response body");return null==n||n.error("Polling request received empty response body"),n$(t,s)}try{l=JSON.parse(u.body)}catch(e){let t=nj("Malformed JSON data in polling response");return null==n||n.error("Polling request received malformed data"),n$(t,s)}if(!Array.isArray(l.events)){let t=nj("Invalid polling response: missing or invalid events array");return null==n||n.error("Polling response does not contain a valid events array"),n$(t,s)}return function(t,e,n,r){let i=ei.createProtocolHandler({"flag-eval":nz},r),a;if(t.forEach(t=>{if(a)return;let s=i.processEvent(t);switch(s.type){case"payload":a=nP(s.payload,e,n);break;case"goodbye":a=nM(s.reason,e);break;case"serverError":{let t=nT(s.reason);null==r||r.error(`Server error during polling: ${s.reason}`),a=n$(t,e);break}case"error":if("MISSING_PAYLOAD"===s.kind||"PROTOCOL_ERROR"===s.kind){let t=nj(s.message);null==r||r.warn(`Protocol error during polling: ${s.message}`),a=n$(t,e)}else null==r||r.warn(s.message)}}),a)return a;let s=nT("Unexpected end of polling response");return null==r||r.error("Unexpected end of polling response"),n$(s,e)}(l.events,s,o,n)}catch(e){let t=null!=(r=null==e?void 0:e.message)?r:String(e);return null==n||n.error(`Polling request failed with network error: ${t}`),n$(nA(t),s)}}var nV=Symbol("shutdown");function nq(){let t=[],e=[];return{put(n){let r=e.shift();r?r(n):t.push(n)},take:()=>t.length>0?Promise.resolve(t.shift()):new Promise(t=>{e.push(t)})}}function nK(t,e){var n,r;let i=null!=(n=null==e?void 0:e.isFDv1Fallback)&&n,a=null!=(r=null==e?void 0:e.initialState)?r:i?"blocked":"available";return{factory:t,isFDv1Fallback:i,state:a}}var nH=["server-intent","put-object","delete-object","payload-transferred","goodbye","error","heart-beat"];function n_(t,e){var n,r;return null!=e&&e.pollingBaseUri||null!=e&&e.streamingBaseUri?new tb(null!=(n=e.streamingBaseUri)?n:t.serviceEndpoints.streaming,null!=(r=e.pollingBaseUri)?r:t.serviceEndpoints.polling,t.serviceEndpoints.events,t.serviceEndpoints.analyticsEventPath,t.serviceEndpoints.diagnosticEventPath,t.serviceEndpoints.includeAuthorizationHeader,t.serviceEndpoints.payloadFilterKey):t.serviceEndpoints}function nB(t,e){if(!(null!=e&&e.pollingBaseUri))return t.requestor;let n=n_(t,e);return nL(t.plainContextString,n,t.polling.paths,t.requests,t.encoding,t.baseHeaders,t.queryParams)}function nJ(t,e,n){var r,i;let a=n_(e,t.endpoints),s=nB(e,t.endpoints),o=e.streaming.paths.pathGet(e.encoding,e.plainContextString);return function(t){let e=nq(),n=ei.createProtocolHandler({"flag-eval":nz},t.logger),r=D({},t.headers);function i(){var e;let n=[...t.parameters],r=null==(e=t.selectorGetter)?void 0:e.call(t);return r&&n.push({key:"basis",value:encodeURIComponent(r)}),tE(t.serviceEndpoints,t.streamUriPath,n)}let a,s,o=!1,l=!1,u=!1;function c(){s=Date.now()}function d(e){s&&t.diagnosticsManager&&t.diagnosticsManager.recordStreamInit(s,!e,Date.now()-s),s=void 0}
1return{start(){if(l||u)return;l=!0,c();let s=t.requests.createEventSource(i(),{headers:r,errorFilter:n=>{var r,i,a,s,l,u;return(null==(r=n.headers)?void 0:r["x-ld-fd-fallback"])==="true"?(o=!0,d(!1),e.put(nR(nN(null!=(i=n.status)?i:0),!0)),!1):!function({status:t}){return!t||tP(t)}(n)?(null==(a=t.logger)||a.error(tN(n,"streaming request")),d(!1),e.put(nR(nN(null!=(s=n.status)?s:0),o)),!1):(null==(l=t.logger)||l.warn(tN(n,"streaming request","will retry")),d(!1),c(),e.put(n$(nN(null!=(u=n.status)?u:0),o)),!0)},initialRetryDelayMillis:t.initialRetryDelayMillis,readTimeoutMillis:3e5,retryResetIntervalMillis:6e4,urlBuilder:i});a=s,nH.forEach(r=>{s.addEventListener(r,i=>{let a;if(u){null==(s=t.logger)||s.debug(`Received ${r} event after processor was closed. Skipping.`);return}if(!(null!=i&&i.data)){"error"!==r&&(null==(l=t.logger)||l.warn(`Event from EventStream missing data for "${r}".`));return}null==(c=t.logger)||c.debug(`Received ${r} event`);try{a=JSON.parse(i.data)}catch(n){null==(h=t.logger)||h.error(`Stream received data that was unable to be parsed in "${r}" message`),null==(g=t.logger)||g.debug(`Data follows: ${i.data}`),e.put(n$(nj("Malformed JSON in EventStream"),o));return}var s,l,c,h,g,p=n.processEvent({event:r,data:a});switch(p.type){case"payload":d(!0),e.put(nP(p.payload,o));break;case"goodbye":e.put(nM(p.reason,o));break;case"serverError":e.put(n$(nT(p.reason),o));break;case"error":("MISSING_PAYLOAD"===p.kind||"PROTOCOL_ERROR"===p.kind)&&e.put(n$(nj(p.message),o))}})}),s.addEventListener("ping",async()=>{var n,r,i,a,s,l,c;if(u){null==(n=t.logger)||n.debug("Ping received after processor was closed. Skipping.");return}if(null==(r=t.logger)||r.debug("Got PING, going to poll LaunchDarkly for feature flag updates"),!t.pingHandler){null==(i=t.logger)||i.warn("Ping event received but no ping handler configured.");return}try{let n=await t.pingHandler.handlePing();if(u){null==(a=t.logger)||a.debug("Ping completed after processor was closed. Skipping processing.");return}e.put(n)}catch(n){if(u)return;null==(l=t.logger)||l.error(`Error handling ping: ${null!=(s=null==n?void 0:n.message)?s:n}`),e.put(n$(nA(null!=(c=null==n?void 0:n.message)?c:"Error during ping poll"),o))}}),s.onclose=()=>{var e;null==(e=t.logger)||e.info("Closed LaunchDarkly stream connection")},s.onerror=t=>{var n;u||t&&"number"==typeof t.status||e.put(n$(nA(null!=(n=null==t?void 0:t.message)?n:"IO Error"),o))},s.onopen=()=>{var e;null==(e=t.logger)||e.info("Opened LaunchDarkly stream connection"),n.reset()},s.onretrying=e=>{var n;null==(n=t.logger)||n.info(`Will retry stream connection in ${e.delayMillis} milliseconds`)}},close(){u||(u=!0,null==a||a.close(),a=void 0,e.put(nC()))},takeResult:()=>e.take()}}({requests:e.requests,serviceEndpoints:a,streamUriPath:o,parameters:e.queryParams,selectorGetter:n,headers:e.baseHeaders,initialRetryDelayMillis:(null!=(r=t.initialReconnectDelay)?r:e.streaming.initialReconnectDelaySeconds)*1e3,logger:e.logger,pingHandler:(i=e.logger,{handlePing:()=>nU(s,n(),i)})})}function nG(t,e,n){let r,i,a=!1,s=new Promise(t=>{r=t});function o(){let n;i||a||(i={promise:(n=t$(t/1e3,`${e} condition`)).promise.then(()=>new Promise(()=>{}),()=>e),cancel:n.cancel}).promise.then(t=>{i=void 0,null==r||r(t)})}function l(){null==i||i.cancel(),i=void 0}return n||o(),{promise:s,inform(t){a||null==n||n(t,{start:o,cancel:l})},close(){a=!0,l()}}}function nW(t){return nG(t,"fallback",(t,{start:e,cancel:n})=>{"changeSet"===t.type?n():"status"===t.type&&"interrupted"===t.state&&e()})}function nZ(t){return{promise:0===t.length?void 0:Promise.race(t.map(t=>t.promise)),inform(e){t.forEach(t=>t.inform(e))},close(){t.forEach(t=>t.close())}}}var nY="[FDv2DataManagerBase]";function nQ(){return"u">typeof document}function nX(){return"u">typeof window}function n0(t,e,n){return nQ()?(document.addEventListener(t,e,n),()=>{document.removeEventListener(t,e,n)}):()=>{}}function n1(t,e,n){return nX()?(window.addEventListener(t,e,n),()=>{window.removeEventListener(t,e,n)}):()=>{}}function n3(){return nX()?window.location.href:""}var n2=class extends nD{constructor(t,e,n,r,i,a,s,o,l,u){super(t,e,n,r,a,s,o,l,u),this.Hn=i,this.Z=void 0,this.jt=!1,this.Z=i.streaming}I(t,...e){this.logger.debug(`[BrowserDataManager] ${t}`,...e)}async identify(t,e,n,r){this.closed?this.I("Identify called after data manager was closed."):(this.context=n,null!=r&&r.hash?this.setConnectionParams({queryParameters:[{key:"h",value:r.hash}]}):this.setConnectionParams(),this.l=null==r?void 0:r.hash,null!=r&&r.bootstrap?this.Mn(n,r,t):(await this.flagManager.loadCached(n)&&this.I("Identify - Flags loaded from cache. Continuing to initialize via a poll."),await this.Fn(n,t,e)),this.Pe(),this.Vt())}async $n(t){let e=es(JSON.stringify(Z.toLDContext(t)),this.config.serviceEndpoints,this.getPollingPaths(),this.platform.requests,this.platform.encoding,this.baseHeaders,[],this.config.withReasons,this.config.useReport,this.l),n;for(let t=0;t<=3;t+=1)try{return await e.requestPayload()}catch(e){if(!function({status:t}){return!t||tP(t)}(e))throw e;n=e,t<3&&(this.I(tN(e,"initial poll request","will retry")),await t_(1e3))}throw n}async Fn(t,e,n){var r,i;try{this.dataSourceStatusManager.requestStateUpdate("INITIALIZING");let n=await this.$n(t);try{let r=this.createStreamListeners(t,e).get("put");r.processJson(r.deserializeData(n))}catch(t){this.dataSourceStatusManager.reportError(tr.InvalidData,null!=(r=t.message)?r:"Could not parse poll response")}}catch(t){this.dataSourceStatusManager.reportError(tr.NetworkError,null!=(i=t.message)?i:"unexpected network error",t.status),n(t)}}Mn(t,e,n){let{bootstrapParsed:r}=e;r||(r=e4(this.logger,e.bootstrap)),this.flagManager.setBootstrap(t,r),this.dataSourceStatusManager.requestStateUpdate("VALID"),this.I("Identify - Initialization completed from bootstrap"),n()}setForcedStreaming(t){this.Z=t,this.Vt()}setAutomaticStreamingState(t){this.jt=t,this.Vt()}Vt(){let t=this.Z||this.jt&&void 0===this.Z;this.I(`Updating streaming state. forced(${this.Z}) automatic(${this.jt})`),t?this.Rn():this.Pe()}Pe(){var t;this.updateProcessor&&this.I("Stopping update processor."),null==(t=this.updateProcessor)||t.close(),this.updateProcessor=void 0}Rn(){this.updateProcessor?this.I("Update processor already active. Not changing state."):this.context?(this.I("Starting update processor."),this.Nn(this.context)):this.I("Context not set, not starting update processor.")}Nn(t,e,n){var r;let i=Z.toLDContext(t);null==(r=this.updateProcessor)||r.close();let a=es(JSON.stringify(Z.toLDContext(t)),this.config.serviceEndpoints,this.getPollingPaths(),this.platform.requests,this.platform.encoding,this.baseHeaders,[],this.config.withReasons,this.config.useReport,this.l);this.createStreamingProcessor(i,t,a,e,n),this.updateProcessor.start()}};function n4(t){if("string"!=typeof t)throw TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var n6=class{constructor(t,e){let n=t.filter(t=>{var e;return null==(e=t.urls)?void 0:e.some(t=>(function(t,e,n,r){let i=(("substring"===t.kind||"regex"===t.kind)&&r.includes("/")?e:e.replace(r,"")).replace(n,"");switch(t.kind){case"exact":return RegExp(`^${n4(t.url)}/?$`).test(e);case"canonical":return RegExp(`^${n4(t.url)}/?$`).test(i);case"substring":return RegExp(`.*${n4(t.substring)}.*$`).test(i);case"regex":return new RegExp(t.pattern).test(i);default:return!1}})(t,n3(),nX()?window.location.search:"",nX()?window.location.hash:""))}),r=n.filter(t=>"pageview"===t.kind),i=n.filter(t=>"click"===t.kind);r.forEach(t=>e(t)),i.length&&(this.xe=n0("click",t=>{let n;
1(n=[],i.forEach(e=>{let r=t.target,{selector:i}=e,a=function(t){if(nQ())return document.querySelectorAll(t)}(i);for(;r&&null!=a&&a.length;){for(let t=0;t<a.length;t+=1)if(r===a[t]){n.push(e);break}r=r.parentNode}}),n).forEach(t=>{e(t)})}))}close(){var t;null==(t=this.xe)||t.call(this)}},n5=class{constructor(t){this.Bt=n3();let e=()=>{let e=n3();e!==this.Bt&&(this.Bt=e,t())};this.Ht=setInterval(e,300);let n=n1("popstate",e);this.Le=()=>{n()}}close(){var t;this.Ht&&clearInterval(this.Ht),null==(t=this.Le)||t.call(this)}},n9=class{constructor(t,e,n,r,i,a=t=>new n5(t)){this.z=e,this.jn=r,this.zn=i,this.pt=[],this.Te=!1,this.X=`${n}/sdk/goals/${t}`,this.Ae=a(()=>{this.Gt()})}async initialize(){await this.Un(),this.Gt()}startTracking(){this.Te=!0,this.Gt()}Gt(){var t;this.Te&&(null==(t=this.qt)||t.close(),this.pt&&this.pt.length&&(this.qt=new n6(this.pt,t=>{this.zn(n3(),t)})))}async Un(){try{let t=await this.z.fetch(this.X);this.pt=await t.json()}catch(t){this.jn(new tD(`Encountered error fetching goals: ${t}`))}}close(){var t,e;null==(t=this.Ae)||t.close(),null==(e=this.qt)||e.close()}},n8={fetchGoals:!0,eventUrlTransformer:t=>t,streaming:void 0,plugins:[]},n7={fetchGoals:U.Boolean,eventUrlTransformer:U.Function,streaming:U.Boolean,plugins:U.createTypeArray("LDPlugin",{})},rt=class{constructor(t,e){switch(this.w=t,this.Oe=[],e){case"sha1":this.Kt="SHA-1";break;case"sha256":this.Kt="SHA-256";break;default:throw Error(`Algorithm is not supported ${e}`)}}async asyncDigest(t){let e=this.Oe.join(""),n=new TextEncoder().encode(e),r=await this.w.subtle.digest(this.Kt,n);switch(t){case"base64":return btoa(String.fromCharCode(...new Uint8Array(r)));case"hex":return[...new Uint8Array(r)].map(t=>t.toString(16).padStart(2,"0")).join("");default:throw Error(`Encoding is not supported ${t}`)}}update(t){return this.Oe.push(t),this}},re={start:0,end:3},rn={start:4,end:5},rr={start:6,end:7},ri={start:8,end:8},ra={start:9,end:9},rs={start:10,end:15};function ro(t,e){let n="";for(let r=e.start;r<=e.end;r+=1)n+=t[r].toString(16).padStart(2,"0");return n}var rl=class{createHash(t){return new rt(function(){if("u">typeof crypto)return crypto;throw Error("Access to a web crypto API is required")}(),t)}randomUUID(){var t;return"u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():((t=function(){if("u">typeof crypto&&crypto.getRandomValues){let t=new Uint8Array(16);return crypto.getRandomValues(t),[...t.values()]}let t=[];for(let e=0;e<16;e+=1)t.push(Math.floor(256*Math.random()));return t}())[ri.start]=(128|t[ri.start])&191,t[rr.start]=15&t[rr.start]|64,`${ro(t,re)}-${ro(t,rn)}-${ro(t,rr)}-${ro(t,ri)}${ro(t,ra)}-${ro(t,rs)}`)}},ru=class{btoa(t){return btoa(Array.from(new TextEncoder().encode(t),t=>String.fromCodePoint(t)).join(""))}},rc=class{constructor(t){this.e=t}platformData(){return{name:"JS"}}sdkData(){let t={name:"@launchdarkly/js-client-sdk",version:"4.6.5",userAgentBase:"JSClient"};return this.e.wrapperName&&(t.wrapperName=this.e.wrapperName),this.e.wrapperVersion&&(t.wrapperVersion=this.e.wrapperVersion),t}},rd=class{constructor(t,e){this.X=t,this.n={},this.x=new te(e.initialRetryDelayMillis,e.retryResetIntervalMillis),this.Me=e.errorFilter,this.Jt=e.urlBuilder,this.Fe()}Fe(){this.Jt&&(this.X=this.Jt()),this.G=new EventSource(this.X),this.G.onopen=()=>{var t;this.x.success(),null==(t=this.onopen)||t.call(this)},this.G.onerror=t=>{var e;t instanceof MessageEvent||(this.Vn(t),null==(e=this.onerror)||e.call(this,t))},Object.entries(this.n).forEach(([t,e])=>{e.forEach(e=>{var n;null==(n=this.G)||n.addEventListener(t,e)})})}addEventListener(t,e){var n,r;null!=(n=this.n)[t]||(n[t]=[]),this.n[t].push(e),null==(r=this.G)||r.addEventListener(t,e)}close(){var t,e;clearTimeout(this.Wt),this.Wt=void 0,null==(t=this.G)||t.close(),null==(e=this.onclose)||e.call(this)}Bn(t){var e;null==(e=this.onretrying)||e.call(this,{delayMillis:t}),this.Wt=setTimeout(()=>{this.Fe()},t)}Vn(t){this.close(),("number"!=typeof t.status||this.Me(t))&&this.Bn(this.x.fail())}},rh=class{fetch(t,e){return fetch(t,e)}createEventSource(t,e){return new rd(t,e)}getEventSourceCapabilities(){return{customMethod:!1,readTimeout:!1,headers:!1}}};function rg(){return"u">typeof localStorage}var rp=class{constructor(t){this.t=t}async clear(t){var e;try{localStorage.removeItem(t)}catch(n){null==(e=this.t)||e.error(`Error clearing key from localStorage: ${t}, reason: ${n}`)}}async get(t){var e;try{let e=localStorage.getItem(t);return null!=e?e:null}catch(n){return null==(e=this.t)||e.error(`Error getting key from localStorage: ${t}, reason: ${n}`),null}}async set(t,e){var n;try{localStorage.setItem(t,e)}catch(e){null==(n=this.t)||n.error(`Error setting key in localStorage: ${t}, reason: ${e}`)}}},rf=class{constructor(t,e){this.encoding=new ru,this.crypto=new rl,this.requests=new rh,rg()&&(this.storage=new rp(t)),this.info=new rc(e)}},rv=class extends nm{constructor(t,e,n,r={},i){var a,s,o,l,u;let{logger:c,debug:d}=r,h=null!=c?c:new tc({destination:{debug:console.debug,info:console.info,warn:console.warn,error:console.error},level:d?"debug":"info"}),g=null!=(a=r.baseUri)?a:"https://clientsdk.launchdarkly.com",p=null!=i?i:new rf(h,r),f=function(t,e){let n=D({},n8);
1return Object.entries(n7).forEach(r=>{let[i,a]=r,s=t[i];void 0!==s&&(a.is(s)?n[i]=s:e.warn(tp.wrongOptionType(i,a.getType(),typeof s)))}),n}(r,h),v=function(t){let e,n=(null!=(e=D({},t)).flushInterval||(e.flushInterval=2),e);return Object.keys(n8).forEach(t=>{delete n[t]}),n}(((t,e)=>w(t,b(e)))(D({},r),{logger:h})),{eventUrlTransformer:y}=f,m=nw(t);super(t,n,p,v,(e,n,r,i,a)=>{var s,o,l;return n.dataSystem?function(t){var e;let{platform:n,flagManager:r,config:i,baseHeaders:a,emitter:s,transitionTable:o,foregroundMode:l,backgroundMode:u,modeTable:c,sourceFactoryProvider:d,buildQueryParams:h,fdv1Endpoints:g,fallbackTimeoutMs:p,recoveryTimeoutMs:f}=t,{logger:v}=i,y=nb(s),m=null!=(e=i.dataSystem)&&e.connectionModes?D(D({},c),i.dataSystem.connectionModes):c,k,E=l,S=l,x,O,I,P,$=!1,C=!1,R=!1,M,N="fresh",A,j,T=!1,F,z,U="available",V="foreground";function q(){return void 0!==A?A:function(t,e){let n=t.find(t=>{var n;return n=t.conditions,Object.entries(n).every(([t,n])=>void 0===n||e[t]===n)});if(n){let{mode:t}=n;return"object"==typeof t?e[nO[t.configured]]:t}return e.foregroundMode}(o,{lifecycle:V,networkAvailable:"available"===U,foregroundMode:S,backgroundMode:null!=u?u:"offline"})}function K(){return!0===j?"streaming":!1===j?"streaming"===l?"one-shot":l:T?"streaming":l}function H(){S=K(),null==O||O.setRequestedMode(S)}function _(t){var e,n;let i;v.debug(`${nY} dataCallback: type=${t.type}, updates=${t.updates.length}, state=${t.state}`),k=t.state;let a=I;if(!a)return void v.warn(`${nY} dataCallback called without an identified context.`);let s=(n=null!=(e=t.updates)?e:[],i={},n.forEach(t=>{"flag-eval"===t.kind&&(i[t.key]=function(t){if(t.deleted)return{version:t.version,flag:{version:t.version,deleted:!0,value:void 0,trackEvents:!1}};let e=t.object;return{version:t.version,flag:w(D({},e),b({version:t.version}))}}(t))}),i);r.applyChanges(a,s,t.type).catch(t=>{v.warn(`${nY} Failed to persist flag cache: ${t}`)}),"cached"===N&&!$&&F&&($=!0,F(),F=void 0,z=void 0)}function B(t,e){if(!P)return void v.warn(`${nY} Cannot create data source without factory context.`);let{initializerFactories:n,synchronizerSlots:r}=function(t,e,n){var r,a,s,o,l;let u=[];n&&t.initializers.filter(t=>!(C&&"cache"===t.type)).forEach(t=>{let n=d.createInitializerFactory(t,e);n?u.push(n):v.warn(`${nY} Unsupported initializer type '${t.type}'. It will be skipped.`)});let c=[];if(t.synchronizers.forEach(t=>{let n=d.createSynchronizerSlot(t,e);n?c.push(n):v.warn(`${nY} Unsupported synchronizer type '${t.type}'. It will be skipped.`)}),g&&c.length>0){let n=t.fdv1Fallback,u=(null!=(r=null==n?void 0:n.pollInterval)?r:i.pollInterval)*1e3,d=null!=(a=null==n?void 0:n.endpoints)&&a.pollingBaseUri||null!=(s=null==n?void 0:n.endpoints)&&s.streamingBaseUri?new tb(null!=(o=n.endpoints.streamingBaseUri)?o:e.serviceEndpoints.streaming,null!=(l=n.endpoints.pollingBaseUri)?l:e.serviceEndpoints.polling,e.serviceEndpoints.events,e.serviceEndpoints.analyticsEventPath,e.serviceEndpoints.diagnosticEventPath,e.serviceEndpoints.includeAuthorizationHeader,e.serviceEndpoints.payloadFilterKey):e.serviceEndpoints;c.push(nK({create:()=>(function(t,e,n){let r=nq(),i,a=new Promise(t=>{i=t}),s,o=!1,l=!1;function u(t){o||(s=setTimeout(c,Math.min(Math.max(e-(Date.now()-t),0),e)))}async function c(){if(o)return;null==n||n.debug("Polling FDv1 endpoint for feature flag updates");let e=Date.now();try{let i,s=await t.requestPayload();if(o)return;try{var a;a=JSON.parse(s),i={version:1,type:"full",updates:Object.entries(a).map(([t,e])=>{var n;return{kind:"flag",key:t,version:null!=(n=e.version)?n:1,object:e}})}}catch(t){null==n||n.error("FDv1 polling received malformed data"),r.put({type:"status",state:"interrupted",errorInfo:nj("Malformed data in FDv1 polling response"),fdv1Fallback:!1}),u(e);return}r.put(nP(i,!1))}catch(t){if(o)return;if(void 0!==t.status&&!tP(t.status)){null==n||n.error(tN(t,"FDv1 polling request")),o=!0,null==i||i(nR(nN(t.status),!1)),i=void 0;return}null==n||n.warn(tN(t,"FDv1 polling request","will retry")),r.put({type:"status",state:"interrupted",errorInfo:t.status?nN(t.status):nA(t.message),fdv1Fallback:!1})}u(e)}return{next:()=>(l||(l=!0,c()),Promise.race([a,r.take()])),close(){o=!0,void 0!==s&&(clearTimeout(s),s=void 0),null==i||i(nC()),i=void 0}}})(es(e.plainContextString,d,g.polling(),e.requests,e.encoding,e.baseHeaders,e.queryParams,i.withReasons,i.useReport),u,v)},{isFDv1Fallback:!0}))}return{initializerFactories:u,synchronizerSlots:c}}(m[t],P,e);if(E=t,0===n.length&&0===r.length){v.debug(`${nY} Mode '${t}' has no sources. No data source created.`),!$&&F&&($=!0,F(),F=void 0,z=void 0);return}(x=function(t){let{initializerFactories:e,synchronizerSlots:n,dataCallback:r,statusManager:i,selectorGetter:a,logger:s,fallbackTimeoutMs:o=12e4,recoveryTimeoutMs:l=3e5}=t,u=!1,c=!1,d=!1,h,g,p=e.length>0&&e.every(t=>!0===t.isCache)&&0===n.length,f=function(t,e,n){let r,i=-1,a=-1,s=!1;function o(){r&&(r.close(),r=void 0)}return{get isShutdown(){return s},getNextInitializerAndSetActive(){if(s||(i+=1)>=t.length)return;o();let e=t[i].create(n);return r=e,e},getNextAvailableSynchronizerAndSetActive(){if(s||0===e.length)return;let t=0;for(;t<e.length;){(a+=1)>=e.length&&(a=0);let i=e[a];if("available"===i.state){o();let t=i.factory.create(n);return r=t,t}t+=1}},blockCurrentSynchronizer(){a>=0&&a<e.length&&(e[a].state="blocked")},resetSourceIndex(){a=-1},fdv1Fallback(){e.forEach(t=>
1{t.state=t.isFDv1Fallback?"available":"blocked"}),a=-1},isPrimeSynchronizer:()=>a===e.findIndex(t=>"available"===t.state),getAvailableSynchronizerCount:()=>e.filter(t=>"available"===t.state).length,hasFDv1Fallback:()=>e.some(t=>t.isFDv1Fallback),close(){s=!0,o()}}}(e,n,a);function v(){u||(u=!0,null==h||h(),h=void 0,g=void 0)}function y(t){r(t.payload),i.requestStateUpdate("VALID")}function m(t){t.errorInfo&&i.reportError(t.errorInfo.kind,t.errorInfo.message,t.errorInfo.statusCode,"interrupted"===t.state)}function w(t){return!!(t.fdv1Fallback&&f.hasFDv1Fallback())&&(f.fdv1Fallback(),!0)}async function b(){var t,e;let n=!1;for(;!c;){let r=f.getNextInitializerAndSetActive();if(void 0===r)break;let i=await r.run();if(c)return;if("changeSet"===i.type&&"none"!==i.payload.type){if(y(i),w(i)){d=!0;break}if(i.payload.state)return void v();d=!0}else if("status"===i.type){switch(i.state){case"interrupted":case"terminal_error":null==s||s.warn(`Initializer failed: ${null!=(e=null==(t=i.errorInfo)?void 0:t.message)?e:"unknown error"}`),m(i),n=!0;break;case"shutdown":return}w(i)}}c||(p?(d||n||i.requestStateUpdate("VALID"),v()):d&&v())}async function k(){for(var t,e,n,r;!c;){let i=f.getNextAvailableSynchronizerAndSetActive();if(void 0===i){u||(null==g||g(Error("All data sources exhausted without receiving data.")),h=void 0,g=void 0);return}let a=function(t,e,n=12e4,r=3e5){return t<=1?nZ([]):nZ(e?[nW(n)]:[nW(n),nG(r,"recovery")])}(f.getAvailableSynchronizerCount(),f.isPrimeSynchronizer(),o,l);a.promise&&(null==s||s.debug("Fallback condition active for current synchronizer."));let d=!0;try{for(;!c&&d;){let o=[i.next().then(t=>({source:"sync",value:t}))];void 0!==a.promise&&o.push(a.promise.then(t=>({source:"condition",value:t})));let l=await Promise.race(o);if(c)return;if("condition"===l.source){let t=l.value;"fallback"===t?null==s||s.warn("Fallback condition fired, moving to next synchronizer."):"recovery"===t&&(null==s||s.info("Recovery condition fired, resetting to primary synchronizer."),f.resetSourceIndex()),d=!1}else{let i=l.value;if(a.inform(i),"changeSet"===i.type)y(i),u||v();else if("status"===i.type)switch(i.state){case"interrupted":null==s||s.warn(`Synchronizer interrupted: ${null!=(e=null==(t=i.errorInfo)?void 0:t.message)?e:"unknown error"}`),m(i);break;case"terminal_error":null==s||s.error(`Synchronizer terminal error: ${null!=(r=null==(n=i.errorInfo)?void 0:n.message)?r:"unknown error"}`),m(i),f.blockCurrentSynchronizer(),d=!1;break;case"shutdown":return}w(i)&&(d=!1)}}}finally{a.close()}}}async function E(){if(0===e.length&&0===n.length){i.requestStateUpdate("VALID"),v();return}await b(),c||await k()}return{start:()=>new Promise((t,e)=>{h=t,g=e,i.requestStateUpdate("INITIALIZING"),E().then(()=>{u||(null==g||g(Error("Data source closed before initialization completed.")),h=void 0,g=void 0)}).catch(t=>{u?null==s||s.error(`Orchestration error: ${t}`):(null==g||g(t instanceof Error?t:Error(String(t))),h=void 0,g=void 0)})}),close(){c=!0,f.close()}}}({initializerFactories:n,synchronizerSlots:r,dataCallback:_,statusManager:y,selectorGetter:()=>k,logger:v,fallbackTimeoutMs:p,recoveryTimeoutMs:f})).start().then(()=>{$=!0,F&&(F(),F=void 0,z=void 0)}).catch(t=>{z&&(z(t instanceof Error?t:Error(String(t))),F=void 0,z=void 0)})}function J(t){if(R||!P)return;U=t.networkState,V=t.lifecycleState,S=t.requestedMode;let e=q();e===E?v.debug(`${nY} Reconcile: mode unchanged (${e}). No action.`):(v.debug(`${nY} Reconcile: mode switching from '${E}' to '${e}'.`),null==x||x.close(),x=void 0,B(e,!k))}return{get configuredForegroundMode(){return l},async identify(e,r,s,o){if(R)return void v.debug(`${nY} Identify called after close.`);null==x||x.close(),x=void 0,null==O||O.close(),O=void 0,k=void 0,$=!1,C=!1,N=null!=o&&o.waitForNetworkResults?"fresh":"cached",I=s,F=e,z=r;let l=JSON.stringify(Z.toLDContext(s)),u=h(o);i.withReasons&&u.push({key:"withReasons",value:"true"});let c={pathGet:(t,e)=>`/sdk/stream/eval/${tH(e,t)}`,pathReport(t,e){throw Error("Report for FDv2 unsupported.")},pathPost:(t,e)=>"/sdk/stream/eval",pathPing(t,e){throw Error("Ping for streaming unsupported.")}},d={pathGet:(t,e)=>`/sdk/poll/eval/${tH(e,t)}`,pathReport(t,e){throw Error("Report for FDv2 unsupported.")},pathPost:(t,e)=>"/sdk/poll/eval",pathPing(t,e){throw Error("Ping for polling unsupported.")}},g=nL(l,i.serviceEndpoints,d,n.requests,n.encoding,a,u),p=await eT(n.crypto,t.credential);if(R)return void v.debug(`${nY} Identify aborted: closed during async setup.`);P={requestor:g,requests:n.requests,encoding:n.encoding,serviceEndpoints:i.serviceEndpoints,baseHeaders:a,queryParams:u,plainContextString:l,logger:v,polling:{paths:d,intervalSeconds:i.pollInterval},streaming:{paths:c,initialReconnectDelaySeconds:i.streamInitialReconnectDelay},storage:n.storage,crypto:n.crypto,environmentNamespace:p,context:s},S=K();let f=q();v.debug(`${nY} Identify: initial mode resolved to '${f}'.`),(C=(null==o?void 0:o.bootstrap)!==void 0)?($=!0,y.requestStateUpdate("VALID"),null==F||F(),F=void 0,z=void 0,m[f].synchronizers.length>0&&B(f,!1)):B(f,!0),O=function(t){let{initialState:e,onReconcile:n,debounceMs:r=1e3}=t,{networkState:i,lifecycleState:a,requestedMode:s}=e,o,l=!1;function u(){l||(void 0!==o&&clearTimeout(o),o=setTimeout(()=>{o=void 0,l||n({networkState:i,lifecycleState:a,requestedMode:s})},r))}return{setNetworkState(t){i!==t&&(i=t,u())},setLifecycleState(t){a!==t&&(a=t,u())},setRequestedMode(t){s!==t&&(s=t,u())},close(){l=!0,void 0!==o&&(clearTimeout(o),o=void 0)}}}({initialState:{networkState:U,lifecycleState:V,requestedMode:S},onReconcile:J})},close(){R=!0,null==x||x.close(),x=void 0,null==O||O.close(),O=void 0,F=void 0,z=void 0},setNetworkState(t){U=t,null==O||O.setNetworkState(t)},setLifecycleState(t){"background"===t&&"background"!==V&&(null==M||M()),V=t,null==O||O.setLifecycleState(t)},setConnectionMode(t){A=t,void 0!==t?null==O||O.setRequestedMode(t):H()},getCurrentMode:()=>E,setFlushCallback(t){M=t},setForcedStreaming(t){j=t,H()},setAutomaticStreamingState(t){T=t,H()}}}({platform:p,flagManager:e,credential:t,config:n,baseHeaders:r,emitter:i,transitionTable:nI,foregroundMode:(s=n.dataSystem,"object"==typeof(l=s.automaticModeSwitching)&&null!==l&&"type"in l&&"manual"===l.type?s.automaticModeSwitching.initialConnectionMode:null!=(o=s.foregroundConnectionMode)?o:eI.foregroundConnectionMode),backgroundMode:void 0,modeTable:ek,sourceFactoryProvi
1der:{createInitializerFactory(t,e){switch(t.type){case"polling":{let n=nB(e,t.endpoints);return{create:t=>{var r;let i,a;return r=e.logger,a=new Promise(t=>{i=t}),{async run(){let e=t(),i;for(let t=0;t<=3;t+=1){let s=await Promise.race([a,nU(n,e,r)]);if(s===nV)return nC();if("changeSet"===s.type||"interrupted"!==s.state)return s;if(i=s,t<3&&(null==r||r.warn(`Recoverable polling error (attempt ${t+1}/4), retrying in 1000ms...`),await Promise.race([a,t_(1e3)])===nV))return nC()}let s=i;return nR(s.errorInfo,s.fdv1Fallback)},close(){null==i||i(nV),i=void 0}}}}}case"streaming":return{create:n=>{var r;let i,a,s;return r=nJ(t,e,n),i=!1,s=new Promise(t=>{a=t}),{run:()=>i?Promise.resolve(nC()):(r.start(),Promise.race([r.takeResult().then(t=>(r.close(),t)),s])),close(){i||(i=!0,r.close(),null==a||a(nC()),a=void 0)}}}};case"cache":var n;return n={storage:e.storage,crypto:e.crypto,environmentNamespace:e.environmentNamespace,context:e.context,logger:e.logger},{isCache:!0,create(t){let e,r=new Promise(t=>{e=t});return{run:async()=>Promise.race([r,nF(n)]),close(){null==e||e(nC()),e=void 0}}}};default:return}},createSynchronizerSlot(t,e){var n;switch(t.type){case"polling":{let r=(null!=(n=t.pollInterval)?n:e.polling.intervalSeconds)*1e3,i=nB(e,t.endpoints);return nK({create:t=>(function(t,e,n,r){let i=nq(),a,s=new Promise(t=>{a=t}),o,l=!1;async function u(){if(l)return;let s=Date.now();try{let r=await nU(t,n(),e);if(l)return;let s=!1;"status"===r.type&&"terminal_error"===r.state&&(l=!0,s=!0),s?(null==a||a(r),a=void 0):i.put(r)}catch(t){null==e||e.debug(`Polling error: ${t}`)}l||(o=setTimeout(()=>{u()},Math.min(Math.max(r-(Date.now()-s),0),r)))}return u(),{next:async()=>Promise.race([s,i.take()]),close(){l=!0,void 0!==o&&(clearTimeout(o),o=void 0),null==a||a(nC()),a=void 0}}})(i,e.logger,t,r)})}case"streaming":return nK({create:n=>{var r;let i,a,s,o;return r=nJ(t,e,n),i=!1,a=!1,o=new Promise(t=>{s=t}),{next:()=>a?Promise.resolve(nC()):(i||(i=!0,r.start()),Promise.race([r.takeResult(),o])),close(){a||(a=!0,r.close(),null==s||s(nC()),s=void 0)}}}});default:return}}},fdv1Endpoints:nw(t),buildQueryParams:e=>{let n=[{key:"auth",value:t}];return null!=e&&e.hash&&n.push({key:"h",value:e.hash}),n}}):new n2(p,e,t,n,f,m.polling,m.streaming,r,i,a)},{getLegacyStorageKeys:()=>(function(){if(!rg())return[];let t=[];for(let e=0;e<localStorage.length;e+=1){let n=localStorage.key(e);n&&t.push(n)}return t})().filter(e=>e.startsWith(`ld:${t}:`)),analyticsEventPath:`/events/bulk/${t}`,diagnosticEventPath:`/events/diagnostic/${t}`,includeAuthorizationHeader:!1,highTimeoutThreshold:5,userAgentHeaderName:"x-launchdarkly-user-agent",dataSystemDefaults:eI,trackEventModifier:t=>new ei.InputCustomEvent(t.context,t.key,t.data,t.metricValue,t.samplingRatio,y(n3())),getImplementationHooks:t=>ei.safeGetHooks(h,t,f.plugins),credentialType:"clientSideId",requiresStart:!0,initialContext:e}),this.setEventSendingEnabled(!0,!1),void 0!==f.streaming&&(null==(o=(s=this.dataManager).setForcedStreaming)||o.call(s,f.streaming)),null==(u=(l=this.dataManager).setFlushCallback)||u.call(l,()=>this.flush()),this.Zt=f.plugins,f.fetchGoals&&(this.Yt=new n9(t,p.requests,g,t=>{h.error(t.message)},(t,e)=>{let n=this.getInternalContext();if(!n)return;let r=y(t);"click"===e.kind?this.sendEvent({kind:"click",url:r,samplingRatio:1,key:e.key,creationDate:Date.now(),context:n,selector:e.selector}):this.sendEvent({kind:"pageview",url:r,samplingRatio:1,key:e.key,creationDate:Date.now(),context:n})}),this.Yt.initialize(),f.automaticBackgroundHandling&&function(t){n0("visibilitychange",()=>{"hidden"===(nQ()?document.visibilityState:"visibile")&&t()}),n1("pagehide",t)}(()=>this.flush()))}registerPlugins(t){var e;ei.safeRegisterPlugins(this.logger,this.environmentMetadata,t,this.Zt||[]);let n=this.getDebugOverrides();n&&(e=this.logger,(this.Zt||[]).forEach(t=>{var r;try{null==(r=t.registerDebug)||r.call(t,n)}catch(n){e.error(`Exception thrown registering plugin ${ei.safeGetName(e,t)}.`)}}))}async identify(t,e){return super.identify(t,e)}async identifyResult(t,e){var n;let r=(null==e?void 0:e.sheddable)===void 0?w(D({},e),b({sheddable:!0})):e,i=await super.identifyResult(t,r);return this.startPromise&&(null==(n=this.Yt)||n.startTracking()),i}setConnectionMode(t){this.dataManager.setConnectionMode?void 0===t||t in ek?this.dataManager.setConnectionMode(t):this.logger.warn(`setConnectionMode called with invali
1d mode '${t}'. Valid modes: ${Object.keys(ek).join(", ")}.`):this.logger.warn("setConnectionMode requires the FDv2 data system (dataSystem option). The call has no effect without it.")}setStreaming(t){var e,n;null==(n=(e=this.dataManager).setForcedStreaming)||n.call(e,t)}$e(){var t,e;let n=this.emitter.eventNames().some(t=>t.startsWith("change:")||"change"===t);null==(e=(t=this.dataManager).setAutomaticStreamingState)||e.call(t,n)}on(t,e){super.on(t,e),this.$e()}off(t,e){super.off(t,e),this.$e()}};function ry(t){let e=Object.fromEntries(Object.entries(null!=t?t:{}).filter(([t])=>!t.startsWith("$"))),n=void 0!==t;function r(t,n,r){return t in e&&r(e[t])?e[t]:n}function i(t,n){return t in e?e[t]:n}function a(t,e,n){return{value:n?r(t,e,n):i(t,e),variationIndex:null,reason:null}}let s=t=>"boolean"==typeof t,o=t=>"number"==typeof t,l=t=>"string"==typeof t,u=()=>{},c=()=>u,d=()=>Promise.resolve();return{allFlags:()=>f({},e),getContext:()=>{},getInitializationState:()=>"initializing",getInitializationError:()=>{},isReady:()=>n,boolVariation:(t,e)=>r(t,e,s),numberVariation:(t,e)=>r(t,e,o),stringVariation:(t,e)=>r(t,e,l),jsonVariation:(t,e)=>i(t,e),boolVariationDetail:(t,e)=>a(t,e,s),numberVariationDetail:(t,e)=>a(t,e,o),stringVariationDetail:(t,e)=>a(t,e,l),jsonVariationDetail:(t,e)=>a(t,e),variation:(t,e)=>i(t,e),variationDetail:(t,e)=>a(t,e),on:u,off:u,onContextChange:c,onInitializationStatusChange:c,shouldUseCamelCaseFlagKeys:()=>!0,close:d,flush:d,identify:d,track:u,addHook:u,waitForInitialization:d,setStreaming:u,start:d,logger:{debug:u,info:u,warn:u,error:u}}}function rm(t,e,n={}){var r,i;if("u"<typeof window)return ry();let{useCamelCaseFlagKeys:a=!0}=n,s=((t,e)=>{var n={};for(var r in t)h.call(t,r)&&0>e.indexOf(r)&&(n[r]=t[r]);if(null!=t&&d)for(var r of d(t))0>e.indexOf(r)&&g.call(t,r)&&(n[r]=t[r]);return n})(n,["useCamelCaseFlagKeys"]),o=u(f({},s),c({wrapperName:null!=(r=null==s?void 0:s.wrapperName)?r:"react-client-sdk",wrapperVersion:null!=(i=null==s?void 0:s.wrapperVersion)?i:"4.0.1"})),l=function(t,e,n,r={}){let i=new rv(t,e,n,r,void 0),a={variation:(t,e)=>i.variation(t,e),variationDetail:(t,e)=>i.variationDetail(t,e),boolVariation:(t,e)=>i.boolVariation(t,e),boolVariationDetail:(t,e)=>i.boolVariationDetail(t,e),numberVariation:(t,e)=>i.numberVariation(t,e),numberVariationDetail:(t,e)=>i.numberVariationDetail(t,e),stringVariation:(t,e)=>i.stringVariation(t,e),stringVariationDetail:(t,e)=>i.stringVariationDetail(t,e),jsonVariation:(t,e)=>i.jsonVariation(t,e),jsonVariationDetail:(t,e)=>i.jsonVariationDetail(t,e),track:(t,e,n)=>i.track(t,e,n),on:(t,e)=>i.on(t,e),off:(t,e)=>i.off(t,e),flush:()=>i.flush(),setConnectionMode:t=>i.setConnectionMode(t),setStreaming:t=>i.setStreaming(t),identify:(t,e)=>i.identifyResult(t,e),getContext:()=>i.getContext(),close:()=>i.close(),allFlags:()=>i.allFlags(),addHook:t=>i.addHook(t),waitForInitialization:t=>i.waitForInitialization(t),logger:i.logger,start:t=>i.start(t)};return i.registerPlugins(a),a}(t,e,tz.Disabled,o),p="initializing",v=!1,y=!1,m=!1,w=new Set,b=new Set,k;function E(){let t=l.getContext();t&&w.forEach(e=>e(t))}return u(f({},l),c({start:t=>y?l.start(t):(y=!0,null!=t&&t.bootstrap&&(v=!0),l.start(t).then(t=>(p=t.status,k=t,m||(m=!0,E()),b.forEach(e=>e(t)),t))),identify:(t,e)=>l.identify(t,e).then(t=>("completed"===t.status&&E(),t)),getInitializationState:()=>p,getInitializationError:()=>(null==k?void 0:k.status)==="failed"?k.error:void 0,onContextChange:t=>(w.add(t),()=>{w.delete(t)}),onInitializationStatusChange:t=>(k&&t(k),b.add(t),()=>{b.delete(t)}),isReady:()=>"initializing"!==p||v,shouldUseCamelCaseFlagKeys:()=>a}))}function rw(t,e){var n;let r=null!=(n=null==e?void 0:e.Provider)?n:y.Provider;return({children:e})=>{var n;let[i,a]=(0,s.useState)({client:t,context:null!=(n=t.getContext())?n:void 0,initializedState:t.getInitializationState(),error:t.getInitializationError()});return(0,s.useEffect)(()=>{let e=!0,n=t.onInitializationStatusChange(t=>{e&&a(e=>e.initializedState===t.status?e:u(f({},e),c({initializedState:t.status,error:"failed"===t.status?t.error:void 0})))}),r=t.onContextChange(t=>{e&&a(e=>u(f({},e),c({context:t})))});return()=>{e=!1,n(),r()}},[]),o().createElement(r,{value:i},e)}}function rb(t,e,n){let{deferInitialization:r,startOptions:i,reactContext:a,ldOptions:s,bootstrap:o}=null!=n?n:{},l=rm(t,e,s);if(!r){let t=o?u(f({},i),c({bootstrap:o})):i;l.start(t)}return rw(l,a)}function rk({clientSideId:t,context:e,bootstrap:n,options:r,reactContext:i,children:a}){let l=(0,s.useRef)(null);null===l.current&&("u"<typeof window?l.current=rw(ry(n),i):l.current=rb(t,e,u(f({},r),c({bootstrap:n,reactContext:i}))));let d=l.current;return o().createElement(d,null,a)}function rE(t){let{client:e,context:n}=(0,s.useContext)(null!=t?t:y);(0,s.useEffect)(()=>
1{e.logger.warn("[LaunchDarkly] useFlags is deprecated and will be removed in a future major version.")},[]);let[r,i]=(0,s.useState)(()=>e.allFlags()),a=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{a.current&&i(e.allFlags()),a.current=!0;let t=()=>i(e.allFlags());return e.on("change",t),()=>e.off("change",t)},[e,n]),(0,s.useMemo)(()=>{let t,n,i,a;return t=new Map,n=e.shouldUseCamelCaseFlagKeys(),i={},a={},Object.keys(r).filter(t=>0!==t.indexOf("$")).forEach(t=>{if(n){let e=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((t,e)=>{let n=t.toLowerCase();return 0===e?n:n.charAt(0).toUpperCase()+n.slice(1)}).join("");i[e]=r[t],a[e]=t}else i[t]=r[t]}),new Proxy(i,{get(r,i,s){var o;let l=Reflect.get(r,i,s);if("symbol"==typeof i||!Object.prototype.hasOwnProperty.call(r,i))return l;if(void 0===l)return;if(t.has(i))return t.get(i);let u=n&&null!=(o=a[i])?o:i,c=e.variation(u,l);return t.set(i,c),c}})},[e,r,n])}function rS(t){let{initializedState:e,error:n}=(0,s.useContext)(null!=t?t:y);return"failed"===e?{status:"failed",error:n}:{status:e}}function rx(t){let{client:e}=(0,s.useContext)(null!=t?t:y);return e}function rD(t,e,n,r,i){let{client:a,context:o}=(0,s.useContext)(null!=r?r:y),l=a.isReady(),u=(0,s.useRef)(e),c=(0,s.useRef)(n);u.current=e,c.current=n;let d=(0,s.useRef)(!1),[h,g]=(0,s.useState)(()=>l?n(a,t,e):i?i(e):e);return(0,s.useEffect)(()=>{d.current&&l&&g(c.current(a,t,u.current)),d.current=!0;let e=()=>g(c.current(a,t,u.current));return a.on(`change:${t}`,e),()=>a.off(`change:${t}`,e)},[a,t,o,l]),h}function rO(t,e,n){return rD(t,e,(t,e,n)=>t.boolVariation(e,n),n)}function rI(t,e,n){return rD(t,e,(t,e,n)=>t.stringVariation(e,n),n)}function rP(t,e,n){return rD(t,e,(t,e,n)=>t.numberVariation(e,n),n)}function r$(t,e,n){return rD(t,e,(t,e,n)=>t.jsonVariation(e,n),n)}function rC(t){return{value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"CLIENT_NOT_READY"}}}function rR(t,e,n){return rD(t,e,(t,e,n)=>t.boolVariationDetail(e,n),n,rC)}function rM(t,e,n){return rD(t,e,(t,e,n)=>t.stringVariationDetail(e,n),n,rC)}function rN(t,e,n){return rD(t,e,(t,e,n)=>t.numberVariationDetail(e,n),n,rC)}function rA(t,e,n){return rD(t,e,(t,e,n)=>t.jsonVariationDetail(e,n),n,rC)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.