@thg-agentic/hyper-personalisation-web 3.24.0 → 3.25.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 +46 -16
- package/dist/hp.min.js +2 -2
- package/dist/onsite-render.min.js +3 -3
- package/dist/onsite-wheel.min.js +1 -1
- package/package.json +1 -1
- package/src/bootstrap.js +59 -30
- package/src/consent-gate.js +8 -5
- package/src/context.js +2 -1
- package/src/device-storage.js +4 -4
- package/src/index.js +68 -7
- package/src/onsite/render.js +49 -18
- package/src/onsite/styles.js +1 -1
- package/src/onsite/wheel.js +61 -13
- package/src/settings.js +30 -2
- package/src/social-proof.js +5 -1
- package/src/storage-scope.js +2 -2
- package/src/transport.js +22 -2
- package/src/version.js +1 -1
- package/types/bootstrap.d.ts +3 -2
- package/types/hp.d.ts +3 -2
- package/types/index.d.ts +4 -3
package/README.md
CHANGED
|
@@ -78,14 +78,23 @@ collects, is a settings change and never a deploy:
|
|
|
78
78
|
|
|
79
79
|
What `bootstrap` does:
|
|
80
80
|
|
|
81
|
-
- **Resolves to the client**, or `null` when the key is not enabled
|
|
82
|
-
on a first visit, or the options are invalid. Invalid options log one console warning listing
|
|
81
|
+
- **Resolves to the client**, or `null` when the key is not enabled or the options are invalid. Invalid options log one console warning listing
|
|
83
82
|
every problem. It never rejects, and a second call on the same page returns the first client.
|
|
84
83
|
- **Settings.** The last good answer is cached in `localStorage`, only once analytics is granted,
|
|
85
84
|
and forgotten on a refusal. A page with a cache starts from it at once and asks the API again for
|
|
86
85
|
the next page; a first visit waits for the API (which answers `Cache-Control: max-age=10`
|
|
87
|
-
and an `ETag`, so the browser revalidates for a `304`)
|
|
88
|
-
off too.
|
|
86
|
+
and an `ETag`, so the browser revalidates for a `304`), for at most 3 seconds (3.24.2). A key the
|
|
87
|
+
API switches off clears the cache, so the next page is off too. Onsite forms are the exception: they start from the fresh answer when it comes within a
|
|
88
|
+
second, else from the cache, so a form set live, changed or stopped shows on the next page.
|
|
89
|
+
- **An API it cannot reach never turns collection off** (3.25). A first visit whose settings fail
|
|
90
|
+
(a 5xx, 408 or 429, a timeout, an answer that is not settings; a 4xx is the key refused, and the
|
|
91
|
+
page is off) starts on built-in defaults: collection
|
|
92
|
+
only, with no property (the ingest stamps the key's, so a key scoped to several properties needs
|
|
93
|
+
the page's `propertyId`), campaign parameters only in URLs, the device id from
|
|
94
|
+
`identityCookies.anonymousId` else the SDK's own cookie, no sampling, no tracking plan and no
|
|
95
|
+
onsite forms. Consent is still the CMP's, strictly. They are never cached, so the next page asks
|
|
96
|
+
the API again, and what the ingest cannot take waits in the retry buffer (see
|
|
97
|
+
[Choosing a delivery path](#choosing-a-delivery-path)).
|
|
89
98
|
- **Consent**, identity, one page view, the dataLayer bridge and a once-per-session `identify`, as
|
|
90
99
|
configured. A page restored from the back/forward cache runs no script again, so `bootstrap`
|
|
91
100
|
reads consent again, then sends its `back_forward` page view on `pageshow` and reports its lists
|
|
@@ -96,8 +105,7 @@ What `bootstrap` does:
|
|
|
96
105
|
messageId and time it was made at, and are sent in order once it has. The page view is stamped
|
|
97
106
|
when the page was navigated to, so none of them precedes it (3.18). A page that navigates
|
|
98
107
|
first (a sign-in that redirects at once) carries them in sessionStorage, and the next page's
|
|
99
|
-
`bootstrap` sends them once, before its own page view (since 3.9).
|
|
100
|
-
request never answered: the API down, or the request cancelled by the navigation (3.9.1). The carry is a device write,
|
|
108
|
+
`bootstrap` sends them once, before its own page view (since 3.9). The carry is a device write,
|
|
101
109
|
so it is made only once this device has granted analytics, or unanswered with `holdAcrossPages`;
|
|
102
110
|
the next page's consent decides whether they are sent, and a refusal drops them. Once started,
|
|
103
111
|
the SDK hands its queue to `sendBeacon` at `pagehide` itself.
|
|
@@ -634,6 +642,21 @@ The sign-up itself is sent whatever the analytics answer: it is the visitor's ma
|
|
|
634
642
|
close and submitted, plus one subscribed flag and the last claimed code (localStorage), and a
|
|
635
643
|
kept teaser tab (sessionStorage).
|
|
636
644
|
|
|
645
|
+
**Prizes that cannot be claimed.** A form with prizes claims as soon as the sign-up is taken. If
|
|
646
|
+
the claim fails (the offers API unreachable, an error, or no answer in 8 seconds), the sign-up
|
|
647
|
+
still counts: a spin offers one retry ("You're signed up, but we couldn't load your prize. Please
|
|
648
|
+
try again."), then thanks the shopper and says the prize could not be loaded, as does a `code`
|
|
649
|
+
block. The shopper stays subscribed and the form is done with them (`already submitted`), so they
|
|
650
|
+
are never asked for their address twice. No code was drawn, so the destinations get the sign-up
|
|
651
|
+
without one (ADR 0064, decision 5).
|
|
652
|
+
|
|
653
|
+
**Testing a live form again.** A browser that has seen a form keeps to its caps. To see it as a
|
|
654
|
+
new visitor, open a private window, or delete `thg_hp_onsite:<property>` from both localStorage
|
|
655
|
+
(shows ever, last close, submitted, subscribed, the last code) and sessionStorage (shows this
|
|
656
|
+
session, the gap between popups, a teaser's tab, the A/B version), then reload;
|
|
657
|
+
`thg_hp_settings:<writeKey>` in localStorage is the cached settings. `?hp_debug=onsite` logs why
|
|
658
|
+
each form did or did not show, and a preview link (`?hp_preview=`) counts nothing.
|
|
659
|
+
|
|
637
660
|
**Budgets**, enforced by `tests/onsite-chunks.test.mjs`, each about 5% over its chunk:
|
|
638
661
|
`onsite.min.js` under 5.875 KiB gzipped (about 5.6 KiB), `onsite-render.min.js` under 14 KiB (about
|
|
639
662
|
13.7 KiB), so a page that shows a form loads about 19 KiB of onsite code and one whose forms never
|
|
@@ -660,12 +683,13 @@ With a `consent` adapter the SDK is strict:
|
|
|
660
683
|
is never a grant, however long it takes.
|
|
661
684
|
- **Page closed before an answer:** nothing is sent. Switching to another tab is not closing the
|
|
662
685
|
page: held events wait for the visitor to come back.
|
|
663
|
-
- **A navigation before an answer** (a
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
686
|
+
- **A navigation before an answer** (a visitor who answers the banner on their second page, a
|
|
687
|
+
sign-in that redirects) loses what the page held, landing page included, unless you opt in with
|
|
688
|
+
`holdAcrossPages: true` (since 3.5). Then held events are also kept in sessionStorage under
|
|
689
|
+
`thg_hp_held:<writeKey>` and sent when a later page's answer is a grant, stamped with it. A
|
|
690
|
+
refusal deletes them, and so does a tab left unanswered for 30 minutes. This writes event data
|
|
691
|
+
to the device before the visitor answers, which strict mode otherwise never does, so turn it on
|
|
692
|
+
only where your consent policy allows that.
|
|
669
693
|
- **The retry buffer:** a batch is kept in localStorage only while analytics is granted, and one
|
|
670
694
|
kept on an earlier page is replayed only once this page's answer is a grant. A refusal clears it.
|
|
671
695
|
- **Consent changes:** each change is recorded as a `Consent Updated` event. A decision that
|
|
@@ -907,8 +931,14 @@ delivery differs.
|
|
|
907
931
|
- Dependency-free.
|
|
908
932
|
- Batched, with a retry buffer in localStorage: each batch is stored before it is sent and
|
|
909
933
|
removed when the ingest accepts it (or rejects it for good), so an outage costs a delay, not the
|
|
910
|
-
events.
|
|
911
|
-
|
|
934
|
+
events. A batch is retried with exponential backoff on its page, then on every later page of the
|
|
935
|
+
site for 24 hours, with each event's `messageId`, so one that had landed is removed by the
|
|
936
|
+
warehouse's deduplication on `(org, source, messageId)`. The buffer is per write key (3.25; per
|
|
937
|
+
property before; what 3.24 kept per property is moved over on the first page) and capped at 20
|
|
938
|
+
batches and 1 MB, oldest dropped first.
|
|
939
|
+
- On page unload, sends by `sendBeacon` in chunks that fit. A beacon's answer is never seen, so
|
|
940
|
+
while the ingest is failing (a send failed on this page, or the settings could not be fetched)
|
|
941
|
+
each beaconed chunk is also kept in the retry buffer for the next page (3.25).
|
|
912
942
|
- Never throws into the page. An event JSON cannot serialise (a BigInt, a circular object, a
|
|
913
943
|
throwing `toJSON`) is dropped on its own, logged under `debug`, and the queue behind it carries
|
|
914
944
|
on. A `Date` in properties is sent as its ISO string.
|
|
@@ -1002,13 +1032,13 @@ SDK per page.
|
|
|
1002
1032
|
| Kind | Default name | Where | Scope |
|
|
1003
1033
|
|---|---|---|---|
|
|
1004
1034
|
| `consent` | `thg_hp_consent` | cookie | the consent decision, for your servers and `forwarded` pages |
|
|
1005
|
-
| `retry` | `thg_hp_retry:<
|
|
1035
|
+
| `retry` | `thg_hp_retry:<writeKey>` | localStorage | batches waiting for the ingest; only under a grant |
|
|
1006
1036
|
| `sessionSignals` | `thg_hp_session_signals:<property>:<session>` | localStorage (sessionStorage until a session is bound) | in-session audience counters |
|
|
1007
1037
|
| `identified` | `thg_hp_identified:<property>` | sessionStorage | the identify already sent this session |
|
|
1008
1038
|
| `previousPage` | `thg_hp_prev_page:<property>` | sessionStorage | the previous page view's messageId; only under a grant |
|
|
1009
1039
|
| `decisions` | `thg_hp_decisions:<property>` | sessionStorage | the decisions in force, latest per slot; only under a grant |
|
|
1010
1040
|
| `settings` | `thg_hp_settings:<writeKey>` | localStorage | the last good settings; only under a grant |
|
|
1011
|
-
| `held` | `thg_hp_held:<
|
|
1041
|
+
| `held` | `thg_hp_held:<writeKey>` | sessionStorage | events held for an unanswered CMP; only with `holdAcrossPages` |
|
|
1012
1042
|
| `carried` | `thg_hp_carried:<writeKey>` | sessionStorage | `hp` calls made before the SDK started, on a page that navigated first (3.9); only under a grant, or with `holdAcrossPages` |
|
|
1013
1043
|
| `recommendationContext` | `thg_hp_recommendation_context` | localStorage | The visit's wire form, for `hp.recommendationContext()` on the next page before the SDK starts there; 30 minutes from the last event, only while personalisation is granted (3.11) |
|
|
1014
1044
|
| `anonymousId` | `thg_hp_anonymous_id` | cookie, one per browser | Hyper-Personalisation's device id, for a source set to `hp_cookie`; only under a grant (see [Device ids](#device-ids)) |
|
package/dist/hp.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(()=>{var on=e=>{throw TypeError(e)};var Kr=(e,t,n)=>t.has(e)||on("Cannot "+n);var sn=(e,t,n)=>t.has(e)?on("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var O=(e,t,n)=>(Kr(e,t,"access private method"),n);var Ae=[];for(let e=2;Ae.length<64;e++)Ae.every(t=>e%t!==0)&&Ae.push(e);var an=e=>(e-Math.floor(e))*2**32>>>0,Gr=Ae.slice(0,8).map(e=>an(Math.sqrt(e))),zr=Ae.map(e=>an(Math.cbrt(e))),Y=(e,t)=>e>>>t|e<<32-t;function cn(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(Gr),o=new Uint32Array(64);for(let s=0;s<n.length;s+=16){for(let y=0;y<64;y++){if(y<16){o[y]=n[s+y];continue}let _=o[y-15],A=o[y-2],v=Y(_,7)^Y(_,18)^_>>>3,m=Y(A,17)^Y(A,19)^A>>>10;o[y]=o[y-16]+v+o[y-7]+m}let[i,c,u,d,f,p,h,b]=r;for(let y=0;y<64;y++){let _=Y(f,6)^Y(f,11)^Y(f,25),A=b+_+(f&p^~f&h)+zr[y]+o[y]|0,m=(Y(i,2)^Y(i,13)^Y(i,22))+(i&c^i&u^c&u)|0;[b,h,p,f,d,u,c,i]=[h,p,f,d+A|0,u,c,i,A+m|0]}[i,c,u,d,f,p,h,b].forEach((y,_)=>{r[_]+=y})}return Array.from(r,s=>s.toString(16).padStart(8,"0")).join("")}var ut=(e,t)=>e<<t|e>>>32-t;function un(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]:ut(r[p-3]^r[p-8]^r[p-14]^r[p-16],1);let[i,c,u,d,f]=n;for(let p=0;p<80;p++){let h,b;p<20?(h=c&u|~c&d,b=1518500249):p<40?(h=c^u^d,b=1859775393):p<60?(h=c&u|c&d|u&d,b=2400959708):(h=c^u^d,b=3395469782);let y=ut(i,5)+h+f+b+r[p]|0;[f,d,u,c,i]=[d,u,ut(c,30),i,y]}[i,c,u,d,f].forEach((p,h)=>{n[h]+=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 Wr="e28e8ada-5b76-4209-bba9-79b823a0af75",Jr=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");function ln(e,t){let n=Uint8Array.from(e.replace(/-/g,"").match(/../g),c=>Number.parseInt(c,16)),r=new TextEncoder().encode(t),o=new Uint8Array(16+r.length);o.set(n),o.set(r,16);let s=un(o).slice(0,16);s[6]=s[6]&15|80,s[8]=s[8]&63|128;let i=Jr(s);return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}var se=(e,t)=>typeof e=="string"&&e!==""&&e.length<=t?e:null;function $e(e,t){return se(e,64)??se(t,256)}function dn({sessionId:e,slot:t,arm:n}={}){let r=se(e,256);return!r||!se(t,256)||!se(n,256)?null:ln(Wr,`${r}:${t}:${n}`)}var Yr="4b1f2c7e-9a3d-4e58-b6c1-2d7f0a9e8c53";function fn({sessionId:e,surface:t}={}){let n=se(e,256);return!n||!se(t,64)?null:ln(Yr,`${n}:${t}`)}var Xr=Array.from({length:11},(e,t)=>t/10);function Zr(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,c=o?Math.min(i,o.width*o.height):i;return c>0&&s/c>=t}function Q(e){let{selector:t,onViewable:n,visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=e,i=new Map,c=new WeakSet,u=new Set,d=m=>{i.has(m)||i.set(m,setTimeout(()=>{i.delete(m),n(m)&&(p?.unobserve(m),u.delete(m))},o))},f=m=>{clearTimeout(i.get(m)),i.delete(m)},p=typeof IntersectionObserver>"u"?null:new IntersectionObserver(m=>{for(let E of m){let w=E.target;if(!Zr(E,r)){u.delete(w),f(w);continue}u.add(w),h()&&d(w)}},{threshold:Xr}),h=()=>typeof document>"u"||document.visibilityState!=="hidden",b=()=>{if(h())for(let m of u)d(m);else for(let m of u)f(m)};document.addEventListener("visibilitychange",b);let y=()=>{for(let m of s.querySelectorAll(t))c.has(m)||(c.add(m),p?.observe(m))},_=typeof MutationObserver>"u"?null:new MutationObserver(()=>y()),A=()=>{y(),_?.observe(s===document?document.body:s,{childList:!0,subtree:!0})},v=s===document&&!document.body;return v?document.addEventListener("DOMContentLoaded",A,{once:!0}):A(),()=>{v&&document.removeEventListener("DOMContentLoaded",A),document.removeEventListener("visibilitychange",b),p?.disconnect(),_?.disconnect();for(let m of i.values())clearTimeout(m);i.clear(),u.clear()}}function lt(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 Q({selector:n,root:s,visibleRatio:r,dwellMs:o,onViewable(i){let c=i.dataset?.hpExposure?.trim();return c&&e.surfaceViewed({surface:c}),!0}})}var pn=e=>{try{return new URL(e,document.baseURI).toString()}catch{return e}};function dt(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,c=new Set,u=y=>y.closest?.(n)??null,d=y=>{let _=y.dataset.hpList?.trim();return _?{list_id:_,category:y.dataset.hpListCategory?.trim()||null}:null},f=y=>Array.from(y.querySelectorAll(r)).filter(_=>u(_)===y),p=(y,_)=>{try{let A=JSON.parse(y.dataset.hpProduct??"");return!A||typeof A!="object"||!A.product_id?null:{...A,position:A.position??_+1,...A.url?{url:pn(A.url)}:{},...A.image_url?{image_url:pn(A.image_url)}:{}}}catch{return null}},h=Q({selector:`${n} ${r}`,root:i,visibleRatio:o,dwellMs:s,onViewable(y){let _=u(y);if(!_||_.dataset.hpListView==="manual")return!0;let A=d(_);if(!A||c.has(A.list_id))return!0;let v=new Set,m=f(_).map(p).filter(E=>!E||v.has(E.product_id)?!1:(v.add(E.product_id),!0));return m.length===0||(c.add(A.list_id),e.productListViewed({...A,products:m})),!0}}),b=y=>{let A=y.target?.closest?.("a[href]")?.closest(r);if(!A)return;let v=u(A),m=p(A,v?f(v).indexOf(A):0);m&&e.productClicked({list_id:v?d(v)?.list_id??null:null,products:[m]})};return document.addEventListener("click",b,!0),()=>{document.removeEventListener("click",b,!0),h()}}function R(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 Ue(e,...t){let n=R(e,...t);if(n===null)return null;let r=Number(n);return Number.isFinite(r)?Math.trunc(r):null}function Qr(e,t){let n=R(e,"hpPromotion");return n?{promotion_id:n,name:R(e,"hpPromotionName"),creative:R(e,"hpPromotionCreative"),position:R(e,"hpPromotionSlot")??String(t+1)}:null}function ft(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-promotion]",resolve:r=Qr,visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,c=new Set,u=p=>{let h=Array.from(i.querySelectorAll(n)),b=h.indexOf(p);try{return r(p,b<0?h.length:b)}catch{return null}},d=Q({selector:n,root:i,visibleRatio:o,dwellMs:s,onViewable(p){let h=u(p);return!h||c.has(h.promotion_id)?!1:(c.add(h.promotion_id),e.promotionViewed(h),!0)}}),f=p=>{let h=p.target;if(!h||typeof h.closest!="function")return;let b=h.closest(n),y=h.closest("a[href]");if(!b||!y||!b.contains(y)&&!y.contains(b))return;let _=u(b);_&&e.promotionClicked({..._,href:y.getAttribute("href")})};return document.addEventListener("click",f,!0),()=>{document.removeEventListener("click",f,!0),d()}}function eo(e){let t=R(e,"hpRecoRequest"),n=R(e,"hpRecoPlacement"),r=R(e,"hpRecoStrategy");if(!t||!n||!r)return null;let o=R(e,"hpRecoHoldout");return{recommendation_request_id:t,placement:n,strategy:r,recipe:R(e,"hpRecoRecipe"),algorithm_version:R(e,"hpRecoAlgorithmVersion"),experiment:R(e,"hpRecoExperiment"),variant:R(e,"hpRecoVariant"),holdout:o===null?null:o==="true",assignment_bucket:Ue(e,"hpRecoBucket"),assignment_unit_kind:R(e,"hpRecoUnitKind"),candidate_set_fingerprint:R(e,"hpRecoFingerprint"),candidate_set_size:Ue(e,"hpRecoCandidates"),ranked_by:R(e,"hpRecoRankedBy"),served_at:R(e,"hpRecoServedAt")}}function to(e,t){let n=R(e,"hpRecoProduct");if(!n)return null;let r=R(e,"hpRecoPrice");return{product_id:n,sku:R(e,"hpRecoSku"),name:R(e,"hpRecoName"),brand:R(e,"hpRecoBrand"),price:r===null||Number.isNaN(Number(r))?null:Number(r),position:Ue(e,"hpRecoPosition")??t+1}}function pt(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=eo,resolveTile:s=to,visibleRatio:i=.5,dwellMs:c=1e3,root:u=document}=t,d=new Set,f=new Map,p=new Map,h=(m,...E)=>{try{return m(...E)}catch{return null}},b=m=>typeof m.closest=="function"?m.closest(n):null,y=m=>Array.from(m.querySelectorAll(r)),_=(m,E)=>{if(p.delete(E.recommendation_request_id),d.has(E.recommendation_request_id))return;let w=y(m).map((S,T)=>h(s,S,T)).filter(S=>S?.product_id);if(w.length===0)return;d.add(E.recommendation_request_id);let g=[...f.get(E.recommendation_request_id)?.values()??[]].sort((S,T)=>S.position-T.position);e.recommendationsViewed({...E,products:w,viewable:g})},A=Q({selector:`${n} ${r}`,root:u,visibleRatio:i,dwellMs:c,onViewable(m){let E=b(m);if(!E)return!0;let w=h(o,E);if(!w)return!0;let g=w.recommendation_request_id,S=h(s,m,y(E).indexOf(m));if(S?.product_id){f.has(g)||f.set(g,new Map);let T=f.get(g);T.has(S.position)||T.set(S.position,{position:S.position,product_id:S.product_id,viewable_at:new Date().toISOString()})}return!d.has(g)&&!p.has(g)&&p.set(g,setTimeout(()=>_(E,w),0)),!0}}),v=m=>{let E=m.target;if(!E||typeof E.closest!="function")return;let w=E.closest(r);if(!w)return;let g=E.closest("[data-hp-reco-interaction]"),S=E.closest("a[href]"),T=S&&(w.contains(S)||S.contains(w));if(!(g&&w.contains(g))&&!T)return;let D=b(w);if(!D)return;let K=h(o,D);if(!K)return;let z=h(s,w,y(D).indexOf(w));if(!z?.product_id)return;let B=K.recommendation_request_id;d.has(B)||(clearTimeout(p.get(B)),_(D,K)),e.productClicked({recommendation_request_id:K.recommendation_request_id,interaction:R(g??w,"hpRecoInteraction")??"navigate",products:[z]})};return document.addEventListener("click",v,!0),()=>{document.removeEventListener("click",v,!0);for(let m of p.values())clearTimeout(m);p.clear(),A()}}var we=new Set(["home","list","product","search","basket","checkout","order_confirmation","login","register","account","info","blog","other"]),no=new Set(["products"]),mn=e=>e==null;function mt(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=>mt(r,t)):Object.fromEntries(Object.entries(e).filter(([,r])=>!mn(r)).map(([r,o])=>[r,mt(o,t)]));return t.delete(e),n}function ht(e){if(!e)return e;let t=mt(e);for(let n of no)n in e&&mn(e[n])&&(t[n]=e[n]);return t}function hn(){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 ro=new Set(["","unknown","undefined","null","none","nil","nan","anonymous","guest","0","-1"]);function q(e){if(e==null)return null;let t=String(e).trim();return ro.has(t.toLowerCase())?null:t}function ee(){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 gn="1.18";function U(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 oo={gclid:"gclid",fbclid:"fbclid",ttclid:"ttclid"},so=/[a-z0-9._%+-]+@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}/i,io=/\d(?:[ -]?\d){12,}/,ao=new Set(["gclid","fbclid","ttclid","msclkid"]);function wn(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=!ao.has(String(t).toLowerCase());return n.some(o=>so.test(o)||r&&io.test(o))}function co(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(oo)]){let i=t.get(o);i&&!wn(i,o)&&(n[s]=i)}return Object.keys(n).length?n:null}var uo=["email","e-mail","password","pass","pwd","token","auth","code","uid","customer_id","postcode","zip","phone","applyCode"],lo=["email","password","passwd","pwd","token","secret","auth","session","phone","postcode","zip","address","birth","card","cvv","iban","ssn","customerid","userid"],fo=["tel","uid","dob"],po=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","gclid","fbclid","ttclid","msclkid"],mo=new Set(uo.map(e=>e.toLowerCase()));function ho(e){let t=String(e).toLowerCase();if(mo.has(t))return!0;let n=t.replace(/[-_.]/g,"");return lo.some(o=>n.includes(o))?!0:String(e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(o=>fo.includes(o))}function gt(e){return(e??[]).map(t=>{try{return new RegExp(`^${t}$`,"i")}catch{return{test:n=>n.toLowerCase()===String(t).toLowerCase()}}})}function Sn(e,t={}){if(!e)return null;try{let n=new URLSearchParams(e),r=t.queryParamAllowlist?gt([...t.queryParamAllowlist,...po]):null,o=gt(t.queryParamBlocklist),s=gt(t.sensitiveParamAllowlist);for(let c of new Set(n.keys()))(ho(c)&&!s.some(d=>d.test(c))||n.getAll(c).some(d=>wn(d,c))||(r?!r.some(d=>d.test(c)):o.some(d=>d.test(c))))&&n.delete(c);let i=n.toString();return i?`?${i}`:""}catch{return""}}function _n(e,t,n={}){if(!e)return null;try{let r=new URL(e);return t&&r.origin===t?r.origin+r.pathname+(Sn(r.search,n)??""):r.origin+r.pathname}catch{return null}}function yt(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:_n(n.href,location.origin,t)}catch{return null}}function wt(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function yn(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{2}$/.test(t)?t:null}function St(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 go(e){return{property_id:String(e.propertyId),channel:e.channel??null,market:e.market??null,environment:e.environment??null}}function yo(e){let t=typeof window<"u"?window.location:null,n=t?Sn(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"?_n(document.referrer,t?.origin,e):null,title:typeof document<"u"&&document.title||null,type:e.pageType??null}}var ve;function wo(){if(ve!==void 0)return ve;try{ve=globalThis.Temporal?.Now?.timeZoneId?.()||Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{ve=null}return ve}function bn(e,t={}){let n=typeof window<"u"?window.location:null,r={library:{name:e.libraryName,version:e.libraryVersion},spec:{version:gn},source:go(e),session_id:M(e.getSessionId,null),identity_trust:q(M(e.getAnonymousId,null))?"device":"none",page:yo(e),campaign:n?co(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:wt(M(e.getCurrency,e.currency)),locale:St(M(e.getLocale,e.locale)),timezone:wo(),country:yn(e.country),ship_to_country:yn(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 xn(r,t)}function xn(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]=xn(e[r],o):o!==void 0&&(n[r]=o);return n}var ce=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"}),So={retry:"cdp.retry",sessionSignals:"cdp_session_signals",identified:"cdp_identified",previousPage:"cdp_prev_page_message_id"},_t={...ce},In=!1;function Ve(e){let t={...ce};for(let[n,r]of Object.entries(e??{})){if(!(n in ce))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}_t=t}function L(e){return _t[e]}var _o="_",kn=e=>e==null||e===""?_o:String(e);function F(e,t,n){let r=`${e}:${kn(t)}`;return n==null||n===""?r:`${r}:${n}`}function An(e,t){return`${e}:${kn(t)}:`}function Be(){if(!In){In=!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(So)){if(n!==o&&!n.startsWith(`${o}:`))continue;let s=_t[r]+n.slice(o.length);t.getItem(s)===null&&t.setItem(s,t.getItem(n)),t.removeItem(n)}}catch{}}}}var xt=1800*1e3,je=()=>{try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}},bt=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}};function vn(e,t=()=>Date.now()){return{read(){try{let n=je()?.getItem(e),r=n?JSON.parse(n):null;return!r||t()-r.savedAt>xt?(r&&je()?.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?je()?.removeItem(e):je()?.setItem(e,JSON.stringify({savedAt:t(),items:n,anonymousId:r}))}catch{}}}}var bo=400*24*60*60;function te(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 xo({name:e,domain:t=null,legacyKey:n,read:r,mint:o,mayStore:s,carried:i=null}){let c=null;try{c=bt()?.getItem(n)||null}catch{c=null}let u=r(e)??c??i,d=!1,f=()=>{if(!(d||u===null||!s())&&(d=te(e,u,bo,t),!(!d||c===null)))try{bt()?.removeItem(n),c=null}catch{}};return{get(){return u??(u=o()),f(),u},peek:()=>u,persist:f,forget(){te(e,"",0,t),u=null,d=!1;try{bt()?.removeItem(n)}catch{}c=null}}}function En(e,{carried:t=null,mayStore:n,orOwn:r=!1}){let o=e.anonymousIdSource,s=()=>xo({name:L("anonymousId"),domain:e.consentCookieDomain??null,legacyKey:F(L("anonymousId"),e.propertyId),read:U,mint:ee,mayStore:n,carried:t});if(o?.source==="hp_cookie"){let u=s();return e.getAnonymousId=()=>u.get(),u}if(o?.source==="site_cookie"&&o.cookie){let u=o.cookie;e.getAnonymousId=()=>U(u)}if(!r)return null;let i=e.getAnonymousId,c=s();return e.getAnonymousId=()=>q(M(i,null))??c.get(),c}var Io=200;function Cn(e,t,n=()=>Date.now()){let r=()=>F(L("carried"),e),o=!1;function s(){try{let i=JSON.parse(sessionStorage.getItem(r())??"null");return!i||!(n()-i.savedAt<=xt)?[]: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(-Io)})),!0)}catch{return!1}},close(){o=!0}}}var ji=ce.consent,He=Object.freeze({visitor:"visitor",host:"host"}),Pn=()=>({basis:He.host}),ko="hp-consent",ue=["analytics","marketing","personalisation","ad_user_data","ad_personalization"],On={analytics:"a",marketing:"m",personalisation:"p",ad_user_data:"aud",ad_personalization:"adp"},X=()=>typeof window<"u",Ln=()=>X()&&typeof window.cookieStore?.addEventListener=="function",Ao=e=>e===!0?!0:e===!1?!1:null;function Se(e){if(!e||typeof e!="object")return null;let t={};for(let n of ue)t[n]=Ao(e[n]);return t}function kt(e,t){return!e||!t?e===t:ue.every(n=>e[n]===t[n])}function At(e){if(!e)return"";let t=[];for(let n of ue){let r=e[n];(r===!0||r===!1)&&t.push(`${On[n]}=${r?1:0}`)}return t.join("&")}function vt(e){return{[ko]:At(Se(e))}}function Ee(e){let t=Se({});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(On).map(([s,i])=>[i,s])),o=new Set;for(let s of n.split("&")){let i=s.indexOf("=");if(i<=0)continue;let c=r[s.slice(0,i).trim()],u={1:!0,0:!1}[s.slice(i+1).trim()]??null;!c||u===null||o.has(c)||(t[c]===null?t[c]=u:t[c]!==u&&(t[c]=null,o.add(c)))}return t}function Et(e,t){if(!t)return e;let n=r=>{if(!r)return r;let o={...r};for(let s of ue)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 Ct(e,t={}){return{...e,ad_user_data:t.ad_user_data??e.marketing,ad_personalization:t.ad_personalization??e.marketing}}function qe(e,t){let n=!0;return{notify:()=>{if(n)try{let o=e();o&&t(o)}catch{}},stop:()=>n=!1}}var vo={analytics:["analytics","measure_content_performance","audience_measurement"],marketing:["marketing","targeting","advertising","select_personalized_ads","create_ads_profile"],personalisation:["personalisation","personalization","select_personalized_content","create_content_profile"]};function Eo(e,t){if(!t?.length)return null;let n=!1;for(let[r,o]of Object.entries(e)){let s=String(o?.id??r).toLowerCase();if(t.some(c=>{let u=String(c).toLowerCase();return s===u||s.startsWith(`${u}-`)})&&(n=!0,o?.enabled===!0))return!0}return n?!1:null}function Tn(e={}){let t={...vo,...e.purposes};function n(){let r=X()?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=>Eo(o,t[i]);return Ct({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(!X())return()=>{};let o=qe(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 It(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 Nn(e={}){let t={analytics:"C0002",personalisation:"C0003",marketing:"C0004",...e.groups},n=e.impliedConsent===!0;function r(){let i=It(U("OptanonConsent"));if(i.groups){let d={};for(let f of i.groups.split(",")){let[p,h]=f.split(":");p?.trim()&&(d[p.trim()]=h==="1"?!0:h==="0"?!1:null)}return f=>d[f]??!1}let c=X()?window.OnetrustActiveGroups:void 0;if(typeof c!="string"||!c.length)return null;let u=new Set(c.split(",").map(d=>d.trim()).filter(Boolean));return d=>u.has(d)}function o(){if(U("OptanonAlertBoxClosed"))return!0;try{if(X()&&window.OneTrust?.IsAlertBoxClosed?.()===!0)return!0}catch{}return Number.parseInt(It(U("OptanonConsent")).interactionCount,10)>0?!0:n&&X()&&(!!window.OneTrust||typeof window.OnetrustActiveGroups=="string")}function s(){if(!o())return null;let i=r();if(!i)return null;let c=p=>t[p]?i(t[p]):null,u=Ct({analytics:c("analytics"),marketing:c("marketing"),personalisation:c("personalisation")},{ad_user_data:c("ad_user_data"),ad_personalization:c("ad_personalization")}),d=It(U("OptanonConsent"));return(typeof navigator<"u"&&navigator.globalPrivacyControl===!0||d.isGpcEnabled==="1")&&(u.marketing=!1,u.ad_user_data=!1,u.ad_personalization=!1),u}return{name:"onetrust",read:s,observesChanges:!0,subscribe(i){if(!X())return()=>{};let c=qe(s,i),u=!1,d=()=>{u||!window.OneTrust?.OnConsentChanged||(u=!0,window.OneTrust.OnConsentChanged(c.notify))};window.addEventListener("OneTrustGroupsUpdated",c.notify);let f=window.OptanonWrapper;return window.OptanonWrapper=function(...h){try{typeof f=="function"&&f.apply(this,h)}finally{d(),c.notify()}},d(),()=>{c.stop(),window.removeEventListener("OneTrustGroupsUpdated",c.notify)}}}}function Co(e){let t=String(e).split(",").map(n=>n.trim()).filter(Boolean);return t.length?new Set(t):null}function Rn(e){let{name:t,categories:n,parse:r=Co,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 c(){let u=U(t);if(u==null)return null;let d;if(o!==void 0&&u===o)d=new Set;else try{d=r(u)}catch{d=null}if(!(d instanceof Set))return null;let f=p=>n[p]?d.has(n[p]):null;return Ct({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:c,get observesChanges(){return Ln()},subscribe(u){if(!X())return()=>{};let d=qe(c,u),f=p=>{[...p.changed??[],...p.deleted??[]].some(b=>b?.name===t)&&d.notify()};return window.addEventListener(i,d.notify),window.cookieStore?.addEventListener?.("change",f),()=>{d.stop(),window.removeEventListener(i,d.notify),window.cookieStore?.removeEventListener?.("change",f)}}}}function Mn(e={}){let t=e.name??L("consent"),n=()=>{let r=U(t);if(r==null)return null;let o=Ee(r);return o.analytics==null?null:o};return{name:"forwarded",read:n,get observesChanges(){return Ln()},subscribe(r){if(!X())return()=>{};let o=qe(n,r),s=i=>{[...i.changed??[],...i.deleted??[]].some(u=>u?.name===t)&&o.notify()};return window.cookieStore?.addEventListener?.("change",s),()=>{o.stop(),window.cookieStore?.removeEventListener?.("change",s)}}}}function Dn(e){let t=Se(e);return{name:"static",basis:He.host,read:()=>t?{...t}:null,observesChanges:!0,subscribe:()=>()=>{}}}function $n(e){if(e==null)return null;let t=String(e).split("/").map(n=>n.trim()).filter(Boolean).join("/");return t===""?null:t}function Po(e){let t=e.item_category;if(t!=null&&String(t).includes("/"))return $n(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 $n(n.join("/"))}var Oo=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t};function Lo(...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 Fe=e=>Lo(e.item_group_id,e.item_id);function To(e,t=Fe){if(!e)return null;let n=c=>c==null||c===""||Number.isNaN(Number(c))?null:Number(c),r=c=>{let u=n(c);return u==null?null:Math.round(u*1e6)/1e6},o=c=>{let u=r(c);return u!=null&&u>=0?u:null},s=c=>{let u=n(c);return Number.isInteger(u)&&u>=0?u:null},i=Oo;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:Po(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 Pt(e,t=Fe){return(e??[]).map(n=>To(n,t)).filter(n=>n?.product_id)}var No=1e3,Ro={shipping:2,payment:3},Mo=new Set(["password","google","apple","facebook","magic_link","sso","passkey","other"]),V=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t},Do=e=>{if(e==null||e===""||typeof e=="object")return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null},Ke=e=>e!==null&&typeof e=="object";function $o(e){return Array.isArray(e.items)?e.items.filter(Ke):null}function Un(e){let t=V(e)?.toLowerCase().replace(/[\s-]+/g,"_");return t?Mo.has(t)?t:t==="email"||t==="email_password"?"password":"other":null}function Uo({ecommerce:e,items:t}){let n=s=>({promotion_id:V(s.promotion_id),name:V(s.promotion_name),creative:V(s.creative_name),position:V(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 Vn=({ecommerce:e,items:t})=>V(e.item_list_id)??V(e.item_list_name)??V(t[0]?.item_list_id)??V(t[0]?.item_list_name),le=(e,t)=>t.products?.length?{event:e,properties:t}:null,Vo=new Set(["product","products","item","items"]);function Bo({ecommerce:e}){let t=V(e.item_id),n=V(e.content_type)?.toLowerCase();return!t||n&&!Vo.has(n)?null:{event:"Product Shared",properties:{share_via:V(e.method),products:[{product_id:t}]}}}function jo(e){let t=o=>le("Product List Viewed",{list_id:Vn(o),products:o.products}),n=o=>{let s=V(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=>le("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=>le("Product Clicked",{list_id:Vn(o),products:o.products.slice(0,1)}),add_to_cart:o=>le("Product Added",{cart_id:V(o.ecommerce.cart_id),products:o.products}),remove_from_cart:o=>le("Product Removed",{cart_id:V(o.ecommerce.cart_id),products:o.products}),view_cart:o=>({event:"Cart Viewed",properties:{cart_id:V(o.ecommerce.cart_id),value:o.value,currency:o.currency,coupon:V(o.ecommerce.coupon),...o.itemsListed?{products:o.products}:{}}}),begin_checkout:o=>le("Checkout Started",{value:o.value,currency:o.currency,coupon:V(o.ecommerce.coupon),products:o.products}),add_shipping_info:o=>({event:"Checkout Step Completed",properties:{step:e.shipping,step_name:"shipping",shipping_method:V(o.ecommerce.shipping_tier)}}),add_payment_info:o=>({event:"Payment Info Entered",properties:{step:e.payment,step_name:"payment",payment_method:V(o.ecommerce.payment_type)}}),view_promotion:r("Promotion Viewed"),select_promotion:r("Promotion Clicked"),add_to_wishlist:o=>le("Product Added to Wishlist",{products:o.products}),share:Bo,login:o=>({event:"Signed In",properties:{method:Un(o.ecommerce.method)}}),sign_up:o=>({event:"Signed Up",properties:{method:Un(o.ecommerce.method)}})}}var Ho=e=>e.event;function qo(e,t){if(!Ke(e))return null;if(typeof e.length=="number"&&e[0]==="event"&&typeof e[1]=="string"){let r=Ke(e[2])?e[2]:{};return{name:e[1],entry:r,ecommerce:r}}let n=V(t(e));return n?{name:n,entry:e,ecommerce:Ke(e.ecommerce)?e.ecommerce:e}:null}function Ot(e){return Array.isArray(e)?`[${e.map(Ot).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Ot(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function Bn(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=jo({...Ro,...t.steps}),o=t.map??{},s=t.eventName??Ho,i=t.productId??Fe,c=new Set(["purchase","refund",...t.ignore??[]]),u=t.dedupeMs??No,d=new Map,f=!0;function p(w,g,S){if(u<=0)return!1;let T=`${w}|${S??""}|${Ot(g)}`,D=Date.now();for(let[K,z]of d)D-z>u&&d.delete(K);return d.has(T)?!0:(d.set(T,D),!1)}let h=null,b=new Set;function y(w,g){if(w!=="Product Viewed")return!1;let S=typeof location>"u"?"":location.pathname;S!==h&&(h=S,b.clear());let T=g.products?.[0]?.product_id;return T?b.has(T)?!0:(b.add(T),!1):!1}function _({event:w,properties:g={}},S){if(!w||p(w,g,S)||y(w,g))return;let T=S?{context:{currency:S}}:void 0;if(w==="Signed Out"&&typeof e.signedOut=="function"){e.signedOut(T);return}e.track(w,g,T)}function A(w){let g=t.transform?t.transform(w):w,S=qo(g,s);if(!S||c.has(S.name))return;let T=Object.hasOwn(o,S.name),D=T?o[S.name]:r[S.name];if(typeof D!="function")return;let K=$o(S.ecommerce),z=K??[],B={...S,items:z,itemsListed:K!==null,products:Pt(z,i),currency:wt(S.ecommerce.currency),value:Do(S.ecommerce.value)};B.promotions=Uo(B);let Ie=T?D(g,{...B,toProducts:W=>Pt(W,i)}):D(B);for(let W of[Ie].flat())W&&_(W,B.currency)}function v(w){if(f)try{A(w)}catch(g){try{t.onError?.(g,w)}catch{}}}for(let w of n.slice())v(w);let m=n.push;function E(...w){let g=m.apply(this,w);for(let S of w)v(S);return g}return n.push=E,()=>{f=!1,n.push===E&&(n.push=m)}}var Fo="hp_debug",Ko=256;function Go(){try{return new URLSearchParams(location.search).get(Fo)}catch{return null}}function jn(e,t){if(typeof location>"u")return!1;try{let n=Go();if(n!==null){let o=n.trim();o===""||o.length>Ko?sessionStorage.removeItem(t):sessionStorage.setItem(t,o)}let r=sessionStorage.getItem(t);return!!(e&&r&&cn(r)===e)}catch{return!1}}var _e=class extends Error{},zo={inHoldout:()=>!0,personalisationGroup:()=>"excluded",servingHeaders:()=>({}),recommendationContext:()=>({}),flush:()=>Promise.resolve(),reset:()=>{}};function Lt(e,t){let n=zo[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 _e)throw i;return r(i)}}}function Hn(e){for(let t of Reflect.ownKeys(e)){let{value:n}=Object.getOwnPropertyDescriptor(e,t)??{};typeof n=="function"&&(e[t]=Lt(t,n))}return e}var Ce=Symbol("hp.identityOption");var Wo=4320*60*60,Jo=100,Yo=1e3,Xo=2e3,qn=500,Ge=e=>(e?.unref?.(),e);function Zo(e,t){if(t?.analytics===!0&&e.analytics===!1)return"withdrawn";let n=ue.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 Qo(e,t,n=L("consent")){if(!(typeof document>"u"))try{let r=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",o=t?`; Domain=${t}`:"";document.cookie=`${n}=${At(e)}; Path=/; Max-Age=${Wo}; SameSite=Lax`+o+r}catch{}}function es(e){let t=Ee(U(e));return ue.some(n=>t[n]!==null)?t:null}function Fn(e){let{adapter:t,timeoutMs:n=5e3,cookieDomain:r=null,cookieName:o=L("consent"),release:s,announce:i}=e,c=e.discard??(()=>{}),u="pending",d=null,f=null,p=null,h=null,b=!1,y=null,_=[],A=N=>{u=N,e.onStatus?.(N)};function v(){try{return Se(t.read())}catch{return null}}function m(){f&&clearInterval(f),p&&clearTimeout(p),f=null,p=null}let E=()=>typeof window<"u"&&typeof document<"u",w=()=>{try{return typeof t.subscribe=="function"&&t.observesChanges===!0}catch{return!1}};function g(){h&&clearInterval(h),h=null}function S(){b||h||d===null||w()||E()&&document.visibilityState==="hidden"||(h=Ge(setInterval(()=>B(v()),Xo)))}let T=()=>u==="pending"||u==="unknown",D=e.store??null,K=()=>{let N=_.splice(0);D?.write([]);for(let j of N)s(j)},z=()=>{let N=_.splice(0);D?.write([]);for(let j of N)c(j)};function B(N){let j=Se(N);if(!j||j.analytics===null)return;let ge=d===null,Z=ge?es(o):d;if(!ge&&kt(Z,j))return;m(),d=j,S(),Qo(j,r,o);let k=!kt(Z,j);if(j.analytics){A("granted"),K(),k&&i({action:Zo(j,Z),state:j,previous:Z,withdrawal:!1});return}z(),Z?.analytics===!0&&i({action:"withdrawn",state:j,previous:Z,withdrawal:!0}),A("denied")}function Ie(){p=null,u==="pending"&&(A("unknown"),f&&clearInterval(f),f=Ge(setInterval(()=>B(v()),Yo)))}function W(N){T()&&(D||N?.type!=="visibilitychange"&&!N?.persisted&&z())}let oe=N=>{document.visibilityState==="hidden"?(g(),W(N)):S()},ke=N=>{g(),W(N)},he=N=>{N?.persisted&&d!==null&&B(v()),S()};return{get status(){return u},get state(){return d?{...d}:null},stamp(){return d?{...d,source:t.name??null,basis:t.basis??He.visitor}:null},admits(){return u==="granted"},hold(N){return!T()||_.length>=qn?(c(N),!1):(_.push(N),D?.write(_),!0)},onHidden:W,start(){b=!1;try{y=t.subscribe?.(N=>B(N))??null}catch(N){e.debug&&console.warn("[hp] consent adapter subscribe failed",N)}E()&&(window.addEventListener("pagehide",ke),window.addEventListener("pageshow",he),document.addEventListener("visibilitychange",oe)),D&&_.length===0&&_.push(...D.read().slice(-qn)),B(v()),!d&&(f=Ge(setInterval(()=>B(v()),Jo)),p=Ge(setTimeout(Ie,n)))},stop(){b=!0,m(),g(),typeof y=="function"&&y(),E()&&(window.removeEventListener("pagehide",ke),window.removeEventListener("pageshow",he),document.removeEventListener("visibilitychange",oe))}}}var ts=["recommendation","search_rank","banner","offer","layout","copy","price","other"],ze=e=>typeof e=="string"&&e!=="";function Kn(e){return(Array.isArray(e?.decisions)?e.decisions:[]).filter(t=>ze(t?.slot)&&ze(t.decision_id)&&t.holdout!==!0).map(({decision_id:t,slot:n,arm:r,kind:o})=>({decision_id:t,slot:n,...ze(r)&&{arm:r},...ts.includes(o)&&{kind:o}}))}function Gn({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=>ze(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(c=>c.slot));n=[...r().filter(c=>!i.has(c.slot)),...s],o()},forget(){n=[];try{sessionStorage.removeItem(e)}catch{}}}}function ns(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 We(e,t,n=1e4){return ns(`${t}\0${e}`)%n}function Tt(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 Nt(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}=Tt(e),s=We(t,e.salt),i=u=>Math.round(u*1e4),c=r>0&&s<i(r)?"holdout":!n||s<i(r+o)?"personalised":"excluded";return{holdout:c==="holdout",bucket:s,group:c}}function zn(e,t){return typeof e!="string"||e===""||t==null||t===""?null:We(t,`bandit-vs-default:${e}`)<1e4/2?"default":"bandit"}var rs="hp_preview",os=256;function Wn(e,t=null){if(typeof location>"u")return U(e);let n=null;try{n=new URLSearchParams(location.search).get(rs)}catch{n=null}if(n===null)return U(e);let r=n.trim();return r===""||r.length>os?(te(e,"",0,t),null):(te(e,r,null,t),r)}var ss=40,is=128,as=5,cs=60,Yn=e=>typeof e=="string"&&e!==""&&e.length<=is&&!e.includes(","),Jn=e=>Array.isArray(e)?e.filter(Yn).slice(0,ss):[],us=e=>Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.replaceAll(","," ").trim()).filter(t=>t!=="").slice(0,as):[],ls=e=>Object.entries(e&&typeof e=="object"?e:{}).filter(([t,n])=>Yn(t)&&Number.isFinite(n)&&n>=1).sort(([,t],[,n])=>n-t).slice(0,cs).map(([t,n])=>`${t}:${Math.floor(n)}`);function Rt(e){let t={},n={viewed:Jn(e?.recentProducts),basket:Jn(e?.basketProducts),q:us(e?.recentSearches),impressed:ls(e?.impressions)};for(let[r,o]of Object.entries(n))o.length>0&&(t[r]=o.join(","));return t}var ds=1800*1e3;function Xn(e,t=Date.now()){try{localStorage.setItem(L("recommendationContext"),JSON.stringify({context:e,until:t+ds}))}catch{}}function Zn(){try{localStorage.removeItem(L("recommendationContext"))}catch{}}var fs="hp_sample",Qn=1e4;function er(e,t){return!(typeof t=="number"&&t<1)||e==null||e===""?!0:We(e,fs,Qn)<Math.round(t*Qn)}function be(e){return e.trim().toLowerCase().replace(/\s*\/\s*/g,"/").replace(/^\/+|\/+$/g,"")}var ps=2,ms=12;function Pe(e,t=ps){return e.split("/").slice(0,t).join("/")}function Mt(e,t){if(typeof t!="string"||!t.trim())return null;let n=Pe(be(t));return n?(e.unshift(n),e.length=Math.min(e.length,ms),n):null}var de=()=>L("sessionSignals"),xe=null,Dt=()=>xe??de();function tr(){try{return xe?localStorage:sessionStorage}catch{return}}function nr(e,t){let n=t==null?null:String(t),r=e?F(de(),n,e):null;if(r===xe)return;let o=xe===null?hs():null;if(xe=r,!!xe)try{let s=Dt(),i=An(de(),n);for(let c of Object.keys(localStorage))c.startsWith(i)&&c!==s&&localStorage.removeItem(c);o&&!localStorage.getItem(s)&&(localStorage.setItem(s,JSON.stringify(o)),sessionStorage.removeItem(de()))}catch{}}function hs(){try{let e=sessionStorage.getItem(de());if(!e)return null;let t=JSON.parse(e);return t&&(t.productViews>0||t.listViews>0||t.basketValue!=null||t.recentProducts?.length||t.recentBrowse?.length)?t:null}catch{return null}}function Je(){return{productViews:0,listViews:0,cartAdds:0,searches:0,recentProducts:[],recentCategories:[],recentBrowse:[],basketProducts:[],basketValue:null,recentSearches:[],impressions:{},browsingCategory:null,recentBrowseCategories:[],browsingListing:null,listViewsByCategory:{},startedAt:0}}function $t(){let e=tr();if(!e)return Je();try{let t=e.getItem(Dt());return t?{...Je(),...JSON.parse(t)}:{...Je(),startedAt:Date.now()}}catch{return{...Je(),startedAt:Date.now()}}}function Ut(e){let t=tr();if(t)try{t.setItem(Dt(),JSON.stringify(e))}catch{}}function Vt(){return $t()}function rr(){for(let e of[()=>sessionStorage,()=>localStorage])try{let t=e();t.removeItem(de());for(let n of Object.keys(t))n.startsWith(`${de()}:`)&&t.removeItem(n)}catch{}}var or=20,sr=200,gs=new Set(["Product Viewed","Product Clicked","Product Added","Product Added to Wishlist"]),ys=new Set(["Product Viewed","Product Added"]),ir=50;function Ye(e,t){let n=Mt(e.recentBrowse,t);return n?(e.recentBrowseCategories=[e.browsingListing?.category??null,...e.recentBrowseCategories].slice(0,e.recentBrowse.length),n):null}function ws(e,t){let n=e.listViewsByCategory;n[t]=(n[t]??0)+1;let r=Object.keys(n);if(r.length>ir){let o={};for(let s of r.sort((i,c)=>n[c]-n[i]).slice(0,ir))o[s]=n[s];e.listViewsByCategory=o}}function ar(e,t){let n=$t();n.startedAt||(n.startedAt=Date.now());let r=Array.isArray(t?.products)?t.products:[];switch(e){case"Product Viewed":n.productViews+=1,Ye(n,n.browsingCategory);break;case"Product List Viewed":{let i=t?.list_id,c=t?.category;if(!(typeof i=="string"&&i.includes("/")&&!i.startsWith("cdp-")))break;let d=typeof c=="string"&&Pe(be(c))||null,f=d?Pe(be(i)):"";if(!f){n.browsingCategory=null,n.browsingListing=null;break}n.browsingListing={key:f,category:d},Ye(n,f),n.browsingCategory=f,ws(n,d),n.listViews+=1}break;case"Product List Filtered":{let i=t?.change,c=typeof t?.list_id=="string"?t.list_id:"",u=typeof i?.value=="string"?i.value:"",d=n.browsingListing;if(u&&i?.action!=="removed"&&d&&Pe(be(c))===d.key){let f=Ye(n,`${c}/${u}`);f&&(n.browsingCategory=f)}break}case"Product Added":{n.cartAdds+=1,Ye(n,n.browsingCategory);for(let i of r){let c=i.product_id;typeof c!="string"||!c||(n.basketProducts=[c,...n.basketProducts.filter(u=>u!==c)].slice(0,or))}break}case"Product Removed":{for(let i of r){let c=i.product_id;typeof c=="string"&&c&&(n.basketProducts=n.basketProducts.filter(u=>u!==c))}break}case"Products Searched":{n.searches+=1;let i=t?.query;if(typeof i=="string"&&i.trim()){let c=i.trim().toLowerCase().slice(0,64);n.recentSearches=[c,...n.recentSearches.filter(u=>u!==c)].slice(0,5)}break}case"Product Clicked":case"Product Added to Wishlist":break;case"Cart Updated":{let i=t?.value;return n.basketValue=typeof i=="number"&&Number.isFinite(i)&&i>=0?i:null,Ut(n),n}default:return n}let o=gs.has(e);if(o)for(let i of r)typeof i.product_id=="string"&&i.product_id&&delete n.impressions[i.product_id];else{for(let c of r){let u=c.product_id;typeof u!="string"||!u||(n.impressions[u]=(n.impressions[u]??0)+1)}let i=Object.keys(n.impressions);if(i.length>sr){let c={};for(let u of i.sort((d,f)=>n.impressions[f]-n.impressions[d]).slice(0,sr))c[u]=n.impressions[u];n.impressions=c}}let s=new Set;for(let i of r){let c=i.product_id;if(o&&typeof c=="string"&&c&&(n.recentProducts=[c,...n.recentProducts.filter(u=>u!==c)].slice(0,or)),ys.has(e)&&typeof i.category=="string"&&i.category){let u=be(i.category);u&&!s.has(u)&&(s.add(u),Mt(n.recentCategories,u))}}return Ut(n),n}var cr=1800*1e3;function ur({name:e,domain:t=null,mayStore:n,now:r=()=>Date.now(),mint:o=ee}){let s=null,i=0,c=()=>{s!==null&&n()&&te(e,s,cr/1e3,t)};return{get(){let u=r(),d=U(e);return d?s=d:(s===null||u-i>=cr)&&(s=o()),i=u,c(),s},persist:c,forget(){te(e,"",0,t),s=null}}}var G=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),lr=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),jt=Object.freeze({enabled:!1});function dr(e,t){let n=e?.track;return G(n)?(Object.hasOwn(n,t)?n[t]:n.__default)?.enabled!==!1:!0}function Ss(e,t){return`${ne(e)}/v1/projects/${encodeURIComponent(t)}/settings`}var _s="https://hp.thgingenuity.com";function ne(e){return e==null||e===""?_s:pr(e)}function fr(e,t){return e!=null&&e!==""?ne(e):t?.startsWith("https://")?t:ne(void 0)}function pr(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 bs(e){if(!G(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>typeof n=="boolean"));return Object.keys(t).length?t:null}var Bt=e=>typeof e=="number"&&e>=0&&e<=1,xs=/^[0-9a-f]{64}$/;function Is(e){return G(e)?{enabled:e.enabled===!0,tokenSha256:typeof e.tokenSha256=="string"&&xs.test(e.tokenSha256)?e.tokenSha256:null}:{enabled:!1,tokenSha256:null}}function ks(e){if(!G(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>G(n)&&Bt(n.share)&&(n.ramp==null||Bt(n.ramp))&&typeof n.salt=="string"&&n.salt!=="").map(([n,r])=>[n,{share:r.share,ramp:r.ramp??null,salt:r.salt,...lr(r.readoutSlots)&&r.readoutSlots.length>0&&{readoutSlots:r.readoutSlots}}]));return Object.keys(t).length?t:null}var As=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;function vs(e){return G(e)?e.source==="hp_cookie"?{source:"hp_cookie"}:e.source!=="site_cookie"?null:e.cookie==null?{source:"site_cookie",cookie:null}:typeof e.cookie=="string"&&As.test(e.cookie)?{source:"site_cookie",cookie:e.cookie}:null:null}function Es(e){let t=Array.isArray(e?.forms)?e.forms.filter(G):[];return t.length===0?null:{forms:t,capture:G(e.capture)?e.capture:null,...Number.isInteger(e.overlay_gap_minutes)?{overlay_gap_minutes:e.overlay_gap_minutes}:{}}}function Cs(e){let t=G(e)?e.hp:null;return G(t)&&typeof t.enabled=="boolean"}function Ht(e){let t=G(e)?e.hp:null;if(!G(t)||t.enabled!==!0)return jt;let n=Es(t.onsite);return{enabled:!0,propertyId:typeof t.propertyId=="string"&&t.propertyId!==""?t.propertyId:null,environment:typeof t.environment=="string"?t.environment:null,consentPurposes:bs(t.consent?.purposes),queryParamAllowlist:lr(t.queryParamAllowlist)?t.queryParamAllowlist:null,anonymousId:vs(t.anonymousId),apiHost:pr(t.apiHost),holdouts:ks(t.holdouts),sampleRate:Bt(t.sampleRate)?t.sampleRate:1,debug:Is(t.debug),...n&&{onsite:n},plan:G(e.plan)&&G(e.plan.track)?{track:e.plan.track}:null}}async function mr(e,t,n=globalThis.fetch){try{let r=await n(Ss(e,t),{credentials:"omit",headers:{accept:"application/json"}});if(!r.ok)return null;let o=await r.json();return Cs(o)?Ht(o):null}catch{return null}}var Xe=e=>F(L("settings"),e);function hr(e){try{let t=localStorage.getItem(Xe(e));if(!t)return null;let n=JSON.parse(t);return n?.enabled===!0?n:null}catch{return null}}function gr(e,t){try{t?.enabled===!0?localStorage.setItem(Xe(e),JSON.stringify(t)):localStorage.removeItem(Xe(e))}catch{}}function qt(e){try{localStorage.removeItem(Xe(e))}catch{}}var Ps={flushAt:20,flushIntervalMs:1e4,maxQueue:500,maxRetryAgeMs:1440*60*1e3,maxRetries:5,maxPersistedBatches:20,maxPersistedBytes:1024*1024,storageKey:ce.retry,beaconSafeBytes:56*1024,maxBatchEvents:100,maxBatchBytes:500*1024},Ze=()=>Date.now(),yr=3e4,Yt=55*1024;function Os(e,t=Ze()){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 re=e=>typeof TextEncoder<"u"?new TextEncoder().encode(e).length:Buffer.byteLength(e),Ft=()=>typeof window<"u"&&typeof document<"u";function Ls(){try{return!Ft()||!window.localStorage?null:(window.localStorage.getItem("thg_hp_probe"),window.localStorage)}catch{return null}}var I,Kt,Gt,Qe,zt,Wt,wr,Oe,Le,Te,Sr,Jt,_r,et,tt=class{constructor(t){sn(this,I);this.o={...Ps,...t},this.queue=[],this.timer=null,this.storage=Ls(),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,Ft()&&(window.addEventListener("pagehide",()=>this.flush({beacon:!0})),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()}),O(this,I,et).call(this))}replayPersisted(){return this.replayAllowed=!0,O(this,I,et).call(this)}clearPersisted(){if(this.replayAllowed=!1,!!this.storage)try{let t=O(this,I,Te).call(this).filter(n=>this.sinceRefusal.has(n?.id));t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey)}catch{}}discardQueued(){this.queue=[],this.epoch+=1,this.sinceRefusal.clear(),O(this,I,Gt).call(this);for(let t of this.wakers)t()}enqueue(t){let n;try{n=JSON.parse(JSON.stringify(t))}catch(r){this.o.onError?.(`event ${t?.messageId??""} cannot be serialised; dropped`,r);return}this.queue.push(n),this.queue.length>this.o.maxQueue&&this.queue.splice(0,this.queue.length-this.o.maxQueue),this.queue.length>=this.o.flushAt?this.flush():O(this,I,Kt).call(this)}flush(t={}){if(O(this,I,Gt).call(this),this.queue.length===0)return Promise.resolve();if(t.beacon&&Ft()&&typeof navigator<"u"&&navigator.sendBeacon)return O(this,I,wr).call(this),Promise.resolve();if(this.inflight)return this.inflight;let n=O(this,I,Wt).call(this,this.queue,this.o.maxBatchEvents,this.o.maxBatchBytes).map(o=>{let s=O(this,I,Jt).call(this,o);return s&&(this.sending.add(s),this.sinceRefusal.add(s)),{batch:o,id:s}});this.queue=[];let r=this.epoch;return this.inflight=(async()=>{for(let{batch:o,id:s}of n){if(r!==this.epoch){O(this,I,Le).call(this,s);continue}await O(this,I,Oe).call(this,o,0,s,r)}})().finally(()=>{this.inflight=null,this.queue.length>=this.o.flushAt?this.flush():this.queue.length&&O(this,I,Kt).call(this)}),this.inflight}};I=new WeakSet,Kt=function(){this.timer||(this.timer=setTimeout(()=>this.flush(),this.o.flushIntervalMs),this.timer?.unref?.())},Gt=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},Qe=function(t){return JSON.stringify({batch:t,writeKey:this.o.writeKey,sentAt:new Date().toISOString()})},zt=function(){return`${this.o.apiHost.replace(/\/$/,"")}/v1/batch`},Wt=function(t,n,r){let o=re(O(this,I,Qe).call(this,[])),s=[],i=[],c=o;for(let u of t){let d=re(JSON.stringify(u))+1;i.length&&(i.length>=n||c+d>r)&&(s.push(i),i=[],c=o),i.push(u),c+=d}return i.length&&s.push(i),s},wr=function(){let t=this.queue;this.queue=[];let n=O(this,I,zt).call(this);for(let r of O(this,I,Wt).call(this,t,this.o.maxBatchEvents,this.o.beaconSafeBytes)){let o=O(this,I,Qe).call(this,r);if(re(o)<=this.o.beaconSafeBytes){let s=!1;try{s=navigator.sendBeacon(n,new Blob([o],{type:"text/plain"}))}catch{s=!1}if(s)continue}O(this,I,Oe).call(this,r,0,O(this,I,Jt).call(this,r))}},Oe=async function(t,n,r=null,o=this.epoch){r&&this.sending.add(r);let s=O(this,I,Qe).call(this,t),i=0;try{let c=await fetch(O(this,I,zt).call(this),{method:"POST",headers:{"Content-Type":"text/plain"},body:s,keepalive:re(s)<=this.o.beaconSafeBytes});if(c.ok)return O(this,I,Le).call(this,r),O(this,I,et).call(this),!0;let u=c.status===408||c.status===429||c.status>=500;if(u&&(i=Os(c.headers?.get?.("retry-after"))),!u)return O(this,I,Le).call(this,r),this.o.onError?.(`CDP ingest rejected batch (${c.status}); dropping ${t.length} events`),!0;throw new Error(`retryable ${c.status}`)}catch(c){if(n>=this.o.maxRetries){r&&this.sending.delete(r);let d=r?"kept for the next page":"dropped";return this.o.onError?.(`CDP ingest unreachable after ${n} attempts; ${d}: ${t.length} events`,c),!1}let u=Math.max(Math.min(1e3*2**n,yr)*(.5+Math.random()),Math.min(i,yr));return o===this.epoch&&await new Promise(d=>{let f=()=>{clearTimeout(p),this.wakers.delete(f),d()},p=setTimeout(f,u);this.wakers.add(f)}),o!==this.epoch?(O(this,I,Le).call(this,r),!1):O(this,I,Oe).call(this,t,n+1,r,o)}},Le=function(t){t&&(this.sending.delete(t),this.sinceRefusal.delete(t),O(this,I,_r).call(this,t))},Te=function(){let t=JSON.parse(this.storage.getItem(this.o.storageKey)||"[]");return Array.isArray(t)?t:[]},Sr=function(t,n){let r=i=>re(JSON.stringify(i))+1,o=[...t,n].slice(-this.o.maxPersistedBatches),s=o.reduce((i,c)=>i+r(c),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},Jt=function(t){if(!this.storage||this.o.mayPersist&&!this.o.mayPersist())return null;try{let n={at:Ze(),id:`${Ze()}-${Math.random().toString(36).slice(2)}`,batch:t};return re(JSON.stringify(n))+3>this.o.maxPersistedBytes?null:O(this,I,Sr).call(this,O(this,I,Te).call(this),n)?n.id:null}catch{return null}},_r=function(t){if(!(!t||!this.storage))try{let n=O(this,I,Te).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{}},et=function(){if(!this.storage||!this.replayAllowed)return this.draining??Promise.resolve();if(this.draining)return this.draining;let t;try{let r=O(this,I,Te).call(this);t=r.filter(o=>Array.isArray(o?.batch)&&Ze()-o.at<this.o.maxRetryAgeMs).map(o=>o.id?o:{...o,id:`${o.at}-${Math.random().toString(36).slice(2)}`}),(t.length!==r.length||t.some((o,s)=>o!==r[s]))&&(t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey))}catch{return Promise.resolve()}let n=t.filter(r=>!this.sending.has(r.id));return n.length?(this.draining=(async()=>{for(let r of n)if(!this.replayAllowed||!await O(this,I,Oe).call(this,r.batch,0,r.id))return})().finally(()=>{this.draining=null}),this.draining):Promise.resolve()};var br="3.24.0",xr="@thg-agentic/hyper-personalisation-web";var Ts=new Set(["audiences","decisions","recommendations"]);var Ns=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),Rs=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite-access");function Ms(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 Ds="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";function $s(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 nt(e){if(typeof e!="string")return null;let t=$s(e.trim());return t===Ds?null:t}var Ir=Object.freeze({email_sha256:"sha256",phone_sha256:"sha256",accepts_marketing:"boolean",gender:"string",created_at:"date-time"}),Us=/^\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 Vs(e){if(typeof e!="string"||!Us.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 Bs(e,t){return t===null?null:e==="sha256"?nt(t)??void 0:e==="date-time"?t instanceof Date?Number.isNaN(t.getTime())?void 0:t.toISOString():Vs(t)?t:void 0:typeof t===e?t:void 0}function js(e,t){let n={},r=[];for(let[o,s]of Object.entries(e)){let i=Object.hasOwn(Ir,o)?Ir[o]:null,c=i?Bs(i,s):void 0;c===void 0?r.push(o):n[o]=c}return t&&r.length&&console.warn(`[hp] identify: not sent, not spec traits: ${r.join(", ")}`),n}var kr=!1,Ar=!1;function Hs(){Ar||(Ar=!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 qs(e){!e||kr||(kr=!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 Fs(e){try{return re(JSON.stringify(e))}catch{return 0}}function vr(e){return e&&typeof e.context=="object"&&e.context!==null?e.context:e}function Er(e){let t=ne(e?.apiHost);if(!t)throw new Error("createAnalytics: apiHost, when given, must be a host or an http(s) origin");if(!e?.propertyId)throw new Error("createAnalytics: propertyId is required");let n={libraryName:xr,libraryVersion:br,writeKey:"web",queryParamBlocklist:[],debug:!1,validate:null,consentTimeoutMs:5e3,...e,apiHost:t};Ve(n.storageNames),Be();let r=!!n.consent;r||Hs();let o=null;n.getConsent=()=>o?o.stamp():Pn();let s=()=>!r||o?.status==="granted",i=r&&n.holdAcrossPages?vn(F(L("held"),n.propertyId)):null,c=i?.read()??{items:[],anonymousId:null};n.mintAnonymousId!==void 0&&qs(n.debug);let u=En(n,{carried:c.anonymousId,mayStore:s,orOwn:!0}),d=ur({name:L("session"),domain:n.consentCookieDomain??null,mayStore:s}),f=n.getSessionId;n.getSessionId=()=>q(M(f,null))??d.get();let p=Wn(L("preview"),n.consentCookieDomain??null),h=(a,l)=>n.debug&&console.warn("[hp]",a,l??""),b=n.transport??new tt({apiHost:n.apiHost,writeKey:n.writeKey,storageKey:F(L("retry"),n.propertyId),mayPersist:r?()=>o?.status==="granted":void 0,deferReplay:r,onError:h}),y=F(L("previousPage"),n.propertyId),_=null,A=()=>{if(_)return _;try{return sessionStorage.getItem(y)||null}catch{return null}};typeof window<"u"&&window.addEventListener("pageshow",a=>{a.persisted&&(_=null)});let v=a=>{if(_=a||null,!(r&&o.status!=="granted"))try{sessionStorage.setItem(y,a)}catch{}},m=Gn({key:F(L("decisions"),n.propertyId),mayStore:s});n.getDecisions??(n.getDecisions=m.current);let E=q(M(n.getUserId,null)),w=null,g=null,S=null,T=null,D=new Set,K=new Set;function z(a){if(a.type!=="track"||a.event!=="Cart Updated")return;let l=a.properties?.value;T=typeof l=="number"&&Number.isFinite(l)&&l>=0?l:null;for(let x of D)try{x()}catch(P){console.warn("[hp] a basket listener failed",P)}}function B(a,l,x=!1){z(a);try{return Ie(a,l,x)}catch(P){if(P instanceof _e)throw P;return console.warn("[hp] the event was not sent",P),null}}function Ie(a,l,x){let P=S;S=null;let H=a.type==="track"?a.event:a.type;if(!x&&!dr(n.plan,H))return null;let C={messageId:P?.messageId??ee(),timestamp:P?.timestamp??new Date().toISOString(),anonymousId:q(M(n.getAnonymousId,null)),userId:E??null,...a,context:bn(n,vr(l))};if(C.properties&&(C.properties=ht(C.properties)),typeof C.properties?.href=="string"&&(C.properties.href=yt(C.properties.href,n)),!x&&!er(C.anonymousId,n.sampleRate))return n.debug&&console.debug("[hp] not sent: outside the sample",C),null;if(n.beforeSend){let ye;try{ye=n.beforeSend(C)}catch(Fr){return console.warn("[hp] beforeSend failed; the event was not sent",Fr),null}if(!ye)return null;let{type:De,event:rn,messageId:Hr,timestamp:qr}=C;C={...ye,type:De,messageId:Hr,timestamp:qr,...rn?{event:rn}:{}}}if(n.validate){let ye=n.validate(C,{producer:"web"});if(!ye.valid){let De=`[hp] invalid ${C.event??C.type}:
|
|
1
|
+
(()=>{var sn=e=>{throw TypeError(e)};var zr=(e,t,n)=>t.has(e)||sn("Cannot "+n);var an=(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 O=(e,t,n)=>(zr(e,t,"access private method"),n);var Ae=[];for(let e=2;Ae.length<64;e++)Ae.every(t=>e%t!==0)&&Ae.push(e);var cn=e=>(e-Math.floor(e))*2**32>>>0,Gr=Ae.slice(0,8).map(e=>cn(Math.sqrt(e))),Wr=Ae.map(e=>cn(Math.cbrt(e))),Y=(e,t)=>e>>>t|e<<32-t;function un(e){let t=new TextEncoder().encode(String(e)),n=new Uint32Array((t.length+8>>6)*16+16);t.forEach((i,s)=>{n[s>>2]|=i<<24-s%4*8}),n[t.length>>2]|=128<<24-t.length%4*8,n[n.length-2]=Math.floor(t.length/2**29),n[n.length-1]=t.length*8;let r=Uint32Array.from(Gr),o=new Uint32Array(64);for(let i=0;i<n.length;i+=16){for(let y=0;y<64;y++){if(y<16){o[y]=n[i+y];continue}let b=o[y-15],v=o[y-2],A=Y(b,7)^Y(b,18)^b>>>3,m=Y(v,17)^Y(v,19)^v>>>10;o[y]=o[y-16]+A+o[y-7]+m}let[s,c,u,d,f,p,g,_]=r;for(let y=0;y<64;y++){let b=Y(f,6)^Y(f,11)^Y(f,25),v=_+b+(f&p^~f&g)+Wr[y]+o[y]|0,m=(Y(s,2)^Y(s,13)^Y(s,22))+(s&c^s&u^c&u)|0;[_,g,p,f,d,u,c,s]=[g,p,f,d+v|0,u,c,s,v+m|0]}[s,c,u,d,f,p,g,_].forEach((y,b)=>{r[b]+=y})}return Array.from(r,i=>i.toString(16).padStart(8,"0")).join("")}var lt=(e,t)=>e<<t|e>>>32-t;function ln(e){let t=new Uint32Array((e.length+8>>6)*16+16);e.forEach((i,s)=>{t[s>>2]|=i<<24-s%4*8}),t[e.length>>2]|=128<<24-e.length%4*8,t[t.length-2]=Math.floor(e.length/2**29),t[t.length-1]=e.length*8;let n=Uint32Array.of(1732584193,4023233417,2562383102,271733878,3285377520),r=new Uint32Array(80);for(let i=0;i<t.length;i+=16){for(let p=0;p<80;p++)r[p]=p<16?t[i+p]:lt(r[p-3]^r[p-8]^r[p-14]^r[p-16],1);let[s,c,u,d,f]=n;for(let p=0;p<80;p++){let g,_;p<20?(g=c&u|~c&d,_=1518500249):p<40?(g=c^u^d,_=1859775393):p<60?(g=c&u|c&d|u&d,_=2400959708):(g=c^u^d,_=3395469782);let y=lt(s,5)+g+f+_+r[p]|0;[f,d,u,c,s]=[d,u,lt(c,30),s,y]}[s,c,u,d,f].forEach((p,g)=>{n[g]+=p})}let o=new Uint8Array(20);return n.forEach((i,s)=>{o[s*4]=i>>>24,o[s*4+1]=i>>>16,o[s*4+2]=i>>>8,o[s*4+3]=i}),o}var Jr="e28e8ada-5b76-4209-bba9-79b823a0af75",Yr=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");function dn(e,t){let n=Uint8Array.from(e.replace(/-/g,"").match(/../g),c=>Number.parseInt(c,16)),r=new TextEncoder().encode(t),o=new Uint8Array(16+r.length);o.set(n),o.set(r,16);let i=ln(o).slice(0,16);i[6]=i[6]&15|80,i[8]=i[8]&63|128;let s=Yr(i);return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20)}`}var se=(e,t)=>typeof e=="string"&&e!==""&&e.length<=t?e:null;function Ue(e,t){return se(e,64)??se(t,256)}function fn({sessionId:e,slot:t,arm:n}={}){let r=se(e,256);return!r||!se(t,256)||!se(n,256)?null:dn(Jr,`${r}:${t}:${n}`)}var Xr="4b1f2c7e-9a3d-4e58-b6c1-2d7f0a9e8c53";function pn({sessionId:e,surface:t}={}){let n=se(e,256);return!n||!se(t,64)?null:dn(Xr,`${n}:${t}`)}var Zr=Array.from({length:11},(e,t)=>t/10);function Qr(e,t){if(!e.isIntersecting)return!1;let{intersectionRect:n,boundingClientRect:r,rootBounds:o}=e;if(!n||!r)return!0;let i=n.width*n.height,s=r.width*r.height,c=o?Math.min(s,o.width*o.height):s;return c>0&&i/c>=t}function Q(e){let{selector:t,onViewable:n,visibleRatio:r=.5,dwellMs:o=1e3,root:i=document}=e,s=new Map,c=new WeakSet,u=new Set,d=m=>{s.has(m)||s.set(m,setTimeout(()=>{s.delete(m),n(m)&&(p?.unobserve(m),u.delete(m))},o))},f=m=>{clearTimeout(s.get(m)),s.delete(m)},p=typeof IntersectionObserver>"u"?null:new IntersectionObserver(m=>{for(let E of m){let w=E.target;if(!Qr(E,r)){u.delete(w),f(w);continue}u.add(w),g()&&d(w)}},{threshold:Zr}),g=()=>typeof document>"u"||document.visibilityState!=="hidden",_=()=>{if(g())for(let m of u)d(m);else for(let m of u)f(m)};document.addEventListener("visibilitychange",_);let y=()=>{for(let m of i.querySelectorAll(t))c.has(m)||(c.add(m),p?.observe(m))},b=typeof MutationObserver>"u"?null:new MutationObserver(()=>y()),v=()=>{y(),b?.observe(i===document?document.body:i,{childList:!0,subtree:!0})},A=i===document&&!document.body;return A?document.addEventListener("DOMContentLoaded",v,{once:!0}):v(),()=>{A&&document.removeEventListener("DOMContentLoaded",v),document.removeEventListener("visibilitychange",_),p?.disconnect(),b?.disconnect();for(let m of s.values())clearTimeout(m);s.clear(),u.clear()}}function dt(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-exposure]",visibleRatio:r=.5,dwellMs:o=1e3,root:i=document}=t;return Q({selector:n,root:i,visibleRatio:r,dwellMs:o,onViewable(s){let c=s.dataset?.hpExposure?.trim();return c&&e.surfaceViewed({surface:c}),!0}})}var mn=e=>{try{return new URL(e,document.baseURI).toString()}catch{return e}};function ft(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-list]",tileSelector:r="[data-hp-product]",visibleRatio:o=.5,dwellMs:i=1e3,root:s=document}=t,c=new Set,u=y=>y.closest?.(n)??null,d=y=>{let b=y.dataset.hpList?.trim();return b?{list_id:b,category:y.dataset.hpListCategory?.trim()||null}:null},f=y=>Array.from(y.querySelectorAll(r)).filter(b=>u(b)===y),p=(y,b)=>{try{let v=JSON.parse(y.dataset.hpProduct??"");return!v||typeof v!="object"||!v.product_id?null:{...v,position:v.position??b+1,...v.url?{url:mn(v.url)}:{},...v.image_url?{image_url:mn(v.image_url)}:{}}}catch{return null}},g=Q({selector:`${n} ${r}`,root:s,visibleRatio:o,dwellMs:i,onViewable(y){let b=u(y);if(!b||b.dataset.hpListView==="manual")return!0;let v=d(b);if(!v||c.has(v.list_id))return!0;let A=new Set,m=f(b).map(p).filter(E=>!E||A.has(E.product_id)?!1:(A.add(E.product_id),!0));return m.length===0||(c.add(v.list_id),e.productListViewed({...v,products:m})),!0}}),_=y=>{let v=y.target?.closest?.("a[href]")?.closest(r);if(!v)return;let A=u(v),m=p(v,A?f(A).indexOf(v):0);m&&e.productClicked({list_id:A?d(A)?.list_id??null:null,products:[m]})};return document.addEventListener("click",_,!0),()=>{document.removeEventListener("click",_,!0),g()}}function R(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 $e(e,...t){let n=R(e,...t);if(n===null)return null;let r=Number(n);return Number.isFinite(r)?Math.trunc(r):null}function eo(e,t){let n=R(e,"hpPromotion");return n?{promotion_id:n,name:R(e,"hpPromotionName"),creative:R(e,"hpPromotionCreative"),position:R(e,"hpPromotionSlot")??String(t+1)}:null}function pt(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-promotion]",resolve:r=eo,visibleRatio:o=.5,dwellMs:i=1e3,root:s=document}=t,c=new Set,u=p=>{let g=Array.from(s.querySelectorAll(n)),_=g.indexOf(p);try{return r(p,_<0?g.length:_)}catch{return null}},d=Q({selector:n,root:s,visibleRatio:o,dwellMs:i,onViewable(p){let g=u(p);return!g||c.has(g.promotion_id)?!1:(c.add(g.promotion_id),e.promotionViewed(g),!0)}}),f=p=>{let g=p.target;if(!g||typeof g.closest!="function")return;let _=g.closest(n),y=g.closest("a[href]");if(!_||!y||!_.contains(y)&&!y.contains(_))return;let b=u(_);b&&e.promotionClicked({...b,href:y.getAttribute("href")})};return document.addEventListener("click",f,!0),()=>{document.removeEventListener("click",f,!0),d()}}function to(e){let t=R(e,"hpRecoRequest"),n=R(e,"hpRecoPlacement"),r=R(e,"hpRecoStrategy");if(!t||!n||!r)return null;let o=R(e,"hpRecoHoldout");return{recommendation_request_id:t,placement:n,strategy:r,recipe:R(e,"hpRecoRecipe"),algorithm_version:R(e,"hpRecoAlgorithmVersion"),experiment:R(e,"hpRecoExperiment"),variant:R(e,"hpRecoVariant"),holdout:o===null?null:o==="true",assignment_bucket:$e(e,"hpRecoBucket"),assignment_unit_kind:R(e,"hpRecoUnitKind"),candidate_set_fingerprint:R(e,"hpRecoFingerprint"),candidate_set_size:$e(e,"hpRecoCandidates"),ranked_by:R(e,"hpRecoRankedBy"),served_at:R(e,"hpRecoServedAt")}}function no(e,t){let n=R(e,"hpRecoProduct");if(!n)return null;let r=R(e,"hpRecoPrice");return{product_id:n,sku:R(e,"hpRecoSku"),name:R(e,"hpRecoName"),brand:R(e,"hpRecoBrand"),price:r===null||Number.isNaN(Number(r))?null:Number(r),position:$e(e,"hpRecoPosition")??t+1}}function mt(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=to,resolveTile:i=no,visibleRatio:s=.5,dwellMs:c=1e3,root:u=document}=t,d=new Set,f=new Map,p=new Map,g=(m,...E)=>{try{return m(...E)}catch{return null}},_=m=>typeof m.closest=="function"?m.closest(n):null,y=m=>Array.from(m.querySelectorAll(r)),b=(m,E)=>{if(p.delete(E.recommendation_request_id),d.has(E.recommendation_request_id))return;let w=y(m).map((S,T)=>g(i,S,T)).filter(S=>S?.product_id);if(w.length===0)return;d.add(E.recommendation_request_id);let h=[...f.get(E.recommendation_request_id)?.values()??[]].sort((S,T)=>S.position-T.position);e.recommendationsViewed({...E,products:w,viewable:h})},v=Q({selector:`${n} ${r}`,root:u,visibleRatio:s,dwellMs:c,onViewable(m){let E=_(m);if(!E)return!0;let w=g(o,E);if(!w)return!0;let h=w.recommendation_request_id,S=g(i,m,y(E).indexOf(m));if(S?.product_id){f.has(h)||f.set(h,new Map);let T=f.get(h);T.has(S.position)||T.set(S.position,{position:S.position,product_id:S.product_id,viewable_at:new Date().toISOString()})}return!d.has(h)&&!p.has(h)&&p.set(h,setTimeout(()=>b(E,w),0)),!0}}),A=m=>{let E=m.target;if(!E||typeof E.closest!="function")return;let w=E.closest(r);if(!w)return;let h=E.closest("[data-hp-reco-interaction]"),S=E.closest("a[href]"),T=S&&(w.contains(S)||S.contains(w));if(!(h&&w.contains(h))&&!T)return;let D=_(w);if(!D)return;let K=g(o,D);if(!K)return;let G=g(i,w,y(D).indexOf(w));if(!G?.product_id)return;let B=K.recommendation_request_id;d.has(B)||(clearTimeout(p.get(B)),b(D,K)),e.productClicked({recommendation_request_id:K.recommendation_request_id,interaction:R(h??w,"hpRecoInteraction")??"navigate",products:[G]})};return document.addEventListener("click",A,!0),()=>{document.removeEventListener("click",A,!0);for(let m of p.values())clearTimeout(m);p.clear(),v()}}var we=new Set(["home","list","product","search","basket","checkout","order_confirmation","login","register","account","info","blog","other"]),ro=new Set(["products"]),hn=e=>e==null;function ht(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=>ht(r,t)):Object.fromEntries(Object.entries(e).filter(([,r])=>!hn(r)).map(([r,o])=>[r,ht(o,t)]));return t.delete(e),n}function gt(e){if(!e)return e;let t=ht(e);for(let n of ro)n in e&&hn(e[n])&&(t[n]=e[n]);return t}function gn(){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 oo=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 oo.has(t.toLowerCase())?null:t}function ee(){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 yn="1.18";function $(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 so={gclid:"gclid",fbclid:"fbclid",ttclid:"ttclid"},io=/[a-z0-9._%+-]+@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}/i,ao=/\d(?:[ -]?\d){12,}/,co=new Set(["gclid","fbclid","ttclid","msclkid"]);function Sn(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=!co.has(String(t).toLowerCase());return n.some(o=>io.test(o)||r&&ao.test(o))}function uo(e){if(!e)return null;let t=new URLSearchParams(e),n={},r={utm_source:"source",utm_medium:"medium",utm_campaign:"name",utm_term:"term",utm_content:"content"};for(let[o,i]of[...Object.entries(r),...Object.entries(so)]){let s=t.get(o);s&&!Sn(s,o)&&(n[i]=s)}return Object.keys(n).length?n:null}var lo=["email","e-mail","password","pass","pwd","token","auth","code","uid","customer_id","postcode","zip","phone","applyCode"],fo=["email","password","passwd","pwd","token","secret","auth","session","phone","postcode","zip","address","birth","card","cvv","iban","ssn","customerid","userid"],po=["tel","uid","dob"],mo=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","gclid","fbclid","ttclid","msclkid"],ho=new Set(lo.map(e=>e.toLowerCase()));function go(e){let t=String(e).toLowerCase();if(ho.has(t))return!0;let n=t.replace(/[-_.]/g,"");return fo.some(o=>n.includes(o))?!0:String(e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(o=>po.includes(o))}function yt(e){return(e??[]).map(t=>{try{return new RegExp(`^${t}$`,"i")}catch{return{test:n=>n.toLowerCase()===String(t).toLowerCase()}}})}function _n(e,t={}){if(!e)return null;try{let n=new URLSearchParams(e),r=t.queryParamAllowlist?yt([...t.queryParamAllowlist,...mo]):null,o=yt(t.queryParamBlocklist),i=yt(t.sensitiveParamAllowlist);for(let c of new Set(n.keys()))(go(c)&&!i.some(d=>d.test(c))||n.getAll(c).some(d=>Sn(d,c))||(r?!r.some(d=>d.test(c)):o.some(d=>d.test(c))))&&n.delete(c);let s=n.toString();return s?`?${s}`:""}catch{return""}}function bn(e,t,n={}){if(!e)return null;try{let r=new URL(e);return t&&r.origin===t?r.origin+r.pathname+(_n(r.search,n)??""):r.origin+r.pathname}catch{return null}}function wt(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:bn(n.href,location.origin,t)}catch{return null}}function St(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function wn(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{2}$/.test(t)?t:null}function _t(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 yo(e){return{...e.propertyId==null?{}:{property_id:String(e.propertyId)},channel:e.channel??null,market:e.market??null,environment:e.environment??null}}function wo(e){let t=typeof window<"u"?window.location:null,n=t?_n(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"?bn(document.referrer,t?.origin,e):null,title:typeof document<"u"&&document.title||null,type:e.pageType??null}}var ve;function So(){if(ve!==void 0)return ve;try{ve=globalThis.Temporal?.Now?.timeZoneId?.()||Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{ve=null}return ve}function In(e,t={}){let n=typeof window<"u"?window.location:null,r={library:{name:e.libraryName,version:e.libraryVersion},spec:{version:yn},source:yo(e),session_id:M(e.getSessionId,null),identity_trust:F(M(e.getAnonymousId,null))?"device":"none",page:wo(e),campaign:n?uo(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:St(M(e.getCurrency,e.currency)),locale:_t(M(e.getLocale,e.locale)),timezone:So(),country:wn(e.country),ship_to_country:wn(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 xn(r,t)}function xn(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]=xn(e[r],o):o!==void 0&&(n[r]=o);return n}var ce=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"}),_o={retry:"cdp.retry",sessionSignals:"cdp_session_signals",identified:"cdp_identified",previousPage:"cdp_prev_page_message_id"},bt={...ce},kn=!1;function Ve(e){let t={...ce};for(let[n,r]of Object.entries(e??{})){if(!(n in ce))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}bt=t}function L(e){return bt[e]}var bo="_",An=e=>e==null||e===""?bo:String(e);function j(e,t,n){let r=`${e}:${An(t)}`;return n==null||n===""?r:`${r}:${n}`}function vn(e,t){return`${e}:${An(t)}:`}function Be(){if(!kn){kn=!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(_o)){if(n!==o&&!n.startsWith(`${o}:`))continue;let i=bt[r]+n.slice(o.length);t.getItem(i)===null&&t.setItem(i,t.getItem(n)),t.removeItem(n)}}catch{}}}}var xt=1800*1e3,je=()=>{try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}},It=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}};function En(e,t=()=>Date.now()){return{read(){try{let n=je()?.getItem(e),r=n?JSON.parse(n):null;return!r||t()-r.savedAt>xt?(r&&je()?.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?je()?.removeItem(e):je()?.setItem(e,JSON.stringify({savedAt:t(),items:n,anonymousId:r}))}catch{}}}}var Io=400*24*60*60;function te(e,t,n,r){if(typeof document>"u")return!1;try{let o=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",i=r?`; Domain=${r}`:"",s=n===null?"":`; Max-Age=${n}`;return document.cookie=`${e}=${encodeURIComponent(t)}; Path=/${s}; SameSite=Lax`+i+o,!0}catch{return!1}}function xo({name:e,domain:t=null,legacyKey:n,read:r,mint:o,mayStore:i,carried:s=null}){let c=null;try{c=It()?.getItem(n)||null}catch{c=null}let u=r(e)??c??s,d=!1,f=()=>{if(!(d||u===null||!i())&&(d=te(e,u,Io,t),!(!d||c===null)))try{It()?.removeItem(n),c=null}catch{}};return{get(){return u??(u=o()),f(),u},peek:()=>u,persist:f,forget(){te(e,"",0,t),u=null,d=!1;try{It()?.removeItem(n)}catch{}c=null}}}function Cn(e,{carried:t=null,mayStore:n,orOwn:r=!1}){let o=e.anonymousIdSource,i=()=>xo({name:L("anonymousId"),domain:e.consentCookieDomain??null,legacyKey:j(L("anonymousId"),e.propertyId),read:$,mint:ee,mayStore:n,carried:t});if(o?.source==="hp_cookie"){let u=i();return e.getAnonymousId=()=>u.get(),u}if(o?.source==="site_cookie"&&o.cookie){let u=o.cookie;e.getAnonymousId=()=>$(u)}if(!r)return null;let s=e.getAnonymousId,c=i();return e.getAnonymousId=()=>F(M(s,null))??c.get(),c}var ko=200;function Pn(e,t,n=()=>Date.now()){let r=()=>j(L("carried"),e),o=!1;function i(){try{let s=JSON.parse(sessionStorage.getItem(r())??"null");return!s||!(n()-s.savedAt<=xt)?[]:Array.isArray(s.calls)?s.calls:[]}catch{return[]}}return{take(){let s=i();try{sessionStorage.removeItem(r())}catch{}return s},save(s){try{return o||!t()?!1:(sessionStorage.setItem(r(),JSON.stringify({savedAt:n(),calls:[...i(),...s].slice(-ko)})),!0)}catch{return!1}},close(){o=!0}}}var Gi=ce.consent,He=Object.freeze({visitor:"visitor",host:"host"}),On=()=>({basis:He.host}),Ao="hp-consent",ue=["analytics","marketing","personalisation","ad_user_data","ad_personalization"],Ln={analytics:"a",marketing:"m",personalisation:"p",ad_user_data:"aud",ad_personalization:"adp"},X=()=>typeof window<"u",Tn=()=>X()&&typeof window.cookieStore?.addEventListener=="function",vo=e=>e===!0?!0:e===!1?!1:null;function Se(e){if(!e||typeof e!="object")return null;let t={};for(let n of ue)t[n]=vo(e[n]);return t}function At(e,t){return!e||!t?e===t:ue.every(n=>e[n]===t[n])}function vt(e){if(!e)return"";let t=[];for(let n of ue){let r=e[n];(r===!0||r===!1)&&t.push(`${Ln[n]}=${r?1:0}`)}return t.join("&")}function Et(e){return{[Ao]:vt(Se(e))}}function Ee(e){let t=Se({});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(Ln).map(([i,s])=>[s,i])),o=new Set;for(let i of n.split("&")){let s=i.indexOf("=");if(s<=0)continue;let c=r[i.slice(0,s).trim()],u={1:!0,0:!1}[i.slice(s+1).trim()]??null;!c||u===null||o.has(c)||(t[c]===null?t[c]=u:t[c]!==u&&(t[c]=null,o.add(c)))}return t}function Ct(e,t){if(!t)return e;let n=r=>{if(!r)return r;let o={...r};for(let i of ue)i!=="analytics"&&t[i]!==!0&&(o[i]=null);return o};return{name:e.name,basis:e.basis,read:()=>n(e.read()),subscribe:r=>e.subscribe(o=>r(n(o))),get observesChanges(){return e.observesChanges}}}function Pt(e,t={}){return{...e,ad_user_data:t.ad_user_data??e.marketing,ad_personalization:t.ad_personalization??e.marketing}}function qe(e,t){let n=!0;return{notify:()=>{if(n)try{let o=e();o&&t(o)}catch{}},stop:()=>n=!1}}var Eo={analytics:["analytics","measure_content_performance","audience_measurement"],marketing:["marketing","targeting","advertising","select_personalized_ads","create_ads_profile"],personalisation:["personalisation","personalization","select_personalized_content","create_content_profile"]};function Co(e,t){if(!t?.length)return null;let n=!1;for(let[r,o]of Object.entries(e)){let i=String(o?.id??r).toLowerCase();if(t.some(c=>{let u=String(c).toLowerCase();return i===u||i.startsWith(`${u}-`)})&&(n=!0,o?.enabled===!0))return!0}return n?!1:null}function Nn(e={}){let t={...Eo,...e.purposes};function n(){let r=X()?window.Didomi:void 0;if(!r?.getCurrentUserStatus||r.shouldUserStatusBeCollected?.()!==!1||r.isUserStatusPartial?.()===!0)return null;let o=r.getCurrentUserStatus()?.purposes;if(!o||typeof o!="object")return null;let i=s=>Co(o,t[s]);return Pt({analytics:i("analytics"),marketing:i("marketing"),personalisation:i("personalisation")},{ad_user_data:i("ad_user_data"),ad_personalization:i("ad_personalization")})}return{name:"didomi",read:n,observesChanges:!0,subscribe(r){if(!X())return()=>{};let o=qe(n,r),i={event:"consent.changed",listener:o.notify};return window.didomiEventListeners=window.didomiEventListeners||[],window.didomiEventListeners.push(i),window.didomiOnReady=window.didomiOnReady||[],window.didomiOnReady.push(s=>{o.notify(),(s??window.Didomi)?.on?.("consent.changed",o.notify)}),window.Didomi?.on?.("consent.changed",o.notify),o.stop}}}function kt(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 Rn(e={}){let t={analytics:"C0002",personalisation:"C0003",marketing:"C0004",...e.groups},n=e.impliedConsent===!0;function r(){let s=kt($("OptanonConsent"));if(s.groups){let d={};for(let f of s.groups.split(",")){let[p,g]=f.split(":");p?.trim()&&(d[p.trim()]=g==="1"?!0:g==="0"?!1:null)}return f=>d[f]??!1}let c=X()?window.OnetrustActiveGroups:void 0;if(typeof c!="string"||!c.length)return null;let u=new Set(c.split(",").map(d=>d.trim()).filter(Boolean));return d=>u.has(d)}function o(){if($("OptanonAlertBoxClosed"))return!0;try{if(X()&&window.OneTrust?.IsAlertBoxClosed?.()===!0)return!0}catch{}return Number.parseInt(kt($("OptanonConsent")).interactionCount,10)>0?!0:n&&X()&&(!!window.OneTrust||typeof window.OnetrustActiveGroups=="string")}function i(){if(!o())return null;let s=r();if(!s)return null;let c=p=>t[p]?s(t[p]):null,u=Pt({analytics:c("analytics"),marketing:c("marketing"),personalisation:c("personalisation")},{ad_user_data:c("ad_user_data"),ad_personalization:c("ad_personalization")}),d=kt($("OptanonConsent"));return(typeof navigator<"u"&&navigator.globalPrivacyControl===!0||d.isGpcEnabled==="1")&&(u.marketing=!1,u.ad_user_data=!1,u.ad_personalization=!1),u}return{name:"onetrust",read:i,observesChanges:!0,subscribe(s){if(!X())return()=>{};let c=qe(i,s),u=!1,d=()=>{u||!window.OneTrust?.OnConsentChanged||(u=!0,window.OneTrust.OnConsentChanged(c.notify))};window.addEventListener("OneTrustGroupsUpdated",c.notify);let f=window.OptanonWrapper;return window.OptanonWrapper=function(...g){try{typeof f=="function"&&f.apply(this,g)}finally{d(),c.notify()}},d(),()=>{c.stop(),window.removeEventListener("OneTrustGroupsUpdated",c.notify)}}}}function Po(e){let t=String(e).split(",").map(n=>n.trim()).filter(Boolean);return t.length?new Set(t):null}function Mn(e){let{name:t,categories:n,parse:r=Po,refusedValue:o,source:i="native",changeEvent:s="thg_hp_consent_change"}=e??{};if(typeof t!="string"||t==="")throw new Error("cookieConsent: `name` (the cookie your banner writes) is required");if(!n||typeof n.analytics!="string")throw new Error("cookieConsent: `categories.analytics` (the category id that grants analytics) is required");function c(){let u=$(t);if(u==null)return null;let d;if(o!==void 0&&u===o)d=new Set;else try{d=r(u)}catch{d=null}if(!(d instanceof Set))return null;let f=p=>n[p]?d.has(n[p]):null;return Pt({analytics:f("analytics"),marketing:f("marketing"),personalisation:f("personalisation")},{ad_user_data:f("ad_user_data"),ad_personalization:f("ad_personalization")})}return{name:i,read:c,get observesChanges(){return Tn()},subscribe(u){if(!X())return()=>{};let d=qe(c,u),f=p=>{[...p.changed??[],...p.deleted??[]].some(_=>_?.name===t)&&d.notify()};return window.addEventListener(s,d.notify),window.cookieStore?.addEventListener?.("change",f),()=>{d.stop(),window.removeEventListener(s,d.notify),window.cookieStore?.removeEventListener?.("change",f)}}}}function Dn(e={}){let t=e.name??L("consent"),n=()=>{let r=$(t);if(r==null)return null;let o=Ee(r);return o.analytics==null?null:o};return{name:"forwarded",read:n,get observesChanges(){return Tn()},subscribe(r){if(!X())return()=>{};let o=qe(n,r),i=s=>{[...s.changed??[],...s.deleted??[]].some(u=>u?.name===t)&&o.notify()};return window.cookieStore?.addEventListener?.("change",i),()=>{o.stop(),window.cookieStore?.removeEventListener?.("change",i)}}}}function Un(e){let t=Se(e);return{name:"static",basis:He.host,read:()=>t?{...t}:null,observesChanges:!0,subscribe:()=>()=>{}}}function $n(e){if(e==null)return null;let t=String(e).split("/").map(n=>n.trim()).filter(Boolean).join("/");return t===""?null:t}function Oo(e){let t=e.item_category;if(t!=null&&String(t).includes("/"))return $n(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 $n(n.join("/"))}var Lo=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t};function To(...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 Fe=e=>To(e.item_group_id,e.item_id);function No(e,t=Fe){if(!e)return null;let n=c=>c==null||c===""||Number.isNaN(Number(c))?null:Number(c),r=c=>{let u=n(c);return u==null?null:Math.round(u*1e6)/1e6},o=c=>{let u=r(c);return u!=null&&u>=0?u:null},i=c=>{let u=n(c);return Number.isInteger(u)&&u>=0?u:null},s=Lo;return{product_id:s(t(e)),sku:s(e.item_id),name:s(e.item_name),brand:s(e.item_brand),variant:s(e.item_variant)??s(e.variant),category:Oo(e),price:r(e.price),discount:o(e.discount),quantity:i(e.quantity),coupon:s(e.coupon),position:i(e.index)!=null?i(e.index)+1:null,url:s(e.url)??s(e.item_url)??null,image_url:s(e.image_url)??s(e.image_link)??null,displayed_sku:s(e.displayed_sku)??s(e.displayed_variant_sku)}}function Ot(e,t=Fe){return(e??[]).map(n=>No(n,t)).filter(n=>n?.product_id)}var Ro=1e3,Mo={shipping:2,payment:3},Do=new Set(["password","google","apple","facebook","magic_link","sso","passkey","other"]),V=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t},Uo=e=>{if(e==null||e===""||typeof e=="object")return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null},Ke=e=>e!==null&&typeof e=="object";function $o(e){return Array.isArray(e.items)?e.items.filter(Ke):null}function Vn(e){let t=V(e)?.toLowerCase().replace(/[\s-]+/g,"_");return t?Do.has(t)?t:t==="email"||t==="email_password"?"password":"other":null}function Vo({ecommerce:e,items:t}){let n=i=>({promotion_id:V(i.promotion_id),name:V(i.promotion_name),creative:V(i.creative_name),position:V(i.creative_slot)}),r=new Set,o=[];for(let i of[n(e),...t.map(n)])!i.promotion_id||r.has(i.promotion_id)||(r.add(i.promotion_id),o.push(i));return o}var Bn=({ecommerce:e,items:t})=>V(e.item_list_id)??V(e.item_list_name)??V(t[0]?.item_list_id)??V(t[0]?.item_list_name),le=(e,t)=>t.products?.length?{event:e,properties:t}:null,Bo=new Set(["product","products","item","items"]);function jo({ecommerce:e}){let t=V(e.item_id),n=V(e.content_type)?.toLowerCase();return!t||n&&!Bo.has(n)?null:{event:"Product Shared",properties:{share_via:V(e.method),products:[{product_id:t}]}}}function Ho(e){let t=o=>le("Product List Viewed",{list_id:Bn(o),products:o.products}),n=o=>{let i=V(o.ecommerce.search_term);return i?{event:"Products Searched",properties:{query:i,...o.products.length?{products:o.products}:{}}}:null},r=o=>i=>i.promotions.map(s=>({event:o,properties:s}));return{view_item:o=>le("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=>le("Product Clicked",{list_id:Bn(o),products:o.products.slice(0,1)}),add_to_cart:o=>le("Product Added",{cart_id:V(o.ecommerce.cart_id),products:o.products}),remove_from_cart:o=>le("Product Removed",{cart_id:V(o.ecommerce.cart_id),products:o.products}),view_cart:o=>({event:"Cart Viewed",properties:{cart_id:V(o.ecommerce.cart_id),value:o.value,currency:o.currency,coupon:V(o.ecommerce.coupon),...o.itemsListed?{products:o.products}:{}}}),begin_checkout:o=>le("Checkout Started",{value:o.value,currency:o.currency,coupon:V(o.ecommerce.coupon),products:o.products}),add_shipping_info:o=>({event:"Checkout Step Completed",properties:{step:e.shipping,step_name:"shipping",shipping_method:V(o.ecommerce.shipping_tier)}}),add_payment_info:o=>({event:"Payment Info Entered",properties:{step:e.payment,step_name:"payment",payment_method:V(o.ecommerce.payment_type)}}),view_promotion:r("Promotion Viewed"),select_promotion:r("Promotion Clicked"),add_to_wishlist:o=>le("Product Added to Wishlist",{products:o.products}),share:jo,login:o=>({event:"Signed In",properties:{method:Vn(o.ecommerce.method)}}),sign_up:o=>({event:"Signed Up",properties:{method:Vn(o.ecommerce.method)}})}}var qo=e=>e.event;function Fo(e,t){if(!Ke(e))return null;if(typeof e.length=="number"&&e[0]==="event"&&typeof e[1]=="string"){let r=Ke(e[2])?e[2]:{};return{name:e[1],entry:r,ecommerce:r}}let n=V(t(e));return n?{name:n,entry:e,ecommerce:Ke(e.ecommerce)?e.ecommerce:e}:null}function Lt(e){return Array.isArray(e)?`[${e.map(Lt).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Lt(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function jn(e,t={}){if(!e||typeof e.track!="function")throw new Error("connectDataLayer: analytics must have a track(event, properties, options) method");let n=t.dataLayer??(typeof window<"u"?window.dataLayer=window.dataLayer||[]:null);if(!Array.isArray(n))return()=>{};let r=Ho({...Mo,...t.steps}),o=t.map??{},i=t.eventName??qo,s=t.productId??Fe,c=new Set(["purchase","refund",...t.ignore??[]]),u=t.dedupeMs??Ro,d=new Map,f=!0;function p(w,h,S){if(u<=0)return!1;let T=`${w}|${S??""}|${Lt(h)}`,D=Date.now();for(let[K,G]of d)D-G>u&&d.delete(K);return d.has(T)?!0:(d.set(T,D),!1)}let g=null,_=new Set;function y(w,h){if(w!=="Product Viewed")return!1;let S=typeof location>"u"?"":location.pathname;S!==g&&(g=S,_.clear());let T=h.products?.[0]?.product_id;return T?_.has(T)?!0:(_.add(T),!1):!1}function b({event:w,properties:h={}},S){if(!w||p(w,h,S)||y(w,h))return;let T=S?{context:{currency:S}}:void 0;if(w==="Signed Out"&&typeof e.signedOut=="function"){e.signedOut(T);return}e.track(w,h,T)}function v(w){let h=t.transform?t.transform(w):w,S=Fo(h,i);if(!S||c.has(S.name))return;let T=Object.hasOwn(o,S.name),D=T?o[S.name]:r[S.name];if(typeof D!="function")return;let K=$o(S.ecommerce),G=K??[],B={...S,items:G,itemsListed:K!==null,products:Ot(G,s),currency:St(S.ecommerce.currency),value:Uo(S.ecommerce.value)};B.promotions=Vo(B);let xe=T?D(h,{...B,toProducts:W=>Ot(W,s)}):D(B);for(let W of[xe].flat())W&&b(W,B.currency)}function A(w){if(f)try{v(w)}catch(h){try{t.onError?.(h,w)}catch{}}}for(let w of n.slice())A(w);let m=n.push;function E(...w){let h=m.apply(this,w);for(let S of w)A(S);return h}return n.push=E,()=>{f=!1,n.push===E&&(n.push=m)}}var Ko="hp_debug",zo=256;function Go(){try{return new URLSearchParams(location.search).get(Ko)}catch{return null}}function Hn(e,t){if(typeof location>"u")return!1;try{let n=Go();if(n!==null){let o=n.trim();o===""||o.length>zo?sessionStorage.removeItem(t):sessionStorage.setItem(t,o)}let r=sessionStorage.getItem(t);return!!(e&&r&&un(r)===e)}catch{return!1}}var _e=class extends Error{},Wo={inHoldout:()=>!0,personalisationGroup:()=>"excluded",servingHeaders:()=>({}),recommendationContext:()=>({}),flush:()=>Promise.resolve(),reset:()=>{}};function Tt(e,t){let n=Wo[e]??(()=>null),r=o=>(console.warn(`[hp] ${String(e)} failed; nothing was sent`,o),n());return function(...i){try{let s=t.apply(this,i);return typeof s?.then=="function"?Promise.resolve(s).catch(r):s}catch(s){if(s instanceof _e)throw s;return r(s)}}}function qn(e){for(let t of Reflect.ownKeys(e)){let{value:n}=Object.getOwnPropertyDescriptor(e,t)??{};typeof n=="function"&&(e[t]=Tt(t,n))}return e}var Ce=Symbol("hp.identityOption");var Jo=4320*60*60,Yo=100,Xo=1e3,Zo=2e3,Fn=500,ze=e=>(e?.unref?.(),e);function Qo(e,t){if(t?.analytics===!0&&e.analytics===!1)return"withdrawn";let n=ue.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 es(e,t,n=L("consent")){if(!(typeof document>"u"))try{let r=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",o=t?`; Domain=${t}`:"";document.cookie=`${n}=${vt(e)}; Path=/; Max-Age=${Jo}; SameSite=Lax`+o+r}catch{}}function ts(e){let t=Ee($(e));return ue.some(n=>t[n]!==null)?t:null}function Kn(e){let{adapter:t,timeoutMs:n=5e3,cookieDomain:r=null,cookieName:o=L("consent"),release:i,announce:s}=e,c=e.discard??(()=>{}),u="pending",d=null,f=null,p=null,g=null,_=!1,y=null,b=[],v=N=>{u=N,e.onStatus?.(N)};function A(){try{return Se(t.read())}catch{return null}}function m(){f&&clearInterval(f),p&&clearTimeout(p),f=null,p=null}let E=()=>typeof window<"u"&&typeof document<"u",w=()=>{try{return typeof t.subscribe=="function"&&t.observesChanges===!0}catch{return!1}};function h(){g&&clearInterval(g),g=null}function S(){_||g||d===null||w()||E()&&document.visibilityState==="hidden"||(g=ze(setInterval(()=>B(A()),Zo)))}let T=()=>u==="pending"||u==="unknown",D=e.store??null,K=()=>{let N=b.splice(0);D?.write([]);for(let H of N)i(H)},G=()=>{let N=b.splice(0);D?.write([]);for(let H of N)c(H)};function B(N){let H=Se(N);if(!H||H.analytics===null)return;let ge=d===null,Z=ge?ts(o):d;if(!ge&&At(Z,H))return;m(),d=H,S(),es(H,r,o);let k=!At(Z,H);if(H.analytics){v("granted"),K(),k&&s({action:Qo(H,Z),state:H,previous:Z,withdrawal:!1});return}G(),Z?.analytics===!0&&s({action:"withdrawn",state:H,previous:Z,withdrawal:!0}),v("denied")}function xe(){p=null,u==="pending"&&(v("unknown"),f&&clearInterval(f),f=ze(setInterval(()=>B(A()),Xo)))}function W(N){if(T()){if(D){D.write(b);return}N?.type!=="visibilitychange"&&!N?.persisted&&G()}}let oe=N=>{document.visibilityState==="hidden"?(h(),W(N)):S()},ke=N=>{h(),W(N)},he=N=>{N?.persisted&&d!==null&&B(A()),S()};return{get status(){return u},get state(){return d?{...d}:null},stamp(){return d?{...d,source:t.name??null,basis:t.basis??He.visitor}:null},admits(){return u==="granted"},hold(N){return!T()||b.length>=Fn?(c(N),!1):(b.push(N),!0)},onHidden:W,start(){_=!1;try{y=t.subscribe?.(N=>B(N))??null}catch(N){e.debug&&console.warn("[hp] consent adapter subscribe failed",N)}E()&&(window.addEventListener("pagehide",ke),window.addEventListener("pageshow",he),document.addEventListener("visibilitychange",oe)),D&&b.length===0&&b.push(...D.read().slice(-Fn)),B(A()),!d&&(f=ze(setInterval(()=>B(A()),Yo)),p=ze(setTimeout(xe,n)))},stop(){_=!0,m(),h(),typeof y=="function"&&y(),E()&&(window.removeEventListener("pagehide",ke),window.removeEventListener("pageshow",he),document.removeEventListener("visibilitychange",oe))}}}var ns=["recommendation","search_rank","banner","offer","layout","copy","price","other"],Ge=e=>typeof e=="string"&&e!=="";function zn(e){return(Array.isArray(e?.decisions)?e.decisions:[]).filter(t=>Ge(t?.slot)&&Ge(t.decision_id)&&t.holdout!==!0).map(({decision_id:t,slot:n,arm:r,kind:o})=>({decision_id:t,slot:n,...Ge(r)&&{arm:r},...ns.includes(o)&&{kind:o}}))}function Gn({key:e,mayStore:t}){let n,r=()=>{if(n)return n;try{let i=JSON.parse(sessionStorage.getItem(e));n=Array.isArray(i)?i.filter(s=>Ge(s?.slot)):[]}catch{n=[]}return n},o=()=>{try{n?.length&&t()&&sessionStorage.setItem(e,JSON.stringify(n))}catch{}};return{persist:o,current:()=>r().length?n.map(i=>({...i})):null,remember(i){if(!i.length)return;let s=new Set(i.map(c=>c.slot));n=[...r().filter(c=>!s.has(c.slot)),...i],o()},forget(){n=[];try{sessionStorage.removeItem(e)}catch{}}}}function rs(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 We(e,t,n=1e4){return rs(`${t}\0${e}`)%n}function Nt(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 Rt(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}=Nt(e),i=We(t,e.salt),s=u=>Math.round(u*1e4),c=r>0&&i<s(r)?"holdout":!n||i<s(r+o)?"personalised":"excluded";return{holdout:c==="holdout",bucket:i,group:c}}function Wn(e,t){return typeof e!="string"||e===""||t==null||t===""?null:We(t,`bandit-vs-default:${e}`)<1e4/2?"default":"bandit"}var os="hp_preview",ss=256;function Jn(e,t=null){if(typeof location>"u")return $(e);let n=null;try{n=new URLSearchParams(location.search).get(os)}catch{n=null}if(n===null)return $(e);let r=n.trim();return r===""||r.length>ss?(te(e,"",0,t),null):(te(e,r,null,t),r)}var is=40,as=128,cs=5,us=60,Xn=e=>typeof e=="string"&&e!==""&&e.length<=as&&!e.includes(","),Yn=e=>Array.isArray(e)?e.filter(Xn).slice(0,is):[],ls=e=>Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.replaceAll(","," ").trim()).filter(t=>t!=="").slice(0,cs):[],ds=e=>Object.entries(e&&typeof e=="object"?e:{}).filter(([t,n])=>Xn(t)&&Number.isFinite(n)&&n>=1).sort(([,t],[,n])=>n-t).slice(0,us).map(([t,n])=>`${t}:${Math.floor(n)}`);function Mt(e){let t={},n={viewed:Yn(e?.recentProducts),basket:Yn(e?.basketProducts),q:ls(e?.recentSearches),impressed:ds(e?.impressions)};for(let[r,o]of Object.entries(n))o.length>0&&(t[r]=o.join(","));return t}var fs=1800*1e3;function Zn(e,t=Date.now()){try{localStorage.setItem(L("recommendationContext"),JSON.stringify({context:e,until:t+fs}))}catch{}}function Qn(){try{localStorage.removeItem(L("recommendationContext"))}catch{}}var ps="hp_sample",er=1e4;function tr(e,t){return!(typeof t=="number"&&t<1)||e==null||e===""?!0:We(e,ps,er)<Math.round(t*er)}function be(e){return e.trim().toLowerCase().replace(/\s*\/\s*/g,"/").replace(/^\/+|\/+$/g,"")}var ms=2,hs=12;function Pe(e,t=ms){return e.split("/").slice(0,t).join("/")}function Dt(e,t){if(typeof t!="string"||!t.trim())return null;let n=Pe(be(t));return n?(e.unshift(n),e.length=Math.min(e.length,hs),n):null}var de=()=>L("sessionSignals"),Ie=null,Ut=()=>Ie??de();function nr(){try{return Ie?localStorage:sessionStorage}catch{return}}function rr(e,t){let n=t==null?null:String(t),r=e?j(de(),n,e):null;if(r===Ie)return;let o=Ie===null?gs():null;if(Ie=r,!!Ie)try{let i=Ut(),s=vn(de(),n);for(let c of Object.keys(localStorage))c.startsWith(s)&&c!==i&&localStorage.removeItem(c);o&&!localStorage.getItem(i)&&(localStorage.setItem(i,JSON.stringify(o)),sessionStorage.removeItem(de()))}catch{}}function gs(){try{let e=sessionStorage.getItem(de());if(!e)return null;let t=JSON.parse(e);return t&&(t.productViews>0||t.listViews>0||t.basketValue!=null||t.recentProducts?.length||t.recentBrowse?.length)?t:null}catch{return null}}function Je(){return{productViews:0,listViews:0,cartAdds:0,searches:0,recentProducts:[],recentCategories:[],recentBrowse:[],basketProducts:[],basketValue:null,recentSearches:[],impressions:{},browsingCategory:null,recentBrowseCategories:[],browsingListing:null,listViewsByCategory:{},startedAt:0}}function $t(){let e=nr();if(!e)return Je();try{let t=e.getItem(Ut());return t?{...Je(),...JSON.parse(t)}:{...Je(),startedAt:Date.now()}}catch{return{...Je(),startedAt:Date.now()}}}function Vt(e){let t=nr();if(t)try{t.setItem(Ut(),JSON.stringify(e))}catch{}}function Bt(){return $t()}function or(){for(let e of[()=>sessionStorage,()=>localStorage])try{let t=e();t.removeItem(de());for(let n of Object.keys(t))n.startsWith(`${de()}:`)&&t.removeItem(n)}catch{}}var sr=20,ir=200,ys=new Set(["Product Viewed","Product Clicked","Product Added","Product Added to Wishlist"]),ws=new Set(["Product Viewed","Product Added"]),ar=50;function Ye(e,t){let n=Dt(e.recentBrowse,t);return n?(e.recentBrowseCategories=[e.browsingListing?.category??null,...e.recentBrowseCategories].slice(0,e.recentBrowse.length),n):null}function Ss(e,t){let n=e.listViewsByCategory;n[t]=(n[t]??0)+1;let r=Object.keys(n);if(r.length>ar){let o={};for(let i of r.sort((s,c)=>n[c]-n[s]).slice(0,ar))o[i]=n[i];e.listViewsByCategory=o}}function cr(e,t){let n=$t();n.startedAt||(n.startedAt=Date.now());let r=Array.isArray(t?.products)?t.products:[];switch(e){case"Product Viewed":n.productViews+=1,Ye(n,n.browsingCategory);break;case"Product List Viewed":{let s=t?.list_id,c=t?.category;if(!(typeof s=="string"&&s.includes("/")&&!s.startsWith("cdp-")))break;let d=typeof c=="string"&&Pe(be(c))||null,f=d?Pe(be(s)):"";if(!f){n.browsingCategory=null,n.browsingListing=null;break}n.browsingListing={key:f,category:d},Ye(n,f),n.browsingCategory=f,Ss(n,d),n.listViews+=1}break;case"Product List Filtered":{let s=t?.change,c=typeof t?.list_id=="string"?t.list_id:"",u=typeof s?.value=="string"?s.value:"",d=n.browsingListing;if(u&&s?.action!=="removed"&&d&&Pe(be(c))===d.key){let f=Ye(n,`${c}/${u}`);f&&(n.browsingCategory=f)}break}case"Product Added":{n.cartAdds+=1,Ye(n,n.browsingCategory);for(let s of r){let c=s.product_id;typeof c!="string"||!c||(n.basketProducts=[c,...n.basketProducts.filter(u=>u!==c)].slice(0,sr))}break}case"Product Removed":{for(let s of r){let c=s.product_id;typeof c=="string"&&c&&(n.basketProducts=n.basketProducts.filter(u=>u!==c))}break}case"Products Searched":{n.searches+=1;let s=t?.query;if(typeof s=="string"&&s.trim()){let c=s.trim().toLowerCase().slice(0,64);n.recentSearches=[c,...n.recentSearches.filter(u=>u!==c)].slice(0,5)}break}case"Product Clicked":case"Product Added to Wishlist":break;case"Cart Updated":{let s=t?.value;return n.basketValue=typeof s=="number"&&Number.isFinite(s)&&s>=0?s:null,Vt(n),n}default:return n}let o=ys.has(e);if(o)for(let s of r)typeof s.product_id=="string"&&s.product_id&&delete n.impressions[s.product_id];else{for(let c of r){let u=c.product_id;typeof u!="string"||!u||(n.impressions[u]=(n.impressions[u]??0)+1)}let s=Object.keys(n.impressions);if(s.length>ir){let c={};for(let u of s.sort((d,f)=>n.impressions[f]-n.impressions[d]).slice(0,ir))c[u]=n.impressions[u];n.impressions=c}}let i=new Set;for(let s of r){let c=s.product_id;if(o&&typeof c=="string"&&c&&(n.recentProducts=[c,...n.recentProducts.filter(u=>u!==c)].slice(0,sr)),ws.has(e)&&typeof s.category=="string"&&s.category){let u=be(s.category);u&&!i.has(u)&&(i.add(u),Dt(n.recentCategories,u))}}return Vt(n),n}var ur=1800*1e3;function lr({name:e,domain:t=null,mayStore:n,now:r=()=>Date.now(),mint:o=ee}){let i=null,s=0,c=()=>{i!==null&&n()&&te(e,i,ur/1e3,t)};return{get(){let u=r(),d=$(e);return d?i=d:(i===null||u-s>=ur)&&(i=o()),s=u,c(),i},persist:c,forget(){te(e,"",0,t),i=null}}}var z=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),dr=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),fr=Object.freeze({enabled:!1}),Ht=Object.freeze({enabled:!0,queryParamAllowlist:Object.freeze([])});function pr(e,t){let n=e?.track;return z(n)?(Object.hasOwn(n,t)?n[t]:n.__default)?.enabled!==!1:!0}function _s(e,t){return`${ne(e)}/v1/projects/${encodeURIComponent(t)}/settings`}var bs="https://hp.thgingenuity.com";function ne(e){return e==null||e===""?bs:hr(e)}function mr(e,t){return e!=null&&e!==""?ne(e):t?.startsWith("https://")?t:ne(void 0)}function hr(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 Is(e){if(!z(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>typeof n=="boolean"));return Object.keys(t).length?t:null}var jt=e=>typeof e=="number"&&e>=0&&e<=1,xs=/^[0-9a-f]{64}$/;function ks(e){return z(e)?{enabled:e.enabled===!0,tokenSha256:typeof e.tokenSha256=="string"&&xs.test(e.tokenSha256)?e.tokenSha256:null}:{enabled:!1,tokenSha256:null}}function As(e){if(!z(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>z(n)&&jt(n.share)&&(n.ramp==null||jt(n.ramp))&&typeof n.salt=="string"&&n.salt!=="").map(([n,r])=>[n,{share:r.share,ramp:r.ramp??null,salt:r.salt,...dr(r.readoutSlots)&&r.readoutSlots.length>0&&{readoutSlots:r.readoutSlots}}]));return Object.keys(t).length?t:null}var vs=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;function Es(e){return z(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"&&vs.test(e.cookie)?{source:"site_cookie",cookie:e.cookie}:null:null}function Cs(e){let t=Array.isArray(e?.forms)?e.forms.filter(z):[];return t.length===0?null:{forms:t,capture:z(e.capture)?e.capture:null,...Number.isInteger(e.overlay_gap_minutes)?{overlay_gap_minutes:e.overlay_gap_minutes}:{}}}function Ps(e){let t=z(e)?e.hp:null;return z(t)&&typeof t.enabled=="boolean"}function qt(e){let t=z(e)?e.hp:null;if(!z(t)||t.enabled!==!0)return fr;let n=Cs(t.onsite);return{enabled:!0,propertyId:typeof t.propertyId=="string"&&t.propertyId!==""?t.propertyId:null,environment:typeof t.environment=="string"?t.environment:null,consentPurposes:Is(t.consent?.purposes),queryParamAllowlist:dr(t.queryParamAllowlist)?t.queryParamAllowlist:null,anonymousId:Es(t.anonymousId),apiHost:hr(t.apiHost),holdouts:As(t.holdouts),sampleRate:jt(t.sampleRate)?t.sampleRate:1,debug:ks(t.debug),...n&&{onsite:n},plan:z(e.plan)&&z(e.plan.track)?{track:e.plan.track}:null}}var Os=3e3;async function gr(e,t,n=globalThis.fetch,r=Os){try{let o=await n(_s(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 fr;if(!o.ok)return null;let i=await o.json();return Ps(i)?qt(i):null}catch{return null}}var Xe=e=>j(L("settings"),e);function yr(e){try{let t=localStorage.getItem(Xe(e));if(!t)return null;let n=JSON.parse(t);return n?.enabled===!0?n:null}catch{return null}}function wr(e,t){try{t?.enabled===!0?localStorage.setItem(Xe(e),JSON.stringify(t)):localStorage.removeItem(Xe(e))}catch{}}function Ft(e){try{localStorage.removeItem(Xe(e))}catch{}}var Ls={flushAt:20,flushIntervalMs:1e4,maxQueue:500,maxRetryAgeMs:1440*60*1e3,maxRetries:5,maxPersistedBatches:20,maxPersistedBytes:1024*1024,storageKey:ce.retry,beaconSafeBytes:56*1024,maxBatchEvents:100,maxBatchBytes:500*1024},Ze=()=>Date.now(),Sr=3e4,Yt=55*1024;function Ts(e,t=Ze()){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 re=e=>typeof TextEncoder<"u"?new TextEncoder().encode(e).length:Buffer.byteLength(e),Kt=()=>typeof window<"u"&&typeof document<"u";function Ns(){try{return!Kt()||!window.localStorage?null:(window.localStorage.getItem("thg_hp_probe"),window.localStorage)}catch{return null}}var I,zt,Gt,Qe,Wt,Jt,_r,Oe,Le,Te,br,et,Ir,tt,nt=class{constructor(t){an(this,I);this.o={...Ls,...t},this.queue=[],this.timer=null,this.storage=Ns(),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,Kt()&&(window.addEventListener("pagehide",()=>this.flush({beacon:!0})),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()}),O(this,I,tt).call(this))}markFailing(){this.answered||(this.failing=!0)}replayPersisted(){return this.replayAllowed=!0,O(this,I,tt).call(this)}clearPersisted(){if(this.replayAllowed=!1,!!this.storage)try{let t=O(this,I,Te).call(this).filter(n=>this.sinceRefusal.has(n?.id));t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey)}catch{}}discardQueued(){this.queue=[],this.epoch+=1,this.sinceRefusal.clear(),O(this,I,Gt).call(this);for(let t of this.wakers)t()}enqueue(t){let n;try{n=JSON.parse(JSON.stringify(t))}catch(r){this.o.onError?.(`event ${t?.messageId??""} cannot be serialised; dropped`,r);return}this.queue.push(n),this.queue.length>this.o.maxQueue&&this.queue.splice(0,this.queue.length-this.o.maxQueue),this.queue.length>=this.o.flushAt?this.flush():O(this,I,zt).call(this)}flush(t={}){if(O(this,I,Gt).call(this),this.queue.length===0)return Promise.resolve();if(t.beacon&&Kt()&&typeof navigator<"u"&&navigator.sendBeacon)return O(this,I,_r).call(this),Promise.resolve();if(this.inflight)return this.inflight;let n=O(this,I,Jt).call(this,this.queue,this.o.maxBatchEvents,this.o.maxBatchBytes).map(o=>{let i=O(this,I,et).call(this,o);return i&&(this.sending.add(i),this.sinceRefusal.add(i)),{batch:o,id:i}});this.queue=[];let r=this.epoch;return this.inflight=(async()=>{for(let{batch:o,id:i}of n){if(r!==this.epoch){O(this,I,Le).call(this,i);continue}await O(this,I,Oe).call(this,o,0,i,r)}})().finally(()=>{this.inflight=null,this.queue.length>=this.o.flushAt?this.flush():this.queue.length&&O(this,I,zt).call(this)}),this.inflight}};I=new WeakSet,zt=function(){this.timer||(this.timer=setTimeout(()=>this.flush(),this.o.flushIntervalMs),this.timer?.unref?.())},Gt=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},Qe=function(t){return JSON.stringify({batch:t,writeKey:this.o.writeKey,sentAt:new Date().toISOString()})},Wt=function(){return`${this.o.apiHost.replace(/\/$/,"")}/v1/batch`},Jt=function(t,n,r){let o=re(O(this,I,Qe).call(this,[])),i=[],s=[],c=o;for(let u of t){let d=re(JSON.stringify(u))+1;s.length&&(s.length>=n||c+d>r)&&(i.push(s),s=[],c=o),s.push(u),c+=d}return s.length&&i.push(s),i},_r=function(){let t=this.queue;this.queue=[];let n=O(this,I,Wt).call(this);for(let r of O(this,I,Jt).call(this,t,this.o.maxBatchEvents,this.o.beaconSafeBytes)){let o=O(this,I,Qe).call(this,r);if(re(o)<=this.o.beaconSafeBytes){let i=!1;try{i=navigator.sendBeacon(n,new Blob([o],{type:"text/plain"}))}catch{i=!1}if(i){let s=this.failing?O(this,I,et).call(this,r):null;s&&this.sending.add(s);continue}}O(this,I,Oe).call(this,r,0,O(this,I,et).call(this,r))}},Oe=async function(t,n,r=null,o=this.epoch){r&&this.sending.add(r);let i=O(this,I,Qe).call(this,t),s=0;try{let c=await fetch(O(this,I,Wt).call(this),{method:"POST",headers:{"Content-Type":"text/plain"},body:i,keepalive:re(i)<=this.o.beaconSafeBytes});if(c.ok)return this.failing=!1,this.answered=!0,O(this,I,Le).call(this,r),O(this,I,tt).call(this),!0;let u=c.status===408||c.status===429||c.status>=500;if(u&&(s=Ts(c.headers?.get?.("retry-after"))),!u)return O(this,I,Le).call(this,r),this.o.onError?.(`CDP ingest rejected batch (${c.status}); dropping ${t.length} events`),!0;throw new Error(`retryable ${c.status}`)}catch(c){if(this.failing=!0,n>=this.o.maxRetries){r&&this.sending.delete(r);let d=r?"kept for the next page":"dropped";return this.o.onError?.(`CDP ingest unreachable after ${n} attempts; ${d}: ${t.length} events`,c),!1}let u=Math.max(Math.min(1e3*2**n,Sr)*(.5+Math.random()),Math.min(s,Sr));return o===this.epoch&&await new Promise(d=>{let f=()=>{clearTimeout(p),this.wakers.delete(f),d()},p=setTimeout(f,u);this.wakers.add(f)}),o!==this.epoch?(O(this,I,Le).call(this,r),!1):O(this,I,Oe).call(this,t,n+1,r,o)}},Le=function(t){t&&(this.sending.delete(t),this.sinceRefusal.delete(t),O(this,I,Ir).call(this,t))},Te=function(){let t=JSON.parse(this.storage.getItem(this.o.storageKey)||"[]");return Array.isArray(t)?t:[]},br=function(t,n){let r=s=>re(JSON.stringify(s))+1,o=[...t,n].slice(-this.o.maxPersistedBatches),i=o.reduce((s,c)=>s+r(c),2);for(;o.length>1&&i>this.o.maxPersistedBytes;)i-=r(o[0]),o=o.slice(1);for(;o.length;)try{return this.storage.setItem(this.o.storageKey,JSON.stringify(o)),!0}catch{o=o.slice(1)}return!1},et=function(t){if(!this.storage||this.o.mayPersist&&!this.o.mayPersist())return null;try{let n={at:Ze(),id:`${Ze()}-${Math.random().toString(36).slice(2)}`,batch:t};return re(JSON.stringify(n))+3>this.o.maxPersistedBytes?null:O(this,I,br).call(this,O(this,I,Te).call(this),n)?n.id:null}catch{return null}},Ir=function(t){if(!(!t||!this.storage))try{let n=O(this,I,Te).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{}},tt=function(){if(!this.storage||!this.replayAllowed)return this.draining??Promise.resolve();if(this.draining)return this.draining;let t;try{let r=O(this,I,Te).call(this);t=r.filter(o=>Array.isArray(o?.batch)&&Ze()-o.at<this.o.maxRetryAgeMs).map(o=>o.id?o:{...o,id:`${o.at}-${Math.random().toString(36).slice(2)}`}),(t.length!==r.length||t.some((o,i)=>o!==r[i]))&&(t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey))}catch{return Promise.resolve()}let n=t.filter(r=>!this.sending.has(r.id));return n.length?(this.draining=(async()=>{for(let r of n)if(!this.replayAllowed||!await O(this,I,Oe).call(this,r.batch,0,r.id))return})().finally(()=>{this.draining=null}),this.draining):Promise.resolve()};var xr="3.25.0",kr="@thg-agentic/hyper-personalisation-web";var Rs=new Set(["audiences","decisions","recommendations"]);var Ms=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),Ds=Symbol.for("@thg-agentic/hyper-personalisation-web.unreachable"),Us=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite-access");function $s(e){let t={...e??{}},n=Array.isArray(t.products)?t.products:null;if(t.item_count==null&&n){let r=n.map(o=>o?.quantity);r.every(Number.isInteger)&&(t.item_count=r.reduce((o,i)=>o+i,0))}return t}var Vs="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";function Bs(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 rt(e){if(typeof e!="string")return null;let t=Bs(e.trim());return t===Vs?null:t}var Ar=Object.freeze({email_sha256:"sha256",phone_sha256:"sha256",accepts_marketing:"boolean",gender:"string",created_at:"date-time"}),js=/^\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 Hs(e){if(typeof e!="string"||!js.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 qs(e,t){return t===null?null:e==="sha256"?rt(t)??void 0:e==="date-time"?t instanceof Date?Number.isNaN(t.getTime())?void 0:t.toISOString():Hs(t)?t:void 0:typeof t===e?t:void 0}function Fs(e,t){let n={},r=[];for(let[o,i]of Object.entries(e)){let s=Object.hasOwn(Ar,o)?Ar[o]:null,c=s?qs(s,i):void 0;c===void 0?r.push(o):n[o]=c}return t&&r.length&&console.warn(`[hp] identify: not sent, not spec traits: ${r.join(", ")}`),n}var vr=!1,Er=!1;function Ks(){Er||(Er=!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 zs(e){!e||vr||(vr=!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 Gs(e){try{return re(JSON.stringify(e))}catch{return 0}}function Cr(e){return e&&typeof e.context=="object"&&e.context!==null?e.context:e}function Ws(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,i]of n)try{let s=globalThis[r],c=j(L(o),e),u=s?.getItem(c);if(!u)continue;let d=j(L(o),t),f=s.getItem(d);s.setItem(d,JSON.stringify(i(JSON.parse(u),f?JSON.parse(f):null))),s.removeItem(c)}catch{}}function Pr(e){let t=ne(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:kr,libraryVersion:xr,writeKey:"web",queryParamBlocklist:[],debug:!1,validate:null,consentTimeoutMs:5e3,...e,apiHost:t};Ve(n.storageNames),Be();let r=!!n.consent;r||Ks();let o=null;n.getConsent=()=>o?o.stamp():On();let i=()=>!r||o?.status==="granted";Ws(n.propertyId,n.writeKey);let s=r&&n.holdAcrossPages?En(j(L("held"),n.writeKey)):null,c=s?.read()??{items:[],anonymousId:null};n.mintAnonymousId!==void 0&&zs(n.debug);let u=Cn(n,{carried:c.anonymousId,mayStore:i,orOwn:!0}),d=lr({name:L("session"),domain:n.consentCookieDomain??null,mayStore:i}),f=n.getSessionId;n.getSessionId=()=>F(M(f,null))??d.get();let p=Jn(L("preview"),n.consentCookieDomain??null),g=(a,l)=>n.debug&&console.warn("[hp]",a,l??""),_=n.transport??new nt({apiHost:n.apiHost,writeKey:n.writeKey,storageKey:j(L("retry"),n.writeKey),mayPersist:r?()=>o?.status==="granted":void 0,deferReplay:r,onError:g}),y=j(L("previousPage"),n.propertyId),b=null,v=()=>{if(b)return b;try{return sessionStorage.getItem(y)||null}catch{return null}};typeof window<"u"&&window.addEventListener("pageshow",a=>{a.persisted&&(b=null)});let A=a=>{if(b=a||null,!(r&&o.status!=="granted"))try{sessionStorage.setItem(y,a)}catch{}},m=Gn({key:j(L("decisions"),n.propertyId),mayStore:i});n.getDecisions??(n.getDecisions=m.current);let E=F(M(n.getUserId,null)),w=null,h=null,S=null,T=null,D=new Set,K=new Set;function G(a){if(a.type!=="track"||a.event!=="Cart Updated")return;let l=a.properties?.value;T=typeof l=="number"&&Number.isFinite(l)&&l>=0?l:null;for(let x of D)try{x()}catch(P){console.warn("[hp] a basket listener failed",P)}}function B(a,l,x=!1){G(a);try{return xe(a,l,x)}catch(P){if(P instanceof _e)throw P;return console.warn("[hp] the event was not sent",P),null}}function xe(a,l,x){let P=S;S=null;let q=a.type==="track"?a.event:a.type;if(!x&&!pr(n.plan,q))return null;let C={messageId:P?.messageId??ee(),timestamp:P?.timestamp??new Date().toISOString(),anonymousId:F(M(n.getAnonymousId,null)),userId:E??null,...a,context:In(n,Cr(l))};if(C.properties&&(C.properties=gt(C.properties)),typeof C.properties?.href=="string"&&(C.properties.href=wt(C.properties.href,n)),!x&&!tr(C.anonymousId,n.sampleRate))return n.debug&&console.debug("[hp] not sent: outside the sample",C),null;if(n.beforeSend){let ye;try{ye=n.beforeSend(C)}catch(Kr){return console.warn("[hp] beforeSend failed; the event was not sent",Kr),null}if(!ye)return null;let{type:De,event:on,messageId:qr,timestamp:Fr}=C;C={...ye,type:De,messageId:qr,timestamp:Fr,...on?{event:on}:{}}}if(n.validate){let ye=n.validate(C,{producer:"web"});if(!ye.valid){let De=`[hp] invalid ${C.event??C.type}:
|
|
2
2
|
${ye.errors.join(`
|
|
3
|
-
`)}`;if(n.throwOnInvalid)throw new _e(De);console.error(De)}}n.debug&&console.debug("[hp]",C.event??C.type,C);let nn=Fs(C);return nn>Yt?(h(`${C.event??C.type} not sent: ${nn} bytes, over the ${Yt}-byte limit for one event`),null):(Z(C,x),C)}function W(a){if(a.type==="track"&&N(a),n.onEvent)try{n.onEvent(a)}catch(l){console.warn("[hp] onEvent observer failed",l)}}let oe=()=>r&&o?.state?.personalisation===!0,ke=()=>nr(M(n.getSessionId,null),n.propertyId),he=!1;function N(a){try{oe()?(ke(),Xn(Rt(ar(a.event,a.properties))),he=!0):j()}catch(l){n.debug&&console.warn("[hp] the visit was not recorded",l)}}function j(a=!1){Zn(),(a||he)&&rr(),he=!1}function ge(){d.forget(),m.forget(),ct.clear(),u?.forget(),j(!0)}function Z(a,l){!r||l||o.admits()?(W(a),b.enqueue(a)):o.hold(a)}let k=(a,l,x)=>B({type:"track",event:a,properties:l??{}},x),ct=new Set,Br=(a,l,x)=>a==="audiences"?{audiences:l?null:x.audiences??[]}:a==="decisions"?{decisions:(x.decisions??[]).map(P=>({slot:P.slot,decision_id:P.decision_id??null,arm:P.arm??null,...P.variant&&{variant:P.variant}}))}:{recommendation_request_id:x.recommendation_request_id??null};r&&(o=Fn({adapter:n.consent,timeoutMs:n.consentTimeoutMs,cookieDomain:n.consentCookieDomain,debug:n.debug,store:i&&{read:()=>c.items,write:a=>i.write(a,u?.peek()??null)},release(a){a.context&&(a.context.consent=o.stamp()),W(a),b.enqueue(a)},onStatus(a){if(a==="granted"&&(u?.persist(),d.persist(),_&&v(_),m.persist(),b.replayPersisted?.()),a==="denied"){b.clearPersisted?.(),u?.forget(),d.forget();try{sessionStorage.removeItem(y)}catch{}m.forget(),j(!0)}try{n.onConsentStatus?.(a)}catch(l){console.warn("[hp] onConsentStatus observer failed",l)}if(a==="granted"||a==="denied")for(let l of K)try{l()}catch(x){console.warn("[hp] a consent listener failed",x)}},announce({action:a,state:l,previous:x,withdrawal:P}){l?.personalisation!==!0&&j(x?.personalisation===!0),P&&b.discardQueued?.(),B({type:"track",event:"Consent Updated",properties:{action:a,state:l}},void 0,P),P&&b.flush()}}),o.start());let Zt=()=>n.holdout?Tt(n.holdout):null,Qt=()=>Nt(n.holdout,q(M(n.getAnonymousId,null))).group;function jr(a,l){if(!Array.isArray(a?.decisions))return a;let x=n.holdout?.readoutSlots??[],P=q(M(n.getAnonymousId,null));return{...a,decisions:a.decisions.map(H=>{let C=H?.variant==="bandit"||H?.variant==="default"?H.variant:!l&&H?.holdout!==!0&&x.includes(H?.slot)?zn(H.slot,P):null;return C?C==="default"?{...H,variant:C,decision_id:null}:{...H,variant:C}:H})}}function en(a,l){if(p)return null;let x=a?.exposure,P=x?.holdout===!0,H=jr(a,P);return m.remember(Kn(H)),!x?.token||ct.has(x.token)?null:(ct.add(x.token),k("Personalisation Exposed",{exposure_token:x.token,surface:x.surface,holdout:P,holdout_share:x.holdout_share??Zt()?.holdout_share??null,personalised_share:x.personalised_share??Zt()?.personalised_share??null,...Br(x.surface,P,H)},l))}function tn(a){return E&&ge(),E=null,w=null,g=null,a}return Hn({track:(a,l,x)=>a==="Signed Out"?tn(k(a,l,x)):k(a,l,x),page(a,l){a??(a={});let x=n.pageType??null;a.type&&(we.has(a.type)?(x=a.type,n.pageType=a.type):n.debug&&console.warn(`[hp] ignoring unknown page.type "${a.type}". Allowed: ${[...we].join(", ")}`));let P=B({type:"page",properties:{name:a.name??null,navigation_trigger:a.navigation_trigger??hn(),previous_message_id:A()}},{page:{type:x},...vr(l)??{}});return P&&v(P.messageId),P},identify(a,l,x){let{userId:P,...H}=a&&typeof a=="object"?a:{};if(P!==void 0){let C=q(P);x===Ce?g=C:w&&C&&C!==w?ge():n.debug&&g&&C&&C!==g&&console.warn("[hp] identify names another userId than the identity option; using the new one"),E=C,C&&x!==Ce&&(w=C)}return B({type:"identify",traits:js(H,n.debug)},l)},reset(){E&&ge(),E=null,w=null,g=null,v("")},productViewed:(a,l)=>k("Product Viewed",a,l),productListViewed:(a,l)=>k("Product List Viewed",a,l),recommendationsViewed:(a,l)=>k("Recommendations Viewed",a,l),personalisationExposed:(a,l)=>k("Personalisation Exposed",a,l),recordExposure:en,surfaceViewed({surface:a}={},l){if(!Ts.has(a)||!n.holdout||a!=="decisions"&&!oe())return null;let x=q(M(n.getAnonymousId,null)),P=Nt(n.holdout,x).group;if(P==="excluded")return null;let H=fn({sessionId:$e(M(n.getSessionId,null),x),surface:a});return H?en({exposure:{token:H,surface:a,holdout:P==="holdout"}},l):null},inHoldout:()=>Qt()!=="personalised",personalisationGroup:Qt,productClicked:(a,l)=>k("Product Clicked",a,l),productListFiltered:(a,l)=>k("Product List Filtered",a,l),productsSearched:(a,l)=>k("Products Searched",a,l),searchSuggestionsViewed:(a,l)=>k("Search Suggestions Viewed",a,l),productAdded:(a,l)=>k("Product Added",a,l),productRemoved:(a,l)=>k("Product Removed",a,l),cartUpdated:(a,l)=>k("Cart Updated",Ms(a),l),identityLinked:(a,l)=>k("Identity Linked",a,l),slotEngaged:(a,l)=>p?null:k("Slot Engaged",a,l),productVariantSelected:(a,l)=>k("Product Variant Selected",a,l),cartViewed:(a,l)=>k("Cart Viewed",a,l),productAddedToWishlist:(a,l)=>k("Product Added to Wishlist",a,l),productRemovedFromWishlist:(a,l)=>k("Product Removed from Wishlist",a,l),wishlistProductAddedToCart:(a,l)=>k("Wishlist Product Added to Cart",a,l),productShared:(a,l)=>k("Product Shared",a,l),cartShared:(a,l)=>k("Cart Shared",a,l),couponEntered:(a,l)=>k("Coupon Entered",a,l),couponApplied:(a,l)=>k("Coupon Applied",a,l),couponDenied:(a,l)=>k("Coupon Denied",a,l),couponRemoved:(a,l)=>k("Coupon Removed",a,l),checkoutStarted:(a,l)=>k("Checkout Started",a,l),promotionViewed:(a,l)=>k("Promotion Viewed",a,l),promotionClicked:(a,l)=>k("Promotion Clicked",a,l),checkoutStepViewed:(a,l)=>k("Checkout Step Viewed",a,l),checkoutStepCompleted:(a,l)=>k("Checkout Step Completed",a,l),paymentInfoEntered:(a,l)=>k("Payment Info Entered",a,l),checkoutFailed:(a,l)=>k("Checkout Failed",a,l),signedIn:(a,l)=>k("Signed In",a,l),signedUp:(a,l)=>k("Signed Up",a,l),signedOut:a=>tn(k("Signed Out",{},a)),newsletterSubscribed:(a,l)=>k("Newsletter Subscribed",a,l),newsletterUnsubscribed:(a,l)=>k("Newsletter Unsubscribed",a,l),preferencesStated:(a,l)=>k("Preferences Stated",a,l),backInStockSubscribed:(a,l)=>k("Back In Stock Subscribed",a,l),productReviewed:(a,l)=>k("Product Reviewed",a,l),consentUpdated:(a,l)=>k("Consent Updated",a,l),flush:a=>b.flush(a),recommendationContext(){if(!oe())return{};try{return ke(),Rt(Vt())}catch{return{}}},get consent(){return o?o.state:null},servingHeaders:()=>vt(o?.state??null),get lastPageMessageId(){return A()},get anonymousId(){return q(M(n.getAnonymousId,null))},[Rs](){return{writeKey:n.writeKey,storageKey:F(L("onsite"),n.propertyId),gatewayHost:n.apiHost,servingHost:n.servingHost??n.apiHost,settings:n.onsite??null,debug:n.debug===!0,preview:p,anonymousId:()=>q(M(n.getAnonymousId,null)),sessionId:()=>q(M(n.getSessionId,null)),analytics:s,personalisation:oe,consent:()=>n.getConsent(),headers:()=>vt(o?.state??null),pageUrl:()=>typeof location>"u"?null:yt(location.href,n),locale:()=>St(M(n.getLocale,n.locale)),basketValue:()=>{let a=Vt().basketValue;return T??(Number.isFinite(a)?a:null)},onBasket:a=>(D.add(a),()=>D.delete(a)),consentAnswered:()=>!o||o.status==="granted"||o.status==="denied",onConsentAnswered:a=>(K.add(a),()=>K.delete(a))}},[Ns](a,l,x){if(typeof this[a]=="function"){S=typeof x?.messageId=="string"&&typeof x?.timestamp=="string"?{messageId:x.messageId,timestamp:x.timestamp}:null;try{this[a](...Array.isArray(l)?l:[])}finally{S=null}}}})}var Ne=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite"),J=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.pending"),Re=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.listeners"),rt=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.suppressed"),Ks=["shown","submitted","apply","closed","held"],Cr=10,fe=()=>typeof window>"u"?null:window;function Me(){try{for(let{resolve:e}of fe()?.[J]?.splice(0)??[])e(!1)}catch{}}var pe=Object.freeze({open(e){try{let t=fe();if(!t||typeof e!="string")return Promise.resolve(!1);if(t[Ne])return t[Ne].open(e);if(t[J]??(t[J]=[]),t[J].length<Cr)return new Promise(n=>t[J].push({slot:e,resolve:n}))}catch{}return Promise.resolve(!1)},show(e){return pe.open(e)},on(e,t){var n;try{let r=fe();return!r||!Ks.includes(e)||typeof t!="function"?()=>{}:(r[Re]??(r[Re]={}),((n=r[Re])[e]??(n[e]=new Set)).add(t),()=>r[Re][e].delete(t))}catch{return()=>{}}},suppress(e="page"){try{let t=fe();if(!t)return;(t[rt]??(t[rt]=new Set)).add(String(e)),t[Ne]?.suppress()}catch{}},unsuppress(e){try{let t=fe()?.[rt];e===void 0?t?.clear():t?.delete(String(e))}catch{}},ready(){try{let e=fe();if(!e)return Promise.resolve([]);if(e[Ne])return Promise.resolve(pe.debug());if(e[J]??(e[J]=[]),e[J].length<Cr)return new Promise(t=>e[J].push({slot:null,resolve:()=>t(pe.debug())}))}catch{}return Promise.resolve([])},debug(){try{return fe()?.[Ne]?.debug()??[]}catch{return[]}}});function Pr(e){let t=typeof document>"u"?null:document.currentScript?.src;return t?new URL(e,t).href:null}var ot=new Map;function Or(e,t){return window[t]?Promise.resolve(window[t]):e?(ot.has(t)||ot.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(()=>ot.delete(t))),ot.get(t)):Promise.reject(new Error("the CDN script\u2019s own URL is unknown"))}var Gs=Pr("onsite.min.js"),Lr=()=>Or(Gs,Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.module"));var Xt=Symbol.for("@thg-agentic/hyper-personalisation-web.bootstrap"),zs=Symbol.for("@thg-agentic/hyper-personalisation-web.drain"),Ws=Symbol.for("@thg-agentic/hyper-personalisation-web.carry"),Tr=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),Js=Symbol.for("@thg-agentic/hyper-personalisation-web.assignment"),Ys=Symbol.for("@thg-agentic/hyper-personalisation-web.recommendation-context"),at=e=>e?()=>U(e):()=>null,Mr={didomi:e=>Tn({purposes:e.purposes}),onetrust:e=>Nn({groups:e.groups,impliedConsent:e.impliedConsent}),cookie:e=>Rn({name:e.name,categories:e.categories,refusedValue:e.refusedValue,source:e.source,changeEvent:e.changeEvent}),forwarded:e=>Mn({name:e.name}),static:e=>{if(!e.state||typeof e.state!="object")throw new Error('consent.state is required for provider "static"');return Dn(e.state)}},Nr=Object.keys(Mr),me=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),st=e=>typeof e=="string"&&e!=="",Xs=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Dr=e=>me(e)&&typeof e.read=="function";function Zs(e,t={}){let n=[];if(!me(e))return["config must be { writeKey, apiHost? }"];st(e.writeKey)||n.push("writeKey is required"),ne(e.apiHost)||n.push("apiHost, when given, must be a host or an http(s) origin"),t.propertyId!==void 0&&!st(t.propertyId)&&n.push("propertyId must be a string");let{consent:r}=t;if(!Dr(r)&&!(me(r)&&Nr.includes(r.provider))&&n.push(`consent must be a consent adapter or { provider: ${Nr.join(" | ")} }`),t.autocapture!==void 0&&t.autocapture!==!1&&!me(t.autocapture)&&n.push("autocapture must be false or { promotions, productLists, recommendations }"),t.onsite!==void 0&&typeof t.onsite!="boolean"&&!me(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(!me(t.identityCookies))n.push("identityCookies must be an object");else for(let o of["anonymousId","sessionId"]){let s=t.identityCookies[o];s!==void 0&&!st(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&&(me(t.dataLayer)?(t.dataLayer.name!==void 0&&!st(t.dataLayer.name)&&n.push("dataLayer.name must be a string"),t.dataLayer.ignore!==void 0&&!Xs(t.dataLayer.ignore)&&n.push("dataLayer.ignore must be an array of strings")):n.push("dataLayer must be an object")),n}function Qs(e,t,n){if(Dr(e))return Et(e,t.consentPurposes);let{provider:r,...o}=e,s=n?.consent?.[r]??Mr[r];return Et(s(o),t.consentPurposes)}var $r=(e,t)=>`${e??""}|${t??""}`;function ei(e,t){let n=q(t?.userId),r=nt(t?.emailSha256);if(!n&&!r)return null;try{let o=F(L("identified"),e);if(sessionStorage.getItem(o)===$r(n,r))return null}catch{}return{...n?{userId:n}:{},...r?{email_sha256:r}:{}}}async function ti({writeKey:e,apiHost:t},n){if(n.settings!==void 0)return{settings:Ht(n.settings),revalidated:null};let r=mr(t,e),o=hr(e);if(o)return{settings:o,revalidated:r};let s=await r,i=s??jt;return{settings:i,revalidated:Promise.resolve(i),unreachable:s===null}}function Ur(e,t){let n=t??{},r=typeof window<"u"?window:null;if(r?.[Xt])return r[Xt];let o=Cn(e?.writeKey,()=>{let{analytics:i}=Ee(U(L("consent")));return i===!0||i===null&&n.holdAcrossPages===!0}),s=oi(e,n,o);if(r){let i=n.extend?.getSessionId??at(n.identityCookies?.sessionId),c=at(n.identityCookies?.anonymousId);r[Js]=({slot:u,arm:d}={})=>dn({sessionId:$e(i(),c()),slot:u,arm:d}),r[Xt]=s,r[Ws]=o,r[zs]?.(s)}return s}function ni(){let e=globalThis.performance?.now?.();return new Date(Date.now()-(Number.isFinite(e)?e:0)).toISOString()}function Rr(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(ft(e,r(n.promotions))),n.productLists&&o.push(dt(e,r(n.productLists))),n.recommendations&&o.push(pt(e,r(n.recommendations))),n.exposures&&o.push(lt(e,r(n.exposures)))}catch(s){console.warn("[hp] autocapture not started:",s?.message??s)}return()=>{for(let s of o)s()}}function ri(e,t,n){if(!t||!n.onsite)return Me();Lr().then(r=>r.startOnsite(e,t===!0?{}:t)).catch(r=>{Me(),console.warn("[hp] onsite not started:",r?.message??r)})}function it(e){return e.close(),Me(),null}async function oi(e,t,n){try{let r=Zs(e,t);if(r.length)return console.warn(`[hp] not started, the configuration is invalid: ${r.join("; ")}`),it(n);Ve(t.storageNames),Be();let{writeKey:o}=e,[{settings:s,revalidated:i,unreachable:c},u]=await Promise.all([ti(e,t),Promise.resolve(t.identity).catch(()=>null)]),d=i?s:null,f=!1,p=()=>f&&d&&gr(o,d);if(i?.then(g=>{g&&(d=g,g.enabled?p():qt(o))}),c)return Me(),null;if(!s.enabled)return t.debug&&console.info("[hp] off: the settings for this write key do not enable it"),it(n);let h=t.propertyId??s.propertyId;if(!h)return console.warn("[hp] not started: this write key covers several properties, so propertyId is required"),it(n);let{preset:b}=t,y=ei(h,u),_=t.debug===!0||s.debug?.enabled===!0||jn(s.debug?.tokenSha256??null,L("debug")),A=q(u?.userId),v=Er({apiHost:fr(e.apiHost,s.apiHost),servingHost:ne(e.apiHost),onsite:s.onsite??null,writeKey:o,propertyId:h,pageType:we.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?.[h],getCurrency:t.getCurrency,getShipToCountry:t.getShipToCountry,getLocale:t.getLocale,consent:Qs(t.consent,s,b),consentCookieDomain:t.consentCookieDomain,storageNames:t.storageNames,holdAcrossPages:t.holdAcrossPages===!0,mintAnonymousId:t.mintAnonymousId,debug:_,anonymousIdSource:s.anonymousId??void 0,getAnonymousId:at(t.identityCookies?.anonymousId),getSessionId:t.identityCookies?.sessionId?at(t.identityCookies.sessionId):void 0,getUserId:()=>A,beforeSend:t.beforeSend,...t.extend,onConsentStatus(g){if(g==="granted"&&(f=!0,p()),g==="denied"){qt(o);try{sessionStorage.removeItem(F(L("identified"),h))}catch{}}t.extend?.onConsentStatus?.(g)},onEvent(g){if(g.type==="identify"){let S=$r(q(g.userId),nt(g.traits?.email_sha256));try{sessionStorage.setItem(F(L("identified"),h),S)}catch{}}t.extend?.onEvent?.(g)}});typeof window<"u"&&(window[Ys]=()=>v.recommendationContext());for(let[g,S,T]of n.take())try{v[Tr](g,S,T)}catch(D){console.warn(`[hp] carried ${g} failed`,D)}v[Tr]("page",[t.pageType?{type:t.pageType}:{}],{messageId:ee(),timestamp:ni()});let m=Rr(v,t.autocapture),E=v.page;v.page=Lt("page",(...g)=>{let S=E(...g);return m(),m=Rr(v,t.autocapture),S});let w=typeof window<"u"?window:null;if(w?.addEventListener?.("pageshow",g=>{g.persisted&&v.page({navigation_trigger:"back_forward"})}),t.dataLayer&&w){let g=t.dataLayer.name??"dataLayer";w[g]=w[g]||[],Bn(v,{...b,dataLayer:w[g],ignore:[...b?.ignore??[],...t.dataLayer.ignore??[]],onError:S=>_&&console.warn("[hp] dataLayer mapping failed",S)})}return y&&v.identify(y,void 0,Ce),v.onsite=pe,ri(v,t.onsite,s),v}catch(r){return console.warn("[hp] not started:",r?.message??r),it(n)}}function Vr(e){e.initialized=!0,Ur(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 $=window.hp=window.hp||[];$.servingHeaders??($.servingHeaders=()=>({}));$.inHoldout??($.inHoldout=()=>!0);$.personalisationGroup??($.personalisationGroup=()=>"excluded");$.recommendationContext??($.recommendationContext=()=>({}));$.onsite??($.onsite=pe);$.initialized||($._config?Vr($):$.load=(e,t)=>{$._config=e,$._options=t??{},Vr($)});})();
|
|
3
|
+
`)}`;if(n.throwOnInvalid)throw new _e(De);console.error(De)}}n.debug&&console.debug("[hp]",C.event??C.type,C);let rn=Gs(C);return rn>Yt?(g(`${C.event??C.type} not sent: ${rn} bytes, over the ${Yt}-byte limit for one event`),null):(Z(C,x),C)}function W(a){if(a.type==="track"&&N(a),n.onEvent)try{n.onEvent(a)}catch(l){console.warn("[hp] onEvent observer failed",l)}}let oe=()=>r&&o?.state?.personalisation===!0,ke=()=>rr(M(n.getSessionId,null),n.propertyId),he=!1;function N(a){try{oe()?(ke(),Zn(Mt(cr(a.event,a.properties))),he=!0):H()}catch(l){n.debug&&console.warn("[hp] the visit was not recorded",l)}}function H(a=!1){Qn(),(a||he)&&or(),he=!1}function ge(){d.forget(),m.forget(),ut.clear(),u?.forget(),H(!0)}function Z(a,l){!r||l||o.admits()?(W(a),_.enqueue(a)):o.hold(a)}let k=(a,l,x)=>B({type:"track",event:a,properties:l??{}},x),ut=new Set,jr=(a,l,x)=>a==="audiences"?{audiences:l?null:x.audiences??[]}:a==="decisions"?{decisions:(x.decisions??[]).map(P=>({slot:P.slot,decision_id:P.decision_id??null,arm:P.arm??null,...P.variant&&{variant:P.variant}}))}:{recommendation_request_id:x.recommendation_request_id??null};r&&(o=Kn({adapter:n.consent,timeoutMs:n.consentTimeoutMs,cookieDomain:n.consentCookieDomain,debug:n.debug,store:s&&{read:()=>c.items,write:a=>s.write(a,u?.peek()??null)},release(a){a.context&&(a.context.consent=o.stamp()),W(a),_.enqueue(a)},onStatus(a){if(a==="granted"&&(u?.persist(),d.persist(),b&&A(b),m.persist(),_.replayPersisted?.()),a==="denied"){_.clearPersisted?.(),u?.forget(),d.forget();try{sessionStorage.removeItem(y)}catch{}m.forget(),H(!0)}try{n.onConsentStatus?.(a)}catch(l){console.warn("[hp] onConsentStatus observer failed",l)}if(a==="granted"||a==="denied")for(let l of K)try{l()}catch(x){console.warn("[hp] a consent listener failed",x)}},announce({action:a,state:l,previous:x,withdrawal:P}){l?.personalisation!==!0&&H(x?.personalisation===!0),P&&_.discardQueued?.(),B({type:"track",event:"Consent Updated",properties:{action:a,state:l}},void 0,P),P&&_.flush()}}),o.start());let Qt=()=>n.holdout?Nt(n.holdout):null,en=()=>Rt(n.holdout,F(M(n.getAnonymousId,null))).group;function Hr(a,l){if(!Array.isArray(a?.decisions))return a;let x=n.holdout?.readoutSlots??[],P=F(M(n.getAnonymousId,null));return{...a,decisions:a.decisions.map(q=>{let C=q?.variant==="bandit"||q?.variant==="default"?q.variant:!l&&q?.holdout!==!0&&x.includes(q?.slot)?Wn(q.slot,P):null;return C?C==="default"?{...q,variant:C,decision_id:null}:{...q,variant:C}:q})}}function tn(a,l){if(p)return null;let x=a?.exposure,P=x?.holdout===!0,q=Hr(a,P);return m.remember(zn(q)),!x?.token||ut.has(x.token)?null:(ut.add(x.token),k("Personalisation Exposed",{exposure_token:x.token,surface:x.surface,holdout:P,holdout_share:x.holdout_share??Qt()?.holdout_share??null,personalised_share:x.personalised_share??Qt()?.personalised_share??null,...jr(x.surface,P,q)},l))}function nn(a){return E&&ge(),E=null,w=null,h=null,a}return qn({track:(a,l,x)=>a==="Signed Out"?nn(k(a,l,x)):k(a,l,x),page(a,l){a??(a={});let x=n.pageType??null;a.type&&(we.has(a.type)?(x=a.type,n.pageType=a.type):n.debug&&console.warn(`[hp] ignoring unknown page.type "${a.type}". Allowed: ${[...we].join(", ")}`));let P=B({type:"page",properties:{name:a.name??null,navigation_trigger:a.navigation_trigger??gn(),previous_message_id:v()}},{page:{type:x},...Cr(l)??{}});return P&&A(P.messageId),P},identify(a,l,x){let{userId:P,...q}=a&&typeof a=="object"?a:{};if(P!==void 0){let C=F(P);x===Ce?h=C:w&&C&&C!==w?ge():n.debug&&h&&C&&C!==h&&console.warn("[hp] identify names another userId than the identity option; using the new one"),E=C,C&&x!==Ce&&(w=C)}return B({type:"identify",traits:Fs(q,n.debug)},l)},reset(){E&&ge(),E=null,w=null,h=null,A("")},productViewed:(a,l)=>k("Product Viewed",a,l),productListViewed:(a,l)=>k("Product List Viewed",a,l),recommendationsViewed:(a,l)=>k("Recommendations Viewed",a,l),personalisationExposed:(a,l)=>k("Personalisation Exposed",a,l),recordExposure:tn,surfaceViewed({surface:a}={},l){if(!Rs.has(a)||!n.holdout||a!=="decisions"&&!oe())return null;let x=F(M(n.getAnonymousId,null)),P=Rt(n.holdout,x).group;if(P==="excluded")return null;let q=pn({sessionId:Ue(M(n.getSessionId,null),x),surface:a});return q?tn({exposure:{token:q,surface:a,holdout:P==="holdout"}},l):null},inHoldout:()=>en()!=="personalised",personalisationGroup:en,productClicked:(a,l)=>k("Product Clicked",a,l),productListFiltered:(a,l)=>k("Product List Filtered",a,l),productsSearched:(a,l)=>k("Products Searched",a,l),searchSuggestionsViewed:(a,l)=>k("Search Suggestions Viewed",a,l),productAdded:(a,l)=>k("Product Added",a,l),productRemoved:(a,l)=>k("Product Removed",a,l),cartUpdated:(a,l)=>k("Cart Updated",$s(a),l),identityLinked:(a,l)=>k("Identity Linked",a,l),slotEngaged:(a,l)=>p?null:k("Slot Engaged",a,l),productVariantSelected:(a,l)=>k("Product Variant Selected",a,l),cartViewed:(a,l)=>k("Cart Viewed",a,l),productAddedToWishlist:(a,l)=>k("Product Added to Wishlist",a,l),productRemovedFromWishlist:(a,l)=>k("Product Removed from Wishlist",a,l),wishlistProductAddedToCart:(a,l)=>k("Wishlist Product Added to Cart",a,l),productShared:(a,l)=>k("Product Shared",a,l),cartShared:(a,l)=>k("Cart Shared",a,l),couponEntered:(a,l)=>k("Coupon Entered",a,l),couponApplied:(a,l)=>k("Coupon Applied",a,l),couponDenied:(a,l)=>k("Coupon Denied",a,l),couponRemoved:(a,l)=>k("Coupon Removed",a,l),checkoutStarted:(a,l)=>k("Checkout Started",a,l),promotionViewed:(a,l)=>k("Promotion Viewed",a,l),promotionClicked:(a,l)=>k("Promotion Clicked",a,l),checkoutStepViewed:(a,l)=>k("Checkout Step Viewed",a,l),checkoutStepCompleted:(a,l)=>k("Checkout Step Completed",a,l),paymentInfoEntered:(a,l)=>k("Payment Info Entered",a,l),checkoutFailed:(a,l)=>k("Checkout Failed",a,l),signedIn:(a,l)=>k("Signed In",a,l),signedUp:(a,l)=>k("Signed Up",a,l),signedOut:a=>nn(k("Signed Out",{},a)),newsletterSubscribed:(a,l)=>k("Newsletter Subscribed",a,l),newsletterUnsubscribed:(a,l)=>k("Newsletter Unsubscribed",a,l),preferencesStated:(a,l)=>k("Preferences Stated",a,l),backInStockSubscribed:(a,l)=>k("Back In Stock Subscribed",a,l),productReviewed:(a,l)=>k("Product Reviewed",a,l),consentUpdated:(a,l)=>k("Consent Updated",a,l),flush:a=>_.flush(a),recommendationContext(){if(!oe())return{};try{return ke(),Mt(Bt())}catch{return{}}},get consent(){return o?o.state:null},servingHeaders:()=>Et(o?.state??null),get lastPageMessageId(){return v()},get anonymousId(){return F(M(n.getAnonymousId,null))},[Us](){return{writeKey:n.writeKey,storageKey:j(L("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)),analytics:i,personalisation:oe,consent:()=>n.getConsent(),headers:()=>Et(o?.state??null),pageUrl:()=>typeof location>"u"?null:wt(location.href,n),locale:()=>_t(M(n.getLocale,n.locale)),basketValue:()=>{let a=Bt().basketValue;return T??(Number.isFinite(a)?a:null)},onBasket:a=>(D.add(a),()=>D.delete(a)),consentAnswered:()=>!o||o.status==="granted"||o.status==="denied",onConsentAnswered:a=>(K.add(a),()=>K.delete(a))}},[Ds](){_.markFailing?.()},[Ms](a,l,x){if(typeof this[a]=="function"){S=typeof x?.messageId=="string"&&typeof x?.timestamp=="string"?{messageId:x.messageId,timestamp:x.timestamp}:null;try{this[a](...Array.isArray(l)?l:[])}finally{S=null}}}})}var Ne=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite"),J=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.pending"),Re=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.listeners"),ot=Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.suppressed"),Js=["shown","submitted","apply","closed","held"],Or=10,fe=()=>typeof window>"u"?null:window;function Me(){try{for(let{resolve:e}of fe()?.[J]?.splice(0)??[])e(!1)}catch{}}var pe=Object.freeze({open(e){try{let t=fe();if(!t||typeof e!="string")return Promise.resolve(!1);if(t[Ne])return t[Ne].open(e);if(t[J]??(t[J]=[]),t[J].length<Or)return new Promise(n=>t[J].push({slot:e,resolve:n}))}catch{}return Promise.resolve(!1)},show(e){return pe.open(e)},on(e,t){var n;try{let r=fe();return!r||!Js.includes(e)||typeof t!="function"?()=>{}:(r[Re]??(r[Re]={}),((n=r[Re])[e]??(n[e]=new Set)).add(t),()=>r[Re][e].delete(t))}catch{return()=>{}}},suppress(e="page"){try{let t=fe();if(!t)return;(t[ot]??(t[ot]=new Set)).add(String(e)),t[Ne]?.suppress()}catch{}},unsuppress(e){try{let t=fe()?.[ot];e===void 0?t?.clear():t?.delete(String(e))}catch{}},ready(){try{let e=fe();if(!e)return Promise.resolve([]);if(e[Ne])return Promise.resolve(pe.debug());if(e[J]??(e[J]=[]),e[J].length<Or)return new Promise(t=>e[J].push({slot:null,resolve:()=>t(pe.debug())}))}catch{}return Promise.resolve([])},debug(){try{return fe()?.[Ne]?.debug()??[]}catch{return[]}}});function Lr(e){let t=typeof document>"u"?null:document.currentScript?.src;return t?new URL(e,t).href:null}var st=new Map;function Tr(e,t){return window[t]?Promise.resolve(window[t]):e?(st.has(t)||st.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(()=>st.delete(t))),st.get(t)):Promise.reject(new Error("the CDN script\u2019s own URL is unknown"))}var Ys=Lr("onsite.min.js"),Xt=()=>Tr(Ys,Symbol.for("@thg-agentic/hyper-personalisation-web.onsite.module"));var Zt=Symbol.for("@thg-agentic/hyper-personalisation-web.bootstrap"),Xs=Symbol.for("@thg-agentic/hyper-personalisation-web.drain"),Zs=Symbol.for("@thg-agentic/hyper-personalisation-web.carry"),Nr=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),Qs=Symbol.for("@thg-agentic/hyper-personalisation-web.unreachable"),ei=Symbol.for("@thg-agentic/hyper-personalisation-web.assignment"),ti=Symbol.for("@thg-agentic/hyper-personalisation-web.recommendation-context"),ct=e=>e?()=>$(e):()=>null,Dr={didomi:e=>Nn({purposes:e.purposes}),onetrust:e=>Rn({groups:e.groups,impliedConsent:e.impliedConsent}),cookie:e=>Mn({name:e.name,categories:e.categories,refusedValue:e.refusedValue,source:e.source,changeEvent:e.changeEvent}),forwarded:e=>Dn({name:e.name}),static:e=>{if(!e.state||typeof e.state!="object")throw new Error('consent.state is required for provider "static"');return Un(e.state)}},Rr=Object.keys(Dr),me=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),it=e=>typeof e=="string"&&e!=="",ni=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Ur=e=>me(e)&&typeof e.read=="function";function ri(e,t={}){let n=[];if(!me(e))return["config must be { writeKey, apiHost? }"];it(e.writeKey)||n.push("writeKey is required"),ne(e.apiHost)||n.push("apiHost, when given, must be a host or an http(s) origin"),t.propertyId!==void 0&&!it(t.propertyId)&&n.push("propertyId must be a string");let{consent:r}=t;if(!Ur(r)&&!(me(r)&&Rr.includes(r.provider))&&n.push(`consent must be a consent adapter or { provider: ${Rr.join(" | ")} }`),t.autocapture!==void 0&&t.autocapture!==!1&&!me(t.autocapture)&&n.push("autocapture must be false or { promotions, productLists, recommendations }"),t.onsite!==void 0&&typeof t.onsite!="boolean"&&!me(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(!me(t.identityCookies))n.push("identityCookies must be an object");else for(let o of["anonymousId","sessionId"]){let i=t.identityCookies[o];i!==void 0&&!it(i)&&n.push(`identityCookies.${o} must be a cookie name`)}for(let o of["getCurrency","getShipToCountry","getLocale"])t[o]!==void 0&&typeof t[o]!="function"&&n.push(`${o} must be a function`);return t.dataLayer!==void 0&&(me(t.dataLayer)?(t.dataLayer.name!==void 0&&!it(t.dataLayer.name)&&n.push("dataLayer.name must be a string"),t.dataLayer.ignore!==void 0&&!ni(t.dataLayer.ignore)&&n.push("dataLayer.ignore must be an array of strings")):n.push("dataLayer must be an object")),n}function oi(e,t,n){if(Ur(e))return Ct(e,t.consentPurposes);let{provider:r,...o}=e,i=n?.consent?.[r]??Dr[r];return Ct(i(o),t.consentPurposes)}var $r=(e,t)=>`${e??""}|${t??""}`;function si(e,t){let n=F(t?.userId),r=rt(t?.emailSha256);if(!n&&!r)return null;try{let o=j(L("identified"),e);if(sessionStorage.getItem(o)===$r(n,r))return null}catch{}return{...n?{userId:n}:{},...r?{email_sha256:r}:{}}}async function ii({writeKey:e,apiHost:t},n){if(n.settings!==void 0)return{settings:qt(n.settings),revalidated:null};let r=gr(t,e),o=yr(e);if(o)return{settings:o,revalidated:r,fetched:r};let i=await r;return i?{settings:i,revalidated:r,fetched:r}:{settings:Ht,revalidated:null,fetched:r}}function Vr(e,t){let n=t??{},r=typeof window<"u"?window:null;if(r?.[Zt])return r[Zt];let o=Pn(e?.writeKey,()=>{let{analytics:s}=Ee($(L("consent")));return s===!0||s===null&&n.holdAcrossPages===!0}),i=li(e,n,o);if(r){let s=n.extend?.getSessionId??ct(n.identityCookies?.sessionId),c=ct(n.identityCookies?.anonymousId);r[ei]=({slot:u,arm:d}={})=>fn({sessionId:Ue(s(),c()),slot:u,arm:d}),r[Zt]=i,r[Zs]=o,r[Xs]?.(i)}return i}function ai(){let e=globalThis.performance?.now?.();return new Date(Date.now()-(Number.isFinite(e)?e:0)).toISOString()}function Mr(e,t){if(t===!1)return()=>{};let n={promotions:!0,productLists:!0,recommendations:!0,exposures:!0,...t},r=i=>i&&typeof i=="object"?i:{},o=[];try{n.promotions&&o.push(pt(e,r(n.promotions))),n.productLists&&o.push(ft(e,r(n.productLists))),n.recommendations&&o.push(mt(e,r(n.recommendations))),n.exposures&&o.push(dt(e,r(n.exposures)))}catch(i){console.warn("[hp] autocapture not started:",i?.message??i)}return()=>{for(let i of o)i()}}var ci=1e3;function ui(e,t,n,r){if(!t)return Me();let o=n.onsite?Xt():null;o?.catch(()=>{}),(r?Promise.race([r.then(s=>s??n),new Promise(s=>setTimeout(()=>s(n),ci))]):Promise.resolve(n)).then(s=>{let c=s.enabled?s.onsite:null;if(!c)return Me();let u=t===!0?{}:t;return(o??Xt()).then(d=>d.startOnsite(e,{...u,settings:u.settings??c}))}).catch(s=>{Me(),console.warn("[hp] onsite not started:",s?.message??s)})}function at(e){return e.close(),Me(),null}async function li(e,t,n){try{let r=ri(e,t);if(r.length)return console.warn(`[hp] not started, the configuration is invalid: ${r.join("; ")}`),at(n);Ve(t.storageNames),Be();let{writeKey:o}=e,[{settings:i,revalidated:s,fetched:c},u]=await Promise.all([ii(e,t),Promise.resolve(t.identity).catch(()=>null)]),d=s?i:null,f=!1,p=()=>f&&d&&wr(o,d);if(s?.then(h=>{h&&(d=h,h.enabled?p():Ft(o))}),!i.enabled)return t.debug&&console.info("[hp] off: the settings for this write key do not enable it"),at(n);let g=t.propertyId??i.propertyId??null;if(!g&&i!==Ht)return console.warn("[hp] not started: this write key covers several properties, so propertyId is required"),at(n);let{preset:_}=t,y=si(g,u),b=t.debug===!0||i.debug?.enabled===!0||Hn(i.debug?.tokenSha256??null,L("debug")),v=F(u?.userId),A=Pr({apiHost:mr(e.apiHost,i.apiHost),servingHost:ne(e.apiHost),onsite:i.onsite??null,writeKey:o,propertyId:g,pageType:we.has(t.pageType)?t.pageType:void 0,environment:i.environment,queryParamAllowlist:i.queryParamAllowlist??void 0,plan:i.plan,sampleRate:i.sampleRate??1,holdout:i.holdouts?.[g],getCurrency:t.getCurrency,getShipToCountry:t.getShipToCountry,getLocale:t.getLocale,consent:oi(t.consent,i,_),consentCookieDomain:t.consentCookieDomain,storageNames:t.storageNames,holdAcrossPages:t.holdAcrossPages===!0,mintAnonymousId:t.mintAnonymousId,debug:b,anonymousIdSource:i.anonymousId??void 0,getAnonymousId:ct(t.identityCookies?.anonymousId),getSessionId:t.identityCookies?.sessionId?ct(t.identityCookies.sessionId):void 0,getUserId:()=>v,beforeSend:t.beforeSend,...t.extend,onConsentStatus(h){if(h==="granted"&&(f=!0,p()),h==="denied"){Ft(o);try{sessionStorage.removeItem(j(L("identified"),g))}catch{}}t.extend?.onConsentStatus?.(h)},onEvent(h){if(h.type==="identify"){let S=$r(F(h.userId),rt(h.traits?.email_sha256));try{sessionStorage.setItem(j(L("identified"),g),S)}catch{}}t.extend?.onEvent?.(h)}});typeof window<"u"&&(window[ti]=()=>A.recommendationContext()),c?.then(h=>h===null&&A[Qs]());for(let[h,S,T]of n.take())try{A[Nr](h,S,T)}catch(D){console.warn(`[hp] carried ${h} failed`,D)}A[Nr]("page",[t.pageType?{type:t.pageType}:{}],{messageId:ee(),timestamp:ai()});let m=Mr(A,t.autocapture),E=A.page;A.page=Tt("page",(...h)=>{let S=E(...h);return m(),m=Mr(A,t.autocapture),S});let w=typeof window<"u"?window:null;if(w?.addEventListener?.("pageshow",h=>{h.persisted&&A.page({navigation_trigger:"back_forward"})}),t.dataLayer&&w){let h=t.dataLayer.name??"dataLayer";w[h]=w[h]||[],jn(A,{..._,dataLayer:w[h],ignore:[..._?.ignore??[],...t.dataLayer.ignore??[]],onError:S=>b&&console.warn("[hp] dataLayer mapping failed",S)})}return y&&A.identify(y,void 0,Ce),A.onsite=pe,ui(A,t.onsite,i,s),A}catch(r){return console.warn("[hp] not started:",r?.message??r),at(n)}}function Br(e){e.initialized=!0,Vr(e._config,e._options).then(t=>{let n=e.splice(0);if(!t){for(let r of e.methods??[])e[r]=()=>e;return}e.client=t;for(let[r,o]of Object.entries(t))typeof o=="function"&&(e[r]=o);for(let[r,...o]of n)try{t[r]?.(...o)}catch(i){console.warn(`[hp] queued ${r} failed`,i)}})}var U=window.hp=window.hp||[];U.servingHeaders??(U.servingHeaders=()=>({}));U.inHoldout??(U.inHoldout=()=>!0);U.personalisationGroup??(U.personalisationGroup=()=>"excluded");U.recommendationContext??(U.recommendationContext=()=>({}));U.onsite??(U.onsite=pe);U.initialized||(U._config?Br(U):U.load=(e,t)=>{U._config=e,U._options=t??{},Br(U)});})();
|