Files
pymc_console-dist/frontend/dist/assets/Configuration-CobIQjJB.js
GitHub Actions Bot c8c3f164ee Sync build v0.9.286
Automated sync from private repository.
Commit: fad7f9633de61427bfc2c672b7ddecaa0952d717
2026-02-27 07:48:08 +00:00

3 lines
51 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-fonts-CRZaZSFf.js","assets/vendor-fonts-hkYiuhFD.css"])))=>i.map(i=>d[i]);
import{r as e,j as s}from"./vendor-react-alRNW2nb.js";import{c as t}from"./vendor-core-FtpmsTnh.js";import{bM as a,bN as l,bO as n,T as r,bP as i,q as o,av as c,k as d,bQ as u,bR as m,B as x,bS as p,I as h}from"./index-CkRTgHHA.js";import{g as y,a as f,c as g,r as b,s as j,b as v,u as N,d as w}from"./system-OS35JnnX.js";import{C as k}from"./ConfirmModal-B6Rz8ROW.js";import{_ as C}from"./cosmograph-DqYT4sUA.js";import{L as S,a as _,X as F,b3 as T,C as E,d as P,c as R,b4 as D,as as I,I as L,k as A,n as z,b5 as M,R as K,b6 as V,b7 as O,b8 as $,b9 as H,a9 as q,ba as B,a3 as U,aX as X,o as G,D as W,bb as J}from"./vendor-icons-TO0PZKGR.js";import{N as Y}from"./NodeInformationCard-tOZNdmfP.js";import{i as Q,g as Z,s as ee,a as se,k as te}from"./keycap-sfx-Bpx9zhkt.js";import{C as ae,P as le,a as ne,B as re}from"./PageLayout-BWMUVZgC.js";import{R as ie,C as oe}from"./Grid-m53vqd2Y.js";import"./vendor-virt-BytWoLhu.js";import"./vendor-charts-C916_-gs.js";import"./vendor-motion-DNp0Qg4F.js";import"./vendor-fonts-CRZaZSFf.js";import"./DataBox-DpDXI-WX.js";const ce=1500,de="h-[38px]",ue="h-[32px]",me="px-3",xe="px-2.5",pe="rounded-lg";function he({label:a,value:l,editValue:n,onSave:r,type:i="text",suffix:o,placeholder:c,readOnly:d=!1,layout:u="stacked",min:m,max:x,step:p,maxLength:h,description:y,className:f}){const[g,b]=e.useState(!1),[j,v]=e.useState(""),[N,w]=e.useState("idle"),k=e.useRef(null),C=e.useRef(!0),E=e.useRef(null),P=!d&&!!r;e.useEffect(()=>(C.current=!0,()=>{C.current=!1,E.current&&clearTimeout(E.current)}),[]);const R=e.useCallback(()=>{P&&(v(n??l),b(!0),w("idle"),requestAnimationFrame(()=>{var e;return null==(e=k.current)?void 0:e.select()}))},[P,n,l]),D=e.useCallback(()=>{b(!1),v(""),w("idle")},[]),I=e.useCallback(async()=>{if(r&&"loading"!==N)if(j!==(n??l)){E.current&&clearTimeout(E.current),w("loading");try{if(await r(j),!C.current)return;w("success"),b(!1),E.current=setTimeout(()=>{C.current&&w("idle")},ce)}catch{if(!C.current)return;w("error"),E.current=setTimeout(()=>{C.current&&w("idle")},ce)}}else D()},[r,j,n,l,D,N]),L=e.useCallback(e=>{"Enter"===e.key?(e.preventDefault(),I()):"Escape"===e.key&&(e.preventDefault(),D())},[I,D]);return"inline"===u?s.jsxs("div",{className:t("group flex items-center justify-between gap-3",f),children:[s.jsx("label",{className:"type-label text-fg-muted truncate",children:a}),g?s.jsxs("div",{className:t(ue,pe,xe,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20","min-w-[100px]"),children:[s.jsx("input",{ref:k,type:i,value:j,onChange:e=>v(e.target.value),onKeyDown:L,placeholder:c,min:m,max:x,step:p,maxLength:h,disabled:"loading"===N,className:t("bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0",o?"w-12 text-right":"w-full")}),o&&s.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:o}),s.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:"loading"===N?s.jsx(S,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:I,className:"p-0.5 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:s.jsx(_,{className:"w-3 h-3"})}),s.jsx("button",{onClick:D,className:"p-0.5 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:s.jsx(F,{className:"w-3 h-3"})})]})})]}):s.jsxs("div",{className:t(ue,pe,xe,"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?R:void 0,children:[s.jsx("span",{className:"type-data text-fg-primary",children:l}),"success"===N&&s.jsx(_,{className:"w-3 h-3 text-sys-green ml-1.5 shrink-0"}),"error"===N&&s.jsx(F,{className:"w-3 h-3 text-sys-red ml-1.5 shrink-0"}),"idle"===N&&P&&s.jsx(T,{className:"w-3 h-3 text-fg-muted ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]}):s.jsxs("div",{className:t("group",f),children:[s.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),g?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:t(de,pe,me,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20"),children:[s.jsx("input",{ref:k,type:i,value:j,onChange:e=>v(e.target.value),onKeyDown:L,placeholder:c,min:m,max:x,step:p,maxLength:h,disabled:"loading"===N,className:"w-full bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0"}),o&&s.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:o}),s.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:"loading"===N?s.jsx(S,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:I,className:"p-1 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:s.jsx(_,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:D,className:"p-1 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:s.jsx(F,{className:"w-3.5 h-3.5"})})]})})]}),y&&s.jsx("p",{className:"type-data-xs text-fg-muted mt-1 ml-3",children:y})]}):s.jsxs("div",{className:t(de,pe,me,"flex items-center transition-all","bg-input-bg border border-input-border",P&&"cursor-pointer hover:border-edge-strong"),onClick:P?R:void 0,children:[s.jsx("span",{className:"type-data text-fg-primary flex-1 whitespace-nowrap",children:l}),"success"===N&&s.jsx(_,{className:"w-3.5 h-3.5 text-sys-green shrink-0"}),"error"===N&&s.jsx(F,{className:"w-3.5 h-3.5 text-sys-red shrink-0"}),"idle"===N&&P&&s.jsx(T,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]})}function ye({label:a,value:l,editValue:n,options:r,onSave:i,readOnly:o=!1,layout:c="stacked",className:d}){const[u,m]=e.useState(!1),[x,p]=e.useState(""),[h,y]=e.useState("idle"),f=e.useRef(null),g=e.useRef(!0),b=e.useRef(null),j=!o&&!!i;e.useEffect(()=>(g.current=!0,()=>{g.current=!1,b.current&&clearTimeout(b.current)}),[]);const v=e.useCallback(()=>{j&&(p(String(n)),m(!0),y("idle"),requestAnimationFrame(()=>{var e;return null==(e=f.current)?void 0:e.focus()}))},[j,n]),N=e.useCallback(()=>{m(!1),p(""),y("idle")},[]),w=e.useCallback(async()=>{if(i&&"loading"!==h)if(x!==String(n)){b.current&&clearTimeout(b.current),y("loading");try{if(await i(x),!g.current)return;y("success"),m(!1),b.current=setTimeout(()=>{g.current&&y("idle")},ce)}catch{if(!g.current)return;y("error"),b.current=setTimeout(()=>{g.current&&y("idle")},ce)}}else N()},[i,x,n,N,h]),k=e.useCallback(e=>{"Escape"===e.key&&(e.preventDefault(),N())},[N]),C="inline"===c,T=C?ue:de,P=C?xe:me,R=s.jsxs("div",{className:t(T,pe,P,"flex items-center transition-all relative","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20",C&&"min-w-[100px]"),children:[s.jsx("select",{ref:f,value:x,onChange:e=>p(e.target.value),onKeyDown:k,disabled:"loading"===h,className:t("bg-transparent text-fg-primary focus:outline-none appearance-none cursor-pointer type-data flex-1 min-w-0","pr-6"),children:r.map(e=>s.jsx("option",{value:e.value,children:e.label},String(e.value)))}),s.jsx(E,{className:"absolute right-auto w-3.5 h-3.5 text-fg-muted pointer-events-none",style:{right:"loading"===h?"2rem":"3.5rem"}}),s.jsx("div",{className:"flex items-center gap-0.5 ml-1 shrink-0",children:"loading"===h?s.jsx(S,{className:t("text-fg-muted animate-spin",C?"w-3 h-3":"w-3.5 h-3.5")}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:w,className:t("rounded hover:bg-sys-green/15 text-sys-green transition-colors",C?"p-0.5":"p-1"),title:"Save",children:s.jsx(_,{className:C?"w-3 h-3":"w-3.5 h-3.5"})}),s.jsx("button",{onClick:N,className:t("rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",C?"p-0.5":"p-1"),title:"Cancel (Esc)",children:s.jsx(F,{className:C?"w-3 h-3":"w-3.5 h-3.5"})})]})})]}),D=s.jsxs("div",{className:t(T,pe,P,"flex items-center transition-all","bg-input-bg border border-input-border",j&&"cursor-pointer hover:border-edge-strong",C?"justify-end min-w-[80px]":""),onClick:j?v:void 0,children:[s.jsx("span",{className:t("type-data text-fg-primary",!C&&"flex-1"),children:l}),"success"===h&&s.jsx(_,{className:t("text-sys-green shrink-0",C?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),"error"===h&&s.jsx(F,{className:t("text-sys-red shrink-0",C?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),"idle"===h&&j&&s.jsx(E,{className:t("text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0",C?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")})]});return C?s.jsxs("div",{className:t("group flex items-center justify-between",d),children:[s.jsx("label",{className:"type-label text-fg-muted shrink-0",children:a}),u?R:D]}):s.jsxs("div",{className:t("group",d),children:[s.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),u?R:D]})}async function fe(e){return a("/api/update_web_config",{method:"POST",body:JSON.stringify(e)})}e.memo(function(){const{theme:e}=l(),{themeId:t}=e,a=n.find(e=>e.meta.id===t)??n[0];return s.jsx("div",{className:"h-10 flex items-center justify-center",children:s.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:a.meta.name})})});const ge=e.memo(function({compact:e=!1}){const{theme:a,setTheme:r}=l(),{themeId:i}=a;return s.jsx("div",{className:t("grid grid-cols-2 gap-2",e?"w-full min-w-0 self-stretch":"w-full"),children:[...n].reverse().map(a=>{const l=i===a.meta.id,n=a.meta.isDark;return s.jsxs("button",{type:"button",title:a.meta.name,className:t("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",e&&"h-6",l?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>r(a.meta.id),children:[s.jsx("div",{className:t("flex-1 h-full",n?"bg-[#18181b]":"bg-[#EFF0F1]")}),s.jsx("div",{className:"flex flex-col h-full",children:a.display.palette.map((e,t)=>s.jsx("div",{className:"flex flex-1",children:e.map((e,t)=>s.jsx("div",{className:"w-2 h-full",style:{backgroundColor:e}},t))},t))})]},a.meta.id)})})});let be=!1,je=null;const ve=e.memo(function(){const{theme:t,setTheme:a}=l(),{themeId:n}=t,i="breeze dark"===n,o=e.useCallback(e=>{a(e?"breeze dark":"breeze light")},[a]);return s.jsx(r,{enabled:i,onChange:o,label:s.jsxs(s.Fragment,{children:["Dark Mode: ",i?s.jsx(P,{className:"w-3.5 h-3.5 text-sys-blue inline"}):s.jsx(R,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),Ne=e.memo(function({layout:t="horizontal"}){return e.useEffect(()=>{!async function(){be||je||(je=(async()=>{try{await Promise.all([C(()=>import("./vendor-fonts-CRZaZSFf.js").then(e=>e.l),__vite__mapDeps([0,1])),C(()=>import("./vendor-fonts-CRZaZSFf.js").then(e=>e.a),__vite__mapDeps([0,1])),C(()=>import("./vendor-fonts-CRZaZSFf.js").then(e=>e.b),__vite__mapDeps([0,1])),C(()=>import("./vendor-fonts-CRZaZSFf.js").then(e=>e.c),__vite__mapDeps([0,1]))]),be=!0}catch(e){console.warn("Failed to load theme fonts:",e)}})())}()},[]),"toggle-only"===t?s.jsx(ve,{}):"thumbnails-only"===t?s.jsx(ge,{}):"vertical"===t?s.jsxs("div",{className:"flex flex-col items-start gap-3",children:[s.jsx(ve,{}),s.jsx(ge,{})]}):s.jsxs("div",{className:"flex items-stretch gap-4",children:[s.jsx("div",{className:"flex-shrink-0 flex items-start",children:s.jsx(ve,{})}),s.jsx(ge,{compact:!0})]})}),we=2e3;function ke(s,t,a){const[l,n]=e.useState("idle"),[r,i]=e.useState(null),o=e.useRef(!0),c=e.useRef(null),d=e.useRef(null),u=e.useRef(!1),m=e.useRef("idle"),x=e.useRef(s),p=e.useRef(t),h=e.useRef(a);return m.current=l,x.current=s,p.current=t,h.current=a,e.useEffect(()=>(o.current=!0,()=>{o.current=!1,c.current&&clearTimeout(c.current),d.current&&clearTimeout(d.current)}),[]),{enabled:null!==r?r:s,status:l,toggle:e.useCallback(async e=>{if("loading"===m.current)return;const s=x.current;c.current&&clearTimeout(c.current),d.current&&clearTimeout(d.current),u.current=!1,i(e),n("loading"),c.current=setTimeout(()=>{!u.current&&o.current&&(i(s),n("error"),d.current=setTimeout(()=>{o.current&&(n("idle"),i(null))},we))},1e4);try{if(await p.current(e),u.current=!0,c.current&&clearTimeout(c.current),!o.current)return;n("success"),d.current=setTimeout(()=>{var e;o.current&&(n("idle"),i(null),null==(e=h.current)||e.call(h))},we)}catch{if(u.current=!0,c.current&&clearTimeout(c.current),!o.current)return;i(s),n("error"),d.current=setTimeout(()=>{o.current&&(n("idle"),i(null))},we)}},[])}}function Ce(){const{latitude:a,longitude:l,enabled:n,setLocation:r,enable:c,disable:d,clear:u}=i(),[m,x]=e.useState(!1),[p,h]=e.useState(""),[y,f]=e.useState(""),[g,b]=e.useState("idle"),[j,v]=e.useState(null),N=e.useRef(null),w=e.useRef(null),k=e.useRef(!0);e.useEffect(()=>(k.current=!0,()=>{k.current=!1,w.current&&clearTimeout(w.current)}),[]);const C=()=>{x(!1),v(null)};e.useEffect(()=>{if(!m)return;const e=e=>{"loading"!==g&&N.current&&!N.current.contains(e.target)&&C()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[m,g]);const E=null!==a&&null!==l;return s.jsx(ae,{children:s.jsxs("div",{ref:N,children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx(o,{icon:s.jsx(D,{}),title:"Stealth"}),s.jsxs("div",{className:"flex items-center gap-1",children:[E&&!m&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{n?d():c()},className:t("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",n?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),title:n?"Disable stealth location":"Enable stealth location",children:s.jsx("span",{className:t("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",n?"translate-x-5":"translate-x-0.5")})}),s.jsx("button",{onClick:()=>{u(),x(!1)},className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-sys-red hover:bg-sys-red/10",title:"Clear stealth location",children:s.jsx(I,{className:"w-4 h-4"})})]}),m?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:C,disabled:"loading"===g,className:t("p-2 rounded-lg transition-colors","loading"===g?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:s.jsx(F,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{if("loading"===g)return;w.current&&clearTimeout(w.current);const e=((e,s)=>{const t=parseFloat(e),a=parseFloat(s);return isNaN(t)||isNaN(a)?"Please enter valid numbers":t<-90||t>90?"Latitude must be between -90 and 90":a<-180||a>180?"Longitude must be between -180 and 180":0===t&&0===a?"Coordinates (0, 0) are invalid":null})(p,y);if(e)return void v(e);b("loading"),v(null);const s=parseFloat(p),t=parseFloat(y);r(s,t),n||c(),b("success"),w.current=setTimeout(()=>{k.current&&(b("idle"),x(!1))},1e3)},disabled:"loading"===g,className:t("p-2 rounded-lg transition-colors","loading"===g?"text-sys-blue cursor-wait":"success"===g?"text-sys-green":"error"===g?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:"loading"===g?s.jsx(S,{className:"w-4 h-4 animate-spin"}):"success"===g?s.jsx(_,{className:"w-4 h-4"}):"error"===g?s.jsx(F,{className:"w-4 h-4"}):s.jsx(_,{className:"w-4 h-4"})})]}):s.jsx("button",{onClick:()=>{h((null==a?void 0:a.toFixed(6))??""),f((null==l?void 0:l.toFixed(6))??""),v(null),x(!0)},className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:E?"Edit stealth location":"Set stealth location",children:s.jsx(T,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"bg-sys-cyan/5 rounded-xl p-3 mb-4",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(L,{className:"w-4 h-4 text-sys-cyan flex-shrink-0 mt-0.5"}),s.jsxs("p",{className:"type-body-sm text-fg-muted",children:[s.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 — ",s.jsx("span",{className:"text-sys-cyan",children:"never sent to config.yaml or the mesh"}),"."]})]})}),j&&s.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:j}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"type-label text-fg-muted block mb-1",children:m?"Latitude (°)":"Latitude"}),s.jsx("div",{className:t("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:m?s.jsx("input",{type:"number",value:p,onChange:e=>h(e.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"}):s.jsx("span",{className:t("type-data",E&&n?"text-fg-primary":"text-fg-muted"),children:E?a.toFixed(6):"Not set"})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"type-label text-fg-muted block mb-1",children:m?"Longitude (°)":"Longitude"}),s.jsx("div",{className:t("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:m?s.jsx("input",{type:"number",value:y,onChange:e=>f(e.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"}):s.jsx("span",{className:t("type-data",E&&n?"text-fg-primary":"text-fg-muted"),children:E?l.toFixed(6):"Not set"})})]})]}),E&&!m&&s.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:t("w-2 h-2 rounded-full",n?"bg-sys-green":"bg-fg-muted")}),s.jsx("span",{className:"type-body-sm text-fg-muted",children:n?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}const Se=[{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"}],_e=[5,6,7,8,9,10,11,12],Fe=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],Te="radioConfig";function Ee(e){if(!e)return"Never";const s=Date.now()-1e3*e,t=Math.floor(s/6e4),a=Math.floor(s/36e5),l=Math.floor(s/864e5);return t<1?"Just now":t<60?`${t}m ago`:a<24?`${a}h ago`:l<365?`${l}d ago`:`${Math.floor(l/365)}y ago`}function Pe({node:e,level:a,expandedKeys:l,selectedKeyId:n,globalFloodPolicy:r,onSelect:i,onToggle:o}){const c=l.has(e.id),d=n===e.id,u=e.children&&e.children.length>0,m="allow"===r;return s.jsxs("div",{children:[s.jsxs("div",{className:t("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",d?"bg-sys-blue/15":"hover:bg-subtle-fill",m&&"opacity-50 cursor-not-allowed"),style:{marginLeft:16*a+"px"},onClick:()=>!m&&i(e.id),children:[u?s.jsx("button",{onClick:s=>{s.stopPropagation(),o(e.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:s.jsx(W,{className:t("w-3.5 h-3.5 text-fg-muted transition-transform",c&&"rotate-90")})}):s.jsx("span",{className:"w-5"}),s.jsx(J,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),s.jsx("span",{className:"type-data text-fg-primary flex-1 truncate",children:e.name}),s.jsx("span",{className:"type-data-xs text-fg-muted hidden sm:inline",title:e.last_used?new Date(1e3*e.last_used).toLocaleString():void 0,children:Ee(e.last_used)}),s.jsx("span",{className:t("type-data-xs px-2 py-0.5 rounded-full","allow"===e.floodPolicy?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:"allow"===e.floodPolicy?"Allow":"Deny"})]}),u&&c&&s.jsx("div",{children:e.children.map(e=>s.jsx(Pe,{node:e,level:a+1,expandedKeys:l,selectedKeyId:n,globalFloodPolicy:r,onSelect:i,onToggle:o},e.id))})]})}function Re(){const[a,l]=e.useState(Q),[n,i]=e.useState(Z),[o,c]=e.useState(!1),d=e.useCallback(e=>{l(e),ee(e)},[]),u=e.useCallback(e=>{const s=parseFloat(e.target.value);i(s),se(s)},[]),m=e.useCallback(async()=>{o||(c(!0),await te(),c(!1))},[o]);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(r,{enabled:a,onChange:d,label:s.jsxs(s.Fragment,{children:["Sound: ",s.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"}),s.jsx(x,{color:"primary",outline:!0,onClick:m,disabled:!a||o,className:"w-16 justify-center",children:o?"…":"Test"})]}),s.jsxs("div",{className:t("flex items-center gap-3",!a&&"opacity-40 pointer-events-none"),children:[s.jsx("span",{className:"type-label text-fg-muted w-14 shrink-0",children:"Volume"}),s.jsx("input",{type:"range",min:0,max:1,step:.05,value:n,onChange:u,className:"flex-1 accent-sys-blue h-1.5 cursor-pointer"}),s.jsxs("span",{className:"data-box w-16 justify-center",children:[Math.round(100*n),"%"]})]})]})}function De(){var l,n,i,C,F,T;const{stats:E,setMode:P,clearModeMutation:R,setDutyCycleConfig:D,clearDutyCycleMutation:W,fetchStats:J,startMutation:Q,clearMutation:Z}=c(),ee=null==(l=null==E?void 0:E.config)?void 0:l.radio,se=null==(n=null==E?void 0:E.config)?void 0:n.repeater,te=null==(i=null==E?void 0:E.config)?void 0:i.duty_cycle,ce=(null==E?void 0:E.node_name)||(null==(C=null==E?void 0:E.config)?void 0:C.node_name)||"Unknown Node",de=(null==se?void 0:se.mode)??"forward",ue=(null==te?void 0:te.enforcement_enabled)??!1,me=null==(F=null==E?void 0:E.config)?void 0:F.delays,xe=e.useRef(!0);e.useEffect(()=>(xe.current=!0,()=>{xe.current=!1}),[]);const pe=null==(T=null==E?void 0:E.config)?void 0:T.web,[ge,be]=e.useState([]),[je,ve]=e.useState(!1),[we,Ee]=e.useState(null),[De,Ie]=e.useState(!1),[Le,Ae]=e.useState(""),[ze,Me]=e.useState(null),[Ke,Ve]=e.useState(!1),[Oe,$e]=e.useState(null),[He,qe]=e.useState(!1),[Be,Ue]=e.useState(!1),[Xe,Ge]=e.useState(!1),[We,Je]=e.useState([]),[Ye,Qe]=e.useState(!1),[Ze,es]=e.useState(null),[ss,ts]=e.useState(()=>"allow"===localStorage.getItem("pymc:globalFloodPolicy")?"allow":"deny"),as=e.useCallback(e=>{ts(e),localStorage.setItem("pymc:globalFloodPolicy",e)},[]),[ls,ns]=e.useState(!1),[rs,is]=e.useState(null),[os,cs]=e.useState(new Set),[ds,us]=e.useState(!1),[ms,xs]=e.useState(!1),[ps,hs]=e.useState(!1),[ys,fs]=e.useState(null),[gs,bs]=e.useState(null),[js,vs]=e.useState(""),[Ns,ws]=e.useState("allow"),[ks,Cs]=e.useState(!1),[Ss,_s]=e.useState(!0),[Fs,Ts]=e.useState(!1),[Es,Ps]=e.useState(!0),[Rs,Ds]=e.useState("idle"),[Is,Ls]=e.useState(!1),[As,zs]=e.useState(!1),Ms=e.useCallback(()=>{const e=null==me?void 0:me.tx_delay_factor;return e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??1:"number"==typeof e?e:1},[me]),Ks=e.useCallback(()=>{const e=null==me?void 0:me.direct_tx_delay_factor;return"number"==typeof e?e:.5},[me]),Vs=e.useCallback(()=>{const e=null==te?void 0:te.max_airtime_percent;return"number"==typeof e?e:e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??6:6},[te]),Os=ke("forward"===de,async e=>{await P(e?"forward":"monitor")},R),$s=ke(ue,async e=>{await D({max_airtime_percent:Vs(),enforcement_enabled:e})},W),Hs=ke((null==pe?void 0:pe.cors_enabled)??!1,async e=>{var s;const t=await fe({web:{cors_enabled:e}});if(!t.success&&!(null==(s=t.data)?void 0:s.persisted))throw new Error("CORS update failed");await J()}),qs=e.useCallback(async e=>{Q(Te);try{const s=await d(e);if(!s.success)throw new Error(s.error||"Failed to save");await J({force:!0}).catch(()=>{})}finally{Z(Te)}},[Q,Z,J]);e.useEffect(()=>{(async()=>{Ps(!0);try{const e=await g();e.success&&e.data?Ts(e.data.exists):Ts(!1);const s=null==pe?void 0:pe.web_path;_s(!s||""===s)}catch{Ts(!1)}finally{Ps(!1)}})()},[null==pe?void 0:pe.web_path]);const Bs=async e=>{var s;if("loading"!==Rs){Ds("loading");try{const t=await fe({web:{web_path:e?null:"/opt/pymc_console/web/html"}});if(!xe.current)return;t.success||(null==(s=t.data)?void 0:s.persisted)?(_s(e),Ds("success"),Ls(!0),setTimeout(()=>{xe.current&&Ds("idle")},2e3)):(Ds("error"),setTimeout(()=>{xe.current&&Ds("idle")},2e3))}catch{if(!xe.current)return;Ds("error"),setTimeout(()=>{xe.current&&Ds("idle")},2e3)}}},Us=e.useCallback(async()=>{ve(!0),Ee(null);try{const e=await async function(){return a("/auth/tokens")}();be(e.tokens||[])}catch(e){Ee(e instanceof Error?e.message:"Failed to fetch tokens")}finally{ve(!1)}},[]);e.useEffect(()=>{Us()},[Us]);const Xs=async()=>{if(Le.trim()){qe(!0),Ee(null);try{const e=await async function(e){return a("/auth/tokens",{method:"POST",body:JSON.stringify({name:e})})}(Le.trim());Me(e.token||null),Ie(!1),Ve(!0),Ae(""),await Us()}catch(e){Ee(e instanceof Error?e.message:"Failed to create token")}finally{qe(!1)}}else Ee("Token name is required")},Gs=e=>e?new Date(1e3*e).toLocaleString():"Never",Ws=e.useCallback(e=>{const s=new Map,t=[];return e.forEach(e=>{const t={id:e.id,name:e.name,floodPolicy:e.flood_policy,transport_key:e.transport_key,last_used:e.last_used,parent_id:e.parent_id,children:[]};s.set(e.id,t)}),s.forEach(e=>{e.parent_id&&s.has(e.parent_id)?s.get(e.parent_id).children.push(e):t.push(e)}),t},[]),Js=e.useCallback(async()=>{Qe(!0),es(null);try{const e=await y();if(e.success&&e.data){const s=Ws(e.data);Je(s),is(e=>{if(null===e)return null;const t=s=>{for(const a of s){if(a.id===e)return!0;if(a.children&&t(a.children))return!0}return!1};return t(s)?e:null})}else es(e.error||"Failed to load transport keys")}catch(e){es(e instanceof Error?e.message:"Unknown error occurred")}finally{Qe(!1)}},[Ws]);e.useEffect(()=>{Js(),f().then(e=>{e.success&&e.data&&as(e.data.global_flood_allow?"allow":"deny")}).catch(()=>{})},[Js]);const Ys=e.useCallback((e,s)=>{for(const t of e){if(t.id===s)return t;if(t.children){const e=Ys(t.children,s);if(e)return e}}return null},[]),Qs=e.useCallback(()=>{if(!rs)return;const e=Ys(We,rs);return null==e?void 0:e.name},[rs,We,Ys]),Zs=e.useCallback(e=>{cs(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},[]),et=async()=>{if(js.trim()){Cs(!0),es(null);try{const e=await v({name:js.trim(),flood_policy:Ns,parent_id:rs??void 0});e.success?(await Js(),us(!1),vs(""),ws("allow")):es(e.error||"Failed to add transport key")}catch(e){es(e instanceof Error?e.message:"Failed to add transport key")}finally{Cs(!1)}}else es("Key name is required")},st=e.useCallback(()=>{if(!rs)return;const e=Ys(We,rs);e&&(fs({...e}),xs(!0))},[rs,We,Ys]);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&(ds&&(us(!1),vs(""),ws("allow")),ms&&(xs(!1),fs(null)),ps&&(hs(!1),bs(null)),De&&(Ie(!1),Ae("")),Ke&&(Ve(!1),Me(null)))};if(ds||ms||ps||De||Ke)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ds,ms,ps,De,Ke]);const tt=e.useCallback(()=>{if(!rs)return;const e=Ys(We,rs);e&&(bs(e),hs(!0))},[rs,We,Ys]);return s.jsxs(le,{children:[s.jsx(ne,{title:"Configuration",icon:s.jsx(A,{})}),s.jsxs(re,{children:[s.jsxs(ie,{template:"standard",children:[s.jsx(oe,{span:12,md:6,children:s.jsxs(ae,{neomorphic:!0,children:[s.jsx(o,{icon:s.jsx(z,{}),title:"Repeater Settings"}),se?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(he,{label:"Node Name",value:ce,onSave:async e=>qs({node_name:e}),placeholder:"Enter node name",maxLength:50})}),s.jsx(he,{label:"Latitude",value:0!==se.latitude?se.latitude.toFixed(6):"Not set",editValue:String(se.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async e=>qs({latitude:parseFloat(e)})}),s.jsx(he,{label:"Longitude",value:0!==se.longitude?se.longitude.toFixed(6):"Not set",editValue:String(se.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async e=>qs({longitude:parseFloat(e)})}),s.jsx(he,{label:"Advert Interval",value:se.send_advert_interval_hours>0?`${se.send_advert_interval_hours}h`:"Disabled",editValue:String(se.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async e=>qs({flood_advert_interval_hours:parseInt(e,10)})}),s.jsx(he,{label:"Score-based TX",value:se.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):s.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),s.jsx(oe,{span:12,md:6,children:s.jsxs(ae,{neomorphic:!0,children:[s.jsx(o,{icon:s.jsx(M,{}),title:"Radio Configuration"}),ee?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(he,{label:"Frequency",value:u(ee.frequency),editValue:(ee.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async e=>qs({frequency_mhz:parseFloat(e)})}),s.jsx(he,{label:"TX Power",value:`${ee.tx_power} dBm`,editValue:String(ee.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async e=>qs({tx_power:parseInt(e,10)})}),s.jsx(ye,{label:"Bandwidth",value:m(ee.bandwidth),editValue:ee.bandwidth/1e3,options:Se,onSave:async e=>qs({bandwidth_khz:parseFloat(e)})}),s.jsx(ye,{label:"Spreading Factor",value:`SF${ee.spreading_factor}`,editValue:ee.spreading_factor,options:_e.map(e=>({value:e,label:`SF${e}`})),onSave:async e=>qs({spreading_factor:parseInt(e,10)})}),s.jsx(ye,{label:"Coding Rate",value:`4/${ee.coding_rate}`,editValue:ee.coding_rate,options:Fe,onSave:async e=>qs({coding_rate:parseInt(e,10)})}),s.jsx(he,{label:"Preamble",value:`${ee.preamble_length} symbols`,readOnly:!0})]}):s.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),s.jsxs(ie,{template:"standard",children:[s.jsx(oe,{span:12,md:6,children:s.jsxs(ae,{neomorphic:!0,children:[s.jsx(o,{icon:s.jsx(K,{}),title:"Operating Mode"}),s.jsx("p",{className:"type-label text-fg-muted mb-3",children:"Control how the repeater handles packets"}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[s.jsxs("div",{className:"flex-1 space-y-4",children:[s.jsx(r,{enabled:Os.enabled,onChange:Os.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:Os.status,size:"md"}),s.jsx(r,{enabled:$s.enabled,onChange:$s.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:$s.status,size:"md"}),s.jsx(he,{label:"Max Airtime",layout:"inline",value:`${Vs().toFixed(1)}%`,editValue:String(Vs()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async e=>{await D({max_airtime_percent:parseFloat(e),enforcement_enabled:ue}),W()}})]}),s.jsx("div",{className:"hidden lg:block w-px bg-border-subtle"}),s.jsxs("div",{className:"flex-1 pt-4 lg:pt-0 border-t lg:border-t-0 border-edge-subtle",children:[s.jsx("label",{className:"type-label text-fg-muted block mb-3",children:"TX Delays"}),s.jsxs("div",{className:"space-y-3",children:[s.jsx(he,{label:"Flood",layout:"inline",value:`${Ms().toFixed(2)}x`,editValue:String(Ms()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async e=>qs({tx_delay_factor:parseFloat(e)})}),s.jsx(he,{label:"Direct",layout:"inline",value:`${Ks().toFixed(2)}s`,editValue:String(Ks()),type:"number",suffix:"s",step:.1,min:0,max:5,onSave:async e=>qs({direct_tx_delay_factor:parseFloat(e)})})]})]})]})]})}),s.jsx(oe,{span:12,md:6,children:s.jsxs(ae,{neomorphic:!0,children:[s.jsx(o,{icon:s.jsx(A,{}),title:"App Settings"}),s.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Appearance and web server options."}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(r,{enabled:Hs.enabled,onChange:Hs.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:Hs.status,size:"md"}),s.jsx("div",{children:s.jsx(Ne,{})}),s.jsx(Re,{})]})]})})]}),s.jsx(ie,{template:"auto",children:s.jsxs(ae,{neomorphic:!0,children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[s.jsx(o,{icon:s.jsx(V,{}),title:"Regions Transport Keys",subtitle:"Manage regional key hierarchy for flood control"}),s.jsxs("div",{className:"flex gap-2 flex-wrap",children:[s.jsxs(x,{color:"primary",outline:!0,onClick:()=>us(!0),disabled:"allow"===ss,children:[s.jsx(O,{"data-slot":"icon"}),"Add"]}),s.jsx(x,{color:"primary",outline:!0,onClick:st,disabled:!rs||"allow"===ss,children:"Edit"}),s.jsx(x,{color:"danger",outline:!0,onClick:tt,disabled:!rs||"allow"===ss,children:"Delete"})]})]}),s.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:s.jsx(r,{enabled:"deny"===ss,onChange:e=>(async e=>{ns(!0),es(null);try{const s=await j("allow"===e);s.success?as(e):es(s.error||"Failed to update global flood policy")}catch(s){es(s instanceof Error?s.message:"Failed to update global flood policy")}finally{ns(!1)}})(e?"deny":"allow"),label:s.jsxs(s.Fragment,{children:["Require Transport Keys: ",s.jsx("span",{className:"deny"===ss?"text-sys-green":"text-sys-red",children:"deny"===ss?"On":"Off"})]}),tooltip:"When enabled, only packets with matching transport keys are forwarded. When disabled, all packets flood freely.",status:ls?"loading":"idle",disabled:ls,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})}),Ze&&s.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:Ze}),s.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:Ye?s.jsxs("div",{className:"flex items-center justify-center py-6",children:[s.jsx(S,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),s.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading transport keys..."})]}):0===We.length?s.jsxs("div",{className:"text-center py-6",children:[s.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:s.jsx(V,{className:"w-6 h-6 text-fg-muted/50"})}),s.jsx("p",{className:"type-body text-fg-muted",children:"No transport keys found"}),s.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first transport key to get started"})]}):s.jsx("div",{className:"space-y-1",children:We.map(e=>s.jsx(Pe,{node:e,level:0,expandedKeys:os,selectedKeyId:rs,globalFloodPolicy:ss,onSelect:is,onToggle:Zs},e.id))})})]})}),s.jsx(ie,{template:"auto",children:s.jsxs(ae,{neomorphic:!0,children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[s.jsx(o,{icon:s.jsx($,{}),title:"API Tokens",subtitle:"Manage API tokens for machine-to-machine authentication"}),s.jsxs(x,{color:"primary",outline:!0,onClick:()=>Ie(!0),children:[s.jsx(O,{"data-slot":"icon"}),"Create Token"]})]}),s.jsx("div",{className:"bg-sys-cyan/5 radius-inner p-4 mb-4",children:s.jsxs("div",{className:"flex gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-cyan/20 flex items-center justify-center flex-shrink-0",children:s.jsx(L,{className:"w-4 h-4 text-sys-cyan"})}),s.jsxs("div",{className:"type-body-sm text-fg-muted",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-fg-secondary",children:"API tokens"})," are used for machine-to-machine authentication. Include the token in the ",s.jsx("code",{className:"type-code bg-sys-cyan/20 px-1.5 py-0.5 rounded-full text-sys-cyan",children:"X-API-Key"})," header when making API requests."]}),s.jsx("p",{className:"mt-1 text-fg-muted/70",children:"Tokens are only shown once at creation. Store them securely."})]})]})}),we&&s.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:we}),je&&0===ge.length?s.jsxs("div",{className:"flex items-center justify-center py-6",children:[s.jsx(S,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),s.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading tokens..."})]}):ge.length>0?s.jsx("div",{className:"space-y-2",children:ge.map(e=>s.jsx("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong radius-inner p-4 transition-base",children:s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-sys-blue/10 flex items-center justify-center flex-shrink-0",children:s.jsx($,{className:"w-5 h-5 text-sys-blue"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"type-body text-fg-primary font-medium truncate",children:e.name}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-0.5",children:[s.jsxs("span",{className:"type-data-sm text-fg-muted truncate",children:["Created: ",Gs(e.created_at)]}),s.jsxs("span",{className:"type-data-sm text-fg-muted truncate",children:["Last used: ",Gs(e.last_used)]})]})]})]}),s.jsxs(x,{color:"danger",outline:!0,onClick:()=>$e({id:e.id,name:e.name}),disabled:Be,children:[s.jsx(I,{"data-slot":"icon"}),"Revoke"]})]})},e.id))}):s.jsxs("div",{className:"bg-subtle-fill radius-inner p-6 text-center",children:[s.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:s.jsx($,{className:"w-7 h-7 text-fg-muted/50"})}),s.jsx("h3",{className:"type-body text-fg-primary font-medium mb-1",children:"No API Tokens"}),s.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Create a token to enable API access"}),s.jsx(x,{color:"primary",outline:!0,onClick:()=>Ie(!0),children:"Create Your First Token"})]})]})}),s.jsx(ie,{template:"auto",children:s.jsxs(ae,{neomorphic:!0,children:[s.jsx(o,{icon:s.jsx(H,{}),title:"Web Frontend",subtitle:"Choose which web interface to use",className:"mb-4"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("label",{className:t("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Ss?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30","loading"===Rs&&"opacity-50 pointer-events-none"),children:[s.jsx("input",{type:"radio",name:"frontend",checked:Ss,onChange:()=>Bs(!0),disabled:"loading"===Rs,className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"type-body text-fg-primary font-medium",children:"Default Frontend"}),s.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.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"})]}),s.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Built-in pyMC Repeater web interface"}),s.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),s.jsxs("label",{className:t("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Ss?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5","loading"===Rs&&"opacity-50 pointer-events-none"),children:[s.jsx("input",{type:"radio",name:"frontend",checked:!Ss,onChange:()=>Bs(!1),disabled:"loading"===Rs,className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"type-body text-fg-primary font-medium",children:"PyMC Console"}),s.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 ⚡"})]}),s.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),s.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!Es&&s.jsx("div",{className:t("bg-subtle-fill radius-card p-4",Fs?"border border-sys-green/20":"border border-sys-cyan/20"),children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:t("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",Fs?"bg-sys-green/20":"bg-sys-cyan/20"),children:Fs?s.jsx(q,{className:"w-4 h-4 text-sys-green"}):s.jsx(L,{className:"w-4 h-4 text-sys-cyan"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h4",{className:"type-body text-fg-primary font-medium",children:Fs?"PyMC Console has been detected":"PyMC Console Not Installed"}),Fs?s.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["PyMC Console is installed at ",s.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"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"type-body-sm text-fg-muted mt-1 mb-3",children:["PyMC Console must be installed at ",s.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."]}),s.jsxs(x,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[s.jsx(B,{"data-slot":"icon"}),"PyMC Console Install Instructions"]})]})]})]})}),Is&&s.jsx("div",{className:"bg-subtle-fill radius-card p-4 border border-sys-indigo/30",children:s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-indigo/20 flex items-center justify-center flex-shrink-0",children:s.jsx(U,{className:"w-4 h-4 text-sys-indigo"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h4",{className:"type-body text-fg-primary font-medium",children:"Service restart required"}),s.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),s.jsx(x,{color:"warning",outline:!0,onClick:async()=>{if(!As){zs(!0);try{await b(),Ls(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Ls(!1),setTimeout(()=>{window.location.reload()},3e3)}}},disabled:As,children:As?s.jsxs(s.Fragment,{children:[s.jsx(S,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(X,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),E&&s.jsx(ie,{template:"auto",children:s.jsx(Y,{nodeName:ce,repeaterVersion:E.version,coreVersion:E.core_version,localHash:E.local_hash,publicKey:E.public_key})}),E&&(0===(null==se?void 0:se.latitude)||!(null==se?void 0:se.latitude))&&(0===(null==se?void 0:se.longitude)||!(null==se?void 0:se.longitude))&&s.jsx(ie,{template:"auto",children:s.jsx(Ce,{})})]}),De&&s.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&Ie(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:s.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[s.jsx("h3",{id:"create-token-modal-title",className:"type-micro mb-4",children:"Create API Token"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(p,{label:"Token Name",type:"text",value:Le,onChange:e=>Ae(e.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",description:"Give your token a descriptive name to identify its purpose",onKeyDown:e=>"Enter"===e.key&&Xs(),autoFocus:!0}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx(x,{color:"muted",outline:!0,onClick:()=>{Ie(!1),Ae(""),Ee(null)},disabled:He,children:"Cancel"}),s.jsx(x,{color:"primary",onClick:Xs,disabled:He||!Le.trim(),children:He?s.jsxs(s.Fragment,{children:[s.jsx(S,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),Ke&&ze&&s.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&Ve(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:s.jsxs("div",{className:"surface-modal radius-card p-6 max-w-lg w-full",children:[s.jsx("h3",{id:"show-token-modal-title",className:"type-micro mb-4",children:"Token Created Successfully"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(U,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-fg-secondary",children:[s.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"type-label text-fg-primary block mb-1.5",children:"Your API Token"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(h,{value:ze,readOnly:!0,className:"flex-1 font-mono"}),s.jsxs(x,{color:"primary",outline:!0,onClick:()=>{ze&&(navigator.clipboard.writeText(ze),Ge(!0),setTimeout(()=>Ge(!1),2e3))},children:[Xe?s.jsx(_,{"data-slot":"icon",className:"text-sys-green"}):s.jsx(G,{"data-slot":"icon"}),Xe?"Copied!":"Copy"]})]})]}),s.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary mb-2",children:s.jsx("strong",{children:"Usage Example:"})}),s.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: ',ze.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),s.jsx("div",{className:"flex justify-end mt-6",children:s.jsx(x,{color:"primary",onClick:()=>{Ve(!1),Me(null)},children:"Done"})})]})]})}),s.jsx(k,{isOpen:!!Oe,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${null==Oe?void 0:Oe.name}'? This action cannot be undone.`,confirmLabel:Be?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:async()=>{if(Oe){Ue(!0),Ee(null);try{await async function(e){return a(`/auth/tokens/${e}`,{method:"DELETE"})}(Oe.id),await Us(),$e(null)}catch(e){Ee(e instanceof Error?e.message:"Failed to revoke token")}finally{Ue(!1)}}},onCancel:()=>$e(null)}),ds&&s.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&us(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:s.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[s.jsx("h3",{id:"add-key-modal-title",className:"type-micro mb-4",children:"Add Transport Key"}),s.jsxs("div",{className:"space-y-4",children:[rs&&s.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: ",s.jsx("strong",{className:"text-fg-primary",children:Qs()})]}),s.jsx(p,{label:"Key Name",type:"text",value:js,onChange:e=>vs(e.target.value),placeholder:"e.g., Region Name, Group Key",onKeyDown:e=>"Enter"===e.key&&et(),autoFocus:!0}),s.jsxs("div",{children:[s.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),s.jsxs("div",{className:"toggle-group w-full",children:[s.jsx("button",{onClick:()=>ws("deny"),className:t("toggle-group-item flex-1","deny"===Ns&&"active !text-sys-red"),children:"Deny"}),s.jsx("button",{onClick:()=>ws("allow"),className:t("toggle-group-item flex-1","allow"===Ns&&"active !text-sys-green"),children:"Allow"})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx(x,{color:"muted",outline:!0,onClick:()=>{us(!1),vs(""),ws("allow")},disabled:ks,children:"Cancel"}),s.jsx(x,{color:"primary",onClick:et,disabled:ks||!js.trim(),children:ks?s.jsxs(s.Fragment,{children:[s.jsx(S,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),ms&&ys&&s.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&xs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:s.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[s.jsx("h3",{id:"edit-key-modal-title",className:"type-micro mb-4",children:"Edit Transport Key"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(p,{label:"Key Name",type:"text",value:ys.name,onChange:e=>fs({...ys,name:e.target.value}),autoFocus:!0}),s.jsxs("div",{children:[s.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),s.jsxs("div",{className:"toggle-group w-full",children:[s.jsx("button",{onClick:()=>fs({...ys,floodPolicy:"deny"}),className:t("toggle-group-item flex-1","deny"===ys.floodPolicy&&"active !text-sys-red"),children:"Deny"}),s.jsx("button",{onClick:()=>fs({...ys,floodPolicy:"allow"}),className:t("toggle-group-item flex-1","allow"===ys.floodPolicy&&"active !text-sys-green"),children:"Allow"})]})]}),ys.transport_key&&s.jsxs("div",{children:[s.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Transport Key"}),s.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:ys.transport_key})]}),s.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[s.jsx(x,{color:"danger",outline:!0,onClick:()=>{xs(!1),bs(ys),hs(!0),fs(null)},disabled:ks,children:"Delete"}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(x,{color:"muted",outline:!0,onClick:()=>{xs(!1),fs(null)},disabled:ks,children:"Cancel"}),s.jsx(x,{color:"primary",onClick:async()=>{if(ys){Cs(!0),es(null);try{const e=await N(ys.id,{name:ys.name,flood_policy:ys.floodPolicy});e.success?(await Js(),xs(!1),fs(null)):es(e.error||"Failed to update transport key")}catch(e){es(e instanceof Error?e.message:"Failed to update transport key")}finally{Cs(!1)}}},disabled:ks||!ys.name.trim(),children:ks?s.jsxs(s.Fragment,{children:[s.jsx(S,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),ps&&gs&&s.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&hs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:s.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[s.jsx("h3",{id:"delete-key-modal-title",className:"type-micro mb-4",children:"Delete Transport Key"}),s.jsxs("p",{className:"text-fg-secondary mb-4",children:["Are you sure you want to delete ",s.jsxs("strong",{className:"text-fg-primary",children:["'",gs.name,"'"]}),"?"]}),gs.children&&gs.children.length>0&&s.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3 mb-4",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(U,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-fg-secondary",children:["This key has ",gs.children.length," child key(s). Deleting will also remove all children."]})]})}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(x,{color:"muted",outline:!0,onClick:()=>{hs(!1),bs(null)},disabled:ks,children:"Cancel"}),s.jsx(x,{color:"danger",onClick:async()=>{if(gs){Cs(!0),es(null);try{const e=await w(gs.id);e.success?(await Js(),hs(!1),bs(null),is(null)):es(e.error||"Failed to delete transport key")}catch(e){es(e instanceof Error?e.message:"Failed to delete transport key")}finally{Cs(!1)}}},disabled:ks,children:ks?s.jsxs(s.Fragment,{children:[s.jsx(S,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{De as default};