import{q as u,n as e}from"./vendor-react-DfNOgXDS.js";import{c6 as b,ck as h,bS as g,c0 as c,bT as x,cw as k,H as f}from"./index-CRANE7wv.js";import{S as y}from"./shield-DcMvRCrt.js";import{C as j}from"./chart-no-axes-column-Bfj3lKFM.js";import{M as v}from"./megaphone-XVfPgSVQ.js";import"./vendor-query-CutdBoCI.js";import"./vendor-dayjs-BrZ9gQN4.js";import"./vendor-antd-core-R0BvUBa1.js";import"./vendor-i18n-BWzZRYJm.js";import"./vendor-sentry-BlaL7Aw0.js";/**
 * @license lucide-react v1.16.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const N=[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]],w=b("cookie",N),C=({checked:t,disabled:n,onChange:i,id:a,label:r})=>e.jsx("button",{type:"button",id:a,role:"switch","aria-checked":t,"aria-label":r,disabled:n,onClick:()=>i==null?void 0:i(!t),className:["relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",n?"cursor-not-allowed opacity-60":"cursor-pointer",t?"bg-primary":"bg-gray-200"].join(" "),children:e.jsx("span",{className:["pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow-md ring-0 transition-transform duration-200",t?"translate-x-5":"translate-x-0"].join(" ")})}),d=({icon:t,title:n,description:i,always:a,checked:r,onChange:l,id:s,expanded:o,onToggleExpand:m,details:p})=>e.jsxs("div",{className:"border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-bg-subtle",children:[e.jsx(t,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("button",{type:"button",className:"flex-1 flex items-center justify-between gap-2 text-left",onClick:m,children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:n}),a&&e.jsx("span",{className:"ml-2 text-xs text-text-muted bg-bg px-1.5 py-0.5 rounded border border-border",children:"Всегда включены"}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:i})]}),e.jsx(f,{className:["h-4 w-4 text-text-muted shrink-0 transition-transform duration-200",o?"rotate-180":""].join(" ")})]}),e.jsx(C,{id:s,label:n,checked:r,disabled:a,onChange:l})]}),o&&e.jsx("div",{className:"px-4 py-3 text-xs text-text-muted border-t border-border bg-bg",children:p})]});function R(){const[t,n]=u.useState(()=>({decision:h(),detailsOpen:!1,analytics:!0,marketing:!0,expandedSection:null}));if(t.decision!=="unknown")return null;const i=()=>{x({analytics:!0,marketing:!0}),c("cookie_consent_decision",{decision:"accepted_all"}),n(s=>({...s,decision:"accepted"}))},a=()=>{k(),c("cookie_consent_decision",{decision:"rejected"}),n(s=>({...s,decision:"rejected"}))},r=()=>{x({analytics:t.analytics,marketing:t.marketing}),c("cookie_consent_decision",{decision:"granular",analytics:t.analytics,marketing:t.marketing}),n(s=>({...s,decision:"accepted"}))},l=s=>n(o=>({...o,expandedSection:o.expandedSection===s?null:s}));return e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-end sm:items-center justify-center p-0 sm:p-4",role:"dialog","aria-modal":"true","aria-label":"Настройки cookies","data-testid":"cookie-consent-banner",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),e.jsxs("div",{className:"relative w-full sm:max-w-xl bg-bg rounded-t-2xl sm:rounded-2xl shadow-2xl flex flex-col max-h-[90vh] sm:max-h-[85vh]",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 pt-6 pb-4 border-b border-border shrink-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(w,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-base font-semibold text-text leading-snug",children:"Cookies и аналитика"}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"Для работы сайта и улучшения вашего опыта"})]}),e.jsx("button",{type:"button",onClick:a,"data-testid":"cookie-consent-close","aria-label":"Закрыть",className:"p-1 rounded-lg text-text-muted hover:text-text hover:bg-bg-subtle transition-colors",children:e.jsx(g,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 px-6 py-4 space-y-3",children:[e.jsxs("p",{className:"text-sm text-text-muted leading-relaxed",children:["Avalog использует cookies для обеспечения работы сайта, аналитики и персонализации. Вы можете принять все cookies или настроить их по категориям. Подробнее —"," ",e.jsx("a",{href:"/privacy",className:"text-primary underline underline-offset-2",onClick:()=>c("cookie_consent_policy_clicked"),children:"политикой конфиденциальности"}),"."]}),t.detailsOpen&&e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(d,{icon:y,id:"cookie-functional",title:"Необходимые",description:"Обеспечивают базовую работу сайта",always:!0,checked:!0,expanded:t.expandedSection==="functional",onToggleExpand:()=>l("functional"),details:"Сессия авторизации, выбранный язык, данные корзины калькулятора. Без этих cookies сайт не будет работать корректно. Хранятся на время сессии или до 1 года."}),e.jsx(d,{icon:j,id:"cookie-analytics",title:"Аналитика",description:"Анонимная статистика для улучшения продукта",checked:t.analytics,onChange:s=>n(o=>({...o,analytics:s})),expanded:t.expandedSection==="analytics",onToggleExpand:()=>l("analytics"),details:"PostHog — анализ поведения пользователей: популярные маршруты, воронки, ошибки. Данные анонимизированы, не передаются третьим лицам. Срок хранения — 12 месяцев."}),e.jsx(d,{icon:v,id:"cookie-marketing",title:"Маркетинг",description:"Ретаргетинг и A/B-тесты",checked:t.marketing,onChange:s=>n(o=>({...o,marketing:s})),expanded:t.expandedSection==="marketing",onToggleExpand:()=>l("marketing"),details:"Используются для показа релевантной рекламы и проведения A/B-тестов интерфейса. Не отправляем данные рекламным сетям без вашего явного согласия."})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-border shrink-0 space-y-2",children:[e.jsx("button",{type:"button",onClick:i,"data-testid":"cookie-consent-accept-btn",className:"w-full h-11 rounded-xl bg-primary text-white font-semibold text-sm hover:bg-primary-dark transition-colors",children:"Принять все cookies"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:a,"data-testid":"cookie-consent-reject-btn",className:"flex-1 h-10 rounded-xl border border-border text-sm font-medium text-text hover:bg-bg-subtle transition-colors",children:"Только необходимые"}),t.detailsOpen?e.jsx("button",{type:"button",onClick:r,"data-testid":"cookie-consent-save-btn",className:"flex-1 h-10 rounded-xl border border-primary text-primary text-sm font-medium hover:bg-primary/5 transition-colors",children:"Сохранить выбор"}):e.jsx("button",{type:"button",onClick:()=>n(s=>({...s,detailsOpen:!0})),"data-testid":"cookie-consent-details-btn",className:"flex-1 h-10 rounded-xl border border-border text-sm font-medium text-text-muted hover:bg-bg-subtle transition-colors",children:"Настройки"})]})]})]})]})}export{R as default};