@uniformdev/context 12.2.1-alpha.184 → 14.2.1-alpha.145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,25 +1,47 @@
1
- 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';
2
- 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';
1
+ import { T as TransitionDataStore, S as StorageCommands, V as VisitorData, a as TransitionDataStoreOptions, D as DecayFunction, O as OutputSeverity, L as LogDrain, C as ContextPlugin, b as CriteriaEvaluator, c as StringMatch, d as ScoreVector, A as AggregateDimension, e as VariantMatchCriteria } from './types-c81df08a';
2
+ export { A as AggregateDimension, k as AggregateDimensionInput, a7 as BehaviorTag, Z as Context, Y as ContextEvents, U as ContextOptions, C as ContextPlugin, q as ContextState, r as ContextStateUpdate, b as CriteriaEvaluator, l as CriteriaEvaluatorResult, 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, f 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, d as ScoreVector, J as ServerToClientTransitionState, v as SetConsentCommand, y as SetControlGroupCommand, w as SetQuirkCommand, x as SetTestCommand, $ as Severity, g as Signal, i as SignalCriteria, h as SignalCriteriaGroup, s as StorageCommand, S as StorageCommands, c as StringMatch, ac as TaggedContent, j 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, e 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-c81df08a';
3
+ import Cookies from 'js-cookie';
4
+ import './v2-manifest.swagger-d0899723';
3
5
  import 'mitt';
4
6
 
5
7
  declare type CookieTransitionDataStoreOptions = {
6
- cookieAdapter: CookieAdapter;
8
+ /**
9
+ * The value of the score cookie during server-side rendering.
10
+ * Should be parsed from the incoming request.
11
+ * IMPORTANT: If not passed, the transition store will not have any effect during SSR.
12
+ */
13
+ serverCookieValue?: string;
14
+ /**
15
+ * The name of the cookie to store client-to-server score information in.
16
+ * Defaults to UNIFORM_DEFAULT_COOKIE_NAME if not set.
17
+ */
7
18
  cookieName?: string;
19
+ /**
20
+ * Attributes to set on the transfer cookie.
21
+ * Persistence is not necessary, because the data is only used for temporary transition;
22
+ * local storage is the master copy. Defaults to SameSite=Lax.
23
+ */
24
+ cookieAttributes?: Cookies.CookieAttributes;
8
25
  };
26
+ declare const UNIFORM_DEFAULT_COOKIE_NAME = "ufvd";
27
+ /**
28
+ * Handles client-to-server score handoff using an encoded cookie with the visitor score vector.
29
+ * NOTE: forget me is not supported when on the server side.
30
+ */
9
31
  declare class CookieTransitionDataStore extends TransitionDataStore {
10
32
  #private;
11
- constructor({ cookieAdapter, cookieName }: CookieTransitionDataStoreOptions);
33
+ constructor({ serverCookieValue, cookieName, cookieAttributes, }: CookieTransitionDataStoreOptions);
12
34
  handleDelete(): Promise<void>;
13
35
  handleUpdateData(_: StorageCommands[], computedValue: VisitorData): Promise<void>;
14
36
  }
15
37
 
16
38
  declare type EdgeTransitionDataStoreOptions = TransitionDataStoreOptions & {
17
- cookieAdapter: CookieAdapter;
39
+ serverCookieValue?: string;
18
40
  visitorIdCookieName?: string;
19
41
  };
20
42
  declare class EdgeTransitionDataStore extends TransitionDataStore {
21
43
  #private;
22
- constructor({ cookieAdapter, visitorIdCookieName, ...base }: EdgeTransitionDataStoreOptions);
44
+ constructor({ serverCookieValue, visitorIdCookieName, ...base }: EdgeTransitionDataStoreOptions);
23
45
  handleDelete(fromAllDevices?: boolean): Promise<void>;
24
46
  handleUpdateData(commands: StorageCommands[]): Promise<void>;
25
47
  }
@@ -88,10 +110,10 @@ declare const quirkEvaluator: CriteriaEvaluator;
88
110
 
89
111
  declare const eventEvaluator: CriteriaEvaluator;
90
112
 
91
- declare const pageVisitedEvaluator: CriteriaEvaluator;
113
+ declare const currentPageEvaluator: CriteriaEvaluator;
92
114
 
93
115
  /** Tests if a StringMatch matches a string value */
94
- declare function isStringMatch(lhs: string | null | undefined, match: StringMatch): boolean;
116
+ declare function isStringMatch(lhs: string | number | null | undefined, match: StringMatch): boolean;
95
117
 
96
118
  /** Computes aggregated scores based on other dimensions */
97
119
  declare function computeAggregateDimensions(primitiveScores: ScoreVector, aggregates: Record<string, AggregateDimension>): ScoreVector;
@@ -125,4 +147,4 @@ declare const EdgeNodeTagName = "nesitag";
125
147
  */
126
148
  declare function enableContextDevTools(): ContextPlugin;
127
149
 
128
- 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 };
150
+ export { CookieTransitionDataStore, CookieTransitionDataStoreOptions, EdgeNodeTagName, EdgePersonalizeComponentOptions, EdgeTestComponentOptions, EdgeTransitionDataStore, EdgeTransitionDataStoreOptions, LinearDecayOptions, ScriptType, UNIFORM_DEFAULT_COOKIE_NAME, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, evaluateVariantMatch, eventEvaluator, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, queryStringEvaluator, quirkEvaluator };
package/dist/index.esm.js CHANGED
@@ -1,3 +1,3 @@
1
- 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 N,k,rt=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,$,ot=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 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,$).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,$=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 _,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 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 Rt="~",Lt="!",At="-";function Jt(r){if(!r)return;let t=r.split(Rt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:Mt(at(o)),scores:Mt(at(i)),tests:at(e)}}function at(r){return r.split(Lt).map(e=>e.split(At)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function Mt(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=wt(o),t),{})}function Bt(r){return[ut(r.tests),ut(Ot(r.sessionScores)),ut(Ot(r.scores))].join(Rt)}function Ot(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(At)).join(Lt)}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 D=s-a-t;if(D<=0)return!1;let C=D/864e5,U=1-Math.min(o,C*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=Number(i.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let d=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=d+c;break;case"modscoreS":if(e)break;let l=Number(i.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let D=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=D+l;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,V,M,w,z,Z,te,tt,ee,F,zt,Q,qt,dt=class{constructor(t){m(this,V);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,V,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,V,M).visitorData,...i})});let o=t.transitionStore.data;o&&y(this,w,z).call(this,{...n(this,V,M).visitorData,...o},!0)}}get data(){var e,o;let t=n(this,V,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,V,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,V,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,V,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,V=new WeakSet,M=function(){return n(this,A).get(W)},w=new WeakSet,z=function(t,e=!1){var D,C,U,ft,mt,gt;let o=n(this,V,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),(C=(D=n(this,h)).decay)==null||C.call(D,{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 Nt({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&&$t(l.pz,a)&&(s=!0,i.push(l))}return{personalized:s,variations:i}}u();function $t(r,t){return(r==null?void 0:r.crit)?!r.op||r.op==="&"?r.crit.every(e=>Gt(e,t)):r.crit.some(e=>Gt(e,t)):!0}function Gt(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,D)=>{let C=a[D];if(c>d&&c<=d+C)return l;d+=C}),o&&t.setTestVariantId(r,(s=o.id)!=null?s:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as ie}from"dequal/lite";var O,x,K,S,ne=class{constructor(t){v(this,"manifest");m(this,O,{});m(this,x,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,x,{}),(a=t.plugins)==null||a.forEach(d=>{!d.logDrain||n(this,S).on("log",d.logDrain)}),this.manifest=new ot({manifest:e,evaluator:new G({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 D;let l={...d.scores};for(let C in d.sessionScores)l[C]=((D=l[C])!=null?D:0)+d.sessionScores[C];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,x),previousState:n(this,x),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,x);g(this,x,{...n(this,x),...t}),e.push(...this.manifest.computeSignals({state:n(this,x),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=Nt({...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,x,{}),await this.storage.delete(t)}};O=new WeakMap,x=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}
2
- `,...o.map(i=>JSON.stringify(i,null,2)))}}function $r(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})
3
- `,...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,G 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,$r as enableConsoleLogDrain,Hr as enableContextDevTools,Qr as enableDebugConsoleLogDrain,$t as evaluateVariantMatch,xt as eventEvaluator,B as getEnrichmentVectorKey,E as isStringMatch,it as pageViewCountDimension,Dt as pageViewCountEvaluator,bt as pageVisitedEvaluator,Nt as personalizeVariations,Ct as queryStringEvaluator,Vt as quirkEvaluator,lt as testVariations};
1
+ import{a as H}from"./chunk-CEKV2MHL.mjs";import{d as D,e as s,f as d,g,h as S,i as u}from"./chunk-AFJ7PNM5.mjs";u();u();u();function Ct(r,t){let e={...r};for(let o in t){let i=Vt(r,o,t,new Set([o]));i!==0&&(e[o]=i)}return e}function Vt(r,t,e,o){var a;let i=0;for(let n of e[t].inputs){let c=(a=r[n.dim])!=null?a:0;if(!c&&e[n.dim]){if(o.has(n.dim))continue;let m=new Set(o);m.add(n.dim),c=Vt(r,n.dim,e,m)}if(c!==0)if(n.sign==="c"){i=0;break}else n.sign==="-"?i-=c:i+=c}return i}u();var $,k,it=class{constructor(t,e,o){d(this,$,void 0);d(this,k,void 0);D(this,"signal");g(this,k,t),this.signal=e,g(this,$,o)}computeSignal(t,e){if(t.scores[s(this,k)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=s(this,$).evaluate(t,this.signal.crit,e,this.signal,s(this,k)),a=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!i.changed){if(i.result)e.push({type:a,data:{dimension:s(this,k),delta:this.signal.str}});else if(this.signal.dur==="t"){let n=t.visitor.sessionScores[s(this,k)];n&&e.push({type:a,data:{dimension:s(this,k),delta:-n}})}}}};$=new WeakMap,k=new WeakMap;var x,G,nt=class{constructor({manifest:t,evaluator:e=new _({})}){D(this,"data");d(this,x,void 0);d(this,G,void 0);var o,i,a;g(this,x,(o=t.project)!=null?o:{}),this.data=t,g(this,G,Object.entries((a=(i=s(this,x).pz)==null?void 0:i.sig)!=null?a:[]).map(([n,c])=>new it(n,c,e)))}rollForControlGroup(){var t,e;return Math.random()<((e=(t=s(this,x).pz)==null?void 0:t.control)!=null?e:0)}getTest(t){var e;return(e=s(this,x).test)==null?void 0:e[t]}computeSignals(t){let e=[];return s(this,G).forEach(o=>{o.computeSignal(t,e)}),e}computeAggregateDimensions(t){var e,o;return Ct(t,(o=(e=s(this,x).pz)==null?void 0:e.agg)!=null?o:{})}getDimensionByKey(t){var o,i,a,n;let e=t.indexOf(H);return e<=0?(i=(o=s(this,x).pz)==null?void 0:o.sig)==null?void 0:i[t]:(n=(a=s(this,x).pz)==null?void 0:a.enr)==null?void 0:n[t.substring(0,e)]}};x=new WeakMap,G=new WeakMap;u();import{dequal as Ht}from"dequal/lite";var bt=(r,t)=>{var a,n;if(t.type!=="CK")return{result:!1,changed:!1};let e=!Ht(xt(r.state.cookies),xt((a=r.previousState)==null?void 0:a.cookies)),o=(n=r.state.cookies)==null?void 0:n[t.cookieName];return{result:b(o,t.match),changed:e}};function xt(r){if(!r)return;if(!r.ufvd)return r;let{ufvd:t,...e}=r;return e}u();u();function Et(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 Y(r,t){return`${r}${H}${t}`}var st=Y("$pvc","v"),Tt=(r,t,e)=>{var n,c;if(t.type!=="PVC")return{result:!1,changed:!1};let o=!r.previousState||((n=r.state.url)==null?void 0:n.toString())!==((c=r.previousState.url)==null?void 0:c.toString()),a=(r.visitor.sessionScores[st]||0)+1;if(Et(a,t.match)){let l=e.some(m=>m.type==="modscoreS"&&m.data.dimension===st);return o&&!l&&e.push({type:"modscoreS",data:{dimension:st,delta:1}}),{result:!0,changed:o}}return{result:!1,changed:o}};u();var kt=(r,t)=>{var a,n,c,l,m;if(t.type!=="QS")return{result:!1,changed:!1};let e=!r.previousState||((n=(a=r.state.url)==null?void 0:a.searchParams)==null?void 0:n.toString())!==((l=(c=r.previousState.url)==null?void 0:c.searchParams)==null?void 0:l.toString()),o=(m=r.state.url)==null?void 0:m.searchParams.get(t.queryName);return{result:b(o,t.match),changed:e}};u();var wt=(r,t,e,o,i)=>{var y;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&o.dur==="t"&&r.scores[i]>0)return{result:!0,changed:!1};let a=r.visitor.quirks[t.key],n=(y=r.state.quirks)==null?void 0:y[t.key],c=n!=null?n:a,l=Boolean(n&&a!==n);return{result:b(c,t.match),changed:l}};u();var Pt=(r,t)=>{var o,i;if(t.type!=="EVT")return{result:!1,changed:!1};let e=(i=(o=r.state.events)==null?void 0:o.some(a=>b(a.event,t.event)))!=null?i:!1;return{result:e,changed:e}};u();var Ot=(r,t)=>{var i,a,n,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let e=!r.previousState||((a=(i=r.state.url)==null?void 0:i.pathname)==null?void 0:a.toString())!==((c=(n=r.previousState.url)==null?void 0:n.pathname)==null?void 0:c.toString());return{result:b((l=r.state.url)==null?void 0:l.pathname,t.path),changed:e}};u();var F,_=class{constructor(t){d(this,F,void 0);g(this,F,t)}evaluate(t,e,o,i,a){let n=!(e.op==="&"||!e.op),c=!1;for(let l of e.clauses){let m;if(l.type==="G")m=this.evaluate(t,l,o,i,a);else{let y=s(this,F)[l.type];if(!y)throw new Error(`${l.type} signal criteria not registered`);m=y(t,l,o,i,a)}if(m.changed&&(c=!0),m.result===n)return{result:n,changed:c}}return{result:!n,changed:c}}};F=new WeakMap;u();function b(r,t){var n,c,l,m,y,V;let e=(n=t==null?void 0:t.op)!=null?n:"=";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:"":Mt(r)).toString(),a=(o?t.rhs:Mt(t.rhs)).toString();switch(e){case"=":return i===a;case"!=":return i!==a;case"~":return(l=i.includes(a))!=null?l:!1;case"!~":return!((m=i.includes(a))==null||m);case"//":return new RegExp(t.rhs.toString(),o?"":"i").test((y=r==null?void 0:r.toString())!=null?y:"");case"!//":return!new RegExp(t.rhs.toString(),o?"":"i").test((V=r==null?void 0:r.toString())!=null?V:"");default:throw new Error(`Unknown match type ${e}.`)}}function Mt(r){var t,e;return(e=(t=r==null?void 0:r.toString())==null?void 0:t.toUpperCase())!=null?e:""}u();var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});u();u();import Yt from"mitt";import{dequal as Xt}from"dequal/lite";var Wt="__UNIFORM_DATA__",O,I,j=class{constructor({initialData:t}){d(this,O,void 0);d(this,I,Yt());D(this,"events",{on:s(this,I).on,off:s(this,I).off});t&&g(this,O,t)}get data(){return s(this,O)}updateData(t,e){return g(this,O,e),this.handleUpdateData(t,e)}async delete(t){g(this,O,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){Xt(this.data,t)||(g(this,O,t),s(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Wt);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};O=new WeakMap,I=new WeakMap;u();var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rt=at.split(""),Ut=new Array(123);for(let r=0;r<at.length;r++)Ut[at.charCodeAt(r)]=r;var ut=r=>{if(r<0)return`-${ut(-r)}`;let t=r>>>0,e=r/4294967296>>>0,o="";for(;e>0;)o=Rt[63&t]+o,t>>>=6,t|=(63&e)<<26,e>>>=6;let i="";do i=Rt[63&t]+i,t>>>=6;while(t>0);return i+o},Lt=r=>{let t=0,e=r.charAt(0)==="-"?1:0;for(let o=e;o<r.length;o++)t=t*64+Ut[r.charCodeAt(o)];return e?-t:t};import ct from"js-cookie";var lt=typeof document=="undefined",Zt="ufvd",R,Q,te=class extends j{constructor({serverCookieValue:t,cookieName:e=Zt,cookieAttributes:o={sameSite:"lax"}}){super({initialData:lt?ee(t):void 0});d(this,R,void 0);d(this,Q,void 0);g(this,R,e),g(this,Q,o)}handleDelete(){return lt||ct.remove(s(this,R)),Promise.resolve()}async handleUpdateData(t,e){lt||(e.consent?ct.set(s(this,R),re(e),s(this,Q)):ct.remove(s(this,R)))}};R=new WeakMap,Q=new WeakMap;var zt="~",Nt="!",qt="-";function ee(r){if(!r)return;let t=r.split(zt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:At(dt(o)),scores:At(dt(i)),tests:dt(e)}}function dt(r){return r.split(Nt).map(e=>e.split(qt)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function At(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=Lt(o),t),{})}function re(r){return[ft(r.tests),ft(It(r.sessionScores)),ft(It(r.scores))].join(zt)}function It(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=ut(o),t),{})}function ft(r){return Object.entries(r).map(t=>t.join(qt)).join(Nt)}u();var W,ie,oe=class extends j{constructor({serverCookieValue:t,visitorIdCookieName:e="ufvi",...o}){super(o);d(this,W);o.initialData||S(this,W,ie).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)}};W=new WeakSet,ie=async function(){let t=await new Promise(e=>{setTimeout(()=>{e(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};u();function lr(r){let{gracePeriod:t=864e5,decayRate:e=1/30,decayCap:o=.95}=r!=null?r:{};return function({now:a,lastUpd:n,scores:c,sessionScores:l}){if(typeof n!="number")return!1;let y=a-n-t;if(y<=0)return!1;let V=y/864e5,A=1-Math.min(o,V*e);return A<=0?!1:($t(c,A),$t(l,A),!0)}}function $t(r,t){for(let e in r)r[e]*=t}u();import ae from"mitt";import{dequal as Z}from"dequal/lite";u();var pt=class{constructor(){D(this,"inMemoryFallback",{});D(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 ne from"rfdc";var se=ne();function Gt(r,t,e){let o=t?se(t):X();return r.forEach(i=>{var a,n;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=Number(i.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let l=(a=o.scores[i.data.dimension])!=null?a:0;o.scores[i.data.dimension]=l+c;break;case"modscoreS":if(e)break;let m=Number(i.data.delta);if(isNaN(m))throw new Error("Non-number delta received");let y=(n=o.sessionScores[i.data.dimension])!=null?n:0;o.sessionScores[i.data.dimension]=y+m;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var tt="ufvisitor",E,U,N,h,C,M,w,z,et,ue,rt,ce,K,_t,B,Ft,mt=class{constructor(t){d(this,C);d(this,w);d(this,et);d(this,rt);d(this,K);d(this,B);d(this,E,ae());d(this,U,new pt);d(this,N,void 0);d(this,h,void 0);D(this,"events",{on:s(this,E).on,off:s(this,E).off});if(g(this,h,t),s(this,C,M)||S(this,w,z).call(this,S(this,B,Ft).call(this),!0),t.transitionStore){let e=t.transitionStore.getClientTransitionState();if(e){let i=[];e.quirks&&i.push(...Object.entries(e.quirks).map(([a,n])=>({type:"setquirk",data:{key:a,value:n}}))),e.tests&&i.push(...Object.entries(e.tests).map(([a,n])=>({type:"settest",data:{test:a,variant:n}}))),this.updateData(i),e.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(e.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{S(this,w,z).call(this,{...s(this,C,M).visitorData,...i})});let o=t.transitionStore.data;o&&S(this,w,z).call(this,{...s(this,C,M).visitorData,...o},!0)}}get data(){var e,o;let t=s(this,C,M);if(S(this,rt,ce).call(this,t)){let{sessionScores:i,...a}=t.visitorData;return S(this,w,z).call(this,{...a,sessionScores:{}}),(o=(e=s(this,h)).onLogMessage)==null||o.call(e,["info",120]),s(this,C,M).visitorData}return t.visitorData}get decayEnabled(){return!!s(this,h).decay}async updateData(t){var o,i,a,n;if(t.length===0)return;(i=(o=s(this,h)).onLogMessage)==null||i.call(o,["debug",101,t]);let e=Gt(t,this.data,(a=s(this,C,M))==null?void 0:a.visitorData.controlGroup);t.some(c=>c.type==="consent"&&!c.data)&&s(this,U).delete(tt,!0),S(this,w,z).call(this,e),await((n=s(this,h).transitionStore)==null?void 0:n.updateData(t,s(this,C,M).visitorData))}async delete(t){var e,o,i;s(this,U).delete(tt,!1),await((e=s(this,h).transitionStore)==null?void 0:e.delete(t)),S(this,w,z).call(this,S(this,B,Ft).call(this)),(i=(o=s(this,h)).onLogMessage)==null||i.call(o,["info",103,t])}};E=new WeakMap,U=new WeakMap,N=new WeakMap,h=new WeakMap,C=new WeakSet,M=function(){return s(this,U).get(tt)},w=new WeakSet,z=function(t,e=!1){var y,V,A,St,yt,Dt;let o=s(this,C,M),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,K,_t).call(this,t.scores),S(this,K,_t).call(this,t.sessionScores),(V=(y=s(this,h)).decay)==null||V.call(y,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let a=!Z(o==null?void 0:o.visitorData.scores,t.scores),n=!Z(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),c=!Z(o==null?void 0:o.visitorData.quirks,t.quirks),l=!Z(o==null?void 0:o.visitorData.tests,t.tests),m={updated:i,visitorData:t};S(this,et,ue).call(this),s(this,U).set(tt,m,!!t.consent),(St=(A=s(this,h)).onLogMessage)==null||St.call(A,["debug",102,t]),e||((a||n)&&s(this,E).emit("scoresUpdated",t),c&&s(this,E).emit("quirksUpdated",t),l&&s(this,E).emit("testsUpdated",t),((yt=o==null?void 0:o.visitorData)==null?void 0:yt.consent)!==t.consent&&s(this,E).emit("consentUpdated",t),((Dt=o==null?void 0:o.visitorData)==null?void 0:Dt.controlGroup)!==t.controlGroup&&s(this,E).emit("controlGroupUpdated",t))},et=new WeakSet,ue=function(){typeof document=="undefined"||!s(this,h).visitLifespan||(s(this,N)&&window.clearTimeout(s(this,N)),g(this,N,window.setTimeout(()=>{this.data},s(this,h).visitLifespan+50)))},rt=new WeakSet,ce=function(t){let e=s(this,h).visitLifespan;return e?t.updated+e<Date.now():!1},K=new WeakSet,_t=function(t){var e,o;if(!!s(this,h).manifest)for(let i in t){let a=t[i],n=s(this,h).manifest.getDimensionByKey(i);!n||a>n.cap&&((o=(e=s(this,h)).onLogMessage)==null||o.call(e,["debug",110,{dim:i,score:a,cap:n.cap}]),t[i]=n.cap)}},B=new WeakSet,Ft=function(){var t,e,o;return{...X(),consent:(t=s(this,h).defaultConsent)!=null?t:!1,controlGroup:(o=(e=s(this,h).manifest)==null?void 0:e.rollForControlGroup())!=null?o:!1}};u();import de from"mitt";u();u();function jt({context:r,variations:t,take:e=1}){var c,l;let o=(c=r.storage.data.controlGroup)!=null?c:!1,i=[],a=!1,n=r.scores;for(let m of t){if(i.length===e)break;if(!((l=m.pz)!=null&&l.crit.length)){i.push(m);continue}!o&&Qt(m.pz,n)&&(a=!0,i.push(m))}return{personalized:a,variations:i}}u();function Qt(r,t){return r!=null&&r.crit?!r.op||r.op==="&"?r.crit.every(e=>Kt(e,t)):r.crit.some(e=>Kt(e,t)):!0}function Kt(r,t){var n;let{op:e,l:o}=r,i=(n=t[o])!=null?n:0;if(e==="+")return Math.max(...Object.values(t))===i&&i>0;if(e==="-")return Math.min(...Object.values(t))===i&&i>0;let a=r.rDim?t[r.rDim]:r.r;if(a===void 0)return!1;if(e===">")return i>a;if(e===">=")return i>=a;if(e==="<")return i<a;if(e==="<=")return i<=a;if(e==="=")return i===a;if(e==="!=")return i!==a;throw new Error(`Unknown op: ${e}`)}u();var le=r=>{let{values:t,total:e,missingDistribution:o}=r.reduce((i,a)=>(a.testDistribution?i.total+=a.testDistribution:++i.missingDistribution,i.values.push(a.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 a=(100-e)/o;t.forEach((n,c)=>{typeof n=="undefined"&&(t[c]=a)})}return t},gt=({name:r,context:t,variations:e})=>{var a;let o,i=t.getTestVariantId(r);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=e.find(n=>n.id===i),o||t.log("warn",401,{test:r,variant:i})),!o){let n=le(e),c=Math.floor(Math.random()*100),l=0;o=e.find((m,y)=>{let V=n[y];if(c>l&&c<=l+V)return m;l+=V}),o&&t.setTestVariantId(r,(a=o.id)!=null?a:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as Bt}from"dequal/lite";var L,P,T,J,v,q,ht,fe=class{constructor(t){d(this,q);D(this,"manifest");d(this,L,!1);d(this,P,{});d(this,T,void 0);d(this,J,{});d(this,v,de());D(this,"events",{on:s(this,v).on,off:s(this,v).off});D(this,"storage");var i,a;let{manifest:e,...o}=t;g(this,T,{}),(i=t.plugins)==null||i.forEach(n=>{!n.logDrain||s(this,v).on("log",n.logDrain)}),this.manifest=new nt({manifest:e,evaluator:new _({CK:bt,QS:kt,QK:wt,PVC:Tt,EVT:Pt,PV:Ot})}),this.storage=new mt({...o,manifest:this.manifest,onServerTransitionScoresReceived:n=>{g(this,P,n),g(this,L,!0),s(this,v).emit("log",["debug",130,n])},onLogMessage:n=>s(this,v).emit("log",n)}),this.storage.events.on("scoresUpdated",S(this,q,ht).bind(this)),s(this,L)||S(this,q,ht).call(this,this.storage.data),this.storage.events.on("quirksUpdated",n=>{let c=this.manifest.computeSignals({scores:s(this,P),state:s(this,T),previousState:s(this,T),visitor:this.storage.data});this.storage.updateData(c),s(this,v).emit("quirksUpdated",n.quirks),s(this,v).emit("log",["info",4,n.quirks])}),s(this,v).emit("log",["debug",1]),(a=t.plugins)==null||a.forEach(n=>{!n.init||n.init(this)})}get scores(){return s(this,P)}async update(t){var o;let e=[];t.quirks&&e.push(...Object.entries(t.quirks).map(([i,a])=>({type:"setquirk",data:{key:i,value:a}}))),t.enrichments&&t.enrichments.forEach(i=>{let a=Y(i.cat,i.key);this.manifest.getDimensionByKey(a)?e.push({type:"modscore",data:{dimension:a,delta:i.str}}):s(this,v).emit("log",["warn",5,i])}),e.push(...this.manifest.computeSignals({state:t,previousState:s(this,T),visitor:this.storage.data,scores:s(this,P)})),s(this,v).emit("log",["debug",2,{...t,url:(o=t.url)==null?void 0:o.toString()}]),g(this,T,{...s(this,T),...t}),await this.storage.updateData(e),s(this,L)&&(S(this,q,ht).call(this,this.storage.data),g(this,L,!1),s(this,v).emit("log",["debug",131]))}getTestVariantId(t){var o;let e=this.manifest.getTest(t);return e?(o=e.wv)!=null?o:this.storage.data.tests[t]:(s(this,v).emit("log",["warn",401,t]),null)}setTestVariantId(t,e){this.storage.updateData([{type:"settest",data:{test:t,variant:e}}])}log(...t){s(this,v).emit("log",t)}test(t){var o,i;let e=gt({...t,context:this});return s(this,v).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=jt({...t,context:this}),o=s(this,J)[t.name],i={name:t.name,variantIds:e.variations.map(a=>{var n;return(n=a.id)!=null?n:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&Bt(i.variantIds,o)&&(i.changed=!1),s(this,v).emit("personalizationResult",i),s(this,J)[t.name]=i.variantIds,e}async forget(t){g(this,T,{}),await this.storage.delete(t)}};L=new WeakMap,P=new WeakMap,T=new WeakMap,J=new WeakMap,v=new WeakMap,q=new WeakSet,ht=function(t){var i;let e={...t.scores};for(let a in t.sessionScores)e[a]=((i=e[a])!=null?i:0)+t.sessionScores[a];e=this.manifest.computeAggregateDimensions(e),!Bt(e,s(this,P))&&(g(this,P,e),s(this,v).emit("scoresUpdated",e),s(this,v).emit("log",["info",3,e]))};u();u();function ot(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 pe(r){return([t,e,...o])=>{!ot(r,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${e}
2
+ `,...o.map(i=>JSON.stringify(i,null,2)))}}function Jr(r){return{logDrain:pe(r)}}u();u();var Jt={1:()=>["context","constructed"],2:r=>["context","received data update",r],3:r=>["context","new score vector",r],4:r=>["context","updated quirks",r],5:r=>["context","ignored enrichment update for unknown enrichment category",r.cat],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],131:()=>["storage","server to client transition data was discarded"],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 me(r){return([t,e,...o])=>{if(!ot(r,t))return;let i=Jt[e],a=`\u{1F94B} [${new Date().toLocaleTimeString()}][${t}]`;if(!i){console[t](`${a} unknown event ID ${e} - ensure all Uniform packages are the same version`,...o);return}let[n,c,...l]=i(...o);console[t](`${a}[${n}] ${c} (Event ID: ${e})
3
+ `,...l.map(m=>JSON.stringify(m,null,2)))}}function Zr(r){return{logDrain:me(r)}}u();var ge=(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))(ge||{}),eo="nesitag";u();var vt=typeof top!="undefined";function oo(){return{logDrain:r=>{!vt||top==null||top.postMessage({type:"uniform:context:log",message:r},window.location.origin)},init:r=>{let t=[],e=[],o=()=>{!vt||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=n=>{!n.changed||(t.push(n),o())},a=n=>{!n.variantAssigned||(e.push(n),o())};if(vt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=r;try{top==null||top.addEventListener("message",async n=>{if(!n.data)return;let c=n.data;await he(c,r)})}catch(n){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",n)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),o()}return r.events.on("personalizationResult",i),r.events.on("testResult",a),r.storage.events.on("*",o),()=>{r.storage.events.off("*",o),r.events.off("personalizationResult",i),r.events.off("testResult",a)}}}}async function he(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{fe as Context,te as CookieTransitionDataStore,eo as EdgeNodeTagName,oe as EdgeTransitionDataStore,_ as GroupCriteriaEvaluator,nt as ManifestInstance,Wt as SERVER_STATE_ID,ge as ScriptType,j as TransitionDataStore,Zt as UNIFORM_DEFAULT_COOKIE_NAME,mt as VisitorDataStore,Ct as computeAggregateDimensions,bt as cookieEvaluator,pe as createConsoleLogDrain,me as createDebugConsoleLogDrain,lr as createLinearDecay,Ot as currentPageEvaluator,X as emptyVisitorData,Jr as enableConsoleLogDrain,oo as enableContextDevTools,Zr as enableDebugConsoleLogDrain,Qt as evaluateVariantMatch,Pt as eventEvaluator,Y as getEnrichmentVectorKey,b as isStringMatch,st as pageViewCountDimension,Tt as pageViewCountEvaluator,jt as personalizeVariations,kt as queryStringEvaluator,wt as quirkEvaluator,gt as testVariations};
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var ne=Object.create;var q=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?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Tt=e=>q(e,"__esModule",{value:!0});var le=(e,t)=>{for(var r in t)q(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")&&q(e,i,{get:()=>t[i],enumerable:!(o=se(t,i))||o.enumerable});return e},H=(e,t)=>kt(Tt(q(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:()=>$t,EdgeNodeTagName:()=>xe,EdgeTransitionDataStore:()=>Ft,GroupCriteriaEvaluator:()=>A,ManifestInstance:()=>X,SERVER_STATE_ID:()=>Lt,ScriptType:()=>ie,TransitionDataStore:()=>I,VisitorDataStore:()=>ot,computeAggregateDimensions:()=>at,cookieEvaluator:()=>ct,createConsoleLogDrain:()=>ee,createDebugConsoleLogDrain:()=>oe,createLinearDecay:()=>he,emptyVisitorData:()=>F,enableConsoleLogDrain:()=>Ce,enableContextDevTools:()=>be,enableDebugConsoleLogDrain:()=>Ve,evaluateVariantMatch:()=>Ct,eventEvaluator:()=>ft,getEnrichmentVectorKey:()=>_,isStringMatch:()=>D,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 d=new Set(o);d.add(a.dim),u=wt(e,a.dim,r,d)}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 D(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(d=>d.type==="modscoreS"&&d.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 D(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 D(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=>D(i.event,t.event)))!=null?o:!1};var mt=(e,t)=>{var r;return t.type!=="PV"?!1:D((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 d=n(this,j)[u.type];if(!d)throw new Error(`${u.type} signal criteria not registered`);c=d(t,u,o,i,s)}if(c===a)return a}return!a}};j=new WeakMap;function D(e,t){var a,u,c,d;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!((d=i.includes(s))!=null?d:!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,U,I=class{constructor({initialData:t}){p(this,k,void 0);p(this,U,(0,Mt.default)());h(this,"events",{on:n(this,U).on,off:n(this,U).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,U).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,U=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,$t=class extends I{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 Gt="~",_t="!",jt="-";function fe(e){if(!e)return;let t=e.split(Gt);if(t.length>3)return;let[r,o,i]=t;return{consent:!0,sessionScores:Nt(St(o)),scores:Nt(St(i)),tests:St(r)}}function St(e){return e.split(_t).map(r=>r.split(jt)).reduce((r,o)=>(o.length!==2||(r[o[0]]=o[1]),r),{})}function Nt(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=It(o),t),{})}function me(e){return[vt(e.tests),vt(qt(e.sessionScores)),vt(qt(e.scores))].join(Gt)}function qt(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(jt)).join(_t)}var Z,ge,Ft=class extends I{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 y=v/864e5,L=1-Math.min(o,y*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 Yt=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=Number(i.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=c+u;break;case"modscoreS":if(r)break;let d=Number(i.data.delta);if(isNaN(d))throw new Error("Non-number delta received");let v=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=v+d;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var tt="ufvisitor",b,R,N,m,C,w,T,z,et,ve,rt,ye,K,Bt,J,Ht,ot=class{constructor(t){p(this,C);p(this,T);p(this,et);p(this,rt);p(this,K);p(this,J);p(this,b,(0,Yt.default)());p(this,R,new yt);p(this,N,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,C,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,C,w).visitorData,...i})});let o=t.transitionStore.data;o&&S(this,T,z).call(this,{...n(this,C,w).visitorData,...o},!0)}}get data(){var r,o;let t=n(this,C,w);if(S(this,rt,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,C,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,C,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,C,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,Ht).call(this)),(i=(o=n(this,m)).onLogMessage)==null||i.call(o,["info",103,t])}};b=new WeakMap,R=new WeakMap,N=new WeakMap,m=new WeakMap,C=new WeakSet,w=function(){return n(this,R).get(tt)},T=new WeakSet,z=function(t,r=!1){var v,y,L,xt,bt,Et;let o=n(this,C,w),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,K,Bt).call(this,t.scores),S(this,K,Bt).call(this,t.sessionScores),(y=(v=n(this,m)).decay)==null||y.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),d={updated:i,visitorData:t};S(this,et,ve).call(this),n(this,R).set(tt,d,!!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))},et=new WeakSet,ve=function(){typeof window=="undefined"||!n(this,m).visitLifespan||(n(this,N)&&window.clearTimeout(n(this,N)),f(this,N,window.setTimeout(()=>{this.data},n(this,m).visitLifespan+50)))},rt=new WeakSet,ye=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 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 d of t){if(i.length===r)break;if(!((c=d.pz)==null?void 0:c.crit.length)){i.push(d);continue}!o&&Ct(d.pz,a)&&(s=!0,i.push(d))}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((d,v)=>{let y=a[v];if(u>c&&u<=c+y)return d;c+=y}),o&&t.setTestVariantId(e,(s=o.id)!=null?s:"Unknown")}return{result:o,variantAssigned:!i}};var Zt=require("dequal/lite"),P,V,B,g,te=class{constructor(t){h(this,"manifest");p(this,P,{});p(this,V,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,V,{}),(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 ot({...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 d={...c.scores};for(let y in c.sessionScores)d[y]=((v=d[y])!=null?v:0)+c.sessionScores[y];d=this.manifest.computeAggregateDimensions(d),f(this,P,d),n(this,g).emit("scoresUpdated",d),n(this,g).emit("log",["info",3,d])};this.storage.events.on("scoresUpdated",s),i||s(this.storage.data),this.storage.events.on("quirksUpdated",c=>{let d=this.manifest.computeSignals({scores:n(this,P),state:n(this,V),previousState:n(this,V),visitor:this.storage.data});this.storage.updateData(d),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,V);f(this,V,{...n(this,V),...t}),r.push(...this.manifest.computeSignals({state:n(this,V),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,V,{}),await this.storage.delete(t)}};P=new WeakMap,V=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}
2
- `,...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})
3
- `,...c.map(d=>JSON.stringify(d,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});
1
+ var fe=Object.create;var $=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var ve=(e,t,r)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Rt=e=>$(e,"__esModule",{value:!0});var Se=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},Ut=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of me(t))!he.call(e,i)&&(r||i!=="default")&&$(e,i,{get:()=>t[i],enumerable:!(o=pe(t,i))||o.enumerable});return e},G=(e,t)=>Ut(Rt($(e!=null?fe(ge(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),ye=(e=>(t,r)=>e&&e.get(t)||(r=Ut(Rt({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var S=(e,t,r)=>(ve(e,typeof t!="symbol"?t+"":t,r),r),ct=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var s=(e,t,r)=>(ct(e,t,"read from private field"),r?r.call(e):t.get(e)),l=(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)},p=(e,t,r,o)=>(ct(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var h=(e,t,r)=>(ct(e,t,"access private method"),r);var Ue={};Se(Ue,{Context:()=>ae,CookieTransitionDataStore:()=>Jt,EdgeNodeTagName:()=>Oe,EdgeTransitionDataStore:()=>Wt,GroupCriteriaEvaluator:()=>L,ManifestInstance:()=>Z,SERVER_STATE_ID:()=>Gt,ScriptType:()=>de,TransitionDataStore:()=>I,UNIFORM_DEFAULT_COOKIE_NAME:()=>Bt,VisitorDataStore:()=>st,computeAggregateDimensions:()=>lt,cookieEvaluator:()=>ft,createConsoleLogDrain:()=>ue,createDebugConsoleLogDrain:()=>le,createLinearDecay:()=>Ve,currentPageEvaluator:()=>vt,emptyVisitorData:()=>K,enableConsoleLogDrain:()=>we,enableContextDevTools:()=>Me,enableDebugConsoleLogDrain:()=>Pe,evaluateVariantMatch:()=>Et,eventEvaluator:()=>ht,getEnrichmentVectorKey:()=>j,isStringMatch:()=>y,pageViewCountDimension:()=>tt,pageViewCountEvaluator:()=>pt,personalizeVariations:()=>bt,queryStringEvaluator:()=>mt,quirkEvaluator:()=>gt,testVariations:()=>at});function lt(e,t){let r={...e};for(let o in t){let i=Lt(e,o,t,new Set([o]));i!==0&&(r[o]=i)}return r}function Lt(e,t,r,o){var a;let i=0;for(let n of r[t].inputs){let u=(a=e[n.dim])!=null?a:0;if(!u&&r[n.dim]){if(o.has(n.dim))continue;let f=new Set(o);f.add(n.dim),u=Lt(e,n.dim,r,f)}if(u!==0)if(n.sign==="c"){i=0;break}else n.sign==="-"?i-=u:i+=u}return i}var W="_";var _,E,dt=class{constructor(t,r,o){l(this,_,void 0);l(this,E,void 0);S(this,"signal");p(this,E,t),this.signal=r,p(this,_,o)}computeSignal(t,r){if(t.scores[s(this,E)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=s(this,_).evaluate(t,this.signal.crit,r,this.signal,s(this,E)),a=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!i.changed){if(i.result)r.push({type:a,data:{dimension:s(this,E),delta:this.signal.str}});else if(this.signal.dur==="t"){let n=t.visitor.sessionScores[s(this,E)];n&&r.push({type:a,data:{dimension:s(this,E),delta:-n}})}}}};_=new WeakMap,E=new WeakMap;var x,F,Z=class{constructor({manifest:t,evaluator:r=new L({})}){S(this,"data");l(this,x,void 0);l(this,F,void 0);var o,i,a;p(this,x,(o=t.project)!=null?o:{}),this.data=t,p(this,F,Object.entries((a=(i=s(this,x).pz)==null?void 0:i.sig)!=null?a:[]).map(([n,u])=>new dt(n,u,r)))}rollForControlGroup(){var t,r;return Math.random()<((r=(t=s(this,x).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=s(this,x).test)==null?void 0:r[t]}computeSignals(t){let r=[];return s(this,F).forEach(o=>{o.computeSignal(t,r)}),r}computeAggregateDimensions(t){var r,o;return lt(t,(o=(r=s(this,x).pz)==null?void 0:r.agg)!=null?o:{})}getDimensionByKey(t){var o,i,a,n;let r=t.indexOf(W);return r<=0?(i=(o=s(this,x).pz)==null?void 0:o.sig)==null?void 0:i[t]:(n=(a=s(this,x).pz)==null?void 0:a.enr)==null?void 0:n[t.substring(0,r)]}};x=new WeakMap,F=new WeakMap;var It=require("dequal/lite"),ft=(e,t)=>{var a,n;if(t.type!=="CK")return{result:!1,changed:!1};let r=!(0,It.dequal)(At(e.state.cookies),At((a=e.previousState)==null?void 0:a.cookies)),o=(n=e.state.cookies)==null?void 0:n[t.cookieName];return{result:y(o,t.match),changed:r}};function At(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}function zt(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 j(e,t){return`${e}${W}${t}`}var tt=j("$pvc","v"),pt=(e,t,r)=>{var n,u;if(t.type!=="PVC")return{result:!1,changed:!1};let o=!e.previousState||((n=e.state.url)==null?void 0:n.toString())!==((u=e.previousState.url)==null?void 0:u.toString()),a=(e.visitor.sessionScores[tt]||0)+1;if(zt(a,t.match)){let c=r.some(f=>f.type==="modscoreS"&&f.data.dimension===tt);return o&&!c&&r.push({type:"modscoreS",data:{dimension:tt,delta:1}}),{result:!0,changed:o}}return{result:!1,changed:o}};var mt=(e,t)=>{var a,n,u,c,f;if(t.type!=="QS")return{result:!1,changed:!1};let r=!e.previousState||((n=(a=e.state.url)==null?void 0:a.searchParams)==null?void 0:n.toString())!==((c=(u=e.previousState.url)==null?void 0:u.searchParams)==null?void 0:c.toString()),o=(f=e.state.url)==null?void 0:f.searchParams.get(t.queryName);return{result:y(o,t.match),changed:r}};var gt=(e,t,r,o,i)=>{var v;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&o.dur==="t"&&e.scores[i]>0)return{result:!0,changed:!1};let a=e.visitor.quirks[t.key],n=(v=e.state.quirks)==null?void 0:v[t.key],u=n!=null?n:a,c=Boolean(n&&a!==n);return{result:y(u,t.match),changed:c}};var ht=(e,t)=>{var o,i;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(i=(o=e.state.events)==null?void 0:o.some(a=>y(a.event,t.event)))!=null?i:!1;return{result:r,changed:r}};var vt=(e,t)=>{var i,a,n,u,c;if(t.type!=="PV")return{result:!1,changed:!1};let r=!e.previousState||((a=(i=e.state.url)==null?void 0:i.pathname)==null?void 0:a.toString())!==((u=(n=e.previousState.url)==null?void 0:n.pathname)==null?void 0:u.toString());return{result:y((c=e.state.url)==null?void 0:c.pathname,t.path),changed:r}};var Q,L=class{constructor(t){l(this,Q,void 0);p(this,Q,t)}evaluate(t,r,o,i,a){let n=!(r.op==="&"||!r.op),u=!1;for(let c of r.clauses){let f;if(c.type==="G")f=this.evaluate(t,c,o,i,a);else{let v=s(this,Q)[c.type];if(!v)throw new Error(`${c.type} signal criteria not registered`);f=v(t,c,o,i,a)}if(f.changed&&(u=!0),f.result===n)return{result:n,changed:u}}return{result:!n,changed:u}}};Q=new WeakMap;function y(e,t){var n,u,c,f,v,C;let r=(n=t==null?void 0:t.op)!=null?n:"=";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:"":Nt(e)).toString(),a=(o?t.rhs:Nt(t.rhs)).toString();switch(r){case"=":return i===a;case"!=":return i!==a;case"~":return(c=i.includes(a))!=null?c:!1;case"!~":return!((f=i.includes(a))==null||f);case"//":return new RegExp(t.rhs.toString(),o?"":"i").test((v=e==null?void 0:e.toString())!=null?v:"");case"!//":return!new RegExp(t.rhs.toString(),o?"":"i").test((C=e==null?void 0:e.toString())!=null?C:"");default:throw new Error(`Unknown match type ${r}.`)}}function Nt(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var K=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var qt=G(require("mitt")),$t=require("dequal/lite"),Gt="__UNIFORM_DATA__",w,A,I=class{constructor({initialData:t}){l(this,w,void 0);l(this,A,(0,qt.default)());S(this,"events",{on:s(this,A).on,off:s(this,A).off});t&&p(this,w,t)}get data(){return s(this,w)}updateData(t,r){return p(this,w,r),this.handleUpdateData(t,r)}async delete(t){p(this,w,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,$t.dequal)(this.data,t)||(p(this,w,t),s(this,A).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Gt);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};w=new WeakMap,A=new WeakMap;var St="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_t=St.split(""),Ft=new Array(123);for(let e=0;e<St.length;e++)Ft[St.charCodeAt(e)]=e;var yt=e=>{if(e<0)return`-${yt(-e)}`;let t=e>>>0,r=e/4294967296>>>0,o="";for(;r>0;)o=_t[63&t]+o,t>>>=6,t|=(63&r)<<26,r>>>=6;let i="";do i=_t[63&t]+i,t>>>=6;while(t>0);return i+o},jt=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let o=r;o<e.length;o++)t=t*64+Ft[e.charCodeAt(o)];return r?-t:t};var et=G(require("js-cookie")),Dt=typeof document=="undefined",Bt="ufvd",O,B,Jt=class extends I{constructor({serverCookieValue:t,cookieName:r=Bt,cookieAttributes:o={sameSite:"lax"}}){super({initialData:Dt?De(t):void 0});l(this,O,void 0);l(this,B,void 0);p(this,O,r),p(this,B,o)}handleDelete(){return Dt||et.default.remove(s(this,O)),Promise.resolve()}async handleUpdateData(t,r){Dt||(r.consent?et.default.set(s(this,O),Ce(r),s(this,B)):et.default.remove(s(this,O)))}};O=new WeakMap,B=new WeakMap;var Ht="~",Yt="!",Xt="-";function De(e){if(!e)return;let t=e.split(Ht);if(t.length>3)return;let[r,o,i]=t;return{consent:!0,sessionScores:Qt(Ct(o)),scores:Qt(Ct(i)),tests:Ct(r)}}function Ct(e){return e.split(Yt).map(r=>r.split(Xt)).reduce((r,o)=>(o.length!==2||(r[o[0]]=o[1]),r),{})}function Qt(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=jt(o),t),{})}function Ce(e){return[xt(e.tests),xt(Kt(e.sessionScores)),xt(Kt(e.scores))].join(Ht)}function Kt(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=yt(o),t),{})}function xt(e){return Object.entries(e).map(t=>t.join(Xt)).join(Yt)}var rt,xe,Wt=class extends I{constructor({serverCookieValue:t,visitorIdCookieName:r="ufvi",...o}){super(o);l(this,rt);o.initialData||h(this,rt,xe).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)}};rt=new WeakSet,xe=async function(){let t=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};function Ve(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:o=.95}=e!=null?e:{};return function({now:a,lastUpd:n,scores:u,sessionScores:c}){if(typeof n!="number")return!1;let v=a-n-t;if(v<=0)return!1;let C=v/864e5,U=1-Math.min(o,C*r);return U<=0?!1:(Zt(u,U),Zt(c,U),!0)}}function Zt(e,t){for(let r in e)e[r]*=t}var ie=G(require("mitt")),J=require("dequal/lite");var Vt=class{constructor(){S(this,"inMemoryFallback",{});S(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 te=G(require("rfdc"));var be=(0,te.default)();function ee(e,t,r){let o=t?be(t):K();return e.forEach(i=>{var a,n;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=Number(i.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(a=o.scores[i.data.dimension])!=null?a:0;o.scores[i.data.dimension]=c+u;break;case"modscoreS":if(r)break;let f=Number(i.data.delta);if(isNaN(f))throw new Error("Non-number delta received");let v=(n=o.sessionScores[i.data.dimension])!=null?n:0;o.sessionScores[i.data.dimension]=v+f;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var ot="ufvisitor",V,M,N,m,D,P,T,z,it,Ee,nt,Te,H,re,Y,oe,st=class{constructor(t){l(this,D);l(this,T);l(this,it);l(this,nt);l(this,H);l(this,Y);l(this,V,(0,ie.default)());l(this,M,new Vt);l(this,N,void 0);l(this,m,void 0);S(this,"events",{on:s(this,V).on,off:s(this,V).off});if(p(this,m,t),s(this,D,P)||h(this,T,z).call(this,h(this,Y,oe).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();if(r){let i=[];r.quirks&&i.push(...Object.entries(r.quirks).map(([a,n])=>({type:"setquirk",data:{key:a,value:n}}))),r.tests&&i.push(...Object.entries(r.tests).map(([a,n])=>({type:"settest",data:{test:a,variant:n}}))),this.updateData(i),r.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(r.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{h(this,T,z).call(this,{...s(this,D,P).visitorData,...i})});let o=t.transitionStore.data;o&&h(this,T,z).call(this,{...s(this,D,P).visitorData,...o},!0)}}get data(){var r,o;let t=s(this,D,P);if(h(this,nt,Te).call(this,t)){let{sessionScores:i,...a}=t.visitorData;return h(this,T,z).call(this,{...a,sessionScores:{}}),(o=(r=s(this,m)).onLogMessage)==null||o.call(r,["info",120]),s(this,D,P).visitorData}return t.visitorData}get decayEnabled(){return!!s(this,m).decay}async updateData(t){var o,i,a,n;if(t.length===0)return;(i=(o=s(this,m)).onLogMessage)==null||i.call(o,["debug",101,t]);let r=ee(t,this.data,(a=s(this,D,P))==null?void 0:a.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&s(this,M).delete(ot,!0),h(this,T,z).call(this,r),await((n=s(this,m).transitionStore)==null?void 0:n.updateData(t,s(this,D,P).visitorData))}async delete(t){var r,o,i;s(this,M).delete(ot,!1),await((r=s(this,m).transitionStore)==null?void 0:r.delete(t)),h(this,T,z).call(this,h(this,Y,oe).call(this)),(i=(o=s(this,m)).onLogMessage)==null||i.call(o,["info",103,t])}};V=new WeakMap,M=new WeakMap,N=new WeakMap,m=new WeakMap,D=new WeakSet,P=function(){return s(this,M).get(ot)},T=new WeakSet,z=function(t,r=!1){var v,C,U,Pt,Ot,Mt;let o=s(this,D,P),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(h(this,H,re).call(this,t.scores),h(this,H,re).call(this,t.sessionScores),(C=(v=s(this,m)).decay)==null||C.call(v,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let a=!(0,J.dequal)(o==null?void 0:o.visitorData.scores,t.scores),n=!(0,J.dequal)(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),u=!(0,J.dequal)(o==null?void 0:o.visitorData.quirks,t.quirks),c=!(0,J.dequal)(o==null?void 0:o.visitorData.tests,t.tests),f={updated:i,visitorData:t};h(this,it,Ee).call(this),s(this,M).set(ot,f,!!t.consent),(Pt=(U=s(this,m)).onLogMessage)==null||Pt.call(U,["debug",102,t]),r||((a||n)&&s(this,V).emit("scoresUpdated",t),u&&s(this,V).emit("quirksUpdated",t),c&&s(this,V).emit("testsUpdated",t),((Ot=o==null?void 0:o.visitorData)==null?void 0:Ot.consent)!==t.consent&&s(this,V).emit("consentUpdated",t),((Mt=o==null?void 0:o.visitorData)==null?void 0:Mt.controlGroup)!==t.controlGroup&&s(this,V).emit("controlGroupUpdated",t))},it=new WeakSet,Ee=function(){typeof document=="undefined"||!s(this,m).visitLifespan||(s(this,N)&&window.clearTimeout(s(this,N)),p(this,N,window.setTimeout(()=>{this.data},s(this,m).visitLifespan+50)))},nt=new WeakSet,Te=function(t){let r=s(this,m).visitLifespan;return r?t.updated+r<Date.now():!1},H=new WeakSet,re=function(t){var r,o;if(!!s(this,m).manifest)for(let i in t){let a=t[i],n=s(this,m).manifest.getDimensionByKey(i);!n||a>n.cap&&((o=(r=s(this,m)).onLogMessage)==null||o.call(r,["debug",110,{dim:i,score:a,cap:n.cap}]),t[i]=n.cap)}},Y=new WeakSet,oe=function(){var t,r,o;return{...K(),consent:(t=s(this,m).defaultConsent)!=null?t:!1,controlGroup:(o=(r=s(this,m).manifest)==null?void 0:r.rollForControlGroup())!=null?o:!1}};var se=G(require("mitt"));function bt({context:e,variations:t,take:r=1}){var u,c;let o=(u=e.storage.data.controlGroup)!=null?u:!1,i=[],a=!1,n=e.scores;for(let f of t){if(i.length===r)break;if(!((c=f.pz)!=null&&c.crit.length)){i.push(f);continue}!o&&Et(f.pz,n)&&(a=!0,i.push(f))}return{personalized:a,variations:i}}function Et(e,t){return e!=null&&e.crit?!e.op||e.op==="&"?e.crit.every(r=>ne(r,t)):e.crit.some(r=>ne(r,t)):!0}function ne(e,t){var n;let{op:r,l:o}=e,i=(n=t[o])!=null?n:0;if(r==="+")return Math.max(...Object.values(t))===i&&i>0;if(r==="-")return Math.min(...Object.values(t))===i&&i>0;let a=e.rDim?t[e.rDim]:e.r;if(a===void 0)return!1;if(r===">")return i>a;if(r===">=")return i>=a;if(r==="<")return i<a;if(r==="<=")return i<=a;if(r==="=")return i===a;if(r==="!=")return i!==a;throw new Error(`Unknown op: ${r}`)}var ke=e=>{let{values:t,total:r,missingDistribution:o}=e.reduce((i,a)=>(a.testDistribution?i.total+=a.testDistribution:++i.missingDistribution,i.values.push(a.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 a=(100-r)/o;t.forEach((n,u)=>{typeof n=="undefined"&&(t[u]=a)})}return t},at=({name:e,context:t,variations:r})=>{var a;let o,i=t.getTestVariantId(e);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=r.find(n=>n.id===i),o||t.log("warn",401,{test:e,variant:i})),!o){let n=ke(r),u=Math.floor(Math.random()*100),c=0;o=r.find((f,v)=>{let C=n[v];if(u>c&&u<=c+C)return f;c+=C}),o&&t.setTestVariantId(e,(a=o.id)!=null?a:"Unknown")}return{result:o,variantAssigned:!i}};var kt=require("dequal/lite"),R,k,b,X,g,q,Tt,ae=class{constructor(t){l(this,q);S(this,"manifest");l(this,R,!1);l(this,k,{});l(this,b,void 0);l(this,X,{});l(this,g,(0,se.default)());S(this,"events",{on:s(this,g).on,off:s(this,g).off});S(this,"storage");var i,a;let{manifest:r,...o}=t;p(this,b,{}),(i=t.plugins)==null||i.forEach(n=>{!n.logDrain||s(this,g).on("log",n.logDrain)}),this.manifest=new Z({manifest:r,evaluator:new L({CK:ft,QS:mt,QK:gt,PVC:pt,EVT:ht,PV:vt})}),this.storage=new st({...o,manifest:this.manifest,onServerTransitionScoresReceived:n=>{p(this,k,n),p(this,R,!0),s(this,g).emit("log",["debug",130,n])},onLogMessage:n=>s(this,g).emit("log",n)}),this.storage.events.on("scoresUpdated",h(this,q,Tt).bind(this)),s(this,R)||h(this,q,Tt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",n=>{let u=this.manifest.computeSignals({scores:s(this,k),state:s(this,b),previousState:s(this,b),visitor:this.storage.data});this.storage.updateData(u),s(this,g).emit("quirksUpdated",n.quirks),s(this,g).emit("log",["info",4,n.quirks])}),s(this,g).emit("log",["debug",1]),(a=t.plugins)==null||a.forEach(n=>{!n.init||n.init(this)})}get scores(){return s(this,k)}async update(t){var o;let r=[];t.quirks&&r.push(...Object.entries(t.quirks).map(([i,a])=>({type:"setquirk",data:{key:i,value:a}}))),t.enrichments&&t.enrichments.forEach(i=>{let a=j(i.cat,i.key);this.manifest.getDimensionByKey(a)?r.push({type:"modscore",data:{dimension:a,delta:i.str}}):s(this,g).emit("log",["warn",5,i])}),r.push(...this.manifest.computeSignals({state:t,previousState:s(this,b),visitor:this.storage.data,scores:s(this,k)})),s(this,g).emit("log",["debug",2,{...t,url:(o=t.url)==null?void 0:o.toString()}]),p(this,b,{...s(this,b),...t}),await this.storage.updateData(r),s(this,R)&&(h(this,q,Tt).call(this,this.storage.data),p(this,R,!1),s(this,g).emit("log",["debug",131]))}getTestVariantId(t){var o;let r=this.manifest.getTest(t);return r?(o=r.wv)!=null?o:this.storage.data.tests[t]:(s(this,g).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){s(this,g).emit("log",t)}test(t){var o,i;let r=at({...t,context:this});return s(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=bt({...t,context:this}),o=s(this,X)[t.name],i={name:t.name,variantIds:r.variations.map(a=>{var n;return(n=a.id)!=null?n:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&(0,kt.dequal)(i.variantIds,o)&&(i.changed=!1),s(this,g).emit("personalizationResult",i),s(this,X)[t.name]=i.variantIds,r}async forget(t){p(this,b,{}),await this.storage.delete(t)}};R=new WeakMap,k=new WeakMap,b=new WeakMap,X=new WeakMap,g=new WeakMap,q=new WeakSet,Tt=function(t){var i;let r={...t.scores};for(let a in t.sessionScores)r[a]=((i=r[a])!=null?i:0)+t.sessionScores[a];r=this.manifest.computeAggregateDimensions(r),!(0,kt.dequal)(r,s(this,k))&&(p(this,k,r),s(this,g).emit("scoresUpdated",r),s(this,g).emit("log",["info",3,r]))};function ut(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 ue(e){return([t,r,...o])=>{!ut(e,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
2
+ `,...o.map(i=>JSON.stringify(i,null,2)))}}function we(e){return{logDrain:ue(e)}}var ce={1:()=>["context","constructed"],2:e=>["context","received data update",e],3:e=>["context","new score vector",e],4:e=>["context","updated quirks",e],5:e=>["context","ignored enrichment update for unknown enrichment category",e.cat],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],131:()=>["storage","server to client transition data was discarded"],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 le(e){return([t,r,...o])=>{if(!ut(e,t))return;let i=ce[r],a=`\u{1F94B} [${new Date().toLocaleTimeString()}][${t}]`;if(!i){console[t](`${a} unknown event ID ${r} - ensure all Uniform packages are the same version`,...o);return}let[n,u,...c]=i(...o);console[t](`${a}[${n}] ${u} (Event ID: ${r})
3
+ `,...c.map(f=>JSON.stringify(f,null,2)))}}function Pe(e){return{logDrain:le(e)}}var de=(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))(de||{}),Oe="nesitag";var wt=typeof top!="undefined";function Me(){return{logDrain:e=>{!wt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],o=()=>{!wt||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=n=>{!n.changed||(t.push(n),o())},a=n=>{!n.variantAssigned||(r.push(n),o())};if(wt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async n=>{if(!n.data)return;let u=n.data;await Re(u,e)})}catch(n){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",n)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),o()}return e.events.on("personalizationResult",i),e.events.on("testResult",a),e.storage.events.on("*",o),()=>{e.storage.events.off("*",o),e.events.off("personalizationResult",i),e.events.off("testResult",a)}}}}async function Re(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=ye(Ue);0&&(module.exports={Context,CookieTransitionDataStore,EdgeNodeTagName,EdgeTransitionDataStore,GroupCriteriaEvaluator,ManifestInstance,SERVER_STATE_ID,ScriptType,TransitionDataStore,UNIFORM_DEFAULT_COOKIE_NAME,VisitorDataStore,computeAggregateDimensions,cookieEvaluator,createConsoleLogDrain,createDebugConsoleLogDrain,createLinearDecay,currentPageEvaluator,emptyVisitorData,enableConsoleLogDrain,enableContextDevTools,enableDebugConsoleLogDrain,evaluateVariantMatch,eventEvaluator,getEnrichmentVectorKey,isStringMatch,pageViewCountDimension,pageViewCountEvaluator,personalizeVariations,queryStringEvaluator,quirkEvaluator,testVariations});
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- 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 N,k,rt=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,$,ot=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 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,$).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,$=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 _,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 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 Rt="~",Lt="!",At="-";function Jt(r){if(!r)return;let t=r.split(Rt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:Mt(at(o)),scores:Mt(at(i)),tests:at(e)}}function at(r){return r.split(Lt).map(e=>e.split(At)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function Mt(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=wt(o),t),{})}function Bt(r){return[ut(r.tests),ut(Ot(r.sessionScores)),ut(Ot(r.scores))].join(Rt)}function Ot(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(At)).join(Lt)}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 D=s-a-t;if(D<=0)return!1;let C=D/864e5,U=1-Math.min(o,C*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=Number(i.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let d=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=d+c;break;case"modscoreS":if(e)break;let l=Number(i.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let D=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=D+l;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,V,M,w,z,Z,te,tt,ee,F,zt,Q,qt,dt=class{constructor(t){m(this,V);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,V,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,V,M).visitorData,...i})});let o=t.transitionStore.data;o&&y(this,w,z).call(this,{...n(this,V,M).visitorData,...o},!0)}}get data(){var e,o;let t=n(this,V,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,V,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,V,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,V,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,V=new WeakSet,M=function(){return n(this,A).get(W)},w=new WeakSet,z=function(t,e=!1){var D,C,U,ft,mt,gt;let o=n(this,V,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),(C=(D=n(this,h)).decay)==null||C.call(D,{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 Nt({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&&$t(l.pz,a)&&(s=!0,i.push(l))}return{personalized:s,variations:i}}u();function $t(r,t){return(r==null?void 0:r.crit)?!r.op||r.op==="&"?r.crit.every(e=>Gt(e,t)):r.crit.some(e=>Gt(e,t)):!0}function Gt(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,D)=>{let C=a[D];if(c>d&&c<=d+C)return l;d+=C}),o&&t.setTestVariantId(r,(s=o.id)!=null?s:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as ie}from"dequal/lite";var O,x,K,S,ne=class{constructor(t){v(this,"manifest");m(this,O,{});m(this,x,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,x,{}),(a=t.plugins)==null||a.forEach(d=>{!d.logDrain||n(this,S).on("log",d.logDrain)}),this.manifest=new ot({manifest:e,evaluator:new G({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 D;let l={...d.scores};for(let C in d.sessionScores)l[C]=((D=l[C])!=null?D:0)+d.sessionScores[C];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,x),previousState:n(this,x),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,x);g(this,x,{...n(this,x),...t}),e.push(...this.manifest.computeSignals({state:n(this,x),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=Nt({...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,x,{}),await this.storage.delete(t)}};O=new WeakMap,x=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}
2
- `,...o.map(i=>JSON.stringify(i,null,2)))}}function $r(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})
3
- `,...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,G 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,$r as enableConsoleLogDrain,Hr as enableContextDevTools,Qr as enableDebugConsoleLogDrain,$t as evaluateVariantMatch,xt as eventEvaluator,B as getEnrichmentVectorKey,E as isStringMatch,it as pageViewCountDimension,Dt as pageViewCountEvaluator,bt as pageVisitedEvaluator,Nt as personalizeVariations,Ct as queryStringEvaluator,Vt as quirkEvaluator,lt as testVariations};
1
+ import{a as H}from"./chunk-CEKV2MHL.mjs";import{d as D,e as s,f as d,g,h as S,i as u}from"./chunk-AFJ7PNM5.mjs";u();u();u();function Ct(r,t){let e={...r};for(let o in t){let i=Vt(r,o,t,new Set([o]));i!==0&&(e[o]=i)}return e}function Vt(r,t,e,o){var a;let i=0;for(let n of e[t].inputs){let c=(a=r[n.dim])!=null?a:0;if(!c&&e[n.dim]){if(o.has(n.dim))continue;let m=new Set(o);m.add(n.dim),c=Vt(r,n.dim,e,m)}if(c!==0)if(n.sign==="c"){i=0;break}else n.sign==="-"?i-=c:i+=c}return i}u();var $,k,it=class{constructor(t,e,o){d(this,$,void 0);d(this,k,void 0);D(this,"signal");g(this,k,t),this.signal=e,g(this,$,o)}computeSignal(t,e){if(t.scores[s(this,k)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=s(this,$).evaluate(t,this.signal.crit,e,this.signal,s(this,k)),a=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!i.changed){if(i.result)e.push({type:a,data:{dimension:s(this,k),delta:this.signal.str}});else if(this.signal.dur==="t"){let n=t.visitor.sessionScores[s(this,k)];n&&e.push({type:a,data:{dimension:s(this,k),delta:-n}})}}}};$=new WeakMap,k=new WeakMap;var x,G,nt=class{constructor({manifest:t,evaluator:e=new _({})}){D(this,"data");d(this,x,void 0);d(this,G,void 0);var o,i,a;g(this,x,(o=t.project)!=null?o:{}),this.data=t,g(this,G,Object.entries((a=(i=s(this,x).pz)==null?void 0:i.sig)!=null?a:[]).map(([n,c])=>new it(n,c,e)))}rollForControlGroup(){var t,e;return Math.random()<((e=(t=s(this,x).pz)==null?void 0:t.control)!=null?e:0)}getTest(t){var e;return(e=s(this,x).test)==null?void 0:e[t]}computeSignals(t){let e=[];return s(this,G).forEach(o=>{o.computeSignal(t,e)}),e}computeAggregateDimensions(t){var e,o;return Ct(t,(o=(e=s(this,x).pz)==null?void 0:e.agg)!=null?o:{})}getDimensionByKey(t){var o,i,a,n;let e=t.indexOf(H);return e<=0?(i=(o=s(this,x).pz)==null?void 0:o.sig)==null?void 0:i[t]:(n=(a=s(this,x).pz)==null?void 0:a.enr)==null?void 0:n[t.substring(0,e)]}};x=new WeakMap,G=new WeakMap;u();import{dequal as Ht}from"dequal/lite";var bt=(r,t)=>{var a,n;if(t.type!=="CK")return{result:!1,changed:!1};let e=!Ht(xt(r.state.cookies),xt((a=r.previousState)==null?void 0:a.cookies)),o=(n=r.state.cookies)==null?void 0:n[t.cookieName];return{result:b(o,t.match),changed:e}};function xt(r){if(!r)return;if(!r.ufvd)return r;let{ufvd:t,...e}=r;return e}u();u();function Et(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 Y(r,t){return`${r}${H}${t}`}var st=Y("$pvc","v"),Tt=(r,t,e)=>{var n,c;if(t.type!=="PVC")return{result:!1,changed:!1};let o=!r.previousState||((n=r.state.url)==null?void 0:n.toString())!==((c=r.previousState.url)==null?void 0:c.toString()),a=(r.visitor.sessionScores[st]||0)+1;if(Et(a,t.match)){let l=e.some(m=>m.type==="modscoreS"&&m.data.dimension===st);return o&&!l&&e.push({type:"modscoreS",data:{dimension:st,delta:1}}),{result:!0,changed:o}}return{result:!1,changed:o}};u();var kt=(r,t)=>{var a,n,c,l,m;if(t.type!=="QS")return{result:!1,changed:!1};let e=!r.previousState||((n=(a=r.state.url)==null?void 0:a.searchParams)==null?void 0:n.toString())!==((l=(c=r.previousState.url)==null?void 0:c.searchParams)==null?void 0:l.toString()),o=(m=r.state.url)==null?void 0:m.searchParams.get(t.queryName);return{result:b(o,t.match),changed:e}};u();var wt=(r,t,e,o,i)=>{var y;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&o.dur==="t"&&r.scores[i]>0)return{result:!0,changed:!1};let a=r.visitor.quirks[t.key],n=(y=r.state.quirks)==null?void 0:y[t.key],c=n!=null?n:a,l=Boolean(n&&a!==n);return{result:b(c,t.match),changed:l}};u();var Pt=(r,t)=>{var o,i;if(t.type!=="EVT")return{result:!1,changed:!1};let e=(i=(o=r.state.events)==null?void 0:o.some(a=>b(a.event,t.event)))!=null?i:!1;return{result:e,changed:e}};u();var Ot=(r,t)=>{var i,a,n,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let e=!r.previousState||((a=(i=r.state.url)==null?void 0:i.pathname)==null?void 0:a.toString())!==((c=(n=r.previousState.url)==null?void 0:n.pathname)==null?void 0:c.toString());return{result:b((l=r.state.url)==null?void 0:l.pathname,t.path),changed:e}};u();var F,_=class{constructor(t){d(this,F,void 0);g(this,F,t)}evaluate(t,e,o,i,a){let n=!(e.op==="&"||!e.op),c=!1;for(let l of e.clauses){let m;if(l.type==="G")m=this.evaluate(t,l,o,i,a);else{let y=s(this,F)[l.type];if(!y)throw new Error(`${l.type} signal criteria not registered`);m=y(t,l,o,i,a)}if(m.changed&&(c=!0),m.result===n)return{result:n,changed:c}}return{result:!n,changed:c}}};F=new WeakMap;u();function b(r,t){var n,c,l,m,y,V;let e=(n=t==null?void 0:t.op)!=null?n:"=";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:"":Mt(r)).toString(),a=(o?t.rhs:Mt(t.rhs)).toString();switch(e){case"=":return i===a;case"!=":return i!==a;case"~":return(l=i.includes(a))!=null?l:!1;case"!~":return!((m=i.includes(a))==null||m);case"//":return new RegExp(t.rhs.toString(),o?"":"i").test((y=r==null?void 0:r.toString())!=null?y:"");case"!//":return!new RegExp(t.rhs.toString(),o?"":"i").test((V=r==null?void 0:r.toString())!=null?V:"");default:throw new Error(`Unknown match type ${e}.`)}}function Mt(r){var t,e;return(e=(t=r==null?void 0:r.toString())==null?void 0:t.toUpperCase())!=null?e:""}u();var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});u();u();import Yt from"mitt";import{dequal as Xt}from"dequal/lite";var Wt="__UNIFORM_DATA__",O,I,j=class{constructor({initialData:t}){d(this,O,void 0);d(this,I,Yt());D(this,"events",{on:s(this,I).on,off:s(this,I).off});t&&g(this,O,t)}get data(){return s(this,O)}updateData(t,e){return g(this,O,e),this.handleUpdateData(t,e)}async delete(t){g(this,O,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){Xt(this.data,t)||(g(this,O,t),s(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Wt);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};O=new WeakMap,I=new WeakMap;u();var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rt=at.split(""),Ut=new Array(123);for(let r=0;r<at.length;r++)Ut[at.charCodeAt(r)]=r;var ut=r=>{if(r<0)return`-${ut(-r)}`;let t=r>>>0,e=r/4294967296>>>0,o="";for(;e>0;)o=Rt[63&t]+o,t>>>=6,t|=(63&e)<<26,e>>>=6;let i="";do i=Rt[63&t]+i,t>>>=6;while(t>0);return i+o},Lt=r=>{let t=0,e=r.charAt(0)==="-"?1:0;for(let o=e;o<r.length;o++)t=t*64+Ut[r.charCodeAt(o)];return e?-t:t};import ct from"js-cookie";var lt=typeof document=="undefined",Zt="ufvd",R,Q,te=class extends j{constructor({serverCookieValue:t,cookieName:e=Zt,cookieAttributes:o={sameSite:"lax"}}){super({initialData:lt?ee(t):void 0});d(this,R,void 0);d(this,Q,void 0);g(this,R,e),g(this,Q,o)}handleDelete(){return lt||ct.remove(s(this,R)),Promise.resolve()}async handleUpdateData(t,e){lt||(e.consent?ct.set(s(this,R),re(e),s(this,Q)):ct.remove(s(this,R)))}};R=new WeakMap,Q=new WeakMap;var zt="~",Nt="!",qt="-";function ee(r){if(!r)return;let t=r.split(zt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:At(dt(o)),scores:At(dt(i)),tests:dt(e)}}function dt(r){return r.split(Nt).map(e=>e.split(qt)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function At(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=Lt(o),t),{})}function re(r){return[ft(r.tests),ft(It(r.sessionScores)),ft(It(r.scores))].join(zt)}function It(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=ut(o),t),{})}function ft(r){return Object.entries(r).map(t=>t.join(qt)).join(Nt)}u();var W,ie,oe=class extends j{constructor({serverCookieValue:t,visitorIdCookieName:e="ufvi",...o}){super(o);d(this,W);o.initialData||S(this,W,ie).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)}};W=new WeakSet,ie=async function(){let t=await new Promise(e=>{setTimeout(()=>{e(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};u();function lr(r){let{gracePeriod:t=864e5,decayRate:e=1/30,decayCap:o=.95}=r!=null?r:{};return function({now:a,lastUpd:n,scores:c,sessionScores:l}){if(typeof n!="number")return!1;let y=a-n-t;if(y<=0)return!1;let V=y/864e5,A=1-Math.min(o,V*e);return A<=0?!1:($t(c,A),$t(l,A),!0)}}function $t(r,t){for(let e in r)r[e]*=t}u();import ae from"mitt";import{dequal as Z}from"dequal/lite";u();var pt=class{constructor(){D(this,"inMemoryFallback",{});D(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 ne from"rfdc";var se=ne();function Gt(r,t,e){let o=t?se(t):X();return r.forEach(i=>{var a,n;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=Number(i.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let l=(a=o.scores[i.data.dimension])!=null?a:0;o.scores[i.data.dimension]=l+c;break;case"modscoreS":if(e)break;let m=Number(i.data.delta);if(isNaN(m))throw new Error("Non-number delta received");let y=(n=o.sessionScores[i.data.dimension])!=null?n:0;o.sessionScores[i.data.dimension]=y+m;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var tt="ufvisitor",E,U,N,h,C,M,w,z,et,ue,rt,ce,K,_t,B,Ft,mt=class{constructor(t){d(this,C);d(this,w);d(this,et);d(this,rt);d(this,K);d(this,B);d(this,E,ae());d(this,U,new pt);d(this,N,void 0);d(this,h,void 0);D(this,"events",{on:s(this,E).on,off:s(this,E).off});if(g(this,h,t),s(this,C,M)||S(this,w,z).call(this,S(this,B,Ft).call(this),!0),t.transitionStore){let e=t.transitionStore.getClientTransitionState();if(e){let i=[];e.quirks&&i.push(...Object.entries(e.quirks).map(([a,n])=>({type:"setquirk",data:{key:a,value:n}}))),e.tests&&i.push(...Object.entries(e.tests).map(([a,n])=>({type:"settest",data:{test:a,variant:n}}))),this.updateData(i),e.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(e.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{S(this,w,z).call(this,{...s(this,C,M).visitorData,...i})});let o=t.transitionStore.data;o&&S(this,w,z).call(this,{...s(this,C,M).visitorData,...o},!0)}}get data(){var e,o;let t=s(this,C,M);if(S(this,rt,ce).call(this,t)){let{sessionScores:i,...a}=t.visitorData;return S(this,w,z).call(this,{...a,sessionScores:{}}),(o=(e=s(this,h)).onLogMessage)==null||o.call(e,["info",120]),s(this,C,M).visitorData}return t.visitorData}get decayEnabled(){return!!s(this,h).decay}async updateData(t){var o,i,a,n;if(t.length===0)return;(i=(o=s(this,h)).onLogMessage)==null||i.call(o,["debug",101,t]);let e=Gt(t,this.data,(a=s(this,C,M))==null?void 0:a.visitorData.controlGroup);t.some(c=>c.type==="consent"&&!c.data)&&s(this,U).delete(tt,!0),S(this,w,z).call(this,e),await((n=s(this,h).transitionStore)==null?void 0:n.updateData(t,s(this,C,M).visitorData))}async delete(t){var e,o,i;s(this,U).delete(tt,!1),await((e=s(this,h).transitionStore)==null?void 0:e.delete(t)),S(this,w,z).call(this,S(this,B,Ft).call(this)),(i=(o=s(this,h)).onLogMessage)==null||i.call(o,["info",103,t])}};E=new WeakMap,U=new WeakMap,N=new WeakMap,h=new WeakMap,C=new WeakSet,M=function(){return s(this,U).get(tt)},w=new WeakSet,z=function(t,e=!1){var y,V,A,St,yt,Dt;let o=s(this,C,M),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,K,_t).call(this,t.scores),S(this,K,_t).call(this,t.sessionScores),(V=(y=s(this,h)).decay)==null||V.call(y,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let a=!Z(o==null?void 0:o.visitorData.scores,t.scores),n=!Z(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),c=!Z(o==null?void 0:o.visitorData.quirks,t.quirks),l=!Z(o==null?void 0:o.visitorData.tests,t.tests),m={updated:i,visitorData:t};S(this,et,ue).call(this),s(this,U).set(tt,m,!!t.consent),(St=(A=s(this,h)).onLogMessage)==null||St.call(A,["debug",102,t]),e||((a||n)&&s(this,E).emit("scoresUpdated",t),c&&s(this,E).emit("quirksUpdated",t),l&&s(this,E).emit("testsUpdated",t),((yt=o==null?void 0:o.visitorData)==null?void 0:yt.consent)!==t.consent&&s(this,E).emit("consentUpdated",t),((Dt=o==null?void 0:o.visitorData)==null?void 0:Dt.controlGroup)!==t.controlGroup&&s(this,E).emit("controlGroupUpdated",t))},et=new WeakSet,ue=function(){typeof document=="undefined"||!s(this,h).visitLifespan||(s(this,N)&&window.clearTimeout(s(this,N)),g(this,N,window.setTimeout(()=>{this.data},s(this,h).visitLifespan+50)))},rt=new WeakSet,ce=function(t){let e=s(this,h).visitLifespan;return e?t.updated+e<Date.now():!1},K=new WeakSet,_t=function(t){var e,o;if(!!s(this,h).manifest)for(let i in t){let a=t[i],n=s(this,h).manifest.getDimensionByKey(i);!n||a>n.cap&&((o=(e=s(this,h)).onLogMessage)==null||o.call(e,["debug",110,{dim:i,score:a,cap:n.cap}]),t[i]=n.cap)}},B=new WeakSet,Ft=function(){var t,e,o;return{...X(),consent:(t=s(this,h).defaultConsent)!=null?t:!1,controlGroup:(o=(e=s(this,h).manifest)==null?void 0:e.rollForControlGroup())!=null?o:!1}};u();import de from"mitt";u();u();function jt({context:r,variations:t,take:e=1}){var c,l;let o=(c=r.storage.data.controlGroup)!=null?c:!1,i=[],a=!1,n=r.scores;for(let m of t){if(i.length===e)break;if(!((l=m.pz)!=null&&l.crit.length)){i.push(m);continue}!o&&Qt(m.pz,n)&&(a=!0,i.push(m))}return{personalized:a,variations:i}}u();function Qt(r,t){return r!=null&&r.crit?!r.op||r.op==="&"?r.crit.every(e=>Kt(e,t)):r.crit.some(e=>Kt(e,t)):!0}function Kt(r,t){var n;let{op:e,l:o}=r,i=(n=t[o])!=null?n:0;if(e==="+")return Math.max(...Object.values(t))===i&&i>0;if(e==="-")return Math.min(...Object.values(t))===i&&i>0;let a=r.rDim?t[r.rDim]:r.r;if(a===void 0)return!1;if(e===">")return i>a;if(e===">=")return i>=a;if(e==="<")return i<a;if(e==="<=")return i<=a;if(e==="=")return i===a;if(e==="!=")return i!==a;throw new Error(`Unknown op: ${e}`)}u();var le=r=>{let{values:t,total:e,missingDistribution:o}=r.reduce((i,a)=>(a.testDistribution?i.total+=a.testDistribution:++i.missingDistribution,i.values.push(a.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 a=(100-e)/o;t.forEach((n,c)=>{typeof n=="undefined"&&(t[c]=a)})}return t},gt=({name:r,context:t,variations:e})=>{var a;let o,i=t.getTestVariantId(r);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=e.find(n=>n.id===i),o||t.log("warn",401,{test:r,variant:i})),!o){let n=le(e),c=Math.floor(Math.random()*100),l=0;o=e.find((m,y)=>{let V=n[y];if(c>l&&c<=l+V)return m;l+=V}),o&&t.setTestVariantId(r,(a=o.id)!=null?a:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as Bt}from"dequal/lite";var L,P,T,J,v,q,ht,fe=class{constructor(t){d(this,q);D(this,"manifest");d(this,L,!1);d(this,P,{});d(this,T,void 0);d(this,J,{});d(this,v,de());D(this,"events",{on:s(this,v).on,off:s(this,v).off});D(this,"storage");var i,a;let{manifest:e,...o}=t;g(this,T,{}),(i=t.plugins)==null||i.forEach(n=>{!n.logDrain||s(this,v).on("log",n.logDrain)}),this.manifest=new nt({manifest:e,evaluator:new _({CK:bt,QS:kt,QK:wt,PVC:Tt,EVT:Pt,PV:Ot})}),this.storage=new mt({...o,manifest:this.manifest,onServerTransitionScoresReceived:n=>{g(this,P,n),g(this,L,!0),s(this,v).emit("log",["debug",130,n])},onLogMessage:n=>s(this,v).emit("log",n)}),this.storage.events.on("scoresUpdated",S(this,q,ht).bind(this)),s(this,L)||S(this,q,ht).call(this,this.storage.data),this.storage.events.on("quirksUpdated",n=>{let c=this.manifest.computeSignals({scores:s(this,P),state:s(this,T),previousState:s(this,T),visitor:this.storage.data});this.storage.updateData(c),s(this,v).emit("quirksUpdated",n.quirks),s(this,v).emit("log",["info",4,n.quirks])}),s(this,v).emit("log",["debug",1]),(a=t.plugins)==null||a.forEach(n=>{!n.init||n.init(this)})}get scores(){return s(this,P)}async update(t){var o;let e=[];t.quirks&&e.push(...Object.entries(t.quirks).map(([i,a])=>({type:"setquirk",data:{key:i,value:a}}))),t.enrichments&&t.enrichments.forEach(i=>{let a=Y(i.cat,i.key);this.manifest.getDimensionByKey(a)?e.push({type:"modscore",data:{dimension:a,delta:i.str}}):s(this,v).emit("log",["warn",5,i])}),e.push(...this.manifest.computeSignals({state:t,previousState:s(this,T),visitor:this.storage.data,scores:s(this,P)})),s(this,v).emit("log",["debug",2,{...t,url:(o=t.url)==null?void 0:o.toString()}]),g(this,T,{...s(this,T),...t}),await this.storage.updateData(e),s(this,L)&&(S(this,q,ht).call(this,this.storage.data),g(this,L,!1),s(this,v).emit("log",["debug",131]))}getTestVariantId(t){var o;let e=this.manifest.getTest(t);return e?(o=e.wv)!=null?o:this.storage.data.tests[t]:(s(this,v).emit("log",["warn",401,t]),null)}setTestVariantId(t,e){this.storage.updateData([{type:"settest",data:{test:t,variant:e}}])}log(...t){s(this,v).emit("log",t)}test(t){var o,i;let e=gt({...t,context:this});return s(this,v).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=jt({...t,context:this}),o=s(this,J)[t.name],i={name:t.name,variantIds:e.variations.map(a=>{var n;return(n=a.id)!=null?n:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&Bt(i.variantIds,o)&&(i.changed=!1),s(this,v).emit("personalizationResult",i),s(this,J)[t.name]=i.variantIds,e}async forget(t){g(this,T,{}),await this.storage.delete(t)}};L=new WeakMap,P=new WeakMap,T=new WeakMap,J=new WeakMap,v=new WeakMap,q=new WeakSet,ht=function(t){var i;let e={...t.scores};for(let a in t.sessionScores)e[a]=((i=e[a])!=null?i:0)+t.sessionScores[a];e=this.manifest.computeAggregateDimensions(e),!Bt(e,s(this,P))&&(g(this,P,e),s(this,v).emit("scoresUpdated",e),s(this,v).emit("log",["info",3,e]))};u();u();function ot(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 pe(r){return([t,e,...o])=>{!ot(r,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${e}
2
+ `,...o.map(i=>JSON.stringify(i,null,2)))}}function Jr(r){return{logDrain:pe(r)}}u();u();var Jt={1:()=>["context","constructed"],2:r=>["context","received data update",r],3:r=>["context","new score vector",r],4:r=>["context","updated quirks",r],5:r=>["context","ignored enrichment update for unknown enrichment category",r.cat],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],131:()=>["storage","server to client transition data was discarded"],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 me(r){return([t,e,...o])=>{if(!ot(r,t))return;let i=Jt[e],a=`\u{1F94B} [${new Date().toLocaleTimeString()}][${t}]`;if(!i){console[t](`${a} unknown event ID ${e} - ensure all Uniform packages are the same version`,...o);return}let[n,c,...l]=i(...o);console[t](`${a}[${n}] ${c} (Event ID: ${e})
3
+ `,...l.map(m=>JSON.stringify(m,null,2)))}}function Zr(r){return{logDrain:me(r)}}u();var ge=(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))(ge||{}),eo="nesitag";u();var vt=typeof top!="undefined";function oo(){return{logDrain:r=>{!vt||top==null||top.postMessage({type:"uniform:context:log",message:r},window.location.origin)},init:r=>{let t=[],e=[],o=()=>{!vt||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=n=>{!n.changed||(t.push(n),o())},a=n=>{!n.variantAssigned||(e.push(n),o())};if(vt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=r;try{top==null||top.addEventListener("message",async n=>{if(!n.data)return;let c=n.data;await he(c,r)})}catch(n){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",n)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),o()}return r.events.on("personalizationResult",i),r.events.on("testResult",a),r.storage.events.on("*",o),()=>{r.storage.events.off("*",o),r.events.off("personalizationResult",i),r.events.off("testResult",a)}}}}async function he(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{fe as Context,te as CookieTransitionDataStore,eo as EdgeNodeTagName,oe as EdgeTransitionDataStore,_ as GroupCriteriaEvaluator,nt as ManifestInstance,Wt as SERVER_STATE_ID,ge as ScriptType,j as TransitionDataStore,Zt as UNIFORM_DEFAULT_COOKIE_NAME,mt as VisitorDataStore,Ct as computeAggregateDimensions,bt as cookieEvaluator,pe as createConsoleLogDrain,me as createDebugConsoleLogDrain,lr as createLinearDecay,Ot as currentPageEvaluator,X as emptyVisitorData,Jr as enableConsoleLogDrain,oo as enableContextDevTools,Zr as enableDebugConsoleLogDrain,Qt as evaluateVariantMatch,Pt as eventEvaluator,Y as getEnrichmentVectorKey,b as isStringMatch,st as pageViewCountDimension,Tt as pageViewCountEvaluator,jt as personalizeVariations,kt as queryStringEvaluator,wt as quirkEvaluator,gt as testVariations};