{"version":3,"file":"shared-lib.Bn0e_olr.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/tdtaH6wCfWDjENs3h1RY/Etkx9fGzN5zpMDne9RRs/CookieBanner.js"],"sourcesContent":["// Cookie banner with editable text and link to cookie policy page.\n// Can be reopened from anywhere (e.g. footer link \"Configurar cookies\") by dispatching\n// the window event \"rub-open-cookie-settings\". When consent is withdrawn after having\n// been accepted, Google Analytics consent is set to denied and its cookies are removed.\n// Accept and decline buttons share exactly the same visual weight.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";const CONSENT_STORAGE_KEY=\"rub-cookie-consent\";const OPEN_EVENT=\"rub-open-cookie-settings\";/**\n * Sends the consent decision to Google's gtag Consent Mode.\n * gtag is defined globally in the site's <head> custom code (see gtag/js snippet).\n * If gtag isn't available yet (e.g. site being edited outside Framer's published head),\n * this is a no-op and won't throw.\n */function updateGtagConsent(status){try{const w=window;if(typeof w.gtag===\"function\"){w.gtag(\"consent\",\"update\",{analytics_storage:status===\"accepted\"?\"granted\":\"denied\"});}}catch(e){// gtag not available - ignore\n}}/**\n * Removes Google Analytics cookies set on this site.\n * Tries the current host and its parent domains, since GA cookies are usually\n * set on the registrable domain.\n */function clearAnalyticsCookies(){try{if(typeof document===\"undefined\")return;const matcher=/^(_ga|_gid|_gat)/;const names=document.cookie.split(\";\").map(c=>c.split(\"=\")[0].trim()).filter(n=>n&&matcher.test(n));const host=window.location.hostname;const parts=host.split(\".\");const domains=[host,\".\"+host];for(let i=1;i<parts.length-1;i++){domains.push(\".\"+parts.slice(i).join(\".\"));}names.forEach(name=>{const expired=`${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;document.cookie=expired;domains.forEach(d=>{document.cookie=`${expired}; domain=${d}`;});});}catch(e){// ignore\n}}/**\n * Cookie Banner with editable text and cookie policy link\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 120\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CookieBanner(props){const{message,acceptLabel,declineLabel,linkText,cookiePolicyUrl,backgroundColor,textColor,linkColor,buttonColor,buttonTextColor,font,buttonFont,borderRadius}=props;const[show,setShow]=useState(false);const[checkedStorage,setCheckedStorage]=useState(false);useEffect(()=>{let existingConsent=null;try{existingConsent=window.localStorage.getItem(CONSENT_STORAGE_KEY);}catch(e){// localStorage not available (e.g. private browsing) - show banner anyway\n}if(!existingConsent){startTransition(()=>setShow(true));}else if(existingConsent===\"accepted\"||existingConsent===\"declined\"){// Re-apply the stored decision in case the head snippet's own\n// localStorage check ran before this component mounted.\nupdateGtagConsent(existingConsent);}startTransition(()=>setCheckedStorage(true));// Allow reopening the banner from anywhere (footer \"Configurar cookies\" link)\nfunction handleOpen(){startTransition(()=>{setCheckedStorage(true);setShow(true);});}window.addEventListener(OPEN_EVENT,handleOpen);return()=>window.removeEventListener(OPEN_EVENT,handleOpen);},[]);function readStoredConsent(){try{return window.localStorage.getItem(CONSENT_STORAGE_KEY);}catch(e){return null;}}function saveConsent(value){try{window.localStorage.setItem(CONSENT_STORAGE_KEY,value);}catch(e){// ignore if storage isn't available\n}}function handleAccept(){saveConsent(\"accepted\");updateGtagConsent(\"accepted\");startTransition(()=>setShow(false));}function handleDecline(){const previous=readStoredConsent();saveConsent(\"declined\");updateGtagConsent(\"declined\");startTransition(()=>setShow(false));// Consent withdrawn after having been accepted: remove analytics cookies.\nif(previous===\"accepted\"){clearAnalyticsCookies();}}const isEditor=RenderTarget.current()===RenderTarget.canvas;// Avoid a flash of the banner before we've had a chance to check storage,\n// except in the Framer canvas editor where we always want it visible for editing.\nif(!isEditor&&!checkedStorage)return null;if(!isEditor&&!show)return null;if(RenderTarget.current()===RenderTarget.thumbnail)return null;// Same style for both options so neither is visually favoured.\nconst buttonStyles={borderRadius:10,flex:1,border:`1px solid ${buttonColor}`,padding:\"8px 18px\",cursor:\"pointer\",background:buttonColor,color:buttonTextColor,...buttonFont};const isFixedWidth=props?.style&&props.style.width===\"100%\";return /*#__PURE__*/_jsxs(\"div\",{role:\"dialog\",\"aria-label\":\"Cookies\",style:{...props.style,overflow:\"hidden\",position:\"relative\",...isFixedWidth?{...props?.style}:{minWidth:\"max-content\"},background:backgroundColor,color:textColor,borderRadius,display:\"flex\",flexDirection:\"column\",justifyContent:\"space-between\",padding:20,boxShadow:\"0 2px 8px rgba(0,0,0,0.08)\",gap:16},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:8},children:[/*#__PURE__*/_jsx(\"span\",{style:{...font},children:message}),/*#__PURE__*/_jsx(\"a\",{href:cookiePolicyUrl,target:\"_blank\",rel:\"noopener noreferrer\",style:{...font,color:linkColor,textDecoration:\"underline\",cursor:\"pointer\",width:\"max-content\"},children:linkText})]}),/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",display:\"flex\",gap:10},children:[/*#__PURE__*/_jsx(\"button\",{style:buttonStyles,onClick:handleDecline,children:declineLabel}),/*#__PURE__*/_jsx(\"button\",{style:buttonStyles,onClick:handleAccept,children:acceptLabel})]})]});}addPropertyControls(CookieBanner,{message:{type:ControlType.String,title:\"Message\",defaultValue:\"Usamos cookies para mejorar tu experiencia en nuestro sitio web.\",displayTextArea:true},linkText:{type:ControlType.String,title:\"Link Text\",defaultValue:\"Pol\\xedtica de cookies\"},cookiePolicyUrl:{type:ControlType.String,title:\"Cookie Policy URL\",defaultValue:\"/cookies\",placeholder:\"https://example.com/cookies\"},acceptLabel:{type:ControlType.String,title:\"Accept Label\",defaultValue:\"Aceptar\"},declineLabel:{type:ControlType.String,title:\"Decline Label\",defaultValue:\"Rechazar\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},linkColor:{type:ControlType.Color,title:\"Link Color\",defaultValue:\"#0099FF\"},buttonColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"#000000\"},buttonTextColor:{type:ControlType.Color,title:\"Button Text\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{variant:\"Medium\",fontSize:\"14px\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},buttonFont:{type:ControlType.Font,title:\"Button Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{variant:\"Semibold\",fontSize:\"14px\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:32}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CookieBanner\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"120\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"400\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CookieBanner.map"],"mappings":"oNAUG,SAAS,EAAkB,EAAO,CAAC,GAAG,CAAC,IAAM,EAAE,EAAU,OAAO,EAAE,MAAO,YAAY,EAAE,KAAK,UAAU,SAAS,CAAC,kBAAkB,IAAS,WAAW,UAAU,QAAQ,CAAC,CAAG,MAAS,CACxL,CAAC,CAIE,SAAS,GAAuB,CAAC,GAAG,CAAC,GAAG,OAAO,SAAW,IAAY,OAAO,IAAM,EAAQ,mBAAyB,EAAM,SAAS,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,EAAQ,KAAK,CAAC,CAAC,EAAQ,EAAK,EAAO,SAAS,SAAe,EAAM,EAAK,MAAM,GAAG,EAAQ,EA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