bitsnap-react 1.9.0 → 1.11.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 +95 -7
- package/dist/CartProvider-ONIOELW5.mjs +2 -0
- package/dist/CartProvider-Q3CIVK5K.js +2 -0
- package/dist/CartProvider-Q3CIVK5K.js.map +1 -0
- package/dist/analytics.d.mts +22 -5
- package/dist/analytics.d.ts +22 -5
- package/dist/analytics.js +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.d.mts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/chunk-7RGH57QG.js +2 -0
- package/dist/chunk-7RGH57QG.js.map +1 -0
- package/dist/chunk-ADYVTMGH.mjs +2 -0
- package/dist/chunk-ADYVTMGH.mjs.map +1 -0
- package/dist/{chunk-FHDFLSPW.js → chunk-ASNUY3EU.js} +2 -2
- package/dist/chunk-ASNUY3EU.js.map +1 -0
- package/dist/{chunk-HKVMSMDF.mjs → chunk-C5Q7DGCD.mjs} +2 -2
- package/dist/{chunk-LJWS6ZRJ.mjs → chunk-C5RMHUOG.mjs} +2 -2
- package/dist/{chunk-KG6RU37U.js → chunk-CUQ2PNCJ.js} +3 -3
- package/dist/chunk-CUQ2PNCJ.js.map +1 -0
- package/dist/{chunk-VXB7LA4E.js → chunk-ELGNOAH4.js} +2 -2
- package/dist/chunk-ELGNOAH4.js.map +1 -0
- package/dist/chunk-EZWH6BB2.mjs +2 -0
- package/dist/chunk-EZWH6BB2.mjs.map +1 -0
- package/dist/{chunk-SLLBTQTW.mjs → chunk-GPNALARZ.mjs} +2 -2
- package/dist/chunk-GT3OH55Y.js +2 -0
- package/dist/chunk-GT3OH55Y.js.map +1 -0
- package/dist/{chunk-SZ256RCC.mjs → chunk-H3YP2QPV.mjs} +2 -2
- package/dist/chunk-HG4YOJWE.mjs +4 -0
- package/dist/chunk-HG4YOJWE.mjs.map +1 -0
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/{chunk-VM6JEJFZ.js → chunk-PUYK4YHE.js} +2 -2
- package/dist/chunk-PUYK4YHE.js.map +1 -0
- package/dist/chunk-T57337WD.mjs +2 -0
- package/dist/chunk-T57337WD.mjs.map +1 -0
- package/dist/{chunk-3IMJALBX.js → chunk-VQQBBSK2.js} +2 -2
- package/dist/chunk-VQQBBSK2.js.map +1 -0
- package/dist/chunk-XIHGWNTS.js +2 -0
- package/dist/chunk-XIHGWNTS.js.map +1 -0
- package/dist/{chunk-GN63ITLA.mjs → chunk-XQ43IC4M.mjs} +2 -2
- package/dist/{chunk-V4U2PTKN.js → chunk-YFETPEI6.js} +2 -2
- package/dist/chunk-YFETPEI6.js.map +1 -0
- package/dist/consent.d.mts +7 -0
- package/dist/consent.d.ts +7 -0
- package/dist/consent.js +29 -15
- package/dist/consent.js.map +1 -1
- package/dist/consent.mjs +29 -15
- package/dist/consent.mjs.map +1 -1
- package/dist/course.d.mts +2 -2
- package/dist/course.d.ts +2 -2
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/course.mjs.map +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/embed/consent.js +27 -13
- package/dist/errors.js.map +1 -1
- package/dist/index.d.mts +40 -8
- package/dist/index.d.ts +40 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{instrument-C_abZLHk.d.ts → instrument-CmxK7S4T.d.mts} +22 -5
- package/dist/{instrument-C_abZLHk.d.mts → instrument-CmxK7S4T.d.ts} +22 -5
- package/dist/internal.js.map +1 -1
- package/dist/methods-C5HWYPPN.mjs +2 -0
- package/dist/methods-CHNMFVFV.js +2 -0
- package/dist/methods-CHNMFVFV.js.map +1 -0
- package/dist/models.js.map +1 -1
- package/dist/returns.d.mts +1 -1
- package/dist/returns.d.ts +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/{types-D_WnqwR_.d.mts → types-BnVWLcoB.d.mts} +1 -1
- package/dist/{types-BaqLJYuq.d.ts → types-i-IuN4Im.d.ts} +1 -1
- package/package.json +2 -2
- package/dist/CartProvider-XWTLBIZ5.js +0 -2
- package/dist/CartProvider-XWTLBIZ5.js.map +0 -1
- package/dist/CartProvider-ZURLJNBW.mjs +0 -2
- package/dist/chunk-3IMJALBX.js.map +0 -1
- package/dist/chunk-3UHPJ6NK.js +0 -2
- package/dist/chunk-3UHPJ6NK.js.map +0 -1
- package/dist/chunk-CO2P4FR5.js +0 -2
- package/dist/chunk-CO2P4FR5.js.map +0 -1
- package/dist/chunk-E6QVQEGZ.mjs +0 -2
- package/dist/chunk-E6QVQEGZ.mjs.map +0 -1
- package/dist/chunk-FHDFLSPW.js.map +0 -1
- package/dist/chunk-KG6RU37U.js.map +0 -1
- package/dist/chunk-LZE2E4TE.mjs +0 -4
- package/dist/chunk-LZE2E4TE.mjs.map +0 -1
- package/dist/chunk-QZJGNLCZ.js +0 -2
- package/dist/chunk-QZJGNLCZ.js.map +0 -1
- package/dist/chunk-RA452LXZ.mjs +0 -2
- package/dist/chunk-RA452LXZ.mjs.map +0 -1
- package/dist/chunk-V4U2PTKN.js.map +0 -1
- package/dist/chunk-VM6JEJFZ.js.map +0 -1
- package/dist/chunk-VXB7LA4E.js.map +0 -1
- package/dist/chunk-XVQKEGPO.mjs +0 -2
- package/dist/chunk-XVQKEGPO.mjs.map +0 -1
- package/dist/methods-CYARZTYL.mjs +0 -2
- package/dist/methods-DAPEWVI6.js +0 -2
- package/dist/methods-DAPEWVI6.js.map +0 -1
- /package/dist/{CartProvider-ZURLJNBW.mjs.map → CartProvider-ONIOELW5.mjs.map} +0 -0
- /package/dist/{chunk-HKVMSMDF.mjs.map → chunk-C5Q7DGCD.mjs.map} +0 -0
- /package/dist/{chunk-LJWS6ZRJ.mjs.map → chunk-C5RMHUOG.mjs.map} +0 -0
- /package/dist/{chunk-SLLBTQTW.mjs.map → chunk-GPNALARZ.mjs.map} +0 -0
- /package/dist/{chunk-SZ256RCC.mjs.map → chunk-H3YP2QPV.mjs.map} +0 -0
- /package/dist/{chunk-GN63ITLA.mjs.map → chunk-XQ43IC4M.mjs.map} +0 -0
- /package/dist/{methods-CYARZTYL.mjs.map → methods-C5HWYPPN.mjs.map} +0 -0
package/dist/consent.mjs
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import{b as te,
|
|
1
|
+
import{b as te,i as ne,j as oe,k as ie,l as re,m as se,o as J,p as ae}from"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";import{useCallback as R,useRef as we,useSyncExternalStore as $e}from"react";var A=["analytics","marketing","preferences"];var Ee='script[type="text/plain"][data-bitsnap-consent]:not([data-bitsnap-queued])',Ae="iframe[data-bitsnap-consent][data-src]",ce=(e,n)=>A.includes(n??"")&&e[n];function Se(e){return new Promise(n=>{e.addEventListener("load",()=>n(),{once:!0}),e.addEventListener("error",()=>n(),{once:!0})})}function le(e,n){let t=e.createElement("script");for(let{name:s,value:l}of Array.from(n.attributes))s==="type"||s==="data-bitsnap-queued"||(s==="data-type"?l==="module"&&t.setAttribute("type","module"):s==="data-src"?t.setAttribute("src",l):t.setAttribute(s,l));n.nonce&&(t.nonce=n.nonce);let r=t.hasAttribute("src");r?n.hasAttribute("async")||(t.async=!1):t.text=n.text;let p=r?Se(t):void 0;return n.parentNode?.replaceChild(t,n),p}function de(e,n){let t=0;try{let r=null,p=[];e.querySelectorAll(Ee).forEach(s=>{if(!ce(n,s.getAttribute("data-bitsnap-consent")))return;t++;let l=!s.hasAttribute("data-src")&&!s.hasAttribute("src");if(r||l&&p.length>0){s.setAttribute("data-bitsnap-queued",""),r=(r??Promise.all(p).then(()=>{})).then(()=>{try{return le(e,s)}catch{}}),p=[];return}let b=le(e,s);b&&p.push(b)}),e.querySelectorAll(Ae).forEach(s=>{if(!ce(n,s.getAttribute("data-bitsnap-consent")))return;let l=s.getAttribute("data-src");l&&s.getAttribute("src")!==l&&(s.setAttribute("src",l),s.removeAttribute("data-src"),t++)})}catch{}return t}var pe="https://bitsnap.pl",fe="https://collect.bitsnap.pl";function V(){return{version:1,theme:"auto",position:"bottom",categories:{analytics:!0,marketing:!0,preferences:!1},services:[],poweredBy:!0}}var Le=["auto","light","dark"],je=["bottom","bottom-left","bottom-right"],Pe=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function Oe(e){return typeof e=="string"&&Pe.test(e.trim())?e.trim():void 0}function _e(e){if(typeof e!="string")return;let n=e.trim();return/^(?:https?:\/\/|\/(?!\/)|#|\?)/i.test(n)?n:void 0}function ze(e){if(!Array.isArray(e))return[];let n=[];for(let t of e)t&&typeof t.name=="string"&&A.includes(t.category)&&n.push({name:t.name,category:t.category,cookies:Array.isArray(t.cookies)?t.cookies.filter(r=>typeof r=="string"):void 0});return n}function H(...e){let n=V();for(let t of e){if(!t||typeof t!="object")continue;typeof t.version=="number"&&t.version>=0&&(n.version=Math.floor(t.version)),Le.includes(t.theme)&&(n.theme=t.theme),je.includes(t.position)&&(n.position=t.position);let r=Oe(t.accentColor);r&&(n.accentColor=r);let p=_e(t.privacyPolicyUrl);if(p&&(n.privacyPolicyUrl=p),t.categories&&typeof t.categories=="object")for(let s of A)typeof t.categories[s]=="boolean"&&(n.categories[s]=t.categories[s]);t.services!==void 0&&(n.services=ze(t.services)),t.texts&&typeof t.texts=="object"&&(n.texts=t.texts)}return n}async function ue(e,n,t=3e3){if(typeof fetch!="function")return null;let r=typeof AbortController=="function"?new AbortController:void 0,p=setTimeout(()=>r?.abort(),t);try{let s=await fetch(`${e.replace(/\/+$/,"")}/api/consent/config?key=${encodeURIComponent(n)}`,{signal:r?.signal,credentials:"omit"});if(!s.ok)return null;let l=await s.json();if(!l||typeof l!="object")return null;let b=l.config&&typeof l.config=="object"?l.config:null,g=l.enabled!==!1;return b||!g?{enabled:g,config:b}:null}catch{return null}finally{clearTimeout(p)}}var Me={ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied",functionality_storage:"denied",personalization_storage:"denied",security_storage:"granted",wait_for_update:500},z=e=>e?"granted":"denied";function Q(e){return{analytics_storage:z(e.analytics),ad_storage:z(e.marketing),ad_user_data:z(e.marketing),ad_personalization:z(e.marketing),functionality_storage:z(e.preferences),personalization_storage:z(e.preferences)}}function Ue(e,n){return n==="off"?!1:n==="on"||typeof e.gtag=="function"||Array.isArray(e.dataLayer)}function Be(e){if(typeof e.gtag=="function")return e.gtag;let n=e.dataLayer=e.dataLayer||[],t=function(){n.push(arguments)};return e.gtag=t,t}function ge(e,n){if(!Ue(e,n))return null;let t=Be(e);return{setDefault:()=>t("consent","default",{...Me}),update:r=>t("consent","update",Q(r))}}var ee={pl:{title:"Szanujemy Twoj\u0105 prywatno\u015B\u0107",description:"U\u017Cywamy plik\xF3w cookie, aby strona dzia\u0142a\u0142a poprawnie. Za Twoj\u0105 zgod\u0105 wykorzystujemy je te\u017C do statystyk, personalizacji i reklam. Mo\u017Cesz zaakceptowa\u0107 wszystkie, odrzuci\u0107 wszystkie albo wybra\u0107, na co si\u0119 zgadzasz.",acceptAll:"Akceptuj wszystkie",rejectAll:"Odrzu\u0107 wszystkie",settings:"Ustawienia",save:"Zapisz wyb\xF3r",close:"Zamknij",necessaryTitle:"Niezb\u0119dne",necessaryDescription:"Potrzebne do dzia\u0142ania strony: koszyk, zapami\u0119tanie Twojego wyboru, bezpiecze\u0144stwo. Nie mo\u017Cna ich wy\u0142\u0105czy\u0107.",analyticsTitle:"Statystyki",analyticsDescription:"Pomagaj\u0105 nam zrozumie\u0107, jak odwiedzaj\u0105cy korzystaj\u0105 ze strony, \u017Ceby\u015Bmy mogli j\u0105 ulepsza\u0107.",marketingTitle:"Marketing",marketingDescription:"Pozwalaj\u0105 mierzy\u0107 skuteczno\u015B\u0107 reklam i pokazywa\u0107 Ci oferty dopasowane do zainteresowa\u0144.",preferencesTitle:"Preferencje",preferencesDescription:"Zapami\u0119tuj\u0105 Twoje ustawienia, na przyk\u0142ad j\u0119zyk czy wygl\u0105d strony.",poweredBy:"Powered by"},en:{title:"We value your privacy",description:"We use cookies to make this site work. With your consent we also use them for statistics, personalization and ads. You can accept all, reject all, or choose what you agree to.",acceptAll:"Accept all",rejectAll:"Reject all",settings:"Settings",save:"Save choices",close:"Close",necessaryTitle:"Necessary",necessaryDescription:"Needed for the site to work: the cart, remembering your choice, security. They cannot be turned off.",analyticsTitle:"Analytics",analyticsDescription:"Help us understand how visitors use the site, so we can improve it.",marketingTitle:"Marketing",marketingDescription:"Measure how well ads work and show you offers that match your interests.",preferencesTitle:"Preferences",preferencesDescription:"Remember your settings, such as language or how the site looks.",poweredBy:"Powered by"}},ye={pl:{privacy:"Polityka prywatno\u015Bci",services:"Us\u0142ugi",always:"Zawsze aktywne"},en:{privacy:"Privacy policy",services:"Services",always:"Always on"}};function F(e,n){return e==="pl"||e==="en"?e:/^pl\b/i.test(n??"")?"pl":"en"}function X(e,n){let t={...ee[e]},r=n?.[e];if(r)for(let p of Object.keys(t)){let s=r[p];typeof s=="string"&&s.trim()!==""&&(t[p]=s)}return t}function De(e){let n=e.replace("#","");n.length===3&&(n=n.replace(/./g,"$&$&"));let t=parseInt(n,16);return[t>>16&255,t>>8&255,t&255]}function me(e){let[n,t,r]=De(e).map(p=>{let s=p/255;return s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4)});return .2126*n+.7152*t+.0722*r}function q(e,n){let[t,r]=[me(e),me(n)].sort((p,s)=>s-p);return(t+.05)/(r+.05)}function be(e){return q(e,"#ffffff")>=q(e,"#111111")?"#ffffff":"#111111"}var Y={light:{bg:"#ffffff",fg:"#14171c",muted:"#495260",border:"#c9ced6",off:"#6b7280",thumb:"#ffffff",accent:"#1d4ed8",onAccent:"#ffffff",link:"#1d4ed8"},dark:{bg:"#171a20",fg:"#f1f3f6",muted:"#b7beca",border:"#3a404b",off:"#8b93a1",thumb:"#171a20",accent:"#8ab4ff",onAccent:"#0b1220",link:"#9dc0ff"}},Ce=e=>`--bg:${e.bg};--fg:${e.fg};--muted:${e.muted};--border:${e.border};--off:${e.off};--thumb:${e.thumb};--accent:${e.accent};--on-accent:${e.onAccent};--link:${e.link};--focus:${e.accent}`,he=`
|
|
2
2
|
:host{all:initial}
|
|
3
3
|
*{box-sizing:border-box}
|
|
4
4
|
[hidden]{display:none!important}
|
|
5
|
-
.root{${
|
|
6
|
-
.root[data-theme=dark]{${
|
|
5
|
+
.root{${Ce(Y.light)};position:fixed;inset:0;pointer-events:none;z-index:2147483000;font:14px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;color:var(--fg);-webkit-text-size-adjust:100%}
|
|
6
|
+
.root[data-theme=dark]{${Ce(Y.dark)};color-scheme:dark}
|
|
7
7
|
button,input{font:inherit;color:inherit}
|
|
8
8
|
.banner,.overlay{pointer-events:auto}
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
.bottom
|
|
12
|
-
.
|
|
9
|
+
::selection{background:color-mix(in srgb,var(--accent) 24%,transparent)}
|
|
10
|
+
.banner{position:absolute;background:var(--bg);color:var(--fg);max-height:92vh;overflow:auto;outline:none;animation:in .22s ease-out}
|
|
11
|
+
.bottom{left:0;right:0;bottom:0;border-top:1px solid var(--border);box-shadow:0 -8px 28px rgba(15,23,42,.08);padding:20px 24px calc(20px + env(safe-area-inset-bottom,0px))}
|
|
12
|
+
.root[data-theme=dark] .bottom{box-shadow:0 -8px 28px rgba(0,0,0,.4)}
|
|
13
|
+
.bottom .inner{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"text actions" "foot actions";gap:4px 40px;align-items:center;max-width:1120px;margin:0 auto}
|
|
14
|
+
.bottom .text{max-width:68ch}
|
|
15
|
+
.bottom .btn,.bottom .link-btn{flex:0 0 auto}
|
|
16
|
+
.card{bottom:16px;width:min(400px,calc(100vw - 32px));border:1px solid var(--border);border-radius:14px;padding:20px;box-shadow:0 12px 32px rgba(15,23,42,.14)}
|
|
17
|
+
.root[data-theme=dark] .card{box-shadow:0 12px 32px rgba(0,0,0,.45)}
|
|
13
18
|
.bottom-left{left:16px}
|
|
14
19
|
.bottom-right{right:16px}
|
|
15
20
|
.card .inner{display:flex;flex-direction:column;gap:16px}
|
|
@@ -17,15 +22,19 @@ button,input{font:inherit;color:inherit}
|
|
|
17
22
|
.actions{grid-area:actions;display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:flex-end}
|
|
18
23
|
.card .actions{justify-content:stretch}
|
|
19
24
|
.foot{grid-area:foot}
|
|
20
|
-
.title{font-size:
|
|
21
|
-
.desc{margin:0;color:var(--muted)}
|
|
22
|
-
.desc a
|
|
23
|
-
.btn{min-height:44px;padding:0 20px;border
|
|
24
|
-
.btn
|
|
25
|
-
.
|
|
25
|
+
.title{font-size:17px;font-weight:650;line-height:1.35;letter-spacing:-.01em;text-wrap:balance;margin:0 0 6px}
|
|
26
|
+
.desc{margin:0;color:var(--muted);line-height:1.55;text-wrap:pretty}
|
|
27
|
+
.desc a{color:var(--link);text-decoration:underline;text-underline-offset:3px}
|
|
28
|
+
.btn,.link-btn{min-height:44px;padding:0 20px;border-radius:10px;font-weight:600;cursor:pointer;white-space:nowrap;transition:background-color .12s ease-out,filter .12s ease-out,border-color .12s ease-out}
|
|
29
|
+
.btn{border:2px solid var(--accent);background:var(--accent);color:var(--on-accent);flex:1 1 150px}
|
|
30
|
+
.btn:hover{filter:brightness(.93)}
|
|
31
|
+
.btn:active{filter:brightness(.87)}
|
|
32
|
+
.link-btn{border:1px solid var(--border);background:transparent;color:var(--fg);text-decoration:none}
|
|
33
|
+
.link-btn:hover{background:color-mix(in srgb,var(--fg) 6%,transparent)}
|
|
34
|
+
.link-btn:active{background:color-mix(in srgb,var(--fg) 10%,transparent)}
|
|
26
35
|
.card .link-btn{flex:1 1 100%}
|
|
27
36
|
button:focus-visible,a:focus-visible,.dialog:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
|
|
28
|
-
.foot{font-size:12px;color:var(--muted);padding-top:
|
|
37
|
+
.foot{font-size:12px;color:var(--muted);padding-top:8px}
|
|
29
38
|
.foot a{color:var(--muted);text-decoration:none;display:inline-flex;align-items:center;gap:5px;vertical-align:middle}
|
|
30
39
|
.foot a:hover{text-decoration:underline}
|
|
31
40
|
.foot b{color:var(--fg);font-weight:700;letter-spacing:-.01em}
|
|
@@ -57,10 +66,15 @@ input:focus-visible+.track{outline:2px solid var(--focus);outline-offset:2px}
|
|
|
57
66
|
.d-foot .actions{justify-content:stretch}
|
|
58
67
|
@keyframes in{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
|
|
59
68
|
@keyframes fade{from{opacity:0}to{opacity:1}}
|
|
69
|
+
@media(max-width:960px){
|
|
70
|
+
.bottom .inner{grid-template-columns:minmax(0,1fr);grid-template-areas:"text" "actions" "foot";gap:14px}
|
|
71
|
+
.bottom .actions{justify-content:flex-start}
|
|
72
|
+
}
|
|
60
73
|
@media(max-width:640px){
|
|
61
74
|
.bottom{padding:16px 16px calc(16px + env(safe-area-inset-bottom,0px))}
|
|
62
75
|
.bottom .inner{grid-template-columns:1fr;grid-template-areas:"text" "actions" "foot";gap:12px}
|
|
63
76
|
.bottom .actions{justify-content:stretch}
|
|
77
|
+
.bottom .btn{flex:1 1 130px}
|
|
64
78
|
.bottom .link-btn{flex:1 1 100%}
|
|
65
79
|
.card{left:8px;right:8px;bottom:8px;width:auto}
|
|
66
80
|
.overlay{align-items:flex-end;padding:0}
|
|
@@ -71,5 +85,5 @@ input:focus-visible+.track{outline:2px solid var(--focus);outline-offset:2px}
|
|
|
71
85
|
.btn{flex-basis:130px;padding:0 12px}
|
|
72
86
|
}
|
|
73
87
|
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}
|
|
74
|
-
`.replace(/\n/g,"");var Xe='<svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><rect width="16" height="16" rx="4" fill="currentColor" style="color:var(--fg)"/><circle cx="8" cy="8" r="3" fill="var(--bg)"/></svg>',qe='<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 3l10 10M13 3L3 13" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none"/></svg>',Je="button:not([disabled]),input:not([disabled]),a[href]";function ve(e){let{doc:t,config:n,texts:i,locale:p}=e,s=me[p],l=null,u=null,g,f,y,b,v,h="none",w=null,T=null,E=new Map;function c(o,a={},...d){let m=t.createElement(o);for(let C of Object.keys(a))C==="class"?m.className=a[C]:m.setAttribute(C,a[C]);for(let C of d)m.append(C);return m}function x(o,a,d){let m=c("button",{type:"button",class:o},a);return m.addEventListener("click",d),m}function z(){let o=c("a",{href:`https://bitsnap.pl/?utm_source=consent_banner&utm_medium=referral&utm_content=${encodeURIComponent(t.location?.hostname??"")}`,target:"_blank",rel:"noopener"});return o.append(i.poweredBy+" "),o.insertAdjacentHTML("beforeend",Xe),o.append(c("b",{},"bitsnap")),c("div",{class:"foot"},o)}function k(){let o=c("p",{class:"desc",id:"d"},i.description);return n.privacyPolicyUrl&&o.append(" ",c("a",{href:n.privacyPolicyUrl,target:"_blank",rel:"noopener"},s.privacy)),o}function j(){v=x("link-btn",i.settings,()=>B()),f=c("div",{class:`banner ${n.position==="bottom"?"bottom":`card ${n.position}`}`,role:"region","aria-live":"polite","aria-labelledby":"t","aria-describedby":"d",tabindex:"-1"},c("div",{class:"inner"},c("div",{class:"text"},c("div",{class:"title",id:"t"},i.title),k()),c("div",{class:"actions"},x("btn",i.acceptAll,e.onAcceptAll),x("btn",i.rejectAll,e.onRejectAll),v),z()))}function U(o){let a=n.services.filter(C=>C.category===o),d=c("input",{type:"checkbox",role:"switch","aria-labelledby":`l-${o}`,"aria-describedby":`p-${o}`});o==="necessary"?(d.checked=!0,d.disabled=!0):E.set(o,d);let m=c("div",{class:"cat"},c("div",{class:"row"},c("span",{class:"cat-title",id:`l-${o}`},i[`${o}Title`]),c("span",{style:"display:flex;align-items:center"},...o==="necessary"?[c("span",{class:"always"},s.always)]:[],c("label",{class:"switch"},d,c("span",{class:"track"})))),c("p",{id:`p-${o}`},i[`${o}Description`]));return a.length>0&&m.append(c("p",{class:"svc"},c("b",{},`${s.services}: `),a.map(C=>C.name).join(", "))),m}function R(){let o=c("button",{type:"button",class:"x","aria-label":i.close});o.insertAdjacentHTML("beforeend",qe),o.addEventListener("click",()=>_());let a=c("div",{class:"d-body"},U("necessary"));for(let d of A)n.categories[d]&&a.append(U(d));b=c("div",{class:"dialog",role:"dialog","aria-modal":"true","aria-labelledby":"st",tabindex:"-1"},c("div",{class:"d-head"},c("div",{class:"title",id:"st"},i.settings),o),a,c("div",{class:"d-foot"},c("div",{class:"actions"},x("btn",i.save,()=>e.onSave(I())),x("btn",i.acceptAll,e.onAcceptAll),x("btn",i.rejectAll,e.onRejectAll)),z())),y=c("div",{class:"overlay"},b),y.addEventListener("mousedown",d=>{d.target===y&&_()})}function I(){let o={analytics:!1,marketing:!1,preferences:!1};return E.forEach((a,d)=>o[d]=a.checked),o}function S(){let o=n.theme==="dark"||n.theme==="auto"&&!!T?.matches;g.setAttribute("data-theme",o?"dark":"light"),N(o)}function N(o){let a=n.accentColor;if(a){if(o&&q(a,J.dark.bg)<3){for(let d of["--accent","--focus","--on-accent"])g.style.removeProperty(d);return}g.style.setProperty("--accent",a),g.style.setProperty("--focus",a),g.style.setProperty("--on-accent",he(a))}}function D(){l||(l=c("div",{id:"bitsnap-consent","data-bitsnap-consent-host":""}),u=l.attachShadow({mode:"open"}),u.append(c("style",{},xe)),g=c("div",{class:"root",lang:p}),j(),R(),f.hidden=!0,y.hidden=!0,g.append(f,y),u.append(g),typeof t.defaultView?.matchMedia=="function"&&(T=t.defaultView.matchMedia("(prefers-color-scheme: dark)"),T.addEventListener?.("change",S)),S(),t.body.append(l))}function L(){return Array.from(b.querySelectorAll(Je))}function P(o){if(h!=="settings")return;if(o.key==="Escape"){o.preventDefault(),_();return}if(o.key!=="Tab")return;let a=L();if(a.length===0)return;let d=u?.activeElement,m=a[0],C=a[a.length-1],W=!d||!b.contains(d);o.shiftKey&&(W||d===m||d===b)?(o.preventDefault(),C.focus()):!o.shiftKey&&(W||d===C)&&(o.preventDefault(),m.focus())}function K(o=!1){try{D(),h="banner",t.removeEventListener("keydown",P,!0),y.hidden=!0,f.hidden=!1,o&&f.focus({preventScroll:!0})}catch{}}function B(){try{if(D(),h!=="settings"){let a=t.activeElement;w=a&&a!==l&&a!==t.body?a:null}let o=e.getChoices();E.forEach((a,d)=>a.checked=!!o?.[d]),h="settings",f.hidden=!0,y.hidden=!1,t.addEventListener("keydown",P,!0),b.focus({preventScroll:!0})}catch{}}function _(){h==="settings"&&(t.removeEventListener("keydown",P,!0),y.hidden=!0,e.hasChoice()?(h="none",w?.focus?.({preventScroll:!0})):(h="banner",f.hidden=!1,v.focus({preventScroll:!0})))}function G(){if(!l)return;t.removeEventListener("keydown",P,!0);let o=h==="settings";h="none",f.hidden=!0,y.hidden=!0,o&&w?.focus?.({preventScroll:!0})}function r(){t.removeEventListener("keydown",P,!0),T?.removeEventListener?.("change",S),l?.remove(),l=null,u=null,h="none"}return{showBanner:K,showSettings:B,hide:G,destroy:r}}var O=()=>({analytics:!1,marketing:!1,preferences:!1}),we=e=>e&&{id:e.id,ts:e.ts,bv:e.bv,c:{...e.c}};function Y(e={}){let t=typeof window<"u"?window:void 0,n=t?.document,i=new Set,p=e.apiHost||se,s=e.collectHost||ae,l=e.projectKey?te(e.projectKey):null,u=de(l??void 0,e.scope),g=!!e.preview,f=$(z()),y=null,b=null,v=null,h=!1,w=!1,T,E=[],c=t&&!g?k(()=>ye(t,e.gcm),null):null;k(()=>c?.setDefault(),void 0);let x=n&&!g?fe(n,u):null;function z(r){let o={...e.config};return e.theme&&(o.theme=e.theme),e.position&&(o.position=e.position),e.privacyPolicyUrl&&(o.privacyPolicyUrl=e.privacyPolicyUrl),{...r,...o}}function k(r,o){try{return r()}catch{return o}}function j(r){let o=O();for(let a of A)o[a]=!!r?.[a]&&f.categories[a];return o}function U(r){i.forEach(o=>k(()=>o({...r,c:{...r.c}}),void 0)),k(()=>{t?.dispatchEvent(new t.CustomEvent("bitsnap:consent",{detail:{...r,c:{...r.c}}}))},void 0)}function R(r,o){g||!l||typeof fetch!="function"||k(()=>{let a=JSON.stringify({k:l,consent_id:o.id,action:r,c:o.c,bv:o.bv,host:t?.location?.hostname??"",ts:o.ts});fetch(`${s.replace(/\/+$/,"")}/consent`,{method:"POST",keepalive:!0,credentials:"omit",body:a}).catch(()=>{})},void 0)}function I(r){return A.filter(o=>r[o]&&f.categories[o])}function S(r,o){if(!n||w)return;if(g){v?.hide();return}let a=y??b,d=a?I(a.c).filter(W=>!r[W]):[],m=d.length>0?"withdraw":o,C={id:a?.id??pe(),ts:Math.floor(Date.now()/1e3),bv:f.version,c:r};ue(n,u,C),y=C,b=null,N(C.c),d.length>0&&V(n,f.services,d),v?.hide(),U({...C,action:m}),R(m,C),d.length>0&&e.reloadOnWithdraw&&D()}function N(r){k(()=>c?.update(r),void 0),n&&re(n,r)}function D(){setTimeout(()=>k(()=>t?.location.reload(),void 0),50)}function L(){if(!n||!h||w)return null;if(!v){let r=F(e.locale,t?.navigator?.language);v=ve({doc:n,config:f,locale:r,texts:P(X(r,f.texts)),getChoices:()=>y?.c??null,hasChoice:()=>y!==null,onAcceptAll:()=>S(j({analytics:!0,marketing:!0,preferences:!0}),"accept_all"),onRejectAll:()=>S(O(),"reject_all"),onSave:o=>S(j(o),"custom")})}return v}function P(r){let o=e.title?.trim(),a=e.description?.trim();return{...r,...o&&{title:o},...a&&{description:a}}}function K(r){r.target?.closest?.("[data-bitsnap-consent-open]")&&(r.preventDefault(),G.open())}let B=(async()=>{if(!n||!t)return null;let r=l&&!g?await ce(p,l):null;if(w)return null;let o=r?.config?void 0:e.categories;if(f=$(r?.config,o?{categories:{...O(),...o}}:void 0,z()),n.readyState==="loading"&&await new Promise(m=>n.addEventListener("DOMContentLoaded",()=>m(),{once:!0})),w)return null;h=!0,n.addEventListener("click",K),T=()=>n.removeEventListener("click",K);let a=!l||r?.config!=null,d=r?.enabled===!1;return g?L()?.showBanner():x&&(d||!a||x.bv===f.version)?(y=x,N(j(y.c))):(x&&(b=x),d||L()?.showBanner()),E.splice(0).forEach(m=>k(m,void 0)),k(()=>t.dispatchEvent(new t.CustomEvent("bitsnap:consent:ready")),void 0),we(y)})().catch(()=>null);function _(r){h?r():E.push(r)}let G={get:()=>we(y),denied:r=>(y??b)?.c[r]===!1,on(r,o){return r!=="change"||typeof o!="function"?()=>{}:(i.add(o),()=>void i.delete(o))},open(){h?L()?.showSettings():B.then(()=>L()?.showSettings())},close(){v?.hide()},accept:r=>_(()=>S(j(r),"custom")),acceptAll:()=>_(()=>S(j({analytics:!0,marketing:!0,preferences:!0}),"accept_all")),rejectAll:()=>_(()=>S(O(),"reject_all")),reset(){if(!n||w)return;if(g){L()?.showBanner();return}let r=y??b,o=r?I(r.c):[];ge(n,u),y=null,b=r,k(()=>c?.update(O()),void 0),o.length>0&&V(n,f.services,o),U({id:r?.id??"",ts:Math.floor(Date.now()/1e3),bv:f.version,c:O(),action:"reset"}),r&&o.length>0&&R("withdraw",{id:r.id,ts:Math.floor(Date.now()/1e3),bv:f.version,c:O()}),L()?.showBanner(!0),o.length>0&&e.reloadOnWithdraw&&D()},ready:B,destroy(){w=!0,T?.(),v?.destroy(),v=null,i.clear()}};return Ye(G)}function Ye(e){let t={...e};for(let n of Object.keys(e)){let i=e[n];typeof i=="function"&&(t[n]=(...p)=>{try{return i(...p)}catch{return n==="get"?null:n==="on"?()=>{}:void 0}})}return t}function Ve(e){let{projectKey:t,theme:n,locale:i,position:p,privacyPolicyUrl:s,scope:l,apiHost:u,collectHost:g,reloadOnWithdraw:f,gcm:y,preview:b,title:v,description:h}=e,w=JSON.stringify(e.config??null),T=ke(e.config);T.current=e.config;let E=JSON.stringify(e.categories??null),c=ke(e.categories);return c.current=e.categories,ne(()=>{if(window.BitsnapConsent)return;let x=Y({projectKey:t,theme:n,locale:i,position:p,privacyPolicyUrl:s,scope:l,apiHost:u,collectHost:g,reloadOnWithdraw:f,gcm:y,preview:b,title:v,description:h,categories:c.current,config:T.current});return window.BitsnapConsent=x,()=>{x.destroy(),window.BitsnapConsent===x&&delete window.BitsnapConsent}},[t,n,i,p,s,l,u,g,f,y,b,v,h,E,w]),null}var Te="null",Se=null;function Qe(){let e=typeof window>"u"?null:window.BitsnapConsent?.get()??null,t=JSON.stringify(e);return t!==Te&&(Te=t,Se=e),Se}function et(e){return window.addEventListener("bitsnap:consent",e),window.addEventListener("bitsnap:consent:ready",e),()=>{window.removeEventListener("bitsnap:consent",e),window.removeEventListener("bitsnap:consent:ready",e)}}function tt(){let e=Ze(et,Qe,()=>null),t=H(()=>window.BitsnapConsent?.open(),[]),n=H(l=>window.BitsnapConsent?.accept(l),[]),i=H(()=>window.BitsnapConsent?.acceptAll(),[]),p=H(()=>window.BitsnapConsent?.rejectAll(),[]),s=H(()=>window.BitsnapConsent?.reset(),[]);return{consent:e,decided:e!==null,open:t,accept:n,acceptAll:i,rejectAll:p,reset:s}}export{Ve as BitsnapConsent,ee as DEFAULT_TEXTS,Y as createConsent,Z as defaultConfig,$ as mergeConfig,X as mergeTexts,F as resolveLocale,Q as toConsentModeUpdate,tt as useConsent};
|
|
88
|
+
`.replace(/\n/g,"");var He='<svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><rect width="16" height="16" rx="4" fill="currentColor" style="color:var(--fg)"/><circle cx="8" cy="8" r="3" fill="var(--bg)"/></svg>',Re='<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 3l10 10M13 3L3 13" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none"/></svg>',Ie="button:not([disabled]),input:not([disabled]),a[href]";function xe(e){let{doc:n,config:t,texts:r,locale:p}=e,s=ye[p],l=null,b=null,g,u,f,h,v,C="none",w=null,T=null,S=new Map;function c(o,a={},...d){let y=n.createElement(o);for(let m of Object.keys(a))m==="class"?y.className=a[m]:y.setAttribute(m,a[m]);for(let m of d)y.append(m);return y}function x(o,a,d){let y=c("button",{type:"button",class:o},a);return y.addEventListener("click",d),y}function M(){let o=c("a",{href:`https://bitsnap.pl/?utm_source=consent_banner&utm_medium=referral&utm_content=${encodeURIComponent(n.location?.hostname??"")}`,target:"_blank",rel:"noopener"});return o.append(r.poweredBy+" "),o.insertAdjacentHTML("beforeend",He),o.append(c("b",{},"bitsnap")),c("div",{class:"foot"},o)}function k(){let o=c("p",{class:"desc",id:"d"},r.description);return t.privacyPolicyUrl&&o.append(" ",c("a",{href:t.privacyPolicyUrl,target:"_blank",rel:"noopener"},s.privacy)),o}function j(){v=x("link-btn",r.settings,()=>D()),u=c("div",{class:`banner ${t.position==="bottom"?"bottom":`card ${t.position}`}`,role:"region","aria-live":"polite","aria-labelledby":"t","aria-describedby":"d",tabindex:"-1"},c("div",{class:"inner"},c("div",{class:"text"},c("div",{class:"title",id:"t"},r.title),k()),c("div",{class:"actions"},x("btn",r.acceptAll,e.onAcceptAll),x("btn",r.rejectAll,e.onRejectAll),v),M()))}function U(o){let a=t.services.filter(m=>m.category===o),d=c("input",{type:"checkbox",role:"switch","aria-labelledby":`l-${o}`,"aria-describedby":`p-${o}`});o==="necessary"?(d.checked=!0,d.disabled=!0):S.set(o,d);let y=c("div",{class:"cat"},c("div",{class:"row"},c("span",{class:"cat-title",id:`l-${o}`},r[`${o}Title`]),c("span",{style:"display:flex;align-items:center"},...o==="necessary"?[c("span",{class:"always"},s.always)]:[],c("label",{class:"switch"},d,c("span",{class:"track"})))),c("p",{id:`p-${o}`},r[`${o}Description`]));return a.length>0&&y.append(c("p",{class:"svc"},c("b",{},`${s.services}: `),a.map(m=>m.name).join(", "))),y}function I(){let o=c("button",{type:"button",class:"x","aria-label":r.close});o.insertAdjacentHTML("beforeend",Re),o.addEventListener("click",()=>O());let a=c("div",{class:"d-body"},U("necessary"));for(let d of A)t.categories[d]&&a.append(U(d));h=c("div",{class:"dialog",role:"dialog","aria-modal":"true","aria-labelledby":"st",tabindex:"-1"},c("div",{class:"d-head"},c("div",{class:"title",id:"st"},r.settings),o),a,c("div",{class:"d-foot"},c("div",{class:"actions"},x("btn",r.save,()=>e.onSave(N())),x("btn",r.acceptAll,e.onAcceptAll),x("btn",r.rejectAll,e.onRejectAll)),M())),f=c("div",{class:"overlay"},h),f.addEventListener("mousedown",d=>{d.target===f&&O()})}function N(){let o={analytics:!1,marketing:!1,preferences:!1};return S.forEach((a,d)=>o[d]=a.checked),o}function E(){let o=t.theme==="dark"||t.theme==="auto"&&!!T?.matches;g.setAttribute("data-theme",o?"dark":"light"),$(o)}function $(o){let a=t.accentColor;if(a){if(o&&q(a,Y.dark.bg)<3){for(let d of["--accent","--focus","--on-accent"])g.style.removeProperty(d);return}g.style.setProperty("--accent",a),g.style.setProperty("--focus",a),g.style.setProperty("--on-accent",be(a))}}function B(){l||(l=c("div",{id:"bitsnap-consent","data-bitsnap-consent-host":""}),b=l.attachShadow({mode:"open"}),b.append(c("style",{},he)),g=c("div",{class:"root",lang:p}),j(),I(),u.hidden=!0,f.hidden=!0,g.append(u,f),b.append(g),typeof n.defaultView?.matchMedia=="function"&&(T=n.defaultView.matchMedia("(prefers-color-scheme: dark)"),T.addEventListener?.("change",E)),E(),n.body.append(l))}function L(){return Array.from(h.querySelectorAll(Ie))}function P(o){if(C!=="settings")return;if(o.key==="Escape"){o.preventDefault(),O();return}if(o.key!=="Tab")return;let a=L();if(a.length===0)return;let d=b?.activeElement,y=a[0],m=a[a.length-1],W=!d||!h.contains(d);o.shiftKey&&(W||d===y||d===h)?(o.preventDefault(),m.focus()):!o.shiftKey&&(W||d===m)&&(o.preventDefault(),y.focus())}function K(o=!1){try{B(),C="banner",n.removeEventListener("keydown",P,!0),f.hidden=!0,u.hidden=!1,o&&u.focus({preventScroll:!0})}catch{}}function D(){try{if(B(),C!=="settings"){let a=n.activeElement;w=a&&a!==l&&a!==n.body?a:null}let o=e.getChoices();S.forEach((a,d)=>a.checked=!!o?.[d]),C="settings",u.hidden=!0,f.hidden=!1,n.addEventListener("keydown",P,!0),h.focus({preventScroll:!0})}catch{}}function O(){C==="settings"&&(n.removeEventListener("keydown",P,!0),f.hidden=!0,e.hasChoice()?(C="none",w?.focus?.({preventScroll:!0})):(C="banner",u.hidden=!1,v.focus({preventScroll:!0})))}function G(){if(!l)return;n.removeEventListener("keydown",P,!0);let o=C==="settings";C="none",u.hidden=!0,f.hidden=!0,o&&w?.focus?.({preventScroll:!0})}function i(){n.removeEventListener("keydown",P,!0),T?.removeEventListener?.("change",E),l?.remove(),l=null,b=null,C="none"}return{showBanner:K,showSettings:D,hide:G,destroy:i}}var _=()=>({analytics:!1,marketing:!1,preferences:!1}),ve=e=>e&&{id:e.id,ts:e.ts,bv:e.bv,c:{...e.c}};function Z(e={}){let n=typeof window<"u"?window:void 0,t=n?.document,r=new Set,p=e.apiHost||pe,s=e.collectHost||fe,l=e.projectKey?te(e.projectKey):null,b=ne(l??void 0,e.scope),g=!!e.preview,u=H(M()),f=null,h=null,v=null,C=!1,w=!1,T,S=[],c=n&&!g?k(()=>ge(n,e.gcm),null):null;k(()=>c?.setDefault(),void 0);let x=t&&!g?ie(t,b):null;function M(i){let o={...e.config};return e.theme&&(o.theme=e.theme),e.position&&(o.position=e.position),e.privacyPolicyUrl&&(o.privacyPolicyUrl=e.privacyPolicyUrl),{...i,...o}}function k(i,o){try{return i()}catch{return o}}function j(i){let o=_();for(let a of A)o[a]=!!i?.[a]&&u.categories[a];return o}function U(i){r.forEach(o=>k(()=>o({...i,c:{...i.c}}),void 0)),k(()=>{n?.dispatchEvent(new n.CustomEvent("bitsnap:consent",{detail:{...i,c:{...i.c}}}))},void 0)}function I(i,o){g||!l||typeof fetch!="function"||k(()=>{let a=JSON.stringify({k:l,consent_id:o.id,action:i,c:o.c,bv:o.bv,host:n?.location?.hostname??"",ts:o.ts});fetch(`${s.replace(/\/+$/,"")}/consent`,{method:"POST",keepalive:!0,credentials:"omit",body:a}).catch(()=>{})},void 0)}function N(i){return A.filter(o=>i[o]&&u.categories[o])}function E(i,o){if(!t||w)return;if(g){v?.hide();return}let a=f??h,d=a?N(a.c).filter(W=>!i[W]):[],y=d.length>0?"withdraw":o,m={id:a?.id??oe(),ts:Math.floor(Date.now()/1e3),bv:u.version,c:i};re(t,b,m),f=m,h=null,$(m.c),d.length>0&&J(t,u.services,d),v?.hide(),U({...m,action:y}),I(y,m),d.length>0&&e.reloadOnWithdraw&&B()}function $(i){k(()=>c?.update(i),void 0),t&&de(t,i)}function B(){setTimeout(()=>k(()=>n?.location.reload(),void 0),50)}function L(){if(!t||!C||w)return null;if(!v){let i=F(e.locale,n?.navigator?.language);v=xe({doc:t,config:u,locale:i,texts:P(X(i,u.texts)),getChoices:()=>f?.c??null,hasChoice:()=>f!==null,onAcceptAll:()=>E(j({analytics:!0,marketing:!0,preferences:!0}),"accept_all"),onRejectAll:()=>E(_(),"reject_all"),onSave:o=>E(j(o),"custom")})}return v}function P(i){let o=e.title?.trim(),a=e.description?.trim();return{...i,...o&&{title:o},...a&&{description:a}}}function K(i){i.target?.closest?.("[data-bitsnap-consent-open]")&&(i.preventDefault(),G.open())}let D=(async()=>{if(!t||!n)return null;let i=l&&!g?await ue(p,l):null;if(w)return null;let o=i?.config?void 0:e.categories;if(u=H(i?.config,o?{categories:{..._(),...o}}:void 0,M()),t.readyState==="loading"&&await new Promise(y=>t.addEventListener("DOMContentLoaded",()=>y(),{once:!0})),w)return null;C=!0,t.addEventListener("click",K),T=()=>t.removeEventListener("click",K);let a=!l||i?.config!=null,d=i?.enabled===!1;return g?L()?.showBanner():x&&(d||!a||x.bv===u.version)?(f=x,$(j(f.c))):(x&&(h=x),d||L()?.showBanner()),S.splice(0).forEach(y=>k(y,void 0)),k(()=>n.dispatchEvent(new n.CustomEvent("bitsnap:consent:ready")),void 0),ve(f)})().catch(()=>null);function O(i){C?i():S.push(i)}let G={scope:e.scope==="project"&&l?"project":"global",projectKey:l,get:()=>ve(f),denied:i=>(f??h)?.c[i]===!1,on(i,o){return i!=="change"||typeof o!="function"?()=>{}:(r.add(o),()=>void r.delete(o))},open(){C?L()?.showSettings():D.then(()=>L()?.showSettings())},close(){v?.hide()},accept:i=>O(()=>E(j(i),"custom")),acceptAll:()=>O(()=>E(j({analytics:!0,marketing:!0,preferences:!0}),"accept_all")),rejectAll:()=>O(()=>E(_(),"reject_all")),reset(){if(!t||w)return;if(g){L()?.showBanner();return}let i=f??h,o=i?N(i.c):[];se(t,b),f=null,h=i,k(()=>c?.update(_()),void 0),o.length>0&&J(t,u.services,o),U({id:i?.id??"",ts:Math.floor(Date.now()/1e3),bv:u.version,c:_(),action:"reset"}),i&&o.length>0&&I("withdraw",{id:i.id,ts:Math.floor(Date.now()/1e3),bv:u.version,c:_()}),L()?.showBanner(!0),o.length>0&&e.reloadOnWithdraw&&B()},ready:D,destroy(){w=!0,T?.(),v?.destroy(),v=null,r.clear()}};return Ne(G)}function Ne(e){let n={...e};for(let t of Object.keys(e)){let r=e[t];typeof r=="function"&&(n[t]=(...p)=>{try{return r(...p)}catch{return t==="get"?null:t==="on"?()=>{}:void 0}})}return n}function Ke(e){let{projectKey:n,theme:t,locale:r,position:p,privacyPolicyUrl:s,scope:l,apiHost:b,collectHost:g,reloadOnWithdraw:u,gcm:f,preview:h,title:v,description:C}=e,w=JSON.stringify(e.config??null),T=we(e.config);T.current=e.config;let S=JSON.stringify(e.categories??null),c=we(e.categories);return c.current=e.categories,ae(()=>{if(window.BitsnapConsent)return;let x=Z({projectKey:n,theme:t,locale:r,position:p,privacyPolicyUrl:s,scope:l,apiHost:b,collectHost:g,reloadOnWithdraw:u,gcm:f,preview:h,title:v,description:C,categories:c.current,config:T.current});return window.BitsnapConsent=x,()=>{x.destroy(),window.BitsnapConsent===x&&delete window.BitsnapConsent}},[n,t,r,p,s,l,b,g,u,f,h,v,C,S,w]),null}var ke="null",Te=null;function Ge(){let e=typeof window>"u"?null:window.BitsnapConsent?.get()??null,n=JSON.stringify(e);return n!==ke&&(ke=n,Te=e),Te}function We(e){return window.addEventListener("bitsnap:consent",e),window.addEventListener("bitsnap:consent:ready",e),()=>{window.removeEventListener("bitsnap:consent",e),window.removeEventListener("bitsnap:consent:ready",e)}}function Fe(){let e=$e(We,Ge,()=>null),n=R(()=>window.BitsnapConsent?.open(),[]),t=R(l=>window.BitsnapConsent?.accept(l),[]),r=R(()=>window.BitsnapConsent?.acceptAll(),[]),p=R(()=>window.BitsnapConsent?.rejectAll(),[]),s=R(()=>window.BitsnapConsent?.reset(),[]);return{consent:e,decided:e!==null,open:n,accept:t,acceptAll:r,rejectAll:p,reset:s}}export{Ke as BitsnapConsent,ee as DEFAULT_TEXTS,Z as createConsent,V as defaultConfig,H as mergeConfig,X as mergeTexts,F as resolveLocale,Q as toConsentModeUpdate,Fe as useConsent};
|
|
75
89
|
//# sourceMappingURL=consent.mjs.map
|