Socket
Socket
Sign inDemoInstall

@uniformdev/context

Package Overview
Dependencies
Maintainers
8
Versions
604
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniformdev/context - npm Package Compare versions

Comparing version 12.2.1-alpha.171 to 12.2.1-alpha.177

dist/chunk-GU2YFM6V.mjs

4

dist/api/api.js

@@ -1,2 +0,2 @@

var T=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var $=(r,e,t)=>e in r?T(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var v=r=>T(r,"__esModule",{value:!0});var V=(r,e)=>{for(var t in e)T(r,t,{get:e[t],enumerable:!0})},H=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of M(e))!Q.call(r,n)&&(t||n!=="default")&&T(r,n,{get:()=>e[n],enumerable:!(i=J(e,n))||i.enumerable});return r};var K=(r=>(e,t)=>r&&r.get(e)||(t=H(v({}),e,1),r&&r.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var m=(r,e,t)=>($(r,typeof e!="symbol"?e+"":e,t),t),q=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var o=(r,e,t)=>(q(r,e,"read from private field"),t?t.call(r):e.get(r)),a=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)};var B={};V(B,{AggregateClient:()=>j,ApiClientError:()=>y,ContextClient:()=>L,DimensionClient:()=>U,EnrichmentClient:()=>f,ManifestClient:()=>G,QuirkClient:()=>O,SignalClient:()=>w,computeDimensionDisplayName:()=>z,nullLimitPolicy:()=>N});var N=async r=>await r(),y=class extends Error{constructor(e,t,i,n,s){super(`${e}
${n}${s?" "+s:""} (${t} ${i})`);this.errorMessage=e;this.fetchMethod=t;this.fetchUri=i;this.statusCode=n;this.statusText=s;Object.setPrototypeOf(this,y.prototype)}};var c=class{constructor(e){m(this,"options");var t,i,n,s,p,h;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");this.options={...e,fetch:(t=e.fetch)!=null?t:fetch,apiHost:(i=e.apiHost)!=null?i:"https://uniform.app",apiKey:(n=e.apiKey)!=null?n:null,projectId:(s=e.projectId)!=null?s:null,bearerToken:(p=e.bearerToken)!=null?p:null,limitPolicy:(h=e.limitPolicy)!=null?h:N}}async apiClient(e,t){return this.options.limitPolicy(async()=>{var s;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},n=await fetch(e.toString(),{...t,headers:{...t==null?void 0:t.headers,...i}});if(!n.ok){let p="";try{let h=await n.text();try{let C=JSON.parse(h);C.errorMessage?p=Array.isArray(C.errorMessage)?C.errorMessage.join(", "):C.errorMessage:p=h}catch(C){p=h}}catch(h){p="General error"}throw new y(p,(s=t==null?void 0:t.method)!=null?s:"GET",e.toString(),n.status)}return(t==null?void 0:t.expectNoContent)?null:await n.json()})}createUrl(e,t){let i=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([n,s])=>{var p;typeof s!="undefined"&&s!==null&&i.searchParams.append(n,(p=s==null?void 0:s.toString())!=null?p:"")}),i}};var g,E=class extends c{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(o(E,g),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(o(E,g));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(o(E,g));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},j=E;g=new WeakMap,a(j,g,"/api/v2/aggregate");var D,k=class extends c{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(o(k,D),{...e,projectId:t});return await this.apiClient(i)}},U=k;D=new WeakMap,a(U,D,"/api/v2/dimension");var P,I,u=class extends c{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(o(u,P),{...e,projectId:t});return await this.apiClient(i)}async upsertCategory(e){let t=this.createUrl(o(u,P));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(e){let t=this.createUrl(o(u,P));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(e){let t=this.createUrl(o(u,I));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(e){let t=this.createUrl(o(u,I));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},f=u;P=new WeakMap,I=new WeakMap,a(f,P,"/api/v1/enrichments"),a(f,I,"/api/v1/enrichment-values");var S,A=class extends c{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(o(A,S),{...e,projectId:t});return await this.apiClient(i)}},G=A;S=new WeakMap,a(G,S,"/api/v2/manifest");var d,R=class extends c{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(o(R,d),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(o(R,d));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(o(R,d));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},O=R;d=new WeakMap,a(O,d,"/api/v2/quirk");var x,b=class extends c{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(o(b,x),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(o(b,x));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(o(b,x));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},w=b;x=new WeakMap,a(w,x,"/api/v2/signal");var L=class{constructor(e){m(this,"enrichments");m(this,"aggregates");m(this,"dimensions");m(this,"manifest");m(this,"quirks");m(this,"signals");this.enrichments=new f(e),this.aggregates=new j(e),this.dimensions=new U(e),this.manifest=new G(e),this.quirks=new O(e),this.signals=new w(e)}};function z(r){return`${r.category==="ENR"?r.subcategory:r.category==="SIG"?"Signal":r.subcategory==="1"?"Intent":"Audience"}: ${r.name}`}module.exports=K(B);0&&(module.exports={AggregateClient,ApiClientError,ContextClient,DimensionClient,EnrichmentClient,ManifestClient,QuirkClient,SignalClient,computeDimensionDisplayName,nullLimitPolicy});
var b=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var $=(r,e,t)=>e in r?b(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var H=r=>b(r,"__esModule",{value:!0});var K=(r,e)=>{for(var t in e)b(r,t,{get:e[t],enumerable:!0})},z=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of v(e))!Q.call(r,o)&&(t||o!=="default")&&b(r,o,{get:()=>e[o],enumerable:!(i=V(e,o))||i.enumerable});return r};var q=(r=>(e,t)=>r&&r.get(e)||(t=z(H({}),e,1),r&&r.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var h=(r,e,t)=>($(r,typeof e!="symbol"?e+"":e,t),t),B=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var n=(r,e,t)=>(B(r,e,"read from private field"),t?t.call(r):e.get(r)),c=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)};var W={};K(W,{AggregateClient:()=>E,ApiClientError:()=>g,ContextClient:()=>M,DimensionClient:()=>D,EnrichmentClient:()=>f,ManifestClient:()=>R,QuirkClient:()=>I,SignalClient:()=>G,computeDimensionDefinitionDisplayData:()=>J,computeDimensionDisplayData:()=>Y,computeDimensionDisplayName:()=>F,nullLimitPolicy:()=>A});var A=async r=>await r(),g=class extends Error{constructor(e,t,i,o,s){super(`${e}
${o}${s?" "+s:""} (${t} ${i})`);this.errorMessage=e;this.fetchMethod=t;this.fetchUri=i;this.statusCode=o;this.statusText=s;Object.setPrototypeOf(this,g.prototype)}};var p=class{constructor(e){h(this,"options");var t,i,o,s,a,m;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");this.options={...e,fetch:(t=e.fetch)!=null?t:fetch,apiHost:(i=e.apiHost)!=null?i:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(s=e.projectId)!=null?s:null,bearerToken:(a=e.bearerToken)!=null?a:null,limitPolicy:(m=e.limitPolicy)!=null?m:A}}async apiClient(e,t){return this.options.limitPolicy(async()=>{var s;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await fetch(e.toString(),{...t,headers:{...t==null?void 0:t.headers,...i}});if(!o.ok){let a="";try{let m=await o.text();try{let C=JSON.parse(m);C.errorMessage?a=Array.isArray(C.errorMessage)?C.errorMessage.join(", "):C.errorMessage:a=m}catch(C){a=m}}catch(m){a="General error"}throw new g(a,(s=t==null?void 0:t.method)!=null?s:"GET",e.toString(),o.status)}return(t==null?void 0:t.expectNoContent)?null:await o.json()})}createUrl(e,t){let i=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,s])=>{var a;typeof s!="undefined"&&s!==null&&i.searchParams.append(o,(a=s==null?void 0:s.toString())!=null?a:"")}),i}};var y,j=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(j,y),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(n(j,y));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(n(j,y));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},E=j;y=new WeakMap,c(E,y,"/api/v2/aggregate");var S,N=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(N,S),{...e,projectId:t});return await this.apiClient(i)}},D=N;S=new WeakMap,c(D,S,"/api/v2/dimension");var P,U,u=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(u,P),{...e,projectId:t});return await this.apiClient(i)}async upsertCategory(e){let t=this.createUrl(n(u,P));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(e){let t=this.createUrl(n(u,P));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(e){let t=this.createUrl(n(u,U));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(e){let t=this.createUrl(n(u,U));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},f=u;P=new WeakMap,U=new WeakMap,c(f,P,"/api/v1/enrichments"),c(f,U,"/api/v1/enrichment-values");var T,k=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(k,T),{...e,projectId:t});return await this.apiClient(i)}},R=k;T=new WeakMap,c(R,T,"/api/v2/manifest");var d,O=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(O,d),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(n(O,d));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(n(O,d));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},I=O;d=new WeakMap,c(I,d,"/api/v2/quirk");var x,w=class extends p{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,i=this.createUrl(n(w,x),{...e,projectId:t});return await this.apiClient(i)}async upsert(e){let t=this.createUrl(n(w,x));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(n(w,x));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},G=w;x=new WeakMap,c(G,x,"/api/v2/signal");var M=class{constructor(e){h(this,"enrichments");h(this,"aggregates");h(this,"dimensions");h(this,"manifest");h(this,"quirks");h(this,"signals");this.enrichments=new f(e),this.aggregates=new E(e),this.dimensions=new D(e),this.manifest=new R(e),this.quirks=new I(e),this.signals=new G(e)}};var L="_";function J(r){let e=r.category==="ENR"?"Enrichment":r.category==="SIG"?"Signal":r.subcategory==="1"?"Intent":r.subcategory==="0"?"Audience":"Aggregate";return{dim:r.dim,name:r.name,type:e,category:r.category==="ENR"?r.subcategory:void 0}}function Y(r,e){var t,i,o,s;if((i=(t=e.project.pz)==null?void 0:t.agg)==null?void 0:i[r])return{dim:r,name:r,type:"Aggregate"};if((s=(o=e.project.pz)==null?void 0:o.sig)==null?void 0:s[r])return{dim:r,name:r,type:"Signal"};if(r.indexOf(L)>=0){let[a,m]=r.split(L);return{dim:r,name:m,type:"Enrichment",category:a}}}function F(r){let{type:e,name:t}=J(r);return`${e}: ${t}`}module.exports=q(W);0&&(module.exports={AggregateClient,ApiClientError,ContextClient,DimensionClient,EnrichmentClient,ManifestClient,QuirkClient,SignalClient,computeDimensionDefinitionDisplayData,computeDimensionDisplayData,computeDimensionDisplayName,nullLimitPolicy});

@@ -1,185 +0,5 @@

import { c as components, e as external } from './v2-manifest.swagger-d0899723';
import * as mitt from 'mitt';
import { C as CookieAdapter, T as TransitionDataStore, S as StorageCommands, V as VisitorData, a as TransitionDataStoreOptions, D as DecayFunction, O as OutputSeverity, L as LogDrain, b as ContextPlugin, c as CriteriaEvaluator, d as StringMatch, e as ScoreVector, A as AggregateDimension, f as VariantMatchCriteria } from './types-1ad8439c';
export { A as AggregateDimension, l as AggregateDimensionInput, a7 as BehaviorTag, Z as Context, Y as ContextEvents, U as ContextOptions, b as ContextPlugin, q as ContextState, r as ContextStateUpdate, C as CookieAdapter, c as CriteriaEvaluator, D as DecayFunction, z as DecayOptions, af as DevToolsActions, aj as DevToolsDataEvent, ag as DevToolsEvent, ah as DevToolsEvents, an as DevToolsForgetEvent, ak as DevToolsHelloEvent, ai as DevToolsLogEvent, am as DevToolsRawCommandsEvent, ae as DevToolsState, ad as DevToolsUiVersion, al as DevToolsUpdateEvent, a6 as DimensionMatch, E as EnrichmentCategory, n as EnrichmentData, o as EventData, G as GroupCriteriaEvaluator, I as IdentifyCommand, L as LogDrain, a1 as LogMessage, _ as LogMessages, M as ManifestInstance, g as ManifestV2, a0 as MessageFunc, t as ModifyScoreCommand, u as ModifySessionScoreCommand, N as NumberMatch, O as OutputSeverity, W as PersonalizationEvent, P as PersonalizationManifest, a4 as PersonalizeOptions, a9 as PersonalizedResult, a8 as PersonalizedVariant, Q as Quirks, K as SERVER_STATE_ID, e as ScoreVector, J as ServerToClientTransitionState, v as SetConsentCommand, y as SetControlGroupCommand, w as SetQuirkCommand, x as SetTestCommand, $ as Severity, h as Signal, j as SignalCriteria, i as SignalCriteriaGroup, s as StorageCommand, S as StorageCommands, d as StringMatch, ac as TaggedContent, k as TestDefinition, X as TestEvent, a3 as TestOptions, ab as TestResult, aa as TestVariant, m as Tests, T as TransitionDataStore, R as TransitionDataStoreEvents, a as TransitionDataStoreOptions, f as VariantMatchCriteria, V as VisitorData, H as VisitorDataStore, F as VisitorDataStoreEvents, B as VisitorDataStoreOptions, p as emptyVisitorData, a5 as personalizeVariations, a2 as testVariations } from './types-1ad8439c';
import 'mitt';
declare type StorageCommand<TID extends string = string, TData = unknown> = {
type: TID;
data: TData;
};
/** Commands that can be issued to alter the storage of Uniform Context data */
declare type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand;
/**
* Changes the visitor's permanent score for a given dimension
*/
declare type ModifyScoreCommand = StorageCommand<'modscore', {
dimension: string;
delta: number;
}>;
/**
* Changes the visitor's session (time-based) score for a given dimension
*/
declare type ModifySessionScoreCommand = StorageCommand<'modscoreS', {
dimension: string;
delta: number;
}>;
/**
* Changes the visitor's storage consent setting.
* Setting consent to false will trigger deletion of any stored data for the visitor.
* Scores are still collected in-memory when consent is false; just not persisted.
*/
declare type SetConsentCommand = StorageCommand<'consent', boolean>;
/** Sets a permanent quirk key and value for the visitor */
declare type SetQuirkCommand = StorageCommand<'setquirk', {
key: string;
value: string;
}>;
/** Sets a specific variant as being this visitor's variant on an A/B test */
declare type SetTestCommand = StorageCommand<'settest', {
test: string;
variant: string;
}>;
/**
* Identifies the visitor as being a specific unique identifier.
* NOTE: this only has an effect when using an external cross-device transition storage system.
* NOTE: you cannot read the identified visitor ID back from the storage system once it is set.
*/
declare type IdentifyCommand = StorageCommand<'identify', {
identity: string;
}>;
declare type Quirks = {
[key: string]: string;
};
declare type Tests = {
[key: string]: string;
};
declare type ScoreVector = {
[key: string]: number;
};
declare type EnrichmentData = {
/** Enrichment category name */
cat: string;
/** Enrichment key value */
key: string;
/** Strength value (amount of score added when viewing content) */
str: number;
};
declare type EventData = {
event: string;
payload?: any;
};
declare type VisitorData = {
/** Quirk key-value data */
quirks: Quirks;
/** A/B test variant selections */
tests: Tests;
/** Personalization score data for the current session (merge with all time for totals) */
sessionScores: ScoreVector;
/** Personalization score data for all time (merge with session for totals) */
scores: ScoreVector;
/**
* Whether consent has been given to store the visitor data
* If false or not set: visitor data is stored in memory and is lost if the browser refreshes
* If true: visitor data is stored in localStorage and any other transition storage if registered
*/
consent?: boolean;
/**
* Whether the visitor has been assigned to the personalization control group -
* visitors who are not shown personalization. If this is true, all scores will be zeroed,
* and score updates will be ignored. This has no effect on quirks or tests.
*
* If this value is not set, a random roll will be performed to determine membership,
* based on the control group size.
*/
controlGroup?: boolean;
};
declare const emptyVisitorData: () => VisitorData;
declare type ContextState = {
cookies: Record<string, string>;
url: URL;
quirks: Quirks;
enrichments: EnrichmentData[];
events: EventData[];
};
declare type ContextStateUpdate = {
state: Partial<ContextState>;
previousState: Partial<ContextState>;
visitor: VisitorData;
scores: ScoreVector;
};
declare type TransitionDataStoreOptions = {
initialData?: Partial<VisitorData>;
};
declare type ServerToClientTransitionState = Pick<Partial<VisitorData>, 'quirks' | 'tests'> & {
/**
* Server Score Vector - the resultant scores _on the server side_ after the server/edge render completes
* Note that the client side does not trust these scores; they are only used until it's done with initial
* recomputation.
*/
ssv?: ScoreVector;
};
declare const SERVER_STATE_ID = "__UNIFORM_DATA__";
declare type TransitionDataStoreEvents = {
/**
* Fired when the data is updated asynchronously
* (i.e. a promise resolves with new data from a backend)
*
* NOT fired for synchronous updates (e.g. calling updateData()), unless this also results in an async update of the data afterwards.
* NOT fired if an asynchronous update does not result in any change compared to the last known data.
*/
dataUpdatedAsync: Partial<VisitorData>;
};
declare abstract class TransitionDataStore {
#private;
constructor({ initialData }: TransitionDataStoreOptions);
get data(): Partial<VisitorData> | undefined;
/**
* Subscribe to events from the transition storage
*/
readonly events: {
on: {
<Key extends "dataUpdatedAsync">(type: Key, handler: mitt.Handler<TransitionDataStoreEvents[Key]>): void;
(type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
};
off: {
<Key_1 extends "dataUpdatedAsync">(type: Key_1, handler?: mitt.Handler<TransitionDataStoreEvents[Key_1]> | undefined): void;
(type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
};
};
/**
* Updates data in the transition storage.
* @param commands Commands to execute against existing stored value (event based stores)
* @param computedValue Pre-computed new value against existing value (object based stores)
* @returns Resolved promise when the data has been updated
*/
updateData(commands: StorageCommands[], computedValue: VisitorData): Promise<void>;
/**
* Deletes a visitor's stored data, forgetting them.
* @param fromAllDevices - false: logout from this device ID. true: forget all data about the visitor and their identity.
*/
delete(fromAllDevices?: boolean): Promise<void>;
/**
* Deletes a visitor's stored data, forgetting them.
* Important: do not emit any async score update events from this function.
* @param fromAllDevices - false: logout from this device ID. true: forget all data about the visitor and their identity.
*/
abstract handleDelete(fromAllDevices?: boolean): Promise<void>;
/**
* Updates visitor data in the transition store.
*
* NOTE: The updated data is optimistically stored in TransitionDataStore automatically,
* so unless the updated data is _changed_ by the backend data store, there is no need
* to emit async score changed events when the visitor data is done updating.
*/
abstract handleUpdateData(commands: StorageCommands[], computedValue: VisitorData): Promise<void>;
protected signalAsyncDataUpdate(newScores: Partial<VisitorData>): void;
/**
* When we load on the client side after a server side rendering has occurred (server to client transition),
* we can have a page script (ID: __UNIFORM_DATA__) that contains the computed visitor data from the SSR/edge render.
* This data is injected into the first render to allow score syncing and the server to request commands be applied
* to the client side data store.
*/
getClientTransitionState(): ServerToClientTransitionState | undefined;
}
declare type CookieTransitionDataStoreOptions = {

@@ -233,23 +53,3 @@ cookieAdapter: CookieAdapter;

declare type CookieAdapter = {
get: (name: string) => string | undefined;
set: (name: string, value: string) => void;
remove: (name: string) => void;
};
declare type DecayOptions = {
now: number;
lastUpd: number | undefined;
scores: ScoreVector;
sessionScores: ScoreVector;
};
/**
* Computes decay of visitor scores over time.
* NOTE: it is expected that this function mutates the incoming score vectors,
* if it needs to apply score decay. The data store ensures immutability already.
*
* @returns true if any decay was applied, false otherwise
*/
declare type DecayFunction = (options: DecayOptions) => boolean;
/**
* Creates a new log drain that will log to the console.

@@ -268,55 +68,2 @@ * The log drain will only log event IDs, but is much smaller than the

/** Defines all error codes and their parameter(s) */
declare type LogMessages = {
/** Context constructed */
1: MessageFunc;
/** Context received data update */
2: MessageFunc<Partial<Omit<ContextState, 'url'> & {
url: string;
}>>;
/** Context emitted new score vector */
3: MessageFunc<ScoreVector>;
/** Context emitted updated quirks */
4: MessageFunc<Quirks>;
/** Storage received update commands */
101: MessageFunc<StorageCommands[]>;
/** Storage data was updated */
102: MessageFunc<VisitorData>;
/** Storage data was deleted bool: fromAllDevices */
103: MessageFunc<boolean>;
/** Storage score was truncated to its cap */
110: MessageFunc<{
dim: string;
score: number;
cap: number;
}>;
/** Storage visitor data expired and was cleared */
120: MessageFunc;
/** Server to client transition score data was loaded */
130: MessageFunc<ScoreVector>;
/** Placement does not have a name */
301: MessageFunc;
/** Test did not exist */
401: MessageFunc<string>;
/** Previously shown test variant no longer in variant data */
402: MessageFunc<{
test: string;
variant: string;
}>;
/** gtag was not present on the page to emit events to */
700: MessageFunc;
/** Enabled gtag event signal redirection */
701: MessageFunc;
};
declare type Severity = 'debug' | 'info' | 'warn' | 'error';
declare type OutputSeverity = Severity | 'none';
declare type MessageFunc<TArg = void> = (arg: TArg) => [string, string, ...any];
declare type LogMessage<TID extends keyof LogMessages = keyof LogMessages> = [
severity: Severity,
id: TID,
...args: Parameters<LogMessages[TID]>
];
declare type LogDrain = (message: LogMessage) => void;
/**

@@ -335,114 +82,2 @@ * Creates a new log drain that will log full debug messages to the console.

declare type VisitorDataStoreOptions = {
/** Transition storage used to transfer server or edge side execution state to the client. Unused for client side only. */
transitionStore?: TransitionDataStore;
/** Duration of a 'visit' measured by this number of milliseconds without performing any updates */
visitLifespan?: number;
/** Personalization manifest data. If set, the data store will automatically apply score caps in the manifest data. */
manifest?: ManifestInstance;
/** Allows decaying of scores over time based on time between visits. Default: no decay */
decay?: DecayFunction;
/**
* Sets the default value of storage consent for new unknown visitors.
* If storage consent is not given, only in-memory data will be stored which is lost when the browser leaves the page.
* @default false - consent is not given for new visitors until they explicitly give it with an update command
*/
defaultConsent?: boolean;
/**
* Function called when server-to-client transfer state is loaded and contains server-side computed scores.
* These scores are used as a temporary shim for the current scores on the client side, until score computation
* is completed the first time (which occurs when the current url is fed into the Context).
*
* Because the feed of the URL may be marginally delayed (for example in React it's in an effect so it's a second render),
* one render might be done with _no_ scores unless we dropped the server scores in temporarily, resulting in a flash of unpersonalized content.
*/
onServerTransitionScoresReceived?: (ssv: ScoreVector) => void;
/** Called when a log message is emitted from the data store */
onLogMessage?: (message: LogMessage) => void;
};
declare type VisitorDataStoreEvents = {
/**
* Fired when the stored data is updated.
* This is fired for any update, whether from integrated or transition storage.
* The event is NOT fired if an update does not result in any score changes.
*/
scoresUpdated: Pick<VisitorData, 'scores' | 'sessionScores'>;
/**
* Fired when stored quirks are updated.
* This is fired for any update, whether from integrated or transition storage.
* The event is NOT fired if an update does not result in any quirk changes.
*/
quirksUpdated: Pick<VisitorData, 'quirks'>;
/**
* Fired when test variant selection is updated.
*/
testsUpdated: Pick<VisitorData, 'tests'>;
/**
* Fired when storage consent is changed
*/
consentUpdated: Pick<VisitorData, 'consent'>;
/**
* Fired when visitor control group membership is changed
*/
controlGroupUpdated: Pick<VisitorData, 'controlGroup'>;
};
declare class VisitorDataStore {
#private;
constructor(options: VisitorDataStoreOptions);
/** Gets the current visitor data. This property is always up to date. */
get data(): VisitorData;
get decayEnabled(): boolean;
/**
* Subscribe to events from storage
*/
readonly events: {
on: {
<Key extends keyof VisitorDataStoreEvents>(type: Key, handler: mitt.Handler<VisitorDataStoreEvents[Key]>): void;
(type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
};
off: {
<Key_1 extends keyof VisitorDataStoreEvents>(type: Key_1, handler?: mitt.Handler<VisitorDataStoreEvents[Key_1]> | undefined): void;
(type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
};
};
/** Push data update command(s) into the visitor data */
updateData(commands: StorageCommands[]): Promise<void>;
/**
* Deletes visitor data (forgetting them)
* In most cases you should use forget() on the Context instead of this function, which also clears the Context state.
* @param fromAllDevices for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
*/
delete(fromAllDevices: boolean): Promise<void>;
}
declare class ManifestInstance {
#private;
readonly data: ManifestV2;
constructor({ manifest, evaluator, }: {
manifest: ManifestV2;
evaluator?: GroupCriteriaEvaluator;
});
rollForControlGroup(): boolean;
getTest(name: string): TestDefinition | undefined;
computeSignals(update: ContextStateUpdate): StorageCommands[];
/**
* Computes aggregated scores based on other dimensions
*/
computeAggregateDimensions(primitiveScores: ScoreVector): ScoreVector;
getDimensionByKey(scoreKey: string): EnrichmentCategory | Signal | undefined;
}
declare type SharedTypes = external['uniform-context-types.swagger.yml']['components']['schemas'];
declare type ManifestV2 = components['schemas']['ManifestV2'];
declare type PersonalizationManifest = components['schemas']['PersonalizationManifest'];
declare type Signal = SharedTypes['Signal'];
declare type SignalCriteriaGroup = SharedTypes['SignalCriteriaGroup'];
declare type SignalCriteria = SharedTypes['SignalCriteria'];
declare type EnrichmentCategory = SharedTypes['EnrichmentCategory'];
declare type StringMatch = SharedTypes['StringMatch'];
declare type NumberMatch = SharedTypes['NumberMatch'];
declare type TestDefinition = SharedTypes['Test'];
declare type AggregateDimension = SharedTypes['AggregateDimension'];
declare type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
declare const cookieEvaluator: CriteriaEvaluator;

@@ -461,15 +96,2 @@

/**
* A type that evaluates a signal criteria type and
* decides if it matches the current Context state or not.
* @returns {boolean} - true for a match, false for no match
* */
declare type CriteriaEvaluator = (update: ContextStateUpdate, criteria: SignalCriteria, commands: StorageCommands[], signal: Signal, dimension: string) => boolean;
declare class GroupCriteriaEvaluator {
#private;
constructor(criteriaEvaluators: Record<string, CriteriaEvaluator>);
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: Signal, dimension: string): boolean;
}
/** Tests if a StringMatch matches a string value */

@@ -483,232 +105,4 @@ declare function isStringMatch(lhs: string | null | undefined, match: StringMatch): boolean;

/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
declare type BehaviorTag = {
beh?: EnrichmentData[];
};
/** Defines the shape of a personalized content variant */
declare type PersonalizedVariant = {
/** A unique identifier for this variation */
id: string;
/** Match criteria for this variation */
pz?: VariantMatchCriteria;
};
/** The result of computing personalized content from variations */
declare type PersonalizedResult<TVariant> = {
/** Whether or not this result contains a personalized result */
personalized: boolean;
/** Matching variations */
variations: Array<TVariant>;
};
/** Defines the shape of a A/B test variant */
declare type TestVariant = {
/** The identifier for this variant. This value persisted to storage when a variant is selected. */
id: string;
/**
* A number between 0 and 100 representing what percentage of visitors will be selected for this variant.
* If not provided, this variant will be selected in equal proportion to other variants without an explicit distribution.
*/
testDistribution?: number;
};
/** The result of computing an A/B test result */
declare type TestResult<TVariant> = {
/** The selected variation */
result: TVariant | undefined;
};
/** Defines the shape of arbitrarily tagged content where the tag can be for a test, behaviour, or personalization */
declare type TaggedContent = PersonalizedVariant & TestVariant & BehaviorTag & {
/** @deprecated no longer used */
intents?: IntentTagVector;
};
/**
* A vector keyed by intent ID which contains magnitude and configuration data for each intent ID that has been tagged
* @deprecated no longer used
*/
declare type IntentTagVector = Record<string, IntentTagAxis>;
/**
* An individual intent tag magnitude value in an IntentTagVector
* @deprecated no longer used
*/
interface IntentTagAxis {
/** If this is true, don't use this intent tag when calculating personalization. If false or unspecified, personalization is allowed. */
noPn?: boolean;
/** If this is true, don't use this intent tag when calculating behavior. If false or unspecified, behavior is allowed. */
noBeh?: boolean;
/**
* If this is true, ANY strength in the tagged intent will result in selecting this variant to personalize,
* regardless of other intents' strengths. If more than one tag is override,
* they are sorted normally.
*/
override?: boolean;
/**
* Sets the minimum visitor score required to trigger this variation.
* If more than one intent tag matches, the one with the highest threshold will win.
*/
threshold?: number;
/** Strength of the intent tag. If unspecified, IntentTagStrength.Normal should be inferred */
str?: number | string;
}
declare type PersonalizeOptions<TVariant> = {
/** Name of placement */
name?: string;
/** Possible variants to place */
variations: Iterable<TVariant>;
/** Maximum number of variants to place (default: 1) */
take?: number;
};
declare function personalizeVariations<TVariant extends PersonalizedVariant>({ context, variations, take, }: PersonalizeOptions<TVariant> & {
context: Context;
}): PersonalizedResult<TVariant>;
declare function evaluateVariantMatch(match: VariantMatchCriteria | undefined | null, vec: ScoreVector): boolean;
declare type VariantMatchCriteria = {
/**
* Operation for match criteria
*
* @defaultValue `&`
*/
op?: '&' | '|';
crit: DimensionMatch[];
};
declare type DimensionMatch = {
/**
* Left hand side of the match expression (name of dimension in score vector)
* NOTE: if the dimension is not present in the score vector, it will be treated as if it has a value of 0
*/
l: string;
/**
* Operator of the match expression
* Whole-vector (RHS only) operators - these do not require a `r` or `rDim` set:
* +: `l` is the strongest dimension in the score vector
* -: `l` is the weakest dimension in the score vector. This does not match if the dimension has no score at all.
*
* Comparison operators:
* >: `l` is greater than the right hand side expression
* >= : `l` is greater than or equal to the right hand side expression
* <: `l` is less than the right hand side expression
* <= : `l` is less than or equal to the right hand side expression
* =: `l` is equal to the right hand side expression
* !=: `l` is not equal to the right hand side expression
*/
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!=';
/**
* Right hand side of the match expression (not required for op = + or - which have no right side)
* This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
* To reference another score dimension as the RHS, use the `rDim` property instead.
* `r` and `rDim` are mutually exclusive; if both are specified, then `rDim` wins.
*/
r?: number | string;
/**
* Right hand side of the match expression (not required for op = + or - which have no right side)
* This value is treated as a reference to another score dimension, if it is present in the score vector.
* If the referenced dimension is NOT present in the score vector, the match will always be false.
* To reference a constant value instead as the RHS, use the `r` property instead.
* `r` and `rDim` are mutually exclusive; if both are specified, then `rDim` wins.
*/
rDim?: string;
};
declare type TestOptions<TVariant extends TestVariant> = {
/** The name of the test that is being run, must be included in the manifest. */
name: string;
/** Variations that are being tested. */
variations: TVariant[];
};
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, }: TestOptions<TVariant> & {
context: Context;
}) => TestResult<TVariant>;
/**
* Defines a plugin for Uniform Context.
* The plugin should attach event handlers in its creation function.
* @returns A function that detaches any event handlers when called
*/
declare type ContextPlugin = {
logDrain?: LogDrain;
init?: (context: Context) => () => void;
};
declare type ContextOptions = {
/** The Context Manifest to load (from the Context API) */
manifest: ManifestV2;
/**
* Context plugins to load at initialize time.
* Plugins that hook to the log event should be added here so that they can catch init-time log message events.
*
* Note that the Context passed to the plugin is not yet fully initialized, and is intended for event handler attachment
* only - don't call scores, update, etc on it. If you need to call these methods immediately, attach your plugin after initialisation.
*/
plugins?: Array<ContextPlugin>;
} & Omit<VisitorDataStoreOptions, 'manifest' | 'onServerTransitionScoresReceived'>;
declare type PersonalizationEvent = {
name: string;
variantIds: string[];
control: boolean | undefined;
};
declare type TestEvent = {
name: string;
variantId: string | undefined;
control: boolean | undefined;
};
declare type ContextEvents = {
/**
* Fired when the scores are updated.
* The event is NOT fired if an update does not result in any score changes.
* The result is merged between session and permanent data.
*/
scoresUpdated: Readonly<ScoreVector>;
/**
* Fired when quirk data changes. Not fired if no changes to quirks are made
* (e.g. setting it to the same value it already has)
*/
quirksUpdated: Quirks;
/**
* Fired when a log message is emitted from Context
* Note that event handlers attached to this event will not catch events
* logged during initialisation of the Context unless they are attached as plugins to the constructor.
*/
log: LogMessage;
/** Test variant has been selected */
testResult: TestEvent;
/** Personalization variants have been selected */
personalizationResult: PersonalizationEvent;
};
declare class Context implements Context {
#private;
readonly manifest: ManifestInstance;
constructor(options: ContextOptions);
get scores(): Readonly<ScoreVector>;
/**
* Subscribe to events
*/
readonly events: {
on: {
<Key extends keyof ContextEvents>(type: Key, handler: mitt.Handler<ContextEvents[Key]>): void;
(type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
};
off: {
<Key_1 extends keyof ContextEvents>(type: Key_1, handler?: mitt.Handler<ContextEvents[Key_1]> | undefined): void;
(type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
};
};
readonly storage: VisitorDataStore;
update(newData: Partial<ContextState>): Promise<void>;
getTestVariantId(testName: string): string | null | undefined;
setTestVariantId(testName: string, variantId: string): void;
/**
* Writes a message to the Context log sink.
* Used by Uniform internal SDK; not intended for public use.
*/
log(...message: LogMessage): void;
/** Executes an A/B test with a given set of variants, showing the visitor's assigned variant (or selecting one to assign, if none is set yet) */
test<TVariant extends TestVariant>(options: TestOptions<TVariant>): TestResult<TVariant>;
/** Executes a personalized placement with a given set of variants */
personalize<TVariant extends PersonalizedVariant>(options: PersonalizeOptions<TVariant>): PersonalizedResult<TVariant>;
/**
* Forgets the visitor's data and resets the Context to its initial state.
* @param fromAllDevices for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
*/
forget(fromAllDevices: boolean): Promise<void>;
}
declare enum ScriptType {

@@ -732,66 +126,2 @@ ListStart = "nesi-list-start",

/**
* The version of the DevTools UI to load when in Chromium extension context.
* 1: Uniform Optimize.
* 2: Uniform Context.
*/
declare type DevToolsUiVersion = 1 | 2;
/**
* The data state provided to the devtools for rendering.
*/
declare type DevToolsState = {
/** Current computed visitor scores (includes aggregates) */
scores: Readonly<ScoreVector>;
/** Current visitor data (includes quirks, raw scores, tests, consent, etc) */
data: Readonly<VisitorData>;
/** Personalization events that have fired since devtools started */
personalizations: Array<PersonalizationEvent>;
/** Test events that have fired since devtools started */
tests: Array<TestEvent>;
/** The Context manifest */
manifest: ManifestV2;
};
/** Mutations the DevTools can take on the data it receives */
declare type DevToolsActions = {
/** Standard updates; maps to Context.update() */
update: (newData: Partial<ContextState>) => Promise<void>;
/** Raw updates to the storage subsystem. Maps to Context.storage.updateData() */
rawUpdate: (commands: StorageCommands[]) => Promise<void>;
/** Forget the current visitor and clear data on this device */
forget: () => Promise<void>;
};
declare type DevToolsEvent<Type extends string = string, TEventData = unknown> = {
/** The integration ID that is required */
type: Type;
} & TEventData;
declare type DevToolsEvents = DevToolsLogEvent | DevToolsDataEvent | DevToolsHelloEvent | DevToolsUpdateEvent | DevToolsRawCommandsEvent | DevToolsForgetEvent;
/** A log message emitted as an event to the browser extension */
declare type DevToolsLogEvent = DevToolsEvent<'uniform:context:log', {
message: LogMessage;
}>;
/** Emitted when data is updated in Context to the devtools */
declare type DevToolsDataEvent = DevToolsEvent<'uniform:context:data', {
data: DevToolsState;
}>;
/** A hello message emitted as an event from the browser extension to test if the page contains Context */
declare type DevToolsHelloEvent = DevToolsEvent<'uniform:context:hello', {
uiVersion: DevToolsUiVersion;
}>;
/** Devtools requests a normal update cycle (regular data update, re-eval signals, etc) */
declare type DevToolsUpdateEvent = DevToolsEvent<'uniform-in:context:update', {
newData: Partial<ContextState>;
}>;
/** Devtools requests a raw update cycle (explicitly set scores of dimensions in durations, etc) */
declare type DevToolsRawCommandsEvent = DevToolsEvent<'uniform-in:context:commands', {
commands: StorageCommands[];
}>;
/** A request to forget me from the DevTools */
declare type DevToolsForgetEvent = DevToolsEvent<'uniform-in:context:forget', unknown>;
declare global {
interface Window {
/** Window var set by enableContextDevTools() to enable embedded devtools to receive Context instance and attach events to it. */
__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__?: Context;
}
}
/**
* Enables a Context instance to feed data to the Uniform Context DevTools.

@@ -804,2 +134,2 @@ * DevTools can be hosted either as a Chromium extension, or as a standalone

export { AggregateDimension, AggregateDimensionInput, BehaviorTag, Context, ContextEvents, ContextOptions, ContextPlugin, ContextState, ContextStateUpdate, CookieAdapter, CookieTransitionDataStore, CookieTransitionDataStoreOptions, CriteriaEvaluator, DecayFunction, DecayOptions, DevToolsActions, DevToolsDataEvent, DevToolsEvent, DevToolsEvents, DevToolsForgetEvent, DevToolsHelloEvent, DevToolsLogEvent, DevToolsRawCommandsEvent, DevToolsState, DevToolsUiVersion, DevToolsUpdateEvent, DimensionMatch, EdgeNodeTagName, EdgePersonalizeComponentOptions, EdgeTestComponentOptions, EdgeTransitionDataStore, EdgeTransitionDataStoreOptions, EnrichmentCategory, EnrichmentData, EventData, GroupCriteriaEvaluator, IdentifyCommand, LinearDecayOptions, LogDrain, LogMessage, LogMessages, ManifestInstance, ManifestV2, MessageFunc, ModifyScoreCommand, ModifySessionScoreCommand, NumberMatch, OutputSeverity, PersonalizationEvent, PersonalizationManifest, PersonalizeOptions, PersonalizedResult, PersonalizedVariant, Quirks, SERVER_STATE_ID, ScoreVector, ScriptType, ServerToClientTransitionState, SetConsentCommand, SetQuirkCommand, SetTestCommand, Severity, Signal, SignalCriteria, SignalCriteriaGroup, StorageCommand, StorageCommands, StringMatch, TaggedContent, TestDefinition, TestEvent, TestOptions, TestResult, TestVariant, Tests, TransitionDataStore, TransitionDataStoreEvents, TransitionDataStoreOptions, VariantMatchCriteria, VisitorData, VisitorDataStore, VisitorDataStoreEvents, VisitorDataStoreOptions, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, emptyVisitorData, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, evaluateVariantMatch, eventEvaluator, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, pageVisitedEvaluator, personalizeVariations, queryStringEvaluator, quirkEvaluator, testVariations };
export { CookieTransitionDataStore, CookieTransitionDataStoreOptions, EdgeNodeTagName, EdgePersonalizeComponentOptions, EdgeTestComponentOptions, EdgeTransitionDataStore, EdgeTransitionDataStoreOptions, LinearDecayOptions, ScriptType, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, evaluateVariantMatch, eventEvaluator, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, pageVisitedEvaluator, queryStringEvaluator, quirkEvaluator };

@@ -1,3 +0,3 @@

import{d as v,e as n,f as m,g,h as y,i as u}from"./chunk-KZPEO35A.mjs";u();u();u();function gt(r,t){let e={...r};for(let o in t){let i=ht(r,o,t,new Set([o]));i!==0&&(e[o]=i)}return e}function ht(r,t,e,o){var s;let i=0;for(let a of e[t].inputs){let c=(s=r[a.dim])!=null?s:0;if(!c&&e[a.dim]){if(o.has(a.dim))continue;let f=new Set(o);f.add(a.dim),c=ht(r,a.dim,e,f)}if(c!==0)if(a.sign==="c"){i=0;break}else a.sign==="-"?i-=c:i+=c}return i}u();var K="_";u();var N,k,et=class{constructor(t,e,o){m(this,N,void 0);m(this,k,void 0);v(this,"signal");g(this,k,t),this.signal=e,g(this,N,o)}computeSignals(t,e){if(t.scores[n(this,k)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=n(this,N).evaluate(t,this.signal.crit,e,this.signal,n(this,k)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(i)e.push({type:s,data:{dimension:n(this,k),delta:this.signal.str}});else if(this.signal.dur==="t"){let a=t.visitor.sessionScores[n(this,k)];a&&e.push({type:s,data:{dimension:n(this,k),delta:-a}})}}};N=new WeakMap,k=new WeakMap;var b,$,rt=class{constructor({manifest:t,evaluator:e=new G({})}){v(this,"data");m(this,b,void 0);m(this,$,void 0);var o,i,s;g(this,b,(o=t.project)!=null?o:{}),this.data=t,g(this,$,Object.entries((s=(i=n(this,b).pz)==null?void 0:i.sig)!=null?s:[]).map(([a,c])=>new et(a,c,e)))}rollForControlGroup(){var t,e;return Math.random()<((e=(t=n(this,b).pz)==null?void 0:t.control)!=null?e:0)}getTest(t){var e;return(e=n(this,b).test)==null?void 0:e[t]}computeSignals(t){let e=[];return n(this,$).forEach(o=>{o.computeSignals(t,e)}),e}computeAggregateDimensions(t){var e,o;return gt(t,(o=(e=n(this,b).pz)==null?void 0:e.agg)!=null?o:{})}getDimensionByKey(t){var o,i,s,a;let e=t.indexOf(K);return e<=0?(i=(o=n(this,b).pz)==null?void 0:o.sig)==null?void 0:i[t]:(a=(s=n(this,b).pz)==null?void 0:s.enr)==null?void 0:a[t.substring(0,e)]}};b=new WeakMap,$=new WeakMap;u();var St=(r,t)=>{var i;if(t.type!=="CK")return!1;let e=(i=r.state.cookies)==null?void 0:i[t.cookieName];return E(e,t.match)};u();u();function vt(r,t){var o;if(typeof r=="undefined"||r===null)return!1;let e=Number(r);if(isNaN(e))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return e===t.rhs;case"!=":return e!==t.rhs;case">":return e>t.rhs;case"<":return e<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}u();function J(r,t){return`${r}${K}${t}`}var ot=J("$pvc","v"),yt=(r,t,e)=>{var a,c;if(t.type!=="PVC")return!1;let o=!r.previousState||((a=r.state.url)==null?void 0:a.toString())!==((c=r.previousState.url)==null?void 0:c.toString()),s=(r.visitor.sessionScores[ot]||0)+1;if(vt(s,t.match)){let d=e.some(f=>f.type==="modscoreS"&&f.data.dimension===ot);return o&&!d&&e.push({type:"modscoreS",data:{dimension:ot,delta:1}}),!0}return!1};u();var Dt=(r,t)=>{var o;if(t.type!=="QS")return!1;let e=(o=r.state.url)==null?void 0:o.searchParams.get(t.queryName);return E(e,t.match)};u();var Ct=(r,t,e,o,i)=>{if(t.type!=="QK")return!1;if(typeof window=="undefined"&&o.dur==="t"&&r.scores[i]>0)return!0;let s=r.visitor.quirks[t.key];return E(s,t.match)};u();var Vt=(r,t)=>{var e,o;return t.type!=="EVT"?!1:(o=(e=r.state.events)==null?void 0:e.some(i=>E(i.event,t.event)))!=null?o:!1};u();var xt=(r,t)=>{var e;return t.type!=="PV"?!1:E((e=r.state.url)==null?void 0:e.pathname,t.path)};u();var _,G=class{constructor(t){m(this,_,void 0);g(this,_,t)}evaluate(t,e,o,i,s){let a=!(e.op==="&"||!e.op);for(let c of e.clauses){let d;if(c.type==="G")d=this.evaluate(t,c,o,i,s);else{let f=n(this,_)[c.type];if(!f)throw new Error(`${c.type} signal criteria not registered`);d=f(t,c,o,i,s)}if(d===a)return a}return!a}};_=new WeakMap;u();function E(r,t){var a,c,d,f;let e=(a=t==null?void 0:t.op)!=null?a:"=";if(t.op==="*")return r!==null&&typeof r!="undefined";if(t.op==="!*")return r===null||typeof r=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${e}`);let o=(c=t.cs)!=null?c:!1,i=o?r!=null?r:"":bt(r),s=o?t.rhs:bt(t.rhs);switch(e){case"=":return i===s;case"!=":return i!==s;case"~":return(d=i.includes(s))!=null?d:!1;case"!~":return!((f=i.includes(s))!=null?f:!0);case"//":return new RegExp(t.rhs,o?"":"i").test(r!=null?r:"");case"!//":return!new RegExp(t.rhs,o?"":"i").test(r!=null?r:"");default:throw new Error(`Unknown match type ${e}.`)}}function bt(r){var t;return(t=r==null?void 0:r.toUpperCase())!=null?t:""}u();var B=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});u();u();import _t from"mitt";import{dequal as jt}from"dequal/lite";var Ft="__UNIFORM_DATA__",P,I,j=class{constructor({initialData:t}){m(this,P,void 0);m(this,I,_t());v(this,"events",{on:n(this,I).on,off:n(this,I).off});t&&g(this,P,t)}get data(){return n(this,P)}updateData(t,e){return g(this,P,e),this.handleUpdateData(t,e)}async delete(t){g(this,P,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){jt(this.data,t)||(g(this,P,t),n(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Ft);return(t==null?void 0:t.textContent)?JSON.parse(t.textContent):void 0}};P=new WeakMap,I=new WeakMap;u();var it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Et=it.split(""),Tt=new Array(123);for(let r=0;r<it.length;r++)Tt[it.charCodeAt(r)]=r;var nt=r=>{if(r<0)return`-${nt(-r)}`;let t=r>>>0,e=r/4294967296>>>0,o="";for(;e>0;)o=Et[63&t]+o,t>>>=6,t|=(63&e)<<26,e>>>=6;let i="";do i=Et[63&t]+i,t>>>=6;while(t>0);return i+o},kt=r=>{let t=0,e=r.charAt(0)==="-"?1:0;for(let o=e;o<r.length;o++)t=t*64+Tt[r.charCodeAt(o)];return e?-t:t};var wt=typeof window=="undefined",R,L,Qt=class extends j{constructor({cookieAdapter:t,cookieName:e="ufvd"}){super({initialData:wt?Kt(t.get(e)):void 0});m(this,R,void 0);m(this,L,void 0);g(this,R,e),g(this,L,t)}handleDelete(){return n(this,L).remove(n(this,R)),Promise.resolve()}async handleUpdateData(t,e){wt||(e.consent?n(this,L).set(n(this,R),Jt(e)):n(this,L).remove(n(this,R)))}};R=new WeakMap,L=new WeakMap;var Pt="~",Mt="!",Ot="-";function Kt(r){if(!r)return;let t=r.split(Pt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:Rt(st(o)),scores:Rt(st(i)),tests:st(e)}}function st(r){return r.split(Mt).map(e=>e.split(Ot)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function Rt(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=kt(o),t),{})}function Jt(r){return[at(r.tests),at(Lt(r.sessionScores)),at(Lt(r.scores))].join(Pt)}function Lt(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=nt(o),t),{})}function at(r){return Object.entries(r).map(t=>t.join(Ot)).join(Mt)}u();var H,Ht,Bt=class extends j{constructor({cookieAdapter:t,visitorIdCookieName:e="ufvi",...o}){super(o);m(this,H);o.initialData||y(this,H,Ht).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let e=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});e&&this.signalAsyncDataUpdate(e)}};H=new WeakSet,Ht=async function(){let t=await new Promise(e=>{setTimeout(()=>{e(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};u();function tr(r){let{gracePeriod:t=864e5,decayRate:e=1/30,decayCap:o=.95}=r!=null?r:{};return function({now:s,lastUpd:a,scores:c,sessionScores:d}){if(typeof a!="number")return!1;let x=s-a-t;if(x<=0)return!1;let D=x/864e5,A=1-Math.min(o,D*e);return A<=0?!1:(Ut(c,A),Ut(d,A),!0)}}function Ut(r,t){for(let e in r)r[e]*=t}u();import Wt from"mitt";import{dequal as Y}from"dequal/lite";u();var ut=class{constructor(){v(this,"inMemoryFallback",{});v(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let e=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||e)return e;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return e}}set(t,e,o){if(this.inMemoryFallback[t]=e,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(e))}catch(i){console.warn(i)}}delete(t,e){e||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};u();import Yt from"rfdc";var Xt=Yt();function At(r,t,e){let o=t?Xt(t):B();return r.forEach(i=>{var s,a;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(e)break;let c=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=c+i.data.delta;break;case"modscoreS":if(e)break;let d=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=d+i.data.delta;break;case"identify":break;default:throw new Error("Unknown command")}}),o}var X="ufvisitor",T,U,q,h,C,M,w,z,W,Zt,Z,te,F,It,Q,zt,ct=class{constructor(t){m(this,C);m(this,w);m(this,W);m(this,Z);m(this,F);m(this,Q);m(this,T,Wt());m(this,U,new ut);m(this,q,void 0);m(this,h,void 0);v(this,"events",{on:n(this,T).on,off:n(this,T).off});if(g(this,h,t),n(this,C,M)||y(this,w,z).call(this,y(this,Q,zt).call(this),!0),t.transitionStore){let e=t.transitionStore.getClientTransitionState();if(e){let i=[];e.quirks&&i.push(...Object.entries(e.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),e.tests&&i.push(...Object.entries(e.tests).map(([s,a])=>({type:"settest",data:{test:s,variant:a}}))),this.updateData(i),e.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(e.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{y(this,w,z).call(this,{...n(this,C,M).visitorData,...i})});let o=t.transitionStore.data;o&&y(this,w,z).call(this,{...n(this,C,M).visitorData,...o},!0)}}get data(){var e,o;let t=n(this,C,M);if(y(this,Z,te).call(this,t)){let{sessionScores:i,...s}=t.visitorData;return y(this,w,z).call(this,{...s,sessionScores:{}}),(o=(e=n(this,h)).onLogMessage)==null||o.call(e,["info",120]),n(this,C,M).visitorData}return t.visitorData}get decayEnabled(){return!!n(this,h).decay}async updateData(t){var o,i,s,a;if(t.length===0)return;(i=(o=n(this,h)).onLogMessage)==null||i.call(o,["debug",101,t]);let e=At(t,this.data,(s=n(this,C,M))==null?void 0:s.visitorData.controlGroup);t.some(c=>c.type==="consent"&&!c.data)&&n(this,U).delete(X,!0),y(this,w,z).call(this,e),await((a=n(this,h).transitionStore)==null?void 0:a.updateData(t,n(this,C,M).visitorData))}async delete(t){var e,o,i;n(this,U).delete(X,!1),await((e=n(this,h).transitionStore)==null?void 0:e.delete(t)),y(this,w,z).call(this,y(this,Q,zt).call(this)),(i=(o=n(this,h)).onLogMessage)==null||i.call(o,["info",103,t])}};T=new WeakMap,U=new WeakMap,q=new WeakMap,h=new WeakMap,C=new WeakSet,M=function(){return n(this,U).get(X)},w=new WeakSet,z=function(t,e=!1){var x,D,A,pt,ft,mt;let o=n(this,C,M),i=Date.now();y(this,F,It).call(this,t.scores),y(this,F,It).call(this,t.sessionScores),(D=(x=n(this,h)).decay)==null||D.call(x,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores});let s=!Y(o==null?void 0:o.visitorData.scores,t.scores),a=!Y(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),c=!Y(o==null?void 0:o.visitorData.quirks,t.quirks),d=!Y(o==null?void 0:o.visitorData.tests,t.tests),f={updated:i,visitorData:t};y(this,W,Zt).call(this),n(this,U).set(X,f,!!t.consent),(pt=(A=n(this,h)).onLogMessage)==null||pt.call(A,["debug",102,t]),e||((s||a)&&n(this,T).emit("scoresUpdated",t),c&&n(this,T).emit("quirksUpdated",t),d&&n(this,T).emit("testsUpdated",t),((ft=o==null?void 0:o.visitorData)==null?void 0:ft.consent)!==t.consent&&n(this,T).emit("consentUpdated",t),((mt=o==null?void 0:o.visitorData)==null?void 0:mt.controlGroup)!==t.controlGroup&&n(this,T).emit("controlGroupUpdated",t))},W=new WeakSet,Zt=function(){typeof window=="undefined"||!n(this,h).visitLifespan||(n(this,q)&&window.clearTimeout(n(this,q)),g(this,q,window.setTimeout(()=>{this.data},n(this,h).visitLifespan+50)))},Z=new WeakSet,te=function(t){let e=n(this,h).visitLifespan;return e?t.updated+e<Date.now():!1},F=new WeakSet,It=function(t){var e,o;if(!!n(this,h).manifest)for(let i in t){let s=t[i],a=n(this,h).manifest.getDimensionByKey(i);!a||s>a.cap&&((o=(e=n(this,h)).onLogMessage)==null||o.call(e,["debug",110,{dim:i,score:s,cap:a.cap}]),t[i]=a.cap)}},Q=new WeakSet,zt=function(){var t,e,o;return{...B(),consent:(t=n(this,h).defaultConsent)!=null?t:!1,controlGroup:(o=(e=n(this,h).manifest)==null?void 0:e.rollForControlGroup())!=null?o:!1}};u();import re from"mitt";u();u();function qt({context:r,variations:t,take:e=1}){var c,d;let o=(c=r.storage.data.controlGroup)!=null?c:!1,i=[],s=!1,a=r.scores;for(let f of t){if(i.length===e)break;if(!((d=f.pz)==null?void 0:d.crit.length)){i.push(f);continue}!o&&Nt(f.pz,a)&&(s=!0,i.push(f))}return{personalized:s,variations:i}}u();function Nt(r,t){return(r==null?void 0:r.crit)?!r.op||r.op==="&"?r.crit.every(e=>$t(e,t)):r.crit.some(e=>$t(e,t)):!0}function $t(r,t){var a;let{op:e,l:o}=r,i=(a=t[o])!=null?a:0;if(e==="+")return Math.max(...Object.values(t))===i&&i>0;if(e==="-")return Math.min(...Object.values(t))===i&&i>0;let s=r.rDim?t[r.rDim]:r.r;if(s===void 0)return!1;if(e===">")return i>s;if(e===">=")return i>=s;if(e==="<")return i<s;if(e==="<=")return i<=s;if(e==="=")return i===s;if(e==="!=")return i!==s;throw new Error(`Unknown op: ${e}`)}u();var ee=r=>{let{values:t,total:e,missingDistribution:o}=r.reduce((i,s)=>(s.testDistribution?i.total+=s.testDistribution:++i.missingDistribution,i.values.push(s.testDistribution),i),{values:[],total:0,missingDistribution:0});if(e>100)throw new Error(`Total distribution ${e} is over the maximum 100.`);if(e<100){let s=(100-e)/o;t.forEach((a,c)=>{typeof a=="undefined"&&(t[c]=s)})}return t},dt=({name:r,context:t,variations:e})=>{var s;let o,i=t.getTestVariantId(r);if(i===null)return{result:void 0};if(i&&(o=e.find(a=>a.id===i),o||t.log("warn",401,{test:r,variant:i})),!o){let a=ee(e),c=Math.floor(Math.random()*100),d=0;o=e.find((f,x)=>{let D=a[x];if(c>d&&c<=d+D)return f;d+=D}),o&&t.setTestVariantId(r,(s=o.id)!=null?s:"Unknown")}return{result:o}};var O,V,S,oe=class{constructor(t){v(this,"manifest");m(this,O,{});m(this,V,void 0);m(this,S,re());v(this,"events",{on:n(this,S).on,off:n(this,S).off});v(this,"storage");var a,c;let{manifest:e,...o}=t;g(this,V,{}),(a=t.plugins)==null||a.forEach(d=>{!d.logDrain||n(this,S).on("log",d.logDrain)}),this.manifest=new rt({manifest:e,evaluator:new G({CK:St,QS:Dt,QK:Ct,PVC:yt,EVT:Vt,PV:xt})});let i=!1;this.storage=new ct({...o,manifest:this.manifest,onServerTransitionScoresReceived:d=>{g(this,O,d),i=!0,n(this,S).emit("log",["debug",130,d])},onLogMessage:d=>n(this,S).emit("log",d)});let s=d=>{var x;let f={...d.scores};for(let D in d.sessionScores)f[D]=((x=f[D])!=null?x:0)+d.sessionScores[D];f=this.manifest.computeAggregateDimensions(f),g(this,O,f),n(this,S).emit("scoresUpdated",f),n(this,S).emit("log",["info",3,f])};this.storage.events.on("scoresUpdated",s),i||s(this.storage.data),this.storage.events.on("quirksUpdated",d=>{let f=this.manifest.computeSignals({scores:n(this,O),state:n(this,V),previousState:n(this,V),visitor:this.storage.data});this.storage.updateData(f),n(this,S).emit("quirksUpdated",d.quirks),n(this,S).emit("log",["info",4,d.quirks])}),n(this,S).emit("log",["debug",1]),(c=t.plugins)==null||c.forEach(d=>{!d.init||d.init(this)})}get scores(){return n(this,O)}async update(t){var i;let e=[];n(this,S).emit("log",["info",2,{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&(e.push(...Object.entries(t.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),t.quirks=void 0),t.enrichments&&(e.push(...t.enrichments.map(s=>({type:"modscore",data:{dimension:J(s.cat,s.key),delta:s.str}}))),t.enrichments=void 0);let o=n(this,V);g(this,V,{...n(this,V),...t}),e.push(...this.manifest.computeSignals({state:n(this,V),previousState:o,visitor:this.storage.data,scores:n(this,O)})),await this.storage.updateData(e)}getTestVariantId(t){var o;let e=this.manifest.getTest(t);return e?(o=e.wv)!=null?o:this.storage.data.tests[t]:(n(this,S).emit("log",["warn",401,t]),null)}setTestVariantId(t,e){this.storage.updateData([{type:"settest",data:{test:t,variant:e}}])}log(...t){n(this,S).emit("log",t)}test(t){var o;let e=dt({...t,context:this});return n(this,S).emit("testResult",{name:t.name,variantId:(o=e.result)==null?void 0:o.id,control:this.storage.data.controlGroup}),e}personalize(t){let e=qt({...t,context:this});return t.name?n(this,S).emit("personalizationResult",{name:t.name,variantIds:e.variations.map(o=>{var i;return(i=o.id)!=null?i:"Unknown"}),control:this.storage.data.controlGroup}):this.log("warn",301),e}async forget(t){g(this,V,{}),await this.storage.delete(t)}};O=new WeakMap,V=new WeakMap,S=new WeakMap;u();u();function tt(r,t){if(r==="none")return!1;switch(t){case"debug":return r==="debug";case"info":return r==="info"||r==="debug";case"warn":return r==="warn"||r==="info"||r==="debug";case"error":return r==="debug"||"info";default:return!1}}function ie(r){return([t,e,...o])=>{!tt(r,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${e}
`,...o.map(i=>JSON.stringify(i,null,2)))}}function qr(r){return{logDrain:ie(r)}}u();u();var Gt={1:()=>["tracker","constructed"],2:r=>["tracker","received data update",r],3:r=>["tracker","new score vector",r],4:r=>["tracker","updated quirks",r],101:r=>["storage","received update commands",r],102:r=>["storage","data was updated",r],103:r=>["storage",`data was deleted ${r?"from all devices":"from this device"}`],110:({dim:r,cap:t,score:e})=>["storage",`${r} score ${e} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:r=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",r],301:()=>["placement","Missing `name` field on personalization. Analytics events will not be triggered."],401:r=>["testing",`${r} was unknown; it will not be run.`],402:({test:r,variant:t})=>["testing",`${r} no longer has visitor's variant ${t}; it will be removed.`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};function ne(r){return([t,e,...o])=>{if(!tt(r,t))return;let i=Gt[e],s=`\u{1F94B} [${new Date().toLocaleTimeString()}][${t}]`;i||console[t](`${s} unknown message ID ${e} - ensure all Uniform packages are the same version`,...o);let[a,c,...d]=i(...o);console[t](`${s}[${a}] ${c} (Event ID: ${e})
`,...d.map(f=>JSON.stringify(f,null,2)))}}function jr(r){return{logDrain:ne(r)}}u();var se=(c=>(c.ListStart="nesi-list-start",c.ListEnd="nesi-list-end",c.ListItem="nesi-list-item-html",c.ListItemSettings="nesi-list-item-settings",c.TestStart="nesi-test-start",c.TestEnd="nesi-test-end",c.Unknown="unknown",c))(se||{}),Qr="nesitag";u();var lt=typeof top!="undefined";function Jr(){return{logDrain:r=>{!lt||top==null||top.postMessage({type:"uniform:context:log",message:r},window.location.origin)},init:r=>{let t=[],e=[];lt&&(window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=r,top==null||top.addEventListener("message",async a=>{if(!a.data)return;let c=a.data;await ae(c,r)}),top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin));let o=()=>{!lt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:r.scores,data:r.storage.data,manifest:r.manifest.data,personalizations:t,tests:e}},window.location.origin)},i=a=>{t.push(a),o()},s=a=>{e.push(a),o()};return r.events.on("personalizationResult",i),r.events.on("testResult",s),r.storage.events.on("*",o),()=>{r.storage.events.off("*",o),r.events.off("personalizationResult",i),r.events.off("testResult",s)}}}}async function ae(r,t){r.type==="uniform-in:context:update"&&r.newData&&await t.update(r.newData),r.type==="uniform-in:context:commands"&&r.commands&&Array.isArray(r.commands)&&await t.storage.updateData(r.commands),r.type==="uniform-in:context:forget"&&await t.forget(!1)}export{oe as Context,Qt as CookieTransitionDataStore,Qr as EdgeNodeTagName,Bt as EdgeTransitionDataStore,G as GroupCriteriaEvaluator,rt as ManifestInstance,Ft as SERVER_STATE_ID,se as ScriptType,j as TransitionDataStore,ct as VisitorDataStore,gt as computeAggregateDimensions,St as cookieEvaluator,ie as createConsoleLogDrain,ne as createDebugConsoleLogDrain,tr as createLinearDecay,B as emptyVisitorData,qr as enableConsoleLogDrain,Jr as enableContextDevTools,jr as enableDebugConsoleLogDrain,Nt as evaluateVariantMatch,Vt as eventEvaluator,J as getEnrichmentVectorKey,E as isStringMatch,ot as pageViewCountDimension,yt as pageViewCountEvaluator,xt as pageVisitedEvaluator,qt as personalizeVariations,Dt as queryStringEvaluator,Ct as quirkEvaluator,dt as testVariations};
import{a as J}from"./chunk-GU2YFM6V.mjs";import{d as v,e as n,f as m,g,h as y,i as u}from"./chunk-KZPEO35A.mjs";u();u();u();function ht(r,t){let e={...r};for(let o in t){let i=St(r,o,t,new Set([o]));i!==0&&(e[o]=i)}return e}function St(r,t,e,o){var s;let i=0;for(let a of e[t].inputs){let c=(s=r[a.dim])!=null?s:0;if(!c&&e[a.dim]){if(o.has(a.dim))continue;let l=new Set(o);l.add(a.dim),c=St(r,a.dim,e,l)}if(c!==0)if(a.sign==="c"){i=0;break}else a.sign==="-"?i-=c:i+=c}return i}u();var $,k,rt=class{constructor(t,e,o){m(this,$,void 0);m(this,k,void 0);v(this,"signal");g(this,k,t),this.signal=e,g(this,$,o)}computeSignals(t,e){if(t.scores[n(this,k)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=n(this,$).evaluate(t,this.signal.crit,e,this.signal,n(this,k)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(i)e.push({type:s,data:{dimension:n(this,k),delta:this.signal.str}});else if(this.signal.dur==="t"){let a=t.visitor.sessionScores[n(this,k)];a&&e.push({type:s,data:{dimension:n(this,k),delta:-a}})}}};$=new WeakMap,k=new WeakMap;var b,G,ot=class{constructor({manifest:t,evaluator:e=new N({})}){v(this,"data");m(this,b,void 0);m(this,G,void 0);var o,i,s;g(this,b,(o=t.project)!=null?o:{}),this.data=t,g(this,G,Object.entries((s=(i=n(this,b).pz)==null?void 0:i.sig)!=null?s:[]).map(([a,c])=>new rt(a,c,e)))}rollForControlGroup(){var t,e;return Math.random()<((e=(t=n(this,b).pz)==null?void 0:t.control)!=null?e:0)}getTest(t){var e;return(e=n(this,b).test)==null?void 0:e[t]}computeSignals(t){let e=[];return n(this,G).forEach(o=>{o.computeSignals(t,e)}),e}computeAggregateDimensions(t){var e,o;return ht(t,(o=(e=n(this,b).pz)==null?void 0:e.agg)!=null?o:{})}getDimensionByKey(t){var o,i,s,a;let e=t.indexOf(J);return e<=0?(i=(o=n(this,b).pz)==null?void 0:o.sig)==null?void 0:i[t]:(a=(s=n(this,b).pz)==null?void 0:s.enr)==null?void 0:a[t.substring(0,e)]}};b=new WeakMap,G=new WeakMap;u();var vt=(r,t)=>{var i;if(t.type!=="CK")return!1;let e=(i=r.state.cookies)==null?void 0:i[t.cookieName];return E(e,t.match)};u();u();function yt(r,t){var o;if(typeof r=="undefined"||r===null)return!1;let e=Number(r);if(isNaN(e))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return e===t.rhs;case"!=":return e!==t.rhs;case">":return e>t.rhs;case"<":return e<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}u();function B(r,t){return`${r}${J}${t}`}var it=B("$pvc","v"),Dt=(r,t,e)=>{var a,c;if(t.type!=="PVC")return!1;let o=!r.previousState||((a=r.state.url)==null?void 0:a.toString())!==((c=r.previousState.url)==null?void 0:c.toString()),s=(r.visitor.sessionScores[it]||0)+1;if(yt(s,t.match)){let d=e.some(l=>l.type==="modscoreS"&&l.data.dimension===it);return o&&!d&&e.push({type:"modscoreS",data:{dimension:it,delta:1}}),!0}return!1};u();var Ct=(r,t)=>{var o;if(t.type!=="QS")return!1;let e=(o=r.state.url)==null?void 0:o.searchParams.get(t.queryName);return E(e,t.match)};u();var Vt=(r,t,e,o,i)=>{if(t.type!=="QK")return!1;if(typeof window=="undefined"&&o.dur==="t"&&r.scores[i]>0)return!0;let s=r.visitor.quirks[t.key];return E(s,t.match)};u();var xt=(r,t)=>{var e,o;return t.type!=="EVT"?!1:(o=(e=r.state.events)==null?void 0:e.some(i=>E(i.event,t.event)))!=null?o:!1};u();var bt=(r,t)=>{var e;return t.type!=="PV"?!1:E((e=r.state.url)==null?void 0:e.pathname,t.path)};u();var _,N=class{constructor(t){m(this,_,void 0);g(this,_,t)}evaluate(t,e,o,i,s){let a=!(e.op==="&"||!e.op);for(let c of e.clauses){let d;if(c.type==="G")d=this.evaluate(t,c,o,i,s);else{let l=n(this,_)[c.type];if(!l)throw new Error(`${c.type} signal criteria not registered`);d=l(t,c,o,i,s)}if(d===a)return a}return!a}};_=new WeakMap;u();function E(r,t){var a,c,d,l;let e=(a=t==null?void 0:t.op)!=null?a:"=";if(t.op==="*")return r!==null&&typeof r!="undefined";if(t.op==="!*")return r===null||typeof r=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${e}`);let o=(c=t.cs)!=null?c:!1,i=o?r!=null?r:"":Et(r),s=o?t.rhs:Et(t.rhs);switch(e){case"=":return i===s;case"!=":return i!==s;case"~":return(d=i.includes(s))!=null?d:!1;case"!~":return!((l=i.includes(s))!=null?l:!0);case"//":return new RegExp(t.rhs,o?"":"i").test(r!=null?r:"");case"!//":return!new RegExp(t.rhs,o?"":"i").test(r!=null?r:"");default:throw new Error(`Unknown match type ${e}.`)}}function Et(r){var t;return(t=r==null?void 0:r.toUpperCase())!=null?t:""}u();var H=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});u();u();import jt from"mitt";import{dequal as Ft}from"dequal/lite";var Qt="__UNIFORM_DATA__",P,I,j=class{constructor({initialData:t}){m(this,P,void 0);m(this,I,jt());v(this,"events",{on:n(this,I).on,off:n(this,I).off});t&&g(this,P,t)}get data(){return n(this,P)}updateData(t,e){return g(this,P,e),this.handleUpdateData(t,e)}async delete(t){g(this,P,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){Ft(this.data,t)||(g(this,P,t),n(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Qt);return(t==null?void 0:t.textContent)?JSON.parse(t.textContent):void 0}};P=new WeakMap,I=new WeakMap;u();var nt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tt=nt.split(""),kt=new Array(123);for(let r=0;r<nt.length;r++)kt[nt.charCodeAt(r)]=r;var st=r=>{if(r<0)return`-${st(-r)}`;let t=r>>>0,e=r/4294967296>>>0,o="";for(;e>0;)o=Tt[63&t]+o,t>>>=6,t|=(63&e)<<26,e>>>=6;let i="";do i=Tt[63&t]+i,t>>>=6;while(t>0);return i+o},wt=r=>{let t=0,e=r.charAt(0)==="-"?1:0;for(let o=e;o<r.length;o++)t=t*64+kt[r.charCodeAt(o)];return e?-t:t};var Pt=typeof window=="undefined",R,L,Kt=class extends j{constructor({cookieAdapter:t,cookieName:e="ufvd"}){super({initialData:Pt?Jt(t.get(e)):void 0});m(this,R,void 0);m(this,L,void 0);g(this,R,e),g(this,L,t)}handleDelete(){return n(this,L).remove(n(this,R)),Promise.resolve()}async handleUpdateData(t,e){Pt||(e.consent?n(this,L).set(n(this,R),Bt(e)):n(this,L).remove(n(this,R)))}};R=new WeakMap,L=new WeakMap;var Mt="~",Ot="!",Rt="-";function Jt(r){if(!r)return;let t=r.split(Mt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:Lt(at(o)),scores:Lt(at(i)),tests:at(e)}}function at(r){return r.split(Ot).map(e=>e.split(Rt)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function Lt(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=wt(o),t),{})}function Bt(r){return[ut(r.tests),ut(At(r.sessionScores)),ut(At(r.scores))].join(Mt)}function At(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=st(o),t),{})}function ut(r){return Object.entries(r).map(t=>t.join(Rt)).join(Ot)}u();var Y,Yt,Ht=class extends j{constructor({cookieAdapter:t,visitorIdCookieName:e="ufvi",...o}){super(o);m(this,Y);o.initialData||y(this,Y,Yt).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let e=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});e&&this.signalAsyncDataUpdate(e)}};Y=new WeakSet,Yt=async function(){let t=await new Promise(e=>{setTimeout(()=>{e(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};u();function er(r){let{gracePeriod:t=864e5,decayRate:e=1/30,decayCap:o=.95}=r!=null?r:{};return function({now:s,lastUpd:a,scores:c,sessionScores:d}){if(typeof a!="number")return!1;let x=s-a-t;if(x<=0)return!1;let D=x/864e5,U=1-Math.min(o,D*e);return U<=0?!1:(Ut(c,U),Ut(d,U),!0)}}function Ut(r,t){for(let e in r)r[e]*=t}u();import Zt from"mitt";import{dequal as X}from"dequal/lite";u();var ct=class{constructor(){v(this,"inMemoryFallback",{});v(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let e=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||e)return e;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return e}}set(t,e,o){if(this.inMemoryFallback[t]=e,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(e))}catch(i){console.warn(i)}}delete(t,e){e||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};u();import Xt from"rfdc";var Wt=Xt();function It(r,t,e){let o=t?Wt(t):H();return r.forEach(i=>{var s,a;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(e)break;let c=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=c+i.data.delta;break;case"modscoreS":if(e)break;let d=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=d+i.data.delta;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var W="ufvisitor",T,A,q,h,C,M,w,z,Z,te,tt,ee,F,zt,Q,qt,dt=class{constructor(t){m(this,C);m(this,w);m(this,Z);m(this,tt);m(this,F);m(this,Q);m(this,T,Zt());m(this,A,new ct);m(this,q,void 0);m(this,h,void 0);v(this,"events",{on:n(this,T).on,off:n(this,T).off});if(g(this,h,t),n(this,C,M)||y(this,w,z).call(this,y(this,Q,qt).call(this),!0),t.transitionStore){let e=t.transitionStore.getClientTransitionState();if(e){let i=[];e.quirks&&i.push(...Object.entries(e.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),e.tests&&i.push(...Object.entries(e.tests).map(([s,a])=>({type:"settest",data:{test:s,variant:a}}))),this.updateData(i),e.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(e.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{y(this,w,z).call(this,{...n(this,C,M).visitorData,...i})});let o=t.transitionStore.data;o&&y(this,w,z).call(this,{...n(this,C,M).visitorData,...o},!0)}}get data(){var e,o;let t=n(this,C,M);if(y(this,tt,ee).call(this,t)){let{sessionScores:i,...s}=t.visitorData;return y(this,w,z).call(this,{...s,sessionScores:{}}),(o=(e=n(this,h)).onLogMessage)==null||o.call(e,["info",120]),n(this,C,M).visitorData}return t.visitorData}get decayEnabled(){return!!n(this,h).decay}async updateData(t){var o,i,s,a;if(t.length===0)return;(i=(o=n(this,h)).onLogMessage)==null||i.call(o,["debug",101,t]);let e=It(t,this.data,(s=n(this,C,M))==null?void 0:s.visitorData.controlGroup);t.some(c=>c.type==="consent"&&!c.data)&&n(this,A).delete(W,!0),y(this,w,z).call(this,e),await((a=n(this,h).transitionStore)==null?void 0:a.updateData(t,n(this,C,M).visitorData))}async delete(t){var e,o,i;n(this,A).delete(W,!1),await((e=n(this,h).transitionStore)==null?void 0:e.delete(t)),y(this,w,z).call(this,y(this,Q,qt).call(this)),(i=(o=n(this,h)).onLogMessage)==null||i.call(o,["info",103,t])}};T=new WeakMap,A=new WeakMap,q=new WeakMap,h=new WeakMap,C=new WeakSet,M=function(){return n(this,A).get(W)},w=new WeakSet,z=function(t,e=!1){var x,D,U,ft,mt,gt;let o=n(this,C,M),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(y(this,F,zt).call(this,t.scores),y(this,F,zt).call(this,t.sessionScores),(D=(x=n(this,h)).decay)==null||D.call(x,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let s=!X(o==null?void 0:o.visitorData.scores,t.scores),a=!X(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),c=!X(o==null?void 0:o.visitorData.quirks,t.quirks),d=!X(o==null?void 0:o.visitorData.tests,t.tests),l={updated:i,visitorData:t};y(this,Z,te).call(this),n(this,A).set(W,l,!!t.consent),(ft=(U=n(this,h)).onLogMessage)==null||ft.call(U,["debug",102,t]),e||((s||a)&&n(this,T).emit("scoresUpdated",t),c&&n(this,T).emit("quirksUpdated",t),d&&n(this,T).emit("testsUpdated",t),((mt=o==null?void 0:o.visitorData)==null?void 0:mt.consent)!==t.consent&&n(this,T).emit("consentUpdated",t),((gt=o==null?void 0:o.visitorData)==null?void 0:gt.controlGroup)!==t.controlGroup&&n(this,T).emit("controlGroupUpdated",t))},Z=new WeakSet,te=function(){typeof window=="undefined"||!n(this,h).visitLifespan||(n(this,q)&&window.clearTimeout(n(this,q)),g(this,q,window.setTimeout(()=>{this.data},n(this,h).visitLifespan+50)))},tt=new WeakSet,ee=function(t){let e=n(this,h).visitLifespan;return e?t.updated+e<Date.now():!1},F=new WeakSet,zt=function(t){var e,o;if(!!n(this,h).manifest)for(let i in t){let s=t[i],a=n(this,h).manifest.getDimensionByKey(i);!a||s>a.cap&&((o=(e=n(this,h)).onLogMessage)==null||o.call(e,["debug",110,{dim:i,score:s,cap:a.cap}]),t[i]=a.cap)}},Q=new WeakSet,qt=function(){var t,e,o;return{...H(),consent:(t=n(this,h).defaultConsent)!=null?t:!1,controlGroup:(o=(e=n(this,h).manifest)==null?void 0:e.rollForControlGroup())!=null?o:!1}};u();import oe from"mitt";u();u();function $t({context:r,variations:t,take:e=1}){var c,d;let o=(c=r.storage.data.controlGroup)!=null?c:!1,i=[],s=!1,a=r.scores;for(let l of t){if(i.length===e)break;if(!((d=l.pz)==null?void 0:d.crit.length)){i.push(l);continue}!o&&Gt(l.pz,a)&&(s=!0,i.push(l))}return{personalized:s,variations:i}}u();function Gt(r,t){return(r==null?void 0:r.crit)?!r.op||r.op==="&"?r.crit.every(e=>Nt(e,t)):r.crit.some(e=>Nt(e,t)):!0}function Nt(r,t){var a;let{op:e,l:o}=r,i=(a=t[o])!=null?a:0;if(e==="+")return Math.max(...Object.values(t))===i&&i>0;if(e==="-")return Math.min(...Object.values(t))===i&&i>0;let s=r.rDim?t[r.rDim]:r.r;if(s===void 0)return!1;if(e===">")return i>s;if(e===">=")return i>=s;if(e==="<")return i<s;if(e==="<=")return i<=s;if(e==="=")return i===s;if(e==="!=")return i!==s;throw new Error(`Unknown op: ${e}`)}u();var re=r=>{let{values:t,total:e,missingDistribution:o}=r.reduce((i,s)=>(s.testDistribution?i.total+=s.testDistribution:++i.missingDistribution,i.values.push(s.testDistribution),i),{values:[],total:0,missingDistribution:0});if(e>100)throw new Error(`Total distribution ${e} is over the maximum 100.`);if(e<100){let s=(100-e)/o;t.forEach((a,c)=>{typeof a=="undefined"&&(t[c]=s)})}return t},lt=({name:r,context:t,variations:e})=>{var s;let o,i=t.getTestVariantId(r);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=e.find(a=>a.id===i),o||t.log("warn",401,{test:r,variant:i})),!o){let a=re(e),c=Math.floor(Math.random()*100),d=0;o=e.find((l,x)=>{let D=a[x];if(c>d&&c<=d+D)return l;d+=D}),o&&t.setTestVariantId(r,(s=o.id)!=null?s:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as ie}from"dequal/lite";var O,V,K,S,ne=class{constructor(t){v(this,"manifest");m(this,O,{});m(this,V,void 0);m(this,K,{});m(this,S,oe());v(this,"events",{on:n(this,S).on,off:n(this,S).off});v(this,"storage");var a,c;let{manifest:e,...o}=t;g(this,V,{}),(a=t.plugins)==null||a.forEach(d=>{!d.logDrain||n(this,S).on("log",d.logDrain)}),this.manifest=new ot({manifest:e,evaluator:new N({CK:vt,QS:Ct,QK:Vt,PVC:Dt,EVT:xt,PV:bt})});let i=!1;this.storage=new dt({...o,manifest:this.manifest,onServerTransitionScoresReceived:d=>{g(this,O,d),i=!0,n(this,S).emit("log",["debug",130,d])},onLogMessage:d=>n(this,S).emit("log",d)});let s=d=>{var x;let l={...d.scores};for(let D in d.sessionScores)l[D]=((x=l[D])!=null?x:0)+d.sessionScores[D];l=this.manifest.computeAggregateDimensions(l),g(this,O,l),n(this,S).emit("scoresUpdated",l),n(this,S).emit("log",["info",3,l])};this.storage.events.on("scoresUpdated",s),i||s(this.storage.data),this.storage.events.on("quirksUpdated",d=>{let l=this.manifest.computeSignals({scores:n(this,O),state:n(this,V),previousState:n(this,V),visitor:this.storage.data});this.storage.updateData(l),n(this,S).emit("quirksUpdated",d.quirks),n(this,S).emit("log",["info",4,d.quirks])}),n(this,S).emit("log",["debug",1]),(c=t.plugins)==null||c.forEach(d=>{!d.init||d.init(this)})}get scores(){return n(this,O)}async update(t){var i;let e=[];n(this,S).emit("log",["info",2,{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&(e.push(...Object.entries(t.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),t.quirks=void 0),t.enrichments&&(e.push(...t.enrichments.map(s=>({type:"modscore",data:{dimension:B(s.cat,s.key),delta:s.str}}))),t.enrichments=void 0);let o=n(this,V);g(this,V,{...n(this,V),...t}),e.push(...this.manifest.computeSignals({state:n(this,V),previousState:o,visitor:this.storage.data,scores:n(this,O)})),await this.storage.updateData(e)}getTestVariantId(t){var o;let e=this.manifest.getTest(t);return e?(o=e.wv)!=null?o:this.storage.data.tests[t]:(n(this,S).emit("log",["warn",401,t]),null)}setTestVariantId(t,e){this.storage.updateData([{type:"settest",data:{test:t,variant:e}}])}log(...t){n(this,S).emit("log",t)}test(t){var o,i;let e=lt({...t,context:this});return n(this,S).emit("testResult",{name:t.name,variantId:(i=(o=e.result)==null?void 0:o.id)!=null?i:void 0,variantAssigned:e.variantAssigned}),e}personalize(t){let e=$t({...t,context:this}),o=n(this,K)[t.name],i={name:t.name,variantIds:e.variations.map(s=>{var a;return(a=s.id)!=null?a:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&ie(i.variantIds,o)&&(i.changed=!1),n(this,S).emit("personalizationResult",i),n(this,K)[t.name]=i.variantIds,e}async forget(t){g(this,V,{}),await this.storage.delete(t)}};O=new WeakMap,V=new WeakMap,K=new WeakMap,S=new WeakMap;u();u();function et(r,t){if(r==="none")return!1;switch(t){case"debug":return r==="debug";case"info":return r==="info"||r==="debug";case"warn":return r==="warn"||r==="info"||r==="debug";case"error":return r==="debug"||"info";default:return!1}}function se(r){return([t,e,...o])=>{!et(r,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${e}
`,...o.map(i=>JSON.stringify(i,null,2)))}}function Gr(r){return{logDrain:se(r)}}u();u();var _t={1:()=>["tracker","constructed"],2:r=>["tracker","received data update",r],3:r=>["tracker","new score vector",r],4:r=>["tracker","updated quirks",r],101:r=>["storage","received update commands",r],102:r=>["storage","data was updated",r],103:r=>["storage",`data was deleted ${r?"from all devices":"from this device"}`],110:({dim:r,cap:t,score:e})=>["storage",`${r} score ${e} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:r=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",r],401:r=>["testing",`${r} was unknown; it will not be run.`],402:({test:r,variant:t})=>["testing",`${r} no longer has visitor's variant ${t}; it will be removed.`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};function ae(r){return([t,e,...o])=>{if(!et(r,t))return;let i=_t[e],s=`\u{1F94B} [${new Date().toLocaleTimeString()}][${t}]`;i||console[t](`${s} unknown message ID ${e} - ensure all Uniform packages are the same version`,...o);let[a,c,...d]=i(...o);console[t](`${s}[${a}] ${c} (Event ID: ${e})
`,...d.map(l=>JSON.stringify(l,null,2)))}}function Qr(r){return{logDrain:ae(r)}}u();var ue=(c=>(c.ListStart="nesi-list-start",c.ListEnd="nesi-list-end",c.ListItem="nesi-list-item-html",c.ListItemSettings="nesi-list-item-settings",c.TestStart="nesi-test-start",c.TestEnd="nesi-test-end",c.Unknown="unknown",c))(ue||{}),Jr="nesitag";u();var pt=typeof top!="undefined";function Hr(){return{logDrain:r=>{!pt||top==null||top.postMessage({type:"uniform:context:log",message:r},window.location.origin)},init:r=>{let t=[],e=[];pt&&(window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=r,top==null||top.addEventListener("message",async a=>{if(!a.data)return;let c=a.data;await ce(c,r)}),top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin));let o=()=>{!pt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:r.scores,data:r.storage.data,manifest:r.manifest.data,personalizations:t,tests:e}},window.location.origin)},i=a=>{!a.changed||(t.push(a),o())},s=a=>{!a.variantAssigned||(e.push(a),o())};return r.events.on("personalizationResult",i),r.events.on("testResult",s),r.storage.events.on("*",o),()=>{r.storage.events.off("*",o),r.events.off("personalizationResult",i),r.events.off("testResult",s)}}}}async function ce(r,t){r.type==="uniform-in:context:update"&&r.newData&&await t.update(r.newData),r.type==="uniform-in:context:commands"&&r.commands&&Array.isArray(r.commands)&&await t.storage.updateData(r.commands),r.type==="uniform-in:context:forget"&&await t.forget(!1)}export{ne as Context,Kt as CookieTransitionDataStore,Jr as EdgeNodeTagName,Ht as EdgeTransitionDataStore,N as GroupCriteriaEvaluator,ot as ManifestInstance,Qt as SERVER_STATE_ID,ue as ScriptType,j as TransitionDataStore,dt as VisitorDataStore,ht as computeAggregateDimensions,vt as cookieEvaluator,se as createConsoleLogDrain,ae as createDebugConsoleLogDrain,er as createLinearDecay,H as emptyVisitorData,Gr as enableConsoleLogDrain,Hr as enableContextDevTools,Qr as enableDebugConsoleLogDrain,Gt as evaluateVariantMatch,xt as eventEvaluator,B as getEnrichmentVectorKey,E as isStringMatch,it as pageViewCountDimension,Dt as pageViewCountEvaluator,bt as pageVisitedEvaluator,$t as personalizeVariations,Ct as queryStringEvaluator,Vt as quirkEvaluator,lt as testVariations};

@@ -1,3 +0,3 @@

var oe=Object.create;var N=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var ue=(e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Et=e=>N(e,"__esModule",{value:!0});var ce=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},Tt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ne(t))!ae.call(e,i)&&(r||i!=="default")&&N(e,i,{get:()=>t[i],enumerable:!(o=ie(t,i))||o.enumerable});return e},B=(e,t)=>Tt(Et(N(e!=null?oe(se(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),de=(e=>(t,r)=>e&&e.get(t)||(r=Tt(Et({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var h=(e,t,r)=>(ue(e,typeof t!="symbol"?t+"":t,r),r),nt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var n=(e,t,r)=>(nt(e,t,"read from private field"),r?r.call(e):t.get(e)),p=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},f=(e,t,r,o)=>(nt(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var S=(e,t,r)=>(nt(e,t,"access private method"),r);var be={};ce(be,{Context:()=>Wt,CookieTransitionDataStore:()=>zt,EdgeNodeTagName:()=>Ce,EdgeTransitionDataStore:()=>jt,GroupCriteriaEvaluator:()=>U,ManifestInstance:()=>Y,SERVER_STATE_ID:()=>Rt,ScriptType:()=>re,TransitionDataStore:()=>A,VisitorDataStore:()=>tt,computeAggregateDimensions:()=>st,cookieEvaluator:()=>ut,createConsoleLogDrain:()=>Zt,createDebugConsoleLogDrain:()=>ee,createLinearDecay:()=>me,emptyVisitorData:()=>F,enableConsoleLogDrain:()=>ye,enableContextDevTools:()=>Ve,enableDebugConsoleLogDrain:()=>De,evaluateVariantMatch:()=>Dt,eventEvaluator:()=>pt,getEnrichmentVectorKey:()=>_,isStringMatch:()=>y,pageViewCountDimension:()=>X,pageViewCountEvaluator:()=>ct,pageVisitedEvaluator:()=>ft,personalizeVariations:()=>yt,queryStringEvaluator:()=>dt,quirkEvaluator:()=>lt,testVariations:()=>ot});function st(e,t){let r={...e};for(let o in t){let i=kt(e,o,t,new Set([o]));i!==0&&(r[o]=i)}return r}function kt(e,t,r,o){var s;let i=0;for(let a of r[t].inputs){let u=(s=e[a.dim])!=null?s:0;if(!u&&r[a.dim]){if(o.has(a.dim))continue;let l=new Set(o);l.add(a.dim),u=kt(e,a.dim,r,l)}if(u!==0)if(a.sign==="c"){i=0;break}else a.sign==="-"?i-=u:i+=u}return i}var H="_";var $,E,at=class{constructor(t,r,o){p(this,$,void 0);p(this,E,void 0);h(this,"signal");f(this,E,t),this.signal=r,f(this,$,o)}computeSignals(t,r){if(t.scores[n(this,E)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=n(this,$).evaluate(t,this.signal.crit,r,this.signal,n(this,E)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(i)r.push({type:s,data:{dimension:n(this,E),delta:this.signal.str}});else if(this.signal.dur==="t"){let a=t.visitor.sessionScores[n(this,E)];a&&r.push({type:s,data:{dimension:n(this,E),delta:-a}})}}};$=new WeakMap,E=new WeakMap;var x,G,Y=class{constructor({manifest:t,evaluator:r=new U({})}){h(this,"data");p(this,x,void 0);p(this,G,void 0);var o,i,s;f(this,x,(o=t.project)!=null?o:{}),this.data=t,f(this,G,Object.entries((s=(i=n(this,x).pz)==null?void 0:i.sig)!=null?s:[]).map(([a,u])=>new at(a,u,r)))}rollForControlGroup(){var t,r;return Math.random()<((r=(t=n(this,x).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=n(this,x).test)==null?void 0:r[t]}computeSignals(t){let r=[];return n(this,G).forEach(o=>{o.computeSignals(t,r)}),r}computeAggregateDimensions(t){var r,o;return st(t,(o=(r=n(this,x).pz)==null?void 0:r.agg)!=null?o:{})}getDimensionByKey(t){var o,i,s,a;let r=t.indexOf(H);return r<=0?(i=(o=n(this,x).pz)==null?void 0:o.sig)==null?void 0:i[t]:(a=(s=n(this,x).pz)==null?void 0:s.enr)==null?void 0:a[t.substring(0,r)]}};x=new WeakMap,G=new WeakMap;var ut=(e,t)=>{var i;if(t.type!=="CK")return!1;let r=(i=e.state.cookies)==null?void 0:i[t.cookieName];return y(r,t.match)};function wt(e,t){var o;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return r===t.rhs;case"!=":return r!==t.rhs;case">":return r>t.rhs;case"<":return r<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function _(e,t){return`${e}${H}${t}`}var X=_("$pvc","v"),ct=(e,t,r)=>{var a,u;if(t.type!=="PVC")return!1;let o=!e.previousState||((a=e.state.url)==null?void 0:a.toString())!==((u=e.previousState.url)==null?void 0:u.toString()),s=(e.visitor.sessionScores[X]||0)+1;if(wt(s,t.match)){let c=r.some(l=>l.type==="modscoreS"&&l.data.dimension===X);return o&&!c&&r.push({type:"modscoreS",data:{dimension:X,delta:1}}),!0}return!1};var dt=(e,t)=>{var o;if(t.type!=="QS")return!1;let r=(o=e.state.url)==null?void 0:o.searchParams.get(t.queryName);return y(r,t.match)};var lt=(e,t,r,o,i)=>{if(t.type!=="QK")return!1;if(typeof window=="undefined"&&o.dur==="t"&&e.scores[i]>0)return!0;let s=e.visitor.quirks[t.key];return y(s,t.match)};var pt=(e,t)=>{var r,o;return t.type!=="EVT"?!1:(o=(r=e.state.events)==null?void 0:r.some(i=>y(i.event,t.event)))!=null?o:!1};var ft=(e,t)=>{var r;return t.type!=="PV"?!1:y((r=e.state.url)==null?void 0:r.pathname,t.path)};var j,U=class{constructor(t){p(this,j,void 0);f(this,j,t)}evaluate(t,r,o,i,s){let a=!(r.op==="&"||!r.op);for(let u of r.clauses){let c;if(u.type==="G")c=this.evaluate(t,u,o,i,s);else{let l=n(this,j)[u.type];if(!l)throw new Error(`${u.type} signal criteria not registered`);c=l(t,u,o,i,s)}if(c===a)return a}return!a}};j=new WeakMap;function y(e,t){var a,u,c,l;let r=(a=t==null?void 0:t.op)!=null?a:"=";if(t.op==="*")return e!==null&&typeof e!="undefined";if(t.op==="!*")return e===null||typeof e=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${r}`);let o=(u=t.cs)!=null?u:!1,i=o?e!=null?e:"":Pt(e),s=o?t.rhs:Pt(t.rhs);switch(r){case"=":return i===s;case"!=":return i!==s;case"~":return(c=i.includes(s))!=null?c:!1;case"!~":return!((l=i.includes(s))!=null?l:!0);case"//":return new RegExp(t.rhs,o?"":"i").test(e!=null?e:"");case"!//":return!new RegExp(t.rhs,o?"":"i").test(e!=null?e:"");default:throw new Error(`Unknown match type ${r}.`)}}function Pt(e){var t;return(t=e==null?void 0:e.toUpperCase())!=null?t:""}var F=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Mt=B(require("mitt")),Ot=require("dequal/lite"),Rt="__UNIFORM_DATA__",k,I,A=class{constructor({initialData:t}){p(this,k,void 0);p(this,I,(0,Mt.default)());h(this,"events",{on:n(this,I).on,off:n(this,I).off});t&&f(this,k,t)}get data(){return n(this,k)}updateData(t,r){return f(this,k,r),this.handleUpdateData(t,r)}async delete(t){f(this,k,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,Ot.dequal)(this.data,t)||(f(this,k,t),n(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Rt);return(t==null?void 0:t.textContent)?JSON.parse(t.textContent):void 0}};k=new WeakMap,I=new WeakMap;var mt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Lt=mt.split(""),Ut=new Array(123);for(let e=0;e<mt.length;e++)Ut[mt.charCodeAt(e)]=e;var gt=e=>{if(e<0)return`-${gt(-e)}`;let t=e>>>0,r=e/4294967296>>>0,o="";for(;r>0;)o=Lt[63&t]+o,t>>>=6,t|=(63&r)<<26,r>>>=6;let i="";do i=Lt[63&t]+i,t>>>=6;while(t>0);return i+o},At=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let o=r;o<e.length;o++)t=t*64+Ut[e.charCodeAt(o)];return r?-t:t};var It=typeof window=="undefined",M,O,zt=class extends A{constructor({cookieAdapter:t,cookieName:r="ufvd"}){super({initialData:It?le(t.get(r)):void 0});p(this,M,void 0);p(this,O,void 0);f(this,M,r),f(this,O,t)}handleDelete(){return n(this,O).remove(n(this,M)),Promise.resolve()}async handleUpdateData(t,r){It||(r.consent?n(this,O).set(n(this,M),pe(r)):n(this,O).remove(n(this,M)))}};M=new WeakMap,O=new WeakMap;var qt="~",Nt="!",$t="-";function le(e){if(!e)return;let t=e.split(qt);if(t.length>3)return;let[r,o,i]=t;return{consent:!0,sessionScores:Gt(ht(o)),scores:Gt(ht(i)),tests:ht(r)}}function ht(e){return e.split(Nt).map(r=>r.split($t)).reduce((r,o)=>(o.length!==2||(r[o[0]]=o[1]),r),{})}function Gt(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=At(o),t),{})}function pe(e){return[St(e.tests),St(_t(e.sessionScores)),St(_t(e.scores))].join(qt)}function _t(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=gt(o),t),{})}function St(e){return Object.entries(e).map(t=>t.join($t)).join(Nt)}var W,fe,jt=class extends A{constructor({cookieAdapter:t,visitorIdCookieName:r="ufvi",...o}){super(o);p(this,W);o.initialData||S(this,W,fe).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let r=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};W=new WeakSet,fe=async function(){let t=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};function me(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:o=.95}=e!=null?e:{};return function({now:s,lastUpd:a,scores:u,sessionScores:c}){if(typeof a!="number")return!1;let V=s-a-t;if(V<=0)return!1;let v=V/864e5,L=1-Math.min(o,v*r);return L<=0?!1:(Ft(u,L),Ft(c,L),!0)}}function Ft(e,t){for(let r in e)e[r]*=t}var Jt=B(require("mitt")),Q=require("dequal/lite");var vt=class{constructor(){h(this,"inMemoryFallback",{});h(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return r}}set(t,r,o){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(r))}catch(i){console.warn(i)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};var Qt=B(require("rfdc"));var ge=(0,Qt.default)();function Kt(e,t,r){let o=t?ge(t):F();return e.forEach(i=>{var s,a;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(r)break;let u=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=u+i.data.delta;break;case"modscoreS":if(r)break;let c=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=c+i.data.delta;break;case"identify":break;default:throw new Error("Unknown command")}}),o}var Z="ufvisitor",b,R,q,m,D,w,T,z,et,he,rt,Se,K,Bt,J,Ht,tt=class{constructor(t){p(this,D);p(this,T);p(this,et);p(this,rt);p(this,K);p(this,J);p(this,b,(0,Jt.default)());p(this,R,new vt);p(this,q,void 0);p(this,m,void 0);h(this,"events",{on:n(this,b).on,off:n(this,b).off});if(f(this,m,t),n(this,D,w)||S(this,T,z).call(this,S(this,J,Ht).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();if(r){let i=[];r.quirks&&i.push(...Object.entries(r.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),r.tests&&i.push(...Object.entries(r.tests).map(([s,a])=>({type:"settest",data:{test:s,variant:a}}))),this.updateData(i),r.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(r.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{S(this,T,z).call(this,{...n(this,D,w).visitorData,...i})});let o=t.transitionStore.data;o&&S(this,T,z).call(this,{...n(this,D,w).visitorData,...o},!0)}}get data(){var r,o;let t=n(this,D,w);if(S(this,rt,Se).call(this,t)){let{sessionScores:i,...s}=t.visitorData;return S(this,T,z).call(this,{...s,sessionScores:{}}),(o=(r=n(this,m)).onLogMessage)==null||o.call(r,["info",120]),n(this,D,w).visitorData}return t.visitorData}get decayEnabled(){return!!n(this,m).decay}async updateData(t){var o,i,s,a;if(t.length===0)return;(i=(o=n(this,m)).onLogMessage)==null||i.call(o,["debug",101,t]);let r=Kt(t,this.data,(s=n(this,D,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&n(this,R).delete(Z,!0),S(this,T,z).call(this,r),await((a=n(this,m).transitionStore)==null?void 0:a.updateData(t,n(this,D,w).visitorData))}async delete(t){var r,o,i;n(this,R).delete(Z,!1),await((r=n(this,m).transitionStore)==null?void 0:r.delete(t)),S(this,T,z).call(this,S(this,J,Ht).call(this)),(i=(o=n(this,m)).onLogMessage)==null||i.call(o,["info",103,t])}};b=new WeakMap,R=new WeakMap,q=new WeakMap,m=new WeakMap,D=new WeakSet,w=function(){return n(this,R).get(Z)},T=new WeakSet,z=function(t,r=!1){var V,v,L,Vt,xt,bt;let o=n(this,D,w),i=Date.now();S(this,K,Bt).call(this,t.scores),S(this,K,Bt).call(this,t.sessionScores),(v=(V=n(this,m)).decay)==null||v.call(V,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores});let s=!(0,Q.dequal)(o==null?void 0:o.visitorData.scores,t.scores),a=!(0,Q.dequal)(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),u=!(0,Q.dequal)(o==null?void 0:o.visitorData.quirks,t.quirks),c=!(0,Q.dequal)(o==null?void 0:o.visitorData.tests,t.tests),l={updated:i,visitorData:t};S(this,et,he).call(this),n(this,R).set(Z,l,!!t.consent),(Vt=(L=n(this,m)).onLogMessage)==null||Vt.call(L,["debug",102,t]),r||((s||a)&&n(this,b).emit("scoresUpdated",t),u&&n(this,b).emit("quirksUpdated",t),c&&n(this,b).emit("testsUpdated",t),((xt=o==null?void 0:o.visitorData)==null?void 0:xt.consent)!==t.consent&&n(this,b).emit("consentUpdated",t),((bt=o==null?void 0:o.visitorData)==null?void 0:bt.controlGroup)!==t.controlGroup&&n(this,b).emit("controlGroupUpdated",t))},et=new WeakSet,he=function(){typeof window=="undefined"||!n(this,m).visitLifespan||(n(this,q)&&window.clearTimeout(n(this,q)),f(this,q,window.setTimeout(()=>{this.data},n(this,m).visitLifespan+50)))},rt=new WeakSet,Se=function(t){let r=n(this,m).visitLifespan;return r?t.updated+r<Date.now():!1},K=new WeakSet,Bt=function(t){var r,o;if(!!n(this,m).manifest)for(let i in t){let s=t[i],a=n(this,m).manifest.getDimensionByKey(i);!a||s>a.cap&&((o=(r=n(this,m)).onLogMessage)==null||o.call(r,["debug",110,{dim:i,score:s,cap:a.cap}]),t[i]=a.cap)}},J=new WeakSet,Ht=function(){var t,r,o;return{...F(),consent:(t=n(this,m).defaultConsent)!=null?t:!1,controlGroup:(o=(r=n(this,m).manifest)==null?void 0:r.rollForControlGroup())!=null?o:!1}};var Xt=B(require("mitt"));function yt({context:e,variations:t,take:r=1}){var u,c;let o=(u=e.storage.data.controlGroup)!=null?u:!1,i=[],s=!1,a=e.scores;for(let l of t){if(i.length===r)break;if(!((c=l.pz)==null?void 0:c.crit.length)){i.push(l);continue}!o&&Dt(l.pz,a)&&(s=!0,i.push(l))}return{personalized:s,variations:i}}function Dt(e,t){return(e==null?void 0:e.crit)?!e.op||e.op==="&"?e.crit.every(r=>Yt(r,t)):e.crit.some(r=>Yt(r,t)):!0}function Yt(e,t){var a;let{op:r,l:o}=e,i=(a=t[o])!=null?a:0;if(r==="+")return Math.max(...Object.values(t))===i&&i>0;if(r==="-")return Math.min(...Object.values(t))===i&&i>0;let s=e.rDim?t[e.rDim]:e.r;if(s===void 0)return!1;if(r===">")return i>s;if(r===">=")return i>=s;if(r==="<")return i<s;if(r==="<=")return i<=s;if(r==="=")return i===s;if(r==="!=")return i!==s;throw new Error(`Unknown op: ${r}`)}var ve=e=>{let{values:t,total:r,missingDistribution:o}=e.reduce((i,s)=>(s.testDistribution?i.total+=s.testDistribution:++i.missingDistribution,i.values.push(s.testDistribution),i),{values:[],total:0,missingDistribution:0});if(r>100)throw new Error(`Total distribution ${r} is over the maximum 100.`);if(r<100){let s=(100-r)/o;t.forEach((a,u)=>{typeof a=="undefined"&&(t[u]=s)})}return t},ot=({name:e,context:t,variations:r})=>{var s;let o,i=t.getTestVariantId(e);if(i===null)return{result:void 0};if(i&&(o=r.find(a=>a.id===i),o||t.log("warn",401,{test:e,variant:i})),!o){let a=ve(r),u=Math.floor(Math.random()*100),c=0;o=r.find((l,V)=>{let v=a[V];if(u>c&&u<=c+v)return l;c+=v}),o&&t.setTestVariantId(e,(s=o.id)!=null?s:"Unknown")}return{result:o}};var P,C,g,Wt=class{constructor(t){h(this,"manifest");p(this,P,{});p(this,C,void 0);p(this,g,(0,Xt.default)());h(this,"events",{on:n(this,g).on,off:n(this,g).off});h(this,"storage");var a,u;let{manifest:r,...o}=t;f(this,C,{}),(a=t.plugins)==null||a.forEach(c=>{!c.logDrain||n(this,g).on("log",c.logDrain)}),this.manifest=new Y({manifest:r,evaluator:new U({CK:ut,QS:dt,QK:lt,PVC:ct,EVT:pt,PV:ft})});let i=!1;this.storage=new tt({...o,manifest:this.manifest,onServerTransitionScoresReceived:c=>{f(this,P,c),i=!0,n(this,g).emit("log",["debug",130,c])},onLogMessage:c=>n(this,g).emit("log",c)});let s=c=>{var V;let l={...c.scores};for(let v in c.sessionScores)l[v]=((V=l[v])!=null?V:0)+c.sessionScores[v];l=this.manifest.computeAggregateDimensions(l),f(this,P,l),n(this,g).emit("scoresUpdated",l),n(this,g).emit("log",["info",3,l])};this.storage.events.on("scoresUpdated",s),i||s(this.storage.data),this.storage.events.on("quirksUpdated",c=>{let l=this.manifest.computeSignals({scores:n(this,P),state:n(this,C),previousState:n(this,C),visitor:this.storage.data});this.storage.updateData(l),n(this,g).emit("quirksUpdated",c.quirks),n(this,g).emit("log",["info",4,c.quirks])}),n(this,g).emit("log",["debug",1]),(u=t.plugins)==null||u.forEach(c=>{!c.init||c.init(this)})}get scores(){return n(this,P)}async update(t){var i;let r=[];n(this,g).emit("log",["info",2,{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&(r.push(...Object.entries(t.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),t.quirks=void 0),t.enrichments&&(r.push(...t.enrichments.map(s=>({type:"modscore",data:{dimension:_(s.cat,s.key),delta:s.str}}))),t.enrichments=void 0);let o=n(this,C);f(this,C,{...n(this,C),...t}),r.push(...this.manifest.computeSignals({state:n(this,C),previousState:o,visitor:this.storage.data,scores:n(this,P)})),await this.storage.updateData(r)}getTestVariantId(t){var o;let r=this.manifest.getTest(t);return r?(o=r.wv)!=null?o:this.storage.data.tests[t]:(n(this,g).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){n(this,g).emit("log",t)}test(t){var o;let r=ot({...t,context:this});return n(this,g).emit("testResult",{name:t.name,variantId:(o=r.result)==null?void 0:o.id,control:this.storage.data.controlGroup}),r}personalize(t){let r=yt({...t,context:this});return t.name?n(this,g).emit("personalizationResult",{name:t.name,variantIds:r.variations.map(o=>{var i;return(i=o.id)!=null?i:"Unknown"}),control:this.storage.data.controlGroup}):this.log("warn",301),r}async forget(t){f(this,C,{}),await this.storage.delete(t)}};P=new WeakMap,C=new WeakMap,g=new WeakMap;function it(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}function Zt(e){return([t,r,...o])=>{!it(e,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
`,...o.map(i=>JSON.stringify(i,null,2)))}}function ye(e){return{logDrain:Zt(e)}}var te={1:()=>["tracker","constructed"],2:e=>["tracker","received data update",e],3:e=>["tracker","new score vector",e],4:e=>["tracker","updated quirks",e],101:e=>["storage","received update commands",e],102:e=>["storage","data was updated",e],103:e=>["storage",`data was deleted ${e?"from all devices":"from this device"}`],110:({dim:e,cap:t,score:r})=>["storage",`${e} score ${r} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:e=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",e],301:()=>["placement","Missing `name` field on personalization. Analytics events will not be triggered."],401:e=>["testing",`${e} was unknown; it will not be run.`],402:({test:e,variant:t})=>["testing",`${e} no longer has visitor's variant ${t}; it will be removed.`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};function ee(e){return([t,r,...o])=>{if(!it(e,t))return;let i=te[r],s=`\u{1F94B} [${new Date().toLocaleTimeString()}][${t}]`;i||console[t](`${s} unknown message ID ${r} - ensure all Uniform packages are the same version`,...o);let[a,u,...c]=i(...o);console[t](`${s}[${a}] ${u} (Event ID: ${r})
`,...c.map(l=>JSON.stringify(l,null,2)))}}function De(e){return{logDrain:ee(e)}}var re=(u=>(u.ListStart="nesi-list-start",u.ListEnd="nesi-list-end",u.ListItem="nesi-list-item-html",u.ListItemSettings="nesi-list-item-settings",u.TestStart="nesi-test-start",u.TestEnd="nesi-test-end",u.Unknown="unknown",u))(re||{}),Ce="nesitag";var Ct=typeof top!="undefined";function Ve(){return{logDrain:e=>{!Ct||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[];Ct&&(window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e,top==null||top.addEventListener("message",async a=>{if(!a.data)return;let u=a.data;await xe(u,e)}),top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin));let o=()=>{!Ct||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:r}},window.location.origin)},i=a=>{t.push(a),o()},s=a=>{r.push(a),o()};return e.events.on("personalizationResult",i),e.events.on("testResult",s),e.storage.events.on("*",o),()=>{e.storage.events.off("*",o),e.events.off("personalizationResult",i),e.events.off("testResult",s)}}}}async function xe(e,t){e.type==="uniform-in:context:update"&&e.newData&&await t.update(e.newData),e.type==="uniform-in:context:commands"&&e.commands&&Array.isArray(e.commands)&&await t.storage.updateData(e.commands),e.type==="uniform-in:context:forget"&&await t.forget(!1)}module.exports=de(be);0&&(module.exports={Context,CookieTransitionDataStore,EdgeNodeTagName,EdgeTransitionDataStore,GroupCriteriaEvaluator,ManifestInstance,SERVER_STATE_ID,ScriptType,TransitionDataStore,VisitorDataStore,computeAggregateDimensions,cookieEvaluator,createConsoleLogDrain,createDebugConsoleLogDrain,createLinearDecay,emptyVisitorData,enableConsoleLogDrain,enableContextDevTools,enableDebugConsoleLogDrain,evaluateVariantMatch,eventEvaluator,getEnrichmentVectorKey,isStringMatch,pageViewCountDimension,pageViewCountEvaluator,pageVisitedEvaluator,personalizeVariations,queryStringEvaluator,quirkEvaluator,testVariations});
var ne=Object.create;var N=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var de=(e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Tt=e=>N(e,"__esModule",{value:!0});var le=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},kt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ae(t))!ce.call(e,i)&&(r||i!=="default")&&N(e,i,{get:()=>t[i],enumerable:!(o=se(t,i))||o.enumerable});return e},H=(e,t)=>kt(Tt(N(e!=null?ne(ue(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),pe=(e=>(t,r)=>e&&e.get(t)||(r=kt(Tt({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var h=(e,t,r)=>(de(e,typeof t!="symbol"?t+"":t,r),r),st=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var n=(e,t,r)=>(st(e,t,"read from private field"),r?r.call(e):t.get(e)),p=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},f=(e,t,r,o)=>(st(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var S=(e,t,r)=>(st(e,t,"access private method"),r);var Te={};le(Te,{Context:()=>te,CookieTransitionDataStore:()=>qt,EdgeNodeTagName:()=>xe,EdgeTransitionDataStore:()=>Ft,GroupCriteriaEvaluator:()=>A,ManifestInstance:()=>X,SERVER_STATE_ID:()=>Lt,ScriptType:()=>ie,TransitionDataStore:()=>U,VisitorDataStore:()=>et,computeAggregateDimensions:()=>at,cookieEvaluator:()=>ct,createConsoleLogDrain:()=>ee,createDebugConsoleLogDrain:()=>oe,createLinearDecay:()=>he,emptyVisitorData:()=>F,enableConsoleLogDrain:()=>Ce,enableContextDevTools:()=>be,enableDebugConsoleLogDrain:()=>Ve,evaluateVariantMatch:()=>Ct,eventEvaluator:()=>ft,getEnrichmentVectorKey:()=>_,isStringMatch:()=>y,pageViewCountDimension:()=>W,pageViewCountEvaluator:()=>dt,pageVisitedEvaluator:()=>mt,personalizeVariations:()=>Dt,queryStringEvaluator:()=>lt,quirkEvaluator:()=>pt,testVariations:()=>it});function at(e,t){let r={...e};for(let o in t){let i=wt(e,o,t,new Set([o]));i!==0&&(r[o]=i)}return r}function wt(e,t,r,o){var s;let i=0;for(let a of r[t].inputs){let u=(s=e[a.dim])!=null?s:0;if(!u&&r[a.dim]){if(o.has(a.dim))continue;let l=new Set(o);l.add(a.dim),u=wt(e,a.dim,r,l)}if(u!==0)if(a.sign==="c"){i=0;break}else a.sign==="-"?i-=u:i+=u}return i}var Y="_";var $,E,ut=class{constructor(t,r,o){p(this,$,void 0);p(this,E,void 0);h(this,"signal");f(this,E,t),this.signal=r,f(this,$,o)}computeSignals(t,r){if(t.scores[n(this,E)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=n(this,$).evaluate(t,this.signal.crit,r,this.signal,n(this,E)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(i)r.push({type:s,data:{dimension:n(this,E),delta:this.signal.str}});else if(this.signal.dur==="t"){let a=t.visitor.sessionScores[n(this,E)];a&&r.push({type:s,data:{dimension:n(this,E),delta:-a}})}}};$=new WeakMap,E=new WeakMap;var x,G,X=class{constructor({manifest:t,evaluator:r=new A({})}){h(this,"data");p(this,x,void 0);p(this,G,void 0);var o,i,s;f(this,x,(o=t.project)!=null?o:{}),this.data=t,f(this,G,Object.entries((s=(i=n(this,x).pz)==null?void 0:i.sig)!=null?s:[]).map(([a,u])=>new ut(a,u,r)))}rollForControlGroup(){var t,r;return Math.random()<((r=(t=n(this,x).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=n(this,x).test)==null?void 0:r[t]}computeSignals(t){let r=[];return n(this,G).forEach(o=>{o.computeSignals(t,r)}),r}computeAggregateDimensions(t){var r,o;return at(t,(o=(r=n(this,x).pz)==null?void 0:r.agg)!=null?o:{})}getDimensionByKey(t){var o,i,s,a;let r=t.indexOf(Y);return r<=0?(i=(o=n(this,x).pz)==null?void 0:o.sig)==null?void 0:i[t]:(a=(s=n(this,x).pz)==null?void 0:s.enr)==null?void 0:a[t.substring(0,r)]}};x=new WeakMap,G=new WeakMap;var ct=(e,t)=>{var i;if(t.type!=="CK")return!1;let r=(i=e.state.cookies)==null?void 0:i[t.cookieName];return y(r,t.match)};function Pt(e,t){var o;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return r===t.rhs;case"!=":return r!==t.rhs;case">":return r>t.rhs;case"<":return r<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function _(e,t){return`${e}${Y}${t}`}var W=_("$pvc","v"),dt=(e,t,r)=>{var a,u;if(t.type!=="PVC")return!1;let o=!e.previousState||((a=e.state.url)==null?void 0:a.toString())!==((u=e.previousState.url)==null?void 0:u.toString()),s=(e.visitor.sessionScores[W]||0)+1;if(Pt(s,t.match)){let c=r.some(l=>l.type==="modscoreS"&&l.data.dimension===W);return o&&!c&&r.push({type:"modscoreS",data:{dimension:W,delta:1}}),!0}return!1};var lt=(e,t)=>{var o;if(t.type!=="QS")return!1;let r=(o=e.state.url)==null?void 0:o.searchParams.get(t.queryName);return y(r,t.match)};var pt=(e,t,r,o,i)=>{if(t.type!=="QK")return!1;if(typeof window=="undefined"&&o.dur==="t"&&e.scores[i]>0)return!0;let s=e.visitor.quirks[t.key];return y(s,t.match)};var ft=(e,t)=>{var r,o;return t.type!=="EVT"?!1:(o=(r=e.state.events)==null?void 0:r.some(i=>y(i.event,t.event)))!=null?o:!1};var mt=(e,t)=>{var r;return t.type!=="PV"?!1:y((r=e.state.url)==null?void 0:r.pathname,t.path)};var j,A=class{constructor(t){p(this,j,void 0);f(this,j,t)}evaluate(t,r,o,i,s){let a=!(r.op==="&"||!r.op);for(let u of r.clauses){let c;if(u.type==="G")c=this.evaluate(t,u,o,i,s);else{let l=n(this,j)[u.type];if(!l)throw new Error(`${u.type} signal criteria not registered`);c=l(t,u,o,i,s)}if(c===a)return a}return!a}};j=new WeakMap;function y(e,t){var a,u,c,l;let r=(a=t==null?void 0:t.op)!=null?a:"=";if(t.op==="*")return e!==null&&typeof e!="undefined";if(t.op==="!*")return e===null||typeof e=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${r}`);let o=(u=t.cs)!=null?u:!1,i=o?e!=null?e:"":Ot(e),s=o?t.rhs:Ot(t.rhs);switch(r){case"=":return i===s;case"!=":return i!==s;case"~":return(c=i.includes(s))!=null?c:!1;case"!~":return!((l=i.includes(s))!=null?l:!0);case"//":return new RegExp(t.rhs,o?"":"i").test(e!=null?e:"");case"!//":return!new RegExp(t.rhs,o?"":"i").test(e!=null?e:"");default:throw new Error(`Unknown match type ${r}.`)}}function Ot(e){var t;return(t=e==null?void 0:e.toUpperCase())!=null?t:""}var F=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Mt=H(require("mitt")),Rt=require("dequal/lite"),Lt="__UNIFORM_DATA__",k,I,U=class{constructor({initialData:t}){p(this,k,void 0);p(this,I,(0,Mt.default)());h(this,"events",{on:n(this,I).on,off:n(this,I).off});t&&f(this,k,t)}get data(){return n(this,k)}updateData(t,r){return f(this,k,r),this.handleUpdateData(t,r)}async delete(t){f(this,k,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,Rt.dequal)(this.data,t)||(f(this,k,t),n(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Lt);return(t==null?void 0:t.textContent)?JSON.parse(t.textContent):void 0}};k=new WeakMap,I=new WeakMap;var gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",At=gt.split(""),Ut=new Array(123);for(let e=0;e<gt.length;e++)Ut[gt.charCodeAt(e)]=e;var ht=e=>{if(e<0)return`-${ht(-e)}`;let t=e>>>0,r=e/4294967296>>>0,o="";for(;r>0;)o=At[63&t]+o,t>>>=6,t|=(63&r)<<26,r>>>=6;let i="";do i=At[63&t]+i,t>>>=6;while(t>0);return i+o},It=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let o=r;o<e.length;o++)t=t*64+Ut[e.charCodeAt(o)];return r?-t:t};var zt=typeof window=="undefined",O,M,qt=class extends U{constructor({cookieAdapter:t,cookieName:r="ufvd"}){super({initialData:zt?fe(t.get(r)):void 0});p(this,O,void 0);p(this,M,void 0);f(this,O,r),f(this,M,t)}handleDelete(){return n(this,M).remove(n(this,O)),Promise.resolve()}async handleUpdateData(t,r){zt||(r.consent?n(this,M).set(n(this,O),me(r)):n(this,M).remove(n(this,O)))}};O=new WeakMap,M=new WeakMap;var Nt="~",$t="!",Gt="-";function fe(e){if(!e)return;let t=e.split(Nt);if(t.length>3)return;let[r,o,i]=t;return{consent:!0,sessionScores:_t(St(o)),scores:_t(St(i)),tests:St(r)}}function St(e){return e.split($t).map(r=>r.split(Gt)).reduce((r,o)=>(o.length!==2||(r[o[0]]=o[1]),r),{})}function _t(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=It(o),t),{})}function me(e){return[vt(e.tests),vt(jt(e.sessionScores)),vt(jt(e.scores))].join(Nt)}function jt(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=ht(o),t),{})}function vt(e){return Object.entries(e).map(t=>t.join(Gt)).join($t)}var Z,ge,Ft=class extends U{constructor({cookieAdapter:t,visitorIdCookieName:r="ufvi",...o}){super(o);p(this,Z);o.initialData||S(this,Z,ge).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let r=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};Z=new WeakSet,ge=async function(){let t=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};function he(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:o=.95}=e!=null?e:{};return function({now:s,lastUpd:a,scores:u,sessionScores:c}){if(typeof a!="number")return!1;let V=s-a-t;if(V<=0)return!1;let v=V/864e5,L=1-Math.min(o,v*r);return L<=0?!1:(Qt(u,L),Qt(c,L),!0)}}function Qt(e,t){for(let r in e)e[r]*=t}var Bt=H(require("mitt")),Q=require("dequal/lite");var yt=class{constructor(){h(this,"inMemoryFallback",{});h(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return r}}set(t,r,o){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(r))}catch(i){console.warn(i)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};var Kt=H(require("rfdc"));var Se=(0,Kt.default)();function Jt(e,t,r){let o=t?Se(t):F();return e.forEach(i=>{var s,a;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(r)break;let u=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=u+i.data.delta;break;case"modscoreS":if(r)break;let c=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=c+i.data.delta;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var tt="ufvisitor",b,R,q,m,D,w,T,z,rt,ve,ot,ye,K,Ht,J,Yt,et=class{constructor(t){p(this,D);p(this,T);p(this,rt);p(this,ot);p(this,K);p(this,J);p(this,b,(0,Bt.default)());p(this,R,new yt);p(this,q,void 0);p(this,m,void 0);h(this,"events",{on:n(this,b).on,off:n(this,b).off});if(f(this,m,t),n(this,D,w)||S(this,T,z).call(this,S(this,J,Yt).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();if(r){let i=[];r.quirks&&i.push(...Object.entries(r.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),r.tests&&i.push(...Object.entries(r.tests).map(([s,a])=>({type:"settest",data:{test:s,variant:a}}))),this.updateData(i),r.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(r.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{S(this,T,z).call(this,{...n(this,D,w).visitorData,...i})});let o=t.transitionStore.data;o&&S(this,T,z).call(this,{...n(this,D,w).visitorData,...o},!0)}}get data(){var r,o;let t=n(this,D,w);if(S(this,ot,ye).call(this,t)){let{sessionScores:i,...s}=t.visitorData;return S(this,T,z).call(this,{...s,sessionScores:{}}),(o=(r=n(this,m)).onLogMessage)==null||o.call(r,["info",120]),n(this,D,w).visitorData}return t.visitorData}get decayEnabled(){return!!n(this,m).decay}async updateData(t){var o,i,s,a;if(t.length===0)return;(i=(o=n(this,m)).onLogMessage)==null||i.call(o,["debug",101,t]);let r=Jt(t,this.data,(s=n(this,D,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&n(this,R).delete(tt,!0),S(this,T,z).call(this,r),await((a=n(this,m).transitionStore)==null?void 0:a.updateData(t,n(this,D,w).visitorData))}async delete(t){var r,o,i;n(this,R).delete(tt,!1),await((r=n(this,m).transitionStore)==null?void 0:r.delete(t)),S(this,T,z).call(this,S(this,J,Yt).call(this)),(i=(o=n(this,m)).onLogMessage)==null||i.call(o,["info",103,t])}};b=new WeakMap,R=new WeakMap,q=new WeakMap,m=new WeakMap,D=new WeakSet,w=function(){return n(this,R).get(tt)},T=new WeakSet,z=function(t,r=!1){var V,v,L,xt,bt,Et;let o=n(this,D,w),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,K,Ht).call(this,t.scores),S(this,K,Ht).call(this,t.sessionScores),(v=(V=n(this,m)).decay)==null||v.call(V,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let s=!(0,Q.dequal)(o==null?void 0:o.visitorData.scores,t.scores),a=!(0,Q.dequal)(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),u=!(0,Q.dequal)(o==null?void 0:o.visitorData.quirks,t.quirks),c=!(0,Q.dequal)(o==null?void 0:o.visitorData.tests,t.tests),l={updated:i,visitorData:t};S(this,rt,ve).call(this),n(this,R).set(tt,l,!!t.consent),(xt=(L=n(this,m)).onLogMessage)==null||xt.call(L,["debug",102,t]),r||((s||a)&&n(this,b).emit("scoresUpdated",t),u&&n(this,b).emit("quirksUpdated",t),c&&n(this,b).emit("testsUpdated",t),((bt=o==null?void 0:o.visitorData)==null?void 0:bt.consent)!==t.consent&&n(this,b).emit("consentUpdated",t),((Et=o==null?void 0:o.visitorData)==null?void 0:Et.controlGroup)!==t.controlGroup&&n(this,b).emit("controlGroupUpdated",t))},rt=new WeakSet,ve=function(){typeof window=="undefined"||!n(this,m).visitLifespan||(n(this,q)&&window.clearTimeout(n(this,q)),f(this,q,window.setTimeout(()=>{this.data},n(this,m).visitLifespan+50)))},ot=new WeakSet,ye=function(t){let r=n(this,m).visitLifespan;return r?t.updated+r<Date.now():!1},K=new WeakSet,Ht=function(t){var r,o;if(!!n(this,m).manifest)for(let i in t){let s=t[i],a=n(this,m).manifest.getDimensionByKey(i);!a||s>a.cap&&((o=(r=n(this,m)).onLogMessage)==null||o.call(r,["debug",110,{dim:i,score:s,cap:a.cap}]),t[i]=a.cap)}},J=new WeakSet,Yt=function(){var t,r,o;return{...F(),consent:(t=n(this,m).defaultConsent)!=null?t:!1,controlGroup:(o=(r=n(this,m).manifest)==null?void 0:r.rollForControlGroup())!=null?o:!1}};var Wt=H(require("mitt"));function Dt({context:e,variations:t,take:r=1}){var u,c;let o=(u=e.storage.data.controlGroup)!=null?u:!1,i=[],s=!1,a=e.scores;for(let l of t){if(i.length===r)break;if(!((c=l.pz)==null?void 0:c.crit.length)){i.push(l);continue}!o&&Ct(l.pz,a)&&(s=!0,i.push(l))}return{personalized:s,variations:i}}function Ct(e,t){return(e==null?void 0:e.crit)?!e.op||e.op==="&"?e.crit.every(r=>Xt(r,t)):e.crit.some(r=>Xt(r,t)):!0}function Xt(e,t){var a;let{op:r,l:o}=e,i=(a=t[o])!=null?a:0;if(r==="+")return Math.max(...Object.values(t))===i&&i>0;if(r==="-")return Math.min(...Object.values(t))===i&&i>0;let s=e.rDim?t[e.rDim]:e.r;if(s===void 0)return!1;if(r===">")return i>s;if(r===">=")return i>=s;if(r==="<")return i<s;if(r==="<=")return i<=s;if(r==="=")return i===s;if(r==="!=")return i!==s;throw new Error(`Unknown op: ${r}`)}var De=e=>{let{values:t,total:r,missingDistribution:o}=e.reduce((i,s)=>(s.testDistribution?i.total+=s.testDistribution:++i.missingDistribution,i.values.push(s.testDistribution),i),{values:[],total:0,missingDistribution:0});if(r>100)throw new Error(`Total distribution ${r} is over the maximum 100.`);if(r<100){let s=(100-r)/o;t.forEach((a,u)=>{typeof a=="undefined"&&(t[u]=s)})}return t},it=({name:e,context:t,variations:r})=>{var s;let o,i=t.getTestVariantId(e);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=r.find(a=>a.id===i),o||t.log("warn",401,{test:e,variant:i})),!o){let a=De(r),u=Math.floor(Math.random()*100),c=0;o=r.find((l,V)=>{let v=a[V];if(u>c&&u<=c+v)return l;c+=v}),o&&t.setTestVariantId(e,(s=o.id)!=null?s:"Unknown")}return{result:o,variantAssigned:!i}};var Zt=require("dequal/lite"),P,C,B,g,te=class{constructor(t){h(this,"manifest");p(this,P,{});p(this,C,void 0);p(this,B,{});p(this,g,(0,Wt.default)());h(this,"events",{on:n(this,g).on,off:n(this,g).off});h(this,"storage");var a,u;let{manifest:r,...o}=t;f(this,C,{}),(a=t.plugins)==null||a.forEach(c=>{!c.logDrain||n(this,g).on("log",c.logDrain)}),this.manifest=new X({manifest:r,evaluator:new A({CK:ct,QS:lt,QK:pt,PVC:dt,EVT:ft,PV:mt})});let i=!1;this.storage=new et({...o,manifest:this.manifest,onServerTransitionScoresReceived:c=>{f(this,P,c),i=!0,n(this,g).emit("log",["debug",130,c])},onLogMessage:c=>n(this,g).emit("log",c)});let s=c=>{var V;let l={...c.scores};for(let v in c.sessionScores)l[v]=((V=l[v])!=null?V:0)+c.sessionScores[v];l=this.manifest.computeAggregateDimensions(l),f(this,P,l),n(this,g).emit("scoresUpdated",l),n(this,g).emit("log",["info",3,l])};this.storage.events.on("scoresUpdated",s),i||s(this.storage.data),this.storage.events.on("quirksUpdated",c=>{let l=this.manifest.computeSignals({scores:n(this,P),state:n(this,C),previousState:n(this,C),visitor:this.storage.data});this.storage.updateData(l),n(this,g).emit("quirksUpdated",c.quirks),n(this,g).emit("log",["info",4,c.quirks])}),n(this,g).emit("log",["debug",1]),(u=t.plugins)==null||u.forEach(c=>{!c.init||c.init(this)})}get scores(){return n(this,P)}async update(t){var i;let r=[];n(this,g).emit("log",["info",2,{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&(r.push(...Object.entries(t.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),t.quirks=void 0),t.enrichments&&(r.push(...t.enrichments.map(s=>({type:"modscore",data:{dimension:_(s.cat,s.key),delta:s.str}}))),t.enrichments=void 0);let o=n(this,C);f(this,C,{...n(this,C),...t}),r.push(...this.manifest.computeSignals({state:n(this,C),previousState:o,visitor:this.storage.data,scores:n(this,P)})),await this.storage.updateData(r)}getTestVariantId(t){var o;let r=this.manifest.getTest(t);return r?(o=r.wv)!=null?o:this.storage.data.tests[t]:(n(this,g).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){n(this,g).emit("log",t)}test(t){var o,i;let r=it({...t,context:this});return n(this,g).emit("testResult",{name:t.name,variantId:(i=(o=r.result)==null?void 0:o.id)!=null?i:void 0,variantAssigned:r.variantAssigned}),r}personalize(t){let r=Dt({...t,context:this}),o=n(this,B)[t.name],i={name:t.name,variantIds:r.variations.map(s=>{var a;return(a=s.id)!=null?a:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&(0,Zt.dequal)(i.variantIds,o)&&(i.changed=!1),n(this,g).emit("personalizationResult",i),n(this,B)[t.name]=i.variantIds,r}async forget(t){f(this,C,{}),await this.storage.delete(t)}};P=new WeakMap,C=new WeakMap,B=new WeakMap,g=new WeakMap;function nt(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}function ee(e){return([t,r,...o])=>{!nt(e,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
`,...o.map(i=>JSON.stringify(i,null,2)))}}function Ce(e){return{logDrain:ee(e)}}var re={1:()=>["tracker","constructed"],2:e=>["tracker","received data update",e],3:e=>["tracker","new score vector",e],4:e=>["tracker","updated quirks",e],101:e=>["storage","received update commands",e],102:e=>["storage","data was updated",e],103:e=>["storage",`data was deleted ${e?"from all devices":"from this device"}`],110:({dim:e,cap:t,score:r})=>["storage",`${e} score ${r} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:e=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",e],401:e=>["testing",`${e} was unknown; it will not be run.`],402:({test:e,variant:t})=>["testing",`${e} no longer has visitor's variant ${t}; it will be removed.`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};function oe(e){return([t,r,...o])=>{if(!nt(e,t))return;let i=re[r],s=`\u{1F94B} [${new Date().toLocaleTimeString()}][${t}]`;i||console[t](`${s} unknown message ID ${r} - ensure all Uniform packages are the same version`,...o);let[a,u,...c]=i(...o);console[t](`${s}[${a}] ${u} (Event ID: ${r})
`,...c.map(l=>JSON.stringify(l,null,2)))}}function Ve(e){return{logDrain:oe(e)}}var ie=(u=>(u.ListStart="nesi-list-start",u.ListEnd="nesi-list-end",u.ListItem="nesi-list-item-html",u.ListItemSettings="nesi-list-item-settings",u.TestStart="nesi-test-start",u.TestEnd="nesi-test-end",u.Unknown="unknown",u))(ie||{}),xe="nesitag";var Vt=typeof top!="undefined";function be(){return{logDrain:e=>{!Vt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[];Vt&&(window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e,top==null||top.addEventListener("message",async a=>{if(!a.data)return;let u=a.data;await Ee(u,e)}),top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin));let o=()=>{!Vt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:r}},window.location.origin)},i=a=>{!a.changed||(t.push(a),o())},s=a=>{!a.variantAssigned||(r.push(a),o())};return e.events.on("personalizationResult",i),e.events.on("testResult",s),e.storage.events.on("*",o),()=>{e.storage.events.off("*",o),e.events.off("personalizationResult",i),e.events.off("testResult",s)}}}}async function Ee(e,t){e.type==="uniform-in:context:update"&&e.newData&&await t.update(e.newData),e.type==="uniform-in:context:commands"&&e.commands&&Array.isArray(e.commands)&&await t.storage.updateData(e.commands),e.type==="uniform-in:context:forget"&&await t.forget(!1)}module.exports=pe(Te);0&&(module.exports={Context,CookieTransitionDataStore,EdgeNodeTagName,EdgeTransitionDataStore,GroupCriteriaEvaluator,ManifestInstance,SERVER_STATE_ID,ScriptType,TransitionDataStore,VisitorDataStore,computeAggregateDimensions,cookieEvaluator,createConsoleLogDrain,createDebugConsoleLogDrain,createLinearDecay,emptyVisitorData,enableConsoleLogDrain,enableContextDevTools,enableDebugConsoleLogDrain,evaluateVariantMatch,eventEvaluator,getEnrichmentVectorKey,isStringMatch,pageViewCountDimension,pageViewCountEvaluator,pageVisitedEvaluator,personalizeVariations,queryStringEvaluator,quirkEvaluator,testVariations});
{
"name": "@uniformdev/context",
"version": "12.2.1-alpha.171+b2055e2a",
"version": "12.2.1-alpha.177+62e00ad7",
"description": "Uniform Context core package",

@@ -57,3 +57,3 @@ "license": "SEE LICENSE IN LICENSE.txt",

"@types/yargs": "17.0.8",
"@uniformdev/cli": "^12.2.1-alpha.171+b2055e2a",
"@uniformdev/cli": "^12.2.1-alpha.177+62e00ad7",
"benny": "^3.7.1",

@@ -81,3 +81,3 @@ "eslint": "8.7.0",

],
"gitHead": "b2055e2a1db9288562eb59768708f2f385d61c10"
"gitHead": "62e00ad7698fe93306fcbc58a1faaffbbe04f778"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc