{"version":3,"file":"DynamicWAButton.DQdUpyBa.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/QMxMB3gRaYSOO5dlqOXt/ERUzdgf1r5X3qcMPyx7x/DynamicWAButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function DynamicWAButton(props){const[waLink,setWaLink]=useState(\"#\");const[loading,setLoading]=useState(true);useEffect(()=>{const SHEET_URL=\"https://docs.google.com/spreadsheets/d/e/2PACX-1vS1d1MvXzvtMn1yA9xnFwh2gSDvBOJ2Df1HoaTKCZRNZQESkZ78i_brTQhIcZREUSn5rW6nlly7fB8B/pub?gid=0&single=true&output=csv\";async function fetchWALink(){try{const response=await fetch(`${SHEET_URL}&t=${Date.now()}`,{cache:\"no-store\",headers:{\"Cache-Control\":\"no-cache\",Pragma:\"no-cache\"}});const csvText=await response.text();const parseCSVRows=text=>{const rows=[];let currentRow=[];let currentCell=\"\";let inQuotes=false;for(let i=0;i<text.length;i++){const char=text[i];if(char==='\"'){inQuotes=!inQuotes;}else if(char===\",\"&&!inQuotes){currentRow.push(currentCell.trim());currentCell=\"\";}else if((char===\"\\n\"||char===\"\\r\")&&!inQuotes){if(currentRow.length>0||currentCell!==\"\"){currentRow.push(currentCell.trim());rows.push(currentRow);currentRow=[];currentCell=\"\";}}else{currentCell+=char;}}if(currentRow.length>0||currentCell!==\"\"){currentRow.push(currentCell.trim());rows.push(currentRow);}return rows;};const allData=parseCSVRows(csvText).slice(1);const ahora=new Date;const hoyUTC=new Date(Date.UTC(ahora.getUTCFullYear(),ahora.getUTCMonth(),ahora.getUTCDate()));const webinars=allData.map(cols=>({fecha:new Date(cols[0]),active:cols[4]?.trim().toUpperCase(),waGroup:cols[5]})).filter(w=>!isNaN(w.fecha.getTime()));// Ordenamos por fecha para elegir siempre el más cercano de los TRUE\nconst proximo=webinars.filter(w=>w.active===\"TRUE\"&&w.fecha>hoyUTC).sort((a,b)=>a.fecha-b.fecha)[0];if(proximo&&proximo.waGroup){let link=proximo.waGroup;if(link&&!link.startsWith(\"http\"))link=\"https://\"+link;setWaLink(link);}}catch(error){}finally{setLoading(false);}}fetchWALink();},[]);return /*#__PURE__*/_jsxs(\"a\",{href:waLink,target:\"_blank\",rel:\"noopener noreferrer\",style:{...containerStyle,backgroundColor:props.backgroundColor,opacity:loading?.6:1},className:\"dynamic-wa-button\",children:[/*#__PURE__*/_jsx(\"div\",{style:overlayStyle}),/*#__PURE__*/_jsx(\"span\",{style:{...textStyle,color:props.textColor},children:loading?\"Cargando...\":props.text}),/*#__PURE__*/_jsx(\"style\",{children:`\n                .dynamic-wa-button { transition: transform 0.2s ease, filter 0.2s ease !important; text-decoration: none !important; }\n                .dynamic-wa-button:hover { transform: scale(1.02); filter: brightness(1.1); }\n            `})]});}const containerStyle={position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\",maxWidth:\"440px\",height:\"58px\",borderRadius:\"10px\",overflow:\"hidden\",border:\"1px solid rgba(255, 255, 255, 0.15)\",cursor:\"pointer\"};const overlayStyle={position:\"absolute\",inset:0,background:\"linear-gradient(147deg, rgba(255, 255, 255, 0) 40.9505%, rgba(0, 0, 0, 0.5) 100%)\",mixBlendMode:\"overlay\",zIndex:1};const textStyle={position:\"relative\",zIndex:2,fontSize:\"19px\",fontWeight:\"700\",letterSpacing:\"-0.02em\",fontFamily:'\"Plus Jakarta Sans\", sans-serif'};addPropertyControls(DynamicWAButton,{text:{type:ControlType.String,title:\"Texto\",defaultValue:\"Me sumo al grupo\"},backgroundColor:{type:ControlType.Color,title:\"Fondo\",defaultValue:\"#38c23d\"},textColor:{type:ControlType.Color,title:\"Texto Color\",defaultValue:\"#FFFFFF\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DynamicWAButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerM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