const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/page-soportevital-DQtvdBj2.js","assets/0-vendor-react-DWOJpYrt.js","assets/1-vendor-utils-Delnuc0l.js","assets/vendor-utils-Dfs9RUU9.css","assets/2-vendor-markdown-BQlHAcA7.js","assets/page-comunicacion-DmHQUHoW.js","assets/page-ajustes-DgawOEJM.js","assets/page-farmacos-BsW3CLyQ.js","assets/page-patologias-CAkXUO11.js","assets/page-escena-ZCRqUJc7.js","assets/page-herramientas-DcKR8MlC.js","assets/page-material-Ck8ErBi1.js","assets/page-telefono-tnu9q39s.js","assets/page-manualindex-iXG0WSpO.js","assets/page-galeriaimagenes-Dnb019dP.js","assets/page-manual-viewer-scmsIV_3.js","assets/component-markdown-S2Gzerbp.js","assets/page-rcp-CZ8w6Oz0.js","assets/page-ictus-Oam15e1v.js","assets/page-shock-DhKboriQ.js","assets/page-viaaerea-CKEU5wcY.js","assets/page-favoritos-DDtM_cze.js","assets/page-historial-DRNAlGuI.js","assets/page-acerca-_Mt0Ax57.js","assets/page-privacidad-I8o09WuK.js","assets/page-descargoresponsabilidad-DSgOxrdC.js","assets/page-avisolegal-W9N3WFzz.js","assets/page-parto-DUwiEgy8.js","assets/GuideIndex-CyqK2c3S.js","assets/page-index-DvnG8OQi.js","assets/page-notfound-CX_Wllnx.js","assets/GuideViewer-CCIQxKzP.js","assets/GuideNavigation-8OWTG37Z.js","assets/page-testingpage-D_q9Y_VH.js","assets/GuideSectionViewer-DGLFWYd-.js","assets/VitalsDashboard-ByReykvi.js","assets/SepsisChecklist-D8Co53T_.js","assets/timers-DtW-cs9v.js","assets/IctusChecklist-BrhTLt4s.js","assets/ParadaChecklist-Bul0fsVj.js","assets/PartoChecklist-DcLWkRPK.js","assets/AnafilaxiaChecklist-GssBTsnG.js","assets/IntoxicacionesChecklist-mYkQyLGE.js","assets/ConvulsionesChecklist-sTdTUAEq.js","assets/TermicasChecklist-CNVEh2gL.js","assets/ShockSepticPathway-OevyubcK.js","assets/BroselowQuick-Cnc3TNmR.js","assets/page-urgencias-ANdUuGm2.js"])))=>i.map(i=>d[i]); import{r,j as e,aI as G,aJ as H,aK as U,aL as q,X as A,aM as $,aN as F,aO as pe,c as xe,aP as he,aQ as Q,aR as fe,aS as ge,m as E,u as J,av as ve,_ as be,T as j,aT as je,aU as we,aV as ye,aW as K,aX as Ne,aY as Ee,Z as Y,aZ as _e,F as X,a_ as Se,K as C,Q as ke,aq as Ie,an as Ae,l as Ce,au as Te,x as Pe,al as Le,w as Re,a$ as Oe,I as De,a as Z,aC as ee,a0 as ze,b0 as Me,b1 as Ve,b2 as We,b3 as c,b4 as Be}from"./0-vendor-react-DWOJpYrt.js";import{d as Ge,c as He,f as Ue,_ as u}from"./page-farmacos-BsW3CLyQ.js";import{a as qe,o as $e,s as z,as as Fe}from"./1-vendor-utils-Delnuc0l.js";import{c as y,B as b,a as Qe}from"./page-ajustes-DgawOEJM.js";import{P as Je}from"./page-rcp-CZ8w6Oz0.js";import{c as Ke,a as Ye,b as Xe,u as Ze,P as et}from"./page-herramientas-DcKR8MlC.js";import{C as tt,c as st,d as at,e as rt,B as ot}from"./page-comunicacion-DmHQUHoW.js";import{H as nt}from"./page-index-DvnG8OQi.js";import{N as it}from"./page-notfound-CX_Wllnx.js";import"./2-vendor-markdown-BQlHAcA7.js";import"./page-galeriaimagenes-Dnb019dP.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function a(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(n){if(n.ep)return;n.ep=!0;const i=a(n);fetch(n.href,i)}})();function lt(t=!0){const s=r.useRef(new Set);r.useEffect(()=>{if(!t||typeof window>"u")return;const a=o=>{const n=o.target;if(!(n instanceof Element))return;const i=n.closest("a[href]");if(!i)return;const l=i.getAttribute("href");if(!(!l||l.startsWith("#")||l.startsWith("mailto:")||l.startsWith("tel:"))&&l.startsWith("/")&&!s.current.has(l)){const m=document.createElement("link");m.rel="prefetch",m.href=l,document.head.appendChild(m),s.current.add(l)}};return document.addEventListener("mouseenter",a,{capture:!0}),()=>{document.removeEventListener("mouseenter",a,{capture:!0})}},[t])}const ct=1,dt=1e6;let T=0;function ut(){return T=(T+1)%Number.MAX_SAFE_INTEGER,T.toString()}const P=new Map,M=t=>{if(P.has(t))return;const s=setTimeout(()=>{P.delete(t),N({type:"REMOVE_TOAST",toastId:t})},dt);P.set(t,s)},mt=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,ct)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(a=>a.id===s.toast.id?{...a,...s.toast}:a)};case"DISMISS_TOAST":{const{toastId:a}=s;return a?M(a):t.toasts.forEach(o=>{M(o.id)}),{...t,toasts:t.toasts.map(o=>o.id===a||a===void 0?{...o,open:!1}:o)}}case"REMOVE_TOAST":return s.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(a=>a.id!==s.toastId)}}},_=[];let S={toasts:[]};function N(t){S=mt(S,t),_.forEach(s=>{s(S)})}function pt({...t}){const s=ut(),a=n=>N({type:"UPDATE_TOAST",toast:{...n,id:s}}),o=()=>N({type:"DISMISS_TOAST",toastId:s});return N({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:n=>{n||o()}}}),{id:s,dismiss:o,update:a}}function xt(){const[t,s]=r.useState(S);return r.useEffect(()=>(_.push(s),()=>{const a=_.indexOf(s);a>-1&&_.splice(a,1)}),[t]),{...t,toast:pt,dismiss:a=>N({type:"DISMISS_TOAST",toastId:a})}}const ht=pe,te=r.forwardRef(({className:t,...s},a)=>e.jsx(G,{ref:a,className:y("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));te.displayName=G.displayName;const ft=qe("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),se=r.forwardRef(({className:t,variant:s,...a},o)=>e.jsx(H,{ref:o,className:y(ft({variant:s}),t),...a}));se.displayName=H.displayName;const gt=r.forwardRef(({className:t,...s},a)=>e.jsx(U,{ref:a,className:y("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...s}));gt.displayName=U.displayName;const ae=r.forwardRef(({className:t,...s},a)=>e.jsx(q,{ref:a,className:y("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(A,{className:"h-4 w-4"})}));ae.displayName=q.displayName;const re=r.forwardRef(({className:t,...s},a)=>e.jsx($,{ref:a,className:y("text-sm font-semibold",t),...s}));re.displayName=$.displayName;const oe=r.forwardRef(({className:t,...s},a)=>e.jsx(F,{ref:a,className:y("text-sm opacity-90",t),...s}));oe.displayName=F.displayName;function vt(){const{toasts:t}=xt();return e.jsxs(ht,{children:[t.map(function({id:s,title:a,description:o,action:n,...i}){return e.jsxs(se,{...i,children:[e.jsxs("div",{className:"grid gap-1",children:[a&&e.jsx(re,{children:a}),o&&e.jsx(oe,{children:o})]}),n,e.jsx(ae,{})]},s)}),e.jsx(te,{})]})}const bt=({...t})=>{const{theme:s="system"}=xe();return e.jsx(he,{theme:s,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})},jt=fe,wt=r.forwardRef(({className:t,sideOffset:s=4,...a},o)=>e.jsx(Q,{ref:o,sideOffset:s,className:y("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));wt.displayName=Q.displayName;const ne=r.memo(()=>e.jsx(ge,{className:"w-5 h-5 text-muted-foreground"}));ne.displayName="MenuIcon";const ie=r.memo(()=>e.jsx(E,{className:"w-5 h-5 text-muted-foreground"}));ie.displayName="SearchIcon";const R=r.memo(({onSearchClick:t,onMenuClick:s})=>{const a=J(),o=ve(),n=r.useMemo(()=>o.pathname!=="/",[o.pathname]),i=r.useMemo(()=>o.pathname==="/urgencias",[o.pathname]),[l,m]=r.useState(navigator.onLine);r.useEffect(()=>{const x=()=>m(!0),g=()=>m(!1);return window.addEventListener("online",x),window.addEventListener("offline",g),()=>{window.removeEventListener("online",x),window.removeEventListener("offline",g)}},[]);const d=r.useCallback(()=>{window.history.length>1?a(-1):a("/")},[a]),v=r.useCallback(()=>{requestAnimationFrame(()=>{s()})},[s]),p=r.useCallback(()=>{requestAnimationFrame(()=>{t()})},[t]);return r.useMemo(()=>l?"bg-success/20 text-success":"bg-warning/20 text-warning",[l]),e.jsxs("header",{className:"fixed top-0 left-0 right-0 z-50 bg-card border-b border-border",children:[e.jsxs("div",{className:"flex items-center justify-between h-14 px-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[n&&e.jsx(b,{onClick:d,variant:"ghost",size:"icon",className:"w-9 h-9","aria-label":"Volver",children:e.jsx(be,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary flex items-center justify-center",children:e.jsx("span",{className:"text-primary-foreground font-bold text-sm",children:"TES"})}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsx("h1",{className:"font-semibold text-foreground text-sm",children:"EMERGES TES"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Guía de Protocolos"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{if(i){window.history.length>1?a(-1):a("/");return}a("/urgencias")},className:`w-10 h-10 flex items-center justify-center rounded-lg transition-all ${i?"bg-[hsl(var(--emergency-high))]/15 text-[hsl(var(--emergency-high))] border border-[hsl(var(--emergency-high))]/40":"bg-[hsl(var(--emergency-high))] text-white hover:opacity-90"} active:scale-95`,"aria-label":i?"Salir del modo urgencias":"Activar modo urgencias",children:e.jsx(j,{className:"w-5 h-5"})}),i&&e.jsx("span",{className:"px-2 py-1 rounded-full text-[10px] font-semibold tracking-wide bg-[hsl(var(--emergency-high))]/15 text-[hsl(var(--emergency-high))] border border-[hsl(var(--emergency-high))]/40",children:"URG"}),e.jsx("div",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium ${l?"bg-success/20 text-success":"bg-warning/20 text-warning"}`,children:l?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-3 h-3"}),e.jsx("span",{className:"hidden sm:inline",children:"Online"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3"}),e.jsx("span",{className:"hidden sm:inline",children:"Offline"})]})}),e.jsx("button",{onClick:p,className:"w-10 h-10 flex items-center justify-center rounded-lg hover:bg-muted active:bg-accent active:scale-95 transition-all","aria-label":"Buscar",children:e.jsx(ie,{})}),e.jsx("button",{onClick:v,className:"w-10 h-10 flex items-center justify-center rounded-lg hover:bg-muted active:bg-accent active:scale-95 transition-all","aria-label":"Menú",children:e.jsx(ne,{})})]})]}),i&&e.jsx("div",{className:"h-1 w-full bg-[hsl(var(--emergency-high))]"})]})});R.displayName="Header";const yt=[{path:"/",icon:e.jsx(K,{className:"w-5 h-5"}),label:"Home"},{path:"/soporte-vital",icon:e.jsx(j,{className:"w-5 h-5"}),label:"Soporte"},{path:"/patologias",icon:e.jsx(Ne,{className:"w-5 h-5"}),label:"Patologías"},{path:"/escena",icon:e.jsx(Ee,{className:"w-5 h-5"}),label:"Escena"},{path:"/farmacos",icon:e.jsx(Y,{className:"w-5 h-5"}),label:"Fármacos"},{path:"/herramientas",icon:e.jsx(_e,{className:"w-5 h-5"}),label:"Herram."}],Nt=()=>e.jsx("nav",{className:"bottom-nav",children:e.jsx("div",{className:"flex items-stretch justify-around max-w-lg mx-auto",children:yt.map(t=>e.jsxs(ye,{to:t.path,className:({isActive:s})=>`bottom-nav-item flex-1 ${s?"active":""}`,children:[t.icon,e.jsx("span",{className:"text-xs mt-1 font-medium",children:t.label})]},t.path))})}),le=()=>e.jsx("footer",{className:"hidden md:block py-6 border-t border-border mt-auto",children:e.jsxs("div",{className:"container max-w-2xl mx-auto px-4",children:[e.jsx("div",{className:"bg-muted/50 border border-border rounded-lg p-4 mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(j,{className:"w-5 h-5 text-orange-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Contenido orientativo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Esta app no sustituye los protocolos oficiales de tu servicio. Uso bajo responsabilidad del profesional sanitario. Contenido en proceso de validación médica."}),e.jsxs("div",{className:"flex gap-3 text-xs mt-2",children:[e.jsx("a",{href:"/descargo-responsabilidad",className:"text-primary hover:underline",children:"Descargo de responsabilidad"}),e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("a",{href:"/aviso-legal",className:"text-primary hover:underline",children:"Aviso legal"}),e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("a",{href:"/privacidad",className:"text-primary hover:underline",children:"Privacidad"})]})]})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"EMERGES TES - Guía de Protocolos"}),e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("a",{href:"https://ko-fi.com/emergestes",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-primary transition-colors","aria-label":"Apoya el proyecto EMERGES TES",title:"Ayuda a mantener EMERGES TES gratuito",children:"☕ Apóyanos"})]})]})});function Et(t){const s=Ge(),a=t.toLowerCase().trim();return a.length<2?[]:s.filter(o=>{const n=o.title.toLowerCase().includes(a),i=o.shortTitle?.toLowerCase().includes(a),l=o.category.toLowerCase().includes(a),m=o.steps.some(d=>d.toLowerCase().includes(a));return n||i||l||m})}function _t(t){const s=He(),a=t.toLowerCase().trim();return a.length<2?[]:s.filter(o=>{const n=o.genericName.toLowerCase().includes(a),i=o.tradeName?.toLowerCase().includes(a),l=o.category.toLowerCase().includes(a),m=o.indications.some(d=>d.toLowerCase().includes(a));return n||i||l||m})}const St=[{acronym:"RCP",expanded:["reanimación cardiopulmonar","parada cardiorrespiratoria"]},{acronym:"PCR",expanded:["parada cardiorrespiratoria","reanimación cardiopulmonar"]},{acronym:"OVACE",expanded:["obstrucción vía aérea","cuerpo extraño","vía aérea"]},{acronym:"EAP",expanded:["enfermedad arterial periférica"]},{acronym:"SVB",expanded:["soporte vital básico"]},{acronym:"SVA",expanded:["soporte vital avanzado"]}];function kt(t){const s=t.toUpperCase().trim(),a=St.find(o=>o.acronym.toUpperCase()===s);return a?a.expanded:[]}function It(t){if(!t||t.trim().length===0)return t;const s=t.trim().split(/\s+/),a=[];for(const o of s){a.push(o);const n=kt(o);n.length>0&&a.push(...n)}return a.join(" ")}function At(t,s){const a=t.safeParse(s);return{success:a.success,data:a.success?a.data:void 0,errors:a.success?void 0:a.error}}const Ct=$e({query:z().min(2,"La búsqueda debe tener al menos 2 caracteres").max(100,"La búsqueda no puede exceder 100 caracteres").regex(/^[a-zA-Z0-9áéíóúÁÉÍÓÚñÑ\s\-]+$/,"La búsqueda contiene caracteres inválidos"),type:Fe(["all","procedure","drug"]).optional(),category:z().optional()});function Tt(t){return At(Ct,t)}function Pt(t,s="all",a="all"){const[o,n]=r.useState([]),[i,l]=r.useState(!1),[m,d]=r.useState(null),v=r.useMemo(()=>{if(t.length<2)return null;const p=Tt({query:t,type:s,category:a});return p.success?(d(null),p.data?.query||null):(d("Búsqueda inválida"),null)},[t,s,a]);return r.useEffect(()=>{if(!v){n([]),l(!1);return}l(!0),d(null);try{const p=It(v);let x=[],g=[];(s==="all"||s==="procedure")&&(x=Et(p).filter(f=>a!=="all"&&Lt(a)?a===f.category:!0).map(f=>({type:"procedure",id:f.id,title:f.shortTitle,subtitle:f.category.replace("_"," "),category:f.category,priority:f.priority,ageGroup:f.ageGroup}))),(s==="all"||s==="drug")&&(g=_t(p).filter(f=>a!=="all"&&Rt(a)?a===f.category:!0).map(f=>({type:"drug",id:f.id,title:f.genericName,subtitle:f.tradeName,category:f.category}))),n([...x,...g].slice(0,12))}catch(p){d("Error al realizar la búsqueda"),console.error("Error en búsqueda:",p),n([])}finally{l(!1)}},[v,s,a]),{results:o,isSearching:i,error:m}}function Lt(t){return["soporte_vital","patologias","escena"].includes(t)}function Rt(t){return["cardiovascular","respiratorio","neurologico","analgesia","oxigenoterapia","otros"].includes(t)}const Ot=({isOpen:t,onClose:s})=>{const[a,o]=r.useState(""),[n,i]=r.useState("all"),[l,m]=r.useState("all"),d=r.useRef(null),v=J(),{addToHistory:p}=Qe(),x=Ue(a,300),{results:g,isSearching:w,error:f}=Pt(x,n,l);r.useEffect(()=>{t&&d.current&&d.current.focus()},[t]),r.useEffect(()=>{t||(i("all"),m("all"),o(""))},[t]);const D=h=>{if(!h?.id){console.warn("[SearchModal] Intento de navegar a resultado sin ID");return}p({id:h.id,type:h.type,title:h.title,path:h.type==="procedure"?`/soporte-vital?id=${h.id}`:`/farmacos?id=${h.id}`}),h.type==="procedure"?v(`/soporte-vital?id=${h.id}`):v(`/farmacos?id=${h.id}`),s(),o("")};return t?e.jsx("div",{className:"fixed inset-0 z-[100] bg-background/95 backdrop-blur-sm",children:e.jsxs("div",{className:"flex flex-col h-full max-w-2xl mx-auto p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(E,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{ref:d,type:"text",value:a,onChange:h=>o(h.target.value),placeholder:"Buscar protocolo, fármaco, calculadora...",className:"w-full h-14 pl-12 pr-4 bg-card border border-border rounded-xl text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsx("button",{onClick:s,className:"w-14 h-14 flex items-center justify-center rounded-xl bg-card border border-border hover:bg-muted transition-colors","aria-label":"Cerrar búsqueda",children:e.jsx(A,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto scroll-touch",children:[f&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(j,{className:"w-12 h-12 text-yellow-500 mb-4"}),e.jsx("p",{className:"text-foreground font-medium",children:"Error en la búsqueda"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:f})]}),!f&&w?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin mb-4"}),e.jsx("p",{className:"text-foreground font-medium",children:"Buscando..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Por favor espera"})]}):!f&&g.length>0?e.jsx("div",{className:"space-y-2",children:g.map(h=>h?.id?e.jsxs("button",{onClick:()=>D(h),className:"w-full flex items-center gap-4 p-4 bg-card border border-border rounded-xl hover:border-primary/50 active:bg-muted/50 active:scale-[0.99] transition-all text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:h.type==="procedure"?e.jsx(X,{className:"w-5 h-5 text-primary"}):e.jsx(Y,{className:"w-5 h-5 text-secondary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-foreground truncate",children:h.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[h.subtitle&&e.jsx("p",{className:"text-sm text-muted-foreground capitalize truncate",children:h.subtitle}),h.priority&&e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${h.priority==="critico"?"bg-red-500/20 text-red-600 dark:text-red-400":h.priority==="alto"?"bg-orange-500/20 text-orange-600 dark:text-orange-400":h.priority==="medio"?"bg-yellow-500/20 text-yellow-600 dark:text-yellow-400":"bg-blue-500/20 text-blue-600 dark:text-blue-400"}`,children:h.priority}),h.ageGroup&&h.ageGroup!=="todos"&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:h.ageGroup})]})]}),e.jsx(Se,{className:"w-5 h-5 text-muted-foreground flex-shrink-0"})]},`${h.type}-${h.id}`):null)}):x.length>=2?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(E,{className:"w-12 h-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-foreground",children:"No se encontraron resultados"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Intenta con otros términos"})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(E,{className:"w-12 h-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-foreground",children:"Escribe para buscar"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Protocolos, fármacos, calculadoras..."})]})]})]})}):null},Dt=r.memo(({Icon:t,className:s})=>e.jsx(t,{className:s||"w-5 h-5"}));Dt.displayName="MenuIcon";const ce=r.memo(({isOpen:t,onClose:s})=>{if(!t)return null;const a=r.useCallback(()=>{setTimeout(async()=>{const n={title:"EMERGES TES - Guía de Protocolos",text:"Guía rápida de protocolos médicos de emergencias para Técnicos de Emergencias Sanitarias",url:window.location.origin};try{navigator.share?(await navigator.share(n),setTimeout(()=>s(),0)):(await navigator.clipboard.writeText(n.url),C.success("URL copiada al portapapeles"),setTimeout(()=>s(),0))}catch(i){if(i.name!=="AbortError"){console.error("Error al compartir:",i);try{await navigator.clipboard.writeText(n.url),C.success("URL copiada al portapapeles")}catch(l){console.error("Error al copiar:",l),C.error("No se pudo copiar al portapapeles")}}}},0)},[s]),o=r.useMemo(()=>[{icon:ke,label:"Manual Completo",path:"/manual",onClick:s},{icon:Ie,label:"Guías de Refuerzo",path:"/guia-refuerzo",onClick:s},{icon:Ae,label:"Protocolos Transtelefónicos",path:"/telefono",onClick:s},{icon:Ce,label:"Guiones de Comunicación",path:"/comunicacion",onClick:s},{icon:Te,label:"Checklists Material",path:"/material",onClick:s},{icon:Pe,label:"Favoritos",path:"/favoritos",onClick:s},{icon:Le,label:"Historial",path:"/historial",onClick:s},{icon:Re,label:"Compartir App",onClick:a},{icon:Oe,label:"Ajustes",path:"/ajustes",onClick:s},{icon:De,label:"Acerca de",path:"/acerca",onClick:s}],[s,a]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[90] bg-background/80 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:"fixed top-0 right-0 bottom-0 z-[95] w-80 max-w-[85vw] bg-card border-l border-border shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between h-14 px-4 border-b border-border",children:[e.jsx("h2",{className:"font-semibold text-foreground",children:"Menú"}),e.jsx("button",{onClick:s,className:"w-10 h-10 flex items-center justify-center rounded-lg hover:bg-muted transition-colors","aria-label":"Cerrar menú",children:e.jsx(A,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-4 space-y-2",children:o.map((n,i)=>{const l=n.icon,m=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:e.jsx(l,{className:"w-5 h-5"})}),e.jsx("span",{className:"font-medium text-foreground",children:n.label})]});return n.path?e.jsx(Z,{to:n.path,onClick:d=>{n.onClick&&requestAnimationFrame(()=>{n.onClick?.()})},className:"w-full flex items-center gap-4 p-4 rounded-xl hover:bg-muted transition-colors text-left",children:m},i):e.jsx("button",{onClick:d=>{d.preventDefault(),requestAnimationFrame(()=>{n.onClick?.()})},className:"w-full flex items-center gap-4 p-4 rounded-xl hover:bg-muted transition-colors text-left",children:m},i)})}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-4 border-t border-border",children:[e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"EMERGES TES v1.0.0"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center mt-1",children:"Guía de Protocolos para TES"})]})]})]})});ce.displayName="MenuSheet";const zt=()=>{const[t,s]=r.useState({registration:null,updateAvailable:!1,offline:!navigator.onLine});return r.useEffect(()=>{if(!("serviceWorker"in navigator))return;if(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"){const d=()=>s(p=>({...p,offline:!1})),v=()=>s(p=>({...p,offline:!0}));return window.addEventListener("online",d),window.addEventListener("offline",v),()=>{window.removeEventListener("online",d),window.removeEventListener("offline",v)}}const i=()=>s(d=>({...d,offline:!1})),l=()=>s(d=>({...d,offline:!0}));window.addEventListener("online",i),window.addEventListener("offline",l),navigator.serviceWorker.register("/sw.js").then(d=>{s(x=>({...x,registration:d}));const p=setInterval(()=>{d.update()},3600*1e3);return d.addEventListener("updatefound",()=>{const x=d.installing;x&&x.addEventListener("statechange",()=>{x.state==="installed"&&navigator.serviceWorker.controller&&s(g=>({...g,updateAvailable:!0}))})}),()=>{clearInterval(p),window.removeEventListener("online",i),window.removeEventListener("offline",l)}}).catch(d=>{console.error("SW registration failed:",d)})},[]),{...t,updateServiceWorker:async()=>{if(t.registration)try{await t.registration.update(),t.registration.waiting&&(t.registration.waiting.postMessage({type:"SKIP_WAITING"}),window.location.reload())}catch(n){console.error("Error updating service worker:",n)}},reloadPage:()=>{window.location.reload()}}},Mt=()=>{const{updateAvailable:t,updateServiceWorker:s,reloadPage:a}=zt(),[o,n]=r.useState(!1);if(r.useEffect(()=>{t&&n(!0)},[t]),!t||!o)return null;const i=()=>{s(),a()},l=()=>{n(!1)};return e.jsx("div",{className:"fixed bottom-20 left-0 right-0 z-50 px-4 md:px-0",children:e.jsx("div",{className:"container max-w-2xl mx-auto",children:e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg shadow-lg p-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ee,{className:"w-5 h-5 animate-spin"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Nueva versión disponible"}),e.jsx("p",{className:"text-sm opacity-90",children:"Hay una actualización de la aplicación. Actualiza para obtener las últimas mejoras."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{size:"sm",variant:"secondary",onClick:i,className:"bg-background text-foreground hover:bg-background/90",children:"Actualizar ahora"}),e.jsx(b,{size:"sm",variant:"ghost",onClick:l,className:"text-primary-foreground/80 hover:text-primary-foreground",children:"Más tarde"})]})]})})})},Vt=()=>{const[t,s]=r.useState(null),[a,o]=r.useState(!1),[n,i]=r.useState(!1),[l,m]=r.useState(!1);return r.useEffect(()=>{console.log("[PWA Install] Hook initialized");const p=()=>window.matchMedia("(display-mode: standalone)").matches?(console.log("[PWA Install] App is already installed (standalone mode)"),i(!0),!0):window.navigator.standalone===!0?(console.log("[PWA Install] App is already installed (iOS standalone)"),i(!0),!0):!1;if(p()){console.log("[PWA Install] App already installed, skipping install prompt");return}console.log("[PWA Install] Setting up install prompt listeners");const x=f=>{f.preventDefault(),s(f),o(!0),setTimeout(()=>{m(!0)},3e3)},g=()=>{i(!0),o(!1),s(null),m(!1)};return window.addEventListener("beforeinstallprompt",x),window.addEventListener("appinstalled",g),p()?()=>{window.removeEventListener("beforeinstallprompt",x),window.removeEventListener("appinstalled",g)}:()=>{window.removeEventListener("beforeinstallprompt",x),window.removeEventListener("appinstalled",g)}},[]),{isInstallable:a,isInstalled:n,showBanner:l,install:async()=>{if(!t)return console.log("[PWA Install] install() called but no deferredPrompt available"),!1;try{console.log("[PWA Install] Showing install prompt"),await t.prompt();const{outcome:p}=await t.userChoice;return console.log("[PWA Install] User choice:",p),p==="accepted"?(i(!0),m(!1),!0):!1}catch(p){return console.error("[PWA Install] Error installing PWA:",p),!1}finally{s(null),o(!1)}},dismissBanner:()=>{m(!1),localStorage.setItem("pwa-install-dismissed",Date.now().toString())}}},Wt=()=>{const{isInstallable:t,showBanner:s,install:a,dismissBanner:o}=Vt();if(r.useEffect(()=>{},[t,s]),!(t&&s))return null;const i=async()=>{console.log("[InstallBanner] Install button clicked");const m=await a();console.log(m?"[InstallBanner] Installation successful":"[InstallBanner] Installation cancelled or failed")},l=()=>{o()};return e.jsx("div",{className:"fixed bottom-20 left-0 right-0 z-40 px-4 md:px-0",children:e.jsx("div",{className:"container max-w-2xl mx-auto",children:e.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/90 text-primary-foreground rounded-lg shadow-lg p-4 flex items-center justify-between gap-4 animate-in slide-in-from-bottom-5",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary-foreground/20 flex items-center justify-center flex-shrink-0",children:e.jsx(ze,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm",children:"Instalar EMERGES TES"}),e.jsx("p",{className:"text-xs opacity-90 truncate",children:"Instala la app para acceso rápido y uso offline"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(b,{size:"sm",variant:"secondary",onClick:i,className:"bg-primary-foreground text-primary hover:bg-primary-foreground/90 whitespace-nowrap",children:"Instalar"}),e.jsx("button",{onClick:l,className:"w-8 h-8 flex items-center justify-center rounded-lg text-primary-foreground/80 hover:text-primary-foreground hover:bg-primary-foreground/20 transition-colors","aria-label":"Cerrar",children:e.jsx(A,{className:"w-4 h-4"})})]})]})})})},V="emerges-tes-disclaimer-accepted",Bt=()=>{const[t,s]=r.useState(!1);r.useEffect(()=>{localStorage.getItem(V)||setTimeout(()=>{s(!0)},500)},[]);const a=()=>{localStorage.setItem(V,"true"),s(!1)};return t?e.jsx("div",{className:"fixed inset-0 z-[200] bg-background/95 backdrop-blur-sm flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-2xl w-full bg-card border border-border rounded-xl shadow-2xl overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-orange-500 to-red-500 p-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j,{className:"w-8 h-8 text-white"}),e.jsx("h2",{className:"text-2xl font-bold text-white",children:"Aviso Legal Importante"})]})}),e.jsx("div",{className:"p-6 space-y-4 max-h-[60vh] overflow-y-auto",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-foreground font-medium",children:"Esta aplicación contiene información orientativa sobre protocolos de emergencias sanitarias."}),e.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-2",children:[e.jsxs("p",{className:"font-semibold text-foreground flex items-center gap-2",children:[e.jsx(j,{className:"w-5 h-5 text-orange-500"}),"Esta aplicación NO SUSTITUYE:"]}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground ml-7",children:[e.jsx("li",{children:"Los protocolos oficiales de tu servicio de emergencias"}),e.jsx("li",{children:"La formación continuada obligatoria"}),e.jsx("li",{children:"El criterio clínico del profesional sanitario"}),e.jsx("li",{children:"La supervisión médica cuando sea necesaria"})]})]}),e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 p-4 rounded-lg border border-yellow-200 dark:border-yellow-800",children:[e.jsxs("p",{className:"font-semibold text-yellow-800 dark:text-yellow-200 flex items-center gap-2",children:[e.jsx(X,{className:"w-5 h-5"}),"Contenido en proceso de validación"]}),e.jsx("p",{className:"text-yellow-700 dark:text-yellow-300 text-sm mt-2",children:"El contenido médico de esta aplicación está siendo revisado por profesionales sanitarios. Algunos protocolos pueden no estar completamente validados."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"Responsabilidad del usuario:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground ml-2",children:[e.jsx("li",{children:"El uso de esta aplicación es bajo tu responsabilidad profesional"}),e.jsx("li",{children:"Debes seguir siempre los protocolos de tu servicio"}),e.jsx("li",{children:"En caso de duda, consulta con el médico coordinador"}),e.jsx("li",{children:"La información está actualizada según las guías ERC/AHA vigentes"})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-4 rounded-lg border border-blue-200 dark:border-blue-800",children:e.jsxs("p",{className:"text-blue-800 dark:text-blue-200 text-sm",children:[e.jsx("span",{className:"font-semibold",children:"Objetivo de la app:"})," Proporcionar una referencia rápida de consulta para profesionales TES durante emergencias. Es una herramienta de apoyo, no un protocolo oficial vinculante."]})})]})}),e.jsxs("div",{className:"bg-muted p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(j,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("p",{children:'Al hacer clic en "Aceptar y continuar", confirmas que has leído y comprendido este aviso legal y que eres un profesional sanitario.'})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-3",children:e.jsx(b,{onClick:a,className:"flex-1 bg-gradient-to-r from-orange-500 to-red-500 hover:from-orange-600 hover:to-red-600",size:"lg",children:"Aceptar y continuar"})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:["Para más información, consulta nuestra ",e.jsx("a",{href:"/descargo-responsabilidad",className:"underline hover:text-foreground",children:"política de descargo de responsabilidad"})]})]})]})}):null};class Gt extends r.Component{constructor(s){super(s),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s,errorInfo:null}}componentDidCatch(s,a){console.error("[ErrorBoundary] Caught an error:",{error:s.toString(),stack:s.stack,componentStack:a.componentStack}),this.setState({error:s,errorInfo:a})}handleReset=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-md w-full space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(j,{className:"w-16 h-16 text-destructive mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Algo salió mal"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"La aplicación encontró un error inesperado. Por favor, intenta recargar la página."})]}),!1,e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(b,{onClick:this.handleReset,className:"w-full",children:[e.jsx(ee,{className:"w-4 h-4 mr-2"}),"Intentar de nuevo"]}),e.jsxs(b,{variant:"outline",className:"w-full",onClick:()=>{window.location.href="/"},children:[e.jsx(K,{className:"w-4 h-4 mr-2"}),"Ir al inicio"]})]})]})}):this.props.children}}const Ht=[t=>{const s=t.vitals.gcs;return typeof s!="number"?null:s<=8?{id:"airway_critical",priority:"CRITICAL",message:"Glasgow ≤ 8. Considerar vía aérea avanzada.",actions:[{label:"Guía vía aérea (próximamente)"}]}:null},t=>{const s=Ke(t.vitals);return typeof s.value!="number"?null:s.value>=2?{id:"sepsis_alert",priority:"HIGH",message:"qSOFA ≥ 2. Sospecha de sepsis.",actions:[{label:"Checklist Sepsis",route:"/checklists/sepsis"}]}:null},t=>{const s=Ye(t.vitals.systolicBP,t.vitals.diastolicBP),a=Xe(t.vitals.heartRate,t.vitals.systolicBP);return typeof s.value!="number"||typeof a.value!="number"?null:a.value>1&&s.value<65?{id:"shock_alert",priority:"CRITICAL",message:"Shock Index > 1 y MAP < 65. Shock probable.",actions:[{label:"Perfusiones",route:"/herramientas"}]}:null}],W={CRITICAL:3,HIGH:2,MEDIUM:1},Ut=t=>Ht.map(a=>a(t)).filter(a=>!!a).sort((a,o)=>W[o.priority]-W[a.priority]),qt={CRITICAL:"border-red-500/50 bg-red-500/10 text-red-100",HIGH:"border-amber-500/50 bg-amber-500/10 text-amber-100",MEDIUM:"border-blue-500/40 bg-blue-500/10 text-blue-100"},$t=()=>{const{patient:t,vitals:s}=Ze(),[a,o]=r.useState({}),n=r.useMemo(()=>!t&&!s?[]:Ut({patient:t,vitals:s}).filter(l=>!a[l.id]).slice(0,3),[t,s,a]);return n.length===0?null:e.jsx("div",{className:"space-y-3",children:n.map(i=>e.jsxs(tt,{className:`border ${qt[i.priority]}`,children:[e.jsxs(st,{className:"flex flex-row items-start justify-between space-y-0",children:[e.jsx(at,{className:"text-base",children:i.message}),e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>o(l=>({...l,[i.id]:!0})),children:"Ocultar"})]}),e.jsx(rt,{className:"flex flex-wrap gap-2",children:i.actions.map((l,m)=>l.route?e.jsx(b,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(Z,{to:l.route,children:l.label})},m):e.jsx(b,{variant:"outline",size:"sm",disabled:!0,children:l.label},m))})]},i.id))})},Ft=({onClick:t,isActive:s})=>e.jsxs("button",{type:"button",onClick:t,"aria-label":"Activar modo emergencia",className:`fixed right-4 bottom-24 md:bottom-6 z-[999] flex items-center gap-2 rounded-full px-4 py-3 shadow-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white ${s?"bg-red-700 text-white":"bg-red-600 text-white hover:bg-red-700 active:scale-[0.98]"}`,children:[e.jsx(j,{className:"h-5 w-5"}),e.jsx("span",{className:"text-base font-semibold",children:"Emergencia"})]}),Qt=({onSelect:t})=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:"¿Qué está pasando ahora mismo?"}),e.jsx("p",{className:"text-sm text-white/80",children:"Selecciona la opción que mejor encaje."})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx("button",{type:"button",onClick:()=>t("medica"),className:"w-full rounded-xl border-2 border-white/20 bg-white/10 px-4 py-5 text-lg font-semibold text-white hover:bg-white/20",children:"Emergencia médica"}),e.jsx("button",{type:"button",onClick:()=>t("accidente"),className:"w-full rounded-xl border-2 border-white/20 bg-white/10 px-4 py-5 text-lg font-semibold text-white hover:bg-white/20",children:"Accidente"}),e.jsx("button",{type:"button",onClick:()=>t("tecnico"),className:"w-full rounded-xl border-2 border-white/20 bg-white/10 px-4 py-5 text-lg font-semibold text-white hover:bg-white/20",children:"Incidente técnico"}),e.jsx("button",{type:"button",onClick:()=>t("otro"),className:"w-full rounded-xl border-2 border-white/20 bg-white/10 px-4 py-5 text-lg font-semibold text-white hover:bg-white/20",children:"Otro"})]})]}),de="emergency_events_v1",ue="emergency_pending_notifications_v1",O=()=>{if(typeof window>"u")return[];try{const t=window.localStorage.getItem(de);return t?JSON.parse(t):[]}catch{return[]}},me=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(de,JSON.stringify(t))}catch{}},Jt=()=>{if(typeof window>"u")return null;const t=["user","currentUser","auth_user","username"];for(const s of t){const a=window.localStorage.getItem(s);if(a)try{const o=JSON.parse(a);if(typeof o=="string")return o;if(o&&typeof o.name=="string")return o.name;if(o&&typeof o.username=="string")return o.username}catch{if(a)return a}}return null},Kt=()=>{const t=new Date().toISOString(),s={id:`emergency_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,createdAt:t,updatedAt:t,status:navigator.onLine?"active":"pending_sync",user:Jt(),connectivity:navigator.onLine?"online":"offline"},a=O();return a.unshift(s),me(a),s},I=(t,s)=>{const o=O().map(n=>n.id===t?{...n,...s,updatedAt:new Date().toISOString()}:n);me(o)},Yt=t=>O().find(s=>s.id===t),Xt=()=>typeof window>"u"||!navigator.geolocation?Promise.resolve(null):new Promise(t=>{navigator.geolocation.getCurrentPosition(s=>{t({lat:s.coords.latitude,lng:s.coords.longitude,accuracy:s.coords.accuracy})},()=>t(null),{enableHighAccuracy:!0,timeout:4e3})}),Zt=()=>{if(typeof window>"u")return[];try{const t=window.localStorage.getItem(ue);return t?JSON.parse(t):[]}catch{return[]}},es=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(ue,JSON.stringify(t))}catch{}},B=t=>{const s=Zt();s.includes(t)||(s.push(t),es(s))},ts=async t=>{const s=Yt(t);if(!s||typeof window>"u")return"queued";const a=window.localStorage.getItem("emergency_notify_url");if(!navigator.onLine||!a)return B(t),"queued";try{if(!(await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).ok)throw new Error("notification_failed");return"sent"}catch{return B(t),"queued"}},ss={medica:"Emergencia médica",accidente:"Accidente",tecnico:"Incidente técnico",otro:"Otro"},as={medica:["Respira hondo y habla en voz calmada.","Asegura la zona si es posible.","Comprueba conciencia y respiración.","Sigue las instrucciones en pantalla."],accidente:["Respira hondo y mantén la calma.","Asegura la zona y evita nuevos riesgos.","Cuenta rápidamente cuántas personas necesitan ayuda.","Sigue las instrucciones en pantalla."],tecnico:["Respira hondo y reduce la velocidad.","Detén el uso del equipo si es seguro hacerlo.","Aísla la zona para evitar más daños.","Sigue las instrucciones en pantalla."],otro:["Respira hondo y observa el entorno.","Asegura la zona si es posible.","Identifica la prioridad más urgente.","Sigue las instrucciones en pantalla."]},rs=({eventId:t,situation:s,onClose:a,onRestart:o,isOnline:n})=>{const[i,l]=r.useState("idle");r.useEffect(()=>{I(t,{status:"instructions"})},[t]),r.useEffect(()=>{let d=!0;return(async()=>{const p=await ts(t);d&&l(p)})(),()=>{d=!1}},[t]);const m=r.useMemo(()=>as[s],[s]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"text-sm uppercase tracking-wide text-white/70",children:"No estás solo. Sigue estos pasos."}),e.jsx("h2",{className:"text-2xl font-bold text-white",children:ss[s]}),e.jsx("p",{className:"text-sm text-white/80",children:"Una acción clara por paso. Vamos contigo."})]}),e.jsx("div",{className:"rounded-xl border border-white/20 bg-white/10 p-5 space-y-4",children:m.map(d=>e.jsxs("div",{className:"flex items-start gap-3 text-white text-lg",children:[e.jsx("span",{className:"mt-1 h-3 w-3 rounded-full bg-white"}),e.jsx("span",{children:d})]},d))}),e.jsxs("div",{className:"rounded-xl border border-white/20 bg-white/5 p-4 text-white/80 text-sm",children:[i==="sent"&&"Coordinación notificada.",i==="queued"&&"Aviso guardado para sincronizar.",i==="idle"&&"Preparando aviso a coordinación..."]}),n?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("a",{href:"tel:112",className:"w-full rounded-xl bg-white px-4 py-4 text-center text-lg font-semibold text-red-700",children:"Llamar al 112"}),e.jsx("a",{href:"sms:112",className:"w-full rounded-xl border-2 border-white/40 px-4 py-4 text-center text-lg font-semibold text-white",children:"Enviar mensaje rápido"})]}):e.jsx("div",{className:"rounded-xl border border-white/30 bg-white/10 p-4 text-white text-sm",children:"Sin conexión. Seguimos en modo offline y guardamos el evento para sincronizar después."}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("button",{type:"button",onClick:o,className:"w-full rounded-xl border-2 border-white/40 px-4 py-3 text-base font-semibold text-white",children:"Cambiar situación"}),e.jsx("button",{type:"button",onClick:()=>{I(t,{status:"completed"}),a()},className:"w-full rounded-xl bg-white/20 px-4 py-3 text-base font-semibold text-white",children:"Cerrar modo emergencia"})]})]})},os=({isOpen:t,onClose:s})=>{const[a,o]=r.useState("select"),[n,i]=r.useState(null),[l,m]=r.useState(null),[d,v]=r.useState(typeof navigator<"u"?navigator.onLine:!0);r.useEffect(()=>{if(!t)return;let x=!1;const g=Kt();return i(g.id),o("select"),m(null),Xt().then(w=>{x||w&&I(g.id,{location:w})}),()=>{x=!0}},[t]),r.useEffect(()=>{if(!t)return;const x=()=>v(!0),g=()=>v(!1);return window.addEventListener("online",x),window.addEventListener("offline",g),()=>{window.removeEventListener("online",x),window.removeEventListener("offline",g)}},[t]),r.useEffect(()=>{if(!t)return;const x=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=x}},[t]);const p=r.useMemo(()=>a==="select"?"Estás en una situación crítica. Estamos contigo.":"No estás solo. Sigue estos pasos.",[a]);return t?e.jsx("div",{className:"fixed inset-0 z-[1000] bg-black/95 text-white",children:e.jsxs("div",{className:"mx-auto flex min-h-screen w-full max-w-2xl flex-col justify-between px-6 py-8",children:[e.jsxs("div",{className:"space-y-3 text-center",children:[e.jsx("p",{className:"text-sm uppercase tracking-wide text-white/70",children:"Modo Emergencia"}),e.jsx("h1",{className:"text-3xl font-extrabold text-white",children:p})]}),e.jsxs("div",{className:"flex-1 py-8",children:[a==="select"&&e.jsx(Qt,{onSelect:x=>{n&&I(n,{situation:x,status:"situation_selected"}),m(x),o("instructions")}}),a==="instructions"&&n&&l&&e.jsx(rs,{eventId:n,situation:l,isOnline:d,onRestart:()=>{o("select"),m(null)},onClose:s})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full rounded-xl border border-white/30 px-4 py-3 text-base font-semibold text-white/80",children:"Salir del modo emergencia"})]})}):null},ns=()=>{const[t,s]=r.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(Ft,{onClick:()=>s(!0),isActive:t}),e.jsx(os,{isOpen:t,onClose:()=>s(!1)})]})},is=()=>e.jsx(ot,{variant:"info",className:"bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/30",children:"Modo Formación"}),L=({children:t,onSearchClick:s,onMenuClick:a})=>e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx(R,{onSearchClick:s,onMenuClick:a}),e.jsx("main",{className:"pt-14 pb-8 flex-1",children:e.jsxs("div",{className:"container max-w-2xl md:max-w-3xl lg:max-w-7xl mx-auto py-6",children:[e.jsx("div",{className:"mb-4",children:e.jsx(is,{})}),t]})}),e.jsx(le,{})]}),ls=r.lazy(()=>u(()=>import("./page-soportevital-DQtvdBj2.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),cs=r.lazy(()=>u(()=>import("./page-patologias-CAkXUO11.js"),__vite__mapDeps([8,1,2,3,4]))),ds=r.lazy(()=>u(()=>import("./page-escena-ZCRqUJc7.js"),__vite__mapDeps([9,1,2,3,4,5,6]))),us=r.lazy(()=>u(()=>import("./page-farmacos-BsW3CLyQ.js").then(t=>t.F),__vite__mapDeps([7,1,2,3,4,5,6]))),ms=r.lazy(()=>u(()=>import("./page-herramientas-DcKR8MlC.js").then(t=>t.H),__vite__mapDeps([10,1,2,3,4,5,6]))),ps=r.lazy(()=>u(()=>import("./page-material-Ck8ErBi1.js"),__vite__mapDeps([11,1,2,3,4,6,5]))),xs=r.lazy(()=>u(()=>import("./page-telefono-tnu9q39s.js"),__vite__mapDeps([12,1,2,3,4,6,5]))),hs=r.lazy(()=>u(()=>import("./page-comunicacion-DmHQUHoW.js").then(t=>t.f),__vite__mapDeps([5,1,2,3,4,6]))),fs=r.lazy(()=>u(()=>import("./page-manualindex-iXG0WSpO.js"),__vite__mapDeps([13,1,2,3,4,14,6,15,16]))),gs=r.lazy(()=>u(()=>import("./page-manual-viewer-scmsIV_3.js").then(t=>t.M),__vite__mapDeps([15,1,2,3,4,16,14,6]))),vs=r.lazy(()=>u(()=>import("./page-rcp-CZ8w6Oz0.js").then(t=>t.R),__vite__mapDeps([17,1,2,3,4,14,6,7,5]))),bs=r.lazy(()=>u(()=>import("./page-ictus-Oam15e1v.js"),__vite__mapDeps([18,1,2,3,4,14,6,7,5]))),js=r.lazy(()=>u(()=>import("./page-shock-DhKboriQ.js"),__vite__mapDeps([19,1,2,3,4,14,6,17,7,5]))),ws=r.lazy(()=>u(()=>import("./page-viaaerea-CKEU5wcY.js"),__vite__mapDeps([20,1,2,3,4,14,6,17,7,5]))),ys=r.lazy(()=>u(()=>import("./page-favoritos-DDtM_cze.js"),__vite__mapDeps([21,1,2,3,4,6]))),Ns=r.lazy(()=>u(()=>import("./page-historial-DRNAlGuI.js"),__vite__mapDeps([22,1,2,3,4,6]))),Es=r.lazy(()=>u(()=>import("./page-ajustes-DgawOEJM.js").then(t=>t.A),__vite__mapDeps([6,1,2,3,4]))),_s=r.lazy(()=>u(()=>import("./page-acerca-_Mt0Ax57.js"),__vite__mapDeps([23,1,2,3,4]))),Ss=r.lazy(()=>u(()=>import("./page-galeriaimagenes-Dnb019dP.js").then(t=>t.G),__vite__mapDeps([14,1,2,3,4,6]))),ks=r.lazy(()=>u(()=>import("./page-privacidad-I8o09WuK.js"),__vite__mapDeps([24,1,2,3,4]))),Is=r.lazy(()=>u(()=>import("./page-descargoresponsabilidad-DSgOxrdC.js"),__vite__mapDeps([25,1,2,3,4]))),As=r.lazy(()=>u(()=>import("./page-avisolegal-W9N3WFzz.js"),__vite__mapDeps([26,1,2,3,4]))),Cs=r.lazy(()=>u(()=>import("./page-parto-DUwiEgy8.js"),__vite__mapDeps([27,1,2,3,4]))),Ts=r.lazy(()=>u(()=>import("./GuideIndex-CyqK2c3S.js"),__vite__mapDeps([28,1,2,3,4,7,5,6,17,14,10,29,30]))),Ps=r.lazy(()=>u(()=>import("./GuideViewer-CCIQxKzP.js"),__vite__mapDeps([31,1,2,3,4,7,5,6,32,17,14,16,10,29,30]))),Ls=r.lazy(()=>u(()=>import("./page-testingpage-D_q9Y_VH.js"),__vite__mapDeps([33,1,2,3,4,5,6,7,17,14]))),Rs=r.lazy(()=>u(()=>import("./GuideSectionViewer-DGLFWYd-.js"),__vite__mapDeps([34,1,2,3,4,7,5,6,32,17,14,16,10,29,30]))),Os=r.lazy(()=>u(()=>import("./VitalsDashboard-ByReykvi.js"),__vite__mapDeps([35,1,2,3,4,10,5,6]))),Ds=r.lazy(()=>u(()=>import("./SepsisChecklist-D8Co53T_.js"),__vite__mapDeps([36,1,2,3,4,10,5,6,37]))),zs=r.lazy(()=>u(()=>import("./IctusChecklist-BrhTLt4s.js"),__vite__mapDeps([38,1,2,3,4,6,5,37]))),Ms=r.lazy(()=>u(()=>import("./ParadaChecklist-Bul0fsVj.js"),__vite__mapDeps([39,1,2,3,4,6,5,37]))),Vs=r.lazy(()=>u(()=>import("./PartoChecklist-DcLWkRPK.js"),__vite__mapDeps([40,1,2,3,4,6,5,37]))),Ws=r.lazy(()=>u(()=>import("./AnafilaxiaChecklist-GssBTsnG.js"),__vite__mapDeps([41,1,2,3,4,10,5,6,37]))),Bs=r.lazy(()=>u(()=>import("./IntoxicacionesChecklist-mYkQyLGE.js"),__vite__mapDeps([42,1,2,3,4,10,5,6,37]))),Gs=r.lazy(()=>u(()=>import("./ConvulsionesChecklist-sTdTUAEq.js"),__vite__mapDeps([43,1,2,3,4,10,5,6,37]))),Hs=r.lazy(()=>u(()=>import("./TermicasChecklist-CNVEh2gL.js"),__vite__mapDeps([44,1,2,3,4,6,5,37]))),Us=r.lazy(()=>u(()=>import("./ShockSepticPathway-OevyubcK.js"),__vite__mapDeps([45,1,2,3,4,10,5,6,37]))),qs=r.lazy(()=>u(()=>import("./BroselowQuick-Cnc3TNmR.js"),__vite__mapDeps([46,1,2,3,4,5,6,10]))),$s=r.lazy(()=>u(()=>import("./page-urgencias-ANdUuGm2.js"),__vite__mapDeps([47,1,2,3,4,6,29]))),Fs=()=>{const[t,s]=r.useState(!1),[a,o]=r.useState(!1);return r.useEffect(()=>{u(async()=>{const{initPreloadOptimizations:n}=await import("./preload-CBmKlyiG.js");return{initPreloadOptimizations:n}},[]).then(({initPreloadOptimizations:n})=>{n()})},[]),lt(!0),e.jsx(Me,{attribute:"class",defaultTheme:"dark",enableSystem:!0,children:e.jsxs(jt,{children:[e.jsx(vt,{}),e.jsx(bt,{}),e.jsx(Ve,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:e.jsx(Gt,{children:e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx(R,{onSearchClick:()=>s(!0),onMenuClick:()=>o(!0)}),e.jsx("main",{className:"pt-14 pb-safe flex-1",children:e.jsxs("div",{className:"container max-w-2xl md:max-w-3xl lg:max-w-7xl py-4",children:[e.jsx("div",{className:"mb-4",children:e.jsx($t,{})}),e.jsx(r.Suspense,{fallback:e.jsx(Je,{}),children:e.jsxs(We,{children:[e.jsx(c,{path:"/",element:e.jsx(nt,{onSearchClick:()=>s(!0)})}),e.jsx(c,{path:"/soporte-vital",element:e.jsx(ls,{})}),e.jsx(c,{path:"/patologias",element:e.jsx(cs,{})}),e.jsx(c,{path:"/escena",element:e.jsx(ds,{})}),e.jsx(c,{path:"/farmacos",element:e.jsx(us,{})}),e.jsx(c,{path:"/herramientas",element:e.jsx(ms,{})}),e.jsx(c,{path:"/material",element:e.jsx(ps,{})}),e.jsx(c,{path:"/telefono",element:e.jsx(xs,{})}),e.jsx(c,{path:"/comunicacion",element:e.jsx(hs,{})}),e.jsx(c,{path:"/manual",element:e.jsx(fs,{})}),e.jsx(c,{path:"/manual/:parte/:bloque/:capitulo",element:e.jsx(gs,{})}),e.jsx(c,{path:"/rcp",element:e.jsx(vs,{})}),e.jsx(c,{path:"/ictus",element:e.jsx(bs,{})}),e.jsx(c,{path:"/shock",element:e.jsx(js,{})}),e.jsx(c,{path:"/via-aerea",element:e.jsx(ws,{})}),e.jsx(c,{path:"/urgencias",element:e.jsx($s,{})}),e.jsx(c,{path:"/favoritos",element:e.jsx(ys,{})}),e.jsx(c,{path:"/historial",element:e.jsx(Ns,{})}),e.jsx(c,{path:"/ajustes",element:e.jsx(Es,{})}),e.jsx(c,{path:"/acerca",element:e.jsx(_s,{})}),e.jsx(c,{path:"/galeria",element:e.jsx(Ss,{})}),e.jsx(c,{path:"/privacidad",element:e.jsx(ks,{})}),e.jsx(c,{path:"/descargo-responsabilidad",element:e.jsx(Is,{})}),e.jsx(c,{path:"/aviso-legal",element:e.jsx(As,{})}),e.jsx(c,{path:"/parto",element:e.jsx(Cs,{})}),e.jsx(c,{path:"/testing",element:e.jsx(Ls,{})}),e.jsx(c,{path:"/advanced/vitals",element:e.jsx(Os,{})}),e.jsx(c,{path:"/checklists/sepsis",element:e.jsx(Ds,{})}),e.jsx(c,{path:"/checklists/ictus",element:e.jsx(zs,{})}),e.jsx(c,{path:"/checklists/parada",element:e.jsx(Ms,{})}),e.jsx(c,{path:"/checklists/parto",element:e.jsx(Vs,{})}),e.jsx(c,{path:"/checklists/anafilaxia",element:e.jsx(Ws,{})}),e.jsx(c,{path:"/checklists/intoxicaciones",element:e.jsx(Bs,{})}),e.jsx(c,{path:"/checklists/convulsiones",element:e.jsx(Gs,{})}),e.jsx(c,{path:"/checklists/termicas",element:e.jsx(Hs,{})}),e.jsx(c,{path:"/pathways/shock-septico",element:e.jsx(Us,{})}),e.jsx(c,{path:"/advanced/broselow",element:e.jsx(qs,{})}),e.jsx(c,{path:"/guia-refuerzo",element:e.jsx(L,{onSearchClick:()=>s(!0),onMenuClick:()=>o(!0),children:e.jsx(Ts,{})})}),e.jsx(c,{path:"/guia-refuerzo/:guia",element:e.jsx(L,{onSearchClick:()=>s(!0),onMenuClick:()=>o(!0),children:e.jsx(Ps,{})})}),e.jsx(c,{path:"/guia-refuerzo/:guia/seccion/:numero",element:e.jsx(L,{onSearchClick:()=>s(!0),onMenuClick:()=>o(!0),children:e.jsx(Rs,{})})}),e.jsx(c,{path:"*",element:e.jsx(it,{})})]})})]})}),e.jsx(Nt,{}),e.jsx(le,{}),e.jsx(Mt,{}),e.jsx(Wt,{}),e.jsx(Ot,{isOpen:t,onClose:()=>s(!1)}),e.jsx(ce,{isOpen:a,onClose:()=>o(!1)}),e.jsx(Bt,{}),e.jsx(ns,{})]})})})]})})};if(typeof window<"u"){const t=console.error;console.error=(...s)=>{const a=s[0]?.toString()||"";a.includes("message channel closed")||a.includes("runtime.lastError")||a.includes("Extension context invalidated")||t.apply(console,s)},window.addEventListener("error",s=>{console.error("[Global Error Handler]",{message:s.message,filename:s.filename,lineno:s.lineno,colno:s.colno,error:s.error})}),window.addEventListener("unhandledrejection",s=>{console.error("[Unhandled Promise Rejection]",{reason:s.reason,promise:s.promise})})}"serviceWorker"in navigator&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname==="[::1]")&&(async()=>{try{const s=await navigator.serviceWorker.getRegistrations();if(s.length>0){if(console.log("[SW] 🧹 Development mode: unregistering",s.length,"service worker(s)..."),await Promise.all(s.map(a=>a.unregister())),"caches"in window){const a=await caches.keys();await Promise.all(a.map(o=>caches.delete(o))),console.log("[SW] ✅ Caches cleared")}if(console.log("[SW] ✅ Service workers unregistered"),navigator.serviceWorker.controller){console.log("[SW] 🔄 Reloading to apply changes..."),window.location.reload();return}}}catch(s){console.error("[SW] ❌ Error cleaning up:",s)}})();"serviceWorker"in navigator&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname==="[::1]"||window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{updateViaCache:"none"}).then(a=>{console.log("[SW] Registered:",a.scope);const o=()=>{a.update().catch(n=>{console.log("[SW] Update check failed:",n)})};setInterval(o,3600*1e3),document.addEventListener("visibilitychange",()=>{document.hidden||o()}),a.addEventListener("updatefound",()=>{const n=a.installing;n&&n.addEventListener("statechange",()=>{n.state==="installed"&&navigator.serviceWorker.controller&&console.log("[SW] New version available")})})}).catch(a=>{console.error("[SW] Registration failed:",a)})}));const k=document.getElementById("root");if(!k)throw new Error("Root element not found");try{Be.createRoot(k).render(e.jsx(et,{children:e.jsx(Fs,{})}))}catch(t){console.error("[React] Error rendering app:",t);const s=t instanceof Error?t.message:String(t),a=document.createElement("div");a.style.cssText="padding: 2rem; text-align: center; font-family: sans-serif;";const o=document.createElement("h1");o.textContent="Error al cargar la aplicación",a.appendChild(o);const n=document.createElement("p");n.textContent="Por favor, recarga la página. Si el problema persiste, limpia la caché del navegador.",a.appendChild(n);const i=document.createElement("p");throw i.style.cssText="color: #666; font-size: 0.9rem;",i.textContent=`Error: ${s}`,a.appendChild(i),k.innerHTML="",k.appendChild(a),t}export{is as G};