1import{j as e,m as t}from"./vendor-framer-3515f164.js";import{r,f as s}from"./vendor-react-c28adb65.js";import{u as a}from"./index-33680efc.js";import{ar as n,am as o,J as i,v as l,w as c,av as d,z as u,as as p,s as m,u as x}from"./vendor-ui-938df96e.js";import{u as h}from"./useAudioInput-43baa8a8.js";const f={damping:.96,timeScale:1,resolutionScale:1},g=!0,b=1,v=[],w=f,y="wavesSimulationState";const j=({isPlaying:s,speed:a,onPlayPause:m,onReset:x,onSpeedChange:h,onExport:f,onImport:g,isAudioReactive:b,onToggleAudioReactive:v})=>{const w=r.useRef(null);return e.jsxs(t.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"w-full max-w-4xl mx-auto p-4 bg-[#0a0a0a]/80 backdrop-blur-md border border-cyan-500/20 rounded-xl shadow-[0_0_20px_rgba(6,182,212,0.1)] flex flex-col md:flex-row gap-6 items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:m,className:"flex items-center justify-center w-12 h-12 rounded-full border transition-all duration-300 "+(s?"bg-cyan-500/10 border-cyan-500 text-cyan-400 shadow-[0_0_15px_rgba(6,182,212,0.3)]":"bg-white/5 border-white/10 text-gray-400 hover:border-cyan-500/50 hover:text-cyan-200"),children:s?e.jsx(n,{className:"w-5 h-5 fill-current"}):e.jsx(o,{className:"w-5 h-5 fill-current ml-1"})}),e.jsx("button",{onClick:x,className:"p-3 rounded-lg bg-white/5 border border-white/10 text-gray-400 hover:text-white hover:bg-white/10 hover:border-white/30 transition-all",title:"Reiniciar Simulación",children:e.jsx(i,{className:"w-5 h-5"})}),e.jsx("button",{onClick:v,className:"p-3 rounded-lg border transition-all "+(b?"bg-purple-500/20 border-purple-500 text-purple-400 shadow-[0_0_15px_rgba(168,85,247,0.3)]":"bg-white/5 border-white/10 text-gray-400 hover:border-purple-500/50 hover:text-purple-200"),title:"Modo Audio-Reactivo",children:b?e.jsx(l,{className:"w-5 h-5"}):e.jsx(c,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex flex-col ml-2",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-gray-500",children:"Estado"}),e.jsx("span",{className:"text-sm font-medium "+(s?"text-cyan-400":"text-yellow-500"),children:s?"EJECUTANDO":"PAUSADO"})]})]}),e.jsxs("div",{className:"flex-1 w-full md:w-auto px-4 border-l border-r border-white/5 flex flex-col gap-3",children:[e.jsx("div",{className:"flex items-center justify-between text-xs text-cyan-400 uppercase tracking-wider font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{className:"w-4 h-4"}),e.jsxs("span",{children:["Velocidad: ",a.toFixed(1),"x"]})]})}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsx("input",{type:"range",min:"0.1",max:"2.0",step:"0.1",value:a,onChange:e=>h(parseFloat(e.target.value)),className:"flex-1 h-1.5 bg-gray-700 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-cyan-400 [&::-webkit-slider-thumb]:shadow-[0_0_10px_rgba(34,211,238,0.5)] transition-all"})}),e.jsx("div",{className:"flex justify-between gap-2",children:[.5,1,1.5,2].map(t=>e.jsxs("button",{onClick:()=>h(t),className:"text-[9px] px-2 py-1 rounded transition-colors "+(a===t?"bg-cyan-500/20 text-cyan-400":"text-gray-500 hover:text-gray-300"),children:[t.toFixed(1),"x"]},t))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:f,className:"flex items-center gap-2 px-4 py-2 bg-slate-800 hover:bg-slate-700 rounded-lg text-xs font-bold text-blue-400 border border-slate-700 transition-all",children:[e.jsx(u,{className:"w-4 h-4"}),"Exportar"]}),e.jsxs("button",{onClick:()=>{var e;return null==(e=w.current)?void 0:e.click()},className:"flex items-center gap-2 px-4 py-2 bg-slate-800 hover:bg-slate-700 rounded-lg text-xs font-bold text-green-400 border border-slate-700 transition-all",children:[e.jsx(p,{className:"w-4 h-4"}),"Importar",e.jsx("input",{type:"file",ref:w,onChange:e=>{var t;const r=null==(t=e.target.files)?void 0:t[0];r&&g(r),e.target.value=""},accept:".json",className:"hidden"})]})]})]})},N=()=>{const n=r.useRef(null),o=r.useRef(null),i=s(),{isPlaying:l,speed:c,sources:d,config:u,togglePlay:p,reset:N,setSpeed:S,exportState:k,importState:C}=function(){const[e,t]=r.useState(g),[s,n]=r.useState(b),[o,i]=r.useState(v),[l,c]=r.useState(w),{toast:d}=a();r.useEffect(()=>{try{const e=localStorage.getItem(y);if(e){const t=JSON.parse(e);void 0!==t.speed&&n(t.speed),void 0!==t.sources&&i(t.sources),void 0!==t.config&&c({...f,...t.config})}}catch(e){}},[]),r.useEffect(()=>{try{const e={speed:s,sources:o,config:l};localStorage.setItem(y,JSON.stringify(e))}catch(e){}},[s,o,l]);const u=r.useCallback(()=>t(e=>!e),[]),p=r.useCallback(()=>{n(b),i(v),c(w),t(!1),d({title:"Simulación reiniciada",description:"Todos los parámetros han vuelto a sus valores por defecto."})},[d]),m=r.useCallback(e=>{i(t=>[...t,{...e,id:crypto.randomUUID()}])},[]),x=r.useCallback(e=>{i(t=>t.filter(t=>t.id!==e))},[]),h=r.useCallback((e,t)=>{i(r=>r.map(r=>r.id===e?{...r,...t}:r))},[]),j=r.useCallback(()=>{const e={manifest:{name:"waves-sim",version:"1.0",timestamp:(new Date).toISOString()},sources:o,config:{...l,speed:s}},t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=`waves-state-${Date.now()}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r),d({title:"Estado exp
1ortado",description:"La configuración se ha guardado correctamente."})},[o,l,s,d]),N=r.useCallback(async e=>{try{const t=await e.text(),r=JSON.parse(t);r.sources&&i(r.sources),r.config&&(c({...f,...r.config}),r.config.speed&&n(r.config.speed)),d({title:"Estado importado",description:"Se han cargado los parámetros de la simulación."})}catch(t){d({title:"Error al importar",description:"El archivo seleccionado no es válido.",variant:"destructive"})}},[d]);return{isPlaying:e,speed:s,sources:o,config:l,togglePlay:u,reset:p,setSpeed:n,setConfig:c,addSource:m,removeSource:x,updateSource:h,exportState:j,importState:N}}(),{isListening:M,toggleAudio:R,audioData:A}=h(),E=r.useRef({cols:0,rows:0,current:[],previous:[],damping:u.damping,time:0}),_=r.useRef(),I=(e,t)=>{const r=Math.ceil(e/10),s=Math.ceil(t/10);E.current.cols=r,E.current.rows=s,E.current.current=new Array(r).fill(0).map(()=>new Array(s).fill(0)),E.current.previous=new Array(r).fill(0).map(()=>new Array(s).fill(0)),E.current.time=0};r.useEffect(()=>{E.current.damping=u.damping},[u]),r.useEffect(()=>{const e=n.current,t=o.current,r=()=>{t&&e&&(e.width=t.clientWidth,e.height=t.clientHeight,I(e.width,e.height))};return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),r.useEffect(()=>{const e=n.current;if(!e)return;const t=e.getContext("2d");if(!t)return;const r=()=>{if(!l)return void(_.current=requestAnimationFrame(r));const{cols:s,rows:a,current:n,previous:o,damping:i}=E.current;let d=1,u=!0;if(c>=1?d=Math.round(c):Math.random()>c&&(u=!1),u){for(let e=0;e<d;e++){E.current.time+=1;for(let t=1;t<s-1;t++)for(let e=1;e<a-1;e++)n[t][e]=(o[t-1][e]+o[t+1][e]+o[t][e-1]+o[t][e+1])/2-n[t][e],n[t][e]=n[t][e]*i;const e=E.current.previous;E.current.previous=E.current.current,E.current.current=e}if(M&&(null==A?void 0:A.bands)&&l){const e=6,t=Math.floor(s/(e+1));for(let r=0;r<e;r++){const e=A.bands[r]||0;if(e>.05){const n=t*(r+1),o=Math.floor(a/2);n>0&&n<s-1&&o>0&&o<a-1&&(E.current.previous[n][o]+=600*e)}}}}t.fillStyle="#050505",t.fillRect(0,0,e.width,e.height);const p=E.current.previous;for(let e=0;e<s;e++)for(let r=0;r<a;r++){const s=p[e][r];if(Math.abs(s)>.05){const a=10*e,n=10*r;t.fillStyle=s>0?`rgba(6, 182, 212, ${Math.min(1,Math.abs(s))})`:`rgba(168, 85, 247, ${Math.min(1,Math.abs(s))})`,t.fillRect(a,n,10,10)}}_.current=requestAnimationFrame(r)};_.current=requestAnimationFrame(r);const s=setInterval(()=>{if(Math.random()>.9&&l){const e=Math.floor(Math.random()*(E.current.cols-4))+2,t=Math.floor(Math.random()*(E.current.rows-4))+2;e>=0&&e<E.current.cols&&t>=0&&t<E.current.rows&&(E.current.previous[e][t]=500)}},500);return()=>{_.current&&cancelAnimationFrame(_.current),clearInterval(s)}},[l,c,M,A]),r.useEffect(()=>{l||1!==c||n.current&&I(n.current.width,n.current.height)},[d,l,c]);return e.jsxs("div",{className:"relative w-full h-screen bg-[#050505] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"absolute top-0 left-0 right-0 z-50 p-6 flex flex-col gap-4 pointer-events-none",children:[e.jsx("div",{className:"flex items-start justify-between pointer-events-auto",children:e.jsxs(t.button,{whileHover:{x:-5},onClick:()=>i("/research"),className:"flex items-center gap-2 px-4 py-2 bg-black/60 border border-purple-500/30 text-purple-400 rounded-lg backdrop-blur-md hover:bg-purple-950/50 hover:border-purple-400 transition-all shadow-[0_0_15px_rgba(168,85,247,0.2)]",children:[e.jsx(m,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium uppercase tracking-wider",children:"Volver"})]})}),e.jsx("div",{className:"pointer-events-auto",children:e.jsx(j,{isPlaying:l,speed:c,onPlayPause:p,onReset:N,onSpeedChange:S,onExport:k,onImport:C,isAudioReactive:M,onToggleAudioReactive:R})})]}),e.jsx("div",{ref:o,className:"flex-grow relative cursor-crosshair z-0",children:e.jsx("canvas",{ref:n,onMouseMove:e=>{if(!n.current)return;const t=n.current.getBoundingClientRect(),r=Math.floor((e.clientX-t.left)/10),s=Math.floor((e.clientY-t.top)/10);r>0&&r<E.current.cols-1&&s>0&&s<E.current.rows-1&&(E.current.previous[r][s]=500)},className:"block w-full h-full"})}),e.jsxs("div",{className:"absolute bottom-10 right-10 pointer-events-none text-right z-10",children:[e.jsx("h1",{className:"text-4xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-cyan-400 to-purple-500 o
1pacity-50",children:"ONDAS"}),e.jsxs("div",{className:"flex items-center justify-end gap-2 text-gray-500 mt-2",children:[e.jsx(x,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs uppercase tracking-widest",children:"Interactúa con el cursor"})]})]})]})};export{N as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.