{"version":3,"file":"AccessGuard.56v-FaVT.mjs","names":["useState","useRef","remaining"],"sources":["https:/framerusercontent.com/modules/p2Z3y728CNVOumakc6K6/vsK2irsxNnL45p0Be0zq/AccessGuard.js"],"sourcesContent":["// ─────────────────────────────────────────────────────────────\n// AccessGuard.tsx — Bloqueo por tiempo para usuarios no registrados\n//\n// INSTRUCCIONES:\n// 1. Assets → Code → + → \"New File\" → nombra \"AccessGuard.tsx\"\n// 2. Pega este código\n// 3. Arrastra el componente a la página de la biblioteca\n// 4. Ponlo en el layer más alto (encima de todo el contenido)\n// 5. Dale width: 100% y height: 100% en posición Fixed\n// ─────────────────────────────────────────────────────────────\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls}from\"framer\";import{useState,useEffect,useRef}from\"react\";import{auth}from\"https://framerusercontent.com/modules/ieS0rO0yyGY3dyXKfMfI/UKAjoJDNnNirLhmnMIUt/Supabase.js\";const FREE_MINUTES=2;const FREE_MS=FREE_MINUTES*60*1e3;const STORAGE_KEY=\"cm_first_visit\";export default function AccessGuard(){const[blocked,setBlocked]=useState(false);const[timeLeft,setTimeLeft]=useState(FREE_MS);const[loggedIn,setLoggedIn]=useState(false);const intervalRef=useRef(null);useEffect(()=>{// Si ya está logueado, no hacer nada\nconst session=auth.getSession();if(session){setLoggedIn(true);return;}// Registrar primera visita\nconst firstVisit=localStorage.getItem(STORAGE_KEY);const now=Date.now();if(!firstVisit){localStorage.setItem(STORAGE_KEY,String(now));}const startTime=Number(localStorage.getItem(STORAGE_KEY)||now);const elapsed=now-startTime;const remaining=FREE_MS-elapsed;if(remaining<=0){setBlocked(true);return;}setTimeLeft(remaining);// Countdown cada segundo\nintervalRef.current=setInterval(()=>{const now=Date.now();const elapsed=now-startTime;const remaining=FREE_MS-elapsed;if(remaining<=0){clearInterval(intervalRef.current);setBlocked(true);}else{setTimeLeft(remaining);}},1e3);// Escuchar si el usuario se loguea desde otra parte\nconst checkSession=setInterval(()=>{const s=auth.getSession();if(s){setLoggedIn(true);clearInterval(checkSession);clearInterval(intervalRef.current);}},1e3);return()=>{clearInterval(intervalRef.current);clearInterval(checkSession);};},[]);// Si está logueado, no renderizar nada\nif(loggedIn)return null;// Formatear tiempo restante\nconst minutes=Math.floor(timeLeft/6e4);const seconds=Math.floor(timeLeft%6e4/1e3);const timeString=`${minutes}:${seconds.toString().padStart(2,\"0\")}`;// Timer visible (no bloqueante)\nif(!blocked)return /*#__PURE__*/_jsxs(\"div\",{style:styles.timerBadge,children:[/*#__PURE__*/_jsx(\"span\",{style:styles.timerIcon,children:\"⏱\"}),/*#__PURE__*/_jsxs(\"span\",{style:styles.timerText,children:[\"Acceso gratuito: \",timeString]}),/*#__PURE__*/_jsx(\"span\",{style:styles.timerLink,onClick:()=>window.openAuthModal?.(),children:\"Reg\\xedstrate gratis\"})]});// Overlay bloqueante\nreturn /*#__PURE__*/_jsx(\"div\",{style:styles.overlay,children:/*#__PURE__*/_jsxs(\"div\",{style:styles.card,children:[/*#__PURE__*/_jsx(\"div\",{style:styles.iconWrapper,children:\"🔒\"}),/*#__PURE__*/_jsx(\"h2\",{style:styles.title,children:\"Tu tiempo de acceso gratuito termin\\xf3\"}),/*#__PURE__*/_jsx(\"p\",{style:styles.subtitle,children:\"Reg\\xedstrate gratis para seguir explorando la biblioteca de materiales de Code Materials.\"}),/*#__PURE__*/_jsxs(\"ul\",{style:styles.benefits,children:[/*#__PURE__*/_jsx(\"li\",{children:\"✦ Acceso completo a todos los materiales\"}),/*#__PURE__*/_jsx(\"li\",{children:\"✦ Guarda tus favoritos\"}),/*#__PURE__*/_jsx(\"li\",{children:\"✦ Crea moodboards\"}),/*#__PURE__*/_jsx(\"li\",{children:\"✦ Conecta con las marcas\"})]}),/*#__PURE__*/_jsx(\"button\",{style:styles.primaryBtn,onClick:()=>window.openAuthModal?.(),children:\"Crear cuenta gratis\"}),/*#__PURE__*/_jsxs(\"p\",{style:styles.loginText,children:[\"\\xbfYa tienes cuenta?\",\" \",/*#__PURE__*/_jsx(\"span\",{style:styles.loginLink,onClick:()=>window.openAuthModal?.(),children:\"Inicia sesi\\xf3n\"})]})]})});}addPropertyControls(AccessGuard,{});const styles={timerBadge:{position:\"fixed\",bottom:24,left:\"50%\",transform:\"translateX(-50%)\",background:\"#1a1a1a\",color:\"#fff\",borderRadius:100,padding:\"10px 20px\",display:\"flex\",alignItems:\"center\",gap:10,fontSize:13,zIndex:9998,boxShadow:\"0 4px 20px rgba(0,0,0,0.2)\",whiteSpace:\"nowrap\"},timerIcon:{fontSize:14},timerText:{fontVariantNumeric:\"tabular-nums\"},timerLink:{color:\"#fff\",textDecoration:\"underline\",cursor:\"pointer\",opacity:.8,marginLeft:4},overlay:{position:\"fixed\",inset:0,top:0,left:0,right:0,bottom:0,width:\"100vw\",height:\"100vh\",background:\"rgba(10,10,10,0.85)\",backdropFilter:\"blur(8px)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",zIndex:9998},card:{background:\"#fff\",borderRadius:20,padding:\"40px 36px\",width:420,maxWidth:\"90vw\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",gap:16,textAlign:\"center\"},iconWrapper:{fontSize:48},title:{fontSize:22,fontWeight:700,color:\"#1a1a1a\",margin:0,lineHeight:1.3},subtitle:{fontSize:15,color:\"#666\",margin:0,lineHeight:1.6},benefits:{listStyle:\"none\",padding:0,margin:0,display:\"flex\",flexDirection:\"column\",gap:8,alignSelf:\"stretch\",textAlign:\"left\",fontSize:14,color:\"#444\"},primaryBtn:{background:\"#1a1a1a\",color:\"#fff\",border:\"none\",borderRadius:10,padding:\"14px 32px\",fontSize:15,fontWeight:600,cursor:\"pointer\",fontFamily:\"inherit\",width:\"100%\",marginTop:8},loginText:{fontSize:13,color:\"#888\",margin:0},loginLink:{color:\"#1a1a1a\",fontWeight:600,cursor:\"pointer\",textDecoration:\"underline\"}};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AccessGuard\",\"slots\":[],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