import{r as a,j as e,b as p,c as v,d as y,e as j,f as N,C}from"./0-vendor-react-DWOJpYrt.js";import{t as k,c as w,a as S}from"./1-vendor-utils-Delnuc0l.js";function A(...s){return k(w(s))}const E=S("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 active:scale-[0.98] active:translate-y-px active:shadow-inner [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 active:bg-destructive/80",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 active:bg-secondary/70",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/70",link:"text-primary underline-offset-4 hover:underline active:text-primary/80"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),x=a.forwardRef(({className:s,variant:c,size:o,asChild:d=!1,...l},m)=>{const u=d?p:"button";return e.jsx(u,{className:A(E({variant:c,size:o,className:s})),ref:m,...l})});x.displayName="Button";const g="emerges-tes-search-history",F=20,_=()=>{const[s,c]=a.useState([]);a.useEffect(()=>{try{const n=sessionStorage.getItem(g);if(n){const i=JSON.parse(n);c(i)}}catch(n){console.error("Error loading search history:",n),c([])}},[]);const o=a.useCallback(n=>{try{const i=n.slice(0,F);sessionStorage.setItem(g,JSON.stringify(i)),c(i)}catch(i){console.error("Error saving search history:",i)}},[]),d=a.useCallback(n=>{const i=Date.now();if(s.filter(t=>t.id===n.id&&i-t.searchedAt<300*1e3).length>0){const t=s.map(f=>f.id===n.id?{...f,searchedAt:i}:f);t.sort((f,h)=>h.searchedAt-f.searchedAt),o(t)}else{const t={...n,searchedAt:i};o([t,...s])}},[s,o]),l=a.useCallback((n=10)=>s.slice(0,n),[s]),m=a.useCallback(()=>{o([])},[o]),u=a.useCallback(n=>{o(s.filter(i=>i.id!==n))},[s,o]);return{history:s,addToHistory:d,getRecentHistory:l,clearHistory:m,removeFromHistory:u}},b="emerges-tes-favorites",H=()=>{const[s,c]=a.useState([]);a.useEffect(()=>{try{const r=localStorage.getItem(b);if(r){const t=JSON.parse(r);c(t)}}catch(r){console.error("Error loading favorites:",r),c([])}},[]);const o=a.useCallback(r=>{try{localStorage.setItem(b,JSON.stringify(r)),c(r)}catch(t){console.error("Error saving favorites:",t)}},[]),d=a.useCallback(r=>{const t={...r,addedAt:Date.now()};o([...s,t])},[s,o]),l=a.useCallback(r=>{o(s.filter(t=>t.id!==r))},[s,o]),m=a.useCallback(r=>s.some(t=>t.id===r),[s]),u=a.useCallback(r=>{m(r.id)?l(r.id):d(r)},[m,d,l]),n=a.useCallback(r=>s.filter(t=>t.type===r),[s]),i=a.useCallback(()=>{o([])},[o]);return{favorites:s,addFavorite:d,removeFavorite:l,toggleFavorite:u,isFavorite:m,getFavoritesByType:n,clearFavorites:i}},O=()=>{const{theme:s,setTheme:c}=v(),{clearFavorites:o}=H(),{clearHistory:d}=_(),[l,m]=a.useState(!1);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-1",children:"Ajustes"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Configuración de la aplicación"})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"font-semibold text-foreground",children:"Apariencia"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>c("light"),className:`w-full flex items-center gap-4 p-4 rounded-lg border transition-colors ${s==="light"?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:border-primary/50"}`,children:[e.jsx(y,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:"Claro"})]}),e.jsxs("button",{onClick:()=>c("dark"),className:`w-full flex items-center gap-4 p-4 rounded-lg border transition-colors ${s==="dark"?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:border-primary/50"}`,children:[e.jsx(j,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:"Oscuro"})]}),e.jsxs("button",{onClick:()=>c("system"),className:`w-full flex items-center gap-4 p-4 rounded-lg border transition-colors ${s==="system"?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:border-primary/50"}`,children:[e.jsx(N,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:"Sistema"})]})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"font-semibold text-foreground",children:"Datos"}),e.jsxs("div",{className:"p-4 bg-card border border-border rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"Favoritos"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Guardados localmente en tu dispositivo"})]}),e.jsx(x,{variant:"outline",size:"sm",onClick:()=>{o()},children:"Limpiar"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"Historial"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Búsquedas recientes (sesión)"})]}),e.jsx(x,{variant:"outline",size:"sm",onClick:()=>{d()},children:"Limpiar"})]})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"font-semibold text-foreground",children:"Información"}),e.jsxs("div",{className:"p-4 bg-card border border-border rounded-lg space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Versión"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"1.0.0"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Almacenamiento"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Local"})]})]})]}),e.jsxs("div",{className:"p-4 bg-muted border border-border rounded-lg flex items-start gap-3",children:[e.jsx(C,{className:"w-5 h-5 text-muted-foreground flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground mb-1",children:"Datos locales"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Todos los datos se guardan localmente en tu dispositivo. Si limpias el almacenamiento del navegador, se perderán."})]})]})]})},z=Object.freeze(Object.defineProperty({__proto__:null,default:O},Symbol.toStringTag,{value:"Module"}));export{z as A,x as B,_ as a,A as c,H as u};