1import{j as e,u as H,r as i,e8 as M,e9 as v,ea as z,L as K,aD as U,aR as V}from"./vendor-BeA4siBz.js";import{a8 as $,n as B,ac as b,B as h,ad as l,ab as W,ae as q,f as G}from"./index-C2NQ_9nj.js";import{S as p}from"./switch-D4mtp9yh.js";import{L as g}from"./label-BgiDwF3G.js";import{P as J,u as X}from"./dialog-watchdog-6C3ud1rn.js";import{u as Y}from"./use-overlay-suppressed-BxgVbqoT.js";const L="data-cookie-consent-banner",Q=60*60*24*365;function w(){if(typeof document>"u")return null;const n=document.cookie.match(new RegExp(`(?:^|; )${l}=([^;]*)`));return n?decodeURIComponent(n[1]):null}function Z(n){const o=encodeURIComponent(n);document.cookie=`${l}=${o}; path=/; max-age=${Q}; SameSite=Lax`}function ee(){try{return!!(localStorage.getItem(l)||w())}catch{return!!w()}}function ce(){return ee()}function E(){try{window.dispatchEvent(new Event(W))}catch{}}function S(n){const o=JSON.stringify(n);try{localStorage.setItem(l,o)}catch{}Z(o)}function O(){return q()}const A={essential:!0,analytics:!1,marketing:!1};function _(n){G("PATCH","/api/user/ui-prefs",{cookieConsent:n}).catch(()=>{})}function le(){return e.jsx(J,{marker:L,label:"CookieConsent",children:e.jsx(se,{})})}function se(){const[n]=H(),R=$()||n.startsWith("/hirevi")?"/hirevi/privacy":"/legal#privacy",[y,r]=i.useState(!1),[d,C]=i.useState(!1),[c,m]=i.useState(A),{user:a,isLoading:j}=B(),x=!!a,k=i.useRef(null);i.useEffect(()=>{var N;if(j)return;const s=a?`user:${a.id}`:"anon";if(k.current===s)return;k.current=s;const t=(N=a==null?void 0:a.uiPrefs)==null?void 0:N.cookieConsent;if(t){S(t),r(!1),E();return}const f=O();if(f){x&&f.status&&_(f);return}const F=setTimeout(()=>r(!0),1e3);return()=>clearTimeout(F)},[j,a,x]),i.useEffect(()=>{const s=()=>{const t=O();m(t!=null&&t.preferences?{essential:!0,analytics:t.preferences.analytics===!0,marketing:t.preferences.marketing===!0}:A),C(!0),r(!0)};return window.addEventListener(b,s),()=>window.removeEventListener(b,s)},[]),X({open:y,marker:L,label:"CookieConsent",onForceClose:()=>r(!1)});const u=s=>{S(s),x&&_(s),r(!1),E()},D=()=>{u({status:"accepted",timestamp:new Date().toISOString(),preferences:{essential:!0,analytics:!0,marketing:!0}})},I=()=>{u({status:"essential_only",timestamp:new Date().toISOString(),preferences:{essential:!0,analytics:!1,marketing:!1}})},P=()=>{const s=c.analytics||c.marketing?"accepted":"essential_only";u({status:s,timestamp:new Date().toISOString(),preferences:{...c,essential:!0}})},T=Y();return!y||T?null:e.jsx(M,{children:e.jsx(v.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},"data-cookie-consent-banner":"true",className:"fixed bottom-[calc(env(safe-area-inset-bottom,0px)_+_4.5rem)] md:bottom-0 left-0 right-0 z-[1001] p-3 sm:p-4 md:p-6",children:e.jsx("div",{className:"max-w-4xl mx-auto bg-white border border-slate-200 shadow-2xl rounded-xl overflow-hidden",children:e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"bg-primary/10 p-2 rounded-lg shrink-0 mt-0.5",children:e.jsx(z,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-slate-900",children:"Cookie Settings"}),e.jsxs("p",{className:"text-xs text-slate-600 mt-1 leading-relaxed",children:["Essential cookies keep this site working securely â they support safe operation, sign-in, your cart, and checkout. Optional Analytics and Marketing cookies are off unless you turn them on, and you can browse and shop either way. Accept All enables the optional categories; Decline keeps only essential cookies."," ",e.jsx(K,{href:R,className:"text-primary hover:underline font-medium",children:"Privacy Policy"})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-center sm:justify-between",children:[e.jsx("button",{className:"text-xs text-slate-500 hover:text-slate-700 flex items-center gap-1 self-start sm:self-auto",onClick:()=>C(!d),children:d?e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"h-3 w-3"})," Hide settings"]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-3 w-3"})," Manage preferences"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{variant:"outline",size:"sm",onClick:I,className:"flex-1 sm:flex-none text-xs font-semibold",children:"Decline"}),e.jsx(h,{size:"sm",onClick:D,className:"flex-1 sm:flex-none bg-green-600 hover:bg-green-700 text-white text-xs font-semibold px-5",children:"Accept All"})]})]}),d&&e.jsxs(v.div,{initial:{height:0,opacity:0}
1,animate:{height:"auto",opacity:1},className:"mt-4 pt-4 border-t border-slate-100",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(g,{htmlFor:"essential",className:"font-semibold text-slate-900 text-sm",children:"Essential"}),e.jsx(p,{id:"essential",checked:!0,disabled:!0})]}),e.jsx("p",{className:"text-xs text-slate-500 leading-relaxed",children:"Necessary for the website to function correctly. Cannot be disabled."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(g,{htmlFor:"analytics",className:"font-semibold text-slate-900 text-sm",children:"Analytics"}),e.jsx(p,{id:"analytics",checked:c.analytics,onCheckedChange:s=>m(t=>({...t,analytics:s}))})]}),e.jsx("p",{className:"text-xs text-slate-500 leading-relaxed",children:"Helps us understand how visitors interact with the site."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(g,{htmlFor:"marketing",className:"font-semibold text-slate-900 text-sm",children:"Marketing"}),e.jsx(p,{id:"marketing",checked:c.marketing,onCheckedChange:s=>m(t=>({...t,marketing:s}))})]}),e.jsx("p",{className:"text-xs text-slate-500 leading-relaxed",children:"Used to display relevant and engaging ads."})]})]}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(h,{size:"sm",onClick:P,className:"text-xs font-semibold px-6",children:"Save My Choices"})})]})]})})})})}export{W as COOKIE_CONSENT_RESOLVED_EVENT,le as default,ce as hasCookieConsent};
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.