diff --git a/README.md b/README.md index 1d5169b..aa7dee4 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,6 @@ limits, live traffic and a LuCI admin that follows a modern design. or within circles (family sees family, guests see guests). "Who reaches what" sums up the rules and "Check access" walks them step by step for a device and an address. -- **Find home devices** (optional, needs `umdns`): AirPlay, printers and shared - Macs at home show up on iPhone, iPad and Mac over the tunnel, published as - DNS-SD records in dnsmasq. - **Limits.** End dates (pause, keep, or remove devices when they pass), monthly or total data limits, allowed hours, pause one person or everyone. Devices drop off the tunnel at once (`awg syncconf`, no interface restart). diff --git a/package/luci-app-dawnline/Makefile b/package/luci-app-dawnline/Makefile index 1eb3f27..ef74411 100644 --- a/package/luci-app-dawnline/Makefile +++ b/package/luci-app-dawnline/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-dawnline -PKG_VERSION:=0.3.0 +PKG_VERSION:=0.3.1 PKG_RELEASE:=1 PKG_LICENSE:=MIT diff --git a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js index da7a047..7625dc3 100644 --- a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js +++ b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js @@ -7,14 +7,14 @@ 'require rpc'; 'require uci'; 'require ui'; -var An=Object.create;var Qt=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Nn=Object.getOwnPropertyNames;var zn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var Hn=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var In=(i,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Nn(t))!Rn.call(i,s)&&s!==n&&Qt(i,s,{get:()=>t[s],enumerable:!(a=Pn(t,s))||a.enumerable});return i};var Bn=(i,t,n)=>(n=i!=null?An(zn(i)):{},In(t||!i||!i.__esModule?Qt(n,"default",{value:i,enumerable:!0}):n,i));var nn=Hn((en,tn)=>{"use strict";var Xt=(function(){var i=function($,N){var C=236,T=17,y=$,A=n[N],m=null,h=0,P=null,f=[],_={},O=function(M,E){h=y*4+17,m=(function(x){for(var D=new Array(x),k=0;k=7&&W(M),P==null&&(P=Te(y,A,f)),le(P,E)},G=function(M,E){for(var x=-1;x<=7;x+=1)if(!(M+x<=-1||h<=M+x))for(var D=-1;D<=7;D+=1)E+D<=-1||h<=E+D||(0<=x&&x<=6&&(D==0||D==6)||0<=D&&D<=6&&(x==0||x==6)||2<=x&&x<=4&&2<=D&&D<=4?m[M+x][E+D]=!0:m[M+x][E+D]=!1)},B=function(){for(var M=0,E=0,x=0;x<8;x+=1){O(!0,x);var D=s.getLostPoint(_);(x==0||M>D)&&(M=D,E=x)}return E},S=function(){for(var M=8;M>x&1)==1;m[Math.floor(x/3)][x%3+h-8-3]=D}for(var x=0;x<18;x+=1){var D=!M&&(E>>x&1)==1;m[x%3+h-8-3][Math.floor(x/3)]=D}},te=function(M,E){for(var x=A<<3|E,D=s.getBCHTypeInfo(x),k=0;k<15;k+=1){var H=!M&&(D>>k&1)==1;k<6?m[k][8]=H:k<8?m[k+1][8]=H:m[h-15+k][8]=H}for(var k=0;k<15;k+=1){var H=!M&&(D>>k&1)==1;k<8?m[8][h-k-1]=H:k<9?m[8][15-k-1+1]=H:m[8][15-k-1]=H}m[h-8][8]=!M},le=function(M,E){for(var x=-1,D=h-1,k=7,H=0,V=s.getMaskFunction(E),K=h-1;K>0;K-=2)for(K==6&&(K-=1);;){for(var ie=0;ie<2;ie+=1)if(m[D][K-ie]==null){var ce=!1;H>>k&1)==1);var Q=V(D,K-ie);Q&&(ce=!ce),m[D][K-ie]=ce,k-=1,k==-1&&(H+=1,k=7)}if(D+=x,D<0||h<=D){D-=x,x=-x;break}}},de=function(M,E){for(var x=0,D=0,k=0,H=new Array(E.length),V=new Array(E.length),K=0;K=0?Vt.getAt(Yt):0}}for(var Jt=0,Q=0;QK*8)throw"code length overflow. ("+k.getLengthInBits()+">"+K*8+")";for(k.getLengthInBits()+4<=K*8&&k.put(0,4);k.getLengthInBits()%8!=0;)k.putBit(!1);for(;!(k.getLengthInBits()>=K*8||(k.put(C,8),k.getLengthInBits()>=K*8));)k.put(T,8);return de(k,D)};_.addData=function(M,E){E=E||"Byte";var x=null;switch(E){case"Numeric":x=p(M);break;case"Alphanumeric":x=u(M);break;case"Byte":x=c(M);break;case"Kanji":x=b(M);break;default:throw"mode:"+E}f.push(x),P=null},_.isDark=function(M,E){if(M<0||h<=M||E<0||h<=E)throw M+","+E;return m[M][E]},_.getModuleCount=function(){return h},_.make=function(){if(y<1){for(var M=1;M<40;M++){for(var E=l.getRSBlocks(M,A),x=d(),D=0;D"u"?M*4:E;var x="";x+='";for(var k=0;k<_.getModuleCount();k+=1)x+='"}return x+="",x+="
';x+="
",x},_.createSvgTag=function(M,E,x,D){var k={};typeof arguments[0]=="object"&&(k=arguments[0],M=k.cellSize,E=k.margin,x=k.alt,D=k.title),M=M||2,E=typeof E>"u"?M*4:E,x=typeof x=="string"?{text:x}:x||{},x.text=x.text||null,x.id=x.text?x.id||"qrcode-description":null,D=typeof D=="string"?{text:D}:D||{},D.text=D.text||null,D.id=D.text?D.id||"qrcode-title":null;var H=_.getModuleCount()*M+E*2,V,K,ie,ce,Q="",ge;for(ge="l"+M+",0 0,"+M+" -"+M+",0 0,-"+M+"z ",Q+=''+I(D.text)+"":"",Q+=x.text?''+I(x.text)+"":"",Q+='',Q+='"u"?M*4:E;var x=_.getModuleCount()*M+E*2,D=E,k=x-E;return j(x,x,function(H,V){if(D<=H&&H"u"?M*4:E;var D=_.getModuleCount()*M+E*2,k="";return k+="",k};var I=function(M){for(var E="",x=0;x":E+=">";break;case"&":E+="&";break;case'"':E+=""";break;default:E+=D;break}}return E},ae=function(M){var E=1;M=typeof M>"u"?E*2:M;var x=_.getModuleCount()*E+M*2,D=M,k=x-M,H,V,K,ie,ce,Q={"██":"█","█ ":"▀"," █":"▄"," ":" "},ge={"██":"▀","█ ":"▀"," █":" "," ":" "},fe="";for(H=0;H=k?ge[ce]:Q[ce];fe+=` -`}return x%2&&M>0?fe.substring(0,fe.length-x-1)+Array(x+1).join("▀"):fe.substring(0,fe.length-1)};return _.createASCII=function(M,E){if(M=M||1,M<2)return ae(E);M-=1,E=typeof E>"u"?M*2:E;var x=_.getModuleCount()*M+E*2,D=E,k=x-E,H,V,K,ie,ce=Array(M+1).join("██"),Q=Array(M+1).join(" "),ge="",fe="";for(H=0;H>>8),A.push(P&255)):A.push(T)}}return A}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},s=(function(){var $=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],N=1335,C=7973,T=21522,y={},A=function(m){for(var h=0;m!=0;)h+=1,m>>>=1;return h};return y.getBCHTypeInfo=function(m){for(var h=m<<10;A(h)-A(N)>=0;)h^=N<=0;)h^=C<5&&(P+=3+O-5)}for(var f=0;f=256;)y-=255;return $[y]},T})();function r($,N){if(typeof $.length>"u")throw $.length+"/"+N;var C=(function(){for(var y=0;y<$.length&&$[y]==0;)y+=1;for(var A=new Array($.length-y+N),m=0;m<$.length-y;m+=1)A[m]=$[m+y];return A})(),T={};return T.getAt=function(y){return C[y]},T.getLength=function(){return C.length},T.multiply=function(y){for(var A=new Array(T.getLength()+y.getLength()-1),m=0;m"u")throw"bad rs block @ typeNumber:"+y+"/errorCorrectionLevel:"+A;for(var h=m.length/3,P=[],f=0;f>>7-T%8&1)==1},C.put=function(T,y){for(var A=0;A>>y-A-1&1)==1)},C.getLengthInBits=function(){return N},C.putBit=function(T){var y=Math.floor(N/8);$.length<=y&&$.push(0),T&&($[y]|=128>>>N%8),N+=1},C},p=function($){var N=t.MODE_NUMBER,C=$,T={};T.getMode=function(){return N},T.getLength=function(m){return C.length},T.write=function(m){for(var h=C,P=0;P+2>>8&255)*192+(f&255),m.put(f,13),P+=2}if(P>>8)},N.writeBytes=function(C,T,y){T=T||0,y=y||C.length;for(var A=0;A0&&(C+=","),C+=$[T];return C+="]",C},N},w=function(){var $=0,N=0,C=0,T="",y={},A=function(h){T+=String.fromCharCode(m(h&63))},m=function(h){if(!(h<0)){if(h<26)return 65+h;if(h<52)return 97+(h-26);if(h<62)return 48+(h-52);if(h==62)return 43;if(h==63)return 47}throw"n:"+h};return y.writeByte=function(h){for($=$<<8|h&255,N+=8,C+=1;N>=6;)A($>>>N-6),N-=6},y.flush=function(){if(N>0&&(A($<<6-N),$=0,N=0),C%3!=0)for(var h=3-C%3,P=0;P=N.length){if(y==0)return-1;throw"unexpected end of file./"+y}var h=N.charAt(C);if(C+=1,h=="=")return y=0,-1;if(h.match(/^\s$/))continue;T=T<<6|m(h.charCodeAt(0)),y+=6}var P=T>>>y-8&255;return y-=8,P};var m=function(h){if(65<=h&&h<=90)return h-65;if(97<=h&&h<=122)return h-97+26;if(48<=h&&h<=57)return h-48+52;if(h==43)return 62;if(h==47)return 63;throw"c:"+h};return A},Y=function($,N){var C=$,T=N,y=new Array($*N),A={};A.setPixel=function(f,_,O){y[_*C+f]=O},A.write=function(f){f.writeString("GIF87a"),f.writeShort(C),f.writeShort(T),f.writeByte(128),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(255),f.writeByte(255),f.writeByte(255),f.writeString(","),f.writeShort(0),f.writeShort(0),f.writeShort(C),f.writeShort(T),f.writeByte(0);var _=2,O=h(_);f.writeByte(_);for(var G=0;O.length-G>255;)f.writeByte(255),f.writeBytes(O,G,255),G+=255;f.writeByte(O.length-G),f.writeBytes(O,G,O.length-G),f.writeByte(0),f.writeString(";")};var m=function(f){var _=f,O=0,G=0,B={};return B.write=function(S,q){if(S>>>q)throw"length over";for(;O+q>=8;)_.writeByte(255&(S<>>=8-O,G=0,O=0;G=S<0&&_.writeByte(G)},B},h=function(f){for(var _=1<>6,128|o&63):o<55296||o>=57344?a.push(224|o>>12,128|o>>6&63,128|o&63):(s++,o=65536+((o&1023)<<10|n.charCodeAt(s)&1023),a.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63))}return a}return t(i)}})();(function(i){typeof define=="function"&&define.amd?define([],i):typeof en=="object"&&(tn.exports=i())})(function(){return Xt})});function Tt(i,t){return i==null||i===!1||i===""||(Array.isArray(i)?i.forEach(n=>Tt(n,t)):t.push(i instanceof Node?i:String(i))),t}function e(i,t,n){let a=window.E,s=t!=null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Node);return!s&&n===void 0?a(i,{},Tt(t,[])):a(i,s?t:{},Tt(n,[]))}function J(i,t=[]){let n=rpc.declare({object:"luci.dawnline",method:i,params:t});return async(...a)=>{let s=await n(...a);if(s&&typeof s=="object"&&typeof s.error=="string")throw new Error(s.error);return s}}var jn=J("logs_clear",["person","device","category","older_days"]),On=(i={})=>jn(i.person??"",i.device??"",i.category??"",i.older_days??""),Un=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets"]});async function qn(i,t){let a=[i,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(o=>t[o]),t.paused,t.services,t.circle,t.home_nets],s=await Un(...a);if(s&&typeof s.error=="string")throw new Error(s.error);return s}var Wn=J("status",["days"]),Gn=0;async function Fn(i){let t=await Wn(i);return Gn=Date.now(),t}var z={personUpdate:qn,settingsGet:J("settings_get"),settingsUpdate:J("settings_update",["values"]),serviceSet:J("service_set",["id","name","address","ports"]),serviceDelete:J("service_delete",["id"]),geoClear:J("geo_clear"),events:J("events",["limit"]),logsClear:On,interfaces:J("interfaces",["id"]),serverInterfaces:J("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:J("circle_set",["id","server","name","color","members"]),circleDelete:J("circle_delete",["id"]),accessCheck:J("access_check",["from","to"]),homeHosts:J("home_hosts",["id"]),usageClear:J("usage_clear",["scope","id"]),uninstall:J("uninstall",["confirm"]),status:Fn,setupDefaults:J("setup_defaults"),serverCreate:J("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:J("server_obfuscation",["id","preset"]),serverUpdate:J("server_update",["id","values"]),serverDelete:J("server_delete",["id"]),personCreate:J("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:J("person_pause",["id","paused"]),personRegen:J("person_regen",["id"]),personDelete:J("person_delete",["id"]),personUsage:J("person_usage",["id","days"]),pauseAll:J("pause_all",["paused"]),deviceCreate:J("device_create",["person","name","kind"]),deviceConfig:J("device_config",["id"]),deviceUpdate:J("device_update",["id","name","disabled"]),deviceDelete:J("device_delete",["id"]),deviceRotate:J("device_rotate",["id"]),apply:J("apply"),health:J("health"),healthFix:J("health_fix",["id"]),serviceLog:J("service_log"),serviceLogClear:J("service_log_clear",["older_days"]),backupList:J("backup_list"),backupCreate:J("backup_create"),backupRestore:J("backup_restore",["name"]),backupDelete:J("backup_delete",["name"]),backupRead:J("backup_read",["name"]),backupUpload:J("backup_upload",["data"]),exportJson:J("export"),importJson:J("import",["data"]),updatesStatus:J("updates_status"),updatesRun:J("updates_run",["what"])};var Zt={phone:'',computer:'',tablet:'',router:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function Ct(i,t="dl-icon"){let n=Zt[i]??Zt.phone;return``}function v(i,t="dl-icon"){let n=document.createElement("span");return n.className="dl-icon-wrap",n.innerHTML=Ct(i,t),n}function R(i,t,n="neutral",a={}){let{disabled:s,...o}=a,r=e("button",{class:`cbi-button cbi-button-${n}`,type:"button",...o,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!r.disabled){r.disabled=!0,r.classList.add("spinning");try{await t(l)}catch(d){ne(Dt(d),"error")}finally{r.disabled=!1,r.classList.remove("spinning")}}}},i);return r.disabled=!!s,r}function ke(i,t,n,a="neutral",s=""){return R([v(i),e("span",{class:"dl-btn-label"},t)],n,a,{title:t,class:`cbi-button cbi-button-${a} dl-icon-btn ${s}`.trim()})}function ne(i,t="info",n=0){let a=document.querySelector(".dl-toasts");a||(a=e("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(a));let s=t==="error"?"x":t==="warning"?"alert":t==="success"?"check":null,o=()=>{r.classList.remove("show"),setTimeout(()=>r.remove(),200)},r=e("div",{class:`dl-toast ${t}`},[s?v(s):"",e("span",{},i),t==="error"?e("button",{type:"button","aria-label":"Close",click:o},v("x")):""]);a.appendChild(r),requestAnimationFrame(()=>r.classList.add("show")),setTimeout(o,n||(t==="error"?8e3:t==="warning"?5e3:2600))}function Dt(i){return i instanceof Error?i.message:String(i)}async function U(i,t){try{let n=await i();return t&&ne(t,"success",3500),n}catch(n){ne(Dt(n),"error",1e4);return}}function se(i,t,n,a=""){ui.showModal(i,[e("div",{class:`dl-modal ${a}`},t),e("div",{class:"button-row"},n)])}function X(){ui.hideModal()}function re(i,t,n="Confirm",a=!1){return new Promise(s=>{se(i,t,[e("button",{class:"cbi-button cbi-button-neutral",type:"button",click:()=>{X(),s(!1)}},"Cancel")," ",e("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{X(),s(!0)}},n)])})}async function he(i,t="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(i);else{let n=e("textarea",{style:"position:fixed;opacity:0"},i);document.body.appendChild(n),n.select(),document.execCommand("copy"),n.remove()}ne(t,"success",2500)}catch(n){ne(Dt(n),"error")}}function ve(i,t,n="text/plain"){let a=globalThis,s=typeof t=="string"?new a.Blob([t],{type:n}):t,o=URL.createObjectURL(s),r=e("a",{href:o,download:i,style:"display:none"});document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(o),r.remove()},1e3)}function Ae(i,t){let n={ok:"success",warn:"warning",error:"error",info:"notice"}[i];return e("div",{class:`alert-message ${n}`},t)}function Pe(i,t=""){let n=e("div",{class:t});return n.innerHTML=i,n}function At(i,t){return new Promise(n=>{let a=e("input",{type:"file",accept:i,style:"display:none"});a.addEventListener("cancel",()=>{a.remove(),n(null)}),a.addEventListener("change",()=>{let s=a.files?.[0];if(a.remove(),!s)return n(null);let o=new FileReader;o.onload=()=>{let r=String(o.result??"");n({name:s.name,data:t==="base64"?r.replace(/^data:[^,]*,/,""):r})},o.onerror=()=>n(null),t==="base64"?o.readAsDataURL(s):o.readAsText(s)}),document.body.appendChild(a),a.click()})}function we(i,t){let n=document.querySelector(".dl-dd");if(n&&(n.dlClose?n.dlClose():n.remove(),n.dlAnchor===i))return;let a=e("div",{class:"dl-dd dl-root",role:"menu"},t.map(u=>u?e("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),u.run()}},[u.icon??"",e("span",{},u.label)]):e("hr")));document.body.appendChild(a);let s=i.getBoundingClientRect(),o=a.offsetWidth,r=a.offsetHeight;a.style.top=`${s.bottom+6+r>window.innerHeight-8&&s.top-6-r>8?s.top-6-r:s.bottom+6}px`,a.style.left=`${Math.max(8,Math.min(s.right-o,window.innerWidth-o-8))}px`;let l=u=>{!a.contains(u.target)&&!i.contains(u.target)&&p()},d=u=>{u.key==="Escape"&&p()};a.dlAnchor=i,a.dlClose=p;function p(){a.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",p,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var an=Bn(nn(),1),Kn='';function Oe(i,t=3,n=!0){let a=(0,an.default)(0,i.length>300?"Q":"H");a.addData(i,"Byte"),a.make();let s=a.getModuleCount(),o=s+t*2,r=n?Math.round(s*.22):0;r&&(s-r)%2&&r++;let l=(s-r)/2,d=l+r,p=(b,g)=>r>0&&b>=l&&b=l&&g${Kn}`}return`${c}`}var Vn={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Yn={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function Jn(i){let t={};for(let[n,a]of Object.entries(Yn))i[n]!=null&&i[n]!==""&&(t[a]=String(i[n]));return t}function Qn(i,t){let n=i.amnezia,a=n.obfuscation??{},s=d=>a[d]!=null&&a[d]!==""?String(a[d]):Vn[d],o=n.host.replace(/^\[(.*)\]$/,"$1"),r={H1:s("h1"),H2:s("h2"),H3:s("h3"),H4:s("h4"),I1:s("i1"),I2:s("i2"),I3:s("i3"),I4:s("i4"),I5:s("i5"),Jc:s("jc"),Jmin:s("jmin"),Jmax:s("jmax"),S1:s("s1"),S2:s("s2"),S3:s("s3"),S4:s("s4"),...Jn(a),allowed_ips:n.allowed_ips,client_ip:n.client_ip,client_priv_key:n.client_priv_key,client_pub_key:n.client_pub_key,config:i.conf.replace(/\r?\n/g,`\r -`),hostName:o,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(r),port:String(n.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:o};return n.dns[0]&&(l.dns1=n.dns[0]),n.dns[1]&&(l.dns2=n.dns[1]),l}function Zn(i){let t="";for(let n=0;n"u")return null;try{let n=new t.Blob([i]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.Response(n).arrayBuffer()),s=new Uint8Array(4+a.length);return new DataView(s.buffer).setUint32(0,i.length,!1),s.set(a,4),s}catch{return null}}async function sn(i,t,n=!0){let a=new TextEncoder().encode(JSON.stringify(Qn(i,t))),s=n?await Xn(a):null;return`vpn://${Zn(s??a)}`}function Z(i){if(!i||i<0)return"0 B";let t=["B","KB","MB","GB","TB"],n=0,a=i;for(;a>=1024&&n=100||n===0?Math.round(a):a.toFixed(1)} ${t[n]}`}function $e(i){let t=i*8;return t<1e3?`${Math.round(t)} bit/s`:t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)} kbit/s`:t<1e9?`${(t/1e6).toFixed(t<1e7?1:0)} Mbit/s`:`${(t/1e9).toFixed(1)} Gbit/s`}function ue(i,t=Date.now()/1e3){if(!i)return"never";let n=Math.max(0,Math.round(t-i));return n<60?"just now":n<3600?`${Math.floor(n/60)} min ago`:n<86400?`${Math.floor(n/3600)} h ago`:n<86400*30?`${Math.floor(n/86400)} d ago`:new Date(i*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function on(i){if(!i||i<0)return"—";let t=Math.floor(i/86400),n=Math.floor(i%86400/3600),a=Math.floor(i%3600/60);return t?`${t}d ${n}h`:n?`${n}h ${a}m`:`${a}m`}function Ne(i){let t=new Date(i*1e3),n=new Date,a=t.toDateString()===n.toDateString(),s=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?s:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${s}`}function _e(i){if(!i)return"";let[t,n,a]=i.split("-").map(Number);return new Date(t,n-1,a).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ze(i,t=Date.now()){if(!i)return null;let[n,a,s]=i.split("-").map(Number),o=new Date(n,a-1,s,23,59,59).getTime();return Math.ceil((o-t)/864e5)}var Ue={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var rn=["computer","phone","tablet","router","other"],Se={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Pt={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Re(i){let t=i.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let n=t[0][0]??"",a=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(n+a).toUpperCase()}function rt(i){let t=n=>n.disabled?3:n.online?0:n.handshake?1:2;return i.map((n,a)=>[n,a]).sort((n,a)=>t(n[0])-t(a[0])||n[1]-a[1]).map(([n])=>n)}var ln="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl",ea="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",ta="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",na={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Qe=null;function aa(i){let t=window;return i.appendChild(e("link",{rel:"stylesheet",href:`${ln}.css`})),t.maplibregl?Promise.resolve(t.maplibregl):Qe||(Qe=new Promise((n,a)=>{let s=e("script",{src:`${ln}.js`});s.onload=()=>t.maplibregl?n(t.maplibregl):a(new Error("MapLibre failed to load")),s.onerror=()=>{Qe=null,a(new Error("Could not load the map library (no internet access from this browser?)"))},i.appendChild(s)}),Qe)}function lt(){let i=document.documentElement.getAttribute("data-darkmode");return i!=null?i==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function sa(i,t,n=48){let a=(i[0]+t[0])/2,s=(i[1]+t[1])/2,o=t[0]-i[0],r=t[1]-i[1],l=Math.hypot(o,r)||1,d=Math.min(.25*l,12),p=a-r/l*d,u=s+o/l*d,c=[];for(let b=0;b<=n;b++){let g=b/n,w=1-g;c.push([w*w*i[0]+2*w*g*p+g*g*t[0],w*w*i[1]+2*w*g*u+g*g*t[1]])}return c}function ia(i,t){let n=new Map;for(let a of i.geo.points){if(i.person&&a.person!==i.person||(t==="online"?!a.online:i.now-a.ts>na[t]))continue;let s=n.get(a.device);(!s||a.online&&!s.online||a.online===s.online&&a.ts>s.ts)&&n.set(a.device,a)}return[...n.values()]}var qe=class{constructor(t,n="online",a=380){this.cb=t;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.anim=0;this.data=null;this.fitted=!1;this.range=n,this.status=e("div",{class:"dl-map-status"}),this.el=e("div",{class:"dl-geomap",style:`height:${a}px`},this.status)}async mount(t){this.data=t;try{this.gl=await aa(this.el)}catch(n){this.status.textContent=n.message;return}this.map=new this.gl.Map({container:this.el,style:lt()?ea:ta,center:[t.geo.home?.lon??20,t.geo.home?.lat??50],zoom:3,attributionControl:{compact:!0},dragRotate:!1,pitchWithRotate:!1,cooperativeGestures:!0}),this.map.addControl(new this.gl.NavigationControl({showCompass:!1}),"bottom-right"),this.map.on("load",()=>{this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],"#40c977",lt()?"#ededed":"#0d0d0d"],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],"#40c977",lt()?"#ededed":"#0d0d0d"],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],!1],layout:{"line-cap":"round"},paint:{"line-color":lt()?"#ededed":"#0d0d0d","line-opacity":.35,"line-width":1.5,"line-dasharray":[2,3]}}),this.map.addLayer({id:"dl-arc-glow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-opacity":.18,"line-width":7}}),this.map.addLayer({id:"dl-arc-live",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-width":2}}),this.map.addLayer({id:"dl-arc-flow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#ffffff","line-width":2,"line-opacity":.8,"line-dasharray":[0,4,3]}}),this.animate(),this.draw()})}setRange(t){this.range=t,this.fitted=!1,this.draw()}update(t){this.data=t,this.draw()}destroy(){cancelAnimationFrame(this.anim),this.map?.remove(),this.map=null}animate(){let t=[[0,4,3],[.5,4,2.5],[1,4,2],[1.5,4,1.5],[2,4,1],[2.5,4,.5],[3,4,0],[0,.5,3,3.5],[0,1,3,3],[0,1.5,3,2.5],[0,2,3,2],[0,2.5,3,1.5],[0,3,3,1],[0,3.5,3,.5]],n=-1,a=0,s=o=>{this.map&&(o-a>70&&(a=o,n=(n+1)%t.length,this.map.getLayer("dl-arc-flow")&&this.map.setPaintProperty("dl-arc-flow","line-dasharray",t[n])),this.anim=requestAnimationFrame(s))};this.anim=requestAnimationFrame(s)}groups(t){let n=new Map;for(let a of t){let s=`${a.asn||a.org||a.ip}|${a.city}|${a.cc}`,o=n.get(s);o||(o={key:s,lat:a.lat,lon:a.lon,city:a.city,country:a.country,cc:a.cc,asn:a.asn,org:a.org,online:!1,ts:0,points:[]},n.set(s,o)),o.points.push(a),o.online||(o.online=a.online),o.ts=Math.max(o.ts,a.ts)}return[...n.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let t=this.data,n=this.groups(ia(t,this.range)),a=t.geo.home;for(let r of this.markers)r.remove();this.markers=[];let s=new Map,o=n.map(r=>{let l=`${r.lat.toFixed(2)},${r.lon.toFixed(2)}`,d=s.get(l)??0;return s.set(l,d+1),{g:r,at:[r.lon+d*.25,r.lat]}});if(this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:o.map(({g:r,at:l})=>({type:"Feature",properties:{online:r.online},geometry:{type:"Point",coordinates:l}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?o.map(({g:r,at:l})=>({type:"Feature",properties:{online:r.online},geometry:{type:"LineString",coordinates:sa([a.lon,a.lat],l)}})):[]}),a){let r=e("div",{class:"dl-mk-home",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`});r.innerHTML=Ct("home","dl-mk-home-ic"),this.markers.push(new this.gl.Marker({element:r}).setLngLat([a.lon,a.lat]).addTo(this.map))}for(let{g:r,at:l}of o){let d=r.points.length,p=e("button",{type:"button",class:`dl-mk${r.online?" online":""}${d>1?" multi":""}`,"aria-label":`${d} device${d===1?"":"s"} via ${r.org||"unknown network"} in ${r.city||"unknown city"}`},d>1?e("span",{class:"dl-mk-count"},String(d)):e("span",{class:"dl-mk-dot"})),c=!!a&&Math.abs(l[0]-a.lon)<.02&&Math.abs(l[1]-a.lat)<.02?[22,-16]:[0,0];p.addEventListener("click",b=>{b.stopPropagation(),this.openPopup(r,l,c)}),this.markers.push(new this.gl.Marker({element:p,offset:c}).setLngLat(l).addTo(this.map))}if(!this.fitted){let r=o.map(l=>l.at);a&&(r.length===0||this.range!=="online"||o.some(l=>l.g.online))&&r.push([a.lon,a.lat]),this.fit(r),this.fitted=!0}this.status.textContent=o.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none"}fit(t){if(!t.length)return;let n=(d,p)=>{let u=Math.PI/180,c=(p[1]-d[1])*u,b=(p[0]-d[0])*u,g=Math.sin(c/2)**2+Math.cos(d[1]*u)*Math.cos(p[1]*u)*Math.sin(b/2)**2;return 12742*Math.asin(Math.sqrt(g))},a=[t.reduce((d,p)=>d+p[0],0)/t.length,t.reduce((d,p)=>d+p[1],0)/t.length],s=t;if(t.length>=5){let d=[...t].sort((p,u)=>n(a,p)-n(a,u));s=d.slice(0,Math.ceil(d.length*.9))}if(Math.max(...s.map(d=>n(a,d)))<25){this.map.jumpTo({center:a,zoom:9.5});return}let r=new this.gl.LngLatBounds(s[0],s[0]);s.forEach(d=>r.extend(d));let l=this.el.clientHeight||380;this.map.fitBounds(r,{padding:{top:Math.min(90,l/4),bottom:Math.min(70,l/5),left:60,right:60},maxZoom:9,duration:0})}openPopup(t,n,a=[0,0]){let s=this.data;this.popup?.remove();let o=[t.city,t.cc||t.country].filter(Boolean).join(", "),r=[...new Set(t.points.map(u=>u.person))],l=t.points.sort((u,c)=>Number(c.online)-Number(u.online)||c.ts-u.ts).map(u=>{let c=s.people.find(g=>g.id===u.person),b=c?.devices.find(g=>g.id===u.device);return e("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(u.person,u.device)},[e("span",{class:`dl-pop-dot${u.online?" on":""}`}),e("span",{class:"dl-pop-name"},[e("b",{},c?.name??u.person),` · ${b?.name??"device"}`]),e("span",{class:"dl-faint dl-nowrap"},u.online?"now":ue(u.ts,s.now))])}),d=e("div",{class:"dl-pop"},[e("div",{class:"dl-pop-head"},[e("span",{class:"dl-pop-net"},v("globe")),e("div",{class:"dl-stack"},[e("strong",{},t.org||"Unknown network"),e("span",{class:"dl-faint"},[t.asn?`AS${t.asn} · `:"",o?`${o} · approximate`:"approximate location"])])]),e("div",{class:"dl-pop-list"},l),r.length===1?e("div",{class:"dl-pop-actions"},[e("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(r[0])},`Open ${s.people.find(u=>u.id===r[0])?.name??"person"}`)]):""]),p=this.el.clientHeight||380;this.map.easeTo({center:n,offset:[0,Math.min(140,p*.32)],duration:300}),this.popup=new this.gl.Popup({offset:[a[0],a[1]-18],anchor:"bottom",closeButton:!1,focusAfterOpen:!1,maxWidth:"300px",className:"dl-popup"}).setLngLat(n).setDOMContent(d).addTo(this.map)}};function dt(i,t,n=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],s=e("div",{class:"dl-seg",role:"tablist"});for(let[o,r]of a)o==="online"&&!n||s.appendChild(e("button",{type:"button",role:"tab",class:o===i?"on":"","data-v":o,click:()=>{s.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===o)),t(o)}},r));return s}var He=null;function pe(i,t){let n=a=>{He??(He=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),He.replaceChildren(...t().map(s=>typeof s=="string"?document.createTextNode(s):s)),He.style.display="",He.style.left=`${a.clientX}px`,He.style.top=`${a.clientY-10}px`};i.addEventListener("mouseenter",n),i.addEventListener("mousemove",n),i.addEventListener("mouseleave",()=>He&&(He.style.display="none"))}function dn(i,t=120,n=26){let a=Math.max(1,...i),s=e("div",{class:"dl-spark"});s.style.width=`${t}px`,s.style.height=`${n}px`;let o=Date.now();return i.forEach((r,l)=>{let d=e("i");d.style.height=`${Math.max(6,r/a*100)}%`,r||d.classList.add("zero");let p=i.length-1-l,u=new Date(o-p*864e5);pe(d,()=>[e("div",{class:"dl-tip-title"},p===0?"Today":p===1?"Yesterday":u.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},Z(r))]),s.appendChild(d)}),s}var pn=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"standard",title:"Standard",ic:"shield",stealth:2,speed:4,text:"Junk packets and random headers. Gets through most VPN blocking with no speed cost.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"strong",title:"Strong",ic:"shieldplus",stealth:3,speed:3,text:"More and larger junk packets for networks that block VPNs aggressively. Connects a little slower.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],We=i=>pn.find(t=>t.id===i),oa={v2:"Needs AmneziaWG 1.5 or newer on the router.",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."};function cn(i,t){return e("span",{class:"dl-dots",title:`${t}: ${i} of 4`},[e("span",{class:"dl-dots-label"},t),e("span",{class:"dl-dots-row"},[0,1,2,3].map(n=>e("i",{class:ndom.content(s,pn.map(r=>{let l=!r.needs||i[r.needs],d=r.id===t;return e("button",{type:"button",role:"radio","aria-checked":d?"true":"false","aria-disabled":l?null:"true",class:`dl-method${d?" on":""}${l?"":" off"}`,click:()=>{!l||d||(t=r.id,o(),n(r.id))}},[e("div",{class:"dl-method-head"},[e("span",{class:"dl-method-ic"},v(r.ic)),e("b",{},r.title),r.id===a?e("span",{class:"dl-pill ok"},"Current"):""]),e("p",{},r.text),e("div",{class:"dl-method-meters"},[cn(r.stealth,"Stealth"),cn(r.speed,"Speed")]),e("div",{class:"dl-method-foot"},l?[v("phone"),e("span",{},r.apps)]:[v("alert"),e("span",{},oa[r.needs])])])}));return o(),s}function Ze(i){return`${L.url("admin/network/dawnline/server")}?${i?`server=${encodeURIComponent(i)}&`:""}section=people`}function be(i,t){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(i)}${t?`&device=${encodeURIComponent(t)}`:""}`}var ra={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",paused_all:"warn",resumed_all:"ok",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},la={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",paused_all:"pause",resumed_all:"play"};function da(i,t){return t.device?i.people.flatMap(a=>a.devices).find(a=>a.id===t.device)?.kind??t.dkind??"other":la[t.type]??"activity"}var ca=["person_added","person_removed","person_changed","paused_all","resumed_all"];function xe(i){return i.by?i.by:ca.includes(i.type)||i.detail==="by admin"||i.detail?.endsWith(" (admin)")?"admin":i.detail?.endsWith(" (portal)")?"portal":null}function pa(i){return(i.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}function zt(i,t){let n=i.people.find(w=>w.id===t.person),a=n?.name??t.pname??t.person??"",s=n?.devices.find(w=>w.id===t.device)?.name??t.dname??"",o=w=>e("b",{},w),r=w=>e("span",{class:"dl-muted"},w),l=w=>e("span",{class:"dl-mono"},w),d=w=>t.hosts?.[w]?[e("span",{class:"dl-ev-host"},[e("b",{},t.hosts[w]),e("span",{class:"dl-faint"},` (${w})`)])]:[l(w)],p=w=>e("span",{class:"dl-ev-kind"},`${w} `),u=s?`${a} · ${s}`:a,c=pa(t),b=c||s||"a device",g=w=>[e("span",{class:"dl-you"},"You"),r(` ${w} `)];if(xe(t)==="admin")switch(t.type){case"device_added":return[...g("added"),p("device"),o(b),r(" for "),o(a)];case"device_removed":return[...g("removed"),p("device"),o(b),r(" from "),o(a)];case"paused":return[...g("paused"),p("person"),o(a)];case"resumed":return[...g("resumed"),p("person"),o(a)];case"device_changed":{let w=c.startsWith("renamed from ");return[...g(w?"renamed":c),p("device"),o(s||"a device"),r(" of "),o(a),...w?[r(` · was ${c.slice(13)}`)]:[]]}case"device_keys":return[...g("issued new keys for"),p("device"),o(b),r(" of "),o(a),r(" · it needs its new configuration")];case"link_changed":return[...g("issued a new link for"),p("person"),o(a),r(" · the old link stopped working")];case"paused_all":return[e("span",{class:"dl-you"},"You"),r(" paused everyone")];case"resumed_all":return[e("span",{class:"dl-you"},"You"),r(" resumed everyone")]}switch(t.type){case"connect":return[p("Device"),o(u),r(" connected"),...t.detail?[r(" from "),...d(t.detail)]:[],...t.where?[r(` · ${t.where}`)]:[]];case"disconnect":return[p("Device"),o(u),r(" went offline")];case"roam":return[p("Device"),o(u),r(" changed network "),...(t.detail??"").split(" → ").flatMap((w,F)=>F?[r(" → "),...d(w)]:d(w))];case"device_added":return[p("Person"),o(a),r(" added "),p("device"),o(b),...xe(t)==="portal"?[r(" on their portal")]:[]];case"device_removed":return[p("Person"),o(a),r(" removed "),p("device"),o(b),...xe(t)==="portal"?[r(" on their portal")]:[]];case"device_keys":return[p("Person"),o(a),r(" issued new keys for "),p("device"),o(b),r(" on their portal")];case"person_added":return[...g("added"),p("person"),o(t.detail??a)];case"person_removed":return[...g("removed"),p("person"),o(t.detail??a)];case"person_changed":return[...g("changed"),p("person"),o(a),...c?[r(` · ${c.replace(/_/g," ")}`)]:[]];case"paused":return[p("Person"),o(a),r(` paused — ${t.detail??""}`)];case"resumed":return[p("Person"),o(a),r(" resumed"),...t.detail&&t.detail!=="active"?[r(` — ${t.detail}`)]:[]];case"paused_all":return[r("Everyone paused")];case"resumed_all":return[r("Everyone resumed")];case"portal_blocked":return[e("b",{class:"dl-sys-src"},"Personal portal"),r(" blocked "),l(t.detail??""),r(" for 15 min after too many wrong codes")];case"devices_removed":return[p("Person"),o(a),r(" — all devices removed, end date reached")];default:return[r(`${t.type}${t.detail?`: ${t.detail}`:""}`)]}}var ha={portal_blocked:["globe","bad"]};function ua(i,t){if(i.servers.length<2||!t.person)return"";let n=i.people.find(s=>s.id===t.person),a=n&&i.servers.find(s=>s.id===n.server);return a?e("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function Ie(i,t,n={}){let a=ha[t.type],s=xe(t);return e("div",{class:`dl-row${s==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[s==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):a?e("span",{class:"dl-ev-tile sys"},v(a[0])):e("span",{class:`dl-ev-tile ev ${ra[t.type]??""}`},v(da(i,t))),e("span",{class:"dl-row-main"},zt(i,t)),n.server===!1?"":ua(i,t),e("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString()},ue(t.ts,i.now))])}function ma(i){let t=[],n=(s,o)=>e("a",{href:s},o);for(let s of i.servers)s.enabled&&!s.up&&t.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,n(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});i.settings.paused_all&&t.push({tone:"warn",text:["Everyone is paused."]});for(let s of i.people)if(s.state==="quota")t.push({tone:"warn",text:[n(be(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")t.push({tone:"warn",text:[n(be(s.id),s.name),"’s access has ended."]});else{let o=ze(s.expires);o!=null&&o>=0&&o<=Math.max(s.expire_warn,3)&&t.push({tone:"",text:[n(be(s.id),s.name),`’s access ends in ${o} day${o===1?"":"s"}.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&t.push({tone:"",text:[n(be(s.id),s.name)," has used 90% of the data limit."]})}let a=i.people.flatMap(s=>s.devices.filter(o=>o.config_stale).map(o=>[s,o]));return a.length&&t.push({tone:"warn",text:a.length===1?[n(be(a[0][0].id,a[0][1].id),`${a[0][0].name} · ${a[0][1].name}`)," needs its configuration again."]:[`${a.length} devices need their configuration again (networks or DNS changed).`]}),i.servers.some(s=>s.lan_like)&&i.like_home.error&&t.push({tone:"warn",text:[`Internet through the LAN is off: ${i.like_home.error} `,n(L.url("admin/network/dawnline/diagnostics"),"Details")]}),i.settings.portal_enabled||t.push({tone:"",text:["The personal portal is off. ",n(L.url("admin/network/dawnline/settings"),"Turn on")]}),t}function ct(i,t){let n=i.servers.find(d=>d.id===t)??i.servers[0],a=i.people.filter(d=>d.server===n.id),s=new Set(a.map(d=>d.id)),o=a.flatMap(d=>d.devices),r=d=>a.reduce((p,u)=>{let c=d(u);return[p[0]+c[0],p[1]+c[1]]},[0,0]),l=n.series?.[n.series.length-1];return{...i,servers:[n],people:a,series:n.series??i.series,events:i.events.filter(d=>d.person?s.has(d.person):!0),geo:{...i.geo,points:i.geo.points.filter(d=>s.has(d.person))},totals:{people:a.length,devices:o.length,online:o.filter(d=>d.online).length,active:a.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:r(d=>d.month)}}}var pt=class{constructor(t,n){this.srvId=t;this.go=n;this.el=e("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(t){this.st=ct(t,this.srvId);for(let n of["health","bento","side","activity"])this.parts[n]=e("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),e("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(t){this.st=ct(t,this.srvId),this.paint(),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let t=await z.health().catch(()=>null);if(!t)return;let n=t.checks.filter(o=>o.status==="warn"||o.status==="error");if(!n.length){dom.content(this.parts.health,"");return}let a=n.filter(o=>o.status==="error").length,s=`${n.length} ${a?n.length===1?"problem":"problems":n.length===1?"warning":"warnings"}`;dom.content(this.parts.health,e("div",{class:`dl-healthstrip ${a?"bad":"warn"}`},[e("span",{class:"dl-healthstrip-title"},[v("alert"),s]),...n.slice(0,3).map(o=>{let r=e("span",{class:"dl-healthstrip-item"},o.title);return pe(r,()=>[e("div",{class:"dl-tip-title"},o.title),e("div",{class:"dl-muted"},o.detail)]),r}),n.length>3?e("span",{class:"dl-sub"},`+${n.length-3} more`):"",e("a",{href:L.url("admin/network/dawnline/diagnostics")},n.some(o=>o.fix)?"Fix in Diagnostics →":"Open Diagnostics →")]))}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let t=this.st,n=e("div",{class:"dl-panel-head pad"},[e("div",{class:"dl-stack"},[e("h3",{},"Where people connect from"),e("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),e("span",{class:"dl-spacer"}),dt(this.range,o=>{this.range=o,this.map?.setRange(o)})]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[n,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map=new qe({openPerson:o=>location.href=be(o),openDevice:(o,r)=>location.href=be(o,r)},this.range);let a=e("div",{class:"dl-map-legend"},[e("span",{},[e("i",{class:"dot ok"}),"Online"]),e("span",{},[e("i",{class:"dot"}),"Seen recently"]),e("span",{},[e("i",{class:"line"}),"Live tunnel"])]),s=e("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[n,s])}paint(){let t=this.st,n=t.servers[0],a=t.people.reduce((l,d)=>l+Math.max(0,d.device_limit-d.devices.length),0),s=t.people.flatMap(l=>l.devices.filter(d=>d.online));dom.content(this.parts.bento,e("div",{class:"dl-bento"},[this.onlineTile(s),this.speedTile(),this.disguiseTile(n),this.monthTile(a)]));let o=ma(t);dom.content(this.parts.side,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Needs attention"),e("span",{class:"dl-spacer"}),e("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),o.length?o.slice(0,8).map(l=>e("div",{class:"dl-attn-item dl-row"},[e("span",{class:`dl-ev-dot ${l.tone}`}),e("span",{},l.text)])):e("div",{class:"dl-row dl-muted"},[v("check"),"All good. Nothing needs you right now."])]));let r=[...t.events].reverse().slice(0,8);dom.content(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-spacer"}),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),r.length?r.map(l=>Ie(t,l)):e("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]))}onlineTile(t){let n=this.st,a=12,s=j=>j.spark[j.spark.length-1]??0,o=j=>n.geo.points.find($=>$.device===j.id&&$.city)?.city,r=j=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(j.endpoint??""),l=j=>(r(j)?"home":o(j))??"",d=j=>[...n.events].reverse().find($=>$.type==="connect"&&$.device===j.id)?.ts??0,p=n.people.map(j=>({p:j,devs:j.devices.filter($=>$.online).sort(($,N)=>s(N)-s($))})).filter(j=>j.devs.length).sort((j,$)=>$.devs.reduce((N,C)=>N+s(C),0)-j.devs.reduce((N,C)=>N+s(C),0)),u=p.length<=2,c=({p:j,devs:$})=>{let N=$.map(d).filter(Boolean),C=N.length?Math.min(...N):0,T=(j.rate??[]).slice(-15),y=T[T.length-1],A=y&&n.now-y[0]<180?y:null,m=200,h=30,P=Math.max(1,...T.map(B=>Math.max(B[1],B[2]))),f=B=>T.map((S,q)=>`${T.length>1?q/(T.length-1)*m:m},${h-2-S[B]/P*(h-6)}`),_=T.length>1?Pe(``):"",O=!A||A[1]<64&&A[2]<64,G=j.access==="both"?["home","globe"]:j.access==="lan"?["home"]:["globe"];return[e("div",{class:"dl-hc"},[e("div",{class:"dl-hc-head"},[e("span",{class:"dl-onl-av sm"},Re(j.name)),e("span",{class:"dl-stack"},[e("b",{},j.name),e("span",{class:"dl-hc-since"},C?`online for ${ue(C,n.now).replace(" ago","")}`:"online")]),e("span",{class:"dl-hc-reach"},G.map(B=>e("span",{class:`dl-ibadge ${B==="home"?"lan":"inet"}`},v(B))))]),e("div",{class:"dl-hc-speed"},[e("div",{class:"dl-hc-speed-row"},O?[e("span",{class:"dl-faint"},"Idle right now")]:[e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${$e(A[2])}`]),e("span",{},[e("span",{class:"dl-up"},"↑"),` ${$e(A[1])}`]),e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint"},"15 min")]),_]),e("div",{class:"dl-hc-devs"},$.map(B=>e("span",{class:"dl-hc-dev"},[v(B.kind),[B.name,l(B)].filter(Boolean).join(" · ")]))),e("div",{class:"dl-hc-foot"},[e("span",{class:"dl-faint"},`${Z($.reduce((B,S)=>B+s(S),0))} today · ${Z(j.month[0]+j.month[1])} this month`)])])]},b=j=>{let{p:$,devs:N}=j,C=e("span",{class:"dl-onl-dev"},N.length>1?String(N.length):v(N[0].kind)),T=e("a",{class:`dl-onl-p${u?"":" sm"}`,href:be($.id),"aria-label":`${$.name}, online`},[e("span",{class:"dl-onl-av"},[Re($.name),C]),u?e("span",{class:"dl-onl-name"},$.name):"",u?e("span",{class:"dl-onl-meta"},[...N.slice(0,3).map(y=>v(y.kind)),N.length>3?`+${N.length-3}`:"",l(N[0])?e("span",{},` · ${l(N[0])}`):""]):""]);return pe(T,()=>c(j)),T},g=e("b",{class:`dl-onl-count${p.length?"":" none"}`},String(p.length)),w=p.reduce((j,$)=>j+$.devs.length,0);p.length&&pe(g,()=>[`${p.length} ${p.length===1?"person":"people"} · ${w} device${w===1?"":"s"}`]);let F=p.length>a?p.slice(0,a-1):p,Y=n.people.flatMap(j=>j.devices.map($=>({p:j,d:$}))).filter(j=>j.d.handshake).sort((j,$)=>$.d.handshake-j.d.handshake)[0];return e("div",{class:"dl-bento-tile online"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Online"),g]),p.length?e("div",{class:`dl-onl-row${u?"":" grid"}`},[...F.map(b),p.length>a?e("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:j=>{this.go&&(j.preventDefault(),this.go("people","online"))}},[e("span",{class:"dl-onl-av"},`+${p.length-F.length}`)]):""]):e("div",{class:"dl-onl-empty"},[e("span",{},"Nobody is connected"),Y?e("span",{class:"dl-sub"},`Last: ${Y.p.name}, ${ue(Y.d.handshake,n.now)}`):e("span",{class:"dl-sub"},"No device has connected yet")])])}speedTile(){return Rt(this.st.servers[0]?.rate??[],this.st.now,this.st.totals.today)}disguiseTile(t){let n=We(t.preset),a=t.obf??{},s=(l,d)=>e("span",{class:`dl-segs ${d}`},[0,1,2,3].map(p=>e("i",{class:p+a[l]).map(l=>`${l.toUpperCase()} ${a[l]}`);return r.length&&o.push(r.slice(0,2).join(" · ")+(r.length>2?` +${r.length-2}`:"")),["h1","h2","h3","h4"].some(l=>a[l]&&a[l]!==String(["h1","h2","h3","h4"].indexOf(l)+1))&&o.push("H1–H4 random"),a.i1&&o.push(a.i1.includes("0x8580")?"DNS-like first packet":"Signature packets"),a.header_protection_key&&o.push("Encrypted headers"),o.length||o.push(n?.id==="off"?"Plain WireGuard":"No values yet"),e("div",{class:"dl-bento-tile dl-disg"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Disguise"),e("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(t.id)}§ion=disguise`},"Change")]),e("div",{class:"dl-disg-id"},[e("span",{class:"dl-disg-ic"},v(n?.ic??"shield")),e("span",{class:"dl-stack"},[e("b",{},n?n.title:"Custom"),e("span",{class:"dl-sub"},n?n.short:"Set by hand")])]),n?e("div",{class:"dl-disg-meters"},[e("span",{},"Stealth"),s(n.stealth,"acc"),e("span",{},"Speed"),s(n.speed,"ok")]):"",e("div",{class:"dl-disg-chips"},o.map(l=>e("span",{},l)))])}monthTile(t){let n=this.st.totals,a=this.st.people.filter(s=>s.state!=="active").length;return Ht(this.st.series,`${n.people} ${n.people===1?"person":"people"}${a?` · ${a} paused`:""} · ${t} device slot${t===1?"":"s"} free`)}};function Rt(i,t,n){let a=i.slice(-15),s=a[a.length-1],o=s&&t-s[0]<180,r=o?s[2]:0,l=o?s[1]:0,[d,p]=n,u=200,c=40,b=Math.max(1,...a.map($=>Math.max($[1],$[2]))),g=$=>a.map((N,C)=>`${a.length>1?C/(a.length-1)*u:u},${c-2-N[$]/b*(c-6)}`),w=g(2),F=g(1),Y=a.length>1?Pe(``):e("div",{class:"dl-speed-wait"},[e("i"),e("span",{},"Collecting… 1 point a minute")]),j=($,N,C,T)=>e("div",{class:"dl-speed-col"},[e("span",{class:"dl-sub"},[e("span",{class:C},N),` ${$}`]),e("span",{class:"dl-speed-val"},$e(T))]);return a.length>1&&pe(Y,()=>{let $=a[a.length-1];return[e("div",{class:"dl-tip-title"},new Date($[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),e("div",{},`↓ ${$e($[2])} · ↑ ${$e($[1])}`)]}),e("div",{class:"dl-bento-tile"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Speed now"),e("span",{class:"dl-sub"},"last 15 min")]),e("div",{class:"dl-speed-cols"},[j("Download","↓","dl-dn",r),j("Upload","↑","dl-up",l)]),Y,e("div",{class:"dl-speed-today"},[e("span",{},["Today ",e("b",{},Z(d+p))]),e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${Z(p)} `,e("span",{class:"dl-up"},"↑"),` ${Z(d)}`])])])}function Ht(i,t){let n=i.slice(-30),a=n.map(p=>p.rx+p.tx),s=Math.max(1,...a),o=a.reduce((p,u)=>p+u,0),r=a.reduce((p,u,c)=>u>a[p]?c:p,0),l=p=>new Date(`${p}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"}),d=e("div",{class:"dl-bento-bars"},n.map((p,u)=>{let c=a[u],b=e("i",{class:u===n.length-1?"hi":"",style:`height:${Math.max(4,c/s*100)}%`});return pe(b,()=>[e("div",{class:"dl-tip-title"},u===n.length-1?`Today · ${l(p.day)}`:l(p.day)),e("div",{},Z(c)),e("div",{class:"dl-muted dl-mono"},`↓ ${Z(p.tx)} ↑ ${Z(p.rx)}`)]),b}));return e("div",{class:"dl-bento-tile month"},[e("div",{class:"dl-bento-head"},[e("span",{},[e("span",{class:"dl-metric-label"},"Last 30 days"),e("b",{class:"dl-bento-total"},Z(o))]),a[r]>0?e("span",{class:"dl-sub"},`peak ${Z(a[r])} · ${l(n[r].day)}`):""]),n.length?d:e("p",{class:"dl-muted"},"No traffic yet."),e("div",{class:"dl-bento-head"},[e("span",{class:"dl-sub"},n.length?l(n[0].day):""),e("span",{class:"dl-sub"},t),e("span",{class:"dl-sub"},"today")])])}var ga={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",paused_all:"people",resumed_all:"people",portal_blocked:"problems"},Xe=["connections","people","problems"],Ge={connections:"Connections",people:"People",problems:"Problems"},hn={connections:"Connects, disconnects and IP changes",people:"People and their devices added, changed, paused, removed",problems:"Blocked portal sign-ins (tunnels and services are in the service log)"},ht=i=>ga[i]??"problems";function fa(i){let t=new Map(i.people.map(a=>[a.id,a.name])),n=new Map(i.people.flatMap(a=>a.devices.map(s=>[s.id,s.name])));return{people:t,devices:n}}function va(i){let t=i==null?"":String(i);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}var ut={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"};function Le(i,t,n,a="",s=[]){let o=fa(i),r=[...t.map(c=>({ts:c.ts,category:ht(c.type),type:c.type,person:c.person?o.people.get(c.person)??c.pname??c.person:"",device:c.device?o.devices.get(c.device)??c.dname??c.device:"",detail:c.detail??"",where:c.where??"",by:xe(c)??""})),...s.map(c=>({ts:c.ts,category:"system",type:`${c.src}.${c.level}`,person:"",device:"",detail:`${c.who?`${c.who} `:""}${c.msg}${c.detail?` -${c.detail}`:""}`,where:ut[c.src]??c.src,by:""}))].sort((c,b)=>c.ts-b.ts).map(({ts:c,...b})=>({time:new Date(c*1e3).toISOString(),...b})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${a?`-${a}`:""}-${l}.${n}`;if(n==="json"){ve(d,JSON.stringify(r,null,2),"application/json");return}let p=["time","category","type","person","device","detail","where","by"],u=[p.join(","),...r.map(c=>p.map(b=>va(c[b])).join(","))].join(` -`);ve(d,u,"text/csv")}var ba=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]];function Ce(i,t,n,a,s,o=!1){let r=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...Xe.map(d=>e("option",{value:d,selected:d===s?"selected":null},Ge[d])),o?e("option",{value:"system",selected:s==="system"?"selected":null},"System"):""]),l=e("select",{class:"cbi-input-select"},ba.map(([d,p])=>e("option",{value:d},p)));se(i,[e("p",{class:"dl-muted"},`${t} This cannot be undone; export first if you want a copy.`),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Category"),r]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Which events"),l])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Clear",async()=>{let d=await U(async()=>{let p=o&&(r.value==="system"||r.value==="")?await z.serviceLogClear(l.value):{removed:0},u=r.value==="system"?{removed:0}:await z.logsClear({...n,category:r.value,older_days:l.value});return{removed:p.removed+u.removed}});d&&(X(),ne(d.removed?`${d.removed} event${d.removed===1?"":"s"} removed`:"Nothing matched","success",3e3),a())},"negative")])}function Fe(i,t,n,a){let s=i==="device"?`Clears ${n}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:i==="person"?`Clears ${n}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";se(i==="all"?"Reset all traffic history?":`Reset traffic history for ${n}?`,[e("p",{class:"dl-muted"},s)],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Reset",async()=>{await U(()=>z.usageClear(i,t),"Traffic history reset")&&(X(),a())},"negative")])}var mt=null;function xa(i){return i?new Date(i*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function un(i,t,n=!1){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},i),e("button",{type:"button",class:`dl-kvrow-v copy${n?" dl-mono":""}`,title:"Copy",click:()=>he(t,`${i} copied`)},[e("span",{},t),v("copy")])])}function gt(i,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},i),e("span",{class:"dl-kvrow-v"},t)])}function mn(i,t){if(/^\s*\[.+\]\s*$/.test(i))return e("span",{class:"dl-conf-sec"},i);let n=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(i);if(!n)return document.createTextNode(i);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(i);return e("span",{},[e("span",{class:"dl-conf-k"},n[1])," ",a&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):n[2]])}function wa(i){let t=!1,n=e("pre",{class:"dl-conf"}),a=()=>dom.content(n,i.conf.split(` +var An=Object.create;var Qt=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Nn=Object.getOwnPropertyNames;var zn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var Hn=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var In=(i,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Nn(t))!Rn.call(i,s)&&s!==n&&Qt(i,s,{get:()=>t[s],enumerable:!(a=Pn(t,s))||a.enumerable});return i};var Bn=(i,t,n)=>(n=i!=null?An(zn(i)):{},In(t||!i||!i.__esModule?Qt(n,"default",{value:i,enumerable:!0}):n,i));var nn=Hn((en,tn)=>{"use strict";var Xt=(function(){var i=function(_,N){var C=236,D=17,$=_,A=n[N],m=null,h=0,P=null,f=[],S={},j=function(M,E){h=$*4+17,m=(function(w){for(var y=new Array(w),T=0;T=7&&X(M),P==null&&(P=De($,A,f)),ie(P,E)},W=function(M,E){for(var w=-1;w<=7;w+=1)if(!(M+w<=-1||h<=M+w))for(var y=-1;y<=7;y+=1)E+y<=-1||h<=E+y||(0<=w&&w<=6&&(y==0||y==6)||0<=y&&y<=6&&(w==0||w==6)||2<=w&&w<=4&&2<=y&&y<=4?m[M+w][E+y]=!0:m[M+w][E+y]=!1)},v=function(){for(var M=0,E=0,w=0;w<8;w+=1){j(!0,w);var y=s.getLostPoint(S);(w==0||M>y)&&(M=y,E=w)}return E},U=function(){for(var M=8;M>w&1)==1;m[Math.floor(w/3)][w%3+h-8-3]=y}for(var w=0;w<18;w+=1){var y=!M&&(E>>w&1)==1;m[w%3+h-8-3][Math.floor(w/3)]=y}},le=function(M,E){for(var w=A<<3|E,y=s.getBCHTypeInfo(w),T=0;T<15;T+=1){var B=!M&&(y>>T&1)==1;T<6?m[T][8]=B:T<8?m[T+1][8]=B:m[h-15+T][8]=B}for(var T=0;T<15;T+=1){var B=!M&&(y>>T&1)==1;T<8?m[8][h-T-1]=B:T<9?m[8][15-T-1+1]=B:m[8][15-T-1]=B}m[h-8][8]=!M},ie=function(M,E){for(var w=-1,y=h-1,T=7,B=0,Y=s.getMaskFunction(E),F=h-1;F>0;F-=2)for(F==6&&(F-=1);;){for(var ae=0;ae<2;ae+=1)if(m[y][F-ae]==null){var de=!1;B>>T&1)==1);var J=Y(y,F-ae);J&&(de=!de),m[y][F-ae]=de,T-=1,T==-1&&(B+=1,T=7)}if(y+=w,y<0||h<=y){y-=w,w=-w;break}}},me=function(M,E){for(var w=0,y=0,T=0,B=new Array(E.length),Y=new Array(E.length),F=0;F=0?Yt.getAt(Vt):0}}for(var Jt=0,J=0;JF*8)throw"code length overflow. ("+T.getLengthInBits()+">"+F*8+")";for(T.getLengthInBits()+4<=F*8&&T.put(0,4);T.getLengthInBits()%8!=0;)T.putBit(!1);for(;!(T.getLengthInBits()>=F*8||(T.put(C,8),T.getLengthInBits()>=F*8));)T.put(D,8);return me(T,y)};S.addData=function(M,E){E=E||"Byte";var w=null;switch(E){case"Numeric":w=p(M);break;case"Alphanumeric":w=u(M);break;case"Byte":w=c(M);break;case"Kanji":w=x(M);break;default:throw"mode:"+E}f.push(w),P=null},S.isDark=function(M,E){if(M<0||h<=M||E<0||h<=E)throw M+","+E;return m[M][E]},S.getModuleCount=function(){return h},S.make=function(){if($<1){for(var M=1;M<40;M++){for(var E=l.getRSBlocks(M,A),w=d(),y=0;y"u"?M*4:E;var w="";w+='";for(var T=0;T';w+=""}return w+="",w+="
",w},S.createSvgTag=function(M,E,w,y){var T={};typeof arguments[0]=="object"&&(T=arguments[0],M=T.cellSize,E=T.margin,w=T.alt,y=T.title),M=M||2,E=typeof E>"u"?M*4:E,w=typeof w=="string"?{text:w}:w||{},w.text=w.text||null,w.id=w.text?w.id||"qrcode-description":null,y=typeof y=="string"?{text:y}:y||{},y.text=y.text||null,y.id=y.text?y.id||"qrcode-title":null;var B=S.getModuleCount()*M+E*2,Y,F,ae,de,J="",ge;for(ge="l"+M+",0 0,"+M+" -"+M+",0 0,-"+M+"z ",J+=''+H(y.text)+"":"",J+=w.text?''+H(w.text)+"":"",J+='',J+='"u"?M*4:E;var w=S.getModuleCount()*M+E*2,y=E,T=w-E;return I(w,w,function(B,Y){if(y<=B&&B"u"?M*4:E;var y=S.getModuleCount()*M+E*2,T="";return T+="",T};var H=function(M){for(var E="",w=0;w":E+=">";break;case"&":E+="&";break;case'"':E+=""";break;default:E+=y;break}}return E},re=function(M){var E=1;M=typeof M>"u"?E*2:M;var w=S.getModuleCount()*E+M*2,y=M,T=w-M,B,Y,F,ae,de,J={"██":"█","█ ":"▀"," █":"▄"," ":" "},ge={"██":"▀","█ ":"▀"," █":" "," ":" "},fe="";for(B=0;B=T?ge[de]:J[de];fe+=` +`}return w%2&&M>0?fe.substring(0,fe.length-w-1)+Array(w+1).join("▀"):fe.substring(0,fe.length-1)};return S.createASCII=function(M,E){if(M=M||1,M<2)return re(E);M-=1,E=typeof E>"u"?M*2:E;var w=S.getModuleCount()*M+E*2,y=E,T=w-E,B,Y,F,ae,de=Array(M+1).join("██"),J=Array(M+1).join(" "),ge="",fe="";for(B=0;B>>8),A.push(P&255)):A.push(D)}}return A}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},s=(function(){var _=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],N=1335,C=7973,D=21522,$={},A=function(m){for(var h=0;m!=0;)h+=1,m>>>=1;return h};return $.getBCHTypeInfo=function(m){for(var h=m<<10;A(h)-A(N)>=0;)h^=N<=0;)h^=C<5&&(P+=3+j-5)}for(var f=0;f=256;)$-=255;return _[$]},D})();function r(_,N){if(typeof _.length>"u")throw _.length+"/"+N;var C=(function(){for(var $=0;$<_.length&&_[$]==0;)$+=1;for(var A=new Array(_.length-$+N),m=0;m<_.length-$;m+=1)A[m]=_[m+$];return A})(),D={};return D.getAt=function($){return C[$]},D.getLength=function(){return C.length},D.multiply=function($){for(var A=new Array(D.getLength()+$.getLength()-1),m=0;m"u")throw"bad rs block @ typeNumber:"+$+"/errorCorrectionLevel:"+A;for(var h=m.length/3,P=[],f=0;f>>7-D%8&1)==1},C.put=function(D,$){for(var A=0;A<$;A+=1)C.putBit((D>>>$-A-1&1)==1)},C.getLengthInBits=function(){return N},C.putBit=function(D){var $=Math.floor(N/8);_.length<=$&&_.push(0),D&&(_[$]|=128>>>N%8),N+=1},C},p=function(_){var N=t.MODE_NUMBER,C=_,D={};D.getMode=function(){return N},D.getLength=function(m){return C.length},D.write=function(m){for(var h=C,P=0;P+2>>8&255)*192+(f&255),m.put(f,13),P+=2}if(P>>8)},N.writeBytes=function(C,D,$){D=D||0,$=$||C.length;for(var A=0;A<$;A+=1)N.writeByte(C[A+D])},N.writeString=function(C){for(var D=0;D0&&(C+=","),C+=_[D];return C+="]",C},N},k=function(){var _=0,N=0,C=0,D="",$={},A=function(h){D+=String.fromCharCode(m(h&63))},m=function(h){if(!(h<0)){if(h<26)return 65+h;if(h<52)return 97+(h-26);if(h<62)return 48+(h-52);if(h==62)return 43;if(h==63)return 47}throw"n:"+h};return $.writeByte=function(h){for(_=_<<8|h&255,N+=8,C+=1;N>=6;)A(_>>>N-6),N-=6},$.flush=function(){if(N>0&&(A(_<<6-N),_=0,N=0),C%3!=0)for(var h=3-C%3,P=0;P=N.length){if($==0)return-1;throw"unexpected end of file./"+$}var h=N.charAt(C);if(C+=1,h=="=")return $=0,-1;if(h.match(/^\s$/))continue;D=D<<6|m(h.charCodeAt(0)),$+=6}var P=D>>>$-8&255;return $-=8,P};var m=function(h){if(65<=h&&h<=90)return h-65;if(97<=h&&h<=122)return h-97+26;if(48<=h&&h<=57)return h-48+52;if(h==43)return 62;if(h==47)return 63;throw"c:"+h};return A},K=function(_,N){var C=_,D=N,$=new Array(_*N),A={};A.setPixel=function(f,S,j){$[S*C+f]=j},A.write=function(f){f.writeString("GIF87a"),f.writeShort(C),f.writeShort(D),f.writeByte(128),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(255),f.writeByte(255),f.writeByte(255),f.writeString(","),f.writeShort(0),f.writeShort(0),f.writeShort(C),f.writeShort(D),f.writeByte(0);var S=2,j=h(S);f.writeByte(S);for(var W=0;j.length-W>255;)f.writeByte(255),f.writeBytes(j,W,255),W+=255;f.writeByte(j.length-W),f.writeBytes(j,W,j.length-W),f.writeByte(0),f.writeString(";")};var m=function(f){var S=f,j=0,W=0,v={};return v.write=function(U,q){if(U>>>q)throw"length over";for(;j+q>=8;)S.writeByte(255&(U<>>=8-j,W=0,j=0;W=U<0&&S.writeByte(W)},v},h=function(f){for(var S=1<>6,128|o&63):o<55296||o>=57344?a.push(224|o>>12,128|o>>6&63,128|o&63):(s++,o=65536+((o&1023)<<10|n.charCodeAt(s)&1023),a.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63))}return a}return t(i)}})();(function(i){typeof define=="function"&&define.amd?define([],i):typeof en=="object"&&(tn.exports=i())})(function(){return Xt})});function Et(i,t){return i==null||i===!1||i===""||(Array.isArray(i)?i.forEach(n=>Et(n,t)):t.push(i instanceof Node?i:String(i))),t}function e(i,t,n){let a=window.E,s=t!=null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Node);return!s&&n===void 0?a(i,{},Et(t,[])):a(i,s?t:{},Et(n,[]))}function V(i,t=[]){let n=rpc.declare({object:"luci.dawnline",method:i,params:t});return async(...a)=>{let s=await n(...a);if(s&&typeof s=="object"&&typeof s.error=="string")throw new Error(s.error);return s}}var jn=V("logs_clear",["person","device","category","older_days"]),On=(i={})=>jn(i.person??"",i.device??"",i.category??"",i.older_days??""),Un=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets"]});async function qn(i,t){let a=[i,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(o=>t[o]),t.paused,t.services,t.circle,t.home_nets],s=await Un(...a);if(s&&typeof s.error=="string")throw new Error(s.error);return s}var Wn=V("status",["days"]),Gn=0;async function Fn(i){let t=await Wn(i);return Gn=Date.now(),t}var z={personUpdate:qn,settingsGet:V("settings_get"),settingsUpdate:V("settings_update",["values"]),serviceSet:V("service_set",["id","name","address","ports"]),serviceDelete:V("service_delete",["id"]),geoClear:V("geo_clear"),events:V("events",["limit"]),logsClear:On,interfaces:V("interfaces",["id"]),serverInterfaces:V("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:V("circle_set",["id","server","name","color","members"]),circleDelete:V("circle_delete",["id"]),accessCheck:V("access_check",["from","to"]),homeHosts:V("home_hosts",["id"]),usageClear:V("usage_clear",["scope","id"]),uninstall:V("uninstall",["confirm"]),status:Fn,setupDefaults:V("setup_defaults"),serverCreate:V("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:V("server_obfuscation",["id","preset"]),serverUpdate:V("server_update",["id","values"]),serverDelete:V("server_delete",["id"]),personCreate:V("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:V("person_pause",["id","paused"]),personRegen:V("person_regen",["id"]),personDelete:V("person_delete",["id"]),personUsage:V("person_usage",["id","days"]),pauseAll:V("pause_all",["paused"]),deviceCreate:V("device_create",["person","name","kind"]),deviceConfig:V("device_config",["id"]),deviceUpdate:V("device_update",["id","name","disabled"]),deviceDelete:V("device_delete",["id"]),deviceRotate:V("device_rotate",["id"]),apply:V("apply"),health:V("health"),healthFix:V("health_fix",["id"]),serviceLog:V("service_log"),serviceLogClear:V("service_log_clear",["older_days"]),backupList:V("backup_list"),backupCreate:V("backup_create"),backupRestore:V("backup_restore",["name"]),backupDelete:V("backup_delete",["name"]),backupRead:V("backup_read",["name"]),backupUpload:V("backup_upload",["data"]),exportJson:V("export"),importJson:V("import",["data"]),updatesStatus:V("updates_status"),updatesRun:V("updates_run",["what"])};var Zt={phone:'',computer:'',tablet:'',router:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function Tt(i,t="dl-icon"){let n=Zt[i]??Zt.phone;return``}function b(i,t="dl-icon"){let n=document.createElement("span");return n.className="dl-icon-wrap",n.innerHTML=Tt(i,t),n}function R(i,t,n="neutral",a={}){let{disabled:s,...o}=a,r=e("button",{class:`cbi-button cbi-button-${n}`,type:"button",...o,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!r.disabled){r.disabled=!0,r.classList.add("spinning");try{await t(l)}catch(d){te(Ct(d),"error")}finally{r.disabled=!1,r.classList.remove("spinning")}}}},i);return r.disabled=!!s,r}function ke(i,t,n,a="neutral",s=""){return R([b(i),e("span",{class:"dl-btn-label"},t)],n,a,{title:t,class:`cbi-button cbi-button-${a} dl-icon-btn ${s}`.trim()})}function te(i,t="info",n=0){let a=document.querySelector(".dl-toasts");a||(a=e("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(a));let s=t==="error"?"x":t==="warning"?"alert":t==="success"?"check":null,o=()=>{r.classList.remove("show"),setTimeout(()=>r.remove(),200)},r=e("div",{class:`dl-toast ${t}`},[s?b(s):"",e("span",{},i),t==="error"?e("button",{type:"button","aria-label":"Close",click:o},b("x")):""]);a.appendChild(r),requestAnimationFrame(()=>r.classList.add("show")),setTimeout(o,n||(t==="error"?8e3:t==="warning"?5e3:2600))}function Ct(i){return i instanceof Error?i.message:String(i)}async function O(i,t){try{let n=await i();return t&&te(t,"success",3500),n}catch(n){te(Ct(n),"error",1e4);return}}function ne(i,t,n,a=""){ui.showModal(i,[e("div",{class:`dl-modal ${a}`},t),e("div",{class:"button-row"},n)])}function Z(){ui.hideModal()}function oe(i,t,n="Confirm",a=!1){return new Promise(s=>{ne(i,t,[e("button",{class:"cbi-button cbi-button-neutral",type:"button",click:()=>{Z(),s(!1)}},"Cancel")," ",e("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{Z(),s(!0)}},n)])})}async function pe(i,t="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(i);else{let n=e("textarea",{style:"position:fixed;opacity:0"},i);document.body.appendChild(n),n.select(),document.execCommand("copy"),n.remove()}te(t,"success",2500)}catch(n){te(Ct(n),"error")}}function ve(i,t,n="text/plain"){let a=globalThis,s=typeof t=="string"?new a.Blob([t],{type:n}):t,o=URL.createObjectURL(s),r=e("a",{href:o,download:i,style:"display:none"});document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(o),r.remove()},1e3)}function Ae(i,t){let n={ok:"success",warn:"warning",error:"error",info:"notice"}[i];return e("div",{class:`alert-message ${n}`},t)}function Pe(i,t=""){let n=e("div",{class:t});return n.innerHTML=i,n}function Dt(i,t){return new Promise(n=>{let a=e("input",{type:"file",accept:i,style:"display:none"});a.addEventListener("cancel",()=>{a.remove(),n(null)}),a.addEventListener("change",()=>{let s=a.files?.[0];if(a.remove(),!s)return n(null);let o=new FileReader;o.onload=()=>{let r=String(o.result??"");n({name:s.name,data:t==="base64"?r.replace(/^data:[^,]*,/,""):r})},o.onerror=()=>n(null),t==="base64"?o.readAsDataURL(s):o.readAsText(s)}),document.body.appendChild(a),a.click()})}function we(i,t){let n=document.querySelector(".dl-dd");if(n&&(n.dlClose?n.dlClose():n.remove(),n.dlAnchor===i))return;let a=e("div",{class:"dl-dd dl-root",role:"menu"},t.map(u=>u?e("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),u.run()}},[u.icon??"",e("span",{},u.label)]):e("hr")));document.body.appendChild(a);let s=i.getBoundingClientRect(),o=a.offsetWidth,r=a.offsetHeight;a.style.top=`${s.bottom+6+r>window.innerHeight-8&&s.top-6-r>8?s.top-6-r:s.bottom+6}px`,a.style.left=`${Math.max(8,Math.min(s.right-o,window.innerWidth-o-8))}px`;let l=u=>{!a.contains(u.target)&&!i.contains(u.target)&&p()},d=u=>{u.key==="Escape"&&p()};a.dlAnchor=i,a.dlClose=p;function p(){a.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",p,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var an=Bn(nn(),1),Kn='';function Oe(i,t=3,n=!0){let a=(0,an.default)(0,i.length>300?"Q":"H");a.addData(i,"Byte"),a.make();let s=a.getModuleCount(),o=s+t*2,r=n?Math.round(s*.22):0;r&&(s-r)%2&&r++;let l=(s-r)/2,d=l+r,p=(x,g)=>r>0&&x>=l&&x=l&&g${Kn}`}return`${c}`}var Yn={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Vn={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function Jn(i){let t={};for(let[n,a]of Object.entries(Vn))i[n]!=null&&i[n]!==""&&(t[a]=String(i[n]));return t}function Qn(i,t){let n=i.amnezia,a=n.obfuscation??{},s=d=>a[d]!=null&&a[d]!==""?String(a[d]):Yn[d],o=n.host.replace(/^\[(.*)\]$/,"$1"),r={H1:s("h1"),H2:s("h2"),H3:s("h3"),H4:s("h4"),I1:s("i1"),I2:s("i2"),I3:s("i3"),I4:s("i4"),I5:s("i5"),Jc:s("jc"),Jmin:s("jmin"),Jmax:s("jmax"),S1:s("s1"),S2:s("s2"),S3:s("s3"),S4:s("s4"),...Jn(a),allowed_ips:n.allowed_ips,client_ip:n.client_ip,client_priv_key:n.client_priv_key,client_pub_key:n.client_pub_key,config:i.conf.replace(/\r?\n/g,`\r +`),hostName:o,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(r),port:String(n.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:o};return n.dns[0]&&(l.dns1=n.dns[0]),n.dns[1]&&(l.dns2=n.dns[1]),l}function Zn(i){let t="";for(let n=0;n"u")return null;try{let n=new t.Blob([i]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.Response(n).arrayBuffer()),s=new Uint8Array(4+a.length);return new DataView(s.buffer).setUint32(0,i.length,!1),s.set(a,4),s}catch{return null}}async function sn(i,t,n=!0){let a=new TextEncoder().encode(JSON.stringify(Qn(i,t))),s=n?await Xn(a):null;return`vpn://${Zn(s??a)}`}function Q(i){if(!i||i<0)return"0 B";let t=["B","KB","MB","GB","TB"],n=0,a=i;for(;a>=1024&&n=100||n===0?Math.round(a):a.toFixed(1)} ${t[n]}`}function $e(i){let t=i*8;return t<1e3?`${Math.round(t)} bit/s`:t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)} kbit/s`:t<1e9?`${(t/1e6).toFixed(t<1e7?1:0)} Mbit/s`:`${(t/1e9).toFixed(1)} Gbit/s`}function he(i,t=Date.now()/1e3){if(!i)return"never";let n=Math.max(0,Math.round(t-i));return n<60?"just now":n<3600?`${Math.floor(n/60)} min ago`:n<86400?`${Math.floor(n/3600)} h ago`:n<86400*30?`${Math.floor(n/86400)} d ago`:new Date(i*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function on(i){if(!i||i<0)return"—";let t=Math.floor(i/86400),n=Math.floor(i%86400/3600),a=Math.floor(i%3600/60);return t?`${t}d ${n}h`:n?`${n}h ${a}m`:`${a}m`}function Ne(i){let t=new Date(i*1e3),n=new Date,a=t.toDateString()===n.toDateString(),s=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?s:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${s}`}function _e(i){if(!i)return"";let[t,n,a]=i.split("-").map(Number);return new Date(t,n-1,a).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ze(i,t=Date.now()){if(!i)return null;let[n,a,s]=i.split("-").map(Number),o=new Date(n,a-1,s,23,59,59).getTime();return Math.ceil((o-t)/864e5)}var Ue={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var rn=["computer","phone","tablet","router","other"],Se={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},At={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Re(i){let t=i.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let n=t[0][0]??"",a=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(n+a).toUpperCase()}function rt(i){let t=n=>n.disabled?3:n.online?0:n.handshake?1:2;return i.map((n,a)=>[n,a]).sort((n,a)=>t(n[0])-t(a[0])||n[1]-a[1]).map(([n])=>n)}var ln="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl",ea="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",ta="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",na={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Je=null;function aa(i){let t=window;return i.appendChild(e("link",{rel:"stylesheet",href:`${ln}.css`})),t.maplibregl?Promise.resolve(t.maplibregl):Je||(Je=new Promise((n,a)=>{let s=e("script",{src:`${ln}.js`});s.onload=()=>t.maplibregl?n(t.maplibregl):a(new Error("MapLibre failed to load")),s.onerror=()=>{Je=null,a(new Error("Could not load the map library (no internet access from this browser?)"))},i.appendChild(s)}),Je)}function lt(){let i=document.documentElement.getAttribute("data-darkmode");return i!=null?i==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function sa(i,t,n=48){let a=(i[0]+t[0])/2,s=(i[1]+t[1])/2,o=t[0]-i[0],r=t[1]-i[1],l=Math.hypot(o,r)||1,d=Math.min(.25*l,12),p=a-r/l*d,u=s+o/l*d,c=[];for(let x=0;x<=n;x++){let g=x/n,k=1-g;c.push([k*k*i[0]+2*k*g*p+g*g*t[0],k*k*i[1]+2*k*g*u+g*g*t[1]])}return c}function ia(i,t){let n=new Map;for(let a of i.geo.points){if(i.person&&a.person!==i.person||(t==="online"?!a.online:i.now-a.ts>na[t]))continue;let s=n.get(a.device);(!s||a.online&&!s.online||a.online===s.online&&a.ts>s.ts)&&n.set(a.device,a)}return[...n.values()]}var qe=class{constructor(t,n="online",a=380){this.cb=t;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.anim=0;this.data=null;this.fitted=!1;this.range=n,this.status=e("div",{class:"dl-map-status"}),this.el=e("div",{class:"dl-geomap",style:`height:${a}px`},this.status)}async mount(t){this.data=t;try{this.gl=await aa(this.el)}catch(n){this.status.textContent=n.message;return}this.map=new this.gl.Map({container:this.el,style:lt()?ea:ta,center:[t.geo.home?.lon??20,t.geo.home?.lat??50],zoom:3,attributionControl:{compact:!0},dragRotate:!1,pitchWithRotate:!1,cooperativeGestures:!0}),this.map.addControl(new this.gl.NavigationControl({showCompass:!1}),"bottom-right"),this.map.on("load",()=>{this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],"#40c977",lt()?"#ededed":"#0d0d0d"],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],"#40c977",lt()?"#ededed":"#0d0d0d"],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],!1],layout:{"line-cap":"round"},paint:{"line-color":lt()?"#ededed":"#0d0d0d","line-opacity":.35,"line-width":1.5,"line-dasharray":[2,3]}}),this.map.addLayer({id:"dl-arc-glow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-opacity":.18,"line-width":7}}),this.map.addLayer({id:"dl-arc-live",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-width":2}}),this.map.addLayer({id:"dl-arc-flow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#ffffff","line-width":2,"line-opacity":.8,"line-dasharray":[0,4,3]}}),this.animate(),this.draw()})}setRange(t){this.range=t,this.fitted=!1,this.draw()}update(t){this.data=t,this.draw()}destroy(){cancelAnimationFrame(this.anim),this.map?.remove(),this.map=null}animate(){let t=[[0,4,3],[.5,4,2.5],[1,4,2],[1.5,4,1.5],[2,4,1],[2.5,4,.5],[3,4,0],[0,.5,3,3.5],[0,1,3,3],[0,1.5,3,2.5],[0,2,3,2],[0,2.5,3,1.5],[0,3,3,1],[0,3.5,3,.5]],n=-1,a=0,s=o=>{this.map&&(o-a>70&&(a=o,n=(n+1)%t.length,this.map.getLayer("dl-arc-flow")&&this.map.setPaintProperty("dl-arc-flow","line-dasharray",t[n])),this.anim=requestAnimationFrame(s))};this.anim=requestAnimationFrame(s)}groups(t){let n=new Map;for(let a of t){let s=`${a.asn||a.org||a.ip}|${a.city}|${a.cc}`,o=n.get(s);o||(o={key:s,lat:a.lat,lon:a.lon,city:a.city,country:a.country,cc:a.cc,asn:a.asn,org:a.org,online:!1,ts:0,points:[]},n.set(s,o)),o.points.push(a),o.online||(o.online=a.online),o.ts=Math.max(o.ts,a.ts)}return[...n.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let t=this.data,n=this.groups(ia(t,this.range)),a=t.geo.home;for(let r of this.markers)r.remove();this.markers=[];let s=new Map,o=n.map(r=>{let l=`${r.lat.toFixed(2)},${r.lon.toFixed(2)}`,d=s.get(l)??0;return s.set(l,d+1),{g:r,at:[r.lon+d*.25,r.lat]}});if(this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:o.map(({g:r,at:l})=>({type:"Feature",properties:{online:r.online},geometry:{type:"Point",coordinates:l}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?o.map(({g:r,at:l})=>({type:"Feature",properties:{online:r.online},geometry:{type:"LineString",coordinates:sa([a.lon,a.lat],l)}})):[]}),a){let r=e("div",{class:"dl-mk-home",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`});r.innerHTML=Tt("home","dl-mk-home-ic"),this.markers.push(new this.gl.Marker({element:r}).setLngLat([a.lon,a.lat]).addTo(this.map))}for(let{g:r,at:l}of o){let d=r.points.length,p=e("button",{type:"button",class:`dl-mk${r.online?" online":""}${d>1?" multi":""}`,"aria-label":`${d} device${d===1?"":"s"} via ${r.org||"unknown network"} in ${r.city||"unknown city"}`},d>1?e("span",{class:"dl-mk-count"},String(d)):e("span",{class:"dl-mk-dot"})),c=!!a&&Math.abs(l[0]-a.lon)<.02&&Math.abs(l[1]-a.lat)<.02?[22,-16]:[0,0];p.addEventListener("click",x=>{x.stopPropagation(),this.openPopup(r,l,c)}),this.markers.push(new this.gl.Marker({element:p,offset:c}).setLngLat(l).addTo(this.map))}if(!this.fitted){let r=o.map(l=>l.at);a&&(r.length===0||this.range!=="online"||o.some(l=>l.g.online))&&r.push([a.lon,a.lat]),this.fit(r),this.fitted=!0}this.status.textContent=o.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none"}fit(t){if(!t.length)return;let n=(d,p)=>{let u=Math.PI/180,c=(p[1]-d[1])*u,x=(p[0]-d[0])*u,g=Math.sin(c/2)**2+Math.cos(d[1]*u)*Math.cos(p[1]*u)*Math.sin(x/2)**2;return 12742*Math.asin(Math.sqrt(g))},a=[t.reduce((d,p)=>d+p[0],0)/t.length,t.reduce((d,p)=>d+p[1],0)/t.length],s=t;if(t.length>=5){let d=[...t].sort((p,u)=>n(a,p)-n(a,u));s=d.slice(0,Math.ceil(d.length*.9))}if(Math.max(...s.map(d=>n(a,d)))<25){this.map.jumpTo({center:a,zoom:9.5});return}let r=new this.gl.LngLatBounds(s[0],s[0]);s.forEach(d=>r.extend(d));let l=this.el.clientHeight||380;this.map.fitBounds(r,{padding:{top:Math.min(90,l/4),bottom:Math.min(70,l/5),left:60,right:60},maxZoom:9,duration:0})}openPopup(t,n,a=[0,0]){let s=this.data;this.popup?.remove();let o=[t.city,t.cc||t.country].filter(Boolean).join(", "),r=[...new Set(t.points.map(u=>u.person))],l=t.points.sort((u,c)=>Number(c.online)-Number(u.online)||c.ts-u.ts).map(u=>{let c=s.people.find(g=>g.id===u.person),x=c?.devices.find(g=>g.id===u.device);return e("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(u.person,u.device)},[e("span",{class:`dl-pop-dot${u.online?" on":""}`}),e("span",{class:"dl-pop-name"},[e("b",{},c?.name??u.person),` · ${x?.name??"device"}`]),e("span",{class:"dl-faint dl-nowrap"},u.online?"now":he(u.ts,s.now))])}),d=e("div",{class:"dl-pop"},[e("div",{class:"dl-pop-head"},[e("span",{class:"dl-pop-net"},b("globe")),e("div",{class:"dl-stack"},[e("strong",{},t.org||"Unknown network"),e("span",{class:"dl-faint"},[t.asn?`AS${t.asn} · `:"",o?`${o} · approximate`:"approximate location"])])]),e("div",{class:"dl-pop-list"},l),r.length===1?e("div",{class:"dl-pop-actions"},[e("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(r[0])},`Open ${s.people.find(u=>u.id===r[0])?.name??"person"}`)]):""]),p=this.el.clientHeight||380;this.map.easeTo({center:n,offset:[0,Math.min(140,p*.32)],duration:300}),this.popup=new this.gl.Popup({offset:[a[0],a[1]-18],anchor:"bottom",closeButton:!1,focusAfterOpen:!1,maxWidth:"300px",className:"dl-popup"}).setLngLat(n).setDOMContent(d).addTo(this.map)}};function dt(i,t,n=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],s=e("div",{class:"dl-seg",role:"tablist"});for(let[o,r]of a)o==="online"&&!n||s.appendChild(e("button",{type:"button",role:"tab",class:o===i?"on":"","data-v":o,click:()=>{s.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===o)),t(o)}},r));return s}var He=null;function ce(i,t){let n=a=>{He??(He=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),He.replaceChildren(...t().map(s=>typeof s=="string"?document.createTextNode(s):s)),He.style.display="",He.style.left=`${a.clientX}px`,He.style.top=`${a.clientY-10}px`};i.addEventListener("mouseenter",n),i.addEventListener("mousemove",n),i.addEventListener("mouseleave",()=>He&&(He.style.display="none"))}function dn(i,t=120,n=26){let a=Math.max(1,...i),s=e("div",{class:"dl-spark"});s.style.width=`${t}px`,s.style.height=`${n}px`;let o=Date.now();return i.forEach((r,l)=>{let d=e("i");d.style.height=`${Math.max(6,r/a*100)}%`,r||d.classList.add("zero");let p=i.length-1-l,u=new Date(o-p*864e5);ce(d,()=>[e("div",{class:"dl-tip-title"},p===0?"Today":p===1?"Yesterday":u.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},Q(r))]),s.appendChild(d)}),s}var pn=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"standard",title:"Standard",ic:"shield",stealth:2,speed:4,text:"Junk packets and random headers. Gets through most VPN blocking with no speed cost.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"strong",title:"Strong",ic:"shieldplus",stealth:3,speed:3,text:"More and larger junk packets for networks that block VPNs aggressively. Connects a little slower.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],We=i=>pn.find(t=>t.id===i),oa={v2:"Needs AmneziaWG 1.5 or newer on the router.",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."};function cn(i,t){return e("span",{class:"dl-dots",title:`${t}: ${i} of 4`},[e("span",{class:"dl-dots-label"},t),e("span",{class:"dl-dots-row"},[0,1,2,3].map(n=>e("i",{class:ndom.content(s,pn.map(r=>{let l=!r.needs||i[r.needs],d=r.id===t;return e("button",{type:"button",role:"radio","aria-checked":d?"true":"false","aria-disabled":l?null:"true",class:`dl-method${d?" on":""}${l?"":" off"}`,click:()=>{!l||d||(t=r.id,o(),n(r.id))}},[e("div",{class:"dl-method-head"},[e("span",{class:"dl-method-ic"},b(r.ic)),e("b",{},r.title),r.id===a?e("span",{class:"dl-pill ok"},"Current"):""]),e("p",{},r.text),e("div",{class:"dl-method-meters"},[cn(r.stealth,"Stealth"),cn(r.speed,"Speed")]),e("div",{class:"dl-method-foot"},l?[b("phone"),e("span",{},r.apps)]:[b("alert"),e("span",{},oa[r.needs])])])}));return o(),s}function Qe(i){return`${L.url("admin/network/dawnline/server")}?${i?`server=${encodeURIComponent(i)}&`:""}section=people`}function be(i,t){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(i)}${t?`&device=${encodeURIComponent(t)}`:""}`}var ra={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",paused_all:"warn",resumed_all:"ok",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},la={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",paused_all:"pause",resumed_all:"play"};function da(i,t){return t.device?i.people.flatMap(a=>a.devices).find(a=>a.id===t.device)?.kind??t.dkind??"other":la[t.type]??"activity"}var ca=["person_added","person_removed","person_changed","paused_all","resumed_all"];function xe(i){return i.by?i.by:ca.includes(i.type)||i.detail==="by admin"||i.detail?.endsWith(" (admin)")?"admin":i.detail?.endsWith(" (portal)")?"portal":null}function pa(i){return(i.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}function Nt(i,t){let n=i.people.find(k=>k.id===t.person),a=n?.name??t.pname??t.person??"",s=n?.devices.find(k=>k.id===t.device)?.name??t.dname??"",o=k=>e("b",{},k),r=k=>e("span",{class:"dl-muted"},k),l=k=>e("span",{class:"dl-mono"},k),d=k=>t.hosts?.[k]?[e("span",{class:"dl-ev-host"},[e("b",{},t.hosts[k]),e("span",{class:"dl-faint"},` (${k})`)])]:[l(k)],p=k=>e("span",{class:"dl-ev-kind"},`${k} `),u=s?`${a} · ${s}`:a,c=pa(t),x=c||s||"a device",g=k=>[e("span",{class:"dl-you"},"You"),r(` ${k} `)];if(xe(t)==="admin")switch(t.type){case"device_added":return[...g("added"),p("device"),o(x),r(" for "),o(a)];case"device_removed":return[...g("removed"),p("device"),o(x),r(" from "),o(a)];case"paused":return[...g("paused"),p("person"),o(a)];case"resumed":return[...g("resumed"),p("person"),o(a)];case"device_changed":{let k=c.startsWith("renamed from ");return[...g(k?"renamed":c),p("device"),o(s||"a device"),r(" of "),o(a),...k?[r(` · was ${c.slice(13)}`)]:[]]}case"device_keys":return[...g("issued new keys for"),p("device"),o(x),r(" of "),o(a),r(" · it needs its new configuration")];case"link_changed":return[...g("issued a new link for"),p("person"),o(a),r(" · the old link stopped working")];case"paused_all":return[e("span",{class:"dl-you"},"You"),r(" paused everyone")];case"resumed_all":return[e("span",{class:"dl-you"},"You"),r(" resumed everyone")]}switch(t.type){case"connect":return[p("Device"),o(u),r(" connected"),...t.detail?[r(" from "),...d(t.detail)]:[],...t.where?[r(` · ${t.where}`)]:[]];case"disconnect":return[p("Device"),o(u),r(" went offline")];case"roam":return[p("Device"),o(u),r(" changed network "),...(t.detail??"").split(" → ").flatMap((k,G)=>G?[r(" → "),...d(k)]:d(k))];case"device_added":return[p("Person"),o(a),r(" added "),p("device"),o(x),...xe(t)==="portal"?[r(" on their portal")]:[]];case"device_removed":return[p("Person"),o(a),r(" removed "),p("device"),o(x),...xe(t)==="portal"?[r(" on their portal")]:[]];case"device_keys":return[p("Person"),o(a),r(" issued new keys for "),p("device"),o(x),r(" on their portal")];case"person_added":return[...g("added"),p("person"),o(t.detail??a)];case"person_removed":return[...g("removed"),p("person"),o(t.detail??a)];case"person_changed":return[...g("changed"),p("person"),o(a),...c?[r(` · ${c.replace(/_/g," ")}`)]:[]];case"paused":return[p("Person"),o(a),r(` paused — ${t.detail??""}`)];case"resumed":return[p("Person"),o(a),r(" resumed"),...t.detail&&t.detail!=="active"?[r(` — ${t.detail}`)]:[]];case"paused_all":return[r("Everyone paused")];case"resumed_all":return[r("Everyone resumed")];case"portal_blocked":return[e("b",{class:"dl-sys-src"},"Personal portal"),r(" blocked "),l(t.detail??""),r(" for 15 min after too many wrong codes")];case"devices_removed":return[p("Person"),o(a),r(" — all devices removed, end date reached")];default:return[r(`${t.type}${t.detail?`: ${t.detail}`:""}`)]}}var ha={portal_blocked:["globe","bad"]};function ua(i,t){if(i.servers.length<2||!t.person)return"";let n=i.people.find(s=>s.id===t.person),a=n&&i.servers.find(s=>s.id===n.server);return a?e("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function Ie(i,t,n={}){let a=ha[t.type],s=xe(t);return e("div",{class:`dl-row${s==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[s==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):a?e("span",{class:"dl-ev-tile sys"},b(a[0])):e("span",{class:`dl-ev-tile ev ${ra[t.type]??""}`},b(da(i,t))),e("span",{class:"dl-row-main"},Nt(i,t)),n.server===!1?"":ua(i,t),e("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString()},he(t.ts,i.now))])}function ma(i){let t=[],n=(s,o)=>e("a",{href:s},o);for(let s of i.servers)s.enabled&&!s.up&&t.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,n(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});i.settings.paused_all&&t.push({tone:"warn",text:["Everyone is paused."]});for(let s of i.people)if(s.state==="quota")t.push({tone:"warn",text:[n(be(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")t.push({tone:"warn",text:[n(be(s.id),s.name),"’s access has ended."]});else{let o=ze(s.expires);o!=null&&o>=0&&o<=Math.max(s.expire_warn,3)&&t.push({tone:"",text:[n(be(s.id),s.name),`’s access ends in ${o} day${o===1?"":"s"}.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&t.push({tone:"",text:[n(be(s.id),s.name)," has used 90% of the data limit."]})}let a=i.people.flatMap(s=>s.devices.filter(o=>o.config_stale).map(o=>[s,o]));return a.length&&t.push({tone:"warn",text:a.length===1?[n(be(a[0][0].id,a[0][1].id),`${a[0][0].name} · ${a[0][1].name}`)," needs its configuration again."]:[`${a.length} devices need their configuration again (networks or DNS changed).`]}),i.servers.some(s=>s.lan_like)&&i.like_home.error&&t.push({tone:"warn",text:[`Internet through the LAN is off: ${i.like_home.error} `,n(L.url("admin/network/dawnline/diagnostics"),"Details")]}),i.settings.portal_enabled||t.push({tone:"",text:["The personal portal is off. ",n(L.url("admin/network/dawnline/settings"),"Turn on")]}),t}function ct(i,t){let n=i.servers.find(d=>d.id===t)??i.servers[0],a=i.people.filter(d=>d.server===n.id),s=new Set(a.map(d=>d.id)),o=a.flatMap(d=>d.devices),r=d=>a.reduce((p,u)=>{let c=d(u);return[p[0]+c[0],p[1]+c[1]]},[0,0]),l=n.series?.[n.series.length-1];return{...i,servers:[n],people:a,series:n.series??i.series,events:i.events.filter(d=>d.person?s.has(d.person):!0),geo:{...i.geo,points:i.geo.points.filter(d=>s.has(d.person))},totals:{people:a.length,devices:o.length,online:o.filter(d=>d.online).length,active:a.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:r(d=>d.month)}}}var pt=class{constructor(t,n){this.srvId=t;this.go=n;this.el=e("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(t){this.st=ct(t,this.srvId);for(let n of["health","bento","side","activity"])this.parts[n]=e("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),e("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(t){this.st=ct(t,this.srvId),this.paint(),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let t=await z.health().catch(()=>null);if(!t)return;let n=t.checks.filter(o=>o.status==="warn"||o.status==="error");if(!n.length){dom.content(this.parts.health,"");return}let a=n.filter(o=>o.status==="error").length,s=`${n.length} ${a?n.length===1?"problem":"problems":n.length===1?"warning":"warnings"}`;dom.content(this.parts.health,e("div",{class:`dl-healthstrip ${a?"bad":"warn"}`},[e("span",{class:"dl-healthstrip-title"},[b("alert"),s]),...n.slice(0,3).map(o=>{let r=e("span",{class:"dl-healthstrip-item"},o.title);return ce(r,()=>[e("div",{class:"dl-tip-title"},o.title),e("div",{class:"dl-muted"},o.detail)]),r}),n.length>3?e("span",{class:"dl-sub"},`+${n.length-3} more`):"",e("a",{href:L.url("admin/network/dawnline/diagnostics")},n.some(o=>o.fix)?"Fix in Diagnostics →":"Open Diagnostics →")]))}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let t=this.st,n=e("div",{class:"dl-panel-head pad"},[e("div",{class:"dl-stack"},[e("h3",{},"Where people connect from"),e("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),e("span",{class:"dl-spacer"}),dt(this.range,o=>{this.range=o,this.map?.setRange(o)})]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[n,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map=new qe({openPerson:o=>location.href=be(o),openDevice:(o,r)=>location.href=be(o,r)},this.range);let a=e("div",{class:"dl-map-legend"},[e("span",{},[e("i",{class:"dot ok"}),"Online"]),e("span",{},[e("i",{class:"dot"}),"Seen recently"]),e("span",{},[e("i",{class:"line"}),"Live tunnel"])]),s=e("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[n,s])}paint(){let t=this.st,n=t.servers[0],a=t.people.reduce((l,d)=>l+Math.max(0,d.device_limit-d.devices.length),0),s=t.people.flatMap(l=>l.devices.filter(d=>d.online));dom.content(this.parts.bento,e("div",{class:"dl-bento"},[this.onlineTile(s),this.speedTile(),this.disguiseTile(n),this.monthTile(a)]));let o=ma(t);dom.content(this.parts.side,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Needs attention"),e("span",{class:"dl-spacer"}),e("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),o.length?o.slice(0,8).map(l=>e("div",{class:"dl-attn-item dl-row"},[e("span",{class:`dl-ev-dot ${l.tone}`}),e("span",{},l.text)])):e("div",{class:"dl-row dl-muted"},[b("check"),"All good. Nothing needs you right now."])]));let r=[...t.events].reverse().slice(0,8);dom.content(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-spacer"}),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),r.length?r.map(l=>Ie(t,l)):e("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]))}onlineTile(t){let n=this.st,a=12,s=I=>I.spark[I.spark.length-1]??0,o=I=>n.geo.points.find(_=>_.device===I.id&&_.city)?.city,r=I=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(I.endpoint??""),l=I=>(r(I)?"home":o(I))??"",d=I=>[...n.events].reverse().find(_=>_.type==="connect"&&_.device===I.id)?.ts??0,p=n.people.map(I=>({p:I,devs:I.devices.filter(_=>_.online).sort((_,N)=>s(N)-s(_))})).filter(I=>I.devs.length).sort((I,_)=>_.devs.reduce((N,C)=>N+s(C),0)-I.devs.reduce((N,C)=>N+s(C),0)),u=p.length<=2,c=({p:I,devs:_})=>{let N=_.map(d).filter(Boolean),C=N.length?Math.min(...N):0,D=(I.rate??[]).slice(-15),$=D[D.length-1],A=$&&n.now-$[0]<180?$:null,m=200,h=30,P=Math.max(1,...D.map(v=>Math.max(v[1],v[2]))),f=v=>D.map((U,q)=>`${D.length>1?q/(D.length-1)*m:m},${h-2-U[v]/P*(h-6)}`),S=D.length>1?Pe(``):"",j=!A||A[1]<64&&A[2]<64,W=I.access==="both"?["home","globe"]:I.access==="lan"?["home"]:["globe"];return[e("div",{class:"dl-hc"},[e("div",{class:"dl-hc-head"},[e("span",{class:"dl-onl-av sm"},Re(I.name)),e("span",{class:"dl-stack"},[e("b",{},I.name),e("span",{class:"dl-hc-since"},C?`online for ${he(C,n.now).replace(" ago","")}`:"online")]),e("span",{class:"dl-hc-reach"},W.map(v=>e("span",{class:`dl-ibadge ${v==="home"?"lan":"inet"}`},b(v))))]),e("div",{class:"dl-hc-speed"},[e("div",{class:"dl-hc-speed-row"},j?[e("span",{class:"dl-faint"},"Idle right now")]:[e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${$e(A[2])}`]),e("span",{},[e("span",{class:"dl-up"},"↑"),` ${$e(A[1])}`]),e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint"},"15 min")]),S]),e("div",{class:"dl-hc-devs"},_.map(v=>e("span",{class:"dl-hc-dev"},[b(v.kind),[v.name,l(v)].filter(Boolean).join(" · ")]))),e("div",{class:"dl-hc-foot"},[e("span",{class:"dl-faint"},`${Q(_.reduce((v,U)=>v+s(U),0))} today · ${Q(I.month[0]+I.month[1])} this month`)])])]},x=I=>{let{p:_,devs:N}=I,C=e("span",{class:"dl-onl-dev"},N.length>1?String(N.length):b(N[0].kind)),D=e("a",{class:`dl-onl-p${u?"":" sm"}`,href:be(_.id),"aria-label":`${_.name}, online`},[e("span",{class:"dl-onl-av"},[Re(_.name),C]),u?e("span",{class:"dl-onl-name"},_.name):"",u?e("span",{class:"dl-onl-meta"},[...N.slice(0,3).map($=>b($.kind)),N.length>3?`+${N.length-3}`:"",l(N[0])?e("span",{},` · ${l(N[0])}`):""]):""]);return ce(D,()=>c(I)),D},g=e("b",{class:`dl-onl-count${p.length?"":" none"}`},String(p.length)),k=p.reduce((I,_)=>I+_.devs.length,0);p.length&&ce(g,()=>[`${p.length} ${p.length===1?"person":"people"} · ${k} device${k===1?"":"s"}`]);let G=p.length>a?p.slice(0,a-1):p,K=n.people.flatMap(I=>I.devices.map(_=>({p:I,d:_}))).filter(I=>I.d.handshake).sort((I,_)=>_.d.handshake-I.d.handshake)[0];return e("div",{class:"dl-bento-tile online"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Online"),g]),p.length?e("div",{class:`dl-onl-row${u?"":" grid"}`},[...G.map(x),p.length>a?e("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:I=>{this.go&&(I.preventDefault(),this.go("people","online"))}},[e("span",{class:"dl-onl-av"},`+${p.length-G.length}`)]):""]):e("div",{class:"dl-onl-empty"},[e("span",{},"Nobody is connected"),K?e("span",{class:"dl-sub"},`Last: ${K.p.name}, ${he(K.d.handshake,n.now)}`):e("span",{class:"dl-sub"},"No device has connected yet")])])}speedTile(){return zt(this.st.servers[0]?.rate??[],this.st.now,this.st.totals.today)}disguiseTile(t){let n=We(t.preset),a=t.obf??{},s=(l,d)=>e("span",{class:`dl-segs ${d}`},[0,1,2,3].map(p=>e("i",{class:p+a[l]).map(l=>`${l.toUpperCase()} ${a[l]}`);return r.length&&o.push(r.slice(0,2).join(" · ")+(r.length>2?` +${r.length-2}`:"")),["h1","h2","h3","h4"].some(l=>a[l]&&a[l]!==String(["h1","h2","h3","h4"].indexOf(l)+1))&&o.push("H1–H4 random"),a.i1&&o.push(a.i1.includes("0x8580")?"DNS-like first packet":"Signature packets"),a.header_protection_key&&o.push("Encrypted headers"),o.length||o.push(n?.id==="off"?"Plain WireGuard":"No values yet"),e("div",{class:"dl-bento-tile dl-disg"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Disguise"),e("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(t.id)}§ion=disguise`},"Change")]),e("div",{class:"dl-disg-id"},[e("span",{class:"dl-disg-ic"},b(n?.ic??"shield")),e("span",{class:"dl-stack"},[e("b",{},n?n.title:"Custom"),e("span",{class:"dl-sub"},n?n.short:"Set by hand")])]),n?e("div",{class:"dl-disg-meters"},[e("span",{},"Stealth"),s(n.stealth,"acc"),e("span",{},"Speed"),s(n.speed,"ok")]):"",e("div",{class:"dl-disg-chips"},o.map(l=>e("span",{},l)))])}monthTile(t){let n=this.st.totals,a=this.st.people.filter(s=>s.state!=="active").length;return Rt(this.st.series,`${n.people} ${n.people===1?"person":"people"}${a?` · ${a} paused`:""} · ${t} device slot${t===1?"":"s"} free`)}};function zt(i,t,n){let a=i.slice(-15),s=a[a.length-1],o=s&&t-s[0]<180,r=o?s[2]:0,l=o?s[1]:0,[d,p]=n,u=200,c=40,x=Math.max(1,...a.map(_=>Math.max(_[1],_[2]))),g=_=>a.map((N,C)=>`${a.length>1?C/(a.length-1)*u:u},${c-2-N[_]/x*(c-6)}`),k=g(2),G=g(1),K=a.length>1?Pe(``):e("div",{class:"dl-speed-wait"},[e("i"),e("span",{},"Collecting… 1 point a minute")]),I=(_,N,C,D)=>e("div",{class:"dl-speed-col"},[e("span",{class:"dl-sub"},[e("span",{class:C},N),` ${_}`]),e("span",{class:"dl-speed-val"},$e(D))]);return a.length>1&&ce(K,()=>{let _=a[a.length-1];return[e("div",{class:"dl-tip-title"},new Date(_[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),e("div",{},`↓ ${$e(_[2])} · ↑ ${$e(_[1])}`)]}),e("div",{class:"dl-bento-tile"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Speed now"),e("span",{class:"dl-sub"},"last 15 min")]),e("div",{class:"dl-speed-cols"},[I("Download","↓","dl-dn",r),I("Upload","↑","dl-up",l)]),K,e("div",{class:"dl-speed-today"},[e("span",{},["Today ",e("b",{},Q(d+p))]),e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${Q(p)} `,e("span",{class:"dl-up"},"↑"),` ${Q(d)}`])])])}function Rt(i,t){let n=i.slice(-30),a=n.map(p=>p.rx+p.tx),s=Math.max(1,...a),o=a.reduce((p,u)=>p+u,0),r=a.reduce((p,u,c)=>u>a[p]?c:p,0),l=p=>new Date(`${p}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"}),d=e("div",{class:"dl-bento-bars"},n.map((p,u)=>{let c=a[u],x=e("i",{class:u===n.length-1?"hi":"",style:`height:${Math.max(4,c/s*100)}%`});return ce(x,()=>[e("div",{class:"dl-tip-title"},u===n.length-1?`Today · ${l(p.day)}`:l(p.day)),e("div",{},Q(c)),e("div",{class:"dl-muted dl-mono"},`↓ ${Q(p.tx)} ↑ ${Q(p.rx)}`)]),x}));return e("div",{class:"dl-bento-tile month"},[e("div",{class:"dl-bento-head"},[e("span",{},[e("span",{class:"dl-metric-label"},"Last 30 days"),e("b",{class:"dl-bento-total"},Q(o))]),a[r]>0?e("span",{class:"dl-sub"},`peak ${Q(a[r])} · ${l(n[r].day)}`):""]),n.length?d:e("p",{class:"dl-muted"},"No traffic yet."),e("div",{class:"dl-bento-head"},[e("span",{class:"dl-sub"},n.length?l(n[0].day):""),e("span",{class:"dl-sub"},t),e("span",{class:"dl-sub"},"today")])])}var ga={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",paused_all:"people",resumed_all:"people",portal_blocked:"problems"},Ze=["connections","people","problems"],Ge={connections:"Connections",people:"People",problems:"Problems"},hn={connections:"Connects, disconnects and IP changes",people:"People and their devices added, changed, paused, removed",problems:"Blocked portal sign-ins (tunnels and services are in the service log)"},ht=i=>ga[i]??"problems";function fa(i){let t=new Map(i.people.map(a=>[a.id,a.name])),n=new Map(i.people.flatMap(a=>a.devices.map(s=>[s.id,s.name])));return{people:t,devices:n}}function va(i){let t=i==null?"":String(i);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}var ut={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"};function Le(i,t,n,a="",s=[]){let o=fa(i),r=[...t.map(c=>({ts:c.ts,category:ht(c.type),type:c.type,person:c.person?o.people.get(c.person)??c.pname??c.person:"",device:c.device?o.devices.get(c.device)??c.dname??c.device:"",detail:c.detail??"",where:c.where??"",by:xe(c)??""})),...s.map(c=>({ts:c.ts,category:"system",type:`${c.src}.${c.level}`,person:"",device:"",detail:`${c.who?`${c.who} `:""}${c.msg}${c.detail?` +${c.detail}`:""}`,where:ut[c.src]??c.src,by:""}))].sort((c,x)=>c.ts-x.ts).map(({ts:c,...x})=>({time:new Date(c*1e3).toISOString(),...x})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${a?`-${a}`:""}-${l}.${n}`;if(n==="json"){ve(d,JSON.stringify(r,null,2),"application/json");return}let p=["time","category","type","person","device","detail","where","by"],u=[p.join(","),...r.map(c=>p.map(x=>va(c[x])).join(","))].join(` +`);ve(d,u,"text/csv")}var ba=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]];function Te(i,t,n,a,s,o=!1){let r=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...Ze.map(d=>e("option",{value:d,selected:d===s?"selected":null},Ge[d])),o?e("option",{value:"system",selected:s==="system"?"selected":null},"System"):""]),l=e("select",{class:"cbi-input-select"},ba.map(([d,p])=>e("option",{value:d},p)));ne(i,[e("p",{class:"dl-muted"},`${t} This cannot be undone; export first if you want a copy.`),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Category"),r]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Which events"),l])],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Clear",async()=>{let d=await O(async()=>{let p=o&&(r.value==="system"||r.value==="")?await z.serviceLogClear(l.value):{removed:0},u=r.value==="system"?{removed:0}:await z.logsClear({...n,category:r.value,older_days:l.value});return{removed:p.removed+u.removed}});d&&(Z(),te(d.removed?`${d.removed} event${d.removed===1?"":"s"} removed`:"Nothing matched","success",3e3),a())},"negative")])}function Fe(i,t,n,a){let s=i==="device"?`Clears ${n}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:i==="person"?`Clears ${n}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";ne(i==="all"?"Reset all traffic history?":`Reset traffic history for ${n}?`,[e("p",{class:"dl-muted"},s)],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Reset",async()=>{await O(()=>z.usageClear(i,t),"Traffic history reset")&&(Z(),a())},"negative")])}var mt=null;function xa(i){return i?new Date(i*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function un(i,t,n=!1){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},i),e("button",{type:"button",class:`dl-kvrow-v copy${n?" dl-mono":""}`,title:"Copy",click:()=>pe(t,`${i} copied`)},[e("span",{},t),b("copy")])])}function gt(i,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},i),e("span",{class:"dl-kvrow-v"},t)])}function mn(i,t){if(/^\s*\[.+\]\s*$/.test(i))return e("span",{class:"dl-conf-sec"},i);let n=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(i);if(!n)return document.createTextNode(i);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(i);return e("span",{},[e("span",{class:"dl-conf-k"},n[1])," ",a&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):n[2]])}function wa(i){let t=!1,n=e("pre",{class:"dl-conf"}),a=()=>dom.content(n,i.conf.split(` `).flatMap((r,l)=>l?[` -`,mn(r,t)]:[mn(r,t)])),s=e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),t=!t,dom.content(s,[v(t?"x":"key"),t?"Hide key":"Show key"]),a()}},[v("key"),"Show key"]);a();let o=new Blob([i.conf]).size;return e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-filecard"},[e("span",{class:"dl-filecard-ic"},".conf"),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono dl-ellipsis"},i.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${o} bytes · import it in the app`)]),R([v("download")," Download"],()=>ve(i.filename,i.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[v("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),s,e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),he(i.conf,"Configuration copied")}},[v("copy"),"Copy"])]),n])])}async function It(i,t="file"){if(!i.has_private_key)return e("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let n=await sn(i,`${i.server} · ${i.person} · ${i.name}`),a={qr:()=>e("div",{class:"dl-qr-pane"},[Pe(Oe(i.conf),"dl-qr"),e("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-linkbox"},[e("span",{class:"dl-mono"},n),R("Copy",()=>he(n,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>wa(i)},s=e("div",{class:"dl-connect-body"}),o=e("div",{class:"dl-seg"}),r=l=>{o.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(s,a[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])o.appendChild(e("button",{type:"button","data-id":l,click:()=>r(l)},d));return r(t),e("div",{class:"dl-stack gap12"},[o,s])}function ya(i,t,n,a){mt?.close();let s=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[i,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>l()},v("x"))]),e("div",{class:"dl-drawer-body"},t),n?e("div",{class:"dl-drawer-foot"},n):""]),o=e("div",{class:"dl-drawer-overlay dl-root",click:p=>{p.target===o&&l()}},s),r=p=>{p.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&l()};function l(){document.removeEventListener("keydown",r),o.classList.remove("open"),setTimeout(()=>o.remove(),220),mt===d&&(mt=null),a()}let d={close:l,panel:s};return document.addEventListener("keydown",r),document.body.appendChild(o),requestAnimationFrame(()=>o.classList.add("open")),mt=d,d}var gn={connect:["ok","Connected","plug"],disconnect:["","Went offline","plug"],roam:["","Changed network","network"],device_added:["ok","Added","plus"],device_removed:["","Removed","trash"],device_keys:["","New keys","reset"]};function ka(i,t){let n=i.filter(a=>a.device===t&&gn[a.type]).reverse().slice(0,12);return n.length?e("div",{class:"dl-dev-log"},n.map(a=>{let[s,o,r]=gn[a.type],l=a.type==="connect"?[a.detail?e("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?e("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[e("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[e("span",{class:"dl-muted"},xe(a)==="portal"?" on the portal":xe(a)==="admin"?" by you":"")]:[],d=new Date(a.ts*1e3);return e("div",{class:`dl-dev-log-row${xe(a)==="admin"?" dl-ev-by-admin":""}`},[xe(a)==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):e("span",{class:`dl-ev-tile ev ${s}`},v(r)),e("span",{class:"dl-row-main"},[e("span",{},o),...l]),e("span",{class:"dl-faint dl-nowrap",title:d.toLocaleString()},ue(a.ts))])})):e("div",{class:"dl-sub"},"No activity yet.")}function $a(i){return i.disabled?e("span",{class:"dl-dstat"},"Disabled"):i.online?e("span",{class:"dl-dstat ok"},"Connected"):i.handshake?e("span",{class:"dl-dstat"},`Last seen ${ue(i.handshake)}`):e("span",{class:"dl-dstat warn"},"Waiting for the first connection")}async function De(i,t,n,a){let s=await U(()=>z.deviceConfig(t.id));if(!s)return;let o=t,r=i,l=await It(s),d=e("div",{class:"dl-drawer-title"}),p=e("div",{}),u=e("div",{}),c=e("div",{},e("div",{class:"dl-sub"},"Loading…")),b=[],g=async()=>{let h=await z.events(5e3).catch(()=>null);h&&(b=h.events.filter(P=>P.device===o.id),dom.content(c,ka(h.events,o.id)))},w=()=>{let h=a?.points.find(f=>f.device===o.id&&f.ip===o.endpoint);dom.content(d,[e("span",{class:`dl-dcard-ic${o.online?" on":""}`},v(o.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},o.name),R([v("edit")],()=>Y(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},[`${r.name} · ${Se[o.kind]}`])])]);let P=o.spark.reduce((f,_)=>f+_,0);dom.content(p,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),$a(o)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},Z(o.month[0]+o.month[1])),e("span",{class:"dl-sub dl-mono"},`↓ ${Z(o.month[1])} ↑ ${Z(o.month[0])}`)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"Last 7 days"),e("b",{},Z(P)),dn(o.spark,120,22)])])),dom.content(u,e("div",{class:"dl-kv2"},[un("Tunnel address",o.address),o.hostname&&r.access!=="internet"?un("Local address",o.hostname):"",o.endpoint?gt("Client IP",e("span",{},[o.endpoint,h?e("span",{class:"dl-muted"},` · ${[h.city,h.org].filter(Boolean).join(" · ")}`):""])):"",gt("Total",e("span",{class:"dl-kv-act"},[`↓ ${Z(o.total[1])} · ↑ ${Z(o.total[0])}`,e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe("device",o.id,o.name,()=>setTimeout(F,300))},"Reset")])),gt("Added",`${xa(o.created)} · ${o.created_by==="portal"?"from the portal":"by you"}`),gt("Public key",e("span",{class:"dl-mono dl-faint"},s.amnezia.client_pub_key?`${s.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(j,[R([v(o.disabled?"play":"pause"),o.disabled?" Enable":" Disable"],async()=>{await U(()=>z.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&await F()},"neutral",o.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),R([v("key")," New keys"],async()=>{if(!await re("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;if(await U(()=>z.deviceRotate(o.id),"New keys generated")){n(),m.close();let _=await z.status(1),O=_.people.find(B=>B.id===r.id),G=O?.devices.find(B=>B.id===o.id);O&&G&&De(O,G,n,_.geo)}}),e("span",{class:"dl-spacer"}),R([v("trash")," Remove"],async()=>{await re(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>z.deviceDelete(o.id),"Device removed")&&(m.close(),n())},"negative")])},F=async()=>{let h=await z.status(1).catch(()=>null),P=h?.people.find(_=>_.id===r.id),f=P?.devices.find(_=>_.id===o.id);!h||!P||!f||(r=P,o=f,a=h.geo,w(),n())},Y=()=>{let h=e("input",{type:"text",class:"cbi-input-text",value:o.name,maxlength:48});se(`Rename ${o.name}`,[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},h)])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{await U(()=>z.deviceUpdate(o.id,h.value,void 0),"Renamed")&&(X(),await F())},"positive")]),setTimeout(()=>h.select(),50)},j=e("div",{class:"dl-drawer-actions"}),$=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Connect")]),o.config_stale?e("div",{class:"dl-note warn"},[v("alert"),e("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",l]),N=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Activity"),e("div",{class:"dl-dsec-actions"},[e("button",{type:"button",class:"dl-linkbtn",click:()=>Le({people:[r]},b,"csv",o.id)},"Export"),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Ce(`Clear ${o.name}'s activity`,`Removes events about ${o.name}.`,{device:o.id},g)},"Clear"),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),c]),C=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},e("h4",{},"Details")),u]),T=!o.handshake||o.config_stale,y=e("div",{class:"dl-stack gap16"},T?[p,$,C,N]:[p,C,N,$]);g();let A=window.setInterval(()=>{F(),g()},8e3),m=ya(d,y,j,()=>clearInterval(A));w()}function Ke(i,t){let n=e("input",{type:"text",class:"cbi-input-text",placeholder:Se.phone,maxlength:48}),a="phone",s=e("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},rn.map(r=>e("button",{type:"button",role:"radio",class:r===a?"on":"","aria-checked":r===a?"true":"false","data-kind":r,click:()=>{a=r,s.querySelectorAll("button").forEach(l=>{let d=l.dataset.kind===r;l.classList.toggle("on",d),l.setAttribute("aria-checked",d?"true":"false")}),n.placeholder=Se[r]}},[v(r),e("span",{},Se[r])]))),o=i.devices.length>=i.device_limit;se(`Add a device for ${i.name}`,[o?e("p",{class:"dl-hint"},`${i.name} already has ${i.devices.length} of ${i.device_limit} devices. As admin you can still add one.`):"",e("div",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Type"),s]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Name"),n])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Add device",async()=>{let r=n.value.trim()||n.placeholder.replace(/^e\.g\. /,""),l=await U(()=>z.deviceCreate(i.id,r,a));if(!l)return;X(),ne(`${r} added`,"success",3e3),t();let d=await z.status(1),p=d.people.find(c=>c.id===i.id),u=p?.devices.find(c=>c.id===l.id);p&&u&&De(p,u,t,d.geo)},"positive")]),setTimeout(()=>n.focus(),50)}var Me=1080,tt=1512,ye=96,_a="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Sa="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",et=i=>i.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function La(i,t,n){let a=new URL(n),s=a.pathname.slice(1),o=Math.min(92,Math.floor((Me-2*ye)/(.58*(4+i.name.length)))),r=Me-2*ye,l=392,d=40,p=Oe(n,2).replace("`${F}`;return``+u(ye+82,ye+42,36,"#a3a3a3",et(t))+u(ye,276,o,"#ffffff",`Hi, ${et(i.name)}`,'font-weight="600"')+u(ye,340,40,"#8a8a8a",`Scan to connect to ${et(t)}`)+``+p+`${et(s)}`+u(Me/2,l+r+156,34,"#737373",et(a.host),'text-anchor="middle"')+""}async function Ma(i){let t=new Image;t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`,await t.decode();let n=document.createElement("canvas");return n.width=Me,n.height=tt,n.getContext("2d").drawImage(t,0,0,Me,tt),new Promise((a,s)=>n.toBlob(o=>o?a(o):s(new Error("Could not draw the card")),"image/png"))}async function nt(i,t,n={}){if(!i.link){ne("The personal portal is off. Turn it on in Settings.","warning");return}let a=i.link,s=await U(()=>Ma(La(i,t,a)));if(!s)return;let o=new File([s],`${i.id}-invite.png`,{type:"image/png"}),r=URL.createObjectURL(s),l=navigator,d=!!l.canShare?.({files:[o]}),p=()=>{URL.revokeObjectURL(r),X()},u=d?R([v("link")," Share card"],async()=>{try{await l.share({files:[o],title:`Invite ${i.name}`})}catch{}},"positive"):R([v("download")," Download card"],()=>ve(o.name,s),"positive");se(n.title??`Invite ${i.name}`,e("div",{class:"dl-invite"},[e("img",{src:r,alt:`Invite card for ${i.name}`}),e("div",{class:"dl-invite-side"},[e("p",{class:"dl-muted"},n.lead??`Send ${i.name} the card or the link. They open it, add their devices and connect — no account needed.`),e("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>he(a,"Personal link copied")},[e("span",{},a.replace(/^https:\/\//,"")),v("copy")]),...(i.links??[]).filter(c=>c!==a).map(c=>e("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>he(c,"Link copied")},[e("span",{},c.replace(/^https?:\/\//,"")),e("span",{class:`dl-pill ${c.startsWith("http:")?"warn":""}`},c.startsWith("http:")?"HTTP":"Also"),v("copy")])),e("ol",{class:"dl-invite-steps"},[e("li",{},["Install ",e("b",{},"AmneziaVPN")," on the device"]),e("li",{},"Open the link or scan the code"),e("li",{},"Add the device and connect")]),e("div",{class:"dl-invite-actions"},[u,R([v("copy")," Copy link"],()=>he(a,"Personal link copied"))])])]),[e("button",{class:"cbi-button cbi-button-neutral",click:p},"Done")],"wide")}var Ea={active:"",paused:"pause",paused_all:"pause",expired:"calendar",quota:"chart",hours:"clock",no_server:"alert"};function Bt(i){if(i.state==="active")return"";let t=e("span",{class:`dl-ibadge ${Da(i)}`,"aria-label":Pt[i.state]},v(Ea[i.state]||"alert"));return pe(t,()=>[e("div",{class:"dl-tip-title"},Pt[i.state])]),t}function Ta(i){let t=i.devices.length,n=Math.max(1,i.device_limit,t),a=Math.min(160,n*22+(n-1)*3);return e("div",{class:"dl-slotbar",title:`${t} of ${i.device_limit} devices`},[e("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:n},(s,o)=>e("i",{class:o>=i.device_limit?"over":oe("span",{class:`dl-ibadge ${a}`},v(a==="lan"?"home":"globe"))));return pe(n,()=>[e("div",{class:"dl-tip-title"},Ue[i.access]),i.access==="lan"&&i.services?.length?e("div",{class:"dl-muted"},`${i.services.length} home service${i.services.length===1?"":"s"} only`):""]),n}function Da(i){return i.state==="active"?"ok":i.state==="quota"||i.state==="expired"?"bad":"warn"}function Aa(i,t){let n=i,s=e("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(o=>e("button",{type:"button",class:`dl-choice${o.v===n?" selected":""}`,"data-v":o.v,click:()=>{n=o.v,s.querySelectorAll(".dl-choice").forEach(r=>r.classList.toggle("selected",r.dataset.v===o.v)),t?.(o.v)}},[e("span",{class:"dl-choice-title"},[v(o.ic),Ue[o.v]]),e("span",{class:"dl-choice-text"},o.text)])));return{el:s,get:()=>n}}function Pa(i){return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function fn(i){let t=ze(i.expires);return i.state==="quota"||i.state==="expired"||t!=null&&t<=Math.max(i.expire_warn,3)||!!i.quota_limit&&i.quota_used>=i.quota_limit*.9}function Na(i){let t=i?new Date(`${i}T12:00:00`):new Date,n=t.getTime()t===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.polling=!1;this.el=null;this.statusSeq=0;this.statusShown=0}async load(){return z.status(30)}scope(t){return this.serverId?ct(t,this.serverId):t}embed(t,n){return this.serverId=n,this.render(t)}person(t){return this.st.people.find(n=>n.id===t)}async latestStatus(){let t=++this.statusSeq,n=await z.status(30).catch(()=>null);return!n||te("em",{},n.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people."),a.serverId&&(r.filter=l=>a.st.people.some(d=>d.id===l)),r.handleAdd=()=>a.openCreate(),r.handleRemove=l=>a.remove(l),r.renderRowActions=()=>e("div",{class:"dl-none"}),s=r.option(form.DummyValue,"_card"),s.modalonly=!1,s.textvalue=l=>a.renderCard(e("div",{class:"dl-card",id:`dl-card-${l}`}),l),o.render().then(l=>{l.classList.add("dl-map","dl-root");let d=e("select",{class:"dl-select","aria-label":"Sort",change:u=>{a.sort=u.target.value,a.decorate()}},[e("option",{value:"seen"},"Last seen"),e("option",{value:"name"},"Name"),e("option",{value:"usage"},"Usage")]),p=e("div",{class:"dl-root"},[a.serverId?"":e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"People"),e("span",{class:"dl-muted",id:"dl-people-count"},this.countText())]),n.servers.length?R([v("plus")," Add person"],()=>a.openCreate(),"add"):""]),n.servers.length?"":e("div",{class:"alert-message warning"},["No server yet. ",e("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),e("div",{class:"dl-toolbar"},[e("div",{class:"dl-seg",id:"dl-people-tabs",role:"tablist"}),e("div",{class:"dl-toolbar-end"},[d,a.serverId?R([v("plus")," Add person"],()=>a.openCreate(),"add"):""])]),l]);return this.el=p,requestAnimationFrame(()=>this.decorate()),this.polling||(this.polling=!0,poll.add(()=>a.el?.isConnected?a.poll():Promise.resolve(),10)),!vn&&new URLSearchParams(location.search).get("add")&&(vn=!0,setTimeout(()=>a.openCreate(),100)),p})}countText(){let t=this.st.totals;return`${t.people} ${t.people===1?"person":"people"} · ${t.devices} device${t.devices===1?"":"s"} · ${t.online} online`}decorate(){let t=document.getElementById("dl-people-count");t&&(t.textContent=this.countText());let n=this.st.people,a={all:n.length,online:n.filter(c=>c.online>0).length,attention:n.filter(fn).length,paused:n.filter(c=>c.state!=="active"&&c.state!=="quota"&&c.state!=="expired").length},s=document.getElementById("dl-people-tabs");if(s){let c={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(s,Object.keys(c).map(b=>e("button",{type:"button",role:"tab",class:b===this.filter?"on":"",click:()=>{this.filter=b,this.decorate()}},[c[b],e("b",{class:b==="attention"&&a[b]?"warn":""},String(a[b]))])))}let o=c=>!(this.filter==="online"&&!c.online||this.filter==="attention"&&!fn(c)||this.filter==="paused"&&!(c.state!=="active"&&c.state!=="quota"&&c.state!=="expired")),r=[...n].sort((c,b)=>this.sort==="name"?c.name.localeCompare(b.name):this.sort==="usage"?b.month[0]+b.month[1]-(c.month[0]+c.month[1]):b.online-c.online||b.last_seen-c.last_seen),l=null,d=0;for(let c of r){let g=document.getElementById(`dl-card-${c.id}`)?.closest(".cbi-section-table-row");if(!g)continue;l??(l=g.parentElement),l?.appendChild(g),g.classList.toggle("dl-off",c.state!=="active"),g.classList.toggle("dl-attn-row",c.state==="quota"||c.state==="expired");let w=o(c);g.classList.toggle("dl-filtered",!w),w&&d++}let p=l?.closest(".cbi-section-table")??l,u=document.getElementById("dl-people-none");p&&n.length&&!d?(u??(u=e("div",{id:"dl-people-none",class:"dl-empty"})),dom.content(u,e("p",{},"No one here right now.")),u.parentElement!==p.parentElement&&p.after(u)):u?.remove()}async poll(){let t=await this.latestStatus();if(!t)return;let n=this.scope(t);this.st=n,this.paintCards(),this.decorate()}async quick(t,n,a){await U(()=>z.personUpdate(t.id,n),a)&&await this.poll()}renderCard(t,n){let a=this.person(n);if(!a)return dom.content(t,e("em",{},"Not saved yet — use “Save & Apply”.")),t;let s=ze(a.expires),o=Math.max(0,a.device_limit-a.devices.length),r=[];if(a.expires){let c=s!=null&&s>=0&&s<=Math.max(a.expire_warn,3),b=s!=null&&s<0;r.push(e("span",{class:`dl-pill-ic${b?" bad":c?" warn":""}`,title:`Access ends ${_e(a.expires)}`},[v("calendar"),b?`ended ${_e(a.expires)}`:c?`ends in ${s} day${s===1?"":"s"}`:`until ${_e(a.expires)}`]))}a.hours&&r.push(e("span",{class:"dl-pill-ic",title:"Allowed hours"},[v("clock"),a.hours.replace("-","–")]));let l=rt(a.devices).map(c=>e("button",{type:"button",class:`dl-chip${c.disabled?" disabled":""}${c.online?" live":""}`,title:`${Se[c.kind]} · ${c.address}${c.online?` · online from ${c.endpoint}`:c.handshake?` · seen ${ue(c.handshake,this.st.now)}`:""}`,click:b=>{b.preventDefault(),De(a,c,()=>this.refresh(),this.st.geo)}},[v(c.kind),e("span",{class:"dl-chip-name"},c.name),!c.handshake&&!c.disabled?e("span",{class:"dl-chip-tag"},"not set up"):""]));l.push(e("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:o>0?"Add device":"Add device · over the limit, admins can still add",click:c=>{c.preventDefault(),Ke(a,()=>this.refresh())}},v("plus")));let d=[];a.state==="quota"&&a.quota_period==="month"&&d.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{bonus_gb:String((a.bonus_gb||0)+10)},"+10 GB this month")},"+10 GB this month")),a.expires&&s!=null&&s<=Math.max(a.expire_warn,3)&&d.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:Na(a.expires)},"Extended by 1 month")},"Extend 1 month"));let p=ke("more","More",c=>we(c.currentTarget,[{label:"Open",icon:v("open"),run:()=>{location.href=be(a.id)}},a.link?{label:"Invite card",icon:v("qr"),run:()=>nt(a,this.st.servers.find(b=>b.id===a.server)?.name??"Home")}:null,o>0?{label:"Add device",icon:v("plus"),run:()=>Ke(a,()=>this.refresh())}:null,null,{label:a.paused?"Resume":"Pause",icon:v(a.paused?"play":"pause"),warn:!a.paused,run:()=>this.togglePause(a)},{label:"Delete",icon:v("trash"),danger:!0,run:()=>this.remove(a.id)}].filter((b,g,w)=>b||g>0&&w[g-1])),"neutral","dl-icon-only"),u=e("div",{class:"dl-pcard-actions"},[a.link?ke("link","Copy link",()=>he(a.link,"Personal link copied"),"neutral","dl-icon-only"):"",p]);return dom.content(t,e("div",{class:"dl-pcard"},[e("div",{class:"dl-pcard-main"},[e("div",{class:"dl-pcard-top"},[e("span",{class:`dl-avatar${a.online?" online":""}`},Re(a.name)),e("div",{class:"dl-pcard-who"},[e("div",{class:"dl-card-head"},[e("a",{class:"dl-card-name",href:be(a.id)},a.name),Bt(a),Ca(a),...r]),Ta(a)])]),e("div",{class:"dl-chips"},l),d.length?e("div",{class:"dl-fixes"},d):""]),this.usageSide(a,u)])),t}usageSide(t,n){let a=t.quota_used||t.month[0]+t.month[1],s=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,o=t.devices.reduce((u,c)=>u+(c.spark[c.spark.length-1]??0),0),r=t.rate?.[t.rate.length-1],l=t.online&&r&&this.st.now-r[0]<180,d=e("div",{class:`dl-usebar${s>=100?" bad":s>=90?" warn":""}`});if(t.quota_limit){let u=e("i",{class:"fill"});u.style.width=`${s}%`,d.appendChild(u),pe(d,()=>[e("div",{class:"dl-tip-title"},`${s.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${Z(t.quota_used)} of ${Z(t.quota_limit)} · ${Z(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},t.quota_period==="total"?"In total":`This month${t.bonus_gb?` · includes +${t.bonus_gb} GB extra`:""}`)])}else{let u=t.devices.map(c=>({d:c,v:c.month[0]+c.month[1]})).filter(c=>c.v>0).sort((c,b)=>b.v-c.v);u.forEach((c,b)=>{let g=e("i",{class:`c${Math.min(b,4)}`});g.style.flexGrow=String(c.v),d.appendChild(g)}),u.length&&pe(d,()=>[e("div",{class:"dl-tip-title"},"This month by device"),...u.map((c,b)=>e("div",{class:"dl-tip-row"},[e("span",{class:`dl-swatch c${Math.min(b,4)}`}),e("span",{},c.d.name),e("b",{},Z(c.v))]))])}let p=t.quota_limit?`${Z(Math.max(0,t.quota_limit-t.quota_used))} left`:"no limit";return e("div",{class:"dl-pside"},[e("div",{class:"dl-pside-top"},[l?e("span",{class:"dl-pside-state live"},"Online"):e("span",{class:"dl-pside-state"},t.online?"Online":t.last_seen?"Offline":"Never connected"),n]),e("div",{class:"dl-use-num"},[e("b",{class:a?"":"dl-faint"},Z(a)),e("span",{class:"dl-faint"},t.quota_limit?`of ${Z(t.quota_limit)}`:t.quota_period==="total"&&t.quota_gb?"in total":"this month")]),d,l?e("div",{class:"dl-use-live",title:"Right now"},[`↓ ${$e(r[2])}`,e("span",{class:"dl-faint"},`↑ ${$e(r[1])}`)]):e("div",{class:"dl-faint dl-pside-foot"},o?`today ${Z(o)} · ${p}`:p)])}async togglePause(t){await U(()=>z.personPause(t.id,!t.paused),t.paused?`${t.name} resumed`:`${t.name} paused`)&&await this.refresh()}async remove(t){let n=this.person(t);await re(`Remove ${n?.name??t}?`,`All ${n?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await U(()=>z.personDelete(t),"Person removed")&&await this.refresh()}openCreate(){let t=this.st;if(!t.servers.length){ne("Set up the server first.","warning");return}let n=e("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=Aa("internet"),s=e("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:t.settings.default_device_limit}),o=e("input",{type:"date",class:"cbi-input-text"}),r=e("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),l=(c,b)=>e("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{if(!b)o.value="";else{let g=new Date;g.setMonth(g.getMonth()+b),o.value=Pa(g)}}},c),d=t.servers[0],p=!this.serverId&&t.servers.length>1?e("select",{class:"cbi-input-select"},t.servers.map(c=>e("option",{value:c.id},c.name))):null,u=(c,b,g)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},c),e("div",{class:"cbi-value-field"},[b,g?e("div",{class:"cbi-value-description"},g):""])]);se("Add person",[u("Name",n),p?u("Server",p):"",e("div",{class:"cbi-value dl-block"},[e("label",{class:"cbi-value-title"},"Access"),e("div",{class:"cbi-value-field"},a.el)]),u("Devices",s,"How many devices they can add themselves."),u("End date",e("div",{class:"dl-actions"},[o,l("1 month",1),l("3 months",3),l("1 year",12),l("None",0)]),"Optional."),u("Monthly data (GB)",r,"Optional. They are paused when it runs out and resumed next month.")],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Create and copy link",async()=>{let c=await U(()=>z.personCreate(n.value.trim(),"",p?.value??d.id,a.get(),Number(s.value)||t.settings.default_device_limit,o.value,Number(r.value)||0,"month"));c&&(c.link&&await he(c.link,"Personal link copied"),this.showCreated(c.id,n.value.trim(),c.link,t.servers.find(b=>b.id===(p?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>n.focus(),50)}showCreated(t,n,a,s){if(a){nt({id:t,name:n,link:a},s,{title:`${n} is ready`,lead:`Send ${n} the card or the link. They open it, add their devices and connect — no account needed.`});return}se(`${n} is ready`,[e("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[e("button",{class:"cbi-button cbi-button-positive",click:X},"Done")])}};function Ee(i,t,n){let a=e("button",{type:"button",role:"switch",class:`dl-switch${i?" on":""}`,"aria-checked":i?"true":"false","aria-label":t,click:()=>{let s=!a.classList.contains("on");a.classList.toggle("on",s),a.setAttribute("aria-checked",s?"true":"false"),n?.(s)}},e("i"));return a}var Ve=i=>i.classList.contains("on");function oe(i,t={}){return e("input",{type:"text",class:"cbi-input-text",value:i,...t})}function ee(i,t,n){return e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},i),n?e("span",{class:"dl-sub"},n):""]),e("div",{class:"dl-setrow-ctl"},t)])}function at(i,t,n,a=""){return e("section",{class:`dl-setsec ${a}`},[e("div",{class:"dl-setsec-body"},[i?e("h3",{},i):"",...t]),n.length?e("div",{class:"dl-setsec-foot"},n):""])}function me(i,t,n,a){return e("div",{class:"dl-group"},[e("div",{class:"dl-group-head"},[e("span",{class:"dl-group-ic"},v(i)),e("span",{class:"dl-stack"},[e("b",{},t),n?e("span",{class:"dl-sub"},n):""])]),e("div",{class:"dl-group-body"},a.filter(s=>s!==""))])}var ft=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],bt=i=>e("i",{class:"dl-circle-dot",style:`background:${ft[i?.color??0]??ft[0]}`}),Ye=i=>i.access==="both"||i.access==="lan"&&!i.services?.length;function bn(i,t,n){let a=oe(i?.name??t.name??"",{placeholder:"NAS"}),s=oe(i?.address??t.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),o=oe((i?.ports??t.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),r=(l,d)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},l),e("div",{class:"cbi-value-field"},d)]);se(i?`Edit ${i.name}`:"Add service",[r("Name",a),r("Address",s),r("Ports",o)],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{let l=o.value.split(/[ ,]+/).filter(Boolean);await U(()=>z.serviceSet(i?.id??"",a.value,s.value,l),"Saved")&&(X(),n())},"positive")])}var za={_smb:"SMB",_afpovertcp:"AFP",_http:"Web",_https:"Web",_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:"Printer",_ipps:"Printer",_printer:"Printer","_pdl-datastream":"Printer",_airplay:"AirPlay",_raop:"AirPlay",_rfb:"Screen sharing",_googlecast:"Cast",_hap:"HomeKit",_rdp:"Remote desktop",_ftp:"FTP"},Ra=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function Ha(i){let t=new Map;for(let n of i.services){let a=za[n.type.split(".")[0]];!a||!n.port||(t.get(a)??t.set(a,new Set).get(a)).add(String(n.port))}return t.size?[...t].map(([n,a])=>[n,[...a].sort((s,o)=>+s-+o)]):Ra}function xn(i,t,n){let a=i.services,s=e("div",{class:"dl-stack gap8"},e("span",{class:"dl-sub"},"Looking for devices at home…")),o=a.length?a.map(d=>e("div",{class:"dl-row"},[v("home"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},d.name),e("span",{class:"dl-mono dl-faint"},`${d.address}${d.ports.length?` · ports ${d.ports.join(", ")}`:" · all ports"}`)]),R("Edit",()=>bn(d,{},n)),R([v("trash")],async()=>{await re(`Remove ${d.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await U(()=>z.serviceDelete(d.id),"Removed")&&n()},"neutral",{title:"Remove","aria-label":`Remove ${d.name}`})])):[e("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")];async function r(d,p){let u=a.find(b=>b.address===d.address);(p===null?u&&await U(()=>z.serviceDelete(u.id),`${u.name} removed`):await U(()=>z.serviceSet(u?.id??"",u?.name??(d.name||d.address),d.address,p),u?`${u.name} updated`:`${d.name||d.address} added`))&&n()}function l(d){let p=a.find(g=>g.address===d.address),u=!!p&&!p.ports.length,c=new Set(p?.ports??[]),b=(g,w,F)=>e("button",{type:"button",class:`dl-chipbtn${w?" on":""}`,"aria-pressed":w?"true":"false",click:F},g);return e("div",{class:"dl-row"},[v(d.services.some(g=>g.type.startsWith("_ipp")||g.type.startsWith("_printer"))?"file":"computer"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},d.name||d.address),e("span",{class:"dl-mono dl-faint"},d.address)]),e("div",{class:"dl-chips-row dl-host-ports"},[b("All ports",u,()=>r(d,u?null:[])),...Ha(d).map(([g,w])=>{let F=!u&&w.every(Y=>c.has(Y));return b(`${g} ${w.join(", ")}`,F,()=>{let Y=new Set(u?[]:c);for(let j of w)F?Y.delete(j):Y.add(j);r(d,Y.size?[...Y]:null)})})])])}return z.homeHosts(t).then(d=>{let p=d.hosts.some(u=>a.some(c=>c.address===u.address))&&!a.length;dom.content(s,d.hosts.length?e("details",{class:"dl-params",open:p?"":null},[e("summary",{},[v("chevron"),e("span",{},"Add from devices at home"),e("span",{class:"dl-pcount"},String(d.hosts.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},d.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),e("div",{class:"dl-list"},d.hosts.map(l))])]):e("span",{class:"dl-sub"},"No devices found in the home network right now."))}).catch(()=>dom.content(s,e("span",{class:"dl-sub"},"Couldn't read the devices at home."))),e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-iflead"},[e("div",{class:"dl-iflead-row"},[e("b",{},"Home services"),R([v("plus")," Add service"],()=>bn(null,{},n))]),e("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),e("div",{class:"dl-list"},o),s])}function vt(i,t,n,a){let s=new Set(i.circles.filter(g=>g.server===t).map(g=>g.color)),o=n?.color??ft.findIndex((g,w)=>!s.has(w));o<0&&(o=0);let r=oe(n?.name??"",{placeholder:"Family"}),l=i.people.filter(g=>g.server===t).sort((g,w)=>g.name.localeCompare(w.name)),d=new Set(l.filter(g=>n&&g.circle===n.id).map(g=>g.id)),p=e("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),u=()=>dom.content(p,ft.map((g,w)=>e("button",{type:"button",role:"radio",class:`dl-swatch${w===o?" on":""}`,style:`--sw:${g}`,"aria-checked":w===o?"true":"false","aria-label":`Colour ${w+1}`,click:()=>{o=w,u()}})));u();let c=e("div",{class:"dl-chips-row"},l.map(g=>{let w=g.circle&&g.circle!==n?.id?i.circles.find(F=>F.id===g.circle):void 0;return e("button",{type:"button",class:`dl-chipbtn${d.has(g.id)?" on":""}`,title:Ye(g)?w?`Now in ${w.name}`:"":`${g.name} has no home access: their devices aren't reachable anyway`,click:F=>{d.delete(g.id)||d.add(g.id),F.currentTarget.classList.toggle("on",d.has(g.id))}},[g.name,Ye(g)?w?e("b",{},w.name):"":e("b",{},"internet")])})),b=(g,w)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},g),e("div",{class:"cbi-value-field"},w)]);se(n?`Edit ${n.name}`:"New circle",[b("Name",r),b("Colour",p),b("People",c),e("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[n?R("Delete",async()=>{await U(()=>z.circleDelete(n.id),`${n.name} deleted`)&&(X(),a())},"negative"):"",e("span",{class:"dl-spacer"}),e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{await U(()=>z.circleSet(n?.id??"",t,r.value,o,[...d]),"Saved")&&(X(),a())},"positive")],"dl-circle-modal")}function wn(i,t,n){let a=i.circles.filter(s=>s.server===t);return e("div",{class:"dl-chips-row dl-circles"},[...a.map(s=>{let o=i.people.filter(r=>r.circle===s.id).map(r=>r.name);return e("button",{type:"button",class:"dl-chip",title:`Edit ${s.name}`,click:()=>vt(i,t,s,n)},[bt(s),e("b",{},s.name),e("span",{class:"dl-faint"},o.length?o.join(", "):"nobody yet")])}),e("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>vt(i,t,null,n)},v("plus"))])}function yn(i,t){let n=i.people.filter(u=>u.server===t.id),a=(u="")=>e("span",{class:"dl-yes"},[v("check"),u]),s=()=>e("span",{class:"dl-faint"},"—"),o=u=>{let c=new Set(u.map(b=>b.access==="lan"&&b.services?.length?"services":b.home_nets?.length?"some":"all"));return c.size||c.add("all"),a([...c].map(b=>({all:"all networks",some:"their networks",services:"services"})[b]).join(" / "))},r=()=>t.mesh==="off"?s():t.mesh==="circles"?a("circle"):a(),l=t.lan_like?"like home":"direct",d=(u,c,b)=>e("tr",{},[e("td",{},[e("b",{},u),e("div",{class:"dl-sub"},`${c.length} ${c.length===1?"person":"people"}`)]),...b.map(g=>e("td",{},g))]),p=u=>n.filter(c=>c.access===u);return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Who reaches what"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"From the rules on this server")]),e("div",{class:"dl-reach-wrap"},e("table",{class:"dl-table dl-reach"},[e("tr",{},["","Internet","Home","This router","Each other"].map(u=>e("th",{},u))),d("Internet",p("internet"),[a(l),s(),e("span",{class:"dl-faint"},"DNS"),s()]),d("Home",p("lan"),[e("span",{class:"dl-faint"},"their own"),o(p("lan")),a(),r()]),d("Both",p("both"),[a(l),o(p("both")),a(),r()])])),e("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function kn(i,t){let n=i.people.filter(p=>p.server===t.id).flatMap(p=>p.devices.map(u=>({id:u.id,label:`${p.name} · ${u.name}`}))).sort((p,u)=>p.label.localeCompare(u.label)),a="@addr",s=(p,u)=>{let c=e("select",{class:"cbi-input-select","aria-label":p},[...n.map(F=>e("option",{value:F.id,selected:F.id===u?"selected":null},F.label)),e("option",{value:a,selected:u===a?"selected":null},"Address")]),b=oe("",{placeholder:p,class:"cbi-input-text dl-mono"}),g=e("div",{class:"dl-check-end"},[c,b]),w=()=>b.hidden=c.value!==a;return c.addEventListener("change",w),w(),{el:g,value:()=>c.value===a?b.value.trim():c.value}},o=s("10.0.1.11",n[0]?.id??a),r=s("10.0.1.20:445",a),l=e("div",{class:"dl-stack gap8"}),d=async()=>{let p=await U(()=>z.accessCheck(o.value(),r.value()));if(!p)return;let u=p.steps.findIndex(c=>!c.ok);dom.content(l,[e("div",{class:`dl-verdict ${p.ok?"ok":"bad"}`},[e("b",{},p.ok?"Allowed":"Blocked"),e("span",{class:"dl-sub"},p.ok?"Every step lets it through":`Stops at step ${u+1} of ${p.steps.length}`)]),e("ul",{class:"dl-checks"},p.steps.map(c=>e("li",{},[e("span",{class:`dl-check-icon ${c.ok?"ok":"error"}`},v(c.ok?"check":"x")),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},c.title),c.detail?e("div",{class:"dl-check-detail"},c.detail):""])])))])};return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Check access"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"Why something does or does not connect")]),e("div",{class:"dl-check-form"},[o.el,e("span",{class:"dl-faint"},"→"),r.el,R("Check",d)]),l])])}var Ia={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",bonjour:"Bonjour for home devices"},Ba=300*1e3;async function Je(i,t,n){if(!t.length)return!0;if(!await re(`Install ${Ia[i]}?`,`${t.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,"Install"))return!1;let s=(await z.updatesStatus().catch(()=>null))?.job?.started??0;if(!await U(()=>z.updatesRun(`pkgs:${t.join(",")}`)))return!1;ne(`Installing ${t.join(", ")}…`,"info",4e3);let o=Date.now()+Ba;for(;Date.now()setTimeout(d,2e3));let l=(await z.updatesStatus().catch(()=>null))?.job;if(!(!l||l.started===s||l.state==="running"))return l.state==="done"?(ne(`${t.join(", ")} installed`,"success"),setTimeout(()=>n?.(),4e3),!0):(ne(l.error??"Installation failed","error"),!1)}return ne("Still installing: see Updates for the log.","warning"),!1}async function $n(i,t){let n=await U(()=>z.updatesStatus());return n?Je(i,n.needs?.[i]??[],t):!1}var ja=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Oa={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function xt(i,t,n){let a=e("button",{type:"button",role:"switch",class:`dl-switch${i?" on":""}`,"aria-checked":i?"true":"false","aria-label":t,click:()=>{let s=!a.classList.contains("on");a.classList.toggle("on",s),a.setAttribute("aria-checked",s?"true":"false"),n(s)}},e("i"));return a}function _n(i,t,n){let a=i.id,s=e("div",{class:"dl-stack gap16"},e("section",{class:"dl-setsec"},e("div",{class:"dl-setsec-body"},e("p",{class:"dl-muted"},"Loading interfaces…")))),o,r=!0,l="",d=!0,p=!0,u="all",c=!1,b=xn(t,a,n),g=new Set,w="",F=()=>JSON.stringify([p,r,r?"":l,d,[...g].sort()]),Y=()=>o.detected.lan||o.saved.lan||"",j=()=>(r?o.detected.wan||o.saved.wan:l)||"",$=()=>new Map(o.devices.map(S=>[S.name,S])),N=()=>{let S=$();return[...d&&Y()?[Y()]:[],...[...g].filter(W=>W!==Y())].filter(W=>W!==j()).map(W=>S.get(W)??{name:W,nets:[],missing:!0})},C=(S,q)=>{o=S,q&&(r=S.config.auto_wan,l=S.config.wan_device||S.detected.wan||S.saved.wan||"",d=S.config.auto_lan,p=S.config.lan_like,u=S.config.mesh??(S.config.device_mesh?"all":"off"),g=new Set(S.config.lan_devices),w=F()),O()},T=async S=>{let q=await z.interfaces(a).catch(W=>(ne(W.message,"error"),null));q&&C(q,S)};function y(S){let q=d&&S.name===Y(),W=!!S.own||!!S.master||S.name===j()||q;return q||g.has(S.name)||!W&&(S.nets.length>0||!!S.missing)}function A(S){let q=d&&S.name===Y(),W=S.name===j(),te=!q&&g.has(S.name),de=!(!!S.own||!!S.master||W||q)&&(S.nets.length>0||te||!!S.missing),Te=(te||q)&&!S.zone&&!S.missing,I=S.missing?"Not present right now":S.own?"This server":S.master?`Port of ${S.master}`:W?`Internet${S.zone?` · zone ${S.zone}`:""}`:S.nets.length?S.nets.join(", "):"No IPv4 network",ae=e("button",{type:"button",class:`dl-if${te?" sel":""}${q?" auto":""}${!de&&!te&&!q?" off":""}${Te?" warn":""}`,"aria-pressed":te||q?"true":"false","aria-disabled":de?null:"true",click:()=>{de&&(g.has(S.name)?g.delete(S.name):g.add(S.name),O())}},[e("span",{class:"dl-if-ic"},v(Oa[S.kind]??"link")),e("span",{class:"dl-if-main"},[e("span",{class:"dl-if-name"},S.name),e("span",{class:"dl-if-sub"},I)]),q?e("span",{class:"dl-if-badge ok"},"Auto"):te?e("span",{class:"dl-if-check"},v("check")):""]);return pe(ae,()=>[e("div",{class:"dl-tip-title"},S.name),e("div",{class:"dl-muted"},[S.logical?`Interface ${S.logical}`:"No netifd interface",S.zone?` · zone ${S.zone}`:" · no firewall zone"]),S.members.length?e("div",{class:"dl-muted"},`Ports: ${S.members.join(", ")}`):"",S.nets.length?e("div",{class:"dl-mono"},S.nets.join(", ")):"",Te?e("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",S.master?e("div",{class:"dl-muted"},`Choose ${S.master} to include it.`):""]),ae}function m(){let S=o.like_home;return!p||!o.config.lan_like?"":!o.needs?.length&&S.active&&S.bridged?"ok":"warn"}function h(){let S=o.like_home;return p?o.needs?.length?[e("span",{class:"dl-warn"},`Needs ${o.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:o.config.lan_like?S.active&&S.bridged?["Internet traffic enters ",e("span",{class:"dl-mono"},S.dev??"")," as ",e("span",{class:"dl-mono"},S.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[e("span",{class:"dl-warn"},`Not working: ${S.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let P={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function f(S,q,W,te,le="",de){return e("div",{class:de?"dl-setrow head":"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:`dl-need-ic ${le}`},v(S)),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},q),e("span",{class:"dl-sub"},W),de??""])]),e("div",{class:"dl-setrow-ctl"},te)])}let _=(S,q)=>{let W=te=>e("span",{class:"dl-mono"},te);return S?e("span",{},[" Now: ",W(S),...q&&q!==S?[", was ",W(q)]:[],"."]):e("span",{},q?[" Not found now: using ",W(q),"."]:[" Not found."])};function O(){let S=e("select",{class:"cbi-input-select","aria-label":"Internet interface",change:k=>{l=k.target.value,O()}},o.devices.filter(k=>!k.own&&!k.master&&k.zone&&!k.missing).map(k=>e("option",{value:k.name,selected:k.name===l?"selected":null},`${k.name} · zone ${k.zone}`))),W=N().flatMap(k=>k.nets.map(H=>[H,k.name])),te=JSON.parse(F()),le=JSON.parse(w),de=(...k)=>k.some(H=>JSON.stringify(te[H])!==JSON.stringify(le[H])),Te=de(0,1,2),I=de(3,4),ae=k=>R("Save",async()=>{let H=await U(()=>z.serverInterfaces(a,r,r?"":l,d,[...g],p,u!=="off",u),"Access saved");H&&(C(H,!0),H.nets_changed&&H.lan_only&&ne(`${H.lan_only} ${H.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!k}),M=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Internet"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Internet or Both")]),f("home","Internet like a home device",h(),[p&&o.needs?.length?R("Install",()=>Je("home",o.needs,()=>T(!1)),"positive"):"",xt(p,"Internet like a home device",k=>{p=k,O()})],m()),f("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",_(o.detected.wan,o.saved.wan)],[r?"":S,xt(r,"Auto-detect WAN",k=>{r=k,O()})])]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},p?["Internet like a home device",j()?[" · leaves through ",e("span",{class:"dl-mono"},j())]:""]:j()?["Internet straight to ",e("span",{class:"dl-mono"},j())]:"No WAN found"),ae(Te)])]),E=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":"Devices reach each other"},[["off","Off"],["all","Everyone"],["circles","Circles"]].map(([k,H])=>e("button",{type:"button",role:"radio",class:u===k?"on":"","aria-checked":u===k?"true":"false",click:async()=>{u!==k&&await U(()=>z.serverUpdate(a,{mesh:k}),`Devices reach each other: ${H}`)&&n()}},H))),x=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Home network"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Home or Both"),R([v("reset")," Rescan"],()=>T(!1),"neutral",{title:"Read the interfaces again"})]),f("network","Networks","Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it.","","",B()),f("link","Devices reach each other",P[u],E,"",u==="circles"?wn(t,a,n):void 0),G(),b]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub dl-if-summary"},W.length?["Home access reaches ",...W.flatMap(([k,H],V)=>[V?", ":"",e("span",{class:"dl-mono"},k),` (${H})`])]:"No home network: Home access reaches nothing but this router."),ae(I)])]),D=window.scrollY;s.style.minHeight=`${s.offsetHeight}px`,dom.content(s,[M,x]),s.style.minHeight="",window.scrollTo({top:D})}function G(){let S=o.bonjour,q=async te=>{await U(()=>z.serverUpdate(a,{bonjour:te}),te?"Finding home devices":"Home devices no longer listed")&&T(!1)},W=S.needs.length?e("span",{class:"dl-warn"},` Needs ${S.needs.join(", ")}.`):S.on&&!S.running?e("span",{class:"dl-warn"}," umdns is not running."):S.on?` Listing ${S.services} service${S.services===1?"":"s"} from home now.`:"";return f("wifi",["Find home devices ",e("span",{class:"dl-faint dl-w400"},"· Bonjour")],["iPhone, iPad and Mac on the VPN see AirPlay, printers and shared Macs at home, as on Wi-Fi. Android and Chromecast look only on the local network.",W],S.needs.length?R("Install",()=>Je("bonjour",S.needs,()=>T(!1)),"positive"):xt(S.on,"Find home devices",te=>q(te)),S.on&&S.running?"ok":"")}function B(){let S=o.devices.filter(y),q=o.devices.filter(W=>!y(W));return e("div",{class:"dl-stack gap8 dl-netpick"},[S.length?e("div",{class:"dl-ifgrid"},S.map(A)):e("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),e("label",{class:"dl-boxrow"},[e("span",{class:"dl-stack"},[e("span",{},"Auto-detect LAN"),e("span",{class:"dl-sub"},["Adds the LAN this router uses.",_(o.detected.lan,o.saved.lan)])]),xt(d,"Auto-detect LAN",W=>{d=W,O()})]),q.length?e("details",{class:"dl-params",open:c?"":null,toggle:W=>c=W.currentTarget.open},[e("summary",{},[v("chevron"),e("span",{},"Other interfaces"),e("span",{class:"dl-pcount"},String(q.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...ja.map(([W,te])=>{let le=q.filter(de=>de.category===W);return le.length?e("div",{class:"dl-ifgroup"},[e("h4",{},te),e("div",{class:"dl-ifgrid"},le.map(A))]):""})])]):""])}return T(!0),s}var Sn=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["disguise","Disguise"],["tunnel","Tunnel"]],Ua={general:"connection",network:"connection",interfaces:"access",advanced:"tunnel"},Ln=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function qa(i){let t=p=>i[p]!=null&&i[p]!=="",n=Ln.filter(([p])=>t(p));if(!n.length)return null;let a=(p,u)=>e("span",{class:"dl-pv"},[e("i",{},u),e("b",{},p==="header_protection_key"?`${i[p].slice(0,6)}••••`:i[p])]),s=(p,u,c,b)=>{let g=Ln.filter(([w])=>b.includes(w)&&t(w));return g.length?e("div",{class:"dl-pgroup"},[e("div",{class:"dl-pgroup-head"},[v(u),e("b",{},p)]),e("p",{},c),e("div",{class:"dl-pvals"},g.map(([w,F])=>a(w,F)))]):""},o=Number(i.jc||0),r=(i.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=n.map(([p,u])=>`${u} = ${i[p]}`).join(` -`),d=e("div",{class:"dl-pgrid"},[s("Junk packets","zap",o?`${o} random packet${o===1?"":"s"} of ${i.jmin}–${i.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),s("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),s("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),s("Signatures","globe",r,["i1","i2","i3","i4","i5"]),s("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),s("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return e("details",{class:"dl-params"},[e("summary",{},[v("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(n.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:p=>{p.preventDefault(),he(l,"Parameters copied")}},"Copy as config")]),d])}var jt=(i,t)=>{let n=new URLSearchParams;i&&n.set("server",i),t&&t!=="overview"&&n.set("section",t);let a=n.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},st=class{constructor(){this.noFooter=!0;this.root=e("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=e("div",{});this.headEl=e("div",{});this.secEl=e("div",{});this.bodyEl=e("div",{class:"dl-srvbody"})}async load(){let t=await z.status(31),n=t.servers.length?null:await z.setupDefaults();return[t,n]}render([t,n]){if(this.st=t,!t.servers.length&&n)return this.wizard(n);let a=new URLSearchParams(location.search),s=a.get("section")??"",o=Ua[s]??s;return Sn.some(([r])=>r===o)&&(this.section=o),this.srvId=(t.servers.find(r=>r.id===a.get("server"))??t.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),poll.add(async()=>{if(this.section!=="overview")return;let r=await z.status(31).catch(()=>null);if(!r||!r.servers.length)return;this.st=r;let l=this.current();dom.content(this.headEl,this.head(l)),this.paintTabs(),this.ov[l.id]?.update(r)},10),this.root}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await z.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=jt())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let t=this.current();dom.content(this.tabsEl,e("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(n=>e("button",{type:"button",role:"tab",class:`dl-srvtab${n.id===t.id?" on":""}`,"aria-selected":n.id===t.id?"true":"false",click:()=>{n.id!==this.srvId&&(this.srvId=n.id,this.paint())}},[e("i",{class:`dot ${n.up?"ok":"bad"}`}),e("b",{},n.name),e("span",{class:"dl-mono dl-faint"},`:${n.port}`)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[v("plus"),"Add server"])]))}paintSections(){dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},Sn.map(([t,n])=>e("button",{type:"button",role:"tab","data-section":t,class:t===this.section?"on":"","aria-selected":t===this.section?"true":"false",click:()=>this.showSection(t)},n))))}go(t,n){let a=this.pp[this.current().id];if(n&&a)a.filter=n,a.el&&a.decorate();else if(n){let s=this.pp[this.current().id]=new Be;s.filter=n}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let t=[...Object.values(this.ov).map(n=>n.el),...Object.values(this.pp).map(n=>n.el)];for(let n of t)n&&this.bodyEl.contains(n)&&n.remove()}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(r=>{let l=r.dataset.section===t;r.classList.toggle("on",l),r.setAttribute("aria-selected",l?"true":"false")});let n=this.st,a=this.current(),o={overview:()=>{let r=this.ov[a.id];return r?(r.update(n),r.el):(this.ov[a.id]=new pt(a.id,(l,d)=>this.go(l,d))).mount(n)},people:()=>{var p,u;let r=this.pp[a.id];if(r?.el)return r.poll(),r.el;let l=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((p=this.pp)[u=a.id]??(p[u]=new Be)).embed(n,a.id).then(c=>{l.isConnected?dom.content(l,c):l.replaceChildren(c)}),l},connection:()=>this.connection(a),access:()=>this.access(a),disguise:()=>this.disguise(a),tunnel:()=>this.tunnel(a)}[t]();this.detachKept(),dom.content(this.bodyEl,o)}head(t){let n=this.st,a=(l,d)=>e("span",{class:"dl-addrbar-seg"},[v(l),...d]),s=`${t.endpoint||"—"}:${t.port}`,o=!t.enabled||n.settings.paused_all,r=e("div",{class:"dl-actions"},[o?R([v("play")," Turn on"],async()=>{n.settings.paused_all&&!await U(()=>z.pauseAll(!1))||(t.enabled?await this.refresh():await this.save(t,{enabled:"1"},"Server turned on"))},"positive"):""]);return e("div",{class:"dl-srvpagehead"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),e("span",{class:`dl-pill ${t.enabled?t.up?"ok":"bad":"off"}`},t.enabled?t.up?"Running":"Not running":"Turned off"),n.settings.paused_all&&t.enabled?e("span",{class:"dl-pill warn"},"Off"):"",e("span",{class:"dl-spacer"}),r]),e("div",{class:"dl-addrbar"},[e("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address and port",click:()=>he(s,"Address copied")},[v("globe"),e("span",{class:"dl-mono"},s),v("copy")]),a("tunnel",[e("span",{class:"dl-mono"},t.ifname)]),a("network",[e("span",{class:"dl-mono"},t.subnet)]),t.up?a("clock",[`up ${on(t.uptime)}`]):""])])}async save(t,n,a="Saved"){await U(()=>z.serverUpdate(t.id,n),a)&&await this.refresh()}connection(t){let n=oe(t.name,{placeholder:"Home"}),a=oe(t.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),s=oe(String(t.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),o=oe(t.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),r=oe(String(t.mtu??""),{placeholder:"1380",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),l=oe(String(t.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"});return at("Connection",[e("p",{class:"dl-muted"},"How devices find this server, and what goes into their configuration."),me("router","Server","What people see",[ee("Name",n,"Shown to people in their portal.")]),me("globe","Devices connect to","Where the tunnel answers from the internet",[ee("Public address",a,"Hostname or IP of the router on the internet. A DDNS name keeps links working when your IP changes."),ee("UDP port",s,"Opened on the WAN firewall automatically.")]),me("file","In every device configuration","Changing these marks devices “Update config” until they import again",[ee("DNS for devices",o,"Empty = this router, which sends each query where your home network would."),ee("MTU",r,"Lower it if some sites hang on mobile networks."),ee("Keep-alive",l,"Seconds between packets devices send to keep NAT open. 0 = off.")])],[e("span"),R("Save",()=>this.save(t,{name:n.value,endpoint:a.value,port:s.value,dns:o.value,mtu:r.value,keepalive:l.value}),"positive")])}access(t){let n=()=>this.refresh();return e("div",{class:"dl-stack gap16"},[_n(t,this.st,n),e("div",{class:"dl-health-cols"},[yn(this.st,t),kn(this.st,t)])])}disguise(t){let n=We(t.preset)?t.preset:void 0,a=n??"standard",s=R("",()=>this.applyDisguise(t,a,a===n),"positive"),o=()=>{dom.content(s,a===n?[v("reset")," Generate new values"]:`Switch to ${We(a).title}`)};o();let r=qa(t.obf??{});return at("Disguise",[e("p",{class:"dl-muted"},"AmneziaWG reshapes the tunnel so networks that block VPNs do not recognise it. Every device gets these settings in its configuration."),Nt(this.st.awg,a,l=>{a=l,o()},n),this.st.awg.v3?"":Ae("info",["This router runs an older AmneziaWG. ",e("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]),r??""],[e("span",{class:"dl-sub"},"Applies at once. Every device on this server must import its configuration again."),s])}async applyDisguise(t,n,a){let s=We(n),r=this.st.people.filter(d=>d.server===t.id).reduce((d,p)=>d+p.devices.length,0);await re(a?"Generate new disguise values?":`Switch to ${s.title}?`,`${r} device${r===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${n==="max"?" They need an app with AmneziaWG 3.1.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await U(()=>z.serverObfuscation(t.id,n),a?"New values applied":`${s.title} applied`)&&(ne("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())}tunnel(t){let n=this.st.people.filter(s=>s.server===t.id).length,a=R(t.enabled?"Turn off":"Turn on",async()=>{t.enabled&&!await re(`Turn off ${t.name}?`,`The tunnel stops and ${n} ${n===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(t,{enabled:t.enabled?"0":"1"},t.enabled?"Server turned off":"Server turned on")},t.enabled?"negative":"positive");return e("div",{class:"dl-stack gap16"},[at("Tunnel",[e("p",{class:"dl-muted"},"Technical details. They are set when the server is created and rarely change."),ee("Interface",e("span",{class:"dl-mono"},`${t.ifname} · router ${t.address}`)),ee("Tunnel subnet",e("span",{class:"dl-mono"},t.subnet),"Device addresses come from it."),ee("Server public key",e("span",{class:"dl-keyrow"},[e("code",{class:"dl-mono"},t.public_key),R([v("copy")],()=>he(t.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))],[]),at("Danger zone",[e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},t.enabled?"Turn off this server":"This server is off"),e("span",{class:"dl-sub"},t.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),e("div",{class:"dl-setrow-ctl"},a)]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Remove server"),e("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${n} ${n===1?"person":"people"} with all their devices. A backup is made first.`)]),e("div",{class:"dl-setrow-ctl"},R([v("trash")," Remove"],()=>this.remove(t),"negative"))])],[],"danger")])}async addServer(){let t=await U(()=>z.setupDefaults());t&&dom.content(this.root,this.wizard(t,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async remove(t){let n=this.st.people.filter(a=>a.server===t.id);se(`Remove ${t.name}?`,[e("p",{},`This removes the tunnel, its firewall rules and ${n.length} ${n.length===1?"person":"people"} with all their devices. A backup is made first.`)],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Remove",async()=>{X(),await U(()=>z.serverDelete(t.id),"Server removed")&&setTimeout(()=>{location.href=jt()},800)},"negative")])}wizard(t,n=!1,a){let s={id:t.id,name:t.name,endpoint:t.endpoint,port:t.port,subnet:t.subnet,preset:"standard",portal:!1,portal_port:t.portal_port||8443,lan_like:!0,lan_zone:t.lan_zone,wan_zone:t.wan_zone},o=0,r=e("div",{class:"dl-wizard"}),l=(c,b={})=>{let g=oe(String(s[c]),b);return g.addEventListener("input",()=>{s[c]=c==="port"||c==="portal_port"?Number(g.value):g.value.trim()}),g},d=n?["Connection","Disguise"]:["Connection","Disguise","Portal"],p=[()=>e("div",{class:"dl-wizard-groups"},[e("p",{class:"dl-muted"},"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),me("router","Server","What people see",[ee("Name",l("name"),"Shown to people in their portal.")]),me("globe","Devices connect to","Where the tunnel answers from the internet",[ee("Public address",l("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),"Hostname or IP address of your router on the internet."),ee("UDP port",l("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),"Opened on the WAN firewall automatically. A random high port is fine.")]),me("network","Tunnel network","Addresses devices get inside the tunnel",[ee("Tunnel subnet",l("subnet",{class:"cbi-input-text dl-mono"}),`Must not overlap your networks (${t.taken.join(", ")||"none found"}).`)])]),()=>e("div",{},[e("p",{},"AmneziaWG reshapes the tunnel so networks that block VPNs do not recognise it. Every device gets these settings automatically; you can change the method later."),Nt(t.awg,s.preset,c=>s.preset=c)]),()=>{let c=l("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),b=ee("Listening port",c,"TCP port on WAN for the portal; the whole port belongs to it.");b.hidden=!s.portal;let g=e("div",{class:"dl-seg",role:"radiogroup","aria-label":"Personal portal"},["off","on"].map(w=>e("button",{type:"button",role:"radio",class:w==="on"===s.portal?"on":"","aria-checked":w==="on"===s.portal?"true":"false",click:F=>{s.portal=w==="on",b.hidden=!s.portal,g.querySelectorAll("button").forEach(Y=>{let j=Y===F.currentTarget;Y.classList.toggle("on",j),Y.setAttribute("aria-checked",j?"true":"false")})}},w==="on"?"On":"Off")));return e("div",{class:"dl-wizard-groups"},[me("home","Internet like a home device","How devices reach the internet",[ee("Through the home network",Ee(s.lan_like,"Internet like a home device",w=>s.lan_like=w),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),me("link","Personal portal","A page where each person adds their own devices with their personal link",[ee("Portal",g,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),b])])}],u=()=>{dom.content(r,[e("h2",{},n?"Add a server":"Set up Dawnline"),e("div",{class:"dl-steps"},d.map((c,b)=>e("span",{class:`dl-step${b===o?" current":b0?R("Back",()=>{o--,u()}):a?R("Cancel",a):"",e("span",{class:"dl-spacer"}),o{if(o===0&&(!s.endpoint||!s.port||!s.subnet)){ne("Fill in the public address, port and subnet.","warning");return}o++,u()},"positive"):R("Create server",async()=>{let c=await U(()=>z.serverCreate(s.id,s.name,t.ifname,s.port,s.subnet,s.endpoint,t.mtu,s.preset,s.lan_zone,s.wan_zone,s.lan_like,n?void 0:s.portal,n?void 0:s.portal_port),"Server created");c&&setTimeout(()=>{location.href=jt(c.id)},1500)},"positive")])])};return u(),r}};var wt=300,Wa=["all","connections","people","system","problems"],Ga={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Fa={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function Ka(i){let t=new Date(i*1e3),n=new Date,a=new Date;return a.setDate(n.getDate()-1),t.toDateString()===n.toDateString()?"Today":t.toDateString()===a.toDateString()?"Yesterday":t.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}function Ot(i){let t=i.keep_days>0?`${i.keep_days} day${i.keep_days===1?"":"s"}`:"no age limit",n=i.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${i.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${t}, up to ${i.max.toLocaleString("en-GB")} events, ${n}.`}var Ut=i=>i.sys?["error","repair","down"].includes(i.sys.level):ht(i.ev.type)==="problems";function qt(i,t,n,a){let s=i.by==="admin",o=e("div",{class:`dl-row dl-slog-row ${s?"dl-ev-by-admin":`dl-ev-by-system ${Ga[i.level]??""}`}${i.detail?" has-detail":""}`},[s?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):e("span",{class:"dl-ev-tile sys",title:i.level},v(Fa[i.src]??"zap")),e("span",{class:"dl-row-main"},s?[e("span",{class:"dl-you"},"You"),e("span",{class:"dl-muted"},` ${i.msg} `),i.kind?e("span",{class:"dl-ev-kind"},`${i.kind} `):"",i.who?e("b",{},i.who):"",i.note?e("span",{class:"dl-muted"},` · ${i.note}`):"",i.detail?e("span",{class:`dl-slog-more${t?" open":""}`},v("chevron")):"",i.detail&&t?e("pre",{class:"dl-slog-detail"},i.detail):""]:[i.src==="awg"&&i.who&&i.who!=="AmneziaWG"?e("span",{class:"dl-ev-kind"},"Server "):"",e("b",{class:"dl-sys-src",title:ut[i.src]??i.src},i.who??ut[i.src]??i.src)," ",e("span",{class:"dl-muted"},i.msg),i.detail?e("span",{class:`dl-slog-more${t?" open":""}`},v("chevron")):"",i.detail&&t?e("pre",{class:"dl-slog-detail"},i.detail):""]),e("span",{class:"dl-faint dl-nowrap",title:new Date(i.ts*1e3).toLocaleString()},a)]);return i.detail&&o.addEventListener("click",r=>{r.target.closest("pre")||n()}),o}var yt=class{constructor(t,n,a){this.events=[];this.system=[];this.kind="all";this.shown=wt;this.open=new Set;this.list=e("div",{});this.sub="";this.tabs=e("div",{class:"dl-seg",role:"tablist"});this.st=t,this.take(n),this.system=a,this.el=e("div",{},[e("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let t=()=>this.kind==="all"?"":this.kind,n=o=>()=>{let r=this.filtered().reverse();Le(this.st,r.filter(l=>l.ev).map(l=>l.ev),o,t(),r.filter(l=>l.sys).map(l=>l.sys))},a=R([v("download")," Export"],()=>we(a,[{label:"CSV (spreadsheet)",icon:v("download"),run:n("csv")},{label:"JSON",icon:v("download"),run:n("json")}])),s=R([v("trash")," Clear"],()=>Ce("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[a,s]}take(t){this.events=t.events,this.policy=t.policy;let n=Xe.filter(a=>!t.policy.categories.includes(a));this.sub=`${Ot(t.policy)}${n.length?` Not recorded: ${n.map(a=>Ge[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[t,n]=await Promise.all([z.events(2e4).catch(()=>null),z.serviceLog().catch(()=>null)]);t&&this.take(t),n&&(this.system=n.log),this.paint()}items(){return[...this.events.map(t=>({ts:t.ts,ev:t})),...this.system.map(t=>({ts:t.ts,sys:t}))].sort((t,n)=>n.ts-t.ts)}matches(t,n){return n==="all"?!0:n==="problems"?Ut(t):n==="system"?!!t.sys:!!t.ev&&ht(t.ev.type)===n}filtered(){return this.items().filter(t=>this.matches(t,this.kind))}paintTabs(t){dom.content(this.tabs,Wa.map(n=>e("button",{type:"button",role:"tab",class:n===this.kind?"on":"","aria-selected":n===this.kind?"true":"false",click:()=>this.show(n)},[n==="all"?"All":n==="system"?"System":Ge[n],e("b",{},String(t.filter(a=>this.matches(a,n)).length))])))}show(t){this.kind=t,this.shown=wt,this.paint()}paint(){this.paintTabs(this.items());let t=this.filtered();if(!t.length){dom.content(this.list,e("div",{class:"dl-empty"},[e("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let n=[],a="",s=null;for(let o of t.slice(0,this.shown)){let r=Ka(o.ts);r!==a&&(a=r,s=e("div",{class:"dl-panel flush"},e("div",{class:"dl-panel-head pad"},e("h3",{},r))),n.push(s));let l=new Date(o.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(o.sys){let d=`${o.sys.ts}|${o.sys.msg}`;s.appendChild(qt(o.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else{let d=Ie(this.st,o.ev);d.lastElementChild.textContent=l,s.appendChild(d)}}t.length>this.shown&&n.push(e("div",{class:"dl-more-row"},R(`Show ${Math.min(wt,t.length-this.shown)} more of ${t.length-this.shown}`,()=>{this.shown+=wt,this.paint()}))),dom.content(this.list,n)}};var Va={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},Mn=3;function Wt(i){let t=new Date(i*1e3),n=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),a=Math.round((new Date(new Date().toDateString()).getTime()-new Date(t.toDateString()).getTime())/864e5);return`${a===0?"Today":a===1?"Yesterday":t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${n}`}async function Ya(i){let t=await U(()=>z.backupRead(i.name));if(!t)return;let n=atob(t.data),a=new Uint8Array(n.length);for(let o=0;oYa(i),"neutral","dl-icon-only"),ke("more","More",n=>we(n.currentTarget,[{label:"Restore",icon:v("reset"),run:async()=>{await re("Restore this backup?",`Everything returns to ${Wt(i.created)}. The current state is backed up first.`,"Restore",!0)&&await U(()=>z.backupRestore(i.name),"Restored")&&t()}},{label:"Delete",icon:v("trash"),danger:!0,run:async()=>{await re("Delete this backup?",`The backup from ${Wt(i.created)} is removed from the router.`,"Delete",!0)&&await U(()=>z.backupDelete(i.name),"Backup deleted")&&t()}}]),"neutral","dl-icon-only")])])}function Gt(i,t){let n=i.slice(0,Mn).map(d=>En(d,t)),a=i.slice(Mn),s=i.length?e("div",{class:"dl-list"},[...n,a.length?e("details",{class:"dl-bk-older"},[e("summary",{},[v("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(d=>En(d,t))]):""]):e("div",{class:"dl-list"},[e("div",{class:"dl-row dl-muted"},"No backups yet.")]),o=R("Restore from file",async()=>{let d=await At(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await re("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await U(()=>z.backupUpload(d.data),"Restored")&&t()}),r=R("Export JSON",async()=>{let d=await U(()=>z.exportJson());d&&ve(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=R("Import JSON",async()=>{let d=await At(".json,application/json","text");if(!d)return;let p;try{p=JSON.parse(d.data)}catch{ne("Not a JSON file.","error");return}await re("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await U(()=>z.importJson(p),"Imported")&&t()});return e("section",{class:"dl-setsec",id:"dl-set-backups"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-setsec-head"},[e("div",{class:"dl-stack"},[e("h3",{},"Backups"),e("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),e("span",{class:"dl-spacer"}),R([v("plus")," Back up now"],async()=>{await U(()=>z.backupCreate(),"Backup created")&&t()},"positive")]),s]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),e("span",{class:"dl-row-actions dl-bk-actions"},[o,r,l])])])}function it(i,t,n){i.some(([o])=>o===t)||(i=[...i,[t,t]]);let a=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":n,"data-value":t}),s=()=>dom.content(a,i.map(([o,r])=>e("button",{type:"button",role:"radio",class:o===a.dataset.value?"on":"","aria-checked":o===a.dataset.value?"true":"false",click:()=>{a.dataset.value=o,s()}},r)));return s(),a}function Ft(i,t,n=`${t}s`){return`${i.toLocaleString("en-GB")} ${i===1?t:n}`}function kt(i){return i<1024?`${i} B`:i<1048576?`${(i/1024).toFixed(i<10240?1:0)} KB`:`${(i/1048576).toFixed(1)} MB`}var $t=class{constructor(){this.root=e("div",{class:"dl-settings-main"});this.backups=[]}load(){return z.settingsGet()}render(t){return this.d=t,this.paint(),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),e("div",{},[e("div",{class:"dl-pagehead"},[e("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(t,n="Saved"){let a=await U(()=>z.settingsUpdate(t),n);a&&(this.d=a,this.paint())}section(t,n,a,s,o="",r=[]){return e("section",{class:`dl-setsec ${o}`,id:`dl-set-${t}`},[e("div",{class:"dl-setsec-body"},[r.length?e("div",{class:"dl-setsec-head"},[e("h3",{},n),e("span",{class:"dl-spacer"}),...r]):e("h3",{},n),...a]),s.length?e("div",{class:"dl-setsec-foot"},s):""])}portalSection(){let t=this.d.settings,n=this.d.effective,a=this.d.cert,s=this.d.portal_candidates??[],o=this.d.portal_checks??[],r=Ee(n.portal_enabled,"Enable portal"),l=oe(t.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),d=Ee(n.portal_443,"Standard ports",()=>T()),p=oe(t.portal_title,{placeholder:"Dawnline"}),u=oe(t.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),c=oe("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),b=I=>/^\d{1,3}(\.\d{1,3}){3}$/.test(I),g=[n.portal_host,...n.portal_alt??[]].filter((I,ae,M)=>I&&M.indexOf(I)===ae);!g.length&&s[0]&&(g=[s[0].host]);let w=[...s],F=I=>{I&&!w.some(ae=>ae.host===I)&&w.push({host:I,kind:b(I)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})};g.forEach(F);let Y=I=>I.kind==="ip"?e("span",{class:"dl-addr-warn"},[v("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):e("span",{class:"dl-sub"},I.cloudflare?"Behind Cloudflare · often stalls in Russia":I.ips.length?I.here?`Points at this router${I.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${I.ips.join(", ")}, not this router`:"Your address"),j=e("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),$=I=>{g.includes(I)?g.length>1&&(g=g.filter(ae=>ae!==I)):g=[...g,I],N(),T()},N=()=>dom.content(j,[...w.map(I=>{let ae=g.includes(I.host),M=g[0]===I.host;return e("div",{class:`dl-addr-opt${ae?" on":""}`,role:"checkbox","aria-checked":ae?"true":"false",tabindex:"0",click:()=>$(I.host),keydown:E=>{(E.key===" "||E.key==="Enter")&&(E.preventDefault(),$(I.host))}},[e("i",{class:"dl-addr-check"},ae?v("check"):""),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono"},I.host),Y(I)]),M?e("span",{class:"dl-pill info"},"Main"):ae?e("button",{type:"button",class:"dl-linkbtn",click:E=>{E.stopPropagation(),g=[I.host,...g.filter(x=>x!==I.host)],N(),T()}},"Make main"):I.cloudflare?e("span",{class:"dl-pill warn"},"Cloudflare"):I.kind==="ip"?e("span",{class:"dl-pill"},"IP"):I.here&&I.cert?e("span",{class:"dl-pill ok"},"Recommended"):""])}),e("div",{class:"dl-addr-opt other"},[e("i",{class:"dl-addr-check"},v("plus")),c,R("Add",()=>{let I=c.value.trim().toLowerCase();I&&(F(I),g.includes(I)||(g=[...g,I]),c.value="",N(),T())})])]);c.addEventListener("keydown",I=>{I.key==="Enter"&&(I.preventDefault(),c.nextElementSibling?.click())});let C=e("div",{class:"dl-links"}),T=()=>{let I=Ve(d),ae=Number(l.value)||n.portal_port;dom.content(C,g.map((M,E)=>{let x=b(M),D=x?I?80:ae+1:I&&!this.d.wan443_taken?443:ae,k=`${x?"http":"https"}://${M}${D===(x?80:443)?"":`:${D}`}/`;return e("div",{class:"dl-link-row"},[e("span",{class:`dl-link-ic ${x?"warn":"ok"}`},v(x?"alert":"lock")),e("span",{class:"dl-mono dl-link-url"},[k,e("b",{},"kamiro-telosu-bavine")]),E===0?e("span",{class:"dl-pill info"},"Main"):x?e("span",{class:"dl-pill warn"},"HTTP"):""])}))};N(),T(),l.addEventListener("input",()=>T());let y={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_443:"Port 443",portal_lan:"Works at home",portal_http:"Plain HTTP",cert:"Certificate"},A=o.filter(I=>I.status!=="skip"),m=A.filter(I=>I.status==="error"||I.status==="warn"),h=A.some(I=>I.status==="error")?"error":m.length?"warn":"ok",P=e("div",{class:"dl-ready-details",hidden:!0},A.map(I=>e("div",{class:`dl-ready-item ${I.status}`},[v(I.status==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("span",{},I.title),e("span",{class:"dl-sub"},I.detail)])]))),f=e("div",{class:"dl-stack gap8"},[e("div",{class:`dl-ready-sum ${h}`},[v(h==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("b",{},h==="ok"?`All ${A.length} checks passed`:`${A.length-m.length} of ${A.length} checks passed`),m.length?e("span",{class:"dl-sub"},m.map(I=>I.detail).join(" ")):e("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),e("button",{type:"button",class:"dl-linkbtn",click:I=>{P.hidden=!P.hidden,I.currentTarget.textContent=P.hidden?"Details":"Hide"}},"Details")]),e("div",{class:"dl-chips-row"},A.map(I=>e("span",{class:`dl-check-chip ${I.status}`,title:I.detail},[v(I.status==="ok"?"check":"alert"),y[I.id]??I.title]))),P]),_=a&&!a.self_signed&&a.expires?new Date(a.expires).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",O=ee("Standard ports",d,this.d.wan443_taken?"Port 443 is already forwarded to another device, so HTTPS links keep the listening port.":"Links without a port: 443 for names, 80 for IP addresses. Mobile networks often drop other ports. From the internet these reach only the portal; LuCI stays closed."),G=ee("Listening port",l,this.d.port_owners.length?`Port ${n.portal_port} is used by ${this.d.port_owners.join(", ")}.`:`Where the portal runs on the router: HTTPS here, plain HTTP for IP addresses on ${n.portal_port+1}.`),B=!!(t.portal_cert&&t.portal_key),S=a?B?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",q=()=>{let I=oe(t.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),ae=oe(t.portal_key,{placeholder:"/etc/ssl/…/key"});se("Use your own certificate",[e("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),ee("Certificate file",I),ee("Key file",ae)],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",()=>{X(),this.save({portal_cert:I.value.trim(),portal_key:ae.value.trim()},"Certificate saved")},"positive")])},W=this.d.needs??{https:[],acme:[],home:[]},te=(I,ae,M,E,x,D)=>e("div",{class:`dl-row dl-need-row ${ae}`},[ae?e("span",{class:"dl-need-ic"},v(I)):v(I),e("span",{class:"dl-row-main dl-stack"},[e("b",{},M),e("span",{class:"dl-sub"},E)]),R(D,()=>Je(x,W[x],()=>this.reload()),"positive")]),le=W.https.length?te("lock","bad","HTTPS isn’t available on this router",`The portal needs ${W.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",de=W.acme.length&&(!a||a.self_signed)?te("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${t.portal_host?` for ${t.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",Te=[e("div",{class:"dl-row"},[v("lock"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},[S,_?e("span",{class:"dl-faint"},` · until ${_}`):""]),e("span",{class:"dl-sub dl-ellipsis",title:a?.path??""},a?a.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${B?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),e("div",{class:"dl-row"},[v("file"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Your own files"),e("span",{class:"dl-sub"},B?`${t.portal_cert} · ${t.portal_key}`:"Not set: the certificate is picked automatically.")]),B?R("Reset",()=>this.save({portal_cert:"",portal_key:""},"Automatic certificate"),"negative"):"",R(B?"Change":"Use files",q)]),de];return this.section("portal","Personal portal",[e("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),le?e("div",{class:"dl-list"},[le]):"",me("network","Ports","How the portal listens",[O,G]),me("edit","Appearance","What people see",[ee("Title",p,"Shown at the top of the portal."),ee("Unknown links",u,"Where a wrong or old link goes, for example your website. Empty shows a plain “Not found”.")]),me("link","Addresses","Pick one or more; the first is the main link",[j,e("div",{class:"dl-stack gap8"},[C,e("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),me("lock","Certificate","Used for HTTPS links",Te),n.portal_enabled&&A.length?me("check","Ready to share","The portal’s checks from Health",[f]):""],[e("span"),R("Save",()=>this.save({portal_enabled:Ve(r)?"1":"0",portal_443:Ve(d)?"1":"0",portal_host:g[0]??"",portal_alt:g.slice(1),portal_port:l.value,portal_title:p.value,portal_redirect:u.value.trim()}),"positive")],"",[n.portal_enabled?W.https.length?e("span",{class:"dl-pill bad"},"Can’t start"):e("span",{class:`dl-pill ${h==="ok"?"ok":h==="error"?"bad":"warn"}`},h==="error"?"Needs attention":"Ready"):"",r])}paint(){let t=this.d.settings,n=this.d.effective,a=this.portalSection(),s=oe(t.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),o=Ee(n.hostnames,"Device hostnames"),r=oe(t.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),l=oe(t.home_dns_fallback==="none"?"":t.home_dns_fallback||n.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),d=this.section("defaults","Defaults",[ee("Devices per person",s,"Pre-filled when you add someone."),ee("Device hostnames",e("div",{class:"dl-hostport"},[o,e("span",{class:"dl-faint dl-mono"},"phone.myata."),r]),"Name devices in your home DNS."),ee("Fallback DNS",l,"For Home-only devices using home names: the second DNS server, used by the device when the tunnel is down. Empty = none.")],[e("span"),R("Save",()=>this.save({default_device_limit:s.value,hostnames:Ve(o)?"1":"0",domain:r.value,home_dns_fallback:l.value}),"positive")]),p=Ee(n.geo_enabled,"Locations"),u=e("select",{class:"cbi-input-select"},[e("option",{value:"ipwho.is",selected:n.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),e("option",{value:"ipapi.co",selected:n.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]),c=this.section("map","Map & locations",[e("div",{class:"dl-setrow head"},[e("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),p]),ee("Provider",u)],[e("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),R("Save",()=>this.save({geo_enabled:Ve(p)?"1":"0",geo_provider:u.value}),"positive")]),b=this.logsSection(),g=this.section("danger","Remove Dawnline from this router",[e("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[e("span"),R("Remove",()=>this.uninstall(),"negative")],"danger"),w=Gt(this.backups,()=>{this.reload(),this.loadBackups()});dom.content(this.root,[a,d,c,b,w,g])}logsSection(){let t=this.d.logs,n=t.policy,a=it([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(n.keep_days),"Keep activity"),s=it([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(n.max),"Maximum events"),o=it([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],n.persist,"Save to flash"),r=it([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(n.usage_days),"Daily traffic"),l=it([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(n.usage_months),"Monthly traffic"),d=new Set(n.categories),p=e("div",{class:"dl-chips-row"},Xe.map(w=>{let F=e("button",{type:"button",class:`dl-chipbtn${d.has(w)?" on":""}`,title:hn[w],click:()=>{d.has(w)?d.delete(w):d.add(w),F.classList.toggle("on",d.has(w))}},[Ge[w],e("b",{},String(t.by_category[w]??0))]);return F})),u=w=>new Date(w).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),c=t.oldest?u(new Date(t.oldest*1e3)):"",b=(w,F,Y,j)=>e("div",{class:"dl-row"},[v(w),e("span",{class:"dl-row-main dl-stack"},[e("b",{},F),e("span",{class:"dl-sub"},Y)]),...j]),g=w=>R(w.toUpperCase(),async()=>{let[F,Y]=await Promise.all([z.status(1),z.events(2e4)]);Le(F,Y.events,w)},"neutral",{title:`Download the log as ${w.toUpperCase()}`});return this.section("logs","Logs & history",[e("p",{class:"dl-muted"},Ot(n)),ee("Keep activity",a,"Older events are removed automatically."),ee("Maximum size",s,"Newest events are kept when the log is full."),ee("Record",p,"Switched-off categories are not logged from now on."),ee("Save to flash",o,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),ee("Daily traffic",r,"Per-day history behind the charts."),ee("Monthly traffic",l,"Per-month totals; data limits use the current month."),e("h4",{class:"dl-setsub"},"Stored data"),e("div",{class:"dl-list"},[b("activity","Activity log",t.events?`${Ft(t.events,"event")} since ${c} · ${kt(t.log_ram)} in memory${n.persist==="off"?"":`, ${kt(t.log_flash)} on flash`}`:"Empty",[g("csv"),g("json"),R("Clear",()=>Ce("Clear activity","Removes events from the log on the router.",{},()=>this.reload()),"negative")]),b("chart","Traffic history",t.usage_days?`${Ft(t.usage_days,"day")} since ${u(t.usage_since)} · ${kt(t.usage_flash)} on flash`:"Empty",[R("Reset",()=>Fe("all","","",()=>setTimeout(()=>this.reload(),300)),"negative")]),b("pin","Location cache",`${Ft(this.d.geo_cached,"address","addresses")} · ${kt(t.geo_flash)} on flash`,[R("Clear",async()=>{await U(()=>z.geoClear(),"Location cache cleared")&&this.reload()},"negative")])])],[e("span",{class:"dl-sub"},"Clear one person or device from their own page."),R("Save",()=>this.save({log_keep_days:a.dataset.value,log_max:s.dataset.value,log_persist:o.dataset.value,usage_keep_days:r.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]}),"positive")])}async loadBackups(){let t=await z.backupList().catch(()=>null);if(t){this.backups=t.backups;let n=document.getElementById("dl-set-backups");n&&n.replaceWith(Gt(this.backups,()=>{this.reload(),this.loadBackups()}))}}async reload(){let t=await z.settingsGet().catch(()=>null);t&&(this.d=t,this.paint())}uninstall(){let t=oe("",{placeholder:"remove"});se("Remove Dawnline?",[e("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),t],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Remove Dawnline",async()=>{await U(()=>z.uninstall(t.value.trim()),"Dawnline removed")&&(X(),setTimeout(()=>location.reload(),800))},"negative")])}};var Ja={ok:"check",warn:"alert",error:"x",skip:"pause"},Tn={apply:"Repair",sync:"Reload devices",restart:"Restart service",updates:"Open updates"},_t=class{constructor(t,n,a,s){this.el=e("div",{});this.wdEl=e("div",{});this.checksEl=e("div",{class:"dl-panel"});this.recentEl=e("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=e("div",{});this.open=new Set;this.st=t,this.sl=n,this.events=a,this.toLog=s,dom.content(this.el,[this.summary,this.wdEl,e("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(n,a)}async run(t){let n=t?await U(()=>z.healthFix(t),"Done"):await z.health().catch(()=>null);n&&this.take(n)}take(t){this.checks=t.checks,this.paintChecks(),this.paintLive(t,this.events)}paintChecks(){let t=this.checks;if(!t){dom.content(this.summary,""),dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks")]),e("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let n=t.filter(r=>r.status==="error").length,a=t.filter(r=>r.status==="warn").length;dom.content(this.summary,n?Ae("error",`${n} problem${n>1?"s":""} need attention.`):a?Ae("warn",`${a} warning${a>1?"s":""}.`):Ae("ok","All checks passed."));let s=new Map;for(let r of this.sl.watchdog.repairs)s.set(r.id,Math.max(s.get(r.id)??0,r.ts));let o=()=>this.run();dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks"),e("span",{class:"dl-spacer"}),R("Run again",o)]),e("ul",{class:"dl-checks"},t.map(r=>e("li",{},[e("span",{class:`dl-check-icon ${r.status}`},v(Ja[r.status])),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},r.title),e("div",{class:"dl-check-detail"},r.detail),s.has(r.id)?e("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${Ne(s.get(r.id))}`):""]),r.fix?r.fix.startsWith("install:")?R("Install",()=>$n(r.fix.slice(8),o),"action"):r.fix==="updates"?e("a",{class:"cbi-button cbi-button-action",href:L.url("admin/network/dawnline/updates")},Tn.updates):R(Tn[r.fix]??"Fix",()=>this.run(r.fix),"action"):""])))])}paintLive(t,n){this.sl=t,this.events=n;let a=t.watchdog,s=a.beat!=null&&a.now-a.beat>180,o=a.repairs.filter(d=>a.now-d.ts<86400),r=o[o.length-1],l=Ee(a.enabled,"Watchdog repairs",async d=>{await U(()=>z.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||l.classList.toggle("on",!d);let u=await z.serviceLog().catch(()=>null);u&&this.paintLive(u,this.events)});dom.content(this.wdEl,e("div",{class:"dl-panel dl-wd"},[e("div",{class:"dl-wd-head"},[e("span",{class:`dl-wd-tile${a.enabled?"":" off"}`},v("shield")),e("div",{class:"dl-stack"},[e("span",{class:"dl-wd-title"},"Watchdog"),e("span",{class:"dl-sub"},a.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),e("span",{class:"dl-spacer"}),l]),e("div",{class:"dl-wd-foot"},[e("div",{class:"dl-wd-chips"},a.targets.map(d=>e("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?"OK":`Not working${d.tries?` · ${d.tries} repair${d.tries>1?"s":""}`:""}`},[v(d.ok?"check":"x"),d.name]))),e("span",{class:`dl-sub${s?" dl-warn-text":""}`},s?`The agent has not checked in for ${Math.round((a.now-a.beat)/60)} min; cron restarts it after 5.`:[a.last?`Looked ${ue(a.last,a.now)}`:"Starts within a minute"," · ",o.length?`${o.length} repair${o.length>1?"s":""} today, last ${r.name} at ${Ne(r.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let t=Date.now()/1e3-604800,n=[...this.events.map(s=>({ts:s.ts,ev:s})),...this.sl.log.map(s=>({ts:s.ts,sys:s}))].filter(s=>s.ts>=t&&Ut(s)).sort((s,o)=>o.ts-s.ts),a=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Recent problems"),e("span",{class:"dl-spacer"}),n.length?e("a",{href:"#",click:s=>(s.preventDefault(),this.toLog())},"All in Log →"):""]);if(!n.length){dom.content(this.recentEl,[a,e("div",{class:"dl-recent-empty"},[e("span",{class:"dl-check-icon ok"},v("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[a,...n.slice(0,8).map(s=>{if(s.sys){let r=s.sys,l=`${r.ts}|${r.msg}`;return qt(r,this.open.has(l),()=>{this.open.delete(l)||this.open.add(l),this.paintRecent()},Ne(r.ts))}let o=Ie(this.st,s.ev);return o.lastElementChild.textContent=Ne(s.ts),o})])}},Qa=[{title:"ip-full · veth",sub:"Policy routing and the home-like link",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"OpenSSL",sub:"HTTPS for the personal portal",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"ACME",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],St=class{constructor(){this.running=!1}load(){return z.updatesStatus()}render(t){return this.root=e("div",{class:"dl-root dl-upd"}),this.paint(t),poll.add(async()=>{let n=await z.updatesStatus().catch(()=>null);n&&n.job?.state==="running"?this.paint(n):n&&this.running&&(this.running=!1,this.paint(n),n.job?.component==="app"&&n.job.state==="done"&&(ui.menu?.flushCache(),setTimeout(()=>location.reload(),1500)))},3),this.root}paint(t){let n=t.job;this.running=n?.state==="running";let a=t.check?.components??{},s=t.firmware,o=a.app,r=a.amneziawg,l=a.packages,d={disabled:this.running},p=(f,_)=>e("span",{class:`dl-pill ${f}`},_),u=(f,_,O)=>e("div",{class:"dl-upd-row"},[e("span",{class:"dl-stack"},[e("span",{class:"dl-upd-name"},f),e("span",{class:"dl-sub"},_)]),O]),c=(f,_,O,G,B=[])=>e("section",{class:"dl-setsec dl-upd-sec"},[e("div",{class:"dl-upd-head"},[e("span",{class:"dl-group-ic"},v(f)),e("span",{class:"dl-stack"},[e("b",{},_),e("span",{class:"dl-sub"},O)]),G]),...B]),b=f=>f?new Date(f).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",g=c("sunrise","Dawnline",o?.repo?`${t.version} · ${o.repo}`:t.version,o?o.update?R(`Update to ${o.latest}`,()=>this.run("app"),"positive",d):o.latest?p("ok","Up to date"):p("","No releases yet"):p("","Not checked")),w=r?.sources??{},Y=Object.keys(w).map(f=>{let _=w[f],O=r?.current===f,G=[_.version?`${_.tag} build${_.date?` · ${b(_.date)}`:""} · ${_.gen==="3.1"?"devices need AmneziaVPN with 3.1":"works with every AmneziaWG app"}`:`No build for OpenWrt ${s?.version??""}`],B=_.version?O?r?.update?R("Update",()=>this.runAwg(f,!!r.ru,_.gen),"positive",d):p("ok","Installed"):R("Switch",()=>this.runAwg(f,!!r?.ru,_.gen),"neutral",d):p("","No build");return u([_.gen?`AmneziaWG ${_.gen}`:"AmneziaWG",e("span",{class:"dl-faint"},` · ${_.label}`)],G,B)});r?.current&&w[r.current]?.version&&Y.push(u("Russian translation","LuCI pages for AmneziaWG in Russian",R(r.ru?"Remove":"Add",()=>this.runAwg(r.current,!r.ru,r.gen),"neutral",d)));let j=c("shield","AmneziaWG",r?.installed?`${r.gen?`${r.gen} · `:""}${r.installed} · changing it restarts every tunnel`:"Not installed",r?"":p("","Not checked"),Y.length?Y:[u("Builds for this router","Check for updates to see them.","")]),$=l?.pkgs??{},N=[],C=Qa.filter(f=>f.feature==="home"?t.home:t.portal);for(let f of C){let _=f.pkgs.filter(B=>$[B]?.installed),O=[...new Set(_.flatMap(B=>[...$[B]?.latest?[B]:[],...$[B]?.with??[]]))],G=t.needs?.[f.feature]??f.pkgs.filter(B=>!$[B]?.installed);if(G.length)N.push(u(f.title,f.optional?`Not installed · ${f.sub}`:e("span",{class:"dl-upd-bad"},`Missing ${G.join(", ")} · ${f.sub}`),R("Install",()=>this.runPkgs(G,f.title),"neutral",d)));else if(O.length){let B=_.find(W=>$[W]?.latest),S=B?[e("span",{class:"dl-mono"},[`${$[B].installed} → `,e("b",{},$[B].latest)])]:[],q=O.filter(W=>W!==B);q.length&&S.push(`${B?" · ":""}${q.length<=2?`${B?"with ":""}${q.join(", ")}`:`${B?"+":""}${q.length} related packages`}`),N.push(u(f.title,S,R("Update",()=>this.runPkgs(_.filter(W=>$[W]?.latest||$[W]?.with?.length),f.title,O),"neutral",d)))}else N.push(u(f.title,f.sub,p("ok","Up to date")))}let T=C.flatMap(f=>f.pkgs).filter(f=>$[f]?.installed),y=[...new Set(T.flatMap(f=>[...$[f].latest?[f]:[],...$[f].with??[]]))],A=c("package","System packages",l?y.length?`${y.length} update${y.length===1?"":"s"} from the OpenWrt ${s?.version?.replace(/\.\d+$/,"")??""} feeds`:"What Dawnline adds to OpenWrt is current":"What Dawnline adds to OpenWrt",l?y.length?R("Update all",()=>this.runPkgs(T.filter(f=>$[f].latest||$[f].with?.length),"all packages",y),"positive",d):"":p("","Not checked"),l?N:[]),m=n?e("details",{class:"dl-params dl-upd-job",open:this.running?"open":null},[e("summary",{},[v("chevron"),e("span",{},"Last job"),p(n.state==="done"?"ok":n.state==="failed"?"bad":"warn",n.state==="running"?n.phase||"Running":n.state==="done"?"Finished":"Failed"),e("span",{class:"dl-sub"},`${n.action==="check"?"check":n.component??""} · ${Ne(n.started)}${n.finished?` · ${n.finished-n.started} s`:""}`)]),n.error?Ae("error",n.error):"",e("pre",{class:"dl-log"},n.log.join(` -`))]):"",h=y.length+(o?.update?1:0)+(r?.update?1:0),P=[s?.version?`OpenWrt ${s.version} · ${s.target}`:"",t.check?h?`${h} update${h===1?"":"s"} ready`:"everything is current":"not checked yet",t.check?`checked ${Ne(t.check.time)}`:""].filter(Boolean).join(" · ");dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Updates"),e("span",{class:"dl-faint"},P)]),R([v("refresh")," Check now"],()=>this.run("check"),"neutral",d)]),g,j,A,m])}async runAwg(t,n,a){await re(a?`Install AmneziaWG ${a}?`:"Install AmneziaWG?","Every AmneziaWG tunnel on the router restarts for a few seconds, HomeTunnel too. Devices stay configured.","Install")&&this.start(`amneziawg:${t}${n?":ru":""}`)}async runPkgs(t,n,a=t){await re(`Update ${n}?`,`${a.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&this.start(`pkgs:${t.join(",")}`)}async run(t){t!=="check"&&!await re(`Update ${t==="app"?"Dawnline":t}?`,"A backup is made first. The page reloads when it finishes.","Update")||this.start(t)}async start(t){if(await U(()=>z.updatesRun(t))){this.running=!0;let n=await z.updatesStatus().catch(()=>null);n&&this.paint(n)}}};function Kt(i){return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function Za(i,t,n,a=30){let s=i?new Date(`${i}T12:00:00`):new Date;return t==="day"?s.setDate(s.getDate()+n):t==="week"?s.setDate(s.getDate()+7*n):t==="month"?s.setMonth(s.getMonth()+n):t==="year"?s.setFullYear(s.getFullYear()+n):s.setDate(s.getDate()+a*n),Kt(s)}var Xa={internet:"Browse the internet through your router. No access to devices at home, and home cannot reach theirs.",lan:"Reach devices at home, and home reaches theirs. Internet stays on their own connection.",both:"Home devices and the internet, all through your router. Home reaches their devices too."},Lt=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.refreshSeq=0;this.refreshShown=0}async load(){this.id=new URLSearchParams(location.search).get("id")??"";let[t,n,a]=await Promise.all([z.status(30),z.events(5e3).catch(()=>({events:[]})),z.personUsage(this.id,30).catch(()=>null)]);return this.series=a?.person??[],this.devSeries=a?.devices??{},[t,n.events]}render([t,n]){this.st=t,this.events=n;let a=t.people.find(l=>l.id===this.id);if(!a)return e("div",{class:"dl-empty"},[e("h3",{},"Person not found"),e("p",{},"They may have been removed."),e("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=a;for(let l of["head","devices","traffic","places","activity","limits"])this.parts[l]=e("div",{});this.parts.devices.className="dl-person-devices";let s=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:Ze(a.server)},t.servers.find(l=>l.id===a.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:Ze(a.server)},"People"),e("span",{},"/"),e("span",{},a.name)]),this.parts.head,e("div",{class:"dl-grid-person"},[e("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),e("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let o=new URLSearchParams(location.search),r=o.get("device")&&a.devices.find(l=>l.id===o.get("device"));return r?setTimeout(()=>De(this.p,r,()=>this.refresh(),this.st.geo),50):o.get("add")&&setTimeout(()=>Ke(this.p,()=>this.refresh()),50),poll.add(()=>this.refresh(!0),15),s}async refresh(t=!1){let n=++this.refreshSeq,[a,s,o]=await Promise.all([z.status(30).catch(()=>null),z.events(5e3).catch(()=>null),z.personUsage(this.id,30).catch(()=>null)]);if(!a||nl.id===this.id);if(!r){t||(location.href=Ze(this.p?.server));return}this.p=r,this.paint(),this.map?.update(this.mapData())}async patch(t,n){var o;let a=await U(()=>z.personUpdate(this.p.id,t),n);if(!a)return;let s=this.st.people.findIndex(r=>r.id===this.p.id);(o=a.person).rate??(o.rate=this.p.rate),s>=0&&(this.st.people[s]=a.person),this.p=a.person,this.paint()}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}mapCard(){let t=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),this.st.geo.enabled?dt("30d",n=>this.map?.setRange(n),!1):"",R("Hide",()=>{this.mapOpen=!1,this.map?.destroy(),this.map=null,this.paintPlaces()},"neutral")]);return this.st.geo.enabled?(this.map=new qe({openPerson:()=>{},openDevice:(n,a)=>{let s=this.p.devices.find(o=>o.id===a);s&&De(this.p,s,()=>this.refresh(),this.st.geo)}},"30d",280),requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[t,this.map.el])):e("div",{class:"dl-panel flush"},[t,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])])}paint(){let t=this.p,n=this.st,a=t.online?"online now":t.last_seen?`last seen ${ue(t.last_seen,n.now)}`:"never connected",s=this.series.find(c=>c.day===Kt(new Date));dom.content(this.parts.traffic,e("div",{class:`dl-person-live${t.online?"":" solo"}`},[t.online?Rt(t.rate??[],n.now,s?[s.rx,s.tx]:[0,0]):"",Ht(this.series,`${Z(t.month[0]+t.month[1])} this month`)]));let o=t.created?`Added ${_e(Kt(new Date(t.created*1e3)))}`:"",r=[{label:"Rename",icon:v("edit"),run:()=>this.rename()},{label:t.note?"Edit note":"Add note",icon:v("file"),run:()=>this.editNote()},...t.link?[null,{label:"Invite card",icon:v("qr"),run:()=>this.invite()},{label:"New link",icon:v("key"),run:()=>this.newLink()}]:[],null,{label:t.paused?"Resume":"Pause",icon:v(t.paused?"play":"pause"),warn:!t.paused,run:()=>this.patch({paused:!t.paused},t.paused?"Resumed":"Paused")},{label:"Delete",icon:v("trash"),danger:!0,run:()=>this.remove()}];dom.content(this.parts.head,e("div",{class:"dl-person-head"},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-person-id"},[e("span",{class:`dl-avatar lg${t.online?" online":""}`},Re(t.name)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),Bt(t)]),e("span",{class:"dl-faint",title:o},`${t.devices.length} of ${t.device_limit} devices · ${a}`)])]),e("div",{class:"dl-pcard-actions"},[t.link?ke("link","Copy link",()=>he(t.link,"Personal link copied"),"neutral","dl-icon-only"):"",ke("more","More",c=>we(c.currentTarget,r),"neutral","dl-icon-only")])]),t.note?e("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>this.editNote()},[v("file"),e("span",{},t.note)]):""])),this.paintDevices(),this.paintLimits(),this.paintPlaces();let l=this.events.filter(c=>c.person===t.id),d=[],p=[...l].reverse();for(let c=0;c1){let F=w.querySelector(".dl-row-main");dom.content(F,[...zt(n,b).slice(0,3),e("span",{class:"dl-muted"},`${g} times`)]),F.title=p.slice(c,c+g).map(Y=>Y.detail??"").join(` -`)}d.push(w),c+=g-1}let u=R([v("more")],()=>we(u,[{label:"Export CSV",icon:v("download"),run:()=>Le(this.st,l,"csv",t.id)},{label:"Export JSON",icon:v("download"),run:()=>Le(this.st,l,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:v("trash"),danger:!0,run:()=>Ce(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>this.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});dom.content(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},l.length>10?`latest 10 of ${l.length}`:""),e("span",{class:"dl-spacer"}),u]),d.length?d:e("div",{class:"dl-row dl-muted"},"Nothing yet.")]))}deviceStatus(t){return t.disabled?e("span",{class:"dl-dstat"},"Disabled"):t.online?e("span",{class:"dl-dstat ok"},"Connected"):t.handshake?e("span",{class:"dl-dstat"},`Last seen ${ue(t.handshake,this.st.now)}`):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},"Not set up yet")}deviceBars(t){let n=(this.devSeries[t]??[]).slice(-30),a=n.map(r=>r.rx+r.tx),s=Math.max(1,...a),o=r=>new Date(`${r}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"});return e("div",{class:"dl-dbars"},n.map((r,l)=>{let d=e("i",{class:`${a[l]?"":"zero"}${l===n.length-1?" hi":""}`});return d.style.height=`${Math.max(8,a[l]/s*100)}%`,pe(d,()=>[e("div",{class:"dl-tip-title"},l===n.length-1?`Today · ${o(r.day)}`:o(r.day)),e("div",{},Z(a[l]))]),d}))}paintDevices(){let t=this.p,n=()=>this.refresh(),a=rt(t.devices).map(o=>{let r=()=>De(t,o,n,this.st.geo);return e("article",{class:`dl-dcard${o.online?" online":""}${o.disabled?" off":""}`},[e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},v(o.kind)),e("button",{type:"button",class:"dl-dcard-title",click:r},[e("b",{},o.name),this.deviceStatus(o),o.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),R([v("more")],r,"neutral",{title:`${o.name}: connect, rename, keys, remove`,class:"cbi-button cbi-button-neutral dl-icon-only"})]),o.handshake?e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},Z(o.month[0]+o.month[1])),e("span",{class:"dl-sub"},"this month")]),this.deviceBars(o.id)]):o.disabled?e("div",{class:"dl-sub"},`${Se[o.kind]} · created ${ue(o.created,this.st.now)} ${o.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>this.showDeviceQr(o)},[v("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>this.downloadConfig(o)},[v("download"),"Config"])])])}),s=t.devices.length>=t.device_limit;a.push(e("button",{type:"button",class:"dl-dslot add",click:()=>Ke(t,n)},[e("span",{class:"dl-dslot-ic"},v("plus")),e("span",{class:"dl-stack"},[e("b",{},"Add device"),s?e("span",{class:"dl-sub"},`Over the limit · ${t.devices.length} of ${t.device_limit}`):""])])),dom.content(this.parts.devices,e("section",{class:"dl-devsec"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Devices"),e("span",{class:"dl-sub"},`${t.online} online`)]),e("div",{class:"dl-dgrid"},a)]))}paintLimits(){let t=this.p,n=e("div",{class:"dl-seg wide",role:"radiogroup","aria-label":"Access"},["internet","lan","both"].map(m=>e("button",{type:"button",role:"radio",class:t.access===m?"on":"","aria-checked":t.access===m?"true":"false",click:()=>t.access!==m&&this.patch({access:m},`Access: ${Ue[m]}`)},[v(m==="internet"?"globe":m==="lan"?"home":"shield"),m==="internet"?"Internet":m==="lan"?"Home":"Both"]))),a=ze(t.expires),s=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});s.addEventListener("change",()=>s.value&&this.patch({expires:s.value},`Access until ${_e(s.value)}`));let o=(m,h,P)=>{let f=Za(t.expires&&(a??-1)>=0?t.expires:"",m,h);return this.patch({expires:f},`Access until ${_e(f)}`),P},r=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([m,h,P])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>o(m,h,P)},P)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{try{s.showPicker()}catch{s.focus()}}},[v("calendar"),t.expires?_e(t.expires):"Date"]),s]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[t.expire_action],p=e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Access ends"),t.expires?e("span",{class:a!=null&&a<0?"dl-bad":a!=null&&a<=t.expire_warn?"dl-warn":"dl-ok"},a!=null&&a<0?"ended":`${a} day${a===1?"":"s"} left`):e("span",{class:"dl-faint"},"no end date")]),e("div",{class:"dl-chips-row"},[...r,l,t.expires?e("button",{type:"button",class:"dl-chipbtn",click:()=>this.patch({expires:""},"No end date")},"No end"):""]),e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`When it ends: ${d}${t.expire_warn?`, warn ${t.expire_warn} day${t.expire_warn===1?"":"s"} before`:""}`),e("a",{href:"#",click:m=>{m.preventDefault(),this.endSettings()}},"Change")])]),u=t.quota_used||t.month[0]+t.month[1],c=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,b=e("div",{class:`dl-meter${c>=100?" bad":c>=90?" warn":""}`},[e("i"),t.quota_limit?e("span",{class:"mark",title:"Alert at 90%"}):""]);b.firstChild.style.width=`${c}%`,t.quota_limit&&pe(b,()=>[e("div",{class:"dl-tip-title"},`${c.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${Z(t.quota_used)} of ${Z(t.quota_limit)} · ${Z(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},"Alert at 90%")]);let g=e("div",{class:"dl-seg sm"},["month","total"].map(m=>e("button",{type:"button",class:t.quota_period===m?"on":"",click:()=>t.quota_period!==m&&this.patch({quota_period:m})},m==="month"?"Monthly":"Total"))),w=[10,50,100].map(m=>e("button",{type:"button",class:`dl-chipbtn${t.quota_gb===m?" on":""}`,click:()=>this.patch({quota_gb:String(m)},`Data limit ${m} GB`)},`${m} GB`));w.push(e("button",{type:"button",class:`dl-chipbtn${t.quota_gb?"":" on"}`,click:()=>this.patch({quota_gb:""},"No data limit")},"Unlimited")),w.push(e("button",{type:"button",class:"dl-chipbtn",click:()=>{let m=prompt("Data limit in GB",t.quota_gb?String(t.quota_gb):"");m!=null&&m.trim()!==""&&Number(m)>0&&this.patch({quota_gb:m.trim()},`Data limit ${m.trim()} GB`)}},"Custom"));let F=e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Data"),g]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[Z(u),t.quota_limit?e("span",{class:"dl-faint"},` of ${Z(t.quota_limit)}`):e("span",{class:"dl-faint"}," · no limit")]),t.quota_period==="month"?e("span",{class:"dl-sub"},"resets on the 1st"):""]),t.quota_limit?b:"",e("div",{class:"dl-chips-row"},w),t.quota_gb&&t.quota_period==="month"?e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},t.bonus_gb?`Includes +${t.bonus_gb} GB extra this month`:"Need a little more this month?"),e("a",{href:"#",click:m=>{m.preventDefault(),this.patch({bonus_gb:String((t.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`${Z(t.total[0]+t.total[1])} in total`),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe("person",t.id,t.name,()=>setTimeout(()=>this.refresh(),300))},"Reset usage")])]),Y=!!t.hours,[j,$]=(t.hours||"07:00-23:00").split("-"),N=e("input",{type:"time",class:"cbi-input-text",value:j}),C=e("input",{type:"time",class:"cbi-input-text",value:$}),T=()=>this.patch({hours:`${N.value}-${C.value}`},`Allowed ${N.value}–${C.value}`);N.addEventListener("change",T),C.addEventListener("change",T);let y=e("button",{type:"button",role:"switch","aria-checked":Y?"true":"false",class:`dl-switch${Y?" on":""}`,"aria-label":"Limit hours",click:()=>this.patch({hours:Y?"":"07:00-23:00"},Y?"Any time":"Allowed 07:00–23:00")},e("i")),A=e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-row"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-tile2-label"},"Allowed hours"),e("span",{},Y?`${j} – ${$} (router time)`:"Any time")]),y]),Y?e("div",{class:"dl-tile2-row"},[N,e("span",{class:"dl-faint"},"to"),C]):""]);dom.content(this.parts.limits,e("section",{class:"dl-devsec","aria-label":"Access and limits"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Access & limits")]),e("div",{class:"dl-panel"},[e("div",{class:"dl-stack gap8"},[e("span",{class:"dl-tile2-label"},"Can reach"),n,e("span",{class:"dl-sub"},Xa[t.access]),t.access==="lan"&&this.st.services.length?this.servicesPicker():"",Ye(t)?this.netsPicker():"",t.access==="lan"?this.dnsPicker():""]),e("div",{class:"dl-tiles2"},[this.devTile(),this.circleTile(),p,F,A])])]))}dnsPicker(){let t=this.p,n=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":"DNS"},[["device","Device’s own DNS"],["home","Home names"]].map(([s,o])=>e("button",{type:"button",role:"radio",class:t.dns_mode===s?"on":"","aria-checked":t.dns_mode===s?"true":"false",click:()=>t.dns_mode!==s&&this.patch({dns_mode:s},s==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")},o))),a=this.st.settings.home_dns_fallback;return e("div",{class:"dl-stack gap4 dl-dnspick"},[e("div",{class:"dl-row-actions"},[e("span",{class:"dl-sub"},"DNS"),n]),e("span",{class:"dl-sub"},t.dns_mode==="home"?["Names like ",e("span",{class:"dl-mono"},`nas.${this.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",a?[" (",e("span",{class:"dl-mono"},a)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}netsPicker(){let t=this.p,a=this.st.servers.find(o=>o.id===t.server)?.home??[];if(a.length<2)return"";let s=new Set(t.home_nets?.length?t.home_nets:a.map(o=>o.dev));return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},a.map(o=>e("button",{type:"button",class:`dl-chipbtn${s.has(o.dev)?" on":""}`,"aria-pressed":s.has(o.dev)?"true":"false",title:o.nets.join(", "),click:()=>{let r=new Set(s);if(r.delete(o.dev)||r.add(o.dev),!r.size)return ne("Keep at least one network, or choose Internet only.","warning",5e3);let l=r.size===a.length?[]:[...r];this.patch({home_nets:l},l.length?`${t.name} reaches ${l.join(", ")}`:`${t.name} reaches every home network`)}},o.dev))),e("span",{class:"dl-sub"},t.home_nets?.length?`Home networks ${t.name} reaches. Networks added to the server later stay out.`:`Home networks ${t.name} reaches: all of them. Untick one to keep ${t.name} out of it.`)])}circleTile(){let t=this.p;if(this.st.servers.find(l=>l.id===t.server)?.mesh!=="circles"||!Ye(t))return"";let a=this.st.circles.filter(l=>l.server===t.server),s=a.find(l=>l.id===t.circle),o=s?this.st.people.filter(l=>l.id!==t.id&&l.circle===s.id&&Ye(l)).map(l=>l.name):[],r=R("Change",()=>we(r,[...a.map(l=>({label:l.name,icon:bt(l),run:()=>l.id!==t.circle&&this.patch({circle:l.id},`${t.name} is in ${l.name}`)})),t.circle?{label:"No circle",icon:v("x"),run:()=>this.patch({circle:""},`${t.name} is in no circle`)}:null,{label:"New circle",icon:v("plus"),run:()=>vt(this.st,t.server,null,()=>this.refresh())}]));return e("div",{class:"dl-tile2"},[e("span",{class:"dl-tile2-label"},["Devices see each other",e("span",{class:"dl-faint dl-w400"},"circle")]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-circle-name"},s?[bt(s),s.name]:e("span",{class:"dl-muted"},"No circle")),r]),e("span",{class:"dl-sub"},s?o.length?`${t.name}'s devices and ${o.join(", ")}'s see each other. Others don't.`:`Nobody else in ${s.name} yet: only ${t.name}'s own devices see each other.`:`Only ${t.name}'s own devices see each other.`)])}servicesPicker(){let t=new Set(this.p.services??[]);return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},this.st.services.map(n=>e("button",{type:"button",class:`dl-chipbtn${t.has(n.id)?" on":""}`,title:`${n.address}${n.ports.length?` · ${n.ports.join(", ")}`:""}`,click:()=>{t.has(n.id)?t.delete(n.id):t.add(n.id),this.patch({services:[...t]},t.size?"Home services updated":"Whole home network")}},n.name))),e("span",{class:"dl-sub"},t.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}devTile(){let t=this.p,n=e("div",{class:"dl-slots"});for(let o=0;o=t.device_limit,d=e("i",{class:l?"over":r?"used":""});pe(d,()=>[e("div",{class:"dl-tip-title"},r?`${r.name}${l?" · over the limit":""}`:"Free slot"),e("div",{class:"dl-muted"},r?r.online?"Connected":r.handshake?`Last seen ${ue(r.handshake,this.st.now)}`:"Not set up yet":"They can add a device here")]),n.appendChild(d)}let a=Math.max(1,t.devices.length),s=e("button",{type:"button","aria-label":"Allow fewer devices",disabled:t.device_limit<=a?"disabled":null,click:()=>this.patch({device_limit:String(t.device_limit-1)})},"−");return t.device_limit<=a&&t.devices.length>1&&pe(s,()=>[e("div",{class:"dl-tip-title"},`${t.devices.length} devices in use`),e("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},"Devices"),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[String(t.devices.length),e("span",{class:"dl-faint"},` / ${t.device_limit}`)]),e("div",{class:"dl-stepper"},[s,e("button",{type:"button","aria-label":"Allow more devices",disabled:t.device_limit>=32?"disabled":null,click:()=>this.patch({device_limit:String(t.device_limit+1)})},"+")])]),n])}paintPlaces(){let t=this.st;if(!t.geo.enabled){dom.content(this.parts.places,e("div",{class:"dl-places"},[v("pin"),e("div",{class:"dl-stack"},[e("span",{},"Locations are off"),e("span",{class:"dl-sub"},"City-level, from the client IP")]),e("span",{class:"dl-spacer"}),e("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]));return}if(this.mapOpen){(!this.map||!this.parts.places.contains(this.map.el))&&dom.content(this.parts.places,this.mapCard());return}let n=t.now-30*86400,a=t.geo.points.filter(r=>r.person===this.p.id&&r.ts>=n).sort((r,l)=>l.ts-r.ts),s=[...new Set(a.map(r=>r.city||r.country).filter(Boolean))],o=a[0];dom.content(this.parts.places,e("div",{class:"dl-places"},[v("pin"),e("div",{class:"dl-stack"},[e("span",{},o?o.city||o.country:"No locations yet"),e("span",{class:"dl-sub"},o?`${s.length} place${s.length===1?"":"s"} in 30 days${o.org?` · ${o.org}`:""}`:"Shown after a device connects")]),e("span",{class:"dl-spacer"}),a.length?R("Show map",()=>{this.mapOpen=!0,this.paintPlaces()},"neutral"):""]))}invite(){let t=this.st.servers.find(n=>n.id===this.p.server)?.name??"Home";nt(this.p,t)}showQr(){let t=this.p;t.link&&se(`${t.name}’s link`,[e("div",{class:"dl-qr-pane"},[Pe(Oe(t.link),"dl-qr"),e("div",{class:"dl-hint"},"Scan with the phone camera to open the portal.")])],[e("button",{class:"cbi-button",click:X},"Close")])}async newLink(){let t=this.p;if(!await re("Create a new link?","The old link stops working right away.","Create new link",!0))return;let n=await U(()=>z.personRegen(t.id),"New link created");n?.link&&(t.link=n.link,he(n.link,"New link copied"),this.paint())}async showDeviceQr(t){let n=await U(()=>z.deviceConfig(t.id));n&&se(`Set up ${t.name}`,[await It(n,"qr")],[e("button",{class:"cbi-button",click:X},"Close")])}async downloadConfig(t){let n=await U(()=>z.deviceConfig(t.id));if(n){if(!n.has_private_key){ne("This device made its own keys in the browser; its configuration only exists there.","warning");return}ve(n.filename,n.conf,"application/octet-stream")}}editNote(){let t=e("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},this.p.note??"");se("Note",[t],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{X(),await this.patch({note:t.value.trim()},t.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>t.focus(),50)}endSettings(){let t=this.p,n=e("select",{class:"cbi-input-select"},[e("option",{value:"pause",selected:t.expire_action==="pause"?"selected":null},"Pause access"),e("option",{value:"notify",selected:t.expire_action==="notify"?"selected":null},"Keep access"),e("option",{value:"remove",selected:t.expire_action==="remove"?"selected":null},"Remove their devices")]),a=e("select",{class:"cbi-input-select"},[0,1,3,7,14].map(s=>e("option",{value:s,selected:t.expire_warn===s?"selected":null},s?`${s} day${s===1?"":"s"} before`:"Don’t warn")));se("When access ends",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Then"),e("div",{class:"cbi-value-field"},n)]),e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Warn"),e("div",{class:"cbi-value-field"},[a,e("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{X(),await this.patch({expire_action:n.value,expire_warn:a.value},"Saved")},"positive")])}rename(){let t=e("input",{type:"text",class:"cbi-input-text",value:this.p.name,maxlength:48});se("Rename",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},t)])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{X(),await this.patch({name:t.value},"Renamed")},"positive")]),setTimeout(()=>t.select(),50)}async remove(){let t=this.p;await re(`Delete ${t.name}?`,`All ${t.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await U(()=>z.personDelete(t.id),"Deleted")&&(location.href=Ze(t.server))}};var es=[["health","Health"],["log","Log"]],Mt=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=e("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=e("span",{class:"dl-muted"});this.actionsEl=e("div",{class:"dl-row-actions"});this.bodyEl=e("div",{})}load(){return Promise.all([z.status(1),z.events(2e4),z.serviceLog(),this.tab==="health"?z.health().catch(()=>null):Promise.resolve(null)])}render([t,n,a,s]){return this.log=new yt(t,n,a.log),this.health=new _t(t,a,n.events,()=>{this.show("log"),this.log.show("problems")}),s&&this.health.take(s),this.show(this.tab),poll.add(async()=>{if(!this.bodyEl.isConnected)return;let[o,r]=await Promise.all([z.serviceLog().catch(()=>null),z.events(2e4).catch(()=>null)]);r&&this.log.take(r),o&&(this.log.system=o.log),o&&this.health.paintLive(o,r?.events??this.health.events),this.tab==="log"&&(o||r)&&this.log.paint()},10),e("div",{},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}show(t){this.tab=t;let n=new URL(location.href);t==="log"?n.searchParams.set("tab","log"):n.searchParams.delete("tab"),history.replaceState(null,"",n),dom.content(this.segEl,es.map(([a,s])=>e("button",{type:"button",role:"tab",class:a===t?"on":"","aria-selected":a===t?"true":"false",click:()=>a!==this.tab&&this.show(a)},s))),this.bodyEl.replaceChildren(t==="log"?this.log.el:this.health.el),this.subEl.textContent=t==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,t==="log"?this.log.actions():""),t==="log"?this.log.paint():this.health.checks||this.health.run()}};var ts=`:root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.dl-map .cbi-section,.dl-map .cbi-section-node{border:0!important;background:none!important;box-shadow:none!important;padding:0!important}.dl-map .table.cbi-section-table,.dl-map .cbi-section-table>.tbody,.dl-map .cbi-section-table>tbody{display:block!important;width:100%;border:0!important;background:none!important;box-shadow:none!important;border-radius:0!important}.dl-map .cbi-section-table-titles,.dl-map .cbi-section-table-descr,.dl-map .thead{display:none!important}.dl-map .cbi-section-table-row{display:flex!important;flex-wrap:wrap;align-items:flex-start;gap:12px 16px;margin:0 0 12px;padding:16px!important;background:var(--dl-card)!important;border:1px solid var(--dl-line)!important;border-radius:var(--dl-radius)!important;box-shadow:var(--dl-shadow)}.dl-map .cbi-section-table-row.dl-filtered{display:none!important}.dl-map .cbi-section-table-row:hover{background:var(--dl-card)!important}.dl-map .cbi-section-table-row>.td{display:block!important;border:0!important;padding:0!important;background:none!important;width:auto!important}.dl-map .cbi-section-table-row>.td:first-child{flex:1 1 26em;min-width:0}.dl-map .cbi-section-table-row>.td.cbi-section-actions{flex:0 0 auto;margin-left:auto}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div{display:flex;flex-wrap:nowrap;gap:6px;justify-content:flex-end}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div>*{margin:0!important;flex:0 0 auto}.dl-map .cbi-section-table-row>.td:before{display:none!important}.dl-map .cbi-section-table-row.placeholder{color:var(--dl-fg-muted);display:flex!important;justify-content:center;align-items:center;min-height:0!important;height:auto!important;padding:28px 16px!important;text-align:center}.dl-map .cbi-section-table-row.placeholder>*{position:static!important;padding:0!important;margin:0!important;border:0!important;flex:0 1 auto!important}.dl-map .cbi-section-table-row.dl-off .dl-card-name,.dl-map .cbi-section-table-row.dl-off .dl-avatar{opacity:.6}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;box-shadow:inset 0 0 0 1px var(--dl-line);color:var(--dl-fg-muted);aspect-ratio:1;padding:0;justify-content:center}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-map .cbi-section-table-row>.td.cbi-section-actions{margin-left:0;width:100%!important}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div{justify-content:flex-start;flex-wrap:wrap}.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-5px;bottom:-5px;width:20px;height:20px;border-radius:7px;background:var(--dl-card);box-shadow:0 0 0 1.5px var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-healthstrip{display:flex;align-items:center;gap:8px 16px;flex-wrap:wrap;padding:9px 14px;margin:0 0 12px;border-radius:12px;border:1px solid color-mix(in srgb,var(--dl-warn) 45%,transparent);background:var(--dl-warn-wash);font-size:13px;color:var(--dl-fg-muted)}.dl-healthstrip.bad{border-color:color-mix(in srgb,var(--dl-bad) 45%,transparent);background:var(--dl-bad-wash)}.dl-healthstrip-title{display:inline-flex;align-items:center;gap:6px;font-weight:500;color:var(--dl-warn)}.dl-healthstrip.bad .dl-healthstrip-title{color:var(--dl-bad)}.dl-healthstrip-title .dl-icon{width:15px;height:15px}.dl-healthstrip-item{cursor:default}.dl-healthstrip a{margin-left:auto;font-size:12px;font-weight:500;color:var(--dl-fg);text-decoration:none;padding:3px 9px;border-radius:8px}.dl-healthstrip a:hover{background:var(--dl-soft)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}.dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#fff;padding:8px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}.dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}} .dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}.dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.dot{width:8px;height:8px;border-radius:50%;background:var(--dl-fg-faint)}.dl-map-legend i.dot.ok{background:var(--dl-ok)}.dl-map-legend i.line{width:14px;height:2px;border-radius:2px;background:var(--dl-ok)}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;position:relative}.dl-mk-dot{width:12px;height:12px;border-radius:50%;background:#8f8f8f;box-shadow:0 0 0 3px #0000008c}.dl-mk.online .dl-mk-dot{width:14px;height:14px;background:#40c977}.dl-mk.online:before{content:"";position:absolute;inset:-9px;border-radius:50%;background:#40c97747;animation:dl-pulse 2s ease-out infinite}@keyframes dl-pulse{0%{transform:scale(.5);opacity:1}to{transform:scale(1.4);opacity:0}}@media(prefers-reduced-motion:reduce){.dl-mk.online:before{animation:none}}.dl-mk-home{width:22px;height:22px;border-radius:7px;background:#ededed;display:flex;align-items:center;justify-content:center;box-shadow:0 0 0 4px #ededed2e,0 2px 6px #00000080;color:#131313}.dl-mk-home-ic{width:13px;height:13px}.dl-popup{z-index:4}.dl-popup .maplibregl-popup-content{background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);border-radius:12px;padding:12px;box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));font:inherit}.dl-popup .maplibregl-popup-tip{border-top-color:var(--dl-elevated)!important;border-bottom-color:var(--dl-elevated)!important}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-mk.multi{width:26px;height:26px}.dl-mk-count{min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:#8f8f8f;color:#0a0a0a;font:600 11px/22px var(--dl-mono);text-align:center;box-shadow:0 0 0 3px #0000008c;box-sizing:border-box}.dl-mk.online .dl-mk-count{background:#40c977}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px -4px 0}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:5px 4px;border-radius:6px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.maplibregl-ctrl-attrib{font-size:10px}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-map .cbi-section-create,.dl-map>.cbi-section>.cbi-button-add{display:none!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-map .cbi-section-table-row>.td:has(.dl-pcard){flex:1 1 100%;max-width:none!important;width:100%!important;margin:0!important}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}.dl-map .cbi-section-table-row.dl-attn-row{border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}.dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*{border-top:1px solid var(--dl-line)}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-head{display:flex;align-items:center;gap:12px;padding:16px 20px}.dl-upd-head>.dl-stack{flex:1;min-width:0}.dl-upd-head>.dl-stack>b{font-size:15px;font-weight:500}.dl-upd-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 20px;border-top:1px solid var(--dl-line);min-height:40px}.dl-upd-row>.dl-stack{min-width:0}.dl-upd-name{font-size:14px}.dl-upd-row .dl-mono{font-size:11px}.dl-upd-row .dl-mono b{color:var(--dl-fg);font-weight:500}.dl-upd-row>.dl-pill,.dl-upd-row>button,.dl-upd-head>.dl-pill,.dl-upd-head>button{flex:none}.dl-upd-bad{color:var(--dl-bad)}.dl-upd-job>.dl-log,.dl-upd-job>.alert-message{margin:0 14px 14px}.dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}`;function Cn(){let i=document.createElement("style");return i.dataset.dawnline="1",i.textContent=ts,i}function je(i,t){return()=>{let n=new i,a={load:()=>n.load(),render:async s=>{let o=await n.render(s),r=document.createElement("div");return r.className="dl-root",r.append(Cn(),o),r},addFooter(){return n.noFooter?document.createElement("div"):this.super("addFooter",[])}};return t||Object.assign(a,{handleSave:null,handleSaveApply:null,handleReset:null}),a}}var Xo=je(st,!1),er=je(Be,!0),tr=je(st,!1),nr=je($t,!1),ar=je(Lt,!1),sr=je(Mt,!1),ir=je(St,!1);function Dn(i){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${i?`?tab=${i}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var or=Dn(""),rr=Dn("log");return baseclass.extend({ activity: rr, diagnostics: sr, health: or, overview: Xo, people: er, person: ar, server: tr, settings: nr, updates: ir }); +`,mn(r,t)]:[mn(r,t)])),s=e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),t=!t,dom.content(s,[b(t?"x":"key"),t?"Hide key":"Show key"]),a()}},[b("key"),"Show key"]);a();let o=new Blob([i.conf]).size;return e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-filecard"},[e("span",{class:"dl-filecard-ic"},".conf"),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono dl-ellipsis"},i.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${o} bytes · import it in the app`)]),R([b("download")," Download"],()=>ve(i.filename,i.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[b("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),s,e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),pe(i.conf,"Configuration copied")}},[b("copy"),"Copy"])]),n])])}async function Ht(i,t="file"){if(!i.has_private_key)return e("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let n=await sn(i,`${i.server} · ${i.person} · ${i.name}`),a={qr:()=>e("div",{class:"dl-qr-pane"},[Pe(Oe(i.conf),"dl-qr"),e("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-linkbox"},[e("span",{class:"dl-mono"},n),R("Copy",()=>pe(n,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>wa(i)},s=e("div",{class:"dl-connect-body"}),o=e("div",{class:"dl-seg"}),r=l=>{o.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(s,a[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])o.appendChild(e("button",{type:"button","data-id":l,click:()=>r(l)},d));return r(t),e("div",{class:"dl-stack gap12"},[o,s])}function ya(i,t,n,a){mt?.close();let s=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[i,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>l()},b("x"))]),e("div",{class:"dl-drawer-body"},t),n?e("div",{class:"dl-drawer-foot"},n):""]),o=e("div",{class:"dl-drawer-overlay dl-root",click:p=>{p.target===o&&l()}},s),r=p=>{p.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&l()};function l(){document.removeEventListener("keydown",r),o.classList.remove("open"),setTimeout(()=>o.remove(),220),mt===d&&(mt=null),a()}let d={close:l,panel:s};return document.addEventListener("keydown",r),document.body.appendChild(o),requestAnimationFrame(()=>o.classList.add("open")),mt=d,d}var gn={connect:["ok","Connected","plug"],disconnect:["","Went offline","plug"],roam:["","Changed network","network"],device_added:["ok","Added","plus"],device_removed:["","Removed","trash"],device_keys:["","New keys","reset"]};function ka(i,t){let n=i.filter(a=>a.device===t&&gn[a.type]).reverse().slice(0,12);return n.length?e("div",{class:"dl-dev-log"},n.map(a=>{let[s,o,r]=gn[a.type],l=a.type==="connect"?[a.detail?e("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?e("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[e("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[e("span",{class:"dl-muted"},xe(a)==="portal"?" on the portal":xe(a)==="admin"?" by you":"")]:[],d=new Date(a.ts*1e3);return e("div",{class:`dl-dev-log-row${xe(a)==="admin"?" dl-ev-by-admin":""}`},[xe(a)==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):e("span",{class:`dl-ev-tile ev ${s}`},b(r)),e("span",{class:"dl-row-main"},[e("span",{},o),...l]),e("span",{class:"dl-faint dl-nowrap",title:d.toLocaleString()},he(a.ts))])})):e("div",{class:"dl-sub"},"No activity yet.")}function $a(i){return i.disabled?e("span",{class:"dl-dstat"},"Disabled"):i.online?e("span",{class:"dl-dstat ok"},"Connected"):i.handshake?e("span",{class:"dl-dstat"},`Last seen ${he(i.handshake)}`):e("span",{class:"dl-dstat warn"},"Waiting for the first connection")}async function Ce(i,t,n,a){let s=await O(()=>z.deviceConfig(t.id));if(!s)return;let o=t,r=i,l=await Ht(s),d=e("div",{class:"dl-drawer-title"}),p=e("div",{}),u=e("div",{}),c=e("div",{},e("div",{class:"dl-sub"},"Loading…")),x=[],g=async()=>{let h=await z.events(5e3).catch(()=>null);h&&(x=h.events.filter(P=>P.device===o.id),dom.content(c,ka(h.events,o.id)))},k=()=>{let h=a?.points.find(f=>f.device===o.id&&f.ip===o.endpoint);dom.content(d,[e("span",{class:`dl-dcard-ic${o.online?" on":""}`},b(o.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},o.name),R([b("edit")],()=>K(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},[`${r.name} · ${Se[o.kind]}`])])]);let P=o.spark.reduce((f,S)=>f+S,0);dom.content(p,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),$a(o)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},Q(o.month[0]+o.month[1])),e("span",{class:"dl-sub dl-mono"},`↓ ${Q(o.month[1])} ↑ ${Q(o.month[0])}`)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"Last 7 days"),e("b",{},Q(P)),dn(o.spark,120,22)])])),dom.content(u,e("div",{class:"dl-kv2"},[un("Tunnel address",o.address),o.hostname&&r.access!=="internet"?un("Local address",o.hostname):"",o.endpoint?gt("Client IP",e("span",{},[o.endpoint,h?e("span",{class:"dl-muted"},` · ${[h.city,h.org].filter(Boolean).join(" · ")}`):""])):"",gt("Total",e("span",{class:"dl-kv-act"},[`↓ ${Q(o.total[1])} · ↑ ${Q(o.total[0])}`,e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe("device",o.id,o.name,()=>setTimeout(G,300))},"Reset")])),gt("Added",`${xa(o.created)} · ${o.created_by==="portal"?"from the portal":"by you"}`),gt("Public key",e("span",{class:"dl-mono dl-faint"},s.amnezia.client_pub_key?`${s.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(I,[R([b(o.disabled?"play":"pause"),o.disabled?" Enable":" Disable"],async()=>{await O(()=>z.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&await G()},"neutral",o.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),R([b("key")," New keys"],async()=>{if(!await oe("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;if(await O(()=>z.deviceRotate(o.id),"New keys generated")){n(),m.close();let S=await z.status(1),j=S.people.find(v=>v.id===r.id),W=j?.devices.find(v=>v.id===o.id);j&&W&&Ce(j,W,n,S.geo)}}),e("span",{class:"dl-spacer"}),R([b("trash")," Remove"],async()=>{await oe(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await O(()=>z.deviceDelete(o.id),"Device removed")&&(m.close(),n())},"negative")])},G=async()=>{let h=await z.status(1).catch(()=>null),P=h?.people.find(S=>S.id===r.id),f=P?.devices.find(S=>S.id===o.id);!h||!P||!f||(r=P,o=f,a=h.geo,k(),n())},K=()=>{let h=e("input",{type:"text",class:"cbi-input-text",value:o.name,maxlength:48});ne(`Rename ${o.name}`,[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},h)])],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Save",async()=>{await O(()=>z.deviceUpdate(o.id,h.value,void 0),"Renamed")&&(Z(),await G())},"positive")]),setTimeout(()=>h.select(),50)},I=e("div",{class:"dl-drawer-actions"}),_=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Connect")]),o.config_stale?e("div",{class:"dl-note warn"},[b("alert"),e("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",l]),N=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Activity"),e("div",{class:"dl-dsec-actions"},[e("button",{type:"button",class:"dl-linkbtn",click:()=>Le({people:[r]},x,"csv",o.id)},"Export"),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Te(`Clear ${o.name}'s activity`,`Removes events about ${o.name}.`,{device:o.id},g)},"Clear"),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),c]),C=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},e("h4",{},"Details")),u]),D=!o.handshake||o.config_stale,$=e("div",{class:"dl-stack gap16"},D?[p,_,C,N]:[p,C,N,_]);g();let A=window.setInterval(()=>{G(),g()},8e3),m=ya(d,$,I,()=>clearInterval(A));k()}function Ke(i,t){let n=e("input",{type:"text",class:"cbi-input-text",placeholder:Se.phone,maxlength:48}),a="phone",s=e("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},rn.map(r=>e("button",{type:"button",role:"radio",class:r===a?"on":"","aria-checked":r===a?"true":"false","data-kind":r,click:()=>{a=r,s.querySelectorAll("button").forEach(l=>{let d=l.dataset.kind===r;l.classList.toggle("on",d),l.setAttribute("aria-checked",d?"true":"false")}),n.placeholder=Se[r]}},[b(r),e("span",{},Se[r])]))),o=i.devices.length>=i.device_limit;ne(`Add a device for ${i.name}`,[o?e("p",{class:"dl-hint"},`${i.name} already has ${i.devices.length} of ${i.device_limit} devices. As admin you can still add one.`):"",e("div",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Type"),s]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Name"),n])],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Add device",async()=>{let r=n.value.trim()||n.placeholder.replace(/^e\.g\. /,""),l=await O(()=>z.deviceCreate(i.id,r,a));if(!l)return;Z(),te(`${r} added`,"success",3e3),t();let d=await z.status(1),p=d.people.find(c=>c.id===i.id),u=p?.devices.find(c=>c.id===l.id);p&&u&&Ce(p,u,t,d.geo)},"positive")]),setTimeout(()=>n.focus(),50)}var Me=1080,et=1512,ye=96,_a="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Sa="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Xe=i=>i.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function La(i,t,n){let a=new URL(n),s=a.pathname.slice(1),o=Math.min(92,Math.floor((Me-2*ye)/(.58*(4+i.name.length)))),r=Me-2*ye,l=392,d=40,p=Oe(n,2).replace("`${G}`;return``+u(ye+82,ye+42,36,"#a3a3a3",Xe(t))+u(ye,276,o,"#ffffff",`Hi, ${Xe(i.name)}`,'font-weight="600"')+u(ye,340,40,"#8a8a8a",`Scan to connect to ${Xe(t)}`)+``+p+`${Xe(s)}`+u(Me/2,l+r+156,34,"#737373",Xe(a.host),'text-anchor="middle"')+""}async function Ma(i){let t=new Image;t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`,await t.decode();let n=document.createElement("canvas");return n.width=Me,n.height=et,n.getContext("2d").drawImage(t,0,0,Me,et),new Promise((a,s)=>n.toBlob(o=>o?a(o):s(new Error("Could not draw the card")),"image/png"))}async function tt(i,t,n={}){if(!i.link){te("The personal portal is off. Turn it on in Settings.","warning");return}let a=i.link,s=await O(()=>Ma(La(i,t,a)));if(!s)return;let o=new File([s],`${i.id}-invite.png`,{type:"image/png"}),r=URL.createObjectURL(s),l=navigator,d=!!l.canShare?.({files:[o]}),p=()=>{URL.revokeObjectURL(r),Z()},u=d?R([b("link")," Share card"],async()=>{try{await l.share({files:[o],title:`Invite ${i.name}`})}catch{}},"positive"):R([b("download")," Download card"],()=>ve(o.name,s),"positive");ne(n.title??`Invite ${i.name}`,e("div",{class:"dl-invite"},[e("img",{src:r,alt:`Invite card for ${i.name}`}),e("div",{class:"dl-invite-side"},[e("p",{class:"dl-muted"},n.lead??`Send ${i.name} the card or the link. They open it, add their devices and connect — no account needed.`),e("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>pe(a,"Personal link copied")},[e("span",{},a.replace(/^https:\/\//,"")),b("copy")]),...(i.links??[]).filter(c=>c!==a).map(c=>e("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>pe(c,"Link copied")},[e("span",{},c.replace(/^https?:\/\//,"")),e("span",{class:`dl-pill ${c.startsWith("http:")?"warn":""}`},c.startsWith("http:")?"HTTP":"Also"),b("copy")])),e("ol",{class:"dl-invite-steps"},[e("li",{},["Install ",e("b",{},"AmneziaVPN")," on the device"]),e("li",{},"Open the link or scan the code"),e("li",{},"Add the device and connect")]),e("div",{class:"dl-invite-actions"},[u,R([b("copy")," Copy link"],()=>pe(a,"Personal link copied"))])])]),[e("button",{class:"cbi-button cbi-button-neutral",click:p},"Done")],"wide")}var Ea={active:"",paused:"pause",paused_all:"pause",expired:"calendar",quota:"chart",hours:"clock",no_server:"alert"};function It(i){if(i.state==="active")return"";let t=e("span",{class:`dl-ibadge ${Da(i)}`,"aria-label":At[i.state]},b(Ea[i.state]||"alert"));return ce(t,()=>[e("div",{class:"dl-tip-title"},At[i.state])]),t}function Ta(i){let t=i.devices.length,n=Math.max(1,i.device_limit,t),a=Math.min(160,n*22+(n-1)*3);return e("div",{class:"dl-slotbar",title:`${t} of ${i.device_limit} devices`},[e("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:n},(s,o)=>e("i",{class:o>=i.device_limit?"over":oe("span",{class:`dl-ibadge ${a}`},b(a==="lan"?"home":"globe"))));return ce(n,()=>[e("div",{class:"dl-tip-title"},Ue[i.access]),i.access==="lan"&&i.services?.length?e("div",{class:"dl-muted"},`${i.services.length} home service${i.services.length===1?"":"s"} only`):""]),n}function Da(i){return i.state==="active"?"ok":i.state==="quota"||i.state==="expired"?"bad":"warn"}function Aa(i,t){let n=i,s=e("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(o=>e("button",{type:"button",class:`dl-choice${o.v===n?" selected":""}`,"data-v":o.v,click:()=>{n=o.v,s.querySelectorAll(".dl-choice").forEach(r=>r.classList.toggle("selected",r.dataset.v===o.v)),t?.(o.v)}},[e("span",{class:"dl-choice-title"},[b(o.ic),Ue[o.v]]),e("span",{class:"dl-choice-text"},o.text)])));return{el:s,get:()=>n}}function Pa(i){return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function fn(i){let t=ze(i.expires);return i.state==="quota"||i.state==="expired"||t!=null&&t<=Math.max(i.expire_warn,3)||!!i.quota_limit&&i.quota_used>=i.quota_limit*.9}function Na(i){let t=i?new Date(`${i}T12:00:00`):new Date,n=t.getTime()t===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.polling=!1;this.el=null;this.statusSeq=0;this.statusShown=0}async load(){return z.status(30)}scope(t){return this.serverId?ct(t,this.serverId):t}embed(t,n){return this.serverId=n,this.render(t)}person(t){return this.st.people.find(n=>n.id===t)}async latestStatus(){let t=++this.statusSeq,n=await z.status(30).catch(()=>null);return!n||te("em",{},n.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people."),a.serverId&&(r.filter=l=>a.st.people.some(d=>d.id===l)),r.handleAdd=()=>a.openCreate(),r.handleRemove=l=>a.remove(l),r.renderRowActions=()=>e("div",{class:"dl-none"}),s=r.option(form.DummyValue,"_card"),s.modalonly=!1,s.textvalue=l=>a.renderCard(e("div",{class:"dl-card",id:`dl-card-${l}`}),l),o.render().then(l=>{l.classList.add("dl-map","dl-root");let d=e("select",{class:"dl-select","aria-label":"Sort",change:u=>{a.sort=u.target.value,a.decorate()}},[e("option",{value:"seen"},"Last seen"),e("option",{value:"name"},"Name"),e("option",{value:"usage"},"Usage")]),p=e("div",{class:"dl-root"},[a.serverId?"":e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"People"),e("span",{class:"dl-muted",id:"dl-people-count"},this.countText())]),n.servers.length?R([b("plus")," Add person"],()=>a.openCreate(),"add"):""]),n.servers.length?"":e("div",{class:"alert-message warning"},["No server yet. ",e("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),e("div",{class:"dl-toolbar"},[e("div",{class:"dl-seg",id:"dl-people-tabs",role:"tablist"}),e("div",{class:"dl-toolbar-end"},[d,a.serverId?R([b("plus")," Add person"],()=>a.openCreate(),"add"):""])]),l]);return this.el=p,requestAnimationFrame(()=>this.decorate()),this.polling||(this.polling=!0,poll.add(()=>a.el?.isConnected?a.poll():Promise.resolve(),10)),!vn&&new URLSearchParams(location.search).get("add")&&(vn=!0,setTimeout(()=>a.openCreate(),100)),p})}countText(){let t=this.st.totals;return`${t.people} ${t.people===1?"person":"people"} · ${t.devices} device${t.devices===1?"":"s"} · ${t.online} online`}decorate(){let t=document.getElementById("dl-people-count");t&&(t.textContent=this.countText());let n=this.st.people,a={all:n.length,online:n.filter(c=>c.online>0).length,attention:n.filter(fn).length,paused:n.filter(c=>c.state!=="active"&&c.state!=="quota"&&c.state!=="expired").length},s=document.getElementById("dl-people-tabs");if(s){let c={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(s,Object.keys(c).map(x=>e("button",{type:"button",role:"tab",class:x===this.filter?"on":"",click:()=>{this.filter=x,this.decorate()}},[c[x],e("b",{class:x==="attention"&&a[x]?"warn":""},String(a[x]))])))}let o=c=>!(this.filter==="online"&&!c.online||this.filter==="attention"&&!fn(c)||this.filter==="paused"&&!(c.state!=="active"&&c.state!=="quota"&&c.state!=="expired")),r=[...n].sort((c,x)=>this.sort==="name"?c.name.localeCompare(x.name):this.sort==="usage"?x.month[0]+x.month[1]-(c.month[0]+c.month[1]):x.online-c.online||x.last_seen-c.last_seen),l=null,d=0;for(let c of r){let g=document.getElementById(`dl-card-${c.id}`)?.closest(".cbi-section-table-row");if(!g)continue;l??(l=g.parentElement),l?.appendChild(g),g.classList.toggle("dl-off",c.state!=="active"),g.classList.toggle("dl-attn-row",c.state==="quota"||c.state==="expired");let k=o(c);g.classList.toggle("dl-filtered",!k),k&&d++}let p=l?.closest(".cbi-section-table")??l,u=document.getElementById("dl-people-none");p&&n.length&&!d?(u??(u=e("div",{id:"dl-people-none",class:"dl-empty"})),dom.content(u,e("p",{},"No one here right now.")),u.parentElement!==p.parentElement&&p.after(u)):u?.remove()}async poll(){let t=await this.latestStatus();if(!t)return;let n=this.scope(t);this.st=n,this.paintCards(),this.decorate()}async quick(t,n,a){await O(()=>z.personUpdate(t.id,n),a)&&await this.poll()}renderCard(t,n){let a=this.person(n);if(!a)return dom.content(t,e("em",{},"Not saved yet — use “Save & Apply”.")),t;let s=ze(a.expires),o=Math.max(0,a.device_limit-a.devices.length),r=[];if(a.expires){let c=s!=null&&s>=0&&s<=Math.max(a.expire_warn,3),x=s!=null&&s<0;r.push(e("span",{class:`dl-pill-ic${x?" bad":c?" warn":""}`,title:`Access ends ${_e(a.expires)}`},[b("calendar"),x?`ended ${_e(a.expires)}`:c?`ends in ${s} day${s===1?"":"s"}`:`until ${_e(a.expires)}`]))}a.hours&&r.push(e("span",{class:"dl-pill-ic",title:"Allowed hours"},[b("clock"),a.hours.replace("-","–")]));let l=rt(a.devices).map(c=>e("button",{type:"button",class:`dl-chip${c.disabled?" disabled":""}${c.online?" live":""}`,title:`${Se[c.kind]} · ${c.address}${c.online?` · online from ${c.endpoint}`:c.handshake?` · seen ${he(c.handshake,this.st.now)}`:""}`,click:x=>{x.preventDefault(),Ce(a,c,()=>this.refresh(),this.st.geo)}},[b(c.kind),e("span",{class:"dl-chip-name"},c.name),!c.handshake&&!c.disabled?e("span",{class:"dl-chip-tag"},"not set up"):""]));l.push(e("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:o>0?"Add device":"Add device · over the limit, admins can still add",click:c=>{c.preventDefault(),Ke(a,()=>this.refresh())}},b("plus")));let d=[];a.state==="quota"&&a.quota_period==="month"&&d.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{bonus_gb:String((a.bonus_gb||0)+10)},"+10 GB this month")},"+10 GB this month")),a.expires&&s!=null&&s<=Math.max(a.expire_warn,3)&&d.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:Na(a.expires)},"Extended by 1 month")},"Extend 1 month"));let p=ke("more","More",c=>we(c.currentTarget,[{label:"Open",icon:b("open"),run:()=>{location.href=be(a.id)}},a.link?{label:"Invite card",icon:b("qr"),run:()=>tt(a,this.st.servers.find(x=>x.id===a.server)?.name??"Home")}:null,o>0?{label:"Add device",icon:b("plus"),run:()=>Ke(a,()=>this.refresh())}:null,null,{label:a.paused?"Resume":"Pause",icon:b(a.paused?"play":"pause"),warn:!a.paused,run:()=>this.togglePause(a)},{label:"Delete",icon:b("trash"),danger:!0,run:()=>this.remove(a.id)}].filter((x,g,k)=>x||g>0&&k[g-1])),"neutral","dl-icon-only"),u=e("div",{class:"dl-pcard-actions"},[a.link?ke("link","Copy link",()=>pe(a.link,"Personal link copied"),"neutral","dl-icon-only"):"",p]);return dom.content(t,e("div",{class:"dl-pcard"},[e("div",{class:"dl-pcard-main"},[e("div",{class:"dl-pcard-top"},[e("span",{class:`dl-avatar${a.online?" online":""}`},Re(a.name)),e("div",{class:"dl-pcard-who"},[e("div",{class:"dl-card-head"},[e("a",{class:"dl-card-name",href:be(a.id)},a.name),It(a),Ca(a),...r]),Ta(a)])]),e("div",{class:"dl-chips"},l),d.length?e("div",{class:"dl-fixes"},d):""]),this.usageSide(a,u)])),t}usageSide(t,n){let a=t.quota_used||t.month[0]+t.month[1],s=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,o=t.devices.reduce((u,c)=>u+(c.spark[c.spark.length-1]??0),0),r=t.rate?.[t.rate.length-1],l=t.online&&r&&this.st.now-r[0]<180,d=e("div",{class:`dl-usebar${s>=100?" bad":s>=90?" warn":""}`});if(t.quota_limit){let u=e("i",{class:"fill"});u.style.width=`${s}%`,d.appendChild(u),ce(d,()=>[e("div",{class:"dl-tip-title"},`${s.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${Q(t.quota_used)} of ${Q(t.quota_limit)} · ${Q(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},t.quota_period==="total"?"In total":`This month${t.bonus_gb?` · includes +${t.bonus_gb} GB extra`:""}`)])}else{let u=t.devices.map(c=>({d:c,v:c.month[0]+c.month[1]})).filter(c=>c.v>0).sort((c,x)=>x.v-c.v);u.forEach((c,x)=>{let g=e("i",{class:`c${Math.min(x,4)}`});g.style.flexGrow=String(c.v),d.appendChild(g)}),u.length&&ce(d,()=>[e("div",{class:"dl-tip-title"},"This month by device"),...u.map((c,x)=>e("div",{class:"dl-tip-row"},[e("span",{class:`dl-swatch c${Math.min(x,4)}`}),e("span",{},c.d.name),e("b",{},Q(c.v))]))])}let p=t.quota_limit?`${Q(Math.max(0,t.quota_limit-t.quota_used))} left`:"no limit";return e("div",{class:"dl-pside"},[e("div",{class:"dl-pside-top"},[l?e("span",{class:"dl-pside-state live"},"Online"):e("span",{class:"dl-pside-state"},t.online?"Online":t.last_seen?"Offline":"Never connected"),n]),e("div",{class:"dl-use-num"},[e("b",{class:a?"":"dl-faint"},Q(a)),e("span",{class:"dl-faint"},t.quota_limit?`of ${Q(t.quota_limit)}`:t.quota_period==="total"&&t.quota_gb?"in total":"this month")]),d,l?e("div",{class:"dl-use-live",title:"Right now"},[`↓ ${$e(r[2])}`,e("span",{class:"dl-faint"},`↑ ${$e(r[1])}`)]):e("div",{class:"dl-faint dl-pside-foot"},o?`today ${Q(o)} · ${p}`:p)])}async togglePause(t){await O(()=>z.personPause(t.id,!t.paused),t.paused?`${t.name} resumed`:`${t.name} paused`)&&await this.refresh()}async remove(t){let n=this.person(t);await oe(`Remove ${n?.name??t}?`,`All ${n?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await O(()=>z.personDelete(t),"Person removed")&&await this.refresh()}openCreate(){let t=this.st;if(!t.servers.length){te("Set up the server first.","warning");return}let n=e("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=Aa("internet"),s=e("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:t.settings.default_device_limit}),o=e("input",{type:"date",class:"cbi-input-text"}),r=e("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),l=(c,x)=>e("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{if(!x)o.value="";else{let g=new Date;g.setMonth(g.getMonth()+x),o.value=Pa(g)}}},c),d=t.servers[0],p=!this.serverId&&t.servers.length>1?e("select",{class:"cbi-input-select"},t.servers.map(c=>e("option",{value:c.id},c.name))):null,u=(c,x,g)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},c),e("div",{class:"cbi-value-field"},[x,g?e("div",{class:"cbi-value-description"},g):""])]);ne("Add person",[u("Name",n),p?u("Server",p):"",e("div",{class:"cbi-value dl-block"},[e("label",{class:"cbi-value-title"},"Access"),e("div",{class:"cbi-value-field"},a.el)]),u("Devices",s,"How many devices they can add themselves."),u("End date",e("div",{class:"dl-actions"},[o,l("1 month",1),l("3 months",3),l("1 year",12),l("None",0)]),"Optional."),u("Monthly data (GB)",r,"Optional. They are paused when it runs out and resumed next month.")],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Create and copy link",async()=>{let c=await O(()=>z.personCreate(n.value.trim(),"",p?.value??d.id,a.get(),Number(s.value)||t.settings.default_device_limit,o.value,Number(r.value)||0,"month"));c&&(c.link&&await pe(c.link,"Personal link copied"),this.showCreated(c.id,n.value.trim(),c.link,t.servers.find(x=>x.id===(p?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>n.focus(),50)}showCreated(t,n,a,s){if(a){tt({id:t,name:n,link:a},s,{title:`${n} is ready`,lead:`Send ${n} the card or the link. They open it, add their devices and connect — no account needed.`});return}ne(`${n} is ready`,[e("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[e("button",{class:"cbi-button cbi-button-positive",click:Z},"Done")])}};function Ee(i,t,n){let a=e("button",{type:"button",role:"switch",class:`dl-switch${i?" on":""}`,"aria-checked":i?"true":"false","aria-label":t,click:()=>{let s=!a.classList.contains("on");a.classList.toggle("on",s),a.setAttribute("aria-checked",s?"true":"false"),n?.(s)}},e("i"));return a}var Ye=i=>i.classList.contains("on");function se(i,t={}){return e("input",{type:"text",class:"cbi-input-text",value:i,...t})}function ee(i,t,n){return e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},i),n?e("span",{class:"dl-sub"},n):""]),e("div",{class:"dl-setrow-ctl"},t)])}function nt(i,t,n,a=""){return e("section",{class:`dl-setsec ${a}`},[e("div",{class:"dl-setsec-body"},[i?e("h3",{},i):"",...t]),n.length?e("div",{class:"dl-setsec-foot"},n):""])}function ue(i,t,n,a){return e("div",{class:"dl-group"},[e("div",{class:"dl-group-head"},[e("span",{class:"dl-group-ic"},b(i)),e("span",{class:"dl-stack"},[e("b",{},t),n?e("span",{class:"dl-sub"},n):""])]),e("div",{class:"dl-group-body"},a.filter(s=>s!==""))])}var ft=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],bt=i=>e("i",{class:"dl-circle-dot",style:`background:${ft[i?.color??0]??ft[0]}`}),Ve=i=>i.access==="both"||i.access==="lan"&&!i.services?.length;function bn(i,t,n){let a=se(i?.name??t.name??"",{placeholder:"NAS"}),s=se(i?.address??t.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),o=se((i?.ports??t.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),r=(l,d)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},l),e("div",{class:"cbi-value-field"},d)]);ne(i?`Edit ${i.name}`:"Add service",[r("Name",a),r("Address",s),r("Ports",o)],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Save",async()=>{let l=o.value.split(/[ ,]+/).filter(Boolean);await O(()=>z.serviceSet(i?.id??"",a.value,s.value,l),"Saved")&&(Z(),n())},"positive")])}var za={_smb:"SMB",_afpovertcp:"AFP",_http:"Web",_https:"Web",_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:"Printer",_ipps:"Printer",_printer:"Printer","_pdl-datastream":"Printer",_airplay:"AirPlay",_raop:"AirPlay",_rfb:"Screen sharing",_googlecast:"Cast",_hap:"HomeKit",_rdp:"Remote desktop",_ftp:"FTP"},Ra=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function Ha(i){let t=new Map;for(let n of i.services){let a=za[n.type.split(".")[0]];!a||!n.port||(t.get(a)??t.set(a,new Set).get(a)).add(String(n.port))}return t.size?[...t].map(([n,a])=>[n,[...a].sort((s,o)=>+s-+o)]):Ra}function xn(i,t,n){let a=i.services,s=e("div",{class:"dl-stack gap8"},e("span",{class:"dl-sub"},"Looking for devices at home…")),o=a.length?a.map(d=>e("div",{class:"dl-row"},[b("home"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},d.name),e("span",{class:"dl-mono dl-faint"},`${d.address}${d.ports.length?` · ports ${d.ports.join(", ")}`:" · all ports"}`)]),R("Edit",()=>bn(d,{},n)),R([b("trash")],async()=>{await oe(`Remove ${d.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await O(()=>z.serviceDelete(d.id),"Removed")&&n()},"neutral",{title:"Remove","aria-label":`Remove ${d.name}`})])):[e("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")];async function r(d,p){let u=a.find(x=>x.address===d.address);(p===null?u&&await O(()=>z.serviceDelete(u.id),`${u.name} removed`):await O(()=>z.serviceSet(u?.id??"",u?.name??(d.name||d.address),d.address,p),u?`${u.name} updated`:`${d.name||d.address} added`))&&n()}function l(d){let p=a.find(g=>g.address===d.address),u=!!p&&!p.ports.length,c=new Set(p?.ports??[]),x=(g,k,G)=>e("button",{type:"button",class:`dl-chipbtn${k?" on":""}`,"aria-pressed":k?"true":"false",click:G},g);return e("div",{class:"dl-row"},[b(d.services.some(g=>g.type.startsWith("_ipp")||g.type.startsWith("_printer"))?"file":"computer"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},d.name||d.address),e("span",{class:"dl-mono dl-faint"},d.address)]),e("div",{class:"dl-chips-row dl-host-ports"},[x("All ports",u,()=>r(d,u?null:[])),...Ha(d).map(([g,k])=>{let G=!u&&k.every(K=>c.has(K));return x(`${g} ${k.join(", ")}`,G,()=>{let K=new Set(u?[]:c);for(let I of k)G?K.delete(I):K.add(I);r(d,K.size?[...K]:null)})})])])}return z.homeHosts(t).then(d=>{let p=d.hosts.some(u=>a.some(c=>c.address===u.address))&&!a.length;dom.content(s,d.hosts.length?e("details",{class:"dl-params",open:p?"":null},[e("summary",{},[b("chevron"),e("span",{},"Add from devices at home"),e("span",{class:"dl-pcount"},String(d.hosts.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},d.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),e("div",{class:"dl-list"},d.hosts.map(l))])]):e("span",{class:"dl-sub"},"No devices found in the home network right now."))}).catch(()=>dom.content(s,e("span",{class:"dl-sub"},"Couldn't read the devices at home."))),e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-iflead"},[e("div",{class:"dl-iflead-row"},[e("b",{},"Home services"),R([b("plus")," Add service"],()=>bn(null,{},n))]),e("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),e("div",{class:"dl-list"},o),s])}function vt(i,t,n,a){let s=new Set(i.circles.filter(g=>g.server===t).map(g=>g.color)),o=n?.color??ft.findIndex((g,k)=>!s.has(k));o<0&&(o=0);let r=se(n?.name??"",{placeholder:"Family"}),l=i.people.filter(g=>g.server===t).sort((g,k)=>g.name.localeCompare(k.name)),d=new Set(l.filter(g=>n&&g.circle===n.id).map(g=>g.id)),p=e("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),u=()=>dom.content(p,ft.map((g,k)=>e("button",{type:"button",role:"radio",class:`dl-swatch${k===o?" on":""}`,style:`--sw:${g}`,"aria-checked":k===o?"true":"false","aria-label":`Colour ${k+1}`,click:()=>{o=k,u()}})));u();let c=e("div",{class:"dl-chips-row"},l.map(g=>{let k=g.circle&&g.circle!==n?.id?i.circles.find(G=>G.id===g.circle):void 0;return e("button",{type:"button",class:`dl-chipbtn${d.has(g.id)?" on":""}`,title:Ve(g)?k?`Now in ${k.name}`:"":`${g.name} has no home access: their devices aren't reachable anyway`,click:G=>{d.delete(g.id)||d.add(g.id),G.currentTarget.classList.toggle("on",d.has(g.id))}},[g.name,Ve(g)?k?e("b",{},k.name):"":e("b",{},"internet")])})),x=(g,k)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},g),e("div",{class:"cbi-value-field"},k)]);ne(n?`Edit ${n.name}`:"New circle",[x("Name",r),x("Colour",p),x("People",c),e("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[n?R("Delete",async()=>{await O(()=>z.circleDelete(n.id),`${n.name} deleted`)&&(Z(),a())},"negative"):"",e("span",{class:"dl-spacer"}),e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Save",async()=>{await O(()=>z.circleSet(n?.id??"",t,r.value,o,[...d]),"Saved")&&(Z(),a())},"positive")],"dl-circle-modal")}function wn(i,t,n){let a=i.circles.filter(s=>s.server===t);return e("div",{class:"dl-chips-row dl-circles"},[...a.map(s=>{let o=i.people.filter(r=>r.circle===s.id).map(r=>r.name);return e("button",{type:"button",class:"dl-chip",title:`Edit ${s.name}`,click:()=>vt(i,t,s,n)},[bt(s),e("b",{},s.name),e("span",{class:"dl-faint"},o.length?o.join(", "):"nobody yet")])}),e("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>vt(i,t,null,n)},b("plus"))])}function yn(i,t){let n=i.people.filter(u=>u.server===t.id),a=(u="")=>e("span",{class:"dl-yes"},[b("check"),u]),s=()=>e("span",{class:"dl-faint"},"—"),o=u=>{let c=new Set(u.map(x=>x.access==="lan"&&x.services?.length?"services":x.home_nets?.length?"some":"all"));return c.size||c.add("all"),a([...c].map(x=>({all:"all networks",some:"their networks",services:"services"})[x]).join(" / "))},r=()=>t.mesh==="off"?s():t.mesh==="circles"?a("circle"):a(),l=t.lan_like?"like home":"direct",d=(u,c,x)=>e("tr",{},[e("td",{},[e("b",{},u),e("div",{class:"dl-sub"},`${c.length} ${c.length===1?"person":"people"}`)]),...x.map(g=>e("td",{},g))]),p=u=>n.filter(c=>c.access===u);return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Who reaches what"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"From the rules on this server")]),e("div",{class:"dl-reach-wrap"},e("table",{class:"dl-table dl-reach"},[e("tr",{},["","Internet","Home","This router","Each other"].map(u=>e("th",{},u))),d("Internet",p("internet"),[a(l),s(),e("span",{class:"dl-faint"},"DNS"),s()]),d("Home",p("lan"),[e("span",{class:"dl-faint"},"their own"),o(p("lan")),a(),r()]),d("Both",p("both"),[a(l),o(p("both")),a(),r()])])),e("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function kn(i,t){let n=i.people.filter(p=>p.server===t.id).flatMap(p=>p.devices.map(u=>({id:u.id,label:`${p.name} · ${u.name}`}))).sort((p,u)=>p.label.localeCompare(u.label)),a="@addr",s=(p,u)=>{let c=e("select",{class:"cbi-input-select","aria-label":p},[...n.map(G=>e("option",{value:G.id,selected:G.id===u?"selected":null},G.label)),e("option",{value:a,selected:u===a?"selected":null},"Address")]),x=se("",{placeholder:p,class:"cbi-input-text dl-mono"}),g=e("div",{class:"dl-check-end"},[c,x]),k=()=>x.hidden=c.value!==a;return c.addEventListener("change",k),k(),{el:g,value:()=>c.value===a?x.value.trim():c.value}},o=s("10.0.1.11",n[0]?.id??a),r=s("10.0.1.20:445",a),l=e("div",{class:"dl-stack gap8"}),d=async()=>{let p=await O(()=>z.accessCheck(o.value(),r.value()));if(!p)return;let u=p.steps.findIndex(c=>!c.ok);dom.content(l,[e("div",{class:`dl-verdict ${p.ok?"ok":"bad"}`},[e("b",{},p.ok?"Allowed":"Blocked"),e("span",{class:"dl-sub"},p.ok?"Every step lets it through":`Stops at step ${u+1} of ${p.steps.length}`)]),e("ul",{class:"dl-checks"},p.steps.map(c=>e("li",{},[e("span",{class:`dl-check-icon ${c.ok?"ok":"error"}`},b(c.ok?"check":"x")),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},c.title),c.detail?e("div",{class:"dl-check-detail"},c.detail):""])])))])};return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Check access"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"Why something does or does not connect")]),e("div",{class:"dl-check-form"},[o.el,e("span",{class:"dl-faint"},"→"),r.el,R("Check",d)]),l])])}var Ia={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link"},Ba=300*1e3;async function at(i,t,n){if(!t.length)return!0;if(!await oe(`Install ${Ia[i]}?`,`${t.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,"Install"))return!1;let s=(await z.updatesStatus().catch(()=>null))?.job?.started??0;if(!await O(()=>z.updatesRun(`pkgs:${t.join(",")}`)))return!1;te(`Installing ${t.join(", ")}…`,"info",4e3);let o=Date.now()+Ba;for(;Date.now()setTimeout(d,2e3));let l=(await z.updatesStatus().catch(()=>null))?.job;if(!(!l||l.started===s||l.state==="running"))return l.state==="done"?(te(`${t.join(", ")} installed`,"success"),setTimeout(()=>n?.(),4e3),!0):(te(l.error??"Installation failed","error"),!1)}return te("Still installing: see Updates for the log.","warning"),!1}async function $n(i,t){let n=await O(()=>z.updatesStatus());return n?at(i,n.needs?.[i]??[],t):!1}var ja=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Oa={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function Bt(i,t,n){let a=e("button",{type:"button",role:"switch",class:`dl-switch${i?" on":""}`,"aria-checked":i?"true":"false","aria-label":t,click:()=>{let s=!a.classList.contains("on");a.classList.toggle("on",s),a.setAttribute("aria-checked",s?"true":"false"),n(s)}},e("i"));return a}function _n(i,t,n){let a=i.id,s=e("div",{class:"dl-stack gap16"},e("section",{class:"dl-setsec"},e("div",{class:"dl-setsec-body"},e("p",{class:"dl-muted"},"Loading interfaces…")))),o,r=!0,l="",d=!0,p=!0,u="all",c=!1,x=xn(t,a,n),g=new Set,k="",G=()=>JSON.stringify([p,r,r?"":l,d,[...g].sort()]),K=()=>o.detected.lan||o.saved.lan||"",I=()=>(r?o.detected.wan||o.saved.wan:l)||"",_=()=>new Map(o.devices.map(v=>[v.name,v])),N=()=>{let v=_();return[...d&&K()?[K()]:[],...[...g].filter(q=>q!==K())].filter(q=>q!==I()).map(q=>v.get(q)??{name:q,nets:[],missing:!0})},C=(v,U)=>{o=v,U&&(r=v.config.auto_wan,l=v.config.wan_device||v.detected.wan||v.saved.wan||"",d=v.config.auto_lan,p=v.config.lan_like,u=v.config.mesh??(v.config.device_mesh?"all":"off"),g=new Set(v.config.lan_devices),k=G()),j()},D=async v=>{let U=await z.interfaces(a).catch(q=>(te(q.message,"error"),null));U&&C(U,v)};function $(v){let U=d&&v.name===K(),q=!!v.own||!!v.master||v.name===I()||U;return U||g.has(v.name)||!q&&(v.nets.length>0||!!v.missing)}function A(v){let U=d&&v.name===K(),q=v.name===I(),X=!U&&g.has(v.name),ie=!(!!v.own||!!v.master||q||U)&&(v.nets.length>0||X||!!v.missing),me=(X||U)&&!v.zone&&!v.missing,De=v.missing?"Not present right now":v.own?"This server":v.master?`Port of ${v.master}`:q?`Internet${v.zone?` · zone ${v.zone}`:""}`:v.nets.length?v.nets.join(", "):"No IPv4 network",H=e("button",{type:"button",class:`dl-if${X?" sel":""}${U?" auto":""}${!ie&&!X&&!U?" off":""}${me?" warn":""}`,"aria-pressed":X||U?"true":"false","aria-disabled":ie?null:"true",click:()=>{ie&&(g.has(v.name)?g.delete(v.name):g.add(v.name),j())}},[e("span",{class:"dl-if-ic"},b(Oa[v.kind]??"link")),e("span",{class:"dl-if-main"},[e("span",{class:"dl-if-name"},v.name),e("span",{class:"dl-if-sub"},De)]),U?e("span",{class:"dl-if-badge ok"},"Auto"):X?e("span",{class:"dl-if-check"},b("check")):""]);return ce(H,()=>[e("div",{class:"dl-tip-title"},v.name),e("div",{class:"dl-muted"},[v.logical?`Interface ${v.logical}`:"No netifd interface",v.zone?` · zone ${v.zone}`:" · no firewall zone"]),v.members.length?e("div",{class:"dl-muted"},`Ports: ${v.members.join(", ")}`):"",v.nets.length?e("div",{class:"dl-mono"},v.nets.join(", ")):"",me?e("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",v.master?e("div",{class:"dl-muted"},`Choose ${v.master} to include it.`):""]),H}function m(){let v=o.like_home;return!p||!o.config.lan_like?"":!o.needs?.length&&v.active&&v.bridged?"ok":"warn"}function h(){let v=o.like_home;return p?o.needs?.length?[e("span",{class:"dl-warn"},`Needs ${o.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:o.config.lan_like?v.active&&v.bridged?["Internet traffic enters ",e("span",{class:"dl-mono"},v.dev??"")," as ",e("span",{class:"dl-mono"},v.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[e("span",{class:"dl-warn"},`Not working: ${v.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let P={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function f(v,U,q,X,le="",ie){return e("div",{class:ie?"dl-setrow head":"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:`dl-need-ic ${le}`},b(v)),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},U),e("span",{class:"dl-sub"},q),ie??""])]),e("div",{class:"dl-setrow-ctl"},X)])}let S=(v,U)=>{let q=X=>e("span",{class:"dl-mono"},X);return v?e("span",{},[" Now: ",q(v),...U&&U!==v?[", was ",q(U)]:[],"."]):e("span",{},U?[" Not found now: using ",q(U),"."]:[" Not found."])};function j(){let v=e("select",{class:"cbi-input-select","aria-label":"Internet interface",change:y=>{l=y.target.value,j()}},o.devices.filter(y=>!y.own&&!y.master&&y.zone&&!y.missing).map(y=>e("option",{value:y.name,selected:y.name===l?"selected":null},`${y.name} · zone ${y.zone}`))),q=N().flatMap(y=>y.nets.map(T=>[T,y.name])),X=JSON.parse(G()),le=JSON.parse(k),ie=(...y)=>y.some(T=>JSON.stringify(X[T])!==JSON.stringify(le[T])),me=ie(0,1,2),De=ie(3,4),H=y=>R("Save",async()=>{let T=await O(()=>z.serverInterfaces(a,r,r?"":l,d,[...g],p,u!=="off",u),"Access saved");T&&(C(T,!0),T.nets_changed&&T.lan_only&&te(`${T.lan_only} ${T.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!y}),re=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Internet"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Internet or Both")]),f("home","Internet like a home device",h(),[p&&o.needs?.length?R("Install",()=>at("home",o.needs,()=>D(!1)),"positive"):"",Bt(p,"Internet like a home device",y=>{p=y,j()})],m()),f("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",S(o.detected.wan,o.saved.wan)],[r?"":v,Bt(r,"Auto-detect WAN",y=>{r=y,j()})])]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},p?["Internet like a home device",I()?[" · leaves through ",e("span",{class:"dl-mono"},I())]:""]:I()?["Internet straight to ",e("span",{class:"dl-mono"},I())]:"No WAN found"),H(me)])]),M=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":"Devices reach each other"},[["off","Off"],["all","Everyone"],["circles","Circles"]].map(([y,T])=>e("button",{type:"button",role:"radio",class:u===y?"on":"","aria-checked":u===y?"true":"false",click:async()=>{u!==y&&await O(()=>z.serverUpdate(a,{mesh:y}),`Devices reach each other: ${T}`)&&n()}},T))),E=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Home network"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Home or Both"),R([b("reset")," Rescan"],()=>D(!1),"neutral",{title:"Read the interfaces again"})]),f("network","Networks","Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it.","","",W()),f("link","Devices reach each other",P[u],M,"",u==="circles"?wn(t,a,n):void 0),x]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub dl-if-summary"},q.length?["Home access reaches ",...q.flatMap(([y,T],B)=>[B?", ":"",e("span",{class:"dl-mono"},y),` (${T})`])]:"No home network: Home access reaches nothing but this router."),H(De)])]),w=window.scrollY;s.style.minHeight=`${s.offsetHeight}px`,dom.content(s,[re,E]),s.style.minHeight="",window.scrollTo({top:w})}function W(){let v=o.devices.filter($),U=o.devices.filter(q=>!$(q));return e("div",{class:"dl-stack gap8 dl-netpick"},[v.length?e("div",{class:"dl-ifgrid"},v.map(A)):e("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),e("label",{class:"dl-boxrow"},[e("span",{class:"dl-stack"},[e("span",{},"Auto-detect LAN"),e("span",{class:"dl-sub"},["Adds the LAN this router uses.",S(o.detected.lan,o.saved.lan)])]),Bt(d,"Auto-detect LAN",q=>{d=q,j()})]),U.length?e("details",{class:"dl-params",open:c?"":null,toggle:q=>c=q.currentTarget.open},[e("summary",{},[b("chevron"),e("span",{},"Other interfaces"),e("span",{class:"dl-pcount"},String(U.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...ja.map(([q,X])=>{let le=U.filter(ie=>ie.category===q);return le.length?e("div",{class:"dl-ifgroup"},[e("h4",{},X),e("div",{class:"dl-ifgrid"},le.map(A))]):""})])]):""])}return D(!0),s}var Sn=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["disguise","Disguise"],["tunnel","Tunnel"]],Ua={general:"connection",network:"connection",interfaces:"access",advanced:"tunnel"},Ln=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function qa(i){let t=p=>i[p]!=null&&i[p]!=="",n=Ln.filter(([p])=>t(p));if(!n.length)return null;let a=(p,u)=>e("span",{class:"dl-pv"},[e("i",{},u),e("b",{},p==="header_protection_key"?`${i[p].slice(0,6)}••••`:i[p])]),s=(p,u,c,x)=>{let g=Ln.filter(([k])=>x.includes(k)&&t(k));return g.length?e("div",{class:"dl-pgroup"},[e("div",{class:"dl-pgroup-head"},[b(u),e("b",{},p)]),e("p",{},c),e("div",{class:"dl-pvals"},g.map(([k,G])=>a(k,G)))]):""},o=Number(i.jc||0),r=(i.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=n.map(([p,u])=>`${u} = ${i[p]}`).join(` +`),d=e("div",{class:"dl-pgrid"},[s("Junk packets","zap",o?`${o} random packet${o===1?"":"s"} of ${i.jmin}–${i.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),s("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),s("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),s("Signatures","globe",r,["i1","i2","i3","i4","i5"]),s("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),s("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return e("details",{class:"dl-params"},[e("summary",{},[b("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(n.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:p=>{p.preventDefault(),pe(l,"Parameters copied")}},"Copy as config")]),d])}var jt=(i,t)=>{let n=new URLSearchParams;i&&n.set("server",i),t&&t!=="overview"&&n.set("section",t);let a=n.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},st=class{constructor(){this.noFooter=!0;this.root=e("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=e("div",{});this.headEl=e("div",{});this.secEl=e("div",{});this.bodyEl=e("div",{class:"dl-srvbody"})}async load(){let t=await z.status(31),n=t.servers.length?null:await z.setupDefaults();return[t,n]}render([t,n]){if(this.st=t,!t.servers.length&&n)return this.wizard(n);let a=new URLSearchParams(location.search),s=a.get("section")??"",o=Ua[s]??s;return Sn.some(([r])=>r===o)&&(this.section=o),this.srvId=(t.servers.find(r=>r.id===a.get("server"))??t.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),poll.add(async()=>{if(this.section!=="overview")return;let r=await z.status(31).catch(()=>null);if(!r||!r.servers.length)return;this.st=r;let l=this.current();dom.content(this.headEl,this.head(l)),this.paintTabs(),this.ov[l.id]?.update(r)},10),this.root}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await z.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=jt())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let t=this.current();dom.content(this.tabsEl,e("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(n=>e("button",{type:"button",role:"tab",class:`dl-srvtab${n.id===t.id?" on":""}`,"aria-selected":n.id===t.id?"true":"false",click:()=>{n.id!==this.srvId&&(this.srvId=n.id,this.paint())}},[e("i",{class:`dot ${n.up?"ok":"bad"}`}),e("b",{},n.name),e("span",{class:"dl-mono dl-faint"},`:${n.port}`)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[b("plus"),"Add server"])]))}paintSections(){dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},Sn.map(([t,n])=>e("button",{type:"button",role:"tab","data-section":t,class:t===this.section?"on":"","aria-selected":t===this.section?"true":"false",click:()=>this.showSection(t)},n))))}go(t,n){let a=this.pp[this.current().id];if(n&&a)a.filter=n,a.el&&a.decorate();else if(n){let s=this.pp[this.current().id]=new Be;s.filter=n}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let t=[...Object.values(this.ov).map(n=>n.el),...Object.values(this.pp).map(n=>n.el)];for(let n of t)n&&this.bodyEl.contains(n)&&n.remove()}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(r=>{let l=r.dataset.section===t;r.classList.toggle("on",l),r.setAttribute("aria-selected",l?"true":"false")});let n=this.st,a=this.current(),o={overview:()=>{let r=this.ov[a.id];return r?(r.update(n),r.el):(this.ov[a.id]=new pt(a.id,(l,d)=>this.go(l,d))).mount(n)},people:()=>{var p,u;let r=this.pp[a.id];if(r?.el)return r.poll(),r.el;let l=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((p=this.pp)[u=a.id]??(p[u]=new Be)).embed(n,a.id).then(c=>{l.isConnected?dom.content(l,c):l.replaceChildren(c)}),l},connection:()=>this.connection(a),access:()=>this.access(a),disguise:()=>this.disguise(a),tunnel:()=>this.tunnel(a)}[t]();this.detachKept(),dom.content(this.bodyEl,o)}head(t){let n=this.st,a=(l,d)=>e("span",{class:"dl-addrbar-seg"},[b(l),...d]),s=`${t.endpoint||"—"}:${t.port}`,o=!t.enabled||n.settings.paused_all,r=e("div",{class:"dl-actions"},[o?R([b("play")," Turn on"],async()=>{n.settings.paused_all&&!await O(()=>z.pauseAll(!1))||(t.enabled?await this.refresh():await this.save(t,{enabled:"1"},"Server turned on"))},"positive"):""]);return e("div",{class:"dl-srvpagehead"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),e("span",{class:`dl-pill ${t.enabled?t.up?"ok":"bad":"off"}`},t.enabled?t.up?"Running":"Not running":"Turned off"),n.settings.paused_all&&t.enabled?e("span",{class:"dl-pill warn"},"Off"):"",e("span",{class:"dl-spacer"}),r]),e("div",{class:"dl-addrbar"},[e("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address and port",click:()=>pe(s,"Address copied")},[b("globe"),e("span",{class:"dl-mono"},s),b("copy")]),a("tunnel",[e("span",{class:"dl-mono"},t.ifname)]),a("network",[e("span",{class:"dl-mono"},t.subnet)]),t.up?a("clock",[`up ${on(t.uptime)}`]):""])])}async save(t,n,a="Saved"){await O(()=>z.serverUpdate(t.id,n),a)&&await this.refresh()}connection(t){let n=se(t.name,{placeholder:"Home"}),a=se(t.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),s=se(String(t.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),o=se(t.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),r=se(String(t.mtu??""),{placeholder:"1380",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),l=se(String(t.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"});return nt("Connection",[e("p",{class:"dl-muted"},"How devices find this server, and what goes into their configuration."),ue("router","Server","What people see",[ee("Name",n,"Shown to people in their portal.")]),ue("globe","Devices connect to","Where the tunnel answers from the internet",[ee("Public address",a,"Hostname or IP of the router on the internet. A DDNS name keeps links working when your IP changes."),ee("UDP port",s,"Opened on the WAN firewall automatically.")]),ue("file","In every device configuration","Changing these marks devices “Update config” until they import again",[ee("DNS for devices",o,"Empty = this router, which sends each query where your home network would."),ee("MTU",r,"Lower it if some sites hang on mobile networks."),ee("Keep-alive",l,"Seconds between packets devices send to keep NAT open. 0 = off.")])],[e("span"),R("Save",()=>this.save(t,{name:n.value,endpoint:a.value,port:s.value,dns:o.value,mtu:r.value,keepalive:l.value}),"positive")])}access(t){let n=()=>this.refresh();return e("div",{class:"dl-stack gap16"},[_n(t,this.st,n),e("div",{class:"dl-health-cols"},[yn(this.st,t),kn(this.st,t)])])}disguise(t){let n=We(t.preset)?t.preset:void 0,a=n??"standard",s=R("",()=>this.applyDisguise(t,a,a===n),"positive"),o=()=>{dom.content(s,a===n?[b("reset")," Generate new values"]:`Switch to ${We(a).title}`)};o();let r=qa(t.obf??{});return nt("Disguise",[e("p",{class:"dl-muted"},"AmneziaWG reshapes the tunnel so networks that block VPNs do not recognise it. Every device gets these settings in its configuration."),Pt(this.st.awg,a,l=>{a=l,o()},n),this.st.awg.v3?"":Ae("info",["This router runs an older AmneziaWG. ",e("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]),r??""],[e("span",{class:"dl-sub"},"Applies at once. Every device on this server must import its configuration again."),s])}async applyDisguise(t,n,a){let s=We(n),r=this.st.people.filter(d=>d.server===t.id).reduce((d,p)=>d+p.devices.length,0);await oe(a?"Generate new disguise values?":`Switch to ${s.title}?`,`${r} device${r===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${n==="max"?" They need an app with AmneziaWG 3.1.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await O(()=>z.serverObfuscation(t.id,n),a?"New values applied":`${s.title} applied`)&&(te("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())}tunnel(t){let n=this.st.people.filter(s=>s.server===t.id).length,a=R(t.enabled?"Turn off":"Turn on",async()=>{t.enabled&&!await oe(`Turn off ${t.name}?`,`The tunnel stops and ${n} ${n===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(t,{enabled:t.enabled?"0":"1"},t.enabled?"Server turned off":"Server turned on")},t.enabled?"negative":"positive");return e("div",{class:"dl-stack gap16"},[nt("Tunnel",[e("p",{class:"dl-muted"},"Technical details. They are set when the server is created and rarely change."),ee("Interface",e("span",{class:"dl-mono"},`${t.ifname} · router ${t.address}`)),ee("Tunnel subnet",e("span",{class:"dl-mono"},t.subnet),"Device addresses come from it."),ee("Server public key",e("span",{class:"dl-keyrow"},[e("code",{class:"dl-mono"},t.public_key),R([b("copy")],()=>pe(t.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))],[]),nt("Danger zone",[e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},t.enabled?"Turn off this server":"This server is off"),e("span",{class:"dl-sub"},t.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),e("div",{class:"dl-setrow-ctl"},a)]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Remove server"),e("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${n} ${n===1?"person":"people"} with all their devices. A backup is made first.`)]),e("div",{class:"dl-setrow-ctl"},R([b("trash")," Remove"],()=>this.remove(t),"negative"))])],[],"danger")])}async addServer(){let t=await O(()=>z.setupDefaults());t&&dom.content(this.root,this.wizard(t,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async remove(t){let n=this.st.people.filter(a=>a.server===t.id);ne(`Remove ${t.name}?`,[e("p",{},`This removes the tunnel, its firewall rules and ${n.length} ${n.length===1?"person":"people"} with all their devices. A backup is made first.`)],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Remove",async()=>{Z(),await O(()=>z.serverDelete(t.id),"Server removed")&&setTimeout(()=>{location.href=jt()},800)},"negative")])}wizard(t,n=!1,a){let s={id:t.id,name:t.name,endpoint:t.endpoint,port:t.port,subnet:t.subnet,preset:"standard",portal:!1,portal_port:t.portal_port||8443,lan_like:!0,lan_zone:t.lan_zone,wan_zone:t.wan_zone},o=0,r=e("div",{class:"dl-wizard"}),l=(c,x={})=>{let g=se(String(s[c]),x);return g.addEventListener("input",()=>{s[c]=c==="port"||c==="portal_port"?Number(g.value):g.value.trim()}),g},d=n?["Connection","Disguise"]:["Connection","Disguise","Portal"],p=[()=>e("div",{class:"dl-wizard-groups"},[e("p",{class:"dl-muted"},"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),ue("router","Server","What people see",[ee("Name",l("name"),"Shown to people in their portal.")]),ue("globe","Devices connect to","Where the tunnel answers from the internet",[ee("Public address",l("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),"Hostname or IP address of your router on the internet."),ee("UDP port",l("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),"Opened on the WAN firewall automatically. A random high port is fine.")]),ue("network","Tunnel network","Addresses devices get inside the tunnel",[ee("Tunnel subnet",l("subnet",{class:"cbi-input-text dl-mono"}),`Must not overlap your networks (${t.taken.join(", ")||"none found"}).`)])]),()=>e("div",{},[e("p",{},"AmneziaWG reshapes the tunnel so networks that block VPNs do not recognise it. Every device gets these settings automatically; you can change the method later."),Pt(t.awg,s.preset,c=>s.preset=c)]),()=>{let c=l("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),x=ee("Listening port",c,"TCP port on WAN for the portal; the whole port belongs to it.");x.hidden=!s.portal;let g=e("div",{class:"dl-seg",role:"radiogroup","aria-label":"Personal portal"},["off","on"].map(k=>e("button",{type:"button",role:"radio",class:k==="on"===s.portal?"on":"","aria-checked":k==="on"===s.portal?"true":"false",click:G=>{s.portal=k==="on",x.hidden=!s.portal,g.querySelectorAll("button").forEach(K=>{let I=K===G.currentTarget;K.classList.toggle("on",I),K.setAttribute("aria-checked",I?"true":"false")})}},k==="on"?"On":"Off")));return e("div",{class:"dl-wizard-groups"},[ue("home","Internet like a home device","How devices reach the internet",[ee("Through the home network",Ee(s.lan_like,"Internet like a home device",k=>s.lan_like=k),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),ue("link","Personal portal","A page where each person adds their own devices with their personal link",[ee("Portal",g,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),x])])}],u=()=>{dom.content(r,[e("h2",{},n?"Add a server":"Set up Dawnline"),e("div",{class:"dl-steps"},d.map((c,x)=>e("span",{class:`dl-step${x===o?" current":x0?R("Back",()=>{o--,u()}):a?R("Cancel",a):"",e("span",{class:"dl-spacer"}),o{if(o===0&&(!s.endpoint||!s.port||!s.subnet)){te("Fill in the public address, port and subnet.","warning");return}o++,u()},"positive"):R("Create server",async()=>{let c=await O(()=>z.serverCreate(s.id,s.name,t.ifname,s.port,s.subnet,s.endpoint,t.mtu,s.preset,s.lan_zone,s.wan_zone,s.lan_like,n?void 0:s.portal,n?void 0:s.portal_port),"Server created");c&&setTimeout(()=>{location.href=jt(c.id)},1500)},"positive")])])};return u(),r}};var xt=300,Wa=["all","connections","people","system","problems"],Ga={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Fa={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function Ka(i){let t=new Date(i*1e3),n=new Date,a=new Date;return a.setDate(n.getDate()-1),t.toDateString()===n.toDateString()?"Today":t.toDateString()===a.toDateString()?"Yesterday":t.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}function Ot(i){let t=i.keep_days>0?`${i.keep_days} day${i.keep_days===1?"":"s"}`:"no age limit",n=i.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${i.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${t}, up to ${i.max.toLocaleString("en-GB")} events, ${n}.`}var Ut=i=>i.sys?["error","repair","down"].includes(i.sys.level):ht(i.ev.type)==="problems";function qt(i,t,n,a){let s=i.by==="admin",o=e("div",{class:`dl-row dl-slog-row ${s?"dl-ev-by-admin":`dl-ev-by-system ${Ga[i.level]??""}`}${i.detail?" has-detail":""}`},[s?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):e("span",{class:"dl-ev-tile sys",title:i.level},b(Fa[i.src]??"zap")),e("span",{class:"dl-row-main"},s?[e("span",{class:"dl-you"},"You"),e("span",{class:"dl-muted"},` ${i.msg} `),i.kind?e("span",{class:"dl-ev-kind"},`${i.kind} `):"",i.who?e("b",{},i.who):"",i.note?e("span",{class:"dl-muted"},` · ${i.note}`):"",i.detail?e("span",{class:`dl-slog-more${t?" open":""}`},b("chevron")):"",i.detail&&t?e("pre",{class:"dl-slog-detail"},i.detail):""]:[i.src==="awg"&&i.who&&i.who!=="AmneziaWG"?e("span",{class:"dl-ev-kind"},"Server "):"",e("b",{class:"dl-sys-src",title:ut[i.src]??i.src},i.who??ut[i.src]??i.src)," ",e("span",{class:"dl-muted"},i.msg),i.detail?e("span",{class:`dl-slog-more${t?" open":""}`},b("chevron")):"",i.detail&&t?e("pre",{class:"dl-slog-detail"},i.detail):""]),e("span",{class:"dl-faint dl-nowrap",title:new Date(i.ts*1e3).toLocaleString()},a)]);return i.detail&&o.addEventListener("click",r=>{r.target.closest("pre")||n()}),o}var wt=class{constructor(t,n,a){this.events=[];this.system=[];this.kind="all";this.shown=xt;this.open=new Set;this.list=e("div",{});this.sub="";this.tabs=e("div",{class:"dl-seg",role:"tablist"});this.st=t,this.take(n),this.system=a,this.el=e("div",{},[e("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let t=()=>this.kind==="all"?"":this.kind,n=o=>()=>{let r=this.filtered().reverse();Le(this.st,r.filter(l=>l.ev).map(l=>l.ev),o,t(),r.filter(l=>l.sys).map(l=>l.sys))},a=R([b("download")," Export"],()=>we(a,[{label:"CSV (spreadsheet)",icon:b("download"),run:n("csv")},{label:"JSON",icon:b("download"),run:n("json")}])),s=R([b("trash")," Clear"],()=>Te("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[a,s]}take(t){this.events=t.events,this.policy=t.policy;let n=Ze.filter(a=>!t.policy.categories.includes(a));this.sub=`${Ot(t.policy)}${n.length?` Not recorded: ${n.map(a=>Ge[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[t,n]=await Promise.all([z.events(2e4).catch(()=>null),z.serviceLog().catch(()=>null)]);t&&this.take(t),n&&(this.system=n.log),this.paint()}items(){return[...this.events.map(t=>({ts:t.ts,ev:t})),...this.system.map(t=>({ts:t.ts,sys:t}))].sort((t,n)=>n.ts-t.ts)}matches(t,n){return n==="all"?!0:n==="problems"?Ut(t):n==="system"?!!t.sys:!!t.ev&&ht(t.ev.type)===n}filtered(){return this.items().filter(t=>this.matches(t,this.kind))}paintTabs(t){dom.content(this.tabs,Wa.map(n=>e("button",{type:"button",role:"tab",class:n===this.kind?"on":"","aria-selected":n===this.kind?"true":"false",click:()=>this.show(n)},[n==="all"?"All":n==="system"?"System":Ge[n],e("b",{},String(t.filter(a=>this.matches(a,n)).length))])))}show(t){this.kind=t,this.shown=xt,this.paint()}paint(){this.paintTabs(this.items());let t=this.filtered();if(!t.length){dom.content(this.list,e("div",{class:"dl-empty"},[e("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let n=[],a="",s=null;for(let o of t.slice(0,this.shown)){let r=Ka(o.ts);r!==a&&(a=r,s=e("div",{class:"dl-panel flush"},e("div",{class:"dl-panel-head pad"},e("h3",{},r))),n.push(s));let l=new Date(o.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(o.sys){let d=`${o.sys.ts}|${o.sys.msg}`;s.appendChild(qt(o.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else{let d=Ie(this.st,o.ev);d.lastElementChild.textContent=l,s.appendChild(d)}}t.length>this.shown&&n.push(e("div",{class:"dl-more-row"},R(`Show ${Math.min(xt,t.length-this.shown)} more of ${t.length-this.shown}`,()=>{this.shown+=xt,this.paint()}))),dom.content(this.list,n)}};var Ya={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},Mn=3;function Wt(i){let t=new Date(i*1e3),n=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),a=Math.round((new Date(new Date().toDateString()).getTime()-new Date(t.toDateString()).getTime())/864e5);return`${a===0?"Today":a===1?"Yesterday":t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${n}`}async function Va(i){let t=await O(()=>z.backupRead(i.name));if(!t)return;let n=atob(t.data),a=new Uint8Array(n.length);for(let o=0;oVa(i),"neutral","dl-icon-only"),ke("more","More",n=>we(n.currentTarget,[{label:"Restore",icon:b("reset"),run:async()=>{await oe("Restore this backup?",`Everything returns to ${Wt(i.created)}. The current state is backed up first.`,"Restore",!0)&&await O(()=>z.backupRestore(i.name),"Restored")&&t()}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await oe("Delete this backup?",`The backup from ${Wt(i.created)} is removed from the router.`,"Delete",!0)&&await O(()=>z.backupDelete(i.name),"Backup deleted")&&t()}}]),"neutral","dl-icon-only")])])}function Gt(i,t){let n=i.slice(0,Mn).map(d=>En(d,t)),a=i.slice(Mn),s=i.length?e("div",{class:"dl-list"},[...n,a.length?e("details",{class:"dl-bk-older"},[e("summary",{},[b("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(d=>En(d,t))]):""]):e("div",{class:"dl-list"},[e("div",{class:"dl-row dl-muted"},"No backups yet.")]),o=R("Restore from file",async()=>{let d=await Dt(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await oe("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await O(()=>z.backupUpload(d.data),"Restored")&&t()}),r=R("Export JSON",async()=>{let d=await O(()=>z.exportJson());d&&ve(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=R("Import JSON",async()=>{let d=await Dt(".json,application/json","text");if(!d)return;let p;try{p=JSON.parse(d.data)}catch{te("Not a JSON file.","error");return}await oe("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await O(()=>z.importJson(p),"Imported")&&t()});return e("section",{class:"dl-setsec",id:"dl-set-backups"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-setsec-head"},[e("div",{class:"dl-stack"},[e("h3",{},"Backups"),e("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),e("span",{class:"dl-spacer"}),R([b("plus")," Back up now"],async()=>{await O(()=>z.backupCreate(),"Backup created")&&t()},"positive")]),s]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),e("span",{class:"dl-row-actions dl-bk-actions"},[o,r,l])])])}function it(i,t,n){i.some(([o])=>o===t)||(i=[...i,[t,t]]);let a=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":n,"data-value":t}),s=()=>dom.content(a,i.map(([o,r])=>e("button",{type:"button",role:"radio",class:o===a.dataset.value?"on":"","aria-checked":o===a.dataset.value?"true":"false",click:()=>{a.dataset.value=o,s()}},r)));return s(),a}function Ft(i,t,n=`${t}s`){return`${i.toLocaleString("en-GB")} ${i===1?t:n}`}function yt(i){return i<1024?`${i} B`:i<1048576?`${(i/1024).toFixed(i<10240?1:0)} KB`:`${(i/1048576).toFixed(1)} MB`}var kt=class{constructor(){this.root=e("div",{class:"dl-settings-main"});this.backups=[]}load(){return z.settingsGet()}render(t){return this.d=t,this.paint(),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),e("div",{},[e("div",{class:"dl-pagehead"},[e("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(t,n="Saved"){let a=await O(()=>z.settingsUpdate(t),n);a&&(this.d=a,this.paint())}section(t,n,a,s,o="",r=[]){return e("section",{class:`dl-setsec ${o}`,id:`dl-set-${t}`},[e("div",{class:"dl-setsec-body"},[r.length?e("div",{class:"dl-setsec-head"},[e("h3",{},n),e("span",{class:"dl-spacer"}),...r]):e("h3",{},n),...a]),s.length?e("div",{class:"dl-setsec-foot"},s):""])}portalSection(){let t=this.d.settings,n=this.d.effective,a=this.d.cert,s=this.d.portal_candidates??[],o=this.d.portal_checks??[],r=Ee(n.portal_enabled,"Enable portal"),l=se(t.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),d=Ee(n.portal_443,"Standard ports",()=>D()),p=se(t.portal_title,{placeholder:"Dawnline"}),u=se(t.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),c=se("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),x=H=>/^\d{1,3}(\.\d{1,3}){3}$/.test(H),g=[n.portal_host,...n.portal_alt??[]].filter((H,re,M)=>H&&M.indexOf(H)===re);!g.length&&s[0]&&(g=[s[0].host]);let k=[...s],G=H=>{H&&!k.some(re=>re.host===H)&&k.push({host:H,kind:x(H)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})};g.forEach(G);let K=H=>H.kind==="ip"?e("span",{class:"dl-addr-warn"},[b("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):e("span",{class:"dl-sub"},H.cloudflare?"Behind Cloudflare · often stalls in Russia":H.ips.length?H.here?`Points at this router${H.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${H.ips.join(", ")}, not this router`:"Your address"),I=e("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),_=H=>{g.includes(H)?g.length>1&&(g=g.filter(re=>re!==H)):g=[...g,H],N(),D()},N=()=>dom.content(I,[...k.map(H=>{let re=g.includes(H.host),M=g[0]===H.host;return e("div",{class:`dl-addr-opt${re?" on":""}`,role:"checkbox","aria-checked":re?"true":"false",tabindex:"0",click:()=>_(H.host),keydown:E=>{(E.key===" "||E.key==="Enter")&&(E.preventDefault(),_(H.host))}},[e("i",{class:"dl-addr-check"},re?b("check"):""),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono"},H.host),K(H)]),M?e("span",{class:"dl-pill info"},"Main"):re?e("button",{type:"button",class:"dl-linkbtn",click:E=>{E.stopPropagation(),g=[H.host,...g.filter(w=>w!==H.host)],N(),D()}},"Make main"):H.cloudflare?e("span",{class:"dl-pill warn"},"Cloudflare"):H.kind==="ip"?e("span",{class:"dl-pill"},"IP"):H.here&&H.cert?e("span",{class:"dl-pill ok"},"Recommended"):""])}),e("div",{class:"dl-addr-opt other"},[e("i",{class:"dl-addr-check"},b("plus")),c,R("Add",()=>{let H=c.value.trim().toLowerCase();H&&(G(H),g.includes(H)||(g=[...g,H]),c.value="",N(),D())})])]);c.addEventListener("keydown",H=>{H.key==="Enter"&&(H.preventDefault(),c.nextElementSibling?.click())});let C=e("div",{class:"dl-links"}),D=()=>{let H=Ye(d),re=Number(l.value)||n.portal_port;dom.content(C,g.map((M,E)=>{let w=x(M),y=w?H?80:re+1:H&&!this.d.wan443_taken?443:re,T=`${w?"http":"https"}://${M}${y===(w?80:443)?"":`:${y}`}/`;return e("div",{class:"dl-link-row"},[e("span",{class:`dl-link-ic ${w?"warn":"ok"}`},b(w?"alert":"lock")),e("span",{class:"dl-mono dl-link-url"},[T,e("b",{},"kamiro-telosu-bavine")]),E===0?e("span",{class:"dl-pill info"},"Main"):w?e("span",{class:"dl-pill warn"},"HTTP"):""])}))};N(),D(),l.addEventListener("input",()=>D());let $={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_443:"Port 443",portal_lan:"Works at home",portal_http:"Plain HTTP",cert:"Certificate"},A=o.filter(H=>H.status!=="skip"),m=A.filter(H=>H.status==="error"||H.status==="warn"),h=A.some(H=>H.status==="error")?"error":m.length?"warn":"ok",P=e("div",{class:"dl-ready-details",hidden:!0},A.map(H=>e("div",{class:`dl-ready-item ${H.status}`},[b(H.status==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("span",{},H.title),e("span",{class:"dl-sub"},H.detail)])]))),f=e("div",{class:"dl-stack gap8"},[e("div",{class:`dl-ready-sum ${h}`},[b(h==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("b",{},h==="ok"?`All ${A.length} checks passed`:`${A.length-m.length} of ${A.length} checks passed`),m.length?e("span",{class:"dl-sub"},m.map(H=>H.detail).join(" ")):e("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),e("button",{type:"button",class:"dl-linkbtn",click:H=>{P.hidden=!P.hidden,H.currentTarget.textContent=P.hidden?"Details":"Hide"}},"Details")]),e("div",{class:"dl-chips-row"},A.map(H=>e("span",{class:`dl-check-chip ${H.status}`,title:H.detail},[b(H.status==="ok"?"check":"alert"),$[H.id]??H.title]))),P]),S=a&&!a.self_signed&&a.expires?new Date(a.expires).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",j=ee("Standard ports",d,this.d.wan443_taken?"Port 443 is already forwarded to another device, so HTTPS links keep the listening port.":"Links without a port: 443 for names, 80 for IP addresses. Mobile networks often drop other ports. From the internet these reach only the portal; LuCI stays closed."),W=ee("Listening port",l,this.d.port_owners.length?`Port ${n.portal_port} is used by ${this.d.port_owners.join(", ")}.`:`Where the portal runs on the router: HTTPS here, plain HTTP for IP addresses on ${n.portal_port+1}.`),v=!!(t.portal_cert&&t.portal_key),U=a?v?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",q=()=>{let H=se(t.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),re=se(t.portal_key,{placeholder:"/etc/ssl/…/key"});ne("Use your own certificate",[e("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),ee("Certificate file",H),ee("Key file",re)],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Save",()=>{Z(),this.save({portal_cert:H.value.trim(),portal_key:re.value.trim()},"Certificate saved")},"positive")])},X=this.d.needs??{https:[],acme:[],home:[]},le=(H,re,M,E,w,y)=>e("div",{class:`dl-row dl-need-row ${re}`},[re?e("span",{class:"dl-need-ic"},b(H)):b(H),e("span",{class:"dl-row-main dl-stack"},[e("b",{},M),e("span",{class:"dl-sub"},E)]),R(y,()=>at(w,X[w],()=>this.reload()),"positive")]),ie=X.https.length?le("lock","bad","HTTPS isn’t available on this router",`The portal needs ${X.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",me=X.acme.length&&(!a||a.self_signed)?le("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${t.portal_host?` for ${t.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",De=[e("div",{class:"dl-row"},[b("lock"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},[U,S?e("span",{class:"dl-faint"},` · until ${S}`):""]),e("span",{class:"dl-sub dl-ellipsis",title:a?.path??""},a?a.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${v?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),e("div",{class:"dl-row"},[b("file"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Your own files"),e("span",{class:"dl-sub"},v?`${t.portal_cert} · ${t.portal_key}`:"Not set: the certificate is picked automatically.")]),v?R("Reset",()=>this.save({portal_cert:"",portal_key:""},"Automatic certificate"),"negative"):"",R(v?"Change":"Use files",q)]),me];return this.section("portal","Personal portal",[e("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),ie?e("div",{class:"dl-list"},[ie]):"",ue("network","Ports","How the portal listens",[j,W]),ue("edit","Appearance","What people see",[ee("Title",p,"Shown at the top of the portal."),ee("Unknown links",u,"Where a wrong or old link goes, for example your website. Empty shows a plain “Not found”.")]),ue("link","Addresses","Pick one or more; the first is the main link",[I,e("div",{class:"dl-stack gap8"},[C,e("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),ue("lock","Certificate","Used for HTTPS links",De),n.portal_enabled&&A.length?ue("check","Ready to share","The portal’s checks from Health",[f]):""],[e("span"),R("Save",()=>this.save({portal_enabled:Ye(r)?"1":"0",portal_443:Ye(d)?"1":"0",portal_host:g[0]??"",portal_alt:g.slice(1),portal_port:l.value,portal_title:p.value,portal_redirect:u.value.trim()}),"positive")],"",[n.portal_enabled?X.https.length?e("span",{class:"dl-pill bad"},"Can’t start"):e("span",{class:`dl-pill ${h==="ok"?"ok":h==="error"?"bad":"warn"}`},h==="error"?"Needs attention":"Ready"):"",r])}paint(){let t=this.d.settings,n=this.d.effective,a=this.portalSection(),s=se(t.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),o=Ee(n.hostnames,"Device hostnames"),r=se(t.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),l=se(t.home_dns_fallback==="none"?"":t.home_dns_fallback||n.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),d=this.section("defaults","Defaults",[ee("Devices per person",s,"Pre-filled when you add someone."),ee("Device hostnames",e("div",{class:"dl-hostport"},[o,e("span",{class:"dl-faint dl-mono"},"phone.myata."),r]),"Name devices in your home DNS."),ee("Fallback DNS",l,"For Home-only devices using home names: the second DNS server, used by the device when the tunnel is down. Empty = none.")],[e("span"),R("Save",()=>this.save({default_device_limit:s.value,hostnames:Ye(o)?"1":"0",domain:r.value,home_dns_fallback:l.value}),"positive")]),p=Ee(n.geo_enabled,"Locations"),u=e("select",{class:"cbi-input-select"},[e("option",{value:"ipwho.is",selected:n.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),e("option",{value:"ipapi.co",selected:n.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]),c=this.section("map","Map & locations",[e("div",{class:"dl-setrow head"},[e("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),p]),ee("Provider",u)],[e("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),R("Save",()=>this.save({geo_enabled:Ye(p)?"1":"0",geo_provider:u.value}),"positive")]),x=this.logsSection(),g=this.section("danger","Remove Dawnline from this router",[e("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[e("span"),R("Remove",()=>this.uninstall(),"negative")],"danger"),k=Gt(this.backups,()=>{this.reload(),this.loadBackups()});dom.content(this.root,[a,d,c,x,k,g])}logsSection(){let t=this.d.logs,n=t.policy,a=it([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(n.keep_days),"Keep activity"),s=it([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(n.max),"Maximum events"),o=it([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],n.persist,"Save to flash"),r=it([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(n.usage_days),"Daily traffic"),l=it([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(n.usage_months),"Monthly traffic"),d=new Set(n.categories),p=e("div",{class:"dl-chips-row"},Ze.map(k=>{let G=e("button",{type:"button",class:`dl-chipbtn${d.has(k)?" on":""}`,title:hn[k],click:()=>{d.has(k)?d.delete(k):d.add(k),G.classList.toggle("on",d.has(k))}},[Ge[k],e("b",{},String(t.by_category[k]??0))]);return G})),u=k=>new Date(k).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),c=t.oldest?u(new Date(t.oldest*1e3)):"",x=(k,G,K,I)=>e("div",{class:"dl-row"},[b(k),e("span",{class:"dl-row-main dl-stack"},[e("b",{},G),e("span",{class:"dl-sub"},K)]),...I]),g=k=>R(k.toUpperCase(),async()=>{let[G,K]=await Promise.all([z.status(1),z.events(2e4)]);Le(G,K.events,k)},"neutral",{title:`Download the log as ${k.toUpperCase()}`});return this.section("logs","Logs & history",[e("p",{class:"dl-muted"},Ot(n)),ee("Keep activity",a,"Older events are removed automatically."),ee("Maximum size",s,"Newest events are kept when the log is full."),ee("Record",p,"Switched-off categories are not logged from now on."),ee("Save to flash",o,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),ee("Daily traffic",r,"Per-day history behind the charts."),ee("Monthly traffic",l,"Per-month totals; data limits use the current month."),e("h4",{class:"dl-setsub"},"Stored data"),e("div",{class:"dl-list"},[x("activity","Activity log",t.events?`${Ft(t.events,"event")} since ${c} · ${yt(t.log_ram)} in memory${n.persist==="off"?"":`, ${yt(t.log_flash)} on flash`}`:"Empty",[g("csv"),g("json"),R("Clear",()=>Te("Clear activity","Removes events from the log on the router.",{},()=>this.reload()),"negative")]),x("chart","Traffic history",t.usage_days?`${Ft(t.usage_days,"day")} since ${u(t.usage_since)} · ${yt(t.usage_flash)} on flash`:"Empty",[R("Reset",()=>Fe("all","","",()=>setTimeout(()=>this.reload(),300)),"negative")]),x("pin","Location cache",`${Ft(this.d.geo_cached,"address","addresses")} · ${yt(t.geo_flash)} on flash`,[R("Clear",async()=>{await O(()=>z.geoClear(),"Location cache cleared")&&this.reload()},"negative")])])],[e("span",{class:"dl-sub"},"Clear one person or device from their own page."),R("Save",()=>this.save({log_keep_days:a.dataset.value,log_max:s.dataset.value,log_persist:o.dataset.value,usage_keep_days:r.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]}),"positive")])}async loadBackups(){let t=await z.backupList().catch(()=>null);if(t){this.backups=t.backups;let n=document.getElementById("dl-set-backups");n&&n.replaceWith(Gt(this.backups,()=>{this.reload(),this.loadBackups()}))}}async reload(){let t=await z.settingsGet().catch(()=>null);t&&(this.d=t,this.paint())}uninstall(){let t=se("",{placeholder:"remove"});ne("Remove Dawnline?",[e("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),t],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Remove Dawnline",async()=>{await O(()=>z.uninstall(t.value.trim()),"Dawnline removed")&&(Z(),setTimeout(()=>location.reload(),800))},"negative")])}};var Ja={ok:"check",warn:"alert",error:"x",skip:"pause"},Tn={apply:"Repair",sync:"Reload devices",restart:"Restart service",updates:"Open updates"},$t=class{constructor(t,n,a,s){this.el=e("div",{});this.wdEl=e("div",{});this.checksEl=e("div",{class:"dl-panel"});this.recentEl=e("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=e("div",{});this.open=new Set;this.st=t,this.sl=n,this.events=a,this.toLog=s,dom.content(this.el,[this.summary,this.wdEl,e("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(n,a)}async run(t){let n=t?await O(()=>z.healthFix(t),"Done"):await z.health().catch(()=>null);n&&this.take(n)}take(t){this.checks=t.checks,this.paintChecks(),this.paintLive(t,this.events)}paintChecks(){let t=this.checks;if(!t){dom.content(this.summary,""),dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks")]),e("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let n=t.filter(r=>r.status==="error").length,a=t.filter(r=>r.status==="warn").length;dom.content(this.summary,n?Ae("error",`${n} problem${n>1?"s":""} need attention.`):a?Ae("warn",`${a} warning${a>1?"s":""}.`):Ae("ok","All checks passed."));let s=new Map;for(let r of this.sl.watchdog.repairs)s.set(r.id,Math.max(s.get(r.id)??0,r.ts));let o=()=>this.run();dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks"),e("span",{class:"dl-spacer"}),R("Run again",o)]),e("ul",{class:"dl-checks"},t.map(r=>e("li",{},[e("span",{class:`dl-check-icon ${r.status}`},b(Ja[r.status])),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},r.title),e("div",{class:"dl-check-detail"},r.detail),s.has(r.id)?e("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${Ne(s.get(r.id))}`):""]),r.fix?r.fix.startsWith("install:")?R("Install",()=>$n(r.fix.slice(8),o),"action"):r.fix==="updates"?e("a",{class:"cbi-button cbi-button-action",href:L.url("admin/network/dawnline/updates")},Tn.updates):R(Tn[r.fix]??"Fix",()=>this.run(r.fix),"action"):""])))])}paintLive(t,n){this.sl=t,this.events=n;let a=t.watchdog,s=a.beat!=null&&a.now-a.beat>180,o=a.repairs.filter(d=>a.now-d.ts<86400),r=o[o.length-1],l=Ee(a.enabled,"Watchdog repairs",async d=>{await O(()=>z.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||l.classList.toggle("on",!d);let u=await z.serviceLog().catch(()=>null);u&&this.paintLive(u,this.events)});dom.content(this.wdEl,e("div",{class:"dl-panel dl-wd"},[e("div",{class:"dl-wd-head"},[e("span",{class:`dl-wd-tile${a.enabled?"":" off"}`},b("shield")),e("div",{class:"dl-stack"},[e("span",{class:"dl-wd-title"},"Watchdog"),e("span",{class:"dl-sub"},a.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),e("span",{class:"dl-spacer"}),l]),e("div",{class:"dl-wd-foot"},[e("div",{class:"dl-wd-chips"},a.targets.map(d=>e("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?"OK":`Not working${d.tries?` · ${d.tries} repair${d.tries>1?"s":""}`:""}`},[b(d.ok?"check":"x"),d.name]))),e("span",{class:`dl-sub${s?" dl-warn-text":""}`},s?`The agent has not checked in for ${Math.round((a.now-a.beat)/60)} min; cron restarts it after 5.`:[a.last?`Looked ${he(a.last,a.now)}`:"Starts within a minute"," · ",o.length?`${o.length} repair${o.length>1?"s":""} today, last ${r.name} at ${Ne(r.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let t=Date.now()/1e3-604800,n=[...this.events.map(s=>({ts:s.ts,ev:s})),...this.sl.log.map(s=>({ts:s.ts,sys:s}))].filter(s=>s.ts>=t&&Ut(s)).sort((s,o)=>o.ts-s.ts),a=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Recent problems"),e("span",{class:"dl-spacer"}),n.length?e("a",{href:"#",click:s=>(s.preventDefault(),this.toLog())},"All in Log →"):""]);if(!n.length){dom.content(this.recentEl,[a,e("div",{class:"dl-recent-empty"},[e("span",{class:"dl-check-icon ok"},b("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[a,...n.slice(0,8).map(s=>{if(s.sys){let r=s.sys,l=`${r.ts}|${r.msg}`;return qt(r,this.open.has(l),()=>{this.open.delete(l)||this.open.add(l),this.paintRecent()},Ne(r.ts))}let o=Ie(this.st,s.ev);return o.lastElementChild.textContent=Ne(s.ts),o})])}},Qa=[{title:"ip-full · veth",sub:"Policy routing and the home-like link",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"OpenSSL",sub:"HTTPS for the personal portal",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"ACME",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],_t=class{constructor(){this.running=!1}load(){return z.updatesStatus()}render(t){return this.root=e("div",{class:"dl-root dl-upd"}),this.paint(t),poll.add(async()=>{let n=await z.updatesStatus().catch(()=>null);n&&n.job?.state==="running"?this.paint(n):n&&this.running&&(this.running=!1,this.paint(n),n.job?.component==="app"&&n.job.state==="done"&&(ui.menu?.flushCache(),setTimeout(()=>location.reload(),1500)))},3),this.root}paint(t){let n=t.job;this.running=n?.state==="running";let a=t.check?.components??{},s=t.firmware,o=a.app,r=a.amneziawg,l=a.packages,d={disabled:this.running},p=(f,S)=>e("span",{class:`dl-pill ${f}`},S),u=(f,S,j)=>e("div",{class:"dl-upd-row"},[e("span",{class:"dl-stack"},[e("span",{class:"dl-upd-name"},f),e("span",{class:"dl-sub"},S)]),j]),c=(f,S,j,W,v=[])=>e("section",{class:"dl-setsec dl-upd-sec"},[e("div",{class:"dl-upd-head"},[e("span",{class:"dl-group-ic"},b(f)),e("span",{class:"dl-stack"},[e("b",{},S),e("span",{class:"dl-sub"},j)]),W]),...v]),x=f=>f?new Date(f).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",g=c("sunrise","Dawnline",o?.repo?`${t.version} · ${o.repo}`:t.version,o?o.update?R(`Update to ${o.latest}`,()=>this.run("app"),"positive",d):o.latest?p("ok","Up to date"):p("","No releases yet"):p("","Not checked")),k=r?.sources??{},K=Object.keys(k).map(f=>{let S=k[f],j=r?.current===f,W=[S.version?`${S.tag} build${S.date?` · ${x(S.date)}`:""} · ${S.gen==="3.1"?"devices need AmneziaVPN with 3.1":"works with every AmneziaWG app"}`:`No build for OpenWrt ${s?.version??""}`],v=S.version?j?r?.update?R("Update",()=>this.runAwg(f,!!r.ru,S.gen),"positive",d):p("ok","Installed"):R("Switch",()=>this.runAwg(f,!!r?.ru,S.gen),"neutral",d):p("","No build");return u([S.gen?`AmneziaWG ${S.gen}`:"AmneziaWG",e("span",{class:"dl-faint"},` · ${S.label}`)],W,v)});r?.current&&k[r.current]?.version&&K.push(u("Russian translation","LuCI pages for AmneziaWG in Russian",R(r.ru?"Remove":"Add",()=>this.runAwg(r.current,!r.ru,r.gen),"neutral",d)));let I=c("shield","AmneziaWG",r?.installed?`${r.gen?`${r.gen} · `:""}${r.installed} · changing it restarts every tunnel`:"Not installed",r?"":p("","Not checked"),K.length?K:[u("Builds for this router","Check for updates to see them.","")]),_=l?.pkgs??{},N=[],C=Qa.filter(f=>f.feature==="home"?t.home:t.portal);for(let f of C){let S=f.pkgs.filter(v=>_[v]?.installed),j=[...new Set(S.flatMap(v=>[..._[v]?.latest?[v]:[],..._[v]?.with??[]]))],W=t.needs?.[f.feature]??f.pkgs.filter(v=>!_[v]?.installed);if(W.length)N.push(u(f.title,f.optional?`Not installed · ${f.sub}`:e("span",{class:"dl-upd-bad"},`Missing ${W.join(", ")} · ${f.sub}`),R("Install",()=>this.runPkgs(W,f.title),"neutral",d)));else if(j.length){let v=S.find(X=>_[X]?.latest),U=v?[e("span",{class:"dl-mono"},[`${_[v].installed} → `,e("b",{},_[v].latest)])]:[],q=j.filter(X=>X!==v);q.length&&U.push(`${v?" · ":""}${q.length<=2?`${v?"with ":""}${q.join(", ")}`:`${v?"+":""}${q.length} related packages`}`),N.push(u(f.title,U,R("Update",()=>this.runPkgs(S.filter(X=>_[X]?.latest||_[X]?.with?.length),f.title,j),"neutral",d)))}else N.push(u(f.title,f.sub,p("ok","Up to date")))}let D=C.flatMap(f=>f.pkgs).filter(f=>_[f]?.installed),$=[...new Set(D.flatMap(f=>[..._[f].latest?[f]:[],..._[f].with??[]]))],A=c("package","System packages",l?$.length?`${$.length} update${$.length===1?"":"s"} from the OpenWrt ${s?.version?.replace(/\.\d+$/,"")??""} feeds`:"What Dawnline adds to OpenWrt is current":"What Dawnline adds to OpenWrt",l?$.length?R("Update all",()=>this.runPkgs(D.filter(f=>_[f].latest||_[f].with?.length),"all packages",$),"positive",d):"":p("","Not checked"),l?N:[]),m=n?e("details",{class:"dl-params dl-upd-job",open:this.running?"open":null},[e("summary",{},[b("chevron"),e("span",{},"Last job"),p(n.state==="done"?"ok":n.state==="failed"?"bad":"warn",n.state==="running"?n.phase||"Running":n.state==="done"?"Finished":"Failed"),e("span",{class:"dl-sub"},`${n.action==="check"?"check":n.component??""} · ${Ne(n.started)}${n.finished?` · ${n.finished-n.started} s`:""}`)]),n.error?Ae("error",n.error):"",e("pre",{class:"dl-log"},n.log.join(` +`))]):"",h=$.length+(o?.update?1:0)+(r?.update?1:0),P=[s?.version?`OpenWrt ${s.version} · ${s.target}`:"",t.check?h?`${h} update${h===1?"":"s"} ready`:"everything is current":"not checked yet",t.check?`checked ${Ne(t.check.time)}`:""].filter(Boolean).join(" · ");dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Updates"),e("span",{class:"dl-faint"},P)]),R([b("refresh")," Check now"],()=>this.run("check"),"neutral",d)]),g,I,A,m])}async runAwg(t,n,a){await oe(a?`Install AmneziaWG ${a}?`:"Install AmneziaWG?","Every AmneziaWG tunnel on the router restarts for a few seconds, HomeTunnel too. Devices stay configured.","Install")&&this.start(`amneziawg:${t}${n?":ru":""}`)}async runPkgs(t,n,a=t){await oe(`Update ${n}?`,`${a.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&this.start(`pkgs:${t.join(",")}`)}async run(t){t!=="check"&&!await oe(`Update ${t==="app"?"Dawnline":t}?`,"A backup is made first. The page reloads when it finishes.","Update")||this.start(t)}async start(t){if(await O(()=>z.updatesRun(t))){this.running=!0;let n=await z.updatesStatus().catch(()=>null);n&&this.paint(n)}}};function Kt(i){return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function Za(i,t,n,a=30){let s=i?new Date(`${i}T12:00:00`):new Date;return t==="day"?s.setDate(s.getDate()+n):t==="week"?s.setDate(s.getDate()+7*n):t==="month"?s.setMonth(s.getMonth()+n):t==="year"?s.setFullYear(s.getFullYear()+n):s.setDate(s.getDate()+a*n),Kt(s)}var Xa={internet:"Browse the internet through your router. No access to devices at home, and home cannot reach theirs.",lan:"Reach devices at home, and home reaches theirs. Internet stays on their own connection.",both:"Home devices and the internet, all through your router. Home reaches their devices too."},St=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.refreshSeq=0;this.refreshShown=0}async load(){this.id=new URLSearchParams(location.search).get("id")??"";let[t,n,a]=await Promise.all([z.status(30),z.events(5e3).catch(()=>({events:[]})),z.personUsage(this.id,30).catch(()=>null)]);return this.series=a?.person??[],this.devSeries=a?.devices??{},[t,n.events]}render([t,n]){this.st=t,this.events=n;let a=t.people.find(l=>l.id===this.id);if(!a)return e("div",{class:"dl-empty"},[e("h3",{},"Person not found"),e("p",{},"They may have been removed."),e("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=a;for(let l of["head","devices","traffic","places","activity","limits"])this.parts[l]=e("div",{});this.parts.devices.className="dl-person-devices";let s=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:Qe(a.server)},t.servers.find(l=>l.id===a.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:Qe(a.server)},"People"),e("span",{},"/"),e("span",{},a.name)]),this.parts.head,e("div",{class:"dl-grid-person"},[e("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),e("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let o=new URLSearchParams(location.search),r=o.get("device")&&a.devices.find(l=>l.id===o.get("device"));return r?setTimeout(()=>Ce(this.p,r,()=>this.refresh(),this.st.geo),50):o.get("add")&&setTimeout(()=>Ke(this.p,()=>this.refresh()),50),poll.add(()=>this.refresh(!0),15),s}async refresh(t=!1){let n=++this.refreshSeq,[a,s,o]=await Promise.all([z.status(30).catch(()=>null),z.events(5e3).catch(()=>null),z.personUsage(this.id,30).catch(()=>null)]);if(!a||nl.id===this.id);if(!r){t||(location.href=Qe(this.p?.server));return}this.p=r,this.paint(),this.map?.update(this.mapData())}async patch(t,n){var o;let a=await O(()=>z.personUpdate(this.p.id,t),n);if(!a)return;let s=this.st.people.findIndex(r=>r.id===this.p.id);(o=a.person).rate??(o.rate=this.p.rate),s>=0&&(this.st.people[s]=a.person),this.p=a.person,this.paint()}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}mapCard(){let t=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),this.st.geo.enabled?dt("30d",n=>this.map?.setRange(n),!1):"",R("Hide",()=>{this.mapOpen=!1,this.map?.destroy(),this.map=null,this.paintPlaces()},"neutral")]);return this.st.geo.enabled?(this.map=new qe({openPerson:()=>{},openDevice:(n,a)=>{let s=this.p.devices.find(o=>o.id===a);s&&Ce(this.p,s,()=>this.refresh(),this.st.geo)}},"30d",280),requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[t,this.map.el])):e("div",{class:"dl-panel flush"},[t,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])])}paint(){let t=this.p,n=this.st,a=t.online?"online now":t.last_seen?`last seen ${he(t.last_seen,n.now)}`:"never connected",s=this.series.find(c=>c.day===Kt(new Date));dom.content(this.parts.traffic,e("div",{class:`dl-person-live${t.online?"":" solo"}`},[t.online?zt(t.rate??[],n.now,s?[s.rx,s.tx]:[0,0]):"",Rt(this.series,`${Q(t.month[0]+t.month[1])} this month`)]));let o=t.created?`Added ${_e(Kt(new Date(t.created*1e3)))}`:"",r=[{label:"Rename",icon:b("edit"),run:()=>this.rename()},{label:t.note?"Edit note":"Add note",icon:b("file"),run:()=>this.editNote()},...t.link?[null,{label:"Invite card",icon:b("qr"),run:()=>this.invite()},{label:"New link",icon:b("key"),run:()=>this.newLink()}]:[],null,{label:t.paused?"Resume":"Pause",icon:b(t.paused?"play":"pause"),warn:!t.paused,run:()=>this.patch({paused:!t.paused},t.paused?"Resumed":"Paused")},{label:"Delete",icon:b("trash"),danger:!0,run:()=>this.remove()}];dom.content(this.parts.head,e("div",{class:"dl-person-head"},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-person-id"},[e("span",{class:`dl-avatar lg${t.online?" online":""}`},Re(t.name)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),It(t)]),e("span",{class:"dl-faint",title:o},`${t.devices.length} of ${t.device_limit} devices · ${a}`)])]),e("div",{class:"dl-pcard-actions"},[t.link?ke("link","Copy link",()=>pe(t.link,"Personal link copied"),"neutral","dl-icon-only"):"",ke("more","More",c=>we(c.currentTarget,r),"neutral","dl-icon-only")])]),t.note?e("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>this.editNote()},[b("file"),e("span",{},t.note)]):""])),this.paintDevices(),this.paintLimits(),this.paintPlaces();let l=this.events.filter(c=>c.person===t.id),d=[],p=[...l].reverse();for(let c=0;c1){let G=k.querySelector(".dl-row-main");dom.content(G,[...Nt(n,x).slice(0,3),e("span",{class:"dl-muted"},`${g} times`)]),G.title=p.slice(c,c+g).map(K=>K.detail??"").join(` +`)}d.push(k),c+=g-1}let u=R([b("more")],()=>we(u,[{label:"Export CSV",icon:b("download"),run:()=>Le(this.st,l,"csv",t.id)},{label:"Export JSON",icon:b("download"),run:()=>Le(this.st,l,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:b("trash"),danger:!0,run:()=>Te(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>this.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});dom.content(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},l.length>10?`latest 10 of ${l.length}`:""),e("span",{class:"dl-spacer"}),u]),d.length?d:e("div",{class:"dl-row dl-muted"},"Nothing yet.")]))}deviceStatus(t){return t.disabled?e("span",{class:"dl-dstat"},"Disabled"):t.online?e("span",{class:"dl-dstat ok"},"Connected"):t.handshake?e("span",{class:"dl-dstat"},`Last seen ${he(t.handshake,this.st.now)}`):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},"Not set up yet")}deviceBars(t){let n=(this.devSeries[t]??[]).slice(-30),a=n.map(r=>r.rx+r.tx),s=Math.max(1,...a),o=r=>new Date(`${r}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"});return e("div",{class:"dl-dbars"},n.map((r,l)=>{let d=e("i",{class:`${a[l]?"":"zero"}${l===n.length-1?" hi":""}`});return d.style.height=`${Math.max(8,a[l]/s*100)}%`,ce(d,()=>[e("div",{class:"dl-tip-title"},l===n.length-1?`Today · ${o(r.day)}`:o(r.day)),e("div",{},Q(a[l]))]),d}))}paintDevices(){let t=this.p,n=()=>this.refresh(),a=rt(t.devices).map(o=>{let r=()=>Ce(t,o,n,this.st.geo);return e("article",{class:`dl-dcard${o.online?" online":""}${o.disabled?" off":""}`},[e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},b(o.kind)),e("button",{type:"button",class:"dl-dcard-title",click:r},[e("b",{},o.name),this.deviceStatus(o),o.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),R([b("more")],r,"neutral",{title:`${o.name}: connect, rename, keys, remove`,class:"cbi-button cbi-button-neutral dl-icon-only"})]),o.handshake?e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},Q(o.month[0]+o.month[1])),e("span",{class:"dl-sub"},"this month")]),this.deviceBars(o.id)]):o.disabled?e("div",{class:"dl-sub"},`${Se[o.kind]} · created ${he(o.created,this.st.now)} ${o.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>this.showDeviceQr(o)},[b("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>this.downloadConfig(o)},[b("download"),"Config"])])])}),s=t.devices.length>=t.device_limit;a.push(e("button",{type:"button",class:"dl-dslot add",click:()=>Ke(t,n)},[e("span",{class:"dl-dslot-ic"},b("plus")),e("span",{class:"dl-stack"},[e("b",{},"Add device"),s?e("span",{class:"dl-sub"},`Over the limit · ${t.devices.length} of ${t.device_limit}`):""])])),dom.content(this.parts.devices,e("section",{class:"dl-devsec"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Devices"),e("span",{class:"dl-sub"},`${t.online} online`)]),e("div",{class:"dl-dgrid"},a)]))}paintLimits(){let t=this.p,n=e("div",{class:"dl-seg wide",role:"radiogroup","aria-label":"Access"},["internet","lan","both"].map(m=>e("button",{type:"button",role:"radio",class:t.access===m?"on":"","aria-checked":t.access===m?"true":"false",click:()=>t.access!==m&&this.patch({access:m},`Access: ${Ue[m]}`)},[b(m==="internet"?"globe":m==="lan"?"home":"shield"),m==="internet"?"Internet":m==="lan"?"Home":"Both"]))),a=ze(t.expires),s=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});s.addEventListener("change",()=>s.value&&this.patch({expires:s.value},`Access until ${_e(s.value)}`));let o=(m,h,P)=>{let f=Za(t.expires&&(a??-1)>=0?t.expires:"",m,h);return this.patch({expires:f},`Access until ${_e(f)}`),P},r=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([m,h,P])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>o(m,h,P)},P)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{try{s.showPicker()}catch{s.focus()}}},[b("calendar"),t.expires?_e(t.expires):"Date"]),s]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[t.expire_action],p=e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Access ends"),t.expires?e("span",{class:a!=null&&a<0?"dl-bad":a!=null&&a<=t.expire_warn?"dl-warn":"dl-ok"},a!=null&&a<0?"ended":`${a} day${a===1?"":"s"} left`):e("span",{class:"dl-faint"},"no end date")]),e("div",{class:"dl-chips-row"},[...r,l,t.expires?e("button",{type:"button",class:"dl-chipbtn",click:()=>this.patch({expires:""},"No end date")},"No end"):""]),e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`When it ends: ${d}${t.expire_warn?`, warn ${t.expire_warn} day${t.expire_warn===1?"":"s"} before`:""}`),e("a",{href:"#",click:m=>{m.preventDefault(),this.endSettings()}},"Change")])]),u=t.quota_used||t.month[0]+t.month[1],c=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,x=e("div",{class:`dl-meter${c>=100?" bad":c>=90?" warn":""}`},[e("i"),t.quota_limit?e("span",{class:"mark",title:"Alert at 90%"}):""]);x.firstChild.style.width=`${c}%`,t.quota_limit&&ce(x,()=>[e("div",{class:"dl-tip-title"},`${c.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${Q(t.quota_used)} of ${Q(t.quota_limit)} · ${Q(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},"Alert at 90%")]);let g=e("div",{class:"dl-seg sm"},["month","total"].map(m=>e("button",{type:"button",class:t.quota_period===m?"on":"",click:()=>t.quota_period!==m&&this.patch({quota_period:m})},m==="month"?"Monthly":"Total"))),k=[10,50,100].map(m=>e("button",{type:"button",class:`dl-chipbtn${t.quota_gb===m?" on":""}`,click:()=>this.patch({quota_gb:String(m)},`Data limit ${m} GB`)},`${m} GB`));k.push(e("button",{type:"button",class:`dl-chipbtn${t.quota_gb?"":" on"}`,click:()=>this.patch({quota_gb:""},"No data limit")},"Unlimited")),k.push(e("button",{type:"button",class:"dl-chipbtn",click:()=>{let m=prompt("Data limit in GB",t.quota_gb?String(t.quota_gb):"");m!=null&&m.trim()!==""&&Number(m)>0&&this.patch({quota_gb:m.trim()},`Data limit ${m.trim()} GB`)}},"Custom"));let G=e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Data"),g]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[Q(u),t.quota_limit?e("span",{class:"dl-faint"},` of ${Q(t.quota_limit)}`):e("span",{class:"dl-faint"}," · no limit")]),t.quota_period==="month"?e("span",{class:"dl-sub"},"resets on the 1st"):""]),t.quota_limit?x:"",e("div",{class:"dl-chips-row"},k),t.quota_gb&&t.quota_period==="month"?e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},t.bonus_gb?`Includes +${t.bonus_gb} GB extra this month`:"Need a little more this month?"),e("a",{href:"#",click:m=>{m.preventDefault(),this.patch({bonus_gb:String((t.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`${Q(t.total[0]+t.total[1])} in total`),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe("person",t.id,t.name,()=>setTimeout(()=>this.refresh(),300))},"Reset usage")])]),K=!!t.hours,[I,_]=(t.hours||"07:00-23:00").split("-"),N=e("input",{type:"time",class:"cbi-input-text",value:I}),C=e("input",{type:"time",class:"cbi-input-text",value:_}),D=()=>this.patch({hours:`${N.value}-${C.value}`},`Allowed ${N.value}–${C.value}`);N.addEventListener("change",D),C.addEventListener("change",D);let $=e("button",{type:"button",role:"switch","aria-checked":K?"true":"false",class:`dl-switch${K?" on":""}`,"aria-label":"Limit hours",click:()=>this.patch({hours:K?"":"07:00-23:00"},K?"Any time":"Allowed 07:00–23:00")},e("i")),A=e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-row"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-tile2-label"},"Allowed hours"),e("span",{},K?`${I} – ${_} (router time)`:"Any time")]),$]),K?e("div",{class:"dl-tile2-row"},[N,e("span",{class:"dl-faint"},"to"),C]):""]);dom.content(this.parts.limits,e("section",{class:"dl-devsec","aria-label":"Access and limits"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Access & limits")]),e("div",{class:"dl-panel"},[e("div",{class:"dl-stack gap8"},[e("span",{class:"dl-tile2-label"},"Can reach"),n,e("span",{class:"dl-sub"},Xa[t.access]),t.access==="lan"&&this.st.services.length?this.servicesPicker():"",Ve(t)?this.netsPicker():"",t.access==="lan"?this.dnsPicker():""]),e("div",{class:"dl-tiles2"},[this.devTile(),this.circleTile(),p,G,A])])]))}dnsPicker(){let t=this.p,n=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":"DNS"},[["device","Device’s own DNS"],["home","Home names"]].map(([s,o])=>e("button",{type:"button",role:"radio",class:t.dns_mode===s?"on":"","aria-checked":t.dns_mode===s?"true":"false",click:()=>t.dns_mode!==s&&this.patch({dns_mode:s},s==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")},o))),a=this.st.settings.home_dns_fallback;return e("div",{class:"dl-stack gap4 dl-dnspick"},[e("div",{class:"dl-row-actions"},[e("span",{class:"dl-sub"},"DNS"),n]),e("span",{class:"dl-sub"},t.dns_mode==="home"?["Names like ",e("span",{class:"dl-mono"},`nas.${this.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",a?[" (",e("span",{class:"dl-mono"},a)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}netsPicker(){let t=this.p,a=this.st.servers.find(o=>o.id===t.server)?.home??[];if(a.length<2)return"";let s=new Set(t.home_nets?.length?t.home_nets:a.map(o=>o.dev));return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},a.map(o=>e("button",{type:"button",class:`dl-chipbtn${s.has(o.dev)?" on":""}`,"aria-pressed":s.has(o.dev)?"true":"false",title:o.nets.join(", "),click:()=>{let r=new Set(s);if(r.delete(o.dev)||r.add(o.dev),!r.size)return te("Keep at least one network, or choose Internet only.","warning",5e3);let l=r.size===a.length?[]:[...r];this.patch({home_nets:l},l.length?`${t.name} reaches ${l.join(", ")}`:`${t.name} reaches every home network`)}},o.dev))),e("span",{class:"dl-sub"},t.home_nets?.length?`Home networks ${t.name} reaches. Networks added to the server later stay out.`:`Home networks ${t.name} reaches: all of them. Untick one to keep ${t.name} out of it.`)])}circleTile(){let t=this.p;if(this.st.servers.find(l=>l.id===t.server)?.mesh!=="circles"||!Ve(t))return"";let a=this.st.circles.filter(l=>l.server===t.server),s=a.find(l=>l.id===t.circle),o=s?this.st.people.filter(l=>l.id!==t.id&&l.circle===s.id&&Ve(l)).map(l=>l.name):[],r=R("Change",()=>we(r,[...a.map(l=>({label:l.name,icon:bt(l),run:()=>l.id!==t.circle&&this.patch({circle:l.id},`${t.name} is in ${l.name}`)})),t.circle?{label:"No circle",icon:b("x"),run:()=>this.patch({circle:""},`${t.name} is in no circle`)}:null,{label:"New circle",icon:b("plus"),run:()=>vt(this.st,t.server,null,()=>this.refresh())}]));return e("div",{class:"dl-tile2"},[e("span",{class:"dl-tile2-label"},["Devices see each other",e("span",{class:"dl-faint dl-w400"},"circle")]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-circle-name"},s?[bt(s),s.name]:e("span",{class:"dl-muted"},"No circle")),r]),e("span",{class:"dl-sub"},s?o.length?`${t.name}'s devices and ${o.join(", ")}'s see each other. Others don't.`:`Nobody else in ${s.name} yet: only ${t.name}'s own devices see each other.`:`Only ${t.name}'s own devices see each other.`)])}servicesPicker(){let t=new Set(this.p.services??[]);return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},this.st.services.map(n=>e("button",{type:"button",class:`dl-chipbtn${t.has(n.id)?" on":""}`,title:`${n.address}${n.ports.length?` · ${n.ports.join(", ")}`:""}`,click:()=>{t.has(n.id)?t.delete(n.id):t.add(n.id),this.patch({services:[...t]},t.size?"Home services updated":"Whole home network")}},n.name))),e("span",{class:"dl-sub"},t.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}devTile(){let t=this.p,n=e("div",{class:"dl-slots"});for(let o=0;o=t.device_limit,d=e("i",{class:l?"over":r?"used":""});ce(d,()=>[e("div",{class:"dl-tip-title"},r?`${r.name}${l?" · over the limit":""}`:"Free slot"),e("div",{class:"dl-muted"},r?r.online?"Connected":r.handshake?`Last seen ${he(r.handshake,this.st.now)}`:"Not set up yet":"They can add a device here")]),n.appendChild(d)}let a=Math.max(1,t.devices.length),s=e("button",{type:"button","aria-label":"Allow fewer devices",disabled:t.device_limit<=a?"disabled":null,click:()=>this.patch({device_limit:String(t.device_limit-1)})},"−");return t.device_limit<=a&&t.devices.length>1&&ce(s,()=>[e("div",{class:"dl-tip-title"},`${t.devices.length} devices in use`),e("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},"Devices"),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[String(t.devices.length),e("span",{class:"dl-faint"},` / ${t.device_limit}`)]),e("div",{class:"dl-stepper"},[s,e("button",{type:"button","aria-label":"Allow more devices",disabled:t.device_limit>=32?"disabled":null,click:()=>this.patch({device_limit:String(t.device_limit+1)})},"+")])]),n])}paintPlaces(){let t=this.st;if(!t.geo.enabled){dom.content(this.parts.places,e("div",{class:"dl-places"},[b("pin"),e("div",{class:"dl-stack"},[e("span",{},"Locations are off"),e("span",{class:"dl-sub"},"City-level, from the client IP")]),e("span",{class:"dl-spacer"}),e("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]));return}if(this.mapOpen){(!this.map||!this.parts.places.contains(this.map.el))&&dom.content(this.parts.places,this.mapCard());return}let n=t.now-30*86400,a=t.geo.points.filter(r=>r.person===this.p.id&&r.ts>=n).sort((r,l)=>l.ts-r.ts),s=[...new Set(a.map(r=>r.city||r.country).filter(Boolean))],o=a[0];dom.content(this.parts.places,e("div",{class:"dl-places"},[b("pin"),e("div",{class:"dl-stack"},[e("span",{},o?o.city||o.country:"No locations yet"),e("span",{class:"dl-sub"},o?`${s.length} place${s.length===1?"":"s"} in 30 days${o.org?` · ${o.org}`:""}`:"Shown after a device connects")]),e("span",{class:"dl-spacer"}),a.length?R("Show map",()=>{this.mapOpen=!0,this.paintPlaces()},"neutral"):""]))}invite(){let t=this.st.servers.find(n=>n.id===this.p.server)?.name??"Home";tt(this.p,t)}showQr(){let t=this.p;t.link&&ne(`${t.name}’s link`,[e("div",{class:"dl-qr-pane"},[Pe(Oe(t.link),"dl-qr"),e("div",{class:"dl-hint"},"Scan with the phone camera to open the portal.")])],[e("button",{class:"cbi-button",click:Z},"Close")])}async newLink(){let t=this.p;if(!await oe("Create a new link?","The old link stops working right away.","Create new link",!0))return;let n=await O(()=>z.personRegen(t.id),"New link created");n?.link&&(t.link=n.link,pe(n.link,"New link copied"),this.paint())}async showDeviceQr(t){let n=await O(()=>z.deviceConfig(t.id));n&&ne(`Set up ${t.name}`,[await Ht(n,"qr")],[e("button",{class:"cbi-button",click:Z},"Close")])}async downloadConfig(t){let n=await O(()=>z.deviceConfig(t.id));if(n){if(!n.has_private_key){te("This device made its own keys in the browser; its configuration only exists there.","warning");return}ve(n.filename,n.conf,"application/octet-stream")}}editNote(){let t=e("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},this.p.note??"");ne("Note",[t],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Save",async()=>{Z(),await this.patch({note:t.value.trim()},t.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>t.focus(),50)}endSettings(){let t=this.p,n=e("select",{class:"cbi-input-select"},[e("option",{value:"pause",selected:t.expire_action==="pause"?"selected":null},"Pause access"),e("option",{value:"notify",selected:t.expire_action==="notify"?"selected":null},"Keep access"),e("option",{value:"remove",selected:t.expire_action==="remove"?"selected":null},"Remove their devices")]),a=e("select",{class:"cbi-input-select"},[0,1,3,7,14].map(s=>e("option",{value:s,selected:t.expire_warn===s?"selected":null},s?`${s} day${s===1?"":"s"} before`:"Don’t warn")));ne("When access ends",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Then"),e("div",{class:"cbi-value-field"},n)]),e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Warn"),e("div",{class:"cbi-value-field"},[a,e("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Save",async()=>{Z(),await this.patch({expire_action:n.value,expire_warn:a.value},"Saved")},"positive")])}rename(){let t=e("input",{type:"text",class:"cbi-input-text",value:this.p.name,maxlength:48});ne("Rename",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},t)])],[e("button",{class:"cbi-button cbi-button-neutral",click:Z},"Cancel")," ",R("Save",async()=>{Z(),await this.patch({name:t.value},"Renamed")},"positive")]),setTimeout(()=>t.select(),50)}async remove(){let t=this.p;await oe(`Delete ${t.name}?`,`All ${t.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await O(()=>z.personDelete(t.id),"Deleted")&&(location.href=Qe(t.server))}};var es=[["health","Health"],["log","Log"]],Lt=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=e("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=e("span",{class:"dl-muted"});this.actionsEl=e("div",{class:"dl-row-actions"});this.bodyEl=e("div",{})}load(){return Promise.all([z.status(1),z.events(2e4),z.serviceLog(),this.tab==="health"?z.health().catch(()=>null):Promise.resolve(null)])}render([t,n,a,s]){return this.log=new wt(t,n,a.log),this.health=new $t(t,a,n.events,()=>{this.show("log"),this.log.show("problems")}),s&&this.health.take(s),this.show(this.tab),poll.add(async()=>{if(!this.bodyEl.isConnected)return;let[o,r]=await Promise.all([z.serviceLog().catch(()=>null),z.events(2e4).catch(()=>null)]);r&&this.log.take(r),o&&(this.log.system=o.log),o&&this.health.paintLive(o,r?.events??this.health.events),this.tab==="log"&&(o||r)&&this.log.paint()},10),e("div",{},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}show(t){this.tab=t;let n=new URL(location.href);t==="log"?n.searchParams.set("tab","log"):n.searchParams.delete("tab"),history.replaceState(null,"",n),dom.content(this.segEl,es.map(([a,s])=>e("button",{type:"button",role:"tab",class:a===t?"on":"","aria-selected":a===t?"true":"false",click:()=>a!==this.tab&&this.show(a)},s))),this.bodyEl.replaceChildren(t==="log"?this.log.el:this.health.el),this.subEl.textContent=t==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,t==="log"?this.log.actions():""),t==="log"?this.log.paint():this.health.checks||this.health.run()}};var ts=`:root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.dl-map .cbi-section,.dl-map .cbi-section-node{border:0!important;background:none!important;box-shadow:none!important;padding:0!important}.dl-map .table.cbi-section-table,.dl-map .cbi-section-table>.tbody,.dl-map .cbi-section-table>tbody{display:block!important;width:100%;border:0!important;background:none!important;box-shadow:none!important;border-radius:0!important}.dl-map .cbi-section-table-titles,.dl-map .cbi-section-table-descr,.dl-map .thead{display:none!important}.dl-map .cbi-section-table-row{display:flex!important;flex-wrap:wrap;align-items:flex-start;gap:12px 16px;margin:0 0 12px;padding:16px!important;background:var(--dl-card)!important;border:1px solid var(--dl-line)!important;border-radius:var(--dl-radius)!important;box-shadow:var(--dl-shadow)}.dl-map .cbi-section-table-row.dl-filtered{display:none!important}.dl-map .cbi-section-table-row:hover{background:var(--dl-card)!important}.dl-map .cbi-section-table-row>.td{display:block!important;border:0!important;padding:0!important;background:none!important;width:auto!important}.dl-map .cbi-section-table-row>.td:first-child{flex:1 1 26em;min-width:0}.dl-map .cbi-section-table-row>.td.cbi-section-actions{flex:0 0 auto;margin-left:auto}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div{display:flex;flex-wrap:nowrap;gap:6px;justify-content:flex-end}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div>*{margin:0!important;flex:0 0 auto}.dl-map .cbi-section-table-row>.td:before{display:none!important}.dl-map .cbi-section-table-row.placeholder{color:var(--dl-fg-muted);display:flex!important;justify-content:center;align-items:center;min-height:0!important;height:auto!important;padding:28px 16px!important;text-align:center}.dl-map .cbi-section-table-row.placeholder>*{position:static!important;padding:0!important;margin:0!important;border:0!important;flex:0 1 auto!important}.dl-map .cbi-section-table-row.dl-off .dl-card-name,.dl-map .cbi-section-table-row.dl-off .dl-avatar{opacity:.6}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;box-shadow:inset 0 0 0 1px var(--dl-line);color:var(--dl-fg-muted);aspect-ratio:1;padding:0;justify-content:center}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-map .cbi-section-table-row>.td.cbi-section-actions{margin-left:0;width:100%!important}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div{justify-content:flex-start;flex-wrap:wrap}.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-5px;bottom:-5px;width:20px;height:20px;border-radius:7px;background:var(--dl-card);box-shadow:0 0 0 1.5px var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-healthstrip{display:flex;align-items:center;gap:8px 16px;flex-wrap:wrap;padding:9px 14px;margin:0 0 12px;border-radius:12px;border:1px solid color-mix(in srgb,var(--dl-warn) 45%,transparent);background:var(--dl-warn-wash);font-size:13px;color:var(--dl-fg-muted)}.dl-healthstrip.bad{border-color:color-mix(in srgb,var(--dl-bad) 45%,transparent);background:var(--dl-bad-wash)}.dl-healthstrip-title{display:inline-flex;align-items:center;gap:6px;font-weight:500;color:var(--dl-warn)}.dl-healthstrip.bad .dl-healthstrip-title{color:var(--dl-bad)}.dl-healthstrip-title .dl-icon{width:15px;height:15px}.dl-healthstrip-item{cursor:default}.dl-healthstrip a{margin-left:auto;font-size:12px;font-weight:500;color:var(--dl-fg);text-decoration:none;padding:3px 9px;border-radius:8px}.dl-healthstrip a:hover{background:var(--dl-soft)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}.dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#fff;padding:8px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}.dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}} .dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}.dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.dot{width:8px;height:8px;border-radius:50%;background:var(--dl-fg-faint)}.dl-map-legend i.dot.ok{background:var(--dl-ok)}.dl-map-legend i.line{width:14px;height:2px;border-radius:2px;background:var(--dl-ok)}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;position:relative}.dl-mk-dot{width:12px;height:12px;border-radius:50%;background:#8f8f8f;box-shadow:0 0 0 3px #0000008c}.dl-mk.online .dl-mk-dot{width:14px;height:14px;background:#40c977}.dl-mk.online:before{content:"";position:absolute;inset:-9px;border-radius:50%;background:#40c97747;animation:dl-pulse 2s ease-out infinite}@keyframes dl-pulse{0%{transform:scale(.5);opacity:1}to{transform:scale(1.4);opacity:0}}@media(prefers-reduced-motion:reduce){.dl-mk.online:before{animation:none}}.dl-mk-home{width:22px;height:22px;border-radius:7px;background:#ededed;display:flex;align-items:center;justify-content:center;box-shadow:0 0 0 4px #ededed2e,0 2px 6px #00000080;color:#131313}.dl-mk-home-ic{width:13px;height:13px}.dl-popup{z-index:4}.dl-popup .maplibregl-popup-content{background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);border-radius:12px;padding:12px;box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));font:inherit}.dl-popup .maplibregl-popup-tip{border-top-color:var(--dl-elevated)!important;border-bottom-color:var(--dl-elevated)!important}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-mk.multi{width:26px;height:26px}.dl-mk-count{min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:#8f8f8f;color:#0a0a0a;font:600 11px/22px var(--dl-mono);text-align:center;box-shadow:0 0 0 3px #0000008c;box-sizing:border-box}.dl-mk.online .dl-mk-count{background:#40c977}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px -4px 0}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:5px 4px;border-radius:6px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.maplibregl-ctrl-attrib{font-size:10px}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-map .cbi-section-create,.dl-map>.cbi-section>.cbi-button-add{display:none!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-map .cbi-section-table-row>.td:has(.dl-pcard){flex:1 1 100%;max-width:none!important;width:100%!important;margin:0!important}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}.dl-map .cbi-section-table-row.dl-attn-row{border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}.dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*{border-top:1px solid var(--dl-line)}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-head{display:flex;align-items:center;gap:12px;padding:16px 20px}.dl-upd-head>.dl-stack{flex:1;min-width:0}.dl-upd-head>.dl-stack>b{font-size:15px;font-weight:500}.dl-upd-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 20px;border-top:1px solid var(--dl-line);min-height:40px}.dl-upd-row>.dl-stack{min-width:0}.dl-upd-name{font-size:14px}.dl-upd-row .dl-mono{font-size:11px}.dl-upd-row .dl-mono b{color:var(--dl-fg);font-weight:500}.dl-upd-row>.dl-pill,.dl-upd-row>button,.dl-upd-head>.dl-pill,.dl-upd-head>button{flex:none}.dl-upd-bad{color:var(--dl-bad)}.dl-upd-job>.dl-log,.dl-upd-job>.alert-message{margin:0 14px 14px}.dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}`;function Cn(){let i=document.createElement("style");return i.dataset.dawnline="1",i.textContent=ts,i}function je(i,t){return()=>{let n=new i,a={load:()=>n.load(),render:async s=>{let o=await n.render(s),r=document.createElement("div");return r.className="dl-root",r.append(Cn(),o),r},addFooter(){return n.noFooter?document.createElement("div"):this.super("addFooter",[])}};return t||Object.assign(a,{handleSave:null,handleSaveApply:null,handleReset:null}),a}}var Xo=je(st,!1),er=je(Be,!0),tr=je(st,!1),nr=je(kt,!1),ar=je(St,!1),sr=je(Lt,!1),ir=je(_t,!1);function Dn(i){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${i?`?tab=${i}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var or=Dn(""),rr=Dn("log");return baseclass.extend({ activity: rr, diagnostics: sr, health: or, overview: Xo, people: er, person: ar, server: tr, settings: nr, updates: ir }); diff --git a/package/luci-app-dawnline/root/etc/uci-defaults/90_dawnline b/package/luci-app-dawnline/root/etc/uci-defaults/90_dawnline index 654a8cd..ada7f88 100755 --- a/package/luci-app-dawnline/root/etc/uci-defaults/90_dawnline +++ b/package/luci-app-dawnline/root/etc/uci-defaults/90_dawnline @@ -20,6 +20,14 @@ rm -f /www/luci-static/resources/view/dawnline/backups.js # Portal assets moved out of the web root (served only with a valid code). rm -rf /usr/share/dawnline/portal/www/assets +# "Find home devices" (0.3.0) is gone: its option and dnsmasq records too. +for s in $(uci -q show dawnline | sed -n 's/^dawnline\.\([^.]*\)\.bonjour=.*/\1/p'); do uci -q delete "dawnline.$s.bonjour"; done +uci -q commit dawnline +if ls /tmp/dnsmasq*.d/dawnline-bonjour.conf >/dev/null 2>&1; then + rm -f /tmp/dnsmasq*.d/dawnline-bonjour.conf /var/run/dawnline/bonjour.json + /etc/init.d/dnsmasq restart 2>/dev/null +fi + # LuCI caches: menu index, and module URLs (?v= follows the opkg status time). rm -f /tmp/luci-indexcache* /tmp/luci-modulecache/* 2>/dev/null touch /usr/lib/opkg/status 2>/dev/null diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent index c6702ac..825d8e9 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent @@ -20,7 +20,6 @@ import * as ops from 'dawnline.ops'; import * as geo from 'dawnline.geo'; import * as watchdog from 'dawnline.watchdog'; import * as net from 'dawnline.net'; -import * as bonjour from 'dawnline.bonjour'; const TICK = 60 * 1000; const FLUSH_EVERY = 3600; @@ -357,12 +356,6 @@ function tick() { check_wan(m); } catch (e) {} - try { - bonjour.sync(m); - } - catch (e) { - slog('dawnline', 'error', `failed: ${e.message}`, null, 'Find home devices'); - } nightly_backup(); try { check_geo(m); diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/updater b/package/luci-app-dawnline/root/usr/libexec/dawnline/updater index a95a949..5054528 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/updater +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/updater @@ -28,7 +28,7 @@ const AWG_RU = 'luci-i18n-amneziawg-ru'; // OpenWrt packages Dawnline runs on (the Updates tab groups and names them). // What Dawnline itself adds to OpenWrt (the rest of LuCI, ucode, rpcd and uhttpd is the // stock system): the home-like link, and HTTPS plus certificates for the personal portal. -const SYS_PKGS = [ 'ip-full', 'kmod-veth', 'libustream-openssl', 'openssl-util', 'acme', 'acme-acmesh-dnsapi', 'luci-app-acme', 'umdns' ]; +const SYS_PKGS = [ 'ip-full', 'kmod-veth', 'libustream-openssl', 'openssl-util', 'acme', 'acme-acmesh-dnsapi', 'luci-app-acme' ]; // Packages released together with each of the above, updated as a set so OpenSSL never ends up // half old and half new. const PKG_FAMILY = [ @@ -463,9 +463,6 @@ function install_pkgs(arg) { // The portal's HTTPS runs in uhttpd. Restart after this job saved its state. let touched = [ ...names, ...have ]; // A missing piece arrived: set up what waited for it (the portal, the home-like link). - // Bonjour: OpenWrt's mDNS daemon starts at once; the agent publishes what it finds. - if (index(missing, 'umdns') >= 0) - run('/etc/init.d/umdns enable; /etc/init.d/umdns start'); if (length(missing) && length(filter(missing, (n) => match(n, /^(openssl-util|libustream|ip-full|kmod-veth)/)))) run('( sleep 3; /usr/bin/dawnline apply; /etc/init.d/uhttpd restart; /etc/init.d/dawnline restart ) /dev/null 2>&1 &'); else if (length(filter(touched, (n) => match(n, /^(libustream|libopenssl)/)))) diff --git a/package/luci-app-dawnline/root/usr/share/rpcd/ucode/luci.dawnline b/package/luci-app-dawnline/root/usr/share/rpcd/ucode/luci.dawnline index e2fae48..83ffc76 100644 --- a/package/luci-app-dawnline/root/usr/share/rpcd/ucode/luci.dawnline +++ b/package/luci-app-dawnline/root/usr/share/rpcd/ucode/luci.dawnline @@ -17,7 +17,6 @@ import * as net from 'dawnline.net'; import * as loop from 'dawnline.loop'; import * as watchdog from 'dawnline.watchdog'; import * as access from 'dawnline.access'; -import * as bonjour from 'dawnline.bonjour'; function wrap(fn) { return function(req) { @@ -426,7 +425,6 @@ function interfaces_view(srv, snap) { device_mesh: srv.device_mesh, mesh: srv.mesh }, like_home: loop.status(), needs: ops.needs().home, - bonjour: { on: srv.bonjour, needs: ops.needs().bonjour, ...bonjour.view(core.load()) }, effective: sn, zones: snap.zones, devices, @@ -551,12 +549,6 @@ function server_update(a) { } if (v.enabled != null) set('enabled', v.enabled === true || v.enabled == '1' ? '1' : '0'); - let bj = v.bonjour == null ? null : (v.bonjour === true || v.bonjour == '1'); - if (bj != null) { - if (bj && length(ops.needs().bonjour)) - die('Install umdns first.'); - set('bonjour', bj ? '1' : null); - } if (v.device_mesh != null && v.mesh == null) v.mesh = v.device_mesh === true || v.device_mesh == '1' ? 'all' : 'off'; if (v.mesh != null) { @@ -604,12 +596,6 @@ function server_update(a) { admin_log('awg', on ? 'turned on' : 'turned off', 'server', name); if (length(what)) admin_log('awg', 'changed', 'server', name, join(', ', what)); - if (bj != null && bj != srv.bonjour) { - admin_log('awg', bj ? 'turned on' : 'turned off', 'server', name, 'finding home devices (Bonjour)'); - if (bj) - bonjour.start_mdns(); - bonjour.sync(core.load(), true); - } if (mesh != null && mesh != srv.mesh) admin_log('awg', 'changed', 'server', name, { off: 'devices kept apart', all: 'devices reach each other', circles: 'devices reach each other in circles' }[mesh]); diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/bonjour.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/bonjour.uc deleted file mode 100644 index 7b30f93..0000000 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/bonjour.uc +++ /dev/null @@ -1,149 +0,0 @@ -// Dawnline: "Find home devices" (Bonjour over the tunnel). Multicast DNS does -// not cross WireGuard, so what umdns sees on the home networks is published -// as unicast DNS-SD records in dnsmasq: iPhone, iPad and Mac look there -// (browse domains under the home domain and the reverse zone of their own -// tunnel address) and list AirPlay, printers and shared Macs as at home. - -'use strict'; - -import { readfile, writefile, unlink, lsdir, stat } from 'fs'; -import { read_json, write_json, ensure_dir, RUN_DIR } from 'dawnline.util'; -import * as ops from 'dawnline.ops'; - -const FILE = 'dawnline-bonjour.conf'; -const STATE = `${RUN_DIR}/bonjour.json`; -/** dnsmasq restarts to read the records: at most this often when only TXT data changed. */ -const QUIET = 600; -/** Not useful from a phone, or not a service at all. */ -const SKIP = [ '_device-info._tcp', '_companion-link._tcp', '_sleep-proxy._udp', '_workstation._tcp', '_rdlink._tcp', '_hap._udp' ]; - -export function enabled(m) { - for (let id, srv in m.servers) - if (srv.bonjour && srv.private_key) - return true; - return false; -}; - -/** dnsmasq's conf-dirs (one per instance), from its generated configs. */ -function conf_dirs() { - let out = []; - for (let f in lsdir('/var/etc') ?? []) { - if (!match(f, /^dnsmasq\.conf\./)) - continue; - for (let line in split(readfile(`/var/etc/${f}`) ?? '', '\n')) { - let mm = match(line, /^conf-dir=([^,]+)/); - if (mm && index(out, mm[1]) < 0) - push(out, mm[1]); - } - } - return out; -} - -/** An instance name as dnsmasq takes it: printable ASCII, no dots or commas. */ -function instance(s) { - s = replace(s ?? '', /[\u2018\u2019]/g, "'"); - s = replace(s, /[\u201c\u201d]/g, ''); - s = replace(s, /[^\x20-\x7e]/g, ''); - s = replace(s, /[.,"\\]/g, ' '); - s = trim(replace(s, / +/g, ' ')); - return substr(s, 0, 63); -} - -function label(s) { - return substr(trim(replace(replace(s ?? '', /[^A-Za-z0-9-]+/g, '-'), /^-+|-+$/g, '')), 0, 63); -} - -/** Reverse zone of a server's tunnel network (its /24), where devices look for browse domains. */ -function reverse24(subnet) { - let mm = match(subnet ?? '', /^([0-9]+)\.([0-9]+)\.([0-9]+)\.[0-9]+\//); - return mm ? `0.${mm[3]}.${mm[2]}.${mm[1]}.in-addr.arpa` : null; -} - -/** The records, and a signature of what matters without TXT data. */ -export function records(m, services) { - let dom = m.settings.domain || 'lan'; - let lines = [], sig = []; - let zones = [ dom ]; - for (let id, srv in m.servers) - if (srv.bonjour && reverse24(srv.subnet)) - push(zones, reverse24(srv.subnet)); - for (let z in zones) - for (let b in [ 'b', 'db', 'lb' ]) - push(lines, `ptr-record=${b}._dns-sd._udp.${z},${dom}`); - let types = {}, hosts = {}; - for (let s in services) { - if (!s.port || index(SKIP, s.type) >= 0 || !match(s.type, /^_[A-Za-z0-9-]+\._(tcp|udp)$/)) - continue; - let name = instance(s.name), host = label(s.host) || label(replace(s.address, /\./g, '-')); - if (name == '') - continue; - let full = `${name}.${s.type}.${dom}`; - types[s.type] = true; - hosts[host] = s.address; - push(lines, `ptr-record=${s.type}.${dom},${full}`); - push(lines, `srv-host=${full},${host}.${dom},${s.port}`); - let txt = filter(s.txt ?? [], (t) => type(t) == 'string' && length(t) <= 255 && !match(t, /["\\\n]/)); - push(lines, length(txt) ? `txt-record=${full},${join(',', map(txt, (t) => `"${t}"`))}` : `txt-record=${full}`); - push(sig, `${full}|${host}|${s.port}`); - } - for (let t in sort(keys(types))) - push(lines, `ptr-record=_services._dns-sd._udp.${dom},${t}.${dom}`); - for (let h in sort(keys(hosts))) { - push(lines, `host-record=${h}.${dom},${hosts[h]}`); - push(sig, `${h}=${hosts[h]}`); - } - return { conf: '# Written by Dawnline: home devices for Bonjour over the tunnel.\n' + join('\n', lines) + '\n', sig: join('\n', sort(sig)) }; -}; - -function restart_dnsmasq() { - system('/etc/init.d/dnsmasq restart >/dev/null 2>&1'); -} - -/** - * Keep the records in step with what umdns sees (agent tick and apply). - * Turned off: the records go away. - */ -export function sync(m, force) { - let dirs = conf_dirs(); - if (!enabled(m) || !ops.mdns_running()) { - let removed = false; - for (let d in dirs) - if (stat(`${d}/${FILE}`)) { - unlink(`${d}/${FILE}`); - removed = true; - } - if (removed) - restart_dnsmasq(); - unlink(STATE); - return false; - } - let r = records(m, ops.mdns_services()); - let st = read_json(STATE, {}); - let now = time(); - let same = st.conf == r.conf; - let quiet = !force && st.sig == r.sig && now - (st.ts ?? 0) < QUIET; - let missing = length(filter(dirs, (d) => !stat(`${d}/${FILE}`))); - if ((same || quiet) && !missing) - return false; - for (let d in dirs) { - ensure_dir(d); - writefile(`${d}/${FILE}`, r.conf); - system(`chmod 644 ${d}/${FILE}`); - } - write_json(STATE, { conf: r.conf, sig: r.sig, ts: now }, 0o644); - restart_dnsmasq(); - return true; -}; - -/** Turning it on: umdns must run and look at the home networks. */ -export function start_mdns() { - system('/etc/init.d/umdns enable >/dev/null 2>&1; /etc/init.d/umdns start >/dev/null 2>&1'); -}; - -export function view(m) { - let s = ops.mdns_running() ? ops.mdns_services() : []; - return { - running: ops.mdns_running(), - services: length(filter(s, (x) => x.port && index(SKIP, x.type) < 0)), - }; -}; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc index 1b29131..44e1786 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc @@ -137,8 +137,6 @@ export function load(c) { // (Older configs: device_mesh 0/1.) mesh: index(MESH, r.mesh) >= 0 ? r.mesh : (bool(r.device_mesh, true) ? 'all' : 'off'), enabled: bool(r.enabled, true), - // Home devices found over Bonjour are published as DNS-SD records (needs umdns). - bonjour: bool(r.bonjour, false), obf: {}, }; // A person's own devices reach each other whenever the mesh is not off. diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/ops.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/ops.uc index cd2769e..669478a 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/ops.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/ops.uc @@ -34,7 +34,6 @@ export function needs() { acme: miss([ [ file_exists('/usr/lib/acme/client/acme.sh'), 'acme' ], [ file_exists('/usr/lib/acme/client/dnsapi/dns_cf.sh'), 'acme-acmesh-dnsapi' ], [ file_exists('/www/luci-static/resources/view/acme.js'), 'luci-app-acme' ] ]), home: miss([ [ file_exists('/usr/libexec/ip-full'), 'ip-full' ], [ veth, 'kmod-veth' ] ]), - bonjour: miss([ [ file_exists('/usr/sbin/umdns'), 'umdns' ] ]), }; }; @@ -52,7 +51,7 @@ export function mdns_services() { return []; let r = {}; try { - r = json(sh_out(`ubus call umdns browse '{"address":true}' 2>/dev/null`) || '{}') ?? {}; + r = json(sh_out(`ubus call umdns browse '{"address":true,"array":true}' 2>/dev/null`) || '{}') ?? {}; } catch (e) { r = {}; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc index f7b1b27..dc331af 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc @@ -3,7 +3,7 @@ import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; -export const VERSION = '0.3.0'; +export const VERSION = '0.3.1'; /** GitHub repository with Dawnline releases (updates and the installer). */ export const REPO = 'tickcount/luci-app-dawnline'; export const RUN_DIR = '/var/run/dawnline'; diff --git a/web/package-lock.json b/web/package-lock.json index 11076c7..4e8459a 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "dawnline-web", - "version": "0.3.0", + "version": "0.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dawnline-web", - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "dependencies": { "qrcode-generator": "1.4.4" diff --git a/web/package.json b/web/package.json index e002fd5..a5b7e77 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dawnline-web", - "version": "0.3.0", + "version": "0.3.1", "private": true, "license": "MIT", "type": "module", diff --git a/web/src/admin/api.ts b/web/src/admin/api.ts index 2e60639..97cf47e 100644 --- a/web/src/admin/api.ts +++ b/web/src/admin/api.ts @@ -95,7 +95,6 @@ export interface Needs { https: string[]; acme: string[]; home: string[]; - bonjour: string[]; } export interface SettingsData { @@ -189,8 +188,6 @@ export interface InterfacesData { mesh: MeshMode; }; like_home: LikeHome; - /** Find home devices: published from umdns as DNS-SD records. */ - bonjour: { on: boolean; needs: string[]; running: boolean; services: number }; effective: { wan: { dev: string | null; zone: string; auto: boolean; missing: boolean }; home: { dev: string; auto: boolean; nets: string[]; zone: string | null; missing: boolean }[]; diff --git a/web/src/admin/interfaces.ts b/web/src/admin/interfaces.ts index e83e651..59cae91 100644 --- a/web/src/admin/interfaces.ts +++ b/web/src/admin/interfaces.ts @@ -374,7 +374,6 @@ export function accessCards(srv: Server, st: Status, reload: () => void): HTMLEl '', mesh === 'circles' ? circleChips(st, serverId, reload) : undefined, ), - bonjourRow(), services, ]), E('div', { class: 'dl-setsec-foot' }, [ @@ -397,34 +396,6 @@ export function accessCards(srv: Server, st: Status, reload: () => void): HTMLEl window.scrollTo({ top: y }); } - /** Find home devices: AirPlay, printers and shared Macs listed on Apple devices over the tunnel. */ - function bonjourRow(): HTMLElement { - const b = d.bonjour; - const set = async (on: boolean) => { - if (await attempt(() => api.serverUpdate(serverId, { bonjour: on }), on ? 'Finding home devices' : 'Home devices no longer listed')) - load(false); - }; - const state = b.needs.length - ? E('span', { class: 'dl-warn' }, ` Needs ${b.needs.join(', ')}.`) - : b.on && !b.running - ? E('span', { class: 'dl-warn' }, ' umdns is not running.') - : b.on - ? ` Listing ${b.services} service${b.services === 1 ? '' : 's'} from home now.` - : ''; - return setrow( - 'wifi', - ['Find home devices ', E('span', { class: 'dl-faint dl-w400' }, '· Bonjour')], - [ - 'iPhone, iPad and Mac on the VPN see AirPlay, printers and shared Macs at home, as on Wi-Fi. Android and Chromecast look only on the local network.', - state, - ], - b.needs.length - ? button('Install', () => installMissing('bonjour', b.needs, () => load(false)), 'positive') - : sw(b.on, 'Find home devices', (v) => set(v)), - b.on && b.running ? 'ok' : '', - ); - } - /** Interfaces that can be home networks as tiles; the rest folded, by kind. */ function netPicker(): HTMLElement { const avail = d.devices.filter(pickable); diff --git a/web/src/admin/pkgs.ts b/web/src/admin/pkgs.ts index 9891edb..33951b4 100644 --- a/web/src/admin/pkgs.ts +++ b/web/src/admin/pkgs.ts @@ -8,7 +8,6 @@ const WHAT: Record = { https: 'HTTPS for the portal', acme: 'ACME certificates', home: 'the home-like link', - bonjour: 'Bonjour for home devices', }; const WAIT_MS = 5 * 60 * 1000;