@sheeptrack/web 0.2.1 → 0.5.1
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/CHANGELOG.md +42 -0
- package/package.json +1 -1
- package/dist/consent.js +0 -26
- package/dist/esm/consent.js +0 -26
- package/dist/esm/index.js +0 -2
- package/dist/esm/replay.js +0 -53
- package/dist/replay.js +0 -53
- package/dist/sheeptrack.js +0 -2
- package/dist/types/autocapture.d.ts +0 -9
- package/dist/types/consent.d.ts +0 -9
- package/dist/types/ctx.d.ts +0 -30
- package/dist/types/debug.d.ts +0 -17
- package/dist/types/flags.d.ts +0 -21
- package/dist/types/iife.d.ts +0 -1
- package/dist/types/index.d.ts +0 -47
- package/dist/types/replay.d.ts +0 -4
- package/dist/types/util.d.ts +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.1 - 2026-11-25
|
|
4
|
+
|
|
5
|
+
- Consent: the exempt measurement stays anonymous. A choice that grants `personalization` without `analytics` (for example `optIn(['personalization'])`) no longer lets `identify()` attach a user id to it: the call waits until analytics is accepted too.
|
|
6
|
+
- Consent: a refusal stored before the banner was switched off, or by a visitor outside its regions, stays a refusal and does not start the exempt measurement.
|
|
7
|
+
|
|
8
|
+
## 0.5.0 - 2026-11-25
|
|
9
|
+
|
|
10
|
+
- Consent: with `exempt_analytics` on and a banner shown, the anonymous in-memory measurement is no longer stopped when the visitor refuses. It needs no consent, so it goes on with the same in-memory id and session, and nothing is written to the browser. Replay, `identify` and every persistent write still need consent. A GPC or Do Not Track signal now stops it, before the choice as well as after a refusal (until now, exempt mode ignored GPC while the banner was shown). A project without a banner, or a visitor outside its regions, is unchanged. Withdrawing a choice that had been persistent still forgets the old id and queue.
|
|
11
|
+
|
|
12
|
+
## 0.4.0 - 2026-11-24
|
|
13
|
+
|
|
14
|
+
Three changes affect more than the SDK itself.
|
|
15
|
+
|
|
16
|
+
- Feature flags: `semver_gte` and `semver_lt` now ignore a leading `v` (`v2.1.0` = `2.1.0`) and build metadata (`+b1`), and a pre-release sorts below its final version (`1.4.0-rc1` < `1.4.0`). The server applies this rule already. Every SDK published before this one (this SDK up to 0.3.0, and the other platforms until they are updated) still reads `v2.1.0` as major version 0 and treats `1.4.0-rc1` as equal to `1.4.0`. Until all of them are updated, the same flag can give two different results for the same visitor, depending on where it is evaluated.
|
|
17
|
+
- Heatmaps: `$scroll_depth` can be sent a second time for the same page view, with `resumed: true`, when a reader leaves the tab and then reads further down. The server counts each `$scroll_depth` event as a view, so heatmap totals are inflated until the server ignores events that carry `resumed`.
|
|
18
|
+
- Error grouping: the `$error` fingerprint changed (see below). After the deployment that ships this version, each web error opens one new issue. The old issue keeps its history and stops receiving occurrences. Existing rows are not rewritten.
|
|
19
|
+
|
|
20
|
+
Other changes:
|
|
21
|
+
|
|
22
|
+
- Replay: the chunk number is saved in `localStorage` (`pt_s`) with every chunk and read again before the next one. A reload or a second tab of the same session no longer reuses numbers the server already holds (it answered them as duplicates and those chunks were lost). Each write of `pt_s` keeps the higher of the stored and the in-memory number, so a tab that only saves its event queue cannot move the counter back.
|
|
23
|
+
- Replay: chunks that could not be sent (offline, network error, 429, 5xx) stay queued, up to 20, and are retried in order, oldest first, so the sequence has no hole that stops the player. A refusal that will not change (400, 413...) drops the chunk. When the queue is full, the newest chunk is dropped, never the one being retried. A 403 (consent refused by the server) still stops the recorder.
|
|
24
|
+
- Signed URLs: the `X-Amz-*` and `X-Goog-*` parameters (S3, GCS) are removed from the URLs of events and from every URL in the replay (`src`, `href`, each `srcset` candidate, the page URL). In the text of `$error` and `$console`, relative and scheme-less signed URLs are masked too. The replay also cleans `data-src` and each candidate of `data-srcset`; the second candidate of a `data-srcset` used to keep its token.
|
|
25
|
+
- `$console` messages go through the same cleaning as `$error` (credentials, sensitive parameters, signed URLs). The message, stack and error type are cut to 500, 4000 and 100 characters before any processing, so a 100 KB message can no longer freeze the page.
|
|
26
|
+
- `$error` fingerprint: before hashing, minified function names, hashed file names (`index-Dk9HfQzL.js`), line and column numbers, other numbers and URL origins and queries are removed, and the first three stack frames count, for Chrome, Firefox and Safari alike. Known limits: a function name of three characters or fewer is treated as minified, and a Safari frame whose name contains a space (`global code@...`) is skipped.
|
|
27
|
+
- Several tabs: a tab whose session expired joins the session another tab kept alive instead of opening its own, and the tabs of one session share the replay chunk counter.
|
|
28
|
+
- A consent proof whose upload throws (for example when gzip fails) no longer blocks the events and replay chunks queued behind it. It stays pending for the next page load.
|
|
29
|
+
- A direct visit (empty `document.referrer`) now gives an empty `referrer` instead of the current page. An unhandled rejection whose reason has no string message no longer throws inside the SDK.
|
|
30
|
+
- Consent banner: the text colour (black or white) is picked on contrast with a threshold of about 0.18 instead of 0.4, and short hex colours (`#fc0`) and colour names (`yellow`) are understood.
|
|
31
|
+
- `$scroll_depth` is sent as soon as the tab goes to the background, because a mobile browser can kill it without firing `pagehide`.
|
|
32
|
+
|
|
33
|
+
## 0.3.0
|
|
34
|
+
|
|
35
|
+
- Replay: a full snapshot at most every 2 minutes, so the player can seek from the nearest one instead of replaying the session from its start. The delay is checked on each recorded change, so an idle page gets its checkpoint with its next change.
|
|
36
|
+
- Replay: chunks are gzipped once when cut, and the page-hide beacon reuses the compressed body when it is ready (plain JSON otherwise); the browser may still refuse a large beacon, which then stays queued. The chunk cut follows the measured size on the wire (1 MB target, not a beacon limit) instead of a fixed raw size.
|
|
37
|
+
- Replay: canvas content recorded as WebP frames (2 per second) when the project setting `replay.canvas` is on; if the site's CSP blocks rrweb's worker (whether rrweb swallows the error or throws it), recording restarts without canvas instead of stopping.
|
|
38
|
+
- Replay: cross-origin iframes that also load the SDK are merged into the parent's replay when `replay.cross_origin_iframes` is on; a framed page only hands its events to the origins listed in `replay.iframe_parent_origins`, once `location.ancestorOrigins` confirms the parent (without it, e.g. in Firefox, the frame records its own replay), and scrubs them as it does its own uploads. Events from a paused or replaced recorder are ignored. Known limit: after a far seek, the player starts from the parent's last full snapshot, so a merged iframe stays blank until its own next full snapshot (2 minutes at most).
|
|
39
|
+
- Console: when `console` is not passed to `init`, the levels come from the project settings (remote config), still warn+error by default; nothing is captured until that config has loaded.
|
|
40
|
+
- Network: `$network` events carry the response `size` (Content-Length, 0 included) when the server exposes it; a reused `XMLHttpRequest` reports each response once, for its own URL.
|
|
41
|
+
- Heatmaps: clicks inside a `position: fixed` element (sticky header, chat button) are recorded with viewport coordinates, so they land on the element at the top of the page instead of wherever the visitor had scrolled; a fixed element inside a transformed container scrolls with the page and keeps document coordinates.
|
|
42
|
+
- Heatmaps: on back / forward navigation (`popstate`), the scroll depth of the page left is no longer attributed to the page shown next; on `pushState` / `replaceState` the page left is measured before the route changes, so a scroll just before the navigation counts.
|
|
43
|
+
- Replay fixes: if gzip fails the chunk is sent as plain JSON and the upload queue never stays blocked; a chunk still waiting for gzip at page hide goes out by beacon.
|
|
44
|
+
|
|
3
45
|
## 0.2.1
|
|
4
46
|
|
|
5
47
|
- Replay: URLs are recorded absolute (same-origin images were stored as paths and did not load in the player) and each `srcset` candidate is cleaned on its own instead of the whole list being mangled.
|
package/package.json
CHANGED
package/dist/consent.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var j=`
|
|
2
|
-
:host{all:initial}
|
|
3
|
-
*{box-sizing:border-box}
|
|
4
|
-
.w{position:fixed;z-index:2147483647;left:0;right:0;bottom:0;display:flex;justify-content:center;padding:12px;pointer-events:none;
|
|
5
|
-
--bg:var(--pt-bg,var(--abg,hsl(210 20% 98%)));--fg:var(--pt-text,var(--afg,hsl(200 18% 20%)));--p:var(--pt-primary,var(--ap,#004D40));--pf:var(--pt-primary-text,var(--apf,#fff));
|
|
6
|
-
--bd:var(--pt-border,color-mix(in srgb,var(--fg) 22%,var(--bg)));--r:var(--pt-radius,var(--ar,8px));font-family:var(--pt-font,var(--f,system-ui,-apple-system,"Segoe UI",sans-serif))}
|
|
7
|
-
.w.d{--abg:hsl(200 18% 16%);--afg:hsl(210 20% 94%);--ap:hsl(162 65% 42%);--apf:hsl(200 18% 10%)}
|
|
8
|
-
.w.bl{justify-content:flex-start}
|
|
9
|
-
.w.c{inset:0;align-items:center;background:rgb(0 0 0/.45);pointer-events:auto}
|
|
10
|
-
.b{pointer-events:auto;width:100%;max-width:720px;max-height:90vh;overflow:auto;background:var(--bg);color:var(--fg);border:1px solid var(--bd);border-radius:min(calc(var(--r) * 1.5),16px);padding:20px;box-shadow:0 8px 32px rgb(0 0 0/.2);font-size:15px;line-height:1.5}
|
|
11
|
-
.bl .b{max-width:380px}
|
|
12
|
-
h2{margin:0 0 8px;font-size:17px;font-weight:600}
|
|
13
|
-
p{margin:0 0 16px}
|
|
14
|
-
img{height:28px;margin-bottom:8px;display:block}
|
|
15
|
-
.r{display:flex;gap:8px;flex-wrap:wrap}
|
|
16
|
-
button{flex:1 1 140px;min-height:44px;padding:10px 16px;font:inherit;font-weight:600;cursor:pointer;color:var(--pf);background:var(--p);border:2px solid var(--p);border-radius:var(--r)}
|
|
17
|
-
.m{position:fixed;z-index:2147483646;left:16px;bottom:16px;flex:none;width:44px;height:44px;min-height:0;padding:10px;border-radius:50%;box-shadow:0 2px 10px rgb(0 0 0/.25)}
|
|
18
|
-
.m svg{display:block;width:100%;height:100%}
|
|
19
|
-
button:hover{filter:brightness(1.1)}
|
|
20
|
-
button:focus-visible,input:focus-visible,.b:focus-visible{outline:3px solid var(--fg);outline-offset:2px}
|
|
21
|
-
.l{margin:0 0 16px;padding:0;list-style:none;border-top:1px solid var(--bd)}
|
|
22
|
-
.l li{display:flex;gap:12px;align-items:flex-start;padding:10px 0;border-bottom:1px solid var(--bd)}
|
|
23
|
-
.l input{width:22px;height:22px;margin:2px 0 0;accent-color:var(--p);flex:none}
|
|
24
|
-
.l label{display:block;cursor:pointer}.l small{display:block;opacity:.85}
|
|
25
|
-
.l[hidden]{display:none}
|
|
26
|
-
`,b=t=>{let o=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t||"");if(o)return o.slice(1).map(r=>parseInt(r,16));let e=/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/.exec(t||"");return!e||e[4]!==void 0&&parseFloat(e[4])/(e[4].endsWith("%")?100:1)<.5?null:e.slice(1,4).map(Number)},H=t=>t.map(o=>{let e=o/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}).reduce((o,e,r)=>o+e*[.2126,.7152,.0722][r],0),E=t=>{let o=b(t);return o&&H(o)>.4?"#000":"#fff"};function z(){let t=s=>s?getComputedStyle(s):null,o=t(document.body),e={};if(!o)return e;o.fontFamily&&(e["--f"]=o.fontFamily);let r=[document.body,document.documentElement].map(s=>t(s).backgroundColor).find(s=>b(s));r&&b(o.color)&&(e["--abg"]=r,e["--afg"]=o.color);let n=[...document.querySelectorAll("button:not([disabled]),[role=button],a[class*=btn],a[class*=button],input[type=submit]")].find(s=>!s.closest("[data-pt-consent],[data-pt-consent-manage]")&&b(t(s).backgroundColor)&&t(s).display!=="none"&&t(s).visibility!=="hidden"),l=n?t(n).backgroundColor:t(document.querySelector("a[href]"))?.color;l&&b(l)&&(e["--ap"]=l,e["--apf"]=n&&b(t(n).color)?t(n).color:E(l));let a=n&&parseFloat(t(n).borderTopLeftRadius);return a!==void 0&&a>=0&&a<40&&(e["--ar"]=a+"px"),e}var c=(t,o,e,r)=>{let n=document.createElement(t);return o&&(n.className=o),e!==void 0&&(n.textContent=e),r?.appendChild(n),n},A=t=>t.texts[(navigator.language||"en").slice(0,2)]??t.texts.en??Object.values(t.texts)[0];function S(t,o,e){let r=t.style,n=document.createElement("div");n.setAttribute(o,"");let l=n.attachShadow({mode:"open"}),a=c("div",e),s=z();for(let[f,p]of Object.entries(s))a.style.setProperty(f,p);return!s["--abg"]&&!r.primary&&!r.background&&!r.text&&matchMedia("(prefers-color-scheme: dark)").matches&&a.classList.add("d"),r.primary&&(a.style.setProperty("--p",r.primary),a.style.setProperty("--pf",E(r.primary))),r.background&&a.style.setProperty("--bg",r.background),r.text&&a.style.setProperty("--fg",r.text),r.font&&a.style.setProperty("--f",r.font),l.append(c("style","",j),a),{host:n,root:l,wrap:a}}var L=(t,o)=>{let e=()=>{document.body.appendChild(t),o?.()};document.body?e():document.addEventListener("DOMContentLoaded",e,{once:!0})};function N(t,o){let e=A(t);if(!e)return()=>{};let{host:r,wrap:n}=S(t,"data-pt-consent-manage","w"),l=c("button","m",void 0,n);l.type="button",l.setAttribute("aria-label",e.manage),l.title=e.manage;let a="http://www.w3.org/2000/svg",s=document.createElementNS(a,"svg"),f=document.createElementNS(a,"path");return s.setAttribute("viewBox","0 0 24 24"),s.setAttribute("fill","currentColor"),s.setAttribute("aria-hidden","true"),f.setAttribute("d","M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5Zm-3.5 8a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm-5 3a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"),s.append(f),l.append(s),l.onclick=o,L(r),()=>r.remove()}function P({cfg:t,current:o,onChoice:e,onClose:r}){let n=A(t);if(!n)return()=>{};let l=t.style.position??"bottom",{host:a,root:s,wrap:f}=S(t,"data-pt-consent","w"+(l==="center"?" c":l==="bottom-left"?" bl":"")),p=c("div","b",void 0,f);if(p.setAttribute("role","dialog"),p.setAttribute("aria-modal",String(l==="center")),p.setAttribute("aria-labelledby","pt-t"),p.setAttribute("aria-describedby","pt-d"),p.tabIndex=-1,t.style.logo_url&&/^(https:|\/)/.test(t.style.logo_url)){let i=c("img","",void 0,p);i.src=t.style.logo_url,i.alt=""}c("h2","",n.title,p).id="pt-t",c("p","",n.body,p).id="pt-d";let k=[],m=c("ul","l",void 0,p);m.hidden=!o;for(let i of t.categories){let u=c("li","",void 0,m),d=c("input","",void 0,u);d.type="checkbox",d.id="pt-"+i.key,d.disabled=i.required||i.key==="necessary",d.checked=d.disabled||!!o?.[i.key];let v=c("label","",void 0,u);v.htmlFor=d.id,c("strong","",n.categories[i.key]?.label??i.key,v),c("small","",n.categories[i.key]?.description??"",v),k.push([i.key,d])}let M=c("div","r",void 0,p),g=(i,u)=>{let d=c("button","",i,M);return d.type="button",d.onclick=u,d},x=i=>y(Object.fromEntries(k.map(([u,d])=>[u,i===null?d.checked:i||d.disabled])));g(n.reject_all,()=>x(!1));let h=g(o?n.save:n.customize,()=>{if(!m.hidden)return x(null);m.hidden=!1,h.textContent=n.save,h.setAttribute("aria-expanded","true")});h.setAttribute("aria-expanded",String(!m.hidden)),g(n.accept_all,()=>x(!0));let T=document.activeElement,w=matchMedia("(prefers-reduced-motion: reduce)").matches,C=!1;function y(i){if(C)return;C=!0,i&&e(i);let u=!1,d=()=>{u||(u=!0,a.remove(),T?.focus?.(),r())};if(w||!p.animate)return d();p.animate({opacity:[1,0]},{duration:150,easing:"ease-in"}).onfinish=d,setTimeout(d,300)}return p.addEventListener("keydown",i=>{if(i.key==="Escape")return y();if(i.key!=="Tab"||l!=="center")return;let u=[...s.querySelectorAll("input:not(:disabled),button")],d=u[(u.indexOf(s.activeElement)+(i.shiftKey?-1:1)+u.length)%u.length];i.preventDefault(),d.focus()}),L(a,()=>{p.focus({preventScroll:!0}),!w&&p.animate&&p.animate({opacity:[0,1],transform:["translateY(16px)","translateY(0)"]},{duration:250,easing:"ease-out"})}),()=>y()}export{N as manage,z as pageTheme,b as rgb,P as show};
|
package/dist/esm/consent.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var j=`
|
|
2
|
-
:host{all:initial}
|
|
3
|
-
*{box-sizing:border-box}
|
|
4
|
-
.w{position:fixed;z-index:2147483647;left:0;right:0;bottom:0;display:flex;justify-content:center;padding:12px;pointer-events:none;
|
|
5
|
-
--bg:var(--pt-bg,var(--abg,hsl(210 20% 98%)));--fg:var(--pt-text,var(--afg,hsl(200 18% 20%)));--p:var(--pt-primary,var(--ap,#004D40));--pf:var(--pt-primary-text,var(--apf,#fff));
|
|
6
|
-
--bd:var(--pt-border,color-mix(in srgb,var(--fg) 22%,var(--bg)));--r:var(--pt-radius,var(--ar,8px));font-family:var(--pt-font,var(--f,system-ui,-apple-system,"Segoe UI",sans-serif))}
|
|
7
|
-
.w.d{--abg:hsl(200 18% 16%);--afg:hsl(210 20% 94%);--ap:hsl(162 65% 42%);--apf:hsl(200 18% 10%)}
|
|
8
|
-
.w.bl{justify-content:flex-start}
|
|
9
|
-
.w.c{inset:0;align-items:center;background:rgb(0 0 0/.45);pointer-events:auto}
|
|
10
|
-
.b{pointer-events:auto;width:100%;max-width:720px;max-height:90vh;overflow:auto;background:var(--bg);color:var(--fg);border:1px solid var(--bd);border-radius:min(calc(var(--r) * 1.5),16px);padding:20px;box-shadow:0 8px 32px rgb(0 0 0/.2);font-size:15px;line-height:1.5}
|
|
11
|
-
.bl .b{max-width:380px}
|
|
12
|
-
h2{margin:0 0 8px;font-size:17px;font-weight:600}
|
|
13
|
-
p{margin:0 0 16px}
|
|
14
|
-
img{height:28px;margin-bottom:8px;display:block}
|
|
15
|
-
.r{display:flex;gap:8px;flex-wrap:wrap}
|
|
16
|
-
button{flex:1 1 140px;min-height:44px;padding:10px 16px;font:inherit;font-weight:600;cursor:pointer;color:var(--pf);background:var(--p);border:2px solid var(--p);border-radius:var(--r)}
|
|
17
|
-
.m{position:fixed;z-index:2147483646;left:16px;bottom:16px;flex:none;width:44px;height:44px;min-height:0;padding:10px;border-radius:50%;box-shadow:0 2px 10px rgb(0 0 0/.25)}
|
|
18
|
-
.m svg{display:block;width:100%;height:100%}
|
|
19
|
-
button:hover{filter:brightness(1.1)}
|
|
20
|
-
button:focus-visible,input:focus-visible,.b:focus-visible{outline:3px solid var(--fg);outline-offset:2px}
|
|
21
|
-
.l{margin:0 0 16px;padding:0;list-style:none;border-top:1px solid var(--bd)}
|
|
22
|
-
.l li{display:flex;gap:12px;align-items:flex-start;padding:10px 0;border-bottom:1px solid var(--bd)}
|
|
23
|
-
.l input{width:22px;height:22px;margin:2px 0 0;accent-color:var(--p);flex:none}
|
|
24
|
-
.l label{display:block;cursor:pointer}.l small{display:block;opacity:.85}
|
|
25
|
-
.l[hidden]{display:none}
|
|
26
|
-
`,b=t=>{let o=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t||"");if(o)return o.slice(1).map(r=>parseInt(r,16));let e=/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/.exec(t||"");return!e||e[4]!==void 0&&parseFloat(e[4])/(e[4].endsWith("%")?100:1)<.5?null:e.slice(1,4).map(Number)},H=t=>t.map(o=>{let e=o/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}).reduce((o,e,r)=>o+e*[.2126,.7152,.0722][r],0),E=t=>{let o=b(t);return o&&H(o)>.4?"#000":"#fff"};function z(){let t=s=>s?getComputedStyle(s):null,o=t(document.body),e={};if(!o)return e;o.fontFamily&&(e["--f"]=o.fontFamily);let r=[document.body,document.documentElement].map(s=>t(s).backgroundColor).find(s=>b(s));r&&b(o.color)&&(e["--abg"]=r,e["--afg"]=o.color);let n=[...document.querySelectorAll("button:not([disabled]),[role=button],a[class*=btn],a[class*=button],input[type=submit]")].find(s=>!s.closest("[data-pt-consent],[data-pt-consent-manage]")&&b(t(s).backgroundColor)&&t(s).display!=="none"&&t(s).visibility!=="hidden"),l=n?t(n).backgroundColor:t(document.querySelector("a[href]"))?.color;l&&b(l)&&(e["--ap"]=l,e["--apf"]=n&&b(t(n).color)?t(n).color:E(l));let a=n&&parseFloat(t(n).borderTopLeftRadius);return a!==void 0&&a>=0&&a<40&&(e["--ar"]=a+"px"),e}var c=(t,o,e,r)=>{let n=document.createElement(t);return o&&(n.className=o),e!==void 0&&(n.textContent=e),r?.appendChild(n),n},A=t=>t.texts[(navigator.language||"en").slice(0,2)]??t.texts.en??Object.values(t.texts)[0];function S(t,o,e){let r=t.style,n=document.createElement("div");n.setAttribute(o,"");let l=n.attachShadow({mode:"open"}),a=c("div",e),s=z();for(let[f,p]of Object.entries(s))a.style.setProperty(f,p);return!s["--abg"]&&!r.primary&&!r.background&&!r.text&&matchMedia("(prefers-color-scheme: dark)").matches&&a.classList.add("d"),r.primary&&(a.style.setProperty("--p",r.primary),a.style.setProperty("--pf",E(r.primary))),r.background&&a.style.setProperty("--bg",r.background),r.text&&a.style.setProperty("--fg",r.text),r.font&&a.style.setProperty("--f",r.font),l.append(c("style","",j),a),{host:n,root:l,wrap:a}}var L=(t,o)=>{let e=()=>{document.body.appendChild(t),o?.()};document.body?e():document.addEventListener("DOMContentLoaded",e,{once:!0})};function N(t,o){let e=A(t);if(!e)return()=>{};let{host:r,wrap:n}=S(t,"data-pt-consent-manage","w"),l=c("button","m",void 0,n);l.type="button",l.setAttribute("aria-label",e.manage),l.title=e.manage;let a="http://www.w3.org/2000/svg",s=document.createElementNS(a,"svg"),f=document.createElementNS(a,"path");return s.setAttribute("viewBox","0 0 24 24"),s.setAttribute("fill","currentColor"),s.setAttribute("aria-hidden","true"),f.setAttribute("d","M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5Zm-3.5 8a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm-5 3a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"),s.append(f),l.append(s),l.onclick=o,L(r),()=>r.remove()}function P({cfg:t,current:o,onChoice:e,onClose:r}){let n=A(t);if(!n)return()=>{};let l=t.style.position??"bottom",{host:a,root:s,wrap:f}=S(t,"data-pt-consent","w"+(l==="center"?" c":l==="bottom-left"?" bl":"")),p=c("div","b",void 0,f);if(p.setAttribute("role","dialog"),p.setAttribute("aria-modal",String(l==="center")),p.setAttribute("aria-labelledby","pt-t"),p.setAttribute("aria-describedby","pt-d"),p.tabIndex=-1,t.style.logo_url&&/^(https:|\/)/.test(t.style.logo_url)){let i=c("img","",void 0,p);i.src=t.style.logo_url,i.alt=""}c("h2","",n.title,p).id="pt-t",c("p","",n.body,p).id="pt-d";let k=[],m=c("ul","l",void 0,p);m.hidden=!o;for(let i of t.categories){let u=c("li","",void 0,m),d=c("input","",void 0,u);d.type="checkbox",d.id="pt-"+i.key,d.disabled=i.required||i.key==="necessary",d.checked=d.disabled||!!o?.[i.key];let v=c("label","",void 0,u);v.htmlFor=d.id,c("strong","",n.categories[i.key]?.label??i.key,v),c("small","",n.categories[i.key]?.description??"",v),k.push([i.key,d])}let M=c("div","r",void 0,p),g=(i,u)=>{let d=c("button","",i,M);return d.type="button",d.onclick=u,d},x=i=>y(Object.fromEntries(k.map(([u,d])=>[u,i===null?d.checked:i||d.disabled])));g(n.reject_all,()=>x(!1));let h=g(o?n.save:n.customize,()=>{if(!m.hidden)return x(null);m.hidden=!1,h.textContent=n.save,h.setAttribute("aria-expanded","true")});h.setAttribute("aria-expanded",String(!m.hidden)),g(n.accept_all,()=>x(!0));let T=document.activeElement,w=matchMedia("(prefers-reduced-motion: reduce)").matches,C=!1;function y(i){if(C)return;C=!0,i&&e(i);let u=!1,d=()=>{u||(u=!0,a.remove(),T?.focus?.(),r())};if(w||!p.animate)return d();p.animate({opacity:[1,0]},{duration:150,easing:"ease-in"}).onfinish=d,setTimeout(d,300)}return p.addEventListener("keydown",i=>{if(i.key==="Escape")return y();if(i.key!=="Tab"||l!=="center")return;let u=[...s.querySelectorAll("input:not(:disabled),button")],d=u[(u.indexOf(s.activeElement)+(i.shiftKey?-1:1)+u.length)%u.length];i.preventDefault(),d.focus()}),L(a,()=>{p.focus({preventScroll:!0}),!w&&p.animate&&p.animate({opacity:[0,1],transform:["translateY(16px)","translateY(0)"]},{duration:250,easing:"ease-out"})}),()=>y()}export{N as manage,z as pageTheme,b as rgb,P as show};
|
package/dist/esm/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var ve=["token","access_token","id_token","refresh_token","password","pwd","secret","key","api_key","apikey","auth","authorization","code","session","sid","email","mail","signature","sig","otp"];function P(){let e=crypto.getRandomValues(new Uint8Array(16)),t=Date.now();for(let r=5;r>=0;r--)e[r]=t%256,t=Math.floor(t/256);e[6]=e[6]&15|112,e[8]=e[8]&63|128;let n=Array.from(e,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}var V=(e,t)=>String(e??"").slice(0,t);function R(e,t){try{let n=new URL(e,location.href);n.username=n.password="";for(let r of[...n.searchParams.keys()])t.includes(r.toLowerCase())&&n.searchParams.delete(r);return/^#\/[^?=&]*$/.test(n.hash)||(n.hash=""),n.href}catch{return""}}function ye(e){let t=[];for(let n=e,r=0;n&&n!==document.documentElement&&r<4;n=n.parentElement,r++){let o=n.tagName.toLowerCase();if(n.id&&/^[\w-]{1,40}$/.test(n.id)&&!/\d{3,}/.test(n.id)){t.unshift(`${o}#${n.id}`);break}let i=[...n.classList].find(a=>/^[a-zA-Z][\w-]{0,30}$/.test(a)&&!/\d{3,}/.test(a));i&&(o+=`.${i}`),t.unshift(o)}return t.join(" > ").slice(0,120)}async function ee(e){if(typeof CompressionStream>"u")return new Blob([e],{type:"text/plain"});let t=await new Response(new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"))).blob();return new Blob([t],{type:"text/plain"})}var et="a[href],button,summary,[role=button],[data-pt-event]",tt=1e3,nt=500;function we(e,t,n){let r,o=0,i=[],a=!1;return t(()=>{a=!0}),addEventListener("pagehide",()=>{a=!0}),addEventListener("click",s=>{let c=s.target;if(!s.isTrusted||!(c instanceof Element)||o++>=nt||c.closest("[data-pt-block]"))return;let l=ye(c),p=Math.round(s.clientX+scrollX),f=Math.round(s.clientY+scrollY),u=document.documentElement,C=c.closest("[data-pt-event]")?.getAttribute("data-pt-event"),b={selector:l,x:p,y:f,doc_w:u.scrollWidth,doc_h:u.scrollHeight};if(e("$autocapture",{...b,tag:c.tagName.toLowerCase(),pt_event:C||void 0}),C&&e(C.slice(0,100),{selector:l}),!n.frustration)return;let y=s.timeStamp||Date.now();r=b,setTimeout(()=>{r===b&&(r=void 0)},tt),i=i.filter(Z=>y-Z.t<1e3&&Math.hypot(Z.x-p,Z.y-f)<30),i.push({t:y,x:p,y:f}),i.length>=3&&(e("$rageclick",{...b,count:i.length}),i=[]);let D=c.closest(et);if(!D||D.closest("a[target=_blank],a[download]")||/^(mailto|tel):/.test(D.getAttribute("href")||""))return;a=!1;let J=!1,X=new MutationObserver(()=>{J=!0});X.observe(u,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),setTimeout(()=>{X.disconnect(),!J&&!a&&e("$deadclick",b)},1e3)},{capture:!0,passive:!0}),s=>{r&&(e("$errorclick",{...r,...s}),r=void 0)}}function be(e,t){let n=0,r=!1,o=0,i=()=>{let c=document.documentElement,l=Math.max(c.scrollHeight,1);return Math.min(100,Math.round((scrollY+c.clientHeight)/l*100))},a=()=>{o=0,n=Math.max(n,i())},s=()=>{if(r)return;r=!0;let c=document.documentElement;e("$scroll_depth",{max_pct:Math.max(n,i()),doc_h:c.scrollHeight,viewport_h:c.clientHeight})};addEventListener("scroll",()=>{o||(o=requestAnimationFrame(a))},{passive:!0}),addEventListener("pagehide",s),addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&s()),t(()=>{s(),r=!1,n=0})}function te(e,t=0){let n=new TextEncoder().encode(e),r=t>>>0,o=3432918353,i=461845907,a=n.length&-4;for(let c=0;c<a;c+=4){let l=n[c]|n[c+1]<<8|n[c+2]<<16|n[c+3]<<24;l=Math.imul(l,o),l=l<<15|l>>>17,l=Math.imul(l,i),r^=l,r=r<<13|r>>>19,r=Math.imul(r,5)+3864292196|0}let s=0;switch(n.length&3){case 3:s^=n[a+2]<<16;case 2:s^=n[a+1]<<8;case 1:s^=n[a],s=Math.imul(s,o),s=s<<15|s>>>17,s=Math.imul(s,i),r^=s}return r^=n.length,r^=r>>>16,r=Math.imul(r,2246822507),r^=r>>>13,r=Math.imul(r,3266489909),r^=r>>>16,r>>>0}function Se(e,t,n=""){return te(`${e}.${t}${n}`)/4294967296}function Ce(e,t){let n=e.split(/[.+-]/).map(o=>parseInt(o,10)||0),r=t.split(/[.+-]/).map(o=>parseInt(o,10)||0);for(let o=0;o<3;o++)if((n[o]??0)!==(r[o]??0))return(n[o]??0)-(r[o]??0);return 0}function rt(e,t){let n=t[e.property];if(e.operator==="is_set")return n!=null;if(e.operator==="is_not_set")return n==null;if(n==null)return!1;let r=String(n),o=Array.isArray(e.value)?e.value.map(String):[String(e.value)];switch(e.operator){case"eq":return r===String(e.value);case"neq":return r!==String(e.value);case"in":return o.includes(r);case"nin":return!o.includes(r);case"contains":return r.toLowerCase().includes(String(e.value).toLowerCase());case"ncontains":return!r.toLowerCase().includes(String(e.value).toLowerCase());case"regex":if(r.length>1024)return!1;try{return new RegExp(String(e.value)).test(r)}catch{return!1}case"gt":return Number(n)>Number(e.value);case"gte":return Number(n)>=Number(e.value);case"lt":return Number(n)<Number(e.value);case"lte":return Number(n)<=Number(e.value);case"semver_gte":return Ce(r,String(e.value))>=0;case"semver_lt":return Ce(r,String(e.value))<0}}function _e(e,t,n={}){if(!e.active)return{enabled:!1};let o=(e.groups.length?e.groups:[{conditions:[]}]).find(s=>s.conditions.every(c=>rt(c,n)));if(!o)return{enabled:!1};let i=o.rollout_percent??e.rollout_percent;if(Se(e.key,t)*100>=i)return{enabled:!1};if(!e.variants?.length)return ke({enabled:!0},e.payloads?.true);let a=o.variant;if(!a){let s=Se(e.key,t,".variant")*100,c=0;a=e.variants[e.variants.length-1].key;for(let l of e.variants)if(c+=l.weight,s<c){a=l.key;break}}return ke({enabled:!0,variant:a},e.payloads?.[a])}function ke(e,t){return t===void 0?e:{...e,payload:t}}var ot=/\/(\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?=[/?#]|$)/gi;function Ee(e,t,n){if(t.errors){let r=0,o=(i,a,s="",c)=>{if(r++>=20)return;let l=s.split(`
|
|
2
|
-
`).slice(1,4).map(y=>y.replace(/[:\d]+\)?$/,"")).join("|"),p=te([i,a.replace(/\d+/g,"N"),l].join("|")).toString(16),f=t.drop().map(y=>y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),u=y=>y.replace(/https?:\/\/[^\s)'"]+/gi,D=>{let[,J,X=""]=D.match(/^(.*?)(:\d+:\d+)?$/);return R(J,t.drop())+X}),C=y=>f?y.replace(new RegExp(`([?&;#]|%3[bf]|%26|%23)(${f})(=|%3d)(?:%(?!26|23|3b)[0-9a-f]{2}|(?!:\\d+:\\d+(?:$|[\\s)]))[^&\\s)'"#%])*`,"gi"),"$1$2$3[redacted]"):y,b=y=>C(u(C(y)));t.onError?.({fingerprint:p,type:i}),e("$error",{message:V(b(a),500),stack:V(b(s),4e3),type:i,fingerprint:p,release:t.release,filename:c&&R(c,t.drop())})};addEventListener("error",i=>o(i.error?.name||"Error",i.message,i.error?.stack,i.filename)),addEventListener("unhandledrejection",i=>{let a=i.reason;o(a?.name||"UnhandledRejection",a?.message??String(a),a?.stack)})}if(t.network){let r=0,o=(s,c,l,p)=>{if(r>=200||c.startsWith(t.host))return;r++;let f=R(c,t.drop()).replace(ot,"/:id");e("$network",{method:s,url:f,status:l,duration_ms:Math.round(performance.now()-p)})},i=window.fetch;i&&(window.fetch=function(s,c){let l=performance.now(),p=(c?.method||(s instanceof Request?s.method:"GET")).toUpperCase(),f=typeof s=="string"?s:s instanceof URL?s.href:s.url;return i.call(this,s,c).then(u=>(o(p,f,u.status,l),u),u=>{throw o(p,f,0,l),u})});let a=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(s,c,...l){let p=performance.now();return this.addEventListener("loadend",()=>o(s.toUpperCase(),String(c),this.status,p)),a.call(this,s,c,...l)}}if(t.console){let r=0;for(let o of t.console){let i=console[o];console[o]=(...a)=>{i.apply(console,a),r++<100&&e("$console",{level:o,message:V(a.map(s=>typeof s=="string"?s:s instanceof Error?s.message:st(s)).join(" "),500)})}}}t.vitals&&typeof PerformanceObserver<"u"&&it(e,n)}var st=e=>{try{return JSON.stringify(e)}catch{return String(e)}};function it(e,t){let n,r=0,o=0,i=0,a=0,s=[],c=0,l=(u,C,b={})=>{try{new PerformanceObserver(y=>y.getEntries().forEach(C)).observe({type:u,buffered:!0,...b})}catch{}};l("largest-contentful-paint",u=>{n=u.startTime}),l("layout-shift",u=>{u.hadRecentInput||(o&&u.startTime-i<1e3&&u.startTime-a<5e3?o+=u.value:(o=u.value,a=u.startTime),i=u.startTime,r=Math.max(r,o))});let p=new Set;l("event",u=>{u.interactionId&&(p.has(u.interactionId)||(p.add(u.interactionId),c++),s=[...s,u.duration].sort((C,b)=>b-C).slice(0,10))},{durationThreshold:40});let f=()=>{let u={lcp:n&&Math.round(n),inp:s.length?s[Math.min(9,Math.floor(c/50))]:void 0,cls:r?+r.toFixed(4):void 0};(u.lcp!==void 0||u.inp!==void 0||u.cls!==void 0)&&e("$web_vitals",u),r=o=0,s=[],c=0,p.clear(),n=void 0};addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&f()),t(f)}function xe(e){let t=[],n={},r=0,o=new Set,i=new Set;try{let l=e.load();l&&(t=JSON.parse(l))}catch{}async function a(l=!0){let p=await e.json(`/i/v1/flags/definitions?key=${encodeURIComponent(e.key)}${e.env?`&env=${e.env}`:""}`);if(p?.flags&&(t=p.flags,e.save(JSON.stringify(t))),l&&e.canPost()){let f=await e.json("/i/v1/flags",{api_key:e.key,distinct_id:e.id(),environment:e.env,properties:e.props()});f?.flags&&(n=f.flags)}o.forEach(f=>f())}function s(){r||typeof setInterval>"u"||(a(),r=setInterval(()=>document.visibilityState!=="hidden"&&a(!1),e.pollMs))}function c(l){s();let p=t.find(u=>u.key===l),f=p?_e(p,e.id(),e.props()):n[l];return f?(i.has(l)||(i.add(l),e.capture("$feature_flag_called",{flag:l,enabled:f.enabled,variant:f.variant})),f):{enabled:!1}}return{isEnabled:l=>c(l).enabled,getVariant:l=>c(l).variant,getPayload:l=>c(l).payload,reload:()=>a(),onChange(l){return s(),o.add(l),()=>{o.delete(l)}},reset(){i.clear(),r&&a()}}}var Pe=["necessary","analytics","replay","personalization","marketing"],Le=30*6e4,Oe=2e3,at=15e5,lt=100,m,N="",$="",le,W=!1,g=null,d=null,S="anon_"+P(),k=null,I={},A=null,w,h=[],q=[],G=Promise.resolve(),Te,ne=0,re=0,oe=!1,fe=!1,Ne,se,Ae="",qe={},pe=!1,v=null,ie=!1,H=!1,O=!1,ae=!1,j,E,ce=[],ue=new Set,Re="null",Ue,De=new Promise(e=>{Ue=e}),T=e=>{try{return JSON.parse(localStorage.getItem(e)||"null")}catch{return null}},_=(e,t)=>{try{t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}catch{}},K=(e,t)=>{M()==="full"&&_(e,t)},x=e=>!!e&&!!g&&Date.now()<e.t+(g.consent?.validity_days??180)*864e5&&(!g.consent||e.v===g.consent.version),U=e=>e==="necessary"||x(d)&&d.c[e]===!0,je=()=>g?.consent?.respect_gpc!==!1&&(navigator.globalPrivacyControl===!0||navigator.doNotTrack==="1"),ct=/^(Europe\/|Asia\/(Nicosia|Famagusta)$|Atlantic\/(Canary|Madeira|Azores|Reykjavik)$|Africa\/Ceuta$|Indian\/(Reunion|Mayotte)$|America\/(Guadeloupe|Martinique|Cayenne|Marigot|St_Barthelemy)$)/,Be=()=>{try{return ct.test(Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{return!0}};function M(){if(x(d))return d.c.analytics?"full":"off";if(!g)return"wait";let e=g.consent;return!e?.enabled||e.exempt_analytics||e.regions==="eu"&&!Be()?"mem":je()?"off":"wait"}function He(){let e=x(d)?d:null;return{id:e?.id,version:e?.v,categories:e?e.c:M()==="mem"?{analytics:!0}:{}}}var ut=e=>new Promise(t=>{let n=setTimeout(t,e);Ne=()=>{clearTimeout(n),t()}});async function Q(e,t,n=1/0){for(let r=0;;r++){let o=null;try{o=await fetch(e,{credentials:"omit",...t})}catch{}if(o&&o.status!==429&&o.status<500||r+1>=n)return o;await ut(Math.max((Number(o?.headers.get("retry-after"))||0)*1e3,Math.min(3e5,1e3*2**r)*(.5+Math.random()/2)))}}var ze=async(e,t,n,r)=>(await Q($+e,{method:"POST",body:await ee(t),keepalive:r},n))?.status??0,dt=async(e,t)=>{let n=await Q($+e,t?{method:"POST",body:JSON.stringify(t),headers:{"content-type":"text/plain"}}:{},1).catch(()=>null);return n?.ok?n.json().catch(()=>null):null},z=()=>[...ve,...m?.sensitiveParams??[],...g?.replay.mask.ignore_url_params??[]].map(e=>e.toLowerCase());function Fe(){let e=document.documentElement;return{url:R(location.href,z()),referrer:Ae,lang:navigator.language,viewport_w:e.clientWidth,viewport_h:e.clientHeight,platform:"web",app_version:m.release,...qe}}function B(){let e=Date.now();return(!w||e-w.t>Le)&&(w={id:P(),t:e,u:Math.random(),v:Math.random(),n:0}),w.t=e,w.id}function L(e,t={},n={}){let r={id:P(),event:e,ts:new Date().toISOString(),distinct_id:k??S,session_id:B(),environment:le,props:{...Fe(),...t},...n};k&&(r.identified=!0),Je(r),gt(e)}function Je(e){let t=M();if(t==="wait"||!g){q.push(e),q.length>lt&&q.shift();return}if(t==="off")return;let n=g.sampling;B(),!(w.u>=n.sessions||e.event!=="$identify"&&Math.random()>=n.events)&&(h.push(e)>Oe&&h.shift(),h.length>=m.batchSize?$e():ne||(ne=setTimeout(()=>{ne=0,$e()},m.batchInterval)),re||(re=setTimeout(()=>{re=0,F()},1e3)))}function F(){if(M()!=="full")return;let e=h.slice(-Oe);for(;e.length>1&&JSON.stringify(e).length>at;)e=e.slice(e.length>>1);_("pt_q",e.length?e:null),_("pt_s",w)}var Xe=e=>JSON.stringify({api_key:N,sent_at:new Date().toISOString(),consent:He(),batch:e}),Y=()=>M()==="mem"||M()==="full";async function $e(){if(!(oe||!h.length||!Y())){oe=!0;try{for(await G;h.length&&Y();){let e=h.slice(0,100);await Q($+"/i/v1/events",{method:"POST",body:await ee(Xe(e))});let t=new Set(e);h=h.filter(n=>!t.has(n)),F()}}finally{oe=!1}}}function Ie(){for(F(),v?.beacon();h.length&&Y();){let e=h.slice(0,25);if(!navigator.sendBeacon?.($+"/i/v1/events",new Blob([Xe(e)],{type:"text/plain"})))break;let t=new Set(e);h=h.filter(n=>!t.has(n))}F()}function ft(){let e=S;S=T("pt_id")||S,_("pt_id",S);let t=T("pt_s");t&&Date.now()-t.t<Le&&(w=t);let n=T("pt_u");n&&U("personalization")&&(k=n.u,I=n.tr);let r=T("pt_q");Array.isArray(r)&&(h=[...r,...h]);for(let o of[...h,...q])o.distinct_id===e&&(o.distinct_id=S);fe=!0}function Ve(){for(let e of["pt_id","pt_s","pt_q","pt_u","pt_cfg","pt_flags"])_(e,null);h=[],q=[],k=null,I={},w=void 0,fe=!1,S="anon_"+P()}function pt(){let e=Ze.get(),t=JSON.stringify(e);t!==Re&&(Re=t,ue.forEach(n=>{try{n(e)}catch{}}),dispatchEvent(new CustomEvent("pt:consent",{detail:e})))}function We(){pt();let e=M();e==="full"&&!fe&&ft(),e!=="wait"&&(q.splice(0).forEach(t=>e!=="off"&&Je(t)),Ke(),he(),A&&U("personalization")&&(ht(...A),A=null),F())}function ge(e,t){let n=x(d)?d.c:null,r={...e,necessary:!0},o=t==="withdraw"||!!n&&Pe.some(i=>n[i]&&!r[i]);d={id:d?.id||P(),v:g?.consent?.version??0,t:Date.now(),c:r,p:o?"withdraw":t},_("pt_consent",d),Ge(d),r.analytics?r.personalization||(k=null,I={},A=null,_("pt_u",null)):Ve(),r.replay||(v?.stop(),v=null),We(),E?.reset()}function Ge(e){Te=e;let t={api_key:N,consent_id:e.id,policy_version:e.v,choices:e.c,source:e.p};G=G.then(async()=>{let n=await ze("/i/v1/consent",JSON.stringify(t),6,!0);n>199&&n<300&&(delete e.p,d===e&&_("pt_consent",e))})}function Ke(){!g||!pe||document.querySelectorAll('script[type="text/plain"][data-pt-category]').forEach(e=>{if(!U(e.dataset.ptCategory))return;let t=document.createElement("script");for(let n of Array.from(e.attributes))n.name!=="type"&&n.name!=="data-pt-category"&&t.setAttribute(n.name,n.value);t.text=e.text,e.replaceWith(t)})}async function me(e){let t=g?.consent;if(!(!t||O)){O=!0,j?.(),j=void 0;try{(await import("./consent.js")).show({cfg:t,current:e&&d?d.c:null,onChoice:r=>ge(r,"banner"),onClose:()=>{O=!1,Ye()}})}catch{O=!1}}}async function Ye(){let e=g?.consent;if(!(!e?.enabled||!x(d)||O||j||ae||typeof document>"u")){ae=!0;try{if(document.readyState==="loading"&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0})),await new Promise(t=>setTimeout(t,1e3)),O||j||document.querySelector("[data-pt-consent-open]"))return;j=(await import("./consent.js")).manage(e,()=>{me(!0)})}catch{}finally{ae=!1}}}function Me(){d?.p&&d!==Te&&x(d)&&Ge(d),We();let e=g?.consent;e?.enabled&&!x(d)&&!je()&&(e.regions==="always"||Be())?me(!1):Ye()}function he(e=!1){let t=g?.replay;!pe||v||ie||H||!t?.enabled||!U("replay")||typeof document>"u"||(B(),!(w.u>=g.sampling.sessions||!(e||w.v<t.sample_rate))&&(ie=!0,import("./replay.js").then(n=>{if(v||!U("replay"))return;let r=(o,i)=>`/i/v1/replay/${o}/chunks?key=${encodeURIComponent(N)}&seq=${i}`;v=n.start({cfg:t,dropParams:z(),sessionId:B,distinctId:()=>k??S,consent:He,nextSeq:()=>(B(),w.n++),post:async(o,i,a)=>{await G;let s=await ze(r(o,i),a,6);return s===403&&(v?.stop(),v=null,H=!0),s},beacon:(o,i,a)=>!!navigator.sendBeacon?.($+r(o,i),new Blob([a],{type:"text/plain"}))})}).catch(()=>{}).finally(()=>{ie=!1})))}function gt(e){let t=g?.replay.triggers;if(!t||v)return;let n=location.pathname+location.search,r=o=>new RegExp("^"+o.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(n);(e==="$error"&&t.on_error||t.events?.includes(e)||e==="$pageview"&&t.url_patterns?.some(r))&&he(!0)}function de(){let e=R(location.href,z());if(e===se)return;Ae=se??R(document.referrer,z()),se=e;let t=new URL(location.href).searchParams;for(let[n,r]of t)n.startsWith("utm_")&&(qe[n]=r.slice(0,200));L("$pageview")}function mt(){for(let e of["pushState","replaceState"]){let t=history[e];history[e]=function(...n){ce.forEach(o=>o());let r=t.apply(this,n);return de(),r}}addEventListener("popstate",()=>{ce.forEach(e=>e()),de()})}function Lt(e,t){if(W||typeof window>"u")return;W=!0,N=e,m={batchInterval:5e3,batchSize:20,...t},$=m.host.replace(/\/$/,""),le=m.environment,d=T("pt_consent");let n=d?.c.analytics?T("pt_cfg"):null;n&&n.consent?.version===d.v&&(g=n,Me()),E=xe({key:N,env:le,pollMs:m.flagsPollMs??3e4,capture:L,json:dt,id:()=>k??S,props:()=>({...Fe(),$platform:"web",...I}),load:()=>M()==="full"?localStorage.getItem("pt_flags"):null,save:i=>K("pt_flags",JSON.parse(i)),canPost:()=>Y()}),(async()=>{let i=await Q(`${$}/i/v1/config?key=${encodeURIComponent(N)}`,{},5),a=i?.ok?await i.json().catch(()=>null):null;a&&(g=a,pe=!0,K("pt_cfg",a),x(d)||(v?.stop(),v=null),Me(),Ue())})();let r=i=>{ce.push(i)};m.autocapture!==!1&&be(L,r),addEventListener("online",()=>Ne?.()),document.addEventListener("click",i=>{i.target?.closest?.("[data-pt-consent-open]")&&(i.preventDefault(),Ze.open())}),addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible"){H||v?.resume();return}Ie(),v?.pause()}),addEventListener("pagehide",Ie),m.pageviews!==!1&&(mt(),de());let o=m.autocapture!==!1?we(L,r,{frustration:m.frustration!==!1}):void 0;Ee(L,{errors:m.errors!==!1,network:m.network!==!1,vitals:m.vitals!==!1,console:m.console===void 0?["warn","error"]:m.console,drop:z,host:$,release:m.release,onError:o},r),document.addEventListener("DOMContentLoaded",Ke)}function Ot(e,t){W&&L(e,t)}function ht(e,t={}){if(!W)return;if(!U("personalization")){A=[e,t];return}let n=S;k=e,I={...I,...t},K("pt_u",{u:k,tr:I}),L("$identify",{},{anonymous_id:n,traits:t}),E?.reset()}function Tt(){k=null,I={},A=null,w=void 0,S="anon_"+P(),_("pt_u",null),_("pt_s",null),K("pt_id",S),E?.reset()}var Qe=e=>g?e():void De.then(e),Nt=e=>Qe(()=>ge(Object.fromEntries((e??Pe).map(t=>[t,!0])),"api")),At=()=>{Ve(),Qe(()=>ge({},"withdraw"))},Ze={open:()=>De.then(()=>me(!0)),get:()=>x(d)?{...d.c}:null,onChange:e=>(ue.add(e),()=>{ue.delete(e)})},qt={pause(){H=!0,v?.pause()},resume(){H=!1,v?v.resume():he()}},Ut={isEnabled:e=>E?.isEnabled(e)??!1,getVariant:e=>E?.getVariant(e),getPayload:e=>E?.getPayload(e),reload:()=>E?.reload(),onChange:e=>E?.onChange(e)??(()=>{})};export{Ze as consent,Ut as flags,ht as identify,Lt as init,Nt as optIn,At as optOut,qt as replay,Tt as reset,Ot as track};
|