@contentful/optimization-web 0.1.0-alpha4 → 0.1.0-alpha6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/analyzer.html +1 -1
- package/dist/contentful-optimization-web.umd.cjs.map +1 -1
- package/dist/{contentful-optimization-web.umd.cjs → contentful-optimization-web.umd.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +601 -601
- package/dist/index.js.map +1 -1
- package/dist/visualizer.html +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Zi=Symbol.for("preact-signals");function _t(){if(Q>1)Q--;else{for(var t,e=!1;Le!==void 0;){var n=Le;for(Le=void 0,Zt++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Yn(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(Zt=0,Q--,e)throw t}}function le(t){if(Q>0)return t();Q++;try{return t()}finally{_t()}}var y=void 0;function nn(t){var e=y;y=void 0;try{return t()}finally{y=e}}var Le=void 0,Q=0,Zt=0,dt=0;function Kn(t){if(y!==void 0){var e=t.n;if(e===void 0||e.t!==y)return e={i:0,S:t,p:y.s,n:void 0,t:y,e:void 0,x:void 0,r:e},y.s!==void 0&&(y.s.n=e),y.s=e,t.n=e,32&y.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=y.s,e.n=void 0,y.s.n=e,y.s=e),e}}function $(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}$.prototype.brand=Zi;$.prototype.h=function(){return!0};$.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:nn(function(){var r;(r=e.W)==null||r.call(e)}))};$.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&nn(function(){var i;(i=e.Z)==null||i.call(e)}))}};$.prototype.subscribe=function(t){var e=this;return R(function(){var n=e.value,r=y;y=void 0;try{t(n)}finally{y=r}},{name:"sub"})};$.prototype.valueOf=function(){return this.value};$.prototype.toString=function(){return this.value+""};$.prototype.toJSON=function(){return this.value};$.prototype.peek=function(){var t=y;y=void 0;try{return this.value}finally{y=t}};Object.defineProperty($.prototype,"value",{get:function(){var t=Kn(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Zt>100)throw new Error("Cycle detected");this.v=t,this.i++,dt++,Q++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{_t()}}}});function Se(t,e){return new $(t,e)}function Yn(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Wn(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Gn(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function fe(t,e){$.call(this,void 0),this.x=t,this.s=void 0,this.g=dt-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}fe.prototype=new $;fe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===dt))return!0;if(this.g=dt,this.f|=1,this.i>0&&!Yn(this))return this.f&=-2,!0;var t=y;try{Wn(this),y=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return y=t,Gn(this),this.f&=-2,!0};fe.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}$.prototype.S.call(this,t)};fe.prototype.U=function(t){if(this.t!==void 0&&($.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};fe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(fe.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Kn(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Jn(t,e){return new fe(t,e)}function Qn(t){var e=t.u;if(t.u=void 0,typeof e=="function"){Q++;var n=y;y=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,rn(t),r}finally{y=n,_t()}}}function rn(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Qn(t)}function Fi(t){if(y!==this)throw new Error("Out-of-order effect");Gn(this),y=t,this.f&=-2,8&this.f&&rn(this),_t()}function ze(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}ze.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};ze.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Qn(this),Wn(this),Q++;var t=y;return y=this,Fi.bind(this,t)};ze.prototype.N=function(){2&this.f||(this.f|=2,this.o=Le,Le=this)};ze.prototype.d=function(){this.f|=8,1&this.f||rn(this)};ze.prototype.dispose=function(){this.d()};function R(t,e){var n=new ze(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}const ft={resolve(t){return t?t.reduce((e,{key:n,value:r})=>{const i=typeof r=="object"&&r!==null&&"value"in r&&typeof r.value=="object"?r.value:r;return e[n]=i,e},{}):{}}};function p(t,e,n){function r(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(const d in s.prototype)d in a||Object.defineProperty(a,d,{value:s.prototype[d].bind(a)});a._zod.constr=s,a._zod.def=c}const i=n?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:t});function s(a){var c;const u=n?.Parent?new o:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(s,"name",{value:t}),s}class we extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class qi extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Hi={};function Te(t){return Hi}function Ki(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function Yi(t,e){return typeof e=="bigint"?e.toString():e}function Xn(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function er(t){return t==null}function on(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}const Sn=Symbol("evaluating");function E(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==Sn)return r===void 0&&(r=Sn,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function sn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function tr(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}const nr="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function pt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function an(t){if(pt(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(pt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Wi(t){return an(t)?{...t}:t}const Gi=new Set(["string","number","symbol"]);function Ft(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cn(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(r._zod.parent=t),r}function O(t){return{}}function Ji(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function Qi(t,e){if(!an(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const i=tr(t._zod.def,{get shape(){const o={...t._zod.def.shape,...e};return sn(this,"shape",o),o},checks:[]});return cn(t,i)}function Xi(t,e,n){const r=tr(e._zod.def,{get shape(){const i=e._zod.def.shape,o={...i};for(const s in i)o[s]=t?new t({type:"optional",innerType:i[s]}):i[s];return sn(this,"shape",o),o},checks:[]});return cn(e,r)}function Me(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function me(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function Qe(t){return typeof t=="string"?t:t?.message}function Ae(t,e,n){const r={...t,path:t.path??[]};if(!t.message){const i=Qe(t.inst?._zod.def?.error?.(t))??Qe(e?.error?.(t))??Qe(n.customError?.(t))??Qe(n.localeError?.(t))??"Invalid input";r.message=i}return delete r.inst,delete r.continue,e?.reportInput||delete r.input,r}function rr(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function eo(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const ir=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Yi,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},to=p("$ZodError",ir),bt=p("$ZodError",ir,{Parent:Error}),no=t=>(e,n,r,i)=>{const o=r?Object.assign(r,{async:!1}):{async:!1},s=e._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new we;if(s.issues.length){const a=new(i?.Err??t)(s.issues.map(c=>Ae(c,o,Te())));throw nr(a,i?.callee),a}return s.value},ro=no(bt),io=t=>async(e,n,r,i)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(i?.Err??t)(s.issues.map(c=>Ae(c,o,Te())));throw nr(a,i?.callee),a}return s.value},oo=io(bt),so=t=>(e,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new we;return o.issues.length?{success:!1,error:new(t??to)(o.issues.map(s=>Ae(s,i,Te())))}:{success:!0,data:o.value}},or=so(bt),ao=t=>async(e,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(s=>Ae(s,i,Te())))}:{success:!0,data:o.value}},sr=ao(bt),co="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function uo(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function lo(t){const e=uo({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${co}T(?:${r})$`)}const fo=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},po=/^-?\d+(?:\.\d+)?/i,ho=/true|false/i,go=/null/i,wt=p("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),vo=p("$ZodCheckMinLength",(t,e)=>{var n;wt.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!er(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const s=rr(i);r.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),yo=p("$ZodCheckLengthEquals",(t,e)=>{var n;wt.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!er(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),t._zod.check=r=>{const i=r.value,o=i.length;if(o===e.length)return;const s=rr(i),a=o>e.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),mo=p("$ZodCheckStringFormat",(t,e)=>{var n,r;wt.init(t,e),t._zod.onattach.push(i=>{const o=i._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),_o={major:4,minor:1,patch:5},z=p("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=_o;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const i of r)for(const o of i._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const i=(s,a,c)=>{let u=Me(s),d;for(const m of a){if(m._zod.def.when){if(!m._zod.def.when(s))continue}else if(u)continue;const b=s.issues.length,S=m._zod.check(s);if(S instanceof Promise&&c?.async===!1)throw new we;if(d||S instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await S,s.issues.length!==b&&(u||(u=Me(s,b)))});else{if(s.issues.length===b)continue;u||(u=Me(s,b))}}return d?d.then(()=>s):s},o=(s,a,c)=>{if(Me(s))return s.aborted=!0,s;const u=i(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new we;return u.then(d=>t._zod.parse(d,c))}return t._zod.parse(u,c)};t._zod.run=(s,a)=>{if(a.skipChecks)return t._zod.parse(s,a);if(a.direction==="backward"){const u=t._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>o(d,s,a)):o(u,s,a)}const c=t._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new we;return c.then(u=>i(u,r,a))}return i(c,r,a)}}t["~standard"]={validate:i=>{try{const o=or(t,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return sr(t,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),ar=p("$ZodString",(t,e)=>{z.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??fo(t._zod.bag),t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),cr=p("$ZodStringFormat",(t,e)=>{mo.init(t,e),ar.init(t,e)}),bo=p("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=lo(e)),cr.init(t,e)}),wo=p("$ZodNumber",(t,e)=>{z.init(t,e),t._zod.pattern=t._zod.bag.pattern??po,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...o?{received:o}:{}}),n}}),Eo=p("$ZodBoolean",(t,e)=>{z.init(t,e),t._zod.pattern=ho,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),n}}),So=p("$ZodNull",(t,e)=>{z.init(t,e),t._zod.pattern=go,t._zod.values=new Set([null]),t._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:t}),n}}),zo=p("$ZodAny",(t,e)=>{z.init(t,e),t._zod.parse=n=>n}),To=p("$ZodUnknown",(t,e)=>{z.init(t,e),t._zod.parse=n=>n});function zn(t,e,n){t.issues.length&&e.issues.push(...me(n,t.issues)),e.value[n]=t.value}const Ao=p("$ZodArray",(t,e)=>{z.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),n;n.value=Array(i.length);const o=[];for(let s=0;s<i.length;s++){const a=i[s],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?o.push(c.then(u=>zn(u,n,s))):zn(c,n,s)}return o.length?Promise.all(o).then(()=>n):n}});function ht(t,e,n,r){t.issues.length&&e.issues.push(...me(n,t.issues)),t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function ko(t){const e=Object.keys(t.shape);for(const r of e)if(!t.shape[r]._zod.traits.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Ji(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function Po(t,e,n,r,i,o){const s=[],a=i.keySet,c=i.catchall._zod,u=c.def.type;for(const d of Object.keys(e)){if(a.has(d))continue;if(u==="never"){s.push(d);continue}const m=c.run({value:e[d],issues:[]},r);m instanceof Promise?t.push(m.then(b=>ht(b,n,d,e))):ht(m,n,d,e)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:e,inst:o}),t.length?Promise.all(t).then(()=>n):n}const Co=p("$ZodObject",(t,e)=>{z.init(t,e);const n=Xn(()=>ko(e));E(t._zod,"propValues",()=>{const s=e.shape,a={};for(const c in s){const u=s[c]._zod;if(u.values){a[c]??(a[c]=new Set);for(const d of u.values)a[c].add(d)}}return a});const r=pt,i=e.catchall;let o;t._zod.parse=(s,a)=>{o??(o=n.value);const c=s.value;if(!r(c))return s.issues.push({expected:"object",code:"invalid_type",input:c,inst:t}),s;s.value={};const u=[],d=o.shape;for(const m of o.keys){const S=d[m]._zod.run({value:c[m],issues:[]},a);S instanceof Promise?u.push(S.then(_=>ht(_,s,m,c))):ht(S,s,m,c)}return i?Po(u,c,s,a,n.value,t):u.length?Promise.all(u).then(()=>s):s}});function Tn(t,e,n,r){for(const o of t)if(o.issues.length===0)return e.value=o.value,e;const i=t.filter(o=>!Me(o));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(o=>o.issues.map(s=>Ae(s,r,Te())))}),e)}const ur=p("$ZodUnion",(t,e)=>{z.init(t,e),E(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),E(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),E(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),E(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>on(o.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(i,o)=>{if(n)return r(i,o);let s=!1;const a=[];for(const c of e.options){const u=c._zod.run({value:i.value,issues:[]},o);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}return s?Promise.all(a).then(c=>Tn(c,i,t,o)):Tn(a,i,t,o)}}),Io=p("$ZodDiscriminatedUnion",(t,e)=>{ur.init(t,e);const n=t._zod.parse;E(t._zod,"propValues",()=>{const i={};for(const o of e.options){const s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const[a,c]of Object.entries(s)){i[a]||(i[a]=new Set);for(const u of c)i[a].add(u)}}return i});const r=Xn(()=>{const i=e.options,o=new Map;for(const s of i){const a=s._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(const c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,s)}}return o});t._zod.parse=(i,o)=>{const s=i.value;if(!pt(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:t}),i;const a=r.value.get(s?.[e.discriminator]);return a?a._zod.run(i,o):e.unionFallback?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:s,path:[e.discriminator],inst:t}),i)}}),$o=p("$ZodRecord",(t,e)=>{z.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!an(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),n;const o=[];if(e.keyType._zod.values){const s=e.keyType._zod.values;n.value={};for(const c of s)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const u=e.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&n.issues.push(...me(c,d.issues)),n.value[c]=d.value})):(u.issues.length&&n.issues.push(...me(c,u.issues)),n.value[c]=u.value)}let a;for(const c in i)s.has(c)||(a=a??[],a.push(c));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:a})}else{n.value={};for(const s of Reflect.ownKeys(i)){if(s==="__proto__")continue;const a=e.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(u=>Ae(u,r,Te())),input:s,path:[s],inst:t}),n.value[a.value]=a.value;continue}const c=e.valueType._zod.run({value:i[s],issues:[]},r);c instanceof Promise?o.push(c.then(u=>{u.issues.length&&n.issues.push(...me(s,u.issues)),n.value[a.value]=u.value})):(c.issues.length&&n.issues.push(...me(s,c.issues)),n.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Oo=p("$ZodEnum",(t,e)=>{z.init(t,e);const n=Ki(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>Gi.has(typeof i)).map(i=>typeof i=="string"?Ft(i):i.toString()).join("|")})$`),t._zod.parse=(i,o)=>{const s=i.value;return r.has(s)||i.issues.push({code:"invalid_value",values:n,input:s,inst:t}),i}}),Ro=p("$ZodLiteral",(t,e)=>{if(z.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Ft(n):n?Ft(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,r)=>{const i=n.value;return t._zod.values.has(i)||n.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),n}}),Mo=p("$ZodTransform",(t,e)=>{z.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new qi(t.constructor.name);const i=e.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(n.value=s,n));if(i instanceof Promise)throw new we;return n.value=i,n}});function An(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const xo=p("$ZodOptional",(t,e)=>{z.init(t,e),t._zod.optin="optional",t._zod.optout="optional",E(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),E(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${on(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>An(o,n.value)):An(i,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),Vo=p("$ZodNullable",(t,e)=>{z.init(t,e),E(t._zod,"optin",()=>e.innerType._zod.optin),E(t._zod,"optout",()=>e.innerType._zod.optout),E(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${on(n.source)}|null)$`):void 0}),E(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),No=p("$ZodPrefault",(t,e)=>{z.init(t,e),t._zod.optin="optional",E(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),Lo=p("$ZodPipe",(t,e)=>{z.init(t,e),E(t._zod,"values",()=>e.in._zod.values),E(t._zod,"optin",()=>e.in._zod.optin),E(t._zod,"optout",()=>e.out._zod.optout),E(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=e.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Xe(s,e.in,r)):Xe(o,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(o=>Xe(o,e.out,r)):Xe(i,e.out,r)}});function Xe(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const Bo=p("$ZodLazy",(t,e)=>{z.init(t,e),E(t._zod,"innerType",()=>e.getter()),E(t._zod,"pattern",()=>t._zod.innerType._zod.pattern),E(t._zod,"propValues",()=>t._zod.innerType._zod.propValues),E(t._zod,"optin",()=>t._zod.innerType._zod.optin??void 0),E(t._zod,"optout",()=>t._zod.innerType._zod.optout??void 0),t._zod.parse=(n,r)=>t._zod.innerType._zod.run(n,r)}),Uo=p("$ZodCustom",(t,e)=>{wt.init(t,e),z.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,i=e.fn(r);if(i instanceof Promise)return i.then(o=>kn(o,n,r,t));kn(i,n,r,t)}});function kn(t,e,n,r){if(!t){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(eo(i))}}function Do(t,e){return new t({type:"string",...O()})}function jo(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O()})}function Zo(t,e){return new t({type:"number",checks:[],...O()})}function Fo(t,e){return new t({type:"boolean",...O()})}function qo(t,e){return new t({type:"null",...O()})}function Ho(t){return new t({type:"any"})}function Ko(t){return new t({type:"unknown"})}function Yo(t,e){return new vo({check:"min_length",...O(),minimum:t})}function Wo(t,e){return new yo({check:"length_equals",...O(),length:t})}function Go(t,e,n){const r=O();return r.abort??(r.abort=!0),new t({type:"custom",check:"custom",fn:e,...r})}const T=p("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");z.init(t,e),t.def=e,t.type=e.type,t.parse=(n,r)=>ro(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>or(t,n,r),t.parseAsync=async(n,r)=>oo(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>sr(t,n,r),t.check=(...n)=>t.clone({...e,checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),t.clone=(n,r)=>cn(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t)}),lr=p("ZodMiniString",(t,e)=>{ar.init(t,e),T.init(t,e)});function l(t){return Do(lr)}const Jo=p("ZodMiniStringFormat",(t,e)=>{cr.init(t,e),lr.init(t,e)}),Qo=p("ZodMiniNumber",(t,e)=>{wo.init(t,e),T.init(t,e)});function C(t){return Zo(Qo)}const Xo=p("ZodMiniBoolean",(t,e)=>{Eo.init(t,e),T.init(t,e)});function q(t){return Fo(Xo)}const es=p("ZodMiniNull",(t,e)=>{So.init(t,e),T.init(t,e)});function un(t){return qo(es)}const ts=p("ZodMiniAny",(t,e)=>{zo.init(t,e),T.init(t,e)});function Pn(){return Ho(ts)}const ns=p("ZodMiniUnknown",(t,e)=>{To.init(t,e),T.init(t,e)});function rs(){return Ko(ns)}const is=p("ZodMiniArray",(t,e)=>{Ao.init(t,e),T.init(t,e)});function k(t,e){return new is({type:"array",element:t,...O()})}const os=p("ZodMiniObject",(t,e)=>{Co.init(t,e),T.init(t,e),E(t,"shape",()=>e.shape)});function h(t,e){const n={type:"object",get shape(){return sn(this,"shape",{...t}),this.shape},...O()};return new os(n)}function g(t,e){return Qi(t,e)}function ss(t,e){return Xi(fr,t)}function Et(t,e){return t.clone({...t._zod.def,catchall:e})}const as=p("ZodMiniUnion",(t,e)=>{ur.init(t,e),T.init(t,e)});function X(t,e){return new as({type:"union",options:t,...O()})}const cs=p("ZodMiniDiscriminatedUnion",(t,e)=>{Io.init(t,e),T.init(t,e)});function Fe(t,e,n){return new cs({type:"union",options:e,discriminator:t,...O()})}const us=p("ZodMiniRecord",(t,e)=>{$o.init(t,e),T.init(t,e)});function pe(t,e,n){return new us({type:"record",keyType:t,valueType:e,...O()})}const ls=p("ZodMiniEnum",(t,e)=>{Oo.init(t,e),T.init(t,e),t.options=Object.values(e.entries)});function dr(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new ls({type:"enum",entries:n,...O()})}const ds=p("ZodMiniLiteral",(t,e)=>{Ro.init(t,e),T.init(t,e)});function v(t,e){return new ds({type:"literal",values:Array.isArray(t)?t:[t],...O()})}const fs=p("ZodMiniTransform",(t,e)=>{Mo.init(t,e),T.init(t,e)});function ps(t){return new fs({type:"transform",transform:t})}const fr=p("ZodMiniOptional",(t,e)=>{xo.init(t,e),T.init(t,e)});function f(t){return new fr({type:"optional",innerType:t})}const hs=p("ZodMiniNullable",(t,e)=>{Vo.init(t,e),T.init(t,e)});function nt(t){return new hs({type:"nullable",innerType:t})}const gs=p("ZodMiniPrefault",(t,e)=>{No.init(t,e),T.init(t,e)});function K(t,e){return new gs({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Wi(e)}})}const vs=p("ZodMiniPipe",(t,e)=>{Lo.init(t,e),T.init(t,e)});function ys(t,e){return new vs({type:"pipe",in:t,out:e})}const ms=p("ZodMiniLazy",(t,e)=>{Bo.init(t,e),T.init(t,e)});function _s(t){return new ms({type:"lazy",getter:t})}const bs=p("ZodMiniCustom",(t,e)=>{Uo.init(t,e),T.init(t,e)});function ws(t,e){return Go(bs,()=>!0)}function ee(){const t=_s(()=>X([l(),C(),q(),un(),k(t),pe(l(),t)]));return t}const Es=p("$ZodISODateTime",(t,e)=>{bo.init(t,e),Jo.init(t,e)});function Ot(t){return jo(Es)}const qe=Et(h({}),ee()),pr=h({sys:h({type:v("Link"),linkType:l(),id:l()})}),hr=h({sys:h({type:v("Link"),linkType:v("ContentType"),id:l()})}),gr=h({sys:h({type:v("Link"),linkType:v("Environment"),id:l()})}),vr=h({sys:h({type:v("Link"),linkType:v("Space"),id:l()})}),Ss=h({sys:h({type:v("Link"),linkType:v("TaxonomyConcept"),id:l()})}),yr=h({sys:h({type:v("Link"),linkType:v("Tag"),id:l()})}),ln=h({type:v("Entry"),contentType:hr,publishedVersion:C(),id:l(),createdAt:Pn(),updatedAt:Pn(),locale:f(l()),revision:C(),space:vr,environment:gr}),ke=h({fields:qe,metadata:h({tags:k(yr),concepts:f(k(Ss))}),sys:ln});function mr(t){return ke.safeParse(t).success}const _r=g(qe,{nt_audience_id:l(),nt_name:f(l()),nt_description:f(l())}),dn=g(ke,{fields:_r}),zs=g(dn,{contentTypeId:v("nt_audience")}),br=g(ke,{fields:h({nt_name:l(),nt_fallback:f(l()),nt_mergetag_id:l()}),sys:g(ln,{contentType:h({sys:h({type:v("Link"),linkType:v("ContentType"),id:v("nt_mergetag")})})})}),gt=h({id:l(),hidden:K(q(),!1)});function wr(t){return gt.safeParse(t).success}const Er=h({type:f(v("EntryReplacement")),baseline:gt,variants:k(gt)});function Sr(t){return t.type==="EntryReplacement"||t.type===void 0}const qt=h({value:X([l(),q(),un(),C(),pe(l(),ee())])}),zr=dr(["Boolean","Number","Object","String"]),Tr=h({type:v("InlineVariable"),key:l(),valueType:zr,baseline:qt,variants:k(qt)});function Ts(t){return t.type==="InlineVariable"}const Ar=Fe("type",[Er,Tr]),kr=k(Ar),Pr=h({distribution:f(K(k(C()),[.5,.5])),traffic:f(K(C(),0)),components:f(K(kr,[{type:"EntryReplacement",baseline:{id:""},variants:[{id:""}]}])),sticky:f(K(q(),!1))}),Cr=X([v("nt_experiment"),v("nt_personalization")]),Ir=g(qe,{nt_name:l(),nt_description:f(nt(l())),nt_type:Cr,nt_config:ys(f(K(nt(Pr),null)),ps(t=>t??{traffic:0,distribution:[.5,.5],components:[],sticky:!1})),nt_audience:f(nt(dn)),nt_variants:f(K(k(ws()),[])),nt_experience_id:l()}),St=g(ke,{fields:Ir}),As=g(St,{contentTypeId:v("nt_experience")});function xe(t){return St.safeParse(t).success}const $r=k(X([pr,St])),Or=g(ke,{fields:g(qe,{nt_experiences:$r})});function rt(t){return Or.safeParse(t).success}const Rr=f(h({name:l(),version:l()})),fn=h({name:f(l()),source:f(l()),medium:f(l()),term:f(l()),content:f(l())}),Mr=X([v("mobile"),v("server"),v("web")]),xr=pe(l(),l()),ks=2,Ps=h({latitude:C(),longitude:C()}),zt=h({coordinates:f(Ps),city:f(l()),postalCode:f(l()),region:f(l()),regionCode:f(l()),country:f(l()),countryCode:f(l().check(Wo(ks))),continent:f(l()),timezone:f(l())}),Vr=h({name:l(),version:l()}),he=Et(h({path:l(),query:xr,referrer:l(),search:l(),title:f(l()),url:l()}),ee()),He=pe(l(),ee()),Tt=Et(h({name:l()}),ee()),At=pe(l(),ee()),Nr=h({id:l(),isReturningVisitor:q(),landingPage:he,count:C(),activeSessionLength:C(),averageSessionLength:C()}),Ke=h({id:l(),stableId:l(),random:C(),audiences:k(l()),traits:At,location:zt,session:Nr}),Lr=Et(h({id:l()}),ee()),Br=h({data:h(),message:l(),error:nt(q())}),Ur=h({profiles:f(k(Ke))}),Dr=g(Br,{data:Ur}),jr=["Variable"],Zr=h({key:l(),type:X([dr(jr),l()]),meta:h({experienceId:l(),variantIndex:C()})}),Fr=X([l(),q(),un(),C(),pe(l(),ee())]),Cs=g(Zr,{type:l(),value:rs()}),qr=g(Zr,{type:v("Variable"),value:Fr}),Hr=Fe("type",[qr]),pn=k(Hr),kt=h({app:Rr,campaign:fn,gdpr:h({isConsentGiven:q()}),library:Vr,locale:l(),location:f(zt),userAgent:f(l())}),te=h({channel:Mr,context:g(kt,{page:f(he),screen:f(Tt)}),messageId:l(),originalTimestamp:Ot(),sentAt:Ot(),timestamp:Ot(),userId:f(l())}),hn=g(te,{type:v("alias")}),de=g(te,{type:v("component"),componentType:X([v("Entry"),v("Variable")]),componentId:l(),experienceId:f(l()),variantIndex:C()}),gn=g(te,{type:v("group")}),Pt=g(te,{type:v("identify"),traits:At}),vn=g(kt,{page:he}),Ct=g(te,{type:v("page"),name:f(l()),properties:he,context:vn}),yn=g(kt,{screen:Tt}),It=g(te,{type:v("screen"),name:l(),properties:f(He),context:yn}),$t=g(te,{type:v("track"),event:l(),properties:He}),oe={anonymousId:l()},Kr=Fe("type",[g(hn,oe),g(de,oe),g(gn,oe),g(Pt,oe),g(Ct,oe),g(It,oe),g($t,oe)]),Is=k(Kr),mn=Fe("type",[hn,de,gn,Pt,Ct,It,$t]),Be=k(mn),Yr=h({features:f(k(l()))}),$s=h({events:Be.check(Yo(1)),options:f(Yr)}),Wr=h({experienceId:l(),variantIndex:C(),variants:pe(l(),l()),sticky:f(K(q(),!1))}),_n=k(Wr),Gr=h({profile:Ke,experiences:_n,changes:pn}),it=g(Br,{data:Gr}),bn=Fe("type",[de]),Jr=k(bn),Qr=h({profile:Lr,events:Jr}),wn=k(Qr);var Ht=[],Os=t=>new RegExp(t.replace(/\*/g,".*")+"$"),Rs=t=>{Ht=t.split(/[\s,]+/).map(Os)},ge=(t,e,n,...r)=>{for(let i=Ht.length;i--;)if(Ht[i].test(t))return e({name:t,level:n,messages:r})},Ms=t=>{let e="";const n=console[t.level==="fatal"?"error":t.level];t.name&&(e+=`[${t.name}] `),typeof t.messages[0]=="object"?n(e,...t.messages):n(e+t.messages.shift(),...t.messages)},Xr=(t,e)=>({fatal:ge.bind(0,t,e=e||Ms,"fatal"),error:ge.bind(0,t,e,"error"),warn:ge.bind(0,t,e,"warn"),debug:ge.bind(0,t,e,"debug"),info:ge.bind(0,t,e,"info"),log:ge.bind(0,t,e,"log")}),Pe=Xr("");Pe.fatal;Pe.error;Pe.warn;Pe.debug;Pe.info;Pe.log;class ei{name="@contentful/optimization";PREFIX_PARTS=["Ctfl","O10n"];DELIMITER=":";diary;sinks=[];constructor(){this.diary=Xr(this.name,this.onLogEvent.bind(this)),Rs(this.name)}assembleLocationPrefix(e){return`[${[...this.PREFIX_PARTS,e].join(this.DELIMITER)}]`}addSink(e){this.sinks=[...this.sinks.filter(n=>n.name!==e.name),e]}removeSink(e){this.sinks=this.sinks.filter(n=>n.name!==e)}removeSinks(){this.sinks=[]}debug(e,n,...r){this.diary.debug(`${this.assembleLocationPrefix(e)} ${n}`,...r)}info(e,n,...r){this.diary.info(`${this.assembleLocationPrefix(e)} ${n}`,...r)}log(e,n,...r){this.diary.log(`${this.assembleLocationPrefix(e)} ${n}`,...r)}warn(e,n,...r){this.diary.warn(`${this.assembleLocationPrefix(e)} ${n}`,...r)}error(e,n,...r){this.diary.error(`${this.assembleLocationPrefix(e)} ${n}`,...r)}fatal(e,n,...r){this.diary.fatal(`${this.assembleLocationPrefix(e)} ${n}`,...r)}onLogEvent(e){this.sinks.forEach(n=>{n.ingest(e)})}}const G=new ei;function P(t){return{debug:(e,...n)=>{G.debug(t,e,...n)},info:(e,...n)=>{G.info(t,e,...n)},log:(e,...n)=>{G.log(t,e,...n)},warn:(e,...n)=>{G.warn(t,e,...n)},error:(e,...n)=>{G.error(t,e,...n)},fatal:(e,...n)=>{G.fatal(t,e,...n)}}}class ti{}var ve={fatal:60,error:50,warn:40,info:30,debug:20,log:10},xs=(t,e)=>e in ve&&t in ve?ve[e]===ve[t]?0:ve[e]<ve[t]?1:-1:0;const Vs={debug:(...t)=>{console.debug(...t)},info:(...t)=>{console.info(...t)},log:(...t)=>{console.log(...t)},warn:(...t)=>{console.warn(...t)},error:(...t)=>{console.error(...t)},fatal:(...t)=>{console.error(...t)}},Ns=0;class ni extends ti{name="ConsoleLogSink";verbosity;constructor(e){super(),this.verbosity=e??"error"}ingest(e){xs(this.verbosity,e.level)>Ns||Vs[e.level](...e.messages)}}function Ls(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Rt={},Mt,Cn;function Bs(){if(Cn)return Mt;Cn=1;function t(e,n){typeof n=="boolean"&&(n={forever:n}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=n||{},this._maxRetryTime=n&&n.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}return Mt=t,t.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},t.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},t.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var n=new Date().getTime();if(e&&n-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var i=this;return this._timer=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},r),this._options.unref&&this._timer.unref(),!0},t.prototype.attempt=function(e,n){this._fn=e,n&&(n.timeout&&(this._operationTimeout=n.timeout),n.cb&&(this._operationTimeoutCb=n.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},t.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},t.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},t.prototype.start=t.prototype.try,t.prototype.errors=function(){return this._errors},t.prototype.attempts=function(){return this._attempts},t.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},n=null,r=0,i=0;i<this._errors.length;i++){var o=this._errors[i],s=o.message,a=(e[s]||0)+1;e[s]=a,a>=r&&(n=o,r=a)}return n},Mt}var In;function Us(){return In||(In=1,function(t){var e=Bs();t.operation=function(n){var r=t.timeouts(n);return new e(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},t.timeouts=function(n){if(n instanceof Array)return[].concat(n);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var i in n)r[i]=n[i];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],s=0;s<r.retries;s++)o.push(this.createTimeout(s,r));return n&&n.forever&&!o.length&&o.push(this.createTimeout(s,r)),o.sort(function(a,c){return a-c}),o},t.createTimeout=function(n,r){var i=r.randomize?Math.random()+1:1,o=Math.round(i*Math.max(r.minTimeout,1)*Math.pow(r.factor,n));return o=Math.min(o,r.maxTimeout),o},t.wrap=function(n,r,i){if(r instanceof Array&&(i=r,r=null),!i){i=[];for(var o in n)typeof n[o]=="function"&&i.push(o)}for(var s=0;s<i.length;s++){var a=i[s],c=n[a];n[a]=(function(d){var m=t.operation(r),b=Array.prototype.slice.call(arguments,1),S=b.pop();b.push(function(_){m.retry(_)||(_&&(arguments[0]=m.mainError()),S.apply(this,arguments))}),m.attempt(function(){d.apply(n,b)})}).bind(n,c),n[a].options=r}}}(Rt)),Rt}var xt,$n;function Ds(){return $n||($n=1,xt=Us()),xt}var js=Ds();const Zs=Ls(js),Fs=Object.prototype.toString,qs=t=>Fs.call(t)==="[object Error]",Hs=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);function Ks(t){return t&&qs(t)&&t.name==="TypeError"&&typeof t.message=="string"?t.message==="Load failed"?t.stack===void 0:Hs.has(t.message):!1}class Ys extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const On=(t,e,n)=>{const r=n.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=r,t};async function Ws(t,e){return new Promise((n,r)=>{e={...e},e.onFailedAttempt??=()=>{},e.shouldRetry??=()=>!0,e.retries??=10;const i=Zs.operation(e),o=()=>{i.stop(),r(e.signal?.reason)};e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",o,{once:!0});const s=()=>{e.signal?.removeEventListener("abort",o),i.stop()};i.attempt(async a=>{try{const c=await t(a);s(),n(c)}catch(c){try{if(!(c instanceof Error))throw new TypeError(`Non-error was thrown: "${c}". You should only throw errors.`);if(c instanceof Ys)throw c.originalError;if(c instanceof TypeError&&!Ks(c))throw c;if(On(c,a,e),await e.shouldRetry(c)||(i.stop(),r(c)),await e.onFailedAttempt(c),!i.retry(c))throw i.mainError()}catch(u){On(u,a,e),s(),r(u)}}})})}const Vt=P("ApiClient:Retry"),Gs=0,Js=1,Nt=503,Qs=500;class vt extends Error{status;constructor(e,n=Qs){super(e),Object.setPrototypeOf(this,vt.prototype),this.status=n}}function Xs({apiName:t="Optimization",controller:e,fetchMethod:n=fetch,init:r,url:i}){return async()=>{try{const o=await n(i,r);if(o.status===Nt)throw new vt(`${t} API request to "${i.toString()}" failed with status: "[${o.status}] ${o.statusText}".`,Nt);if(!o.ok){const s=new Error(`Request to "${i.toString()}" failed with status: [${o.status}] ${o.statusText} - traceparent: ${o.headers.get("traceparent")}`);Vt.error("Request failed with non-OK status:",s),e.abort();return}return Vt.debug(`Response from "${i.toString()}":`,o),o}catch(o){if(o instanceof vt&&o.status===Nt)throw o;Vt.error(`Request to "${i.toString()}" failed:`,o),e.abort()}}}function ea({apiName:t="Optimization",fetchMethod:e=fetch,intervalTimeout:n=Gs,onFailedAttempt:r,retries:i=Js}={}){return async(o,s)=>{const a=new AbortController;let c;try{c=await Ws(Xs({apiName:t,controller:a,fetchMethod:e,init:s,url:o}),{minTimeout:n,onFailedAttempt:u=>r?.({...u,apiName:t}),retries:i,signal:a.signal})}catch(u){if(!(u instanceof Error)||u.name!=="AbortError")throw u}if(!c)throw new Error(`${t} API request to "${o.toString()}" may not be retried.`);return c}}const ta=P("ApiClient:Timeout"),na=3e3;function ra({apiName:t="Optimization",fetchMethod:e=fetch,onRequestTimeout:n,requestTimeout:r=na}={}){return async(i,o)=>{const s=new AbortController,a=setTimeout(()=>{typeof n=="function"?n({apiName:t}):ta.error(`Request to "${i.toString()}" timed out`,new Error("Request timeout")),s.abort()},r),c=await e(i,{...o,signal:s.signal});return clearTimeout(a),c}}const Rn=P("ApiClient:Fetch");function ia(t){try{const e=ra(t);return ea({...t,fetchMethod:e})}catch(e){throw e instanceof Error&&(e.name==="AbortError"?Rn.warn("Request aborted due to network issues. This request may not be retried."):Rn.error("Request failed:",e)),e}}const oa={create:ia},Mn=P("ApiClient"),sa="main";class ri{name;clientId;environment;fetch;constructor(e,{fetchOptions:n,clientId:r,environment:i}){this.clientId=r,this.environment=i??sa,this.name=e,this.fetch=oa.create({...n??{},apiName:e})}logRequestError(e,{requestName:n}){e instanceof Error&&(e.name==="AbortError"?Mn.warn(`[${this.name}] "${n}" request aborted due to network issues. This request may not be retried.`):Mn.error(`[${this.name}] "${n}" request failed:`,e))}}const B=P("ApiClient:Experience"),ii="https://experience.ninetailed.co/";class aa extends ri{baseUrl;enabledFeatures;ip;locale;plainText;preflight;constructor(e){super("Experience",e);const{baseUrl:n,enabledFeatures:r,ip:i,locale:o,plainText:s,preflight:a}=e;this.baseUrl=n||ii,this.enabledFeatures=r,this.ip=i,this.locale=o,this.plainText=s,this.preflight=a}async getProfile(e,n={}){if(!e)throw new Error("Valid profile ID required.");const r="Get Profile";B.info(`Sending "${r}" request`);try{const i=await this.fetch(this.constructUrl(`v2/organizations/${this.clientId}/environments/${this.environment}/profiles/${e}`,n),{method:"GET"}),{data:{changes:o,experiences:s,profile:a}}=it.parse(await i.json()),c={changes:o,personalizations:s,profile:a};return B.debug(`"${r}" request successfully completed`),c}catch(i){throw this.logRequestError(i,{requestName:r}),i}}async makeProfileMutationRequest({url:e,body:n,options:r}){return await this.fetch(this.constructUrl(e,r),{method:"POST",headers:this.constructHeaders(r),body:JSON.stringify(n),keepalive:!0})}async createProfile({events:e},n={}){const r="Create Profile";B.info(`Sending "${r}" request`);const i={events:Be.parse(e),options:this.constructBodyOptions(n)};B.debug(`"${r}" request body:`,i);try{const o=await this.makeProfileMutationRequest({url:`v2/organizations/${this.clientId}/environments/${this.environment}/profiles`,body:i,options:n}),{data:{changes:s,experiences:a,profile:c}}=it.parse(await o.json()),u={changes:s,personalizations:a,profile:c};return B.debug(`"${r}" request successfully completed`),u}catch(o){throw this.logRequestError(o,{requestName:r}),o}}async updateProfile({profileId:e,events:n},r={}){if(!e)throw new Error("Valid profile ID required.");const i="Update Profile";B.info(`Sending "${i}" request`);const o={events:Be.parse(n),options:this.constructBodyOptions(r)};B.debug(`"${i}" request body:`,o);try{const s=await this.makeProfileMutationRequest({url:`v2/organizations/${this.clientId}/environments/${this.environment}/profiles/${e}`,body:o,options:r}),{data:{changes:a,experiences:c,profile:u}}=it.parse(await s.json()),d={changes:a,personalizations:c,profile:u};return B.debug(`"${i}" request successfully completed`),d}catch(s){throw this.logRequestError(s,{requestName:i}),s}}async upsertProfile({profileId:e,events:n},r){return e?await this.updateProfile({profileId:e,events:n},r):await this.createProfile({events:n},r)}async upsertManyProfiles({events:e},n={}){const r="Upsert Many Profiles";B.info(`Sending "${r}" request`);const i={events:Be.parse(e),options:this.constructBodyOptions(n)};B.debug(`"${r}" request body:`,i);try{const o=await this.makeProfileMutationRequest({url:`v2/organizations/${this.clientId}/environments/${this.environment}/events`,body:i,options:{plainText:!1,...n}}),{data:{profiles:s}}=Dr.parse(await o.json());return B.debug(`"${r}" request successfully completed`),s}catch(o){throw this.logRequestError(o,{requestName:r}),o}}constructUrl(e,n){const r=new URL(e,this.baseUrl),i=n.locale??this.locale,o=n.preflight??this.preflight;return i&&r.searchParams.set("locale",i),o&&r.searchParams.set("type","preflight"),r.toString()}constructHeaders({ip:e=this.ip,plainText:n=this.plainText}){const r=new Map;return e&&r.set("X-Force-IP",e),n??this.plainText??!0?r.set("Content-Type","text/plain"):r.set("Content-Type","application/json"),Object.fromEntries(r)}constructBodyOptions=({enabledFeatures:e=this.enabledFeatures})=>{const n={};return e&&Array.isArray(e)&&e.length>0?n.features=e:n.features=["ip-enrichment","location"],n}}const Ce=P("ApiClient:Insights"),oi="https://ingest.insights.ninetailed.co/";class ca extends ri{baseUrl;beaconHandler;constructor(e){super("Insights",e);const{baseUrl:n,beaconHandler:r}=e;this.baseUrl=n??oi,this.beaconHandler=r}async sendBatchEvents(e,n={}){const{beaconHandler:r=this.beaconHandler}=n,i=new URL(`v1/organizations/${this.clientId}/environments/${this.environment}/events`,this.baseUrl),o=wn.parse(e);if(typeof r=="function"){if(Ce.debug("Queueing events via beaconHandler"),r(i,o))return!0;Ce.warn("beaconHandler failed to queue events; events will be emitted immediately via fetch")}const s="Event Batches";Ce.info(`Sending "${s}" request`),Ce.debug(`"${s}" request body:`,o);try{return await this.fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),keepalive:!0}),Ce.debug(`"${s}" request successfully completed`),!0}catch(a){return this.logRequestError(a,{requestName:s}),!1}}}class si{config;experience;insights;constructor(e){const{personalization:n,analytics:r,...i}=e;this.config=i,this.experience=new aa({...i,...n}),this.insights=new ca({...i,...r})}}function ua(){}function xn(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Vn(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const la="[object RegExp]",da="[object String]",fa="[object Number]",pa="[object Boolean]",Nn="[object Arguments]",ha="[object Symbol]",ga="[object Date]",va="[object Map]",ya="[object Set]",ma="[object Array]",_a="[object Function]",ba="[object ArrayBuffer]",Lt="[object Object]",wa="[object Error]",Ea="[object DataView]",Sa="[object Uint8Array]",za="[object Uint8ClampedArray]",Ta="[object Uint16Array]",Aa="[object Uint32Array]",ka="[object BigUint64Array]",Pa="[object Int8Array]",Ca="[object Int16Array]",Ia="[object Int32Array]",$a="[object BigInt64Array]",Oa="[object Float32Array]",Ra="[object Float64Array]";function yt(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function mt(t){return t==="__proto__"}function _e(t,e){const n=Object.keys(e);for(let r=0;r<n.length;r++){const i=n[r];if(mt(i))continue;const o=e[i],s=t[i];Array.isArray(o)?Array.isArray(s)?t[i]=_e(s,o):t[i]=_e([],o):yt(o)?yt(s)?t[i]=_e(s,o):t[i]=_e({},o):(s===void 0||o!==void 0)&&(t[i]=o)}return t}function Ma(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function xa(t,e,n){return Ve(t,e,void 0,void 0,void 0,void 0,n)}function Ve(t,e,n,r,i,o,s){const a=s(t,e,n,r,i,o);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return Ue(t,e,o,s)}return Ue(t,e,o,s)}function Ue(t,e,n,r){if(Object.is(t,e))return!0;let i=Vn(t),o=Vn(e);if(i===Nn&&(i=Lt),o===Nn&&(o=Lt),i!==o)return!1;switch(i){case da:return t.toString()===e.toString();case fa:{const c=t.valueOf(),u=e.valueOf();return Ma(c,u)}case pa:case ga:case ha:return Object.is(t.valueOf(),e.valueOf());case la:return t.source===e.source&&t.flags===e.flags;case _a:return t===e}n=n??new Map;const s=n.get(t),a=n.get(e);if(s!=null&&a!=null)return s===e;n.set(t,e),n.set(e,t);try{switch(i){case va:{if(t.size!==e.size)return!1;for(const[c,u]of t.entries())if(!e.has(c)||!Ve(u,e.get(c),c,t,e,n,r))return!1;return!0}case ya:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),u=Array.from(e.values());for(let d=0;d<c.length;d++){const m=c[d],b=u.findIndex(S=>Ve(m,S,void 0,t,e,n,r));if(b===-1)return!1;u.splice(b,1)}return!0}case ma:case Sa:case za:case Ta:case Aa:case ka:case Pa:case Ca:case Ia:case $a:case Oa:case Ra:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Ve(t[c],e[c],c,t,e,n,r))return!1;return!0}case ba:return t.byteLength!==e.byteLength?!1:Ue(new Uint8Array(t),new Uint8Array(e),n,r);case Ea:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:Ue(new Uint8Array(t),new Uint8Array(e),n,r);case wa:return t.name===e.name&&t.message===e.message;case Lt:{if(!(Ue(t.constructor,e.constructor,n,r)||yt(t)&&yt(e)))return!1;const u=[...Object.keys(t),...xn(t)],d=[...Object.keys(e),...xn(e)];if(u.length!==d.length)return!1;for(let m=0;m<u.length;m++){const b=u[m],S=t[b];if(!Object.hasOwn(e,b))return!1;const _=e[b];if(!Ve(S,_,b,t,e,n,r))return!1}return!0}default:return!1}}finally{n.delete(t),n.delete(e)}}function Bt(t,e){return xa(t,e,ua)}const Ye=h({campaign:f(fn),locale:f(l()),location:f(zt),page:f(he),screen:f(Tt),userAgent:f(l())}),Va=g(Ye,{componentId:l(),experienceId:f(l()),variantIndex:f(C()),sticky:f(q())}),Na=g(Ye,{traits:f(At),userId:l()}),La=g(Ye,{properties:f(ss(he))}),Ba=g(Ye,{name:l(),properties:He}),Ua=g(Ye,{event:l(),properties:f(K(He,{}))}),Kt={path:"",query:{},referrer:"",search:"",title:"",url:""};class ai{app;channel;library;getLocale;getPageProperties;getUserAgent;constructor(e){const{app:n,channel:r,library:i,getLocale:o,getPageProperties:s,getUserAgent:a}=e;this.app=n,this.channel=r,this.library=i,this.getLocale=o??(()=>"en-US"),this.getPageProperties=s??(()=>Kt),this.getUserAgent=a??(()=>{})}buildUniversalEventProperties({campaign:e={},locale:n,location:r,page:i,screen:o,userAgent:s}){const a=new Date().toISOString();return{channel:this.channel,context:{app:this.app,campaign:e,gdpr:{isConsentGiven:!0},library:this.library,locale:n??this.getLocale()??"en-US",location:r,page:i??this.getPageProperties(),screen:o,userAgent:s??this.getUserAgent()},messageId:crypto.randomUUID(),originalTimestamp:a,sentAt:a,timestamp:a}}buildComponentView(e){const{componentId:n,experienceId:r,variantIndex:i,...o}=Va.parse(e);return{...this.buildUniversalEventProperties(o),type:"component",componentType:"Entry",componentId:n,experienceId:r,variantIndex:i??0}}buildFlagView(e){return{...this.buildComponentView(e),componentType:"Variable"}}buildIdentify(e){const{traits:n={},userId:r,...i}=Na.parse(e);return{...this.buildUniversalEventProperties(i),type:"identify",traits:n,userId:r}}buildPageView(e={}){const{properties:n={},...r}=La.parse(e),i=this.getPageProperties(),o=_e({...i,title:i.title??Kt.title},n),{context:{screen:s,...a},...c}=this.buildUniversalEventProperties(r),u=vn.parse(a);return{...c,context:u,type:"page",properties:o}}buildScreenView(e){const{name:n,properties:r,...i}=Ba.parse(e),{context:{page:o,...s},...a}=this.buildUniversalEventProperties(i),c=yn.parse(s);return{...a,context:c,type:"screen",name:n,properties:r}}buildTrack(e){const{event:n,properties:r={},...i}=Ua.parse(e);return{...this.buildUniversalEventProperties(i),type:"track",event:n,properties:r}}}function Da(t){switch(typeof t){case"number":case"symbol":return!1;case"string":return t.includes(".")||t.includes("[")||t.includes("]")}}function ja(t){return typeof t=="string"||typeof t=="symbol"?t:Object.is(t?.valueOf?.(),-0)?"-0":String(t)}function Za(t){const e=[],n=t.length;if(n===0)return e;let r=0,i="",o="",s=!1;for(t.charCodeAt(0)===46&&(e.push(""),r++);r<n;){const a=t[r];o?a==="\\"&&r+1<n?(r++,i+=t[r]):a===o?o="":i+=a:s?a==='"'||a==="'"?o=a:a==="]"?(s=!1,e.push(i),i=""):i+=a:a==="["?(s=!0,i&&(e.push(i),i="")):a==="."?i&&(e.push(i),i=""):i+=a,r++}return i&&e.push(i),e}function Yt(t,e,n){if(t==null)return n;switch(typeof e){case"string":{if(mt(e))return n;const r=t[e];return r===void 0?Da(e)?Yt(t,Za(e),n):n:r}case"number":case"symbol":{typeof e=="number"&&(e=ja(e));const r=t[e];return r===void 0?n:r}default:{if(Array.isArray(e))return Fa(t,e,n);if(Object.is(e?.valueOf(),-0)?e="-0":e=String(e),mt(e))return n;const r=t[e];return r===void 0?n:r}}}function Fa(t,e,n){if(e.length===0)return n;let r=t;for(let i=0;i<e.length;i++){if(r==null||mt(e[i]))return n;r=r[e[i]]}return r===void 0?n:r}const Ln=P("Personalization"),Bn="Could not resolve Merge Tag value:",Ee={isMergeTagEntry(t){return br.safeParse(t).success},normalizeSelectors(t){return t.split("_").map((e,n,r)=>{const i=r.slice(0,n).join("."),o=r.slice(n).join("_");return[i,o].filter(s=>s!=="").join(".")})},getValueFromProfile(t,e){const r=Ee.normalizeSelectors(t).find(o=>Yt(e,o));if(!r)return;const i=Yt(e,r);if(!(!i||typeof i!="string"&&typeof i!="number"&&typeof i!="boolean"))return`${i}`},resolve(t,e){if(!Ee.isMergeTagEntry(t)){Ln.warn(`${Bn} supplied entry is not a Merge Tag entry`);return}const{fields:{nt_fallback:n}}=t;return Ke.safeParse(e).success?Ee.getValueFromProfile(t.fields.nt_mergetag_id,e)??n:(Ln.warn(`${Bn} no valid profile`),n)}},W=P("Personalization"),Ie="Could not resolve personalized entry variant:",ue={getPersonalizationEntry({personalizedEntry:t,selectedPersonalizations:e},n=!1){return!n&&(!e.length||!rt(t))?void 0:t.fields.nt_experiences.filter(i=>xe(i)).find(i=>e.some(({experienceId:o})=>o===i.fields.nt_experience_id))},getSelectedPersonalization({personalizationEntry:t,selectedPersonalizations:e},n=!1){return!n&&(!e.length||!xe(t))?void 0:e.find(({experienceId:i})=>i===t.fields.nt_experience_id)},getSelectedVariant({personalizedEntry:t,personalizationEntry:e,selectedVariantIndex:n},r=!1){if(!r&&(!rt(t)||!xe(e)))return;const i=e.fields.nt_config?.components?.filter(o=>Sr(o)&&!o.baseline.hidden).find(o=>o.baseline.id===t.sys.id)?.variants;if(i?.length)return i.at(n-1)},getSelectedVariantEntry({personalizationEntry:t,selectedVariant:e},n=!1){if(!n&&(!xe(t)||!wr(e)))return;const r=t.fields.nt_variants?.find(i=>i.sys.id===e.id);return mr(r)?r:void 0},resolve(t,e){if(W.debug(`Resolving personalized entry for baseline entry ${t.sys.id}`),!e?.length)return W.warn(`${Ie} no selectedPersonalizations exist for the current profile`),{entry:t};if(!rt(t))return W.warn(`${Ie} entry ${t.sys.id} is not personalized`),{entry:t};const n=ue.getPersonalizationEntry({personalizedEntry:t,selectedPersonalizations:e},!0);if(!n)return W.warn(`${Ie} could not find a personalization entry for ${t.sys.id}`),{entry:t};const r=ue.getSelectedPersonalization({personalizationEntry:n,selectedPersonalizations:e},!0),i=r?.variantIndex??0;if(i===0)return W.debug(`Resolved personalization entry for entry ${t.sys.id} is baseline`),{entry:t};const o=ue.getSelectedVariant({personalizedEntry:t,personalizationEntry:n,selectedVariantIndex:i},!0);if(!o)return W.warn(`${Ie} could not find a valid replacement variant entry for ${t.sys.id}`),{entry:t};const s=ue.getSelectedVariantEntry({personalizationEntry:n,selectedVariant:o},!0);if(s)W.debug(`Entry ${t.sys.id} has been resolved to variant entry ${s.sys.id}`);else return W.warn(`${Ie} could not find a valid replacement variant entry for ${t.sys.id}`),{entry:t};return{entry:s,personalization:r}}},J=Se(),Z=Se(),Y=Se(),En=Jn(()=>ft.resolve(J.value??[])),je=Se(!0),F=Se(),A=Se();function j(t){return{subscribe(e){return{unsubscribe:R(()=>{e(t.value)})}}}}const be={changes:J,consent:Z,event:Y,flags:En,online:je,personalizations:F,profile:A},ci={batch:le,computed:Jn,effect:R,untracked:nn},et=t=>typeof t=="function",qa=t=>typeof t=="string"?t:typeof t=="symbol"?t.description??String(t):String(t),Ha=t=>typeof t=="string"||typeof t=="symbol",Ka=t=>Object.prototype.toString.call(t)==="[object AsyncFunction]";function D(t,e){return function(n,r){const i=qa(r.name);r.addInitializer(function(){const s=Reflect.get(this,r.name);if(!et(s))return;const a=s,c=Ka(a),u=_=>{const{[t]:L}=_;if(!et(L))throw new TypeError(`@guardedBy expects predicate "${String(t)}" to be a synchronous function.`);return L},d=(_,L)=>{const x=!!u(_).call(_,i,L);return e?.invert===!0?!x:x},m=(_,L)=>{const{onBlocked:I}=e??{};if(I!==void 0){if(et(I)){I.call(_,i,L);return}if(Ha(I)){const{[I]:x}=_;et(x)&&x.call(_,i,L)}}},b=()=>c?Promise.resolve(void 0):void 0,S=function(..._){return d(this,_)?a.call(this,..._):(m(this,_),b())};Reflect.set(this,r.name,S)})}}class ui{#e;constructor(e){const n=new Map;e&&Object.entries(e).map(([r,i])=>n.set(r.length?r:void 0,new Set(i))),this.#e=n}isPresent(e,n){return this.#e.get(e)?.has(n)??!1}addValue(e,n){const r=this.#e.get(e);r?r.add(n):this.#e.set(e,new Set([n]))}removeValue(e,n){this.#e.get(e)?.delete(n)}reset(e){e!==void 0?this.#e.get(e)?.clear():this.#e.clear()}}const Ya=["page","identify"];class li{allowedEventTypes;builder;api;duplicationDetector;interceptors;constructor(e){const{api:n,builder:r,config:i,interceptors:o}=e;this.allowedEventTypes=i?.allowedEventTypes??Ya,this.api=n,this.builder=r,this.duplicationDetector=new ui(i?.preventedComponentEvents),this.interceptors=o}}class di extends li{}var Wa=Object.create,fi=Object.defineProperty,Ga=Object.getOwnPropertyDescriptor,pi=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hi=t=>{throw TypeError(t)},gi=(t,e,n)=>e in t?fi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ja=t=>[,,,Wa(t?.[pi("metadata")]??null)],vi=["class","method","getter","setter","accessor","field","value","get","set"],yi=t=>t!==void 0&&typeof t!="function"?hi("Function expected"):t,Qa=(t,e,n,r,i)=>({kind:vi[t],name:e,metadata:r,addInitializer:o=>n._?hi("Already initialized"):i.push(yi(o||null))}),Xa=(t,e)=>gi(e,pi("metadata"),t[3]),ec=(t,e,n,r)=>{for(var i=0,o=t[e>>1],s=o&&o.length;i<s;i++)o[i].call(n);return r},mi=(t,e,n,r,i,o)=>{for(var s,a,c,u,d=e&7,m=!1,b=!1,S=2,_=vi[d+5],L=t[S]||(t[S]=[]),I=(i=i.prototype,Ga(i,n)),x=r.length-1;x>=0;x--)c=Qa(d,n,a={},t[3],L),c.static=m,c.private=b,u=c.access={has:ie=>n in ie},u.get=ie=>ie[n],s=(0,r[x])(I[_],c),a._=1,yi(s)&&(I[_]=s);return I&&fi(i,n,I),i},Un=(t,e,n)=>gi(t,typeof e!="symbol"?e+"":e,n),_i,bi,Wt,We;const H=P("Analytics"),tc=25;class Ge extends(Wt=di,bi=[D("isNotDuplicated",{onBlocked:"onBlockedByDuplication"}),D("hasConsent",{onBlocked:"onBlockedByConsent"})],_i=[D("isNotDuplicated",{onBlocked:"onBlockedByDuplication"}),D("hasConsent",{onBlocked:"onBlockedByConsent"})],Wt){constructor(e){const{api:n,builder:r,config:i,interceptors:o}=e;super({api:n,builder:r,config:i,interceptors:o}),ec(We,5,this),Un(this,"queue",new Map),Un(this,"states",{eventStream:j(Y),profile:j(A)});const{defaults:s}=i??{};if(s?.profile!==void 0){const{profile:a}=s;A.value=a}R(()=>{const a=A.value?.id;H.info(`Analytics ${Z.value?"will":"will not"} be collected due to consent (${Z.value})`),H.debug(`Profile ${a&&`with ID ${a}`} has been ${a?"set":"cleared"}`)}),R(()=>{je.value&&this.flush()})}reset(){le(()=>{Y.value=void 0,A.value=void 0})}hasConsent(e){return!!Z.value||(this.allowedEventTypes??[]).includes(e==="trackComponentView"||e==="trackFlagView"?"component":e)}onBlockedByConsent(e,n){H.warn(`Event "${e}" was blocked due to lack of consent; payload: ${JSON.stringify(n)}`)}isNotDuplicated(e,n){const[{componentId:r},i]=n,o=this.duplicationDetector.isPresent(i,r);return o||this.duplicationDetector.addValue(i,r),!o}onBlockedByDuplication(e,n){const r=e==="trackFlagView"?"flag":"component";H.debug(`Duplicate "${r} view" event detected, skipping; payload: ${JSON.stringify(n)}`)}async trackComponentView(e,n=""){H.info(`Processing "component view" event for ${e.componentId}`),await this.enqueueEvent(this.builder.buildComponentView(e))}async trackFlagView(e,n=""){H.debug(`Processing "flag view" event for ${e.componentId}`),await this.enqueueEvent(this.builder.buildFlagView(e))}async enqueueEvent(e){const{value:n}=A;if(!n){H.warn("Attempting to emit an event without an Optimization profile");return}const r=await this.interceptors.event.run(e),i=bn.parse(r);H.debug(`Queueing ${i.type} event for profile ${n.id}`,i);const o=this.queue.get(n);Y.value=i,o?o.push(i):this.queue.set(n,[i]),await this.flushMaxEvents()}async flushMaxEvents(){this.queue.values().toArray().flat().length>=tc&&await this.flush()}async flush(){H.debug("Flushing event queue");const e=[];if(this.queue.forEach((r,i)=>e.push({profile:i,events:r})),!e.length)return;await this.api.insights.sendBatchEvents(e)&&this.queue.clear()}}We=Ja(Wt);mi(We,1,"trackComponentView",bi,Ge);mi(We,1,"trackFlagView",_i,Ge);Xa(We,Ge);const Dn=P("Analytics");class wi extends di{async trackComponentView(e){Dn.info('Processing "component view" event');const{profile:n,...r}=e,i=this.builder.buildComponentView(r),o=await this.interceptors.event.run(i),s=de.parse(o);await this.sendBatchEvent(s,n)}async trackFlagView(e){Dn.debug('Processing "flag view" event');const{profile:n,...r}=e,i=this.builder.buildFlagView(r),o=await this.interceptors.event.run(i),s=de.parse(o);await this.sendBatchEvent(s,n)}async sendBatchEvent(e,n){const r=wn.parse([{profile:n,events:[e]}]);await this.api.insights.sendBatchEvents(r)}}const Ei="0.1.0-alpha4",Ne="ctfl-opt-aid",ot="__ctfl_opt_anonymous_id__",st="__ctfl_opt_consent__",at="__ctfl_opt_changes__",ct="__ctfl_opt_debug__",ut="__ctfl_opt_profile__",lt="__ctfl_opt_personalizations__",Gt="ntaid",Jt="__nt_anonymous_id__";class Qt{interceptors=new Map;nextId=0;add(e){const{nextId:n}=this;return this.nextId+=1,this.interceptors.set(n,e),n}remove(e){return this.interceptors.delete(e)}clear(){this.interceptors.clear()}count(){return this.interceptors.size}async run(e){const n=Array.from(this.interceptors.values());let r=e;for(const i of n)r=await i(r);return r}}class Si{api;eventBuilder;config;interceptors={event:new Qt,state:new Qt};constructor(e){this.config=e;const{analytics:n,personalization:r,eventBuilder:i,logLevel:o,environment:s,clientId:a}=e;G.addSink(new ni(o));const c={...n,...r,clientId:a,environment:s};this.api=new si(c),this.eventBuilder=new ai(i??{channel:"server",library:{name:"Optimization Core",version:Ei}})}getCustomFlag(e,n){return this.personalization.getCustomFlag(e,n)}personalizeEntry(e,n){return this.personalization.personalizeEntry(e,n)}getMergeTagValue(e,n){return this.personalization.getMergeTagValue(e,n)}async identify(e){return await this.personalization.identify(e)}async page(e){return await this.personalization.page(e)}async screen(e){return await this.personalization.screen(e)}async track(e){return await this.personalization.track(e)}async trackComponentView(e,n){if(e.sticky)return await this.personalization.trackComponentView(e,n);await this.analytics.trackComponentView(e,n)}async trackFlagView(e,n){await this.analytics.trackFlagView(e,n)}}class zi extends li{flagsResolver=ft;mergeTagValueResolver=Ee;personalizedEntryResolver=ue;getCustomFlag(e,n){return ft.resolve(n)[e]}personalizeEntry(e,n){return ue.resolve(e,n)}getMergeTagValue(e,n){return Ee.resolve(e,n)}}var nc=Object.create,Ti=Object.defineProperty,rc=Object.getOwnPropertyDescriptor,Ai=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ki=t=>{throw TypeError(t)},Pi=(t,e,n)=>e in t?Ti(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ic=t=>[,,,nc(t?.[Ai("metadata")]??null)],Ci=["class","method","getter","setter","accessor","field","value","get","set"],Ii=t=>t!==void 0&&typeof t!="function"?ki("Function expected"):t,oc=(t,e,n,r,i)=>({kind:Ci[t],name:e,metadata:r,addInitializer:o=>n._?ki("Already initialized"):i.push(Ii(o||null))}),sc=(t,e)=>Pi(e,Ai("metadata"),t[3]),ac=(t,e,n,r)=>{for(var i=0,o=t[e>>1],s=o&&o.length;i<s;i++)o[i].call(n);return r},Je=(t,e,n,r,i,o)=>{for(var s,a,c,u,d=e&7,m=!1,b=!1,S=2,_=Ci[d+5],L=t[S]||(t[S]=[]),I=(i=i.prototype,rc(i,n)),x=r.length-1;x>=0;x--)c=oc(d,n,a={},t[3],L),c.static=m,c.private=b,u=c.access={has:ie=>n in ie},u.get=ie=>ie[n],s=(0,r[x])(I[_],c),a._=1,Ii(s)&&(I[_]=s);return I&&Ti(i,n,I),i},Ut=(t,e,n)=>Pi(t,typeof e!="symbol"?e+"":e,n),$i,Oi,Ri,Mi,xi,Xt,ne;const V=P("Personalization");class re extends(Xt=zi,xi=[D("hasConsent",{onBlocked:"onBlockedByConsent"})],Mi=[D("hasConsent",{onBlocked:"onBlockedByConsent"})],Ri=[D("hasConsent",{onBlocked:"onBlockedByConsent"})],Oi=[D("hasConsent",{onBlocked:"onBlockedByConsent"})],$i=[D("isNotDuplicated",{onBlocked:"onBlockedByDuplication"}),D("hasConsent",{onBlocked:"onBlockedByConsent"})],Xt){constructor(e){const{api:n,builder:r,config:i,interceptors:o}=e;super({api:n,builder:r,config:i,interceptors:o}),ac(ne,5,this),Ut(this,"offlineQueue",new Set),Ut(this,"states",{eventStream:j(Y),flags:j(En),profile:j(A),personalizations:j(F)}),Ut(this,"getAnonymousId");const{defaults:s,getAnonymousId:a}=i??{};if(s){const{changes:c,personalizations:u,profile:d}=s;le(()=>{J.value=c,F.value=u,A.value=d})}if(s?.consent!==void 0){const{consent:c}=s;Z.value=c}this.getAnonymousId=a??(()=>{}),R(()=>{V.debug(`Profile ${A.value&&`with ID ${A.value.id}`} has been ${A.value?"set":"cleared"}`)}),R(()=>{V.debug(`Variants have been ${F.value?.length?"populated":"cleared"}`)}),R(()=>{V.info(`Personalization ${Z.value?"will":"will not"} take effect due to consent (${Z.value})`)}),R(()=>{je.value&&this.flush()})}reset(){le(()=>{J.value=void 0,Y.value=void 0,A.value=void 0,F.value=void 0})}getCustomFlag(e,n=J.value){return super.getCustomFlag(e,n)}personalizeEntry(e,n=F.value){return super.personalizeEntry(e,n)}getMergeTagValue(e,n=A.value){return super.getMergeTagValue(e,n)}hasConsent(e){return!!Z.value||(this.allowedEventTypes??[]).includes(e==="trackComponentView"||e==="trackFlagView"?"component":e)}onBlockedByConsent(e,n){V.warn(`Event "${e}" was blocked due to lack of consent; payload: ${JSON.stringify(n)}`)}isNotDuplicated(e,n){const[{componentId:r},i]=n,o=this.duplicationDetector.isPresent(i,r);return o||this.duplicationDetector.addValue(i,r),!o}onBlockedByDuplication(e,n){V.debug(`Duplicate "component view" event detected, skipping; payload: ${JSON.stringify(n)}`)}async identify(e){V.info('Sending "identify" event');const n=this.builder.buildIdentify(e);return await this.sendOrEnqueueEvent(n)}async page(e){V.info('Sending "page" event');const n=this.builder.buildPageView(e);return await this.sendOrEnqueueEvent(n)}async screen(e){V.info(`Sending "screen" event for "${e.name}"`);const n=this.builder.buildScreenView(e);return await this.sendOrEnqueueEvent(n)}async track(e){V.info(`Sending "track" event "${e.event}"`);const n=this.builder.buildTrack(e);return await this.sendOrEnqueueEvent(n)}async trackComponentView(e,n=""){V.info(`Sending "track personalization" event for ${e.componentId}`);const r=this.builder.buildComponentView(e);return await this.sendOrEnqueueEvent(r)}async sendOrEnqueueEvent(e){const n=await this.interceptors.event.run(e),r=mn.parse(n);if(Y.value=r,je.value)return await this.upsertProfile([r]);V.debug(`Queueing ${r.type} event`,r),this.offlineQueue.add(r)}async flush(){this.offlineQueue.size!==0&&(V.debug("Flushing offline event queue"),await this.upsertProfile(Array.from(this.offlineQueue)),this.offlineQueue.clear())}async upsertProfile(e){const n=this.getAnonymousId();n&&V.debug(`Anonymous ID found: ${n}`);const r=await this.api.experience.upsertProfile({profileId:n??A.value?.id,events:e});return await this.updateOutputSignals(r),r}async updateOutputSignals(e){const n=await this.interceptors.state.run(e),{changes:r,personalizations:i,profile:o}=n;le(()=>{Bt(J.value,r)||(J.value=r),Bt(A.value,o)||(A.value=o),Bt(F.value,i)||(F.value=i)})}}ne=ic(Xt);Je(ne,1,"identify",xi,re);Je(ne,1,"page",Mi,re);Je(ne,1,"screen",Ri,re);Je(ne,1,"track",Oi,re);Je(ne,1,"trackComponentView",$i,re);sc(ne,re);const $e=P("Personalization");class Vi extends zi{async identify(e){$e.info('Sending "identify" event');const{profile:n,...r}=e,i=Pt.parse(this.builder.buildIdentify(r));return await this.upsertProfile(i,n)}async page(e){$e.info('Sending "page" event');const{profile:n,...r}=e,i=Ct.parse(this.builder.buildPageView(r));return await this.upsertProfile(i,n)}async screen(e){$e.info(`Sending "screen" event for "${e.name}"`);const{profile:n,...r}=e,i=It.parse(this.builder.buildScreenView(r));return await this.upsertProfile(i,n)}async track(e){$e.info(`Sending "track" event "${e.event}"`);const{profile:n,...r}=e,i=$t.parse(this.builder.buildTrack(r));return await this.upsertProfile(i,n)}async trackComponentView(e){$e.info('Sending "track personalization" event');const{profile:n,...r}=e,i=de.parse(this.builder.buildComponentView(r));return await this.upsertProfile(i,n)}async upsertProfile(e,n){const r=await this.interceptors.event.run(e);return await this.api.experience.upsertProfile({profileId:n?.id,events:[r]})}}class Ni extends Si{analytics;personalization;constructor(e){super(e);const{allowedEventTypes:n,defaults:r,getAnonymousId:i,preventedComponentEvents:o}=e;if(r?.consent!==void 0){const{consent:s}=r;Z.value=s}this.analytics=new Ge({api:this.api,builder:this.eventBuilder,config:{allowedEventTypes:n,preventedComponentEvents:o,defaults:{consent:r?.consent,profile:r?.profile}},interceptors:this.interceptors}),this.personalization=new re({api:this.api,builder:this.eventBuilder,config:{allowedEventTypes:n,getAnonymousId:i,preventedComponentEvents:o,defaults:{consent:r?.consent,changes:r?.changes,profile:r?.profile,personalizations:r?.personalizations}},interceptors:this.interceptors})}get states(){return{consent:j(Z),eventStream:j(Y),flags:j(En),personalizations:j(F),profile:j(A)}}reset(){le(()=>{Y.value=void 0,J.value=void 0,A.value=void 0,F.value=void 0})}async flush(){await this.analytics.flush(),await this.personalization.flush()}consent(e){Z.value=e}online(e){je.value=e}registerPreviewPanel(e){e.signals=be,e.signalFns=ci}}class cc extends Si{analytics;personalization;constructor(e){super(e),this.analytics=new wi({api:this.api,builder:this.eventBuilder,interceptors:this.interceptors}),this.personalization=new Vi({api:this.api,builder:this.eventBuilder,interceptors:this.interceptors})}}/*! js-cookie v3.0.5 | MIT */function tt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var uc={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function en(t,e){function n(i,o,s){if(!(typeof document>"u")){s=tt({},e,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in s)s[c]&&(a+="; "+c,s[c]!==!0&&(a+="="+s[c].split(";")[0]));return document.cookie=i+"="+t.write(o,i)+a}}function r(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var o=document.cookie?document.cookie.split("; "):[],s={},a=0;a<o.length;a++){var c=o[a].split("="),u=c.slice(1).join("=");try{var d=decodeURIComponent(c[0]);if(s[d]=t.read(u,d),i===d)break}catch{}}return i?s[i]:s}}return Object.create({set:n,get:r,remove:function(i,o){n(i,"",tt({},o,{expires:-1}))},withAttributes:function(i){return en(this.converter,tt({},this.attributes,i))},withConverter:function(i){return en(tt({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var ye=en(uc,{path:"/"});const tn=P("Web:AutoTracking");function Ze(t){if(!(typeof HTMLElement<"u"&&typeof SVGElement<"u")||!t||t.nodeType!==1||!("dataset"in t)||!t.dataset||typeof t.dataset!="object"||!("ctflEntryId"in t.dataset))return!1;const{dataset:{ctflEntryId:n}}=t;return typeof n=="string"&&n.trim().length>0}function jn(t){return!t||typeof t!="object"?!1:"entryId"in t&&typeof t.entryId=="string"&&!!t.entryId.trim().length}function lc(t){return(t?.trim().toLowerCase()??"")==="true"}function dc(t){if(t===void 0||!/^\d+$/.test(t))return;const e=Number(t);return Number.isSafeInteger(e)?e:void 0}const fc=t=>async(e,n)=>{if(!jn(n.data)&&!Ze(e))return;let r,i,o,s,a;if(jn(n.data))({data:{duplicationScope:r,entryId:i,personalizationId:o,sticky:s,variantIndex:a}}=n);else if(Ze(e)){({dataset:{ctflDuplicationScope:r,ctflEntryId:i,ctflPersonalizationId:o}}=e);const{dataset:{ctflSticky:c,ctflVariantIndex:u}}=e;s=lc(c),a=dc(u)}if(!i){tn.warn("No entry data found in entry view observer callback; please add data attributes or observe with data info");return}await t.trackComponentView({componentId:i,experienceId:o,sticky:s,variantIndex:a},r)};function Zn(t){if(Ze(t))return t;const e=t.querySelector("[data-ctfl-entry-id]")??void 0;return Ze(e)?e:void 0}const pc=(t,e=!1)=>({onRemoved:n=>{n.forEach(r=>{const i=Zn(r);!i||!t.getStats(i)||(tn.info("Auto-unobserving element (remove):",i),t.unobserve(i))})},onAdded:e?n=>{n.forEach(r=>{const i=Zn(r);i&&(tn.info("Auto-observing element (add):",i),t.observe(i))})}:void 0}),hc=P("Web:EventBuilder");function gc(t){return new URL(t).searchParams.entries().reduce((e,[n,r])=>(e[n]=r,e),{})}function Li(){const{languages:t,language:e}=navigator;return t[0]??e}function Bi(){try{const t=new URL(window.location.href),{referrer:e,title:n}=document;return{hash:window.location.hash,height:window.innerHeight,path:t.pathname,query:gc(t),referrer:e,search:t.search,title:n,url:t.toString(),width:window.innerWidth}}catch(t){return t instanceof Error&&hc.error("Failed to get page properties:",t),{path:"",query:{},referrer:"",search:"",title:"",url:""}}}function Ui(){return navigator.userAgent}const Di="0.1.0-alpha4",M=typeof window<"u"&&typeof document<"u"&&typeof document.addEventListener=="function";function ji(t,e){const n=new Blob([JSON.stringify(e)],{type:"text/plain"});return window.navigator.sendBeacon(t,n)}const vc=P("Web:Network");function yc(t){if(!M)return()=>{};const e=i=>{(async()=>{try{await t(i)}catch(o){vc.error("Error in online state callback:",o)}})()},n=()=>{e(!0)},r=()=>{e(!1)};return window.addEventListener("online",n),window.addEventListener("offline",r),e(typeof navigator.onLine=="boolean"?navigator.onLine:!0),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}const mc=P("Web:Visibility");function _c(t){if(!M)return()=>{};let e=!1;const n=a=>{e||(e=!0,(async()=>{try{await t(a)}catch(c){mc.error("Error handling page visibility change:",c)}})())},r=()=>{e=!1},i=a=>{document.visibilityState==="hidden"?n(a):r()},o=a=>{n(a)},s=()=>{r()};return document.addEventListener("visibilitychange",i),window.addEventListener("pagehide",o),window.addEventListener("pageshow",s),()=>{document.removeEventListener("visibilitychange",i),window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",s)}}const Oe=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),Re=()=>M?document.visibilityState==="visible":!0,ce={DWELL_MS:1e3,RATIO:.1,MAX_RETRIES:2,BACKOFF_MS:300,MULTIPLIER:2,JITTER_DIVISOR:2,SWEEP_INTERVAL_MS:3e4},bc=t=>t+Math.floor(Math.random()*Math.max(1,Math.floor(t/ce.JITTER_DIVISOR))),N={n:(t,e)=>typeof t=="number"?t:e,clamp01:(t,e)=>Math.min(1,Math.max(0,N.n(t,e))),nonNeg:(t,e)=>Math.max(0,N.n(t,e)),atLeast1:(t,e)=>Math.max(1,N.n(t,e))},se=t=>{t.fireTimer!==null&&(clearTimeout(t.fireTimer),t.fireTimer=null)},ae=t=>{t.retryTimer!==null&&(clearTimeout(t.retryTimer),t.retryTimer=null),t.retryScheduledAt=null},Dt=t=>{if(t.ref&&typeof t.ref.deref=="function"){const e=t.ref.deref();if(e)return e}return t.strongRef??null},Fn=100,qn=250,wc=16,Ec=1,Sc=M&&typeof MutationObserver<"u",Hn=M&&typeof window.requestIdleCallback=="function",zc=M&&typeof window.cancelIdleCallback=="function";class U{observer;root;idleTimeoutMs;maxChunk;onChange;onAdded;onRemoved;onError;pendingRecords=[];scheduled=!1;idleHandle=null;disconnected=!1;constructor(e={}){const{root:n,idleTimeoutMs:r=Fn,maxChunk:i=qn,onChange:o,onAdded:s,onRemoved:a,onError:c}=e;this.root=U.isNode(n)?n:M?document:null,this.idleTimeoutMs=U.sanitizeInt(r,Fn,wc),this.maxChunk=U.sanitizeInt(i,qn,Ec),this.onChange=o,this.onAdded=s,this.onRemoved=a,this.onError=c,Sc&&this.root&&(this.observer=new MutationObserver(u=>{for(const d of u)(d.addedNodes.length>0||d.removedNodes.length>0)&&this.pendingRecords.push(d);this.pendingRecords.length>0&&this.scheduleProcess()}),this.observer.observe(this.root,{childList:!0,subtree:!0}))}isActive(){return!!this.observer&&!this.disconnected}disconnect(){this.disconnected||(this.disconnected=!0,this.observer?.disconnect(),this.pendingRecords=[],this.idleHandle!==null&&(U.cancelIdle(this.idleHandle),this.idleHandle=null),this.scheduled=!1)}flush(){this.isActive()&&(this.idleHandle!==null&&(U.cancelIdle(this.idleHandle),this.idleHandle=null),!(!this.scheduled&&this.pendingRecords.length===0)&&(this.scheduled=!1,this.processNow()))}scheduleProcess(){if(!this.isActive()||this.scheduled)return;this.scheduled=!0;const e=()=>{this.idleHandle=null,this.scheduled=!1,this.processNow()};this.idleHandle=Hn?window.requestIdleCallback(e,{timeout:this.idleTimeoutMs}):window.setTimeout(e,this.idleTimeoutMs)}processNow(){if(!this.isActive()||this.pendingRecords.length===0)return;const e=this.drainPending(),{addedNodes:n,removedNodes:r}=U.coalesce(e),{added:i,removed:o}=U.toElementSets(n,r);i.size===0&&o.size===0||(this.deliverAggregate(i,o,e),this.deliverPerKind(o,i))}static isNode(e){return M&&typeof Node<"u"&&e instanceof Node}static sanitizeInt(e,n,r){if(typeof e!="number"||!Number.isFinite(e))return n;const i=Math.trunc(e);return i>=r?i:r}static coalesce(e){const n=new Set,r=new Set;for(const i of e){for(const o of i.addedNodes)r.delete(o)||n.add(o);for(const o of i.removedNodes)n.delete(o)||r.add(o)}return{addedNodes:n,removedNodes:r}}static toElementSets(e,n){const r=U.flattenElements(e,!0),i=U.flattenElements(n,!1);return{added:r,removed:i}}static flattenElements(e,n){const r=new Set;for(const i of e){if(i instanceof Element){(!n||i.isConnected)&&r.add(i),i.querySelectorAll("*").forEach(o=>{(!n||o.isConnected)&&r.add(o)});continue}i instanceof DocumentFragment&&i.querySelectorAll("*").forEach(o=>{(!n||o.isConnected)&&r.add(o)})}return r}static cancelIdle(e){zc?window.cancelIdleCallback(e):M&&window.clearTimeout(e)}drainPending(){const{pendingRecords:e}=this;return this.pendingRecords=[],e}deliverAggregate(e,n,r){if(!this.onChange)return;const i={added:e,removed:n,records:r};this.safeCall(()=>this.onChange?.(i))}deliverPerKind(e,n){const r=e.size>0?[...e]:[],i=n.size>0?[...n]:[];this.onRemoved&&r.length>0&&this.dispatchChunked(r,this.onRemoved),this.onAdded&&i.length>0&&this.dispatchChunked(i,this.onAdded)}dispatchChunked(e,n){if(!this.isActive()||e.length===0)return;if(e.length<=this.maxChunk){this.safeCall(()=>n(e));return}let r=0;const i=()=>{if(!this.isActive())return;const o=Math.min(e.length,r+this.maxChunk),s=e.slice(r,o);r=o,this.safeCall(()=>n(s)),r<e.length&&(Hn?window.requestIdleCallback(i,{timeout:this.idleTimeoutMs}):M&&window.setTimeout(i,this.idleTimeoutMs))};i()}safeCall(e){try{const n=e();Promise.resolve(n).catch(r=>{this.onError?.(r)})}catch(n){this.onError?.(n)}}}class De{callback;opts;io;states=new WeakMap;activeStates=new Set;boundVisibilityHandler=null;sweepInterval=null;constructor(e,n){this.callback=e,this.opts=De.initOptions(n),this.io=new IntersectionObserver(r=>{this.onIntersect(r)},{root:this.opts.root??null,rootMargin:this.opts.rootMargin,threshold:this.opts.minVisibleRatio===0?[0]:[0,this.opts.minVisibleRatio]}),M&&(this.boundVisibilityHandler=()=>{this.onPageVisibilityChange()},document.addEventListener("visibilitychange",this.boundVisibilityHandler))}observe(e,n){let r=this.states.get(e);r||(r=this.createState(e,n),this.states.set(e,r),this.activeStates.add(r),this.ensureSweeper()),this.io.observe(e)}unobserve(e){this.io.unobserve(e);const n=this.states.get(e);n&&(se(n),ae(n),n.done=!0,this.activeStates.delete(n),n.strongRef===e&&(n.strongRef=null),this.states.delete(e),this.maybeStopSweeper())}disconnect(){this.io.disconnect();for(const e of this.activeStates)se(e),ae(e),e.done=!0,e.strongRef=null;this.activeStates.clear(),M&&this.boundVisibilityHandler&&(document.removeEventListener("visibilitychange",this.boundVisibilityHandler),this.boundVisibilityHandler=null),this.stopSweeper()}getStats(e){const n=this.states.get(e);return n?{accumulatedMs:n.accumulatedMs,visibleSince:n.visibleSince,attempts:n.attempts,done:n.done,inFlight:n.inFlight,pendingRetry:n.pendingRetry,lastKnownVisible:n.lastKnownVisible}:null}static initOptions(e){return{dwellTimeMs:N.nonNeg(e?.dwellTimeMs,ce.DWELL_MS),minVisibleRatio:N.clamp01(e?.minVisibleRatio,ce.RATIO),root:e?.root??null,rootMargin:e?.rootMargin??"0px",maxRetries:N.nonNeg(e?.maxRetries,ce.MAX_RETRIES),retryBackoffMs:N.nonNeg(e?.retryBackoffMs,ce.BACKOFF_MS),backoffMultiplier:N.atLeast1(e?.backoffMultiplier,ce.MULTIPLIER)}}createState(e,n){const r={dwellTimeMs:N.nonNeg(n?.dwellTimeMs,this.opts.dwellTimeMs),maxRetries:N.nonNeg(n?.maxRetries,this.opts.maxRetries),retryBackoffMs:N.nonNeg(n?.retryBackoffMs,this.opts.retryBackoffMs),backoffMultiplier:N.atLeast1(n?.backoffMultiplier,this.opts.backoffMultiplier)},i=typeof WeakRef=="function";return{ref:i?new WeakRef(e):null,strongRef:i?null:e,opts:r,data:n?.data,accumulatedMs:0,visibleSince:null,fireTimer:null,retryTimer:null,retryScheduledAt:null,retryDelayMs:null,pendingRetry:!1,attempts:0,done:!1,inFlight:!1,lastKnownVisible:!1}}onPageVisibilityChange(){const e=Oe(),n=!Re();for(const r of this.activeStates)n?De.onHidden(r,e):this.onResume(r,e);this.sweepOrphans()}static onHidden(e,n){if(!e.done&&(e.visibleSince!==null&&(e.accumulatedMs+=n-e.visibleSince,e.visibleSince=null),se(e),e.retryTimer!==null)){const r=e.retryScheduledAt?n-e.retryScheduledAt:0,i=e.retryDelayMs!==null?Math.max(0,e.retryDelayMs-r):null;ae(e),i!==null&&(e.pendingRetry=!0,e.retryDelayMs=i,e.retryScheduledAt=null)}}onResume(e,n){e.done||(e.lastKnownVisible&&e.visibleSince===null&&(e.visibleSince=n,this.scheduleFireIfDue(e,n)),e.pendingRetry&&!e.inFlight&&e.lastKnownVisible&&e.retryDelayMs!==null&&this.scheduleRetry(e,e.retryDelayMs))}onIntersect(e){const n=Oe();for(const r of e){const i=this.states.get(r.target);if(!i||i.done)continue;r.isIntersecting&&r.intersectionRatio>=this.opts.minVisibleRatio&&Re()?this.onVisible(i,n):De.onNotVisible(i,n)}this.sweepOrphans()}onVisible(e,n){if(e.lastKnownVisible=!0,e.visibleSince===null){e.visibleSince=n,e.attempts=0,e.pendingRetry&&!e.inFlight&&e.retryDelayMs!==null?this.scheduleRetry(e,e.retryDelayMs):this.scheduleFireIfDue(e,n);return}!e.pendingRetry&&e.fireTimer===null&&!e.inFlight&&this.scheduleFireIfDue(e,n)}static onNotVisible(e,n){e.lastKnownVisible=!1,e.visibleSince!==null&&(e.accumulatedMs+=n-e.visibleSince,e.visibleSince=null),se(e),(e.pendingRetry||e.retryTimer!==null)&&(ae(e),e.pendingRetry=!1,e.attempts=0)}scheduleFireIfDue(e,n){if(e.done||e.inFlight||e.fireTimer!==null||e.pendingRetry)return;const r=e.accumulatedMs+(e.visibleSince!==null?n-e.visibleSince:0),i=e.opts.dwellTimeMs-r;if(i<=0){this.trigger(e);return}e.fireTimer=setTimeout(()=>{!e.done&&e.lastKnownVisible&&Re()?this.trigger(e):se(e)},Math.ceil(i))}scheduleRetry(e,n){e.pendingRetry=!0,e.retryDelayMs=Math.max(0,Math.ceil(n)),!(!Re()||!e.lastKnownVisible||e.done||e.inFlight)&&(e.retryScheduledAt=Oe(),e.retryTimer=setTimeout(()=>{e.retryTimer=null,e.retryScheduledAt=null,this.attemptCallback(e)},e.retryDelayMs))}trigger(e){if(e.done||e.inFlight)return;const n=Oe(),r=e.accumulatedMs+(e.visibleSince!==null?n-e.visibleSince:0);ae(e),e.pendingRetry=!1,se(e),this.attemptCallback(e,r)}async attemptCallback(e,n){if(e.done||e.inFlight)return;const r=Dt(e);if(!r){this.finalizeDroppedState(e);return}const i=e.attempts+1;e.attempts=i,e.inFlight=!0;const o=n??e.accumulatedMs+(e.visibleSince!==null?Oe()-e.visibleSince:0);try{await this.callback(r,{totalVisibleMs:o,attempts:i,data:e.data}),this.onAttemptSuccess(e,r)}catch{this.onAttemptFailure(e)}}onAttemptSuccess(e,n){e.inFlight=!1,e.done=!0,this.safeAutoUnobserve(n,e)}onAttemptFailure(e){if(e.inFlight=!1,e.attempts>e.opts.maxRetries){this.onRetriesExceeded(e);return}const n=e.opts.retryBackoffMs*Math.pow(e.opts.backoffMultiplier,e.attempts-1),r=bc(n);if(!e.lastKnownVisible||!Re()){e.pendingRetry=!0,e.retryDelayMs=Math.ceil(r),e.retryScheduledAt=null;return}this.scheduleRetry(e,r)}onRetriesExceeded(e){ae(e),e.pendingRetry=!1,e.done=!0;const n=Dt(e);n?this.safeAutoUnobserve(n,e):this.finalizeDroppedState(e)}finalizeDroppedState(e){se(e),ae(e),e.done=!0,this.activeStates.delete(e),e.strongRef&&(this.states.delete(e.strongRef),e.strongRef=null),this.maybeStopSweeper()}safeAutoUnobserve(e,n){try{this.unobserve(e)}catch{this.activeStates.delete(n),n.strongRef===e&&(this.states.delete(e),n.strongRef=null),n.done=!0,this.maybeStopSweeper()}}ensureSweeper(){this.sweepInterval===null&&(this.sweepInterval=setInterval(()=>{this.sweepOrphans()},ce.SWEEP_INTERVAL_MS))}stopSweeper(){this.sweepInterval!==null&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}maybeStopSweeper(){this.activeStates.size===0&&this.stopSweeper()}sweepOrphans(){if(M){for(const e of Array.from(this.activeStates)){const n=Dt(e);if(!n){this.finalizeDroppedState(e);continue}(typeof n.isConnected=="boolean"?n.isConnected:document.contains(n))||this.safeAutoUnobserve(n,e)}this.maybeStopSweeper()}}}const w={reset(t={resetConsent:!1,resetDebug:!1}){t.resetConsent&&localStorage.removeItem(st),t.resetDebug&&localStorage.removeItem(ct),localStorage.removeItem(ot),localStorage.removeItem(at),localStorage.removeItem(ut),localStorage.removeItem(lt)},get anonymousId(){const t=localStorage.getItem(Jt);return t&&localStorage.removeItem(Jt),t??localStorage.getItem(ot)??void 0},set anonymousId(t){w.setCache(ot,t)},get consent(){switch(localStorage.getItem(st)){case"accepted":return!0;case"denied":return!1}},set consent(t){const e=t?"accepted":"denied";w.setCache(st,t===void 0?void 0:e)},get debug(){const t=localStorage.getItem(ct);return t?t==="true":void 0},set debug(t){w.setCache(ct,t)},get changes(){return w.getCache(at,pn)},set changes(t){w.setCache(at,t)},get profile(){return w.getCache(ut,Ke)},set profile(t){w.setCache(ut,t)},get personalizations(){return w.getCache(lt,_n)},set personalizations(t){w.setCache(lt,t)},getCache(t,e){const n=localStorage.getItem(t);if(!n)return;const r=e.safeParse(JSON.parse(n));if(r.success)return r.data},setCache(t,e){e===void 0?localStorage.removeItem(t):localStorage.setItem(t,typeof e=="string"?e:JSON.stringify(e))}},jt=P("Web:SDK"),Tc=365;function Ac({app:t,defaults:e,logLevel:n,...r}){const{consent:i=w.consent,profile:o=w.profile,changes:s=w.changes,personalizations:a=w.personalizations}=e??{};return _e({analytics:{beaconHandler:ji},defaults:{consent:i,changes:s,profile:o,personalizations:a},eventBuilder:{app:t,channel:"web",library:{name:"Optimization Web SDK",version:Di},getLocale:Li,getPageProperties:Bi,getUserAgent:Ui},getAnonymousId:()=>w.anonymousId,logLevel:w.debug?"debug":n},r)}class kc extends Ni{elementViewObserver=void 0;elementExistenceObserver=void 0;autoTrackEntryViews=!1;cookieAttributes=void 0;constructor(e){if(typeof window<"u"&&window.optimization)throw new Error("Optimization is already initialized");const{autoTrackEntryViews:n,...r}=e,i=Ac(r);super(i);const o=ye.get(Gt),s=o??ye.get(Ne);this.autoTrackEntryViews=!0,this.cookieAttributes={domain:i.cookie?.domain,expires:i.cookie?.expires??Tc},yc(a=>{this.online(a)}),_c(async()=>{await this.flush()}),R(()=>{const{changes:{value:a}}=be;w.changes=a}),R(()=>{const{consent:{value:a}}=be;this.autoTrackEntryViews&&(a?this.startAutoTrackingEntryViews():this.stopAutoTrackingEntryViews()),w.consent=a}),R(()=>{const{profile:{value:a}}=be;w.profile=a,this.setAnonymousId(a?.id)}),R(()=>{const{personalizations:{value:a}}=be;w.personalizations=a}),this.initializeFromCookieValues(s,o),typeof window<"u"&&(window.optimization??=this)}initializeFromCookieValues(e,n){n&&ye.remove(Gt),e&&e!==w.anonymousId&&(this.reset(),this.setAnonymousId(e))}setAnonymousId(e){if(!e){ye.remove(Ne),w.anonymousId=void 0;return}ye.set(Ne,e,this.cookieAttributes),w.anonymousId=e}startAutoTrackingEntryViews(e){this.autoTrackEntryViews=!0,this.elementViewObserver=new De(fc(this)),this.elementExistenceObserver=new U(pc(this.elementViewObserver,!0)),document.querySelectorAll("[data-ctfl-entry-id]").forEach(r=>{Ze(r)&&(jt.info("Auto-observing element (init):",r),this.elementViewObserver?.observe(r,{...e}))})}stopAutoTrackingEntryViews(){this.elementExistenceObserver?.disconnect(),this.elementViewObserver?.disconnect()}trackEntryViewForElement(e,n){jt.info("Manually observing element:",e),this.elementViewObserver?.observe(e,n)}untrackEntryViewForElement(e){jt.info("Manually unobserving element:",e),this.elementViewObserver?.unobserve(e)}reset(){this.stopAutoTrackingEntryViews(),ye.remove(Ne),w.reset(),super.reset()}}exports.ANONYMOUS_ID_COOKIE=Ne;exports.ANONYMOUS_ID_COOKIE_LEGACY=Gt;exports.ANONYMOUS_ID_KEY=ot;exports.ANONYMOUS_ID_KEY_LEGACY=Jt;exports.AliasEvent=hn;exports.AnalyticsStateful=Ge;exports.AnalyticsStateless=wi;exports.ApiClient=si;exports.App=Rr;exports.AudienceEntry=dn;exports.AudienceEntryFields=_r;exports.AudienceEntrySkeleton=zs;exports.BatchExperienceData=Ur;exports.BatchExperienceEvent=Kr;exports.BatchExperienceEventArray=Is;exports.BatchExperienceResponse=Dr;exports.BatchInsightsEvent=Qr;exports.BatchInsightsEventArray=wn;exports.CAN_ADD_LISTENERS=M;exports.CHANGES_CACHE_KEY=at;exports.CONSENT_KEY=st;exports.Campaign=fn;exports.Change=Hr;exports.ChangeArray=pn;exports.ChangeType=jr;exports.Channel=Mr;exports.ComponentViewEvent=de;exports.ConsoleLogSink=ni;exports.ContentTypeLink=hr;exports.CoreStateful=Ni;exports.CoreStateless=cc;exports.CtflEntry=ke;exports.DEBUG_FLAG_KEY=ct;exports.DEFAULT_PAGE_PROPERTIES=Kt;exports.Dictionary=xr;exports.EXPERIENCE_BASE_URL=ii;exports.EntryFields=qe;exports.EntryReplacementComponent=Er;exports.EntryReplacementVariant=gt;exports.EntrySys=ln;exports.EnvironmentLink=gr;exports.EventBuilder=ai;exports.ExperienceData=Gr;exports.ExperienceEvent=mn;exports.ExperienceEventArray=Be;exports.ExperienceRequestData=$s;exports.ExperienceRequestOptions=Yr;exports.ExperienceResponse=it;exports.FlagsResolver=ft;exports.GeoLocation=zt;exports.GroupEvent=gn;exports.INSIGHTS_BASE_URL=oi;exports.IdentifyEvent=Pt;exports.InlineVariableComponent=Tr;exports.InlineVariableComponentValueType=zr;exports.InlineVariableVariant=qt;exports.InsightsEvent=bn;exports.InsightsEventArray=Jr;exports.InterceptorManager=Qt;exports.Library=Vr;exports.Link=pr;exports.LogSink=ti;exports.Logger=ei;exports.MergeTagEntry=br;exports.MergeTagValueResolver=Ee;exports.OPTIMIZATION_CORE_SDK_VERSION=Ei;exports.OPTIMIZATION_WEB_SDK_VERSION=Di;exports.Optimization=kc;exports.PERSONALIZATIONS_CACHE_KEY=lt;exports.PROFILE_CACHE_KEY=ut;exports.Page=he;exports.PageEventContext=vn;exports.PageViewEvent=Ct;exports.PartialProfile=Lr;exports.PersonalizationComponent=Ar;exports.PersonalizationComponentArray=kr;exports.PersonalizationConfig=Pr;exports.PersonalizationEntry=St;exports.PersonalizationEntryArray=$r;exports.PersonalizationEntrySkeleton=As;exports.PersonalizationFields=Ir;exports.PersonalizationStateful=re;exports.PersonalizationStateless=Vi;exports.PersonalizationType=Cr;exports.PersonalizedEntry=Or;exports.PersonalizedEntryResolver=ue;exports.Profile=Ke;exports.Properties=He;exports.Screen=Tt;exports.ScreenEventContext=yn;exports.ScreenViewEvent=It;exports.SelectedPersonalization=Wr;exports.SelectedPersonalizationArray=_n;exports.SessionStatistics=Nr;exports.SpaceLink=vr;exports.TagLink=yr;exports.TrackEvent=$t;exports.Traits=At;exports.UniversalEventContext=kt;exports.UniversalEventProperties=te;exports.UnknownChange=Cs;exports.ValuePresence=ui;exports.VariableChange=qr;exports.VariableChangeValue=Fr;exports.batch=le;exports.beaconHandler=ji;exports.createScopedLogger=P;exports.effect=R;exports.getLocale=Li;exports.getPageProperties=Bi;exports.getUserAgent=Ui;exports.guardedBy=D;exports.isEntry=mr;exports.isEntryReplacementComponent=Sr;exports.isEntryReplacementVariant=wr;exports.isInlineVariableComponent=Ts;exports.isPersonalizationEntry=xe;exports.isPersonalizedEntry=rt;exports.logger=G;exports.signalFns=ci;exports.signals=be;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Zi=Symbol.for("preact-signals");function _t(){if(Q>1)Q--;else{for(var t,e=!1;Le!==void 0;){var n=Le;for(Le=void 0,Zt++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Wn(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(Zt=0,Q--,e)throw t}}function de(t){if(Q>0)return t();Q++;try{return t()}finally{_t()}}var y=void 0;function rn(t){var e=y;y=void 0;try{return t()}finally{y=e}}var Le=void 0,Q=0,Zt=0,dt=0;function Yn(t){if(y!==void 0){var e=t.n;if(e===void 0||e.t!==y)return e={i:0,S:t,p:y.s,n:void 0,t:y,e:void 0,x:void 0,r:e},y.s!==void 0&&(y.s.n=e),y.s=e,t.n=e,32&y.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=y.s,e.n=void 0,y.s.n=e,y.s=e),e}}function $(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}$.prototype.brand=Zi;$.prototype.h=function(){return!0};$.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:rn(function(){var r;(r=e.W)==null||r.call(e)}))};$.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&rn(function(){var i;(i=e.Z)==null||i.call(e)}))}};$.prototype.subscribe=function(t){var e=this;return R(function(){var n=e.value,r=y;y=void 0;try{t(n)}finally{y=r}},{name:"sub"})};$.prototype.valueOf=function(){return this.value};$.prototype.toString=function(){return this.value+""};$.prototype.toJSON=function(){return this.value};$.prototype.peek=function(){var t=y;y=void 0;try{return this.value}finally{y=t}};Object.defineProperty($.prototype,"value",{get:function(){var t=Yn(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Zt>100)throw new Error("Cycle detected");this.v=t,this.i++,dt++,Q++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{_t()}}}});function Se(t,e){return new $(t,e)}function Wn(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Gn(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Jn(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function pe(t,e){$.call(this,void 0),this.x=t,this.s=void 0,this.g=dt-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}pe.prototype=new $;pe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===dt))return!0;if(this.g=dt,this.f|=1,this.i>0&&!Wn(this))return this.f&=-2,!0;var t=y;try{Gn(this),y=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return y=t,Jn(this),this.f&=-2,!0};pe.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}$.prototype.S.call(this,t)};pe.prototype.U=function(t){if(this.t!==void 0&&($.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};pe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(pe.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Yn(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Qn(t,e){return new pe(t,e)}function Xn(t){var e=t.u;if(t.u=void 0,typeof e=="function"){Q++;var n=y;y=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,on(t),r}finally{y=n,_t()}}}function on(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Xn(t)}function Fi(t){if(y!==this)throw new Error("Out-of-order effect");Jn(this),y=t,this.f&=-2,8&this.f&&on(this),_t()}function ze(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}ze.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};ze.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Xn(this),Gn(this),Q++;var t=y;return y=this,Fi.bind(this,t)};ze.prototype.N=function(){2&this.f||(this.f|=2,this.o=Le,Le=this)};ze.prototype.d=function(){this.f|=8,1&this.f||on(this)};ze.prototype.dispose=function(){this.d()};function R(t,e){var n=new ze(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}const ft={resolve(t){return t?t.reduce((e,{key:n,value:r})=>{const i=typeof r=="object"&&r!==null&&"value"in r&&typeof r.value=="object"?r.value:r;return e[n]=i,e},{}):{}}};function p(t,e,n){function r(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(const d in s.prototype)d in a||Object.defineProperty(a,d,{value:s.prototype[d].bind(a)});a._zod.constr=s,a._zod.def=c}const i=n?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:t});function s(a){var c;const u=n?.Parent?new o:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(s,"name",{value:t}),s}class we extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class qi extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Hi={};function Te(t){return Hi}function Ki(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function Yi(t,e){return typeof e=="bigint"?e.toString():e}function er(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function tr(t){return t==null}function sn(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}const zn=Symbol("evaluating");function E(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==zn)return r===void 0&&(r=zn,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function an(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function nr(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}const rr="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function pt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function cn(t){if(pt(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(pt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Wi(t){return cn(t)?{...t}:t}const Gi=new Set(["string","number","symbol"]);function Ft(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function un(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(r._zod.parent=t),r}function O(t){return{}}function Ji(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function Qi(t,e){if(!cn(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const i=nr(t._zod.def,{get shape(){const o={...t._zod.def.shape,...e};return an(this,"shape",o),o},checks:[]});return un(t,i)}function Xi(t,e,n){const r=nr(e._zod.def,{get shape(){const i=e._zod.def.shape,o={...i};for(const s in i)o[s]=t?new t({type:"optional",innerType:i[s]}):i[s];return an(this,"shape",o),o},checks:[]});return un(e,r)}function Me(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function _e(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function Qe(t){return typeof t=="string"?t:t?.message}function Ae(t,e,n){const r={...t,path:t.path??[]};if(!t.message){const i=Qe(t.inst?._zod.def?.error?.(t))??Qe(e?.error?.(t))??Qe(n.customError?.(t))??Qe(n.localeError?.(t))??"Invalid input";r.message=i}return delete r.inst,delete r.continue,e?.reportInput||delete r.input,r}function ir(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function eo(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const or=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Yi,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},to=p("$ZodError",or),bt=p("$ZodError",or,{Parent:Error}),no=t=>(e,n,r,i)=>{const o=r?Object.assign(r,{async:!1}):{async:!1},s=e._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new we;if(s.issues.length){const a=new(i?.Err??t)(s.issues.map(c=>Ae(c,o,Te())));throw rr(a,i?.callee),a}return s.value},ro=no(bt),io=t=>async(e,n,r,i)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(i?.Err??t)(s.issues.map(c=>Ae(c,o,Te())));throw rr(a,i?.callee),a}return s.value},oo=io(bt),so=t=>(e,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=e._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new we;return o.issues.length?{success:!1,error:new(t??to)(o.issues.map(s=>Ae(s,i,Te())))}:{success:!0,data:o.value}},sr=so(bt),ao=t=>async(e,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(s=>Ae(s,i,Te())))}:{success:!0,data:o.value}},ar=ao(bt),co="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function uo(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function lo(t){const e=uo({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${co}T(?:${r})$`)}const fo=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},po=/^-?\d+(?:\.\d+)?/i,ho=/true|false/i,go=/null/i,wt=p("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),vo=p("$ZodCheckMinLength",(t,e)=>{var n;wt.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!tr(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const s=ir(i);r.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),yo=p("$ZodCheckLengthEquals",(t,e)=>{var n;wt.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!tr(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),t._zod.check=r=>{const i=r.value,o=i.length;if(o===e.length)return;const s=ir(i),a=o>e.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),mo=p("$ZodCheckStringFormat",(t,e)=>{var n,r;wt.init(t,e),t._zod.onattach.push(i=>{const o=i._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),_o={major:4,minor:1,patch:5},z=p("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=_o;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const i of r)for(const o of i._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const i=(s,a,c)=>{let u=Me(s),d;for(const m of a){if(m._zod.def.when){if(!m._zod.def.when(s))continue}else if(u)continue;const b=s.issues.length,S=m._zod.check(s);if(S instanceof Promise&&c?.async===!1)throw new we;if(d||S instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await S,s.issues.length!==b&&(u||(u=Me(s,b)))});else{if(s.issues.length===b)continue;u||(u=Me(s,b))}}return d?d.then(()=>s):s},o=(s,a,c)=>{if(Me(s))return s.aborted=!0,s;const u=i(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new we;return u.then(d=>t._zod.parse(d,c))}return t._zod.parse(u,c)};t._zod.run=(s,a)=>{if(a.skipChecks)return t._zod.parse(s,a);if(a.direction==="backward"){const u=t._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>o(d,s,a)):o(u,s,a)}const c=t._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new we;return c.then(u=>i(u,r,a))}return i(c,r,a)}}t["~standard"]={validate:i=>{try{const o=sr(t,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return ar(t,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),cr=p("$ZodString",(t,e)=>{z.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??fo(t._zod.bag),t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),ur=p("$ZodStringFormat",(t,e)=>{mo.init(t,e),cr.init(t,e)}),bo=p("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=lo(e)),ur.init(t,e)}),wo=p("$ZodNumber",(t,e)=>{z.init(t,e),t._zod.pattern=t._zod.bag.pattern??po,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...o?{received:o}:{}}),n}}),Eo=p("$ZodBoolean",(t,e)=>{z.init(t,e),t._zod.pattern=ho,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),n}}),So=p("$ZodNull",(t,e)=>{z.init(t,e),t._zod.pattern=go,t._zod.values=new Set([null]),t._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:t}),n}}),zo=p("$ZodAny",(t,e)=>{z.init(t,e),t._zod.parse=n=>n}),To=p("$ZodUnknown",(t,e)=>{z.init(t,e),t._zod.parse=n=>n});function Tn(t,e,n){t.issues.length&&e.issues.push(..._e(n,t.issues)),e.value[n]=t.value}const Ao=p("$ZodArray",(t,e)=>{z.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),n;n.value=Array(i.length);const o=[];for(let s=0;s<i.length;s++){const a=i[s],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?o.push(c.then(u=>Tn(u,n,s))):Tn(c,n,s)}return o.length?Promise.all(o).then(()=>n):n}});function ht(t,e,n,r){t.issues.length&&e.issues.push(..._e(n,t.issues)),t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function ko(t){const e=Object.keys(t.shape);for(const r of e)if(!t.shape[r]._zod.traits.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Ji(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function Po(t,e,n,r,i,o){const s=[],a=i.keySet,c=i.catchall._zod,u=c.def.type;for(const d of Object.keys(e)){if(a.has(d))continue;if(u==="never"){s.push(d);continue}const m=c.run({value:e[d],issues:[]},r);m instanceof Promise?t.push(m.then(b=>ht(b,n,d,e))):ht(m,n,d,e)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:e,inst:o}),t.length?Promise.all(t).then(()=>n):n}const Co=p("$ZodObject",(t,e)=>{z.init(t,e);const n=er(()=>ko(e));E(t._zod,"propValues",()=>{const s=e.shape,a={};for(const c in s){const u=s[c]._zod;if(u.values){a[c]??(a[c]=new Set);for(const d of u.values)a[c].add(d)}}return a});const r=pt,i=e.catchall;let o;t._zod.parse=(s,a)=>{o??(o=n.value);const c=s.value;if(!r(c))return s.issues.push({expected:"object",code:"invalid_type",input:c,inst:t}),s;s.value={};const u=[],d=o.shape;for(const m of o.keys){const S=d[m]._zod.run({value:c[m],issues:[]},a);S instanceof Promise?u.push(S.then(_=>ht(_,s,m,c))):ht(S,s,m,c)}return i?Po(u,c,s,a,n.value,t):u.length?Promise.all(u).then(()=>s):s}});function An(t,e,n,r){for(const o of t)if(o.issues.length===0)return e.value=o.value,e;const i=t.filter(o=>!Me(o));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(o=>o.issues.map(s=>Ae(s,r,Te())))}),e)}const lr=p("$ZodUnion",(t,e)=>{z.init(t,e),E(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),E(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),E(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),E(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>sn(o.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(i,o)=>{if(n)return r(i,o);let s=!1;const a=[];for(const c of e.options){const u=c._zod.run({value:i.value,issues:[]},o);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}return s?Promise.all(a).then(c=>An(c,i,t,o)):An(a,i,t,o)}}),Io=p("$ZodDiscriminatedUnion",(t,e)=>{lr.init(t,e);const n=t._zod.parse;E(t._zod,"propValues",()=>{const i={};for(const o of e.options){const s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const[a,c]of Object.entries(s)){i[a]||(i[a]=new Set);for(const u of c)i[a].add(u)}}return i});const r=er(()=>{const i=e.options,o=new Map;for(const s of i){const a=s._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(const c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,s)}}return o});t._zod.parse=(i,o)=>{const s=i.value;if(!pt(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:t}),i;const a=r.value.get(s?.[e.discriminator]);return a?a._zod.run(i,o):e.unionFallback?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:s,path:[e.discriminator],inst:t}),i)}}),$o=p("$ZodRecord",(t,e)=>{z.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!cn(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),n;const o=[];if(e.keyType._zod.values){const s=e.keyType._zod.values;n.value={};for(const c of s)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const u=e.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&n.issues.push(..._e(c,d.issues)),n.value[c]=d.value})):(u.issues.length&&n.issues.push(..._e(c,u.issues)),n.value[c]=u.value)}let a;for(const c in i)s.has(c)||(a=a??[],a.push(c));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:a})}else{n.value={};for(const s of Reflect.ownKeys(i)){if(s==="__proto__")continue;const a=e.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(u=>Ae(u,r,Te())),input:s,path:[s],inst:t}),n.value[a.value]=a.value;continue}const c=e.valueType._zod.run({value:i[s],issues:[]},r);c instanceof Promise?o.push(c.then(u=>{u.issues.length&&n.issues.push(..._e(s,u.issues)),n.value[a.value]=u.value})):(c.issues.length&&n.issues.push(..._e(s,c.issues)),n.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Oo=p("$ZodEnum",(t,e)=>{z.init(t,e);const n=Ki(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>Gi.has(typeof i)).map(i=>typeof i=="string"?Ft(i):i.toString()).join("|")})$`),t._zod.parse=(i,o)=>{const s=i.value;return r.has(s)||i.issues.push({code:"invalid_value",values:n,input:s,inst:t}),i}}),Ro=p("$ZodLiteral",(t,e)=>{if(z.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Ft(n):n?Ft(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,r)=>{const i=n.value;return t._zod.values.has(i)||n.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),n}}),Mo=p("$ZodTransform",(t,e)=>{z.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new qi(t.constructor.name);const i=e.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(n.value=s,n));if(i instanceof Promise)throw new we;return n.value=i,n}});function kn(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const xo=p("$ZodOptional",(t,e)=>{z.init(t,e),t._zod.optin="optional",t._zod.optout="optional",E(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),E(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${sn(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>kn(o,n.value)):kn(i,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),Vo=p("$ZodNullable",(t,e)=>{z.init(t,e),E(t._zod,"optin",()=>e.innerType._zod.optin),E(t._zod,"optout",()=>e.innerType._zod.optout),E(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${sn(n.source)}|null)$`):void 0}),E(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),No=p("$ZodPrefault",(t,e)=>{z.init(t,e),t._zod.optin="optional",E(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),Lo=p("$ZodPipe",(t,e)=>{z.init(t,e),E(t._zod,"values",()=>e.in._zod.values),E(t._zod,"optin",()=>e.in._zod.optin),E(t._zod,"optout",()=>e.out._zod.optout),E(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=e.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Xe(s,e.in,r)):Xe(o,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(o=>Xe(o,e.out,r)):Xe(i,e.out,r)}});function Xe(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const Bo=p("$ZodLazy",(t,e)=>{z.init(t,e),E(t._zod,"innerType",()=>e.getter()),E(t._zod,"pattern",()=>t._zod.innerType._zod.pattern),E(t._zod,"propValues",()=>t._zod.innerType._zod.propValues),E(t._zod,"optin",()=>t._zod.innerType._zod.optin??void 0),E(t._zod,"optout",()=>t._zod.innerType._zod.optout??void 0),t._zod.parse=(n,r)=>t._zod.innerType._zod.run(n,r)}),Uo=p("$ZodCustom",(t,e)=>{wt.init(t,e),z.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,i=e.fn(r);if(i instanceof Promise)return i.then(o=>Pn(o,n,r,t));Pn(i,n,r,t)}});function Pn(t,e,n,r){if(!t){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(eo(i))}}function Do(t,e){return new t({type:"string",...O()})}function jo(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O()})}function Zo(t,e){return new t({type:"number",checks:[],...O()})}function Fo(t,e){return new t({type:"boolean",...O()})}function qo(t,e){return new t({type:"null",...O()})}function Ho(t){return new t({type:"any"})}function Ko(t){return new t({type:"unknown"})}function Yo(t,e){return new vo({check:"min_length",...O(),minimum:t})}function Wo(t,e){return new yo({check:"length_equals",...O(),length:t})}function Go(t,e,n){const r=O();return r.abort??(r.abort=!0),new t({type:"custom",check:"custom",fn:e,...r})}const T=p("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");z.init(t,e),t.def=e,t.type=e.type,t.parse=(n,r)=>ro(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>sr(t,n,r),t.parseAsync=async(n,r)=>oo(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>ar(t,n,r),t.check=(...n)=>t.clone({...e,checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),t.clone=(n,r)=>un(t,n,r),t.brand=()=>t,t.register=(n,r)=>(n.add(t,r),t)}),dr=p("ZodMiniString",(t,e)=>{cr.init(t,e),T.init(t,e)});function l(t){return Do(dr)}const Jo=p("ZodMiniStringFormat",(t,e)=>{ur.init(t,e),dr.init(t,e)}),Qo=p("ZodMiniNumber",(t,e)=>{wo.init(t,e),T.init(t,e)});function C(t){return Zo(Qo)}const Xo=p("ZodMiniBoolean",(t,e)=>{Eo.init(t,e),T.init(t,e)});function q(t){return Fo(Xo)}const es=p("ZodMiniNull",(t,e)=>{So.init(t,e),T.init(t,e)});function ln(t){return qo(es)}const ts=p("ZodMiniAny",(t,e)=>{zo.init(t,e),T.init(t,e)});function Cn(){return Ho(ts)}const ns=p("ZodMiniUnknown",(t,e)=>{To.init(t,e),T.init(t,e)});function rs(){return Ko(ns)}const is=p("ZodMiniArray",(t,e)=>{Ao.init(t,e),T.init(t,e)});function k(t,e){return new is({type:"array",element:t,...O()})}const os=p("ZodMiniObject",(t,e)=>{Co.init(t,e),T.init(t,e),E(t,"shape",()=>e.shape)});function h(t,e){const n={type:"object",get shape(){return an(this,"shape",{...t}),this.shape},...O()};return new os(n)}function g(t,e){return Qi(t,e)}function ss(t,e){return Xi(pr,t)}function Et(t,e){return t.clone({...t._zod.def,catchall:e})}const as=p("ZodMiniUnion",(t,e)=>{lr.init(t,e),T.init(t,e)});function X(t,e){return new as({type:"union",options:t,...O()})}const cs=p("ZodMiniDiscriminatedUnion",(t,e)=>{Io.init(t,e),T.init(t,e)});function Fe(t,e,n){return new cs({type:"union",options:e,discriminator:t,...O()})}const us=p("ZodMiniRecord",(t,e)=>{$o.init(t,e),T.init(t,e)});function he(t,e,n){return new us({type:"record",keyType:t,valueType:e,...O()})}const ls=p("ZodMiniEnum",(t,e)=>{Oo.init(t,e),T.init(t,e),t.options=Object.values(e.entries)});function fr(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new ls({type:"enum",entries:n,...O()})}const ds=p("ZodMiniLiteral",(t,e)=>{Ro.init(t,e),T.init(t,e)});function v(t,e){return new ds({type:"literal",values:Array.isArray(t)?t:[t],...O()})}const fs=p("ZodMiniTransform",(t,e)=>{Mo.init(t,e),T.init(t,e)});function ps(t){return new fs({type:"transform",transform:t})}const pr=p("ZodMiniOptional",(t,e)=>{xo.init(t,e),T.init(t,e)});function f(t){return new pr({type:"optional",innerType:t})}const hs=p("ZodMiniNullable",(t,e)=>{Vo.init(t,e),T.init(t,e)});function nt(t){return new hs({type:"nullable",innerType:t})}const gs=p("ZodMiniPrefault",(t,e)=>{No.init(t,e),T.init(t,e)});function K(t,e){return new gs({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Wi(e)}})}const vs=p("ZodMiniPipe",(t,e)=>{Lo.init(t,e),T.init(t,e)});function ys(t,e){return new vs({type:"pipe",in:t,out:e})}const ms=p("ZodMiniLazy",(t,e)=>{Bo.init(t,e),T.init(t,e)});function _s(t){return new ms({type:"lazy",getter:t})}const bs=p("ZodMiniCustom",(t,e)=>{Uo.init(t,e),T.init(t,e)});function ws(t,e){return Go(bs,()=>!0)}function ee(){const t=_s(()=>X([l(),C(),q(),ln(),k(t),he(l(),t)]));return t}const Es=p("$ZodISODateTime",(t,e)=>{bo.init(t,e),Jo.init(t,e)});function Ot(t){return jo(Es)}const qe=Et(h({}),ee()),hr=h({sys:h({type:v("Link"),linkType:l(),id:l()})}),gr=h({sys:h({type:v("Link"),linkType:v("ContentType"),id:l()})}),vr=h({sys:h({type:v("Link"),linkType:v("Environment"),id:l()})}),yr=h({sys:h({type:v("Link"),linkType:v("Space"),id:l()})}),Ss=h({sys:h({type:v("Link"),linkType:v("TaxonomyConcept"),id:l()})}),mr=h({sys:h({type:v("Link"),linkType:v("Tag"),id:l()})}),dn=h({type:v("Entry"),contentType:gr,publishedVersion:C(),id:l(),createdAt:Cn(),updatedAt:Cn(),locale:f(l()),revision:C(),space:yr,environment:vr}),ke=h({fields:qe,metadata:h({tags:k(mr),concepts:f(k(Ss))}),sys:dn});function _r(t){return ke.safeParse(t).success}const br=g(qe,{nt_audience_id:l(),nt_name:f(l()),nt_description:f(l())}),fn=g(ke,{fields:br}),zs=g(fn,{contentTypeId:v("nt_audience")}),wr=g(ke,{fields:h({nt_name:l(),nt_fallback:f(l()),nt_mergetag_id:l()}),sys:g(dn,{contentType:h({sys:h({type:v("Link"),linkType:v("ContentType"),id:v("nt_mergetag")})})})}),gt=h({id:l(),hidden:K(q(),!1)});function Er(t){return gt.safeParse(t).success}const Sr=h({type:f(v("EntryReplacement")),baseline:gt,variants:k(gt)});function zr(t){return t.type==="EntryReplacement"||t.type===void 0}const qt=h({value:X([l(),q(),ln(),C(),he(l(),ee())])}),Tr=fr(["Boolean","Number","Object","String"]),Ar=h({type:v("InlineVariable"),key:l(),valueType:Tr,baseline:qt,variants:k(qt)});function Ts(t){return t.type==="InlineVariable"}const kr=Fe("type",[Sr,Ar]),Pr=k(kr),Cr=h({distribution:f(K(k(C()),[.5,.5])),traffic:f(K(C(),0)),components:f(K(Pr,[{type:"EntryReplacement",baseline:{id:""},variants:[{id:""}]}])),sticky:f(K(q(),!1))}),Ir=X([v("nt_experiment"),v("nt_personalization")]),$r=g(qe,{nt_name:l(),nt_description:f(nt(l())),nt_type:Ir,nt_config:ys(f(K(nt(Cr),null)),ps(t=>t??{traffic:0,distribution:[.5,.5],components:[],sticky:!1})),nt_audience:f(nt(fn)),nt_variants:f(K(k(ws()),[])),nt_experience_id:l()}),St=g(ke,{fields:$r}),As=g(St,{contentTypeId:v("nt_experience")});function xe(t){return St.safeParse(t).success}const Or=k(X([hr,St])),Rr=g(ke,{fields:g(qe,{nt_experiences:Or})});function rt(t){return Rr.safeParse(t).success}const Mr=f(h({name:l(),version:l()})),pn=h({name:f(l()),source:f(l()),medium:f(l()),term:f(l()),content:f(l())}),xr=X([v("mobile"),v("server"),v("web")]),Vr=he(l(),l()),ks=2,Ps=h({latitude:C(),longitude:C()}),zt=h({coordinates:f(Ps),city:f(l()),postalCode:f(l()),region:f(l()),regionCode:f(l()),country:f(l()),countryCode:f(l().check(Wo(ks))),continent:f(l()),timezone:f(l())}),Nr=h({name:l(),version:l()}),ge=Et(h({path:l(),query:Vr,referrer:l(),search:l(),title:f(l()),url:l()}),ee()),He=he(l(),ee()),Tt=Et(h({name:l()}),ee()),At=he(l(),ee()),Lr=h({id:l(),isReturningVisitor:q(),landingPage:ge,count:C(),activeSessionLength:C(),averageSessionLength:C()}),Ke=h({id:l(),stableId:l(),random:C(),audiences:k(l()),traits:At,location:zt,session:Lr}),Br=Et(h({id:l()}),ee()),Ur=h({data:h(),message:l(),error:nt(q())}),Dr=h({profiles:f(k(Ke))}),jr=g(Ur,{data:Dr}),Zr=["Variable"],Fr=h({key:l(),type:X([fr(Zr),l()]),meta:h({experienceId:l(),variantIndex:C()})}),qr=X([l(),q(),ln(),C(),he(l(),ee())]),Cs=g(Fr,{type:l(),value:rs()}),Hr=g(Fr,{type:v("Variable"),value:qr}),Kr=Fe("type",[Hr]),hn=k(Kr),kt=h({app:Mr,campaign:pn,gdpr:h({isConsentGiven:q()}),library:Nr,locale:l(),location:f(zt),userAgent:f(l())}),te=h({channel:xr,context:g(kt,{page:f(ge),screen:f(Tt)}),messageId:l(),originalTimestamp:Ot(),sentAt:Ot(),timestamp:Ot(),userId:f(l())}),gn=g(te,{type:v("alias")}),fe=g(te,{type:v("component"),componentType:X([v("Entry"),v("Variable")]),componentId:l(),experienceId:f(l()),variantIndex:C()}),vn=g(te,{type:v("group")}),Pt=g(te,{type:v("identify"),traits:At}),yn=g(kt,{page:ge}),Ct=g(te,{type:v("page"),name:f(l()),properties:ge,context:yn}),mn=g(kt,{screen:Tt}),It=g(te,{type:v("screen"),name:l(),properties:f(He),context:mn}),$t=g(te,{type:v("track"),event:l(),properties:He}),oe={anonymousId:l()},Yr=Fe("type",[g(gn,oe),g(fe,oe),g(vn,oe),g(Pt,oe),g(Ct,oe),g(It,oe),g($t,oe)]),Is=k(Yr),_n=Fe("type",[gn,fe,vn,Pt,Ct,It,$t]),Be=k(_n),Wr=h({features:f(k(l()))}),$s=h({events:Be.check(Yo(1)),options:f(Wr)}),Gr=h({experienceId:l(),variantIndex:C(),variants:he(l(),l()),sticky:f(K(q(),!1))}),bn=k(Gr),Jr=h({profile:Ke,experiences:bn,changes:hn}),it=g(Ur,{data:Jr}),wn=Fe("type",[fe]),Qr=k(wn),Xr=h({profile:Br,events:Qr}),En=k(Xr);var Ht=[],Os=t=>new RegExp(t.replace(/\*/g,".*")+"$"),Rs=t=>{Ht=t.split(/[\s,]+/).map(Os)},ve=(t,e,n,...r)=>{for(let i=Ht.length;i--;)if(Ht[i].test(t))return e({name:t,level:n,messages:r})},Ms=t=>{let e="";const n=console[t.level==="fatal"?"error":t.level];t.name&&(e+=`[${t.name}] `),typeof t.messages[0]=="object"?n(e,...t.messages):n(e+t.messages.shift(),...t.messages)},ei=(t,e)=>({fatal:ve.bind(0,t,e=e||Ms,"fatal"),error:ve.bind(0,t,e,"error"),warn:ve.bind(0,t,e,"warn"),debug:ve.bind(0,t,e,"debug"),info:ve.bind(0,t,e,"info"),log:ve.bind(0,t,e,"log")}),Pe=ei("");Pe.fatal;Pe.error;Pe.warn;Pe.debug;Pe.info;Pe.log;class ti{name="@contentful/optimization";PREFIX_PARTS=["Ctfl","O10n"];DELIMITER=":";diary;sinks=[];constructor(){this.diary=ei(this.name,this.onLogEvent.bind(this)),Rs(this.name)}assembleLocationPrefix(e){return`[${[...this.PREFIX_PARTS,e].join(this.DELIMITER)}]`}addSink(e){this.sinks=[...this.sinks.filter(n=>n.name!==e.name),e]}removeSink(e){this.sinks=this.sinks.filter(n=>n.name!==e)}removeSinks(){this.sinks=[]}debug(e,n,...r){this.diary.debug(`${this.assembleLocationPrefix(e)} ${n}`,...r)}info(e,n,...r){this.diary.info(`${this.assembleLocationPrefix(e)} ${n}`,...r)}log(e,n,...r){this.diary.log(`${this.assembleLocationPrefix(e)} ${n}`,...r)}warn(e,n,...r){this.diary.warn(`${this.assembleLocationPrefix(e)} ${n}`,...r)}error(e,n,...r){this.diary.error(`${this.assembleLocationPrefix(e)} ${n}`,...r)}fatal(e,n,...r){this.diary.fatal(`${this.assembleLocationPrefix(e)} ${n}`,...r)}onLogEvent(e){this.sinks.forEach(n=>{n.ingest(e)})}}const G=new ti;function P(t){return{debug:(e,...n)=>{G.debug(t,e,...n)},info:(e,...n)=>{G.info(t,e,...n)},log:(e,...n)=>{G.log(t,e,...n)},warn:(e,...n)=>{G.warn(t,e,...n)},error:(e,...n)=>{G.error(t,e,...n)},fatal:(e,...n)=>{G.fatal(t,e,...n)}}}class ni{}var ye={fatal:60,error:50,warn:40,info:30,debug:20,log:10},xs=(t,e)=>e in ye&&t in ye?ye[e]===ye[t]?0:ye[e]<ye[t]?1:-1:0;const Vs={debug:(...t)=>{console.debug(...t)},info:(...t)=>{console.info(...t)},log:(...t)=>{console.log(...t)},warn:(...t)=>{console.warn(...t)},error:(...t)=>{console.error(...t)},fatal:(...t)=>{console.error(...t)}},Ns=0;class ri extends ni{name="ConsoleLogSink";verbosity;constructor(e){super(),this.verbosity=e??"error"}ingest(e){xs(this.verbosity,e.level)>Ns||Vs[e.level](...e.messages)}}function Ls(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Rt={},Mt,In;function Bs(){if(In)return Mt;In=1;function t(e,n){typeof n=="boolean"&&(n={forever:n}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=n||{},this._maxRetryTime=n&&n.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}return Mt=t,t.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},t.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},t.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var n=new Date().getTime();if(e&&n-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var i=this;return this._timer=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},r),this._options.unref&&this._timer.unref(),!0},t.prototype.attempt=function(e,n){this._fn=e,n&&(n.timeout&&(this._operationTimeout=n.timeout),n.cb&&(this._operationTimeoutCb=n.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},t.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},t.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},t.prototype.start=t.prototype.try,t.prototype.errors=function(){return this._errors},t.prototype.attempts=function(){return this._attempts},t.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},n=null,r=0,i=0;i<this._errors.length;i++){var o=this._errors[i],s=o.message,a=(e[s]||0)+1;e[s]=a,a>=r&&(n=o,r=a)}return n},Mt}var $n;function Us(){return $n||($n=1,function(t){var e=Bs();t.operation=function(n){var r=t.timeouts(n);return new e(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},t.timeouts=function(n){if(n instanceof Array)return[].concat(n);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var i in n)r[i]=n[i];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],s=0;s<r.retries;s++)o.push(this.createTimeout(s,r));return n&&n.forever&&!o.length&&o.push(this.createTimeout(s,r)),o.sort(function(a,c){return a-c}),o},t.createTimeout=function(n,r){var i=r.randomize?Math.random()+1:1,o=Math.round(i*Math.max(r.minTimeout,1)*Math.pow(r.factor,n));return o=Math.min(o,r.maxTimeout),o},t.wrap=function(n,r,i){if(r instanceof Array&&(i=r,r=null),!i){i=[];for(var o in n)typeof n[o]=="function"&&i.push(o)}for(var s=0;s<i.length;s++){var a=i[s],c=n[a];n[a]=(function(d){var m=t.operation(r),b=Array.prototype.slice.call(arguments,1),S=b.pop();b.push(function(_){m.retry(_)||(_&&(arguments[0]=m.mainError()),S.apply(this,arguments))}),m.attempt(function(){d.apply(n,b)})}).bind(n,c),n[a].options=r}}}(Rt)),Rt}var xt,On;function Ds(){return On||(On=1,xt=Us()),xt}var js=Ds();const Zs=Ls(js),Fs=Object.prototype.toString,qs=t=>Fs.call(t)==="[object Error]",Hs=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);function Ks(t){return t&&qs(t)&&t.name==="TypeError"&&typeof t.message=="string"?t.message==="Load failed"?t.stack===void 0:Hs.has(t.message):!1}class Ys extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const Rn=(t,e,n)=>{const r=n.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=r,t};async function Ws(t,e){return new Promise((n,r)=>{e={...e},e.onFailedAttempt??=()=>{},e.shouldRetry??=()=>!0,e.retries??=10;const i=Zs.operation(e),o=()=>{i.stop(),r(e.signal?.reason)};e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",o,{once:!0});const s=()=>{e.signal?.removeEventListener("abort",o),i.stop()};i.attempt(async a=>{try{const c=await t(a);s(),n(c)}catch(c){try{if(!(c instanceof Error))throw new TypeError(`Non-error was thrown: "${c}". You should only throw errors.`);if(c instanceof Ys)throw c.originalError;if(c instanceof TypeError&&!Ks(c))throw c;if(Rn(c,a,e),await e.shouldRetry(c)||(i.stop(),r(c)),await e.onFailedAttempt(c),!i.retry(c))throw i.mainError()}catch(u){Rn(u,a,e),s(),r(u)}}})})}const Vt=P("ApiClient:Retry"),Gs=0,Js=1,Nt=503,Qs=500;class vt extends Error{status;constructor(e,n=Qs){super(e),Object.setPrototypeOf(this,vt.prototype),this.status=n}}function Xs({apiName:t="Optimization",controller:e,fetchMethod:n=fetch,init:r,url:i}){return async()=>{try{const o=await n(i,r);if(o.status===Nt)throw new vt(`${t} API request to "${i.toString()}" failed with status: "[${o.status}] ${o.statusText}".`,Nt);if(!o.ok){const s=new Error(`Request to "${i.toString()}" failed with status: [${o.status}] ${o.statusText} - traceparent: ${o.headers.get("traceparent")}`);Vt.error("Request failed with non-OK status:",s),e.abort();return}return Vt.debug(`Response from "${i.toString()}":`,o),o}catch(o){if(o instanceof vt&&o.status===Nt)throw o;Vt.error(`Request to "${i.toString()}" failed:`,o),e.abort()}}}function ea({apiName:t="Optimization",fetchMethod:e=fetch,intervalTimeout:n=Gs,onFailedAttempt:r,retries:i=Js}={}){return async(o,s)=>{const a=new AbortController;let c;try{c=await Ws(Xs({apiName:t,controller:a,fetchMethod:e,init:s,url:o}),{minTimeout:n,onFailedAttempt:u=>r?.({...u,apiName:t}),retries:i,signal:a.signal})}catch(u){if(!(u instanceof Error)||u.name!=="AbortError")throw u}if(!c)throw new Error(`${t} API request to "${o.toString()}" may not be retried.`);return c}}const ta=P("ApiClient:Timeout"),na=3e3;function ra({apiName:t="Optimization",fetchMethod:e=fetch,onRequestTimeout:n,requestTimeout:r=na}={}){return async(i,o)=>{const s=new AbortController,a=setTimeout(()=>{typeof n=="function"?n({apiName:t}):ta.error(`Request to "${i.toString()}" timed out`,new Error("Request timeout")),s.abort()},r),c=await e(i,{...o,signal:s.signal});return clearTimeout(a),c}}const Mn=P("ApiClient:Fetch");function ia(t){try{const e=ra(t);return ea({...t,fetchMethod:e})}catch(e){throw e instanceof Error&&(e.name==="AbortError"?Mn.warn("Request aborted due to network issues. This request may not be retried."):Mn.error("Request failed:",e)),e}}const oa={create:ia},xn=P("ApiClient"),sa="main";class ii{name;clientId;environment;fetch;constructor(e,{fetchOptions:n,clientId:r,environment:i}){this.clientId=r,this.environment=i??sa,this.name=e,this.fetch=oa.create({...n??{},apiName:e})}logRequestError(e,{requestName:n}){e instanceof Error&&(e.name==="AbortError"?xn.warn(`[${this.name}] "${n}" request aborted due to network issues. This request may not be retried.`):xn.error(`[${this.name}] "${n}" request failed:`,e))}}const B=P("ApiClient:Experience"),oi="https://experience.ninetailed.co/";class aa extends ii{baseUrl;enabledFeatures;ip;locale;plainText;preflight;constructor(e){super("Experience",e);const{baseUrl:n,enabledFeatures:r,ip:i,locale:o,plainText:s,preflight:a}=e;this.baseUrl=n||oi,this.enabledFeatures=r,this.ip=i,this.locale=o,this.plainText=s,this.preflight=a}async getProfile(e,n={}){if(!e)throw new Error("Valid profile ID required.");const r="Get Profile";B.info(`Sending "${r}" request`);try{const i=await this.fetch(this.constructUrl(`v2/organizations/${this.clientId}/environments/${this.environment}/profiles/${e}`,n),{method:"GET"}),{data:{changes:o,experiences:s,profile:a}}=it.parse(await i.json()),c={changes:o,personalizations:s,profile:a};return B.debug(`"${r}" request successfully completed`),c}catch(i){throw this.logRequestError(i,{requestName:r}),i}}async makeProfileMutationRequest({url:e,body:n,options:r}){return await this.fetch(this.constructUrl(e,r),{method:"POST",headers:this.constructHeaders(r),body:JSON.stringify(n),keepalive:!0})}async createProfile({events:e},n={}){const r="Create Profile";B.info(`Sending "${r}" request`);const i={events:Be.parse(e),options:this.constructBodyOptions(n)};B.debug(`"${r}" request body:`,i);try{const o=await this.makeProfileMutationRequest({url:`v2/organizations/${this.clientId}/environments/${this.environment}/profiles`,body:i,options:n}),{data:{changes:s,experiences:a,profile:c}}=it.parse(await o.json()),u={changes:s,personalizations:a,profile:c};return B.debug(`"${r}" request successfully completed`),u}catch(o){throw this.logRequestError(o,{requestName:r}),o}}async updateProfile({profileId:e,events:n},r={}){if(!e)throw new Error("Valid profile ID required.");const i="Update Profile";B.info(`Sending "${i}" request`);const o={events:Be.parse(n),options:this.constructBodyOptions(r)};B.debug(`"${i}" request body:`,o);try{const s=await this.makeProfileMutationRequest({url:`v2/organizations/${this.clientId}/environments/${this.environment}/profiles/${e}`,body:o,options:r}),{data:{changes:a,experiences:c,profile:u}}=it.parse(await s.json()),d={changes:a,personalizations:c,profile:u};return B.debug(`"${i}" request successfully completed`),d}catch(s){throw this.logRequestError(s,{requestName:i}),s}}async upsertProfile({profileId:e,events:n},r){return e?await this.updateProfile({profileId:e,events:n},r):await this.createProfile({events:n},r)}async upsertManyProfiles({events:e},n={}){const r="Upsert Many Profiles";B.info(`Sending "${r}" request`);const i={events:Be.parse(e),options:this.constructBodyOptions(n)};B.debug(`"${r}" request body:`,i);try{const o=await this.makeProfileMutationRequest({url:`v2/organizations/${this.clientId}/environments/${this.environment}/events`,body:i,options:{plainText:!1,...n}}),{data:{profiles:s}}=jr.parse(await o.json());return B.debug(`"${r}" request successfully completed`),s}catch(o){throw this.logRequestError(o,{requestName:r}),o}}constructUrl(e,n){const r=new URL(e,this.baseUrl),i=n.locale??this.locale,o=n.preflight??this.preflight;return i&&r.searchParams.set("locale",i),o&&r.searchParams.set("type","preflight"),r.toString()}constructHeaders({ip:e=this.ip,plainText:n=this.plainText}){const r=new Map;return e&&r.set("X-Force-IP",e),n??this.plainText??!0?r.set("Content-Type","text/plain"):r.set("Content-Type","application/json"),Object.fromEntries(r)}constructBodyOptions=({enabledFeatures:e=this.enabledFeatures})=>{const n={};return e&&Array.isArray(e)&&e.length>0?n.features=e:n.features=["ip-enrichment","location"],n}}const Ce=P("ApiClient:Insights"),si="https://ingest.insights.ninetailed.co/";class ca extends ii{baseUrl;beaconHandler;constructor(e){super("Insights",e);const{baseUrl:n,beaconHandler:r}=e;this.baseUrl=n??si,this.beaconHandler=r}async sendBatchEvents(e,n={}){const{beaconHandler:r=this.beaconHandler}=n,i=new URL(`v1/organizations/${this.clientId}/environments/${this.environment}/events`,this.baseUrl),o=En.parse(e);if(typeof r=="function"){if(Ce.debug("Queueing events via beaconHandler"),r(i,o))return!0;Ce.warn("beaconHandler failed to queue events; events will be emitted immediately via fetch")}const s="Event Batches";Ce.info(`Sending "${s}" request`),Ce.debug(`"${s}" request body:`,o);try{return await this.fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),keepalive:!0}),Ce.debug(`"${s}" request successfully completed`),!0}catch(a){return this.logRequestError(a,{requestName:s}),!1}}}class ai{config;experience;insights;constructor(e){const{personalization:n,analytics:r,...i}=e;this.config=i,this.experience=new aa({...i,...n}),this.insights=new ca({...i,...r})}}function ua(){}function Vn(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Nn(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const la="[object RegExp]",da="[object String]",fa="[object Number]",pa="[object Boolean]",Ln="[object Arguments]",ha="[object Symbol]",ga="[object Date]",va="[object Map]",ya="[object Set]",ma="[object Array]",_a="[object Function]",ba="[object ArrayBuffer]",Lt="[object Object]",wa="[object Error]",Ea="[object DataView]",Sa="[object Uint8Array]",za="[object Uint8ClampedArray]",Ta="[object Uint16Array]",Aa="[object Uint32Array]",ka="[object BigUint64Array]",Pa="[object Int8Array]",Ca="[object Int16Array]",Ia="[object Int32Array]",$a="[object BigInt64Array]",Oa="[object Float32Array]",Ra="[object Float64Array]";function yt(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function mt(t){return t==="__proto__"}function be(t,e){const n=Object.keys(e);for(let r=0;r<n.length;r++){const i=n[r];if(mt(i))continue;const o=e[i],s=t[i];Array.isArray(o)?Array.isArray(s)?t[i]=be(s,o):t[i]=be([],o):yt(o)?yt(s)?t[i]=be(s,o):t[i]=be({},o):(s===void 0||o!==void 0)&&(t[i]=o)}return t}function Ma(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function xa(t,e,n){return Ve(t,e,void 0,void 0,void 0,void 0,n)}function Ve(t,e,n,r,i,o,s){const a=s(t,e,n,r,i,o);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return Ue(t,e,o,s)}return Ue(t,e,o,s)}function Ue(t,e,n,r){if(Object.is(t,e))return!0;let i=Nn(t),o=Nn(e);if(i===Ln&&(i=Lt),o===Ln&&(o=Lt),i!==o)return!1;switch(i){case da:return t.toString()===e.toString();case fa:{const c=t.valueOf(),u=e.valueOf();return Ma(c,u)}case pa:case ga:case ha:return Object.is(t.valueOf(),e.valueOf());case la:return t.source===e.source&&t.flags===e.flags;case _a:return t===e}n=n??new Map;const s=n.get(t),a=n.get(e);if(s!=null&&a!=null)return s===e;n.set(t,e),n.set(e,t);try{switch(i){case va:{if(t.size!==e.size)return!1;for(const[c,u]of t.entries())if(!e.has(c)||!Ve(u,e.get(c),c,t,e,n,r))return!1;return!0}case ya:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),u=Array.from(e.values());for(let d=0;d<c.length;d++){const m=c[d],b=u.findIndex(S=>Ve(m,S,void 0,t,e,n,r));if(b===-1)return!1;u.splice(b,1)}return!0}case ma:case Sa:case za:case Ta:case Aa:case ka:case Pa:case Ca:case Ia:case $a:case Oa:case Ra:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Ve(t[c],e[c],c,t,e,n,r))return!1;return!0}case ba:return t.byteLength!==e.byteLength?!1:Ue(new Uint8Array(t),new Uint8Array(e),n,r);case Ea:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:Ue(new Uint8Array(t),new Uint8Array(e),n,r);case wa:return t.name===e.name&&t.message===e.message;case Lt:{if(!(Ue(t.constructor,e.constructor,n,r)||yt(t)&&yt(e)))return!1;const u=[...Object.keys(t),...Vn(t)],d=[...Object.keys(e),...Vn(e)];if(u.length!==d.length)return!1;for(let m=0;m<u.length;m++){const b=u[m],S=t[b];if(!Object.hasOwn(e,b))return!1;const _=e[b];if(!Ve(S,_,b,t,e,n,r))return!1}return!0}default:return!1}}finally{n.delete(t),n.delete(e)}}function Bt(t,e){return xa(t,e,ua)}const Ye=h({campaign:f(pn),locale:f(l()),location:f(zt),page:f(ge),screen:f(Tt),userAgent:f(l())}),Va=g(Ye,{componentId:l(),experienceId:f(l()),variantIndex:f(C()),sticky:f(q())}),Na=g(Ye,{traits:f(At),userId:l()}),La=g(Ye,{properties:f(ss(ge))}),Ba=g(Ye,{name:l(),properties:He}),Ua=g(Ye,{event:l(),properties:f(K(He,{}))}),Kt={path:"",query:{},referrer:"",search:"",title:"",url:""};class ci{app;channel;library;getLocale;getPageProperties;getUserAgent;constructor(e){const{app:n,channel:r,library:i,getLocale:o,getPageProperties:s,getUserAgent:a}=e;this.app=n,this.channel=r,this.library=i,this.getLocale=o??(()=>"en-US"),this.getPageProperties=s??(()=>Kt),this.getUserAgent=a??(()=>{})}buildUniversalEventProperties({campaign:e={},locale:n,location:r,page:i,screen:o,userAgent:s}){const a=new Date().toISOString();return{channel:this.channel,context:{app:this.app,campaign:e,gdpr:{isConsentGiven:!0},library:this.library,locale:n??this.getLocale()??"en-US",location:r,page:i??this.getPageProperties(),screen:o,userAgent:s??this.getUserAgent()},messageId:crypto.randomUUID(),originalTimestamp:a,sentAt:a,timestamp:a}}buildComponentView(e){const{componentId:n,experienceId:r,variantIndex:i,...o}=Va.parse(e);return{...this.buildUniversalEventProperties(o),type:"component",componentType:"Entry",componentId:n,experienceId:r,variantIndex:i??0}}buildFlagView(e){return{...this.buildComponentView(e),componentType:"Variable"}}buildIdentify(e){const{traits:n={},userId:r,...i}=Na.parse(e);return{...this.buildUniversalEventProperties(i),type:"identify",traits:n,userId:r}}buildPageView(e={}){const{properties:n={},...r}=La.parse(e),i=this.getPageProperties(),o=be({...i,title:i.title??Kt.title},n),{context:{screen:s,...a},...c}=this.buildUniversalEventProperties(r),u=yn.parse(a);return{...c,context:u,type:"page",properties:o}}buildScreenView(e){const{name:n,properties:r,...i}=Ba.parse(e),{context:{page:o,...s},...a}=this.buildUniversalEventProperties(i),c=mn.parse(s);return{...a,context:c,type:"screen",name:n,properties:r}}buildTrack(e){const{event:n,properties:r={},...i}=Ua.parse(e);return{...this.buildUniversalEventProperties(i),type:"track",event:n,properties:r}}}function Da(t){switch(typeof t){case"number":case"symbol":return!1;case"string":return t.includes(".")||t.includes("[")||t.includes("]")}}function ja(t){return typeof t=="string"||typeof t=="symbol"?t:Object.is(t?.valueOf?.(),-0)?"-0":String(t)}function Za(t){const e=[],n=t.length;if(n===0)return e;let r=0,i="",o="",s=!1;for(t.charCodeAt(0)===46&&(e.push(""),r++);r<n;){const a=t[r];o?a==="\\"&&r+1<n?(r++,i+=t[r]):a===o?o="":i+=a:s?a==='"'||a==="'"?o=a:a==="]"?(s=!1,e.push(i),i=""):i+=a:a==="["?(s=!0,i&&(e.push(i),i="")):a==="."?i&&(e.push(i),i=""):i+=a,r++}return i&&e.push(i),e}function Yt(t,e,n){if(t==null)return n;switch(typeof e){case"string":{if(mt(e))return n;const r=t[e];return r===void 0?Da(e)?Yt(t,Za(e),n):n:r}case"number":case"symbol":{typeof e=="number"&&(e=ja(e));const r=t[e];return r===void 0?n:r}default:{if(Array.isArray(e))return Fa(t,e,n);if(Object.is(e?.valueOf(),-0)?e="-0":e=String(e),mt(e))return n;const r=t[e];return r===void 0?n:r}}}function Fa(t,e,n){if(e.length===0)return n;let r=t;for(let i=0;i<e.length;i++){if(r==null||mt(e[i]))return n;r=r[e[i]]}return r===void 0?n:r}const Bn=P("Personalization"),Un="Could not resolve Merge Tag value:",Ee={isMergeTagEntry(t){return wr.safeParse(t).success},normalizeSelectors(t){return t.split("_").map((e,n,r)=>{const i=r.slice(0,n).join("."),o=r.slice(n).join("_");return[i,o].filter(s=>s!=="").join(".")})},getValueFromProfile(t,e){const r=Ee.normalizeSelectors(t).find(o=>Yt(e,o));if(!r)return;const i=Yt(e,r);if(!(!i||typeof i!="string"&&typeof i!="number"&&typeof i!="boolean"))return`${i}`},resolve(t,e){if(!Ee.isMergeTagEntry(t)){Bn.warn(`${Un} supplied entry is not a Merge Tag entry`);return}const{fields:{nt_fallback:n}}=t;return Ke.safeParse(e).success?Ee.getValueFromProfile(t.fields.nt_mergetag_id,e)??n:(Bn.warn(`${Un} no valid profile`),n)}},W=P("Personalization"),Ie="Could not resolve personalized entry variant:",ue={getPersonalizationEntry({personalizedEntry:t,selectedPersonalizations:e},n=!1){return!n&&(!e.length||!rt(t))?void 0:t.fields.nt_experiences.filter(i=>xe(i)).find(i=>e.some(({experienceId:o})=>o===i.fields.nt_experience_id))},getSelectedPersonalization({personalizationEntry:t,selectedPersonalizations:e},n=!1){return!n&&(!e.length||!xe(t))?void 0:e.find(({experienceId:i})=>i===t.fields.nt_experience_id)},getSelectedVariant({personalizedEntry:t,personalizationEntry:e,selectedVariantIndex:n},r=!1){if(!r&&(!rt(t)||!xe(e)))return;const i=e.fields.nt_config?.components?.filter(o=>zr(o)&&!o.baseline.hidden).find(o=>o.baseline.id===t.sys.id)?.variants;if(i?.length)return i.at(n-1)},getSelectedVariantEntry({personalizationEntry:t,selectedVariant:e},n=!1){if(!n&&(!xe(t)||!Er(e)))return;const r=t.fields.nt_variants?.find(i=>i.sys.id===e.id);return _r(r)?r:void 0},resolve(t,e){if(W.debug(`Resolving personalized entry for baseline entry ${t.sys.id}`),!e?.length)return W.warn(`${Ie} no selectedPersonalizations exist for the current profile`),{entry:t};if(!rt(t))return W.warn(`${Ie} entry ${t.sys.id} is not personalized`),{entry:t};const n=ue.getPersonalizationEntry({personalizedEntry:t,selectedPersonalizations:e},!0);if(!n)return W.warn(`${Ie} could not find a personalization entry for ${t.sys.id}`),{entry:t};const r=ue.getSelectedPersonalization({personalizationEntry:n,selectedPersonalizations:e},!0),i=r?.variantIndex??0;if(i===0)return W.debug(`Resolved personalization entry for entry ${t.sys.id} is baseline`),{entry:t};const o=ue.getSelectedVariant({personalizedEntry:t,personalizationEntry:n,selectedVariantIndex:i},!0);if(!o)return W.warn(`${Ie} could not find a valid replacement variant entry for ${t.sys.id}`),{entry:t};const s=ue.getSelectedVariantEntry({personalizationEntry:n,selectedVariant:o},!0);if(s)W.debug(`Entry ${t.sys.id} has been resolved to variant entry ${s.sys.id}`);else return W.warn(`${Ie} could not find a valid replacement variant entry for ${t.sys.id}`),{entry:t};return{entry:s,personalization:r}}},J=Se(),Z=Se(),Y=Se(),Sn=Qn(()=>ft.resolve(J.value??[])),je=Se(!0),F=Se(),A=Se();function j(t){return{subscribe(e){return{unsubscribe:R(()=>{e(t.value)})}}}}const le={changes:J,consent:Z,event:Y,flags:Sn,online:je,personalizations:F,profile:A},Wt={batch:de,computed:Qn,effect:R,untracked:rn},et=t=>typeof t=="function",qa=t=>typeof t=="string"?t:typeof t=="symbol"?t.description??String(t):String(t),Ha=t=>typeof t=="string"||typeof t=="symbol",Ka=t=>Object.prototype.toString.call(t)==="[object AsyncFunction]";function D(t,e){return function(n,r){const i=qa(r.name);r.addInitializer(function(){const s=Reflect.get(this,r.name);if(!et(s))return;const a=s,c=Ka(a),u=_=>{const{[t]:L}=_;if(!et(L))throw new TypeError(`@guardedBy expects predicate "${String(t)}" to be a synchronous function.`);return L},d=(_,L)=>{const x=!!u(_).call(_,i,L);return e?.invert===!0?!x:x},m=(_,L)=>{const{onBlocked:I}=e??{};if(I!==void 0){if(et(I)){I.call(_,i,L);return}if(Ha(I)){const{[I]:x}=_;et(x)&&x.call(_,i,L)}}},b=()=>c?Promise.resolve(void 0):void 0,S=function(..._){return d(this,_)?a.call(this,..._):(m(this,_),b())};Reflect.set(this,r.name,S)})}}class ui{#e;constructor(e){const n=new Map;e&&Object.entries(e).map(([r,i])=>n.set(r.length?r:void 0,new Set(i))),this.#e=n}isPresent(e,n){return this.#e.get(e)?.has(n)??!1}addValue(e,n){const r=this.#e.get(e);r?r.add(n):this.#e.set(e,new Set([n]))}removeValue(e,n){this.#e.get(e)?.delete(n)}reset(e){e!==void 0?this.#e.get(e)?.clear():this.#e.clear()}}const Ya=["page","identify"];class li{allowedEventTypes;builder;api;duplicationDetector;interceptors;constructor(e){const{api:n,builder:r,config:i,interceptors:o}=e;this.allowedEventTypes=i?.allowedEventTypes??Ya,this.api=n,this.builder=r,this.duplicationDetector=new ui(i?.preventedComponentEvents),this.interceptors=o}}class di extends li{}var Wa=Object.create,fi=Object.defineProperty,Ga=Object.getOwnPropertyDescriptor,pi=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hi=t=>{throw TypeError(t)},gi=(t,e,n)=>e in t?fi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ja=t=>[,,,Wa(t?.[pi("metadata")]??null)],vi=["class","method","getter","setter","accessor","field","value","get","set"],yi=t=>t!==void 0&&typeof t!="function"?hi("Function expected"):t,Qa=(t,e,n,r,i)=>({kind:vi[t],name:e,metadata:r,addInitializer:o=>n._?hi("Already initialized"):i.push(yi(o||null))}),Xa=(t,e)=>gi(e,pi("metadata"),t[3]),ec=(t,e,n,r)=>{for(var i=0,o=t[e>>1],s=o&&o.length;i<s;i++)o[i].call(n);return r},mi=(t,e,n,r,i,o)=>{for(var s,a,c,u,d=e&7,m=!1,b=!1,S=2,_=vi[d+5],L=t[S]||(t[S]=[]),I=(i=i.prototype,Ga(i,n)),x=r.length-1;x>=0;x--)c=Qa(d,n,a={},t[3],L),c.static=m,c.private=b,u=c.access={has:ie=>n in ie},u.get=ie=>ie[n],s=(0,r[x])(I[_],c),a._=1,yi(s)&&(I[_]=s);return I&&fi(i,n,I),i},Dn=(t,e,n)=>gi(t,typeof e!="symbol"?e+"":e,n),_i,bi,Gt,We;const H=P("Analytics"),tc=25;class Ge extends(Gt=di,bi=[D("isNotDuplicated",{onBlocked:"onBlockedByDuplication"}),D("hasConsent",{onBlocked:"onBlockedByConsent"})],_i=[D("isNotDuplicated",{onBlocked:"onBlockedByDuplication"}),D("hasConsent",{onBlocked:"onBlockedByConsent"})],Gt){constructor(e){const{api:n,builder:r,config:i,interceptors:o}=e;super({api:n,builder:r,config:i,interceptors:o}),ec(We,5,this),Dn(this,"queue",new Map),Dn(this,"states",{eventStream:j(Y),profile:j(A)});const{defaults:s}=i??{};if(s?.profile!==void 0){const{profile:a}=s;A.value=a}R(()=>{const a=A.value?.id;H.info(`Analytics ${Z.value?"will":"will not"} be collected due to consent (${Z.value})`),H.debug(`Profile ${a&&`with ID ${a}`} has been ${a?"set":"cleared"}`)}),R(()=>{je.value&&this.flush()})}reset(){de(()=>{Y.value=void 0,A.value=void 0})}hasConsent(e){return!!Z.value||(this.allowedEventTypes??[]).includes(e==="trackComponentView"||e==="trackFlagView"?"component":e)}onBlockedByConsent(e,n){H.warn(`Event "${e}" was blocked due to lack of consent; payload: ${JSON.stringify(n)}`)}isNotDuplicated(e,n){const[{componentId:r},i]=n,o=this.duplicationDetector.isPresent(i,r);return o||this.duplicationDetector.addValue(i,r),!o}onBlockedByDuplication(e,n){const r=e==="trackFlagView"?"flag":"component";H.debug(`Duplicate "${r} view" event detected, skipping; payload: ${JSON.stringify(n)}`)}async trackComponentView(e,n=""){H.info(`Processing "component view" event for ${e.componentId}`),await this.enqueueEvent(this.builder.buildComponentView(e))}async trackFlagView(e,n=""){H.debug(`Processing "flag view" event for ${e.componentId}`),await this.enqueueEvent(this.builder.buildFlagView(e))}async enqueueEvent(e){const{value:n}=A;if(!n){H.warn("Attempting to emit an event without an Optimization profile");return}const r=await this.interceptors.event.run(e),i=wn.parse(r);H.debug(`Queueing ${i.type} event for profile ${n.id}`,i);const o=this.queue.get(n);Y.value=i,o?o.push(i):this.queue.set(n,[i]),await this.flushMaxEvents()}async flushMaxEvents(){this.queue.values().toArray().flat().length>=tc&&await this.flush()}async flush(){H.debug("Flushing event queue");const e=[];if(this.queue.forEach((r,i)=>e.push({profile:i,events:r})),!e.length)return;await this.api.insights.sendBatchEvents(e)&&this.queue.clear()}}We=Ja(Gt);mi(We,1,"trackComponentView",bi,Ge);mi(We,1,"trackFlagView",_i,Ge);Xa(We,Ge);const jn=P("Analytics");class wi extends di{async trackComponentView(e){jn.info('Processing "component view" event');const{profile:n,...r}=e,i=this.builder.buildComponentView(r),o=await this.interceptors.event.run(i),s=fe.parse(o);await this.sendBatchEvent(s,n)}async trackFlagView(e){jn.debug('Processing "flag view" event');const{profile:n,...r}=e,i=this.builder.buildFlagView(r),o=await this.interceptors.event.run(i),s=fe.parse(o);await this.sendBatchEvent(s,n)}async sendBatchEvent(e,n){const r=En.parse([{profile:n,events:[e]}]);await this.api.insights.sendBatchEvents(r)}}const Ei="0.1.0-alpha6",Ne="ctfl-opt-aid",ot="__ctfl_opt_anonymous_id__",st="__ctfl_opt_consent__",at="__ctfl_opt_changes__",ct="__ctfl_opt_debug__",ut="__ctfl_opt_profile__",lt="__ctfl_opt_personalizations__",Jt="ntaid",Qt="__nt_anonymous_id__";class Xt{interceptors=new Map;nextId=0;add(e){const{nextId:n}=this;return this.nextId+=1,this.interceptors.set(n,e),n}remove(e){return this.interceptors.delete(e)}clear(){this.interceptors.clear()}count(){return this.interceptors.size}async run(e){const n=Array.from(this.interceptors.values());let r=e;for(const i of n)r=await i(r);return r}}class Si{api;eventBuilder;config;interceptors={event:new Xt,state:new Xt};constructor(e){this.config=e;const{analytics:n,personalization:r,eventBuilder:i,logLevel:o,environment:s,clientId:a}=e;G.addSink(new ri(o));const c={...n,...r,clientId:a,environment:s};this.api=new ai(c),this.eventBuilder=new ci(i??{channel:"server",library:{name:"Optimization Core",version:Ei}})}getCustomFlag(e,n){return this.personalization.getCustomFlag(e,n)}personalizeEntry(e,n){return this.personalization.personalizeEntry(e,n)}getMergeTagValue(e,n){return this.personalization.getMergeTagValue(e,n)}async identify(e){return await this.personalization.identify(e)}async page(e){return await this.personalization.page(e)}async screen(e){return await this.personalization.screen(e)}async track(e){return await this.personalization.track(e)}async trackComponentView(e,n){if(e.sticky)return await this.personalization.trackComponentView(e,n);await this.analytics.trackComponentView(e,n)}async trackFlagView(e,n){await this.analytics.trackFlagView(e,n)}}class zi extends li{flagsResolver=ft;mergeTagValueResolver=Ee;personalizedEntryResolver=ue;getCustomFlag(e,n){return ft.resolve(n)[e]}personalizeEntry(e,n){return ue.resolve(e,n)}getMergeTagValue(e,n){return Ee.resolve(e,n)}}var nc=Object.create,Ti=Object.defineProperty,rc=Object.getOwnPropertyDescriptor,Ai=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ki=t=>{throw TypeError(t)},Pi=(t,e,n)=>e in t?Ti(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ic=t=>[,,,nc(t?.[Ai("metadata")]??null)],Ci=["class","method","getter","setter","accessor","field","value","get","set"],Ii=t=>t!==void 0&&typeof t!="function"?ki("Function expected"):t,oc=(t,e,n,r,i)=>({kind:Ci[t],name:e,metadata:r,addInitializer:o=>n._?ki("Already initialized"):i.push(Ii(o||null))}),sc=(t,e)=>Pi(e,Ai("metadata"),t[3]),ac=(t,e,n,r)=>{for(var i=0,o=t[e>>1],s=o&&o.length;i<s;i++)o[i].call(n);return r},Je=(t,e,n,r,i,o)=>{for(var s,a,c,u,d=e&7,m=!1,b=!1,S=2,_=Ci[d+5],L=t[S]||(t[S]=[]),I=(i=i.prototype,rc(i,n)),x=r.length-1;x>=0;x--)c=oc(d,n,a={},t[3],L),c.static=m,c.private=b,u=c.access={has:ie=>n in ie},u.get=ie=>ie[n],s=(0,r[x])(I[_],c),a._=1,Ii(s)&&(I[_]=s);return I&&Ti(i,n,I),i},Ut=(t,e,n)=>Pi(t,typeof e!="symbol"?e+"":e,n),$i,Oi,Ri,Mi,xi,en,ne;const V=P("Personalization");class re extends(en=zi,xi=[D("hasConsent",{onBlocked:"onBlockedByConsent"})],Mi=[D("hasConsent",{onBlocked:"onBlockedByConsent"})],Ri=[D("hasConsent",{onBlocked:"onBlockedByConsent"})],Oi=[D("hasConsent",{onBlocked:"onBlockedByConsent"})],$i=[D("isNotDuplicated",{onBlocked:"onBlockedByDuplication"}),D("hasConsent",{onBlocked:"onBlockedByConsent"})],en){constructor(e){const{api:n,builder:r,config:i,interceptors:o}=e;super({api:n,builder:r,config:i,interceptors:o}),ac(ne,5,this),Ut(this,"offlineQueue",new Set),Ut(this,"states",{eventStream:j(Y),flags:j(Sn),profile:j(A),personalizations:j(F)}),Ut(this,"getAnonymousId");const{defaults:s,getAnonymousId:a}=i??{};if(s){const{changes:c,personalizations:u,profile:d}=s;de(()=>{J.value=c,F.value=u,A.value=d})}if(s?.consent!==void 0){const{consent:c}=s;Z.value=c}this.getAnonymousId=a??(()=>{}),R(()=>{V.debug(`Profile ${A.value&&`with ID ${A.value.id}`} has been ${A.value?"set":"cleared"}`)}),R(()=>{V.debug(`Variants have been ${F.value?.length?"populated":"cleared"}`)}),R(()=>{V.info(`Personalization ${Z.value?"will":"will not"} take effect due to consent (${Z.value})`)}),R(()=>{je.value&&this.flush()})}reset(){de(()=>{J.value=void 0,Y.value=void 0,A.value=void 0,F.value=void 0})}getCustomFlag(e,n=J.value){return super.getCustomFlag(e,n)}personalizeEntry(e,n=F.value){return super.personalizeEntry(e,n)}getMergeTagValue(e,n=A.value){return super.getMergeTagValue(e,n)}hasConsent(e){return!!Z.value||(this.allowedEventTypes??[]).includes(e==="trackComponentView"||e==="trackFlagView"?"component":e)}onBlockedByConsent(e,n){V.warn(`Event "${e}" was blocked due to lack of consent; payload: ${JSON.stringify(n)}`)}isNotDuplicated(e,n){const[{componentId:r},i]=n,o=this.duplicationDetector.isPresent(i,r);return o||this.duplicationDetector.addValue(i,r),!o}onBlockedByDuplication(e,n){V.debug(`Duplicate "component view" event detected, skipping; payload: ${JSON.stringify(n)}`)}async identify(e){V.info('Sending "identify" event');const n=this.builder.buildIdentify(e);return await this.sendOrEnqueueEvent(n)}async page(e){V.info('Sending "page" event');const n=this.builder.buildPageView(e);return await this.sendOrEnqueueEvent(n)}async screen(e){V.info(`Sending "screen" event for "${e.name}"`);const n=this.builder.buildScreenView(e);return await this.sendOrEnqueueEvent(n)}async track(e){V.info(`Sending "track" event "${e.event}"`);const n=this.builder.buildTrack(e);return await this.sendOrEnqueueEvent(n)}async trackComponentView(e,n=""){V.info(`Sending "track personalization" event for ${e.componentId}`);const r=this.builder.buildComponentView(e);return await this.sendOrEnqueueEvent(r)}async sendOrEnqueueEvent(e){const n=await this.interceptors.event.run(e),r=_n.parse(n);if(Y.value=r,je.value)return await this.upsertProfile([r]);V.debug(`Queueing ${r.type} event`,r),this.offlineQueue.add(r)}async flush(){this.offlineQueue.size!==0&&(V.debug("Flushing offline event queue"),await this.upsertProfile(Array.from(this.offlineQueue)),this.offlineQueue.clear())}async upsertProfile(e){const n=this.getAnonymousId();n&&V.debug(`Anonymous ID found: ${n}`);const r=await this.api.experience.upsertProfile({profileId:n??A.value?.id,events:e});return await this.updateOutputSignals(r),r}async updateOutputSignals(e){const n=await this.interceptors.state.run(e),{changes:r,personalizations:i,profile:o}=n;de(()=>{Bt(J.value,r)||(J.value=r),Bt(A.value,o)||(A.value=o),Bt(F.value,i)||(F.value=i)})}}ne=ic(en);Je(ne,1,"identify",xi,re);Je(ne,1,"page",Mi,re);Je(ne,1,"screen",Ri,re);Je(ne,1,"track",Oi,re);Je(ne,1,"trackComponentView",$i,re);sc(ne,re);const $e=P("Personalization");class Vi extends zi{async identify(e){$e.info('Sending "identify" event');const{profile:n,...r}=e,i=Pt.parse(this.builder.buildIdentify(r));return await this.upsertProfile(i,n)}async page(e){$e.info('Sending "page" event');const{profile:n,...r}=e,i=Ct.parse(this.builder.buildPageView(r));return await this.upsertProfile(i,n)}async screen(e){$e.info(`Sending "screen" event for "${e.name}"`);const{profile:n,...r}=e,i=It.parse(this.builder.buildScreenView(r));return await this.upsertProfile(i,n)}async track(e){$e.info(`Sending "track" event "${e.event}"`);const{profile:n,...r}=e,i=$t.parse(this.builder.buildTrack(r));return await this.upsertProfile(i,n)}async trackComponentView(e){$e.info('Sending "track personalization" event');const{profile:n,...r}=e,i=fe.parse(this.builder.buildComponentView(r));return await this.upsertProfile(i,n)}async upsertProfile(e,n){const r=await this.interceptors.event.run(e);return await this.api.experience.upsertProfile({profileId:n?.id,events:[r]})}}class Ni extends Si{analytics;personalization;constructor(e){super(e);const{allowedEventTypes:n,defaults:r,getAnonymousId:i,preventedComponentEvents:o}=e;if(r?.consent!==void 0){const{consent:s}=r;Z.value=s}this.analytics=new Ge({api:this.api,builder:this.eventBuilder,config:{allowedEventTypes:n,preventedComponentEvents:o,defaults:{consent:r?.consent,profile:r?.profile}},interceptors:this.interceptors}),this.personalization=new re({api:this.api,builder:this.eventBuilder,config:{allowedEventTypes:n,getAnonymousId:i,preventedComponentEvents:o,defaults:{consent:r?.consent,changes:r?.changes,profile:r?.profile,personalizations:r?.personalizations}},interceptors:this.interceptors})}get states(){return{consent:j(Z),eventStream:j(Y),flags:j(Sn),personalizations:j(F),profile:j(A)}}reset(){de(()=>{Y.value=void 0,J.value=void 0,A.value=void 0,F.value=void 0})}async flush(){await this.analytics.flush(),await this.personalization.flush()}consent(e){Z.value=e}online(e){je.value=e}registerPreviewPanel(e){return e&&(e.signals=le,e.signalFns=Wt),{signals:le,signalFns:Wt}}}class cc extends Si{analytics;personalization;constructor(e){super(e),this.analytics=new wi({api:this.api,builder:this.eventBuilder,interceptors:this.interceptors}),this.personalization=new Vi({api:this.api,builder:this.eventBuilder,interceptors:this.interceptors})}}/*! js-cookie v3.0.5 | MIT */function tt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var uc={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function tn(t,e){function n(i,o,s){if(!(typeof document>"u")){s=tt({},e,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in s)s[c]&&(a+="; "+c,s[c]!==!0&&(a+="="+s[c].split(";")[0]));return document.cookie=i+"="+t.write(o,i)+a}}function r(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var o=document.cookie?document.cookie.split("; "):[],s={},a=0;a<o.length;a++){var c=o[a].split("="),u=c.slice(1).join("=");try{var d=decodeURIComponent(c[0]);if(s[d]=t.read(u,d),i===d)break}catch{}}return i?s[i]:s}}return Object.create({set:n,get:r,remove:function(i,o){n(i,"",tt({},o,{expires:-1}))},withAttributes:function(i){return tn(this.converter,tt({},this.attributes,i))},withConverter:function(i){return tn(tt({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var me=tn(uc,{path:"/"});const nn=P("Web:AutoTracking");function Ze(t){if(!(typeof HTMLElement<"u"&&typeof SVGElement<"u")||!t||t.nodeType!==1||!("dataset"in t)||!t.dataset||typeof t.dataset!="object"||!("ctflEntryId"in t.dataset))return!1;const{dataset:{ctflEntryId:n}}=t;return typeof n=="string"&&n.trim().length>0}function Zn(t){return!t||typeof t!="object"?!1:"entryId"in t&&typeof t.entryId=="string"&&!!t.entryId.trim().length}function lc(t){return(t?.trim().toLowerCase()??"")==="true"}function dc(t){if(t===void 0||!/^\d+$/.test(t))return;const e=Number(t);return Number.isSafeInteger(e)?e:void 0}const fc=t=>async(e,n)=>{if(!Zn(n.data)&&!Ze(e))return;let r,i,o,s,a;if(Zn(n.data))({data:{duplicationScope:r,entryId:i,personalizationId:o,sticky:s,variantIndex:a}}=n);else if(Ze(e)){({dataset:{ctflDuplicationScope:r,ctflEntryId:i,ctflPersonalizationId:o}}=e);const{dataset:{ctflSticky:c,ctflVariantIndex:u}}=e;s=lc(c),a=dc(u)}if(!i){nn.warn("No entry data found in entry view observer callback; please add data attributes or observe with data info");return}await t.trackComponentView({componentId:i,experienceId:o,sticky:s,variantIndex:a},r)};function Fn(t){if(Ze(t))return t;const e=t.querySelector("[data-ctfl-entry-id]")??void 0;return Ze(e)?e:void 0}const pc=(t,e=!1)=>({onRemoved:n=>{n.forEach(r=>{const i=Fn(r);!i||!t.getStats(i)||(nn.info("Auto-unobserving element (remove):",i),t.unobserve(i))})},onAdded:e?n=>{n.forEach(r=>{const i=Fn(r);i&&(nn.info("Auto-observing element (add):",i),t.observe(i))})}:void 0}),hc=P("Web:EventBuilder");function gc(t){return new URL(t).searchParams.entries().reduce((e,[n,r])=>(e[n]=r,e),{})}function Li(){const{languages:t,language:e}=navigator;return t[0]??e}function Bi(){try{const t=new URL(window.location.href),{referrer:e,title:n}=document;return{hash:window.location.hash,height:window.innerHeight,path:t.pathname,query:gc(t),referrer:e,search:t.search,title:n,url:t.toString(),width:window.innerWidth}}catch(t){return t instanceof Error&&hc.error("Failed to get page properties:",t),{path:"",query:{},referrer:"",search:"",title:"",url:""}}}function Ui(){return navigator.userAgent}const Di="0.1.0-alpha6",M=typeof window<"u"&&typeof document<"u"&&typeof document.addEventListener=="function";function ji(t,e){const n=new Blob([JSON.stringify(e)],{type:"text/plain"});return window.navigator.sendBeacon(t,n)}const vc=P("Web:Network");function yc(t){if(!M)return()=>{};const e=i=>{(async()=>{try{await t(i)}catch(o){vc.error("Error in online state callback:",o)}})()},n=()=>{e(!0)},r=()=>{e(!1)};return window.addEventListener("online",n),window.addEventListener("offline",r),e(typeof navigator.onLine=="boolean"?navigator.onLine:!0),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}const mc=P("Web:Visibility");function _c(t){if(!M)return()=>{};let e=!1;const n=a=>{e||(e=!0,(async()=>{try{await t(a)}catch(c){mc.error("Error handling page visibility change:",c)}})())},r=()=>{e=!1},i=a=>{document.visibilityState==="hidden"?n(a):r()},o=a=>{n(a)},s=()=>{r()};return document.addEventListener("visibilitychange",i),window.addEventListener("pagehide",o),window.addEventListener("pageshow",s),()=>{document.removeEventListener("visibilitychange",i),window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",s)}}const Oe=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),Re=()=>M?document.visibilityState==="visible":!0,ce={DWELL_MS:1e3,RATIO:.1,MAX_RETRIES:2,BACKOFF_MS:300,MULTIPLIER:2,JITTER_DIVISOR:2,SWEEP_INTERVAL_MS:3e4},bc=t=>t+Math.floor(Math.random()*Math.max(1,Math.floor(t/ce.JITTER_DIVISOR))),N={n:(t,e)=>typeof t=="number"?t:e,clamp01:(t,e)=>Math.min(1,Math.max(0,N.n(t,e))),nonNeg:(t,e)=>Math.max(0,N.n(t,e)),atLeast1:(t,e)=>Math.max(1,N.n(t,e))},se=t=>{t.fireTimer!==null&&(clearTimeout(t.fireTimer),t.fireTimer=null)},ae=t=>{t.retryTimer!==null&&(clearTimeout(t.retryTimer),t.retryTimer=null),t.retryScheduledAt=null},Dt=t=>{if(t.ref&&typeof t.ref.deref=="function"){const e=t.ref.deref();if(e)return e}return t.strongRef??null},qn=100,Hn=250,wc=16,Ec=1,Sc=M&&typeof MutationObserver<"u",Kn=M&&typeof window.requestIdleCallback=="function",zc=M&&typeof window.cancelIdleCallback=="function";class U{observer;root;idleTimeoutMs;maxChunk;onChange;onAdded;onRemoved;onError;pendingRecords=[];scheduled=!1;idleHandle=null;disconnected=!1;constructor(e={}){const{root:n,idleTimeoutMs:r=qn,maxChunk:i=Hn,onChange:o,onAdded:s,onRemoved:a,onError:c}=e;this.root=U.isNode(n)?n:M?document:null,this.idleTimeoutMs=U.sanitizeInt(r,qn,wc),this.maxChunk=U.sanitizeInt(i,Hn,Ec),this.onChange=o,this.onAdded=s,this.onRemoved=a,this.onError=c,Sc&&this.root&&(this.observer=new MutationObserver(u=>{for(const d of u)(d.addedNodes.length>0||d.removedNodes.length>0)&&this.pendingRecords.push(d);this.pendingRecords.length>0&&this.scheduleProcess()}),this.observer.observe(this.root,{childList:!0,subtree:!0}))}isActive(){return!!this.observer&&!this.disconnected}disconnect(){this.disconnected||(this.disconnected=!0,this.observer?.disconnect(),this.pendingRecords=[],this.idleHandle!==null&&(U.cancelIdle(this.idleHandle),this.idleHandle=null),this.scheduled=!1)}flush(){this.isActive()&&(this.idleHandle!==null&&(U.cancelIdle(this.idleHandle),this.idleHandle=null),!(!this.scheduled&&this.pendingRecords.length===0)&&(this.scheduled=!1,this.processNow()))}scheduleProcess(){if(!this.isActive()||this.scheduled)return;this.scheduled=!0;const e=()=>{this.idleHandle=null,this.scheduled=!1,this.processNow()};this.idleHandle=Kn?window.requestIdleCallback(e,{timeout:this.idleTimeoutMs}):window.setTimeout(e,this.idleTimeoutMs)}processNow(){if(!this.isActive()||this.pendingRecords.length===0)return;const e=this.drainPending(),{addedNodes:n,removedNodes:r}=U.coalesce(e),{added:i,removed:o}=U.toElementSets(n,r);i.size===0&&o.size===0||(this.deliverAggregate(i,o,e),this.deliverPerKind(o,i))}static isNode(e){return M&&typeof Node<"u"&&e instanceof Node}static sanitizeInt(e,n,r){if(typeof e!="number"||!Number.isFinite(e))return n;const i=Math.trunc(e);return i>=r?i:r}static coalesce(e){const n=new Set,r=new Set;for(const i of e){for(const o of i.addedNodes)r.delete(o)||n.add(o);for(const o of i.removedNodes)n.delete(o)||r.add(o)}return{addedNodes:n,removedNodes:r}}static toElementSets(e,n){const r=U.flattenElements(e,!0),i=U.flattenElements(n,!1);return{added:r,removed:i}}static flattenElements(e,n){const r=new Set;for(const i of e){if(i instanceof Element){(!n||i.isConnected)&&r.add(i),i.querySelectorAll("*").forEach(o=>{(!n||o.isConnected)&&r.add(o)});continue}i instanceof DocumentFragment&&i.querySelectorAll("*").forEach(o=>{(!n||o.isConnected)&&r.add(o)})}return r}static cancelIdle(e){zc?window.cancelIdleCallback(e):M&&window.clearTimeout(e)}drainPending(){const{pendingRecords:e}=this;return this.pendingRecords=[],e}deliverAggregate(e,n,r){if(!this.onChange)return;const i={added:e,removed:n,records:r};this.safeCall(()=>this.onChange?.(i))}deliverPerKind(e,n){const r=e.size>0?[...e]:[],i=n.size>0?[...n]:[];this.onRemoved&&r.length>0&&this.dispatchChunked(r,this.onRemoved),this.onAdded&&i.length>0&&this.dispatchChunked(i,this.onAdded)}dispatchChunked(e,n){if(!this.isActive()||e.length===0)return;if(e.length<=this.maxChunk){this.safeCall(()=>n(e));return}let r=0;const i=()=>{if(!this.isActive())return;const o=Math.min(e.length,r+this.maxChunk),s=e.slice(r,o);r=o,this.safeCall(()=>n(s)),r<e.length&&(Kn?window.requestIdleCallback(i,{timeout:this.idleTimeoutMs}):M&&window.setTimeout(i,this.idleTimeoutMs))};i()}safeCall(e){try{const n=e();Promise.resolve(n).catch(r=>{this.onError?.(r)})}catch(n){this.onError?.(n)}}}class De{callback;opts;io;states=new WeakMap;activeStates=new Set;boundVisibilityHandler=null;sweepInterval=null;constructor(e,n){this.callback=e,this.opts=De.initOptions(n),this.io=new IntersectionObserver(r=>{this.onIntersect(r)},{root:this.opts.root??null,rootMargin:this.opts.rootMargin,threshold:this.opts.minVisibleRatio===0?[0]:[0,this.opts.minVisibleRatio]}),M&&(this.boundVisibilityHandler=()=>{this.onPageVisibilityChange()},document.addEventListener("visibilitychange",this.boundVisibilityHandler))}observe(e,n){let r=this.states.get(e);r||(r=this.createState(e,n),this.states.set(e,r),this.activeStates.add(r),this.ensureSweeper()),this.io.observe(e)}unobserve(e){this.io.unobserve(e);const n=this.states.get(e);n&&(se(n),ae(n),n.done=!0,this.activeStates.delete(n),n.strongRef===e&&(n.strongRef=null),this.states.delete(e),this.maybeStopSweeper())}disconnect(){this.io.disconnect();for(const e of this.activeStates)se(e),ae(e),e.done=!0,e.strongRef=null;this.activeStates.clear(),M&&this.boundVisibilityHandler&&(document.removeEventListener("visibilitychange",this.boundVisibilityHandler),this.boundVisibilityHandler=null),this.stopSweeper()}getStats(e){const n=this.states.get(e);return n?{accumulatedMs:n.accumulatedMs,visibleSince:n.visibleSince,attempts:n.attempts,done:n.done,inFlight:n.inFlight,pendingRetry:n.pendingRetry,lastKnownVisible:n.lastKnownVisible}:null}static initOptions(e){return{dwellTimeMs:N.nonNeg(e?.dwellTimeMs,ce.DWELL_MS),minVisibleRatio:N.clamp01(e?.minVisibleRatio,ce.RATIO),root:e?.root??null,rootMargin:e?.rootMargin??"0px",maxRetries:N.nonNeg(e?.maxRetries,ce.MAX_RETRIES),retryBackoffMs:N.nonNeg(e?.retryBackoffMs,ce.BACKOFF_MS),backoffMultiplier:N.atLeast1(e?.backoffMultiplier,ce.MULTIPLIER)}}createState(e,n){const r={dwellTimeMs:N.nonNeg(n?.dwellTimeMs,this.opts.dwellTimeMs),maxRetries:N.nonNeg(n?.maxRetries,this.opts.maxRetries),retryBackoffMs:N.nonNeg(n?.retryBackoffMs,this.opts.retryBackoffMs),backoffMultiplier:N.atLeast1(n?.backoffMultiplier,this.opts.backoffMultiplier)},i=typeof WeakRef=="function";return{ref:i?new WeakRef(e):null,strongRef:i?null:e,opts:r,data:n?.data,accumulatedMs:0,visibleSince:null,fireTimer:null,retryTimer:null,retryScheduledAt:null,retryDelayMs:null,pendingRetry:!1,attempts:0,done:!1,inFlight:!1,lastKnownVisible:!1}}onPageVisibilityChange(){const e=Oe(),n=!Re();for(const r of this.activeStates)n?De.onHidden(r,e):this.onResume(r,e);this.sweepOrphans()}static onHidden(e,n){if(!e.done&&(e.visibleSince!==null&&(e.accumulatedMs+=n-e.visibleSince,e.visibleSince=null),se(e),e.retryTimer!==null)){const r=e.retryScheduledAt?n-e.retryScheduledAt:0,i=e.retryDelayMs!==null?Math.max(0,e.retryDelayMs-r):null;ae(e),i!==null&&(e.pendingRetry=!0,e.retryDelayMs=i,e.retryScheduledAt=null)}}onResume(e,n){e.done||(e.lastKnownVisible&&e.visibleSince===null&&(e.visibleSince=n,this.scheduleFireIfDue(e,n)),e.pendingRetry&&!e.inFlight&&e.lastKnownVisible&&e.retryDelayMs!==null&&this.scheduleRetry(e,e.retryDelayMs))}onIntersect(e){const n=Oe();for(const r of e){const i=this.states.get(r.target);if(!i||i.done)continue;r.isIntersecting&&r.intersectionRatio>=this.opts.minVisibleRatio&&Re()?this.onVisible(i,n):De.onNotVisible(i,n)}this.sweepOrphans()}onVisible(e,n){if(e.lastKnownVisible=!0,e.visibleSince===null){e.visibleSince=n,e.attempts=0,e.pendingRetry&&!e.inFlight&&e.retryDelayMs!==null?this.scheduleRetry(e,e.retryDelayMs):this.scheduleFireIfDue(e,n);return}!e.pendingRetry&&e.fireTimer===null&&!e.inFlight&&this.scheduleFireIfDue(e,n)}static onNotVisible(e,n){e.lastKnownVisible=!1,e.visibleSince!==null&&(e.accumulatedMs+=n-e.visibleSince,e.visibleSince=null),se(e),(e.pendingRetry||e.retryTimer!==null)&&(ae(e),e.pendingRetry=!1,e.attempts=0)}scheduleFireIfDue(e,n){if(e.done||e.inFlight||e.fireTimer!==null||e.pendingRetry)return;const r=e.accumulatedMs+(e.visibleSince!==null?n-e.visibleSince:0),i=e.opts.dwellTimeMs-r;if(i<=0){this.trigger(e);return}e.fireTimer=setTimeout(()=>{!e.done&&e.lastKnownVisible&&Re()?this.trigger(e):se(e)},Math.ceil(i))}scheduleRetry(e,n){e.pendingRetry=!0,e.retryDelayMs=Math.max(0,Math.ceil(n)),!(!Re()||!e.lastKnownVisible||e.done||e.inFlight)&&(e.retryScheduledAt=Oe(),e.retryTimer=setTimeout(()=>{e.retryTimer=null,e.retryScheduledAt=null,this.attemptCallback(e)},e.retryDelayMs))}trigger(e){if(e.done||e.inFlight)return;const n=Oe(),r=e.accumulatedMs+(e.visibleSince!==null?n-e.visibleSince:0);ae(e),e.pendingRetry=!1,se(e),this.attemptCallback(e,r)}async attemptCallback(e,n){if(e.done||e.inFlight)return;const r=Dt(e);if(!r){this.finalizeDroppedState(e);return}const i=e.attempts+1;e.attempts=i,e.inFlight=!0;const o=n??e.accumulatedMs+(e.visibleSince!==null?Oe()-e.visibleSince:0);try{await this.callback(r,{totalVisibleMs:o,attempts:i,data:e.data}),this.onAttemptSuccess(e,r)}catch{this.onAttemptFailure(e)}}onAttemptSuccess(e,n){e.inFlight=!1,e.done=!0,this.safeAutoUnobserve(n,e)}onAttemptFailure(e){if(e.inFlight=!1,e.attempts>e.opts.maxRetries){this.onRetriesExceeded(e);return}const n=e.opts.retryBackoffMs*Math.pow(e.opts.backoffMultiplier,e.attempts-1),r=bc(n);if(!e.lastKnownVisible||!Re()){e.pendingRetry=!0,e.retryDelayMs=Math.ceil(r),e.retryScheduledAt=null;return}this.scheduleRetry(e,r)}onRetriesExceeded(e){ae(e),e.pendingRetry=!1,e.done=!0;const n=Dt(e);n?this.safeAutoUnobserve(n,e):this.finalizeDroppedState(e)}finalizeDroppedState(e){se(e),ae(e),e.done=!0,this.activeStates.delete(e),e.strongRef&&(this.states.delete(e.strongRef),e.strongRef=null),this.maybeStopSweeper()}safeAutoUnobserve(e,n){try{this.unobserve(e)}catch{this.activeStates.delete(n),n.strongRef===e&&(this.states.delete(e),n.strongRef=null),n.done=!0,this.maybeStopSweeper()}}ensureSweeper(){this.sweepInterval===null&&(this.sweepInterval=setInterval(()=>{this.sweepOrphans()},ce.SWEEP_INTERVAL_MS))}stopSweeper(){this.sweepInterval!==null&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}maybeStopSweeper(){this.activeStates.size===0&&this.stopSweeper()}sweepOrphans(){if(M){for(const e of Array.from(this.activeStates)){const n=Dt(e);if(!n){this.finalizeDroppedState(e);continue}(typeof n.isConnected=="boolean"?n.isConnected:document.contains(n))||this.safeAutoUnobserve(n,e)}this.maybeStopSweeper()}}}const w={reset(t={resetConsent:!1,resetDebug:!1}){t.resetConsent&&localStorage.removeItem(st),t.resetDebug&&localStorage.removeItem(ct),localStorage.removeItem(ot),localStorage.removeItem(at),localStorage.removeItem(ut),localStorage.removeItem(lt)},get anonymousId(){const t=localStorage.getItem(Qt);return t&&localStorage.removeItem(Qt),t??localStorage.getItem(ot)??void 0},set anonymousId(t){w.setCache(ot,t)},get consent(){switch(localStorage.getItem(st)){case"accepted":return!0;case"denied":return!1}},set consent(t){const e=t?"accepted":"denied";w.setCache(st,t===void 0?void 0:e)},get debug(){const t=localStorage.getItem(ct);return t?t==="true":void 0},set debug(t){w.setCache(ct,t)},get changes(){return w.getCache(at,hn)},set changes(t){w.setCache(at,t)},get profile(){return w.getCache(ut,Ke)},set profile(t){w.setCache(ut,t)},get personalizations(){return w.getCache(lt,bn)},set personalizations(t){w.setCache(lt,t)},getCache(t,e){const n=localStorage.getItem(t);if(!n)return;const r=e.safeParse(JSON.parse(n));if(r.success)return r.data},setCache(t,e){e===void 0?localStorage.removeItem(t):localStorage.setItem(t,typeof e=="string"?e:JSON.stringify(e))}},jt=P("Web:SDK"),Tc=365;function Ac({app:t,defaults:e,logLevel:n,...r}){const{consent:i=w.consent,profile:o=w.profile,changes:s=w.changes,personalizations:a=w.personalizations}=e??{};return be({analytics:{beaconHandler:ji},defaults:{consent:i,changes:s,profile:o,personalizations:a},eventBuilder:{app:t,channel:"web",library:{name:"Optimization Web SDK",version:Di},getLocale:Li,getPageProperties:Bi,getUserAgent:Ui},getAnonymousId:()=>w.anonymousId,logLevel:w.debug?"debug":n},r)}class kc extends Ni{elementViewObserver=void 0;elementExistenceObserver=void 0;autoTrackEntryViews=!1;cookieAttributes=void 0;constructor(e){if(typeof window<"u"&&window.optimization)throw new Error("Optimization is already initialized");const{autoTrackEntryViews:n,...r}=e,i=Ac(r);super(i);const o=me.get(Jt),s=o??me.get(Ne);this.autoTrackEntryViews=!0,this.cookieAttributes={domain:i.cookie?.domain,expires:i.cookie?.expires??Tc},yc(a=>{this.online(a)}),_c(async()=>{await this.flush()}),R(()=>{const{changes:{value:a}}=le;w.changes=a}),R(()=>{const{consent:{value:a}}=le;this.autoTrackEntryViews&&(a?this.startAutoTrackingEntryViews():this.stopAutoTrackingEntryViews()),w.consent=a}),R(()=>{const{profile:{value:a}}=le;w.profile=a,this.setAnonymousId(a?.id)}),R(()=>{const{personalizations:{value:a}}=le;w.personalizations=a}),this.initializeFromCookieValues(s,o),typeof window<"u"&&(window.optimization??=this)}initializeFromCookieValues(e,n){n&&me.remove(Jt),e&&e!==w.anonymousId&&(this.reset(),this.setAnonymousId(e))}setAnonymousId(e){if(!e){me.remove(Ne),w.anonymousId=void 0;return}me.set(Ne,e,this.cookieAttributes),w.anonymousId=e}startAutoTrackingEntryViews(e){this.autoTrackEntryViews=!0,this.elementViewObserver=new De(fc(this)),this.elementExistenceObserver=new U(pc(this.elementViewObserver,!0)),document.querySelectorAll("[data-ctfl-entry-id]").forEach(r=>{Ze(r)&&(jt.info("Auto-observing element (init):",r),this.elementViewObserver?.observe(r,{...e}))})}stopAutoTrackingEntryViews(){this.elementExistenceObserver?.disconnect(),this.elementViewObserver?.disconnect()}trackEntryViewForElement(e,n){jt.info("Manually observing element:",e),this.elementViewObserver?.observe(e,n)}untrackEntryViewForElement(e){jt.info("Manually unobserving element:",e),this.elementViewObserver?.unobserve(e)}reset(){this.stopAutoTrackingEntryViews(),me.remove(Ne),w.reset(),super.reset()}}exports.ANONYMOUS_ID_COOKIE=Ne;exports.ANONYMOUS_ID_COOKIE_LEGACY=Jt;exports.ANONYMOUS_ID_KEY=ot;exports.ANONYMOUS_ID_KEY_LEGACY=Qt;exports.AliasEvent=gn;exports.AnalyticsStateful=Ge;exports.AnalyticsStateless=wi;exports.ApiClient=ai;exports.App=Mr;exports.AudienceEntry=fn;exports.AudienceEntryFields=br;exports.AudienceEntrySkeleton=zs;exports.BatchExperienceData=Dr;exports.BatchExperienceEvent=Yr;exports.BatchExperienceEventArray=Is;exports.BatchExperienceResponse=jr;exports.BatchInsightsEvent=Xr;exports.BatchInsightsEventArray=En;exports.CAN_ADD_LISTENERS=M;exports.CHANGES_CACHE_KEY=at;exports.CONSENT_KEY=st;exports.Campaign=pn;exports.Change=Kr;exports.ChangeArray=hn;exports.ChangeType=Zr;exports.Channel=xr;exports.ComponentViewEvent=fe;exports.ConsoleLogSink=ri;exports.ContentTypeLink=gr;exports.CoreStateful=Ni;exports.CoreStateless=cc;exports.CtflEntry=ke;exports.DEBUG_FLAG_KEY=ct;exports.DEFAULT_PAGE_PROPERTIES=Kt;exports.Dictionary=Vr;exports.EXPERIENCE_BASE_URL=oi;exports.EntryFields=qe;exports.EntryReplacementComponent=Sr;exports.EntryReplacementVariant=gt;exports.EntrySys=dn;exports.EnvironmentLink=vr;exports.EventBuilder=ci;exports.ExperienceData=Jr;exports.ExperienceEvent=_n;exports.ExperienceEventArray=Be;exports.ExperienceRequestData=$s;exports.ExperienceRequestOptions=Wr;exports.ExperienceResponse=it;exports.FlagsResolver=ft;exports.GeoLocation=zt;exports.GroupEvent=vn;exports.INSIGHTS_BASE_URL=si;exports.IdentifyEvent=Pt;exports.InlineVariableComponent=Ar;exports.InlineVariableComponentValueType=Tr;exports.InlineVariableVariant=qt;exports.InsightsEvent=wn;exports.InsightsEventArray=Qr;exports.InterceptorManager=Xt;exports.Library=Nr;exports.Link=hr;exports.LogSink=ni;exports.Logger=ti;exports.MergeTagEntry=wr;exports.MergeTagValueResolver=Ee;exports.OPTIMIZATION_CORE_SDK_VERSION=Ei;exports.OPTIMIZATION_WEB_SDK_VERSION=Di;exports.Optimization=kc;exports.PERSONALIZATIONS_CACHE_KEY=lt;exports.PROFILE_CACHE_KEY=ut;exports.Page=ge;exports.PageEventContext=yn;exports.PageViewEvent=Ct;exports.PartialProfile=Br;exports.PersonalizationComponent=kr;exports.PersonalizationComponentArray=Pr;exports.PersonalizationConfig=Cr;exports.PersonalizationEntry=St;exports.PersonalizationEntryArray=Or;exports.PersonalizationEntrySkeleton=As;exports.PersonalizationFields=$r;exports.PersonalizationStateful=re;exports.PersonalizationStateless=Vi;exports.PersonalizationType=Ir;exports.PersonalizedEntry=Rr;exports.PersonalizedEntryResolver=ue;exports.Profile=Ke;exports.Properties=He;exports.Screen=Tt;exports.ScreenEventContext=mn;exports.ScreenViewEvent=It;exports.SelectedPersonalization=Gr;exports.SelectedPersonalizationArray=bn;exports.SessionStatistics=Lr;exports.SpaceLink=yr;exports.TagLink=mr;exports.TrackEvent=$t;exports.Traits=At;exports.UniversalEventContext=kt;exports.UniversalEventProperties=te;exports.UnknownChange=Cs;exports.ValuePresence=ui;exports.VariableChange=Hr;exports.VariableChangeValue=qr;exports.batch=de;exports.beaconHandler=ji;exports.createScopedLogger=P;exports.effect=R;exports.getLocale=Li;exports.getPageProperties=Bi;exports.getUserAgent=Ui;exports.guardedBy=D;exports.isEntry=_r;exports.isEntryReplacementComponent=zr;exports.isEntryReplacementVariant=Er;exports.isInlineVariableComponent=Ts;exports.isPersonalizationEntry=xe;exports.isPersonalizedEntry=rt;exports.logger=G;exports.signalFns=Wt;exports.signals=le;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|