@uniformdev/context 14.2.1-alpha.145 → 14.2.1-alpha.249

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.
@@ -1,4 +1,4 @@
1
- import { p as paths$7 } from './v2-manifest.swagger-d0899723';
1
+ import { p as paths$7 } from './v2-manifest.swagger-ff2af13e';
2
2
 
3
3
  /**
4
4
  * This file was auto-generated by openapi-typescript.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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';
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, f as LogMessage } from './types-5f88cc63';
2
+ export { A as AggregateDimension, l as AggregateDimensionInput, ac as BehaviorTag, a0 as Context, $ as ContextEvents, Y as ContextOptions, C as ContextPlugin, t as ContextState, u as ContextStateUpdate, b as CriteriaEvaluator, n as CriteriaEvaluatorParameters, m as CriteriaEvaluatorResult, D as DecayFunction, H as DecayOptions, aj as DevToolsActions, an as DevToolsDataEvent, ak as DevToolsEvent, al as DevToolsEvents, ar as DevToolsForgetEvent, ao as DevToolsHelloEvent, am as DevToolsLogEvent, aq as DevToolsRawCommandsEvent, ai as DevToolsState, ah as DevToolsUiVersion, ap as DevToolsUpdateEvent, ab as DimensionMatch, E as EnrichmentCategory, q as EnrichmentData, r as EventData, G as GroupCriteriaEvaluator, I as IdentifyCommand, L as LogDrain, f as LogMessage, a6 as LogMessageGroup, a5 as LogMessageSingle, a1 as LogMessages, M as ManifestInstance, g as ManifestV2, a3 as MessageCategory, a4 as MessageFunc, w as ModifyScoreCommand, x as ModifySessionScoreCommand, N as NumberMatch, O as OutputSeverity, Z as PersonalizationEvent, P as PersonalizationManifest, a9 as PersonalizeOptions, ae as PersonalizedResult, ad as PersonalizedVariant, Q as Quirks, W as SERVER_STATE_ID, d as ScoreVector, U as ServerToClientTransitionState, y as SetConsentCommand, F as SetControlGroupCommand, z as SetQuirkCommand, B as SetTestCommand, a2 as Severity, h as Signal, j as SignalCriteria, i as SignalCriteriaGroup, o as SignalData, v as StorageCommand, S as StorageCommands, c as StringMatch, k as TestDefinition, _ as TestEvent, a8 as TestOptions, ag as TestResult, af as TestVariant, p as Tests, T as TransitionDataStore, X as TransitionDataStoreEvents, a as TransitionDataStoreOptions, e as VariantMatchCriteria, V as VisitorData, R as VisitorDataStore, K as VisitorDataStoreEvents, J as VisitorDataStoreOptions, s as emptyVisitorData, aa as personalizeVariations, a7 as testVariations } from './types-5f88cc63';
3
3
  import Cookies from 'js-cookie';
4
- import './v2-manifest.swagger-d0899723';
4
+ import './v2-manifest.swagger-ff2af13e';
5
5
  import 'mitt';
6
6
 
7
7
  declare type CookieTransitionDataStoreOptions = {
@@ -86,19 +86,6 @@ declare function createConsoleLogDrain(level: OutputSeverity): LogDrain;
86
86
  */
87
87
  declare function enableConsoleLogDrain(level: OutputSeverity): ContextPlugin;
88
88
 
89
- /**
90
- * Creates a new log drain that will log full debug messages to the console.
91
- * The debug log drain adds significant bundle size, but is useful for debugging.
92
- *
93
- * NOTE: you probably want enableDebugConsoleLogDrain() instead of this function.
94
- */
95
- declare function createDebugConsoleLogDrain(level: OutputSeverity): LogDrain;
96
- /**
97
- * Enables logging Context events to the browser console.
98
- * Lightweight events with only the event ID are emitted.
99
- */
100
- declare function enableDebugConsoleLogDrain(level: OutputSeverity): ContextPlugin;
101
-
102
89
  declare const cookieEvaluator: CriteriaEvaluator;
103
90
 
104
91
  declare const pageViewCountDimension: string;
@@ -114,13 +101,31 @@ declare const currentPageEvaluator: CriteriaEvaluator;
114
101
 
115
102
  /** Tests if a StringMatch matches a string value */
116
103
  declare function isStringMatch(lhs: string | number | null | undefined, match: StringMatch): boolean;
104
+ declare function explainStringMatch(lhs: string | number | null | undefined, match: StringMatch): string;
105
+ declare function explainStringMatchCriteria(match: StringMatch): string;
106
+
107
+ declare type ConsoleDebugLogDrainOptions = {
108
+ enableOnServer?: boolean;
109
+ };
110
+ /**
111
+ * Creates a new log drain that will log full debug messages to the console.
112
+ * The debug log drain adds significant bundle size, but is useful for debugging.
113
+ *
114
+ * NOTE: you probably want enableDebugConsoleLogDrain() instead of this function.
115
+ */
116
+ declare function createDebugConsoleLogDrain(level: OutputSeverity, options?: ConsoleDebugLogDrainOptions): LogDrain;
117
+ /**
118
+ * Enables logging Context events to the browser console.
119
+ * Lightweight events with only the event ID are emitted.
120
+ */
121
+ declare function enableDebugConsoleLogDrain(level: OutputSeverity, options?: ConsoleDebugLogDrainOptions): ContextPlugin;
117
122
 
118
123
  /** Computes aggregated scores based on other dimensions */
119
124
  declare function computeAggregateDimensions(primitiveScores: ScoreVector, aggregates: Record<string, AggregateDimension>): ScoreVector;
120
125
 
121
126
  declare function getEnrichmentVectorKey(category: string, value: string): string;
122
127
 
123
- declare function evaluateVariantMatch(match: VariantMatchCriteria | undefined | null, vec: ScoreVector): boolean;
128
+ declare function evaluateVariantMatch(variantId: string, match: VariantMatchCriteria | undefined | null, vec: ScoreVector, onLogMessage?: (message: LogMessage) => void): boolean;
124
129
 
