PageSourceSearch

https://solarpanelcosts.co.uk/assets/CookieConsent-DxMaktRP.js

js solarpanelcosts.co.uk collected 2026-10-10 01:23:44 UTC 6,319 bytes, 1 lines download raw bytes

1import{r as a,j as e,b as h,B as c}from"./index-C44yip9_.js";const p="cookie-consent-v1",x="cookie-prefs-open",f="cookie-consent-changed",b=1,m=()=>typeof window<"u",w=()=>{if(!m())return!1;const s=window.navigator;if(s.globalPrivacyControl===!0)return!0;const t=s.doNotTrack??window.doNotTrack??s.msDoNotTrack;return t==="1"||t==="yes"},l=()=>{if(!m())return null;try{const s=localStorage.getItem(p);if(!s)return null;const t=JSON.parse(s);return typeof(t==null?void 0:t.analytics)!="boolean"||t.version!==b?null:t}catch{return null}},g=s=>{if(m())try{const t={version:b,ts:s.ts??Date.now(),analytics:s.analytics,marketing:s.marketing,auto:s.auto};localStorage.setItem(p,JSON.stringify(t)),window.dispatchEvent(new Event(f))}catch{}},v=s=>{const t=l();return t?t[s]===!0:!1},E=()=>{m()&&window.dispatchEvent(new Event(x))},k=()=>{const[s,t]=a.useState(()=>l());return a.useEffect(()=>{const r=()=>t(l());return window.addEventListener(f,r),window.addEventListener("storage",r),()=>{window.removeEventListener(f,r),window.removeEventListener("storage",r)}},[]),s},C=({category:s,children:t})=>{const r=k();return!r||!r[s]?null:e.jsx(e.Fragment,{children:t})},N=({initial:s,onClose:t,onSave:r})=>{const[o,u]=a.useState((s==null?void 0:s.analytics)??!1),[i,d]=a.useState((s==null?void 0:s.marketing)??!1);return e.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Cookie preferences",className:"fixed inset-0 z-[60] flex items-end sm:items-center justify-center bg-black/40 p-3 sm:p-6 animate-in fade-in duration-200",onClick:n=>{n.target===n.currentTarget&&t()},children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl bg-white border border-border shadow-2xl p-5 sm:p-6",children:[e.jsx("h2",{className:"font-display text-2xl mb-2",children:"Cookie preferences"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Choose which non-essential cookies you allow. Strictly-necessary cookies are always on — the site won't work without them."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-xl border border-border/60 p-3 bg-cream/40",children:[e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"block font-semibold",children:"Strictly necessary"}),e.jsx("span",{className:"text-muted-foreground",children:"Site security, calculator state, form submission. Always on."})]}),e.jsx("input",{type:"checkbox",checked:!0,disabled:!0,"aria-label":"Strictly necessary (always on)",className:"mt-1 h-4 w-4 accent-midnight"})]}),e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-xl border border-border/60 p-3",children:[e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"block font-semibold",children:"Analytics"}),e.jsx("span",{className:"text-muted-foreground",children:"Not in use today. Reserved in case we add privacy-friendly, aggregated page stats. No advertising."})]}),e.jsx("input",{type:"checkbox",checked:o,onChange:n=>u(n.target.checked),"aria-label":"Allow analytics cookies",className:"mt-1 h-4 w-4 accent-midnight"})]}),e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-xl border border-border/60 p-3",children:[e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"block font-semibold",children:"Marketing"}),e.jsx("span",{className:"text-muted-foreground",children:"We don't use any today. Toggle reserved in case we add a campaign pixel."})]}),e.jsx("input",{type:"checkbox",checked:i,onChange:n=>d(n.target.checked),"aria-label":"Allow marketing cookies",className:"mt-1 h-4 w-4 accent-midnight"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-5 justify-end",children:[e.jsx(c,{variant:"outline",className:"rounded-full h-9 text-xs",onClick:()=>{r({analytics:!1,marketing:!1})},children:"Reject all non-essential"}),e.jsx(c,{variant:"outline",className:"rounded-full h-9 text-xs",onClick:t,children:"Cancel"}),e.jsx(c,{className:"rounded-full h-9 text-xs bg-midnight hover:bg-midnight/90 text-[hsl(var(--midnight-foreground))]",onClick:()=>r({analytics:o,marketing:i}),children:"Save preferences"})]})]})})},S=()=>
1{const[s,t]=a.useState(!1),[r,o]=a.useState(!1),[u,i]=a.useState(null);a.useEffect(()=>{const n=l();if(n){i(n);return}if(w()){g({analytics:!1,marketing:!1,auto:!0}),i(l());return}t(!0)},[]),a.useEffect(()=>{const n=()=>{i(l()),o(!0)};return window.addEventListener(x,n),()=>window.removeEventListener(x,n)},[]);const d=(n,y)=>{g({analytics:n,marketing:y}),i(l()),t(!1)};return a.useEffect(()=>{if(!s)return;const n=document.body.style.paddingBottom;return document.body.style.paddingBottom="10rem",()=>{document.body.style.paddingBottom=n}},[s]),e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{role:"dialog","aria-label":"Cookie consent",className:"fixed inset-x-0 bottom-0 z-50 p-2 sm:p-4 pb-safe animate-in slide-in-from-bottom-4 duration-300",children:e.jsx("div",{className:"container max-w-4xl px-0 sm:px-4",children:e.jsxs("div",{className:"rounded-2xl bg-white border border-border shadow-2xl p-3 sm:p-5 flex flex-col gap-2.5 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"text-[13px] sm:text-sm text-foreground leading-snug",children:[e.jsxs("span",{className:"sm:hidden",children:["We only use strictly-necessary cookies to keep the site working. No tracking."," ",e.jsx(h,{to:"/cookies",className:"underline",children:"Cookie policy"}),"."]}),e.jsxs("span",{className:"hidden sm:inline",children:["We only use strictly-necessary cookies to keep the site working — no analytics, no advertising, no cross-site tracking. See our"," ",e.jsx(h,{to:"/cookies",className:"underline",children:"Cookie policy"}),"."]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-2 shrink-0",children:[e.jsx(c,{variant:"outline",className:"rounded-full h-11 sm:h-9 text-xs order-2 sm:order-none",onClick:()=>{t(!1),o(!0)},children:"Manage"}),e.jsx(c,{className:"rounded-full h-11 sm:h-9 text-xs order-1 sm:order-none bg-midnight hover:bg-midnight/90 text-[hsl(var(--midnight-foreground))]",onClick:()=>d(!1,!1),children:"Got it"})]})]})})}),r&&e.jsx(N,{initial:u,onClose:()=>o(!1),onSave:n=>{d(n.analytics,n.marketing),o(!1)}})]})};export{C as ConsentGate,S as CookieConsent,v as hasConsent,E as openCookiePreferences,k as useConsent};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.