const aceStreamUrl='https://ia600309.us.archive.org/8/items/abcd_20240416/Arena4view.txt';const translationsUrl='translations.json';let translations={};let eventos=[];async function loadTranslations(){try{const response=await fetch(translationsUrl);if(!response.ok){throw new Error('Error al cargar el diccionario de traducciones')}translations=await response.json()}catch(error){console.error('Error:',error)}}async function getAceStreamLinks(){try{const response=await fetch(aceStreamUrl);if(!response.ok){throw new Error('Error al obtener los enlaces AceStream')}const text=await response.text();const lines=text.split('n');const aceStreamMap={};lines.forEach(line=>{const[key,value]=line.split('#');if(key&&value){aceStreamMap[key.trim()]=value.trim()}});return aceStreamMap}catch(error){console.error('Error:',error);return{}}}function formatDate(dateString){return dateString.split('/').slice(0,2).join('/')}function formatTime(timeString){return timeString.replace(' CET','')}function translateTable(table){const rows=table.querySelectorAll('tr');const headerRow=rows[0];if(headerRow){const headerCells=headerRow.querySelectorAll('td');headerCells.forEach((cell)=>{const text=cell.textContent.trim();if(text){const translatedText=translations[text]||text;cell.textContent=translatedText}})}rows.forEach((row,rowIndex)=>{if(rowIndex===0)return;const cells=row.querySelectorAll('td');cells.forEach((cell,cellIndex)=>{if(cellIndex===0){cell.textContent=formatDate(cell.textContent.trim())}if(cellIndex===1){cell.textContent=formatTime(cell.textContent.trim())}if(cellIndex===3||cellIndex===4)return;const text=cell.textContent.trim();if(text){const translatedText=Object.keys(translations).reduce((acc,key)=>{return acc.replace(new RegExp(key,'gi'),translations[key])},text);cell.textContent=translatedText}})})}function mostrarEventosBaloncesto(aceStreamMap){const eventosDiv=document.getElementById('eventos');eventosDiv.innerHTML='';const groupedEvents=eventos.reduce((acc,evento)=>{const[dia,hora,deporte,competicion,eventoNombre,live]=evento;if(deporte.toLowerCase()==='baloncesto'&&dia===obtenerFechaHoy()){if(!acc[competicion]){acc[competicion]=[]}acc[competicion].push(evento)}return acc},{});if(Object.keys(groupedEvents).length===0){const noEventsHTML=`
No se encontraron eventos.
'}}catch(error){console.error('Error:',error);document.getElementById('eventos').innerHTML='Error al cargar los eventos.
'}}window.onload=fetchData;