import{o as $,p as b,q as E,t as L,r as c,_ as M,n as e,O as k,M as I,L as P,S as T}from"./components-DjjSZ9bp.js";/**
 * @remix-run/react v2.17.2
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */let j="positions";function A({getKey:a,...t}){let{isSpaMode:o}=$(),h=b(),m=E();L({getKey:a,storageKey:j});let n=c.useMemo(()=>{if(!a)return null;let r=a(h,m);return r!==h.key?r:null},[]);if(o)return null;let u=((r,l)=>{if(!window.history.state||!window.history.state.key){let i=Math.random().toString(32).slice(2);window.history.replaceState({key:i},"")}try{let p=JSON.parse(sessionStorage.getItem(r)||"{}")[l||window.history.state.key];typeof p=="number"&&window.scrollTo(0,p)}catch(i){console.error(i),sessionStorage.removeItem(r)}}).toString();return c.createElement("script",M({},t,{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${u})(${JSON.stringify(j)}, ${JSON.stringify(n)})`}}))}const O="/assets/styles-D7Zjtr3a.css";function F({apiBase:a="/api"}){const[t,o]=c.useState(null),[h,m]=c.useState(!0),[n,u]=c.useState(null),r=c.useCallback(async()=>{try{const s=await fetch(`${a}/system/ups/status`);if(!s.ok)throw new Error(`HTTP ${s.status}`);const d=await s.json();o(d),u(null)}catch(s){u(s instanceof Error?s.message:"Failed to fetch")}finally{m(!1)}},[a]);if(c.useEffect(()=>{r();let s=null;const d=()=>{s=new EventSource("/sse/events"),s.addEventListener("ups_battery",C=>{try{const w=JSON.parse(C.data);o(y=>y&&{...y,battery_percentage:w.percentage,voltage:w.voltage})}catch(w){console.error("Failed to parse ups_battery event:",w)}}),s.addEventListener("ups_warning",()=>{r()}),s.addEventListener("ups_critical",()=>{r()}),s.onerror=()=>{s==null||s.close(),setTimeout(d,5e3)}};d();const f=setInterval(r,6e4);return()=>{s==null||s.close(),clearInterval(f)}},[a,r]),!h&&(!t||!t.is_available))return null;if(h)return e.jsx("div",{className:"power-widget power-widget--loading",title:"Loading power status...",children:e.jsx("div",{className:"power-widget__icon",children:e.jsx(v,{percentage:50})})});const l=Math.round((t==null?void 0:t.battery_percentage)??0),i=(t==null?void 0:t.power_source)==="ac"||(t==null?void 0:t.battery_status)==="charging",p=l<=10,S=l<=20,_=l>=95&&i;let g="power-widget--normal";p?g="power-widget--critical":S?g="power-widget--low":_?g="power-widget--full":i&&(g="power-widget--charging");const x=[`Battery: ${l}%`,`Source: ${(t==null?void 0:t.power_source)==="ac"?"AC Power":"Battery"}`];if(t!=null&&t.voltage&&t.voltage>0&&x.push(`Voltage: ${(t.voltage/1e3).toFixed(2)}V`),(t==null?void 0:t.current)!==void 0&&(t==null?void 0:t.current)!==null){const s=Math.abs(t.current*1e3).toFixed(0),d=t.current>=0?"charging":"draw";x.push(`Current: ${s}mA ${d}`)}if(t!=null&&t.time_remaining){const s=t.time_remaining;if(s<60)x.push(`Est. runtime: ${s} min`);else{const d=Math.floor(s/60),f=s%60;x.push(`Est. runtime: ${d}h ${f}m`)}}const N=x.join(`
`);return e.jsxs("div",{className:`power-widget ${g}`,title:N,role:"status","aria-label":`Battery at ${l}%${i?", plugged in":", on battery"}`,children:[e.jsx("div",{className:"power-widget__icon",children:e.jsx(v,{percentage:l,isCharging:i})}),e.jsxs("span",{className:"power-widget__percentage",children:[l,"%"]}),i&&e.jsx("span",{className:"power-widget__plug-indicator","aria-label":"Plugged in",title:"AC Power",children:e.jsx(W,{})})]})}function v({percentage:a,isCharging:t=!1}){const o=Math.max(0,Math.min(100,a));return e.jsxs("svg",{className:"battery-icon",viewBox:"0 0 24 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[e.jsx("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",strokeWidth:"1",fill:"none"}),e.jsx("rect",{x:"21",y:"4",width:"3",height:"6",rx:"1",fill:"currentColor"}),e.jsx("rect",{className:"battery-icon__fill",x:"2",y:"2",width:Math.max(0,o/100*17),height:"10",rx:"1",fill:"currentColor"}),t&&e.jsx("path",{className:"battery-icon__bolt",d:"M12 1L8 7H11L9 13L14 6H11L12 1Z",fill:"var(--color-bg)",stroke:"currentColor",strokeWidth:"0.5"})]})}function W(){return e.jsxs("svg",{className:"plug-icon",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"0",width:"2",height:"4",rx:"0.5",fill:"currentColor"}),e.jsx("rect",{x:"7",y:"0",width:"2",height:"4",rx:"0.5",fill:"currentColor"}),e.jsx("rect",{x:"2",y:"3",width:"8",height:"5",rx:"1",fill:"currentColor"}),e.jsx("rect",{x:"5",y:"8",width:"2",height:"4",rx:"0.5",fill:"currentColor"})]})}const B=()=>[{rel:"stylesheet",href:O}];function D({children:a}){return e.jsxs("html",{lang:"en",children:[e.jsxs("head",{children:[e.jsx("meta",{charSet:"utf-8"}),e.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=5"}),e.jsx("meta",{name:"theme-color",content:"#0a0e1a"}),e.jsx("meta",{name:"description",content:"Dangerous Pi - Proxmark3 Management Interface"}),e.jsx(I,{}),e.jsx(P,{})]}),e.jsxs("body",{children:[a,e.jsx(A,{}),e.jsx(T,{})]})]})}function J(){const a=b(),[t,o]=c.useState("dark");c.useEffect(()=>{const n=localStorage.getItem("theme");n?(o(n),document.documentElement.setAttribute("data-theme",n)):(o("dark"),document.documentElement.setAttribute("data-theme","dark"))},[]);const h=()=>{const n=["dark","auto","light"],u=n.indexOf(t),r=n[(u+1)%n.length];o(r),localStorage.setItem("theme",r),document.documentElement.setAttribute("data-theme",r)},m=[{to:"/",label:"Dashboard",icon:"◈"},{to:"/commands",label:"Commands",icon:"▶"},{to:"/settings",label:"Settings",icon:"⚙"},{to:"/updates",label:"Updates",icon:"🔄"},{to:"/logs",label:"Logs",icon:"≡"}];return e.jsxs(e.Fragment,{children:[e.jsx("header",{className:"header",children:e.jsxs("div",{className:"header-content",children:[e.jsxs("a",{href:"/",className:"logo",children:[e.jsx("div",{className:"logo-icon"}),e.jsx("span",{children:"Dangerous Pi"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(F,{}),e.jsx("button",{onClick:h,className:"btn-secondary",style:{minWidth:"44px",padding:"0.5rem"},"aria-label":"Toggle theme",title:`Current theme: ${t}`,children:t==="dark"?"◐":t==="light"?"○":"◑"})]})]})}),e.jsx("nav",{className:"nav",style:{display:"none"},children:m.map(n=>e.jsxs("a",{href:n.to,className:`nav-link ${a.pathname===n.to?"active":""}`,children:[e.jsx("span",{style:{fontSize:"1.25rem"},children:n.icon}),e.jsx("span",{children:n.label})]},n.to))}),e.jsx("main",{className:"main",children:e.jsx(k,{})}),e.jsx("nav",{className:"nav",children:m.map(n=>e.jsxs("a",{href:n.to,className:`nav-link ${a.pathname===n.to?"active":""}`,children:[e.jsx("span",{style:{fontSize:"1.5rem"},children:n.icon}),e.jsx("span",{children:n.label})]},n.to))}),e.jsx("style",{children:`
        @media (min-width: 768px) {
          .nav:first-of-type {
            display: flex !important;
            position: static;
            border: none;
            background: transparent;
            padding: 1rem 0;
            max-width: 1280px;
            margin: 0 auto;
            justify-content: center;
          }

          .nav:last-of-type {
            display: none;
          }

          body {
            padding-bottom: 0;
          }
        }
      `})]})}export{D as Layout,J as default,B as links};