125
130
  declare enum ScriptType {
126
131
  ListStart = "nesi-list-start",
@@ -147,4 +152,4 @@ declare const EdgeNodeTagName = "nesitag";
147
152
  */
148
153
  declare function enableContextDevTools(): ContextPlugin;
149
154
 
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 };
155
+ export { ConsoleDebugLogDrainOptions, CookieTransitionDataStore, CookieTransitionDataStoreOptions, EdgeNodeTagName, EdgePersonalizeComponentOptions, EdgeTestComponentOptions, EdgeTransitionDataStore, EdgeTransitionDataStoreOptions, LinearDecayOptions, ScriptType, UNIFORM_DEFAULT_COOKIE_NAME, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, evaluateVariantMatch, eventEvaluator, explainStringMatch, explainStringMatchCriteria, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, queryStringEvaluator, quirkEvaluator };
package/dist/index.esm.js CHANGED
@@ -1,3 +1,3 @@
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};
1
+ import{a as tt}from"./chunk-CEKV2MHL.mjs";import{d as x,e as a,f,g as v,h as C,i as l}from"./chunk-AFJ7PNM5.mjs";l();l();l();function Pt(e,t){let r={...e};for(let i in t){let n=wt(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function wt(e,t,r,i){var s;let n=0;for(let o of r[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&r[o.dim]){if(i.has(o.dim))continue;let c=new Set(i);c.add(o.dim),u=wt(e,o.dim,r,c)}if(u!==0)if(o.sign==="c"){n=0;break}else o.sign==="-"?n-=u:n+=u}return n}l();var Q,K,lt=class{constructor(t,r,i){f(this,Q,void 0);f(this,K,void 0);x(this,"signal");this.signal=t,v(this,Q,r),v(this,K,i)}computeSignal(t,r){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,Q).evaluate(t,this.signal.crit,r,this.signal,a(this,K)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)r.push({type:s,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let o=t.visitor.sessionScores[this.signal.id];o&&r.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};Q=new WeakMap,K=new WeakMap;var E,B,R,ct=class{constructor({manifest:t,evaluator:r=new H({}),onLogMessage:i=()=>{}}){x(this,"data");f(this,E,void 0);f(this,B,void 0);f(this,R,void 0);var n,s,o;v(this,E,(n=t.project)!=null?n:{}),this.data=t,v(this,B,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,d])=>new lt({...d,id:u},r,i))),v(this,R,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,E).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,E).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,R).call(this,["debug",200,"GROUP"]);try{a(this,B).forEach(i=>{a(this,R).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,R).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,R).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return Pt(t,(i=(r=a(this,E).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(tt);return r<=0?(n=(i=a(this,E).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};E=new WeakMap,B=new WeakMap,R=new WeakMap;l();import{dequal as re}from"dequal/lite";l();function T(e,t){var o,u,d,c,h,g;let r=(o=t==null?void 0:t.op)!=null?o:"=";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 i=(u=t.cs)!=null?u:!1,n=(i?e!=null?e:"":Ot(e)).toString(),s=(i?t.rhs:Ot(t.rhs)).toString();switch(r){case"=":return n===s;case"!=":return n!==s;case"~":return(d=n.includes(s))!=null?d:!1;case"!~":return!((c=n.includes(s))==null||c);case"//":return new RegExp(t.rhs.toString(),i?"":"i").test((h=e==null?void 0:e.toString())!=null?h:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((g=e==null?void 0:e.toString())!=null?g:"");default:throw new Error(`Unknown match type ${r}.`)}}function U(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${dt(t)}`}function dt(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Ot(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var Ut=({update:e,criteria:t,onLogMessage:r})=>{var u,d;if(t.type!=="CK")return{result:!1,changed:!1};let i=!re(Rt(e.state.cookies),Rt((u=e.previousState)==null?void 0:u.cookies)),n=(d=e.state.cookies)==null?void 0:d[t.cookieName],o={result:T(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:U(n,t.match)}]),o};function Rt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}l();l();function $t(e,t){var i;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((i=t==null?void 0:t.op)!=null?i:"="){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 At(e,t){return`${e} ${ie(t)}`}function ie(e){return`${e.op} ${e.rhs}`}l();function et(e,t){return`${e}${tt}${t}`}var ft=et("$pvc","v"),pt=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var c,h;if(t.type!=="PVC")return{result:!1,changed:!1};let n=Boolean(e.state.url&&(!e.previousState||((c=e.state.url)==null?void 0:c.toString())!==((h=e.previousState.url)==null?void 0:h.toString()))),o=(e.visitor.sessionScores[ft]||0)+1,u={result:!1,changed:n},d=r.some(g=>g.type==="modscoreS"&&g.data.dimension===ft);return n&&!d&&r.push({type:"modscoreS",data:{dimension:ft,delta:1}}),$t(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:At(o,t.match)}]),u};pt.alwaysExecute=!0;l();var Nt=({update:e,criteria:t,onLogMessage:r})=>{var u,d,c,h,g;if(t.type!=="QS")return{result:!1,changed:!1};let i=!e.previousState||((d=(u=e.state.url)==null?void 0:u.searchParams)==null?void 0:d.toString())!==((h=(c=e.previousState.url)==null?void 0:c.searchParams)==null?void 0:h.toString()),n=(g=e.state.url)==null?void 0:g.searchParams.get(t.queryName),o={result:T(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:U(n,t.match)}]),o};l();var Gt=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var h;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&r.dur==="t"&&e.scores[r.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],s=(h=e.state.quirks)==null?void 0:h[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),c={result:T(o,t.match),changed:u};return i==null||i(["debug",203,{criteria:t,result:c,explanation:U(o,t.match)}]),c};l();var zt=({update:e,criteria:t,onLogMessage:r})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let i=(o=(s=e.state.events)==null?void 0:s.some(d=>T(d.event,t.event)))!=null?o:!1,n={result:i,changed:i};return r==null||r(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${dt(t.event)}`}]),n};l();var It=({update:e,criteria:t,onLogMessage:r})=>{var u,d,c;if(t.type!=="PV")return{result:!1,changed:!1};let i=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(i==null?void 0:i.toString())!==((c=(d=e.previousState.url)==null?void 0:d.pathname)==null?void 0:c.toString()),o={result:T(i,t.path),changed:n};return r==null||r(["debug",203,{criteria:t,result:o,explanation:U(i,t.path)}]),o};l();var J,H=class{constructor(t){f(this,J,void 0);v(this,J,t)}evaluate(t,r,i,n,s){let o=r.clauses.length>1;o&&(s==null||s(["debug",202,"GROUP",r]));try{let u=!(r.op==="&"||!r.op),d=null,c=!1;for(let g of r.clauses){let D;if(g.type==="G")D=this.evaluate(t,g,i,n,s);else{let b=a(this,J)[g.type];if(d&&!b.alwaysExecute)continue;if(!b)throw new Error(`${g.type} signal criteria not registered`);D=b({update:t,criteria:g,commands:i,signal:n,onLogMessage:s})}D.changed&&(c=!0),!d&&D.result===u&&(d={result:u,changed:c})}let h=d!=null?d:{result:!u,changed:c};return o&&(s==null||s(["debug",204,h])),h}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};J=new WeakMap;l();var rt=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});l();l();import ne from"mitt";import{dequal as oe}from"dequal/lite";var se="__UNIFORM_DATA__",$,I,Y=class{constructor({initialData:t}){f(this,$,void 0);f(this,I,ne());x(this,"events",{on:a(this,I).on,off:a(this,I).off});t&&v(this,$,t)}get data(){return a(this,$)}updateData(t,r){return v(this,$,r),this.handleUpdateData(t,r)}async delete(t){v(this,$,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){oe(this.data,t)||(v(this,$,t),a(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(se);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};$=new WeakMap,I=new WeakMap;l();var mt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qt=mt.split(""),_t=new Array(123);for(let e=0;e<mt.length;e++)_t[mt.charCodeAt(e)]=e;var ht=e=>{if(e<0)return`-${ht(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=qt[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=qt[63&t]+n,t>>>=6;while(t>0);return n+i},jt=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+_t[e.charCodeAt(i)];return r?-t:t};import gt from"js-cookie";var vt=typeof document=="undefined",ae="ufvd",N,W,ue=class extends Y{constructor({serverCookieValue:t,cookieName:r=ae,cookieAttributes:i={sameSite:"lax"}}){super({initialData:vt?le(t):void 0});f(this,N,void 0);f(this,W,void 0);v(this,N,r),v(this,W,i)}handleDelete(){return vt||gt.remove(a(this,N)),Promise.resolve()}async handleUpdateData(t,r){vt||(r.consent?gt.set(a(this,N),ce(r),a(this,W)):gt.remove(a(this,N)))}};N=new WeakMap,W=new WeakMap;var Kt="~",Bt="!",Ht="-";function le(e){if(!e)return;let t=e.split(Kt);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:Ft(St(i)),scores:Ft(St(n)),tests:St(r)}}function St(e){return e.split(Bt).map(r=>r.split(Ht)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function Ft(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=jt(i),t),{})}function ce(e){return[yt(e.tests),yt(Qt(e.sessionScores)),yt(Qt(e.scores))].join(Kt)}function Qt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=ht(i),t),{})}function yt(e){return Object.entries(e).map(t=>t.join(Ht)).join(Bt)}l();var it,fe,de=class extends Y{constructor({serverCookieValue:t,visitorIdCookieName:r="ufvi",...i}){super(i);f(this,it);i.initialData||C(this,it,fe).call(this).catch(n=>{console.error(n)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let r=await new Promise(i=>{setTimeout(()=>{i(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};it=new WeakSet,fe=async function(){let t=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};l();function Vr(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:i=.95}=e!=null?e:{};return function({now:s,lastUpd:o,scores:u,sessionScores:d,onLogMessage:c}){if(typeof o!="number")return!1;let g=s-o-t;if(g<=0)return!1;let D=g/864e5,b=1-Math.min(i,D*r);return b<=0?!1:(Jt(u,b),Jt(d,b),c==null||c(["info",140,`linear decay factor ${b.toPrecision(6)}`]),!0)}}function Jt(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}l();import he from"mitt";import{dequal as nt}from"dequal/lite";l();var Dt=class{constructor(){x(this,"inMemoryFallback",{});x(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let i=localStorage.getItem(t);return i?JSON.parse(i):void 0}catch(i){return r}}set(t,r,i){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!i))try{localStorage.setItem(t,JSON.stringify(r))}catch(n){console.warn(n)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(i){}}};l();import pe from"rfdc";var me=pe();function Yt(e,t,r){let i=t?me(t):rt();return e.forEach(n=>{var s,o;switch(n.type){case"consent":i.consent=n.data;break;case"setquirk":i.quirks[n.data.key]=n.data.value;break;case"settest":i.tests[n.data.test]=n.data.variant;break;case"modscore":if(r)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let d=(s=i.scores[n.data.dimension])!=null?s:0;i.scores[n.data.dimension]=d+u;break;case"modscoreS":if(r)break;let c=Number(n.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let h=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=h+c;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var ot="ufvisitor",k,G,_,y,V,A,w,q,st,ge,at,ve,X,Wt,Z,Xt,Ct=class{constructor(t){f(this,V);f(this,w);f(this,st);f(this,at);f(this,X);f(this,Z);f(this,k,he());f(this,G,new Dt);f(this,_,void 0);f(this,y,void 0);x(this,"events",{on:a(this,k).on,off:a(this,k).off});if(v(this,y,t),a(this,V,A)||C(this,w,q).call(this,C(this,Z,Xt).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();if(r){let n=[];r.quirks&&n.push(...Object.entries(r.quirks).map(([s,o])=>({type:"setquirk",data:{key:s,value:o}}))),r.tests&&n.push(...Object.entries(r.tests).map(([s,o])=>({type:"settest",data:{test:s,variant:o}}))),this.updateData(n),r.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(r.ssv)}t.transitionStore.events.on("dataUpdatedAsync",n=>{C(this,w,q).call(this,{...a(this,V,A).visitorData,...n})});let i=t.transitionStore.data;i&&C(this,w,q).call(this,{...a(this,V,A).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,V,A);if(C(this,at,ve).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return C(this,w,q).call(this,{...s,sessionScores:{}}),(i=(r=a(this,y)).onLogMessage)==null||i.call(r,["info",120]),a(this,V,A).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,y).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,y)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=Yt(t,this.data,(s=a(this,V,A))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,G).delete(ot,!0),C(this,w,q).call(this,r),await((o=a(this,y).transitionStore)==null?void 0:o.updateData(t,a(this,V,A).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,y)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,G).delete(ot,!1),await((n=a(this,y).transitionStore)==null?void 0:n.delete(t)),C(this,w,q).call(this,C(this,Z,Xt).call(this))}finally{(o=(s=a(this,y)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};k=new WeakMap,G=new WeakMap,_=new WeakMap,y=new WeakMap,V=new WeakSet,A=function(){return a(this,G).get(ot)},w=new WeakSet,q=function(t,r=!1){var h,g,D,b,L,Et,Tt,kt;let i=a(this,V,A),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(C(this,X,Wt).call(this,t.scores),C(this,X,Wt).call(this,t.sessionScores),(g=(h=a(this,y)).decay)==null||g.call(h,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,y).onLogMessage}));let s=!nt(i==null?void 0:i.visitorData.scores,t.scores),o=!nt(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!nt(i==null?void 0:i.visitorData.quirks,t.quirks),d=!nt(i==null?void 0:i.visitorData.tests,t.tests),c={updated:n,visitorData:t};C(this,st,ge).call(this),a(this,G).set(ot,c,!!t.consent),(b=(D=a(this,y)).onLogMessage)==null||b.call(D,["debug",102,t]),r||((s||o)&&a(this,k).emit("scoresUpdated",t),u&&a(this,k).emit("quirksUpdated",t),d&&a(this,k).emit("testsUpdated",t),((L=i==null?void 0:i.visitorData)==null?void 0:L.consent)!==t.consent&&a(this,k).emit("consentUpdated",t),((Et=i==null?void 0:i.visitorData)==null?void 0:Et.controlGroup)!==t.controlGroup&&(a(this,k).emit("controlGroupUpdated",t),(kt=(Tt=a(this,y)).onLogMessage)==null||kt.call(Tt,["debug",104,t.controlGroup])))},st=new WeakSet,ge=function(){typeof document=="undefined"||!a(this,y).visitLifespan||(a(this,_)&&window.clearTimeout(a(this,_)),v(this,_,window.setTimeout(()=>{this.data},a(this,y).visitLifespan+50)))},at=new WeakSet,ve=function(t){let r=a(this,y).visitLifespan;return r?t.updated+r<Date.now():!1},X=new WeakSet,Wt=function(t){var r,i;if(!!a(this,y).manifest)for(let n in t){let s=t[n],o=a(this,y).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,y)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},Z=new WeakSet,Xt=function(){var t,r,i;return{...rt(),consent:(t=a(this,y).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,y).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};l();import ye from"mitt";l();l();function Zt({name:e,context:t,variations:r,take:i=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:i}]);try{let d=(s=t.storage.data.controlGroup)!=null?s:!1,c=[],h=!1,g=t.scores;for(let D of r){if(c.length===i)break;if(!((o=D.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:D.id,op:(u=D.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),c.push(D);continue}d||Mt(D.id,D.pz,g,n)&&(h=!0,c.push(D))}return{personalized:h,variations:c}}finally{n==null||n(["info",300,"ENDGROUP"])}}l();function Mt(e,t,r,i){i==null||i(["info",301,"GROUP",{id:e,op:t==null?void 0:t.op}]);let n;try{t!=null&&t.crit?!t.op||t.op==="&"?n=t.crit.every(s=>Lt(s,r,i)):n=t.crit.some(s=>Lt(s,r,i)):(i==null||i(["info",302,{matched:!0,description:"default variation"}]),n=!0),i==null||i(["info",303,n])}finally{i==null||i(["info",301,"ENDGROUP"])}return n}function Lt(e,t,r){var u,d;let{op:i,l:n}=e,s=(u=t[n])!=null?u:0;if(i==="+"){let c=Math.max(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:c,description:`${e.l} has the highest score`}]),c}else if(i==="-"){let c=Math.min(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:c,description:`${e.l} has the lowest non-zero score`}]),c}let o=e.rDim?t[e.rDim]:e.r;if(o===void 0)return r==null||r(["info",302,{matched:!1,description:`${(d=e.rDim)!=null?d:e.r} has no score value`}]),!1;if(i===">"){let c=s>o;return j(r,c,e,s,o),c}else if(i===">="){let c=s>=o;return j(r,c,e,s,o),c}else if(i==="<"){let c=s<o;return j(r,c,e,s,o),c}else if(i==="<="){let c=s<=o;return j(r,c,e,s,o),c}else if(i==="="){let c=s===o;return j(r,c,e,s,o),c}else if(i==="!="){let c=s!==o;return j(r,c,e,s,o),c}else throw new Error(`Unknown op: ${i}`)}function j(e,t,r,i,n){e==null||e(["info",302,{matched:t,description:`${r.l}[${i}] ${r.op} ${r.rDim?`${r.rDim}[${n}]`:r.r}`}])}l();var Se=e=>{let{values:t,total:r,missingDistribution:i}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.testDistribution),n),{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)/i;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},xt=({name:e,context:t,variations:r,onLogMessage:i})=>{i==null||i(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return i==null||i(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=r.find(o=>o.id===s),n||i==null||i(["warn",402,{missingVariant:s,variants:r.map(o=>o.id)}])),!n){let o=Se(r),u=Math.floor(Math.random()*100),d=0;n=r.find((c,h)=>{let g=o[h];if(u>d&&u<=d+g)return c;d+=g}),n&&(i==null||i(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(i==null||i(["info",404,n.id])),{result:n,variantAssigned:!s}}finally{i==null||i(["info",400,"ENDGROUP"])}};import{dequal as te}from"dequal/lite";var z,O,P,M,S,F,bt,De=class{constructor(t){f(this,F);x(this,"manifest");f(this,z,!1);f(this,O,{});f(this,P,void 0);f(this,M,{});f(this,S,ye());x(this,"events",{on:a(this,S).on,off:a(this,S).off});x(this,"storage");var n,s;let{manifest:r,...i}=t;v(this,P,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,S).on("log",o.logDrain)}),a(this,S).emit("log",["info",1,"GROUP"]);try{this.manifest=new ct({onLogMessage:o=>a(this,S).emit("log",o),manifest:r,evaluator:new H({CK:Ut,QS:Nt,QK:Gt,PVC:pt,EVT:zt,PV:It})}),this.storage=new Ct({...i,manifest:this.manifest,onServerTransitionScoresReceived:o=>{v(this,O,o),v(this,z,!0),a(this,S).emit("log",["debug",130,o])},onLogMessage:o=>a(this,S).emit("log",o)}),this.storage.events.on("scoresUpdated",C(this,F,bt).bind(this)),a(this,z)||C(this,F,bt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,O),state:a(this,P),previousState:a(this,P),visitor:this.storage.data});this.storage.updateData(u),a(this,S).emit("quirksUpdated",o.quirks),a(this,S).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,S).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,O)}async update(t){var i;let r=[];try{a(this,S).emit("log",["info",2,"GROUP",{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&r.push(...Object.entries(t.quirks).map(([n,s])=>({type:"setquirk",data:{key:n,value:s}}))),t.enrichments&&t.enrichments.forEach(n=>{let s=et(n.cat,n.key);this.manifest.getDimensionByKey(s)?r.push({type:"modscore",data:{dimension:s,delta:n.str}}):a(this,S).emit("log",["warn",5,n])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,P),visitor:this.storage.data,scores:a(this,O)})),v(this,P,{...a(this,P),...t}),await this.storage.updateData(r),a(this,z)&&(C(this,F,bt).call(this,this.storage.data),v(this,z,!1),a(this,S).emit("log",["debug",131]))}finally{a(this,S).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var i;let r=this.manifest.getTest(t);return r?(i=r.wv)!=null?i:this.storage.data.tests[t]:(a(this,S).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,S).emit("log",t)}test(t){var i,n;let r=xt({...t,context:this,onLogMessage:s=>a(this,S).emit("log",s)});return a(this,S).emit("testResult",{name:t.name,variantId:(n=(i=r.result)==null?void 0:i.id)!=null?n:void 0,variantAssigned:r.variantAssigned}),r}personalize(t){let r=Zt({...t,context:this,onLogMessage:s=>a(this,S).emit("log",s)}),i=a(this,M)[t.name],n={name:t.name,variantIds:r.variations.map(s=>{var o;return(o=s.id)!=null?o:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return i&&te(n.variantIds,i)&&(n.changed=!1),a(this,S).emit("personalizationResult",n),a(this,M)[t.name]=n.variantIds,r}async forget(t){v(this,P,{}),await this.storage.delete(t)}};z=new WeakMap,O=new WeakMap,P=new WeakMap,M=new WeakMap,S=new WeakMap,F=new WeakSet,bt=function(t){var n;let r={...t.scores};for(let s in t.sessionScores)r[s]=((n=r[s])!=null?n:0)+t.sessionScores[s];r=this.manifest.computeAggregateDimensions(r),!te(r,a(this,O))&&(v(this,O,r),a(this,S).emit("scoresUpdated",r),a(this,S).emit("log",["info",3,r]))};l();import Ce from"rfdc";l();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}}var xe=Ce();function be(e){return([t,...r])=>{if(!ut(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
2
+ `,...n.map(xe))}}function li(e){return{logDrain:be(e)}}l();l();var ee={1:()=>["context","initializing Uniform Context"],2:e=>["context","received 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",`deleting visitor data ${e?"from all devices":"from this device"}`],104:e=>["context",e?"Visitor assigned to personalization control group":"Visitor assigned to personalization experiment group"],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"],140:e=>["storage",`score decay was applied: ${e}`],200:()=>["signals","evaluating signals"],201:e=>["signals",`evaluating signal ${e.id} (${e.dur})`],202:e=>["signals",e.op==="|"?"OR":"AND"],203:({criteria:e,result:t,explanation:r})=>["signals",`${e.type}: ${r} is ${t.result} [${t.changed?"CHANGED":"unchanged"}]`],204:e=>["signals",`group result: ${e.result} [${e.changed?"CHANGED":"unchanged"}]`],300:e=>["personalization",`executing personalization '${e.name}'`],301:({id:e,op:t})=>["personalization",`testing variation ${e} (${t==="|"?"OR":"AND"})`],302:({matched:e,description:t})=>["personalization",`${t} is ${e}`],303:e=>["personalization",e?"selected variation":"did not select variation"],400:e=>["testing",`executing A/B test '${e}'`],401:e=>["testing",`${e} is not registered in the manifest; it will not be run.`],402:({missingVariant:e,variants:t})=>["testing",`test variation '${e}' previously assigned to the visitor for this test no longer exists as a variant. It will be removed. This may indicate changing test variations after publishing a test, which will make results invalid. Known variants: ${t.join(", ")}`],403:e=>["testing",`assigned new test variant '${e}'`],404:e=>["testing",`displaying variation '${e}'`],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"]};import Ve from"rfdc";var Ee=Ve();function Te(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!ut(e,n)||r&&!i)return;let[o,...u]=s,d=console[n];if(u[0]==="GROUP"&&(u.shift(),d=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let c=ee[o],h="";switch(n){case"debug":h="\u{1F41E}";break;case"info":h="\u{1F4AC}";break;case"warn":h="\u26A0\uFE0F";break;case"error":h="\u{1F4A5}";break}let g=h;if(!c){d(`${g} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[D,b,...L]=c(...u);d(`${g}[${D}] ${b}
3
+ `,...L.map(Ee))}}function hi(e,t){return{logDrain:Te(e,t)}}l();var ke=(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))(ke||{}),vi="nesitag";l();var Vt=typeof top!="undefined";function yi(){return{logDrain:e=>{!Vt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!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)},n=o=>{!o.changed||(t.push(o),i())},s=o=>{!o.variantAssigned||(r.push(o),i())};if(Vt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Pe(u,e)})}catch(o){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",o)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),i()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),e.storage.events.on("*",i),()=>{e.storage.events.off("*",i),e.events.off("personalizationResult",n),e.events.off("testResult",s)}}}}async function Pe(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)}export{De as Context,ue as CookieTransitionDataStore,vi as EdgeNodeTagName,de as EdgeTransitionDataStore,H as GroupCriteriaEvaluator,ct as ManifestInstance,se as SERVER_STATE_ID,ke as ScriptType,Y as TransitionDataStore,ae as UNIFORM_DEFAULT_COOKIE_NAME,Ct as VisitorDataStore,Pt as computeAggregateDimensions,Ut as cookieEvaluator,be as createConsoleLogDrain,Te as createDebugConsoleLogDrain,Vr as createLinearDecay,It as currentPageEvaluator,rt as emptyVisitorData,li as enableConsoleLogDrain,yi as enableContextDevTools,hi as enableDebugConsoleLogDrain,Mt as evaluateVariantMatch,zt as eventEvaluator,U as explainStringMatch,dt as explainStringMatchCriteria,et as getEnrichmentVectorKey,T as isStringMatch,ft as pageViewCountDimension,pt as pageViewCountEvaluator,Zt as personalizeVariations,Nt as queryStringEvaluator,Gt as quirkEvaluator,xt as testVariations};
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
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});
1
+ var Ce=Object.create;var K=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Te=(e,t,r)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var It=e=>K(e,"__esModule",{value:!0});var ke=(e,t)=>{for(var r in t)K(e,r,{get:t[r],enumerable:!0})},qt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of be(t))!Ee.call(e,n)&&(r||n!=="default")&&K(e,n,{get:()=>t[n],enumerable:!(i=xe(t,n))||i.enumerable});return e},$=(e,t)=>qt(It(K(e!=null?Ce(Ve(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=qt(It({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var D=(e,t,r)=>(Te(e,typeof t!="symbol"?t+"":t,r),r),gt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var a=(e,t,r)=>(gt(e,t,"read from private field"),r?r.call(e):t.get(e)),d=(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)},h=(e,t,r,i)=>(gt(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);var y=(e,t,r)=>(gt(e,t,"access private method"),r);var Be={};ke(Be,{Context:()=>me,CookieTransitionDataStore:()=>ee,EdgeNodeTagName:()=>Fe,EdgeTransitionDataStore:()=>oe,GroupCriteriaEvaluator:()=>z,ManifestInstance:()=>nt,SERVER_STATE_ID:()=>Yt,ScriptType:()=>De,TransitionDataStore:()=>q,UNIFORM_DEFAULT_COOKIE_NAME:()=>te,VisitorDataStore:()=>pt,computeAggregateDimensions:()=>vt,cookieEvaluator:()=>yt,createConsoleLogDrain:()=>ge,createDebugConsoleLogDrain:()=>ye,createLinearDecay:()=>$e,currentPageEvaluator:()=>bt,emptyVisitorData:()=>X,enableConsoleLogDrain:()=>qe,enableContextDevTools:()=>Qe,enableDebugConsoleLogDrain:()=>je,evaluateVariantMatch:()=>Ot,eventEvaluator:()=>xt,explainStringMatch:()=>k,explainStringMatchCriteria:()=>ot,getEnrichmentVectorKey:()=>Y,isStringMatch:()=>x,pageViewCountDimension:()=>st,pageViewCountEvaluator:()=>at,personalizeVariations:()=>Rt,queryStringEvaluator:()=>Dt,quirkEvaluator:()=>Ct,testVariations:()=>mt});function vt(e,t){let r={...e};for(let i in t){let n=_t(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function _t(e,t,r,i){var s;let n=0;for(let o of r[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&r[o.dim]){if(i.has(o.dim))continue;let l=new Set(i);l.add(o.dim),u=_t(e,o.dim,r,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.sign==="-"?n-=u:n+=u}return n}var it="_";var B,H,St=class{constructor(t,r,i){d(this,B,void 0);d(this,H,void 0);D(this,"signal");this.signal=t,h(this,B,r),h(this,H,i)}computeSignal(t,r){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,B).evaluate(t,this.signal.crit,r,this.signal,a(this,H)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)r.push({type:s,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let o=t.visitor.sessionScores[this.signal.id];o&&r.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};B=new WeakMap,H=new WeakMap;var V,J,R,nt=class{constructor({manifest:t,evaluator:r=new z({}),onLogMessage:i=()=>{}}){D(this,"data");d(this,V,void 0);d(this,J,void 0);d(this,R,void 0);var n,s,o;h(this,V,(n=t.project)!=null?n:{}),this.data=t,h(this,J,Object.entries((o=(s=a(this,V).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new St({...c,id:u},r,i))),h(this,R,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,V).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,V).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,R).call(this,["debug",200,"GROUP"]);try{a(this,J).forEach(i=>{a(this,R).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,R).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,R).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return vt(t,(i=(r=a(this,V).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(it);return r<=0?(n=(i=a(this,V).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,V).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};V=new WeakMap,J=new WeakMap,R=new WeakMap;var Qt=require("dequal/lite");function x(e,t){var o,u,c,l,p,m;let r=(o=t==null?void 0:t.op)!=null?o:"=";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 i=(u=t.cs)!=null?u:!1,n=(i?e!=null?e:"":jt(e)).toString(),s=(i?t.rhs:jt(t.rhs)).toString();switch(r){case"=":return n===s;case"!=":return n!==s;case"~":return(c=n.includes(s))!=null?c:!1;case"!~":return!((l=n.includes(s))==null||l);case"//":return new RegExp(t.rhs.toString(),i?"":"i").test((p=e==null?void 0:e.toString())!=null?p:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");default:throw new Error(`Unknown match type ${r}.`)}}function k(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${ot(t)}`}function ot(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function jt(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var yt=({update:e,criteria:t,onLogMessage:r})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let i=!(0,Qt.dequal)(Ft(e.state.cookies),Ft((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:x(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:k(n,t.match)}]),o};function Ft(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}function Kt(e,t){var i;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((i=t==null?void 0:t.op)!=null?i:"="){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 Bt(e,t){return`${e} ${we(t)}`}function we(e){return`${e.op} ${e.rhs}`}function Y(e,t){return`${e}${it}${t}`}var st=Y("$pvc","v"),at=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var l,p;if(t.type!=="PVC")return{result:!1,changed:!1};let n=Boolean(e.state.url&&(!e.previousState||((l=e.state.url)==null?void 0:l.toString())!==((p=e.previousState.url)==null?void 0:p.toString()))),o=(e.visitor.sessionScores[st]||0)+1,u={result:!1,changed:n},c=r.some(m=>m.type==="modscoreS"&&m.data.dimension===st);return n&&!c&&r.push({type:"modscoreS",data:{dimension:st,delta:1}}),Kt(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:Bt(o,t.match)}]),u};at.alwaysExecute=!0;var Dt=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l,p,m;if(t.type!=="QS")return{result:!1,changed:!1};let i=!e.previousState||((c=(u=e.state.url)==null?void 0:u.searchParams)==null?void 0:c.toString())!==((p=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:p.toString()),n=(m=e.state.url)==null?void 0:m.searchParams.get(t.queryName),o={result:x(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:k(n,t.match)}]),o};var Ct=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var p;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&r.dur==="t"&&e.scores[r.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],s=(p=e.state.quirks)==null?void 0:p[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:x(o,t.match),changed:u};return i==null||i(["debug",203,{criteria:t,result:l,explanation:k(o,t.match)}]),l};var xt=({update:e,criteria:t,onLogMessage:r})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let i=(o=(s=e.state.events)==null?void 0:s.some(c=>x(c.event,t.event)))!=null?o:!1,n={result:i,changed:i};return r==null||r(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${ot(t.event)}`}]),n};var bt=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let i=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(i==null?void 0:i.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),o={result:x(i,t.path),changed:n};return r==null||r(["debug",203,{criteria:t,result:o,explanation:k(i,t.path)}]),o};var W,z=class{constructor(t){d(this,W,void 0);h(this,W,t)}evaluate(t,r,i,n,s){let o=r.clauses.length>1;o&&(s==null||s(["debug",202,"GROUP",r]));try{let u=!(r.op==="&"||!r.op),c=null,l=!1;for(let m of r.clauses){let S;if(m.type==="G")S=this.evaluate(t,m,i,n,s);else{let C=a(this,W)[m.type];if(c&&!C.alwaysExecute)continue;if(!C)throw new Error(`${m.type} signal criteria not registered`);S=C({update:t,criteria:m,commands:i,signal:n,onLogMessage:s})}S.changed&&(l=!0),!c&&S.result===u&&(c={result:u,changed:l})}let p=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,p])),p}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};W=new WeakMap;var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Ht=$(require("mitt")),Jt=require("dequal/lite"),Yt="__UNIFORM_DATA__",O,I,q=class{constructor({initialData:t}){d(this,O,void 0);d(this,I,(0,Ht.default)());D(this,"events",{on:a(this,I).on,off:a(this,I).off});t&&h(this,O,t)}get data(){return a(this,O)}updateData(t,r){return h(this,O,r),this.handleUpdateData(t,r)}async delete(t){h(this,O,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,Jt.dequal)(this.data,t)||(h(this,O,t),a(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Yt);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};O=new WeakMap,I=new WeakMap;var Vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wt=Vt.split(""),Xt=new Array(123);for(let e=0;e<Vt.length;e++)Xt[Vt.charCodeAt(e)]=e;var Et=e=>{if(e<0)return`-${Et(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=Wt[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=Wt[63&t]+n,t>>>=6;while(t>0);return n+i},Zt=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+Xt[e.charCodeAt(i)];return r?-t:t};var ut=$(require("js-cookie")),Tt=typeof document=="undefined",te="ufvd",A,Z,ee=class extends q{constructor({serverCookieValue:t,cookieName:r=te,cookieAttributes:i={sameSite:"lax"}}){super({initialData:Tt?Re(t):void 0});d(this,A,void 0);d(this,Z,void 0);h(this,A,r),h(this,Z,i)}handleDelete(){return Tt||ut.default.remove(a(this,A)),Promise.resolve()}async handleUpdateData(t,r){Tt||(r.consent?ut.default.set(a(this,A),Oe(r),a(this,Z)):ut.default.remove(a(this,A)))}};A=new WeakMap,Z=new WeakMap;var re="~",ie="!",ne="-";function Re(e){if(!e)return;let t=e.split(re);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:Mt(kt(i)),scores:Mt(kt(n)),tests:kt(r)}}function kt(e){return e.split(ie).map(r=>r.split(ne)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function Mt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=Zt(i),t),{})}function Oe(e){return[Pt(e.tests),Pt(Lt(e.sessionScores)),Pt(Lt(e.scores))].join(re)}function Lt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=Et(i),t),{})}function Pt(e){return Object.entries(e).map(t=>t.join(ne)).join(ie)}var lt,Ue,oe=class extends q{constructor({serverCookieValue:t,visitorIdCookieName:r="ufvi",...i}){super(i);d(this,lt);i.initialData||y(this,lt,Ue).call(this).catch(n=>{console.error(n)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let r=await new Promise(i=>{setTimeout(()=>{i(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};lt=new WeakSet,Ue=async function(){let t=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};function $e(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:i=.95}=e!=null?e:{};return function({now:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let m=s-o-t;if(m<=0)return!1;let S=m/864e5,C=1-Math.min(i,S*r);return C<=0?!1:(se(u,C),se(c,C),l==null||l(["info",140,`linear decay factor ${C.toPrecision(6)}`]),!0)}}function se(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}var de=$(require("mitt")),M=require("dequal/lite");var wt=class{constructor(){D(this,"inMemoryFallback",{});D(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let i=localStorage.getItem(t);return i?JSON.parse(i):void 0}catch(i){return r}}set(t,r,i){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!i))try{localStorage.setItem(t,JSON.stringify(r))}catch(n){console.warn(n)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(i){}}};var ae=$(require("rfdc"));var Ae=(0,ae.default)();function ue(e,t,r){let i=t?Ae(t):X();return e.forEach(n=>{var s,o;switch(n.type){case"consent":i.consent=n.data;break;case"setquirk":i.quirks[n.data.key]=n.data.value;break;case"settest":i.tests[n.data.test]=n.data.variant;break;case"modscore":if(r)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(s=i.scores[n.data.dimension])!=null?s:0;i.scores[n.data.dimension]=c+u;break;case"modscoreS":if(r)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let p=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=p+l;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var ct="ufvisitor",E,N,j,v,b,U,P,_,dt,Ne,ft,Ge,L,le,tt,ce,pt=class{constructor(t){d(this,b);d(this,P);d(this,dt);d(this,ft);d(this,L);d(this,tt);d(this,E,(0,de.default)());d(this,N,new wt);d(this,j,void 0);d(this,v,void 0);D(this,"events",{on:a(this,E).on,off:a(this,E).off});if(h(this,v,t),a(this,b,U)||y(this,P,_).call(this,y(this,tt,ce).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();if(r){let n=[];r.quirks&&n.push(...Object.entries(r.quirks).map(([s,o])=>({type:"setquirk",data:{key:s,value:o}}))),r.tests&&n.push(...Object.entries(r.tests).map(([s,o])=>({type:"settest",data:{test:s,variant:o}}))),this.updateData(n),r.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(r.ssv)}t.transitionStore.events.on("dataUpdatedAsync",n=>{y(this,P,_).call(this,{...a(this,b,U).visitorData,...n})});let i=t.transitionStore.data;i&&y(this,P,_).call(this,{...a(this,b,U).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,b,U);if(y(this,ft,Ge).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return y(this,P,_).call(this,{...s,sessionScores:{}}),(i=(r=a(this,v)).onLogMessage)==null||i.call(r,["info",120]),a(this,b,U).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,v).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,v)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=ue(t,this.data,(s=a(this,b,U))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,N).delete(ct,!0),y(this,P,_).call(this,r),await((o=a(this,v).transitionStore)==null?void 0:o.updateData(t,a(this,b,U).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,v)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,N).delete(ct,!1),await((n=a(this,v).transitionStore)==null?void 0:n.delete(t)),y(this,P,_).call(this,y(this,tt,ce).call(this))}finally{(o=(s=a(this,v)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};E=new WeakMap,N=new WeakMap,j=new WeakMap,v=new WeakMap,b=new WeakSet,U=function(){return a(this,N).get(ct)},P=new WeakSet,_=function(t,r=!1){var p,m,S,C,rt,Nt,Gt,zt;let i=a(this,b,U),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(y(this,L,le).call(this,t.scores),y(this,L,le).call(this,t.sessionScores),(m=(p=a(this,v)).decay)==null||m.call(p,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,v).onLogMessage}));let s=!(0,M.dequal)(i==null?void 0:i.visitorData.scores,t.scores),o=!(0,M.dequal)(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!(0,M.dequal)(i==null?void 0:i.visitorData.quirks,t.quirks),c=!(0,M.dequal)(i==null?void 0:i.visitorData.tests,t.tests),l={updated:n,visitorData:t};y(this,dt,Ne).call(this),a(this,N).set(ct,l,!!t.consent),(C=(S=a(this,v)).onLogMessage)==null||C.call(S,["debug",102,t]),r||((s||o)&&a(this,E).emit("scoresUpdated",t),u&&a(this,E).emit("quirksUpdated",t),c&&a(this,E).emit("testsUpdated",t),((rt=i==null?void 0:i.visitorData)==null?void 0:rt.consent)!==t.consent&&a(this,E).emit("consentUpdated",t),((Nt=i==null?void 0:i.visitorData)==null?void 0:Nt.controlGroup)!==t.controlGroup&&(a(this,E).emit("controlGroupUpdated",t),(zt=(Gt=a(this,v)).onLogMessage)==null||zt.call(Gt,["debug",104,t.controlGroup])))},dt=new WeakSet,Ne=function(){typeof document=="undefined"||!a(this,v).visitLifespan||(a(this,j)&&window.clearTimeout(a(this,j)),h(this,j,window.setTimeout(()=>{this.data},a(this,v).visitLifespan+50)))},ft=new WeakSet,Ge=function(t){let r=a(this,v).visitLifespan;return r?t.updated+r<Date.now():!1},L=new WeakSet,le=function(t){var r,i;if(!!a(this,v).manifest)for(let n in t){let s=t[n],o=a(this,v).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,v)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},tt=new WeakSet,ce=function(){var t,r,i;return{...X(),consent:(t=a(this,v).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,v).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};var pe=$(require("mitt"));function Rt({name:e,context:t,variations:r,take:i=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:i}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],p=!1,m=t.scores;for(let S of r){if(l.length===i)break;if(!((o=S.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:S.id,op:(u=S.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(S);continue}c||Ot(S.id,S.pz,m,n)&&(p=!0,l.push(S))}return{personalized:p,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function Ot(e,t,r,i){i==null||i(["info",301,"GROUP",{id:e,op:t==null?void 0:t.op}]);let n;try{t!=null&&t.crit?!t.op||t.op==="&"?n=t.crit.every(s=>fe(s,r,i)):n=t.crit.some(s=>fe(s,r,i)):(i==null||i(["info",302,{matched:!0,description:"default variation"}]),n=!0),i==null||i(["info",303,n])}finally{i==null||i(["info",301,"ENDGROUP"])}return n}function fe(e,t,r){var u,c;let{op:i,l:n}=e,s=(u=t[n])!=null?u:0;if(i==="+"){let l=Math.max(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(i==="-"){let l=Math.min(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let o=e.rDim?t[e.rDim]:e.r;if(o===void 0)return r==null||r(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(i===">"){let l=s>o;return F(r,l,e,s,o),l}else if(i===">="){let l=s>=o;return F(r,l,e,s,o),l}else if(i==="<"){let l=s<o;return F(r,l,e,s,o),l}else if(i==="<="){let l=s<=o;return F(r,l,e,s,o),l}else if(i==="="){let l=s===o;return F(r,l,e,s,o),l}else if(i==="!="){let l=s!==o;return F(r,l,e,s,o),l}else throw new Error(`Unknown op: ${i}`)}function F(e,t,r,i,n){e==null||e(["info",302,{matched:t,description:`${r.l}[${i}] ${r.op} ${r.rDim?`${r.rDim}[${n}]`:r.r}`}])}var ze=e=>{let{values:t,total:r,missingDistribution:i}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.testDistribution),n),{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)/i;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},mt=({name:e,context:t,variations:r,onLogMessage:i})=>{i==null||i(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return i==null||i(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=r.find(o=>o.id===s),n||i==null||i(["warn",402,{missingVariant:s,variants:r.map(o=>o.id)}])),!n){let o=ze(r),u=Math.floor(Math.random()*100),c=0;n=r.find((l,p)=>{let m=o[p];if(u>c&&u<=c+m)return l;c+=m}),n&&(i==null||i(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(i==null||i(["info",404,n.id])),{result:n,variantAssigned:!s}}finally{i==null||i(["info",400,"ENDGROUP"])}};var $t=require("dequal/lite"),G,w,T,et,g,Q,Ut,me=class{constructor(t){d(this,Q);D(this,"manifest");d(this,G,!1);d(this,w,{});d(this,T,void 0);d(this,et,{});d(this,g,(0,pe.default)());D(this,"events",{on:a(this,g).on,off:a(this,g).off});D(this,"storage");var n,s;let{manifest:r,...i}=t;h(this,T,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,g).on("log",o.logDrain)}),a(this,g).emit("log",["info",1,"GROUP"]);try{this.manifest=new nt({onLogMessage:o=>a(this,g).emit("log",o),manifest:r,evaluator:new z({CK:yt,QS:Dt,QK:Ct,PVC:at,EVT:xt,PV:bt})}),this.storage=new pt({...i,manifest:this.manifest,onServerTransitionScoresReceived:o=>{h(this,w,o),h(this,G,!0),a(this,g).emit("log",["debug",130,o])},onLogMessage:o=>a(this,g).emit("log",o)}),this.storage.events.on("scoresUpdated",y(this,Q,Ut).bind(this)),a(this,G)||y(this,Q,Ut).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,w),state:a(this,T),previousState:a(this,T),visitor:this.storage.data});this.storage.updateData(u),a(this,g).emit("quirksUpdated",o.quirks),a(this,g).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,g).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,w)}async update(t){var i;let r=[];try{a(this,g).emit("log",["info",2,"GROUP",{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&r.push(...Object.entries(t.quirks).map(([n,s])=>({type:"setquirk",data:{key:n,value:s}}))),t.enrichments&&t.enrichments.forEach(n=>{let s=Y(n.cat,n.key);this.manifest.getDimensionByKey(s)?r.push({type:"modscore",data:{dimension:s,delta:n.str}}):a(this,g).emit("log",["warn",5,n])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,T),visitor:this.storage.data,scores:a(this,w)})),h(this,T,{...a(this,T),...t}),await this.storage.updateData(r),a(this,G)&&(y(this,Q,Ut).call(this,this.storage.data),h(this,G,!1),a(this,g).emit("log",["debug",131]))}finally{a(this,g).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var i;let r=this.manifest.getTest(t);return r?(i=r.wv)!=null?i:this.storage.data.tests[t]:(a(this,g).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,g).emit("log",t)}test(t){var i,n;let r=mt({...t,context:this,onLogMessage:s=>a(this,g).emit("log",s)});return a(this,g).emit("testResult",{name:t.name,variantId:(n=(i=r.result)==null?void 0:i.id)!=null?n:void 0,variantAssigned:r.variantAssigned}),r}personalize(t){let r=Rt({...t,context:this,onLogMessage:s=>a(this,g).emit("log",s)}),i=a(this,et)[t.name],n={name:t.name,variantIds:r.variations.map(s=>{var o;return(o=s.id)!=null?o:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return i&&(0,$t.dequal)(n.variantIds,i)&&(n.changed=!1),a(this,g).emit("personalizationResult",n),a(this,et)[t.name]=n.variantIds,r}async forget(t){h(this,T,{}),await this.storage.delete(t)}};G=new WeakMap,w=new WeakMap,T=new WeakMap,et=new WeakMap,g=new WeakMap,Q=new WeakSet,Ut=function(t){var n;let r={...t.scores};for(let s in t.sessionScores)r[s]=((n=r[s])!=null?n:0)+t.sessionScores[s];r=this.manifest.computeAggregateDimensions(r),!(0,$t.dequal)(r,a(this,w))&&(h(this,w,r),a(this,g).emit("scoresUpdated",r),a(this,g).emit("log",["info",3,r]))};var he=$(require("rfdc"));function ht(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}}var Ie=(0,he.default)();function ge(e){return([t,...r])=>{if(!ht(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
2
+ `,...n.map(Ie))}}function qe(e){return{logDrain:ge(e)}}var ve={1:()=>["context","initializing Uniform Context"],2:e=>["context","received 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",`deleting visitor data ${e?"from all devices":"from this device"}`],104:e=>["context",e?"Visitor assigned to personalization control group":"Visitor assigned to personalization experiment group"],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"],140:e=>["storage",`score decay was applied: ${e}`],200:()=>["signals","evaluating signals"],201:e=>["signals",`evaluating signal ${e.id} (${e.dur})`],202:e=>["signals",e.op==="|"?"OR":"AND"],203:({criteria:e,result:t,explanation:r})=>["signals",`${e.type}: ${r} is ${t.result} [${t.changed?"CHANGED":"unchanged"}]`],204:e=>["signals",`group result: ${e.result} [${e.changed?"CHANGED":"unchanged"}]`],300:e=>["personalization",`executing personalization '${e.name}'`],301:({id:e,op:t})=>["personalization",`testing variation ${e} (${t==="|"?"OR":"AND"})`],302:({matched:e,description:t})=>["personalization",`${t} is ${e}`],303:e=>["personalization",e?"selected variation":"did not select variation"],400:e=>["testing",`executing A/B test '${e}'`],401:e=>["testing",`${e} is not registered in the manifest; it will not be run.`],402:({missingVariant:e,variants:t})=>["testing",`test variation '${e}' previously assigned to the visitor for this test no longer exists as a variant. It will be removed. This may indicate changing test variations after publishing a test, which will make results invalid. Known variants: ${t.join(", ")}`],403:e=>["testing",`assigned new test variant '${e}'`],404:e=>["testing",`displaying variation '${e}'`],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"]};var Se=$(require("rfdc")),_e=(0,Se.default)();function ye(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!ht(e,n)||r&&!i)return;let[o,...u]=s,c=console[n];if(u[0]==="GROUP"&&(u.shift(),c=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let l=ve[o],p="";switch(n){case"debug":p="\u{1F41E}";break;case"info":p="\u{1F4AC}";break;case"warn":p="\u26A0\uFE0F";break;case"error":p="\u{1F4A5}";break}let m=p;if(!l){c(`${m} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[S,C,...rt]=l(...u);c(`${m}[${S}] ${C}
3
+ `,...rt.map(_e))}}function je(e,t){return{logDrain:ye(e,t)}}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||{}),Fe="nesitag";var At=typeof top!="undefined";function Qe(){return{logDrain:e=>{!At||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!At||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)},n=o=>{!o.changed||(t.push(o),i())},s=o=>{!o.variantAssigned||(r.push(o),i())};if(At){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Ke(u,e)})}catch(o){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",o)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),i()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),e.storage.events.on("*",i),()=>{e.storage.events.off("*",i),e.events.off("personalizationResult",n),e.events.off("testResult",s)}}}}async function Ke(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(Be);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,explainStringMatch,explainStringMatchCriteria,getEnrichmentVectorKey,isStringMatch,pageViewCountDimension,pageViewCountEvaluator,personalizeVariations,queryStringEvaluator,quirkEvaluator,testVariations});
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
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};
1
+ import{a as tt}from"./chunk-CEKV2MHL.mjs";import{d as x,e as a,f,g as v,h as C,i as l}from"./chunk-AFJ7PNM5.mjs";l();l();l();function Pt(e,t){let r={...e};for(let i in t){let n=wt(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function wt(e,t,r,i){var s;let n=0;for(let o of r[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&r[o.dim]){if(i.has(o.dim))continue;let c=new Set(i);c.add(o.dim),u=wt(e,o.dim,r,c)}if(u!==0)if(o.sign==="c"){n=0;break}else o.sign==="-"?n-=u:n+=u}return n}l();var Q,K,lt=class{constructor(t,r,i){f(this,Q,void 0);f(this,K,void 0);x(this,"signal");this.signal=t,v(this,Q,r),v(this,K,i)}computeSignal(t,r){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,Q).evaluate(t,this.signal.crit,r,this.signal,a(this,K)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)r.push({type:s,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let o=t.visitor.sessionScores[this.signal.id];o&&r.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};Q=new WeakMap,K=new WeakMap;var E,B,R,ct=class{constructor({manifest:t,evaluator:r=new H({}),onLogMessage:i=()=>{}}){x(this,"data");f(this,E,void 0);f(this,B,void 0);f(this,R,void 0);var n,s,o;v(this,E,(n=t.project)!=null?n:{}),this.data=t,v(this,B,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,d])=>new lt({...d,id:u},r,i))),v(this,R,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,E).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,E).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,R).call(this,["debug",200,"GROUP"]);try{a(this,B).forEach(i=>{a(this,R).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,R).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,R).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return Pt(t,(i=(r=a(this,E).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(tt);return r<=0?(n=(i=a(this,E).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};E=new WeakMap,B=new WeakMap,R=new WeakMap;l();import{dequal as re}from"dequal/lite";l();function T(e,t){var o,u,d,c,h,g;let r=(o=t==null?void 0:t.op)!=null?o:"=";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 i=(u=t.cs)!=null?u:!1,n=(i?e!=null?e:"":Ot(e)).toString(),s=(i?t.rhs:Ot(t.rhs)).toString();switch(r){case"=":return n===s;case"!=":return n!==s;case"~":return(d=n.includes(s))!=null?d:!1;case"!~":return!((c=n.includes(s))==null||c);case"//":return new RegExp(t.rhs.toString(),i?"":"i").test((h=e==null?void 0:e.toString())!=null?h:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((g=e==null?void 0:e.toString())!=null?g:"");default:throw new Error(`Unknown match type ${r}.`)}}function U(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${dt(t)}`}function dt(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Ot(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var Ut=({update:e,criteria:t,onLogMessage:r})=>{var u,d;if(t.type!=="CK")return{result:!1,changed:!1};let i=!re(Rt(e.state.cookies),Rt((u=e.previousState)==null?void 0:u.cookies)),n=(d=e.state.cookies)==null?void 0:d[t.cookieName],o={result:T(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:U(n,t.match)}]),o};function Rt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}l();l();function $t(e,t){var i;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((i=t==null?void 0:t.op)!=null?i:"="){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 At(e,t){return`${e} ${ie(t)}`}function ie(e){return`${e.op} ${e.rhs}`}l();function et(e,t){return`${e}${tt}${t}`}var ft=et("$pvc","v"),pt=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var c,h;if(t.type!=="PVC")return{result:!1,changed:!1};let n=Boolean(e.state.url&&(!e.previousState||((c=e.state.url)==null?void 0:c.toString())!==((h=e.previousState.url)==null?void 0:h.toString()))),o=(e.visitor.sessionScores[ft]||0)+1,u={result:!1,changed:n},d=r.some(g=>g.type==="modscoreS"&&g.data.dimension===ft);return n&&!d&&r.push({type:"modscoreS",data:{dimension:ft,delta:1}}),$t(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:At(o,t.match)}]),u};pt.alwaysExecute=!0;l();var Nt=({update:e,criteria:t,onLogMessage:r})=>{var u,d,c,h,g;if(t.type!=="QS")return{result:!1,changed:!1};let i=!e.previousState||((d=(u=e.state.url)==null?void 0:u.searchParams)==null?void 0:d.toString())!==((h=(c=e.previousState.url)==null?void 0:c.searchParams)==null?void 0:h.toString()),n=(g=e.state.url)==null?void 0:g.searchParams.get(t.queryName),o={result:T(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:U(n,t.match)}]),o};l();var Gt=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var h;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&r.dur==="t"&&e.scores[r.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],s=(h=e.state.quirks)==null?void 0:h[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),c={result:T(o,t.match),changed:u};return i==null||i(["debug",203,{criteria:t,result:c,explanation:U(o,t.match)}]),c};l();var zt=({update:e,criteria:t,onLogMessage:r})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let i=(o=(s=e.state.events)==null?void 0:s.some(d=>T(d.event,t.event)))!=null?o:!1,n={result:i,changed:i};return r==null||r(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${dt(t.event)}`}]),n};l();var It=({update:e,criteria:t,onLogMessage:r})=>{var u,d,c;if(t.type!=="PV")return{result:!1,changed:!1};let i=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(i==null?void 0:i.toString())!==((c=(d=e.previousState.url)==null?void 0:d.pathname)==null?void 0:c.toString()),o={result:T(i,t.path),changed:n};return r==null||r(["debug",203,{criteria:t,result:o,explanation:U(i,t.path)}]),o};l();var J,H=class{constructor(t){f(this,J,void 0);v(this,J,t)}evaluate(t,r,i,n,s){let o=r.clauses.length>1;o&&(s==null||s(["debug",202,"GROUP",r]));try{let u=!(r.op==="&"||!r.op),d=null,c=!1;for(let g of r.clauses){let D;if(g.type==="G")D=this.evaluate(t,g,i,n,s);else{let b=a(this,J)[g.type];if(d&&!b.alwaysExecute)continue;if(!b)throw new Error(`${g.type} signal criteria not registered`);D=b({update:t,criteria:g,commands:i,signal:n,onLogMessage:s})}D.changed&&(c=!0),!d&&D.result===u&&(d={result:u,changed:c})}let h=d!=null?d:{result:!u,changed:c};return o&&(s==null||s(["debug",204,h])),h}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};J=new WeakMap;l();var rt=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});l();l();import ne from"mitt";import{dequal as oe}from"dequal/lite";var se="__UNIFORM_DATA__",$,I,Y=class{constructor({initialData:t}){f(this,$,void 0);f(this,I,ne());x(this,"events",{on:a(this,I).on,off:a(this,I).off});t&&v(this,$,t)}get data(){return a(this,$)}updateData(t,r){return v(this,$,r),this.handleUpdateData(t,r)}async delete(t){v(this,$,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){oe(this.data,t)||(v(this,$,t),a(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(se);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};$=new WeakMap,I=new WeakMap;l();var mt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qt=mt.split(""),_t=new Array(123);for(let e=0;e<mt.length;e++)_t[mt.charCodeAt(e)]=e;var ht=e=>{if(e<0)return`-${ht(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=qt[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=qt[63&t]+n,t>>>=6;while(t>0);return n+i},jt=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+_t[e.charCodeAt(i)];return r?-t:t};import gt from"js-cookie";var vt=typeof document=="undefined",ae="ufvd",N,W,ue=class extends Y{constructor({serverCookieValue:t,cookieName:r=ae,cookieAttributes:i={sameSite:"lax"}}){super({initialData:vt?le(t):void 0});f(this,N,void 0);f(this,W,void 0);v(this,N,r),v(this,W,i)}handleDelete(){return vt||gt.remove(a(this,N)),Promise.resolve()}async handleUpdateData(t,r){vt||(r.consent?gt.set(a(this,N),ce(r),a(this,W)):gt.remove(a(this,N)))}};N=new WeakMap,W=new WeakMap;var Kt="~",Bt="!",Ht="-";function le(e){if(!e)return;let t=e.split(Kt);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:Ft(St(i)),scores:Ft(St(n)),tests:St(r)}}function St(e){return e.split(Bt).map(r=>r.split(Ht)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function Ft(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=jt(i),t),{})}function ce(e){return[yt(e.tests),yt(Qt(e.sessionScores)),yt(Qt(e.scores))].join(Kt)}function Qt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=ht(i),t),{})}function yt(e){return Object.entries(e).map(t=>t.join(Ht)).join(Bt)}l();var it,fe,de=class extends Y{constructor({serverCookieValue:t,visitorIdCookieName:r="ufvi",...i}){super(i);f(this,it);i.initialData||C(this,it,fe).call(this).catch(n=>{console.error(n)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let r=await new Promise(i=>{setTimeout(()=>{i(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};it=new WeakSet,fe=async function(){let t=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};l();function Vr(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:i=.95}=e!=null?e:{};return function({now:s,lastUpd:o,scores:u,sessionScores:d,onLogMessage:c}){if(typeof o!="number")return!1;let g=s-o-t;if(g<=0)return!1;let D=g/864e5,b=1-Math.min(i,D*r);return b<=0?!1:(Jt(u,b),Jt(d,b),c==null||c(["info",140,`linear decay factor ${b.toPrecision(6)}`]),!0)}}function Jt(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}l();import he from"mitt";import{dequal as nt}from"dequal/lite";l();var Dt=class{constructor(){x(this,"inMemoryFallback",{});x(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let i=localStorage.getItem(t);return i?JSON.parse(i):void 0}catch(i){return r}}set(t,r,i){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!i))try{localStorage.setItem(t,JSON.stringify(r))}catch(n){console.warn(n)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(i){}}};l();import pe from"rfdc";var me=pe();function Yt(e,t,r){let i=t?me(t):rt();return e.forEach(n=>{var s,o;switch(n.type){case"consent":i.consent=n.data;break;case"setquirk":i.quirks[n.data.key]=n.data.value;break;case"settest":i.tests[n.data.test]=n.data.variant;break;case"modscore":if(r)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let d=(s=i.scores[n.data.dimension])!=null?s:0;i.scores[n.data.dimension]=d+u;break;case"modscoreS":if(r)break;let c=Number(n.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let h=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=h+c;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var ot="ufvisitor",k,G,_,y,V,A,w,q,st,ge,at,ve,X,Wt,Z,Xt,Ct=class{constructor(t){f(this,V);f(this,w);f(this,st);f(this,at);f(this,X);f(this,Z);f(this,k,he());f(this,G,new Dt);f(this,_,void 0);f(this,y,void 0);x(this,"events",{on:a(this,k).on,off:a(this,k).off});if(v(this,y,t),a(this,V,A)||C(this,w,q).call(this,C(this,Z,Xt).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();if(r){let n=[];r.quirks&&n.push(...Object.entries(r.quirks).map(([s,o])=>({type:"setquirk",data:{key:s,value:o}}))),r.tests&&n.push(...Object.entries(r.tests).map(([s,o])=>({type:"settest",data:{test:s,variant:o}}))),this.updateData(n),r.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(r.ssv)}t.transitionStore.events.on("dataUpdatedAsync",n=>{C(this,w,q).call(this,{...a(this,V,A).visitorData,...n})});let i=t.transitionStore.data;i&&C(this,w,q).call(this,{...a(this,V,A).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,V,A);if(C(this,at,ve).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return C(this,w,q).call(this,{...s,sessionScores:{}}),(i=(r=a(this,y)).onLogMessage)==null||i.call(r,["info",120]),a(this,V,A).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,y).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,y)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=Yt(t,this.data,(s=a(this,V,A))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,G).delete(ot,!0),C(this,w,q).call(this,r),await((o=a(this,y).transitionStore)==null?void 0:o.updateData(t,a(this,V,A).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,y)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,G).delete(ot,!1),await((n=a(this,y).transitionStore)==null?void 0:n.delete(t)),C(this,w,q).call(this,C(this,Z,Xt).call(this))}finally{(o=(s=a(this,y)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};k=new WeakMap,G=new WeakMap,_=new WeakMap,y=new WeakMap,V=new WeakSet,A=function(){return a(this,G).get(ot)},w=new WeakSet,q=function(t,r=!1){var h,g,D,b,L,Et,Tt,kt;let i=a(this,V,A),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(C(this,X,Wt).call(this,t.scores),C(this,X,Wt).call(this,t.sessionScores),(g=(h=a(this,y)).decay)==null||g.call(h,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,y).onLogMessage}));let s=!nt(i==null?void 0:i.visitorData.scores,t.scores),o=!nt(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!nt(i==null?void 0:i.visitorData.quirks,t.quirks),d=!nt(i==null?void 0:i.visitorData.tests,t.tests),c={updated:n,visitorData:t};C(this,st,ge).call(this),a(this,G).set(ot,c,!!t.consent),(b=(D=a(this,y)).onLogMessage)==null||b.call(D,["debug",102,t]),r||((s||o)&&a(this,k).emit("scoresUpdated",t),u&&a(this,k).emit("quirksUpdated",t),d&&a(this,k).emit("testsUpdated",t),((L=i==null?void 0:i.visitorData)==null?void 0:L.consent)!==t.consent&&a(this,k).emit("consentUpdated",t),((Et=i==null?void 0:i.visitorData)==null?void 0:Et.controlGroup)!==t.controlGroup&&(a(this,k).emit("controlGroupUpdated",t),(kt=(Tt=a(this,y)).onLogMessage)==null||kt.call(Tt,["debug",104,t.controlGroup])))},st=new WeakSet,ge=function(){typeof document=="undefined"||!a(this,y).visitLifespan||(a(this,_)&&window.clearTimeout(a(this,_)),v(this,_,window.setTimeout(()=>{this.data},a(this,y).visitLifespan+50)))},at=new WeakSet,ve=function(t){let r=a(this,y).visitLifespan;return r?t.updated+r<Date.now():!1},X=new WeakSet,Wt=function(t){var r,i;if(!!a(this,y).manifest)for(let n in t){let s=t[n],o=a(this,y).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,y)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},Z=new WeakSet,Xt=function(){var t,r,i;return{...rt(),consent:(t=a(this,y).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,y).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};l();import ye from"mitt";l();l();function Zt({name:e,context:t,variations:r,take:i=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:i}]);try{let d=(s=t.storage.data.controlGroup)!=null?s:!1,c=[],h=!1,g=t.scores;for(let D of r){if(c.length===i)break;if(!((o=D.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:D.id,op:(u=D.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),c.push(D);continue}d||Mt(D.id,D.pz,g,n)&&(h=!0,c.push(D))}return{personalized:h,variations:c}}finally{n==null||n(["info",300,"ENDGROUP"])}}l();function Mt(e,t,r,i){i==null||i(["info",301,"GROUP",{id:e,op:t==null?void 0:t.op}]);let n;try{t!=null&&t.crit?!t.op||t.op==="&"?n=t.crit.every(s=>Lt(s,r,i)):n=t.crit.some(s=>Lt(s,r,i)):(i==null||i(["info",302,{matched:!0,description:"default variation"}]),n=!0),i==null||i(["info",303,n])}finally{i==null||i(["info",301,"ENDGROUP"])}return n}function Lt(e,t,r){var u,d;let{op:i,l:n}=e,s=(u=t[n])!=null?u:0;if(i==="+"){let c=Math.max(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:c,description:`${e.l} has the highest score`}]),c}else if(i==="-"){let c=Math.min(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:c,description:`${e.l} has the lowest non-zero score`}]),c}let o=e.rDim?t[e.rDim]:e.r;if(o===void 0)return r==null||r(["info",302,{matched:!1,description:`${(d=e.rDim)!=null?d:e.r} has no score value`}]),!1;if(i===">"){let c=s>o;return j(r,c,e,s,o),c}else if(i===">="){let c=s>=o;return j(r,c,e,s,o),c}else if(i==="<"){let c=s<o;return j(r,c,e,s,o),c}else if(i==="<="){let c=s<=o;return j(r,c,e,s,o),c}else if(i==="="){let c=s===o;return j(r,c,e,s,o),c}else if(i==="!="){let c=s!==o;return j(r,c,e,s,o),c}else throw new Error(`Unknown op: ${i}`)}function j(e,t,r,i,n){e==null||e(["info",302,{matched:t,description:`${r.l}[${i}] ${r.op} ${r.rDim?`${r.rDim}[${n}]`:r.r}`}])}l();var Se=e=>{let{values:t,total:r,missingDistribution:i}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.testDistribution),n),{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)/i;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},xt=({name:e,context:t,variations:r,onLogMessage:i})=>{i==null||i(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return i==null||i(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=r.find(o=>o.id===s),n||i==null||i(["warn",402,{missingVariant:s,variants:r.map(o=>o.id)}])),!n){let o=Se(r),u=Math.floor(Math.random()*100),d=0;n=r.find((c,h)=>{let g=o[h];if(u>d&&u<=d+g)return c;d+=g}),n&&(i==null||i(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(i==null||i(["info",404,n.id])),{result:n,variantAssigned:!s}}finally{i==null||i(["info",400,"ENDGROUP"])}};import{dequal as te}from"dequal/lite";var z,O,P,M,S,F,bt,De=class{constructor(t){f(this,F);x(this,"manifest");f(this,z,!1);f(this,O,{});f(this,P,void 0);f(this,M,{});f(this,S,ye());x(this,"events",{on:a(this,S).on,off:a(this,S).off});x(this,"storage");var n,s;let{manifest:r,...i}=t;v(this,P,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,S).on("log",o.logDrain)}),a(this,S).emit("log",["info",1,"GROUP"]);try{this.manifest=new ct({onLogMessage:o=>a(this,S).emit("log",o),manifest:r,evaluator:new H({CK:Ut,QS:Nt,QK:Gt,PVC:pt,EVT:zt,PV:It})}),this.storage=new Ct({...i,manifest:this.manifest,onServerTransitionScoresReceived:o=>{v(this,O,o),v(this,z,!0),a(this,S).emit("log",["debug",130,o])},onLogMessage:o=>a(this,S).emit("log",o)}),this.storage.events.on("scoresUpdated",C(this,F,bt).bind(this)),a(this,z)||C(this,F,bt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,O),state:a(this,P),previousState:a(this,P),visitor:this.storage.data});this.storage.updateData(u),a(this,S).emit("quirksUpdated",o.quirks),a(this,S).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,S).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,O)}async update(t){var i;let r=[];try{a(this,S).emit("log",["info",2,"GROUP",{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&r.push(...Object.entries(t.quirks).map(([n,s])=>({type:"setquirk",data:{key:n,value:s}}))),t.enrichments&&t.enrichments.forEach(n=>{let s=et(n.cat,n.key);this.manifest.getDimensionByKey(s)?r.push({type:"modscore",data:{dimension:s,delta:n.str}}):a(this,S).emit("log",["warn",5,n])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,P),visitor:this.storage.data,scores:a(this,O)})),v(this,P,{...a(this,P),...t}),await this.storage.updateData(r),a(this,z)&&(C(this,F,bt).call(this,this.storage.data),v(this,z,!1),a(this,S).emit("log",["debug",131]))}finally{a(this,S).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var i;let r=this.manifest.getTest(t);return r?(i=r.wv)!=null?i:this.storage.data.tests[t]:(a(this,S).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,S).emit("log",t)}test(t){var i,n;let r=xt({...t,context:this,onLogMessage:s=>a(this,S).emit("log",s)});return a(this,S).emit("testResult",{name:t.name,variantId:(n=(i=r.result)==null?void 0:i.id)!=null?n:void 0,variantAssigned:r.variantAssigned}),r}personalize(t){let r=Zt({...t,context:this,onLogMessage:s=>a(this,S).emit("log",s)}),i=a(this,M)[t.name],n={name:t.name,variantIds:r.variations.map(s=>{var o;return(o=s.id)!=null?o:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return i&&te(n.variantIds,i)&&(n.changed=!1),a(this,S).emit("personalizationResult",n),a(this,M)[t.name]=n.variantIds,r}async forget(t){v(this,P,{}),await this.storage.delete(t)}};z=new WeakMap,O=new WeakMap,P=new WeakMap,M=new WeakMap,S=new WeakMap,F=new WeakSet,bt=function(t){var n;let r={...t.scores};for(let s in t.sessionScores)r[s]=((n=r[s])!=null?n:0)+t.sessionScores[s];r=this.manifest.computeAggregateDimensions(r),!te(r,a(this,O))&&(v(this,O,r),a(this,S).emit("scoresUpdated",r),a(this,S).emit("log",["info",3,r]))};l();import Ce from"rfdc";l();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}}var xe=Ce();function be(e){return([t,...r])=>{if(!ut(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
2
+ `,...n.map(xe))}}function li(e){return{logDrain:be(e)}}l();l();var ee={1:()=>["context","initializing Uniform Context"],2:e=>["context","received 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",`deleting visitor data ${e?"from all devices":"from this device"}`],104:e=>["context",e?"Visitor assigned to personalization control group":"Visitor assigned to personalization experiment group"],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"],140:e=>["storage",`score decay was applied: ${e}`],200:()=>["signals","evaluating signals"],201:e=>["signals",`evaluating signal ${e.id} (${e.dur})`],202:e=>["signals",e.op==="|"?"OR":"AND"],203:({criteria:e,result:t,explanation:r})=>["signals",`${e.type}: ${r} is ${t.result} [${t.changed?"CHANGED":"unchanged"}]`],204:e=>["signals",`group result: ${e.result} [${e.changed?"CHANGED":"unchanged"}]`],300:e=>["personalization",`executing personalization '${e.name}'`],301:({id:e,op:t})=>["personalization",`testing variation ${e} (${t==="|"?"OR":"AND"})`],302:({matched:e,description:t})=>["personalization",`${t} is ${e}`],303:e=>["personalization",e?"selected variation":"did not select variation"],400:e=>["testing",`executing A/B test '${e}'`],401:e=>["testing",`${e} is not registered in the manifest; it will not be run.`],402:({missingVariant:e,variants:t})=>["testing",`test variation '${e}' previously assigned to the visitor for this test no longer exists as a variant. It will be removed. This may indicate changing test variations after publishing a test, which will make results invalid. Known variants: ${t.join(", ")}`],403:e=>["testing",`assigned new test variant '${e}'`],404:e=>["testing",`displaying variation '${e}'`],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"]};import Ve from"rfdc";var Ee=Ve();function Te(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!ut(e,n)||r&&!i)return;let[o,...u]=s,d=console[n];if(u[0]==="GROUP"&&(u.shift(),d=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let c=ee[o],h="";switch(n){case"debug":h="\u{1F41E}";break;case"info":h="\u{1F4AC}";break;case"warn":h="\u26A0\uFE0F";break;case"error":h="\u{1F4A5}";break}let g=h;if(!c){d(`${g} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[D,b,...L]=c(...u);d(`${g}[${D}] ${b}
3
+ `,...L.map(Ee))}}function hi(e,t){return{logDrain:Te(e,t)}}l();var ke=(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))(ke||{}),vi="nesitag";l();var Vt=typeof top!="undefined";function yi(){return{logDrain:e=>{!Vt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!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)},n=o=>{!o.changed||(t.push(o),i())},s=o=>{!o.variantAssigned||(r.push(o),i())};if(Vt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Pe(u,e)})}catch(o){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",o)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),i()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),e.storage.events.on("*",i),()=>{e.storage.events.off("*",i),e.events.off("personalizationResult",n),e.events.off("testResult",s)}}}}async function Pe(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)}export{De as Context,ue as CookieTransitionDataStore,vi as EdgeNodeTagName,de as EdgeTransitionDataStore,H as GroupCriteriaEvaluator,ct as ManifestInstance,se as SERVER_STATE_ID,ke as ScriptType,Y as TransitionDataStore,ae as UNIFORM_DEFAULT_COOKIE_NAME,Ct as VisitorDataStore,Pt as computeAggregateDimensions,Ut as cookieEvaluator,be as createConsoleLogDrain,Te as createDebugConsoleLogDrain,Vr as createLinearDecay,It as currentPageEvaluator,rt as emptyVisitorData,li as enableConsoleLogDrain,yi as enableContextDevTools,hi as enableDebugConsoleLogDrain,Mt as evaluateVariantMatch,zt as eventEvaluator,U as explainStringMatch,dt as explainStringMatchCriteria,et as getEnrichmentVectorKey,T as isStringMatch,ft as pageViewCountDimension,pt as pageViewCountEvaluator,Zt as personalizeVariations,Nt as queryStringEvaluator,Gt as quirkEvaluator,xt as testVariations};