const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/latin-400-BcR6IdUc.css","assets/latin-500-DCnAHIrw.css","assets/latin-600-CnkPk-vb.css","assets/latin-700-UC1i-VSI.css"])))=>i.map(i=>d[i]);
import{d as ue,r as t,j as e,c as l,L as $,D as B,bk as J,am as Ts,dR as Re,dS as ss,dT as Ze,_ as Te,T as ie,M as et,S as st,dU as tt,N as X,cn as Qe,b_ as at,dV as nt,z as lt,dW as _s,dX as rt,dY as it,dZ as ot,R as ct,B as F,d_ as qe,I as dt,E as ut,F as mt}from"./index-CeMilrX4.js";import{g as xt,a as ft,c as ht,r as pt,s as yt,b as gt,u as bt,d as jt}from"./system-D5lXsOVm.js";import{C as vt}from"./ConfirmModal-BF449Kzb.js";import{N as Nt}from"./NodeInformationCard-DGC6n0fh.js";import{i as kt,g as wt,s as Ct,a as St,k as Tt}from"./keycap-sfx-ByZp-njj.js";import{C as Y,P as _t,a as Ft,B as Et}from"./PageLayout-Cw_MXmcE.js";import{T as Is}from"./trash-2-Bu7BoH4P.js";import{R as te,C as _e}from"./Grid-BuDgMX1I.js";import{A as Rt}from"./antenna-DhdWQ_ro.js";import{P as Fs}from"./plus-D-z0bUE_.js";import{K as Ge}from"./key-round-Dkqq4aT0.js";import{C as Pt}from"./circle-check-CY6Nl8LU.js";import{T as Be}from"./triangle-alert-DiFold9L.js";import{R as Dt}from"./refresh-cw-DqhcBXAw.js";import{C as It}from"./chevron-right-D3QL4sfa.js";import"./DataBox-Da-5DbUW.js";/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Mt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],At=ue("external-link",Mt);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Kt=[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]],Lt=ue("folder-key",Kt);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const zt=[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]],Es=ue("folder-lock",zt);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ot=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Vt=ue("monitor",Ot);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ht=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],es=ue("pencil",Ht);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $t=[["path",{d:"M10.17 4.193a2 2 0 0 1 3.666.013",key:"pltmmw"}],["path",{d:"M14 21h2",key:"v4qezv"}],["path",{d:"m15.874 7.743 1 1.732",key:"10m0iw"}],["path",{d:"m18.849 12.952 1 1.732",key:"zadnam"}],["path",{d:"M21.824 18.18a2 2 0 0 1-1.835 2.824",key:"fvwuk4"}],["path",{d:"M4.024 21a2 2 0 0 1-1.839-2.839",key:"1e1kah"}],["path",{d:"m5.136 12.952-1 1.732",key:"1u4ldi"}],["path",{d:"M8 21h2",key:"i9zjee"}],["path",{d:"m8.102 7.743-1 1.732",key:"1zzo4u"}]],qt=ue("triangle-dashed",$t),Ee=1500,oe={stacked:"h-[38px]",inline:"h-[32px]"},ce={stacked:"px-3",inline:"px-2.5"},de="rounded-lg";function H({label:a,value:c,editValue:r,onSave:f,type:o="text",suffix:d,placeholder:N,readOnly:u=!1,layout:g="stacked",min:i,max:n,step:h,maxLength:T,description:p,className:D}){const[w,k]=t.useState(!1),[y,E]=t.useState(""),[b,z]=t.useState("idle"),O=t.useRef(null),v=t.useRef(!0),_=t.useRef(null),P=!u&&!!f;t.useEffect(()=>(v.current=!0,()=>{v.current=!1,_.current&&clearTimeout(_.current)}),[]);const A=t.useCallback(()=>{P&&(E(r??c),k(!0),z("idle"),requestAnimationFrame(()=>{var C;return(C=O.current)==null?void 0:C.select()}))},[P,r,c]),S=t.useCallback(()=>{k(!1),E(""),z("idle")},[]),m=t.useCallback(async()=>{if(!f||b==="loading")return;if(y===(r??c)){S();return}_.current&&clearTimeout(_.current),z("loading");try{if(await f(y),!v.current)return;z("success"),k(!1),_.current=setTimeout(()=>{v.current&&z("idle")},Ee)}catch{if(!v.current)return;z("error"),_.current=setTimeout(()=>{v.current&&z("idle")},Ee)}},[f,y,r,c,S,b]),K=t.useCallback(C=>{C.key==="Enter"?(C.preventDefault(),m()):C.key==="Escape"&&(C.preventDefault(),S())},[m,S]);return g==="inline"?e.jsxs("div",{className:l("group flex items-center justify-between gap-3",D),children:[e.jsx("label",{className:"type-label text-fg-muted truncate",children:a}),w?e.jsxs("div",{className:l(oe.inline,de,ce.inline,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20","min-w-[100px]"),children:[e.jsx("input",{ref:O,type:o,value:y,onChange:C=>E(C.target.value),onKeyDown:K,placeholder:N,min:i,max:n,step:h,maxLength:T,disabled:b==="loading",className:l("bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0",d?"w-12 text-right":"w-full")}),d&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:d}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:b==="loading"?e.jsx($,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:m,className:"p-0.5 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(B,{className:"w-3 h-3"})}),e.jsx("button",{onClick:S,className:"p-0.5 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(J,{className:"w-3 h-3"})})]})})]}):e.jsxs("div",{className:l(oe.inline,de,ce.inline,"flex items-center justify-end transition-all min-w-[80px]","bg-input-bg border border-input-border",P&&"cursor-pointer hover:border-edge-strong"),onClick:P?A:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary",children:c}),b==="success"&&e.jsx(B,{className:"w-3 h-3 text-sys-green ml-1.5 shrink-0"}),b==="error"&&e.jsx(J,{className:"w-3 h-3 text-sys-red ml-1.5 shrink-0"}),b==="idle"&&P&&e.jsx(es,{className:"w-3 h-3 text-fg-muted ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]}):e.jsxs("div",{className:l("group",D),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:l(oe.stacked,de,ce.stacked,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20"),children:[e.jsx("input",{ref:O,type:o,value:y,onChange:C=>E(C.target.value),onKeyDown:K,placeholder:N,min:i,max:n,step:h,maxLength:T,disabled:b==="loading",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0"}),d&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:d}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:b==="loading"?e.jsx($,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:m,className:"p-1 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(B,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:S,className:"p-1 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(J,{className:"w-3.5 h-3.5"})})]})})]}),p&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-1 ml-3",children:p})]}):e.jsxs("div",{className:l(oe.stacked,de,ce.stacked,"flex items-center transition-all","bg-input-bg border border-input-border",P&&"cursor-pointer hover:border-edge-strong"),onClick:P?A:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary flex-1 whitespace-nowrap",children:c}),b==="success"&&e.jsx(B,{className:"w-3.5 h-3.5 text-sys-green shrink-0"}),b==="error"&&e.jsx(J,{className:"w-3.5 h-3.5 text-sys-red shrink-0"}),b==="idle"&&P&&e.jsx(es,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]})}function Ue({label:a,value:c,editValue:r,options:f,onSave:o,readOnly:d=!1,layout:N="stacked",className:u}){const[g,i]=t.useState(!1),[n,h]=t.useState(""),[T,p]=t.useState("idle"),D=t.useRef(null),w=t.useRef(!0),k=t.useRef(null),y=!d&&!!o;t.useEffect(()=>(w.current=!0,()=>{w.current=!1,k.current&&clearTimeout(k.current)}),[]);const E=t.useCallback(()=>{y&&(h(String(r)),i(!0),p("idle"),requestAnimationFrame(()=>{var m;return(m=D.current)==null?void 0:m.focus()}))},[y,r]),b=t.useCallback(()=>{i(!1),h(""),p("idle")},[]),z=t.useCallback(async()=>{if(!(!o||T==="loading")){if(n===String(r)){b();return}k.current&&clearTimeout(k.current),p("loading");try{if(await o(n),!w.current)return;p("success"),i(!1),k.current=setTimeout(()=>{w.current&&p("idle")},Ee)}catch{if(!w.current)return;p("error"),k.current=setTimeout(()=>{w.current&&p("idle")},Ee)}}},[o,n,r,b,T]),O=t.useCallback(m=>{m.key==="Escape"&&(m.preventDefault(),b())},[b]),v=N==="inline",_=v?oe.inline:oe.stacked,P=v?ce.inline:ce.stacked,A=e.jsxs("div",{className:l(_,de,P,"flex items-center transition-all relative","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20",v&&"min-w-[100px]"),children:[e.jsx("select",{ref:D,value:n,onChange:m=>h(m.target.value),onKeyDown:O,disabled:T==="loading",className:l("bg-transparent text-fg-primary focus:outline-none appearance-none cursor-pointer type-data flex-1 min-w-0","pr-6"),children:f.map(m=>e.jsx("option",{value:m.value,children:m.label},String(m.value)))}),e.jsx(Ts,{className:"absolute right-auto w-3.5 h-3.5 text-fg-muted pointer-events-none",style:{right:T==="loading"?"2rem":"3.5rem"}}),e.jsx("div",{className:"flex items-center gap-0.5 ml-1 shrink-0",children:T==="loading"?e.jsx($,{className:l("text-fg-muted animate-spin",v?"w-3 h-3":"w-3.5 h-3.5")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:z,className:l("rounded hover:bg-sys-green/15 text-sys-green transition-colors",v?"p-0.5":"p-1"),title:"Save",children:e.jsx(B,{className:v?"w-3 h-3":"w-3.5 h-3.5"})}),e.jsx("button",{onClick:b,className:l("rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",v?"p-0.5":"p-1"),title:"Cancel (Esc)",children:e.jsx(J,{className:v?"w-3 h-3":"w-3.5 h-3.5"})})]})})]}),S=e.jsxs("div",{className:l(_,de,P,"flex items-center transition-all","bg-input-bg border border-input-border",y&&"cursor-pointer hover:border-edge-strong",v?"justify-end min-w-[80px]":""),onClick:y?E:void 0,children:[e.jsx("span",{className:l("type-data text-fg-primary",!v&&"flex-1"),children:c}),T==="success"&&e.jsx(B,{className:l("text-sys-green shrink-0",v?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),T==="error"&&e.jsx(J,{className:l("text-sys-red shrink-0",v?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),T==="idle"&&y&&e.jsx(Ts,{className:l("text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0",v?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")})]});return v?e.jsxs("div",{className:l("group flex items-center justify-between",u),children:[e.jsx("label",{className:"type-label text-fg-muted shrink-0",children:a}),g?A:S]}):e.jsxs("div",{className:l("group",u),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),g?A:S]})}async function Gt(){try{return await Re("/api/auth/tokens")}catch{return{tokens:[]}}}async function Bt(a){return Re("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:a})})}async function Ut(a){return Re(`/api/auth/tokens/${a}`,{method:"DELETE"})}async function Rs(a){return Re("/api/update_web_config",{method:"POST",body:JSON.stringify(a)})}t.memo(function(){const{theme:c}=ss(),{themeId:r}=c,f=Ze.find(o=>o.meta.id===r)??Ze[0];return e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center text-fg-secondary",style:{fontFamily:"Inter, system-ui, sans-serif",fontSize:"clamp(0.75rem, 0.6rem + 1.5vw, 1.1rem)",letterSpacing:"-0.02em"},children:f.meta.name})})});const We=t.memo(function({compact:c=!1}){const{theme:r,setTheme:f}=ss(),{themeId:o}=r;return e.jsx("div",{className:l("grid grid-cols-2 gap-2",c?"w-full min-w-0 self-stretch":"w-full"),children:[...Ze].reverse().map(d=>{const N=o===d.meta.id,u=d.meta.isDark;return e.jsxs("button",{type:"button",title:d.meta.name,className:l("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",c&&"h-6",N?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>f(d.meta.id),children:[e.jsx("div",{className:l("flex-1 h-full",u?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:d.display.palette.map((g,i)=>e.jsx("div",{className:"flex flex-1",children:g.map((n,h)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:n}},h))},i))})]},d.meta.id)})})});let Ps=!1,Fe=null;async function Wt(){if(!Ps)return Fe||(Fe=(async()=>{try{await Promise.all([Te(()=>Promise.resolve({}),__vite__mapDeps([0])),Te(()=>Promise.resolve({}),__vite__mapDeps([1])),Te(()=>Promise.resolve({}),__vite__mapDeps([2])),Te(()=>Promise.resolve({}),__vite__mapDeps([3]))]),Ps=!0}catch(a){console.warn("Failed to load theme fonts:",a)}})(),Fe)}const Xe=t.memo(function(){const{theme:c,setTheme:r}=ss(),{themeId:f}=c,o=f==="breeze dark",d=t.useCallback(N=>{r(N?"breeze dark":"breeze light")},[r]);return e.jsx(ie,{enabled:o,onChange:d,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",o?e.jsx(et,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(st,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),Xt=t.memo(function({layout:c="horizontal"}){return t.useEffect(()=>{Wt()},[]),c==="toggle-only"?e.jsx(Xe,{}):c==="thumbnails-only"?e.jsx(We,{}):c==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(Xe,{}),e.jsx(We,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(Xe,{})}),e.jsx(We,{compact:!0})]})}),Yt=1e4,Ye=2e3;function Je(a,c,r){const[f,o]=t.useState("idle"),[d,N]=t.useState(null),u=t.useRef(!0),g=t.useRef(null),i=t.useRef(null),n=t.useRef(!1),h=t.useRef("idle"),T=t.useRef(a),p=t.useRef(c),D=t.useRef(r);h.current=f,T.current=a,p.current=c,D.current=r,t.useEffect(()=>(u.current=!0,()=>{u.current=!1,g.current&&clearTimeout(g.current),i.current&&clearTimeout(i.current)}),[]);const w=t.useCallback(async y=>{if(h.current==="loading")return;const E=T.current;g.current&&clearTimeout(g.current),i.current&&clearTimeout(i.current),n.current=!1,N(y),o("loading"),g.current=setTimeout(()=>{n.current||!u.current||(N(E),o("error"),i.current=setTimeout(()=>{u.current&&(o("idle"),N(null))},Ye))},Yt);try{if(await p.current(y),n.current=!0,g.current&&clearTimeout(g.current),!u.current)return;o("success"),i.current=setTimeout(()=>{var b;u.current&&(o("idle"),N(null),(b=D.current)==null||b.call(D))},Ye)}catch{if(n.current=!0,g.current&&clearTimeout(g.current),!u.current)return;N(E),o("error"),i.current=setTimeout(()=>{u.current&&(o("idle"),N(null))},Ye)}},[]);return{enabled:d!==null?d:a,status:f,toggle:w}}function Jt(){const{latitude:a,longitude:c,enabled:r,setLocation:f,enable:o,disable:d,clear:N}=tt(),[u,g]=t.useState(!1),[i,n]=t.useState(""),[h,T]=t.useState(""),[p,D]=t.useState("idle"),[w,k]=t.useState(null),y=t.useRef(null),E=t.useRef(null),b=t.useRef(!0);t.useEffect(()=>(b.current=!0,()=>{b.current=!1,E.current&&clearTimeout(E.current)}),[]);const z=()=>{n((a==null?void 0:a.toFixed(6))??""),T((c==null?void 0:c.toFixed(6))??""),k(null),g(!0)},O=()=>{g(!1),k(null)};t.useEffect(()=>{if(!u)return;const m=K=>{p!=="loading"&&y.current&&!y.current.contains(K.target)&&O()};return document.addEventListener("mouseup",m),()=>document.removeEventListener("mouseup",m)},[u,p]);const v=(m,K)=>{const C=parseFloat(m),G=parseFloat(K);return isNaN(C)||isNaN(G)?"Please enter valid numbers":C<-90||C>90?"Latitude must be between -90 and 90":G<-180||G>180?"Longitude must be between -180 and 180":C===0&&G===0?"Coordinates (0, 0) are invalid":null},_=()=>{if(p==="loading")return;E.current&&clearTimeout(E.current);const m=v(i,h);if(m){k(m);return}D("loading"),k(null);const K=parseFloat(i),C=parseFloat(h);f(K,C),r||o(),D("success"),E.current=setTimeout(()=>{b.current&&(D("idle"),g(!1))},1e3)},P=()=>{r?d():o()},A=()=>{N(),g(!1)},S=a!==null&&c!==null;return e.jsx(Y,{children:e.jsxs("div",{ref:y,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(X,{icon:e.jsx(qt,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[S&&!u&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:P,className:l("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",r?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),title:r?"Disable stealth location":"Enable stealth location",children:e.jsx("span",{className:l("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",r?"translate-x-5":"translate-x-0.5")})}),e.jsx("button",{onClick:A,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-sys-red hover:bg-sys-red/10",title:"Clear stealth location",children:e.jsx(Is,{className:"w-4 h-4"})})]}),u?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:O,disabled:p==="loading",className:l("p-2 rounded-lg transition-colors",p==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(J,{className:"w-4 h-4"})}),e.jsx("button",{onClick:_,disabled:p==="loading",className:l("p-2 rounded-lg transition-colors",p==="loading"?"text-sys-blue cursor-wait":p==="success"?"text-sys-green":p==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:p==="loading"?e.jsx($,{className:"w-4 h-4 animate-spin"}):p==="success"?e.jsx(B,{className:"w-4 h-4"}):p==="error"?e.jsx(J,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]}):e.jsx("button",{onClick:z,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:S?"Edit stealth location":"Set stealth location",children:e.jsx(es,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-sys-cyan/5 rounded-xl p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Qe,{className:"w-4 h-4 text-sys-cyan flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[e.jsx("span",{className:"text-fg-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",e.jsx("span",{className:"text-sys-cyan",children:"never sent to config.yaml or the mesh"}),"."]})]})}),w&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:w}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:u?"Latitude (°)":"Latitude"}),e.jsx("div",{className:l("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:u?e.jsx("input",{type:"number",value:i,onChange:m=>n(m.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:l("type-data",S&&r?"text-fg-primary":"text-fg-muted"),children:S?a.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:u?"Longitude (°)":"Longitude"}),e.jsx("div",{className:l("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:u?e.jsx("input",{type:"number",value:h,onChange:m=>T(m.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:l("type-data",S&&r?"text-fg-primary":"text-fg-muted"),children:S?c.toFixed(6):"Not set"})})]})]}),S&&!u&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:l("w-2 h-2 rounded-full",r?"bg-sys-green":"bg-fg-muted")}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:r?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}const Zt=[{value:7.8,label:"7.8 kHz"},{value:10.4,label:"10.4 kHz"},{value:15.6,label:"15.6 kHz"},{value:20.8,label:"20.8 kHz"},{value:31.25,label:"31.25 kHz"},{value:41.7,label:"41.7 kHz"},{value:62.5,label:"62.5 kHz"},{value:125,label:"125 kHz"},{value:250,label:"250 kHz"},{value:500,label:"500 kHz"}],Qt=[5,6,7,8,9,10,11,12],ea=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],Ds={RADIO_CONFIG:"radioConfig"};function sa(a){if(!a)return"Never";const r=Date.now()-a*1e3,f=Math.floor(r/6e4),o=Math.floor(r/36e5),d=Math.floor(r/864e5);return f<1?"Just now":f<60?`${f}m ago`:o<24?`${o}h ago`:d<365?`${d}d ago`:`${Math.floor(d/365)}y ago`}function Ms({node:a,level:c,expandedKeys:r,selectedKeyId:f,globalFloodPolicy:o,onSelect:d,onToggle:N}){const u=r.has(a.id),g=f===a.id,i=a.children&&a.children.length>0,n=o==="allow";return e.jsxs("div",{children:[e.jsxs("div",{className:l("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",g?"bg-sys-blue/15":"hover:bg-subtle-fill",n&&"opacity-50 cursor-not-allowed"),style:{marginLeft:`${c*16}px`},onClick:()=>!n&&d(a.id),children:[i?e.jsx("button",{onClick:h=>{h.stopPropagation(),N(a.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(It,{className:l("w-3.5 h-3.5 text-fg-muted transition-transform",u&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(Lt,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary flex-1 truncate",children:a.name}),e.jsx("span",{className:"type-data-xs text-fg-muted hidden sm:inline",title:a.last_used?new Date(a.last_used*1e3).toLocaleString():void 0,children:sa(a.last_used)}),e.jsx("span",{className:l("type-data-xs px-2 py-0.5 rounded-full",a.floodPolicy==="allow"?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:a.floodPolicy==="allow"?"Allow":"Deny"})]}),i&&u&&e.jsx("div",{children:a.children.map(h=>e.jsx(Ms,{node:h,level:c+1,expandedKeys:r,selectedKeyId:f,globalFloodPolicy:o,onSelect:d,onToggle:N},h.id))})]})}function ta(){const[a,c]=t.useState(kt),[r,f]=t.useState(wt),[o,d]=t.useState(!1),N=t.useCallback(i=>{c(i),Ct(i)},[]),u=t.useCallback(i=>{const n=parseFloat(i.target.value);f(n),St(n)},[]),g=t.useCallback(async()=>{o||(d(!0),await Tt(),d(!1))},[o]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(ie,{enabled:a,onChange:N,label:e.jsxs(e.Fragment,{children:["Sound: ",e.jsx("span",{className:a?"text-sys-green":"text-sys-red",children:a?"On":"Off"})]}),tooltip:"Enable or disable UI sound effects and haptic audio feedback",size:"md"}),e.jsx(F,{color:"primary",outline:!0,onClick:g,disabled:!a||o,className:"w-16 justify-center",children:o?"…":"Test"})]}),e.jsxs("div",{className:l("flex items-center gap-3",!a&&"opacity-40 pointer-events-none"),children:[e.jsx("span",{className:"type-label text-fg-muted w-14 shrink-0",children:"Volume"}),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:r,onChange:u,className:"flex-1 accent-sys-blue h-1.5 cursor-pointer"}),e.jsxs("span",{className:"data-box w-16 justify-center",children:[Math.round(r*100),"%"]})]})]})}function ba(){var vs,Ns,ks,ws,Cs,Ss;const{stats:a,setMode:c,clearModeMutation:r,setDutyCycleConfig:f,clearDutyCycleMutation:o,fetchStats:d,startMutation:N,clearMutation:u}=at(),g=nt(),i=(vs=a==null?void 0:a.config)==null?void 0:vs.radio,n=(Ns=a==null?void 0:a.config)==null?void 0:Ns.repeater,h=(ks=a==null?void 0:a.config)==null?void 0:ks.duty_cycle,T=(a==null?void 0:a.node_name)||((ws=a==null?void 0:a.config)==null?void 0:ws.node_name)||"Unknown Node",p=(n==null?void 0:n.mode)??"forward",D=(h==null?void 0:h.enforcement_enabled)??!1,w=(Cs=a==null?void 0:a.config)==null?void 0:Cs.delays,k=t.useRef(!0);t.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const y=(Ss=a==null?void 0:a.config)==null?void 0:Ss.web,[E,b]=t.useState([]),[z,O]=t.useState(!1),[v,_]=t.useState(null),[P,A]=t.useState(!1),[S,m]=t.useState(""),[K,C]=t.useState(null),[G,ge]=t.useState(!1),[ae,Pe]=t.useState(null),[De,ts]=t.useState(!1),[as,ns]=t.useState(!1),[ls,rs]=t.useState(!1),[U,As]=t.useState([]),[Ks,is]=t.useState(!1),[os,I]=t.useState(null),[Z,Ls]=t.useState(()=>localStorage.getItem("pymc:globalFloodPolicy")==="allow"?"allow":"deny"),cs=t.useCallback(s=>{Ls(s),localStorage.setItem("pymc:globalFloodPolicy",s)},[]),[ds,us]=t.useState(!1),[L,Ie]=t.useState(null),[zs,Os]=t.useState(new Set),[be,me]=t.useState(!1),[je,ne]=t.useState(!1),[ve,le]=t.useState(!1),[M,W]=t.useState(null),[Q,xe]=t.useState(null),[Ne,ke]=t.useState(""),[Me,fe]=t.useState("allow"),[q,re]=t.useState(!1),[we,ms]=t.useState(!0),[he,Ae]=t.useState(!1),[Vs,xs]=t.useState(!0),[pe,ee]=t.useState("idle"),[Hs,Ke]=t.useState(!1),[Le,$s]=t.useState(!1),fs=t.useCallback(()=>{const s=w==null?void 0:w.tx_delay_factor;return s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??1:typeof s=="number"?s:1},[w]),hs=t.useCallback(()=>{const s=w==null?void 0:w.direct_tx_delay_factor;return typeof s=="number"?s:.5},[w]),ze=t.useCallback(()=>{const s=h==null?void 0:h.max_airtime_percent;return typeof s=="number"?s:s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??6:6},[h]),Oe=Je(p==="forward",async s=>{await c(s?"forward":"monitor")},r),Ve=Je(D,async s=>{await f({max_airtime_percent:ze(),enforcement_enabled:s})},o),He=Je((y==null?void 0:y.cors_enabled)??!1,async s=>{var j;const x=await Rs({web:{cors_enabled:s}});if(!x.success&&!((j=x.data)!=null&&j.persisted))throw new Error("CORS update failed");await d()}),V=t.useCallback(async s=>{N(Ds.RADIO_CONFIG);try{const x=await lt(s);if(!x.success)throw new Error(x.error||"Failed to save");await d({force:!0}).catch(()=>{})}finally{u(Ds.RADIO_CONFIG)}},[N,u,d]);t.useEffect(()=>{(async()=>{xs(!0);try{const x=await ht();x.success&&x.data?Ae(x.data.exists):Ae(!1);const j=y==null?void 0:y.web_path;ms(!j||j==="")}catch{Ae(!1)}finally{xs(!1)}})()},[y==null?void 0:y.web_path]);const ps=async s=>{var x;if(pe!=="loading"){ee("loading");try{const j=await Rs({web:{web_path:s?null:"/opt/pymc_console/web/html"}});if(!k.current)return;j.success||(x=j.data)!=null&&x.persisted?(ms(s),ee("success"),Ke(!0),setTimeout(()=>{k.current&&ee("idle")},2e3)):(ee("error"),setTimeout(()=>{k.current&&ee("idle")},2e3))}catch{if(!k.current)return;ee("error"),setTimeout(()=>{k.current&&ee("idle")},2e3)}}},qs=async()=>{if(!Le){$s(!0);try{await pt(),Ke(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Ke(!1),setTimeout(()=>{window.location.reload()},3e3)}}},Ce=t.useCallback(async()=>{O(!0),_(null);try{const s=await Gt();b(s.tokens||[])}catch(s){_(s instanceof Error?s.message:"Failed to fetch tokens")}finally{O(!1)}},[]);t.useEffect(()=>{Ce()},[Ce]);const ys=async()=>{if(!S.trim()){_("Token name is required");return}ts(!0),_(null);try{const s=await Bt(S.trim());C(s.token||null),A(!1),ge(!0),m(""),await Ce()}catch(s){_(s instanceof Error?s.message:"Failed to create token")}finally{ts(!1)}},Gs=async()=>{if(ae){ns(!0),_(null);try{await Ut(ae.id),await Ce(),Pe(null)}catch(s){_(s instanceof Error?s.message:"Failed to revoke token")}finally{ns(!1)}}},Bs=async()=>{K&&(await mt(K),rs(!0),setTimeout(()=>rs(!1),2e3))},gs=s=>s?new Date(s*1e3).toLocaleString():"Never",bs=t.useCallback(s=>{const x=new Map,j=[];return s.forEach(R=>{const Se={id:R.id,name:R.name,floodPolicy:R.flood_policy,transport_key:R.transport_key,last_used:R.last_used,parent_id:R.parent_id,children:[]};x.set(R.id,Se)}),x.forEach(R=>{R.parent_id&&x.has(R.parent_id)?x.get(R.parent_id).children.push(R):j.push(R)}),j},[]),ye=t.useCallback(async()=>{is(!0),I(null);try{const s=await xt();if(s.success&&s.data){const x=bs(s.data);As(x),Ie(j=>{if(j===null)return null;const R=Se=>{for(const $e of Se)if($e.id===j||$e.children&&R($e.children))return!0;return!1};return R(x)?j:null})}else I(s.error||"Failed to load transport keys")}catch(s){I(s instanceof Error?s.message:"Unknown error occurred")}finally{is(!1)}},[bs]);t.useEffect(()=>{ye(),ft().then(s=>{s.success&&s.data&&cs(s.data.global_flood_allow?"allow":"deny")}).catch(()=>{})},[ye]);const se=t.useCallback((s,x)=>{for(const j of s){if(j.id===x)return j;if(j.children){const R=se(j.children,x);if(R)return R}}return null},[]),Us=t.useCallback(()=>{if(!L)return;const s=se(U,L);return s==null?void 0:s.name},[L,U,se]),Ws=t.useCallback(s=>{Os(x=>{const j=new Set(x);return j.has(s)?j.delete(s):j.add(s),j})},[]),Xs=async s=>{us(!0),I(null);try{const x=await yt(s==="allow");x.success?cs(s):I(x.error||"Failed to update global flood policy")}catch(x){I(x instanceof Error?x.message:"Failed to update global flood policy")}finally{us(!1)}},js=async()=>{if(!Ne.trim()){I("Key name is required");return}re(!0),I(null);try{const s=await gt({name:Ne.trim(),flood_policy:Me,parent_id:L??void 0});s.success?(await ye(),me(!1),ke(""),fe("allow")):I(s.error||"Failed to add transport key")}catch(s){I(s instanceof Error?s.message:"Failed to add transport key")}finally{re(!1)}},Ys=async()=>{if(M){re(!0),I(null);try{const s=await bt(M.id,{name:M.name,flood_policy:M.floodPolicy});s.success?(await ye(),ne(!1),W(null)):I(s.error||"Failed to update transport key")}catch(s){I(s instanceof Error?s.message:"Failed to update transport key")}finally{re(!1)}}},Js=async()=>{if(Q){re(!0),I(null);try{const s=await jt(Q.id);s.success?(await ye(),le(!1),xe(null),Ie(null)):I(s.error||"Failed to delete transport key")}catch(s){I(s instanceof Error?s.message:"Failed to delete transport key")}finally{re(!1)}}},Zs=t.useCallback(()=>{if(!L)return;const s=se(U,L);s&&(W({...s}),ne(!0))},[L,U,se]);t.useEffect(()=>{const s=j=>{j.key==="Escape"&&(be&&(me(!1),ke(""),fe("allow")),je&&(ne(!1),W(null)),ve&&(le(!1),xe(null)),P&&(A(!1),m("")),G&&(ge(!1),C(null)))};if(be||je||ve||P||G)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[be,je,ve,P,G]);const Qs=t.useCallback(()=>{if(!L)return;const s=se(U,L);s&&(xe(s),le(!0))},[L,U,se]);return e.jsxs(_t,{children:[e.jsx(Ft,{title:"Configuration",icon:e.jsx(_s,{})}),e.jsxs(Et,{ready:g,children:[e.jsxs(te,{template:"standard",children:[e.jsx(_e,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(rt,{}),title:"Repeater Settings"}),n?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(H,{label:"Node Name",value:T,onSave:async s=>V({node_name:s}),placeholder:"Enter node name",maxLength:50})}),e.jsx(H,{label:"Latitude",value:n.latitude!==0?n.latitude.toFixed(6):"Not set",editValue:String(n.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async s=>V({latitude:parseFloat(s)})}),e.jsx(H,{label:"Longitude",value:n.longitude!==0?n.longitude.toFixed(6):"Not set",editValue:String(n.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async s=>V({longitude:parseFloat(s)})}),e.jsx(H,{label:"Advert Interval",value:n.send_advert_interval_hours>0?`${n.send_advert_interval_hours}h`:"Disabled",editValue:String(n.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async s=>V({flood_advert_interval_hours:parseInt(s,10)})}),e.jsx(H,{label:"Score-based TX",value:n.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),e.jsx(_e,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Rt,{}),title:"Radio Configuration"}),i?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(H,{label:"Frequency",value:it(i.frequency),editValue:(i.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async s=>V({frequency_mhz:parseFloat(s)})}),e.jsx(H,{label:"TX Power",value:`${i.tx_power} dBm`,editValue:String(i.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async s=>V({tx_power:parseInt(s,10)})}),e.jsx(Ue,{label:"Bandwidth",value:ot(i.bandwidth),editValue:i.bandwidth/1e3,options:Zt,onSave:async s=>V({bandwidth_khz:parseFloat(s)})}),e.jsx(Ue,{label:"Spreading Factor",value:`SF${i.spreading_factor}`,editValue:i.spreading_factor,options:Qt.map(s=>({value:s,label:`SF${s}`})),onSave:async s=>V({spreading_factor:parseInt(s,10)})}),e.jsx(Ue,{label:"Coding Rate",value:`4/${i.coding_rate}`,editValue:i.coding_rate,options:ea,onSave:async s=>V({coding_rate:parseInt(s,10)})}),e.jsx(H,{label:"Preamble",value:`${i.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(te,{template:"standard",children:[e.jsx(_e,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(ct,{}),title:"Operating Mode"}),e.jsx("p",{className:"type-label text-fg-muted mb-3",children:"Control how the repeater handles packets"}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsx(ie,{enabled:Oe.enabled,onChange:Oe.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:Oe.status,size:"md"}),e.jsx(ie,{enabled:Ve.enabled,onChange:Ve.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:Ve.status,size:"md"}),e.jsx(H,{label:"Max Airtime",layout:"inline",value:`${ze().toFixed(1)}%`,editValue:String(ze()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async s=>{await f({max_airtime_percent:parseFloat(s),enforcement_enabled:D}),o()}})]}),e.jsx("div",{className:"hidden lg:block w-px bg-border-subtle"}),e.jsxs("div",{className:"flex-1 pt-4 lg:pt-0 border-t lg:border-t-0 border-edge-subtle",children:[e.jsx("label",{className:"type-label text-fg-muted block mb-3",children:"TX Delays"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(H,{label:"Flood",layout:"inline",value:`${fs().toFixed(2)}x`,editValue:String(fs()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async s=>V({tx_delay_factor:parseFloat(s)})}),e.jsx(H,{label:"Direct",layout:"inline",value:`${hs().toFixed(2)}s`,editValue:String(hs()),type:"number",suffix:"s",step:.1,min:0,max:5,onSave:async s=>V({direct_tx_delay_factor:parseFloat(s)})})]})]})]})]})}),e.jsx(_e,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(_s,{}),title:"App Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Appearance and web server options."}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ie,{enabled:He.enabled,onChange:He.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:He.status,size:"md"}),e.jsx("div",{children:e.jsx(Xt,{})}),e.jsx(ta,{})]})]})})]}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(X,{icon:e.jsx(Es,{}),title:"Regions Transport Keys",subtitle:"Manage regional key hierarchy for flood control"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(F,{color:"primary",outline:!0,onClick:()=>me(!0),disabled:Z==="allow",children:[e.jsx(Fs,{"data-slot":"icon"}),"Add"]}),e.jsx(F,{color:"primary",outline:!0,onClick:Zs,disabled:!L||Z==="allow",children:"Edit"}),e.jsx(F,{color:"danger",outline:!0,onClick:Qs,disabled:!L||Z==="allow",children:"Delete"})]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsx(ie,{enabled:Z==="deny",onChange:s=>Xs(s?"deny":"allow"),label:e.jsxs(e.Fragment,{children:["Require Transport Keys: ",e.jsx("span",{className:Z==="deny"?"text-sys-green":"text-sys-red",children:Z==="deny"?"On":"Off"})]}),tooltip:"When enabled, only packets with matching transport keys are forwarded. When disabled, all packets flood freely.",status:ds?"loading":"idle",disabled:ds,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})}),os&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:os}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:Ks?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx($,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading transport keys..."})]}):U.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(Es,{className:"w-6 h-6 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No transport keys found"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first transport key to get started"})]}):e.jsx("div",{className:"space-y-1",children:U.map(s=>e.jsx(Ms,{node:s,level:0,expandedKeys:zs,selectedKeyId:L,globalFloodPolicy:Z,onSelect:Ie,onToggle:Ws},s.id))})})]})}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(X,{icon:e.jsx(Ge,{}),title:"API Tokens",subtitle:"Manage API tokens for machine-to-machine authentication"}),e.jsxs(F,{color:"primary",outline:!0,onClick:()=>A(!0),children:[e.jsx(Fs,{"data-slot":"icon"}),"Create Token"]})]}),e.jsx("div",{className:"bg-sys-blue/5 radius-inner p-4 mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Qe,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"type-body-sm text-fg-muted",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-secondary",children:"API tokens"})," are used for machine-to-machine authentication. Include the token in the ",e.jsx("code",{className:"type-code bg-sys-blue/20 px-1.5 py-0.5 rounded-full text-sys-blue",children:"X-API-Key"})," header when making API requests."]}),e.jsx("p",{className:"mt-1 text-fg-muted/70",children:"Tokens are only shown once at creation. Store them securely."})]})]})}),v&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:v}),z&&E.length===0?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx($,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading tokens..."})]}):E.length>0?e.jsx("div",{className:"space-y-2",children:E.map(s=>e.jsx("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong radius-inner p-4 transition-base",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",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-full bg-sys-blue/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Ge,{className:"w-5 h-5 text-sys-blue"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"type-body text-fg-primary font-medium truncate",children:s.name}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-0.5",children:[e.jsxs("span",{className:"type-data-sm text-fg-muted truncate",children:["Created: ",gs(s.created_at)]}),e.jsxs("span",{className:"type-data-sm text-fg-muted truncate",children:["Last used: ",gs(s.last_used)]})]})]})]}),e.jsxs(F,{color:"danger",outline:!0,onClick:()=>Pe({id:s.id,name:s.name}),disabled:as,children:[e.jsx(Is,{"data-slot":"icon"}),"Revoke"]})]})},s.id))}):e.jsxs("div",{className:"bg-subtle-fill radius-inner p-6 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(Ge,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("h3",{className:"type-body text-fg-primary font-medium mb-1",children:"No API Tokens"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Create a token to enable API access"}),e.jsx(F,{color:"primary",outline:!0,onClick:()=>A(!0),children:"Create Your First Token"})]})]})}),e.jsx(te,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Vt,{}),title:"Web Frontend",subtitle:"Choose which web interface to use",className:"mb-4"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:l("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",we?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",pe==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:we,onChange:()=>ps(!0),disabled:pe==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"Default Frontend"}),e.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"type-data-xs bg-sys-cyan/15 text-sys-cyan px-2.5 py-0.5 rounded-full font-medium hover:bg-sys-cyan/25 transition-colors",children:"@RightUp"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Built-in pyMC Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:l("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",we?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",pe==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!we,onChange:()=>ps(!1),disabled:pe==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"PyMC Console"}),e.jsx("span",{className:"type-data-xs bg-sys-indigo/15 text-sys-indigo px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!Vs&&e.jsx("div",{className:l("bg-subtle-fill radius-card p-4",he?"border border-sys-green/20":"border border-sys-cyan/20"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:l("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",he?"bg-sys-green/20":"bg-sys-cyan/20"),children:he?e.jsx(Pt,{className:"w-4 h-4 text-sys-green"}):e.jsx(Qe,{className:"w-4 h-4 text-sys-cyan"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:he?"PyMC Console has been detected":"PyMC Console Not Installed"}),he?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["PyMC Console is installed at ",e.jsx("code",{className:"type-code bg-sys-green/10 px-1.5 py-0.5 rounded-full text-sys-green",children:"/opt/pymc_console/web/html"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1 mb-3",children:["PyMC Console must be installed at ",e.jsx("code",{className:"type-code bg-sys-cyan/10 px-1.5 py-0.5 rounded-full text-sys-cyan",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),e.jsxs(F,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(At,{"data-slot":"icon"}),"PyMC Console Install Instructions"]})]})]})]})}),Hs&&e.jsx("div",{className:"bg-subtle-fill radius-card p-4 border border-sys-indigo/30",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-indigo/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Be,{className:"w-4 h-4 text-sys-indigo"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:"Service restart required"}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),e.jsx(F,{color:"warning",outline:!0,onClick:qs,disabled:Le,children:Le?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Dt,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),a&&e.jsx(te,{template:"auto",children:e.jsx(Nt,{nodeName:T,repeaterVersion:a.version,coreVersion:a.core_version,localHash:a.local_hash,publicKey:a.public_key})}),a&&((n==null?void 0:n.latitude)===0||!(n!=null&&n.latitude))&&((n==null?void 0:n.longitude)===0||!(n!=null&&n.longitude))&&e.jsx(te,{template:"auto",children:e.jsx(Jt,{})})]}),P&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&A(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"create-token-modal-title",className:"type-micro mb-4",children:"Create API Token"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(qe,{label:"Token Name",type:"text",value:S,onChange:s=>m(s.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",description:"Give your token a descriptive name to identify its purpose",onKeyDown:s=>s.key==="Enter"&&ys(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{A(!1),m(""),_(null)},disabled:De,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:ys,disabled:De||!S.trim(),children:De?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),G&&K&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ge(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-lg w-full",children:[e.jsx("h3",{id:"show-token-modal-title",className:"type-micro mb-4",children:"Token Created Successfully"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:[e.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-primary block mb-1.5",children:"Your API Token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(dt,{value:K,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(F,{color:"primary",outline:!0,onClick:Bs,children:[ls?e.jsx(B,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(ut,{"data-slot":"icon"}),ls?"Copied!":"Copy"]})]})]}),e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary mb-2",children:e.jsx("strong",{children:"Usage Example:"})}),e.jsxs("code",{className:"block bg-sys-cyan/20 px-3 py-2 rounded type-code text-sys-cyan overflow-x-auto",children:['curl -H "X-API-Key: ',K.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(F,{color:"primary",onClick:()=>{ge(!1),C(null)},children:"Done"})})]})]})}),e.jsx(vt,{isOpen:!!ae,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${ae==null?void 0:ae.name}'? This action cannot be undone.`,confirmLabel:as?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:Gs,onCancel:()=>Pe(null)}),be&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&me(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"add-key-modal-title",className:"type-micro mb-4",children:"Add Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[L&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding as child of: ",e.jsx("strong",{className:"text-fg-primary",children:Us()})]}),e.jsx(qe,{label:"Key Name",type:"text",value:Ne,onChange:s=>ke(s.target.value),placeholder:"e.g., Region Name, Group Key",onKeyDown:s=>s.key==="Enter"&&js(),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>fe("deny"),className:l("toggle-group-item flex-1",Me==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>fe("allow"),className:l("toggle-group-item flex-1",Me==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{me(!1),ke(""),fe("allow")},disabled:q,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:js,disabled:q||!Ne.trim(),children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),je&&M&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ne(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"edit-key-modal-title",className:"type-micro mb-4",children:"Edit Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(qe,{label:"Key Name",type:"text",value:M.name,onChange:s=>W({...M,name:s.target.value}),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>W({...M,floodPolicy:"deny"}),className:l("toggle-group-item flex-1",M.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>W({...M,floodPolicy:"allow"}),className:l("toggle-group-item flex-1",M.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),M.transport_key&&e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Transport Key"}),e.jsx("code",{className:"block bg-input-bg px-3 py-2 radius-inner border border-input-border type-code text-fg-muted overflow-x-auto",children:M.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(F,{color:"danger",outline:!0,onClick:()=>{ne(!1),xe(M),le(!0),W(null)},disabled:q,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{ne(!1),W(null)},disabled:q,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:Ys,disabled:q||!M.name.trim(),children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),ve&&Q&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&le(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"delete-key-modal-title",className:"type-micro mb-4",children:"Delete Transport Key"}),e.jsxs("p",{className:"text-fg-secondary mb-4",children:["Are you sure you want to delete ",e.jsxs("strong",{className:"text-fg-primary",children:["'",Q.name,"'"]}),"?"]}),Q.children&&Q.children.length>0&&e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:["This key has ",Q.children.length," child key(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(F,{color:"muted",outline:!0,onClick:()=>{le(!1),xe(null)},disabled:q,children:"Cancel"}),e.jsx(F,{color:"danger",onClick:Js,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx($,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{ba as default};
