@thg-agentic/hyper-personalisation-web 3.29.0 → 3.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/hp.min.js +1 -1
- package/dist/onsite-render.min.js +5 -5
- package/package.json +2 -2
- package/src/onsite/render.js +78 -36
- package/src/spec-version.js +1 -1
- package/src/version.js +1 -1
- package/types/events.d.ts +3 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @thg-agentic/hyper-personalisation-web
|
|
2
2
|
|
|
3
3
|
The browser SDK for THG Hyper-Personalisation, a customer data platform. It implements the event
|
|
4
|
-
specification (spec 1.
|
|
4
|
+
specification (spec 1.22, stamped on every event as `context.spec.version`) for any storefront: it
|
|
5
5
|
sends events in the Segment wire format, applies consent strictly whichever CMP the site uses, reads
|
|
6
6
|
the GA4 `dataLayer` the site already pushes to, and has no runtime dependencies.
|
|
7
7
|
|
package/dist/hp.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(()=>{var Sn=e=>{throw TypeError(e)};var lo=(e,t,n)=>t.has(e)||Sn("Cannot "+n);var _n=(e,t,n)=>t.has(e)?Sn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var L=(e,t,n)=>(lo(e,t,"access private method"),n);var Ee=[];for(let e=2;Ee.length<64;e++)Ee.every(t=>e%t!==0)&&Ee.push(e);var bn=e=>(e-Math.floor(e))*2**32>>>0,fo=Ee.slice(0,8).map(e=>bn(Math.sqrt(e))),po=Ee.map(e=>bn(Math.cbrt(e))),Q=(e,t)=>e>>>t|e<<32-t;function In(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(fo),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 k=o[w-15],b=o[w-2],x=Q(k,7)^Q(k,18)^k>>>3,h=Q(b,17)^Q(b,19)^b>>>10;o[w]=o[w-16]+x+o[w-7]+h}let[i,u,c,l,f,p,m,A]=r;for(let w=0;w<64;w++){let k=Q(f,6)^Q(f,11)^Q(f,25),b=A+k+(f&p^~f&m)+po[w]+o[w]|0,h=(Q(i,2)^Q(i,13)^Q(i,22))+(i&u^i&c^u&c)|0;[A,m,p,f,l,c,u,i]=[m,p,f,l+b|0,c,u,i,b+h|0]}[i,u,c,l,f,p,m,A].forEach((w,k)=>{r[k]+=w})}return Array.from(r,s=>s.toString(16).padStart(8,"0")).join("")}var It=(e,t)=>e<<t|e>>>32-t;function kn(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]:It(r[p-3]^r[p-8]^r[p-14]^r[p-16],1);let[i,u,c,l,f]=n;for(let p=0;p<80;p++){let m,A;p<20?(m=u&c|~u&l,A=1518500249):p<40?(m=u^c^l,A=1859775393):p<60?(m=u&c|u&l|c&l,A=2400959708):(m=u^c^l,A=3395469782);let w=It(i,5)+m+f+A+r[p]|0;[f,l,c,u,i]=[l,c,It(u,30),i,w]}[i,u,c,l,f].forEach((p,m)=>{n[m]+=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 mo="e28e8ada-5b76-4209-bba9-79b823a0af75",ho=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");function xn(e,t){let n=Uint8Array.from(e.replace(/-/g,"").match(/../g),u=>Number.parseInt(u,16)),r=new TextEncoder().encode(t),o=new Uint8Array(16+r.length);o.set(n),o.set(r,16);let s=kn(o).slice(0,16);s[6]=s[6]&15|80,s[8]=s[8]&63|128;let i=ho(s);return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}var ue=(e,t)=>typeof e=="string"&&e!==""&&e.length<=t?e:null;function Fe(e,t){return ue(e,64)??ue(t,256)}function An({sessionId:e,slot:t,arm:n}={}){let r=ue(e,256);return!r||!ue(t,256)||!ue(n,256)?null:xn(mo,`${r}:${t}:${n}`)}var go="4b1f2c7e-9a3d-4e58-b6c1-2d7f0a9e8c53";function vn({sessionId:e,surface:t}={}){let n=ue(e,256);return!n||!ue(t,64)?null:xn(go,`${n}:${t}`)}var yo=Array.from({length:11},(e,t)=>t/10);function wo(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,u=o?Math.min(i,o.width*o.height):i;return u>0&&s/u>=t}function re(e){let{selector:t,onViewable:n,visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=e,i=new Map,u=new WeakSet,c=new Set,l=h=>{i.has(h)||i.set(h,setTimeout(()=>{i.delete(h),n(h)&&(p?.unobserve(h),c.delete(h))},o))},f=h=>{clearTimeout(i.get(h)),i.delete(h)},p=typeof IntersectionObserver>"u"?null:new IntersectionObserver(h=>{for(let E of h){let S=E.target;if(!wo(E,r)){c.delete(S),f(S);continue}c.add(S),m()&&l(S)}},{threshold:yo}),m=()=>typeof document>"u"||document.visibilityState!=="hidden",A=()=>{if(m())for(let h of c)l(h);else for(let h of c)f(h)};document.addEventListener("visibilitychange",A);let w=()=>{for(let h of s.querySelectorAll(t))u.has(h)||(u.add(h),p?.observe(h))},k=typeof MutationObserver>"u"?null:new MutationObserver(()=>w()),b=()=>{w(),k?.observe(s===document?document.body:s,{childList:!0,subtree:!0})},x=s===document&&!document.body;return x?document.addEventListener("DOMContentLoaded",b,{once:!0}):b(),()=>{x&&document.removeEventListener("DOMContentLoaded",b),document.removeEventListener("visibilitychange",A),p?.disconnect(),k?.disconnect();for(let h of i.values())clearTimeout(h);i.clear(),c.clear()}}function kt(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 re({selector:n,root:s,visibleRatio:r,dwellMs:o,onViewable(i){let u=i.dataset?.hpExposure?.trim();return u&&e.surfaceViewed({surface:u}),!0}})}var En=e=>{try{return new URL(e,document.baseURI).toString()}catch{return e}};function xt(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,u=new Set,c=w=>w.closest?.(n)??null,l=w=>{let k=w.dataset.hpList?.trim();return k?{list_id:k,category:w.dataset.hpListCategory?.trim()||null}:null},f=w=>Array.from(w.querySelectorAll(r)).filter(k=>c(k)===w),p=(w,k)=>{try{let b=JSON.parse(w.dataset.hpProduct??"");return!b||typeof b!="object"||!b.product_id?null:{...b,position:b.position??k+1,...b.url?{url:En(b.url)}:{},...b.image_url?{image_url:En(b.image_url)}:{}}}catch{return null}},m=re({selector:`${n} ${r}`,root:i,visibleRatio:o,dwellMs:s,onViewable(w){let k=c(w);if(!k||k.dataset.hpListView==="manual")return!0;let b=l(k);if(!b||u.has(b.list_id))return!0;let x=new Set,h=f(k).map(p).filter(E=>!E||x.has(E.product_id)?!1:(x.add(E.product_id),!0));return h.length===0||(u.add(b.list_id),e.productListViewed({...b,products:h})),!0}}),A=w=>{let b=w.target?.closest?.("a[href]")?.closest(r);if(!b)return;let x=c(b),h=p(b,x?f(x).indexOf(b):0);h&&e.productClicked({list_id:x?l(x)?.list_id??null:null,products:[h]})};return document.addEventListener("click",A,!0),()=>{document.removeEventListener("click",A,!0),m()}}function D(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 qe(e,...t){let n=D(e,...t);if(n===null)return null;let r=Number(n);return Number.isFinite(r)?Math.trunc(r):null}function So(e,t){let n=D(e,"hpPromotion");return n?{promotion_id:n,name:D(e,"hpPromotionName"),creative:D(e,"hpPromotionCreative"),position:D(e,"hpPromotionSlot")??String(t+1)}:null}function At(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-promotion]",resolve:r=So,visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,u=new Set,c=p=>{let m=Array.from(i.querySelectorAll(n)),A=m.indexOf(p);try{return r(p,A<0?m.length:A)}catch{return null}},l=re({selector:n,root:i,visibleRatio:o,dwellMs:s,onViewable(p){let m=c(p);return!m||u.has(m.promotion_id)?!1:(u.add(m.promotion_id),e.promotionViewed(m),!0)}}),f=p=>{let m=p.target;if(!m||typeof m.closest!="function")return;let A=m.closest(n),w=m.closest("a[href]");if(!A||!w||!A.contains(w)&&!w.contains(A))return;let k=c(A);k&&e.promotionClicked({...k,href:w.getAttribute("href")})};return document.addEventListener("click",f,!0),()=>{document.removeEventListener("click",f,!0),l()}}function _o(e){let t=D(e,"hpRecoRequest"),n=D(e,"hpRecoPlacement"),r=D(e,"hpRecoStrategy");if(!t||!n||!r)return null;let o=D(e,"hpRecoHoldout");return{recommendation_request_id:t,placement:n,strategy:r,recipe:D(e,"hpRecoRecipe"),algorithm_version:D(e,"hpRecoAlgorithmVersion"),experiment:D(e,"hpRecoExperiment"),variant:D(e,"hpRecoVariant"),holdout:o===null?null:o==="true",assignment_bucket:qe(e,"hpRecoBucket"),assignment_unit_kind:D(e,"hpRecoUnitKind"),candidate_set_fingerprint:D(e,"hpRecoFingerprint"),candidate_set_size:qe(e,"hpRecoCandidates"),ranked_by:D(e,"hpRecoRankedBy"),served_at:D(e,"hpRecoServedAt")}}function bo(e,t){let n=D(e,"hpRecoProduct");if(!n)return null;let r=D(e,"hpRecoPrice");return{product_id:n,sku:D(e,"hpRecoSku"),name:D(e,"hpRecoName"),brand:D(e,"hpRecoBrand"),price:r===null||Number.isNaN(Number(r))?null:Number(r),position:qe(e,"hpRecoPosition")??t+1}}function vt(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=_o,resolveTile:s=bo,visibleRatio:i=.5,dwellMs:u=1e3,root:c=document}=t,l=new Set,f=new Map,p=new Map,m=(h,...E)=>{try{return h(...E)}catch{return null}},A=h=>typeof h.closest=="function"?h.closest(n):null,w=h=>Array.from(h.querySelectorAll(r)),k=(h,E)=>{if(p.delete(E.recommendation_request_id),l.has(E.recommendation_request_id))return;let S=w(h).map((y,O)=>m(s,y,O)).filter(y=>y?.product_id);if(S.length===0)return;l.add(E.recommendation_request_id);let g=[...f.get(E.recommendation_request_id)?.values()??[]].sort((y,O)=>y.position-O.position);e.recommendationsViewed({...E,products:S,viewable:g})},b=re({selector:`${n} ${r}`,root:c,visibleRatio:i,dwellMs:u,onViewable(h){let E=A(h);if(!E)return!0;let S=m(o,E);if(!S)return!0;let g=S.recommendation_request_id,y=m(s,h,w(E).indexOf(h));if(y?.product_id){f.has(g)||f.set(g,new Map);let O=f.get(g);O.has(y.position)||O.set(y.position,{position:y.position,product_id:y.product_id,viewable_at:new Date().toISOString()})}return!l.has(g)&&!p.has(g)&&p.set(g,setTimeout(()=>k(E,S),0)),!0}}),x=h=>{let E=h.target;if(!E||typeof E.closest!="function")return;let S=E.closest(r);if(!S)return;let g=E.closest("[data-hp-reco-interaction]"),y=E.closest("a[href]"),O=y&&(S.contains(y)||y.contains(S));if(!(g&&S.contains(g))&&!O)return;let N=A(S);if(!N)return;let U=m(o,N);if(!U)return;let G=m(s,S,w(N).indexOf(S));if(!G?.product_id)return;let q=U.recommendation_request_id;l.has(q)||(clearTimeout(p.get(q)),k(N,U)),e.productClicked({recommendation_request_id:U.recommendation_request_id,interaction:D(g??S,"hpRecoInteraction")??"navigate",products:[G]})};return document.addEventListener("click",x,!0),()=>{document.removeEventListener("click",x,!0);for(let h of p.values())clearTimeout(h);p.clear(),b()}}var _e=new Set(["home","list","product","search","basket","checkout","order_confirmation","login","register","account","info","blog","other"]),Io=new Set(["products"]),Cn=e=>e==null;function Et(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=>Et(r,t)):Object.fromEntries(Object.entries(e).filter(([,r])=>!Cn(r)).map(([r,o])=>[r,Et(o,t)]));return t.delete(e),n}function Ct(e){if(!e)return e;let t=Et(e);for(let n of Io)n in e&&Cn(e[n])&&(t[n]=e[n]);return t}function Pn(){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 ko=new Set(["","unknown","undefined","null","none","nil","nan","anonymous","guest","0","-1"]);function F(e){if(e==null)return null;let t=String(e).trim();return ko.has(t.toLowerCase())?null:t}var Ce=e=>typeof e=="string"&&e!==""?e:null;function oe(){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 On="1.21";function j(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 xo={gclid:"gclid",fbclid:"fbclid",ttclid:"ttclid"},Ao=/[a-z0-9._%+-]+@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}/i,vo=/\d(?:[ -]?\d){12,}/,Eo=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=!Eo.has(String(t).toLowerCase());return n.some(o=>Ao.test(o)||r&&vo.test(o))}function Ot(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(xo)]){let i=t.get(o);i&&!Tn(i,o)&&(n[s]=i)}return Object.keys(n).length?n:null}var Co=["email","e-mail","password","pass","pwd","token","auth","code","uid","customer_id","postcode","zip","phone","applyCode"],Po=["email","password","passwd","pwd","token","secret","auth","session","phone","postcode","zip","address","birth","card","cvv","iban","ssn","customerid","userid"],Oo=["tel","uid","dob"],Lo=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","gclid","fbclid","ttclid","msclkid"],To=new Set(Co.map(e=>e.toLowerCase()));function No(e){let t=String(e).toLowerCase();if(To.has(t))return!0;let n=t.replace(/[-_.]/g,"");return Po.some(o=>n.includes(o))?!0:String(e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(o=>Oo.includes(o))}function Pt(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?Pt([...t.queryParamAllowlist,...Lo]):null,o=Pt(t.queryParamBlocklist),s=Pt(t.sensitiveParamAllowlist);for(let u of new Set(n.keys()))(No(u)&&!s.some(l=>l.test(u))||n.getAll(u).some(l=>Tn(l,u))||(r?!r.some(l=>l.test(u)):o.some(l=>l.test(u))))&&n.delete(u);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 Lt(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 Tt(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Ln(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{2}$/.test(t)?t:null}function Nt(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 M(e,t){if(typeof e=="function")try{let n=e();if(n!=null)return n}catch{}return t}function Ro(e){return{...e.propertyId==null?{}:{property_id:String(e.propertyId)},channel:e.channel??null,market:e.market??null,environment:e.environment??null}}function Mo(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}}var Pe;function Do(){if(Pe!==void 0)return Pe;try{Pe=globalThis.Temporal?.Now?.timeZoneId?.()||Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{Pe=null}return Pe}function Mn(e,t={}){let n=typeof window<"u"?window.location:null,r={library:{name:e.libraryName,version:e.libraryVersion},spec:{version:On},source:Ro(e),session_id:M(e.getSessionId,null),identity_trust:F(M(e.getAnonymousId,null))?"device":"none",page:Mo(e),campaign:n?Ot(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:Tt(M(e.getCurrency,e.currency)),locale:Nt(M(e.getLocale,e.locale)),timezone:Do(),country:Ln(e.country),ship_to_country:Ln(M(e.getShipToCountry,e.shipToCountry)),ip:null,bot:null,consent:e.getConsent?.()??null,experiments:M(e.getExperiments,null),audiences:M(e.getAudiences,null),decisions:M(e.getDecisions,null),recommendations:M(e.getRecommendations,null),extensions:M(e.getExtensions,null)};return Dn(r,t)}function Dn(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]=Dn(e[r],o):o!==void 0&&(n[r]=o);return n}var fe=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",onsite:"thg_hp_onsite",visitCampaign:"thg_hp_visit_campaign"}),Uo={retry:"cdp.retry",sessionSignals:"cdp_session_signals",identified:"cdp_identified",previousPage:"cdp_prev_page_message_id"},Rt={...fe},Un=!1;function Ke(e){let t={...fe};for(let[n,r]of Object.entries(e??{})){if(!(n in fe))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}Rt=t}function P(e){return Rt[e]}var Vo="_",Vn=e=>e==null||e===""?Vo:String(e);function $(e,t,n){let r=`${e}:${Vn(t)}`;return n==null||n===""?r:`${r}:${n}`}function $n(e,t){return`${e}:${Vn(t)}:`}function Ge(){if(!Un){Un=!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(Uo)){if(n!==o&&!n.startsWith(`${o}:`))continue;let s=Rt[r]+n.slice(o.length);t.getItem(s)===null&&t.setItem(s,t.getItem(n)),t.removeItem(n)}}catch{}}}}var Dt=1800*1e3,ze=()=>{try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}},Mt=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}};function Bn(e,t=()=>Date.now()){return{read(){try{let n=ze()?.getItem(e),r=n?JSON.parse(n):null;return!r||t()-r.savedAt>Dt?(r&&ze()?.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?ze()?.removeItem(e):ze()?.setItem(e,JSON.stringify({savedAt:t(),items:n,anonymousId:r}))}catch{}}}}var $o=400*24*60*60;function se(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 Bo({name:e,domain:t=null,legacyKey:n,read:r,mint:o,mayStore:s,carried:i=null}){let u=null;try{u=Mt()?.getItem(n)||null}catch{u=null}let c=r(e)??u??i,l=!1,f=()=>{if(!(l||c===null||!s())&&(l=se(e,c,$o,t),!(!l||u===null)))try{Mt()?.removeItem(n),u=null}catch{}};return{get(){return c??(c=o()),f(),c},peek:()=>c,persist:f,forget(){se(e,"",0,t),c=null,l=!1;try{Mt()?.removeItem(n)}catch{}u=null}}}function jn(e,{carried:t=null,mayStore:n,orOwn:r=!1}){let o=e.anonymousIdSource,s=()=>Bo({name:P("anonymousId"),domain:e.consentCookieDomain??null,legacyKey:$(P("anonymousId"),e.propertyId),read:j,mint:oe,mayStore:n,carried:t});if(o?.source==="hp_cookie"){let c=s();return e.getAnonymousId=()=>c.get(),c}if(o?.source==="site_cookie"&&o.cookie){let c=o.cookie;e.getAnonymousId=()=>j(c)}if(!r)return null;let i=e.getAnonymousId,u=s();return e.getAnonymousId=()=>F(M(i,null))??u.get(),u}var jo=200;function Hn(e,t,n=()=>Date.now()){let r=()=>$(P("carried"),e),o=!1;function s(){try{let i=JSON.parse(sessionStorage.getItem(r())??"null");return!i||!(n()-i.savedAt<=Dt)?[]: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(-jo)})),!0)}catch{return!1}},close(){o=!0}}}var ma=fe.consent,We=Object.freeze({visitor:"visitor",host:"host"}),qn=()=>({basis:We.host}),Ho="hp-consent",pe=["analytics","marketing","personalisation","ad_user_data","ad_personalization"],Kn={analytics:"a",marketing:"m",personalisation:"p",ad_user_data:"aud",ad_personalization:"adp"},ne=()=>typeof window<"u",Gn=()=>ne()&&typeof window.cookieStore?.addEventListener=="function",Fo=e=>e===!0?!0:e===!1?!1:null;function be(e){if(!e||typeof e!="object")return null;let t={};for(let n of pe)t[n]=Fo(e[n]);return t}function Ut(e,t){return!e||!t?e===t:pe.every(n=>e[n]===t[n])}function Vt(e){if(!e)return"";let t=[];for(let n of pe){let r=e[n];(r===!0||r===!1)&&t.push(`${Kn[n]}=${r?1:0}`)}return t.join("&")}function $t(e){return{[Ho]:Vt(be(e))}}function Oe(e){let t=be({});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(Kn).map(([s,i])=>[i,s])),o=new Set;for(let s of n.split("&")){let i=s.indexOf("=");if(i<=0)continue;let u=r[s.slice(0,i).trim()],c={1:!0,0:!1}[s.slice(i+1).trim()]??null;!u||c===null||o.has(u)||(t[u]===null?t[u]=c:t[u]!==c&&(t[u]=null,o.add(u)))}return t}function Bt(e,t){if(!t)return e;let n=r=>{if(!r)return r;let o={...r};for(let s of pe)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 jt(e,t={}){return{...e,ad_user_data:t.ad_user_data??e.marketing,ad_personalization:t.ad_personalization??e.marketing}}function Je(e,t){let n=!0;return{notify:()=>{if(n)try{let o=e();o&&t(o)}catch{}},stop:()=>n=!1}}var qo={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 Ko(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(u=>{let c=String(u).toLowerCase();return s===c||s.startsWith(`${c}-`)})&&(n=!0,o?.enabled===!0))return!0}return n?!1:null}function zn(e={}){let t={...qo,...e.purposes};function n(){let r=ne()?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=>Ko(o,t[i]);return jt({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(!ne())return()=>{};let o=Je(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 Fn(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 Wn(e={}){let t={analytics:"C0002",personalisation:"C0003",marketing:"C0004",...e.groups},n=e.impliedConsent===!0;function r(){let i=Fn(j("OptanonConsent"));if(i.groups){let l={};for(let f of i.groups.split(",")){let[p,m]=f.split(":");p?.trim()&&(l[p.trim()]=m==="1"?!0:m==="0"?!1:null)}return f=>l[f]??!1}let u=ne()?window.OnetrustActiveGroups:void 0;if(typeof u!="string"||!u.length)return null;let c=new Set(u.split(",").map(l=>l.trim()).filter(Boolean));return l=>c.has(l)}function o(){if(j("OptanonAlertBoxClosed"))return!0;try{if(ne()&&window.OneTrust?.IsAlertBoxClosed?.()===!0)return!0}catch{}return n&&ne()&&(!!window.OneTrust||typeof window.OnetrustActiveGroups=="string")}function s(){if(!o())return null;let i=r();if(!i)return null;let u=p=>t[p]?i(t[p]):null,c=jt({analytics:u("analytics"),marketing:u("marketing"),personalisation:u("personalisation")},{ad_user_data:u("ad_user_data"),ad_personalization:u("ad_personalization")}),l=Fn(j("OptanonConsent"));return(typeof navigator<"u"&&navigator.globalPrivacyControl===!0||l.isGpcEnabled==="1")&&(c.marketing=!1,c.ad_user_data=!1,c.ad_personalization=!1),c}return{name:"onetrust",read:s,observesChanges:!0,subscribe(i){if(!ne())return()=>{};let u=Je(s,i),c=!1,l=()=>{c||!window.OneTrust?.OnConsentChanged||(c=!0,window.OneTrust.OnConsentChanged(u.notify))};window.addEventListener("OneTrustGroupsUpdated",u.notify);let f=window.OptanonWrapper;return window.OptanonWrapper=function(...m){try{typeof f=="function"&&f.apply(this,m)}finally{l(),u.notify()}},l(),()=>{u.stop(),window.removeEventListener("OneTrustGroupsUpdated",u.notify)}}}}function Go(e){let t=String(e).split(",").map(n=>n.trim()).filter(Boolean);return t.length?new Set(t):null}function Jn(e){let{name:t,categories:n,parse:r=Go,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 u(){let c=j(t);if(c==null)return null;let l;if(o!==void 0&&c===o)l=new Set;else try{l=r(c)}catch{l=null}if(!(l instanceof Set))return null;let f=p=>n[p]?l.has(n[p]):null;return jt({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:u,get observesChanges(){return Gn()},subscribe(c){if(!ne())return()=>{};let l=Je(u,c),f=p=>{[...p.changed??[],...p.deleted??[]].some(A=>A?.name===t)&&l.notify()};return window.addEventListener(i,l.notify),window.cookieStore?.addEventListener?.("change",f),()=>{l.stop(),window.removeEventListener(i,l.notify),window.cookieStore?.removeEventListener?.("change",f)}}}}function Yn(e={}){let t=e.name??P("consent"),n=()=>{let r=j(t);if(r==null)return null;let o=Oe(r);return o.analytics==null?null:o};return{name:"forwarded",read:n,get observesChanges(){return Gn()},subscribe(r){if(!ne())return()=>{};let o=Je(n,r),s=i=>{[...i.changed??[],...i.deleted??[]].some(c=>c?.name===t)&&o.notify()};return window.cookieStore?.addEventListener?.("change",s),()=>{o.stop(),window.cookieStore?.removeEventListener?.("change",s)}}}}function Xn(e){let t=be(e);return{name:"static",basis:We.host,read:()=>t?{...t}:null,observesChanges:!0,subscribe:()=>()=>{}}}function Zn(e){if(e==null)return null;let t=String(e).split("/").map(n=>n.trim()).filter(Boolean).join("/");return t===""?null:t}function zo(e){let t=e.item_category;if(t!=null&&String(t).includes("/"))return Zn(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 Zn(n.join("/"))}var Wo=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t};function Jo(...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 Ye=e=>Jo(e.item_group_id,e.item_id);function Yo(e,t=Ye){if(!e)return null;let n=u=>u==null||u===""||Number.isNaN(Number(u))?null:Number(u),r=u=>{let c=n(u);return c==null?null:Math.round(c*1e6)/1e6},o=u=>{let c=r(u);return c!=null&&c>=0?c:null},s=u=>{let c=n(u);return Number.isInteger(c)&&c>=0?c:null},i=Wo;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:zo(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 Ht(e,t=Ye){return(e??[]).map(n=>Yo(n,t)).filter(n=>n?.product_id)}var Xo=1e3,Zo={shipping:2,payment:3},Qo=new Set(["password","google","apple","facebook","magic_link","sso","passkey","other"]),H=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t},es=e=>{if(e==null||e===""||typeof e=="object")return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null},Xe=e=>e!==null&&typeof e=="object";function ts(e){return Array.isArray(e.items)?e.items.filter(Xe):null}function Qn(e){let t=H(e)?.toLowerCase().replace(/[\s-]+/g,"_");return t?Qo.has(t)?t:t==="email"||t==="email_password"?"password":"other":null}function ns({ecommerce:e,items:t}){let n=s=>({promotion_id:H(s.promotion_id),name:H(s.promotion_name),creative:H(s.creative_name),position:H(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 er=({ecommerce:e,items:t})=>H(e.item_list_id)??H(e.item_list_name)??H(t[0]?.item_list_id)??H(t[0]?.item_list_name),me=(e,t)=>t.products?.length?{event:e,properties:t}:null,rs=new Set(["product","products","item","items"]);function os({ecommerce:e}){let t=H(e.item_id),n=H(e.content_type)?.toLowerCase();return!t||n&&!rs.has(n)?null:{event:"Product Shared",properties:{share_via:H(e.method),products:[{product_id:t}]}}}function ss(e){let t=o=>me("Product List Viewed",{list_id:er(o),products:o.products}),n=o=>{let s=H(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=>me("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=>me("Product Clicked",{list_id:er(o),products:o.products.slice(0,1)}),add_to_cart:o=>me("Product Added",{cart_id:H(o.ecommerce.cart_id),products:o.products}),remove_from_cart:o=>me("Product Removed",{cart_id:H(o.ecommerce.cart_id),products:o.products}),view_cart:o=>({event:"Cart Viewed",properties:{cart_id:H(o.ecommerce.cart_id),value:o.value,currency:o.currency,coupon:H(o.ecommerce.coupon),...o.itemsListed?{products:o.products}:{}}}),begin_checkout:o=>me("Checkout Started",{value:o.value,currency:o.currency,coupon:H(o.ecommerce.coupon),products:o.products}),add_shipping_info:o=>({event:"Checkout Step Completed",properties:{step:e.shipping,step_name:"shipping",shipping_method:H(o.ecommerce.shipping_tier)}}),add_payment_info:o=>({event:"Payment Info Entered",properties:{step:e.payment,step_name:"payment",payment_method:H(o.ecommerce.payment_type)}}),view_promotion:r("Promotion Viewed"),select_promotion:r("Promotion Clicked"),add_to_wishlist:o=>me("Product Added to Wishlist",{products:o.products}),share:os,login:o=>({event:"Signed In",properties:{method:Qn(o.ecommerce.method)}}),sign_up:o=>({event:"Signed Up",properties:{method:Qn(o.ecommerce.method)}})}}var is=e=>e.event;function as(e,t){if(!Xe(e))return null;if(typeof e.length=="number"&&e[0]==="event"&&typeof e[1]=="string"){let r=Xe(e[2])?e[2]:{};return{name:e[1],entry:r,ecommerce:r}}let n=H(t(e));return n?{name:n,entry:e,ecommerce:Xe(e.ecommerce)?e.ecommerce:e}:null}function Ft(e){return Array.isArray(e)?`[${e.map(Ft).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Ft(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function tr(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=ss({...Zo,...t.steps}),o=t.map??{},s=t.eventName??is,i=t.productId??Ye,u=new Set(["purchase","refund",...t.ignore??[]]),c=t.dedupeMs??Xo,l=new Map,f=!0;function p(S,g,y){if(c<=0)return!1;let O=`${S}|${y??""}|${Ft(g)}`,N=Date.now();for(let[U,G]of l)N-G>c&&l.delete(U);return l.has(O)?!0:(l.set(O,N),!1)}let m=null,A=new Set;function w(S,g){if(S!=="Product Viewed")return!1;let y=typeof location>"u"?"":location.pathname;y!==m&&(m=y,A.clear());let O=g.products?.[0]?.product_id;return O?A.has(O)?!0:(A.add(O),!1):!1}function k({event:S,properties:g={}},y){if(!S||p(S,g,y)||w(S,g))return;let O=y?{context:{currency:y}}:void 0;if(S==="Signed Out"&&typeof e.signedOut=="function"){e.signedOut(O);return}e.track(S,g,O)}function b(S){let g=t.transform?t.transform(S):S,y=as(g,s);if(!y||u.has(y.name))return;let O=Object.hasOwn(o,y.name),N=O?o[y.name]:r[y.name];if(typeof N!="function")return;let U=ts(y.ecommerce),G=U??[],q={...y,items:G,itemsListed:U!==null,products:Ht(G,i),currency:Tt(y.ecommerce.currency),value:es(y.ecommerce.value)};q.promotions=ns(q);let ee=O?N(g,{...q,toProducts:J=>Ht(J,i)}):N(q);for(let J of[ee].flat())J&&k(J,q.currency)}function x(S){if(f)try{b(S)}catch(g){try{t.onError?.(g,S)}catch{}}}for(let S of n.slice())x(S);let h=n.push;function E(...S){let g=h.apply(this,S);for(let y of S)x(y);return g}return n.push=E,()=>{f=!1,n.push===E&&(n.push=h)}}var cs="hp_debug",us=256;function ls(){try{return new URLSearchParams(location.search).get(cs)}catch{return null}}function nr(e,t){if(typeof location>"u")return!1;try{let n=ls();if(n!==null){let o=n.trim();o===""||o.length>us?sessionStorage.removeItem(t):sessionStorage.setItem(t,o)}let r=sessionStorage.getItem(t);return!!(e&&r&&In(r)===e)}catch{return!1}}var Ie=class extends Error{},ds={inHoldout:()=>!0,personalisationGroup:()=>"excluded",servingHeaders:()=>({}),recommendationContext:()=>({}),flush:()=>Promise.resolve(),reset:()=>{}};function qt(e,t){let n=ds[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 Ie)throw i;return r(i)}}}function rr(e){for(let t of Reflect.ownKeys(e)){let{value:n}=Object.getOwnPropertyDescriptor(e,t)??{};typeof n=="function"&&(e[t]=qt(t,n))}return e}var Le=Symbol("hp.identityOption");var fs=4320*60*60,ps=100,ms=1e3,hs=2e3,or=500,Ze=e=>(e?.unref?.(),e);function gs(e,t){if(t?.analytics===!0&&e.analytics===!1)return"withdrawn";let n=pe.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 ys(e,t,n=P("consent")){if(!(typeof document>"u"))try{let r=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",o=t?`; Domain=${t}`:"";document.cookie=`${n}=${Vt(e)}; Path=/; Max-Age=${fs}; SameSite=Lax`+o+r}catch{}}function ws(e){let t=Oe(j(e));return pe.some(n=>t[n]!==null)?t:null}function sr(e){let{adapter:t,timeoutMs:n=5e3,cookieDomain:r=null,cookieName:o=P("consent"),release:s,announce:i}=e,u=e.discard??(()=>{}),c="pending",l=null,f=null,p=null,m=null,A=!1,w=null,k=[],b=R=>{c=R,e.onStatus?.(R)};function x(){try{return be(t.read())}catch{return null}}function h(){f&&clearInterval(f),p&&clearTimeout(p),f=null,p=null}let E=()=>typeof window<"u"&&typeof document<"u",S=()=>{try{return typeof t.subscribe=="function"&&t.observesChanges===!0}catch{return!1}};function g(){m&&clearInterval(m),m=null}function y(){A||m||l===null||S()||E()&&document.visibilityState==="hidden"||(m=Ze(setInterval(()=>q(x()),hs)))}let O=()=>c==="pending"||c==="unknown",N=e.store??null,U=()=>{let R=k.splice(0);N?.write([]);for(let K of R)s(K)},G=()=>{let R=k.splice(0);N?.write([]);for(let K of R)u(K)};function q(R){let K=be(R);if(!K||K.analytics===null)return;let Z=l===null,Y=Z?ws(o):l;if(!Z&&Ut(Y,K))return;h(),l=K,y(),ys(K,r,o);let ve=!Ut(Y,K);if(K.analytics){b("granted"),U(),ve&&i({action:gs(K,Y),state:K,previous:Y,withdrawal:!1});return}G(),Y?.analytics===!0&&i({action:"withdrawn",state:K,previous:Y,withdrawal:!0}),b("denied")}function ee(){p=null,c==="pending"&&(b("unknown"),f&&clearInterval(f),f=Ze(setInterval(()=>q(x()),ms)))}function J(R){if(O()){if(N){N.write(k);return}R?.type!=="visibilitychange"&&!R?.persisted&&G()}}let Se=R=>{document.visibilityState==="hidden"?(g(),J(R)):y()},je=R=>{g(),J(R)},ce=R=>{R?.persisted&&l!==null&&q(x()),y()};return{get status(){return c},get state(){return l?{...l}:null},stamp(){return l?{...l,source:t.name??null,basis:t.basis??We.visitor}:null},admits(){return c==="granted"},hold(R){return!O()||k.length>=or?(u(R),!1):(k.push(R),!0)},onHidden:J,start(){A=!1;try{w=t.subscribe?.(R=>q(R))??null}catch(R){e.debug&&console.warn("[hp] consent adapter subscribe failed",R)}E()&&(window.addEventListener("pagehide",je),window.addEventListener("pageshow",ce),document.addEventListener("visibilitychange",Se)),N&&k.length===0&&k.push(...N.read().slice(-or)),q(x()),!l&&(f=Ze(setInterval(()=>q(x()),ps)),p=Ze(setTimeout(ee,n)))},stop(){A=!0,h(),g(),typeof w=="function"&&w(),E()&&(window.removeEventListener("pagehide",je),window.removeEventListener("pageshow",ce),document.removeEventListener("visibilitychange",Se))}}}var Ss=["recommendation","search_rank","banner","offer","layout","copy","price","other"],Qe=e=>typeof e=="string"&&e!=="";function ir(e){return(Array.isArray(e?.decisions)?e.decisions:[]).filter(t=>Qe(t?.slot)&&Qe(t.decision_id)&&t.holdout!==!0).map(({decision_id:t,slot:n,arm:r,kind:o})=>({decision_id:t,slot:n,...Qe(r)&&{arm:r},...Ss.includes(o)&&{kind:o}}))}function ar({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=>Qe(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(u=>u.slot));n=[...r().filter(u=>!i.has(u.slot)),...s],o()},forget(){n=[];try{sessionStorage.removeItem(e)}catch{}}}}function _s(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 et(e,t,n=1e4){return _s(`${t}\0${e}`)%n}function Kt(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 Gt(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}=Kt(e),s=et(t,e.salt),i=c=>Math.round(c*1e4),u=r>0&&s<i(r)?"holdout":!n||s<i(r+o)?"personalised":"excluded";return{holdout:u==="holdout",bucket:s,group:u}}function cr(e,t){return typeof e!="string"||e===""||t==null||t===""?null:et(t,`bandit-vs-default:${e}`)<1e4/2?"default":"bandit"}var bs="hp_preview",Is=256;function ur(e,t=null){if(typeof location>"u")return j(e);let n=null;try{n=new URLSearchParams(location.search).get(bs)}catch{n=null}if(n===null)return j(e);let r=n.trim();return r===""||r.length>Is?(se(e,"",0,t),null):(se(e,r,null,t),r)}var ks=40,xs=128,As=5,vs=60,dr=e=>typeof e=="string"&&e!==""&&e.length<=xs&&!e.includes(","),lr=e=>Array.isArray(e)?e.filter(dr).slice(0,ks):[],Es=e=>Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.replaceAll(","," ").trim()).filter(t=>t!=="").slice(0,As):[],Cs=e=>Object.entries(e&&typeof e=="object"?e:{}).filter(([t,n])=>dr(t)&&Number.isFinite(n)&&n>=1).sort(([,t],[,n])=>n-t).slice(0,vs).map(([t,n])=>`${t}:${Math.floor(n)}`);function zt(e){let t={},n={viewed:lr(e?.recentProducts),basket:lr(e?.basketProducts),q:Es(e?.recentSearches),impressed:Cs(e?.impressions)};for(let[r,o]of Object.entries(n))o.length>0&&(t[r]=o.join(","));return t}var Ps=1800*1e3;function fr(e,t=Date.now()){try{localStorage.setItem(P("recommendationContext"),JSON.stringify({context:e,until:t+Ps}))}catch{}}function pr(){try{localStorage.removeItem(P("recommendationContext"))}catch{}}var Os="hp_sample",mr=1e4;function hr(e,t){return!(typeof t=="number"&&t<1)||e==null||e===""?!0:et(e,Os,mr)<Math.round(t*mr)}function ke(e){return e.trim().toLowerCase().replace(/\s*\/\s*/g,"/").replace(/^\/+|\/+$/g,"")}var Ls=2,Ts=12;function Te(e,t=Ls){return e.split("/").slice(0,t).join("/")}function Wt(e,t){if(typeof t!="string"||!t.trim())return null;let n=Te(ke(t));return n?(e.unshift(n),e.length=Math.min(e.length,Ts),n):null}var he=()=>P("sessionSignals"),xe=null,Jt=()=>xe??he();function gr(){try{return xe?localStorage:sessionStorage}catch{return}}function yr(e,t){let n=t==null?null:String(t),r=e?$(he(),n,e):null;if(r===xe)return;let o=xe===null?Ns():null;if(xe=r,!!xe)try{let s=Jt(),i=$n(he(),n);for(let u of Object.keys(localStorage))u.startsWith(i)&&u!==s&&localStorage.removeItem(u);o&&!localStorage.getItem(s)&&(localStorage.setItem(s,JSON.stringify(o)),sessionStorage.removeItem(he()))}catch{}}function Ns(){try{let e=sessionStorage.getItem(he());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.campaign)?t:null}catch{return null}}function tt(){return{productViews:0,listViews:0,cartAdds:0,searches:0,recentProducts:[],recentCategories:[],recentBrowse:[],basketProducts:[],basketValue:null,recentSearches:[],impressions:{},browsingCategory:null,recentBrowseCategories:[],browsingListing:null,listViewsByCategory:{},campaign:null,startedAt:0}}function Yt(){let e=gr();if(!e)return tt();try{let t=e.getItem(Jt());return t?{...tt(),...JSON.parse(t)}:{...tt(),startedAt:Date.now()}}catch{return{...tt(),startedAt:Date.now()}}}function Ne(e){let t=gr();if(t)try{t.setItem(Jt(),JSON.stringify(e))}catch{}}function Re(){return Yt()}function wr(){for(let e of[()=>sessionStorage,()=>localStorage])try{let t=e();t.removeItem(he());for(let n of Object.keys(t))n.startsWith(`${he()}:`)&&t.removeItem(n)}catch{}}var Xt=20,Sr=200,Rs=new Set(["Product Viewed","Product Clicked","Product Added","Product Added to Wishlist"]),Ms=new Set(["Product Viewed","Product Added"]),_r=50;function nt(e,t){let n=Wt(e.recentBrowse,t);return n?(e.recentBrowseCategories=[e.browsingListing?.category??null,...e.recentBrowseCategories].slice(0,e.recentBrowse.length),n):null}function Ds(e,t){let n=e.listViewsByCategory;n[t]=(n[t]??0)+1;let r=Object.keys(n);if(r.length>_r){let o={};for(let s of r.sort((i,u)=>n[u]-n[i]).slice(0,_r))o[s]=n[s];e.listViewsByCategory=o}}var br=e=>[...new Set(e.map(t=>t?.product_id).filter(t=>typeof t=="string"&&t))].slice(0,Xt);function Ir(e,t,n){let r=Yt();r.startedAt||(r.startedAt=Date.now());let o=n!==void 0&&JSON.stringify(n??null)!==JSON.stringify(r.campaign??null);o&&(r.campaign=n??null);let s=Array.isArray(t?.products)?t.products:[];switch(e){case"Product Viewed":r.productViews+=1,nt(r,r.browsingCategory);break;case"Product List Viewed":{let c=t?.list_id,l=t?.category;if(!(typeof c=="string"&&c.includes("/")&&!c.startsWith("cdp-")))break;let p=typeof l=="string"&&Te(ke(l))||null,m=p?Te(ke(c)):"";if(!m){r.browsingCategory=null,r.browsingListing=null;break}r.browsingListing={key:m,category:p},nt(r,m),r.browsingCategory=m,Ds(r,p),r.listViews+=1}break;case"Product List Filtered":{let c=t?.change,l=typeof t?.list_id=="string"?t.list_id:"",f=typeof c?.value=="string"?c.value:"",p=r.browsingListing;if(f&&c?.action!=="removed"&&p&&Te(ke(l))===p.key){let m=nt(r,`${l}/${f}`);m&&(r.browsingCategory=m)}break}case"Product Added":{r.cartAdds+=1,nt(r,r.browsingCategory);for(let c of s){let l=c.product_id;typeof l!="string"||!l||(r.basketProducts=[l,...r.basketProducts.filter(f=>f!==l)].slice(0,Xt))}break}case"Product Removed":{for(let c of s){let l=c.product_id;typeof l=="string"&&l&&(r.basketProducts=r.basketProducts.filter(f=>f!==l))}break}case"Products Searched":{r.searches+=1;let c=t?.query;if(typeof c=="string"&&c.trim()){let l=c.trim().toLowerCase().slice(0,64);r.recentSearches=[l,...r.recentSearches.filter(f=>f!==l)].slice(0,5)}break}case"Product Clicked":case"Product Added to Wishlist":break;case"Cart Viewed":return s.length>0&&(r.basketProducts=br(s)),Ne(r),r;case"Cart Updated":{Array.isArray(t?.products)&&(r.basketProducts=br(s));let c=t?.value;return r.basketValue=typeof c=="number"&&Number.isFinite(c)&&c>=0?c:null,Ne(r),r}default:return o&&Ne(r),r}let i=Rs.has(e);if(i)for(let c of s)typeof c.product_id=="string"&&c.product_id&&delete r.impressions[c.product_id];else{for(let l of s){let f=l.product_id;typeof f!="string"||!f||(r.impressions[f]=(r.impressions[f]??0)+1)}let c=Object.keys(r.impressions);if(c.length>Sr){let l={};for(let f of c.sort((p,m)=>r.impressions[m]-r.impressions[p]).slice(0,Sr))l[f]=r.impressions[f];r.impressions=l}}let u=new Set;for(let c of s){let l=c.product_id;if(i&&typeof l=="string"&&l&&(r.recentProducts=[l,...r.recentProducts.filter(f=>f!==l)].slice(0,Xt)),Ms.has(e)&&typeof c.category=="string"&&c.category){let f=ke(c.category);f&&!u.has(f)&&(u.add(f),Wt(r.recentCategories,f))}}return Ne(r),r}var rt=1800*1e3;function kr({name:e,domain:t=null,mayStore:n,now:r=()=>Date.now(),mint:o=oe}){let s=null,i=0,u=()=>{s!==null&&n()&&se(e,s,rt/1e3,t)};return{get(){let c=r(),l=j(e);return l?s=l:(s===null||c-i>=rt)&&(s=o()),i=c,u(),s},persist:u,forget(){se(e,"",0,t),s=null}}}var W=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),xr=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Ar=Object.freeze({enabled:!1}),Qt=Object.freeze({enabled:!0,queryParamAllowlist:Object.freeze([])});function vr(e,t){let n=e?.track;return W(n)?(Object.hasOwn(n,t)?n[t]:n.__default)?.enabled!==!1:!0}function Us(e,t){return`${ie(e)}/v1/projects/${encodeURIComponent(t)}/settings`}var Vs="https://hp.thgingenuity.com";function ie(e){return e==null||e===""?Vs:Cr(e)}function Er(e,t){return e!=null&&e!==""?ie(e):t?.startsWith("https://")?t:ie(void 0)}function Cr(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 $s(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 Zt=e=>typeof e=="number"&&e>=0&&e<=1,Bs=/^[0-9a-f]{64}$/;function js(e){return W(e)?{enabled:e.enabled===!0,tokenSha256:typeof e.tokenSha256=="string"&&Bs.test(e.tokenSha256)?e.tokenSha256:null}:{enabled:!1,tokenSha256:null}}function Hs(e){if(!W(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>W(n)&&Zt(n.share)&&(n.ramp==null||Zt(n.ramp))&&typeof n.salt=="string"&&n.salt!=="").map(([n,r])=>[n,{share:r.share,ramp:r.ramp??null,salt:r.salt,...xr(r.readoutSlots)&&r.readoutSlots.length>0&&{readoutSlots:r.readoutSlots}}]));return Object.keys(t).length?t:null}var Fs=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;function qs(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"&&Fs.test(e.cookie)?{source:"site_cookie",cookie:e.cookie}:null:null}function Ks(e){let t=Array.isArray(e?.forms)?e.forms.filter(W):[];return t.length===0?null:{forms:t,capture:W(e.capture)?e.capture:null,...Number.isInteger(e.overlay_gap_minutes)?{overlay_gap_minutes:e.overlay_gap_minutes}:{}}}function Gs(e){let t=W(e)?e.hp:null;return W(t)&&typeof t.enabled=="boolean"}function en(e){let t=W(e)?e.hp:null;if(!W(t)||t.enabled!==!0)return Ar;let n=Ks(t.onsite);return{enabled:!0,propertyId:typeof t.propertyId=="string"&&t.propertyId!==""?t.propertyId:null,environment:typeof t.environment=="string"?t.environment:null,consentPurposes:$s(t.consent?.purposes),queryParamAllowlist:xr(t.queryParamAllowlist)?t.queryParamAllowlist:null,anonymousId:qs(t.anonymousId),apiHost:Cr(t.apiHost),holdouts:Hs(t.holdouts),sampleRate:Zt(t.sampleRate)?t.sampleRate:1,debug:js(t.debug),...n&&{onsite:n},plan:W(e.plan)&&W(e.plan.track)?{track:e.plan.track}:null}}var zs=3e3;async function Pr(e,t,n=globalThis.fetch,r=zs){try{let o=await n(Us(e,t),{credentials:"omit",headers:{accept:"application/json"},signal:AbortSignal.timeout?.(r)});if(o.status>=400&&o.status<500&&o.status!==408&&o.status!==429)return Ar;if(!o.ok)return null;let s=await o.json();return Gs(s)?en(s):null}catch{return null}}var ot=e=>$(P("settings"),e);function Or(e){try{let t=localStorage.getItem(ot(e));if(!t)return null;let n=JSON.parse(t);return n?.enabled===!0?n:null}catch{return null}}function Lr(e,t){try{t?.enabled===!0?localStorage.setItem(ot(e),JSON.stringify(t)):localStorage.removeItem(ot(e))}catch{}}function tn(e){try{localStorage.removeItem(ot(e))}catch{}}var Ws={flushAt:20,flushIntervalMs:1e4,maxQueue:500,maxRetryAgeMs:1440*60*1e3,maxRetries:5,maxPersistedBatches:20,maxPersistedBytes:1024*1024,storageKey:fe.retry,beaconSafeBytes:56*1024,maxBatchEvents:100,maxBatchBytes:500*1024},st=()=>Date.now(),Tr=3e4,cn=55*1024;function Js(e,t=st()){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 ae=e=>typeof TextEncoder<"u"?new TextEncoder().encode(e).length:Buffer.byteLength(e),nn=()=>typeof window<"u"&&typeof document<"u";function Ys(){try{return!nn()||!window.localStorage?null:(window.localStorage.getItem("thg_hp_probe"),window.localStorage)}catch{return null}}var I,rn,on,it,sn,an,Nr,Me,De,Ue,Rr,at,Mr,ct,ut=class{constructor(t){_n(this,I);this.o={...Ws,...t},this.queue=[],this.timer=null,this.storage=Ys(),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,this.failing=!1,this.answered=!1,nn()&&(window.addEventListener("pagehide",()=>this.flush({beacon:!0})),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()}),L(this,I,ct).call(this))}markFailing(){this.answered||(this.failing=!0)}replayPersisted(){return this.replayAllowed=!0,L(this,I,ct).call(this)}clearPersisted(){if(this.replayAllowed=!1,!!this.storage)try{let t=L(this,I,Ue).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(),L(this,I,on).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():L(this,I,rn).call(this)}flush(t={}){if(L(this,I,on).call(this),this.queue.length===0)return Promise.resolve();if(t.beacon&&nn()&&typeof navigator<"u"&&navigator.sendBeacon)return L(this,I,Nr).call(this),Promise.resolve();if(this.inflight)return this.inflight;let n=L(this,I,an).call(this,this.queue,this.o.maxBatchEvents,this.o.maxBatchBytes).map(o=>{let s=L(this,I,at).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){L(this,I,De).call(this,s);continue}await L(this,I,Me).call(this,o,0,s,r)}})().finally(()=>{this.inflight=null,this.queue.length>=this.o.flushAt?this.flush():this.queue.length&&L(this,I,rn).call(this)}),this.inflight}};I=new WeakSet,rn=function(){this.timer||(this.timer=setTimeout(()=>this.flush(),this.o.flushIntervalMs),this.timer?.unref?.())},on=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},it=function(t){return JSON.stringify({batch:t,writeKey:this.o.writeKey,sentAt:new Date().toISOString()})},sn=function(){return`${this.o.apiHost.replace(/\/$/,"")}/v1/batch`},an=function(t,n,r){let o=ae(L(this,I,it).call(this,[])),s=[],i=[],u=o;for(let c of t){let l=ae(JSON.stringify(c))+1;i.length&&(i.length>=n||u+l>r)&&(s.push(i),i=[],u=o),i.push(c),u+=l}return i.length&&s.push(i),s},Nr=function(){let t=this.queue;this.queue=[];let n=L(this,I,sn).call(this);for(let r of L(this,I,an).call(this,t,this.o.maxBatchEvents,this.o.beaconSafeBytes)){let o=L(this,I,it).call(this,r);if(ae(o)<=this.o.beaconSafeBytes){let s=!1;try{s=navigator.sendBeacon(n,new Blob([o],{type:"text/plain"}))}catch{s=!1}if(s){let i=this.failing?L(this,I,at).call(this,r):null;i&&this.sending.add(i);continue}}L(this,I,Me).call(this,r,0,L(this,I,at).call(this,r))}},Me=async function(t,n,r=null,o=this.epoch){r&&this.sending.add(r);let s=L(this,I,it).call(this,t),i=0;try{let u=await fetch(L(this,I,sn).call(this),{method:"POST",headers:{"Content-Type":"text/plain"},body:s,keepalive:ae(s)<=this.o.beaconSafeBytes});if(u.ok)return this.failing=!1,this.answered=!0,L(this,I,De).call(this,r),L(this,I,ct).call(this),!0;let c=u.status===408||u.status===429||u.status>=500;if(c&&(i=Js(u.headers?.get?.("retry-after"))),!c)return L(this,I,De).call(this,r),this.o.onError?.(`CDP ingest rejected batch (${u.status}); dropping ${t.length} events`),!0;throw new Error(`retryable ${u.status}`)}catch(u){if(this.failing=!0,n>=this.o.maxRetries){r&&this.sending.delete(r);let l=r?"kept for the next page":"dropped";return this.o.onError?.(`CDP ingest unreachable after ${n} attempts; ${l}: ${t.length} events`,u),!1}let c=Math.max(Math.min(1e3*2**n,Tr)*(.5+Math.random()),Math.min(i,Tr));return o===this.epoch&&await new Promise(l=>{let f=()=>{clearTimeout(p),this.wakers.delete(f),l()},p=setTimeout(f,c);this.wakers.add(f)}),o!==this.epoch?(L(this,I,De).call(this,r),!1):L(this,I,Me).call(this,t,n+1,r,o)}},De=function(t){t&&(this.sending.delete(t),this.sinceRefusal.delete(t),L(this,I,Mr).call(this,t))},Ue=function(){let t=JSON.parse(this.storage.getItem(this.o.storageKey)||"[]");return Array.isArray(t)?t:[]},Rr=function(t,n){let r=i=>ae(JSON.stringify(i))+1,o=[...t,n].slice(-this.o.maxPersistedBatches),s=o.reduce((i,u)=>i+r(u),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},at=function(t){if(!this.storage||this.o.mayPersist&&!this.o.mayPersist())return null;try{let n={at:st(),id:`${st()}-${Math.random().toString(36).slice(2)}`,batch:t};return ae(JSON.stringify(n))+3>this.o.maxPersistedBytes?null:L(this,I,Rr).call(this,L(this,I,Ue).call(this),n)?n.id:null}catch{return null}},Mr=function(t){if(!(!t||!this.storage))try{let n=L(this,I,Ue).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{}},ct=function(){if(!this.storage||!this.replayAllowed)return this.draining??Promise.resolve();if(this.draining)return this.draining;let t;try{let r=L(this,I,Ue).call(this);t=r.filter(o=>Array.isArray(o?.batch)&&st()-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 L(this,I,Me).call(this,r.batch,0,r.id))return})().finally(()=>{this.draining=null}),this.draining):Promise.resolve()};var un="3.29.0",ln="@thg-agentic/hyper-personalisation-web";var Xs=100,Zs=["source","medium","campaign","content","term"];function Ur(e){if(!e||typeof e!="object")return null;let t={};for(let n of Zs){let r=e[n==="campaign"?"name":n];typeof r=="string"&&r&&(t[n]=r.slice(0,Xs))}return Object.keys(t).length?t:null}var Vr=e=>$(P("visitCampaign"),e==null?null:String(e)),Ae=new Map;function $r(e){if(Ae.has(e))return Ae.get(e);try{let t=JSON.parse(localStorage.getItem(e));return t&&typeof t=="object"?t:null}catch{return null}}function Dr(e,t){try{t?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e),Ae.delete(e)}catch{t?Ae.set(e,t):Ae.delete(e)}}function Br(e,t,n){return typeof e?.tags=="object"&&e.tags!==null&&Number.isFinite(e.at)&&n-e.at<rt&&!(t&&e.sid&&e.sid!==t)?e:null}function lt(e,{sessionId:t=null,now:n=Date.now()}={}){return Br($r(Vr(e)),t,n)?.tags??null}function jr(e,t,{sessionId:n=null,keepSession:r=!1,now:o=Date.now()}={}){let s=Vr(e),i=$r(s),u=Br(i,n,o),c=u?.tags??t??null;return c?Dr(s,{tags:c,at:o,sid:(r?n:null)??u?.sid??null}):i&&Dr(s,null),c}function dn(){Ae.clear();try{let e=`${P("visitCampaign")}:`;for(let t of Object.keys(localStorage))t.startsWith(e)&&localStorage.removeItem(t)}catch{}}var Qs=new Set(["audiences","decisions","recommendations"]);var ei=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),ti=Symbol.for("@thg-agentic/hyper-personalisation-web.unreachable"),ni=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite-access");function ri(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 oi="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";function si(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 ft(e){if(typeof e!="string")return null;let t=si(e.trim());return t===oi?null:t}var Hr=Object.freeze({email_sha256:"sha256",phone_sha256:"sha256",accepts_marketing:"boolean",gender:"string",created_at:"date-time"}),ii=/^\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 ai(e){if(typeof e!="string"||!ii.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 ci(e,t){return t===null?null:e==="sha256"?ft(t)??void 0:e==="date-time"?t instanceof Date?Number.isNaN(t.getTime())?void 0:t.toISOString():ai(t)?t:void 0:typeof t===e?t:void 0}function ui(e,t){let n={},r=[];for(let[o,s]of Object.entries(e)){let i=Object.hasOwn(Hr,o)?Hr[o]:null,u=i?ci(i,s):void 0;u===void 0?r.push(o):n[o]=u}return t&&r.length&&console.warn(`[hp] identify: not sent, not spec traits: ${r.join(", ")}`),n}var Fr=!1,qr=!1;function li(){qr||(qr=!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 di(e){!e||Fr||(Fr=!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 fi(e){try{return ae(JSON.stringify(e))}catch{return 0}}function dt(e){return e&&typeof e.context=="object"&&e.context!==null?e.context:e}function pi(e,t){if(e==null||String(e)===t)return;let n=[["localStorage","retry",(r,o)=>[...Array.isArray(r)?r:[],...Array.isArray(o)?o:[]]],["sessionStorage","held",(r,o)=>o?{...o,items:[...r.items??[],...o.items??[]]}:r]];for(let[r,o,s]of n)try{let i=globalThis[r],u=$(P(o),e),c=i?.getItem(u);if(!c)continue;let l=$(P(o),t),f=i.getItem(l);i.setItem(l,JSON.stringify(s(JSON.parse(c),f?JSON.parse(f):null))),i.removeItem(u)}catch{}}function Kr(e){let t=ie(e?.apiHost);if(!t)throw new Error("createAnalytics: apiHost, when given, must be a host or an http(s) origin");if(e?.propertyId!==null&&!e?.propertyId)throw new Error("createAnalytics: propertyId is required (null: the ingest stamps the key\u2019s)");let n={libraryName:ln,libraryVersion:un,writeKey:"web",queryParamBlocklist:[],debug:!1,validate:null,consentTimeoutMs:5e3,...e,apiHost:t};Ke(n.storageNames),Ge();let r=!!n.consent;r||li();let o=null;n.getConsent=()=>o?o.stamp():qn();let s=()=>!r||o?.status==="granted";pi(n.propertyId,n.writeKey);let i=r&&n.holdAcrossPages?Bn($(P("held"),n.writeKey)):null,u=i?.read()??{items:[],anonymousId:null};n.mintAnonymousId!==void 0&&di(n.debug);let c=jn(n,{carried:u.anonymousId,mayStore:s,orOwn:!0}),l=kr({name:P("session"),domain:n.consentCookieDomain??null,mayStore:s}),f=n.getSessionId;n.getSessionId=()=>F(M(f,null))??l.get();let p=ur(P("preview"),n.consentCookieDomain??null),m=()=>F(M(f,null))??j(P("session")),A=Ur(typeof location>"u"?null:Ot(location.search)),w=(a=null)=>{p||jr(n.propertyId,a,{sessionId:m(),keepSession:s()})},k=(a,d)=>n.debug&&console.warn("[hp]",a,d??""),b=n.transport??new ut({apiHost:n.apiHost,writeKey:n.writeKey,storageKey:$(P("retry"),n.writeKey),mayPersist:r?()=>o?.status==="granted":void 0,deferReplay:r,onError:k}),x=$(P("previousPage"),n.propertyId),h=null,E=()=>{if(h)return h;try{return sessionStorage.getItem(x)||null}catch{return null}};typeof window<"u"&&window.addEventListener("pageshow",a=>{a.persisted&&(h=null)});let S=a=>{if(h=a||null,!(r&&o.status!=="granted"))try{sessionStorage.setItem(x,a)}catch{}},g=ar({key:$(P("decisions"),n.propertyId),mayStore:s});n.getDecisions??(n.getDecisions=g.current);let y=F(M(n.getUserId,null)),O=null,N=null,U=y?Ce(n.identityToken):null,G=null,q=null,ee=null,J=new Set,Se=new Set;function je(a){if(a.type==="page"&&(ee=null),a.type==="track"&&a.event==="Product Viewed"){let _=a.properties?.products?.[0]?.product_id;ee=typeof _=="string"&&_?_:ee}if(a.type!=="track"||a.event!=="Cart Updated")return;let d=a.properties?.value;q=typeof d=="number"&&Number.isFinite(d)&&d>=0?d:null;for(let _ of J)try{_()}catch(C){console.warn("[hp] a basket listener failed",C)}}function ce(a,d,_=!1){je(a),w();try{return R(a,d,_)}catch(C){if(C instanceof Ie)throw C;return console.warn("[hp] the event was not sent",C),null}}function R(a,d,_){let C=G;G=null;let V=a.type==="track"?a.event:a.type;if(!_&&!vr(n.plan,V))return null;let T={messageId:C?.messageId??oe(),timestamp:C?.timestamp??new Date().toISOString(),anonymousId:F(M(n.getAnonymousId,null)),userId:y??null,...a,context:Mn(n,dt(d))};if(T.properties&&(T.properties=Ct(T.properties)),typeof T.properties?.href=="string"&&(T.properties.href=Lt(T.properties.href,n)),!_&&!hr(T.anonymousId,n.sampleRate))return n.debug&&console.debug("[hp] not sent: outside the sample",T),null;if(n.beforeSend){let te;try{te=n.beforeSend(T)}catch(uo){return console.warn("[hp] beforeSend failed; the event was not sent",uo),null}if(!te)return null;let{type:z,event:wn,messageId:ao,timestamp:co}=T;T={...te,type:z,messageId:ao,timestamp:co,...wn?{event:wn}:{}}}if(n.validate){let te=n.validate(T,{producer:"web"});if(!te.valid){let z=`[hp] invalid ${T.event??T.type}:
|
|
1
|
+
(()=>{var Sn=e=>{throw TypeError(e)};var lo=(e,t,n)=>t.has(e)||Sn("Cannot "+n);var _n=(e,t,n)=>t.has(e)?Sn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var L=(e,t,n)=>(lo(e,t,"access private method"),n);var Ee=[];for(let e=2;Ee.length<64;e++)Ee.every(t=>e%t!==0)&&Ee.push(e);var bn=e=>(e-Math.floor(e))*2**32>>>0,fo=Ee.slice(0,8).map(e=>bn(Math.sqrt(e))),po=Ee.map(e=>bn(Math.cbrt(e))),Q=(e,t)=>e>>>t|e<<32-t;function In(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(fo),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 k=o[w-15],b=o[w-2],x=Q(k,7)^Q(k,18)^k>>>3,h=Q(b,17)^Q(b,19)^b>>>10;o[w]=o[w-16]+x+o[w-7]+h}let[i,u,c,l,f,p,m,A]=r;for(let w=0;w<64;w++){let k=Q(f,6)^Q(f,11)^Q(f,25),b=A+k+(f&p^~f&m)+po[w]+o[w]|0,h=(Q(i,2)^Q(i,13)^Q(i,22))+(i&u^i&c^u&c)|0;[A,m,p,f,l,c,u,i]=[m,p,f,l+b|0,c,u,i,b+h|0]}[i,u,c,l,f,p,m,A].forEach((w,k)=>{r[k]+=w})}return Array.from(r,s=>s.toString(16).padStart(8,"0")).join("")}var It=(e,t)=>e<<t|e>>>32-t;function kn(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]:It(r[p-3]^r[p-8]^r[p-14]^r[p-16],1);let[i,u,c,l,f]=n;for(let p=0;p<80;p++){let m,A;p<20?(m=u&c|~u&l,A=1518500249):p<40?(m=u^c^l,A=1859775393):p<60?(m=u&c|u&l|c&l,A=2400959708):(m=u^c^l,A=3395469782);let w=It(i,5)+m+f+A+r[p]|0;[f,l,c,u,i]=[l,c,It(u,30),i,w]}[i,u,c,l,f].forEach((p,m)=>{n[m]+=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 mo="e28e8ada-5b76-4209-bba9-79b823a0af75",ho=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");function xn(e,t){let n=Uint8Array.from(e.replace(/-/g,"").match(/../g),u=>Number.parseInt(u,16)),r=new TextEncoder().encode(t),o=new Uint8Array(16+r.length);o.set(n),o.set(r,16);let s=kn(o).slice(0,16);s[6]=s[6]&15|80,s[8]=s[8]&63|128;let i=ho(s);return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}var ue=(e,t)=>typeof e=="string"&&e!==""&&e.length<=t?e:null;function Fe(e,t){return ue(e,64)??ue(t,256)}function An({sessionId:e,slot:t,arm:n}={}){let r=ue(e,256);return!r||!ue(t,256)||!ue(n,256)?null:xn(mo,`${r}:${t}:${n}`)}var go="4b1f2c7e-9a3d-4e58-b6c1-2d7f0a9e8c53";function vn({sessionId:e,surface:t}={}){let n=ue(e,256);return!n||!ue(t,64)?null:xn(go,`${n}:${t}`)}var yo=Array.from({length:11},(e,t)=>t/10);function wo(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,u=o?Math.min(i,o.width*o.height):i;return u>0&&s/u>=t}function re(e){let{selector:t,onViewable:n,visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=e,i=new Map,u=new WeakSet,c=new Set,l=h=>{i.has(h)||i.set(h,setTimeout(()=>{i.delete(h),n(h)&&(p?.unobserve(h),c.delete(h))},o))},f=h=>{clearTimeout(i.get(h)),i.delete(h)},p=typeof IntersectionObserver>"u"?null:new IntersectionObserver(h=>{for(let E of h){let S=E.target;if(!wo(E,r)){c.delete(S),f(S);continue}c.add(S),m()&&l(S)}},{threshold:yo}),m=()=>typeof document>"u"||document.visibilityState!=="hidden",A=()=>{if(m())for(let h of c)l(h);else for(let h of c)f(h)};document.addEventListener("visibilitychange",A);let w=()=>{for(let h of s.querySelectorAll(t))u.has(h)||(u.add(h),p?.observe(h))},k=typeof MutationObserver>"u"?null:new MutationObserver(()=>w()),b=()=>{w(),k?.observe(s===document?document.body:s,{childList:!0,subtree:!0})},x=s===document&&!document.body;return x?document.addEventListener("DOMContentLoaded",b,{once:!0}):b(),()=>{x&&document.removeEventListener("DOMContentLoaded",b),document.removeEventListener("visibilitychange",A),p?.disconnect(),k?.disconnect();for(let h of i.values())clearTimeout(h);i.clear(),c.clear()}}function kt(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 re({selector:n,root:s,visibleRatio:r,dwellMs:o,onViewable(i){let u=i.dataset?.hpExposure?.trim();return u&&e.surfaceViewed({surface:u}),!0}})}var En=e=>{try{return new URL(e,document.baseURI).toString()}catch{return e}};function xt(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,u=new Set,c=w=>w.closest?.(n)??null,l=w=>{let k=w.dataset.hpList?.trim();return k?{list_id:k,category:w.dataset.hpListCategory?.trim()||null}:null},f=w=>Array.from(w.querySelectorAll(r)).filter(k=>c(k)===w),p=(w,k)=>{try{let b=JSON.parse(w.dataset.hpProduct??"");return!b||typeof b!="object"||!b.product_id?null:{...b,position:b.position??k+1,...b.url?{url:En(b.url)}:{},...b.image_url?{image_url:En(b.image_url)}:{}}}catch{return null}},m=re({selector:`${n} ${r}`,root:i,visibleRatio:o,dwellMs:s,onViewable(w){let k=c(w);if(!k||k.dataset.hpListView==="manual")return!0;let b=l(k);if(!b||u.has(b.list_id))return!0;let x=new Set,h=f(k).map(p).filter(E=>!E||x.has(E.product_id)?!1:(x.add(E.product_id),!0));return h.length===0||(u.add(b.list_id),e.productListViewed({...b,products:h})),!0}}),A=w=>{let b=w.target?.closest?.("a[href]")?.closest(r);if(!b)return;let x=c(b),h=p(b,x?f(x).indexOf(b):0);h&&e.productClicked({list_id:x?l(x)?.list_id??null:null,products:[h]})};return document.addEventListener("click",A,!0),()=>{document.removeEventListener("click",A,!0),m()}}function D(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 qe(e,...t){let n=D(e,...t);if(n===null)return null;let r=Number(n);return Number.isFinite(r)?Math.trunc(r):null}function So(e,t){let n=D(e,"hpPromotion");return n?{promotion_id:n,name:D(e,"hpPromotionName"),creative:D(e,"hpPromotionCreative"),position:D(e,"hpPromotionSlot")??String(t+1)}:null}function At(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-promotion]",resolve:r=So,visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,u=new Set,c=p=>{let m=Array.from(i.querySelectorAll(n)),A=m.indexOf(p);try{return r(p,A<0?m.length:A)}catch{return null}},l=re({selector:n,root:i,visibleRatio:o,dwellMs:s,onViewable(p){let m=c(p);return!m||u.has(m.promotion_id)?!1:(u.add(m.promotion_id),e.promotionViewed(m),!0)}}),f=p=>{let m=p.target;if(!m||typeof m.closest!="function")return;let A=m.closest(n),w=m.closest("a[href]");if(!A||!w||!A.contains(w)&&!w.contains(A))return;let k=c(A);k&&e.promotionClicked({...k,href:w.getAttribute("href")})};return document.addEventListener("click",f,!0),()=>{document.removeEventListener("click",f,!0),l()}}function _o(e){let t=D(e,"hpRecoRequest"),n=D(e,"hpRecoPlacement"),r=D(e,"hpRecoStrategy");if(!t||!n||!r)return null;let o=D(e,"hpRecoHoldout");return{recommendation_request_id:t,placement:n,strategy:r,recipe:D(e,"hpRecoRecipe"),algorithm_version:D(e,"hpRecoAlgorithmVersion"),experiment:D(e,"hpRecoExperiment"),variant:D(e,"hpRecoVariant"),holdout:o===null?null:o==="true",assignment_bucket:qe(e,"hpRecoBucket"),assignment_unit_kind:D(e,"hpRecoUnitKind"),candidate_set_fingerprint:D(e,"hpRecoFingerprint"),candidate_set_size:qe(e,"hpRecoCandidates"),ranked_by:D(e,"hpRecoRankedBy"),served_at:D(e,"hpRecoServedAt")}}function bo(e,t){let n=D(e,"hpRecoProduct");if(!n)return null;let r=D(e,"hpRecoPrice");return{product_id:n,sku:D(e,"hpRecoSku"),name:D(e,"hpRecoName"),brand:D(e,"hpRecoBrand"),price:r===null||Number.isNaN(Number(r))?null:Number(r),position:qe(e,"hpRecoPosition")??t+1}}function vt(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=_o,resolveTile:s=bo,visibleRatio:i=.5,dwellMs:u=1e3,root:c=document}=t,l=new Set,f=new Map,p=new Map,m=(h,...E)=>{try{return h(...E)}catch{return null}},A=h=>typeof h.closest=="function"?h.closest(n):null,w=h=>Array.from(h.querySelectorAll(r)),k=(h,E)=>{if(p.delete(E.recommendation_request_id),l.has(E.recommendation_request_id))return;let S=w(h).map((y,O)=>m(s,y,O)).filter(y=>y?.product_id);if(S.length===0)return;l.add(E.recommendation_request_id);let g=[...f.get(E.recommendation_request_id)?.values()??[]].sort((y,O)=>y.position-O.position);e.recommendationsViewed({...E,products:S,viewable:g})},b=re({selector:`${n} ${r}`,root:c,visibleRatio:i,dwellMs:u,onViewable(h){let E=A(h);if(!E)return!0;let S=m(o,E);if(!S)return!0;let g=S.recommendation_request_id,y=m(s,h,w(E).indexOf(h));if(y?.product_id){f.has(g)||f.set(g,new Map);let O=f.get(g);O.has(y.position)||O.set(y.position,{position:y.position,product_id:y.product_id,viewable_at:new Date().toISOString()})}return!l.has(g)&&!p.has(g)&&p.set(g,setTimeout(()=>k(E,S),0)),!0}}),x=h=>{let E=h.target;if(!E||typeof E.closest!="function")return;let S=E.closest(r);if(!S)return;let g=E.closest("[data-hp-reco-interaction]"),y=E.closest("a[href]"),O=y&&(S.contains(y)||y.contains(S));if(!(g&&S.contains(g))&&!O)return;let N=A(S);if(!N)return;let U=m(o,N);if(!U)return;let G=m(s,S,w(N).indexOf(S));if(!G?.product_id)return;let q=U.recommendation_request_id;l.has(q)||(clearTimeout(p.get(q)),k(N,U)),e.productClicked({recommendation_request_id:U.recommendation_request_id,interaction:D(g??S,"hpRecoInteraction")??"navigate",products:[G]})};return document.addEventListener("click",x,!0),()=>{document.removeEventListener("click",x,!0);for(let h of p.values())clearTimeout(h);p.clear(),b()}}var _e=new Set(["home","list","product","search","basket","checkout","order_confirmation","login","register","account","info","blog","other"]),Io=new Set(["products"]),Cn=e=>e==null;function Et(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=>Et(r,t)):Object.fromEntries(Object.entries(e).filter(([,r])=>!Cn(r)).map(([r,o])=>[r,Et(o,t)]));return t.delete(e),n}function Ct(e){if(!e)return e;let t=Et(e);for(let n of Io)n in e&&Cn(e[n])&&(t[n]=e[n]);return t}function Pn(){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 ko=new Set(["","unknown","undefined","null","none","nil","nan","anonymous","guest","0","-1"]);function F(e){if(e==null)return null;let t=String(e).trim();return ko.has(t.toLowerCase())?null:t}var Ce=e=>typeof e=="string"&&e!==""?e:null;function oe(){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 On="1.22";function j(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 xo={gclid:"gclid",fbclid:"fbclid",ttclid:"ttclid"},Ao=/[a-z0-9._%+-]+@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}/i,vo=/\d(?:[ -]?\d){12,}/,Eo=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=!Eo.has(String(t).toLowerCase());return n.some(o=>Ao.test(o)||r&&vo.test(o))}function Ot(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(xo)]){let i=t.get(o);i&&!Tn(i,o)&&(n[s]=i)}return Object.keys(n).length?n:null}var Co=["email","e-mail","password","pass","pwd","token","auth","code","uid","customer_id","postcode","zip","phone","applyCode"],Po=["email","password","passwd","pwd","token","secret","auth","session","phone","postcode","zip","address","birth","card","cvv","iban","ssn","customerid","userid"],Oo=["tel","uid","dob"],Lo=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","gclid","fbclid","ttclid","msclkid"],To=new Set(Co.map(e=>e.toLowerCase()));function No(e){let t=String(e).toLowerCase();if(To.has(t))return!0;let n=t.replace(/[-_.]/g,"");return Po.some(o=>n.includes(o))?!0:String(e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(o=>Oo.includes(o))}function Pt(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?Pt([...t.queryParamAllowlist,...Lo]):null,o=Pt(t.queryParamBlocklist),s=Pt(t.sensitiveParamAllowlist);for(let u of new Set(n.keys()))(No(u)&&!s.some(l=>l.test(u))||n.getAll(u).some(l=>Tn(l,u))||(r?!r.some(l=>l.test(u)):o.some(l=>l.test(u))))&&n.delete(u);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 Lt(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 Tt(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Ln(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{2}$/.test(t)?t:null}function Nt(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 M(e,t){if(typeof e=="function")try{let n=e();if(n!=null)return n}catch{}return t}function Ro(e){return{...e.propertyId==null?{}:{property_id:String(e.propertyId)},channel:e.channel??null,market:e.market??null,environment:e.environment??null}}function Mo(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}}var Pe;function Do(){if(Pe!==void 0)return Pe;try{Pe=globalThis.Temporal?.Now?.timeZoneId?.()||Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{Pe=null}return Pe}function Mn(e,t={}){let n=typeof window<"u"?window.location:null,r={library:{name:e.libraryName,version:e.libraryVersion},spec:{version:On},source:Ro(e),session_id:M(e.getSessionId,null),identity_trust:F(M(e.getAnonymousId,null))?"device":"none",page:Mo(e),campaign:n?Ot(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:Tt(M(e.getCurrency,e.currency)),locale:Nt(M(e.getLocale,e.locale)),timezone:Do(),country:Ln(e.country),ship_to_country:Ln(M(e.getShipToCountry,e.shipToCountry)),ip:null,bot:null,consent:e.getConsent?.()??null,experiments:M(e.getExperiments,null),audiences:M(e.getAudiences,null),decisions:M(e.getDecisions,null),recommendations:M(e.getRecommendations,null),extensions:M(e.getExtensions,null)};return Dn(r,t)}function Dn(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]=Dn(e[r],o):o!==void 0&&(n[r]=o);return n}var fe=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",onsite:"thg_hp_onsite",visitCampaign:"thg_hp_visit_campaign"}),Uo={retry:"cdp.retry",sessionSignals:"cdp_session_signals",identified:"cdp_identified",previousPage:"cdp_prev_page_message_id"},Rt={...fe},Un=!1;function Ke(e){let t={...fe};for(let[n,r]of Object.entries(e??{})){if(!(n in fe))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}Rt=t}function P(e){return Rt[e]}var Vo="_",Vn=e=>e==null||e===""?Vo:String(e);function $(e,t,n){let r=`${e}:${Vn(t)}`;return n==null||n===""?r:`${r}:${n}`}function $n(e,t){return`${e}:${Vn(t)}:`}function Ge(){if(!Un){Un=!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(Uo)){if(n!==o&&!n.startsWith(`${o}:`))continue;let s=Rt[r]+n.slice(o.length);t.getItem(s)===null&&t.setItem(s,t.getItem(n)),t.removeItem(n)}}catch{}}}}var Dt=1800*1e3,ze=()=>{try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}},Mt=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}};function Bn(e,t=()=>Date.now()){return{read(){try{let n=ze()?.getItem(e),r=n?JSON.parse(n):null;return!r||t()-r.savedAt>Dt?(r&&ze()?.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?ze()?.removeItem(e):ze()?.setItem(e,JSON.stringify({savedAt:t(),items:n,anonymousId:r}))}catch{}}}}var $o=400*24*60*60;function se(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 Bo({name:e,domain:t=null,legacyKey:n,read:r,mint:o,mayStore:s,carried:i=null}){let u=null;try{u=Mt()?.getItem(n)||null}catch{u=null}let c=r(e)??u??i,l=!1,f=()=>{if(!(l||c===null||!s())&&(l=se(e,c,$o,t),!(!l||u===null)))try{Mt()?.removeItem(n),u=null}catch{}};return{get(){return c??(c=o()),f(),c},peek:()=>c,persist:f,forget(){se(e,"",0,t),c=null,l=!1;try{Mt()?.removeItem(n)}catch{}u=null}}}function jn(e,{carried:t=null,mayStore:n,orOwn:r=!1}){let o=e.anonymousIdSource,s=()=>Bo({name:P("anonymousId"),domain:e.consentCookieDomain??null,legacyKey:$(P("anonymousId"),e.propertyId),read:j,mint:oe,mayStore:n,carried:t});if(o?.source==="hp_cookie"){let c=s();return e.getAnonymousId=()=>c.get(),c}if(o?.source==="site_cookie"&&o.cookie){let c=o.cookie;e.getAnonymousId=()=>j(c)}if(!r)return null;let i=e.getAnonymousId,u=s();return e.getAnonymousId=()=>F(M(i,null))??u.get(),u}var jo=200;function Hn(e,t,n=()=>Date.now()){let r=()=>$(P("carried"),e),o=!1;function s(){try{let i=JSON.parse(sessionStorage.getItem(r())??"null");return!i||!(n()-i.savedAt<=Dt)?[]: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(-jo)})),!0)}catch{return!1}},close(){o=!0}}}var ma=fe.consent,We=Object.freeze({visitor:"visitor",host:"host"}),qn=()=>({basis:We.host}),Ho="hp-consent",pe=["analytics","marketing","personalisation","ad_user_data","ad_personalization"],Kn={analytics:"a",marketing:"m",personalisation:"p",ad_user_data:"aud",ad_personalization:"adp"},ne=()=>typeof window<"u",Gn=()=>ne()&&typeof window.cookieStore?.addEventListener=="function",Fo=e=>e===!0?!0:e===!1?!1:null;function be(e){if(!e||typeof e!="object")return null;let t={};for(let n of pe)t[n]=Fo(e[n]);return t}function Ut(e,t){return!e||!t?e===t:pe.every(n=>e[n]===t[n])}function Vt(e){if(!e)return"";let t=[];for(let n of pe){let r=e[n];(r===!0||r===!1)&&t.push(`${Kn[n]}=${r?1:0}`)}return t.join("&")}function $t(e){return{[Ho]:Vt(be(e))}}function Oe(e){let t=be({});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(Kn).map(([s,i])=>[i,s])),o=new Set;for(let s of n.split("&")){let i=s.indexOf("=");if(i<=0)continue;let u=r[s.slice(0,i).trim()],c={1:!0,0:!1}[s.slice(i+1).trim()]??null;!u||c===null||o.has(u)||(t[u]===null?t[u]=c:t[u]!==c&&(t[u]=null,o.add(u)))}return t}function Bt(e,t){if(!t)return e;let n=r=>{if(!r)return r;let o={...r};for(let s of pe)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 jt(e,t={}){return{...e,ad_user_data:t.ad_user_data??e.marketing,ad_personalization:t.ad_personalization??e.marketing}}function Je(e,t){let n=!0;return{notify:()=>{if(n)try{let o=e();o&&t(o)}catch{}},stop:()=>n=!1}}var qo={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 Ko(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(u=>{let c=String(u).toLowerCase();return s===c||s.startsWith(`${c}-`)})&&(n=!0,o?.enabled===!0))return!0}return n?!1:null}function zn(e={}){let t={...qo,...e.purposes};function n(){let r=ne()?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=>Ko(o,t[i]);return jt({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(!ne())return()=>{};let o=Je(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 Fn(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 Wn(e={}){let t={analytics:"C0002",personalisation:"C0003",marketing:"C0004",...e.groups},n=e.impliedConsent===!0;function r(){let i=Fn(j("OptanonConsent"));if(i.groups){let l={};for(let f of i.groups.split(",")){let[p,m]=f.split(":");p?.trim()&&(l[p.trim()]=m==="1"?!0:m==="0"?!1:null)}return f=>l[f]??!1}let u=ne()?window.OnetrustActiveGroups:void 0;if(typeof u!="string"||!u.length)return null;let c=new Set(u.split(",").map(l=>l.trim()).filter(Boolean));return l=>c.has(l)}function o(){if(j("OptanonAlertBoxClosed"))return!0;try{if(ne()&&window.OneTrust?.IsAlertBoxClosed?.()===!0)return!0}catch{}return n&&ne()&&(!!window.OneTrust||typeof window.OnetrustActiveGroups=="string")}function s(){if(!o())return null;let i=r();if(!i)return null;let u=p=>t[p]?i(t[p]):null,c=jt({analytics:u("analytics"),marketing:u("marketing"),personalisation:u("personalisation")},{ad_user_data:u("ad_user_data"),ad_personalization:u("ad_personalization")}),l=Fn(j("OptanonConsent"));return(typeof navigator<"u"&&navigator.globalPrivacyControl===!0||l.isGpcEnabled==="1")&&(c.marketing=!1,c.ad_user_data=!1,c.ad_personalization=!1),c}return{name:"onetrust",read:s,observesChanges:!0,subscribe(i){if(!ne())return()=>{};let u=Je(s,i),c=!1,l=()=>{c||!window.OneTrust?.OnConsentChanged||(c=!0,window.OneTrust.OnConsentChanged(u.notify))};window.addEventListener("OneTrustGroupsUpdated",u.notify);let f=window.OptanonWrapper;return window.OptanonWrapper=function(...m){try{typeof f=="function"&&f.apply(this,m)}finally{l(),u.notify()}},l(),()=>{u.stop(),window.removeEventListener("OneTrustGroupsUpdated",u.notify)}}}}function Go(e){let t=String(e).split(",").map(n=>n.trim()).filter(Boolean);return t.length?new Set(t):null}function Jn(e){let{name:t,categories:n,parse:r=Go,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 u(){let c=j(t);if(c==null)return null;let l;if(o!==void 0&&c===o)l=new Set;else try{l=r(c)}catch{l=null}if(!(l instanceof Set))return null;let f=p=>n[p]?l.has(n[p]):null;return jt({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:u,get observesChanges(){return Gn()},subscribe(c){if(!ne())return()=>{};let l=Je(u,c),f=p=>{[...p.changed??[],...p.deleted??[]].some(A=>A?.name===t)&&l.notify()};return window.addEventListener(i,l.notify),window.cookieStore?.addEventListener?.("change",f),()=>{l.stop(),window.removeEventListener(i,l.notify),window.cookieStore?.removeEventListener?.("change",f)}}}}function Yn(e={}){let t=e.name??P("consent"),n=()=>{let r=j(t);if(r==null)return null;let o=Oe(r);return o.analytics==null?null:o};return{name:"forwarded",read:n,get observesChanges(){return Gn()},subscribe(r){if(!ne())return()=>{};let o=Je(n,r),s=i=>{[...i.changed??[],...i.deleted??[]].some(c=>c?.name===t)&&o.notify()};return window.cookieStore?.addEventListener?.("change",s),()=>{o.stop(),window.cookieStore?.removeEventListener?.("change",s)}}}}function Xn(e){let t=be(e);return{name:"static",basis:We.host,read:()=>t?{...t}:null,observesChanges:!0,subscribe:()=>()=>{}}}function Zn(e){if(e==null)return null;let t=String(e).split("/").map(n=>n.trim()).filter(Boolean).join("/");return t===""?null:t}function zo(e){let t=e.item_category;if(t!=null&&String(t).includes("/"))return Zn(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 Zn(n.join("/"))}var Wo=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t};function Jo(...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 Ye=e=>Jo(e.item_group_id,e.item_id);function Yo(e,t=Ye){if(!e)return null;let n=u=>u==null||u===""||Number.isNaN(Number(u))?null:Number(u),r=u=>{let c=n(u);return c==null?null:Math.round(c*1e6)/1e6},o=u=>{let c=r(u);return c!=null&&c>=0?c:null},s=u=>{let c=n(u);return Number.isInteger(c)&&c>=0?c:null},i=Wo;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:zo(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 Ht(e,t=Ye){return(e??[]).map(n=>Yo(n,t)).filter(n=>n?.product_id)}var Xo=1e3,Zo={shipping:2,payment:3},Qo=new Set(["password","google","apple","facebook","magic_link","sso","passkey","other"]),H=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t},es=e=>{if(e==null||e===""||typeof e=="object")return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null},Xe=e=>e!==null&&typeof e=="object";function ts(e){return Array.isArray(e.items)?e.items.filter(Xe):null}function Qn(e){let t=H(e)?.toLowerCase().replace(/[\s-]+/g,"_");return t?Qo.has(t)?t:t==="email"||t==="email_password"?"password":"other":null}function ns({ecommerce:e,items:t}){let n=s=>({promotion_id:H(s.promotion_id),name:H(s.promotion_name),creative:H(s.creative_name),position:H(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 er=({ecommerce:e,items:t})=>H(e.item_list_id)??H(e.item_list_name)??H(t[0]?.item_list_id)??H(t[0]?.item_list_name),me=(e,t)=>t.products?.length?{event:e,properties:t}:null,rs=new Set(["product","products","item","items"]);function os({ecommerce:e}){let t=H(e.item_id),n=H(e.content_type)?.toLowerCase();return!t||n&&!rs.has(n)?null:{event:"Product Shared",properties:{share_via:H(e.method),products:[{product_id:t}]}}}function ss(e){let t=o=>me("Product List Viewed",{list_id:er(o),products:o.products}),n=o=>{let s=H(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=>me("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=>me("Product Clicked",{list_id:er(o),products:o.products.slice(0,1)}),add_to_cart:o=>me("Product Added",{cart_id:H(o.ecommerce.cart_id),products:o.products}),remove_from_cart:o=>me("Product Removed",{cart_id:H(o.ecommerce.cart_id),products:o.products}),view_cart:o=>({event:"Cart Viewed",properties:{cart_id:H(o.ecommerce.cart_id),value:o.value,currency:o.currency,coupon:H(o.ecommerce.coupon),...o.itemsListed?{products:o.products}:{}}}),begin_checkout:o=>me("Checkout Started",{value:o.value,currency:o.currency,coupon:H(o.ecommerce.coupon),products:o.products}),add_shipping_info:o=>({event:"Checkout Step Completed",properties:{step:e.shipping,step_name:"shipping",shipping_method:H(o.ecommerce.shipping_tier)}}),add_payment_info:o=>({event:"Payment Info Entered",properties:{step:e.payment,step_name:"payment",payment_method:H(o.ecommerce.payment_type)}}),view_promotion:r("Promotion Viewed"),select_promotion:r("Promotion Clicked"),add_to_wishlist:o=>me("Product Added to Wishlist",{products:o.products}),share:os,login:o=>({event:"Signed In",properties:{method:Qn(o.ecommerce.method)}}),sign_up:o=>({event:"Signed Up",properties:{method:Qn(o.ecommerce.method)}})}}var is=e=>e.event;function as(e,t){if(!Xe(e))return null;if(typeof e.length=="number"&&e[0]==="event"&&typeof e[1]=="string"){let r=Xe(e[2])?e[2]:{};return{name:e[1],entry:r,ecommerce:r}}let n=H(t(e));return n?{name:n,entry:e,ecommerce:Xe(e.ecommerce)?e.ecommerce:e}:null}function Ft(e){return Array.isArray(e)?`[${e.map(Ft).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Ft(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function tr(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=ss({...Zo,...t.steps}),o=t.map??{},s=t.eventName??is,i=t.productId??Ye,u=new Set(["purchase","refund",...t.ignore??[]]),c=t.dedupeMs??Xo,l=new Map,f=!0;function p(S,g,y){if(c<=0)return!1;let O=`${S}|${y??""}|${Ft(g)}`,N=Date.now();for(let[U,G]of l)N-G>c&&l.delete(U);return l.has(O)?!0:(l.set(O,N),!1)}let m=null,A=new Set;function w(S,g){if(S!=="Product Viewed")return!1;let y=typeof location>"u"?"":location.pathname;y!==m&&(m=y,A.clear());let O=g.products?.[0]?.product_id;return O?A.has(O)?!0:(A.add(O),!1):!1}function k({event:S,properties:g={}},y){if(!S||p(S,g,y)||w(S,g))return;let O=y?{context:{currency:y}}:void 0;if(S==="Signed Out"&&typeof e.signedOut=="function"){e.signedOut(O);return}e.track(S,g,O)}function b(S){let g=t.transform?t.transform(S):S,y=as(g,s);if(!y||u.has(y.name))return;let O=Object.hasOwn(o,y.name),N=O?o[y.name]:r[y.name];if(typeof N!="function")return;let U=ts(y.ecommerce),G=U??[],q={...y,items:G,itemsListed:U!==null,products:Ht(G,i),currency:Tt(y.ecommerce.currency),value:es(y.ecommerce.value)};q.promotions=ns(q);let ee=O?N(g,{...q,toProducts:J=>Ht(J,i)}):N(q);for(let J of[ee].flat())J&&k(J,q.currency)}function x(S){if(f)try{b(S)}catch(g){try{t.onError?.(g,S)}catch{}}}for(let S of n.slice())x(S);let h=n.push;function E(...S){let g=h.apply(this,S);for(let y of S)x(y);return g}return n.push=E,()=>{f=!1,n.push===E&&(n.push=h)}}var cs="hp_debug",us=256;function ls(){try{return new URLSearchParams(location.search).get(cs)}catch{return null}}function nr(e,t){if(typeof location>"u")return!1;try{let n=ls();if(n!==null){let o=n.trim();o===""||o.length>us?sessionStorage.removeItem(t):sessionStorage.setItem(t,o)}let r=sessionStorage.getItem(t);return!!(e&&r&&In(r)===e)}catch{return!1}}var Ie=class extends Error{},ds={inHoldout:()=>!0,personalisationGroup:()=>"excluded",servingHeaders:()=>({}),recommendationContext:()=>({}),flush:()=>Promise.resolve(),reset:()=>{}};function qt(e,t){let n=ds[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 Ie)throw i;return r(i)}}}function rr(e){for(let t of Reflect.ownKeys(e)){let{value:n}=Object.getOwnPropertyDescriptor(e,t)??{};typeof n=="function"&&(e[t]=qt(t,n))}return e}var Le=Symbol("hp.identityOption");var fs=4320*60*60,ps=100,ms=1e3,hs=2e3,or=500,Ze=e=>(e?.unref?.(),e);function gs(e,t){if(t?.analytics===!0&&e.analytics===!1)return"withdrawn";let n=pe.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 ys(e,t,n=P("consent")){if(!(typeof document>"u"))try{let r=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",o=t?`; Domain=${t}`:"";document.cookie=`${n}=${Vt(e)}; Path=/; Max-Age=${fs}; SameSite=Lax`+o+r}catch{}}function ws(e){let t=Oe(j(e));return pe.some(n=>t[n]!==null)?t:null}function sr(e){let{adapter:t,timeoutMs:n=5e3,cookieDomain:r=null,cookieName:o=P("consent"),release:s,announce:i}=e,u=e.discard??(()=>{}),c="pending",l=null,f=null,p=null,m=null,A=!1,w=null,k=[],b=R=>{c=R,e.onStatus?.(R)};function x(){try{return be(t.read())}catch{return null}}function h(){f&&clearInterval(f),p&&clearTimeout(p),f=null,p=null}let E=()=>typeof window<"u"&&typeof document<"u",S=()=>{try{return typeof t.subscribe=="function"&&t.observesChanges===!0}catch{return!1}};function g(){m&&clearInterval(m),m=null}function y(){A||m||l===null||S()||E()&&document.visibilityState==="hidden"||(m=Ze(setInterval(()=>q(x()),hs)))}let O=()=>c==="pending"||c==="unknown",N=e.store??null,U=()=>{let R=k.splice(0);N?.write([]);for(let K of R)s(K)},G=()=>{let R=k.splice(0);N?.write([]);for(let K of R)u(K)};function q(R){let K=be(R);if(!K||K.analytics===null)return;let Z=l===null,Y=Z?ws(o):l;if(!Z&&Ut(Y,K))return;h(),l=K,y(),ys(K,r,o);let ve=!Ut(Y,K);if(K.analytics){b("granted"),U(),ve&&i({action:gs(K,Y),state:K,previous:Y,withdrawal:!1});return}G(),Y?.analytics===!0&&i({action:"withdrawn",state:K,previous:Y,withdrawal:!0}),b("denied")}function ee(){p=null,c==="pending"&&(b("unknown"),f&&clearInterval(f),f=Ze(setInterval(()=>q(x()),ms)))}function J(R){if(O()){if(N){N.write(k);return}R?.type!=="visibilitychange"&&!R?.persisted&&G()}}let Se=R=>{document.visibilityState==="hidden"?(g(),J(R)):y()},je=R=>{g(),J(R)},ce=R=>{R?.persisted&&l!==null&&q(x()),y()};return{get status(){return c},get state(){return l?{...l}:null},stamp(){return l?{...l,source:t.name??null,basis:t.basis??We.visitor}:null},admits(){return c==="granted"},hold(R){return!O()||k.length>=or?(u(R),!1):(k.push(R),!0)},onHidden:J,start(){A=!1;try{w=t.subscribe?.(R=>q(R))??null}catch(R){e.debug&&console.warn("[hp] consent adapter subscribe failed",R)}E()&&(window.addEventListener("pagehide",je),window.addEventListener("pageshow",ce),document.addEventListener("visibilitychange",Se)),N&&k.length===0&&k.push(...N.read().slice(-or)),q(x()),!l&&(f=Ze(setInterval(()=>q(x()),ps)),p=Ze(setTimeout(ee,n)))},stop(){A=!0,h(),g(),typeof w=="function"&&w(),E()&&(window.removeEventListener("pagehide",je),window.removeEventListener("pageshow",ce),document.removeEventListener("visibilitychange",Se))}}}var Ss=["recommendation","search_rank","banner","offer","layout","copy","price","other"],Qe=e=>typeof e=="string"&&e!=="";function ir(e){return(Array.isArray(e?.decisions)?e.decisions:[]).filter(t=>Qe(t?.slot)&&Qe(t.decision_id)&&t.holdout!==!0).map(({decision_id:t,slot:n,arm:r,kind:o})=>({decision_id:t,slot:n,...Qe(r)&&{arm:r},...Ss.includes(o)&&{kind:o}}))}function ar({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=>Qe(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(u=>u.slot));n=[...r().filter(u=>!i.has(u.slot)),...s],o()},forget(){n=[];try{sessionStorage.removeItem(e)}catch{}}}}function _s(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 et(e,t,n=1e4){return _s(`${t}\0${e}`)%n}function Kt(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 Gt(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}=Kt(e),s=et(t,e.salt),i=c=>Math.round(c*1e4),u=r>0&&s<i(r)?"holdout":!n||s<i(r+o)?"personalised":"excluded";return{holdout:u==="holdout",bucket:s,group:u}}function cr(e,t){return typeof e!="string"||e===""||t==null||t===""?null:et(t,`bandit-vs-default:${e}`)<1e4/2?"default":"bandit"}var bs="hp_preview",Is=256;function ur(e,t=null){if(typeof location>"u")return j(e);let n=null;try{n=new URLSearchParams(location.search).get(bs)}catch{n=null}if(n===null)return j(e);let r=n.trim();return r===""||r.length>Is?(se(e,"",0,t),null):(se(e,r,null,t),r)}var ks=40,xs=128,As=5,vs=60,dr=e=>typeof e=="string"&&e!==""&&e.length<=xs&&!e.includes(","),lr=e=>Array.isArray(e)?e.filter(dr).slice(0,ks):[],Es=e=>Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.replaceAll(","," ").trim()).filter(t=>t!=="").slice(0,As):[],Cs=e=>Object.entries(e&&typeof e=="object"?e:{}).filter(([t,n])=>dr(t)&&Number.isFinite(n)&&n>=1).sort(([,t],[,n])=>n-t).slice(0,vs).map(([t,n])=>`${t}:${Math.floor(n)}`);function zt(e){let t={},n={viewed:lr(e?.recentProducts),basket:lr(e?.basketProducts),q:Es(e?.recentSearches),impressed:Cs(e?.impressions)};for(let[r,o]of Object.entries(n))o.length>0&&(t[r]=o.join(","));return t}var Ps=1800*1e3;function fr(e,t=Date.now()){try{localStorage.setItem(P("recommendationContext"),JSON.stringify({context:e,until:t+Ps}))}catch{}}function pr(){try{localStorage.removeItem(P("recommendationContext"))}catch{}}var Os="hp_sample",mr=1e4;function hr(e,t){return!(typeof t=="number"&&t<1)||e==null||e===""?!0:et(e,Os,mr)<Math.round(t*mr)}function ke(e){return e.trim().toLowerCase().replace(/\s*\/\s*/g,"/").replace(/^\/+|\/+$/g,"")}var Ls=2,Ts=12;function Te(e,t=Ls){return e.split("/").slice(0,t).join("/")}function Wt(e,t){if(typeof t!="string"||!t.trim())return null;let n=Te(ke(t));return n?(e.unshift(n),e.length=Math.min(e.length,Ts),n):null}var he=()=>P("sessionSignals"),xe=null,Jt=()=>xe??he();function gr(){try{return xe?localStorage:sessionStorage}catch{return}}function yr(e,t){let n=t==null?null:String(t),r=e?$(he(),n,e):null;if(r===xe)return;let o=xe===null?Ns():null;if(xe=r,!!xe)try{let s=Jt(),i=$n(he(),n);for(let u of Object.keys(localStorage))u.startsWith(i)&&u!==s&&localStorage.removeItem(u);o&&!localStorage.getItem(s)&&(localStorage.setItem(s,JSON.stringify(o)),sessionStorage.removeItem(he()))}catch{}}function Ns(){try{let e=sessionStorage.getItem(he());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.campaign)?t:null}catch{return null}}function tt(){return{productViews:0,listViews:0,cartAdds:0,searches:0,recentProducts:[],recentCategories:[],recentBrowse:[],basketProducts:[],basketValue:null,recentSearches:[],impressions:{},browsingCategory:null,recentBrowseCategories:[],browsingListing:null,listViewsByCategory:{},campaign:null,startedAt:0}}function Yt(){let e=gr();if(!e)return tt();try{let t=e.getItem(Jt());return t?{...tt(),...JSON.parse(t)}:{...tt(),startedAt:Date.now()}}catch{return{...tt(),startedAt:Date.now()}}}function Ne(e){let t=gr();if(t)try{t.setItem(Jt(),JSON.stringify(e))}catch{}}function Re(){return Yt()}function wr(){for(let e of[()=>sessionStorage,()=>localStorage])try{let t=e();t.removeItem(he());for(let n of Object.keys(t))n.startsWith(`${he()}:`)&&t.removeItem(n)}catch{}}var Xt=20,Sr=200,Rs=new Set(["Product Viewed","Product Clicked","Product Added","Product Added to Wishlist"]),Ms=new Set(["Product Viewed","Product Added"]),_r=50;function nt(e,t){let n=Wt(e.recentBrowse,t);return n?(e.recentBrowseCategories=[e.browsingListing?.category??null,...e.recentBrowseCategories].slice(0,e.recentBrowse.length),n):null}function Ds(e,t){let n=e.listViewsByCategory;n[t]=(n[t]??0)+1;let r=Object.keys(n);if(r.length>_r){let o={};for(let s of r.sort((i,u)=>n[u]-n[i]).slice(0,_r))o[s]=n[s];e.listViewsByCategory=o}}var br=e=>[...new Set(e.map(t=>t?.product_id).filter(t=>typeof t=="string"&&t))].slice(0,Xt);function Ir(e,t,n){let r=Yt();r.startedAt||(r.startedAt=Date.now());let o=n!==void 0&&JSON.stringify(n??null)!==JSON.stringify(r.campaign??null);o&&(r.campaign=n??null);let s=Array.isArray(t?.products)?t.products:[];switch(e){case"Product Viewed":r.productViews+=1,nt(r,r.browsingCategory);break;case"Product List Viewed":{let c=t?.list_id,l=t?.category;if(!(typeof c=="string"&&c.includes("/")&&!c.startsWith("cdp-")))break;let p=typeof l=="string"&&Te(ke(l))||null,m=p?Te(ke(c)):"";if(!m){r.browsingCategory=null,r.browsingListing=null;break}r.browsingListing={key:m,category:p},nt(r,m),r.browsingCategory=m,Ds(r,p),r.listViews+=1}break;case"Product List Filtered":{let c=t?.change,l=typeof t?.list_id=="string"?t.list_id:"",f=typeof c?.value=="string"?c.value:"",p=r.browsingListing;if(f&&c?.action!=="removed"&&p&&Te(ke(l))===p.key){let m=nt(r,`${l}/${f}`);m&&(r.browsingCategory=m)}break}case"Product Added":{r.cartAdds+=1,nt(r,r.browsingCategory);for(let c of s){let l=c.product_id;typeof l!="string"||!l||(r.basketProducts=[l,...r.basketProducts.filter(f=>f!==l)].slice(0,Xt))}break}case"Product Removed":{for(let c of s){let l=c.product_id;typeof l=="string"&&l&&(r.basketProducts=r.basketProducts.filter(f=>f!==l))}break}case"Products Searched":{r.searches+=1;let c=t?.query;if(typeof c=="string"&&c.trim()){let l=c.trim().toLowerCase().slice(0,64);r.recentSearches=[l,...r.recentSearches.filter(f=>f!==l)].slice(0,5)}break}case"Product Clicked":case"Product Added to Wishlist":break;case"Cart Viewed":return s.length>0&&(r.basketProducts=br(s)),Ne(r),r;case"Cart Updated":{Array.isArray(t?.products)&&(r.basketProducts=br(s));let c=t?.value;return r.basketValue=typeof c=="number"&&Number.isFinite(c)&&c>=0?c:null,Ne(r),r}default:return o&&Ne(r),r}let i=Rs.has(e);if(i)for(let c of s)typeof c.product_id=="string"&&c.product_id&&delete r.impressions[c.product_id];else{for(let l of s){let f=l.product_id;typeof f!="string"||!f||(r.impressions[f]=(r.impressions[f]??0)+1)}let c=Object.keys(r.impressions);if(c.length>Sr){let l={};for(let f of c.sort((p,m)=>r.impressions[m]-r.impressions[p]).slice(0,Sr))l[f]=r.impressions[f];r.impressions=l}}let u=new Set;for(let c of s){let l=c.product_id;if(i&&typeof l=="string"&&l&&(r.recentProducts=[l,...r.recentProducts.filter(f=>f!==l)].slice(0,Xt)),Ms.has(e)&&typeof c.category=="string"&&c.category){let f=ke(c.category);f&&!u.has(f)&&(u.add(f),Wt(r.recentCategories,f))}}return Ne(r),r}var rt=1800*1e3;function kr({name:e,domain:t=null,mayStore:n,now:r=()=>Date.now(),mint:o=oe}){let s=null,i=0,u=()=>{s!==null&&n()&&se(e,s,rt/1e3,t)};return{get(){let c=r(),l=j(e);return l?s=l:(s===null||c-i>=rt)&&(s=o()),i=c,u(),s},persist:u,forget(){se(e,"",0,t),s=null}}}var W=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),xr=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Ar=Object.freeze({enabled:!1}),Qt=Object.freeze({enabled:!0,queryParamAllowlist:Object.freeze([])});function vr(e,t){let n=e?.track;return W(n)?(Object.hasOwn(n,t)?n[t]:n.__default)?.enabled!==!1:!0}function Us(e,t){return`${ie(e)}/v1/projects/${encodeURIComponent(t)}/settings`}var Vs="https://hp.thgingenuity.com";function ie(e){return e==null||e===""?Vs:Cr(e)}function Er(e,t){return e!=null&&e!==""?ie(e):t?.startsWith("https://")?t:ie(void 0)}function Cr(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 $s(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 Zt=e=>typeof e=="number"&&e>=0&&e<=1,Bs=/^[0-9a-f]{64}$/;function js(e){return W(e)?{enabled:e.enabled===!0,tokenSha256:typeof e.tokenSha256=="string"&&Bs.test(e.tokenSha256)?e.tokenSha256:null}:{enabled:!1,tokenSha256:null}}function Hs(e){if(!W(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>W(n)&&Zt(n.share)&&(n.ramp==null||Zt(n.ramp))&&typeof n.salt=="string"&&n.salt!=="").map(([n,r])=>[n,{share:r.share,ramp:r.ramp??null,salt:r.salt,...xr(r.readoutSlots)&&r.readoutSlots.length>0&&{readoutSlots:r.readoutSlots}}]));return Object.keys(t).length?t:null}var Fs=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;function qs(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"&&Fs.test(e.cookie)?{source:"site_cookie",cookie:e.cookie}:null:null}function Ks(e){let t=Array.isArray(e?.forms)?e.forms.filter(W):[];return t.length===0?null:{forms:t,capture:W(e.capture)?e.capture:null,...Number.isInteger(e.overlay_gap_minutes)?{overlay_gap_minutes:e.overlay_gap_minutes}:{}}}function Gs(e){let t=W(e)?e.hp:null;return W(t)&&typeof t.enabled=="boolean"}function en(e){let t=W(e)?e.hp:null;if(!W(t)||t.enabled!==!0)return Ar;let n=Ks(t.onsite);return{enabled:!0,propertyId:typeof t.propertyId=="string"&&t.propertyId!==""?t.propertyId:null,environment:typeof t.environment=="string"?t.environment:null,consentPurposes:$s(t.consent?.purposes),queryParamAllowlist:xr(t.queryParamAllowlist)?t.queryParamAllowlist:null,anonymousId:qs(t.anonymousId),apiHost:Cr(t.apiHost),holdouts:Hs(t.holdouts),sampleRate:Zt(t.sampleRate)?t.sampleRate:1,debug:js(t.debug),...n&&{onsite:n},plan:W(e.plan)&&W(e.plan.track)?{track:e.plan.track}:null}}var zs=3e3;async function Pr(e,t,n=globalThis.fetch,r=zs){try{let o=await n(Us(e,t),{credentials:"omit",headers:{accept:"application/json"},signal:AbortSignal.timeout?.(r)});if(o.status>=400&&o.status<500&&o.status!==408&&o.status!==429)return Ar;if(!o.ok)return null;let s=await o.json();return Gs(s)?en(s):null}catch{return null}}var ot=e=>$(P("settings"),e);function Or(e){try{let t=localStorage.getItem(ot(e));if(!t)return null;let n=JSON.parse(t);return n?.enabled===!0?n:null}catch{return null}}function Lr(e,t){try{t?.enabled===!0?localStorage.setItem(ot(e),JSON.stringify(t)):localStorage.removeItem(ot(e))}catch{}}function tn(e){try{localStorage.removeItem(ot(e))}catch{}}var Ws={flushAt:20,flushIntervalMs:1e4,maxQueue:500,maxRetryAgeMs:1440*60*1e3,maxRetries:5,maxPersistedBatches:20,maxPersistedBytes:1024*1024,storageKey:fe.retry,beaconSafeBytes:56*1024,maxBatchEvents:100,maxBatchBytes:500*1024},st=()=>Date.now(),Tr=3e4,cn=55*1024;function Js(e,t=st()){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 ae=e=>typeof TextEncoder<"u"?new TextEncoder().encode(e).length:Buffer.byteLength(e),nn=()=>typeof window<"u"&&typeof document<"u";function Ys(){try{return!nn()||!window.localStorage?null:(window.localStorage.getItem("thg_hp_probe"),window.localStorage)}catch{return null}}var I,rn,on,it,sn,an,Nr,Me,De,Ue,Rr,at,Mr,ct,ut=class{constructor(t){_n(this,I);this.o={...Ws,...t},this.queue=[],this.timer=null,this.storage=Ys(),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,this.failing=!1,this.answered=!1,nn()&&(window.addEventListener("pagehide",()=>this.flush({beacon:!0})),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()}),L(this,I,ct).call(this))}markFailing(){this.answered||(this.failing=!0)}replayPersisted(){return this.replayAllowed=!0,L(this,I,ct).call(this)}clearPersisted(){if(this.replayAllowed=!1,!!this.storage)try{let t=L(this,I,Ue).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(),L(this,I,on).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():L(this,I,rn).call(this)}flush(t={}){if(L(this,I,on).call(this),this.queue.length===0)return Promise.resolve();if(t.beacon&&nn()&&typeof navigator<"u"&&navigator.sendBeacon)return L(this,I,Nr).call(this),Promise.resolve();if(this.inflight)return this.inflight;let n=L(this,I,an).call(this,this.queue,this.o.maxBatchEvents,this.o.maxBatchBytes).map(o=>{let s=L(this,I,at).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){L(this,I,De).call(this,s);continue}await L(this,I,Me).call(this,o,0,s,r)}})().finally(()=>{this.inflight=null,this.queue.length>=this.o.flushAt?this.flush():this.queue.length&&L(this,I,rn).call(this)}),this.inflight}};I=new WeakSet,rn=function(){this.timer||(this.timer=setTimeout(()=>this.flush(),this.o.flushIntervalMs),this.timer?.unref?.())},on=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},it=function(t){return JSON.stringify({batch:t,writeKey:this.o.writeKey,sentAt:new Date().toISOString()})},sn=function(){return`${this.o.apiHost.replace(/\/$/,"")}/v1/batch`},an=function(t,n,r){let o=ae(L(this,I,it).call(this,[])),s=[],i=[],u=o;for(let c of t){let l=ae(JSON.stringify(c))+1;i.length&&(i.length>=n||u+l>r)&&(s.push(i),i=[],u=o),i.push(c),u+=l}return i.length&&s.push(i),s},Nr=function(){let t=this.queue;this.queue=[];let n=L(this,I,sn).call(this);for(let r of L(this,I,an).call(this,t,this.o.maxBatchEvents,this.o.beaconSafeBytes)){let o=L(this,I,it).call(this,r);if(ae(o)<=this.o.beaconSafeBytes){let s=!1;try{s=navigator.sendBeacon(n,new Blob([o],{type:"text/plain"}))}catch{s=!1}if(s){let i=this.failing?L(this,I,at).call(this,r):null;i&&this.sending.add(i);continue}}L(this,I,Me).call(this,r,0,L(this,I,at).call(this,r))}},Me=async function(t,n,r=null,o=this.epoch){r&&this.sending.add(r);let s=L(this,I,it).call(this,t),i=0;try{let u=await fetch(L(this,I,sn).call(this),{method:"POST",headers:{"Content-Type":"text/plain"},body:s,keepalive:ae(s)<=this.o.beaconSafeBytes});if(u.ok)return this.failing=!1,this.answered=!0,L(this,I,De).call(this,r),L(this,I,ct).call(this),!0;let c=u.status===408||u.status===429||u.status>=500;if(c&&(i=Js(u.headers?.get?.("retry-after"))),!c)return L(this,I,De).call(this,r),this.o.onError?.(`CDP ingest rejected batch (${u.status}); dropping ${t.length} events`),!0;throw new Error(`retryable ${u.status}`)}catch(u){if(this.failing=!0,n>=this.o.maxRetries){r&&this.sending.delete(r);let l=r?"kept for the next page":"dropped";return this.o.onError?.(`CDP ingest unreachable after ${n} attempts; ${l}: ${t.length} events`,u),!1}let c=Math.max(Math.min(1e3*2**n,Tr)*(.5+Math.random()),Math.min(i,Tr));return o===this.epoch&&await new Promise(l=>{let f=()=>{clearTimeout(p),this.wakers.delete(f),l()},p=setTimeout(f,c);this.wakers.add(f)}),o!==this.epoch?(L(this,I,De).call(this,r),!1):L(this,I,Me).call(this,t,n+1,r,o)}},De=function(t){t&&(this.sending.delete(t),this.sinceRefusal.delete(t),L(this,I,Mr).call(this,t))},Ue=function(){let t=JSON.parse(this.storage.getItem(this.o.storageKey)||"[]");return Array.isArray(t)?t:[]},Rr=function(t,n){let r=i=>ae(JSON.stringify(i))+1,o=[...t,n].slice(-this.o.maxPersistedBatches),s=o.reduce((i,u)=>i+r(u),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},at=function(t){if(!this.storage||this.o.mayPersist&&!this.o.mayPersist())return null;try{let n={at:st(),id:`${st()}-${Math.random().toString(36).slice(2)}`,batch:t};return ae(JSON.stringify(n))+3>this.o.maxPersistedBytes?null:L(this,I,Rr).call(this,L(this,I,Ue).call(this),n)?n.id:null}catch{return null}},Mr=function(t){if(!(!t||!this.storage))try{let n=L(this,I,Ue).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{}},ct=function(){if(!this.storage||!this.replayAllowed)return this.draining??Promise.resolve();if(this.draining)return this.draining;let t;try{let r=L(this,I,Ue).call(this);t=r.filter(o=>Array.isArray(o?.batch)&&st()-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 L(this,I,Me).call(this,r.batch,0,r.id))return})().finally(()=>{this.draining=null}),this.draining):Promise.resolve()};var un="3.30.0",ln="@thg-agentic/hyper-personalisation-web";var Xs=100,Zs=["source","medium","campaign","content","term"];function Ur(e){if(!e||typeof e!="object")return null;let t={};for(let n of Zs){let r=e[n==="campaign"?"name":n];typeof r=="string"&&r&&(t[n]=r.slice(0,Xs))}return Object.keys(t).length?t:null}var Vr=e=>$(P("visitCampaign"),e==null?null:String(e)),Ae=new Map;function $r(e){if(Ae.has(e))return Ae.get(e);try{let t=JSON.parse(localStorage.getItem(e));return t&&typeof t=="object"?t:null}catch{return null}}function Dr(e,t){try{t?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e),Ae.delete(e)}catch{t?Ae.set(e,t):Ae.delete(e)}}function Br(e,t,n){return typeof e?.tags=="object"&&e.tags!==null&&Number.isFinite(e.at)&&n-e.at<rt&&!(t&&e.sid&&e.sid!==t)?e:null}function lt(e,{sessionId:t=null,now:n=Date.now()}={}){return Br($r(Vr(e)),t,n)?.tags??null}function jr(e,t,{sessionId:n=null,keepSession:r=!1,now:o=Date.now()}={}){let s=Vr(e),i=$r(s),u=Br(i,n,o),c=u?.tags??t??null;return c?Dr(s,{tags:c,at:o,sid:(r?n:null)??u?.sid??null}):i&&Dr(s,null),c}function dn(){Ae.clear();try{let e=`${P("visitCampaign")}:`;for(let t of Object.keys(localStorage))t.startsWith(e)&&localStorage.removeItem(t)}catch{}}var Qs=new Set(["audiences","decisions","recommendations"]);var ei=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),ti=Symbol.for("@thg-agentic/hyper-personalisation-web.unreachable"),ni=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite-access");function ri(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 oi="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";function si(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 ft(e){if(typeof e!="string")return null;let t=si(e.trim());return t===oi?null:t}var Hr=Object.freeze({email_sha256:"sha256",phone_sha256:"sha256",accepts_marketing:"boolean",gender:"string",created_at:"date-time"}),ii=/^\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 ai(e){if(typeof e!="string"||!ii.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 ci(e,t){return t===null?null:e==="sha256"?ft(t)??void 0:e==="date-time"?t instanceof Date?Number.isNaN(t.getTime())?void 0:t.toISOString():ai(t)?t:void 0:typeof t===e?t:void 0}function ui(e,t){let n={},r=[];for(let[o,s]of Object.entries(e)){let i=Object.hasOwn(Hr,o)?Hr[o]:null,u=i?ci(i,s):void 0;u===void 0?r.push(o):n[o]=u}return t&&r.length&&console.warn(`[hp] identify: not sent, not spec traits: ${r.join(", ")}`),n}var Fr=!1,qr=!1;function li(){qr||(qr=!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 di(e){!e||Fr||(Fr=!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 fi(e){try{return ae(JSON.stringify(e))}catch{return 0}}function dt(e){return e&&typeof e.context=="object"&&e.context!==null?e.context:e}function pi(e,t){if(e==null||String(e)===t)return;let n=[["localStorage","retry",(r,o)=>[...Array.isArray(r)?r:[],...Array.isArray(o)?o:[]]],["sessionStorage","held",(r,o)=>o?{...o,items:[...r.items??[],...o.items??[]]}:r]];for(let[r,o,s]of n)try{let i=globalThis[r],u=$(P(o),e),c=i?.getItem(u);if(!c)continue;let l=$(P(o),t),f=i.getItem(l);i.setItem(l,JSON.stringify(s(JSON.parse(c),f?JSON.parse(f):null))),i.removeItem(u)}catch{}}function Kr(e){let t=ie(e?.apiHost);if(!t)throw new Error("createAnalytics: apiHost, when given, must be a host or an http(s) origin");if(e?.propertyId!==null&&!e?.propertyId)throw new Error("createAnalytics: propertyId is required (null: the ingest stamps the key\u2019s)");let n={libraryName:ln,libraryVersion:un,writeKey:"web",queryParamBlocklist:[],debug:!1,validate:null,consentTimeoutMs:5e3,...e,apiHost:t};Ke(n.storageNames),Ge();let r=!!n.consent;r||li();let o=null;n.getConsent=()=>o?o.stamp():qn();let s=()=>!r||o?.status==="granted";pi(n.propertyId,n.writeKey);let i=r&&n.holdAcrossPages?Bn($(P("held"),n.writeKey)):null,u=i?.read()??{items:[],anonymousId:null};n.mintAnonymousId!==void 0&&di(n.debug);let c=jn(n,{carried:u.anonymousId,mayStore:s,orOwn:!0}),l=kr({name:P("session"),domain:n.consentCookieDomain??null,mayStore:s}),f=n.getSessionId;n.getSessionId=()=>F(M(f,null))??l.get();let p=ur(P("preview"),n.consentCookieDomain??null),m=()=>F(M(f,null))??j(P("session")),A=Ur(typeof location>"u"?null:Ot(location.search)),w=(a=null)=>{p||jr(n.propertyId,a,{sessionId:m(),keepSession:s()})},k=(a,d)=>n.debug&&console.warn("[hp]",a,d??""),b=n.transport??new ut({apiHost:n.apiHost,writeKey:n.writeKey,storageKey:$(P("retry"),n.writeKey),mayPersist:r?()=>o?.status==="granted":void 0,deferReplay:r,onError:k}),x=$(P("previousPage"),n.propertyId),h=null,E=()=>{if(h)return h;try{return sessionStorage.getItem(x)||null}catch{return null}};typeof window<"u"&&window.addEventListener("pageshow",a=>{a.persisted&&(h=null)});let S=a=>{if(h=a||null,!(r&&o.status!=="granted"))try{sessionStorage.setItem(x,a)}catch{}},g=ar({key:$(P("decisions"),n.propertyId),mayStore:s});n.getDecisions??(n.getDecisions=g.current);let y=F(M(n.getUserId,null)),O=null,N=null,U=y?Ce(n.identityToken):null,G=null,q=null,ee=null,J=new Set,Se=new Set;function je(a){if(a.type==="page"&&(ee=null),a.type==="track"&&a.event==="Product Viewed"){let _=a.properties?.products?.[0]?.product_id;ee=typeof _=="string"&&_?_:ee}if(a.type!=="track"||a.event!=="Cart Updated")return;let d=a.properties?.value;q=typeof d=="number"&&Number.isFinite(d)&&d>=0?d:null;for(let _ of J)try{_()}catch(C){console.warn("[hp] a basket listener failed",C)}}function ce(a,d,_=!1){je(a),w();try{return R(a,d,_)}catch(C){if(C instanceof Ie)throw C;return console.warn("[hp] the event was not sent",C),null}}function R(a,d,_){let C=G;G=null;let V=a.type==="track"?a.event:a.type;if(!_&&!vr(n.plan,V))return null;let T={messageId:C?.messageId??oe(),timestamp:C?.timestamp??new Date().toISOString(),anonymousId:F(M(n.getAnonymousId,null)),userId:y??null,...a,context:Mn(n,dt(d))};if(T.properties&&(T.properties=Ct(T.properties)),typeof T.properties?.href=="string"&&(T.properties.href=Lt(T.properties.href,n)),!_&&!hr(T.anonymousId,n.sampleRate))return n.debug&&console.debug("[hp] not sent: outside the sample",T),null;if(n.beforeSend){let te;try{te=n.beforeSend(T)}catch(uo){return console.warn("[hp] beforeSend failed; the event was not sent",uo),null}if(!te)return null;let{type:z,event:wn,messageId:ao,timestamp:co}=T;T={...te,type:z,messageId:ao,timestamp:co,...wn?{event:wn}:{}}}if(n.validate){let te=n.validate(T,{producer:"web"});if(!te.valid){let z=`[hp] invalid ${T.event??T.type}:
|
|
2
2
|
${te.errors.join(`
|
|
3
3
|
`)}`;if(n.throwOnInvalid)throw new Ie(z);console.error(z)}}n.debug&&console.debug("[hp]",T.event??T.type,T);let bt=fi(T);return bt>cn?(k(`${T.event??T.type} not sent: ${bt} bytes, over the ${cn}-byte limit for one event`),null):(oo(T,_),T)}function K(a){if((a.type==="track"||a.type==="page")&&ro(a),n.onEvent)try{n.onEvent(a)}catch(d){console.warn("[hp] onEvent observer failed",d)}}let Z=()=>r&&o?.state?.personalisation===!0,Y=()=>yr(M(n.getSessionId,null),n.propertyId),ve=!1;function ro(a){try{if(Z()){Y();let d=Ir(a.event,a.properties,lt(n.propertyId,{sessionId:m()}));a.type==="track"&&fr(zt(d)),ve=!0}else He()}catch(d){n.debug&&console.warn("[hp] the visit was not recorded",d)}}function He(a=!1){pr(),(a||ve)&&wr(),ve=!1}function St(){l.forget(),g.forget(),_t.clear(),c?.forget(),He(!0),dn()}function oo(a,d){!r||d||o.admits()?(K(a),b.enqueue(a)):o.hold(a)}let v=(a,d,_)=>ce({type:"track",event:a,properties:d??{}},_),_t=new Set,so=(a,d,_)=>a==="audiences"?{audiences:d?null:_.audiences??[]}:a==="decisions"?{decisions:(_.decisions??[]).map(C=>({slot:C.slot,decision_id:C.decision_id??null,arm:C.arm??null,...C.variant&&{variant:C.variant}}))}:{recommendation_request_id:_.recommendation_request_id??null};w(A),r&&(o=sr({adapter:n.consent,timeoutMs:n.consentTimeoutMs,cookieDomain:n.consentCookieDomain,debug:n.debug,store:i&&{read:()=>u.items,write:a=>i.write(a,c?.peek()??null)},release(a){a.context&&(a.context.consent=o.stamp()),K(a),b.enqueue(a)},onStatus(a){if(a==="granted"&&(c?.persist(),l.persist(),h&&S(h),g.persist(),b.replayPersisted?.()),a==="denied"){b.clearPersisted?.(),c?.forget(),l.forget();try{sessionStorage.removeItem(x)}catch{}g.forget(),He(!0)}try{n.onConsentStatus?.(a)}catch(d){console.warn("[hp] onConsentStatus observer failed",d)}if(a==="granted"||a==="denied")for(let d of Se)try{d()}catch(_){console.warn("[hp] a consent listener failed",_)}},announce({action:a,state:d,previous:_,withdrawal:C}){d?.personalisation!==!0&&He(_?.personalisation===!0),C&&(b.discardQueued?.(),dn()),ce({type:"track",event:"Consent Updated",properties:{action:a,state:d}},void 0,C),C&&b.flush()}}),o.start(),w());let mn=()=>n.holdout?Kt(n.holdout):null,hn=()=>Gt(n.holdout,F(M(n.getAnonymousId,null))).group;function io(a,d){if(!Array.isArray(a?.decisions))return a;let _=n.holdout?.readoutSlots??[],C=F(M(n.getAnonymousId,null));return{...a,decisions:a.decisions.map(V=>{let T=V?.variant==="bandit"||V?.variant==="default"?V.variant:!d&&V?.holdout!==!0&&_.includes(V?.slot)?cr(V.slot,C):null;return T?T==="default"?{...V,variant:T,decision_id:null}:{...V,variant:T}:V})}}function gn(a,d){if(p)return null;let _=a?.exposure,C=_?.holdout===!0,V=io(a,C);return g.remember(ir(V)),!_?.token||_t.has(_.token)?null:(_t.add(_.token),v("Personalisation Exposed",{exposure_token:_.token,surface:_.surface,holdout:C,holdout_share:_.holdout_share??mn()?.holdout_share??null,personalised_share:_.personalised_share??mn()?.personalised_share??null,...so(_.surface,C,V)},d))}function yn(a){return y&&St(),y=null,O=null,N=null,U=null,a}return rr({track:(a,d,_)=>a==="Signed Out"?yn(v(a,d,_)):v(a,d,_),page(a,d){a??(a={});let _=n.pageType??null;a.type&&(_e.has(a.type)?(_=a.type,n.pageType=a.type):n.debug&&console.warn(`[hp] ignoring unknown page.type "${a.type}". Allowed: ${[..._e].join(", ")}`));let C=ce({type:"page",properties:{name:a.name??null,navigation_trigger:a.navigation_trigger??Pn(),previous_message_id:E()}},{page:{type:_},...dt(d)??{}});return C&&S(C.messageId),C},identify(a,d,_){let{userId:C,...V}=a&&typeof a=="object"?a:{},T=Ce(dt(d)?.identity_token);if(C!==void 0){let z=F(C);U=z?z===y?T??U:T:null,_===Le?N=z:O&&z&&z!==O?St():n.debug&&N&&z&&z!==N&&console.warn("[hp] identify names another userId than the identity option; using the new one"),y=z,z&&_!==Le&&(O=z)}else T&&y&&(U=T);let{identity_token:bt,...te}=dt(d)??{};return ce({type:"identify",traits:ui(V,n.debug)},U?{...te,identity_token:U}:te)},reset(){y&&St(),y=null,O=null,N=null,U=null,S("")},productViewed:(a,d)=>v("Product Viewed",a,d),productListViewed:(a,d)=>v("Product List Viewed",a,d),recommendationsViewed:(a,d)=>v("Recommendations Viewed",a,d),personalisationExposed:(a,d)=>v("Personalisation Exposed",a,d),recordExposure:gn,surfaceViewed({surface:a}={},d){if(!Qs.has(a)||!n.holdout||a!=="decisions"&&!Z())return null;let _=F(M(n.getAnonymousId,null)),C=Gt(n.holdout,_).group;if(C==="excluded")return null;let V=vn({sessionId:Fe(M(n.getSessionId,null),_),surface:a});return V?gn({exposure:{token:V,surface:a,holdout:C==="holdout"}},d):null},inHoldout:()=>hn()!=="personalised",personalisationGroup:hn,productClicked:(a,d)=>v("Product Clicked",a,d),productListFiltered:(a,d)=>v("Product List Filtered",a,d),productsSearched:(a,d)=>v("Products Searched",a,d),searchSuggestionsViewed:(a,d)=>v("Search Suggestions Viewed",a,d),productAdded:(a,d)=>v("Product Added",a,d),productRemoved:(a,d)=>v("Product Removed",a,d),cartUpdated:(a,d)=>v("Cart Updated",ri(a),d),identityLinked:(a,d)=>v("Identity Linked",a,d),slotEngaged:(a,d)=>p?null:v("Slot Engaged",a,d),productVariantSelected:(a,d)=>v("Product Variant Selected",a,d),cartViewed:(a,d)=>v("Cart Viewed",a,d),productAddedToWishlist:(a,d)=>v("Product Added to Wishlist",a,d),productRemovedFromWishlist:(a,d)=>v("Product Removed from Wishlist",a,d),wishlistProductAddedToCart:(a,d)=>v("Wishlist Product Added to Cart",a,d),productShared:(a,d)=>v("Product Shared",a,d),cartShared:(a,d)=>v("Cart Shared",a,d),couponEntered:(a,d)=>v("Coupon Entered",a,d),couponApplied:(a,d)=>v("Coupon Applied",a,d),couponDenied:(a,d)=>v("Coupon Denied",a,d),couponRemoved:(a,d)=>v("Coupon Removed",a,d),checkoutStarted:(a,d)=>v("Checkout Started",a,d),promotionViewed:(a,d)=>v("Promotion Viewed",a,d),promotionClicked:(a,d)=>v("Promotion Clicked",a,d),checkoutStepViewed:(a,d)=>v("Checkout Step Viewed",a,d),checkoutStepCompleted:(a,d)=>v("Checkout Step Completed",a,d),paymentInfoEntered:(a,d)=>v("Payment Info Entered",a,d),checkoutFailed:(a,d)=>v("Checkout Failed",a,d),signedIn:(a,d)=>v("Signed In",a,d),signedUp:(a,d)=>v("Signed Up",a,d),signedOut:a=>yn(v("Signed Out",{},a)),newsletterSubscribed:(a,d)=>v("Newsletter Subscribed",a,d),newsletterUnsubscribed:(a,d)=>v("Newsletter Unsubscribed",a,d),preferencesStated:(a,d)=>v("Preferences Stated",a,d),backInStockSubscribed:(a,d)=>v("Back In Stock Subscribed",a,d),productReviewed:(a,d)=>v("Product Reviewed",a,d),consentUpdated:(a,d)=>v("Consent Updated",a,d),flush:a=>b.flush(a),recommendationContext(){if(!Z())return{};try{return Y(),zt(Re())}catch{return{}}},get consent(){return o?o.state:null},servingHeaders:()=>$t(o?.state??null),get lastPageMessageId(){return E()},get anonymousId(){return F(M(n.getAnonymousId,null))},[ni](){return{writeKey:n.writeKey,library:{name:ln,version:un},storageKey:$(P("onsite"),n.propertyId),gatewayHost:n.apiHost,servingHost:n.servingHost??n.apiHost,settings:n.onsite??null,debug:n.debug===!0,preview:p,anonymousId:()=>F(M(n.getAnonymousId,null)),sessionId:()=>F(M(n.getSessionId,null)),identityToken:()=>Z()?U:null,analytics:s,personalisation:Z,consent:()=>n.getConsent(),headers:()=>$t(o?.state??null),pageUrl:()=>typeof location>"u"?null:Lt(location.href,n),locale:()=>Nt(M(n.getLocale,n.locale)),campaign:()=>p?A:lt(n.propertyId,{sessionId:m()}),basketValue:()=>{let a=Re().basketValue;return q??(Number.isFinite(a)?a:null)},sessionSignals:()=>Z()?(Y(),{...Re(),campaign:lt(n.propertyId,{sessionId:m()})}):null,visitContext:()=>{let a=Z();a&&Y();let d=a?Re():null,_=C=>Array.isArray(C)?C.filter(V=>typeof V=="string"&&V.length<=128).slice(0,20):[];return{...n.pageType?{page_type:n.pageType}:{},...ee?{product_id:ee}:{},...d?{basket:_(d.basketProducts),viewed:_(d.recentProducts)}:{}}},onBasket:a=>(J.add(a),()=>J.delete(a)),consentAnswered:()=>!o||o.status==="granted"||o.status==="denied",onConsentAnswered:a=>(Se.add(a),()=>Se.delete(a))}},[ti](){b.markFailing?.()},[ei](a,d,_){if(typeof this[a]=="function"){G=typeof _?.messageId=="string"&&typeof _?.timestamp=="string"?{messageId:_.messageId,timestamp:_.timestamp}:null;try{this[a](...Array.isArray(d)?d:[])}finally{G=null}}}})}var Ve=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite"),X=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.pending"),$e=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.listeners"),pt=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.suppressed"),mi=["shown","submitted","apply","closed","held","nothing"],Gr=10,ge=()=>typeof window>"u"?null:window;function Be(){try{for(let{resolve:e}of ge()?.[X]?.splice(0)??[])e(!1)}catch{}}var ye=Object.freeze({open(e){try{let t=ge();if(!t||typeof e!="string")return Promise.resolve(!1);if(t[Ve])return t[Ve].open(e);if(t[X]??(t[X]=[]),t[X].length<Gr)return new Promise(n=>t[X].push({slot:e,resolve:n}))}catch{}return Promise.resolve(!1)},show(e){return ye.open(e)},on(e,t){var n;try{let r=ge();return!r||!mi.includes(e)||typeof t!="function"?()=>{}:(r[$e]??(r[$e]={}),((n=r[$e])[e]??(n[e]=new Set)).add(t),()=>r[$e][e].delete(t))}catch{return()=>{}}},suppress(e="page"){try{let t=ge();if(!t)return;(t[pt]??(t[pt]=new Set)).add(String(e)),t[Ve]?.suppress()}catch{}},unsuppress(e){try{let t=ge()?.[pt];e===void 0?t?.clear():t?.delete(String(e))}catch{}},ready(){try{let e=ge();if(!e)return Promise.resolve([]);if(e[Ve])return Promise.resolve(ye.debug());if(e[X]??(e[X]=[]),e[X].length<Gr)return new Promise(t=>e[X].push({slot:null,resolve:()=>t(ye.debug())}))}catch{}return Promise.resolve([])},debug(){try{return ge()?.[Ve]?.debug()??[]}catch{return[]}}});function zr(e){let t=typeof document>"u"?null:document.currentScript?.src;return t?new URL(e,t).href:null}var mt=new Map;function Wr(e,t){return window[t]?Promise.resolve(window[t]):e?(mt.has(t)||mt.set(t,new Promise((n,r)=>{let o=document.createElement("script");o.src=e,o.async=!0,o.onload=()=>window[t]?n(window[t]):r(new Error(`${e} did not register`)),o.onerror=()=>r(new Error(`${e} did not load`)),document.head.append(o)}).finally(()=>mt.delete(t))),mt.get(t)):Promise.reject(new Error("the CDN script\u2019s own URL is unknown"))}var hi=zr("onsite.min.js"),fn=()=>Wr(hi,Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.module"));var pn=Symbol.for("@thg-agentic/hyper-personalisation-web.bootstrap"),gi=Symbol.for("@thg-agentic/hyper-personalisation-web.drain"),yi=Symbol.for("@thg-agentic/hyper-personalisation-web.carry"),Jr=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),wi=Symbol.for("@thg-agentic/hyper-personalisation-web.unreachable"),Si=Symbol.for("@thg-agentic/hyper-personalisation-web.assignment"),_i=Symbol.for("@thg-agentic/hyper-personalisation-web.recommendation-context"),yt=e=>e?()=>j(e):()=>null,Zr={didomi:e=>zn({purposes:e.purposes}),onetrust:e=>Wn({groups:e.groups,impliedConsent:e.impliedConsent}),cookie:e=>Jn({name:e.name,categories:e.categories,refusedValue:e.refusedValue,source:e.source,changeEvent:e.changeEvent}),forwarded:e=>Yn({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)}},Yr=Object.keys(Zr),we=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ht=e=>typeof e=="string"&&e!=="",bi=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Qr=e=>we(e)&&typeof e.read=="function";function Ii(e,t={}){let n=[];if(!we(e))return["config must be { writeKey, apiHost? }"];ht(e.writeKey)||n.push("writeKey is required"),ie(e.apiHost)||n.push("apiHost, when given, must be a host or an http(s) origin"),t.propertyId!==void 0&&!ht(t.propertyId)&&n.push("propertyId must be a string");let{consent:r}=t;if(!Qr(r)&&!(we(r)&&Yr.includes(r.provider))&&n.push(`consent must be a consent adapter or { provider: ${Yr.join(" | ")} }`),t.autocapture!==void 0&&t.autocapture!==!1&&!we(t.autocapture)&&n.push("autocapture must be false or { promotions, productLists, recommendations }"),t.onsite!==void 0&&typeof t.onsite!="boolean"&&!we(t.onsite)&&n.push("onsite must be true, false or the onsite options"),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&&!ht(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&&!ht(t.dataLayer.name)&&n.push("dataLayer.name must be a string"),t.dataLayer.ignore!==void 0&&!bi(t.dataLayer.ignore)&&n.push("dataLayer.ignore must be an array of strings")):n.push("dataLayer must be an object")),n}function ki(e,t,n){if(Qr(e))return Bt(e,t.consentPurposes);let{provider:r,...o}=e,s=n?.consent?.[r]??Zr[r];return Bt(s(o),t.consentPurposes)}var wt=(e,t,n)=>`${e??""}|${t??""}${n?"|v":""}`,xi=(e,t,n,r)=>e===wt(t,n,!0)||!r&&e===wt(t,n,!1),Ai=e=>{if(e.context?.identity_token===void 0)return e;let{identity_token:t,...n}=e.context;return{...e,context:n}},eo=e=>{try{return sessionStorage.getItem(e)}catch{return null}};function vi(e,t){let n=F(t?.userId),r=ft(t?.emailSha256);if(!n&&!r)return null;let o=eo($(P("identified"),e));return xi(o,n,r,n!==null&&Ce(t?.token)!==null)?null:{...n?{userId:n}:{},...r?{email_sha256:r}:{}}}async function Ei({writeKey:e,apiHost:t},n){if(n.settings!==void 0)return{settings:en(n.settings),revalidated:null};let r=Pr(t,e),o=Or(e);if(o)return{settings:o,revalidated:r,fetched:r};let s=await r;return s?{settings:s,revalidated:r,fetched:r}:{settings:Qt,revalidated:null,fetched:r}}function to(e,t){let n=t??{},r=typeof window<"u"?window:null;if(r?.[pn])return r[pn];let o=Hn(e?.writeKey,()=>{let{analytics:i}=Oe(j(P("consent")));return i===!0||i===null&&n.holdAcrossPages===!0}),s=Li(e,n,o);if(r){let i=n.extend?.getSessionId??yt(n.identityCookies?.sessionId),u=yt(n.identityCookies?.anonymousId);r[Si]=({slot:c,arm:l}={})=>An({sessionId:Fe(i(),u()),slot:c,arm:l}),r[pn]=s,r[yi]=o,r[gi]?.(s)}return s}function Ci(){let e=globalThis.performance?.now?.();return new Date(Date.now()-(Number.isFinite(e)?e:0)).toISOString()}function Xr(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(At(e,r(n.promotions))),n.productLists&&o.push(xt(e,r(n.productLists))),n.recommendations&&o.push(vt(e,r(n.recommendations))),n.exposures&&o.push(kt(e,r(n.exposures)))}catch(s){console.warn("[hp] autocapture not started:",s?.message??s)}return()=>{for(let s of o)s()}}var Pi=1e3;function Oi(e,t,n,r){if(!t)return Be();let o=n.onsite?fn():null;o?.catch(()=>{}),(r?Promise.race([r.then(i=>i??n),new Promise(i=>setTimeout(()=>i(n),Pi))]):Promise.resolve(n)).then(i=>{let u=i.enabled?i.onsite:null;if(!u)return Be();let c=t===!0?{}:t;return(o??fn()).then(l=>l.startOnsite(e,{...c,settings:c.settings??u}))}).catch(i=>{Be(),console.warn("[hp] onsite not started:",i?.message??i)})}function gt(e){return e.close(),Be(),null}async function Li(e,t,n){try{let r=Ii(e,t);if(r.length)return console.warn(`[hp] not started, the configuration is invalid: ${r.join("; ")}`),gt(n);Ke(t.storageNames),Ge();let{writeKey:o}=e,[{settings:s,revalidated:i,fetched:u},c]=await Promise.all([Ei(e,t),Promise.resolve(t.identity).catch(()=>null)]),l=i?s:null,f=!1,p=()=>f&&l&&Lr(o,l);if(i?.then(g=>{g&&(l=g,g.enabled?p():tn(o))}),!s.enabled)return t.debug&&console.info("[hp] off: the settings for this write key do not enable it"),gt(n);let m=t.propertyId??s.propertyId??null;if(!m&&s!==Qt)return console.warn("[hp] not started: this write key covers several properties, so propertyId is required"),gt(n);let{preset:A}=t,w=vi(m,c),k=t.debug===!0||s.debug?.enabled===!0||nr(s.debug?.tokenSha256??null,P("debug")),b=F(c?.userId),x=Kr({apiHost:Er(e.apiHost,s.apiHost),servingHost:ie(e.apiHost),onsite:s.onsite??null,writeKey:o,propertyId:m,pageType:_e.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?.[m],getCurrency:t.getCurrency,getShipToCountry:t.getShipToCountry,getLocale:t.getLocale,consent:ki(t.consent,s,A),consentCookieDomain:t.consentCookieDomain,storageNames:t.storageNames,holdAcrossPages:t.holdAcrossPages===!0,mintAnonymousId:t.mintAnonymousId,debug:k,anonymousIdSource:s.anonymousId??void 0,getAnonymousId:yt(t.identityCookies?.anonymousId),getSessionId:t.identityCookies?.sessionId?yt(t.identityCookies.sessionId):void 0,getUserId:()=>b,identityToken:c?.token,beforeSend:t.beforeSend,...t.extend,onConsentStatus(g){if(g==="granted"&&(f=!0,p()),g==="denied"){tn(o);try{sessionStorage.removeItem($(P("identified"),m))}catch{}}t.extend?.onConsentStatus?.(g)},onEvent(g){if(g.type==="identify"){let y=$(P("identified"),m),O=F(g.userId),N=ft(g.traits?.email_sha256),U=!!g.context?.identity_token||eo(y)===wt(O,N,!0);try{sessionStorage.setItem(y,wt(O,N,U))}catch{}}t.extend?.onEvent?.(Ai(g))}});typeof window<"u"&&(window[_i]=()=>x.recommendationContext()),u?.then(g=>g===null&&x[wi]());for(let[g,y,O]of n.take())try{x[Jr](g,y,O)}catch(N){console.warn(`[hp] carried ${g} failed`,N)}x[Jr]("page",[t.pageType?{type:t.pageType}:{}],{messageId:oe(),timestamp:Ci()});let h=Xr(x,t.autocapture),E=x.page;x.page=qt("page",(...g)=>{let y=E(...g);return h(),h=Xr(x,t.autocapture),y});let S=typeof window<"u"?window:null;if(S?.addEventListener?.("pageshow",g=>{g.persisted&&x.page({navigation_trigger:"back_forward"})}),t.dataLayer&&S){let g=t.dataLayer.name??"dataLayer";S[g]=S[g]||[],tr(x,{...A,dataLayer:S[g],ignore:[...A?.ignore??[],...t.dataLayer.ignore??[]],onError:y=>k&&console.warn("[hp] dataLayer mapping failed",y)})}return w&&x.identify(w,void 0,Le),x.onsite=ye,Oi(x,t.onsite,s,i),x}catch(r){return console.warn("[hp] not started:",r?.message??r),gt(n)}}function no(e){e.initialized=!0,to(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 B=window.hp=window.hp||[];B.servingHeaders??(B.servingHeaders=()=>({}));B.inHoldout??(B.inHoldout=()=>!0);B.personalisationGroup??(B.personalisationGroup=()=>"excluded");B.recommendationContext??(B.recommendationContext=()=>({}));B.onsite??(B.onsite=ye);B.initialized||(B._config?no(B):B.load=(e,t)=>{B._config=e,B._options=t??{},no(B)});})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{async function
|
|
1
|
+
(()=>{async function Be(o,r,a){let l=b=>Array.from(new Uint8Array(b),w=>w.toString(16).padStart(2,"0")).join(""),p=new TextEncoder,x=o.maxnumber??1e6;for(let b=0;b<=x;b+=256){let w=[];for(let C=b;C<b+256&&C<=x;C++)w.push(crypto.subtle.digest("SHA-256",p.encode(o.salt+C)));let h=(await Promise.all(w)).findIndex(C=>l(C)===o.challenge);if(h>=0)return b+h;if(r&&await r(),a?.aborted)return null}return null}var Ct=()=>globalThis.scheduler?.postTask?.(()=>{},{priority:"user-visible"})??new Promise(o=>setTimeout(o,0)),He=(o,r)=>Be(o,Ct,r);function Tt(o,r){let a=`onmessage=async(e)=>postMessage(await(${Be})(e.data))`,l=URL.createObjectURL(new Blob([a],{type:"text/javascript"}));return new Promise((p,x)=>{let b;try{b=new Worker(l)}catch(h){URL.revokeObjectURL(l),x(h);return}let w=(h,C)=>{b.terminate(),URL.revokeObjectURL(l),h(C)};r.addEventListener("abort",()=>w(p,null),{once:!0}),b.onmessage=h=>w(p,h.data),b.onerror=h=>{h.preventDefault?.(),w(x,h)},b.postMessage({challenge:o.challenge,salt:o.salt,maxnumber:o.maxnumber})})}var Lt=o=>o&&o.algorithm==="SHA-256"&&typeof o.challenge=="string"&&typeof o.salt=="string"&&typeof o.signature=="string";async function Ge(o){if(!Lt(o)||typeof crypto?.subtle?.digest!="function")return null;let r=Date.now(),a=new AbortController,l,p=new Promise(w=>{l=setTimeout(()=>w(null),2e4)}),x=typeof Worker=="function"&&typeof Blob=="function"?Tt(o,a.signal).catch(()=>He(o,a.signal)):He(o,a.signal),b=await Promise.race([x,p]);return clearTimeout(l),a.abort(),typeof b!="number"?null:btoa(JSON.stringify({algorithm:o.algorithm,challenge:o.challenge,number:b,salt:o.salt,signature:o.signature,took:Date.now()-r}))}function X(o){if(typeof o!="string")return null;try{let r=new URL(o);return r.protocol==="https:"?r.href:null}catch{return null}}function K(o){if(typeof o!="string")return null;try{let r=new URL(o);return r.protocol==="https:"||r.protocol==="http:"&&r.hostname==="localhost"?r.href:null}catch{return null}}function be(o,r,a,l){if(typeof r=="string"){o.append(a.createTextNode(r));return}if(l>6||r===null)return;if(Array.isArray(r)){for(let w of r)be(o,w,a,l+1);return}if(typeof r!="object")return;let p="b"in r?"b":"i"in r?"i":"a"in r?"a":null;if(!p)return;let x=p==="a"?X(r.href):null,b=p==="a"&&!x?o:a.createElement(p);x&&(b.setAttribute("href",x),b.setAttribute("rel","noopener")),be(b,r[p],a,l+1),b!==o&&o.append(b)}function Ve(o,r=document){let a=r.createDocumentFragment();return be(a,o,r,0),a}var M=o=>o!==null&&typeof o=="object"&&!Array.isArray(o);function ee(o,r,a){if(typeof a=="string"&&a)return a;let l=M(o?.next?.answers)?o.next.answers:{};for(let p of o?.blocks??[])for(let x of r[p?.question]??[]){let b=l[`${p.question}=${x}`];if(typeof b=="string")return b}return typeof o?.next?.default=="string"?o.next.default:null}var ge={AT:"43",AU:"61",BE:"32",CA:"1",CH:"41",DE:"49",DK:"45",ES:"34",FI:"358",FR:"33",GB:"44",IE:"353",IT:"39",NL:"31",NO:"47",NZ:"64",PL:"48",PT:"351",SE:"46",US:"1"};function Xe(o,r){let a=String(o??"").replace(/[\s.()-]/g,"");a.startsWith("00")&&(a=`+${a.slice(2)}`);let l=ge[String(r??"").toUpperCase()];return!a.startsWith("+")&&l&&(a=`+${l}${a.replace(/^0/,"")}`),/^\+[1-9]\d{7,14}$/.test(a)?a:null}var Ke=o=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o);function xe(o,r,a,l,p){let x=o("select","i");x.setAttribute("aria-label",r);for(let[b,w]of[["",a],...l]){let h=o("option","",w);h.value=b,h.selected=b===p,x.append(h)}return x}var Ze=o=>{let r=o.options.length;return r<=4?r:r%4?3:4};var ve={system:"system-ui,sans-serif","neo-grotesque":'Inter,Roboto,"Helvetica Neue",Arial,sans-serif',humanist:'Seravek,"Gill Sans Nova",Ubuntu,Calibri,sans-serif',"geometric-humanist":"Avenir,Montserrat,Corbel,sans-serif","rounded-sans":'ui-rounded,Quicksand,Comfortaa,"Arial Rounded MT Bold",sans-serif',industrial:'Bahnschrift,"DIN Alternate","Franklin Gothic Medium",sans-serif',transitional:'Charter,"Sitka Text",Cambria,serif',"old-style":'"Iowan Old Style","Palatino Linotype",P052,serif',didone:'Didot,"Bodoni MT","Noto Serif Display",serif',"slab-serif":'Rockwell,"Roboto Slab","DejaVu Serif",serif'},ye="cubic-bezier(.16,1,.3,1)",we=`
|
|
2
2
|
:host{all:initial}
|
|
3
3
|
:host([preview]){display:block;position:relative;width:100%;height:100%;overflow:hidden;contain:layout paint}
|
|
4
4
|
.s{--a:var(--hp-accent,#111);--b:var(--hp-bg,#fff);--t:var(--hp-text,#111);--r:var(--hp-radius,16px);--oa:var(--hp-on-accent,#fff);--ot:var(--hp-on-accent-text,var(--oa));--fl:var(--hp-field,color-mix(in srgb,var(--t) 5%,var(--b)));--ft:var(--hp-field-text,var(--t));--mu:color-mix(in srgb,var(--t) 74%,var(--b));--ln:color-mix(in srgb,var(--t) 18%,var(--b));--br:min(12px,var(--r));--ir:min(var(--r),8px);font:16px/1.5 var(--hp-font,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif);color:var(--t);-webkit-font-smoothing:antialiased;box-sizing:border-box;margin:0;padding:0;border:0;background:none;max-width:none;max-height:none;overflow:visible}
|
|
@@ -13,7 +13,7 @@ dialog::backdrop{background:none}
|
|
|
13
13
|
.mob.popup{padding:12px}
|
|
14
14
|
.ov{display:none;position:absolute;inset:0;background:var(--hp-ov,rgb(10 10 14/.6));animation:hp-fade .3s ease both}
|
|
15
15
|
.popup>.ov,.fullscreen>.ov{display:block}
|
|
16
|
-
.w{position:relative;display:flex;flex-direction:column;width:min(100%,480px);max-height:100%;min-height:0;overflow:auto;overscroll-behavior:contain;background:var(--b);color:var(--t);border-radius:var(--r);box-shadow:0 24px 48px -24px rgb(0 0 0/.35),0 0 0 1px rgb(0 0 0/.05);animation:hp-pop .44s ${
|
|
16
|
+
.w{position:relative;display:flex;flex-direction:column;width:min(100%,480px);max-height:100%;min-height:0;overflow:auto;overscroll-behavior:contain;background:var(--b);color:var(--t);border-radius:var(--r);box-shadow:0 24px 48px -24px rgb(0 0 0/.35),0 0 0 1px rgb(0 0 0/.05);animation:hp-pop .44s ${ye} both}
|
|
17
17
|
.z-sm{width:min(100%,380px)}
|
|
18
18
|
.z-lg{width:min(100%,880px)}
|
|
19
19
|
.z-full,.fullscreen .w{width:100%;height:100%;max-height:none;border-radius:0;box-shadow:none}
|
|
@@ -105,7 +105,7 @@ legend{padding:0;margin-bottom:8px;font-size:13px;font-weight:600}
|
|
|
105
105
|
.pg{display:flex;flex-direction:column;gap:8px}
|
|
106
106
|
.pg p{font-weight:600}
|
|
107
107
|
.tr{height:6px;border-radius:99px;background:color-mix(in srgb,var(--t) 18%,var(--b));overflow:hidden}
|
|
108
|
-
.tr i{display:block;height:100%;border-radius:inherit;background:var(--a);transform:scaleX(0);transform-origin:left;transition:transform .6s ${
|
|
108
|
+
.tr i{display:block;height:100%;border-radius:inherit;background:var(--a);transform:scaleX(0);transform-origin:left;transition:transform .6s ${ye}}
|
|
109
109
|
.bi{display:block;width:100%;height:auto}
|
|
110
110
|
.bl{display:block;border-radius:var(--br)}
|
|
111
111
|
hr{width:100%;margin:4px 0;border:0;border-top:1px solid var(--ln)}
|
|
@@ -169,7 +169,7 @@ hr{width:100%;margin:4px 0;border:0;border-top:1px solid var(--ln)}
|
|
|
169
169
|
.inline .t-stack .m{max-height:none}
|
|
170
170
|
.out .w{animation:hp-out .2s ease-in both}
|
|
171
171
|
.out .ov{animation:hp-fade .2s ease-in reverse both}
|
|
172
|
-
.f>*{animation:hp-rise .5s ${
|
|
172
|
+
.f>*{animation:hp-rise .5s ${ye}}
|
|
173
173
|
.pv .w,.pv .ov,.pv .f>*,.inline .f>*{animation:none}
|
|
174
174
|
@keyframes hp-pop{from{opacity:0;transform:translateY(24px) scale(.96)}}
|
|
175
175
|
@keyframes hp-fade{from{opacity:0}}
|
|
@@ -178,4 +178,4 @@ hr{width:100%;margin:4px 0;border:0;border-top:1px solid var(--ln)}
|
|
|
178
178
|
@keyframes hp-down{from{transform:translateY(-100%)}}
|
|
179
179
|
@keyframes hp-out{to{opacity:0;transform:translateY(12px) scale(.98)}}
|
|
180
180
|
@media (prefers-reduced-motion:reduce){.s .w,.s .ov,.f>*{animation:hp-fade .15s ease both!important}.btn{transition:none}}
|
|
181
|
-
`;var Ct=/^#(?:[0-9a-f]{3}){1,2}$/i,Ge=["popup","fullscreen"],Tt=["ok","verify","already"],Lt=["stack","split","overlay","image-only"],Ve={bar:["bottom","top"],sheet:["bottom-right","bottom-left","bottom"],teaser:["bottom-left","bottom-right","left","right"]},Ot=["xs","sm","md","lg","xl","display"],Xe={xs:4,sm:8,md:16,lg:28,xl:44},Ke={sm:380,md:480,lg:880},Mt=["left","center","right"],Ze={secondary:" b2",link:" no"},It=220,Pt=["verify","already","held","fallback","success"],qt=[500,1500],Nt=600,jt=1800,S={email:"Enter a valid email address.",phone:"Enter a valid mobile number.",intl:"Enter a valid mobile number, starting with + and its country code.",consent:"Tick the box to sign up.",failed:"Something went wrong. Please try again.",busy:"Too many tries. Please wait a moment and try again.",spin:"Sign up first to spin.",yours:"Your code",held:"You\u2019re already on the list",resent:"We\u2019ve sent your code to your inbox again.",inbox:"Your code is in the email we sent when you first signed up.",shop:"Continue shopping",closeOffer:"Close offer",code:"We\u2019ll email your code to you.",claimed:"This email address has already claimed its code.",copied:"Copied",thanks:"Thanks, you\u2019re signed up",retry:"You\u2019re signed up, but we couldn\u2019t load your prize. Please try again.",unclaimed:"We couldn\u2019t load your prize right now.",unavailable:"Not available right now.",won:"You won"},H=(i,o,a)=>i.includes(o)?o:a,I=(i,o,a)=>Number.isFinite(i)?Math.min(Math.max(i,o),a):null,ve=i=>i.type==="date"||i.type==="number",we=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches===!0;function et(i){let o=M(i.layout)?i.layout:{},a=M(o.media)?o.media:null,l=H(Lt,o.template,"stack"),p=a?.side==="right"?"right":"left";return!a&&M(o.image)&&o.image.side!=="none"&&(a=o.image,o.image.side!=="top"&&(l="split",p=o.image.side==="right"?"right":"left")),(!a||!X(a.asset))&&(a=null,l="stack"),{template:l,media:a,side:p,scrim:I(o.scrim,0,.9)??.45,padding:H(["none","sm","md","lg"],o.padding,"md")}}var tt=(i,o)=>H(["sm","md","lg","full"],i.size,null)??(o.template==="split"||o.template==="overlay"?"lg":"md"),nt=(i,o,a=1,l="100vw")=>{if(i==="fullscreen"||o==="full")return l;let p=i==="teaser"?220:i==="sheet"?400:Ke[o]??Ke.md;return`(max-width: 639px) ${l}, ${Math.round(p*a)}px`},it=(i,o)=>i==="lg"?1/Be(o):.5,ot=(i,o,a)=>{if(!a||!Array.isArray(i.widths)||!o.endsWith(".webp"))return null;let l=i.widths.filter(p=>Number.isInteger(p)&&p>0&&p<a).sort((p,x)=>p-x);return l.length===0?null:[...l.map(p=>`${o.slice(0,-5)}-${p}w.webp ${p}w`),`${o} ${a}w`].join(",")},rt=(i,o)=>i.format==="inline"?"inline":o.format&&o.format!=="inline"?o.format:i.format,Ae=i=>i.kind==="video"||i.t==="video",Se={webm:"video/webm",mp4:"video/mp4",m4v:"video/mp4",mov:"video/quicktime",ogv:"video/ogg"},Ee=i=>Se[i.split(/[?#]/)[0].split(".").pop().toLowerCase()],Rt=(i,o)=>[...new Set([o,...Array.isArray(i.sources)?i.sources.map(X):[]])].filter(Boolean).sort((a,l)=>(Ee(l)===Se.webm)-(Ee(a)===Se.webm));function $e(i,o,a,l=new Set){let p=o.steps.find(v=>v.id===a);if(!p)return Promise.resolve();let x=rt(i,o),b=et(p),w=x==="teaser"&&p===o.steps[0],h=x==="teaser"&&!w?"popup":x,C=tt(o.theme,b),$=w?[]:p.blocks.flatMap(v=>{if(v?.t==="image"||v?.t==="video")return[[v]];let W=v?.display==="cards"&&i.questions.find(T=>T.key===v.question&&T.type==="one");return W?Object.values(v.pictures??{}).filter(M).map(T=>[T,it(C,W),"50vw"]):[]});return b.media&&!(w&&b.template!=="image-only")&&$.push([b.media,b.template==="split"?.46:1]),Promise.all($.map(([v,W,T])=>{let L=X(Ae(v)?v.poster:v.asset);if(!L)return null;let R=document.createElement("img"),y=!Ae(v)&&ot(v,L,I(v.width,1,8192));y&&(R.sizes=nt(h,C,W,T),R.srcset=y);let Z=`${R.sizes} ${y||L}`;return l.has(Z)?null:(l.add(Z),R.src=L,R.decode?.().catch(()=>{}))}))}var Je=i=>i?.call?i():clearInterval(i),Dt=0,ke=i=>`hp-${i}-${++Dt}`;function d(i,o,a){let l=document.createElement(i);return o&&(l.className=o),a!==void 0&&l.append(Fe(a)),l}var st=i=>{let o=i.length===4?[...i.slice(1)].map(a=>a+a).join(""):i.slice(1);return[0,2,4].map(a=>Number.parseInt(o.slice(a,a+2),16))},te=i=>{let[o,a,l]=st(i).map(p=>{let x=p/255;return x<=.04045?x/12.92:((x+.055)/1.055)**2.4});return .2126*o+.7152*a+.0722*l},Qe=(i,o=4.5)=>{let a=te(i)+.05,l=1.05/a;return l>=o?"#fff":a/(te("#111")+.05)>l?"#111":"#fff"};function Ut(i,o){let a=($,v)=>v&&i.style.setProperty($,v),l=$=>Ct.test($??"")?$:null;a("--hp-accent",l(o.accent)),a("--hp-bg",l(o.background)),a("--hp-text",l(o.text));let p=I(o.radius,0,48);p!==null&&a("--hp-radius",`${p}px`),a("--hp-font",o.font==="site"?i.ownerDocument.defaultView.getComputedStyle(i.parentElement??i.ownerDocument.body).fontFamily:Object.hasOwn(xe,o.font)?xe[o.font]:null),l(o.accent)&&(a("--hp-on-accent",Qe(o.accent,3)),a("--hp-on-accent-text",Qe(o.accent))),l(o.background)&&te(o.background)<.18&&(a("--hp-field","#fff"),a("--hp-field-text","#111"));let x=M(o.overlay)?o.overlay:{},b=[l(o.text),l(o.background)].filter(Boolean).sort(($,v)=>te($)-te(v))[0],[w,h,C]=st(l(x.colour)??b??"#0b0b0f");a("--hp-ov",`rgb(${w} ${h} ${C} / ${I(x.opacity,0,1)??.6})`)}function Wt(i){try{let o=new CSSStyleSheet;o.replaceSync(ye),i.adoptedStyleSheets=[o]}catch{let o=document.createElement("style");o.textContent=ye,i.append(o)}}function at(i){let{form:o,creative:a,decision:l,access:p,client:x,api:b,counters:w}=i,h=i.preview??null,C=e=>{let t=e.blocks.find(r=>r?.t==="email"||r?.t==="phone");return t?.t==="phone"||!t&&!o.consent_text?o.sms_consent_text:o.consent_text},$=rt(o,a),v=a.theme,W=H(Ve[$]??[],v.position,Ve[$]?.[0]),T=document.createElement("hp-onsite");h&&T.setAttribute("preview",""),Ut(T,v);let L=T.attachShadow({mode:"open"});Wt(L);let R=$!=="inline"&&!h,y=d(R?"dialog":$==="inline"?"section":"div"),Z=d("div","ov"),_=d("div","w"),F=d("div","m");h&&(F.dataset.hpMedia="");let _e=()=>{let e=d("form","f");return e.noValidate=!0,e.addEventListener("submit",wt),e.addEventListener("input",()=>{O.textContent&&E.getAttribute("aria-busy")!=="true"&&N(null)}),e},E=_e(),O=d("p","e");O.id=ke("err"),O.setAttribute("aria-live","assertive");let se=d("div","hd");se.setAttribute("aria-hidden","true"),_.append(se,F,E),y.append(Z,_);let B=$!=="inline"&&d("button","x");B&&(B.type="button",B.addEventListener("click",()=>j("close")),_.append(B),Z.addEventListener("click",()=>j("close"))),L.append(y);let n={step:null,mode:$,size:"md",modal:!1,mobile:h?.device==="mobile",answers:{},sent:new Set,seen:new Set,receipt:null,claim:i.coupon?{code:i.coupon}:h?{code:"WELCOME15"}:null,claiming:null,touched:!1,toWarm:new Set,warmed:i.warmed??new Set,warming:!1,owed:!1,unclaimed:!1,misses:0,submitted:!1,pow:null,wheel:null,timers:[],codes:[],videos:[],closed:!1},J=o.locale||document.documentElement.lang,ze=(o.questions.some(ve)||a.steps.some(e=>e.blocks.some(t=>t?.t==="countdown"||t?.display==="cards")))&&i.loadAnswers().catch(()=>null),Ce=new WeakMap,Te=()=>{let e=M(v.button)?v.button:{};y.className=`s ${n.mode}${W?` p-${W}`:""} b-${H(["pill","rounded","square"],e.shape,"rounded")}${n.mobile?" mob":""}${h?" pv":""}${e.style==="outline"?" bo":""}${v.caps===!0?" uc":""}`},Q=h?null:globalThis.matchMedia?.("(max-width: 639px)"),Le=()=>{n.mobile=Q?.matches===!0,de(),Te()};Q&&(n.mobile=Q.matches===!0,Q.addEventListener?.("change",Le));let ee=(e,t,r={})=>{h||!l.decision_id||!p.analytics()||x.slotEngaged({decision_id:l.decision_id,slot:l.slot,arm:l.arm??null,engagement:e,step:t??n.step?.id??null,...r})},N=(e,t)=>{O.className="e",O.textContent=e??"";for(let s of E.querySelectorAll("[aria-invalid]"))s.removeAttribute("aria-invalid");let r=t?.closest("label,fieldset");r&&E.contains(r)?r.after(O):E.append(O),t&&(t.setAttribute("aria-invalid","true"),t.setAttribute("aria-describedby",O.id),t.focus(),t.scrollIntoView?.({block:"nearest"}))},G=e=>{E.setAttribute("aria-busy",String(e));for(let t of E.querySelectorAll("button"))t.disabled=e},Oe=()=>h?Promise.resolve(null):(n.pow??(n.pow=b.challenge().then(e=>e.status===200?We(e.body):null).catch(()=>null)),n.pow),ae=()=>{for(let e of n.videos)try{document.hidden||we()?e.pause():e.play()?.catch?.(()=>{})}catch{}};document.addEventListener("visibilitychange",ae);function le(e,t,r,s,c){let u=X(e.asset);if(!u)return null;let g=typeof e.alt=="string"?e.alt:"",m;if(Ae(e)){m=d("video",t),m.muted=m.defaultMuted=m.loop=m.playsInline=!0;let A=X(e.poster);A&&(m.poster=A),g?m.setAttribute("aria-label",g):m.setAttribute("aria-hidden","true"),m.autoplay=!we()&&!h,m.preload=m.autoplay?"auto":A?"none":"metadata";let z=Rt(e,u);if(z.length>1)for(let P of z){let q=d("source");q.src=P;let Y=Ee(P);Y&&(q.type=Y),m.append(q)}else m.src=u;n.videos.push(m)}else{m=d("img",t),m.alt=g,m.decoding="async",m.loading=r?"eager":"lazy",r&&(m.fetchPriority="high");let A=ot(e,u,I(e.width,1,8192));A&&(m.sizes=nt(n.mode,n.size,s,c),m.srcset=A),m.src=u}let f=I(e.width,1,8192),k=I(e.height,1,8192);return f&&k&&(m.width=f,m.height=k),M(e.focal)&&(m.style.objectPosition=`${I(e.focal.x,0,100)??50}% ${I(e.focal.y,0,100)??50}%`),m}function Me(e,t){let r=d("label","l");r.append(d("span","lt",e.label??(t==="email"?"Email":"Mobile number")));let s=d("input","i");if(s.type=t,s.name=t==="email"?"email":"phone",s.autocomplete=s.inputMode=t,s.required=!0,typeof e.placeholder=="string"&&(s.placeholder=e.placeholder),s.setAttribute("aria-describedby",O.id),s.addEventListener("focus",Oe,{once:!0}),t!=="tel")return r.append(s),r;s.id=`${O.id}-p`,r.htmlFor=s.id;let c=be(d,"Country code","+",Object.entries(he).map(([g,m])=>[g,`${g} +${m}`]),(e.country||/-(\w\w)$/.exec(J)?.[1]||"").toUpperCase());c.classList.add("cc"),c.name="hp_cc";let u=d("span","ph");return u.append(c,s),r.append(u),r}function lt(e){let t=o.questions.find(f=>f.key===e.question);if(!t||!ve(t)&&!Array.isArray(t.options))return null;let r=d("fieldset");r.dataset.question=t.key,r.append(d("legend","",t.label??""));let s=n.answers[t.key]??[],c=e.display==="cards"&&t.type==="one";if(ve(t)||c)return ze.then(f=>{if(!f)return r.append(d("p","sm",S.unavailable));if(c)return f.answerCards(r,t,e,d,s,k=>le(k,"qi",!1,it(n.size,t),"50vw"),L);f.answerFields(r,t,d,s[0],J),Ce.set(r,()=>f.answerOf(r,t,void 0,J))}),r;let u=t.type==="many",g=H(["list","dropdown"],e.display,"buttons"),m=t.options.filter(f=>M(f)&&typeof f.value=="string");if(g==="dropdown"&&!u)return r.append(be(d,t.label??t.key,"\u2014",m.map(f=>[f.value,f.label??f.value]),s[0])),r;g!=="buttons"&&(r.className="ls");for(let f of m){let k=d("label",g==="buttons"?"ch":"c"),A=d("input");A.type=u?"checkbox":"radio",A.name=`q_${t.key}`,A.value=f.value,A.checked=s.includes(f.value),k.append(A,d("span","",f.label??f.value)),r.append(k)}return r}function ne(){for(let e of n.codes){if(e.replaceChildren(),!n.claim){n.unclaimed&&e.append(d("p","",S.unclaimed));continue}if(!n.claim.code){let s=n.claim.held?S.claimed:n.claim.fallback===!0?S.code:n.claim.prize?.label;s&&e.append(d("p","",s));continue}n.claim.prize?.label&&e.append(d("p","",n.claim.prize.label));let t=d("output");t.textContent=n.claim.code;let r=d("button","btn cp");r.type="button",r.textContent="Copy code",r.addEventListener("click",()=>{navigator.clipboard?.writeText(n.claim.code).then(()=>{r.textContent=S.copied}).catch(()=>{})}),e.append(t,r)}}function ct(e){if(n.claim&&!n.claim.code)return null;let t=d("div","cd");return t.hidden=!0,ze.then(r=>r&&t.isConnected&&n.timers.push(r.countdown(t,e,h,d))),t}function ce(e,t){return e.href=t,e.rel="noopener",e.addEventListener("click",r=>{h?r.preventDefault():ee("click")}),e}function dt(e){let t=e.label??"Continue";if(e.action==="link"){let s=V(e.href);return s?ce(d("a",`btn${Ze[e.variant]??""}`,t),s):null}let r=d("button",`btn${Ze[e.variant]??""}`,t);return r.type=e.action==="submit"?"submit":"button",r.type==="button"?r.addEventListener("click",()=>re(e)):r.dataset.submit="",r}let Ie=(e,t,r)=>(e.classList.add(`x-${H(Ot,t.size,r)}`),Mt.includes(t.align)&&e.classList.add(`a-${t.align}`),e);function Pe(e){let t=le(e,"bi",n.step===a.steps[0]);if(!t)return null;t.style.objectFit=e.fit==="contain"?"contain":"cover";let r=I(e.radius,0,48);r!==null&&(t.style.borderRadius=`${r}px`);let s=I(e.max_height,40,800);if(s!==null&&(t.style.maxHeight=`${s}px`),!t.width&&e.fit!=="contain"&&(t.style.aspectRatio="16 / 9"),e.t==="video"||!V(e.href))return t;let c=ce(d("a","bl"),V(e.href));return c.append(t),c}function pt(e){let t=I(e.threshold,.01,1e7);if(!t)return null;let r=d("div","pg"),s=d("p"),c=d("div","tr"),u=d("i");c.append(u),c.setAttribute("role","progressbar"),c.setAttribute("aria-valuemin","0"),c.setAttribute("aria-valuemax",String(t)),r.append(s,c);let g=f=>f.toFixed(2);try{let f=new Intl.NumberFormat(J||void 0,{style:"currency",currency:e.currency});g=k=>f.format(k)}catch{}let m=()=>{let f=Math.max(0,Number(i.basket?.())||0),k=t-f;s.textContent=k>0?String(e.text??"").replace("{amount}",g(k)):e.done??"",u.style.transform=`scaleX(${Math.min(1,f/t)})`,c.setAttribute("aria-valuenow",String(Math.min(f,t))),s.id||(s.id=ke("pg")),c.setAttribute("aria-labelledby",s.id)};return m(),n.timers.push(setInterval(m,2e3)),r}function ut(e){let t=d("div","pr");return i.loadProducts?.().then(r=>{t.isConnected&&n.timers.push(r.mountProducts(t,e,{el:d,lang:J,root:L,placement:o.slot,preview:h,client:!h&&p.analytics()&&x,engaged:ee,seen:n.seen}))}).catch(()=>{}),t}let qe={heading(e){let t=Ie(d("h2","",e.text),e,"xl");return t.id=ke("h"),t.tabIndex=-1,y.hasAttribute("aria-labelledby")||(y.setAttribute("aria-labelledby",t.id),n.step===a.steps[0]&&Ge.includes(n.mode)&&!h&&(t.autofocus=!0)),t},text:e=>Ie(d("p","",e.text),e,"md"),email:e=>Me(e,"email"),phone:e=>Me(e,"tel"),consent(e){let t=C(n.step)?.text;if(typeof t!="string")return null;if(e.required!==!0)return d("p","sm",t);let r=d("label","c"),s=d("input");return s.type="checkbox",s.name="hp_consent",s.required=!0,s.setAttribute("aria-describedby",O.id),r.append(s,d("span","",t)),r},question:lt,wheel(){let e=d("div","wh");return i.loadWheel().then(t=>{n.closed||(n.wheel=t.mountWheel(e,o.prizes))}).catch(()=>{}),e},code(){let e=d("div","k");return e.setAttribute("aria-live","polite"),n.codes.push(e),e},button:dt,decline(e){let t=d("button","btn no",e.label??"No thanks");return t.type="button",t.addEventListener("click",()=>j("decline")),t},countdown:ct,progress:pt,products:ut,image:Pe,video:Pe,spacer(e){let t=d("div","sp");return t.style.height=`${Xe[e.size]??Xe.md}px`,t.setAttribute("aria-hidden","true"),t},divider:()=>d("hr")};function ft(e,t){F.replaceChildren();let r=e.media,s=!r||t&&e.template!=="image-only";if(n.size=tt(v,e),_.className=`w t-${e.template} z-${n.size}${e.side==="right"?" right":""}${v.text_align==="center"?" ta-center":""}${s?" nm":""}`,_.style.setProperty("--sc",String(e.scrim)),E.className=`f pd-${e.padding}`,F.hidden=s,F.hidden)return;let c=le(r,"",n.step===a.steps[0],e.template==="split"?.46:1);if(!c)return;if(c.width?_.style.setProperty("--ar",`${c.width} / ${c.height}`):_.style.removeProperty("--ar"),e.template!=="image-only"){c.tagName==="IMG"&&e.template==="overlay"&&(c.alt=""),F.append(c);return}let u=V(r.href),g=u?ce(d("a","io"),u):d("button","io");u||(g.type="button",g.addEventListener("click",()=>re({action:"next"}))),g.append(c),F.append(g)}function mt(e){let t=e.blocks.find(c=>c?.t==="heading"),r=e.blocks.find(c=>c?.t==="button"&&c.action==="next"),s=d("button","tb");return s.textContent=t?d("b","",t.text).textContent:r?.label??"Open",s.type="button",s.addEventListener("click",()=>re(r??{action:"next"})),s}function D(e,t=new Set){let r=a.steps.find(z=>z.id===e);if(!r)return j("done");if(r.kind==="question"&&!h&&!p.analytics()&&!t.has(r.id))return D(K(r,n.answers),t.add(r.id));let s=n.step!==null,c=s&&(L.activeElement||document.activeElement===document.body),u=s&&!h?{mode:n.mode,w:_.offsetWidth,h:_.offsetHeight,top:_.offsetTop}:null;n.step=r,n.touched=!1;for(let z of n.timers.splice(0))Je(z);n.codes=[],n.videos=[],n.wheel=null;let g=$==="teaser"&&r===a.steps[0];if(n.mode=$==="teaser"&&!g?"popup":$,$==="teaser"&&w.tab?.(o.slot,g),B&&B.setAttribute("aria-label",g?S.closeOffer:"Close"),Te(),y.removeAttribute("aria-labelledby"),u){let z=_e();E.replaceWith(z),E=z}let m=et(r);ft(m,g);let f=u?.mode==="popup"&&n.mode==="popup";if(de(),u?.mode===n.mode&&u.h>0&&!f&&(_.style.setProperty("--lw",`${u.w}px`),_.style.setProperty("--lh",`${u.h}px`),_.classList.add("lk")),E.replaceChildren(),g&&m.template!=="image-only")E.append(mt(r));else for(let[z,P]of r.blocks.entries()){let q=M(P)&&Object.hasOwn(qe,P.t)?qe[P.t](P):null;q&&(h&&(q.dataset.hpBlock=String(z)),E.append(q))}let k=E.querySelector("[data-submit]"),A=E.querySelector("[name=hp_consent]")?.parentNode;k&&A&&k.before(A),E.hidden=E.childElementCount===0,N(null),ne(),y.hasAttribute("aria-labelledby")?y.removeAttribute("aria-label"):y.setAttribute("aria-label",m.media?.alt?.trim?.()||"Sign up"),f&&u.h>0&&ht(u),s&&Ne(),ae(),h||bt(r),c&&E.querySelector("h2")?.focus()}function de(){_.classList.remove("lk","an"),_.style.removeProperty("--tp")}function ht(e){let t=_.offsetHeight;_.classList.add("an");let r=_.offsetTop,s=Math.max(0,e.top-r);if(s+t>y.clientHeight-2*r)return de();_.style.setProperty("--tp",`${s}px`)}function bt(e){let t=e.next??{};for(let c of[t.default,...Object.values(M(t.answers)?t.answers:{}),...e.blocks.map(u=>u?.next),...Pt])typeof c=="string"&&n.toWarm.add(c);if(n.warming)return;n.warming=!0;let r=()=>{if(n.warming=!1,!n.closed&&T.isConnected)for(let c of n.toWarm)$e(o,a,c,n.warmed);n.toWarm.clear()},s=()=>globalThis.requestIdleCallback?requestIdleCallback(r,{timeout:2e3}):setTimeout(r,200);document.readyState==="complete"?s():window.addEventListener("load",s,{once:!0})}function Ne(){if(!R)return;let e=Ge.includes(n.mode);if(!(y.open&&n.modal===e)){try{y.open&&y.close()}catch{}if(n.modal=e,y.setAttribute("aria-modal",String(e)),e&&typeof y.showModal=="function")y.showModal();else if(typeof y.show=="function"){let t=document.activeElement;y.show(),t&&t!==document.body?t.focus?.({preventScroll:!0}):T.blur()}else y.setAttribute("open","");!e||typeof y.showModal!="function"?y.setAttribute("role","dialog"):y.removeAttribute("role")}}function gt(){for(let e of E.querySelectorAll("fieldset[data-question]")){let t=e.dataset.question,r=Ce.get(e)?.()??{};if(r.error)return r;let s=[r.value,...[...e.querySelectorAll("input:checked,select:not([name])")].map(c=>c.value)].filter(Boolean);s.length?n.answers[t]=s:delete n.answers[t]}}function xt(){let e=[];for(let[r,s]of Object.entries(n.answers)){let c=`${r}=${s.join(",")}`;n.sent.has(c)||(n.sent.add(c),e.push({question:r,values:s}))}let t=n.step.id;if(n.signedUp&&e.length)return void b.answers({anonymousId:p.anonymousId(),sessionId:p.sessionId()??void 0,slot:l.slot,arm:l.arm??void 0,decision_id:l.decision_id??void 0,step:t,...n.signedUp,answers:e,context:je()});if(p.analytics())for(let r of e)x.preferencesStated({...r,source:"onsite",slot:l.slot,arm:l.arm??null,decision_id:l.decision_id??null,step:t})}let je=()=>({page:{url:p.pageUrl()},locale:p.locale()??void 0,consent:p.consent()}),ie=e=>{n.receipt&&!h&&xt(),D(K(n.step,n.answers,e))};async function yt(e){let t=n.step,r=E.querySelector("input[name=email],input[name=phone]");if(!r)return ie(e.next);let s=r.name==="email"?"email":"sms",c=E.querySelector("select[name=hp_cc]")?.value,u=s==="email"?He(r.value.trim())?r.value.trim():null:Ye(r.value,c);if(!u)return N(s==="email"?S.email:c?S.phone:S.intl,r);let g=E.querySelector("input[name=hp_consent]");if(g&&!g.checked)return N(S.consent,g);N(null),G(!0);let m=await Oe();n.pow=null;let f=Object.entries(n.answers).map(([U,fe])=>({question:U,values:fe})),k=s==="sms"?o.sms_consent_text:o.consent_text,A=await b.capture({anonymousId:p.anonymousId(),sessionId:p.sessionId()??void 0,slot:l.slot,arm:l.arm??void 0,decision_id:l.decision_id??void 0,step:t.id,channel:s,[s==="email"?"email":"phone"]:u,...s==="sms"&&n.signedUp,consent_text:k?{id:k.id,version:k.version}:void 0,...f.length?{answers:f}:{},...m?{altcha:m}:{},context:je()}),z=A.body?.status,P=(A.status===202||A.status===200)&&Tt.includes(z);if(n.closed&&!P)return;P||G(!1);let q=A.status===400?A.body?.field:null;if(q==="email"||q==="phone")return N(S[q],r);if(!P)return N(A.status===429?S.busy:S.failed,r);r.value="";for(let[U,fe]of Object.entries(n.answers))n.sent.add(`${U}=${fe.join(",")}`);n.receipt=typeof A.body.receipt=="string"?A.body.receipt:null,s==="email"&&(n.signedUp={email:u,email_receipt:n.receipt}),n.submitted=!0,w.submitted(o.slot),ee("submit",t.id),n.owed=s==="email"&&o.prizes.length>0;let Y=n.owed?pe([]):null;Y||i.emit?.("submitted",{coupon:null});let At=Y&&await Promise.race([Y,new Promise(U=>setTimeout(U,Nt))]);if(n.closed)return;if(G(!1),At?.held)return D(oe("held"));let St=z!=="ok"&&a.steps.some(U=>U.id===z);D(St?z:K(t,n.answers,e.next));let Et=n.step;Y?.then(U=>{U?.held&&!n.closed&&n.step===Et&&!n.touched&&D(oe("held"))})}function oe(e){if(a.steps.some(s=>s.id===e))return e;let t={t:"button",label:S.shop,action:"close"},r=e==="unclaimed"?[{t:"heading",text:S.thanks},{t:"text",text:S.unclaimed},t]:e==="fallback"||n.claim?.code?[{t:"heading",text:e==="fallback"?S.thanks:S.yours},{t:"code"}]:[{t:"heading",text:S.held},{t:"text",text:o.code_relayed===!0?S.resent:S.inbox},t];return a.steps.push({id:e,blocks:r}),e}function Re(e){n.owed&&(n.owed=!1,i.emit?.("submitted",{coupon:e?{code:e.code??null,prize:e.prize?.key}:null}))}function pe(e=qt){let t=n.receipt;return n.claiming??(n.claiming=(async()=>{n.unclaimed=!1;let r;for(let g of[0,...e])if(g&&await new Promise(m=>setTimeout(m,g)),r=await b.claim({slot:l.slot,decision_id:l.decision_id??void 0,receipt:t}),r.status!==503)break;let s=r.body,c=s?.fallback===!0&&!s.code;if(r.status!==200||!(M(s?.prize)||c))return n.claiming=null,!e.length&&r.status===503?pe():(Re(null),n.unclaimed=!0,n.closed||ne(),null);let u=s.held&&!s.code?w.code?.():null;return u&&(s={...s,code:u}),n.claim=s,typeof s.code=="string"&&w.code?.(s.code),Re(s),n.closed||ne(),s})()),n.claiming}async function vt(e){if(!n.receipt)return N(S.spin);G(!0);let t=await pe();if(n.closed)return;if(!t)return G(!1),n.misses+=1,n.misses<2?N(S.retry):D(oe("unclaimed"));let r=t.fallback===!0&&!t.code,s=t.held?-1:o.prizes.findIndex(g=>g.key===t.prize?.key&&g.label===t.prize?.label);if(n.wheel&&s>=0&&!r){if(await n.wheel.spinTo(s),n.closed)return;O.className="e won",O.textContent=`${S.won} ${t.prize.label}`,await new Promise(g=>setTimeout(g,jt))}if(n.closed)return;G(!1);let c=r?"fallback":s<0?"held":null,u=c?oe(c):K(n.step,n.answers,e.next);u?D(u):ne()}function re(e){if(e.action==="close")return j("close");let t=gt();return h?ie(e.next):t?N(t.error,t.input):e.action==="apply"?(i.emit?.("apply",{coupon:n.claim?.code?{code:n.claim.code}:null}),ee("click"),K(n.step,n.answers,e.next)?ie(e.next):j("done")):e.action==="submit"?yt(e):e.action==="spin"?vt(e):ie(e.next)}function wt(e){if(e.preventDefault(),E.getAttribute("aria-busy")==="true")return;let t=n.step.blocks.find(r=>r?.t==="button"&&r.action==="submit");re(t??{action:"next"})}function ue(e=!1){n.closed=!0;for(let r of n.timers.splice(0))Je(r);document.removeEventListener("visibilitychange",ae),Q?.removeEventListener?.("change",Le);let t=()=>{try{y.open&&y.close()}catch{}T.remove()};if(e||!R||we())return t();y.classList.add("out"),setTimeout(t,It)}function j(e){n.closed||h||(!n.submitted&&e!=="done"&&ee("dismiss"),w.closed(o.slot),w.tab?.(o.slot,!1),ue(),i.onClose?.(e))}for(let e of["pointerdown","keydown","input"])y.addEventListener(e,()=>{n.touched=!0});y.addEventListener("cancel",e=>{e.preventDefault(),j("esc")}),y.addEventListener("keydown",e=>{e.key==="Escape"&&!n.modal&&$!=="inline"&&j("esc"),e.key==="Tab"&&n.modal&&kt(e)});function kt(e){let t=[...L.querySelectorAll("input[type=radio]:checked")],r=new Set,s=[...L.querySelectorAll("a[href],button,input,select,textarea")].filter(f=>{if(f.disabled||!f.getClientRects().length)return!1;if(f.type!=="radio")return!0;let k=t.find(A=>A.name===f.name);return(k?f!==k:r.has(f.name))?!1:(r.add(f.name),!0)});if(!s.length)return;let c=e.shiftKey,u=L.activeElement;u?.type==="radio"&&(u=s.find(f=>f.type==="radio"&&f.name===u.name)??u);let g=s.indexOf(u),m=null;if(g<0){let f=k=>u&&u.compareDocumentPosition(k)&4;m=c?s.findLast(k=>!f(k))??s.at(-1):s.find(f)??s[0]}else(c?g===0:g===s.length-1)&&(m=s.at(c?-1:0));m&&(e.preventDefault(),m.focus())}se.addEventListener("pointerdown",e=>{if(!n.mobile||n.mode!=="sheet")return;let t=e.clientY,r=0,s=u=>{r=Math.max(0,u.clientY-t),_.style.transform=`translateY(${r}px)`},c=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",c),_.style.transform="",r>80&&j("close")};document.addEventListener("pointermove",s),document.addEventListener("pointerup",c)});try{D(h?.step&&a.steps.some(e=>e.id===h.step)?h.step:a.steps[0].id),(i.container??document.body).append(T),Ne()}catch(e){throw ue(!0),e}return{close:j,root:L,host:T,show:D,step:()=>n.step?.id??null,modal:()=>!n.closed&&n.modal,destroy:()=>!n.closed&&ue()}}window[Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.render")]={mountForm:at,warm:$e};})();
|
|
181
|
+
`;var Ot=/^#(?:[0-9a-f]{3}){1,2}$/i,Je=["popup","fullscreen"],Mt=["ok","verify","already"],It=["stack","split","overlay","image-only"],Qe={bar:["bottom","top"],sheet:["bottom-right","bottom-left","bottom"],teaser:["bottom-left","bottom-right","left","right"]},Pt=["xs","sm","md","lg","xl","display"],et={xs:4,sm:8,md:16,lg:28,xl:44},tt={sm:380,md:480,lg:880},qt=["left","center","right"],nt={secondary:" b2",link:" no"},Nt=220,jt=["verify","already","held","fallback","success"],Rt=[500,1500],Dt=600,Ut=1800,S={email:"Enter a valid email address.",phone:"Enter a valid mobile number.",intl:"Enter a valid mobile number, starting with + and its country code.",consent:"Tick the box to sign up.",failed:"Something went wrong. Please try again.",busy:"Too many tries. Please wait a moment and try again.",spin:"Sign up first to spin.",yours:"Your code",held:"You\u2019re already on the list",resent:"We\u2019ve sent your code to your inbox again.",inbox:"Your code is in the email we sent when you first signed up.",shop:"Continue shopping",closeOffer:"Close offer",code:"We\u2019ll email your code to you.",claimed:"This email address has already claimed its code.",copied:"Copied",thanks:"Thanks, you\u2019re signed up",retry:"You\u2019re signed up, but we couldn\u2019t load your prize. Please try again.",unclaimed:"We couldn\u2019t load your prize right now.",unavailable:"Not available right now.",won:"You won"},H=(o,r,a)=>o.includes(r)?r:a,I=(o,r,a)=>Number.isFinite(o)?Math.min(Math.max(o,r),a):null,ke=o=>o.type==="date"||o.type==="number",Ae=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches===!0;function rt(o){let r=M(o.layout)?o.layout:{},a=M(r.media)?r.media:null,l=H(It,r.template,"stack"),p=a?.side==="right"?"right":"left";return!a&&M(r.image)&&r.image.side!=="none"&&(a=r.image,r.image.side!=="top"&&(l="split",p=r.image.side==="right"?"right":"left")),(!a||!K(a.asset))&&(a=null,l="stack"),{template:l,media:a,side:p,scrim:I(r.scrim,0,.9)??.45,padding:H(["none","sm","md","lg"],r.padding,"md")}}var st=(o,r)=>H(["sm","md","lg","full"],o.size,null)??(r.template==="split"||r.template==="overlay"?"lg":"md"),at=(o,r,a=1,l="100vw")=>{if(o==="fullscreen"||r==="full")return l;let p=o==="teaser"?220:o==="sheet"?400:tt[r]??tt.md;return`(max-width: 639px) ${l}, ${Math.round(p*a)}px`},lt=(o,r)=>o==="lg"?1/Ze(r):.5,ct=(o,r,a)=>{if(!a||!Array.isArray(o.widths)||!r.endsWith(".webp"))return null;let l=o.widths.filter(p=>Number.isInteger(p)&&p>0&&p<a).sort((p,x)=>p-x);return l.length===0?null:[...l.map(p=>`${r.slice(0,-5)}-${p}w.webp ${p}w`),`${r} ${a}w`].join(",")},dt=(o,r)=>o.format==="inline"?"inline":r.format&&r.format!=="inline"?r.format:o.format,Ee=o=>o.kind==="video"||o.t==="video",$e={webm:"video/webm",mp4:"video/mp4",m4v:"video/mp4",mov:"video/quicktime",ogv:"video/ogg"},_e=o=>$e[o.split(/[?#]/)[0].split(".").pop().toLowerCase()],Wt=(o,r)=>[...new Set([r,...Array.isArray(o.sources)?o.sources.map(K):[]])].filter(Boolean).sort((a,l)=>(_e(l)===$e.webm)-(_e(a)===$e.webm));function ze(o,r,a,l=new Set){let p=r.steps.find(v=>v.id===a);if(!p)return Promise.resolve();let x=dt(o,r),b=rt(p),w=x==="teaser"&&p===r.steps[0],h=x==="teaser"&&!w?"popup":x,C=st(r.theme,b),$=w?[]:p.blocks.flatMap(v=>{if(v?.t==="image"||v?.t==="video")return[[v]];let W=v?.display==="cards"&&o.questions.find(T=>T.key===v.question&&T.type==="one");return W?Object.values(v.pictures??{}).filter(M).map(T=>[T,lt(C,W),"50vw"]):[]});return b.media&&!(w&&b.template!=="image-only")&&$.push([b.media,b.template==="split"?.46:1]),Promise.all($.map(([v,W,T])=>{let L=K(Ee(v)?v.poster:v.asset);if(!L)return null;let j=document.createElement("img"),y=!Ee(v)&&ct(v,L,I(v.width,1,8192));y&&(j.sizes=at(h,C,W,T),j.srcset=y);let Z=`${j.sizes} ${y||L}`;return l.has(Z)?null:(l.add(Z),j.src=L,j.decode?.().catch(()=>{}))}))}var it=o=>o?.call?o():clearInterval(o),Ft=0,Se=o=>`hp-${o}-${++Ft}`;function d(o,r,a){let l=document.createElement(o);return r&&(l.className=r),a!==void 0&&l.append(Ve(a)),l}var pt=o=>{let r=o.length===4?[...o.slice(1)].map(a=>a+a).join(""):o.slice(1);return[0,2,4].map(a=>Number.parseInt(r.slice(a,a+2),16))},te=o=>{let[r,a,l]=pt(o).map(p=>{let x=p/255;return x<=.04045?x/12.92:((x+.055)/1.055)**2.4});return .2126*r+.7152*a+.0722*l},ot=(o,r=4.5)=>{let a=te(o)+.05,l=1.05/a;return l>=r?"#fff":a/(te("#111")+.05)>l?"#111":"#fff"};function Yt(o,r){let a=($,v)=>v&&o.style.setProperty($,v),l=$=>Ot.test($??"")?$:null;a("--hp-accent",l(r.accent)),a("--hp-bg",l(r.background)),a("--hp-text",l(r.text));let p=I(r.radius,0,48);p!==null&&a("--hp-radius",`${p}px`),a("--hp-font",r.font==="site"?o.ownerDocument.defaultView.getComputedStyle(o.parentElement??o.ownerDocument.body).fontFamily:Object.hasOwn(ve,r.font)?ve[r.font]:null),l(r.accent)&&(a("--hp-on-accent",ot(r.accent,3)),a("--hp-on-accent-text",ot(r.accent))),l(r.background)&&te(r.background)<.18&&(a("--hp-field","#fff"),a("--hp-field-text","#111"));let x=M(r.overlay)?r.overlay:{},b=[l(r.text),l(r.background)].filter(Boolean).sort(($,v)=>te($)-te(v))[0],[w,h,C]=pt(l(x.colour)??b??"#0b0b0f");a("--hp-ov",`rgb(${w} ${h} ${C} / ${I(x.opacity,0,1)??.6})`)}function Ht(o){try{let r=new CSSStyleSheet;r.replaceSync(we),o.adoptedStyleSheets=[r]}catch{let r=document.createElement("style");r.textContent=we,o.append(r)}}function ut(o){let{form:r,creative:a,decision:l,access:p,client:x,api:b,counters:w}=o,h=o.preview??null,C=e=>{let t=e.blocks.find(i=>i?.t==="email"||i?.t==="phone");return t?.t==="phone"||!t&&!r.consent_text?r.sms_consent_text:r.consent_text},$=dt(r,a),v=a.theme,W=H(Qe[$]??[],v.position,Qe[$]?.[0]),T=document.createElement("hp-onsite");h&&T.setAttribute("preview",""),Yt(T,v);let L=T.attachShadow({mode:"open"});Ht(L);let j=$!=="inline"&&!h,y=d(j?"dialog":$==="inline"?"section":"div"),Z=d("div","ov"),_=d("div","w"),F=d("div","m");h&&(F.dataset.hpMedia="");let Ce=()=>{let e=d("form","f");return e.noValidate=!0,e.addEventListener("submit",St),e.addEventListener("input",()=>{O.textContent&&E.getAttribute("aria-busy")!=="true"&&N(null)}),e},E=Ce(),O=d("p","e");O.id=Se("err"),O.setAttribute("aria-live","assertive");let se=d("div","hd");se.setAttribute("aria-hidden","true"),_.append(se,F,E),y.append(Z,_);let B=$!=="inline"&&d("button","x");B&&(B.type="button",B.addEventListener("click",()=>D("close")),_.append(B),Z.addEventListener("click",()=>D("close"))),L.append(y);let n={step:null,mode:$,size:"md",modal:!1,mobile:h?.device==="mobile",answers:{},answeredOn:{},sent:new Set,clicked:!1,seen:new Set,receipt:null,claim:o.coupon?{code:o.coupon}:h?{code:"WELCOME15"}:null,claiming:null,touched:!1,toWarm:new Set,warmed:o.warmed??new Set,warming:!1,owed:!1,unclaimed:!1,misses:0,submitted:!1,pow:null,wheel:null,timers:[],codes:[],videos:[],closed:!1},J=r.locale||document.documentElement.lang,Te=(r.questions.some(ke)||a.steps.some(e=>e.blocks.some(t=>t?.t==="countdown"||t?.display==="cards")))&&o.loadAnswers().catch(()=>null),Le=new WeakMap,Oe=()=>{let e=M(v.button)?v.button:{};y.className=`s ${n.mode}${W?` p-${W}`:""} b-${H(["pill","rounded","square"],e.shape,"rounded")}${n.mobile?" mob":""}${h?" pv":""}${e.style==="outline"?" bo":""}${v.caps===!0?" uc":""}`},Q=h?null:globalThis.matchMedia?.("(max-width: 639px)"),Me=()=>{n.mobile=Q?.matches===!0,pe(),Oe()};Q&&(n.mobile=Q.matches===!0,Q.addEventListener?.("change",Me));let ae=!r.channels?.length,G=(e,t,i={})=>{if(!(h||!l.decision_id||!p.analytics())){if(e==="click"){let s=n.clicked;if(n.clicked=!0,s&&!i.products)return}x.slotEngaged({decision_id:l.decision_id,slot:l.slot,arm:l.arm??null,engagement:e,step:t??n.step?.id??null,...i})}},N=(e,t)=>{O.className="e",O.textContent=e??"";for(let s of E.querySelectorAll("[aria-invalid]"))s.removeAttribute("aria-invalid");let i=t?.closest("label,fieldset");i&&E.contains(i)?i.after(O):E.append(O),t&&(t.setAttribute("aria-invalid","true"),t.setAttribute("aria-describedby",O.id),t.focus(),t.scrollIntoView?.({block:"nearest"}))},V=e=>{E.setAttribute("aria-busy",String(e));for(let t of E.querySelectorAll("button"))t.disabled=e},Ie=()=>h?Promise.resolve(null):(n.pow??(n.pow=b.challenge().then(e=>e.status===200?Ge(e.body):null).catch(()=>null)),n.pow),le=()=>{for(let e of n.videos)try{document.hidden||Ae()?e.pause():e.play()?.catch?.(()=>{})}catch{}};document.addEventListener("visibilitychange",le);function ce(e,t,i,s,c){let u=K(e.asset);if(!u)return null;let g=typeof e.alt=="string"?e.alt:"",m;if(Ee(e)){m=d("video",t),m.muted=m.defaultMuted=m.loop=m.playsInline=!0;let A=K(e.poster);A&&(m.poster=A),g?m.setAttribute("aria-label",g):m.setAttribute("aria-hidden","true"),m.autoplay=!Ae()&&!h,m.preload=m.autoplay?"auto":A?"none":"metadata";let z=Wt(e,u);if(z.length>1)for(let P of z){let q=d("source");q.src=P;let Y=_e(P);Y&&(q.type=Y),m.append(q)}else m.src=u;n.videos.push(m)}else{m=d("img",t),m.alt=g,m.decoding="async",m.loading=i?"eager":"lazy",i&&(m.fetchPriority="high");let A=ct(e,u,I(e.width,1,8192));A&&(m.sizes=at(n.mode,n.size,s,c),m.srcset=A),m.src=u}let f=I(e.width,1,8192),k=I(e.height,1,8192);return f&&k&&(m.width=f,m.height=k),M(e.focal)&&(m.style.objectPosition=`${I(e.focal.x,0,100)??50}% ${I(e.focal.y,0,100)??50}%`),m}function Pe(e,t){let i=d("label","l");i.append(d("span","lt",e.label??(t==="email"?"Email":"Mobile number")));let s=d("input","i");if(s.type=t,s.name=t==="email"?"email":"phone",s.autocomplete=s.inputMode=t,s.required=!0,typeof e.placeholder=="string"&&(s.placeholder=e.placeholder),s.setAttribute("aria-describedby",O.id),s.addEventListener("focus",Ie,{once:!0}),t!=="tel")return i.append(s),i;s.id=`${O.id}-p`,i.htmlFor=s.id;let c=xe(d,"Country code","+",Object.entries(ge).map(([g,m])=>[g,`${g} +${m}`]),(e.country||/-(\w\w)$/.exec(J)?.[1]||"").toUpperCase());c.classList.add("cc"),c.name="hp_cc";let u=d("span","ph");return u.append(c,s),i.append(u),i}function ft(e){let t=r.questions.find(f=>f.key===e.question);if(!t||!ke(t)&&!Array.isArray(t.options))return null;let i=d("fieldset");i.dataset.question=t.key,i.append(d("legend","",t.label??""));let s=n.answers[t.key]??[],c=e.display==="cards"&&t.type==="one";if(ke(t)||c)return Te.then(f=>{if(!f)return i.append(d("p","sm",S.unavailable));if(c)return f.answerCards(i,t,e,d,s,k=>ce(k,"qi",!1,lt(n.size,t),"50vw"),L);f.answerFields(i,t,d,s[0],J),Le.set(i,()=>f.answerOf(i,t,void 0,J))}),i;let u=t.type==="many",g=H(["list","dropdown"],e.display,"buttons"),m=t.options.filter(f=>M(f)&&typeof f.value=="string");if(g==="dropdown"&&!u)return i.append(xe(d,t.label??t.key,"\u2014",m.map(f=>[f.value,f.label??f.value]),s[0])),i;g!=="buttons"&&(i.className="ls");for(let f of m){let k=d("label",g==="buttons"?"ch":"c"),A=d("input");A.type=u?"checkbox":"radio",A.name=`q_${t.key}`,A.value=f.value,A.checked=s.includes(f.value),k.append(A,d("span","",f.label??f.value)),i.append(k)}return i}function ne(){for(let e of n.codes){if(e.replaceChildren(),!n.claim){n.unclaimed&&e.append(d("p","",S.unclaimed));continue}if(!n.claim.code){let s=n.claim.held?S.claimed:n.claim.fallback===!0?S.code:n.claim.prize?.label;s&&e.append(d("p","",s));continue}n.claim.prize?.label&&e.append(d("p","",n.claim.prize.label));let t=d("output");t.textContent=n.claim.code;let i=d("button","btn cp");i.type="button",i.textContent="Copy code",i.addEventListener("click",()=>{navigator.clipboard?.writeText(n.claim.code).then(()=>{i.textContent=S.copied}).catch(()=>{})}),e.append(t,i)}}function mt(e){if(n.claim&&!n.claim.code)return null;let t=d("div","cd");return t.hidden=!0,Te.then(i=>i&&t.isConnected&&n.timers.push(i.countdown(t,e,h,d))),t}function de(e,t){return e.href=t,e.rel="noopener",e.addEventListener("click",i=>{if(h)return i.preventDefault();G("click"),We()}),e}function ht(e){let t=e.label??"Continue";if(e.action==="link"){let s=X(e.href);return s?de(d("a",`btn${nt[e.variant]??""}`,t),s):null}let i=d("button",`btn${nt[e.variant]??""}`,t);return i.type=e.action==="submit"?"submit":"button",i.type==="button"?i.addEventListener("click",()=>re(e)):i.dataset.submit="",i}let qe=(e,t,i)=>(e.classList.add(`x-${H(Pt,t.size,i)}`),qt.includes(t.align)&&e.classList.add(`a-${t.align}`),e);function Ne(e){let t=ce(e,"bi",n.step===a.steps[0]);if(!t)return null;t.style.objectFit=e.fit==="contain"?"contain":"cover";let i=I(e.radius,0,48);i!==null&&(t.style.borderRadius=`${i}px`);let s=I(e.max_height,40,800);if(s!==null&&(t.style.maxHeight=`${s}px`),!t.width&&e.fit!=="contain"&&(t.style.aspectRatio="16 / 9"),e.t==="video"||!X(e.href))return t;let c=de(d("a","bl"),X(e.href));return c.append(t),c}function bt(e){let t=I(e.threshold,.01,1e7);if(!t)return null;let i=d("div","pg"),s=d("p"),c=d("div","tr"),u=d("i");c.append(u),c.setAttribute("role","progressbar"),c.setAttribute("aria-valuemin","0"),c.setAttribute("aria-valuemax",String(t)),i.append(s,c);let g=f=>f.toFixed(2);try{let f=new Intl.NumberFormat(J||void 0,{style:"currency",currency:e.currency});g=k=>f.format(k)}catch{}let m=()=>{let f=Math.max(0,Number(o.basket?.())||0),k=t-f;s.textContent=k>0?String(e.text??"").replace("{amount}",g(k)):e.done??"",u.style.transform=`scaleX(${Math.min(1,f/t)})`,c.setAttribute("aria-valuenow",String(Math.min(f,t))),s.id||(s.id=Se("pg")),c.setAttribute("aria-labelledby",s.id)};return m(),n.timers.push(setInterval(m,2e3)),i}function gt(e){let t=d("div","pr");return o.loadProducts?.().then(i=>{t.isConnected&&n.timers.push(i.mountProducts(t,e,{el:d,lang:J,root:L,placement:r.slot,preview:h,client:!h&&p.analytics()&&x,engaged:G,seen:n.seen}))}).catch(()=>{}),t}let je={heading(e){let t=qe(d("h2","",e.text),e,"xl");return t.id=Se("h"),t.tabIndex=-1,y.hasAttribute("aria-labelledby")||(y.setAttribute("aria-labelledby",t.id),n.step===a.steps[0]&&Je.includes(n.mode)&&!h&&(t.autofocus=!0)),t},text:e=>qe(d("p","",e.text),e,"md"),email:e=>Pe(e,"email"),phone:e=>Pe(e,"tel"),consent(e){let t=C(n.step)?.text;if(typeof t!="string")return null;if(e.required!==!0)return d("p","sm",t);let i=d("label","c"),s=d("input");return s.type="checkbox",s.name="hp_consent",s.required=!0,s.setAttribute("aria-describedby",O.id),i.append(s,d("span","",t)),i},question:ft,wheel(){let e=d("div","wh");return o.loadWheel().then(t=>{n.closed||(n.wheel=t.mountWheel(e,r.prizes))}).catch(()=>{}),e},code(){let e=d("div","k");return e.setAttribute("aria-live","polite"),n.codes.push(e),e},button:ht,decline(e){let t=d("button","btn no",e.label??"No thanks");return t.type="button",t.addEventListener("click",()=>D("decline")),t},countdown:mt,progress:bt,products:gt,image:Ne,video:Ne,spacer(e){let t=d("div","sp");return t.style.height=`${et[e.size]??et.md}px`,t.setAttribute("aria-hidden","true"),t},divider:()=>d("hr")};function xt(e,t){F.replaceChildren();let i=e.media,s=!i||t&&e.template!=="image-only";if(n.size=st(v,e),_.className=`w t-${e.template} z-${n.size}${e.side==="right"?" right":""}${v.text_align==="center"?" ta-center":""}${s?" nm":""}`,_.style.setProperty("--sc",String(e.scrim)),E.className=`f pd-${e.padding}`,F.hidden=s,F.hidden)return;let c=ce(i,"",n.step===a.steps[0],e.template==="split"?.46:1);if(!c)return;if(c.width?_.style.setProperty("--ar",`${c.width} / ${c.height}`):_.style.removeProperty("--ar"),e.template!=="image-only"){c.tagName==="IMG"&&e.template==="overlay"&&(c.alt=""),F.append(c);return}let u=X(i.href),g=u?de(d("a","io"),u):d("button","io");u||(g.type="button",g.addEventListener("click",()=>re({action:"next"}))),g.append(c),F.append(g)}function yt(e){let t=e.blocks.find(c=>c?.t==="heading"),i=e.blocks.find(c=>c?.t==="button"&&c.action==="next"),s=d("button","tb");return s.textContent=t?d("b","",t.text).textContent:i?.label??"Open",s.type="button",s.addEventListener("click",()=>re(i??{action:"next"})),s}function R(e,t=new Set){let i=a.steps.find(z=>z.id===e);if(!i)return D("done");if(i.kind==="question"&&!h&&!p.analytics()&&!t.has(i.id))return R(ee(i,n.answers),t.add(i.id));let s=n.step!==null,c=s&&(L.activeElement||document.activeElement===document.body),u=s&&!h?{mode:n.mode,w:_.offsetWidth,h:_.offsetHeight,top:_.offsetTop}:null;n.step=i,n.touched=!1;for(let z of n.timers.splice(0))it(z);n.codes=[],n.videos=[],n.wheel=null;let g=$==="teaser"&&i===a.steps[0];if(n.mode=$==="teaser"&&!g?"popup":$,$==="teaser"&&w.tab?.(r.slot,g),B&&B.setAttribute("aria-label",g?S.closeOffer:"Close"),Oe(),y.removeAttribute("aria-labelledby"),u){let z=Ce();E.replaceWith(z),E=z}let m=rt(i);xt(m,g);let f=u?.mode==="popup"&&n.mode==="popup";if(pe(),u?.mode===n.mode&&u.h>0&&!f&&(_.style.setProperty("--lw",`${u.w}px`),_.style.setProperty("--lh",`${u.h}px`),_.classList.add("lk")),E.replaceChildren(),g&&m.template!=="image-only")E.append(yt(i));else for(let[z,P]of i.blocks.entries()){let q=M(P)&&Object.hasOwn(je,P.t)?je[P.t](P):null;q&&(h&&(q.dataset.hpBlock=String(z)),E.append(q))}let k=E.querySelector("[data-submit]"),A=E.querySelector("[name=hp_consent]")?.parentNode;k&&A&&k.before(A),E.hidden=E.childElementCount===0,N(null),ne(),y.hasAttribute("aria-labelledby")?y.removeAttribute("aria-label"):y.setAttribute("aria-label",m.media?.alt?.trim?.()||"Sign up"),f&&u.h>0&&vt(u),s&&Re(),le(),h||wt(i),c&&E.querySelector("h2")?.focus()}function pe(){_.classList.remove("lk","an"),_.style.removeProperty("--tp")}function vt(e){let t=_.offsetHeight;_.classList.add("an");let i=_.offsetTop,s=Math.max(0,e.top-i);if(s+t>y.clientHeight-2*i)return pe();_.style.setProperty("--tp",`${s}px`)}function wt(e){let t=e.next??{};for(let c of[t.default,...Object.values(M(t.answers)?t.answers:{}),...e.blocks.map(u=>u?.next),...jt])typeof c=="string"&&n.toWarm.add(c);if(n.warming)return;n.warming=!0;let i=()=>{if(n.warming=!1,!n.closed&&T.isConnected)for(let c of n.toWarm)ze(r,a,c,n.warmed);n.toWarm.clear()},s=()=>globalThis.requestIdleCallback?requestIdleCallback(i,{timeout:2e3}):setTimeout(i,200);document.readyState==="complete"?s():window.addEventListener("load",s,{once:!0})}function Re(){if(!j)return;let e=Je.includes(n.mode);if(!(y.open&&n.modal===e)){try{y.open&&y.close()}catch{}if(n.modal=e,y.setAttribute("aria-modal",String(e)),e&&typeof y.showModal=="function")y.showModal();else if(typeof y.show=="function"){let t=document.activeElement;y.show(),t&&t!==document.body?t.focus?.({preventScroll:!0}):T.blur()}else y.setAttribute("open","");!e||typeof y.showModal!="function"?y.setAttribute("role","dialog"):y.removeAttribute("role")}}function De(){for(let e of E.querySelectorAll("fieldset[data-question]")){let t=e.dataset.question,i=Le.get(e)?.()??{};if(i.error)return i;let s=[i.value,...[...e.querySelectorAll("input:checked,select:not([name])")].map(c=>c.value)].filter(Boolean);s.length?(n.answers[t]=s,n.answeredOn[t]=n.step.id):delete n.answers[t]}}function Ue(){let e=Object.entries(n.answers).map(([i,s])=>({question:i,values:s})).filter(i=>!n.sent.has(ue(i))),t=({question:i})=>n.answeredOn[i];if(n.signedUp){for(let i of new Set(e.map(t))){let s=e.filter(c=>t(c)===i);for(let c of s)n.sent.add(ue(c));b.answers({anonymousId:p.anonymousId(),sessionId:p.sessionId()??void 0,slot:l.slot,arm:l.arm??void 0,decision_id:l.decision_id??void 0,step:i,...n.signedUp,answers:s,context:Fe()})}return}if(p.analytics())for(let i of e)n.sent.add(ue(i)),x.preferencesStated({...i,source:"onsite",slot:l.slot,arm:l.arm??null,decision_id:l.decision_id??null,step:t(i)})}let ue=({question:e,values:t})=>`${e}=${t.join(",")}`,We=()=>{ae&&(De(),Ue())},Fe=()=>({page:{url:p.pageUrl()},locale:p.locale()??void 0,consent:p.consent()}),ie=e=>{!h&&(n.receipt||ae)&&Ue(),R(ee(n.step,n.answers,e))};async function kt(e){let t=n.step,i=E.querySelector("input[name=email],input[name=phone]");if(!i)return ie(e.next);let s=i.name==="email"?"email":"sms",c=E.querySelector("select[name=hp_cc]")?.value,u=s==="email"?Ke(i.value.trim())?i.value.trim():null:Xe(i.value,c);if(!u)return N(s==="email"?S.email:c?S.phone:S.intl,i);let g=E.querySelector("input[name=hp_consent]");if(g&&!g.checked)return N(S.consent,g);N(null),V(!0);let m=await Ie();n.pow=null;let f=Object.entries(n.answers).map(([U,he])=>({question:U,values:he})),k=s==="sms"?r.sms_consent_text:r.consent_text,A=await b.capture({anonymousId:p.anonymousId(),sessionId:p.sessionId()??void 0,slot:l.slot,arm:l.arm??void 0,decision_id:l.decision_id??void 0,step:t.id,channel:s,[s==="email"?"email":"phone"]:u,...s==="sms"&&n.signedUp,consent_text:k?{id:k.id,version:k.version}:void 0,...f.length?{answers:f}:{},...m?{altcha:m}:{},context:Fe()}),z=A.body?.status,P=(A.status===202||A.status===200)&&Mt.includes(z);if(n.closed&&!P)return;P||V(!1);let q=A.status===400?A.body?.field:null;if(q==="email"||q==="phone")return N(S[q],i);if(!P)return N(A.status===429?S.busy:S.failed,i);i.value="";for(let[U,he]of Object.entries(n.answers))n.sent.add(`${U}=${he.join(",")}`);n.receipt=typeof A.body.receipt=="string"?A.body.receipt:null,s==="email"&&(n.signedUp={email:u,email_receipt:n.receipt}),n.submitted=!0,w.submitted(r.slot),G("submit",t.id),n.owed=s==="email"&&r.prizes.length>0;let Y=n.owed?fe([]):null;Y||o.emit?.("submitted",{coupon:null});let $t=Y&&await Promise.race([Y,new Promise(U=>setTimeout(U,Dt))]);if(n.closed)return;if(V(!1),$t?.held)return R(oe("held"));let _t=z!=="ok"&&a.steps.some(U=>U.id===z);R(_t?z:ee(t,n.answers,e.next));let zt=n.step;Y?.then(U=>{U?.held&&!n.closed&&n.step===zt&&!n.touched&&R(oe("held"))})}function oe(e){if(a.steps.some(s=>s.id===e))return e;let t={t:"button",label:S.shop,action:"close"},i=e==="unclaimed"?[{t:"heading",text:S.thanks},{t:"text",text:S.unclaimed},t]:e==="fallback"||n.claim?.code?[{t:"heading",text:e==="fallback"?S.thanks:S.yours},{t:"code"}]:[{t:"heading",text:S.held},{t:"text",text:r.code_relayed===!0?S.resent:S.inbox},t];return a.steps.push({id:e,blocks:i}),e}function Ye(e){n.owed&&(n.owed=!1,o.emit?.("submitted",{coupon:e?{code:e.code??null,prize:e.prize?.key}:null}))}function fe(e=Rt){let t=n.receipt;return n.claiming??(n.claiming=(async()=>{n.unclaimed=!1;let i;for(let g of[0,...e])if(g&&await new Promise(m=>setTimeout(m,g)),i=await b.claim({slot:l.slot,decision_id:l.decision_id??void 0,receipt:t}),i.status!==503)break;let s=i.body,c=s?.fallback===!0&&!s.code;if(i.status!==200||!(M(s?.prize)||c))return n.claiming=null,!e.length&&i.status===503?fe():(Ye(null),n.unclaimed=!0,n.closed||ne(),null);let u=s.held&&!s.code?w.code?.():null;return u&&(s={...s,code:u}),n.claim=s,typeof s.code=="string"&&w.code?.(s.code),Ye(s),n.closed||ne(),s})()),n.claiming}async function At(e){if(!n.receipt)return N(S.spin);V(!0);let t=await fe();if(n.closed)return;if(!t)return V(!1),n.misses+=1,n.misses<2?N(S.retry):R(oe("unclaimed"));let i=t.fallback===!0&&!t.code,s=t.held?-1:r.prizes.findIndex(g=>g.key===t.prize?.key&&g.label===t.prize?.label);if(n.wheel&&s>=0&&!i){if(await n.wheel.spinTo(s),n.closed)return;O.className="e won",O.textContent=`${S.won} ${t.prize.label}`,await new Promise(g=>setTimeout(g,Ut))}if(n.closed)return;V(!1);let c=i?"fallback":s<0?"held":null,u=c?oe(c):ee(n.step,n.answers,e.next);u?R(u):ne()}function re(e){if(e.action==="close")return D("close");let t=De();return h?ie(e.next):t?N(t.error,t.input):(ae&&n.step.blocks.some(i=>n.answers[i?.question])&&G("click"),e.action==="apply"?(o.emit?.("apply",{coupon:n.claim?.code?{code:n.claim.code}:null}),G("click"),ie(e.next)):e.action==="submit"?kt(e):e.action==="spin"?At(e):ie(e.next))}function St(e){if(e.preventDefault(),E.getAttribute("aria-busy")==="true")return;let t=n.step.blocks.find(i=>i?.t==="button"&&i.action==="submit");re(t??{action:"next"})}function me(e=!1){n.closed=!0;for(let i of n.timers.splice(0))it(i);document.removeEventListener("visibilitychange",le),Q?.removeEventListener?.("change",Me);let t=()=>{try{y.open&&y.close()}catch{}T.remove()};if(e||!j||Ae())return t();y.classList.add("out"),setTimeout(t,Nt)}function D(e){n.closed||h||(We(),!n.submitted&&e!=="done"&&G("dismiss"),w.closed(r.slot),w.tab?.(r.slot,!1),me(),o.onClose?.(e))}for(let e of["pointerdown","keydown","input"])y.addEventListener(e,()=>{n.touched=!0});y.addEventListener("cancel",e=>{e.preventDefault(),D("esc")}),y.addEventListener("keydown",e=>{e.key==="Escape"&&!n.modal&&$!=="inline"&&D("esc"),e.key==="Tab"&&n.modal&&Et(e)});function Et(e){let t=[...L.querySelectorAll("input[type=radio]:checked")],i=new Set,s=[...L.querySelectorAll("a[href],button,input,select,textarea")].filter(f=>{if(f.disabled||!f.getClientRects().length)return!1;if(f.type!=="radio")return!0;let k=t.find(A=>A.name===f.name);return(k?f!==k:i.has(f.name))?!1:(i.add(f.name),!0)});if(!s.length)return;let c=e.shiftKey,u=L.activeElement;u?.type==="radio"&&(u=s.find(f=>f.type==="radio"&&f.name===u.name)??u);let g=s.indexOf(u),m=null;if(g<0){let f=k=>u&&u.compareDocumentPosition(k)&4;m=c?s.findLast(k=>!f(k))??s.at(-1):s.find(f)??s[0]}else(c?g===0:g===s.length-1)&&(m=s.at(c?-1:0));m&&(e.preventDefault(),m.focus())}se.addEventListener("pointerdown",e=>{if(!n.mobile||n.mode!=="sheet")return;let t=e.clientY,i=0,s=u=>{i=Math.max(0,u.clientY-t),_.style.transform=`translateY(${i}px)`},c=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",c),_.style.transform="",i>80&&D("close")};document.addEventListener("pointermove",s),document.addEventListener("pointerup",c)});try{R(h?.step&&a.steps.some(e=>e.id===h.step)?h.step:a.steps[0].id),(o.container??document.body).append(T),Re()}catch(e){throw me(!0),e}return{close:D,root:L,host:T,show:R,step:()=>n.step?.id??null,modal:()=>!n.closed&&n.modal,destroy:()=>!n.closed&&me()}}window[Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.render")]={mountForm:ut,warm:ze};})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thg-agentic/hyper-personalisation-web",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.0",
|
|
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",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"esbuild": "^0.28.2",
|
|
93
93
|
"jsdom": "^30.1.1",
|
|
94
94
|
"typescript": "^7.0.2",
|
|
95
|
-
"@thg-agentic/hyper-personalisation-spec": "1.
|
|
95
|
+
"@thg-agentic/hyper-personalisation-spec": "1.22.0"
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
98
|
"test": "node --test tests/*.test.mjs",
|
package/src/onsite/render.js
CHANGED
|
@@ -422,7 +422,11 @@ export function mountForm(o) {
|
|
|
422
422
|
modal: false,
|
|
423
423
|
mobile: preview?.device === 'mobile',
|
|
424
424
|
answers: {},
|
|
425
|
+
// The step each answer was given on, by question.
|
|
426
|
+
answeredOn: {},
|
|
425
427
|
sent: new Set(),
|
|
428
|
+
// Whether this view's click is counted: a view counts one, whatever was clicked.
|
|
429
|
+
clicked: false,
|
|
426
430
|
// The products blocks' rails reported seen, by id: a step shown again does not report it twice.
|
|
427
431
|
seen: new Set(),
|
|
428
432
|
receipt: null,
|
|
@@ -481,8 +485,17 @@ export function mountForm(o) {
|
|
|
481
485
|
small.addEventListener?.('change', resize);
|
|
482
486
|
}
|
|
483
487
|
|
|
488
|
+
/** A form that collects nothing: a message, products, or a quiz. */
|
|
489
|
+
const asksNothing = !form.channels?.length;
|
|
490
|
+
|
|
484
491
|
const engaged = (engagement, step, item = {}) => {
|
|
485
492
|
if (preview || !decision.decision_id || !access.analytics()) return;
|
|
493
|
+
// A view counts one click; a products card's always says which product was clicked.
|
|
494
|
+
if (engagement === 'click') {
|
|
495
|
+
const counted = state.clicked;
|
|
496
|
+
state.clicked = true;
|
|
497
|
+
if (counted && !item.products) return;
|
|
498
|
+
}
|
|
486
499
|
client.slotEngaged({
|
|
487
500
|
decision_id: decision.decision_id,
|
|
488
501
|
slot: decision.slot,
|
|
@@ -768,8 +781,9 @@ export function mountForm(o) {
|
|
|
768
781
|
node.href = href;
|
|
769
782
|
node.rel = 'noopener';
|
|
770
783
|
node.addEventListener('click', (e) => {
|
|
771
|
-
if (preview) e.preventDefault();
|
|
772
|
-
|
|
784
|
+
if (preview) return e.preventDefault();
|
|
785
|
+
engaged('click');
|
|
786
|
+
leaving();
|
|
773
787
|
});
|
|
774
788
|
return node;
|
|
775
789
|
}
|
|
@@ -1184,54 +1198,76 @@ export function mountForm(o) {
|
|
|
1184
1198
|
(i) => i.value,
|
|
1185
1199
|
),
|
|
1186
1200
|
].filter(Boolean);
|
|
1187
|
-
if (values.length)
|
|
1188
|
-
|
|
1201
|
+
if (values.length) {
|
|
1202
|
+
state.answers[key] = values;
|
|
1203
|
+
state.answeredOn[key] = state.step.id;
|
|
1204
|
+
} else delete state.answers[key];
|
|
1189
1205
|
}
|
|
1190
1206
|
}
|
|
1191
1207
|
|
|
1192
|
-
/**
|
|
1208
|
+
/**
|
|
1209
|
+
* An answer the gateway did not carry is the page's to report: after the sign-up, or, on a form
|
|
1210
|
+
* that collects nothing (a quiz), as each step's answers are given.
|
|
1211
|
+
*/
|
|
1193
1212
|
function stated() {
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
answers.push({ question, values });
|
|
1200
|
-
}
|
|
1201
|
-
const step = state.step.id;
|
|
1213
|
+
const fresh = Object.entries(state.answers)
|
|
1214
|
+
.map(([question, values]) => ({ question, values }))
|
|
1215
|
+
.filter((a) => !state.sent.has(marker(a)));
|
|
1216
|
+
// Each answer goes with the step it was given on (collect records it), maybe an earlier one.
|
|
1217
|
+
const stepOf = ({ question }) => state.answeredOn[question];
|
|
1202
1218
|
// After the email step, the gateway relays them to that address's profile and records them.
|
|
1203
|
-
if (state.signedUp
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
step,
|
|
1211
|
-
...state.signedUp,
|
|
1212
|
-
answers,
|
|
1213
|
-
context: pageContext(),
|
|
1214
|
-
});
|
|
1215
|
-
if (access.analytics())
|
|
1216
|
-
for (const answer of answers)
|
|
1217
|
-
client.preferencesStated({
|
|
1218
|
-
...answer,
|
|
1219
|
-
source: 'onsite',
|
|
1219
|
+
if (state.signedUp) {
|
|
1220
|
+
for (const step of new Set(fresh.map(stepOf))) {
|
|
1221
|
+
const answers = fresh.filter((a) => stepOf(a) === step);
|
|
1222
|
+
for (const answer of answers) state.sent.add(marker(answer));
|
|
1223
|
+
api.answers({
|
|
1224
|
+
anonymousId: access.anonymousId(),
|
|
1225
|
+
sessionId: access.sessionId() ?? undefined,
|
|
1220
1226
|
slot: decision.slot,
|
|
1221
|
-
arm: decision.arm ??
|
|
1222
|
-
decision_id: decision.decision_id ??
|
|
1227
|
+
arm: decision.arm ?? undefined,
|
|
1228
|
+
decision_id: decision.decision_id ?? undefined,
|
|
1223
1229
|
step,
|
|
1230
|
+
...state.signedUp,
|
|
1231
|
+
answers,
|
|
1232
|
+
context: pageContext(),
|
|
1224
1233
|
});
|
|
1234
|
+
}
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
// Kept back without analytics consent, so a later grant still reports it.
|
|
1238
|
+
if (!access.analytics()) return;
|
|
1239
|
+
for (const answer of fresh) {
|
|
1240
|
+
state.sent.add(marker(answer));
|
|
1241
|
+
client.preferencesStated({
|
|
1242
|
+
...answer,
|
|
1243
|
+
source: 'onsite',
|
|
1244
|
+
slot: decision.slot,
|
|
1245
|
+
arm: decision.arm ?? null,
|
|
1246
|
+
decision_id: decision.decision_id ?? null,
|
|
1247
|
+
step: stepOf(answer),
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1225
1250
|
}
|
|
1226
1251
|
|
|
1252
|
+
const marker = ({ question, values }) => `${question}=${values.join(',')}`;
|
|
1253
|
+
|
|
1254
|
+
/** A quiz left by a link or closed keeps the answers given so far, as on moving on. */
|
|
1255
|
+
const leaving = () => {
|
|
1256
|
+
if (!asksNothing) return;
|
|
1257
|
+
collect();
|
|
1258
|
+
stated();
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1227
1261
|
const pageContext = () => ({
|
|
1228
1262
|
page: { url: access.pageUrl() },
|
|
1229
1263
|
locale: access.locale() ?? undefined,
|
|
1230
1264
|
consent: access.consent(),
|
|
1231
1265
|
});
|
|
1232
1266
|
|
|
1267
|
+
// Answers are reported as the form moves on: after a receipt, or on a form that collects nothing.
|
|
1268
|
+
// A sign-up form's answers before the sign-up travel with it.
|
|
1233
1269
|
const advance = (explicit) => {
|
|
1234
|
-
if (state.receipt
|
|
1270
|
+
if (!preview && (state.receipt || asksNothing)) stated();
|
|
1235
1271
|
show(nextStep(state.step, state.answers, explicit));
|
|
1236
1272
|
};
|
|
1237
1273
|
|
|
@@ -1475,14 +1511,19 @@ export function mountForm(o) {
|
|
|
1475
1511
|
// A preview only moves between steps: nothing is checked, sent or claimed.
|
|
1476
1512
|
if (preview) return advance(block.next);
|
|
1477
1513
|
if (wrong) return say(wrong.error, wrong.input);
|
|
1514
|
+
// A quiz learns from clicks: moving on with an answer is a click.
|
|
1515
|
+
if (
|
|
1516
|
+
asksNothing &&
|
|
1517
|
+
state.step.blocks.some((b) => state.answers[b?.question])
|
|
1518
|
+
)
|
|
1519
|
+
engaged('click');
|
|
1478
1520
|
if (block.action === 'apply') {
|
|
1479
1521
|
o.emit?.('apply', {
|
|
1480
1522
|
coupon: state.claim?.code ? { code: state.claim.code } : null,
|
|
1481
1523
|
});
|
|
1482
1524
|
engaged('click');
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
: close('done');
|
|
1525
|
+
// With no step after it, the form closes, done.
|
|
1526
|
+
return advance(block.next);
|
|
1486
1527
|
}
|
|
1487
1528
|
if (block.action === 'submit') return submit(block);
|
|
1488
1529
|
if (block.action === 'spin') return spin(block);
|
|
@@ -1520,6 +1561,7 @@ export function mountForm(o) {
|
|
|
1520
1561
|
function close(reason) {
|
|
1521
1562
|
// A preview stays on screen: closing is the shopper's, not the trader's.
|
|
1522
1563
|
if (state.closed || preview) return;
|
|
1564
|
+
leaving();
|
|
1523
1565
|
if (!state.submitted && reason !== 'done') engaged('dismiss');
|
|
1524
1566
|
counters.closed(form.slot);
|
|
1525
1567
|
counters.tab?.(form.slot, false);
|
package/src/spec-version.js
CHANGED
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.
|
|
1
|
+
export const VERSION = '3.30.0';
|
|
2
2
|
export const LIB = '@thg-agentic/hyper-personalisation-web';
|
package/types/events.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated from spec/registry.json by scripts/generate-sdk-models.mjs.
|
|
2
2
|
// DO NOT EDIT. Change the schema and regenerate — the schema is the contract,
|
|
3
3
|
// and a hand-edit here is an SDK that disagrees with the ingest.
|
|
4
|
-
// Spec version: 1.
|
|
4
|
+
// Spec version: 1.22
|
|
5
5
|
|
|
6
6
|
/** context.source.environment. Environment the producer runs in. */
|
|
7
7
|
export type CdpSourceEnvironment = 'production' | 'staging' | 'development';
|
|
@@ -104,6 +104,7 @@ export interface RecommendationServed {
|
|
|
104
104
|
strategy?: string | null;
|
|
105
105
|
algorithm_version?: string | null;
|
|
106
106
|
candidate_algorithm_version?: string | null;
|
|
107
|
+
shadow_algorithm_version?: string | null;
|
|
107
108
|
ranked_by?: 'ranker' | 'blend' | 'session' | 'manual' | 'other' | null;
|
|
108
109
|
fusion?: string | null;
|
|
109
110
|
fast_weight?: number | null;
|
|
@@ -713,7 +714,7 @@ export interface SignUpRelayed {
|
|
|
713
714
|
}
|
|
714
715
|
|
|
715
716
|
/** The spec version these models implement. SDKs stamp it on context.spec.version. */
|
|
716
|
-
export const SPEC_VERSION = '1.
|
|
717
|
+
export const SPEC_VERSION = '1.22';
|
|
717
718
|
|
|
718
719
|
/** Every event name the registry accepts. Anything else is rejected at the ingest. */
|
|
719
720
|
export type CdpEventName =
|