Files
pyMC_Repeater/repeater/web/html/assets/Configuration-CbWO2ZfV.js
T
2026-03-05 11:13:44 +00:00

3 lines
129 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/leaflet-src-BtisrQHC.js","assets/_commonjsHelpers-CqkleIqs.js"])))=>i.map(i=>d[i]);
import{a as G,M as re,c as N,r as m,D as te,b as r,g as F,e,t as c,F as K,w as S,v as V,h as Z,q as oe,k as U,L as W,p as o,P as he,s as J,E as de,S as me,x as pe,f as q,y as le,d as we,U as ie,j as D,l as ve,N as xe,V as be,T as _e,i as Y,W as se,o as ne,u as X,X as $e,Q as ee}from"./index-BxyNawLf.js";/* empty css */import{_ as Ce}from"./ConfirmDialog.vue_vue_type_script_setup_true_lang-LY1XakDe.js";import{g as Me,s as Ae}from"./preferences-DtwbSSgO.js";const Se={class:"space-y-4"},je={key:0,class:"bg-green-100 dark:bg-green-500/20 border border-green-500/50 rounded-lg p-3"},Te={class:"text-green-600 dark:text-green-400 text-sm"},Ne={key:1,class:"bg-red-100 dark:bg-red-500/20 border border-red-500/50 rounded-lg p-3"},Ee={class:"text-red-600 dark:text-red-400 text-sm"},Be={class:"flex justify-end gap-2"},Fe=["disabled"],Le=["disabled"],Pe={class:"bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3"},ze={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Ve={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},De={key:1,class:"flex items-center gap-2"},Ie={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Ue={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},He={key:1},Re=["value"],Ke={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},qe={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},We={key:1},Oe=["value"],Ge={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Qe={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Ye={key:1,class:"flex items-center gap-2"},Xe={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Je={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Ze={key:1},et={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1"},tt={class:"text-content-primary dark:text-content-primary font-mono text-sm"},ot={key:2,class:"bg-yellow-500/10 dark:bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-3"},rt=G({__name:"RadioSettings",setup(I){const _=re(),l=N(()=>_.stats?.config?.radio||{}),v=m(!1),k=m(!1),d=m(null),u=m(null),s=m(0),p=m(0),g=m(0),h=m(0),T=m(0),C=m(0),M=[{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"}];te(l,$=>{$&&!v.value&&(s.value=$.frequency?Number(($.frequency/1e6).toFixed(3)):0,p.value=$.spreading_factor??0,g.value=$.bandwidth?Number(($.bandwidth/1e3).toFixed(1)):0,h.value=$.tx_power??0,T.value=$.coding_rate??0,C.value=$.preamble_length??0)},{immediate:!0});const a=N(()=>{const $=l.value.frequency;return $?($/1e6).toFixed(3)+" MHz":"Not set"}),t=N(()=>{const $=l.value.bandwidth;return $?($/1e3).toFixed(1)+" kHz":"Not set"}),n=N(()=>{const $=l.value.tx_power;return $!==void 0?$+" dBm":"Not set"}),A=N(()=>{const $=l.value.coding_rate;return $?"4/"+$:"Not set"}),b=N(()=>{const $=l.value.preamble_length;return $?$+" symbols":"Not set"}),x=N(()=>l.value.spreading_factor??"Not set"),y=()=>{v.value=!0,d.value=null,u.value=null},P=()=>{v.value=!1,d.value=null;const $=l.value;s.value=$.frequency?Number(($.frequency/1e6).toFixed(3)):0,p.value=$.spreading_factor??0,g.value=$.bandwidth?Number(($.bandwidth/1e3).toFixed(1)):0,h.value=$.tx_power??0,T.value=$.coding_rate??0,C.value=$.preamble_length??0},O=async()=>{k.value=!0,d.value=null,u.value=null;try{const $={};s.value&&($.frequency=s.value*1e6),p.value&&($.spreading_factor=p.value),g.value&&($.bandwidth=g.value*1e3),h.value&&($.tx_power=h.value),T.value&&($.coding_rate=T.value);const z=(await W.post("/update_radio_config",$)).data;z.message||z.persisted?(u.value=z.message||"Settings saved successfully",v.value=!1,await _.fetchStats(),setTimeout(()=>{u.value=null},3e3)):z.error?d.value=z.error:d.value="Unknown response from server"}catch($){console.error("Failed to update radio settings:",$);const j=$;d.value=j.response?.data?.error||"Failed to update settings"}finally{k.value=!1}};return($,j)=>(o(),r("div",Se,[u.value?(o(),r("div",je,[e("p",Te,c(u.value),1)])):F("",!0),d.value?(o(),r("div",Ne,[e("p",Ee,c(d.value),1)])):F("",!0),e("div",Be,[v.value?(o(),r(K,{key:1},[e("button",{onClick:P,disabled:k.value,class:"px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,Fe),e("button",{onClick:O,disabled:k.value,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"},c(k.value?"Saving...":"Save Changes"),9,Le)],64)):(o(),r("button",{key:0,onClick:y,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm"}," Edit Settings "))]),e("div",Pe,[e("div",ze,[j[6]||(j[6]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Frequency",-1)),v.value?(o(),r("div",De,[S(e("input",{"onUpdate:modelValue":j[0]||(j[0]=z=>s.value=z),type:"number",step:"0.001",min:"100",max:"1000",class:"w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,s.value,void 0,{number:!0}]]),j[5]||(j[5]=e("span",{class:"text-content-muted dark:text-content-muted text-sm"},"MHz",-1))])):(o(),r("div",Ve,c(a.value),1))]),e("div",Ie,[j[7]||(j[7]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Spreading Factor",-1)),v.value?(o(),r("div",He,[S(e("select",{"onUpdate:modelValue":j[1]||(j[1]=z=>p.value=z),class:"px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},[(o(),r(K,null,Z([5,6,7,8,9,10,11,12],z=>e("option",{key:z,value:z},c(z),9,Re)),64))],512),[[oe,p.value,void 0,{number:!0}]])])):(o(),r("div",Ue,c(x.value),1))]),e("div",Ke,[j[8]||(j[8]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Bandwidth",-1)),v.value?(o(),r("div",We,[S(e("select",{"onUpdate:modelValue":j[2]||(j[2]=z=>g.value=z),class:"px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},[(o(),r(K,null,Z(M,z=>e("option",{key:z.value,value:z.value},c(z.label),9,Oe)),64))],512),[[oe,g.value,void 0,{number:!0}]])])):(o(),r("div",qe,c(t.value),1))]),e("div",Ge,[j[10]||(j[10]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"TX Power",-1)),v.value?(o(),r("div",Ye,[S(e("input",{"onUpdate:modelValue":j[3]||(j[3]=z=>h.value=z),type:"number",min:"2",max:"30",class:"w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,h.value,void 0,{number:!0}]]),j[9]||(j[9]=e("span",{class:"text-content-muted dark:text-content-muted text-sm"},"dBm",-1))])):(o(),r("div",Qe,c(n.value),1))]),e("div",Xe,[j[12]||(j[12]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Coding Rate",-1)),v.value?(o(),r("div",Ze,[S(e("select",{"onUpdate:modelValue":j[4]||(j[4]=z=>T.value=z),class:"px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},j[11]||(j[11]=[e("option",{value:5},"4/5",-1),e("option",{value:6},"4/6",-1),e("option",{value:7},"4/7",-1),e("option",{value:8},"4/8",-1)]),512),[[oe,T.value,void 0,{number:!0}]])])):(o(),r("div",Je,c(A.value),1))]),e("div",et,[j[13]||(j[13]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Preamble Length",-1)),e("span",tt,c(b.value),1)])]),v.value?(o(),r("div",ot,j[14]||(j[14]=[e("p",{class:"text-yellow-700 dark:text-yellow-400 text-xs"},[e("strong",null,"Note:"),U(" Radio hardware changes (frequency, bandwidth, spreading factor, coding rate) may require a service restart to apply. ")],-1)]))):F("",!0)]))}}),st={class:"glass-card border border-stroke-subtle dark:border-white/20 rounded-[15px] w-full max-w-3xl max-h-[90vh] flex flex-col shadow-2xl"},nt={class:"flex-1 relative min-h-[400px]"},at={class:"p-6 border-t border-stroke-subtle dark:border-stroke/10 space-y-4"},lt={class:"grid grid-cols-2 gap-4"},dt=G({__name:"LocationPicker",props:{isOpen:{type:Boolean},latitude:{},longitude:{}},emits:["close","select"],setup(I,{emit:_}){const l=I,v=_,k=m(null),d=m(l.latitude||0),u=m(l.longitude||0);let s=null,p=null;const g=async()=>{if(k.value){h();try{const a=(await me(async()=>{const{default:b}=await import("./leaflet-src-BtisrQHC.js").then(x=>x.l);return{default:b}},__vite__mapDeps([0,1]))).default;delete a.Icon.Default.prototype._getIconUrl,a.Icon.Default.mergeOptions({iconRetinaUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png",iconUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png",shadowUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png"}),await de();const t=d.value||0,n=u.value||0,A=t===0&&n===0?2:13;s=a.map(k.value).setView([t,n],A);try{const b=a.tileLayer("https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png",{maxZoom:19,attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>',errorTileUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="}),x=a.tileLayer("https://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}{r}.png",{maxZoom:19,attribution:"",errorTileUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="});b.addTo(s),x.addTo(s)}catch(b){console.warn("Error loading tiles:",b)}(t!==0||n!==0)&&(p=a.marker([t,n]).addTo(s)),s.on("click",b=>{d.value=b.latlng.lat,u.value=b.latlng.lng,p?p.setLatLng(b.latlng):p=a.marker(b.latlng).addTo(s)}),setTimeout(()=>{s?.invalidateSize()},200)}catch(a){console.error("Failed to initialize map:",a)}}},h=()=>{s&&(s.remove(),s=null,p=null)};te(()=>l.isOpen,async a=>{a?(await de(),await g()):h()}),te(()=>[l.latitude,l.longitude],([a,t])=>{d.value=a,u.value=t});const T=()=>{v("select",{latitude:d.value,longitude:u.value}),v("close")},C=()=>{v("close")},M=()=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(async a=>{if(d.value=a.coords.latitude,u.value=a.coords.longitude,s){s.setView([d.value,u.value],13);const t=(await me(async()=>{const{default:n}=await import("./leaflet-src-BtisrQHC.js").then(A=>A.l);return{default:n}},__vite__mapDeps([0,1]))).default;p?p.setLatLng([d.value,u.value]):p=t.marker([d.value,u.value]).addTo(s)}},a=>{console.error("Error getting location:",a),alert("Unable to get current location. Please check browser permissions.")}):alert("Geolocation is not supported by this browser.")};return he(()=>{h()}),(a,t)=>a.isOpen?(o(),r("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:J(C,["self"])},[e("div",st,[e("div",{class:"flex items-center justify-between p-6 border-b border-stroke-subtle dark:border-stroke/10"},[t[3]||(t[3]=e("h3",{class:"text-xl font-semibold text-content-primary dark:text-content-primary"},"Select Location",-1)),e("button",{onClick:C,class:"text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors"},t[2]||(t[2]=[e("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))]),e("div",nt,[e("div",{ref_key:"mapContainer",ref:k,class:"absolute inset-0 rounded-b-[15px] overflow-hidden"},null,512)]),e("div",at,[e("div",lt,[e("div",null,[t[4]||(t[4]=e("label",{class:"block text-sm font-medium text-content-secondary dark:text-content-muted mb-2"},"Latitude",-1)),S(e("input",{"onUpdate:modelValue":t[0]||(t[0]=n=>d.value=n),type:"number",step:"0.000001",class:"w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary focus:outline-none focus:border-primary",readonly:""},null,512),[[V,d.value,void 0,{number:!0}]])]),e("div",null,[t[5]||(t[5]=e("label",{class:"block text-sm font-medium text-content-secondary dark:text-content-muted mb-2"},"Longitude",-1)),S(e("input",{"onUpdate:modelValue":t[1]||(t[1]=n=>u.value=n),type:"number",step:"0.000001",class:"w-full px-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary focus:outline-none focus:border-primary",readonly:""},null,512),[[V,u.value,void 0,{number:!0}]])])]),e("div",{class:"flex gap-3"},[e("button",{onClick:M,class:"flex-1 px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm flex items-center justify-center gap-2"},t[6]||(t[6]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})],-1),U(" Use Current Location ",-1)])),e("button",{onClick:C,class:"px-6 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm"}," Cancel "),e("button",{onClick:T,class:"px-6 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm"}," Select Location ")]),t[7]||(t[7]=e("p",{class:"text-content-muted dark:text-content-muted text-xs text-center"},"Click on the map to select a location",-1))])])])):F("",!0)}}),it=pe(dt,[["__scopeId","data-v-186d3c86"]]),ct={class:"space-y-4"},ut={key:0,class:"bg-green-100 dark:bg-green-500/10 border border-green-300 dark:border-green-500/30 rounded-lg p-3"},mt={class:"text-green-700 dark:text-green-400 text-sm"},pt={key:1,class:"bg-red-100 dark:bg-red-500/10 border border-red-300 dark:border-red-500/30 rounded-lg p-3"},vt={class:"text-red-700 dark:text-red-400 text-sm"},xt={class:"flex justify-end gap-2"},bt=["disabled"],kt=["disabled"],gt={class:"bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3"},yt={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},ft={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm break-all"},ht={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},wt={class:"text-content-primary dark:text-content-primary font-mono text-xs break-all"},_t={class:"flex flex-col sm:flex-row sm:justify-between sm:items-start py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},$t={class:"text-content-primary dark:text-content-primary font-mono text-xs break-all sm:text-right sm:max-w-xs"},Ct={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Mt={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},At={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},St={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},jt={key:0,class:"flex justify-end"},Tt={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Nt={class:"text-content-primary dark:text-content-primary font-mono text-sm"},Et={class:"flex flex-col py-2 gap-2"},Bt={class:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-1"},Ft={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm sm:ml-4"},Lt={key:1,class:"flex items-center gap-2"},Pt=G({__name:"RepeaterSettings",setup(I){const _=re(),l=N(()=>_.stats?.config||{}),v=N(()=>l.value.repeater||{}),k=N(()=>_.stats),d=m(!1),u=m(!1),s=m(null),p=m(null),g=m(!1),h=m(""),T=m(0),C=m(0),M=m(0);te([l,v],()=>{d.value||(h.value=l.value.node_name||"",T.value=v.value.latitude||0,C.value=v.value.longitude||0,M.value=v.value.send_advert_interval_hours||0)},{immediate:!0});const a=N(()=>l.value.node_name||"Not set"),t=N(()=>k.value?.local_hash||"Not available"),n=N(()=>{const E=k.value?.public_key;return!E||E==="Not set"?"Not set":E}),A=N(()=>{const E=v.value.latitude;return E&&E!==0?E.toFixed(6):"Not set"}),b=N(()=>{const E=v.value.longitude;return E&&E!==0?E.toFixed(6):"Not set"}),x=N(()=>{const E=v.value.mode;return E?E.charAt(0).toUpperCase()+E.slice(1):"Not set"}),y=N(()=>{const E=v.value.send_advert_interval_hours;return E===void 0?"Not set":E===0?"Disabled":E+" hour"+(E!==1?"s":"")}),P=()=>{d.value=!0,s.value=null,p.value=null},O=()=>{d.value=!1,s.value=null,h.value=l.value.node_name||"",T.value=v.value.latitude||0,C.value=v.value.longitude||0,M.value=v.value.send_advert_interval_hours||0},$=async()=>{u.value=!0,s.value=null,p.value=null;try{const E={};h.value&&(E.node_name=h.value),E.latitude=T.value,E.longitude=C.value,E.flood_advert_interval_hours=M.value;const w=(await W.post("/update_radio_config",E)).data;w.message||w.persisted?(p.value=w.message||"Settings saved successfully",d.value=!1,await _.fetchStats(),setTimeout(()=>{p.value=null},3e3)):w.error?s.value=w.error:s.value="Unknown response from server"}catch(E){console.error("Failed to update repeater settings:",E);const B=E;s.value=B.response?.data?.error||"Failed to update settings"}finally{u.value=!1}},j=()=>{g.value=!0},z=E=>{T.value=E.latitude,C.value=E.longitude};return(E,B)=>(o(),r("div",ct,[p.value?(o(),r("div",ut,[e("p",mt,c(p.value),1)])):F("",!0),s.value?(o(),r("div",pt,[e("p",vt,c(s.value),1)])):F("",!0),e("div",xt,[d.value?(o(),r(K,{key:1},[e("button",{onClick:O,disabled:u.value,class:"px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,bt),e("button",{onClick:$,disabled:u.value,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"},c(u.value?"Saving...":"Save Changes"),9,kt)],64)):(o(),r("button",{key:0,onClick:P,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm"}," Edit Settings "))]),e("div",gt,[e("div",yt,[B[5]||(B[5]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Node Name",-1)),d.value?S((o(),r("input",{key:1,"onUpdate:modelValue":B[0]||(B[0]=w=>h.value=w),type:"text",maxlength:"50",class:"w-full sm:w-64 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary",placeholder:"Enter node name"},null,512)),[[V,h.value]]):(o(),r("div",ft,c(a.value),1))]),e("div",ht,[B[6]||(B[6]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Local Hash",-1)),e("span",wt,c(t.value),1)]),e("div",_t,[B[7]||(B[7]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm flex-shrink-0"},"Public Key",-1)),e("span",$t,c(n.value),1)]),e("div",Ct,[B[8]||(B[8]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Latitude",-1)),d.value?S((o(),r("input",{key:1,"onUpdate:modelValue":B[1]||(B[1]=w=>T.value=w),type:"number",step:"0.000001",min:"-90",max:"90",class:"w-full sm:w-48 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512)),[[V,T.value,void 0,{number:!0}]]):(o(),r("div",Mt,c(A.value),1))]),e("div",At,[B[9]||(B[9]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Longitude",-1)),d.value?S((o(),r("input",{key:1,"onUpdate:modelValue":B[2]||(B[2]=w=>C.value=w),type:"number",step:"0.000001",min:"-180",max:"180",class:"w-full sm:w-48 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512)),[[V,C.value,void 0,{number:!0}]]):(o(),r("div",St,c(b.value),1))]),d.value?(o(),r("div",jt,[e("button",{onClick:j,class:"px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm flex items-center gap-2",title:"Pick location on map"},B[10]||(B[10]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})],-1),U(" Pick Location on Map ",-1)]))])):F("",!0),e("div",Tt,[B[11]||(B[11]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Mode",-1)),e("span",Nt,c(x.value),1)]),e("div",Et,[e("div",Bt,[B[13]||(B[13]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Periodic Advertisement Interval",-1)),d.value?(o(),r("div",Lt,[S(e("input",{"onUpdate:modelValue":B[3]||(B[3]=w=>M.value=w),type:"number",min:"0",max:"48",class:"w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,M.value,void 0,{number:!0}]]),B[12]||(B[12]=e("span",{class:"text-content-muted dark:text-content-muted text-sm"},"hours",-1))])):(o(),r("div",Ft,c(y.value),1))]),B[14]||(B[14]=e("span",{class:"text-content-muted dark:text-content-muted text-xs"},"How often the repeater sends an advertisement packet (0 = disabled, 3-48 hours)",-1))])]),q(it,{"is-open":g.value,latitude:T.value,longitude:C.value,onClose:B[4]||(B[4]=w=>g.value=!1),onSelect:z},null,8,["is-open","latitude","longitude"])]))}}),zt={class:"space-y-4"},Vt={key:0,class:"bg-green-100 dark:bg-green-500/20 border border-green-500 dark:border-green-500/50 rounded-lg p-3 text-green-700 dark:text-green-400 text-sm"},Dt={key:1,class:"bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm"},It={class:"flex justify-end gap-2"},Ut=["disabled"],Ht=["disabled"],Rt={class:"bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3"},Kt={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},qt={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Wt={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1"},Ot={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Gt=G({__name:"DutyCycle",setup(I){const _=re(),l=N(()=>_.stats?.config?.duty_cycle||{}),v=N(()=>{const a=l.value.max_airtime_percent;return typeof a=="number"?a.toFixed(1)+"%":a&&typeof a=="object"&&"parsedValue"in a?(a.parsedValue||0).toFixed(1)+"%":"Not set"}),k=N(()=>l.value.enforcement_enabled?"Enabled":"Disabled"),d=m(!1),u=m(!1),s=m(""),p=m(""),g=m(0),h=m(!0),T=()=>{const a=l.value.max_airtime_percent;typeof a=="number"?g.value=a:a&&typeof a=="object"&&"parsedValue"in a?g.value=a.parsedValue||0:g.value=6,h.value=l.value.enforcement_enabled!==!1,d.value=!0,s.value="",p.value=""},C=()=>{d.value=!1,s.value="",p.value=""},M=async()=>{u.value=!0,p.value="",s.value="";try{const t=(await le.post("/api/update_duty_cycle_config",{max_airtime_percent:g.value,enforcement_enabled:h.value})).data;t.message||t.persisted?(s.value=t.message||"Settings saved successfully",d.value=!1,await _.fetchStats(),setTimeout(()=>{s.value=""},3e3)):p.value="Failed to save settings"}catch(a){console.error("Failed to save duty cycle settings:",a),p.value=a.response?.data?.error||"Failed to save settings"}finally{u.value=!1}};return(a,t)=>(o(),r("div",zt,[s.value?(o(),r("div",Vt,c(s.value),1)):F("",!0),p.value?(o(),r("div",Dt,c(p.value),1)):F("",!0),e("div",It,[d.value?(o(),r(K,{key:1},[e("button",{onClick:C,disabled:u.value,class:"px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,Ut),e("button",{onClick:M,disabled:u.value,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"},c(u.value?"Saving...":"Save Changes"),9,Ht)],64)):(o(),r("button",{key:0,onClick:T,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm"}," Edit Settings "))]),e("div",Rt,[e("div",Kt,[t[2]||(t[2]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Max Airtime %",-1)),d.value?S((o(),r("input",{key:1,"onUpdate:modelValue":t[0]||(t[0]=n=>g.value=n),type:"number",step:"0.1",min:"0.1",max:"100",class:"w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512)),[[V,g.value,void 0,{number:!0}]]):(o(),r("div",qt,c(v.value),1))]),e("div",Wt,[t[4]||(t[4]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Enforcement",-1)),d.value?S((o(),r("select",{key:1,"onUpdate:modelValue":t[1]||(t[1]=n=>h.value=n),class:"w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},t[3]||(t[3]=[e("option",{value:!0},"Enabled",-1),e("option",{value:!1},"Disabled",-1)]),512)),[[oe,h.value]]):(o(),r("div",Ot,c(k.value),1))])])]))}}),Qt={class:"space-y-4"},Yt={key:0,class:"bg-green-100 dark:bg-green-500/20 border border-green-500 dark:border-green-500/50 rounded-lg p-3 text-green-700 dark:text-green-400 text-sm"},Xt={key:1,class:"bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm"},Jt={class:"flex justify-end gap-2"},Zt=["disabled"],eo=["disabled"],to={class:"bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3"},oo={class:"flex flex-col py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-2"},ro={class:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-1"},so={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm sm:ml-4"},no={class:"flex flex-col py-2 gap-2"},ao={class:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-1"},lo={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm sm:ml-4"},io=G({__name:"TransmissionDelays",setup(I){const _=re(),l=N(()=>_.stats?.config?.delays||{}),v=N(()=>{const a=l.value.tx_delay_factor;if(a&&typeof a=="object"&&a!==null&&"parsedValue"in a){const t=a.parsedValue;if(typeof t=="number")return t.toFixed(2)+"x"}return"Not set"}),k=N(()=>{const a=l.value.direct_tx_delay_factor;return typeof a=="number"?a.toFixed(2)+"s":"Not set"}),d=m(!1),u=m(!1),s=m(""),p=m(""),g=m(0),h=m(0),T=()=>{const a=l.value.tx_delay_factor;a&&typeof a=="object"&&"parsedValue"in a?g.value=a.parsedValue||1:typeof a=="number"?g.value=a:g.value=1;const t=l.value.direct_tx_delay_factor;h.value=typeof t=="number"?t:.5,d.value=!0,s.value="",p.value=""},C=()=>{d.value=!1,s.value="",p.value=""},M=async()=>{u.value=!0,p.value="",s.value="";try{const t=(await le.post("/api/update_radio_config",{tx_delay_factor:g.value,direct_tx_delay_factor:h.value})).data;t.message||t.persisted?(s.value=t.message||"Settings saved successfully",d.value=!1,await _.fetchStats(),setTimeout(()=>{s.value=""},3e3)):p.value="Failed to save settings"}catch(a){console.error("Failed to save delay settings:",a),p.value=a.response?.data?.error||"Failed to save settings"}finally{u.value=!1}};return(a,t)=>(o(),r("div",Qt,[s.value?(o(),r("div",Yt,c(s.value),1)):F("",!0),p.value?(o(),r("div",Xt,c(p.value),1)):F("",!0),e("div",Jt,[d.value?(o(),r(K,{key:1},[e("button",{onClick:C,disabled:u.value,class:"px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,Zt),e("button",{onClick:M,disabled:u.value,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"},c(u.value?"Saving...":"Save Changes"),9,eo)],64)):(o(),r("button",{key:0,onClick:T,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm"}," Edit Settings "))]),e("div",to,[e("div",oo,[e("div",ro,[t[2]||(t[2]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Flood TX Delay Factor",-1)),d.value?S((o(),r("input",{key:1,"onUpdate:modelValue":t[0]||(t[0]=n=>g.value=n),type:"number",step:"0.1",min:"0",max:"5",class:"w-full sm:w-32 px-3 py-1.5 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512)),[[V,g.value,void 0,{number:!0}]]):(o(),r("div",so,c(v.value),1))]),t[3]||(t[3]=e("span",{class:"text-content-muted dark:text-content-muted text-xs"},"Multiplier for flood packet transmission delays (collision avoidance)",-1))]),e("div",no,[e("div",ao,[t[4]||(t[4]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Direct TX Delay Factor",-1)),d.value?S((o(),r("input",{key:1,"onUpdate:modelValue":t[1]||(t[1]=n=>h.value=n),type:"number",step:"0.1",min:"0",max:"5",class:"w-full sm:w-32 px-3 py-1.5 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512)),[[V,h.value,void 0,{number:!0}]]):(o(),r("div",lo,c(k.value),1))]),t[5]||(t[5]=e("span",{class:"text-content-muted dark:text-content-muted text-xs"},"Base delay for direct-routed packet transmission (seconds)",-1))])])]))}}),ke=we("treeState",()=>{const I=ie(new Set),_=ie({value:null}),l=s=>{I.add(s)},v=s=>{I.delete(s)};return{expandedNodes:I,selectedNodeId:_,addExpandedNode:l,removeExpandedNode:v,isNodeExpanded:s=>I.has(s),setSelectedNode:s=>{_.value=s},toggleExpanded:s=>{I.has(s)?v(s):l(s)}}}),co={class:"select-none"},uo={class:"flex-shrink-0"},mo={key:0,class:"w-3.5 h-3.5 sm:w-4 sm:h-4 text-secondary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},po={key:1,class:"w-3.5 h-3.5 sm:w-4 sm:h-4 text-accent-green",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},vo={key:0,class:"hidden sm:flex items-center gap-1 ml-2"},xo={class:"relative group"},bo=["title"],ko={key:0,class:"text-xs font-mono text-white/50 bg-white/5 px-1.5 py-0.5 rounded border border-white/10"},go={class:"flex justify-between items-start mb-4"},yo={class:"bg-black/20 border border-white/10 rounded-md p-4 mb-4"},fo={class:"text-sm font-mono text-white/80 break-all leading-relaxed"},ho={class:"flex items-center gap-1 sm:gap-2 ml-auto flex-shrink-0"},wo={key:0,class:"hidden sm:flex items-center gap-1"},_o=["title"],$o={key:1,class:"hidden sm:flex items-center gap-1"},Co={key:2,class:"hidden sm:inline-block px-2 py-1 bg-white/10 text-white/60 text-xs rounded-full ml-1"},Mo={key:0,class:"space-y-1"},Ao=G({__name:"TreeNode",props:{node:{},selectedNodeId:{},level:{},disabled:{type:Boolean}},emits:["select"],setup(I,{emit:_}){const l=I,v=_,k=ke(),d=m(!1),u=N({get:()=>k.isNodeExpanded(l.node.id),set:t=>{t?k.addExpandedNode(l.node.id):k.removeExpandedNode(l.node.id)}}),s=N(()=>l.node.children.length>0);function p(t){if(!t)return"Never";const A=new Date().getTime()-t.getTime(),b=Math.floor(A/(1e3*60)),x=Math.floor(A/(1e3*60*60)),y=Math.floor(A/(1e3*60*60*24)),P=Math.floor(y/365);return b<60?`${b}m ago`:x<24?`${x}h ago`:y<365?`${y}d ago`:`${P}y ago`}function g(t){return t?t.length<=16?t:`${t.slice(0,8)}...${t.slice(-8)}`:"No key"}function h(){if(s.value){const t=!u.value;u.value=t}}function T(){v("select",l.node.id)}function C(t){v("select",t)}function M(t){t.stopPropagation(),d.value=!d.value}function a(t){t.stopPropagation(),l.node.transport_key&&window.navigator?.clipboard&&window.navigator.clipboard.writeText(l.node.transport_key)}return(t,n)=>{const A=be("TreeNode",!0);return o(),r("div",co,[e("div",{class:D(["flex flex-wrap sm:flex-nowrap items-start sm:items-center gap-1 sm:gap-2 py-2 px-2 sm:px-3 rounded-lg cursor-pointer transition-all duration-200",l.disabled?"opacity-50 cursor-not-allowed":"hover:bg-white/5",t.selectedNodeId===t.node.id&&!l.disabled?"bg-primary/20 text-primary":"text-white/80 hover:text-white",`ml-${t.level*4}`]),onClick:n[3]||(n[3]=b=>!l.disabled&&T())},[e("div",{class:"flex-shrink-0 w-3 h-3 sm:w-4 sm:h-4 flex items-center justify-center",onClick:J(h,["stop"])},[s.value?(o(),r("svg",{key:0,class:D(["w-2.5 h-2.5 sm:w-3 sm:h-3 transition-transform duration-200",u.value?"rotate-90":"rotate-0"]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},n[4]||(n[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)]),2)):F("",!0)]),e("div",uo,[l.node.name.startsWith("#")?(o(),r("svg",mo,n[5]||(n[5]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"},null,-1)]))):(o(),r("svg",po,n[6]||(n[6]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"},null,-1)])))]),e("span",{class:D(["font-mono text-xs sm:text-sm transition-colors duration-200 break-all",t.selectedNodeId===t.node.id?"text-primary font-medium":""])},c(t.node.name),3),t.node.transport_key?(o(),r("div",vo,[e("div",xo,[e("button",{onClick:M,class:"p-1 rounded hover:bg-white/10 transition-colors",title:d.value?"Hide full key":"Show full key"},n[7]||(n[7]=[e("svg",{class:"w-3 h-3 text-white/60 hover:text-white/80",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})],-1)]),8,bo),d.value?F("",!0):(o(),r("span",ko,c(g(t.node.transport_key)),1)),d.value?(o(),r("div",{key:1,class:"fixed inset-0 z-[9998] flex items-center justify-center bg-black/70 backdrop-blur-md",onClick:n[2]||(n[2]=b=>d.value=!1)},[e("div",{class:"bg-black/20 border border-white/20 rounded-lg shadow-lg p-6 max-w-2xl w-full mx-4",onClick:n[1]||(n[1]=J(()=>{},["stop"]))},[e("div",go,[n[9]||(n[9]=e("h3",{class:"text-lg font-semibold text-white"},"Transport Key",-1)),e("button",{onClick:n[0]||(n[0]=b=>d.value=!1),class:"text-white/60 hover:text-white transition-colors"},n[8]||(n[8]=[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))]),e("div",yo,[e("div",fo,c(t.node.transport_key),1)]),e("div",{class:"flex justify-end"},[e("button",{onClick:a,class:"px-4 py-2 bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green rounded-lg transition-colors flex items-center gap-2",title:"Copy to clipboard"},n[10]||(n[10]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1),U(" Copy Key ",-1)]))])])])):F("",!0)])])):F("",!0),e("div",ho,[t.node.last_used?(o(),r("div",wo,[n[11]||(n[11]=e("svg",{class:"w-3 h-3 text-white/40",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),e("span",{class:"text-xs text-white/50",title:t.node.last_used.toLocaleString()},c(p(t.node.last_used)),9,_o)])):(o(),r("div",$o,n[12]||(n[12]=[e("svg",{class:"w-3 h-3 text-white/30",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),e("span",{class:"text-xs text-white/30 italic"},"Never",-1)]))),e("span",{class:D(["px-1.5 sm:px-2 py-0.5 text-[10px] sm:text-xs font-medium rounded-md transition-colors",t.node.floodPolicy==="allow"?"bg-accent-green/10 text-accent-green/90 border border-accent-green/20":"bg-accent-red/10 text-accent-red/90 border border-accent-red/20"])},c(t.node.floodPolicy==="allow"?"ALLOW":"DENY"),3),s.value?(o(),r("span",Co," > "+c(t.node.children.length),1)):F("",!0)])],2),q(_e,{"enter-active-class":"transition-all duration-300 ease-out","enter-from-class":"opacity-0 max-h-0 overflow-hidden","enter-to-class":"opacity-100 max-h-screen overflow-visible","leave-active-class":"transition-all duration-300 ease-in","leave-from-class":"opacity-100 max-h-screen overflow-visible","leave-to-class":"opacity-0 max-h-0 overflow-hidden"},{default:ve(()=>[u.value&&t.node.children.length>0?(o(),r("div",Mo,[(o(!0),r(K,null,Z(t.node.children,b=>(o(),xe(A,{key:b.id,node:b,"selected-node-id":t.selectedNodeId,level:t.level+1,disabled:l.disabled,onSelect:C},null,8,["node","selected-node-id","level","disabled"]))),128))])):F("",!0)]),_:1})])}}}),So=pe(Ao,[["__scopeId","data-v-59e9974c"]]),jo={class:"flex items-center justify-between mb-6"},To={class:"text-content-secondary dark:text-content-muted text-sm mt-1"},No={key:0},Eo={class:"text-primary font-mono"},Bo={key:1},Fo={for:"keyName",class:"block text-sm font-medium text-white mb-2"},Lo={class:"flex items-center gap-2"},Po={key:0,class:"w-4 h-4 text-secondary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},zo={key:1,class:"w-4 h-4 text-accent-green",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Vo={class:"bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4"},Do={class:"flex items-center gap-3 mb-2"},Io={class:"flex items-center gap-2"},Uo={key:0,class:"w-5 h-5 text-secondary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ho={key:1,class:"w-5 h-5 text-accent-green",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ro={class:"text-content-secondary dark:text-content-muted text-sm"},Ko={class:"grid grid-cols-2 gap-3"},qo={class:"relative cursor-pointer group"},Wo={class:"relative cursor-pointer group"},Oo={class:"flex gap-3 pt-4"},Go=["disabled"],Qo=G({__name:"AddKeyModal",props:{show:{type:Boolean},selectedNodeName:{},selectedNodeId:{}},emits:["close","add"],setup(I,{emit:_}){const l=I,v=_,k=m(""),d=m(""),u=m("allow"),s=N(()=>k.value.startsWith("#")),p=N(()=>({type:s.value?"Region":"Private Key",description:s.value?"Regional organizational key":"Individual assigned key"}));te(s,M=>{M?d.value="This will create a new region for organizing keys":d.value="This will create a new private key entry"},{immediate:!0});const g=N(()=>k.value.trim().length>0),h=()=>{g.value&&(v("add",{name:k.value.trim(),floodPolicy:u.value,parentId:l.selectedNodeId}),k.value="",d.value="",u.value="allow")},T=()=>{k.value="",d.value="",u.value="allow",v("close")},C=M=>{M.target===M.currentTarget&&T()};return(M,a)=>M.show?(o(),r("div",{key:0,onClick:C,class:"fixed inset-0 bg-black/40 backdrop-blur-lg z-[99999] flex items-center justify-center p-4",style:{"backdrop-filter":"blur(8px) saturate(180%)",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"}},[e("div",{class:"bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-md border border-stroke-subtle dark:border-white/10",onClick:a[3]||(a[3]=J(()=>{},["stop"]))},[e("div",jo,[e("div",null,[a[5]||(a[5]=e("h3",{class:"text-xl font-semibold text-content-primary dark:text-content-primary"},"Add New Entry",-1)),e("p",To,[l.selectedNodeName?(o(),r("span",No,[a[4]||(a[4]=U(" Add to: ",-1)),e("span",Eo,c(l.selectedNodeName),1)])):(o(),r("span",Bo," Add to root level (#uk) "))])]),e("button",{onClick:T,class:"text-white/60 hover:text-white transition-colors"},a[6]||(a[6]=[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))]),e("form",{onSubmit:J(h,["prevent"]),class:"space-y-4"},[e("div",null,[e("label",Fo,[e("div",Lo,[s.value?(o(),r("svg",Po,a[7]||(a[7]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"},null,-1)]))):(o(),r("svg",zo,a[8]||(a[8]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"},null,-1)]))),a[9]||(a[9]=U(" Region/Key Name ",-1))])]),S(e("input",{id:"keyName","onUpdate:modelValue":a[0]||(a[0]=t=>k.value=t),type:"text",placeholder:"Enter name (prefix with # for regions)",class:"w-full px-4 py-3 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors",autocomplete:"off"},null,512),[[V,k.value]])]),e("div",Vo,[e("div",Do,[e("div",Io,[s.value?(o(),r("svg",Uo,a[10]||(a[10]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"},null,-1)]))):(o(),r("svg",Ho,a[11]||(a[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1221 9z"},null,-1)]))),e("span",{class:D([s.value?"text-secondary":"text-accent-green","font-medium"])},c(p.value.type),3)]),e("div",{class:D(["flex-1 h-px",s.value?"bg-secondary/20":"bg-accent-green/20"])},null,2)]),e("p",Ro,c(p.value.description),1)]),e("div",null,[a[14]||(a[14]=e("label",{class:"block text-sm font-medium text-content-primary dark:text-content-primary mb-3"},[e("div",{class:"flex items-center gap-2"},[e("svg",{class:"w-4 h-4 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})]),U(" Flood Policy ")])],-1)),e("div",Ko,[e("label",qo,[S(e("input",{type:"radio","onUpdate:modelValue":a[1]||(a[1]=t=>u.value=t),value:"allow",class:"sr-only"},null,512),[[se,u.value]]),a[12]||(a[12]=Y('<div class="flex items-center gap-3 p-3 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg group-has-[:checked]:border-accent-green/50 group-has-[:checked]:bg-accent-green/10 transition-colors"><div class="flex items-center justify-center w-4 h-4 border-2 border-stroke dark:border-stroke/30 rounded-full group-has-[:checked]:border-accent-green group-has-[:checked]:bg-accent-green transition-all"><div class="w-2 h-2 rounded-full bg-white scale-0 group-has-[:checked]:scale-100 transition-transform"></div></div><div class="flex-1"><div class="flex items-center gap-2"><svg class="w-4 h-4 text-accent-green" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg><span class="font-medium text-accent-green text-sm">Allow</span></div><p class="text-content-secondary dark:text-content-muted text-xs mt-1">Permit flooding</p></div></div>',1))]),e("label",Wo,[S(e("input",{type:"radio","onUpdate:modelValue":a[2]||(a[2]=t=>u.value=t),value:"deny",class:"sr-only"},null,512),[[se,u.value]]),a[13]||(a[13]=Y('<div class="flex items-center gap-3 p-3 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg group-has-[:checked]:border-accent-red/50 group-has-[:checked]:bg-accent-red/10 transition-colors"><div class="flex items-center justify-center w-4 h-4 border-2 border-stroke dark:border-stroke/30 rounded-full group-has-[:checked]:border-accent-red group-has-[:checked]:bg-accent-red transition-all"><div class="w-2 h-2 rounded-full bg-white scale-0 group-has-[:checked]:scale-100 transition-transform"></div></div><div class="flex-1"><div class="flex items-center gap-2"><svg class="w-4 h-4 text-accent-red" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg><span class="font-medium text-accent-red text-sm">Deny</span></div><p class="text-content-secondary dark:text-content-muted text-xs mt-1">Block flooding</p></div></div>',1))])])]),e("div",Oo,[e("button",{type:"button",onClick:T,class:"flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors"}," Cancel "),e("button",{type:"submit",disabled:!g.value,class:D(["flex-1 px-4 py-3 rounded-lg transition-colors font-medium",g.value?"bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green":"bg-background-mute dark:bg-stroke/5 border border-stroke-subtle dark:border-stroke/20 text-content-muted dark:text-content-muted cursor-not-allowed"])}," Add "+c(p.value.type),11,Go)])],32)])])):F("",!0)}}),Yo={class:"flex items-center justify-between mb-6"},Xo={class:"text-content-secondary dark:text-content-muted text-sm mt-1"},Jo={class:"text-primary font-mono"},Zo={for:"keyName",class:"block text-sm font-medium text-content-secondary dark:text-content-primary mb-2"},er={class:"flex items-center gap-2"},tr={key:0,class:"w-4 h-4 text-secondary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},or={key:1,class:"w-4 h-4 text-accent-green",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},rr={class:"bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4"},sr={class:"flex items-center gap-3 mb-2"},nr={class:"flex items-center gap-2"},ar={key:0,class:"w-5 h-5 text-secondary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},lr={key:1,class:"w-5 h-5 text-accent-green",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},dr={class:"text-content-secondary dark:text-content-muted text-sm"},ir={key:0,class:"space-y-4"},cr={key:0,class:"bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4"},ur={class:"bg-background-mute dark:bg-black/20 border border-stroke-subtle dark:border-stroke/10 rounded-md p-3"},mr={class:"text-xs font-mono text-content-primary dark:text-content-primary/80 break-all"},pr={key:1,class:"bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4"},vr={class:"flex items-center justify-between"},xr={class:"text-sm text-content-secondary dark:text-content-muted"},br={class:"text-xs text-content-muted dark:text-content-muted"},kr={class:"grid grid-cols-2 gap-3"},gr={class:"relative cursor-pointer group"},yr={class:"relative cursor-pointer group"},fr={class:"flex gap-3 pt-4"},hr=["disabled"],wr=G({__name:"EditKeyModal",props:{show:{type:Boolean},node:{}},emits:["close","save","request-delete"],setup(I,{emit:_}){const l=I,v=_,k=m(""),d=m("allow"),u=N(()=>k.value.startsWith("#")),s=N(()=>({type:u.value?"Region":"Private Key",description:u.value?"Regional organizational key":"Individual assigned key"}));te(()=>l.node,t=>{t?(k.value=t.name,d.value=t.floodPolicy):(k.value="",d.value="allow")},{immediate:!0});const p=N(()=>k.value.trim().length>0&&l.node),g=t=>{const A=new Date().getTime()-t.getTime(),b=Math.floor(A/(1e3*60)),x=Math.floor(A/(1e3*60*60)),y=Math.floor(A/(1e3*60*60*24)),P=Math.floor(y/365);return b<60?`${b}m ago`:x<24?`${x}h ago`:y<365?`${y}d ago`:`${P}y ago`},h=t=>{window.navigator?.clipboard&&window.navigator.clipboard.writeText(t)},T=()=>{!p.value||!l.node||(v("save",{id:l.node.id,name:k.value.trim(),floodPolicy:d.value}),M())},C=()=>{l.node&&(v("request-delete",l.node),M())},M=()=>{v("close")},a=t=>{t.target===t.currentTarget&&M()};return(t,n)=>t.show?(o(),r("div",{key:0,onClick:a,class:"fixed inset-0 bg-black/50 backdrop-blur-lg z-[99999] flex items-center justify-center p-4",style:{"backdrop-filter":"blur(8px) saturate(180%)",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"}},[e("div",{class:"bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-lg border border-stroke-subtle dark:border-white/10",onClick:n[4]||(n[4]=J(()=>{},["stop"]))},[e("div",Yo,[e("div",null,[n[6]||(n[6]=e("h3",{class:"text-xl font-semibold text-content-primary dark:text-content-primary"},"Edit Entry",-1)),e("p",Xo,[n[5]||(n[5]=U(" Modify ",-1)),e("span",Jo,c(t.node?.name),1)])]),e("button",{onClick:M,class:"text-white/60 hover:text-white transition-colors"},n[7]||(n[7]=[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))]),e("form",{onSubmit:J(T,["prevent"]),class:"space-y-4"},[e("div",null,[e("label",Zo,[e("div",er,[u.value?(o(),r("svg",tr,n[8]||(n[8]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"},null,-1)]))):(o(),r("svg",or,n[9]||(n[9]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1721 9z"},null,-1)]))),n[10]||(n[10]=U(" Region/Key Name ",-1))])]),S(e("input",{id:"keyName","onUpdate:modelValue":n[0]||(n[0]=A=>k.value=A),type:"text",placeholder:"Enter name (prefix with # for regions)",class:"w-full px-4 py-3 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors",autocomplete:"off"},null,512),[[V,k.value]])]),e("div",rr,[e("div",sr,[e("div",nr,[u.value?(o(),r("svg",ar,n[11]||(n[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"},null,-1)]))):(o(),r("svg",lr,n[12]||(n[12]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1721 9z"},null,-1)]))),e("span",{class:D([u.value?"text-secondary":"text-accent-green","font-medium"])},c(s.value.type),3)]),e("div",{class:D(["flex-1 h-px",u.value?"bg-secondary/20":"bg-accent-green/20"])},null,2)]),e("p",dr,c(s.value.description),1)]),t.node?(o(),r("div",ir,[t.node.transport_key?(o(),r("div",cr,[n[14]||(n[14]=Y('<div class="flex items-center gap-2 mb-3"><svg class="w-4 h-4 text-primary" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path></svg><span class="text-sm font-medium text-content-primary dark:text-content-primary">Transport Key</span></div>',1)),e("div",ur,[e("div",mr,c(t.node.transport_key),1),e("button",{onClick:n[1]||(n[1]=A=>h(t.node.transport_key||"")),class:"mt-2 text-xs text-accent-green hover:text-accent-green/80 flex items-center gap-1",title:"Copy to clipboard"},n[13]||(n[13]=[e("svg",{class:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1),U(" Copy Key ",-1)]))])])):F("",!0),t.node.last_used?(o(),r("div",pr,[n[15]||(n[15]=e("div",{class:"flex items-center gap-2 mb-3"},[e("svg",{class:"w-4 h-4 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})]),e("span",{class:"text-sm font-medium text-content-primary dark:text-content-primary"},"Last Used")],-1)),e("div",vr,[e("div",xr,c(t.node.last_used.toLocaleDateString())+" at "+c(t.node.last_used.toLocaleTimeString()),1),e("div",br,c(g(t.node.last_used)),1)])])):F("",!0)])):F("",!0),e("div",null,[n[18]||(n[18]=e("label",{class:"block text-sm font-medium text-content-secondary dark:text-content-primary mb-3"},[e("div",{class:"flex items-center gap-2"},[e("svg",{class:"w-4 h-4 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})]),U(" Flood Policy ")])],-1)),e("div",kr,[e("label",gr,[S(e("input",{type:"radio","onUpdate:modelValue":n[2]||(n[2]=A=>d.value=A),value:"allow",class:"sr-only"},null,512),[[se,d.value]]),n[16]||(n[16]=Y('<div class="flex items-center gap-3 p-3 bg-white/5 border border-white/20 rounded-lg group-has-[:checked]:border-accent-green/50 group-has-[:checked]:bg-accent-green/10 transition-colors"><div class="flex items-center justify-center w-4 h-4 border-2 border-white/30 rounded-full group-has-[:checked]:border-accent-green group-has-[:checked]:bg-accent-green transition-all"><div class="w-2 h-2 rounded-full bg-white scale-0 group-has-[:checked]:scale-100 transition-transform"></div></div><div class="flex-1"><div class="flex items-center gap-2"><svg class="w-4 h-4 text-accent-green" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg><span class="font-medium text-accent-green text-sm">Allow</span></div><p class="text-content-muted dark:text-content-muted text-xs mt-1">Permit flooding</p></div></div>',1))]),e("label",yr,[S(e("input",{type:"radio","onUpdate:modelValue":n[3]||(n[3]=A=>d.value=A),value:"deny",class:"sr-only"},null,512),[[se,d.value]]),n[17]||(n[17]=Y('<div class="flex items-center gap-3 p-3 bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg group-has-[:checked]:border-accent-red/50 group-has-[:checked]:bg-accent-red/10 transition-colors"><div class="flex items-center justify-center w-4 h-4 border-2 border-stroke dark:border-stroke/30 rounded-full group-has-[:checked]:border-accent-red group-has-[:checked]:bg-accent-red transition-all"><div class="w-2 h-2 rounded-full bg-white scale-0 group-has-[:checked]:scale-100 transition-transform"></div></div><div class="flex-1"><div class="flex items-center gap-2"><svg class="w-4 h-4 text-accent-red" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg><span class="font-medium text-accent-red text-sm">Deny</span></div><p class="text-content-muted dark:text-content-muted text-xs mt-1">Block flooding</p></div></div>',1))])])]),e("div",fr,[e("button",{type:"button",onClick:C,class:"px-4 py-3 bg-accent-red/20 hover:bg-accent-red/30 border border-accent-red/50 text-accent-red rounded-lg transition-colors"}," Delete "),e("button",{type:"button",onClick:M,class:"flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors"}," Cancel "),e("button",{type:"submit",disabled:!p.value,class:D(["flex-1 px-4 py-3 rounded-lg transition-colors font-medium",p.value?"bg-accent-green/20 hover:bg-accent-green/30 border border-accent-green/50 text-accent-green":"bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 text-content-muted dark:text-content-muted/70 cursor-not-allowed"])}," Save Changes ",10,hr)])],32)])])):F("",!0)}}),_r={class:"flex items-center gap-3 mb-6"},$r={class:"text-content-secondary dark:text-content-muted text-sm mt-1"},Cr={class:"text-accent-red font-mono"},Mr={key:0,class:"bg-accent-red/10 border border-accent-red/30 rounded-lg p-4 mb-6"},Ar={class:"flex items-start gap-3"},Sr={class:"flex-1"},jr={class:"text-accent-red font-medium text-sm mb-2"},Tr={class:"space-y-1 max-h-32 overflow-y-auto"},Nr={key:0,class:"w-3 h-3 text-secondary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Er={key:1,class:"w-3 h-3 text-accent-green",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Br={class:"font-mono"},Fr={key:0,class:"text-content-secondary dark:text-content-muted text-xs"},Lr={key:1,class:"mb-6"},Pr={class:"mb-3"},zr={class:"relative"},Vr={class:"space-y-2 max-h-40 overflow-y-auto border border-stroke-subtle dark:border-stroke/20 rounded-lg p-3 bg-gray-50 dark:bg-white/5"},Dr={key:0,class:"text-center py-4 text-content-secondary dark:text-content-muted text-sm"},Ir={class:"relative"},Ur=["value"],Hr={class:"flex items-center gap-2 flex-1"},Rr={class:"text-content-primary dark:text-content-primary font-mono text-sm"},Kr={key:0,class:"ml-auto px-2 py-0.5 bg-background-mute dark:bg-stroke/10 text-content-secondary dark:text-content-muted text-xs rounded-full"},qr={class:"flex gap-3"},Wr=G({__name:"DeleteConfirmModal",props:{show:{type:Boolean},node:{},allNodes:{}},emits:["close","delete-all","move-children"],setup(I,{emit:_}){const l=I,v=_,k=m(null),d=m(""),u=a=>{const t=[],n=A=>{for(const b of A.children)t.push(b),n(b)};return n(a),t},s=N(()=>l.node?u(l.node):[]),p=N(()=>{if(!l.node)return[];const a=new Set([l.node.id,...s.value.map(n=>n.id)]),t=n=>{const A=[];for(const b of n)b.name.startsWith("#")&&!a.has(b.id)&&A.push(b),b.children.length>0&&A.push(...t(b.children));return A};return t(l.allNodes)}),g=N(()=>{if(!d.value.trim())return p.value;const a=d.value.toLowerCase();return p.value.filter(t=>t.name.toLowerCase().includes(a))}),h=()=>{l.node&&(v("delete-all",l.node.id),C())},T=()=>{!l.node||!k.value||(v("move-children",{nodeId:l.node.id,targetParentId:k.value}),C())},C=()=>{k.value=null,d.value="",v("close")},M=a=>{a.target===a.currentTarget&&C()};return(a,t)=>a.show&&a.node?(o(),r("div",{key:0,onClick:M,class:"fixed inset-0 bg-black/80 backdrop-blur-lg z-[99999] flex items-center justify-center p-4",style:{"backdrop-filter":"blur(8px) saturate(180%)",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"}},[e("div",{class:"bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-lg border border-stroke-subtle dark:border-white/10",onClick:t[2]||(t[2]=J(()=>{},["stop"]))},[e("div",_r,[t[6]||(t[6]=e("svg",{class:"w-6 h-6 text-accent-red",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})],-1)),e("div",null,[t[4]||(t[4]=e("h3",{class:"text-xl font-semibold text-content-primary dark:text-content-primary"},"Confirm Deletion",-1)),e("p",$r,[t[3]||(t[3]=U(" Deleting ",-1)),e("span",Cr,c(a.node?.name),1)])]),e("button",{onClick:C,class:"ml-auto text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors"},t[5]||(t[5]=[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))]),s.value.length>0?(o(),r("div",Mr,[e("div",Ar,[t[9]||(t[9]=e("svg",{class:"w-5 h-5 text-accent-red flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),e("div",Sr,[e("h4",jr," This will affect "+c(s.value.length)+" child "+c(s.value.length===1?"entry":"entries")+": ",1),e("div",Tr,[(o(!0),r(K,null,Z(s.value.slice(0,10),n=>(o(),r("div",{key:n.id,class:"flex items-center gap-2 text-xs text-content-secondary dark:text-content-primary/80"},[n.name.startsWith("#")?(o(),r("svg",Nr,t[7]||(t[7]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"},null,-1)]))):(o(),r("svg",Er,t[8]||(t[8]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1721 9z"},null,-1)]))),e("span",Br,c(n.name),1),e("span",{class:D(["px-1 py-0.5 text-xs rounded",n.floodPolicy==="allow"?"bg-accent-green/20 text-accent-green":"bg-accent-red/20 text-accent-red"])},c(n.floodPolicy),3)]))),128)),s.value.length>10?(o(),r("div",Fr," ...and "+c(s.value.length-10)+" more ",1)):F("",!0)])])])])):F("",!0),s.value.length>0&&p.value.length>0?(o(),r("div",Lr,[t[13]||(t[13]=e("h4",{class:"text-content-primary dark:text-content-primary font-medium text-sm mb-3"},"Move children to another region:",-1)),e("div",Pr,[e("div",zr,[t[10]||(t[10]=e("svg",{class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-content-muted dark:text-content-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})],-1)),S(e("input",{"onUpdate:modelValue":t[0]||(t[0]=n=>d.value=n),type:"text",placeholder:"Search regions...",class:"w-full pl-9 pr-4 py-2 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/20 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-500 dark:placeholder-white/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors text-sm"},null,512),[[V,d.value]])])]),e("div",Vr,[g.value.length===0?(o(),r("div",Dr,c(d.value?"No regions match your search":"No available regions"),1)):F("",!0),(o(!0),r(K,null,Z(g.value,n=>(o(),r("label",{key:n.id,class:"flex items-center gap-3 p-2 rounded cursor-pointer hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors group"},[e("div",Ir,[S(e("input",{type:"radio",value:n.id,"onUpdate:modelValue":t[1]||(t[1]=A=>k.value=A),class:"sr-only peer"},null,8,Ur),[[se,k.value]]),t[11]||(t[11]=e("div",{class:"w-4 h-4 border-2 border-stroke dark:border-stroke/30 rounded-full group-hover:border-stroke dark:group-hover:border-stroke/50 peer-checked:border-primary peer-checked:bg-primary/20 transition-all"},[e("div",{class:"w-2 h-2 rounded-full bg-primary scale-0 peer-checked:scale-100 transition-transform absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"})],-1))]),e("div",Hr,[t[12]||(t[12]=e("svg",{class:"w-4 h-4 text-secondary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})],-1)),e("span",Rr,c(n.name),1),n.children.length>0?(o(),r("span",Kr,c(n.children.length),1)):F("",!0)])]))),128))])])):F("",!0),e("div",qr,[e("button",{onClick:C,class:"flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors"}," Cancel "),s.value.length>0&&k.value?(o(),r("button",{key:0,onClick:T,class:"flex-1 px-4 py-3 bg-primary/20 hover:bg-primary/30 border border-primary/50 text-primary rounded-lg transition-colors"}," Move & Delete ")):F("",!0),e("button",{onClick:h,class:"flex-1 px-4 py-3 bg-accent-red/20 hover:bg-accent-red/30 border border-accent-red/50 text-accent-red rounded-lg transition-colors font-medium"},c(s.value.length>0?"Delete All":"Delete"),1)])])])):F("",!0)}}),Or={class:"space-y-4 sm:space-y-6"},Gr={class:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-3"},Qr={class:"flex gap-2 flex-wrap"},Yr=["disabled"],Xr=["disabled"],Jr=["disabled"],Zr={class:"glass-card rounded-[15px] p-3 sm:p-4 border border-stroke-subtle dark:border-stroke/10 bg-background-mute dark:bg-white/5"},es={class:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3"},ts={class:"flex items-center gap-2 sm:gap-3"},os={class:"flex bg-background-mute dark:bg-stroke/5 rounded-lg border border-stroke-subtle dark:border-stroke/20 p-0.5 sm:p-1"},rs={class:"glass-card rounded-[15px] p-3 sm:p-6 border border-stroke-subtle dark:border-stroke/10"},ss={key:0,class:"flex items-center justify-center py-8"},ns={key:1,class:"text-center py-8"},as={class:"text-content-secondary dark:text-content-muted text-sm"},ls={key:2,class:"text-center py-8"},ds={key:3,class:"space-y-2"},is=G({name:"TransportKeys",__name:"TransportKeys",setup(I){const _=ke(),l=m(!1),v=m(!1),k=m(!1),d=m(null),u=m(null),s=m("deny"),p=m([]),g=m(!1),h=m(null),T=w=>{const f=new Map,H=[];return w.forEach(R=>{const ae={id:R.id,name:R.name,floodPolicy:R.flood_policy,transport_key:R.transport_key,last_used:R.last_used?new Date(R.last_used*1e3):void 0,parent_id:R.parent_id,children:[]};f.set(R.id,ae)}),f.forEach(R=>{R.parent_id&&f.has(R.parent_id)?f.get(R.parent_id).children.push(R):H.push(R)}),H},C=async()=>{try{g.value=!0,h.value=null;const w=await W.getTransportKeys();w.success&&w.data?p.value=T(w.data):h.value=w.error||"Failed to load transport keys"}catch(w){h.value=w instanceof Error?w.message:"Unknown error occurred",console.error("Error loading transport keys:",w)}finally{g.value=!1}};ne(()=>{C()});function M(w,f){for(const H of w){if(H.id===f)return H;if(H.children){const R=M(H.children,f);if(R)return R}}return null}function a(){const w=_.selectedNodeId.value;return w?M(p.value,w)?.name:void 0}function t(w){s.value==="deny"&&_.setSelectedNode(w)}function n(){s.value==="deny"&&(l.value=!0)}function A(){if(s.value==="deny"&&_.selectedNodeId.value){const w=M(p.value,_.selectedNodeId.value);w&&(u.value=w,k.value=!0)}}function b(){if(s.value==="deny"&&_.selectedNodeId.value){const w=M(p.value,_.selectedNodeId.value);w&&(d.value=w,v.value=!0)}}const x=async w=>{try{const f=await W.createTransportKey(w.name,w.floodPolicy,void 0,w.parentId,void 0);f.success?await C():(console.error("Failed to add transport key:",f.error),h.value=f.error||"Failed to add transport key")}catch(f){console.error("Error adding transport key:",f),h.value=f instanceof Error?f.message:"Unknown error occurred"}finally{l.value=!1}};function y(){l.value=!1}async function P(w){try{const f=w==="allow",H=await W.updateGlobalFloodPolicy(f);H.success?s.value=w:(console.error("Failed to update global flood policy:",H.error),h.value=H.error||"Failed to update global flood policy")}catch(f){console.error("Error updating global flood policy:",f),h.value=f instanceof Error?f.message:"Failed to update global flood policy"}}function O(){v.value=!1,d.value=null}async function $(w){try{const f=await W.updateTransportKey(w.id,w.name,w.floodPolicy);f.success?await C():(console.error("Failed to update transport key:",f.error),h.value=f.error||"Failed to update transport key")}catch(f){console.error("Error updating transport key:",f),h.value=f instanceof Error?f.message:"Unknown error occurred"}finally{O()}}function j(w){v.value=!1,d.value=null,u.value=w,k.value=!0}function z(){k.value=!1,u.value=null}async function E(w){try{const f=await W.deleteTransportKey(w);f.success?(await C(),_.setSelectedNode(null)):(console.error("Failed to delete transport key:",f.error),h.value=f.error||"Failed to delete transport key")}catch(f){console.error("Error deleting transport key:",f),h.value=f instanceof Error?f.message:"Unknown error occurred"}finally{z()}}async function B(w){try{const f=await W.deleteTransportKey(w.nodeId);f.success?(await C(),_.setSelectedNode(null)):(console.error("Failed to delete transport key:",f.error),h.value=f.error||"Failed to delete transport key")}catch(f){console.error("Error deleting transport key:",f),h.value=f instanceof Error?f.message:"Unknown error occurred"}finally{z()}}return(w,f)=>(o(),r("div",Or,[e("div",Gr,[f[3]||(f[3]=e("div",null,[e("h3",{class:"text-base sm:text-lg font-semibold text-content-primary dark:text-content-primary mb-1 sm:mb-2"},"Regions/Keys"),e("p",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Manage regional key hierarchy")],-1)),e("div",Qr,[e("button",{onClick:n,disabled:s.value==="allow",class:D(["flex items-center gap-1.5 sm:gap-2 px-2.5 sm:px-3 py-1.5 sm:py-2 rounded-lg border transition-colors text-xs sm:text-sm",s.value==="allow"?"bg-background-mute dark:bg-white/5 text-content-muted dark:text-content-muted/70 border-stroke-subtle dark:border-stroke/20 cursor-not-allowed":"bg-accent-green/10 hover:bg-accent-green/20 text-accent-green border-accent-green/30"])},f[2]||(f[2]=[e("svg",{class:"w-3.5 h-3.5 sm:w-4 sm:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),U(" Add ",-1)]),10,Yr),e("button",{onClick:b,disabled:!X(_).selectedNodeId.value||s.value==="allow",class:D(["px-2.5 sm:px-4 py-1.5 sm:py-2 rounded-lg border transition-colors text-xs sm:text-sm",!X(_).selectedNodeId.value||s.value==="allow"?"bg-background-mute dark:bg-stroke/10 text-content-muted dark:text-content-muted/70 border-stroke-subtle dark:border-stroke/20 cursor-not-allowed":"bg-accent-green/20 hover:bg-accent-green/30 text-accent-green border-accent-green/50"])}," Edit ",10,Xr),e("button",{onClick:A,disabled:!X(_).selectedNodeId.value||s.value==="allow",class:D(["px-2.5 sm:px-4 py-1.5 sm:py-2 rounded-lg border transition-colors text-xs sm:text-sm",!X(_).selectedNodeId.value||s.value==="allow"?"bg-background-mute dark:bg-stroke/10 text-content-muted dark:text-content-muted/70 border-stroke-subtle dark:border-stroke/20 cursor-not-allowed":"bg-accent-red/20 hover:bg-accent-red/30 text-accent-red border-accent-red/50"])}," Delete ",10,Jr)])]),e("div",Zr,[e("div",es,[f[4]||(f[4]=e("div",null,[e("h4",{class:"text-xs sm:text-sm font-medium text-content-primary dark:text-content-primary mb-1"},"Global Flood Policy (*)"),e("p",{class:"text-content-secondary dark:text-content-muted text-[10px] sm:text-xs"},"Master control for repeater flooding")],-1)),e("div",ts,[e("div",os,[e("button",{onClick:f[0]||(f[0]=H=>P("deny")),class:D(["px-2 sm:px-3 py-1 text-[10px] sm:text-xs font-medium rounded transition-colors",s.value==="deny"?"bg-accent-red/20 text-accent-red border border-accent-red/50":"text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary"])}," DENY ",2),e("button",{onClick:f[1]||(f[1]=H=>P("allow")),class:D(["px-2 sm:px-3 py-1 text-[10px] sm:text-xs font-medium rounded transition-colors",s.value==="allow"?"bg-accent-green/20 text-accent-green border border-accent-green/50":"text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-secondary"])}," ALLOW ",2)])])])]),e("div",rs,[g.value?(o(),r("div",ss,f[5]||(f[5]=[e("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-accent-green"},null,-1),e("span",{class:"ml-2 text-content-secondary dark:text-content-muted"},"Loading transport keys...",-1)]))):h.value?(o(),r("div",ns,[f[6]||(f[6]=e("div",{class:"text-accent-red mb-2"},"⚠️ Error loading transport keys",-1)),e("div",as,c(h.value),1),e("button",{onClick:C,class:"mt-4 px-4 py-2 bg-accent-green/20 hover:bg-accent-green/30 text-accent-green border border-accent-green/50 rounded-lg transition-colors"}," Retry ")])):p.value.length===0?(o(),r("div",ls,f[7]||(f[7]=[e("div",{class:"text-content-muted dark:text-content-muted mb-2"},"📝 No transport keys found",-1),e("div",{class:"text-content-muted dark:text-content-muted/60 text-sm"},"Add your first transport key to get started",-1)]))):(o(),r("div",ds,[(o(!0),r(K,null,Z(p.value,H=>(o(),xe(So,{key:H.id,node:H,"selected-node-id":X(_).selectedNodeId.value,level:0,disabled:s.value==="allow",onSelect:t},null,8,["node","selected-node-id","disabled"]))),128))]))]),q(Qo,{show:l.value,"selected-node-name":a(),"selected-node-id":X(_).selectedNodeId.value||void 0,onClose:y,onAdd:x},null,8,["show","selected-node-name","selected-node-id"]),q(wr,{show:v.value,node:d.value,onClose:O,onSave:$,onRequestDelete:j},null,8,["show","node"]),q(Wr,{show:k.value,node:u.value,"all-nodes":p.value,onClose:z,onDeleteAll:E,onMoveChildren:B},null,8,["show","node","all-nodes"])]))}}),cs={class:"space-y-4 sm:space-y-6"},us={class:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3"},ms={key:0,class:"bg-red-500/10 border border-red-500/30 rounded-lg p-4"},ps={class:"flex items-center gap-2 text-red-600 dark:text-red-400"},vs={key:1,class:"flex items-center justify-center py-12"},xs={key:2,class:"space-y-3"},bs={class:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3"},ks={class:"flex-1"},gs={class:"flex items-center gap-2 sm:gap-3"},ys={class:"min-w-0 flex-1"},fs={class:"text-content-primary dark:text-content-primary font-medium text-sm sm:text-base break-all"},hs={class:"flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-1 text-xs text-content-secondary dark:text-content-muted"},ws={class:"truncate"},_s={class:"truncate"},$s=["onClick","disabled"],Cs={key:3,class:"text-center py-12"},Ms={class:"bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-[15px] p-6 max-w-md w-full shadow-2xl"},As={class:"space-y-4"},Ss={class:"flex justify-end gap-3 mt-6"},js=["disabled"],Ts=["disabled"],Ns={class:"bg-surface dark:bg-surface-elevated border border-stroke-subtle dark:border-stroke/20 rounded-[15px] p-6 max-w-lg w-full shadow-2xl"},Es={class:"space-y-4"},Bs={class:"flex gap-2"},Fs=["value"],Ls={class:"bg-blue-500/10 border border-blue-500/30 rounded-lg p-4"},Ps={class:"block bg-blue-500/20 px-3 py-2 rounded text-xs text-blue-100 font-mono overflow-x-auto"},zs=G({name:"APITokens",__name:"APITokens",setup(I){const _=m([]),l=m(!1),v=m(null),k=m(!1),d=m(""),u=m(null),s=m(!1),p=m(!1),g=m(null),h=async()=>{l.value=!0,v.value=null;try{const x=await W.get("/auth/tokens"),y=x.data||x;_.value=y.tokens||[]}catch(x){console.error("Failed to fetch API tokens:",x),v.value=x instanceof Error?x.message:"Failed to fetch tokens"}finally{l.value=!1}},T=async()=>{if(!d.value.trim()){v.value="Token name is required";return}l.value=!0,v.value=null;try{const x=await W.post("/auth/tokens",{name:d.value.trim()}),y=x.data||x;u.value=y.token||null,k.value=!1,s.value=!0,d.value="",await h()}catch(x){console.error("Failed to create API token:",x),v.value=x instanceof Error?x.message:"Failed to create token"}finally{l.value=!1}},C=(x,y)=>{g.value={id:x,name:y},p.value=!0},M=async()=>{if(g.value){l.value=!0,v.value=null;try{await W.delete(`/auth/tokens/${g.value.id}`),await h(),p.value=!1,g.value=null}catch(x){console.error("Failed to revoke API token:",x),v.value=x instanceof Error?x.message:"Failed to revoke token"}finally{l.value=!1}}},a=()=>{k.value=!1,d.value="",v.value=null},t=()=>{s.value=!1,u.value=null},n=()=>{u.value&&navigator.clipboard.writeText(u.value)},A=x=>x?new Date(x*1e3).toLocaleString():"Never",b=N(()=>`${window.location.origin}/api/stats`);return ne(()=>{h()}),(x,y)=>(o(),r(K,null,[e("div",cs,[e("div",us,[y[5]||(y[5]=e("div",null,[e("h2",{class:"text-lg sm:text-xl font-semibold text-content-primary dark:text-content-primary"},"API Tokens"),e("p",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm mt-1"},"Manage API tokens for machine-to-machine authentication")],-1)),e("button",{onClick:y[0]||(y[0]=P=>k.value=!0),class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors flex items-center justify-center gap-2 text-sm sm:text-base"},y[4]||(y[4]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),U(" Create Token ",-1)]))]),y[20]||(y[20]=Y('<div class="bg-blue-500/10 border border-blue-500/30 rounded-lg p-3 sm:p-4"><div class="flex gap-2 sm:gap-3"><svg class="w-4 h-4 sm:w-5 sm:h-5 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg><div class="text-xs sm:text-sm text-blue-700 dark:text-blue-200"><p><strong>API tokens</strong> are used for machine-to-machine authentication. Include the token in the <code class="bg-blue-500/20 px-1 rounded">X-API-Key</code> header when making API requests.</p><p class="mt-2">Tokens are only shown once at creation. Store them securely.</p></div></div></div>',1)),v.value?(o(),r("div",ms,[e("div",ps,[y[6]||(y[6]=e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),U(" "+c(v.value),1)])])):F("",!0),l.value&&_.value.length===0?(o(),r("div",vs,y[7]||(y[7]=[e("div",{class:"text-center"},[e("div",{class:"animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-primary rounded-full mx-auto mb-4"}),e("div",{class:"text-content-secondary dark:text-content-muted"},"Loading tokens...")],-1)]))):_.value.length>0?(o(),r("div",xs,[(o(!0),r(K,null,Z(_.value,P=>(o(),r("div",{key:P.id,class:"bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-3 sm:p-4 hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors"},[e("div",bs,[e("div",ks,[e("div",gs,[y[8]||(y[8]=e("svg",{class:"w-4 h-4 sm:w-5 sm:h-5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"})],-1)),e("div",ys,[e("h3",fs,c(P.name),1),e("div",hs,[e("span",ws,"Created: "+c(A(P.created_at)),1),e("span",_s,"Last used: "+c(A(P.last_used)),1)])])])]),e("button",{onClick:O=>C(P.id,P.name),disabled:l.value,class:"w-full sm:w-auto px-3 py-1.5 bg-red-100 dark:bg-red-500/20 hover:bg-red-500/30 text-red-600 dark:text-red-400 rounded-lg border border-red-500/50 transition-colors disabled:opacity-50 text-sm"}," Revoke ",8,$s)])]))),128))])):(o(),r("div",Cs,[y[9]||(y[9]=e("svg",{class:"w-16 h-16 text-content-muted dark:text-content-muted/40 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"})],-1)),y[10]||(y[10]=e("h3",{class:"text-content-primary dark:text-content-primary font-medium mb-2"},"No API Tokens",-1)),y[11]||(y[11]=e("p",{class:"text-content-secondary dark:text-content-muted text-sm mb-4"},"Create a token to enable API access",-1)),e("button",{onClick:y[1]||(y[1]=P=>k.value=!0),class:"px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors"}," Create Your First Token ")])),k.value?(o(),r("div",{key:4,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:J(a,["self"])},[e("div",Ms,[y[14]||(y[14]=e("h3",{class:"text-xl font-semibold text-content-primary dark:text-content-primary mb-4"},"Create API Token",-1)),e("div",As,[e("div",null,[y[12]||(y[12]=e("label",{class:"block text-sm font-medium text-content-secondary dark:text-content-muted mb-2"},"Token Name",-1)),S(e("input",{"onUpdate:modelValue":y[2]||(y[2]=P=>d.value=P),type:"text",placeholder:"e.g., Production Server, CI/CD Pipeline",class:"w-full px-4 py-2 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary placeholder-gray-400 dark:placeholder-white/40 focus:outline-none focus:border-primary transition-colors",onKeydown:$e(T,["enter"])},null,544),[[V,d.value]]),y[13]||(y[13]=e("p",{class:"text-xs text-content-muted dark:text-content-muted mt-1"},"Give your token a descriptive name to identify its purpose",-1))]),e("div",Ss,[e("button",{onClick:a,disabled:l.value,class:"px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/10 transition-colors disabled:opacity-50"}," Cancel ",8,js),e("button",{onClick:T,disabled:l.value||!d.value.trim(),class:"px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors disabled:opacity-50"},c(l.value?"Creating...":"Create Token"),9,Ts)])])])])):F("",!0),s.value&&u.value?(o(),r("div",{key:5,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:J(t,["self"])},[e("div",Ns,[y[19]||(y[19]=e("h3",{class:"text-xl font-semibold text-content-primary dark:text-content-primary mb-4"},"Token Created Successfully",-1)),e("div",Es,[y[18]||(y[18]=Y('<div class="bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4"><div class="flex gap-3"><svg class="w-5 h-5 text-yellow-600 dark:text-yellow-400 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg><div class="text-sm text-yellow-200"><strong>Save this token now!</strong> For security reasons, it will not be shown again. </div></div></div>',1)),e("div",null,[y[16]||(y[16]=e("label",{class:"block text-sm font-medium text-content-secondary dark:text-content-muted mb-2"},"Your API Token",-1)),e("div",Bs,[e("input",{value:u.value,readonly:"",class:"flex-1 px-4 py-2 bg-background-mute dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary font-mono text-sm"},null,8,Fs),e("button",{onClick:n,class:"px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors flex items-center gap-2",title:"Copy to clipboard"},y[15]||(y[15]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1),U(" Copy ",-1)]))])]),e("div",Ls,[y[17]||(y[17]=e("p",{class:"text-sm text-blue-200 mb-2"},[e("strong",null,"Usage Example:")],-1)),e("code",Ps,' curl -H "X-API-Key: '+c(u.value)+'" '+c(b.value),1)]),e("div",{class:"flex justify-end mt-6"},[e("button",{onClick:t,class:"px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors"}," Done ")])])])])):F("",!0)]),q(Ce,{show:p.value,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${g.value?.name}'? This action cannot be undone.`,"confirm-text":"Revoke","cancel-text":"Cancel",variant:"danger",onConfirm:M,onClose:y[3]||(y[3]=P=>p.value=!1)},null,8,["show","message"])],64))}}),Vs={class:"space-y-6"},Ds={class:"glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6"},Is={class:"space-y-4"},Us={class:"flex items-center justify-between"},Hs=["disabled"],Rs={class:"glass-card rounded-lg border border-stroke-subtle dark:border-stroke/10 p-6"},Ks={class:"space-y-4"},qs={class:"space-y-3"},Ws=["checked","disabled"],Os=["checked","disabled"],Gs={class:"flex items-start gap-3"},Qs={key:0,class:"w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ys={key:1,class:"w-5 h-5 text-accent-cyan flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Xs={class:"flex-1"},Js={class:"text-sm font-medium text-content-primary dark:text-content-primary"},Zs={key:0,class:"text-xs text-green-600 dark:text-green-400 mt-1"},en={key:1,class:"p-4 bg-amber-500/10 border border-amber-500/30 rounded-lg"},tn={class:"flex items-start justify-between gap-3"},on=["disabled"],rn={key:0,class:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24"},sn={key:1,class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},nn={class:"flex items-center space-x-2"},an={key:0,class:"w-5 h-5 text-green-600 dark:text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ln={key:1,class:"w-5 h-5 text-red-600 dark:text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},dn=G({name:"WebSettings",__name:"WebSettings",setup(I){const _=m(!1),l=m(""),v=m(!1),k=m(!1),d=m(!1),u=m(!1),s=m(!0),p=ie({cors_enabled:!1,use_default_frontend:!0}),g=N(()=>v.value?"bg-green-500/10 border-green-600/40 dark:border-green-500/30":"bg-red-500/10 border-red-500/30");async function h(){try{s.value=!0;const b=await W.get("/check_pymc_console");b.success&&b.data&&(u.value=b.data.exists,console.log("PyMC Console exists:",u.value))}catch(b){console.error("Failed to check PyMC Console:",b),u.value=!1}finally{s.value=!1}}async function T(){try{const b=await W.get("/stats");console.log("WebSettings: Full response:",b);let x=null;if(b.success&&b.data?x=b.data:b&&"version"in b&&(x=b),x){const y=x.config?.web||{};console.log("WebSettings: webConfig:",y),p.cors_enabled=y.cors_enabled===!0,console.log("WebSettings: Set cors_enabled to:",p.cors_enabled);const P=y.web_path;p.use_default_frontend=!P||P==="",console.log("WebSettings: Set use_default_frontend to:",p.use_default_frontend,"from web_path:",P)}}catch(b){console.error("Failed to load web settings:",b),n("Failed to load settings",!1)}}async function C(){_.value=!0,l.value="";try{const b={web:{cors_enabled:p.cors_enabled}};p.use_default_frontend?b.web.web_path=null:b.web.web_path="/opt/pymc_console/web/html";const x=await W.post("/update_web_config",b);x.success?(n("Settings saved successfully",!0),k.value=!0):n(x.error||"Failed to save settings",!1)}catch(b){console.error("Failed to save web settings:",b),n(b.message||"Failed to save settings",!1)}finally{_.value=!1}}async function M(){p.cors_enabled=!p.cors_enabled,await C()}async function a(){p.use_default_frontend=!0,await C()}async function t(){p.use_default_frontend=!1,await C()}function n(b,x){l.value=b,v.value=x,setTimeout(()=>{l.value=""},5e3)}async function A(){d.value=!0,l.value="";try{const b=await W.post("/restart_service",{});b.success?(n("Service restart initiated. Page will reload...",!0),k.value=!1,setTimeout(()=>{window.location.reload()},2e3)):n(b.error||"Failed to restart service",!1)}catch(b){b.code==="ERR_NETWORK"||b.message?.includes("Network error")?(n("Service restarting... Page will reload",!0),k.value=!1,setTimeout(()=>{window.location.reload()},3e3)):(console.error("Failed to restart service:",b),n(b.message||"Failed to restart service",!1))}finally{d.value=!1}}return ne(()=>{T(),h()}),(b,x)=>(o(),r("div",Vs,[e("div",Ds,[x[1]||(x[1]=e("div",{class:"flex items-start justify-between mb-4"},[e("div",null,[e("h3",{class:"text-lg font-semibold text-content-primary dark:text-content-primary mb-1"},"CORS Settings"),e("p",{class:"text-sm text-content-secondary dark:text-content-muted"},"Control cross-origin resource sharing for API access")])],-1)),e("div",Is,[e("div",Us,[x[0]||(x[0]=e("div",null,[e("label",{class:"text-sm font-medium text-content-primary dark:text-content-primary"},"Enable CORS"),e("p",{class:"text-xs text-content-secondary dark:text-content-muted mt-1"},"Allow web frontends from different origins to access the API")],-1)),e("button",{onClick:M,disabled:_.value,class:D(["relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2",p.cors_enabled?"bg-cyan-600 dark:bg-teal-500 border-cyan-600 dark:border-teal-500":"bg-gray-400 dark:bg-gray-600 border-gray-400 dark:border-gray-600",_.value?"opacity-50 cursor-not-allowed":"cursor-pointer"])},[e("span",{class:D(["inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",p.cors_enabled?"translate-x-5":"translate-x-0.5"])},null,2)],10,Hs)])])]),e("div",Rs,[x[11]||(x[11]=e("div",{class:"flex items-start justify-between mb-4"},[e("div",null,[e("h3",{class:"text-lg font-semibold text-content-primary dark:text-content-primary mb-1"},"Web Frontend"),e("p",{class:"text-sm text-content-secondary dark:text-content-muted"},"Choose which web interface to use")])],-1)),e("div",Ks,[e("div",qs,[e("label",{class:D(["flex items-start space-x-3 p-4 bg-background-mute dark:bg-background/30 rounded-lg border-2 cursor-pointer transition-all",p.use_default_frontend?"border-accent-cyan bg-accent-cyan/10":"border-stroke-subtle dark:border-stroke/10 hover:border-accent-cyan/50"])},[e("input",{type:"radio",name:"frontend",checked:p.use_default_frontend,onChange:a,disabled:_.value,class:"mt-1 h-4 w-4 text-accent-cyan focus:ring-accent-cyan focus:ring-offset-background"},null,40,Ws),x[2]||(x[2]=e("div",{class:"flex-1"},[e("div",{class:"text-sm font-medium text-content-primary dark:text-content-primary"},"Default Frontend"),e("div",{class:"text-xs text-content-secondary dark:text-content-muted mt-1"},"Built-in pyMC Repeater web interface"),e("div",{class:"text-xs text-content-muted dark:text-content-muted/60 mt-1 font-mono"},"Built-in")],-1))],2),e("label",{class:D(["flex items-start space-x-3 p-4 bg-background-mute dark:bg-background/30 rounded-lg border-2 cursor-pointer transition-all",p.use_default_frontend?"border-stroke-subtle dark:border-stroke/10 hover:border-accent-cyan/50":"border-accent-cyan bg-accent-cyan/10"])},[e("input",{type:"radio",name:"frontend",checked:!p.use_default_frontend,onChange:t,disabled:_.value,class:"mt-1 h-4 w-4 text-accent-cyan focus:ring-accent-cyan focus:ring-offset-background"},null,40,Os),x[3]||(x[3]=Y('<div class="flex-1"><div class="flex items-center justify-between"><div class="text-sm font-medium text-content-primary dark:text-content-primary">PyMC Console</div><span class="text-xs bg-orange-100 dark:bg-orange-500/20 text-orange-600 dark:text-orange-400 px-2 py-0.5 rounded-full border border-orange-500/30 font-medium">@Treehouse⚡</span></div><div class="text-xs text-content-secondary dark:text-content-muted mt-1">Alternative web interface for pyMC Repeater</div><div class="text-xs text-content-muted dark:text-content-muted/60 mt-1 font-mono">/opt/pymc_console/web/html</div></div>',1))],2)]),s.value?F("",!0):(o(),r("div",{key:0,class:D(["p-4 rounded-lg border",u.value?"bg-green-500/5 border-green-500/20":"bg-accent-cyan/5 border-accent-cyan/20"])},[e("div",Gs,[u.value?(o(),r("svg",Qs,x[4]||(x[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)]))):(o(),r("svg",Ys,x[5]||(x[5]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)]))),e("div",Xs,[e("h4",Js,c(u.value?"PyMC Console has been detected":"PyMC Console Not Installed"),1),u.value?(o(),r("p",Zs,x[6]||(x[6]=[U(" PyMC Console is installed at ",-1),e("code",{class:"text-green-700 dark:text-green-300"},"/opt/pymc_console/web/html",-1)]))):(o(),r(K,{key:1},[x[7]||(x[7]=Y('<p class="text-xs text-content-secondary dark:text-content-muted mt-1 mb-3"> PyMC Console must be installed at <code class="text-accent-cyan">/opt/pymc_console/web/html</code> before selecting this option. </p><a href="https://github.com/dmduran12/pymc_console-dist" target="_blank" rel="noopener noreferrer" class="inline-flex items-center gap-2 px-4 py-2 bg-accent-cyan/20 hover:bg-accent-cyan/30 border border-accent-cyan/50 text-accent-cyan rounded-lg text-sm font-medium transition-colors"><svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"></path></svg> PyMC Console Install Instructions </a>',2))],64))])])],2)),k.value?(o(),r("div",en,[e("div",tn,[x[10]||(x[10]=Y('<div class="flex items-start space-x-3 flex-1"><svg class="w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg><div class="flex-1"><h4 class="text-sm font-medium text-amber-600 dark:text-amber-400">Service restart required</h4><p class="text-xs text-amber-700 dark:text-amber-400/80 mt-1">Web frontend changes will take effect after restarting the pymc-repeater service.</p></div></div>',1)),e("button",{onClick:A,disabled:d.value,class:"px-4 py-2 bg-amber-500 hover:bg-amber-600 disabled:bg-amber-500/50 text-white font-medium rounded-lg transition-colors disabled:cursor-not-allowed flex items-center gap-2 whitespace-nowrap"},[d.value?(o(),r("svg",rn,x[8]||(x[8]=[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"},null,-1),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},null,-1)]))):(o(),r("svg",sn,x[9]||(x[9]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},null,-1)]))),U(" "+c(d.value?"Restarting...":"Restart Now"),1)],8,on)])])):F("",!0)])]),l.value?(o(),r("div",{key:0,class:D(["p-4 rounded-lg border",g.value])},[e("div",nn,[v.value?(o(),r("svg",an,x[12]||(x[12]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)]))):(o(),r("svg",ln,x[13]||(x[13]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"},null,-1)]))),e("span",{class:D(v.value?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400")},c(l.value),3)])],2)):F("",!0)]))}}),cn={class:"space-y-4"},un={key:0,class:"bg-green-100 dark:bg-green-500/20 border border-green-500 dark:border-green-500/50 rounded-lg p-3 text-green-700 dark:text-green-400 text-sm"},mn={key:1,class:"bg-red-100 dark:bg-red-500/20 border border-red-500 dark:border-red-500/50 rounded-lg p-3 text-red-700 dark:text-red-400 text-sm"},pn={class:"flex justify-between items-center"},vn=["disabled"],xn={class:"flex gap-2"},bn=["disabled"],kn=["disabled"],gn={class:"bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3"},yn={key:0,class:"flex items-center justify-center py-4"},fn={key:1,class:"text-center py-4"},hn={class:"grid grid-cols-2 sm:grid-cols-4 gap-3"},wn={class:"text-center p-2 bg-white dark:bg-white/5 rounded-lg"},_n={class:"text-center p-2 bg-white dark:bg-white/5 rounded-lg"},$n={class:"text-lg font-mono text-content-primary dark:text-content-primary"},Cn={class:"text-center p-2 bg-white dark:bg-white/5 rounded-lg"},Mn={class:"text-lg font-mono text-green-600 dark:text-green-400"},An={class:"text-center p-2 bg-white dark:bg-white/5 rounded-lg"},Sn={class:"text-lg font-mono text-red-600 dark:text-red-400"},jn={key:0,class:"mt-2 p-2 bg-red-50 dark:bg-red-500/10 rounded-lg border border-red-200 dark:border-red-500/30"},Tn={class:"bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3"},Nn={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},En={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Bn={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Fn={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Ln={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Pn={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},zn={key:1,class:"flex items-center gap-2"},Vn={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1"},Dn={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},In={key:1,class:"flex items-center gap-2"},Un={class:"bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3"},Hn={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Rn={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Kn={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},qn={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Wn={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},On={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Gn={key:1,class:"flex items-center gap-2"},Qn={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},Yn={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},Xn={key:1,class:"flex items-center gap-2"},Jn={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 gap-1"},Zn={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},ea={key:1,class:"flex items-center gap-2"},ta={class:"bg-background-mute dark:bg-white/5 rounded-lg p-3 sm:p-4 space-y-3"},oa={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},ra={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},sa={class:"flex flex-col sm:flex-row sm:justify-between sm:items-center py-2 border-b border-stroke-subtle dark:border-stroke/10 gap-1"},na={key:0,class:"text-content-primary dark:text-content-primary font-mono text-sm"},aa={key:1,class:"flex items-center gap-2"},la={class:"py-2"},da={class:"grid grid-cols-3 gap-2 mt-2"},ia={class:"text-center p-2 bg-white dark:bg-white/5 rounded-lg"},ca={key:0,class:"font-mono text-sm text-content-primary dark:text-content-primary"},ua={class:"text-center p-2 bg-white dark:bg-white/5 rounded-lg"},ma={key:0,class:"font-mono text-sm text-content-primary dark:text-content-primary"},pa={class:"text-center p-2 bg-white dark:bg-white/5 rounded-lg"},va={key:0,class:"font-mono text-sm text-content-primary dark:text-content-primary"},xa=G({__name:"AdvertSettings",setup(I){const _=re(),l=N(()=>_.stats?.config?.repeater||{}),v=N(()=>l.value.advert_rate_limit||{}),k=N(()=>l.value.advert_penalty_box||{}),d=N(()=>l.value.advert_adaptive||{}),u=N(()=>d.value.thresholds||{}),s=m(!1),p=m(!1),g=m(""),h=m(""),T=m(!1),C=m(null),M=m(!0),a=m(2),t=m(1),n=m(10),A=m(60),b=m(!0),x=m(2),y=m(12),P=m(6),O=m(2),$=m(24),j=m(!0),z=m(.1),E=m(5),B=m(.05),w=m(.2),f=m(.5),H=async()=>{T.value=!0;try{const Q=await le.get("/api/advert_rate_limit_stats");Q.data?.success&&(C.value=Q.data.data)}catch(Q){console.error("Failed to fetch rate limit stats:",Q)}finally{T.value=!1}};te([v,k,d],()=>{console.log("[AdvertSettings] Watch triggered, isEditing:",s.value),s.value?console.log("[AdvertSettings] Watch skipped (editing mode)"):(console.log("[AdvertSettings] Watch loading values from store"),console.log("[AdvertSettings] rateLimitConfig:",v.value),console.log("[AdvertSettings] penaltyConfig:",k.value),console.log("[AdvertSettings] adaptiveConfig:",d.value),M.value=v.value.enabled??!1,a.value=v.value.bucket_capacity??2,t.value=v.value.refill_tokens??1,n.value=Math.round((v.value.refill_interval_seconds??36e3)/3600),A.value=Math.round((v.value.min_interval_seconds??0)/60),b.value=k.value.enabled??!1,x.value=k.value.violation_threshold??2,y.value=Math.round((k.value.violation_decay_seconds??43200)/3600),P.value=Math.round((k.value.base_penalty_seconds??21600)/3600),O.value=k.value.penalty_multiplier??2,$.value=Math.round((k.value.max_penalty_seconds??86400)/3600),j.value=d.value.enabled??!1,z.value=d.value.ewma_alpha??.1,E.value=Math.round((d.value.hysteresis_seconds??300)/60),B.value=u.value.quiet_max??.05,w.value=u.value.normal_max??.2,f.value=u.value.busy_max??.5,console.log("[AdvertSettings] Watch loaded values:"),console.log(" rateLimitEnabled:",M.value),console.log(" minIntervalMinutes:",A.value))},{immediate:!0}),ne(()=>{H()});const R=()=>{console.log("[AdvertSettings] reloadFormValues called"),console.log("[AdvertSettings] rateLimitConfig:",v.value),console.log("[AdvertSettings] penaltyConfig:",k.value),console.log("[AdvertSettings] adaptiveConfig:",d.value),M.value=v.value.enabled??!1,a.value=v.value.bucket_capacity??2,t.value=v.value.refill_tokens??1,n.value=Math.round((v.value.refill_interval_seconds??36e3)/3600),A.value=Math.round((v.value.min_interval_seconds??0)/60),b.value=k.value.enabled??!1,x.value=k.value.violation_threshold??2,y.value=Math.round((k.value.violation_decay_seconds??43200)/3600),P.value=Math.round((k.value.base_penalty_seconds??21600)/3600),O.value=k.value.penalty_multiplier??2,$.value=Math.round((k.value.max_penalty_seconds??86400)/3600),j.value=d.value.enabled??!1,z.value=d.value.ewma_alpha??.1,E.value=Math.round((d.value.hysteresis_seconds??300)/60),B.value=u.value.quiet_max??.05,w.value=u.value.normal_max??.2,f.value=u.value.busy_max??.5,console.log("[AdvertSettings] Form values after reload:"),console.log(" rateLimitEnabled:",M.value),console.log(" minIntervalMinutes:",A.value),console.log(" penaltyEnabled:",b.value),console.log(" adaptiveEnabled:",j.value)},ae=()=>{s.value=!0,g.value="",h.value=""},ge=()=>{s.value=!1,g.value="",h.value="",R()},ye=async()=>{p.value=!0,h.value="",g.value="";try{const Q={rate_limit_enabled:M.value,bucket_capacity:a.value,refill_tokens:t.value,refill_interval_seconds:n.value*3600,min_interval_seconds:A.value*60,penalty_enabled:b.value,violation_threshold:x.value,violation_decay_seconds:y.value*3600,base_penalty_seconds:P.value*3600,penalty_multiplier:O.value,max_penalty_seconds:$.value*3600,adaptive_enabled:j.value,ewma_alpha:z.value,hysteresis_seconds:E.value*60,quiet_max:B.value,normal_max:w.value,busy_max:f.value};console.log("[AdvertSettings] Sending save request with payload:",Q);const L=(await le.post("/api/update_advert_rate_limit_config",Q)).data;console.log("[AdvertSettings] API response:",L),L.success?(g.value=L.data?.message||"Settings saved successfully",console.log("[AdvertSettings] Save successful, fetching updated config..."),await _.fetchStats(),console.log("[AdvertSettings] systemStore.fetchStats() complete"),console.log("[AdvertSettings] rateLimitConfig after fetchStats:",v.value),await H(),console.log("[AdvertSettings] fetchStats() complete"),await de(),console.log("[AdvertSettings] nextTick() complete, calling reloadFormValues()"),R(),console.log("[AdvertSettings] reloadFormValues() complete, exiting edit mode"),s.value=!1,setTimeout(()=>{g.value=""},3e3)):(h.value=L.error||"Failed to save settings",console.error("[AdvertSettings] Save failed:",L.error))}catch(Q){console.error("Failed to save advert settings:",Q),h.value=Q.response?.data?.error||"Failed to save settings"}finally{p.value=!1}},ce=N(()=>C.value?.adaptive?.current_tier||"unknown"),fe=N(()=>{switch(ce.value){case"quiet":return"bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400 border-green-500";case"normal":return"bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 border-blue-500";case"busy":return"bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 border-yellow-500";case"congested":return"bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400 border-red-500";default:return"bg-gray-100 dark:bg-gray-500/20 text-gray-700 dark:text-gray-400 border-gray-500"}});return(Q,i)=>(o(),r("div",cn,[g.value?(o(),r("div",un,c(g.value),1)):F("",!0),h.value?(o(),r("div",mn,c(h.value),1)):F("",!0),e("div",pn,[e("button",{onClick:H,disabled:T.value,class:"px-3 py-1.5 text-xs bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-secondary dark:text-content-muted rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors disabled:opacity-50"},c(T.value?"Loading...":"Refresh Stats"),9,vn),e("div",xn,[s.value?(o(),r(K,{key:1},[e("button",{onClick:ge,disabled:p.value,class:"px-3 sm:px-4 py-2 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 text-content-primary dark:text-content-primary rounded-lg border border-stroke-subtle dark:border-stroke/20 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,bn),e("button",{onClick:ye,disabled:p.value,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm disabled:opacity-50 disabled:cursor-not-allowed"},c(p.value?"Saving...":"Save Changes"),9,kn)],64)):(o(),r("button",{key:0,onClick:ae,class:"px-3 sm:px-4 py-2 bg-primary/20 hover:bg-primary/30 text-content-primary dark:text-content-primary rounded-lg border border-primary/50 transition-colors text-sm"}," Edit Settings "))])]),e("div",gn,[i[21]||(i[21]=e("h3",{class:"text-sm font-medium text-content-primary dark:text-content-primary"},"Current Status",-1)),T.value&&!C.value?(o(),r("div",yn,i[14]||(i[14]=[e("div",{class:"animate-spin w-5 h-5 border-2 border-stroke-subtle dark:border-stroke/20 border-t-cyan-500 dark:border-t-primary rounded-full"},null,-1),e("span",{class:"ml-2 text-sm text-content-muted"},"Loading stats...",-1)]))):C.value?(o(),r(K,{key:2},[e("div",hn,[e("div",wn,[i[16]||(i[16]=e("div",{class:"text-xs text-content-muted dark:text-content-muted"},"Mesh Tier",-1)),e("div",{class:D(["mt-1 px-2 py-0.5 rounded border text-xs font-medium inline-block",fe.value])},c(ce.value.toUpperCase()),3)]),e("div",_n,[i[17]||(i[17]=e("div",{class:"text-xs text-content-muted dark:text-content-muted"},"Adverts/min",-1)),e("div",$n,c(C.value.metrics?.adverts_per_min_ewma?.toFixed(2)||"0.00"),1)]),e("div",Cn,[i[18]||(i[18]=e("div",{class:"text-xs text-content-muted dark:text-content-muted"},"Allowed",-1)),e("div",Mn,c(C.value.stats?.adverts_allowed||0),1)]),e("div",An,[i[19]||(i[19]=e("div",{class:"text-xs text-content-muted dark:text-content-muted"},"Dropped",-1)),e("div",Sn,c(C.value.stats?.adverts_dropped||0),1)])]),Object.keys(C.value.active_penalties||{}).length>0?(o(),r("div",jn,[i[20]||(i[20]=e("div",{class:"text-xs font-medium text-red-700 dark:text-red-400 mb-1"},"Active Penalties",-1)),(o(!0),r(K,null,Z(C.value.active_penalties,(L,ue)=>(o(),r("div",{key:ue,class:"text-xs font-mono text-red-600 dark:text-red-400"},c(ue)+"... - "+c(Math.round(L))+"s remaining ",1))),128))])):F("",!0)],64)):(o(),r("div",fn,i[15]||(i[15]=[e("p",{class:"text-xs text-content-muted dark:text-content-muted"},' Stats not available. Click "Refresh Stats" to load. ',-1)])))]),e("div",Tn,[i[29]||(i[29]=e("h3",{class:"text-sm font-medium text-content-primary dark:text-content-primary flex items-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})]),U(" Token Bucket Rate Limiting ")],-1)),i[30]||(i[30]=e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Controls how many adverts each pubkey can send in a given time period.",-1)),e("div",Nn,[i[23]||(i[23]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Rate Limiting",-1)),s.value?S((o(),r("select",{key:1,"onUpdate:modelValue":i[0]||(i[0]=L=>M.value=L),class:"w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},i[22]||(i[22]=[e("option",{value:!0},"Enabled",-1),e("option",{value:!1},"Disabled",-1)]),512)),[[oe,M.value]]):(o(),r("div",En,c(M.value?"Enabled":"Disabled"),1))]),e("div",Bn,[i[24]||(i[24]=e("div",null,[e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Bucket Capacity"),e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Max burst size (adverts)")],-1)),s.value?S((o(),r("input",{key:1,"onUpdate:modelValue":i[1]||(i[1]=L=>a.value=L),type:"number",min:"1",max:"10",class:"w-full sm:w-24 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512)),[[V,a.value,void 0,{number:!0}]]):(o(),r("div",Fn,c(a.value),1))]),e("div",Ln,[i[26]||(i[26]=e("div",null,[e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Refill Interval"),e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Time between token refills")],-1)),s.value?(o(),r("div",zn,[S(e("input",{"onUpdate:modelValue":i[2]||(i[2]=L=>n.value=L),type:"number",min:"1",max:"48",class:"w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,n.value,void 0,{number:!0}]]),i[25]||(i[25]=e("span",{class:"text-content-muted text-sm"},"hours",-1))])):(o(),r("div",Pn,c(n.value)+" hours",1))]),e("div",Vn,[i[28]||(i[28]=e("div",null,[e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Minimum Interval"),e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Hard minimum between adverts")],-1)),s.value?(o(),r("div",In,[S(e("input",{"onUpdate:modelValue":i[3]||(i[3]=L=>A.value=L),type:"number",min:"0",max:"1440",class:"w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,A.value,void 0,{number:!0}]]),i[27]||(i[27]=e("span",{class:"text-content-muted text-sm"},"min",-1))])):(o(),r("div",Dn,c(A.value)+" min",1))])]),e("div",Un,[i[40]||(i[40]=e("h3",{class:"text-sm font-medium text-content-primary dark:text-content-primary flex items-center gap-2"},[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"})]),U(" Penalty Box (Repeat Offenders) ")],-1)),i[41]||(i[41]=e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Applies escalating cooldowns to pubkeys that repeatedly violate limits.",-1)),e("div",Hn,[i[32]||(i[32]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Penalty Box",-1)),s.value?S((o(),r("select",{key:1,"onUpdate:modelValue":i[4]||(i[4]=L=>b.value=L),class:"w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},i[31]||(i[31]=[e("option",{value:!0},"Enabled",-1),e("option",{value:!1},"Disabled",-1)]),512)),[[oe,b.value]]):(o(),r("div",Rn,c(b.value?"Enabled":"Disabled"),1))]),e("div",Kn,[i[33]||(i[33]=e("div",null,[e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Violation Threshold"),e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Violations before penalty")],-1)),s.value?S((o(),r("input",{key:1,"onUpdate:modelValue":i[5]||(i[5]=L=>x.value=L),type:"number",min:"1",max:"10",class:"w-full sm:w-24 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512)),[[V,x.value,void 0,{number:!0}]]):(o(),r("div",qn,c(x.value),1))]),e("div",Wn,[i[35]||(i[35]=e("div",null,[e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Base Penalty Duration"),e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"First penalty duration")],-1)),s.value?(o(),r("div",Gn,[S(e("input",{"onUpdate:modelValue":i[6]||(i[6]=L=>P.value=L),type:"number",min:"1",max:"48",class:"w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,P.value,void 0,{number:!0}]]),i[34]||(i[34]=e("span",{class:"text-content-muted text-sm"},"hours",-1))])):(o(),r("div",On,c(P.value)+" hours",1))]),e("div",Qn,[i[37]||(i[37]=e("div",null,[e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Penalty Multiplier"),e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Escalation factor")],-1)),s.value?(o(),r("div",Xn,[S(e("input",{"onUpdate:modelValue":i[7]||(i[7]=L=>O.value=L),type:"number",min:"1",max:"5",step:"0.5",class:"w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,O.value,void 0,{number:!0}]]),i[36]||(i[36]=e("span",{class:"text-content-muted text-sm"},"x",-1))])):(o(),r("div",Yn,c(O.value)+"x",1))]),e("div",Jn,[i[39]||(i[39]=e("div",null,[e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Max Penalty Duration"),e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Maximum cooldown cap")],-1)),s.value?(o(),r("div",ea,[S(e("input",{"onUpdate:modelValue":i[8]||(i[8]=L=>$.value=L),type:"number",min:"1",max:"168",class:"w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,$.value,void 0,{number:!0}]]),i[38]||(i[38]=e("span",{class:"text-content-muted text-sm"},"hours",-1))])):(o(),r("div",Zn,c($.value)+" hours",1))])]),e("div",ta,[i[51]||(i[51]=Y('<h3 class="text-sm font-medium text-content-primary dark:text-content-primary flex items-center gap-2"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path></svg> Adaptive Rate Limiting </h3><div class="p-3 bg-cyan-50 dark:bg-cyan-500/10 border border-cyan-200 dark:border-cyan-500/30 rounded-lg"><p class="text-xs text-cyan-700 dark:text-cyan-300 leading-relaxed"><strong>How the three systems work together:</strong> Each layer can be enabled/disabled independently and the others will still function. </p><ul class="text-xs text-cyan-700 dark:text-cyan-300 mt-2 space-y-1 ml-4 list-disc"><li><strong>Rate Limiting OFF:</strong> All limiting disabled — adverts pass through freely</li><li><strong>Adaptive OFF:</strong> Token bucket uses fixed limits (no tier scaling), penalty box still works</li><li><strong>Penalty Box OFF:</strong> Token bucket still applies, but no escalating cooldowns for repeat offenders</li></ul><p class="text-xs text-cyan-700 dark:text-cyan-300 mt-2"><strong>Decision flow when all enabled:</strong> Adaptive tier check → Penalty box check → Token bucket check → Violation recording (triggers penalty box) </p><p class="text-xs text-cyan-700 dark:text-cyan-300 mt-1"><strong>Activity tiers:</strong><span class="text-green-600 dark:text-green-400 font-medium">Quiet</span> (bypass limiting) → <span class="text-blue-600 dark:text-blue-400 font-medium">Normal</span> (1x limits) → <span class="text-yellow-600 dark:text-yellow-400 font-medium">Busy</span> (0.5x capacity) → <span class="text-red-600 dark:text-red-400 font-medium">Congested</span> (0.25x capacity) </p></div>',2)),e("div",oa,[i[43]||(i[43]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Adaptive Mode",-1)),s.value?S((o(),r("select",{key:1,"onUpdate:modelValue":i[9]||(i[9]=L=>j.value=L),class:"w-full sm:w-32 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},i[42]||(i[42]=[e("option",{value:!0},"Enabled",-1),e("option",{value:!1},"Disabled",-1)]),512)),[[oe,j.value]]):(o(),r("div",ra,c(j.value?"Enabled":"Disabled"),1))]),e("div",sa,[i[45]||(i[45]=e("div",null,[e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm"},"Tier Change Delay"),e("p",{class:"text-xs text-content-muted dark:text-content-muted"},"Prevents tier flapping")],-1)),s.value?(o(),r("div",aa,[S(e("input",{"onUpdate:modelValue":i[10]||(i[10]=L=>E.value=L),type:"number",min:"0",max:"60",class:"w-20 px-3 py-1.5 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg text-content-primary dark:text-content-primary text-sm focus:outline-none focus:border-primary"},null,512),[[V,E.value,void 0,{number:!0}]]),i[44]||(i[44]=e("span",{class:"text-content-muted text-sm"},"min",-1))])):(o(),r("div",na,c(E.value)+" min",1))]),e("div",la,[i[49]||(i[49]=e("span",{class:"text-content-secondary dark:text-content-muted text-xs sm:text-sm mb-2 block"},"Activity Tier Thresholds (adverts/min)",-1)),e("div",da,[e("div",ia,[i[46]||(i[46]=e("div",{class:"text-xs text-green-600 dark:text-green-400 mb-1"},"Quiet Max",-1)),s.value?S((o(),r("input",{key:1,"onUpdate:modelValue":i[11]||(i[11]=L=>B.value=L),type:"number",min:"0",max:"1",step:"0.01",class:"w-full px-2 py-1 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded text-content-primary dark:text-content-primary text-sm text-center focus:outline-none focus:border-primary"},null,512)),[[V,B.value,void 0,{number:!0}]]):(o(),r("div",ca,c(B.value),1))]),e("div",ua,[i[47]||(i[47]=e("div",{class:"text-xs text-blue-600 dark:text-blue-400 mb-1"},"Normal Max",-1)),s.value?S((o(),r("input",{key:1,"onUpdate:modelValue":i[12]||(i[12]=L=>w.value=L),type:"number",min:"0",max:"5",step:"0.01",class:"w-full px-2 py-1 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded text-content-primary dark:text-content-primary text-sm text-center focus:outline-none focus:border-primary"},null,512)),[[V,w.value,void 0,{number:!0}]]):(o(),r("div",ma,c(w.value),1))]),e("div",pa,[i[48]||(i[48]=e("div",{class:"text-xs text-yellow-600 dark:text-yellow-400 mb-1"},"Busy Max",-1)),s.value?S((o(),r("input",{key:1,"onUpdate:modelValue":i[13]||(i[13]=L=>f.value=L),type:"number",min:"0",max:"10",step:"0.01",class:"w-full px-2 py-1 bg-white dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded text-content-primary dark:text-content-primary text-sm text-center focus:outline-none focus:border-primary"},null,512)),[[V,f.value,void 0,{number:!0}]]):(o(),r("div",va,c(f.value),1))])]),i[50]||(i[50]=e("p",{class:"text-xs text-content-muted dark:text-content-muted mt-2"},"Above Busy Max = Congested tier (strictest limiting)",-1))])])]))}}),ba={class:"p-3 sm:p-6 space-y-4 sm:space-y-6"},ka={class:"glass-card rounded-[15px] z-10 p-3 sm:p-4 border border-cyan-400 dark:border-primary/30 bg-cyan-500/10 dark:bg-primary/10"},ga={class:"text-cyan-700 dark:text-primary text-sm sm:text-base"},ya={class:"mt-1 sm:mt-2 text-cyan-600 dark:text-primary/80"},fa={class:"glass-card rounded-[15px] p-3 sm:p-6"},ha={class:"flex overflow-x-auto border-b border-stroke-subtle dark:border-stroke/10 mb-4 sm:mb-6 -mx-3 px-3 sm:mx-0 sm:px-0 scrollbar-hide"},wa=["onClick"],_a={class:"flex items-center gap-1 sm:gap-2"},$a={key:0,class:"w-3.5 h-3.5 sm:w-4 sm:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ca={key:1,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ma={key:2,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Aa={key:3,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Sa={key:4,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},ja={key:5,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ta={key:6,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Na={key:7,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ea={class:"min-h-[400px]"},Ba={key:0,class:"flex items-center justify-center py-12"},Fa={key:1,class:"flex items-center justify-center py-12"},La={class:"text-center"},Pa={class:"text-content-secondary dark:text-content-muted text-sm mb-4"},za={key:2},Ha=G({name:"ConfigurationView",__name:"Configuration",setup(I){const _=re(),l=m(Me("configuration_activeTab","radio")),v=m(!1);te(l,u=>Ae("configuration_activeTab",u));const k=[{id:"radio",label:"Radio Settings",icon:"radio"},{id:"repeater",label:"Repeater Settings",icon:"repeater"},{id:"advert",label:"Advert Limits",icon:"advert"},{id:"duty",label:"Duty Cycle",icon:"duty"},{id:"delays",label:"TX Delays",icon:"delays"},{id:"transport",label:"Regions/Keys",icon:"keys"},{id:"api-tokens",label:"API Tokens",icon:"tokens"},{id:"web",label:"Web Options",icon:"web"}];ne(async()=>{try{await _.fetchStats(),v.value=!0}catch(u){console.error("Failed to load configuration data:",u),v.value=!0}});function d(u){l.value=u}return(u,s)=>{const p=be("router-link");return o(),r("div",ba,[s[14]||(s[14]=e("div",null,[e("h1",{class:"text-xl sm:text-2xl font-bold text-content-primary dark:text-content-primary"},"Configuration"),e("p",{class:"text-content-secondary dark:text-content-muted mt-1 sm:mt-2 text-sm sm:text-base"},"System configuration and settings")],-1)),e("div",ka,[e("div",ga,[s[3]||(s[3]=e("strong",null,"CAD Calibration Tool Available",-1)),e("p",ya,[s[2]||(s[2]=U(" Optimize your Channel Activity Detection settings. ",-1)),q(p,{to:"/cad-calibration",class:"underline hover:text-cyan-800 dark:hover:text-primary transition-colors"},{default:ve(()=>s[1]||(s[1]=[U(" Launch CAD Calibration Tool → ",-1)])),_:1,__:[1]})])])]),e("div",fa,[e("div",ha,[(o(),r(K,null,Z(k,g=>e("button",{key:g.id,onClick:h=>d(g.id),class:D(["px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors duration-200 border-b-2 mr-3 sm:mr-6 whitespace-nowrap flex-shrink-0",l.value===g.id?"text-cyan-500 dark:text-primary border-cyan-500 dark:border-primary":"text-content-secondary dark:text-content-muted border-transparent hover:text-content-primary dark:hover:text-content-primary hover:border-stroke-subtle dark:hover:border-stroke/30"])},[e("div",_a,[g.icon==="radio"?(o(),r("svg",$a,s[4]||(s[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.822c5.716-5.716 14.976-5.716 20.692 0"},null,-1)]))):g.icon==="repeater"?(o(),r("svg",Ca,s[5]||(s[5]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14M5 12l4-4m-4 4l4 4"},null,-1)]))):g.icon==="advert"?(o(),r("svg",Ma,s[6]||(s[6]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"},null,-1)]))):g.icon==="duty"?(o(),r("svg",Aa,s[7]||(s[7]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)]))):g.icon==="delays"?(o(),r("svg",Sa,s[8]||(s[8]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"},null,-1)]))):g.icon==="keys"?(o(),r("svg",ja,s[9]||(s[9]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"},null,-1)]))):g.icon==="tokens"?(o(),r("svg",Ta,s[10]||(s[10]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"},null,-1)]))):g.icon==="web"?(o(),r("svg",Na,s[11]||(s[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"},null,-1)]))):F("",!0),U(" "+c(g.label),1)])],10,wa)),64))]),e("div",Ea,[!v.value&&X(_).isLoading?(o(),r("div",Ba,s[12]||(s[12]=[e("div",{class:"text-center"},[e("div",{class:"animate-spin w-8 h-8 border-2 border-stroke-subtle dark:border-stroke/20 border-t-cyan-500 dark:border-t-primary rounded-full mx-auto mb-4"}),e("div",{class:"text-content-secondary dark:text-content-muted"},"Loading configuration...")],-1)]))):X(_).error&&!v.value?(o(),r("div",Fa,[e("div",La,[s[13]||(s[13]=e("div",{class:"text-red-500 dark:text-red-400 mb-2"},"Failed to load configuration",-1)),e("div",Pa,c(X(_).error),1),e("button",{onClick:s[0]||(s[0]=g=>X(_).fetchStats()),class:"px-4 py-2 bg-cyan-500/20 dark:bg-primary/20 hover:bg-cyan-500/30 dark:hover:bg-primary/30 text-cyan-900 dark:text-white rounded-lg border border-cyan-500/50 dark:border-primary/50 transition-colors"}," Retry ")])])):(o(),r("div",za,[S(e("div",null,[q(rt,{key:"radio-settings"})],512),[[ee,l.value==="radio"]]),S(e("div",null,[q(Pt,{key:"repeater-settings"})],512),[[ee,l.value==="repeater"]]),S(e("div",null,[q(xa,{key:"advert-settings"})],512),[[ee,l.value==="advert"]]),S(e("div",null,[q(Gt,{key:"duty-cycle"})],512),[[ee,l.value==="duty"]]),S(e("div",null,[q(io,{key:"transmission-delays"})],512),[[ee,l.value==="delays"]]),S(e("div",null,[q(is,{key:"transport-keys"})],512),[[ee,l.value==="transport"]]),S(e("div",null,[q(zs,{key:"api-tokens"})],512),[[ee,l.value==="api-tokens"]]),S(e("div",null,[q(dn,{key:"web-settings"})],512),[[ee,l.value==="web"]])]))])])])}}});export{Ha as default};