@thg-agentic/hyper-personalisation-web 3.19.0 → 3.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hp.min.js CHANGED
@@ -1,3 +1,3 @@
1
- (()=>{var $t=e=>{throw TypeError(e)};var Sr=(e,t,n)=>t.has(e)||$t("Cannot "+n);var Ut=(e,t,n)=>t.has(e)?$t("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var N=(e,t,n)=>(Sr(e,t,"access private method"),n);var we=[];for(let e=2;we.length<64;e++)we.every(t=>e%t!==0)&&we.push(e);var Vt=e=>(e-Math.floor(e))*2**32>>>0,wr=we.slice(0,8).map(e=>Vt(Math.sqrt(e))),_r=we.map(e=>Vt(Math.cbrt(e))),z=(e,t)=>e>>>t|e<<32-t;function Bt(e){let t=new TextEncoder().encode(String(e)),n=new Uint32Array((t.length+8>>6)*16+16);t.forEach((i,s)=>{n[s>>2]|=i<<24-s%4*8}),n[t.length>>2]|=128<<24-t.length%4*8,n[n.length-2]=Math.floor(t.length/2**29),n[n.length-1]=t.length*8;let r=Uint32Array.from(wr),o=new Uint32Array(64);for(let i=0;i<n.length;i+=16){for(let S=0;S<64;S++){if(S<16){o[S]=n[i+S];continue}let b=o[S-15],I=o[S-2],k=z(b,7)^z(b,18)^b>>>3,h=z(I,17)^z(I,19)^I>>>10;o[S]=o[S-16]+k+o[S-7]+h}let[s,a,u,d,p,f,y,x]=r;for(let S=0;S<64;S++){let b=z(p,6)^z(p,11)^z(p,25),I=x+b+(p&f^~p&y)+_r[S]+o[S]|0,h=(z(s,2)^z(s,13)^z(s,22))+(s&a^s&u^a&u)|0;[x,y,f,p,d,u,a,s]=[y,f,p,d+I|0,u,a,s,I+h|0]}[s,a,u,d,p,f,y,x].forEach((S,b)=>{r[b]+=S})}return Array.from(r,i=>i.toString(16).padStart(8,"0")).join("")}var Ye=(e,t)=>e<<t|e>>>32-t;function jt(e){let t=new Uint32Array((e.length+8>>6)*16+16);e.forEach((i,s)=>{t[s>>2]|=i<<24-s%4*8}),t[e.length>>2]|=128<<24-e.length%4*8,t[t.length-2]=Math.floor(e.length/2**29),t[t.length-1]=e.length*8;let n=Uint32Array.of(1732584193,4023233417,2562383102,271733878,3285377520),r=new Uint32Array(80);for(let i=0;i<t.length;i+=16){for(let f=0;f<80;f++)r[f]=f<16?t[i+f]:Ye(r[f-3]^r[f-8]^r[f-14]^r[f-16],1);let[s,a,u,d,p]=n;for(let f=0;f<80;f++){let y,x;f<20?(y=a&u|~a&d,x=1518500249):f<40?(y=a^u^d,x=1859775393):f<60?(y=a&u|a&d|u&d,x=2400959708):(y=a^u^d,x=3395469782);let S=Ye(s,5)+y+p+x+r[f]|0;[p,d,u,a,s]=[d,u,Ye(a,30),s,S]}[s,a,u,d,p].forEach((f,y)=>{n[y]+=f})}let o=new Uint8Array(20);return n.forEach((i,s)=>{o[s*4]=i>>>24,o[s*4+1]=i>>>16,o[s*4+2]=i>>>8,o[s*4+3]=i}),o}var br="e28e8ada-5b76-4209-bba9-79b823a0af75",xr=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");function qt(e,t){let n=Uint8Array.from(e.replace(/-/g,"").match(/../g),a=>Number.parseInt(a,16)),r=new TextEncoder().encode(t),o=new Uint8Array(16+r.length);o.set(n),o.set(r,16);let i=jt(o).slice(0,16);i[6]=i[6]&15|80,i[8]=i[8]&63|128;let s=xr(i);return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20)}`}var re=(e,t)=>typeof e=="string"&&e!==""&&e.length<=t?e:null;function ke(e,t){return re(e,64)??re(t,256)}function Ft({sessionId:e,slot:t,arm:n}={}){let r=re(e,256);return!r||!re(t,256)||!re(n,256)?null:qt(br,`${r}:${t}:${n}`)}var Ir="4b1f2c7e-9a3d-4e58-b6c1-2d7f0a9e8c53";function Ht({sessionId:e,surface:t}={}){let n=re(e,256);return!n||!re(t,64)?null:qt(Ir,`${n}:${t}`)}var Ar=Array.from({length:11},(e,t)=>t/10);function vr(e,t){if(!e.isIntersecting)return!1;let{intersectionRect:n,boundingClientRect:r,rootBounds:o}=e;if(!n||!r)return!0;let i=n.width*n.height,s=r.width*r.height,a=o?Math.min(s,o.width*o.height):s;return a>0&&i/a>=t}function X(e){let{selector:t,onViewable:n,visibleRatio:r=.5,dwellMs:o=1e3,root:i=document}=e,s=new Map,a=new WeakSet,u=new Set,d=h=>{s.has(h)||s.set(h,setTimeout(()=>{s.delete(h),n(h)&&(f?.unobserve(h),u.delete(h))},o))},p=h=>{clearTimeout(s.get(h)),s.delete(h)},f=typeof IntersectionObserver>"u"?null:new IntersectionObserver(h=>{for(let v of h){let w=v.target;if(!vr(v,r)){u.delete(w),p(w);continue}u.add(w),y()&&d(w)}},{threshold:Ar}),y=()=>typeof document>"u"||document.visibilityState!=="hidden",x=()=>{if(y())for(let h of u)d(h);else for(let h of u)p(h)};document.addEventListener("visibilitychange",x);let S=()=>{for(let h of i.querySelectorAll(t))a.has(h)||(a.add(h),f?.observe(h))},b=typeof MutationObserver>"u"?null:new MutationObserver(()=>S()),I=()=>{S(),b?.observe(i===document?document.body:i,{childList:!0,subtree:!0})},k=i===document&&!document.body;return k?document.addEventListener("DOMContentLoaded",I,{once:!0}):I(),()=>{k&&document.removeEventListener("DOMContentLoaded",I),document.removeEventListener("visibilitychange",x),f?.disconnect(),b?.disconnect();for(let h of s.values())clearTimeout(h);s.clear(),u.clear()}}function Xe(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-exposure]",visibleRatio:r=.5,dwellMs:o=1e3,root:i=document}=t;return X({selector:n,root:i,visibleRatio:r,dwellMs:o,onViewable(s){let a=s.dataset?.hpExposure?.trim();return a&&e.surfaceViewed({surface:a}),!0}})}var Kt=e=>{try{return new URL(e,document.baseURI).toString()}catch{return e}};function Ze(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-list]",tileSelector:r="[data-hp-product]",visibleRatio:o=.5,dwellMs:i=1e3,root:s=document}=t,a=new Set,u=S=>S.closest?.(n)??null,d=S=>{let b=S.dataset.hpList?.trim();return b?{list_id:b,category:S.dataset.hpListCategory?.trim()||null}:null},p=S=>Array.from(S.querySelectorAll(r)).filter(b=>u(b)===S),f=(S,b)=>{try{let I=JSON.parse(S.dataset.hpProduct??"");return!I||typeof I!="object"||!I.product_id?null:{...I,position:I.position??b+1,...I.url?{url:Kt(I.url)}:{},...I.image_url?{image_url:Kt(I.image_url)}:{}}}catch{return null}},y=X({selector:`${n} ${r}`,root:s,visibleRatio:o,dwellMs:i,onViewable(S){let b=u(S);if(!b||b.dataset.hpListView==="manual")return!0;let I=d(b);if(!I||a.has(I.list_id))return!0;let k=new Set,h=p(b).map(f).filter(v=>!v||k.has(v.product_id)?!1:(k.add(v.product_id),!0));return h.length===0||(a.add(I.list_id),e.productListViewed({...I,products:h})),!0}}),x=S=>{let I=S.target?.closest?.("a[href]")?.closest(r);if(!I)return;let k=u(I),h=f(I,k?p(k).indexOf(I):0);h&&e.productClicked({list_id:k?d(k)?.list_id??null:null,products:[h]})};return document.addEventListener("click",x,!0),()=>{document.removeEventListener("click",x,!0),y()}}function T(e,...t){let n=e.dataset??{};for(let r of t){let o=n[r];if(typeof o=="string"&&o.trim()!=="")return o.trim()}return null}function Ce(e,...t){let n=T(e,...t);if(n===null)return null;let r=Number(n);return Number.isFinite(r)?Math.trunc(r):null}function Er(e,t){let n=T(e,"hpPromotion");return n?{promotion_id:n,name:T(e,"hpPromotionName"),creative:T(e,"hpPromotionCreative"),position:T(e,"hpPromotionSlot")??String(t+1)}:null}function Qe(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-promotion]",resolve:r=Er,visibleRatio:o=.5,dwellMs:i=1e3,root:s=document}=t,a=new Set,u=f=>{let y=Array.from(s.querySelectorAll(n)),x=y.indexOf(f);try{return r(f,x<0?y.length:x)}catch{return null}},d=X({selector:n,root:s,visibleRatio:o,dwellMs:i,onViewable(f){let y=u(f);return!y||a.has(y.promotion_id)?!1:(a.add(y.promotion_id),e.promotionViewed(y),!0)}}),p=f=>{let y=f.target;if(!y||typeof y.closest!="function")return;let x=y.closest(n),S=y.closest("a[href]");if(!x||!S||!x.contains(S)&&!S.contains(x))return;let b=u(x);b&&e.promotionClicked({...b,href:S.getAttribute("href")})};return document.addEventListener("click",p,!0),()=>{document.removeEventListener("click",p,!0),d()}}function kr(e){let t=T(e,"hpRecoRequest"),n=T(e,"hpRecoPlacement"),r=T(e,"hpRecoStrategy");if(!t||!n||!r)return null;let o=T(e,"hpRecoHoldout");return{recommendation_request_id:t,placement:n,strategy:r,recipe:T(e,"hpRecoRecipe"),algorithm_version:T(e,"hpRecoAlgorithmVersion"),experiment:T(e,"hpRecoExperiment"),variant:T(e,"hpRecoVariant"),holdout:o===null?null:o==="true",assignment_bucket:Ce(e,"hpRecoBucket"),assignment_unit_kind:T(e,"hpRecoUnitKind"),candidate_set_fingerprint:T(e,"hpRecoFingerprint"),candidate_set_size:Ce(e,"hpRecoCandidates"),ranked_by:T(e,"hpRecoRankedBy"),served_at:T(e,"hpRecoServedAt")}}function Cr(e,t){let n=T(e,"hpRecoProduct");if(!n)return null;let r=T(e,"hpRecoPrice");return{product_id:n,sku:T(e,"hpRecoSku"),name:T(e,"hpRecoName"),brand:T(e,"hpRecoBrand"),price:r===null||Number.isNaN(Number(r))?null:Number(r),position:Ce(e,"hpRecoPosition")??t+1}}function et(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-reco-request]",tileSelector:r="[data-hp-reco-product]",resolveRail:o=kr,resolveTile:i=Cr,visibleRatio:s=.5,dwellMs:a=1e3,root:u=document}=t,d=new Set,p=new Map,f=new Map,y=(h,...v)=>{try{return h(...v)}catch{return null}},x=h=>typeof h.closest=="function"?h.closest(n):null,S=h=>Array.from(h.querySelectorAll(r)),b=(h,v)=>{if(f.delete(v.recommendation_request_id),d.has(v.recommendation_request_id))return;let w=S(h).map((_,P)=>y(i,_,P)).filter(_=>_?.product_id);if(w.length===0)return;d.add(v.recommendation_request_id);let g=[...p.get(v.recommendation_request_id)?.values()??[]].sort((_,P)=>_.position-P.position);e.recommendationsViewed({...v,products:w,viewable:g})},I=X({selector:`${n} ${r}`,root:u,visibleRatio:s,dwellMs:a,onViewable(h){let v=x(h);if(!v)return!0;let w=y(o,v);if(!w)return!0;let g=w.recommendation_request_id,_=y(i,h,S(v).indexOf(h));if(_?.product_id){p.has(g)||p.set(g,new Map);let P=p.get(g);P.has(_.position)||P.set(_.position,{position:_.position,product_id:_.product_id,viewable_at:new Date().toISOString()})}return!d.has(g)&&!f.has(g)&&f.set(g,setTimeout(()=>b(v,w),0)),!0}}),k=h=>{let v=h.target;if(!v||typeof v.closest!="function")return;let w=v.closest(r);if(!w)return;let g=v.closest("[data-hp-reco-interaction]"),_=v.closest("a[href]"),P=_&&(w.contains(_)||_.contains(w));if(!(g&&w.contains(g))&&!P)return;let M=x(w);if(!M)return;let H=y(o,M);if(!H)return;let K=y(i,w,S(M).indexOf(w));if(!K?.product_id)return;let j=H.recommendation_request_id;d.has(j)||(clearTimeout(f.get(j)),b(M,H)),e.productClicked({recommendation_request_id:H.recommendation_request_id,interaction:T(g??w,"hpRecoInteraction")??"navigate",products:[K]})};return document.addEventListener("click",k,!0),()=>{document.removeEventListener("click",k,!0);for(let h of f.values())clearTimeout(h);f.clear(),I()}}var fe=new Set(["home","list","product","search","basket","checkout","order_confirmation","login","register","account","info","blog","other"]),Pr=new Set(["products"]),Gt=e=>e==null;function tt(e,t=new WeakSet){if(e instanceof Date)return e.toJSON();if(e===null||typeof e!="object"||t.has(e))return e;t.add(e);let n=Array.isArray(e)?e.map(r=>tt(r,t)):Object.fromEntries(Object.entries(e).filter(([,r])=>!Gt(r)).map(([r,o])=>[r,tt(o,t)]));return t.delete(e),n}function nt(e){if(!e)return e;let t=tt(e);for(let n of Pr)n in e&&Gt(e[n])&&(t[n]=e[n]);return t}function zt(){try{let e=performance.getEntriesByType("navigation")[0];return e?["navigate","reload","back_forward","prerender"].includes(e.type)?e.type:"navigate":null}catch{return null}}var Or=new Set(["","unknown","undefined","null","none","nil","nan","anonymous","guest","0","-1"]);function q(e){if(e==null)return null;let t=String(e).trim();return Or.has(t.toLowerCase())?null:t}function Z(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Wt="1.12";function D(e){if(typeof document>"u")return null;try{let t=document.cookie.split(";").map(n=>n.trim()).find(n=>n.startsWith(`${e}=`));return t&&decodeURIComponent(t.slice(e.length+1))||null}catch{return null}}var Lr={gclid:"gclid",fbclid:"fbclid",ttclid:"ttclid"},Nr=/[a-z0-9._%+-]+@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}/i,Tr=/\d(?:[ -]?\d){12,}/,Rr=new Set(["gclid","fbclid","ttclid","msclkid"]);function Yt(e,t=""){if(typeof e!="string"||e==="")return!1;let n=[e];try{let o=decodeURIComponent(e.replace(/\+/g," "));o!==e&&n.push(o)}catch{}let r=!Rr.has(String(t).toLowerCase());return n.some(o=>Nr.test(o)||r&&Tr.test(o))}function Mr(e){if(!e)return null;let t=new URLSearchParams(e),n={},r={utm_source:"source",utm_medium:"medium",utm_campaign:"name",utm_term:"term",utm_content:"content"};for(let[o,i]of[...Object.entries(r),...Object.entries(Lr)]){let s=t.get(o);s&&!Yt(s,o)&&(n[i]=s)}return Object.keys(n).length?n:null}var Dr=["email","e-mail","password","pass","pwd","token","auth","code","uid","customer_id","postcode","zip","phone","applyCode"],$r=["email","password","passwd","pwd","token","secret","auth","session","phone","postcode","zip","address","birth","card","cvv","iban","ssn","customerid","userid"],Ur=["tel","uid","dob"],Vr=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","gclid","fbclid","ttclid","msclkid"],Br=new Set(Dr.map(e=>e.toLowerCase()));function jr(e){let t=String(e).toLowerCase();if(Br.has(t))return!0;let n=t.replace(/[-_.]/g,"");return $r.some(o=>n.includes(o))?!0:String(e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(o=>Ur.includes(o))}function rt(e){return(e??[]).map(t=>{try{return new RegExp(`^${t}$`,"i")}catch{return{test:n=>n.toLowerCase()===String(t).toLowerCase()}}})}function Xt(e,t={}){if(!e)return null;try{let n=new URLSearchParams(e),r=t.queryParamAllowlist?rt([...t.queryParamAllowlist,...Vr]):null,o=rt(t.queryParamBlocklist),i=rt(t.sensitiveParamAllowlist);for(let a of new Set(n.keys()))(jr(a)&&!i.some(d=>d.test(a))||n.getAll(a).some(d=>Yt(d,a))||(r?!r.some(d=>d.test(a)):o.some(d=>d.test(a))))&&n.delete(a);let s=n.toString();return s?`?${s}`:""}catch{return""}}function qr(e,t,n={}){if(!e)return null;try{let r=new URL(e);return t&&r.origin===t?r.origin+r.pathname+(Xt(r.search,n)??""):r.origin+r.pathname}catch{return null}}function ot(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Jt(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{2}$/.test(t)?t:null}function Fr(e){if(typeof e!="string")return null;let t=e.trim().replace(/_/g,"-");if(!/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(t))return null;try{return Intl.getCanonicalLocales(t)[0]}catch{return null}}function R(e,t){if(typeof e=="function")try{let n=e();if(n!=null)return n}catch{}return t}function Hr(e){return{property_id:String(e.propertyId),channel:e.channel??null,market:e.market??null,environment:e.environment??null}}function Kr(e){let t=typeof window<"u"?window.location:null,n=t?Xt(t.search,e):null;return{url:t?t.origin+t.pathname+(n??""):e.pageUrl??null,path:t?t.pathname:e.pagePath??null,search:n??null,referrer:typeof document<"u"?qr(document.referrer,t?.origin,e):null,title:typeof document<"u"&&document.title||null,type:e.pageType??null}}function Zt(e,t={}){let n=typeof window<"u"?window.location:null,r={library:{name:e.libraryName,version:e.libraryVersion},spec:{version:Wt},source:Hr(e),session_id:R(e.getSessionId,null),render_id:R(e.getRenderId,null),identity_trust:q(R(e.getAnonymousId,null))?"device":"none",page:Kr(e),campaign:n?Mr(n.search):null,device:{user_agent:typeof navigator<"u"?navigator.userAgent:null,type:null,viewport_width:typeof window<"u"?window.innerWidth:null,viewport_height:typeof window<"u"?window.innerHeight:null},currency:ot(R(e.getCurrency,e.currency)),locale:Fr(R(e.getLocale,e.locale)),timezone:(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return null}})(),country:Jt(e.country),ship_to_country:Jt(R(e.getShipToCountry,e.shipToCountry)),ip:null,bot:null,consent:e.getConsent?.()??null,experiments:R(e.getExperiments,null),audiences:R(e.getAudiences,null),decisions:R(e.getDecisions,null),recommendations:R(e.getRecommendations,null),extensions:R(e.getExtensions,null)};return Qt(r,t)}function Qt(e,t){if(!t)return e;let n={...e};for(let[r,o]of Object.entries(t))o&&typeof o=="object"&&!Array.isArray(o)&&e[r]&&typeof e[r]=="object"&&!Array.isArray(e[r])?n[r]=Qt(e[r],o):o!==void 0&&(n[r]=o);return n}var ie=Object.freeze({consent:"thg_hp_consent",retry:"thg_hp_retry",sessionSignals:"thg_hp_session_signals",identified:"thg_hp_identified",previousPage:"thg_hp_prev_page",decisions:"thg_hp_decisions",settings:"thg_hp_settings",held:"thg_hp_held",carried:"thg_hp_carried",recommendationContext:"thg_hp_recommendation_context",anonymousId:"thg_hp_anonymous_id",session:"thg_hp_session",preview:"thg_hp_preview",debug:"thg_hp_debug"}),Gr={retry:"cdp.retry",sessionSignals:"cdp_session_signals",identified:"cdp_identified",previousPage:"cdp_prev_page_message_id"},st={...ie},en=!1;function Pe(e){let t={...ie};for(let[n,r]of Object.entries(e??{})){if(!(n in ie))throw new Error(`storageNames: unknown kind "${n}"`);if(typeof r!="string"||!/^[\w.-]+$/.test(r))throw new Error(`storageNames.${n} must be a non-empty cookie-safe name`);t[n]=r}st=t}function L(e){return st[e]}var zr="_",tn=e=>e==null||e===""?zr:String(e);function F(e,t,n){let r=`${e}:${tn(t)}`;return n==null||n===""?r:`${r}:${n}`}function nn(e,t){return`${e}:${tn(t)}:`}function Oe(){if(!en){en=!0;for(let e of[()=>localStorage,()=>sessionStorage]){let t;try{if(t=e(),!t)continue;for(let n of Object.keys(t))for(let[r,o]of Object.entries(Gr)){if(n!==o&&!n.startsWith(`${o}:`))continue;let i=st[r]+n.slice(o.length);t.getItem(i)===null&&t.setItem(i,t.getItem(n)),t.removeItem(n)}}catch{}}}}var at=1800*1e3,Le=()=>{try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}},it=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}};function rn(e,t=()=>Date.now()){return{read(){try{let n=Le()?.getItem(e),r=n?JSON.parse(n):null;return!r||t()-r.savedAt>at?(r&&Le()?.removeItem(e),{items:[],anonymousId:null}):{items:Array.isArray(r.items)?r.items:[],anonymousId:typeof r.anonymousId=="string"?r.anonymousId:null}}catch{return{items:[],anonymousId:null}}},write(n,r=null){try{n.length===0?Le()?.removeItem(e):Le()?.setItem(e,JSON.stringify({savedAt:t(),items:n,anonymousId:r}))}catch{}}}}var Wr=400*24*60*60;function Q(e,t,n,r){if(typeof document>"u")return!1;try{let o=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",i=r?`; Domain=${r}`:"",s=n===null?"":`; Max-Age=${n}`;return document.cookie=`${e}=${encodeURIComponent(t)}; Path=/${s}; SameSite=Lax`+i+o,!0}catch{return!1}}function Jr({name:e,domain:t=null,legacyKey:n,read:r,mint:o,mayStore:i,carried:s=null}){let a=null;try{a=it()?.getItem(n)||null}catch{a=null}let u=r(e)??a??s,d=!1,p=()=>{if(!(d||u===null||!i())&&(d=Q(e,u,Wr,t),!(!d||a===null)))try{it()?.removeItem(n),a=null}catch{}};return{get(){return u??(u=o()),p(),u},peek:()=>u,persist:p,forget(){Q(e,"",0,t),u=null,d=!1;try{it()?.removeItem(n)}catch{}a=null}}}function on(e,{carried:t=null,mayStore:n,orOwn:r=!1}){let o=e.anonymousIdSource,i=()=>Jr({name:L("anonymousId"),domain:e.consentCookieDomain??null,legacyKey:F(L("anonymousId"),e.propertyId),read:D,mint:Z,mayStore:n,carried:t});if(o?.source==="hp_cookie"){let u=i();return e.getAnonymousId=()=>u.get(),u}if(o?.source==="site_cookie"&&o.cookie){let u=o.cookie;e.getAnonymousId=()=>D(u)}if(!r)return null;let s=e.getAnonymousId,a=i();return e.getAnonymousId=()=>q(R(s,null))??a.get(),a}var Yr=200;function sn(e,t,n=()=>Date.now()){let r=()=>F(L("carried"),e),o=!1;function i(){try{let s=JSON.parse(sessionStorage.getItem(r())??"null");return!s||!(n()-s.savedAt<=at)?[]:Array.isArray(s.calls)?s.calls:[]}catch{return[]}}return{take(){let s=i();try{sessionStorage.removeItem(r())}catch{}return s},save(s){try{return o||!t()?!1:(sessionStorage.setItem(r(),JSON.stringify({savedAt:n(),calls:[...i(),...s].slice(-Yr)})),!0)}catch{return!1}},close(){o=!0}}}var si=ie.consent,Ne=Object.freeze({visitor:"visitor",host:"host"}),an=()=>({basis:Ne.host}),Xr="hp-consent",ae=["analytics","marketing","personalisation","ad_user_data","ad_personalization"],cn={analytics:"a",marketing:"m",personalisation:"p",ad_user_data:"aud",ad_personalization:"adp"},Y=()=>typeof window<"u",un=()=>Y()&&typeof window.cookieStore?.addEventListener=="function",Zr=e=>e===!0?!0:e===!1?!1:null;function pe(e){if(!e||typeof e!="object")return null;let t={};for(let n of ae)t[n]=Zr(e[n]);return t}function ut(e,t){return!e||!t?e===t:ae.every(n=>e[n]===t[n])}function lt(e){if(!e)return"";let t=[];for(let n of ae){let r=e[n];(r===!0||r===!1)&&t.push(`${cn[n]}=${r?1:0}`)}return t.join("&")}function ln(e){return{[Xr]:lt(pe(e))}}function _e(e){let t=pe({});if(e==null)return t;let n=String(e).trim();if(n.length>=2&&n.startsWith('"')&&n.endsWith('"')&&(n=n.slice(1,-1)),n.includes("%"))try{n=decodeURIComponent(n.replace(/\+/g," "))}catch{return t}let r=Object.fromEntries(Object.entries(cn).map(([i,s])=>[s,i])),o=new Set;for(let i of n.split("&")){let s=i.indexOf("=");if(s<=0)continue;let a=r[i.slice(0,s).trim()],u={1:!0,0:!1}[i.slice(s+1).trim()]??null;!a||u===null||o.has(a)||(t[a]===null?t[a]=u:t[a]!==u&&(t[a]=null,o.add(a)))}return t}function dt(e,t){if(!t)return e;let n=r=>{if(!r)return r;let o={...r};for(let i of ae)i!=="analytics"&&t[i]!==!0&&(o[i]=null);return o};return{name:e.name,basis:e.basis,read:()=>n(e.read()),subscribe:r=>e.subscribe(o=>r(n(o))),get observesChanges(){return e.observesChanges}}}function ft(e,t={}){return{...e,ad_user_data:t.ad_user_data??e.marketing,ad_personalization:t.ad_personalization??e.marketing}}function Te(e,t){let n=!0;return{notify:()=>{if(n)try{let o=e();o&&t(o)}catch{}},stop:()=>n=!1}}var Qr={analytics:["analytics","measure_content_performance","audience_measurement"],marketing:["marketing","targeting","advertising","select_personalized_ads","create_ads_profile"],personalisation:["personalisation","personalization","select_personalized_content","create_content_profile"]};function eo(e,t){if(!t?.length)return null;let n=!1;for(let[r,o]of Object.entries(e)){let i=String(o?.id??r).toLowerCase();if(t.some(a=>{let u=String(a).toLowerCase();return i===u||i.startsWith(`${u}-`)})&&(n=!0,o?.enabled===!0))return!0}return n?!1:null}function dn(e={}){let t={...Qr,...e.purposes};function n(){let r=Y()?window.Didomi:void 0;if(!r?.getCurrentUserStatus||r.shouldUserStatusBeCollected?.()!==!1||r.isUserStatusPartial?.()===!0)return null;let o=r.getCurrentUserStatus()?.purposes;if(!o||typeof o!="object")return null;let i=s=>eo(o,t[s]);return ft({analytics:i("analytics"),marketing:i("marketing"),personalisation:i("personalisation")},{ad_user_data:i("ad_user_data"),ad_personalization:i("ad_personalization")})}return{name:"didomi",read:n,observesChanges:!0,subscribe(r){if(!Y())return()=>{};let o=Te(n,r),i={event:"consent.changed",listener:o.notify};return window.didomiEventListeners=window.didomiEventListeners||[],window.didomiEventListeners.push(i),window.didomiOnReady=window.didomiOnReady||[],window.didomiOnReady.push(s=>{o.notify(),(s??window.Didomi)?.on?.("consent.changed",o.notify)}),window.Didomi?.on?.("consent.changed",o.notify),o.stop}}}function ct(e){let t={};if(!e)return t;for(let n of String(e).split("&")){let r=n.indexOf("=");if(r<=0)continue;let o=n.slice(r+1).replace(/\+/g," ");try{o=decodeURIComponent(o)}catch{}t[n.slice(0,r)]=o}return t}function fn(e={}){let t={analytics:"C0002",personalisation:"C0003",marketing:"C0004",...e.groups},n=e.impliedConsent===!0;function r(){let s=Y()?window.OnetrustActiveGroups:void 0;if(typeof s=="string"&&s.length){let d=new Set(s.split(",").map(p=>p.trim()).filter(Boolean));return p=>d.has(p)}let a=ct(D("OptanonConsent"));if(!a.groups)return null;let u={};for(let d of a.groups.split(",")){let[p,f]=d.split(":");p?.trim()&&(u[p.trim()]=f==="1"?!0:f==="0"?!1:null)}return d=>u[d]??null}function o(){if(D("OptanonAlertBoxClosed"))return!0;try{if(Y()&&window.OneTrust?.IsAlertBoxClosed?.()===!0)return!0}catch{}return Number.parseInt(ct(D("OptanonConsent")).interactionCount,10)>0?!0:n&&Y()&&(!!window.OneTrust||typeof window.OnetrustActiveGroups=="string")}function i(){if(!o())return null;let s=r();if(!s)return null;let a=f=>t[f]?s(t[f]):null,u=ft({analytics:a("analytics"),marketing:a("marketing"),personalisation:a("personalisation")},{ad_user_data:a("ad_user_data"),ad_personalization:a("ad_personalization")}),d=ct(D("OptanonConsent"));return(typeof navigator<"u"&&navigator.globalPrivacyControl===!0||d.isGpcEnabled==="1")&&(u.marketing=!1,u.ad_user_data=!1,u.ad_personalization=!1),u}return{name:"onetrust",read:i,observesChanges:!0,subscribe(s){if(!Y())return()=>{};let a=Te(i,s),u=!1,d=()=>{u||!window.OneTrust?.OnConsentChanged||(u=!0,window.OneTrust.OnConsentChanged(a.notify))};window.addEventListener("OneTrustGroupsUpdated",a.notify);let p=window.OptanonWrapper;return window.OptanonWrapper=function(...y){try{typeof p=="function"&&p.apply(this,y)}finally{d(),a.notify()}},d(),()=>{a.stop(),window.removeEventListener("OneTrustGroupsUpdated",a.notify)}}}}function to(e){let t=String(e).split(",").map(n=>n.trim()).filter(Boolean);return t.length?new Set(t):null}function pn(e){let{name:t,categories:n,parse:r=to,refusedValue:o,source:i="native",changeEvent:s="thg_hp_consent_change"}=e??{};if(typeof t!="string"||t==="")throw new Error("cookieConsent: `name` (the cookie your banner writes) is required");if(!n||typeof n.analytics!="string")throw new Error("cookieConsent: `categories.analytics` (the category id that grants analytics) is required");function a(){let u=D(t);if(u==null)return null;let d;if(o!==void 0&&u===o)d=new Set;else try{d=r(u)}catch{d=null}if(!(d instanceof Set))return null;let p=f=>n[f]?d.has(n[f]):null;return ft({analytics:p("analytics"),marketing:p("marketing"),personalisation:p("personalisation")},{ad_user_data:p("ad_user_data"),ad_personalization:p("ad_personalization")})}return{name:i,read:a,get observesChanges(){return un()},subscribe(u){if(!Y())return()=>{};let d=Te(a,u),p=f=>{[...f.changed??[],...f.deleted??[]].some(x=>x?.name===t)&&d.notify()};return window.addEventListener(s,d.notify),window.cookieStore?.addEventListener?.("change",p),()=>{d.stop(),window.removeEventListener(s,d.notify),window.cookieStore?.removeEventListener?.("change",p)}}}}function mn(e={}){let t=e.name??L("consent"),n=()=>{let r=D(t);if(r==null)return null;let o=_e(r);return o.analytics==null?null:o};return{name:"forwarded",read:n,get observesChanges(){return un()},subscribe(r){if(!Y())return()=>{};let o=Te(n,r),i=s=>{[...s.changed??[],...s.deleted??[]].some(u=>u?.name===t)&&o.notify()};return window.cookieStore?.addEventListener?.("change",i),()=>{o.stop(),window.cookieStore?.removeEventListener?.("change",i)}}}}function hn(e){let t=pe(e);return{name:"static",basis:Ne.host,read:()=>t?{...t}:null,observesChanges:!0,subscribe:()=>()=>{}}}function gn(e){if(e==null)return null;let t=String(e).split("/").map(n=>n.trim()).filter(Boolean).join("/");return t===""?null:t}function no(e){let t=e.item_category;if(t!=null&&String(t).includes("/"))return gn(t);let n=[t,e.item_category2,e.item_category3,e.item_category4,e.item_category5].map(r=>r==null?"":String(r).trim()).filter(Boolean);return gn(n.join("/"))}var ro=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t};function oo(...e){for(let t of e){if(typeof t=="number"&&Number.isFinite(t))return String(t);if(typeof t=="string"&&t.trim()!=="")return t.trim()}return null}var Re=e=>oo(e.item_group_id,e.item_id);function so(e,t=Re){if(!e)return null;let n=a=>a==null||a===""||Number.isNaN(Number(a))?null:Number(a),r=a=>{let u=n(a);return u==null?null:Math.round(u*1e6)/1e6},o=a=>{let u=r(a);return u!=null&&u>=0?u:null},i=a=>{let u=n(a);return Number.isInteger(u)&&u>=0?u:null},s=ro;return{product_id:s(t(e)),sku:s(e.item_id),name:s(e.item_name),brand:s(e.item_brand),variant:s(e.item_variant)??s(e.variant),category:no(e),price:r(e.price),discount:o(e.discount),quantity:i(e.quantity),coupon:s(e.coupon),position:i(e.index)!=null?i(e.index)+1:null,url:s(e.url)??s(e.item_url)??null,image_url:s(e.image_url)??s(e.image_link)??null,displayed_sku:s(e.displayed_sku)??s(e.displayed_variant_sku)}}function pt(e,t=Re){return(e??[]).map(n=>so(n,t)).filter(n=>n?.product_id)}var io=1e3,ao={shipping:2,payment:3},co=new Set(["password","google","apple","facebook","magic_link","sso","passkey","other"]),$=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t},uo=e=>{if(e==null||e===""||typeof e=="object")return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null},Me=e=>e!==null&&typeof e=="object";function lo(e){return Array.isArray(e.items)?e.items.filter(Me):null}function yn(e){let t=$(e)?.toLowerCase().replace(/[\s-]+/g,"_");return t?co.has(t)?t:t==="email"||t==="email_password"?"password":"other":null}function fo({ecommerce:e,items:t}){let n=i=>({promotion_id:$(i.promotion_id),name:$(i.promotion_name),creative:$(i.creative_name),position:$(i.creative_slot)}),r=new Set,o=[];for(let i of[n(e),...t.map(n)])!i.promotion_id||r.has(i.promotion_id)||(r.add(i.promotion_id),o.push(i));return o}var Sn=({ecommerce:e,items:t})=>$(e.item_list_id)??$(e.item_list_name)??$(t[0]?.item_list_id)??$(t[0]?.item_list_name),ce=(e,t)=>t.products?.length?{event:e,properties:t}:null,po=new Set(["product","products","item","items"]);function mo({ecommerce:e}){let t=$(e.item_id),n=$(e.content_type)?.toLowerCase();return!t||n&&!po.has(n)?null:{event:"Product Shared",properties:{share_via:$(e.method),products:[{product_id:t}]}}}function ho(e){let t=o=>ce("Product List Viewed",{list_id:Sn(o),products:o.products}),n=o=>{let i=$(o.ecommerce.search_term);return i?{event:"Products Searched",properties:{query:i,...o.products.length?{products:o.products}:{}}}:null},r=o=>i=>i.promotions.map(s=>({event:o,properties:s}));return{view_item:o=>ce("Product Viewed",{currency:o.currency,value:o.value,products:o.products.slice(0,1)}),view_item_list:t,view_search_results:o=>n(o)??t(o),search:n,select_item:o=>ce("Product Clicked",{list_id:Sn(o),products:o.products.slice(0,1)}),add_to_cart:o=>ce("Product Added",{cart_id:$(o.ecommerce.cart_id),products:o.products}),remove_from_cart:o=>ce("Product Removed",{cart_id:$(o.ecommerce.cart_id),products:o.products}),view_cart:o=>({event:"Cart Viewed",properties:{cart_id:$(o.ecommerce.cart_id),value:o.value,currency:o.currency,coupon:$(o.ecommerce.coupon),...o.itemsListed?{products:o.products}:{}}}),begin_checkout:o=>ce("Checkout Started",{value:o.value,currency:o.currency,coupon:$(o.ecommerce.coupon),products:o.products}),add_shipping_info:o=>({event:"Checkout Step Completed",properties:{step:e.shipping,step_name:"shipping",shipping_method:$(o.ecommerce.shipping_tier)}}),add_payment_info:o=>({event:"Payment Info Entered",properties:{step:e.payment,step_name:"payment",payment_method:$(o.ecommerce.payment_type)}}),view_promotion:r("Promotion Viewed"),select_promotion:r("Promotion Clicked"),add_to_wishlist:o=>ce("Product Added to Wishlist",{products:o.products}),share:mo,login:o=>({event:"Signed In",properties:{method:yn(o.ecommerce.method)}}),sign_up:o=>({event:"Signed Up",properties:{method:yn(o.ecommerce.method)}})}}var go=e=>e.event;function yo(e,t){if(!Me(e))return null;if(typeof e.length=="number"&&e[0]==="event"&&typeof e[1]=="string"){let r=Me(e[2])?e[2]:{};return{name:e[1],entry:r,ecommerce:r}}let n=$(t(e));return n?{name:n,entry:e,ecommerce:Me(e.ecommerce)?e.ecommerce:e}:null}function mt(e){return Array.isArray(e)?`[${e.map(mt).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${mt(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function wn(e,t={}){if(!e||typeof e.track!="function")throw new Error("connectDataLayer: analytics must have a track(event, properties, options) method");let n=t.dataLayer??(typeof window<"u"?window.dataLayer=window.dataLayer||[]:null);if(!Array.isArray(n))return()=>{};let r=ho({...ao,...t.steps}),o=t.map??{},i=t.eventName??go,s=t.productId??Re,a=new Set(["purchase","refund",...t.ignore??[]]),u=t.dedupeMs??io,d=new Map,p=!0;function f(w,g,_){if(u<=0)return!1;let P=`${w}|${_??""}|${mt(g)}`,M=Date.now();for(let[H,K]of d)M-K>u&&d.delete(H);return d.has(P)?!0:(d.set(P,M),!1)}let y=null,x=new Set;function S(w,g){if(w!=="Product Viewed")return!1;let _=typeof location>"u"?"":location.pathname;_!==y&&(y=_,x.clear());let P=g.products?.[0]?.product_id;return P?x.has(P)?!0:(x.add(P),!1):!1}function b({event:w,properties:g={}},_){if(!w||f(w,g,_)||S(w,g))return;let P=_?{context:{currency:_}}:void 0;if(w==="Signed Out"&&typeof e.signedOut=="function"){e.signedOut(P);return}e.track(w,g,P)}function I(w){let g=t.transform?t.transform(w):w,_=yo(g,i);if(!_||a.has(_.name))return;let P=Object.hasOwn(o,_.name),M=P?o[_.name]:r[_.name];if(typeof M!="function")return;let H=lo(_.ecommerce),K=H??[],j={..._,items:K,itemsListed:H!==null,products:pt(K,s),currency:ot(_.ecommerce.currency),value:uo(_.ecommerce.value)};j.promotions=fo(j);let te=P?M(g,{...j,toProducts:G=>pt(G,s)}):M(j);for(let G of[te].flat())G&&b(G,j.currency)}function k(w){if(p)try{I(w)}catch(g){try{t.onError?.(g,w)}catch{}}}for(let w of n.slice())k(w);let h=n.push;function v(...w){let g=h.apply(this,w);for(let _ of w)k(_);return g}return n.push=v,()=>{p=!1,n.push===v&&(n.push=h)}}var So="hp_debug",wo=256;function _o(){try{return new URLSearchParams(location.search).get(So)}catch{return null}}function _n(e,t){if(typeof location>"u")return!1;try{let n=_o();if(n!==null){let o=n.trim();o===""||o.length>wo?sessionStorage.removeItem(t):sessionStorage.setItem(t,o)}let r=sessionStorage.getItem(t);return!!(e&&r&&Bt(r)===e)}catch{return!1}}var me=class extends Error{},bo={inHoldout:()=>!0,personalisationGroup:()=>"excluded",servingHeaders:()=>({}),recommendationContext:()=>({}),flush:()=>Promise.resolve(),reset:()=>{}};function ht(e,t){let n=bo[e]??(()=>null),r=o=>(console.warn(`[hp] ${String(e)} failed; nothing was sent`,o),n());return function(...i){try{let s=t.apply(this,i);return typeof s?.then=="function"?Promise.resolve(s).catch(r):s}catch(s){if(s instanceof me)throw s;return r(s)}}}function bn(e){for(let t of Reflect.ownKeys(e)){let{value:n}=Object.getOwnPropertyDescriptor(e,t)??{};typeof n=="function"&&(e[t]=ht(t,n))}return e}var be=Symbol("hp.identityOption");var xo=4320*60*60,Io=100,Ao=1e3,vo=2e3,xn=500,De=e=>(e?.unref?.(),e);function Eo(e,t){if(t?.analytics===!0&&e.analytics===!1)return"withdrawn";let n=ae.map(r=>e[r]).filter(r=>r!==null);return n.length&&n.every(Boolean)?"accept_all":n.length&&n.every(r=>!r)?"reject_all":"custom"}function ko(e,t,n=L("consent")){if(!(typeof document>"u"))try{let r=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",o=t?`; Domain=${t}`:"";document.cookie=`${n}=${lt(e)}; Path=/; Max-Age=${xo}; SameSite=Lax`+o+r}catch{}}function Co(e){let t=_e(D(e));return ae.some(n=>t[n]!==null)?t:null}function In(e){let{adapter:t,timeoutMs:n=5e3,cookieDomain:r=null,cookieName:o=L("consent"),release:i,announce:s}=e,a=e.discard??(()=>{}),u="pending",d=null,p=null,f=null,y=null,x=!1,S=null,b=[],I=m=>{u=m,e.onStatus?.(m)};function k(){try{return pe(t.read())}catch{return null}}function h(){p&&clearInterval(p),f&&clearTimeout(f),p=null,f=null}let v=()=>typeof window<"u"&&typeof document<"u",w=()=>{try{return typeof t.subscribe=="function"&&t.observesChanges===!0}catch{return!1}};function g(){y&&clearInterval(y),y=null}function _(){x||y||d===null||w()||v()&&document.visibilityState==="hidden"||(y=De(setInterval(()=>j(k()),vo)))}let P=()=>u==="pending"||u==="unknown",M=e.store??null,H=()=>{let m=b.splice(0);M?.write([]);for(let B of m)i(B)},K=()=>{let m=b.splice(0);M?.write([]);for(let B of m)a(B)};function j(m){let B=pe(m);if(!B||B.analytics===null)return;let Ae=d===null,J=Ae?Co(o):d;if(!Ae&&ut(J,B))return;h(),d=B,_(),ko(B,r,o);let ve=!ut(J,B);if(B.analytics){I("granted"),H(),ve&&s({action:Eo(B,J),state:B,previous:J,withdrawal:!1});return}K(),J?.analytics===!0&&s({action:"withdrawn",state:B,previous:J,withdrawal:!0}),I("denied")}function te(){f=null,u==="pending"&&(I("unknown"),p&&clearInterval(p),p=De(setInterval(()=>j(k()),Ao)))}function G(m){P()&&(M||m?.type!=="visibilitychange"&&!m?.persisted&&K())}let ne=m=>{document.visibilityState==="hidden"?(g(),G(m)):_()},le=m=>{g(),G(m)},Ie=()=>_();return{get status(){return u},get state(){return d?{...d}:null},stamp(){return d?{...d,source:t.name??null,basis:t.basis??Ne.visitor}:null},admits(){return u==="granted"},hold(m){return!P()||b.length>=xn?(a(m),!1):(b.push(m),M?.write(b),!0)},onHidden:G,start(){x=!1;try{S=t.subscribe?.(m=>j(m))??null}catch(m){e.debug&&console.warn("[hp] consent adapter subscribe failed",m)}v()&&(window.addEventListener("pagehide",le),window.addEventListener("pageshow",Ie),document.addEventListener("visibilitychange",ne)),M&&b.length===0&&b.push(...M.read().slice(-xn)),j(k()),!d&&(p=De(setInterval(()=>j(k()),Io)),f=De(setTimeout(te,n)))},stop(){x=!0,h(),g(),typeof S=="function"&&S(),v()&&(window.removeEventListener("pagehide",le),window.removeEventListener("pageshow",Ie),document.removeEventListener("visibilitychange",ne))}}}var Po=["recommendation","search_rank","banner","offer","layout","copy","price","other"],$e=e=>typeof e=="string"&&e!=="";function An(e){return(Array.isArray(e?.decisions)?e.decisions:[]).filter(t=>$e(t?.slot)&&$e(t.decision_id)&&t.holdout!==!0).map(({decision_id:t,slot:n,arm:r,kind:o})=>({decision_id:t,slot:n,...$e(r)&&{arm:r},...Po.includes(o)&&{kind:o}}))}function vn({key:e,mayStore:t}){let n,r=()=>{if(n)return n;try{let i=JSON.parse(sessionStorage.getItem(e));n=Array.isArray(i)?i.filter(s=>$e(s?.slot)):[]}catch{n=[]}return n},o=()=>{try{n?.length&&t()&&sessionStorage.setItem(e,JSON.stringify(n))}catch{}};return{persist:o,current:()=>r().length?n.map(i=>({...i})):null,remember(i){if(!i.length)return;let s=new Set(i.map(a=>a.slot));n=[...r().filter(a=>!s.has(a.slot)),...i],o()},forget(){n=[];try{sessionStorage.removeItem(e)}catch{}}}}function Oo(e){let t=2166136261,n=String(e);for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t^=t>>>16,t=Math.imul(t,2246822507)>>>0,t^=t>>>13,t=Math.imul(t,3266489909)>>>0,t^=t>>>16,t>>>0}function Ue(e,t,n=1e4){return Oo(`${t}\0${e}`)%n}function gt(e){let t=o=>Math.min(Math.max(Number(o)||0,0),1),n=t(e.share),r=1-n;return{holdout_share:n,personalised_share:e.ramp==null?r:Math.min(t(e.ramp),r)}}function yt(e,t){if(!e||typeof e.salt!="string")return{holdout:!1,bucket:null,group:"personalised"};let n=e.ramp!=null;if(t==null||t==="")return{holdout:!1,bucket:null,group:n?"excluded":"personalised"};let{holdout_share:r,personalised_share:o}=gt(e),i=Ue(t,e.salt),s=u=>Math.round(u*1e4),a=r>0&&i<s(r)?"holdout":!n||i<s(r+o)?"personalised":"excluded";return{holdout:a==="holdout",bucket:i,group:a}}function En(e,t){return typeof e!="string"||e===""||t==null||t===""?null:Ue(t,`bandit-vs-default:${e}`)<1e4/2?"default":"bandit"}var Lo="hp_preview",No=256;function kn(e,t=null){if(typeof location>"u")return D(e);let n=null;try{n=new URLSearchParams(location.search).get(Lo)}catch{n=null}if(n===null)return D(e);let r=n.trim();return r===""||r.length>No?(Q(e,"",0,t),null):(Q(e,r,null,t),r)}var To=40,Ro=128,Mo=5,Do=60,Pn=e=>typeof e=="string"&&e!==""&&e.length<=Ro&&!e.includes(","),Cn=e=>Array.isArray(e)?e.filter(Pn).slice(0,To):[],$o=e=>Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.replaceAll(","," ").trim()).filter(t=>t!=="").slice(0,Mo):[],Uo=e=>Object.entries(e&&typeof e=="object"?e:{}).filter(([t,n])=>Pn(t)&&Number.isFinite(n)&&n>=1).sort(([,t],[,n])=>n-t).slice(0,Do).map(([t,n])=>`${t}:${Math.floor(n)}`);function St(e){let t={},n={viewed:Cn(e?.recentProducts),basket:Cn(e?.basketProducts),q:$o(e?.recentSearches),impressed:Uo(e?.impressions)};for(let[r,o]of Object.entries(n))o.length>0&&(t[r]=o.join(","));return t}var Vo=1800*1e3;function On(e,t=Date.now()){try{localStorage.setItem(L("recommendationContext"),JSON.stringify({context:e,until:t+Vo}))}catch{}}function Ln(){try{localStorage.removeItem(L("recommendationContext"))}catch{}}var Bo="hp_sample",Nn=1e4;function Tn(e,t){return!(typeof t=="number"&&t<1)||e==null||e===""?!0:Ue(e,Bo,Nn)<Math.round(t*Nn)}function wt(e){return e.trim().toLowerCase().replace(/\s*\/\s*/g,"/").replace(/^\/+|\/+$/g,"")}var jo=2,qo=12;function Fo(e,t=jo){return e.split("/").slice(0,t).join("/")}function he(e,t){if(typeof t!="string"||!t.trim())return null;let n=Fo(wt(t));return n?(e.unshift(n),e.length=Math.min(e.length,qo),n):null}var ue=()=>L("sessionSignals"),ge=null,_t=()=>ge??ue();function Rn(){try{return ge?localStorage:sessionStorage}catch{return}}function Mn(e,t){let n=t==null?null:String(t),r=e?F(ue(),n,e):null;if(r===ge)return;let o=ge===null?Ho():null;if(ge=r,!!ge)try{let i=_t(),s=nn(ue(),n);for(let a of Object.keys(localStorage))a.startsWith(s)&&a!==i&&localStorage.removeItem(a);o&&!localStorage.getItem(i)&&(localStorage.setItem(i,JSON.stringify(o)),sessionStorage.removeItem(ue()))}catch{}}function Ho(){try{let e=sessionStorage.getItem(ue());if(!e)return null;let t=JSON.parse(e);return t&&(t.productViews>0||t.listViews>0||t.basketValue!=null||t.recentProducts?.length||t.recentBrowse?.length)?t:null}catch{return null}}function Ve(){return{productViews:0,listViews:0,cartAdds:0,searches:0,recentProducts:[],recentCategories:[],recentBrowse:[],basketProducts:[],basketValue:null,recentSearches:[],impressions:{},browsingCategory:null,startedAt:0}}function bt(){let e=Rn();if(!e)return Ve();try{let t=e.getItem(_t());return t?{...Ve(),...JSON.parse(t)}:{...Ve(),startedAt:Date.now()}}catch{return{...Ve(),startedAt:Date.now()}}}function xt(e){let t=Rn();if(t)try{t.setItem(_t(),JSON.stringify(e))}catch{}}function Dn(){return bt()}function $n(){for(let e of[()=>sessionStorage,()=>localStorage])try{let t=e();t.removeItem(ue());for(let n of Object.keys(t))n.startsWith(`${ue()}:`)&&t.removeItem(n)}catch{}}var Un=20,Vn=200,Ko=new Set(["Product Viewed","Product Clicked","Product Added","Product Added to Wishlist"]),Go=new Set(["Product Viewed","Product Added"]);function Bn(e,t){let n=bt();n.startedAt||(n.startedAt=Date.now());let r=Array.isArray(t?.products)?t.products:[];switch(e){case"Product Viewed":n.productViews+=1,he(n.recentBrowse,n.browsingCategory);break;case"Product List Viewed":{let s=t?.list_id;typeof s=="string"&&s.includes("/")&&!s.startsWith("cdp-")&&(n.listViews+=1,n.browsingCategory=he(n.recentBrowse,s)??n.browsingCategory)}break;case"Product List Filtered":{let s=t?.change,a=typeof t?.list_id=="string"?t.list_id:"",u=typeof s?.value=="string"?s.value:"";u&&s?.action!=="removed"&&(n.browsingCategory=he(n.recentBrowse,`${a}/${u}`)??n.browsingCategory);break}case"Product Added":{n.cartAdds+=1,he(n.recentBrowse,n.browsingCategory);for(let s of r){let a=s.product_id;typeof a!="string"||!a||(n.basketProducts=[a,...n.basketProducts.filter(u=>u!==a)].slice(0,Un))}break}case"Product Removed":{for(let s of r){let a=s.product_id;typeof a=="string"&&a&&(n.basketProducts=n.basketProducts.filter(u=>u!==a))}break}case"Products Searched":{n.searches+=1;let s=t?.query;if(typeof s=="string"&&s.trim()){let a=s.trim().toLowerCase().slice(0,64);n.recentSearches=[a,...n.recentSearches.filter(u=>u!==a)].slice(0,5)}break}case"Product Clicked":case"Product Added to Wishlist":break;case"Cart Updated":{let s=t?.value;return n.basketValue=typeof s=="number"&&Number.isFinite(s)&&s>=0?s:null,xt(n),n}default:return n}let o=Ko.has(e);if(o)for(let s of r)typeof s.product_id=="string"&&s.product_id&&delete n.impressions[s.product_id];else{for(let a of r){let u=a.product_id;typeof u!="string"||!u||(n.impressions[u]=(n.impressions[u]??0)+1)}let s=Object.keys(n.impressions);if(s.length>Vn){let a={};for(let u of s.sort((d,p)=>n.impressions[p]-n.impressions[d]).slice(0,Vn))a[u]=n.impressions[u];n.impressions=a}}let i=new Set;for(let s of r){let a=s.product_id;if(o&&typeof a=="string"&&a&&(n.recentProducts=[a,...n.recentProducts.filter(u=>u!==a)].slice(0,Un)),Go.has(e)&&typeof s.category=="string"&&s.category){let u=wt(s.category);u&&!i.has(u)&&(i.add(u),he(n.recentCategories,u))}}return xt(n),n}var jn=1800*1e3;function qn({name:e,domain:t=null,mayStore:n,now:r=()=>Date.now(),mint:o=Z}){let i=null,s=0,a=()=>{i!==null&&n()&&Q(e,i,jn/1e3,t)};return{get(){let u=r(),d=D(e);return d?i=d:(i===null||u-s>=jn)&&(i=o()),s=u,a(),i},persist:a,forget(){Q(e,"",0,t),i=null}}}var W=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Fn=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),At=Object.freeze({enabled:!1});function Hn(e,t){let n=e?.track;return W(n)?(Object.hasOwn(n,t)?n[t]:n.__default)?.enabled!==!1:!0}function zo(e,t){return`${ye(e)}/v1/projects/${encodeURIComponent(t)}/settings`}var Wo="https://hp.thgingenuity.com";function ye(e){return e==null||e===""?Wo:Kn(e)}function Kn(e){if(typeof e!="string")return null;let t=e.trim().replace(/\/+$/,"");return/^https?:\/\/[^/\s]+$/i.test(t)?t:/^[a-z0-9.-]+(:\d+)?$/i.test(t)?`https://${t}`:null}function Jo(e){if(!W(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>typeof n=="boolean"));return Object.keys(t).length?t:null}var It=e=>typeof e=="number"&&e>=0&&e<=1,Yo=/^[0-9a-f]{64}$/;function Xo(e){return W(e)?{enabled:e.enabled===!0,tokenSha256:typeof e.tokenSha256=="string"&&Yo.test(e.tokenSha256)?e.tokenSha256:null}:{enabled:!1,tokenSha256:null}}function Zo(e){if(!W(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>W(n)&&It(n.share)&&(n.ramp==null||It(n.ramp))&&typeof n.salt=="string"&&n.salt!=="").map(([n,r])=>[n,{share:r.share,ramp:r.ramp??null,salt:r.salt,...Fn(r.readoutSlots)&&r.readoutSlots.length>0&&{readoutSlots:r.readoutSlots}}]));return Object.keys(t).length?t:null}var Qo=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;function es(e){return W(e)?e.source==="hp_cookie"?{source:"hp_cookie"}:e.source!=="site_cookie"?null:e.cookie==null?{source:"site_cookie",cookie:null}:typeof e.cookie=="string"&&Qo.test(e.cookie)?{source:"site_cookie",cookie:e.cookie}:null:null}function vt(e){let t=W(e)?e.hp:null;return!W(t)||t.enabled!==!0?At:{enabled:!0,propertyId:typeof t.propertyId=="string"&&t.propertyId!==""?t.propertyId:null,environment:typeof t.environment=="string"?t.environment:null,consentPurposes:Jo(t.consent?.purposes),queryParamAllowlist:Fn(t.queryParamAllowlist)?t.queryParamAllowlist:null,anonymousId:es(t.anonymousId),apiHost:Kn(t.apiHost),holdouts:Zo(t.holdouts),sampleRate:It(t.sampleRate)?t.sampleRate:1,debug:Xo(t.debug),plan:W(e.plan)&&W(e.plan.track)?{track:e.plan.track}:null}}async function Gn(e,t,n=globalThis.fetch){try{let r=await n(zo(e,t),{credentials:"omit",headers:{accept:"application/json"}});return r.ok?vt(await r.json()):null}catch{return null}}var Be=e=>F(L("settings"),e);function zn(e){try{let t=localStorage.getItem(Be(e));if(!t)return null;let n=JSON.parse(t);return n?.enabled===!0?n:null}catch{return null}}function Wn(e,t){try{t?.enabled===!0?localStorage.setItem(Be(e),JSON.stringify(t)):localStorage.removeItem(Be(e))}catch{}}function Et(e){try{localStorage.removeItem(Be(e))}catch{}}var ts={flushAt:20,flushIntervalMs:1e4,maxQueue:500,maxRetryAgeMs:1440*60*1e3,maxRetries:5,maxPersistedBatches:20,maxPersistedBytes:1024*1024,storageKey:ie.retry,beaconSafeBytes:56*1024,maxBatchEvents:100,maxBatchBytes:500*1024},je=()=>Date.now(),Jn=3e4,Tt=55*1024;function ns(e,t=je()){if(typeof e!="string")return 0;let n=e.trim();if(/^\d+$/.test(n))return Number(n)*1e3;if(n==="")return 0;let r=Date.parse(n);return Number.isNaN(r)?0:Math.max(0,r-t)}var ee=e=>typeof TextEncoder<"u"?new TextEncoder().encode(e).length:Buffer.byteLength(e),kt=()=>typeof window<"u"&&typeof document<"u";function rs(){try{return!kt()||!window.localStorage?null:(window.localStorage.getItem("thg_hp_probe"),window.localStorage)}catch{return null}}var A,Ct,Yn,qe,Pt,Ot,Xn,xe,Lt,Fe,Zn,Nt,Qn,He,Ke=class{constructor(t){Ut(this,A);this.o={...ts,...t},this.queue=[],this.timer=null,this.storage=rs(),this.inflight=null,this.sending=new Set,this.replayAllowed=!this.o.deferReplay,this.draining=null,kt()&&(window.addEventListener("pagehide",()=>this.flush({beacon:!0})),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()}),N(this,A,He).call(this))}replayPersisted(){return this.replayAllowed=!0,N(this,A,He).call(this)}clearPersisted(){if(this.replayAllowed=!1,!!this.storage)try{this.storage.removeItem(this.o.storageKey)}catch{}}enqueue(t){let n;try{n=JSON.parse(JSON.stringify(t))}catch(r){this.o.onError?.(`event ${t?.messageId??""} cannot be serialised; dropped`,r);return}this.queue.push(n),this.queue.length>this.o.maxQueue&&this.queue.splice(0,this.queue.length-this.o.maxQueue),this.queue.length>=this.o.flushAt?this.flush():N(this,A,Ct).call(this)}flush(t={}){if(N(this,A,Yn).call(this),this.queue.length===0)return Promise.resolve();if(t.beacon&&kt()&&typeof navigator<"u"&&navigator.sendBeacon)return N(this,A,Xn).call(this),Promise.resolve();if(this.inflight)return this.inflight;let n=N(this,A,Ot).call(this,this.queue,this.o.maxBatchEvents,this.o.maxBatchBytes).map(r=>{let o=N(this,A,Nt).call(this,r);return o&&this.sending.add(o),{batch:r,id:o}});return this.queue=[],this.inflight=(async()=>{for(let{batch:r,id:o}of n)await N(this,A,xe).call(this,r,0,o)})().finally(()=>{this.inflight=null,this.queue.length>=this.o.flushAt?this.flush():this.queue.length&&N(this,A,Ct).call(this)}),this.inflight}};A=new WeakSet,Ct=function(){this.timer||(this.timer=setTimeout(()=>this.flush(),this.o.flushIntervalMs),this.timer?.unref?.())},Yn=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},qe=function(t){return JSON.stringify({batch:t,writeKey:this.o.writeKey,sentAt:new Date().toISOString()})},Pt=function(){return`${this.o.apiHost.replace(/\/$/,"")}/v1/batch`},Ot=function(t,n,r){let o=ee(N(this,A,qe).call(this,[])),i=[],s=[],a=o;for(let u of t){let d=ee(JSON.stringify(u))+1;s.length&&(s.length>=n||a+d>r)&&(i.push(s),s=[],a=o),s.push(u),a+=d}return s.length&&i.push(s),i},Xn=function(){let t=this.queue;this.queue=[];let n=N(this,A,Pt).call(this);for(let r of N(this,A,Ot).call(this,t,this.o.maxBatchEvents,this.o.beaconSafeBytes)){let o=N(this,A,qe).call(this,r);if(ee(o)<=this.o.beaconSafeBytes){let i=!1;try{i=navigator.sendBeacon(n,new Blob([o],{type:"text/plain"}))}catch{i=!1}if(i)continue}N(this,A,xe).call(this,r,0,N(this,A,Nt).call(this,r))}},xe=async function(t,n,r=null){r&&this.sending.add(r);let o=N(this,A,qe).call(this,t),i=0;try{let s=await fetch(N(this,A,Pt).call(this),{method:"POST",headers:{"Content-Type":"text/plain"},body:o,keepalive:ee(o)<=this.o.beaconSafeBytes});if(s.ok)return N(this,A,Lt).call(this,r),N(this,A,He).call(this),!0;let a=s.status===429||s.status>=500;if(a&&(i=ns(s.headers?.get?.("retry-after"))),!a)return N(this,A,Lt).call(this,r),this.o.onError?.(`CDP ingest rejected batch (${s.status}); dropping ${t.length} events`),!0;throw new Error(`retryable ${s.status}`)}catch(s){if(n>=this.o.maxRetries){r&&this.sending.delete(r);let u=r?"kept for the next page":"dropped";return this.o.onError?.(`CDP ingest unreachable after ${n} attempts; ${u}: ${t.length} events`,s),!1}let a=Math.max(Math.min(1e3*2**n,Jn)*(.5+Math.random()),Math.min(i,Jn));return await new Promise(u=>setTimeout(u,a)),N(this,A,xe).call(this,t,n+1,r)}},Lt=function(t){t&&(this.sending.delete(t),N(this,A,Qn).call(this,t))},Fe=function(){let t=JSON.parse(this.storage.getItem(this.o.storageKey)||"[]");return Array.isArray(t)?t:[]},Zn=function(t,n){let r=s=>ee(JSON.stringify(s))+1,o=[...t,n].slice(-this.o.maxPersistedBatches),i=o.reduce((s,a)=>s+r(a),2);for(;o.length>1&&i>this.o.maxPersistedBytes;)i-=r(o[0]),o=o.slice(1);for(;o.length;)try{return this.storage.setItem(this.o.storageKey,JSON.stringify(o)),!0}catch{o=o.slice(1)}return!1},Nt=function(t){if(!this.storage||this.o.mayPersist&&!this.o.mayPersist())return null;try{let n={at:je(),id:`${je()}-${Math.random().toString(36).slice(2)}`,batch:t};return ee(JSON.stringify(n))+3>this.o.maxPersistedBytes?null:N(this,A,Zn).call(this,N(this,A,Fe).call(this),n)?n.id:null}catch{return null}},Qn=function(t){if(!(!t||!this.storage))try{let n=N(this,A,Fe).call(this).filter(r=>r.id!==t);n.length?this.storage.setItem(this.o.storageKey,JSON.stringify(n)):this.storage.removeItem(this.o.storageKey)}catch{}},He=function(){if(!this.storage||!this.replayAllowed)return this.draining??Promise.resolve();if(this.draining)return this.draining;let t;try{let r=N(this,A,Fe).call(this);t=r.filter(o=>Array.isArray(o?.batch)&&je()-o.at<this.o.maxRetryAgeMs).map(o=>o.id?o:{...o,id:`${o.at}-${Math.random().toString(36).slice(2)}`}),(t.length!==r.length||t.some((o,i)=>o!==r[i]))&&(t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey))}catch{return Promise.resolve()}let n=t.filter(r=>!this.sending.has(r.id));return n.length?(this.draining=(async()=>{for(let r of n)if(!this.replayAllowed||!await N(this,A,xe).call(this,r.batch,0,r.id))return})().finally(()=>{this.draining=null}),this.draining):Promise.resolve()};var er="3.19.0",tr="@thg-agentic/hyper-personalisation-web";var os=new Set(["audiences","decisions","recommendations"]);var ss=Symbol.for("@thg-agentic/hyper-personalisation-web.replay");function is(e){let t={...e??{}},n=Array.isArray(t.products)?t.products:null;if(t.item_count==null&&n){let r=n.map(o=>o?.quantity);r.every(Number.isInteger)&&(t.item_count=r.reduce((o,i)=>o+i,0))}return t}var as="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";function cs(e){if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(!/^[A-Za-z0-9+/_-]{43}=?$/.test(e))return null;try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(44,"="));return t.length!==32?null:Array.from(t,n=>n.charCodeAt(0).toString(16).padStart(2,"0")).join("")}catch{return null}}function Ge(e){if(typeof e!="string")return null;let t=cs(e.trim());return t===as?null:t}var nr=!1,rr=!1;function us(){rr||(rr=!0,console.warn("[hp] no consent adapter: events are sent under the host's lawful basis (basis 'host'). Pass `consent` to send only once the visitor allows analytics."))}function ls(e){!e||nr||(nr=!0,console.warn("[hp] mintAnonymousId is ignored since 3.6: where device ids come from is set per source in the console (the site\u2019s own cookie, or Hyper-Personalisation\u2019s)."))}function ds(e){try{return ee(JSON.stringify(e))}catch{return 0}}function or(e){return e&&typeof e.context=="object"&&e.context!==null?e.context:e}function sr(e){let t=ye(e?.apiHost);if(!t)throw new Error("createAnalytics: apiHost, when given, must be a host or an http(s) origin");if(!e?.propertyId)throw new Error("createAnalytics: propertyId is required");let n={libraryName:tr,libraryVersion:er,writeKey:"web",queryParamBlocklist:[],debug:!1,validate:null,consentTimeoutMs:5e3,...e,apiHost:t};Pe(n.storageNames),Oe();let r=!!n.consent;r||us();let o=null;n.getConsent=()=>o?o.stamp():an();let i=()=>!r||o?.status==="granted",s=r&&n.holdAcrossPages?rn(F(L("held"),n.propertyId)):null,a=s?.read()??{items:[],anonymousId:null};n.mintAnonymousId!==void 0&&ls(n.debug);let u=on(n,{carried:a.anonymousId,mayStore:i,orOwn:!0}),d=qn({name:L("session"),domain:n.consentCookieDomain??null,mayStore:i}),p=n.getSessionId;n.getSessionId=()=>q(R(p,null))??d.get();let f=kn(L("preview"),n.consentCookieDomain??null),y=(c,l)=>n.debug&&console.warn("[hp]",c,l??""),x=n.transport??new Ke({apiHost:n.apiHost,writeKey:n.writeKey,storageKey:F(L("retry"),n.propertyId),mayPersist:r?()=>o?.status==="granted":void 0,deferReplay:r,onError:y}),S=F(L("previousPage"),n.propertyId),b=null,I=()=>{if(b)return b;try{return sessionStorage.getItem(S)||null}catch{return null}},k=c=>{if(b=c||null,!(r&&o.status!=="granted"))try{sessionStorage.setItem(S,c)}catch{}},h=vn({key:F(L("decisions"),n.propertyId),mayStore:i});n.getDecisions??(n.getDecisions=h.current);let v=q(R(n.getUserId,null)),w=null,g=null,_=null;function P(c,l,C=!1){try{return M(c,l,C)}catch(O){if(O instanceof me)throw O;return console.warn("[hp] the event was not sent",O),null}}function M(c,l,C){let O=_;_=null;let E={messageId:O?.messageId??Z(),timestamp:O?.timestamp??new Date().toISOString(),anonymousId:q(R(n.getAnonymousId,null)),userId:v??null,...c,context:Zt(n,or(l))};if(E.properties&&(E.properties=nt(E.properties)),!C&&!Tn(E.anonymousId,n.sampleRate))return n.debug&&console.debug("[hp] not sent: outside the sample",E),null;if(n.beforeSend){let de;try{de=n.beforeSend(E)}catch(yr){return console.warn("[hp] beforeSend failed; the event was not sent",yr),null}if(!de)return null;let{type:Ee,event:Dt,messageId:hr,timestamp:gr}=E;E={...de,type:Ee,messageId:hr,timestamp:gr,...Dt?{event:Dt}:{}}}if(n.validate){let de=n.validate(E,{producer:"web"});if(!de.valid){let Ee=`[hp] invalid ${E.event??E.type}:
2
- ${de.errors.join(`
3
- `)}`;if(n.throwOnInvalid)throw new me(Ee);console.error(Ee)}}n.debug&&console.debug("[hp]",E.event??E.type,E);let U=ds(E);return U>Tt?(y(`${E.event??E.type} not sent: ${U} bytes, over the ${Tt}-byte limit for one event`),null):(Ie(E,C),E)}function H(c){if(c.type==="track"&&G(c),n.onEvent)try{n.onEvent(c)}catch(l){console.warn("[hp] onEvent observer failed",l)}}let K=()=>r&&o?.state?.personalisation===!0,j=()=>Mn(R(n.getSessionId,null),n.propertyId),te=!1;function G(c){try{K()?(j(),On(St(Bn(c.event,c.properties))),te=!0):ne()}catch(l){n.debug&&console.warn("[hp] the visit was not recorded",l)}}function ne(c=!1){Ln(),(c||te)&&$n(),te=!1}function le(){d.forget(),h.forget(),B.clear(),u?.forget(),ne(!0)}function Ie(c,l){!r||l||o.admits()?(H(c),x.enqueue(c)):o.hold(c)}let m=(c,l,C)=>Hn(n.plan,c)?P({type:"track",event:c,properties:l??{}},C):null,B=new Set,Ae=(c,l,C)=>c==="audiences"?{audiences:l?null:C.audiences??[]}:c==="decisions"?{decisions:(C.decisions??[]).map(O=>({slot:O.slot,decision_id:O.decision_id??null,arm:O.arm??null,...O.variant&&{variant:O.variant}}))}:{recommendation_request_id:C.recommendation_request_id??null};r&&(o=In({adapter:n.consent,timeoutMs:n.consentTimeoutMs,cookieDomain:n.consentCookieDomain,debug:n.debug,store:s&&{read:()=>a.items,write:c=>s.write(c,u?.peek()??null)},release(c){c.context&&(c.context.consent=o.stamp()),H(c),x.enqueue(c)},onStatus(c){if(c==="granted"&&(u?.persist(),d.persist(),b&&k(b),h.persist(),x.replayPersisted?.()),c==="denied"){x.clearPersisted?.(),u?.forget(),d.forget();try{sessionStorage.removeItem(S)}catch{}h.forget(),ne(!0)}try{n.onConsentStatus?.(c)}catch(l){console.warn("[hp] onConsentStatus observer failed",l)}},announce({action:c,state:l,previous:C,withdrawal:O}){l?.personalisation!==!0&&ne(C?.personalisation===!0),P({type:"track",event:"Consent Updated",properties:{action:c,state:l}},void 0,O),O&&x.flush()}}),o.start());let J=()=>n.holdout?gt(n.holdout):null,ve=()=>yt(n.holdout,q(R(n.getAnonymousId,null))).group;function mr(c,l){if(!Array.isArray(c?.decisions))return c;let C=n.holdout?.readoutSlots??[],O=q(R(n.getAnonymousId,null));return{...c,decisions:c.decisions.map(E=>{let U=E?.variant==="bandit"||E?.variant==="default"?E.variant:!l&&E?.holdout!==!0&&C.includes(E?.slot)?En(E.slot,O):null;return U?U==="default"?{...E,variant:U,decision_id:null}:{...E,variant:U}:E})}}function Mt(c,l){if(f)return null;let C=c?.exposure,O=C?.holdout===!0,E=mr(c,O);return h.remember(An(E)),!C?.token||B.has(C.token)?null:(B.add(C.token),m("Personalisation Exposed",{exposure_token:C.token,surface:C.surface,holdout:O,holdout_share:C.holdout_share??J()?.holdout_share??null,personalised_share:C.personalised_share??J()?.personalised_share??null,...Ae(C.surface,O,E)},l))}return bn({track:m,page(c,l){c??(c={});let C=n.pageType??null;c.type&&(fe.has(c.type)?(C=c.type,n.pageType=c.type):n.debug&&console.warn(`[hp] ignoring unknown page.type "${c.type}". Allowed: ${[...fe].join(", ")}`));let O=P({type:"page",properties:{name:c.name??null,navigation_trigger:c.navigation_trigger??zt(),previous_message_id:I()}},{page:{type:C},...or(l)??{}});return O&&k(O.messageId),O},identify(c,l,C){let{userId:O,...E}=c&&typeof c=="object"?c:{};if(O!==void 0){let U=q(O);C===be?g=U:w&&U&&U!==w?le():n.debug&&g&&U&&U!==g&&console.warn("[hp] identify names another userId than the identity option; using the new one"),v=U,U&&C!==be&&(w=U)}if(typeof E.email_sha256=="string"){let U=Ge(E.email_sha256);U?E.email_sha256=U:delete E.email_sha256}return P({type:"identify",traits:E},l)},reset(){v&&le(),v=null,w=null,g=null,k("")},productViewed:(c,l)=>m("Product Viewed",c,l),productListViewed:(c,l)=>m("Product List Viewed",c,l),recommendationsViewed:(c,l)=>m("Recommendations Viewed",c,l),personalisationExposed:(c,l)=>m("Personalisation Exposed",c,l),recordExposure:Mt,surfaceViewed({surface:c}={},l){if(!os.has(c)||!n.holdout||c!=="decisions"&&!K())return null;let C=q(R(n.getAnonymousId,null)),O=yt(n.holdout,C).group;if(O==="excluded")return null;let E=Ht({sessionId:ke(R(n.getSessionId,null),C),surface:c});return E?Mt({exposure:{token:E,surface:c,holdout:O==="holdout"}},l):null},inHoldout:()=>ve()!=="personalised",personalisationGroup:ve,productClicked:(c,l)=>m("Product Clicked",c,l),productListFiltered:(c,l)=>m("Product List Filtered",c,l),productsSearched:(c,l)=>m("Products Searched",c,l),searchSuggestionsViewed:(c,l)=>m("Search Suggestions Viewed",c,l),productAdded:(c,l)=>m("Product Added",c,l),productRemoved:(c,l)=>m("Product Removed",c,l),cartUpdated:(c,l)=>m("Cart Updated",is(c),l),identityLinked:(c,l)=>m("Identity Linked",c,l),slotEngaged:(c,l)=>f?null:m("Slot Engaged",c,l),productVariantSelected:(c,l)=>m("Product Variant Selected",c,l),cartViewed:(c,l)=>m("Cart Viewed",c,l),productAddedToWishlist:(c,l)=>m("Product Added to Wishlist",c,l),productRemovedFromWishlist:(c,l)=>m("Product Removed from Wishlist",c,l),wishlistProductAddedToCart:(c,l)=>m("Wishlist Product Added to Cart",c,l),productShared:(c,l)=>m("Product Shared",c,l),cartShared:(c,l)=>m("Cart Shared",c,l),couponEntered:(c,l)=>m("Coupon Entered",c,l),couponApplied:(c,l)=>m("Coupon Applied",c,l),couponDenied:(c,l)=>m("Coupon Denied",c,l),couponRemoved:(c,l)=>m("Coupon Removed",c,l),checkoutStarted:(c,l)=>m("Checkout Started",c,l),promotionViewed:(c,l)=>m("Promotion Viewed",c,l),promotionClicked:(c,l)=>m("Promotion Clicked",c,l),checkoutStepViewed:(c,l)=>m("Checkout Step Viewed",c,l),checkoutStepCompleted:(c,l)=>m("Checkout Step Completed",c,l),paymentInfoEntered:(c,l)=>m("Payment Info Entered",c,l),checkoutFailed:(c,l)=>m("Checkout Failed",c,l),signedIn:(c,l)=>m("Signed In",c,l),signedUp:(c,l)=>m("Signed Up",c,l),signedOut(c){let l=m("Signed Out",{},c);return v&&le(),v=null,w=null,g=null,l},newsletterSubscribed:(c,l)=>m("Newsletter Subscribed",c,l),newsletterUnsubscribed:(c,l)=>m("Newsletter Unsubscribed",c,l),backInStockSubscribed:(c,l)=>m("Back In Stock Subscribed",c,l),productReviewed:(c,l)=>m("Product Reviewed",c,l),consentUpdated:(c,l)=>m("Consent Updated",c,l),flush:c=>x.flush(c),recommendationContext(){if(!K())return{};try{return j(),St(Dn())}catch{return{}}},get consent(){return o?o.state:null},servingHeaders:()=>ln(o?.state??null),get lastPageMessageId(){return I()},get anonymousId(){return q(R(n.getAnonymousId,null))},[ss](c,l,C){if(typeof this[c]=="function"){_=typeof C?.messageId=="string"&&typeof C?.timestamp=="string"?{messageId:C.messageId,timestamp:C.timestamp}:null;try{this[c](...Array.isArray(l)?l:[])}finally{_=null}}}})}var Rt=Symbol.for("@thg-agentic/hyper-personalisation-web.bootstrap"),fs=Symbol.for("@thg-agentic/hyper-personalisation-web.drain"),ps=Symbol.for("@thg-agentic/hyper-personalisation-web.carry"),ir=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),ms=Symbol.for("@thg-agentic/hyper-personalisation-web.assignment"),hs=Symbol.for("@thg-agentic/hyper-personalisation-web.recommendation-context"),Je=e=>e?()=>D(e):()=>null,ur={didomi:e=>dn({purposes:e.purposes}),onetrust:e=>fn({groups:e.groups,impliedConsent:e.impliedConsent}),cookie:e=>pn({name:e.name,categories:e.categories,refusedValue:e.refusedValue,source:e.source,changeEvent:e.changeEvent}),forwarded:e=>mn({name:e.name}),static:e=>{if(!e.state||typeof e.state!="object")throw new Error('consent.state is required for provider "static"');return hn(e.state)}},ar=Object.keys(ur),Se=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ze=e=>typeof e=="string"&&e!=="",gs=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),lr=e=>Se(e)&&typeof e.read=="function";function ys(e,t={}){let n=[];if(!Se(e))return["config must be { writeKey, apiHost? }"];ze(e.writeKey)||n.push("writeKey is required"),ye(e.apiHost)||n.push("apiHost, when given, must be a host or an http(s) origin"),t.propertyId!==void 0&&!ze(t.propertyId)&&n.push("propertyId must be a string");let{consent:r}=t;if(!lr(r)&&!(Se(r)&&ar.includes(r.provider))&&n.push(`consent must be a consent adapter or { provider: ${ar.join(" | ")} }`),t.autocapture!==void 0&&t.autocapture!==!1&&!Se(t.autocapture)&&n.push("autocapture must be false or { promotions, productLists, recommendations }"),t.beforeSend!==void 0&&typeof t.beforeSend!="function"&&n.push("beforeSend must be a function"),t.identityCookies!==void 0)if(!Se(t.identityCookies))n.push("identityCookies must be an object");else for(let o of["anonymousId","sessionId"]){let i=t.identityCookies[o];i!==void 0&&!ze(i)&&n.push(`identityCookies.${o} must be a cookie name`)}for(let o of["getCurrency","getShipToCountry","getLocale"])t[o]!==void 0&&typeof t[o]!="function"&&n.push(`${o} must be a function`);return t.dataLayer!==void 0&&(Se(t.dataLayer)?(t.dataLayer.name!==void 0&&!ze(t.dataLayer.name)&&n.push("dataLayer.name must be a string"),t.dataLayer.ignore!==void 0&&!gs(t.dataLayer.ignore)&&n.push("dataLayer.ignore must be an array of strings")):n.push("dataLayer must be an object")),n}function Ss(e,t,n){if(lr(e))return dt(e,t.consentPurposes);let{provider:r,...o}=e,i=n?.consent?.[r]??ur[r];return dt(i(o),t.consentPurposes)}var dr=(e,t)=>`${e??""}|${t??""}`;function ws(e,t){let n=q(t?.userId),r=Ge(t?.emailSha256);if(!n&&!r)return null;try{let o=F(L("identified"),e);if(sessionStorage.getItem(o)===dr(n,r))return null}catch{}return{...n?{userId:n}:{},...r?{email_sha256:r}:{}}}async function _s({writeKey:e,apiHost:t},n){if(n.settings!==void 0)return{settings:vt(n.settings),revalidated:null};let r=Gn(t,e),o=zn(e);if(o)return{settings:o,revalidated:r};let i=await r,s=i??At;return{settings:s,revalidated:Promise.resolve(s),unreachable:i===null}}function fr(e,t){let n=t??{},r=typeof window<"u"?window:null;if(r?.[Rt])return r[Rt];let o=sn(e?.writeKey,()=>{let{analytics:s}=_e(D(L("consent")));return s===!0||s===null&&n.holdAcrossPages===!0}),i=xs(e,n,o);if(r){let s=n.extend?.getSessionId??Je(n.identityCookies?.sessionId),a=Je(n.identityCookies?.anonymousId);r[ms]=({slot:u,arm:d}={})=>Ft({sessionId:ke(s(),a()),slot:u,arm:d}),r[Rt]=i,r[ps]=o,r[fs]?.(i)}return i}function bs(){let e=globalThis.performance?.now?.();return new Date(Date.now()-(Number.isFinite(e)?e:0)).toISOString()}function cr(e,t){if(t===!1)return()=>{};let n={promotions:!0,productLists:!0,recommendations:!0,exposures:!0,...t},r=i=>i&&typeof i=="object"?i:{},o=[];try{n.promotions&&o.push(Qe(e,r(n.promotions))),n.productLists&&o.push(Ze(e,r(n.productLists))),n.recommendations&&o.push(et(e,r(n.recommendations))),n.exposures&&o.push(Xe(e,r(n.exposures)))}catch(i){console.warn("[hp] autocapture not started:",i?.message??i)}return()=>{for(let i of o)i()}}function We(e){return e.close(),null}async function xs(e,t,n){try{let r=ys(e,t);if(r.length)return console.warn(`[hp] not started, the configuration is invalid: ${r.join("; ")}`),We(n);Pe(t.storageNames),Oe();let{writeKey:o}=e,[{settings:i,revalidated:s,unreachable:a},u]=await Promise.all([_s(e,t),Promise.resolve(t.identity).catch(()=>null)]),d=s?i:null,p=!1,f=()=>p&&d&&Wn(o,d);if(s?.then(g=>{g&&(d=g,g.enabled?f():Et(o))}),a)return null;if(!i.enabled)return t.debug&&console.info("[hp] off: the settings for this write key do not enable it"),We(n);let y=i.propertyId??t.propertyId;if(!y)return console.warn("[hp] not started: this write key covers several properties, so propertyId is required"),We(n);let{preset:x}=t,S=ws(y,u),b=t.debug===!0||i.debug?.enabled===!0||_n(i.debug?.tokenSha256??null,L("debug")),I=q(u?.userId),k=sr({apiHost:i.apiHost??ye(e.apiHost),writeKey:o,propertyId:y,pageType:fe.has(t.pageType)?t.pageType:void 0,environment:i.environment,queryParamAllowlist:i.queryParamAllowlist??void 0,plan:i.plan,sampleRate:i.sampleRate??1,holdout:i.holdouts?.[y],getCurrency:t.getCurrency,getShipToCountry:t.getShipToCountry,getLocale:t.getLocale,consent:Ss(t.consent,i,x),consentCookieDomain:t.consentCookieDomain,storageNames:t.storageNames,holdAcrossPages:t.holdAcrossPages===!0,mintAnonymousId:t.mintAnonymousId,debug:b,anonymousIdSource:i.anonymousId??void 0,getAnonymousId:Je(t.identityCookies?.anonymousId),getSessionId:t.identityCookies?.sessionId?Je(t.identityCookies.sessionId):void 0,getUserId:()=>I,beforeSend:t.beforeSend,...t.extend,onConsentStatus(g){if(g==="granted"&&(p=!0,f()),g==="denied"){Et(o);try{sessionStorage.removeItem(F(L("identified"),y))}catch{}}t.extend?.onConsentStatus?.(g)},onEvent(g){if(g.type==="identify"){let _=dr(q(g.userId),Ge(g.traits?.email_sha256));try{sessionStorage.setItem(F(L("identified"),y),_)}catch{}}t.extend?.onEvent?.(g)}});typeof window<"u"&&(window[hs]=()=>k.recommendationContext());for(let[g,_,P]of n.take())try{k[ir](g,_,P)}catch(M){console.warn(`[hp] carried ${g} failed`,M)}k[ir]("page",[t.pageType?{type:t.pageType}:{}],{messageId:Z(),timestamp:bs()});let h=cr(k,t.autocapture),v=k.page;k.page=ht("page",(...g)=>{let _=v(...g);return h(),h=cr(k,t.autocapture),_});let w=typeof window<"u"?window:null;if(t.dataLayer&&w){let g=t.dataLayer.name??"dataLayer";w[g]=w[g]||[],wn(k,{...x,dataLayer:w[g],ignore:[...x?.ignore??[],...t.dataLayer.ignore??[]],onError:_=>b&&console.warn("[hp] dataLayer mapping failed",_)})}return S&&k.identify(S,void 0,be),k}catch(r){return console.warn("[hp] not started:",r?.message??r),We(n)}}function pr(e){e.initialized=!0,fr(e._config,e._options).then(t=>{let n=e.splice(0);if(!t){for(let r of e.methods??[])e[r]=()=>e;return}e.client=t;for(let[r,o]of Object.entries(t))typeof o=="function"&&(e[r]=o);for(let[r,...o]of n)try{t[r]?.(...o)}catch(i){console.warn(`[hp] queued ${r} failed`,i)}})}var V=window.hp=window.hp||[];V.servingHeaders??(V.servingHeaders=()=>({}));V.inHoldout??(V.inHoldout=()=>!0);V.personalisationGroup??(V.personalisationGroup=()=>"excluded");V.recommendationContext??(V.recommendationContext=()=>({}));V.initialized||(V._config?pr(V):V.load=(e,t)=>{V._config=e,V._options=t??{},pr(V)});})();
1
+ (()=>{var qt=e=>{throw TypeError(e)};var vr=(e,t,n)=>t.has(e)||qt("Cannot "+n);var Ft=(e,t,n)=>t.has(e)?qt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var O=(e,t,n)=>(vr(e,t,"access private method"),n);var Se=[];for(let e=2;Se.length<64;e++)Se.every(t=>e%t!==0)&&Se.push(e);var Ht=e=>(e-Math.floor(e))*2**32>>>0,Cr=Se.slice(0,8).map(e=>Ht(Math.sqrt(e))),Pr=Se.map(e=>Ht(Math.cbrt(e))),W=(e,t)=>e>>>t|e<<32-t;function Kt(e){let t=new TextEncoder().encode(String(e)),n=new Uint32Array((t.length+8>>6)*16+16);t.forEach((s,i)=>{n[i>>2]|=s<<24-i%4*8}),n[t.length>>2]|=128<<24-t.length%4*8,n[n.length-2]=Math.floor(t.length/2**29),n[n.length-1]=t.length*8;let r=Uint32Array.from(Cr),o=new Uint32Array(64);for(let s=0;s<n.length;s+=16){for(let w=0;w<64;w++){if(w<16){o[w]=n[s+w];continue}let b=o[w-15],k=o[w-2],E=W(b,7)^W(b,18)^b>>>3,h=W(k,17)^W(k,19)^k>>>10;o[w]=o[w-16]+E+o[w-7]+h}let[i,a,u,d,f,p,g,x]=r;for(let w=0;w<64;w++){let b=W(f,6)^W(f,11)^W(f,25),k=x+b+(f&p^~f&g)+Pr[w]+o[w]|0,h=(W(i,2)^W(i,13)^W(i,22))+(i&a^i&u^a&u)|0;[x,g,p,f,d,u,a,i]=[g,p,f,d+k|0,u,a,i,k+h|0]}[i,a,u,d,f,p,g,x].forEach((w,b)=>{r[b]+=w})}return Array.from(r,s=>s.toString(16).padStart(8,"0")).join("")}var Qe=(e,t)=>e<<t|e>>>32-t;function Gt(e){let t=new Uint32Array((e.length+8>>6)*16+16);e.forEach((s,i)=>{t[i>>2]|=s<<24-i%4*8}),t[e.length>>2]|=128<<24-e.length%4*8,t[t.length-2]=Math.floor(e.length/2**29),t[t.length-1]=e.length*8;let n=Uint32Array.of(1732584193,4023233417,2562383102,271733878,3285377520),r=new Uint32Array(80);for(let s=0;s<t.length;s+=16){for(let p=0;p<80;p++)r[p]=p<16?t[s+p]:Qe(r[p-3]^r[p-8]^r[p-14]^r[p-16],1);let[i,a,u,d,f]=n;for(let p=0;p<80;p++){let g,x;p<20?(g=a&u|~a&d,x=1518500249):p<40?(g=a^u^d,x=1859775393):p<60?(g=a&u|a&d|u&d,x=2400959708):(g=a^u^d,x=3395469782);let w=Qe(i,5)+g+f+x+r[p]|0;[f,d,u,a,i]=[d,u,Qe(a,30),i,w]}[i,a,u,d,f].forEach((p,g)=>{n[g]+=p})}let o=new Uint8Array(20);return n.forEach((s,i)=>{o[i*4]=s>>>24,o[i*4+1]=s>>>16,o[i*4+2]=s>>>8,o[i*4+3]=s}),o}var Or="e28e8ada-5b76-4209-bba9-79b823a0af75",Lr=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");function zt(e,t){let n=Uint8Array.from(e.replace(/-/g,"").match(/../g),a=>Number.parseInt(a,16)),r=new TextEncoder().encode(t),o=new Uint8Array(16+r.length);o.set(n),o.set(r,16);let s=Gt(o).slice(0,16);s[6]=s[6]&15|80,s[8]=s[8]&63|128;let i=Lr(s);return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}var re=(e,t)=>typeof e=="string"&&e!==""&&e.length<=t?e:null;function Oe(e,t){return re(e,64)??re(t,256)}function Wt({sessionId:e,slot:t,arm:n}={}){let r=re(e,256);return!r||!re(t,256)||!re(n,256)?null:zt(Or,`${r}:${t}:${n}`)}var Tr="4b1f2c7e-9a3d-4e58-b6c1-2d7f0a9e8c53";function Jt({sessionId:e,surface:t}={}){let n=re(e,256);return!n||!re(t,64)?null:zt(Tr,`${n}:${t}`)}var Nr=Array.from({length:11},(e,t)=>t/10);function Rr(e,t){if(!e.isIntersecting)return!1;let{intersectionRect:n,boundingClientRect:r,rootBounds:o}=e;if(!n||!r)return!0;let s=n.width*n.height,i=r.width*r.height,a=o?Math.min(i,o.width*o.height):i;return a>0&&s/a>=t}function X(e){let{selector:t,onViewable:n,visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=e,i=new Map,a=new WeakSet,u=new Set,d=h=>{i.has(h)||i.set(h,setTimeout(()=>{i.delete(h),n(h)&&(p?.unobserve(h),u.delete(h))},o))},f=h=>{clearTimeout(i.get(h)),i.delete(h)},p=typeof IntersectionObserver>"u"?null:new IntersectionObserver(h=>{for(let v of h){let S=v.target;if(!Rr(v,r)){u.delete(S),f(S);continue}u.add(S),g()&&d(S)}},{threshold:Nr}),g=()=>typeof document>"u"||document.visibilityState!=="hidden",x=()=>{if(g())for(let h of u)d(h);else for(let h of u)f(h)};document.addEventListener("visibilitychange",x);let w=()=>{for(let h of s.querySelectorAll(t))a.has(h)||(a.add(h),p?.observe(h))},b=typeof MutationObserver>"u"?null:new MutationObserver(()=>w()),k=()=>{w(),b?.observe(s===document?document.body:s,{childList:!0,subtree:!0})},E=s===document&&!document.body;return E?document.addEventListener("DOMContentLoaded",k,{once:!0}):k(),()=>{E&&document.removeEventListener("DOMContentLoaded",k),document.removeEventListener("visibilitychange",x),p?.disconnect(),b?.disconnect();for(let h of i.values())clearTimeout(h);i.clear(),u.clear()}}function et(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-exposure]",visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=t;return X({selector:n,root:s,visibleRatio:r,dwellMs:o,onViewable(i){let a=i.dataset?.hpExposure?.trim();return a&&e.surfaceViewed({surface:a}),!0}})}var Yt=e=>{try{return new URL(e,document.baseURI).toString()}catch{return e}};function tt(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-list]",tileSelector:r="[data-hp-product]",visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,a=new Set,u=w=>w.closest?.(n)??null,d=w=>{let b=w.dataset.hpList?.trim();return b?{list_id:b,category:w.dataset.hpListCategory?.trim()||null}:null},f=w=>Array.from(w.querySelectorAll(r)).filter(b=>u(b)===w),p=(w,b)=>{try{let k=JSON.parse(w.dataset.hpProduct??"");return!k||typeof k!="object"||!k.product_id?null:{...k,position:k.position??b+1,...k.url?{url:Yt(k.url)}:{},...k.image_url?{image_url:Yt(k.image_url)}:{}}}catch{return null}},g=X({selector:`${n} ${r}`,root:i,visibleRatio:o,dwellMs:s,onViewable(w){let b=u(w);if(!b||b.dataset.hpListView==="manual")return!0;let k=d(b);if(!k||a.has(k.list_id))return!0;let E=new Set,h=f(b).map(p).filter(v=>!v||E.has(v.product_id)?!1:(E.add(v.product_id),!0));return h.length===0||(a.add(k.list_id),e.productListViewed({...k,products:h})),!0}}),x=w=>{let k=w.target?.closest?.("a[href]")?.closest(r);if(!k)return;let E=u(k),h=p(k,E?f(E).indexOf(k):0);h&&e.productClicked({list_id:E?d(E)?.list_id??null:null,products:[h]})};return document.addEventListener("click",x,!0),()=>{document.removeEventListener("click",x,!0),g()}}function N(e,...t){let n=e.dataset??{};for(let r of t){let o=n[r];if(typeof o=="string"&&o.trim()!=="")return o.trim()}return null}function Le(e,...t){let n=N(e,...t);if(n===null)return null;let r=Number(n);return Number.isFinite(r)?Math.trunc(r):null}function Dr(e,t){let n=N(e,"hpPromotion");return n?{promotion_id:n,name:N(e,"hpPromotionName"),creative:N(e,"hpPromotionCreative"),position:N(e,"hpPromotionSlot")??String(t+1)}:null}function nt(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-promotion]",resolve:r=Dr,visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,a=new Set,u=p=>{let g=Array.from(i.querySelectorAll(n)),x=g.indexOf(p);try{return r(p,x<0?g.length:x)}catch{return null}},d=X({selector:n,root:i,visibleRatio:o,dwellMs:s,onViewable(p){let g=u(p);return!g||a.has(g.promotion_id)?!1:(a.add(g.promotion_id),e.promotionViewed(g),!0)}}),f=p=>{let g=p.target;if(!g||typeof g.closest!="function")return;let x=g.closest(n),w=g.closest("a[href]");if(!x||!w||!x.contains(w)&&!w.contains(x))return;let b=u(x);b&&e.promotionClicked({...b,href:w.getAttribute("href")})};return document.addEventListener("click",f,!0),()=>{document.removeEventListener("click",f,!0),d()}}function Mr(e){let t=N(e,"hpRecoRequest"),n=N(e,"hpRecoPlacement"),r=N(e,"hpRecoStrategy");if(!t||!n||!r)return null;let o=N(e,"hpRecoHoldout");return{recommendation_request_id:t,placement:n,strategy:r,recipe:N(e,"hpRecoRecipe"),algorithm_version:N(e,"hpRecoAlgorithmVersion"),experiment:N(e,"hpRecoExperiment"),variant:N(e,"hpRecoVariant"),holdout:o===null?null:o==="true",assignment_bucket:Le(e,"hpRecoBucket"),assignment_unit_kind:N(e,"hpRecoUnitKind"),candidate_set_fingerprint:N(e,"hpRecoFingerprint"),candidate_set_size:Le(e,"hpRecoCandidates"),ranked_by:N(e,"hpRecoRankedBy"),served_at:N(e,"hpRecoServedAt")}}function $r(e,t){let n=N(e,"hpRecoProduct");if(!n)return null;let r=N(e,"hpRecoPrice");return{product_id:n,sku:N(e,"hpRecoSku"),name:N(e,"hpRecoName"),brand:N(e,"hpRecoBrand"),price:r===null||Number.isNaN(Number(r))?null:Number(r),position:Le(e,"hpRecoPosition")??t+1}}function rt(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-reco-request]",tileSelector:r="[data-hp-reco-product]",resolveRail:o=Mr,resolveTile:s=$r,visibleRatio:i=.5,dwellMs:a=1e3,root:u=document}=t,d=new Set,f=new Map,p=new Map,g=(h,...v)=>{try{return h(...v)}catch{return null}},x=h=>typeof h.closest=="function"?h.closest(n):null,w=h=>Array.from(h.querySelectorAll(r)),b=(h,v)=>{if(p.delete(v.recommendation_request_id),d.has(v.recommendation_request_id))return;let S=w(h).map((_,L)=>g(s,_,L)).filter(_=>_?.product_id);if(S.length===0)return;d.add(v.recommendation_request_id);let y=[...f.get(v.recommendation_request_id)?.values()??[]].sort((_,L)=>_.position-L.position);e.recommendationsViewed({...v,products:S,viewable:y})},k=X({selector:`${n} ${r}`,root:u,visibleRatio:i,dwellMs:a,onViewable(h){let v=x(h);if(!v)return!0;let S=g(o,v);if(!S)return!0;let y=S.recommendation_request_id,_=g(s,h,w(v).indexOf(h));if(_?.product_id){f.has(y)||f.set(y,new Map);let L=f.get(y);L.has(_.position)||L.set(_.position,{position:_.position,product_id:_.product_id,viewable_at:new Date().toISOString()})}return!d.has(y)&&!p.has(y)&&p.set(y,setTimeout(()=>b(v,S),0)),!0}}),E=h=>{let v=h.target;if(!v||typeof v.closest!="function")return;let S=v.closest(r);if(!S)return;let y=v.closest("[data-hp-reco-interaction]"),_=v.closest("a[href]"),L=_&&(S.contains(_)||_.contains(S));if(!(y&&S.contains(y))&&!L)return;let R=x(S);if(!R)return;let H=g(o,R);if(!H)return;let K=g(s,S,w(R).indexOf(S));if(!K?.product_id)return;let B=H.recommendation_request_id;d.has(B)||(clearTimeout(p.get(B)),b(R,H)),e.productClicked({recommendation_request_id:H.recommendation_request_id,interaction:N(y??S,"hpRecoInteraction")??"navigate",products:[K]})};return document.addEventListener("click",E,!0),()=>{document.removeEventListener("click",E,!0);for(let h of p.values())clearTimeout(h);p.clear(),k()}}var pe=new Set(["home","list","product","search","basket","checkout","order_confirmation","login","register","account","info","blog","other"]),Ur=new Set(["products"]),Xt=e=>e==null;function ot(e,t=new WeakSet){if(e instanceof Date)return e.toJSON();if(e===null||typeof e!="object"||t.has(e))return e;t.add(e);let n=Array.isArray(e)?e.map(r=>ot(r,t)):Object.fromEntries(Object.entries(e).filter(([,r])=>!Xt(r)).map(([r,o])=>[r,ot(o,t)]));return t.delete(e),n}function st(e){if(!e)return e;let t=ot(e);for(let n of Ur)n in e&&Xt(e[n])&&(t[n]=e[n]);return t}function Zt(){try{let e=performance.getEntriesByType("navigation")[0];return e?["navigate","reload","back_forward","prerender"].includes(e.type)?e.type:"navigate":null}catch{return null}}var Vr=new Set(["","unknown","undefined","null","none","nil","nan","anonymous","guest","0","-1"]);function q(e){if(e==null)return null;let t=String(e).trim();return Vr.has(t.toLowerCase())?null:t}function Z(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Qt="1.16";function M(e){if(typeof document>"u")return null;try{let t=document.cookie.split(";").map(n=>n.trim()).find(n=>n.startsWith(`${e}=`));return t&&decodeURIComponent(t.slice(e.length+1))||null}catch{return null}}var Br={gclid:"gclid",fbclid:"fbclid",ttclid:"ttclid"},jr=/[a-z0-9._%+-]+@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}/i,qr=/\d(?:[ -]?\d){12,}/,Fr=new Set(["gclid","fbclid","ttclid","msclkid"]);function tn(e,t=""){if(typeof e!="string"||e==="")return!1;let n=[e];try{let o=decodeURIComponent(e.replace(/\+/g," "));o!==e&&n.push(o)}catch{}let r=!Fr.has(String(t).toLowerCase());return n.some(o=>jr.test(o)||r&&qr.test(o))}function Hr(e){if(!e)return null;let t=new URLSearchParams(e),n={},r={utm_source:"source",utm_medium:"medium",utm_campaign:"name",utm_term:"term",utm_content:"content"};for(let[o,s]of[...Object.entries(r),...Object.entries(Br)]){let i=t.get(o);i&&!tn(i,o)&&(n[s]=i)}return Object.keys(n).length?n:null}var Kr=["email","e-mail","password","pass","pwd","token","auth","code","uid","customer_id","postcode","zip","phone","applyCode"],Gr=["email","password","passwd","pwd","token","secret","auth","session","phone","postcode","zip","address","birth","card","cvv","iban","ssn","customerid","userid"],zr=["tel","uid","dob"],Wr=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","gclid","fbclid","ttclid","msclkid"],Jr=new Set(Kr.map(e=>e.toLowerCase()));function Yr(e){let t=String(e).toLowerCase();if(Jr.has(t))return!0;let n=t.replace(/[-_.]/g,"");return Gr.some(o=>n.includes(o))?!0:String(e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(o=>zr.includes(o))}function it(e){return(e??[]).map(t=>{try{return new RegExp(`^${t}$`,"i")}catch{return{test:n=>n.toLowerCase()===String(t).toLowerCase()}}})}function nn(e,t={}){if(!e)return null;try{let n=new URLSearchParams(e),r=t.queryParamAllowlist?it([...t.queryParamAllowlist,...Wr]):null,o=it(t.queryParamBlocklist),s=it(t.sensitiveParamAllowlist);for(let a of new Set(n.keys()))(Yr(a)&&!s.some(d=>d.test(a))||n.getAll(a).some(d=>tn(d,a))||(r?!r.some(d=>d.test(a)):o.some(d=>d.test(a))))&&n.delete(a);let i=n.toString();return i?`?${i}`:""}catch{return""}}function rn(e,t,n={}){if(!e)return null;try{let r=new URL(e);return t&&r.origin===t?r.origin+r.pathname+(nn(r.search,n)??""):r.origin+r.pathname}catch{return null}}function on(e,t={}){if(typeof e!="string"||typeof location>"u")return null;try{let n=new URL(e,location.href);return n.protocol!=="https:"&&n.protocol!=="http:"?null:rn(n.href,location.origin,t)}catch{return null}}function at(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function en(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{2}$/.test(t)?t:null}function Xr(e){if(typeof e!="string")return null;let t=e.trim().replace(/_/g,"-");if(!/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(t))return null;try{return Intl.getCanonicalLocales(t)[0]}catch{return null}}function D(e,t){if(typeof e=="function")try{let n=e();if(n!=null)return n}catch{}return t}function Zr(e){return{property_id:String(e.propertyId),channel:e.channel??null,market:e.market??null,environment:e.environment??null}}function Qr(e){let t=typeof window<"u"?window.location:null,n=t?nn(t.search,e):null;return{url:t?t.origin+t.pathname+(n??""):e.pageUrl??null,path:t?t.pathname:e.pagePath??null,search:n??null,referrer:typeof document<"u"?rn(document.referrer,t?.origin,e):null,title:typeof document<"u"&&document.title||null,type:e.pageType??null}}function sn(e,t={}){let n=typeof window<"u"?window.location:null,r={library:{name:e.libraryName,version:e.libraryVersion},spec:{version:Qt},source:Zr(e),session_id:D(e.getSessionId,null),identity_trust:q(D(e.getAnonymousId,null))?"device":"none",page:Qr(e),campaign:n?Hr(n.search):null,device:{user_agent:typeof navigator<"u"?navigator.userAgent:null,type:null,viewport_width:typeof window<"u"?window.innerWidth:null,viewport_height:typeof window<"u"?window.innerHeight:null},currency:at(D(e.getCurrency,e.currency)),locale:Xr(D(e.getLocale,e.locale)),timezone:(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return null}})(),country:en(e.country),ship_to_country:en(D(e.getShipToCountry,e.shipToCountry)),ip:null,bot:null,consent:e.getConsent?.()??null,experiments:D(e.getExperiments,null),audiences:D(e.getAudiences,null),decisions:D(e.getDecisions,null),recommendations:D(e.getRecommendations,null),extensions:D(e.getExtensions,null)};return an(r,t)}function an(e,t){if(!t)return e;let n={...e};for(let[r,o]of Object.entries(t))o&&typeof o=="object"&&!Array.isArray(o)&&e[r]&&typeof e[r]=="object"&&!Array.isArray(e[r])?n[r]=an(e[r],o):o!==void 0&&(n[r]=o);return n}var ie=Object.freeze({consent:"thg_hp_consent",retry:"thg_hp_retry",sessionSignals:"thg_hp_session_signals",identified:"thg_hp_identified",previousPage:"thg_hp_prev_page",decisions:"thg_hp_decisions",settings:"thg_hp_settings",held:"thg_hp_held",carried:"thg_hp_carried",recommendationContext:"thg_hp_recommendation_context",anonymousId:"thg_hp_anonymous_id",session:"thg_hp_session",preview:"thg_hp_preview",debug:"thg_hp_debug"}),eo={retry:"cdp.retry",sessionSignals:"cdp_session_signals",identified:"cdp_identified",previousPage:"cdp_prev_page_message_id"},ct={...ie},cn=!1;function Te(e){let t={...ie};for(let[n,r]of Object.entries(e??{})){if(!(n in ie))throw new Error(`storageNames: unknown kind "${n}"`);if(typeof r!="string"||!/^[\w.-]+$/.test(r))throw new Error(`storageNames.${n} must be a non-empty cookie-safe name`);t[n]=r}ct=t}function T(e){return ct[e]}var to="_",un=e=>e==null||e===""?to:String(e);function F(e,t,n){let r=`${e}:${un(t)}`;return n==null||n===""?r:`${r}:${n}`}function ln(e,t){return`${e}:${un(t)}:`}function Ne(){if(!cn){cn=!0;for(let e of[()=>localStorage,()=>sessionStorage]){let t;try{if(t=e(),!t)continue;for(let n of Object.keys(t))for(let[r,o]of Object.entries(eo)){if(n!==o&&!n.startsWith(`${o}:`))continue;let s=ct[r]+n.slice(o.length);t.getItem(s)===null&&t.setItem(s,t.getItem(n)),t.removeItem(n)}}catch{}}}}var lt=1800*1e3,Re=()=>{try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}},ut=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}};function dn(e,t=()=>Date.now()){return{read(){try{let n=Re()?.getItem(e),r=n?JSON.parse(n):null;return!r||t()-r.savedAt>lt?(r&&Re()?.removeItem(e),{items:[],anonymousId:null}):{items:Array.isArray(r.items)?r.items:[],anonymousId:typeof r.anonymousId=="string"?r.anonymousId:null}}catch{return{items:[],anonymousId:null}}},write(n,r=null){try{n.length===0?Re()?.removeItem(e):Re()?.setItem(e,JSON.stringify({savedAt:t(),items:n,anonymousId:r}))}catch{}}}}var no=400*24*60*60;function Q(e,t,n,r){if(typeof document>"u")return!1;try{let o=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",s=r?`; Domain=${r}`:"",i=n===null?"":`; Max-Age=${n}`;return document.cookie=`${e}=${encodeURIComponent(t)}; Path=/${i}; SameSite=Lax`+s+o,!0}catch{return!1}}function ro({name:e,domain:t=null,legacyKey:n,read:r,mint:o,mayStore:s,carried:i=null}){let a=null;try{a=ut()?.getItem(n)||null}catch{a=null}let u=r(e)??a??i,d=!1,f=()=>{if(!(d||u===null||!s())&&(d=Q(e,u,no,t),!(!d||a===null)))try{ut()?.removeItem(n),a=null}catch{}};return{get(){return u??(u=o()),f(),u},peek:()=>u,persist:f,forget(){Q(e,"",0,t),u=null,d=!1;try{ut()?.removeItem(n)}catch{}a=null}}}function fn(e,{carried:t=null,mayStore:n,orOwn:r=!1}){let o=e.anonymousIdSource,s=()=>ro({name:T("anonymousId"),domain:e.consentCookieDomain??null,legacyKey:F(T("anonymousId"),e.propertyId),read:M,mint:Z,mayStore:n,carried:t});if(o?.source==="hp_cookie"){let u=s();return e.getAnonymousId=()=>u.get(),u}if(o?.source==="site_cookie"&&o.cookie){let u=o.cookie;e.getAnonymousId=()=>M(u)}if(!r)return null;let i=e.getAnonymousId,a=s();return e.getAnonymousId=()=>q(D(i,null))??a.get(),a}var oo=200;function pn(e,t,n=()=>Date.now()){let r=()=>F(T("carried"),e),o=!1;function s(){try{let i=JSON.parse(sessionStorage.getItem(r())??"null");return!i||!(n()-i.savedAt<=lt)?[]:Array.isArray(i.calls)?i.calls:[]}catch{return[]}}return{take(){let i=s();try{sessionStorage.removeItem(r())}catch{}return i},save(i){try{return o||!t()?!1:(sessionStorage.setItem(r(),JSON.stringify({savedAt:n(),calls:[...s(),...i].slice(-oo)})),!0)}catch{return!1}},close(){o=!0}}}var wi=ie.consent,De=Object.freeze({visitor:"visitor",host:"host"}),mn=()=>({basis:De.host}),so="hp-consent",ae=["analytics","marketing","personalisation","ad_user_data","ad_personalization"],hn={analytics:"a",marketing:"m",personalisation:"p",ad_user_data:"aud",ad_personalization:"adp"},Y=()=>typeof window<"u",gn=()=>Y()&&typeof window.cookieStore?.addEventListener=="function",io=e=>e===!0?!0:e===!1?!1:null;function me(e){if(!e||typeof e!="object")return null;let t={};for(let n of ae)t[n]=io(e[n]);return t}function ft(e,t){return!e||!t?e===t:ae.every(n=>e[n]===t[n])}function pt(e){if(!e)return"";let t=[];for(let n of ae){let r=e[n];(r===!0||r===!1)&&t.push(`${hn[n]}=${r?1:0}`)}return t.join("&")}function yn(e){return{[so]:pt(me(e))}}function _e(e){let t=me({});if(e==null)return t;let n=String(e).trim();if(n.length>=2&&n.startsWith('"')&&n.endsWith('"')&&(n=n.slice(1,-1)),n.includes("%"))try{n=decodeURIComponent(n.replace(/\+/g," "))}catch{return t}let r=Object.fromEntries(Object.entries(hn).map(([s,i])=>[i,s])),o=new Set;for(let s of n.split("&")){let i=s.indexOf("=");if(i<=0)continue;let a=r[s.slice(0,i).trim()],u={1:!0,0:!1}[s.slice(i+1).trim()]??null;!a||u===null||o.has(a)||(t[a]===null?t[a]=u:t[a]!==u&&(t[a]=null,o.add(a)))}return t}function mt(e,t){if(!t)return e;let n=r=>{if(!r)return r;let o={...r};for(let s of ae)s!=="analytics"&&t[s]!==!0&&(o[s]=null);return o};return{name:e.name,basis:e.basis,read:()=>n(e.read()),subscribe:r=>e.subscribe(o=>r(n(o))),get observesChanges(){return e.observesChanges}}}function ht(e,t={}){return{...e,ad_user_data:t.ad_user_data??e.marketing,ad_personalization:t.ad_personalization??e.marketing}}function Me(e,t){let n=!0;return{notify:()=>{if(n)try{let o=e();o&&t(o)}catch{}},stop:()=>n=!1}}var ao={analytics:["analytics","measure_content_performance","audience_measurement"],marketing:["marketing","targeting","advertising","select_personalized_ads","create_ads_profile"],personalisation:["personalisation","personalization","select_personalized_content","create_content_profile"]};function co(e,t){if(!t?.length)return null;let n=!1;for(let[r,o]of Object.entries(e)){let s=String(o?.id??r).toLowerCase();if(t.some(a=>{let u=String(a).toLowerCase();return s===u||s.startsWith(`${u}-`)})&&(n=!0,o?.enabled===!0))return!0}return n?!1:null}function wn(e={}){let t={...ao,...e.purposes};function n(){let r=Y()?window.Didomi:void 0;if(!r?.getCurrentUserStatus||r.shouldUserStatusBeCollected?.()!==!1||r.isUserStatusPartial?.()===!0)return null;let o=r.getCurrentUserStatus()?.purposes;if(!o||typeof o!="object")return null;let s=i=>co(o,t[i]);return ht({analytics:s("analytics"),marketing:s("marketing"),personalisation:s("personalisation")},{ad_user_data:s("ad_user_data"),ad_personalization:s("ad_personalization")})}return{name:"didomi",read:n,observesChanges:!0,subscribe(r){if(!Y())return()=>{};let o=Me(n,r),s={event:"consent.changed",listener:o.notify};return window.didomiEventListeners=window.didomiEventListeners||[],window.didomiEventListeners.push(s),window.didomiOnReady=window.didomiOnReady||[],window.didomiOnReady.push(i=>{o.notify(),(i??window.Didomi)?.on?.("consent.changed",o.notify)}),window.Didomi?.on?.("consent.changed",o.notify),o.stop}}}function dt(e){let t={};if(!e)return t;for(let n of String(e).split("&")){let r=n.indexOf("=");if(r<=0)continue;let o=n.slice(r+1).replace(/\+/g," ");try{o=decodeURIComponent(o)}catch{}t[n.slice(0,r)]=o}return t}function Sn(e={}){let t={analytics:"C0002",personalisation:"C0003",marketing:"C0004",...e.groups},n=e.impliedConsent===!0;function r(){let i=dt(M("OptanonConsent"));if(i.groups){let d={};for(let f of i.groups.split(",")){let[p,g]=f.split(":");p?.trim()&&(d[p.trim()]=g==="1"?!0:g==="0"?!1:null)}return f=>d[f]??!1}let a=Y()?window.OnetrustActiveGroups:void 0;if(typeof a!="string"||!a.length)return null;let u=new Set(a.split(",").map(d=>d.trim()).filter(Boolean));return d=>u.has(d)}function o(){if(M("OptanonAlertBoxClosed"))return!0;try{if(Y()&&window.OneTrust?.IsAlertBoxClosed?.()===!0)return!0}catch{}return Number.parseInt(dt(M("OptanonConsent")).interactionCount,10)>0?!0:n&&Y()&&(!!window.OneTrust||typeof window.OnetrustActiveGroups=="string")}function s(){if(!o())return null;let i=r();if(!i)return null;let a=p=>t[p]?i(t[p]):null,u=ht({analytics:a("analytics"),marketing:a("marketing"),personalisation:a("personalisation")},{ad_user_data:a("ad_user_data"),ad_personalization:a("ad_personalization")}),d=dt(M("OptanonConsent"));return(typeof navigator<"u"&&navigator.globalPrivacyControl===!0||d.isGpcEnabled==="1")&&(u.marketing=!1,u.ad_user_data=!1,u.ad_personalization=!1),u}return{name:"onetrust",read:s,observesChanges:!0,subscribe(i){if(!Y())return()=>{};let a=Me(s,i),u=!1,d=()=>{u||!window.OneTrust?.OnConsentChanged||(u=!0,window.OneTrust.OnConsentChanged(a.notify))};window.addEventListener("OneTrustGroupsUpdated",a.notify);let f=window.OptanonWrapper;return window.OptanonWrapper=function(...g){try{typeof f=="function"&&f.apply(this,g)}finally{d(),a.notify()}},d(),()=>{a.stop(),window.removeEventListener("OneTrustGroupsUpdated",a.notify)}}}}function uo(e){let t=String(e).split(",").map(n=>n.trim()).filter(Boolean);return t.length?new Set(t):null}function _n(e){let{name:t,categories:n,parse:r=uo,refusedValue:o,source:s="native",changeEvent:i="thg_hp_consent_change"}=e??{};if(typeof t!="string"||t==="")throw new Error("cookieConsent: `name` (the cookie your banner writes) is required");if(!n||typeof n.analytics!="string")throw new Error("cookieConsent: `categories.analytics` (the category id that grants analytics) is required");function a(){let u=M(t);if(u==null)return null;let d;if(o!==void 0&&u===o)d=new Set;else try{d=r(u)}catch{d=null}if(!(d instanceof Set))return null;let f=p=>n[p]?d.has(n[p]):null;return ht({analytics:f("analytics"),marketing:f("marketing"),personalisation:f("personalisation")},{ad_user_data:f("ad_user_data"),ad_personalization:f("ad_personalization")})}return{name:s,read:a,get observesChanges(){return gn()},subscribe(u){if(!Y())return()=>{};let d=Me(a,u),f=p=>{[...p.changed??[],...p.deleted??[]].some(x=>x?.name===t)&&d.notify()};return window.addEventListener(i,d.notify),window.cookieStore?.addEventListener?.("change",f),()=>{d.stop(),window.removeEventListener(i,d.notify),window.cookieStore?.removeEventListener?.("change",f)}}}}function bn(e={}){let t=e.name??T("consent"),n=()=>{let r=M(t);if(r==null)return null;let o=_e(r);return o.analytics==null?null:o};return{name:"forwarded",read:n,get observesChanges(){return gn()},subscribe(r){if(!Y())return()=>{};let o=Me(n,r),s=i=>{[...i.changed??[],...i.deleted??[]].some(u=>u?.name===t)&&o.notify()};return window.cookieStore?.addEventListener?.("change",s),()=>{o.stop(),window.cookieStore?.removeEventListener?.("change",s)}}}}function xn(e){let t=me(e);return{name:"static",basis:De.host,read:()=>t?{...t}:null,observesChanges:!0,subscribe:()=>()=>{}}}function In(e){if(e==null)return null;let t=String(e).split("/").map(n=>n.trim()).filter(Boolean).join("/");return t===""?null:t}function lo(e){let t=e.item_category;if(t!=null&&String(t).includes("/"))return In(t);let n=[t,e.item_category2,e.item_category3,e.item_category4,e.item_category5].map(r=>r==null?"":String(r).trim()).filter(Boolean);return In(n.join("/"))}var fo=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t};function po(...e){for(let t of e){if(typeof t=="number"&&Number.isFinite(t))return String(t);if(typeof t=="string"&&t.trim()!=="")return t.trim()}return null}var $e=e=>po(e.item_group_id,e.item_id);function mo(e,t=$e){if(!e)return null;let n=a=>a==null||a===""||Number.isNaN(Number(a))?null:Number(a),r=a=>{let u=n(a);return u==null?null:Math.round(u*1e6)/1e6},o=a=>{let u=r(a);return u!=null&&u>=0?u:null},s=a=>{let u=n(a);return Number.isInteger(u)&&u>=0?u:null},i=fo;return{product_id:i(t(e)),sku:i(e.item_id),name:i(e.item_name),brand:i(e.item_brand),variant:i(e.item_variant)??i(e.variant),category:lo(e),price:r(e.price),discount:o(e.discount),quantity:s(e.quantity),coupon:i(e.coupon),position:s(e.index)!=null?s(e.index)+1:null,url:i(e.url)??i(e.item_url)??null,image_url:i(e.image_url)??i(e.image_link)??null,displayed_sku:i(e.displayed_sku)??i(e.displayed_variant_sku)}}function gt(e,t=$e){return(e??[]).map(n=>mo(n,t)).filter(n=>n?.product_id)}var ho=1e3,go={shipping:2,payment:3},yo=new Set(["password","google","apple","facebook","magic_link","sso","passkey","other"]),$=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t},wo=e=>{if(e==null||e===""||typeof e=="object")return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null},Ue=e=>e!==null&&typeof e=="object";function So(e){return Array.isArray(e.items)?e.items.filter(Ue):null}function kn(e){let t=$(e)?.toLowerCase().replace(/[\s-]+/g,"_");return t?yo.has(t)?t:t==="email"||t==="email_password"?"password":"other":null}function _o({ecommerce:e,items:t}){let n=s=>({promotion_id:$(s.promotion_id),name:$(s.promotion_name),creative:$(s.creative_name),position:$(s.creative_slot)}),r=new Set,o=[];for(let s of[n(e),...t.map(n)])!s.promotion_id||r.has(s.promotion_id)||(r.add(s.promotion_id),o.push(s));return o}var An=({ecommerce:e,items:t})=>$(e.item_list_id)??$(e.item_list_name)??$(t[0]?.item_list_id)??$(t[0]?.item_list_name),ce=(e,t)=>t.products?.length?{event:e,properties:t}:null,bo=new Set(["product","products","item","items"]);function xo({ecommerce:e}){let t=$(e.item_id),n=$(e.content_type)?.toLowerCase();return!t||n&&!bo.has(n)?null:{event:"Product Shared",properties:{share_via:$(e.method),products:[{product_id:t}]}}}function Io(e){let t=o=>ce("Product List Viewed",{list_id:An(o),products:o.products}),n=o=>{let s=$(o.ecommerce.search_term);return s?{event:"Products Searched",properties:{query:s,...o.products.length?{products:o.products}:{}}}:null},r=o=>s=>s.promotions.map(i=>({event:o,properties:i}));return{view_item:o=>ce("Product Viewed",{currency:o.currency,value:o.value,products:o.products.slice(0,1)}),view_item_list:t,view_search_results:o=>n(o)??t(o),search:n,select_item:o=>ce("Product Clicked",{list_id:An(o),products:o.products.slice(0,1)}),add_to_cart:o=>ce("Product Added",{cart_id:$(o.ecommerce.cart_id),products:o.products}),remove_from_cart:o=>ce("Product Removed",{cart_id:$(o.ecommerce.cart_id),products:o.products}),view_cart:o=>({event:"Cart Viewed",properties:{cart_id:$(o.ecommerce.cart_id),value:o.value,currency:o.currency,coupon:$(o.ecommerce.coupon),...o.itemsListed?{products:o.products}:{}}}),begin_checkout:o=>ce("Checkout Started",{value:o.value,currency:o.currency,coupon:$(o.ecommerce.coupon),products:o.products}),add_shipping_info:o=>({event:"Checkout Step Completed",properties:{step:e.shipping,step_name:"shipping",shipping_method:$(o.ecommerce.shipping_tier)}}),add_payment_info:o=>({event:"Payment Info Entered",properties:{step:e.payment,step_name:"payment",payment_method:$(o.ecommerce.payment_type)}}),view_promotion:r("Promotion Viewed"),select_promotion:r("Promotion Clicked"),add_to_wishlist:o=>ce("Product Added to Wishlist",{products:o.products}),share:xo,login:o=>({event:"Signed In",properties:{method:kn(o.ecommerce.method)}}),sign_up:o=>({event:"Signed Up",properties:{method:kn(o.ecommerce.method)}})}}var ko=e=>e.event;function Ao(e,t){if(!Ue(e))return null;if(typeof e.length=="number"&&e[0]==="event"&&typeof e[1]=="string"){let r=Ue(e[2])?e[2]:{};return{name:e[1],entry:r,ecommerce:r}}let n=$(t(e));return n?{name:n,entry:e,ecommerce:Ue(e.ecommerce)?e.ecommerce:e}:null}function yt(e){return Array.isArray(e)?`[${e.map(yt).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${yt(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function En(e,t={}){if(!e||typeof e.track!="function")throw new Error("connectDataLayer: analytics must have a track(event, properties, options) method");let n=t.dataLayer??(typeof window<"u"?window.dataLayer=window.dataLayer||[]:null);if(!Array.isArray(n))return()=>{};let r=Io({...go,...t.steps}),o=t.map??{},s=t.eventName??ko,i=t.productId??$e,a=new Set(["purchase","refund",...t.ignore??[]]),u=t.dedupeMs??ho,d=new Map,f=!0;function p(S,y,_){if(u<=0)return!1;let L=`${S}|${_??""}|${yt(y)}`,R=Date.now();for(let[H,K]of d)R-K>u&&d.delete(H);return d.has(L)?!0:(d.set(L,R),!1)}let g=null,x=new Set;function w(S,y){if(S!=="Product Viewed")return!1;let _=typeof location>"u"?"":location.pathname;_!==g&&(g=_,x.clear());let L=y.products?.[0]?.product_id;return L?x.has(L)?!0:(x.add(L),!1):!1}function b({event:S,properties:y={}},_){if(!S||p(S,y,_)||w(S,y))return;let L=_?{context:{currency:_}}:void 0;if(S==="Signed Out"&&typeof e.signedOut=="function"){e.signedOut(L);return}e.track(S,y,L)}function k(S){let y=t.transform?t.transform(S):S,_=Ao(y,s);if(!_||a.has(_.name))return;let L=Object.hasOwn(o,_.name),R=L?o[_.name]:r[_.name];if(typeof R!="function")return;let H=So(_.ecommerce),K=H??[],B={..._,items:K,itemsListed:H!==null,products:gt(K,i),currency:at(_.ecommerce.currency),value:wo(_.ecommerce.value)};B.promotions=_o(B);let te=L?R(y,{...B,toProducts:z=>gt(z,i)}):R(B);for(let z of[te].flat())z&&b(z,B.currency)}function E(S){if(f)try{k(S)}catch(y){try{t.onError?.(y,S)}catch{}}}for(let S of n.slice())E(S);let h=n.push;function v(...S){let y=h.apply(this,S);for(let _ of S)E(_);return y}return n.push=v,()=>{f=!1,n.push===v&&(n.push=h)}}var Eo="hp_debug",vo=256;function Co(){try{return new URLSearchParams(location.search).get(Eo)}catch{return null}}function vn(e,t){if(typeof location>"u")return!1;try{let n=Co();if(n!==null){let o=n.trim();o===""||o.length>vo?sessionStorage.removeItem(t):sessionStorage.setItem(t,o)}let r=sessionStorage.getItem(t);return!!(e&&r&&Kt(r)===e)}catch{return!1}}var he=class extends Error{},Po={inHoldout:()=>!0,personalisationGroup:()=>"excluded",servingHeaders:()=>({}),recommendationContext:()=>({}),flush:()=>Promise.resolve(),reset:()=>{}};function wt(e,t){let n=Po[e]??(()=>null),r=o=>(console.warn(`[hp] ${String(e)} failed; nothing was sent`,o),n());return function(...s){try{let i=t.apply(this,s);return typeof i?.then=="function"?Promise.resolve(i).catch(r):i}catch(i){if(i instanceof he)throw i;return r(i)}}}function Cn(e){for(let t of Reflect.ownKeys(e)){let{value:n}=Object.getOwnPropertyDescriptor(e,t)??{};typeof n=="function"&&(e[t]=wt(t,n))}return e}var be=Symbol("hp.identityOption");var Oo=4320*60*60,Lo=100,To=1e3,No=2e3,Pn=500,Ve=e=>(e?.unref?.(),e);function Ro(e,t){if(t?.analytics===!0&&e.analytics===!1)return"withdrawn";let n=ae.map(r=>e[r]).filter(r=>r!==null);return n.length&&n.every(Boolean)?"accept_all":n.length&&n.every(r=>!r)?"reject_all":"custom"}function Do(e,t,n=T("consent")){if(!(typeof document>"u"))try{let r=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",o=t?`; Domain=${t}`:"";document.cookie=`${n}=${pt(e)}; Path=/; Max-Age=${Oo}; SameSite=Lax`+o+r}catch{}}function Mo(e){let t=_e(M(e));return ae.some(n=>t[n]!==null)?t:null}function On(e){let{adapter:t,timeoutMs:n=5e3,cookieDomain:r=null,cookieName:o=T("consent"),release:s,announce:i}=e,a=e.discard??(()=>{}),u="pending",d=null,f=null,p=null,g=null,x=!1,w=null,b=[],k=m=>{u=m,e.onStatus?.(m)};function E(){try{return me(t.read())}catch{return null}}function h(){f&&clearInterval(f),p&&clearTimeout(p),f=null,p=null}let v=()=>typeof window<"u"&&typeof document<"u",S=()=>{try{return typeof t.subscribe=="function"&&t.observesChanges===!0}catch{return!1}};function y(){g&&clearInterval(g),g=null}function _(){x||g||d===null||S()||v()&&document.visibilityState==="hidden"||(g=Ve(setInterval(()=>B(E()),No)))}let L=()=>u==="pending"||u==="unknown",R=e.store??null,H=()=>{let m=b.splice(0);R?.write([]);for(let j of m)s(j)},K=()=>{let m=b.splice(0);R?.write([]);for(let j of m)a(j)};function B(m){let j=me(m);if(!j||j.analytics===null)return;let ve=d===null,J=ve?Mo(o):d;if(!ve&&ft(J,j))return;h(),d=j,_(),Do(j,r,o);let Ce=!ft(J,j);if(j.analytics){k("granted"),H(),Ce&&i({action:Ro(j,J),state:j,previous:J,withdrawal:!1});return}K(),J?.analytics===!0&&i({action:"withdrawn",state:j,previous:J,withdrawal:!0}),k("denied")}function te(){p=null,u==="pending"&&(k("unknown"),f&&clearInterval(f),f=Ve(setInterval(()=>B(E()),To)))}function z(m){L()&&(R||m?.type!=="visibilitychange"&&!m?.persisted&&K())}let ne=m=>{document.visibilityState==="hidden"?(y(),z(m)):_()},de=m=>{y(),z(m)},Ee=m=>{m?.persisted&&d!==null&&B(E()),_()};return{get status(){return u},get state(){return d?{...d}:null},stamp(){return d?{...d,source:t.name??null,basis:t.basis??De.visitor}:null},admits(){return u==="granted"},hold(m){return!L()||b.length>=Pn?(a(m),!1):(b.push(m),R?.write(b),!0)},onHidden:z,start(){x=!1;try{w=t.subscribe?.(m=>B(m))??null}catch(m){e.debug&&console.warn("[hp] consent adapter subscribe failed",m)}v()&&(window.addEventListener("pagehide",de),window.addEventListener("pageshow",Ee),document.addEventListener("visibilitychange",ne)),R&&b.length===0&&b.push(...R.read().slice(-Pn)),B(E()),!d&&(f=Ve(setInterval(()=>B(E()),Lo)),p=Ve(setTimeout(te,n)))},stop(){x=!0,h(),y(),typeof w=="function"&&w(),v()&&(window.removeEventListener("pagehide",de),window.removeEventListener("pageshow",Ee),document.removeEventListener("visibilitychange",ne))}}}var $o=["recommendation","search_rank","banner","offer","layout","copy","price","other"],Be=e=>typeof e=="string"&&e!=="";function Ln(e){return(Array.isArray(e?.decisions)?e.decisions:[]).filter(t=>Be(t?.slot)&&Be(t.decision_id)&&t.holdout!==!0).map(({decision_id:t,slot:n,arm:r,kind:o})=>({decision_id:t,slot:n,...Be(r)&&{arm:r},...$o.includes(o)&&{kind:o}}))}function Tn({key:e,mayStore:t}){let n,r=()=>{if(n)return n;try{let s=JSON.parse(sessionStorage.getItem(e));n=Array.isArray(s)?s.filter(i=>Be(i?.slot)):[]}catch{n=[]}return n},o=()=>{try{n?.length&&t()&&sessionStorage.setItem(e,JSON.stringify(n))}catch{}};return{persist:o,current:()=>r().length?n.map(s=>({...s})):null,remember(s){if(!s.length)return;let i=new Set(s.map(a=>a.slot));n=[...r().filter(a=>!i.has(a.slot)),...s],o()},forget(){n=[];try{sessionStorage.removeItem(e)}catch{}}}}function Uo(e){let t=2166136261,n=String(e);for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t^=t>>>16,t=Math.imul(t,2246822507)>>>0,t^=t>>>13,t=Math.imul(t,3266489909)>>>0,t^=t>>>16,t>>>0}function je(e,t,n=1e4){return Uo(`${t}\0${e}`)%n}function St(e){let t=o=>Math.min(Math.max(Number(o)||0,0),1),n=t(e.share),r=1-n;return{holdout_share:n,personalised_share:e.ramp==null?r:Math.min(t(e.ramp),r)}}function _t(e,t){if(!e||typeof e.salt!="string")return{holdout:!1,bucket:null,group:"personalised"};let n=e.ramp!=null;if(t==null||t==="")return{holdout:!1,bucket:null,group:n?"excluded":"personalised"};let{holdout_share:r,personalised_share:o}=St(e),s=je(t,e.salt),i=u=>Math.round(u*1e4),a=r>0&&s<i(r)?"holdout":!n||s<i(r+o)?"personalised":"excluded";return{holdout:a==="holdout",bucket:s,group:a}}function Nn(e,t){return typeof e!="string"||e===""||t==null||t===""?null:je(t,`bandit-vs-default:${e}`)<1e4/2?"default":"bandit"}var Vo="hp_preview",Bo=256;function Rn(e,t=null){if(typeof location>"u")return M(e);let n=null;try{n=new URLSearchParams(location.search).get(Vo)}catch{n=null}if(n===null)return M(e);let r=n.trim();return r===""||r.length>Bo?(Q(e,"",0,t),null):(Q(e,r,null,t),r)}var jo=40,qo=128,Fo=5,Ho=60,Mn=e=>typeof e=="string"&&e!==""&&e.length<=qo&&!e.includes(","),Dn=e=>Array.isArray(e)?e.filter(Mn).slice(0,jo):[],Ko=e=>Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.replaceAll(","," ").trim()).filter(t=>t!=="").slice(0,Fo):[],Go=e=>Object.entries(e&&typeof e=="object"?e:{}).filter(([t,n])=>Mn(t)&&Number.isFinite(n)&&n>=1).sort(([,t],[,n])=>n-t).slice(0,Ho).map(([t,n])=>`${t}:${Math.floor(n)}`);function bt(e){let t={},n={viewed:Dn(e?.recentProducts),basket:Dn(e?.basketProducts),q:Ko(e?.recentSearches),impressed:Go(e?.impressions)};for(let[r,o]of Object.entries(n))o.length>0&&(t[r]=o.join(","));return t}var zo=1800*1e3;function $n(e,t=Date.now()){try{localStorage.setItem(T("recommendationContext"),JSON.stringify({context:e,until:t+zo}))}catch{}}function Un(){try{localStorage.removeItem(T("recommendationContext"))}catch{}}var Wo="hp_sample",Vn=1e4;function Bn(e,t){return!(typeof t=="number"&&t<1)||e==null||e===""?!0:je(e,Wo,Vn)<Math.round(t*Vn)}function ge(e){return e.trim().toLowerCase().replace(/\s*\/\s*/g,"/").replace(/^\/+|\/+$/g,"")}var Jo=2,Yo=12;function xe(e,t=Jo){return e.split("/").slice(0,t).join("/")}function xt(e,t){if(typeof t!="string"||!t.trim())return null;let n=xe(ge(t));return n?(e.unshift(n),e.length=Math.min(e.length,Yo),n):null}var ue=()=>T("sessionSignals"),ye=null,It=()=>ye??ue();function jn(){try{return ye?localStorage:sessionStorage}catch{return}}function qn(e,t){let n=t==null?null:String(t),r=e?F(ue(),n,e):null;if(r===ye)return;let o=ye===null?Xo():null;if(ye=r,!!ye)try{let s=It(),i=ln(ue(),n);for(let a of Object.keys(localStorage))a.startsWith(i)&&a!==s&&localStorage.removeItem(a);o&&!localStorage.getItem(s)&&(localStorage.setItem(s,JSON.stringify(o)),sessionStorage.removeItem(ue()))}catch{}}function Xo(){try{let e=sessionStorage.getItem(ue());if(!e)return null;let t=JSON.parse(e);return t&&(t.productViews>0||t.listViews>0||t.basketValue!=null||t.recentProducts?.length||t.recentBrowse?.length)?t:null}catch{return null}}function qe(){return{productViews:0,listViews:0,cartAdds:0,searches:0,recentProducts:[],recentCategories:[],recentBrowse:[],basketProducts:[],basketValue:null,recentSearches:[],impressions:{},browsingCategory:null,recentBrowseCategories:[],browsingListing:null,listViewsByCategory:{},startedAt:0}}function kt(){let e=jn();if(!e)return qe();try{let t=e.getItem(It());return t?{...qe(),...JSON.parse(t)}:{...qe(),startedAt:Date.now()}}catch{return{...qe(),startedAt:Date.now()}}}function At(e){let t=jn();if(t)try{t.setItem(It(),JSON.stringify(e))}catch{}}function Fn(){return kt()}function Hn(){for(let e of[()=>sessionStorage,()=>localStorage])try{let t=e();t.removeItem(ue());for(let n of Object.keys(t))n.startsWith(`${ue()}:`)&&t.removeItem(n)}catch{}}var Kn=20,Gn=200,Zo=new Set(["Product Viewed","Product Clicked","Product Added","Product Added to Wishlist"]),Qo=new Set(["Product Viewed","Product Added"]),zn=50;function Fe(e,t){let n=xt(e.recentBrowse,t);return n?(e.recentBrowseCategories=[e.browsingListing?.category??null,...e.recentBrowseCategories].slice(0,e.recentBrowse.length),n):null}function es(e,t){let n=e.listViewsByCategory;n[t]=(n[t]??0)+1;let r=Object.keys(n);if(r.length>zn){let o={};for(let s of r.sort((i,a)=>n[a]-n[i]).slice(0,zn))o[s]=n[s];e.listViewsByCategory=o}}function Wn(e,t){let n=kt();n.startedAt||(n.startedAt=Date.now());let r=Array.isArray(t?.products)?t.products:[];switch(e){case"Product Viewed":n.productViews+=1,Fe(n,n.browsingCategory);break;case"Product List Viewed":{let i=t?.list_id,a=t?.category;if(!(typeof i=="string"&&i.includes("/")&&!i.startsWith("cdp-")))break;let d=typeof a=="string"&&xe(ge(a))||null,f=d?xe(ge(i)):"";if(!f){n.browsingCategory=null,n.browsingListing=null;break}n.browsingListing={key:f,category:d},Fe(n,f),n.browsingCategory=f,es(n,d),n.listViews+=1}break;case"Product List Filtered":{let i=t?.change,a=typeof t?.list_id=="string"?t.list_id:"",u=typeof i?.value=="string"?i.value:"",d=n.browsingListing;if(u&&i?.action!=="removed"&&d&&xe(ge(a))===d.key){let f=Fe(n,`${a}/${u}`);f&&(n.browsingCategory=f)}break}case"Product Added":{n.cartAdds+=1,Fe(n,n.browsingCategory);for(let i of r){let a=i.product_id;typeof a!="string"||!a||(n.basketProducts=[a,...n.basketProducts.filter(u=>u!==a)].slice(0,Kn))}break}case"Product Removed":{for(let i of r){let a=i.product_id;typeof a=="string"&&a&&(n.basketProducts=n.basketProducts.filter(u=>u!==a))}break}case"Products Searched":{n.searches+=1;let i=t?.query;if(typeof i=="string"&&i.trim()){let a=i.trim().toLowerCase().slice(0,64);n.recentSearches=[a,...n.recentSearches.filter(u=>u!==a)].slice(0,5)}break}case"Product Clicked":case"Product Added to Wishlist":break;case"Cart Updated":{let i=t?.value;return n.basketValue=typeof i=="number"&&Number.isFinite(i)&&i>=0?i:null,At(n),n}default:return n}let o=Zo.has(e);if(o)for(let i of r)typeof i.product_id=="string"&&i.product_id&&delete n.impressions[i.product_id];else{for(let a of r){let u=a.product_id;typeof u!="string"||!u||(n.impressions[u]=(n.impressions[u]??0)+1)}let i=Object.keys(n.impressions);if(i.length>Gn){let a={};for(let u of i.sort((d,f)=>n.impressions[f]-n.impressions[d]).slice(0,Gn))a[u]=n.impressions[u];n.impressions=a}}let s=new Set;for(let i of r){let a=i.product_id;if(o&&typeof a=="string"&&a&&(n.recentProducts=[a,...n.recentProducts.filter(u=>u!==a)].slice(0,Kn)),Qo.has(e)&&typeof i.category=="string"&&i.category){let u=ge(i.category);u&&!s.has(u)&&(s.add(u),xt(n.recentCategories,u))}}return At(n),n}var Jn=1800*1e3;function Yn({name:e,domain:t=null,mayStore:n,now:r=()=>Date.now(),mint:o=Z}){let s=null,i=0,a=()=>{s!==null&&n()&&Q(e,s,Jn/1e3,t)};return{get(){let u=r(),d=M(e);return d?s=d:(s===null||u-i>=Jn)&&(s=o()),i=u,a(),s},persist:a,forget(){Q(e,"",0,t),s=null}}}var G=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Xn=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),vt=Object.freeze({enabled:!1});function Zn(e,t){let n=e?.track;return G(n)?(Object.hasOwn(n,t)?n[t]:n.__default)?.enabled!==!1:!0}function ts(e,t){return`${le(e)}/v1/projects/${encodeURIComponent(t)}/settings`}var ns="https://hp.thgingenuity.com";function le(e){return e==null||e===""?ns:er(e)}function Qn(e,t){return e!=null&&e!==""?le(e):t?.startsWith("https://")?t:le(void 0)}function er(e){if(typeof e!="string")return null;let t=e.trim().replace(/\/+$/,"");return/^https?:\/\/[^/\s]+$/i.test(t)?t:/^[a-z0-9.-]+(:\d+)?$/i.test(t)?`https://${t}`:null}function rs(e){if(!G(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>typeof n=="boolean"));return Object.keys(t).length?t:null}var Et=e=>typeof e=="number"&&e>=0&&e<=1,os=/^[0-9a-f]{64}$/;function ss(e){return G(e)?{enabled:e.enabled===!0,tokenSha256:typeof e.tokenSha256=="string"&&os.test(e.tokenSha256)?e.tokenSha256:null}:{enabled:!1,tokenSha256:null}}function is(e){if(!G(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>G(n)&&Et(n.share)&&(n.ramp==null||Et(n.ramp))&&typeof n.salt=="string"&&n.salt!=="").map(([n,r])=>[n,{share:r.share,ramp:r.ramp??null,salt:r.salt,...Xn(r.readoutSlots)&&r.readoutSlots.length>0&&{readoutSlots:r.readoutSlots}}]));return Object.keys(t).length?t:null}var as=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;function cs(e){return G(e)?e.source==="hp_cookie"?{source:"hp_cookie"}:e.source!=="site_cookie"?null:e.cookie==null?{source:"site_cookie",cookie:null}:typeof e.cookie=="string"&&as.test(e.cookie)?{source:"site_cookie",cookie:e.cookie}:null:null}function us(e){let t=G(e)?e.hp:null;return G(t)&&typeof t.enabled=="boolean"}function Ct(e){let t=G(e)?e.hp:null;return!G(t)||t.enabled!==!0?vt:{enabled:!0,propertyId:typeof t.propertyId=="string"&&t.propertyId!==""?t.propertyId:null,environment:typeof t.environment=="string"?t.environment:null,consentPurposes:rs(t.consent?.purposes),queryParamAllowlist:Xn(t.queryParamAllowlist)?t.queryParamAllowlist:null,anonymousId:cs(t.anonymousId),apiHost:er(t.apiHost),holdouts:is(t.holdouts),sampleRate:Et(t.sampleRate)?t.sampleRate:1,debug:ss(t.debug),plan:G(e.plan)&&G(e.plan.track)?{track:e.plan.track}:null}}async function tr(e,t,n=globalThis.fetch){try{let r=await n(ts(e,t),{credentials:"omit",headers:{accept:"application/json"}});if(!r.ok)return null;let o=await r.json();return us(o)?Ct(o):null}catch{return null}}var He=e=>F(T("settings"),e);function nr(e){try{let t=localStorage.getItem(He(e));if(!t)return null;let n=JSON.parse(t);return n?.enabled===!0?n:null}catch{return null}}function rr(e,t){try{t?.enabled===!0?localStorage.setItem(He(e),JSON.stringify(t)):localStorage.removeItem(He(e))}catch{}}function Pt(e){try{localStorage.removeItem(He(e))}catch{}}var ls={flushAt:20,flushIntervalMs:1e4,maxQueue:500,maxRetryAgeMs:1440*60*1e3,maxRetries:5,maxPersistedBatches:20,maxPersistedBytes:1024*1024,storageKey:ie.retry,beaconSafeBytes:56*1024,maxBatchEvents:100,maxBatchBytes:500*1024},Ke=()=>Date.now(),or=3e4,Mt=55*1024;function ds(e,t=Ke()){if(typeof e!="string")return 0;let n=e.trim();if(/^\d+$/.test(n))return Number(n)*1e3;if(n==="")return 0;let r=Date.parse(n);return Number.isNaN(r)?0:Math.max(0,r-t)}var ee=e=>typeof TextEncoder<"u"?new TextEncoder().encode(e).length:Buffer.byteLength(e),Ot=()=>typeof window<"u"&&typeof document<"u";function fs(){try{return!Ot()||!window.localStorage?null:(window.localStorage.getItem("thg_hp_probe"),window.localStorage)}catch{return null}}var I,Lt,Tt,Ge,Nt,Rt,sr,Ie,ke,Ae,ir,Dt,ar,ze,We=class{constructor(t){Ft(this,I);this.o={...ls,...t},this.queue=[],this.timer=null,this.storage=fs(),this.inflight=null,this.sending=new Set,this.epoch=0,this.sinceRefusal=new Set,this.wakers=new Set,this.replayAllowed=!this.o.deferReplay,this.draining=null,Ot()&&(window.addEventListener("pagehide",()=>this.flush({beacon:!0})),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()}),O(this,I,ze).call(this))}replayPersisted(){return this.replayAllowed=!0,O(this,I,ze).call(this)}clearPersisted(){if(this.replayAllowed=!1,!!this.storage)try{let t=O(this,I,Ae).call(this).filter(n=>this.sinceRefusal.has(n?.id));t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey)}catch{}}discardQueued(){this.queue=[],this.epoch+=1,this.sinceRefusal.clear(),O(this,I,Tt).call(this);for(let t of this.wakers)t()}enqueue(t){let n;try{n=JSON.parse(JSON.stringify(t))}catch(r){this.o.onError?.(`event ${t?.messageId??""} cannot be serialised; dropped`,r);return}this.queue.push(n),this.queue.length>this.o.maxQueue&&this.queue.splice(0,this.queue.length-this.o.maxQueue),this.queue.length>=this.o.flushAt?this.flush():O(this,I,Lt).call(this)}flush(t={}){if(O(this,I,Tt).call(this),this.queue.length===0)return Promise.resolve();if(t.beacon&&Ot()&&typeof navigator<"u"&&navigator.sendBeacon)return O(this,I,sr).call(this),Promise.resolve();if(this.inflight)return this.inflight;let n=O(this,I,Rt).call(this,this.queue,this.o.maxBatchEvents,this.o.maxBatchBytes).map(o=>{let s=O(this,I,Dt).call(this,o);return s&&(this.sending.add(s),this.sinceRefusal.add(s)),{batch:o,id:s}});this.queue=[];let r=this.epoch;return this.inflight=(async()=>{for(let{batch:o,id:s}of n){if(r!==this.epoch){O(this,I,ke).call(this,s);continue}await O(this,I,Ie).call(this,o,0,s,r)}})().finally(()=>{this.inflight=null,this.queue.length>=this.o.flushAt?this.flush():this.queue.length&&O(this,I,Lt).call(this)}),this.inflight}};I=new WeakSet,Lt=function(){this.timer||(this.timer=setTimeout(()=>this.flush(),this.o.flushIntervalMs),this.timer?.unref?.())},Tt=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},Ge=function(t){return JSON.stringify({batch:t,writeKey:this.o.writeKey,sentAt:new Date().toISOString()})},Nt=function(){return`${this.o.apiHost.replace(/\/$/,"")}/v1/batch`},Rt=function(t,n,r){let o=ee(O(this,I,Ge).call(this,[])),s=[],i=[],a=o;for(let u of t){let d=ee(JSON.stringify(u))+1;i.length&&(i.length>=n||a+d>r)&&(s.push(i),i=[],a=o),i.push(u),a+=d}return i.length&&s.push(i),s},sr=function(){let t=this.queue;this.queue=[];let n=O(this,I,Nt).call(this);for(let r of O(this,I,Rt).call(this,t,this.o.maxBatchEvents,this.o.beaconSafeBytes)){let o=O(this,I,Ge).call(this,r);if(ee(o)<=this.o.beaconSafeBytes){let s=!1;try{s=navigator.sendBeacon(n,new Blob([o],{type:"text/plain"}))}catch{s=!1}if(s)continue}O(this,I,Ie).call(this,r,0,O(this,I,Dt).call(this,r))}},Ie=async function(t,n,r=null,o=this.epoch){r&&this.sending.add(r);let s=O(this,I,Ge).call(this,t),i=0;try{let a=await fetch(O(this,I,Nt).call(this),{method:"POST",headers:{"Content-Type":"text/plain"},body:s,keepalive:ee(s)<=this.o.beaconSafeBytes});if(a.ok)return O(this,I,ke).call(this,r),O(this,I,ze).call(this),!0;let u=a.status===408||a.status===429||a.status>=500;if(u&&(i=ds(a.headers?.get?.("retry-after"))),!u)return O(this,I,ke).call(this,r),this.o.onError?.(`CDP ingest rejected batch (${a.status}); dropping ${t.length} events`),!0;throw new Error(`retryable ${a.status}`)}catch(a){if(n>=this.o.maxRetries){r&&this.sending.delete(r);let d=r?"kept for the next page":"dropped";return this.o.onError?.(`CDP ingest unreachable after ${n} attempts; ${d}: ${t.length} events`,a),!1}let u=Math.max(Math.min(1e3*2**n,or)*(.5+Math.random()),Math.min(i,or));return o===this.epoch&&await new Promise(d=>{let f=()=>{clearTimeout(p),this.wakers.delete(f),d()},p=setTimeout(f,u);this.wakers.add(f)}),o!==this.epoch?(O(this,I,ke).call(this,r),!1):O(this,I,Ie).call(this,t,n+1,r,o)}},ke=function(t){t&&(this.sending.delete(t),this.sinceRefusal.delete(t),O(this,I,ar).call(this,t))},Ae=function(){let t=JSON.parse(this.storage.getItem(this.o.storageKey)||"[]");return Array.isArray(t)?t:[]},ir=function(t,n){let r=i=>ee(JSON.stringify(i))+1,o=[...t,n].slice(-this.o.maxPersistedBatches),s=o.reduce((i,a)=>i+r(a),2);for(;o.length>1&&s>this.o.maxPersistedBytes;)s-=r(o[0]),o=o.slice(1);for(;o.length;)try{return this.storage.setItem(this.o.storageKey,JSON.stringify(o)),!0}catch{o=o.slice(1)}return!1},Dt=function(t){if(!this.storage||this.o.mayPersist&&!this.o.mayPersist())return null;try{let n={at:Ke(),id:`${Ke()}-${Math.random().toString(36).slice(2)}`,batch:t};return ee(JSON.stringify(n))+3>this.o.maxPersistedBytes?null:O(this,I,ir).call(this,O(this,I,Ae).call(this),n)?n.id:null}catch{return null}},ar=function(t){if(!(!t||!this.storage))try{let n=O(this,I,Ae).call(this).filter(r=>r.id!==t);n.length?this.storage.setItem(this.o.storageKey,JSON.stringify(n)):this.storage.removeItem(this.o.storageKey)}catch{}},ze=function(){if(!this.storage||!this.replayAllowed)return this.draining??Promise.resolve();if(this.draining)return this.draining;let t;try{let r=O(this,I,Ae).call(this);t=r.filter(o=>Array.isArray(o?.batch)&&Ke()-o.at<this.o.maxRetryAgeMs).map(o=>o.id?o:{...o,id:`${o.at}-${Math.random().toString(36).slice(2)}`}),(t.length!==r.length||t.some((o,s)=>o!==r[s]))&&(t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey))}catch{return Promise.resolve()}let n=t.filter(r=>!this.sending.has(r.id));return n.length?(this.draining=(async()=>{for(let r of n)if(!this.replayAllowed||!await O(this,I,Ie).call(this,r.batch,0,r.id))return})().finally(()=>{this.draining=null}),this.draining):Promise.resolve()};var cr="3.22.2",ur="@thg-agentic/hyper-personalisation-web";var ps=new Set(["audiences","decisions","recommendations"]);var ms=Symbol.for("@thg-agentic/hyper-personalisation-web.replay");function hs(e){let t={...e??{}},n=Array.isArray(t.products)?t.products:null;if(t.item_count==null&&n){let r=n.map(o=>o?.quantity);r.every(Number.isInteger)&&(t.item_count=r.reduce((o,s)=>o+s,0))}return t}var gs="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";function ys(e){if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(!/^[A-Za-z0-9+/_-]{43}=?$/.test(e))return null;try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(44,"="));return t.length!==32?null:Array.from(t,n=>n.charCodeAt(0).toString(16).padStart(2,"0")).join("")}catch{return null}}function Je(e){if(typeof e!="string")return null;let t=ys(e.trim());return t===gs?null:t}var lr=Object.freeze({email_sha256:"sha256",phone_sha256:"sha256",accepts_marketing:"boolean",gender:"string",created_at:"date-time"}),ws=/^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d)$/i;function Ss(e){if(typeof e!="string"||!ws.test(e))return!1;let[t,n,r]=e.slice(0,10).split("-").map(Number),o=new Date(Date.UTC(t,n-1,r));return o.getUTCMonth()===n-1&&o.getUTCDate()===r&&!Number.isNaN(Date.parse(e))}function _s(e,t){return t===null?null:e==="sha256"?Je(t)??void 0:e==="date-time"?t instanceof Date?Number.isNaN(t.getTime())?void 0:t.toISOString():Ss(t)?t:void 0:typeof t===e?t:void 0}function bs(e,t){let n={},r=[];for(let[o,s]of Object.entries(e)){let i=Object.hasOwn(lr,o)?lr[o]:null,a=i?_s(i,s):void 0;a===void 0?r.push(o):n[o]=a}return t&&r.length&&console.warn(`[hp] identify: not sent, not spec traits: ${r.join(", ")}`),n}var dr=!1,fr=!1;function xs(){fr||(fr=!0,console.warn("[hp] no consent adapter: events are sent under the host's lawful basis (basis 'host'). Pass `consent` to send only once the visitor allows analytics."))}function Is(e){!e||dr||(dr=!0,console.warn("[hp] mintAnonymousId is ignored since 3.6: where device ids come from is set per source in the console (the site\u2019s own cookie, or Hyper-Personalisation\u2019s)."))}function ks(e){try{return ee(JSON.stringify(e))}catch{return 0}}function pr(e){return e&&typeof e.context=="object"&&e.context!==null?e.context:e}function mr(e){let t=le(e?.apiHost);if(!t)throw new Error("createAnalytics: apiHost, when given, must be a host or an http(s) origin");if(!e?.propertyId)throw new Error("createAnalytics: propertyId is required");let n={libraryName:ur,libraryVersion:cr,writeKey:"web",queryParamBlocklist:[],debug:!1,validate:null,consentTimeoutMs:5e3,...e,apiHost:t};Te(n.storageNames),Ne();let r=!!n.consent;r||xs();let o=null;n.getConsent=()=>o?o.stamp():mn();let s=()=>!r||o?.status==="granted",i=r&&n.holdAcrossPages?dn(F(T("held"),n.propertyId)):null,a=i?.read()??{items:[],anonymousId:null};n.mintAnonymousId!==void 0&&Is(n.debug);let u=fn(n,{carried:a.anonymousId,mayStore:s,orOwn:!0}),d=Yn({name:T("session"),domain:n.consentCookieDomain??null,mayStore:s}),f=n.getSessionId;n.getSessionId=()=>q(D(f,null))??d.get();let p=Rn(T("preview"),n.consentCookieDomain??null),g=(c,l)=>n.debug&&console.warn("[hp]",c,l??""),x=n.transport??new We({apiHost:n.apiHost,writeKey:n.writeKey,storageKey:F(T("retry"),n.propertyId),mayPersist:r?()=>o?.status==="granted":void 0,deferReplay:r,onError:g}),w=F(T("previousPage"),n.propertyId),b=null,k=()=>{if(b)return b;try{return sessionStorage.getItem(w)||null}catch{return null}};typeof window<"u"&&window.addEventListener("pageshow",c=>{c.persisted&&(b=null)});let E=c=>{if(b=c||null,!(r&&o.status!=="granted"))try{sessionStorage.setItem(w,c)}catch{}},h=Tn({key:F(T("decisions"),n.propertyId),mayStore:s});n.getDecisions??(n.getDecisions=h.current);let v=q(D(n.getUserId,null)),S=null,y=null,_=null;function L(c,l,A=!1){try{return R(c,l,A)}catch(P){if(P instanceof he)throw P;return console.warn("[hp] the event was not sent",P),null}}function R(c,l,A){let P=_;_=null;let U=c.type==="track"?c.event:c.type;if(!A&&!Zn(n.plan,U))return null;let C={messageId:P?.messageId??Z(),timestamp:P?.timestamp??new Date().toISOString(),anonymousId:q(D(n.getAnonymousId,null)),userId:v??null,...c,context:sn(n,pr(l))};if(C.properties&&(C.properties=st(C.properties)),typeof C.properties?.href=="string"&&(C.properties.href=on(C.properties.href,n)),!A&&!Bn(C.anonymousId,n.sampleRate))return n.debug&&console.debug("[hp] not sent: outside the sample",C),null;if(n.beforeSend){let fe;try{fe=n.beforeSend(C)}catch(Er){return console.warn("[hp] beforeSend failed; the event was not sent",Er),null}if(!fe)return null;let{type:Pe,event:jt,messageId:kr,timestamp:Ar}=C;C={...fe,type:Pe,messageId:kr,timestamp:Ar,...jt?{event:jt}:{}}}if(n.validate){let fe=n.validate(C,{producer:"web"});if(!fe.valid){let Pe=`[hp] invalid ${C.event??C.type}:
2
+ ${fe.errors.join(`
3
+ `)}`;if(n.throwOnInvalid)throw new he(Pe);console.error(Pe)}}n.debug&&console.debug("[hp]",C.event??C.type,C);let Bt=ks(C);return Bt>Mt?(g(`${C.event??C.type} not sent: ${Bt} bytes, over the ${Mt}-byte limit for one event`),null):(Ee(C,A),C)}function H(c){if(c.type==="track"&&z(c),n.onEvent)try{n.onEvent(c)}catch(l){console.warn("[hp] onEvent observer failed",l)}}let K=()=>r&&o?.state?.personalisation===!0,B=()=>qn(D(n.getSessionId,null),n.propertyId),te=!1;function z(c){try{K()?(B(),$n(bt(Wn(c.event,c.properties))),te=!0):ne()}catch(l){n.debug&&console.warn("[hp] the visit was not recorded",l)}}function ne(c=!1){Un(),(c||te)&&Hn(),te=!1}function de(){d.forget(),h.forget(),j.clear(),u?.forget(),ne(!0)}function Ee(c,l){!r||l||o.admits()?(H(c),x.enqueue(c)):o.hold(c)}let m=(c,l,A)=>L({type:"track",event:c,properties:l??{}},A),j=new Set,ve=(c,l,A)=>c==="audiences"?{audiences:l?null:A.audiences??[]}:c==="decisions"?{decisions:(A.decisions??[]).map(P=>({slot:P.slot,decision_id:P.decision_id??null,arm:P.arm??null,...P.variant&&{variant:P.variant}}))}:{recommendation_request_id:A.recommendation_request_id??null};r&&(o=On({adapter:n.consent,timeoutMs:n.consentTimeoutMs,cookieDomain:n.consentCookieDomain,debug:n.debug,store:i&&{read:()=>a.items,write:c=>i.write(c,u?.peek()??null)},release(c){c.context&&(c.context.consent=o.stamp()),H(c),x.enqueue(c)},onStatus(c){if(c==="granted"&&(u?.persist(),d.persist(),b&&E(b),h.persist(),x.replayPersisted?.()),c==="denied"){x.clearPersisted?.(),u?.forget(),d.forget();try{sessionStorage.removeItem(w)}catch{}h.forget(),ne(!0)}try{n.onConsentStatus?.(c)}catch(l){console.warn("[hp] onConsentStatus observer failed",l)}},announce({action:c,state:l,previous:A,withdrawal:P}){l?.personalisation!==!0&&ne(A?.personalisation===!0),P&&x.discardQueued?.(),L({type:"track",event:"Consent Updated",properties:{action:c,state:l}},void 0,P),P&&x.flush()}}),o.start());let J=()=>n.holdout?St(n.holdout):null,Ce=()=>_t(n.holdout,q(D(n.getAnonymousId,null))).group;function Ir(c,l){if(!Array.isArray(c?.decisions))return c;let A=n.holdout?.readoutSlots??[],P=q(D(n.getAnonymousId,null));return{...c,decisions:c.decisions.map(U=>{let C=U?.variant==="bandit"||U?.variant==="default"?U.variant:!l&&U?.holdout!==!0&&A.includes(U?.slot)?Nn(U.slot,P):null;return C?C==="default"?{...U,variant:C,decision_id:null}:{...U,variant:C}:U})}}function Ut(c,l){if(p)return null;let A=c?.exposure,P=A?.holdout===!0,U=Ir(c,P);return h.remember(Ln(U)),!A?.token||j.has(A.token)?null:(j.add(A.token),m("Personalisation Exposed",{exposure_token:A.token,surface:A.surface,holdout:P,holdout_share:A.holdout_share??J()?.holdout_share??null,personalised_share:A.personalised_share??J()?.personalised_share??null,...ve(A.surface,P,U)},l))}function Vt(c){return v&&de(),v=null,S=null,y=null,c}return Cn({track:(c,l,A)=>c==="Signed Out"?Vt(m(c,l,A)):m(c,l,A),page(c,l){c??(c={});let A=n.pageType??null;c.type&&(pe.has(c.type)?(A=c.type,n.pageType=c.type):n.debug&&console.warn(`[hp] ignoring unknown page.type "${c.type}". Allowed: ${[...pe].join(", ")}`));let P=L({type:"page",properties:{name:c.name??null,navigation_trigger:c.navigation_trigger??Zt(),previous_message_id:k()}},{page:{type:A},...pr(l)??{}});return P&&E(P.messageId),P},identify(c,l,A){let{userId:P,...U}=c&&typeof c=="object"?c:{};if(P!==void 0){let C=q(P);A===be?y=C:S&&C&&C!==S?de():n.debug&&y&&C&&C!==y&&console.warn("[hp] identify names another userId than the identity option; using the new one"),v=C,C&&A!==be&&(S=C)}return L({type:"identify",traits:bs(U,n.debug)},l)},reset(){v&&de(),v=null,S=null,y=null,E("")},productViewed:(c,l)=>m("Product Viewed",c,l),productListViewed:(c,l)=>m("Product List Viewed",c,l),recommendationsViewed:(c,l)=>m("Recommendations Viewed",c,l),personalisationExposed:(c,l)=>m("Personalisation Exposed",c,l),recordExposure:Ut,surfaceViewed({surface:c}={},l){if(!ps.has(c)||!n.holdout||c!=="decisions"&&!K())return null;let A=q(D(n.getAnonymousId,null)),P=_t(n.holdout,A).group;if(P==="excluded")return null;let U=Jt({sessionId:Oe(D(n.getSessionId,null),A),surface:c});return U?Ut({exposure:{token:U,surface:c,holdout:P==="holdout"}},l):null},inHoldout:()=>Ce()!=="personalised",personalisationGroup:Ce,productClicked:(c,l)=>m("Product Clicked",c,l),productListFiltered:(c,l)=>m("Product List Filtered",c,l),productsSearched:(c,l)=>m("Products Searched",c,l),searchSuggestionsViewed:(c,l)=>m("Search Suggestions Viewed",c,l),productAdded:(c,l)=>m("Product Added",c,l),productRemoved:(c,l)=>m("Product Removed",c,l),cartUpdated:(c,l)=>m("Cart Updated",hs(c),l),identityLinked:(c,l)=>m("Identity Linked",c,l),slotEngaged:(c,l)=>p?null:m("Slot Engaged",c,l),productVariantSelected:(c,l)=>m("Product Variant Selected",c,l),cartViewed:(c,l)=>m("Cart Viewed",c,l),productAddedToWishlist:(c,l)=>m("Product Added to Wishlist",c,l),productRemovedFromWishlist:(c,l)=>m("Product Removed from Wishlist",c,l),wishlistProductAddedToCart:(c,l)=>m("Wishlist Product Added to Cart",c,l),productShared:(c,l)=>m("Product Shared",c,l),cartShared:(c,l)=>m("Cart Shared",c,l),couponEntered:(c,l)=>m("Coupon Entered",c,l),couponApplied:(c,l)=>m("Coupon Applied",c,l),couponDenied:(c,l)=>m("Coupon Denied",c,l),couponRemoved:(c,l)=>m("Coupon Removed",c,l),checkoutStarted:(c,l)=>m("Checkout Started",c,l),promotionViewed:(c,l)=>m("Promotion Viewed",c,l),promotionClicked:(c,l)=>m("Promotion Clicked",c,l),checkoutStepViewed:(c,l)=>m("Checkout Step Viewed",c,l),checkoutStepCompleted:(c,l)=>m("Checkout Step Completed",c,l),paymentInfoEntered:(c,l)=>m("Payment Info Entered",c,l),checkoutFailed:(c,l)=>m("Checkout Failed",c,l),signedIn:(c,l)=>m("Signed In",c,l),signedUp:(c,l)=>m("Signed Up",c,l),signedOut:c=>Vt(m("Signed Out",{},c)),newsletterSubscribed:(c,l)=>m("Newsletter Subscribed",c,l),newsletterUnsubscribed:(c,l)=>m("Newsletter Unsubscribed",c,l),backInStockSubscribed:(c,l)=>m("Back In Stock Subscribed",c,l),productReviewed:(c,l)=>m("Product Reviewed",c,l),consentUpdated:(c,l)=>m("Consent Updated",c,l),flush:c=>x.flush(c),recommendationContext(){if(!K())return{};try{return B(),bt(Fn())}catch{return{}}},get consent(){return o?o.state:null},servingHeaders:()=>yn(o?.state??null),get lastPageMessageId(){return k()},get anonymousId(){return q(D(n.getAnonymousId,null))},[ms](c,l,A){if(typeof this[c]=="function"){_=typeof A?.messageId=="string"&&typeof A?.timestamp=="string"?{messageId:A.messageId,timestamp:A.timestamp}:null;try{this[c](...Array.isArray(l)?l:[])}finally{_=null}}}})}var $t=Symbol.for("@thg-agentic/hyper-personalisation-web.bootstrap"),As=Symbol.for("@thg-agentic/hyper-personalisation-web.drain"),Es=Symbol.for("@thg-agentic/hyper-personalisation-web.carry"),hr=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),vs=Symbol.for("@thg-agentic/hyper-personalisation-web.assignment"),Cs=Symbol.for("@thg-agentic/hyper-personalisation-web.recommendation-context"),Ze=e=>e?()=>M(e):()=>null,wr={didomi:e=>wn({purposes:e.purposes}),onetrust:e=>Sn({groups:e.groups,impliedConsent:e.impliedConsent}),cookie:e=>_n({name:e.name,categories:e.categories,refusedValue:e.refusedValue,source:e.source,changeEvent:e.changeEvent}),forwarded:e=>bn({name:e.name}),static:e=>{if(!e.state||typeof e.state!="object")throw new Error('consent.state is required for provider "static"');return xn(e.state)}},gr=Object.keys(wr),we=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ye=e=>typeof e=="string"&&e!=="",Ps=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Sr=e=>we(e)&&typeof e.read=="function";function Os(e,t={}){let n=[];if(!we(e))return["config must be { writeKey, apiHost? }"];Ye(e.writeKey)||n.push("writeKey is required"),le(e.apiHost)||n.push("apiHost, when given, must be a host or an http(s) origin"),t.propertyId!==void 0&&!Ye(t.propertyId)&&n.push("propertyId must be a string");let{consent:r}=t;if(!Sr(r)&&!(we(r)&&gr.includes(r.provider))&&n.push(`consent must be a consent adapter or { provider: ${gr.join(" | ")} }`),t.autocapture!==void 0&&t.autocapture!==!1&&!we(t.autocapture)&&n.push("autocapture must be false or { promotions, productLists, recommendations }"),t.beforeSend!==void 0&&typeof t.beforeSend!="function"&&n.push("beforeSend must be a function"),t.identityCookies!==void 0)if(!we(t.identityCookies))n.push("identityCookies must be an object");else for(let o of["anonymousId","sessionId"]){let s=t.identityCookies[o];s!==void 0&&!Ye(s)&&n.push(`identityCookies.${o} must be a cookie name`)}for(let o of["getCurrency","getShipToCountry","getLocale"])t[o]!==void 0&&typeof t[o]!="function"&&n.push(`${o} must be a function`);return t.dataLayer!==void 0&&(we(t.dataLayer)?(t.dataLayer.name!==void 0&&!Ye(t.dataLayer.name)&&n.push("dataLayer.name must be a string"),t.dataLayer.ignore!==void 0&&!Ps(t.dataLayer.ignore)&&n.push("dataLayer.ignore must be an array of strings")):n.push("dataLayer must be an object")),n}function Ls(e,t,n){if(Sr(e))return mt(e,t.consentPurposes);let{provider:r,...o}=e,s=n?.consent?.[r]??wr[r];return mt(s(o),t.consentPurposes)}var _r=(e,t)=>`${e??""}|${t??""}`;function Ts(e,t){let n=q(t?.userId),r=Je(t?.emailSha256);if(!n&&!r)return null;try{let o=F(T("identified"),e);if(sessionStorage.getItem(o)===_r(n,r))return null}catch{}return{...n?{userId:n}:{},...r?{email_sha256:r}:{}}}async function Ns({writeKey:e,apiHost:t},n){if(n.settings!==void 0)return{settings:Ct(n.settings),revalidated:null};let r=tr(t,e),o=nr(e);if(o)return{settings:o,revalidated:r};let s=await r,i=s??vt;return{settings:i,revalidated:Promise.resolve(i),unreachable:s===null}}function br(e,t){let n=t??{},r=typeof window<"u"?window:null;if(r?.[$t])return r[$t];let o=pn(e?.writeKey,()=>{let{analytics:i}=_e(M(T("consent")));return i===!0||i===null&&n.holdAcrossPages===!0}),s=Ds(e,n,o);if(r){let i=n.extend?.getSessionId??Ze(n.identityCookies?.sessionId),a=Ze(n.identityCookies?.anonymousId);r[vs]=({slot:u,arm:d}={})=>Wt({sessionId:Oe(i(),a()),slot:u,arm:d}),r[$t]=s,r[Es]=o,r[As]?.(s)}return s}function Rs(){let e=globalThis.performance?.now?.();return new Date(Date.now()-(Number.isFinite(e)?e:0)).toISOString()}function yr(e,t){if(t===!1)return()=>{};let n={promotions:!0,productLists:!0,recommendations:!0,exposures:!0,...t},r=s=>s&&typeof s=="object"?s:{},o=[];try{n.promotions&&o.push(nt(e,r(n.promotions))),n.productLists&&o.push(tt(e,r(n.productLists))),n.recommendations&&o.push(rt(e,r(n.recommendations))),n.exposures&&o.push(et(e,r(n.exposures)))}catch(s){console.warn("[hp] autocapture not started:",s?.message??s)}return()=>{for(let s of o)s()}}function Xe(e){return e.close(),null}async function Ds(e,t,n){try{let r=Os(e,t);if(r.length)return console.warn(`[hp] not started, the configuration is invalid: ${r.join("; ")}`),Xe(n);Te(t.storageNames),Ne();let{writeKey:o}=e,[{settings:s,revalidated:i,unreachable:a},u]=await Promise.all([Ns(e,t),Promise.resolve(t.identity).catch(()=>null)]),d=i?s:null,f=!1,p=()=>f&&d&&rr(o,d);if(i?.then(y=>{y&&(d=y,y.enabled?p():Pt(o))}),a)return null;if(!s.enabled)return t.debug&&console.info("[hp] off: the settings for this write key do not enable it"),Xe(n);let g=t.propertyId??s.propertyId;if(!g)return console.warn("[hp] not started: this write key covers several properties, so propertyId is required"),Xe(n);let{preset:x}=t,w=Ts(g,u),b=t.debug===!0||s.debug?.enabled===!0||vn(s.debug?.tokenSha256??null,T("debug")),k=q(u?.userId),E=mr({apiHost:Qn(e.apiHost,s.apiHost),writeKey:o,propertyId:g,pageType:pe.has(t.pageType)?t.pageType:void 0,environment:s.environment,queryParamAllowlist:s.queryParamAllowlist??void 0,plan:s.plan,sampleRate:s.sampleRate??1,holdout:s.holdouts?.[g],getCurrency:t.getCurrency,getShipToCountry:t.getShipToCountry,getLocale:t.getLocale,consent:Ls(t.consent,s,x),consentCookieDomain:t.consentCookieDomain,storageNames:t.storageNames,holdAcrossPages:t.holdAcrossPages===!0,mintAnonymousId:t.mintAnonymousId,debug:b,anonymousIdSource:s.anonymousId??void 0,getAnonymousId:Ze(t.identityCookies?.anonymousId),getSessionId:t.identityCookies?.sessionId?Ze(t.identityCookies.sessionId):void 0,getUserId:()=>k,beforeSend:t.beforeSend,...t.extend,onConsentStatus(y){if(y==="granted"&&(f=!0,p()),y==="denied"){Pt(o);try{sessionStorage.removeItem(F(T("identified"),g))}catch{}}t.extend?.onConsentStatus?.(y)},onEvent(y){if(y.type==="identify"){let _=_r(q(y.userId),Je(y.traits?.email_sha256));try{sessionStorage.setItem(F(T("identified"),g),_)}catch{}}t.extend?.onEvent?.(y)}});typeof window<"u"&&(window[Cs]=()=>E.recommendationContext());for(let[y,_,L]of n.take())try{E[hr](y,_,L)}catch(R){console.warn(`[hp] carried ${y} failed`,R)}E[hr]("page",[t.pageType?{type:t.pageType}:{}],{messageId:Z(),timestamp:Rs()});let h=yr(E,t.autocapture),v=E.page;E.page=wt("page",(...y)=>{let _=v(...y);return h(),h=yr(E,t.autocapture),_});let S=typeof window<"u"?window:null;if(S?.addEventListener("pageshow",y=>{y.persisted&&E.page({navigation_trigger:"back_forward"})}),t.dataLayer&&S){let y=t.dataLayer.name??"dataLayer";S[y]=S[y]||[],En(E,{...x,dataLayer:S[y],ignore:[...x?.ignore??[],...t.dataLayer.ignore??[]],onError:_=>b&&console.warn("[hp] dataLayer mapping failed",_)})}return w&&E.identify(w,void 0,be),E}catch(r){return console.warn("[hp] not started:",r?.message??r),Xe(n)}}function xr(e){e.initialized=!0,br(e._config,e._options).then(t=>{let n=e.splice(0);if(!t){for(let r of e.methods??[])e[r]=()=>e;return}e.client=t;for(let[r,o]of Object.entries(t))typeof o=="function"&&(e[r]=o);for(let[r,...o]of n)try{t[r]?.(...o)}catch(s){console.warn(`[hp] queued ${r} failed`,s)}})}var V=window.hp=window.hp||[];V.servingHeaders??(V.servingHeaders=()=>({}));V.inHoldout??(V.inHoldout=()=>!0);V.personalisationGroup??(V.personalisationGroup=()=>"excluded");V.recommendationContext??(V.recommendationContext=()=>({}));V.initialized||(V._config?xr(V):V.load=(e,t)=>{V._config=e,V._options=t??{},xr(V)});})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thg-agentic/hyper-personalisation-web",
3
- "version": "3.19.0",
3
+ "version": "3.22.2",
4
4
  "description": "Browser SDK for the THG Hyper-Personalisation event specification: event tracking from a write key and remote settings, strict CMP-agnostic consent, a GA4 dataLayer bridge and in-session audience evaluation. Dependency-free ESM on the Segment wire protocol, a CDN script (dist/hp.min.js), and an optional @segment/analytics-next plugin path.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -74,7 +74,7 @@
74
74
  "esbuild": "^0.28.2",
75
75
  "jsdom": "^30.1.1",
76
76
  "typescript": "^7.0.2",
77
- "@thg-agentic/hyper-personalisation-spec": "1.12.0"
77
+ "@thg-agentic/hyper-personalisation-spec": "1.16.0"
78
78
  },
79
79
  "scripts": {
80
80
  "test": "node --test tests/*.test.mjs",
package/src/bootstrap.js CHANGED
@@ -48,6 +48,7 @@ import {
48
48
  cachedSettings,
49
49
  cacheSettings,
50
50
  DISABLED,
51
+ eventsHost,
51
52
  fetchSettings,
52
53
  forgetSettings,
53
54
  readSettings,
@@ -358,8 +359,8 @@ async function start(config, options, carry) {
358
359
  );
359
360
  return off(carry);
360
361
  }
361
- // A source scoped to one property names it; a source scoped to several leaves it to the page.
362
- const propertyId = settings.propertyId ?? options.propertyId;
362
+ // The page's own property, else the source's default; a source with several and no default needs the page's.
363
+ const propertyId = options.propertyId ?? settings.propertyId;
363
364
  if (!propertyId) {
364
365
  console.warn(
365
366
  '[hp] not started: this write key covers several properties, so propertyId is required',
@@ -377,7 +378,7 @@ async function start(config, options, carry) {
377
378
  const userId = realId(identity?.userId);
378
379
 
379
380
  const client = createAnalytics({
380
- apiHost: settings.apiHost ?? resolveApiHost(config.apiHost),
381
+ apiHost: eventsHost(config.apiHost, settings.apiHost),
381
382
  writeKey,
382
383
  propertyId,
383
384
  // Known before the first page view, so an event the client sends while starting (the consent
@@ -483,6 +484,11 @@ async function start(config, options, carry) {
483
484
  });
484
485
 
485
486
  const host = typeof window !== 'undefined' ? window : null;
487
+ // A page restored from the back/forward cache runs no script again, so it would be shown
488
+ // with no page view and no list impressions. It is a back_forward view like any other.
489
+ host?.addEventListener('pageshow', (event) => {
490
+ if (event.persisted) client.page({ navigation_trigger: 'back_forward' });
491
+ });
486
492
  if (options.dataLayer && host) {
487
493
  const name = options.dataLayer.name ?? 'dataLayer';
488
494
  host[name] = host[name] || [];
@@ -260,7 +260,15 @@ export function createConsentGate(options) {
260
260
  onHidden(event);
261
261
  };
262
262
 
263
- const onPageShow = () => resumeRecheck();
263
+ /**
264
+ * A page restored from the back/forward cache runs no script again, and bootstrap sends a page view
265
+ * for it, so the CMP's answer is read once first: web.dev's bfcache guidance is to refresh state on
266
+ * a `pageshow` whose `persisted` is true. Other tabs are otherwise heard at their next page load.
267
+ */
268
+ const onPageShow = (event) => {
269
+ if (event?.persisted && state !== null) apply(read());
270
+ resumeRecheck();
271
+ };
264
272
 
265
273
  return {
266
274
  get status() {
package/src/consent.js CHANGED
@@ -337,26 +337,32 @@ export function oneTrustConsent(options = {}) {
337
337
  };
338
338
  const impliedConsent = options.impliedConsent === true;
339
339
 
340
+ /**
341
+ * The `OptanonConsent` cookie first: OneTrust writes it before it notifies and reads its own
342
+ * groups from it, while `OnetrustActiveGroups` is a copy a back/forward-cache restore leaves stale.
343
+ * `OnetrustActiveGroups` answers before OneTrust has written the cookie.
344
+ */
340
345
  function activeGroups() {
341
- const live = hasWindow() ? window.OnetrustActiveGroups : undefined;
342
- if (typeof live === 'string' && live.length) {
343
- const active = new Set(
344
- live
345
- .split(',')
346
- .map((g) => g.trim())
347
- .filter(Boolean),
348
- );
349
- return (id) => active.has(id);
350
- }
351
346
  const cookie = parseFormCookie(getCookie('OptanonConsent'));
352
- if (!cookie.groups) return null;
353
- const flags = {};
354
- for (const entry of cookie.groups.split(',')) {
355
- const [id, flag] = entry.split(':');
356
- if (id?.trim())
357
- flags[id.trim()] = flag === '1' ? true : flag === '0' ? false : null;
347
+ if (cookie.groups) {
348
+ const flags = {};
349
+ for (const entry of cookie.groups.split(',')) {
350
+ const [id, flag] = entry.split(':');
351
+ if (id?.trim())
352
+ flags[id.trim()] = flag === '1' ? true : flag === '0' ? false : null;
353
+ }
354
+ // A group the cookie does not list is not consented, as it is absent from the live list.
355
+ return (id) => flags[id] ?? false;
358
356
  }
359
- return (id) => flags[id] ?? null;
357
+ const live = hasWindow() ? window.OnetrustActiveGroups : undefined;
358
+ if (typeof live !== 'string' || !live.length) return null;
359
+ const active = new Set(
360
+ live
361
+ .split(',')
362
+ .map((g) => g.trim())
363
+ .filter(Boolean),
364
+ );
365
+ return (id) => active.has(id);
360
366
  }
361
367
 
362
368
  function answered() {
package/src/context.js CHANGED
@@ -251,6 +251,23 @@ export function scrubReferrer(referrer, origin, cfg = {}) {
251
251
  }
252
252
  }
253
253
 
254
+ /**
255
+ * A link's URL as it may leave the browser: resolved against the page, then scrubbed as a referrer
256
+ * is. A host can decorate its links with the landing page's query, an email's recipient ids
257
+ * included, so a clicked link is held to the page URL's rules.
258
+ */
259
+ export function scrubHref(href, cfg = {}) {
260
+ if (typeof href !== 'string' || typeof location === 'undefined') return null;
261
+ try {
262
+ const url = new URL(href, location.href);
263
+ // mailto:, tel: and javascript: carry their payload where a web URL has its path.
264
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') return null;
265
+ return scrubReferrer(url.href, location.origin, cfg);
266
+ } catch {
267
+ return null;
268
+ }
269
+ }
270
+
254
271
  /** ISO-4217, uppercased; anything else is dropped rather than sent to fail validation. */
255
272
  export function currencyCode(value) {
256
273
  if (typeof value !== 'string') return null;
@@ -304,7 +321,6 @@ export const CONTEXT_KEYS = [
304
321
  'library',
305
322
  'source',
306
323
  'session_id',
307
- 'render_id',
308
324
  'identity_trust',
309
325
  'page',
310
326
  'campaign',
@@ -366,7 +382,6 @@ export function buildContext(cfg, overrides = {}) {
366
382
  spec: { version: SPEC_VERSION },
367
383
  source: sourceContext(cfg),
368
384
  session_id: perRequest(cfg.getSessionId, null),
369
- render_id: perRequest(cfg.getRenderId, null),
370
385
  // The browser is always a real device. Only a cacheable server render is not.
371
386
  identity_trust: realId(perRequest(cfg.getAnonymousId, null))
372
387
  ? 'device'