From 466ca6c7b033f0f3cde8eb5896da4c49642083da Mon Sep 17 00:00:00 2001 From: Aemeath <35622087+tickcount@users.noreply.github.com> Date: Sun, 18 Oct 2026 16:45:22 +0300 Subject: [PATCH] Dawnline 0.8.0 - Every field says what is wrong as you type, in the router's own words, and Save refuses what the router would: UDP port when editing a server, MTU, keep-alive, public address, DNS for devices, person name, device limit, end date and data limit, device names (the next free "Phone 2" is offered), home services, circles, portal title, redirect and other addresses, defaults, update time - Cyrillic names give Latin ids, hostnames and file names; names are counted in characters, the rule names the characters it refuses; end dates must exist on the calendar; a mistyped extra portal address is refused instead of dropped - The public address is checked on the router as it is typed: points at this router, at another address, behind Cloudflare, or the WAN is private or CGNAT; the wizard says so before the first step, never pre-fills a private WAN address and says where its suggestion came from; the Connection card says when the server was last reached from the internet; IPv6 names and literals work throughout - A person can be moved to another server from their page; a server's tunnel network can be changed in the Danger zone (devices are renumbered and marked "Update config"); WAN and LAN zones come from the router's actual devices; when the public IPv4 changed, one click puts the new one in - Over the data limit or outside the allowed hours the tunnel stays connected and the portal explains why nothing gets through, instead of a silent handshake failure; Health's "devices loaded" compares the peers themselves, not their count - Portal: install links for this platform, two first steps on a first visit, the phone's back button closes a sheet, the file goes through the share sheet into the app, two QR codes (AmneziaVPN camera, AmneziaWG and WireGuard apps), the sheet notices the first connection - Admin: Enter submits a dialog, arrow keys walk the menus, Find in People ("/" focuses it), a device of a paused, ended or over-limit person says so, "Keep access" past its end date is said on the Overview, Allowed hours enforce nothing until saved, the invite card shares the link - Health warns when another package's policy routing (mwan3, pbr) sends tunnel traffic past the home-device path - CLI: person ls, device ls, log with -n, --since, --level, --src and --json; exit code 2 for an unknown command and 1 when health finds an error; person rm asks for --yes when devices would go; devices added from the command line get their event and "issued" marker like the UI's - Three disguises: Off, Balanced and Maximum. Standard and Strong (1.0-style junk only, which networks learned to spot) are no longer offered; a server still on one keeps running and its card says to switch. A new server gets the strongest disguise its router can run - Portal: setting up a device is one sheet with two steps. Get the app (AmneziaVPN first; AmneziaWG, and WireGuard with the disguise off, behind "Another app") from the store of the device in hand, with the GitHub release where no store has it and the version the server needs said once; then add the connection (open in AmneziaVPN, copy the key, share or download the file). A device set up from another device gets its link to take there, as a QR code for a phone; a phone set up from a computer also gets the connection as a code, one code revealed at a time so the camera cannot read the wrong one - Portal motion: the first visit comes in once (blocks in reading order, meters fill, the sun rises in the logo); a repaint glides cards to their new places and brings changed values into focus; sheets slide up on phones and can be pulled down, come into focus on a computer, follow their content's height and turn into the next sheet in place; tabs and segments slide, menus, tooltips and toasts grow out of what opened them, copy buttons turn into a check, buttons waiting for the router spin; with reduced motion only the fades remain - Portal: while a device is set up, a card at the top shows the way from it to the router with a light running along it; on the first connection the way fills green, the steps fold away and the sheet closes by itself. The first connection is the first fresh handshake, so it is no longer missed while the watcher catches up (or after new keys), and the device's card goes on to Connected - Portal: QR codes are light dots on a black card, fuller on dense keys, with "Show a light code" for scanners that read only dark on light (every code switches, the choice is kept); the link and code a set-up sheet hands to another device open that device's set-up there at once - Portal: Remove and New keys ask in a small alert with the action's icon; the open one of two cards is not a button; device names are no longer repeated in every line of the set-up sheet; the code card lines up with the rest of its card (a class clash gave it the page's padding); text keeps the arrow cursor, store badges and link buttons are not underlined --- package/luci-app-dawnline/Makefile | 2 +- .../luci-static/resources/dawnline/app.js | 36 +- .../luci-app-dawnline/root/usr/bin/dawnline | 195 ++- .../root/usr/libexec/dawnline/agent | 30 +- .../share/dawnline/portal/assets/portal.css | 2 +- .../share/dawnline/portal/assets/portal.js | 12 +- .../share/rpcd/acl.d/luci-app-dawnline.json | 2 + .../root/usr/share/ucode/dawnline/apply.uc | 18 +- .../root/usr/share/ucode/dawnline/awg.uc | 44 +- .../root/usr/share/ucode/dawnline/core.uc | 74 +- .../root/usr/share/ucode/dawnline/health.uc | 115 +- .../root/usr/share/ucode/dawnline/live.uc | 2 +- .../root/usr/share/ucode/dawnline/lookup.uc | 25 +- .../root/usr/share/ucode/dawnline/portal.uc | 4 + .../usr/share/ucode/dawnline/rpc/common.uc | 8 +- .../root/usr/share/ucode/dawnline/rpc/home.uc | 10 +- .../usr/share/ucode/dawnline/rpc/people.uc | 10 +- .../usr/share/ucode/dawnline/rpc/servers.uc | 98 +- .../usr/share/ucode/dawnline/rpc/status.uc | 35 +- .../root/usr/share/ucode/dawnline/schema.uc | 14 +- .../root/usr/share/ucode/dawnline/util.uc | 113 +- .../root/usr/share/ucode/dawnline/view.uc | 9 +- tests/ucode/awg.test.uc | 22 +- tests/ucode/core.test.uc | 28 + tests/ucode/schema.test.uc | 5 +- tests/ucode/util.test.uc | 24 +- web/package-lock.json | 4 +- web/package.json | 2 +- web/src/admin/access.ts | 25 +- web/src/admin/api.ts | 28 +- web/src/admin/cores/awg.ts | 83 +- web/src/admin/device.ts | 58 +- web/src/admin/disguise.ts | 41 +- web/src/admin/events/model.ts | 2 + web/src/admin/events/render.ts | 8 + web/src/admin/invite.ts | 34 +- web/src/admin/netcheck.ts | 230 +++ web/src/admin/pages/overview.ts | 45 +- web/src/admin/pages/people.ts | 148 +- web/src/admin/pages/person/devices.ts | 2 +- web/src/admin/pages/person/dialogs.ts | 53 +- web/src/admin/pages/person/header.ts | 4 +- web/src/admin/pages/person/index.ts | 25 +- web/src/admin/pages/person/limits.ts | 55 +- web/src/admin/pages/server.ts | 205 ++- web/src/admin/pages/settings/defaults.ts | 48 +- web/src/admin/pages/settings/portal.ts | 29 +- web/src/admin/pages/settings/updates.ts | 16 +- web/src/admin/styles/dialogs.css | 3 + web/src/admin/styles/people.css | 3 + web/src/admin/ui/badges.ts | 21 +- web/src/admin/ui/files.ts | 12 +- web/src/admin/ui/layout.ts | 51 +- web/src/admin/ui/menu.ts | 17 +- web/src/admin/ui/modal.ts | 22 +- web/src/admin/ui/tooltip.ts | 7 + web/src/portal/dom.ts | 32 + web/src/portal/main.ts | 1345 ++++++++++++++--- web/src/portal/motion.ts | 496 ++++++ web/src/portal/portal.css | 1178 ++++++++++++++- web/src/portal/setup.ts | 192 +++ web/src/portal/waitpath.ts | 60 + web/src/shared/icons.ts | 25 + web/src/shared/qr.ts | 101 +- web/src/shared/types.ts | 4 + web/tests/motion.test.ts | 29 + web/tests/netcheck.test.ts | 79 + web/tests/qr.test.ts | 30 + web/tests/setup.test.ts | 79 + 69 files changed, 5182 insertions(+), 686 deletions(-) create mode 100644 web/src/portal/dom.ts create mode 100644 web/src/portal/motion.ts create mode 100644 web/src/portal/setup.ts create mode 100644 web/src/portal/waitpath.ts create mode 100644 web/tests/motion.test.ts create mode 100644 web/tests/qr.test.ts create mode 100644 web/tests/setup.test.ts diff --git a/package/luci-app-dawnline/Makefile b/package/luci-app-dawnline/Makefile index e3e1b28..c5c6d12 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.7.0 +PKG_VERSION:=0.8.0 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 cf36a25..8e1da82 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 @@ -5,25 +5,25 @@ 'require poll'; 'require rpc'; 'require ui'; -var gr=Object.create;var ao=Object.defineProperty;var vr=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var xr=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty;var yr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var kr=(n,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of br(e))!wr.call(n,r)&&r!==o&&ao(n,r,{get:()=>e[r],enumerable:!(a=vr(e,r))||a.enumerable});return n};var $r=(n,e,o)=>(o=n!=null?gr(xr(n)):{},kr(e||!n||!n.__esModule?ao(o,"default",{value:n,enumerable:!0}):o,n));var bo=yr((go,vo)=>{"use strict";var fo=(function(){var n=function(E,y){var S=236,b=17,x=E,M=o[y],h=null,f=0,R=null,C=[],I={},Q=function(T,A){f=x*4+17,h=(function($){for(var H=new Array($),_=0;_<$;_+=1){H[_]=new Array($);for(var j=0;j<$;j+=1)H[_][j]=null}return H})(f),G(0,0),G(f-7,0),G(0,f-7),K(),z(),ce(T,A),x>=7&&X(T),R==null&&(R=U(x,M,C)),fe(R,A)},G=function(T,A){for(var $=-1;$<=7;$+=1)if(!(T+$<=-1||f<=T+$))for(var H=-1;H<=7;H+=1)A+H<=-1||f<=A+H||(0<=$&&$<=6&&(H==0||H==6)||0<=H&&H<=6&&($==0||$==6)||2<=$&&$<=4&&2<=H&&H<=4?h[T+$][A+H]=!0:h[T+$][A+H]=!1)},Y=function(){for(var T=0,A=0,$=0;$<8;$+=1){Q(!0,$);var H=r.getLostPoint(I);($==0||T>H)&&(T=H,A=$)}return A},z=function(){for(var T=8;T>$&1)==1;h[Math.floor($/3)][$%3+f-8-3]=H}for(var $=0;$<18;$+=1){var H=!T&&(A>>$&1)==1;h[$%3+f-8-3][Math.floor($/3)]=H}},ce=function(T,A){for(var $=M<<3|A,H=r.getBCHTypeInfo($),_=0;_<15;_+=1){var j=!T&&(H>>_&1)==1;_<6?h[_][8]=j:_<8?h[_+1][8]=j:h[f-15+_][8]=j}for(var _=0;_<15;_+=1){var j=!T&&(H>>_&1)==1;_<8?h[8][f-_-1]=j:_<9?h[8][15-_-1+1]=j:h[8][15-_-1]=j}h[f-8][8]=!T},fe=function(T,A){for(var $=-1,H=f-1,_=7,j=0,Z=r.getMaskFunction(A),V=f-1;V>0;V-=2)for(V==6&&(V-=1);;){for(var pe=0;pe<2;pe+=1)if(h[H][V-pe]==null){var be=!1;j>>_&1)==1);var ee=Z(H,V-pe);ee&&(be=!be),h[H][V-pe]=be,_-=1,_==-1&&(j+=1,_=7)}if(H+=$,H<0||f<=H){H-=$,$=-$;break}}},O=function(T,A){for(var $=0,H=0,_=0,j=new Array(A.length),Z=new Array(A.length),V=0;V=0?to.getAt(no):0}}for(var oo=0,ee=0;eeV*8)throw"code length overflow. ("+_.getLengthInBits()+">"+V*8+")";for(_.getLengthInBits()+4<=V*8&&_.put(0,4);_.getLengthInBits()%8!=0;)_.putBit(!1);for(;!(_.getLengthInBits()>=V*8||(_.put(S,8),_.getLengthInBits()>=V*8));)_.put(b,8);return O(_,H)};I.addData=function(T,A){A=A||"Byte";var $=null;switch(A){case"Numeric":$=d(T);break;case"Alphanumeric":$=p(T);break;case"Byte":$=u(T);break;case"Kanji":$=w(T);break;default:throw"mode:"+A}C.push($),R=null},I.isDark=function(T,A){if(T<0||f<=T||A<0||f<=A)throw T+","+A;return h[T][A]},I.getModuleCount=function(){return f},I.make=function(){if(x<1){for(var T=1;T<40;T++){for(var A=l.getRSBlocks(T,M),$=c(),H=0;H"u"?T*4:A;var $="";$+='";for(var _=0;_';$+=""}return $+="",$+="
",$},I.createSvgTag=function(T,A,$,H){var _={};typeof arguments[0]=="object"&&(_=arguments[0],T=_.cellSize,A=_.margin,$=_.alt,H=_.title),T=T||2,A=typeof A>"u"?T*4:A,$=typeof $=="string"?{text:$}:$||{},$.text=$.text||null,$.id=$.text?$.id||"qrcode-description":null,H=typeof H=="string"?{text:H}:H||{},H.text=H.text||null,H.id=H.text?H.id||"qrcode-title":null;var j=I.getModuleCount()*T+A*2,Z,V,pe,be,ee="",Te;for(Te="l"+T+",0 0,"+T+" -"+T+",0 0,-"+T+"z ",ee+=''+q(H.text)+"":"",ee+=$.text?''+q($.text)+"":"",ee+='',ee+='"u"?T*4:A;var $=I.getModuleCount()*T+A*2,H=A,_=$-A;return B($,$,function(j,Z){if(H<=j&&j<_&&H<=Z&&Z<_){var V=Math.floor((j-H)/T),pe=Math.floor((Z-H)/T);return I.isDark(pe,V)?0:1}else return 1})},I.createImgTag=function(T,A,$){T=T||2,A=typeof A>"u"?T*4:A;var H=I.getModuleCount()*T+A*2,_="";return _+="",_};var q=function(T){for(var A="",$=0;$":A+=">";break;case"&":A+="&";break;case'"':A+=""";break;default:A+=H;break}}return A},oe=function(T){var A=1;T=typeof T>"u"?A*2:T;var $=I.getModuleCount()*A+T*2,H=T,_=$-T,j,Z,V,pe,be,ee={"██":"█","█ ":"▀"," █":"▄"," ":" "},Te={"██":"▀","█ ":"▀"," █":" "," ":" "},_e="";for(j=0;j<$;j+=2){for(V=Math.floor((j-H)/A),pe=Math.floor((j+1-H)/A),Z=0;Z<$;Z+=1)be="█",H<=Z&&Z<_&&H<=j&&j<_&&I.isDark(V,Math.floor((Z-H)/A))&&(be=" "),H<=Z&&Z<_&&H<=j+1&&j+1<_&&I.isDark(pe,Math.floor((Z-H)/A))?be+=" ":be+="█",_e+=T<1&&j+1>=_?Te[be]:ee[be];_e+=` -`}return $%2&&T>0?_e.substring(0,_e.length-$-1)+Array($+1).join("▀"):_e.substring(0,_e.length-1)};return I.createASCII=function(T,A){if(T=T||1,T<2)return oe(A);T-=1,A=typeof A>"u"?T*2:A;var $=I.getModuleCount()*T+A*2,H=A,_=$-A,j,Z,V,pe,be=Array(T+1).join("██"),ee=Array(T+1).join(" "),Te="",_e="";for(j=0;j<$;j+=1){for(V=Math.floor((j-H)/T),_e="",Z=0;Z<$;Z+=1)pe=1,H<=Z&&Z<_&&H<=j&&j<_&&I.isDark(V,Math.floor((Z-H)/T))&&(pe=0),_e+=pe?be:ee;for(V=0;V>>8),M.push(R&255)):M.push(b)}}return M}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={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},r=(function(){var E=[[],[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]],y=1335,S=7973,b=21522,x={},M=function(h){for(var f=0;h!=0;)f+=1,h>>>=1;return f};return x.getBCHTypeInfo=function(h){for(var f=h<<10;M(f)-M(y)>=0;)f^=y<=0;)f^=S<5&&(R+=3+Q-5)}for(var C=0;C=256;)x-=255;return E[x]},b})();function s(E,y){if(typeof E.length>"u")throw E.length+"/"+y;var S=(function(){for(var x=0;x"u")throw"bad rs block @ typeNumber:"+x+"/errorCorrectionLevel:"+M;for(var f=h.length/3,R=[],C=0;C>>7-b%8&1)==1},S.put=function(b,x){for(var M=0;M>>x-M-1&1)==1)},S.getLengthInBits=function(){return y},S.putBit=function(b){var x=Math.floor(y/8);E.length<=x&&E.push(0),b&&(E[x]|=128>>>y%8),y+=1},S},d=function(E){var y=e.MODE_NUMBER,S=E,b={};b.getMode=function(){return y},b.getLength=function(h){return S.length},b.write=function(h){for(var f=S,R=0;R+2>>8&255)*192+(C&255),h.put(C,13),R+=2}if(R>>8)},y.writeBytes=function(S,b,x){b=b||0,x=x||S.length;for(var M=0;M0&&(S+=","),S+=E[b];return S+="]",S},y},m=function(){var E=0,y=0,S=0,b="",x={},M=function(f){b+=String.fromCharCode(h(f&63))},h=function(f){if(!(f<0)){if(f<26)return 65+f;if(f<52)return 97+(f-26);if(f<62)return 48+(f-52);if(f==62)return 43;if(f==63)return 47}throw"n:"+f};return x.writeByte=function(f){for(E=E<<8|f&255,y+=8,S+=1;y>=6;)M(E>>>y-6),y-=6},x.flush=function(){if(y>0&&(M(E<<6-y),E=0,y=0),S%3!=0)for(var f=3-S%3,R=0;R=y.length){if(x==0)return-1;throw"unexpected end of file./"+x}var f=y.charAt(S);if(S+=1,f=="=")return x=0,-1;if(f.match(/^\s$/))continue;b=b<<6|h(f.charCodeAt(0)),x+=6}var R=b>>>x-8&255;return x-=8,R};var h=function(f){if(65<=f&&f<=90)return f-65;if(97<=f&&f<=122)return f-97+26;if(48<=f&&f<=57)return f-48+52;if(f==43)return 62;if(f==47)return 63;throw"c:"+f};return M},N=function(E,y){var S=E,b=y,x=new Array(E*y),M={};M.setPixel=function(C,I,Q){x[I*S+C]=Q},M.write=function(C){C.writeString("GIF87a"),C.writeShort(S),C.writeShort(b),C.writeByte(128),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(255),C.writeByte(255),C.writeByte(255),C.writeString(","),C.writeShort(0),C.writeShort(0),C.writeShort(S),C.writeShort(b),C.writeByte(0);var I=2,Q=f(I);C.writeByte(I);for(var G=0;Q.length-G>255;)C.writeByte(255),C.writeBytes(Q,G,255),G+=255;C.writeByte(Q.length-G),C.writeBytes(Q,G,Q.length-G),C.writeByte(0),C.writeString(";")};var h=function(C){var I=C,Q=0,G=0,Y={};return Y.write=function(z,K){if(z>>>K)throw"length over";for(;Q+K>=8;)I.writeByte(255&(z<>>=8-Q,G=0,Q=0;G=z<0&&I.writeByte(G)},Y},f=function(C){for(var I=1<>6,128|i&63):i<55296||i>=57344?a.push(224|i>>12,128|i>>6&63,128|i&63):(r++,i=65536+((i&1023)<<10|o.charCodeAt(r)&1023),a.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return a}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof go=="object"&&(vo.exports=n())})(function(){return fo})});function Sn(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>Sn(o,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,o){let a=window.E,r=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!r&&o===void 0?a(n,{},Sn(e,[])):a(n,r?e:{},Sn(o,[]))}var ro={phone:'',computer:'',tablet:'',router:'',server:'',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 $t(n,e="dl-icon"){let o=ro[n]??ro.phone;return``}function v(n,e="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=$t(n,e),o}function F(n,e="info",o=0){let a=document.querySelector(".dl-toasts");a||(a=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(a));let r=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=t("div",{class:`dl-toast ${e}`},[r?v(r):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":"Close",click:i},v("x")):""]);a.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,o||(e==="error"?8e3:e==="warning"?5e3:2600))}function ve(n){return n instanceof Error?n.message:String(n)}async function W(n,e){try{let o=await n();return e&&F(e,"success",3500),o}catch(o){F(ve(o),"error",1e4);return}}function io(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(o=>F(ve(o),"error"))}catch(e){F(ve(e),"error")}}function so(n){if(n&&typeof n=="object"){if(typeof n.error=="string")throw new Error(n.error);typeof n.warning=="string"&&n.warning&&F(n.warning,"warning",12e3)}return n}function J(n,e=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:e});return async(...a)=>so(await o(...a))}var Er=J("logs_clear",["person","device","category","older_days"]),Lr=(n={})=>Er(n.person??"",n.device??"",n.category??"",n.older_days??""),Mr=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 Sr(n,e){let a=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(r=>e[r]),e.paused,e.services,e.circle,e.home_nets];return so(await Mr(...a))}var Tr=J("status",["days"]),P={rev:J("rev"),personUpdate:Sr,settingsGet:J("settings_get"),portalInfo:J("portal_info"),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","person","since"]),logsClear:Lr,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:Tr,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"]),personLinks:J("person_links",["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","remove"]),personDelete:J("person_delete",["id"]),personUsage:J("person_usage",["id","days"]),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"]),updatesReleases:J("updates_releases",["page"]),updatesNotes:J("updates_notes",["component","tag","build"]),updatesChanges:J("updates_changes",["from","to"])};function D(n,e,o="neutral",a={}){let{disabled:r,...i}=a,s=t("button",{class:`cbi-button cbi-button-${o}`,type:"button",...i,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!s.disabled){s.disabled=!0,s.classList.add("spinning");try{await e(l)}catch(c){F(ve(c),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!r,s}function $e(n,e,o,a="neutral",r=""){return D([v(n),t("span",{class:"dl-btn-label"},e)],o,a,{title:e,class:`cbi-button cbi-button-${a} dl-icon-btn ${r}`.trim()})}function Ee(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var dt=null;function Tn(n=!1){let e=dt;dt=null,e?.(n)}function ae(n,e,o,a=""){Tn(),ui.showModal(n,[t("div",{class:`dl-modal ${a}`},e),t("div",{class:"button-row"},o)])}function de(){Tn(),ui.hideModal()}function le(n="Cancel",e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:de},n)}function re(n,e,o="Confirm",a=!1){return new Promise(r=>{ae(n,e,[le()," ",t("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=dt;dt=null,ui.hideModal(),i?.(!0)}},o)]),dt=r})}Ee(()=>{dt&&(Tn(),ui.hideModal())});async function ue(n,e="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let o=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(o),o.select();let a=document.execCommand("copy");if(o.remove(),!a)throw new Error("Copying is blocked here. Select the text and copy it by hand.")}F(e,"success",2500)}catch(o){F(ve(o),"error")}}function Le(n,e,o="text/plain"){let a=globalThis,r=typeof e=="string"?new a.Blob([e],{type:o}):e,i=URL.createObjectURL(r),s=t("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function _n(n,e){return new Promise(o=>{let a=t("input",{type:"file",accept:n,style:"display:none"});a.addEventListener("cancel",()=>{a.remove(),o(null)}),a.addEventListener("change",()=>{let r=a.files?.[0];if(a.remove(),!r)return o(null);let i=new FileReader;i.onload=()=>{let s=String(i.result??"");o({name:r.name,data:e==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>o(null),e==="base64"?i.readAsDataURL(r):i.readAsText(r)}),document.body.appendChild(a),a.click()})}function we(n,e){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let a=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),io(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(a);let r=n.getBoundingClientRect(),i=a.offsetWidth,s=a.offsetHeight;a.style.top=`${r.bottom+6+s>window.innerHeight-8&&r.top-6-s>8?r.top-6-s:r.bottom+6}px`,a.style.left=`${Math.max(8,Math.min(r.right-i,window.innerWidth-i-8))}px`;let l=u=>{!a.contains(u.target)&&!n.contains(u.target)&&p()},c=u=>{u.key==="Escape"&&p()},d=Ee(p);a.dlAnchor=n,a.dlClose=p;function p(){a.remove(),d(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",c,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",c,!0),window.addEventListener("scroll",p,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var et=null,tt=null,Cn=0;function Et(){et&&(et.style.display="none"),tt=null,clearInterval(Cn),Cn=0}function me(n,e){let o=a=>{et??(et=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),et.replaceChildren(...e().map(r=>typeof r=="string"?document.createTextNode(r):r)),et.style.display="",et.style.left=`${a.clientX}px`,et.style.top=`${a.clientY-10}px`,tt=n,Cn||(Cn=window.setInterval(()=>{(!tt?.isConnected||!tt.getClientRects().length)&&Et()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",Et)}Ee(Et);window.addEventListener("scroll",()=>tt&&Et(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{tt&&!tt.contains(n.target)&&Et()},!0);function te(n){if(!n||n<0)return"0 B";let e=["B","KB","MB","GB","TB"],o=0,a=n;for(;a>=1024&&o=100||o===0?Math.round(a):a.toFixed(1)} ${e[o]}`}function ze(n){let e=n*8;return e<1e3?`${Math.round(e)} bit/s`:e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)} kbit/s`:e<1e9?`${(e/1e6).toFixed(e<1e7?1:0)} Mbit/s`:`${(e/1e9).toFixed(1)} Gbit/s`}function ie(n,e=Date.now()/1e3){if(!n)return"never";let o=Math.max(0,Math.round(e-n));return o<60?"just now":o<3600?`${Math.floor(o/60)} min ago`:o<86400?`${Math.floor(o/3600)} h ago`:o<86400*30?`${Math.floor(o/86400)} d ago`:new Date(n*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function pt(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),o=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return e?`${e}d ${o}h`:o?`${o}h ${a}m`:`${a}m`}function Mt(n){let e=new Date(n*1e3),o=new Date,a=e.toDateString()===o.toDateString(),r=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?r:`${e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${r}`}function Ne(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function ut(n){let[e,o,a]=n.split("-").map(Number);return new Date(e,(o||1)-1,a||1,12)}function He(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?ut(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Ce(n){return n?He(n):""}function Pn(n,e){let o=a=>{let[r,i,s]=a.split("-").map(Number);return Date.UTC(r,i-1,s)};return Math.round((o(n)-o(e))/864e5)}function Lt(n,e){let o=ut(n);return o.setDate(o.getDate()+e),Ne(o)}function ct(n,e){let[o,a,r]=n.split("-").map(Number),i=new Date(o,a-1+e,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(r,s)),Ne(i)}function Re(n){return n?.length?n[n.length-1].day:Ne(new Date)}function lo(n,e,o,a,r=30){let i=n||a;return e==="day"?Lt(i,o):e==="week"?Lt(i,7*o):e==="month"?ct(i,o):e==="year"?ct(i,12*o):Lt(i,r*o)}function nt(n,e=Date.now()){if(!n)return null;let o=typeof e=="number"?Ne(new Date(e)):e,a=Pn(n,o);return a>=0?a+1:a}function Fe(n,e){return e!=null&&e>0&&n.expire_warn>0&&e<=n.expire_warn}function Gt(n){return n<=1?"ends today":n===2?"ends tomorrow":`ends in ${n} days`}function Ft(n,e,o=`${e}s`){return`${n.toLocaleString("en-GB")} ${n===1?e:o}`}function St(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var ot={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var co=["computer","phone","tablet","router","other"],je={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},po={active:"Active",paused:"Paused",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server",server_off:"Server is turned off"};function Pe(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let o=e[0][0]??"",a=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(o+a).toUpperCase()}function qt(n){let e=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,a)=>[o,a]).sort((o,a)=>e(o[0])-e(a[0])||o[1]-a[1]).map(([o])=>o)}function ye(n,e,o){return t("span",{class:`dl-pill ${n}`,title:o??null},e)}function _r(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function Cr(n){return n.state==="server_off"&&n.paused?"paused":n.state}function uo(n){let e=Cr(n);return e==="active"||e==="server_off"?"":ye(_r({...n,state:e}),po[e])}function mo(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=t("span",{class:"dl-access","aria-label":ot[n.access]},e.map(a=>t("span",{class:`dl-ibadge ${a}`},v(a==="lan"?"home":"globe"))));return me(o,()=>[t("div",{class:"dl-tip-title"},ot[n.access]),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),o}function Kt(n,e,o="Not set up yet"){return n.disabled?t("span",{class:"dl-dstat"},"Disabled"):n.online?t("span",{class:"dl-dstat ok"},"Connected"):n.handshake?t("span",{class:"dl-dstat"},`Last seen ${ie(n.handshake,e)}`):t("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},o)}var Jt=null;function ho(n,e,o,a){Jt?.close();let r=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>d()},v("x"))]),t("div",{class:"dl-drawer-body"},e),o?t("div",{class:"dl-drawer-foot"},o):""]),i=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===i&&d()}},r),s=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&d()},l=!1,c=Ee(()=>d());function d(){l||(l=!0,c(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),Jt===p&&(Jt=null),a())}let p={close:d,panel:r};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),Jt=p,p}function ne(n,e,o){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),o?t("span",{class:"dl-sub"},o):""]),t("div",{class:"dl-setrow-ctl"},e)])}function mt(n,e,o,a=e){let r=ne(n,a," "),i=r.querySelector(".dl-sub"),s=()=>{let l=o();i.textContent=l.text,i.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),r.refresh=s,s(),r}function Tt(n,e,o,a=""){return t("section",{class:`dl-setsec ${a}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function he(n,e,o,a){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},v(n)),t("span",{class:"dl-stack"},[t("b",{},e),o?t("span",{class:"dl-sub"},o):""])]),t("div",{class:"dl-group-body"},a.filter(r=>r!==""))])}function at(n,e,o,a,r){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},v(n)):v(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-sub"},a)]),r])}function ht(n,e){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${o}`},e)}function qe(n,e=""){let o=t("div",{class:e});return o.innerHTML=n,o}var xo=$r(bo(),1),Pr='';function ft(n,e=3,o=!0){let a=(0,xo.default)(0,n.length>300?"Q":"H");a.addData(n,"Byte"),a.make();let r=a.getModuleCount(),i=r+e*2,s=o?Math.round(r*.22):0;s&&(r-s)%2&&s++;let l=(r-s)/2,c=l+s,d=(w,g)=>s>0&&w>=l&&w=l&&g${Pr}`}return`${u}`}var Dr={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",portal_blocked:"problems"},gt=["connections","people","problems"],rt={connections:"Connections",people:"People",problems:"Problems"},wo={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)"},_t=n=>Dr[n]??"problems",Ct={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},Ar=["person_added","person_removed","person_changed"];function De(n){return n.by?n.by:Ar.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function yo(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var Vt=n=>n.sys?["error","repair","down"].includes(n.sys.level):_t(n.ev.type)==="problems";function Yt(n){let e=n.keep_days>0?`${n.keep_days} day${n.keep_days===1?"":"s"}`:"no age limit",o=n.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${n.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${e}, up to ${n.max.toLocaleString("en-GB")} events, ${o}.`}function ko(n,e=120,o=26,a=Ne(new Date)){let r=Math.max(1,...n),i=t("div",{class:"dl-spark"});return i.style.width=`${e}px`,i.style.height=`${o}px`,n.forEach((s,l)=>{let c=t("i");c.style.height=`${Math.max(6,s/r*100)}%`,s||c.classList.add("zero");let d=n.length-1-l;me(c,()=>[t("div",{class:"dl-tip-title"},d===0?"Today":d===1?"Yesterday":ut(Lt(a,-d)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},te(s))]),i.appendChild(c)}),i}function zr(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function $o(n,e){return[n.join(","),...e.map(o=>n.map(a=>zr(o[a])).join(","))].join(` -`)}function Nr(n){let e=new Map(n.people.map(a=>[a.id,a.name])),o=new Map(n.people.flatMap(a=>a.devices.map(r=>[r.id,r.name])));return{people:e,devices:o}}function Ue(n,e,o,a="",r=[]){let i=Nr(n),s=[...e.map(p=>({ts:p.ts,category:_t(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:De(p)??""})),...r.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?` -${p.detail}`:""}`,where:Ct[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),l=new Date().toISOString().slice(0,10),c=`dawnline-activity${a?`-${a}`:""}-${l}.${o}`;if(o==="json"){Le(c,JSON.stringify(s,null,2),"application/json");return}Le(c,$o(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var Hr=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],Eo=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function Ke(n,e,o,a,r,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...gt.map(c=>t("option",{value:c,selected:c===r?"selected":null},rt[c])),i?t("option",{value:"system",selected:r==="system"?"selected":null},"System"):""]),l=t("select",{class:"cbi-input-select"},Hr.map(([c,d])=>t("option",{value:c},d)));ae(n,[t("p",{class:"dl-muted"},`${e} This cannot be undone; export first if you want a copy.`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Category"),s]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Which events"),l])],[le()," ",D("Clear",async()=>{let c=0;if(s.value!=="system")try{c+=(await P.logsClear({...o,category:s.value,older_days:l.value})).removed}catch(d){F(ve(d),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{c+=(await P.serviceLogClear(l.value)).removed}catch(d){de(),F(`${s.value==="system"?"":`Activity: ${Eo(c).toLowerCase()}. `}The service log was not cleared: ${ve(d)}`,"error",1e4),a();return}de(),F(Eo(c),"success",3e3),a()},"negative")])}function vt(n,e,o,a){let r=n==="device"?`Clears ${o}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${o}'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.";ae(n==="all"?"Reset all traffic history?":`Reset traffic history for ${o}?`,[t("p",{class:"dl-muted"},r)],[le()," ",D("Reset",async()=>{await W(()=>P.usageClear(n,e),"Traffic history reset")&&(de(),a())},"negative")])}function ge(n,e,o){let a=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let r=!a.classList.contains("on");Dn(a,r),o?.(r)}},t("i"));return a}function Dn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var Se=n=>n.classList.contains("on");function xe(n,e,o={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let a=t("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":e}),r=()=>a.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===a.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)a.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==a.dataset.value&&(o.optimistic!==!1&&(a.dataset.value=i,r()),o.onChange?.(i))}},s));return r(),a}function We(n,e,o,a={}){return t("button",{type:"button",...a,class:`dl-chipbtn${e?" on":""}${a.class?` ${a.class}`:""}`,"aria-pressed":e?"true":"false",click:o},n)}function Zt(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function se(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var Rr={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:""},Ir={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 Br(n){let e={};for(let[o,a]of Object.entries(Ir))n[o]!=null&&n[o]!==""&&(e[a]=String(n[o]));return e}function Or(n,e){let o=n.amnezia,a=o.obfuscation??{},r=c=>a[c]!=null&&a[c]!==""?String(a[c]):Rr[c],i=o.host.replace(/^\[(.*)\]$/,"$1"),s={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),...Br(a),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r -`),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(o.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function jr(n){let e="";for(let o=0;o"u")return null;try{let o=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),a=new Uint8Array(await new e.Response(o).arrayBuffer()),r=new Uint8Array(4+a.length);return new DataView(r.buffer).setUint32(0,n.length,!1),r.set(a,4),r}catch{return null}}async function An(n,e,o=!0){let a=new TextEncoder().encode(JSON.stringify(Or(n,e))),r=o?await Ur(a):null;return`vpn://${jr(r??a)}`}var Mo=[{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:"balanced",title:"Balanced",ic:"shieldplus",stealth:3,speed:3,needs:"v2",text:"AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.",apps:"AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps",short:"AmneziaWG 2.0+ apps"},{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"}],Pt=n=>Mo.find(e=>e.id===n),Wr={v2:"Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},Gr={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function Lo(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>t("i",{class:odom.content(i,Mo.map(l=>{let c=!l.needs||n[l.needs],d=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":d?"true":"false","aria-disabled":c?null:"true",class:`dl-method${d?" on":""}${c?"":" off"}`,click:()=>{!c||d||(e=l.id,s(),o(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},v(l.ic)),t("b",{},l.title),l.id===a?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[Lo(l.stealth,"Stealth"),Lo(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},c?[v("phone"),t("span",{},l.apps)]:[v("alert"),t("span",{},(r?Wr:Gr)[l.needs])])])}));return s(),i}function So(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var To=[["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 Fr(n){let e=d=>n[d]!=null&&n[d]!=="",o=To.filter(([d])=>e(d));if(!o.length)return null;let a=(d,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},d==="header_protection_key"?`${n[d].slice(0,6)}••••`:n[d])]),r=(d,p,u,w)=>{let g=To.filter(([m])=>w.includes(m)&&e(m));return g.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[v(p),t("b",{},d)]),t("p",{},u),t("div",{class:"dl-pvals"},g.map(([m,k])=>a(m,k)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=o.map(([d,p])=>`${p} = ${n[d]}`).join(` -`),c=t("div",{class:"dl-pgrid"},[r("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),r("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),r("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),r("Signatures","globe",s,["i1","i2","i3","i4","i5"]),r("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"]),r("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 t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(o.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:d=>{d.preventDefault(),ue(l,"Parameters copied")}},"Copy as config")]),c])}function _o(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},o[1])," ",a&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function qr(n){let e=!1,o=t("pre",{class:"dl-conf"}),a=()=>dom.content(o,n.conf.split(` +var Va=Object.create;var Eo=Object.defineProperty;var Ya=Object.getOwnPropertyDescriptor;var Za=Object.getOwnPropertyNames;var Qa=Object.getPrototypeOf,Xa=Object.prototype.hasOwnProperty;var ei=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var ti=(n,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Za(e))!Xa.call(n,a)&&a!==o&&Eo(n,a,{get:()=>e[a],enumerable:!(r=Ya(e,a))||r.enumerable});return n};var ni=(n,e,o)=>(o=n!=null?Va(Qa(n)):{},ti(e||!n||!n.__esModule?Eo(o,"default",{value:n,enumerable:!0}):o,n));var Qo=ei((Yo,Zo)=>{"use strict";var Vo=(function(){var n=function(x,v){var $=236,E=17,y=x,z=o[v],h=null,f=0,T=null,S=[],N={},G=function(P,D){f=y*4+17,h=(function(_){for(var B=new Array(_),M=0;M<_;M+=1){B[M]=new Array(_);for(var j=0;j<_;j+=1)B[M][j]=null}return B})(f),q(0,0),q(f-7,0),q(0,f-7),J(),R(),le(P,D),y>=7&&Q(P),T==null&&(T=ne(y,z,S)),he(T,D)},q=function(P,D){for(var _=-1;_<=7;_+=1)if(!(P+_<=-1||f<=P+_))for(var B=-1;B<=7;B+=1)D+B<=-1||f<=D+B||(0<=_&&_<=6&&(B==0||B==6)||0<=B&&B<=6&&(_==0||_==6)||2<=_&&_<=4&&2<=B&&B<=4?h[P+_][D+B]=!0:h[P+_][D+B]=!1)},V=function(){for(var P=0,D=0,_=0;_<8;_+=1){G(!0,_);var B=a.getLostPoint(N);(_==0||P>B)&&(P=B,D=_)}return D},R=function(){for(var P=8;P>_&1)==1;h[Math.floor(_/3)][_%3+f-8-3]=B}for(var _=0;_<18;_+=1){var B=!P&&(D>>_&1)==1;h[_%3+f-8-3][Math.floor(_/3)]=B}},le=function(P,D){for(var _=z<<3|D,B=a.getBCHTypeInfo(_),M=0;M<15;M+=1){var j=!P&&(B>>M&1)==1;M<6?h[M][8]=j:M<8?h[M+1][8]=j:h[f-15+M][8]=j}for(var M=0;M<15;M+=1){var j=!P&&(B>>M&1)==1;M<8?h[8][f-M-1]=j:M<9?h[8][15-M-1+1]=j:h[8][15-M-1]=j}h[f-8][8]=!P},he=function(P,D){for(var _=-1,B=f-1,M=7,j=0,Z=a.getMaskFunction(D),Y=f-1;Y>0;Y-=2)for(Y==6&&(Y-=1);;){for(var ce=0;ce<2;ce+=1)if(h[B][Y-ce]==null){var xe=!1;j>>M&1)==1);var ee=Z(B,Y-ce);ee&&(xe=!xe),h[B][Y-ce]=xe,M-=1,M==-1&&(j+=1,M=7)}if(B+=_,B<0||f<=B){B-=_,_=-_;break}}},ue=function(P,D){for(var _=0,B=0,M=0,j=new Array(D.length),Z=new Array(D.length),Y=0;Y=0?ko.getAt($o):0}}for(var Co=0,ee=0;eeY*8)throw"code length overflow. ("+M.getLengthInBits()+">"+Y*8+")";for(M.getLengthInBits()+4<=Y*8&&M.put(0,4);M.getLengthInBits()%8!=0;)M.putBit(!1);for(;!(M.getLengthInBits()>=Y*8||(M.put($,8),M.getLengthInBits()>=Y*8));)M.put(E,8);return ue(M,B)};N.addData=function(P,D){D=D||"Byte";var _=null;switch(D){case"Numeric":_=d(P);break;case"Alphanumeric":_=p(P);break;case"Byte":_=u(P);break;case"Kanji":_=w(P);break;default:throw"mode:"+D}S.push(_),T=null},N.isDark=function(P,D){if(P<0||f<=P||D<0||f<=D)throw P+","+D;return h[P][D]},N.getModuleCount=function(){return f},N.make=function(){if(y<1){for(var P=1;P<40;P++){for(var D=l.getRSBlocks(P,z),_=c(),B=0;B"u"?P*4:D;var _="";_+='";for(var M=0;M';_+=""}return _+="",_+="
",_},N.createSvgTag=function(P,D,_,B){var M={};typeof arguments[0]=="object"&&(M=arguments[0],P=M.cellSize,D=M.margin,_=M.alt,B=M.title),P=P||2,D=typeof D>"u"?P*4:D,_=typeof _=="string"?{text:_}:_||{},_.text=_.text||null,_.id=_.text?_.id||"qrcode-description":null,B=typeof B=="string"?{text:B}:B||{},B.text=B.text||null,B.id=B.text?B.id||"qrcode-title":null;var j=N.getModuleCount()*P+D*2,Z,Y,ce,xe,ee="",De;for(De="l"+P+",0 0,"+P+" -"+P+",0 0,-"+P+"z ",ee+=''+O(B.text)+"":"",ee+=_.text?''+O(_.text)+"":"",ee+='',ee+='"u"?P*4:D;var _=N.getModuleCount()*P+D*2,B=D,M=_-D;return I(_,_,function(j,Z){if(B<=j&&j"u"?P*4:D;var B=N.getModuleCount()*P+D*2,M="";return M+="",M};var O=function(P){for(var D="",_=0;_":D+=">";break;case"&":D+="&";break;case'"':D+=""";break;default:D+=B;break}}return D},F=function(P){var D=1;P=typeof P>"u"?D*2:P;var _=N.getModuleCount()*D+P*2,B=P,M=_-P,j,Z,Y,ce,xe,ee={"██":"█","█ ":"▀"," █":"▄"," ":" "},De={"██":"▀","█ ":"▀"," █":" "," ":" "},Ae="";for(j=0;j<_;j+=2){for(Y=Math.floor((j-B)/D),ce=Math.floor((j+1-B)/D),Z=0;Z<_;Z+=1)xe="█",B<=Z&&Z=M?De[xe]:ee[xe];Ae+=` +`}return _%2&&P>0?Ae.substring(0,Ae.length-_-1)+Array(_+1).join("▀"):Ae.substring(0,Ae.length-1)};return N.createASCII=function(P,D){if(P=P||1,P<2)return F(D);P-=1,D=typeof D>"u"?P*2:D;var _=N.getModuleCount()*P+D*2,B=D,M=_-D,j,Z,Y,ce,xe=Array(P+1).join("██"),ee=Array(P+1).join(" "),De="",Ae="";for(j=0;j<_;j+=1){for(Y=Math.floor((j-B)/P),Ae="",Z=0;Z<_;Z+=1)ce=1,B<=Z&&Z>>8),z.push(T&255)):z.push(E)}}return z}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},r={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},a=(function(){var x=[[],[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]],v=1335,$=7973,E=21522,y={},z=function(h){for(var f=0;h!=0;)f+=1,h>>>=1;return f};return y.getBCHTypeInfo=function(h){for(var f=h<<10;z(f)-z(v)>=0;)f^=v<=0;)f^=$<5&&(T+=3+G-5)}for(var S=0;S=256;)y-=255;return x[y]},E})();function s(x,v){if(typeof x.length>"u")throw x.length+"/"+v;var $=(function(){for(var y=0;y"u")throw"bad rs block @ typeNumber:"+y+"/errorCorrectionLevel:"+z;for(var f=h.length/3,T=[],S=0;S>>7-E%8&1)==1},$.put=function(E,y){for(var z=0;z>>y-z-1&1)==1)},$.getLengthInBits=function(){return v},$.putBit=function(E){var y=Math.floor(v/8);x.length<=y&&x.push(0),E&&(x[y]|=128>>>v%8),v+=1},$},d=function(x){var v=e.MODE_NUMBER,$=x,E={};E.getMode=function(){return v},E.getLength=function(h){return $.length},E.write=function(h){for(var f=$,T=0;T+2>>8&255)*192+(S&255),h.put(S,13),T+=2}if(T>>8)},v.writeBytes=function($,E,y){E=E||0,y=y||$.length;for(var z=0;z0&&($+=","),$+=x[E];return $+="]",$},v},g=function(){var x=0,v=0,$=0,E="",y={},z=function(f){E+=String.fromCharCode(h(f&63))},h=function(f){if(!(f<0)){if(f<26)return 65+f;if(f<52)return 97+(f-26);if(f<62)return 48+(f-52);if(f==62)return 43;if(f==63)return 47}throw"n:"+f};return y.writeByte=function(f){for(x=x<<8|f&255,v+=8,$+=1;v>=6;)z(x>>>v-6),v-=6},y.flush=function(){if(v>0&&(z(x<<6-v),x=0,v=0),$%3!=0)for(var f=3-$%3,T=0;T=v.length){if(y==0)return-1;throw"unexpected end of file./"+y}var f=v.charAt($);if($+=1,f=="=")return y=0,-1;if(f.match(/^\s$/))continue;E=E<<6|h(f.charCodeAt(0)),y+=6}var T=E>>>y-8&255;return y-=8,T};var h=function(f){if(65<=f&&f<=90)return f-65;if(97<=f&&f<=122)return f-97+26;if(48<=f&&f<=57)return f-48+52;if(f==43)return 62;if(f==47)return 63;throw"c:"+f};return z},k=function(x,v){var $=x,E=v,y=new Array(x*v),z={};z.setPixel=function(S,N,G){y[N*$+S]=G},z.write=function(S){S.writeString("GIF87a"),S.writeShort($),S.writeShort(E),S.writeByte(128),S.writeByte(0),S.writeByte(0),S.writeByte(0),S.writeByte(0),S.writeByte(0),S.writeByte(255),S.writeByte(255),S.writeByte(255),S.writeString(","),S.writeShort(0),S.writeShort(0),S.writeShort($),S.writeShort(E),S.writeByte(0);var N=2,G=f(N);S.writeByte(N);for(var q=0;G.length-q>255;)S.writeByte(255),S.writeBytes(G,q,255),q+=255;S.writeByte(G.length-q),S.writeBytes(G,q,G.length-q),S.writeByte(0),S.writeString(";")};var h=function(S){var N=S,G=0,q=0,V={};return V.write=function(R,J){if(R>>>J)throw"length over";for(;G+J>=8;)N.writeByte(255&(R<>>=8-G,q=0,G=0;q=R<0&&N.writeByte(q)},V},f=function(S){for(var N=1<>6,128|i&63):i<55296||i>=57344?r.push(224|i>>12,128|i>>6&63,128|i&63):(a++,i=65536+((i&1023)<<10|o.charCodeAt(a)&1023),r.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return r}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof Yo=="object"&&(Zo.exports=n())})(function(){return Vo})});function jn(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>jn(o,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,o){let r=window.E,a=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!a&&o===void 0?r(n,{},jn(e,[])):r(n,a?e:{},jn(o,[]))}var Lo={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',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 At(n,e="dl-icon"){let o=Lo[n]??Lo.phone;return``}function b(n,e="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=At(n,e),o}function U(n,e="info",o=0){let r=document.querySelector(".dl-toasts");r||(r=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(r));let a=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=t("div",{class:`dl-toast ${e}`},[a?b(a):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":"Close",click:i},b("x")):""]);r.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,o||(e==="error"?8e3:e==="warning"?5e3:2600))}function be(n){return n instanceof Error?n.message:String(n)}async function W(n,e){try{let o=await n();return e&&U(e,"success",3500),o}catch(o){U(be(o),"error",1e4);return}}function Mo(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(o=>U(be(o),"error"))}catch(e){U(be(e),"error")}}function To(n){if(n&&typeof n=="object"){if(typeof n.error=="string")throw new Error(n.error);typeof n.warning=="string"&&n.warning&&U(n.warning,"warning",12e3)}return n}function K(n,e=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:e});return async(...r)=>To(await o(...r))}var oi=K("logs_clear",["person","device","category","older_days"]),ri=(n={})=>oi(n.person??"",n.device??"",n.category??"",n.older_days??""),ai=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","server"]});async function ii(n,e){let r=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(a=>e[a]),e.paused,e.services,e.circle,e.home_nets,e.server];return To(await ai(...r))}var si=K("status",["days"]),A={rev:K("rev"),personUpdate:ii,settingsGet:K("settings_get"),portalInfo:K("portal_info"),settingsUpdate:K("settings_update",["values"]),serviceSet:K("service_set",["id","name","address","ports"]),serviceDelete:K("service_delete",["id"]),geoClear:K("geo_clear"),events:K("events",["limit","person","since"]),logsClear:ri,interfaces:K("interfaces",["id"]),serverInterfaces:K("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:K("circle_set",["id","server","name","color","members"]),circleDelete:K("circle_delete",["id"]),accessCheck:K("access_check",["from","to"]),homeHosts:K("home_hosts",["id"]),usageClear:K("usage_clear",["scope","id"]),uninstall:K("uninstall",["confirm"]),status:si,setupDefaults:K("setup_defaults"),serverCreate:K("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:K("server_obfuscation",["id","preset"]),serverUpdate:K("server_update",["id","values"]),serverPorts:K("server_ports",["id"]),endpointProbe:K("endpoint_probe",["host","id","port"]),serverDelete:K("server_delete",["id"]),personLinks:K("person_links",["id"]),personCreate:K("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:K("person_pause",["id","paused"]),personRegen:K("person_regen",["id","remove"]),personDelete:K("person_delete",["id"]),personUsage:K("person_usage",["id","days"]),deviceCreate:K("device_create",["person","name","kind"]),deviceConfig:K("device_config",["id"]),deviceUpdate:K("device_update",["id","name","disabled"]),deviceDelete:K("device_delete",["id"]),deviceRotate:K("device_rotate",["id"]),apply:K("apply"),health:K("health"),healthFix:K("health_fix",["id"]),serviceLog:K("service_log"),serviceLogClear:K("service_log_clear",["older_days"]),backupList:K("backup_list"),backupCreate:K("backup_create"),backupRestore:K("backup_restore",["name"]),backupDelete:K("backup_delete",["name"]),backupRead:K("backup_read",["name"]),backupUpload:K("backup_upload",["data"]),exportJson:K("export"),importJson:K("import",["data"]),updatesStatus:K("updates_status"),updatesRun:K("updates_run",["what"]),updatesReleases:K("updates_releases",["page"]),updatesNotes:K("updates_notes",["component","tag","build"]),updatesChanges:K("updates_changes",["from","to"])};function H(n,e,o="neutral",r={}){let{disabled:a,...i}=r,s=t("button",{class:`cbi-button cbi-button-${o}`,type:"button",...i,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!s.disabled){s.disabled=!0,s.classList.add("spinning");try{await e(l)}catch(c){U(be(c),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!a,s}function Le(n,e,o,r="neutral",a=""){return H([b(n),t("span",{class:"dl-btn-label"},e)],o,r,{title:e,class:`cbi-button cbi-button-${r} dl-icon-btn ${a}`.trim()})}function $e(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var ht=null;function Un(n=!1){let e=ht;ht=null,e?.(n)}function te(n,e,o,r=""){Un();let a=t("div",{class:`dl-modal ${r}`},e),i=t("div",{class:"button-row"},o);a.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),oe();return}if(s.key!=="Enter"||s.shiftKey||s.ctrlKey||s.metaKey||s.altKey)return;let l=s.target;if(!l||["TEXTAREA","BUTTON","SELECT","A"].includes(l.tagName))return;let c=i.querySelector(".cbi-button-positive");!c||c.disabled||(s.preventDefault(),c.click())}),ui.showModal(n,[a,i])}function oe(){Un(),ui.hideModal()}function ae(n="Cancel",e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:oe},n)}function se(n,e,o="Confirm",r=!1){return new Promise(a=>{te(n,e,[ae()," ",t("button",{class:`cbi-button ${r?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=ht;ht=null,ui.hideModal(),i?.(!0)}},o)]),ht=a})}$e(()=>{ht&&(Un(),ui.hideModal())});async function pe(n,e="Copied to clipboard",o=!1){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let r=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(r),r.select();let a=document.execCommand("copy");if(r.remove(),!a)throw new Error("Copying is blocked here. Select the text and copy it by hand.")}return U(e,"success",2500),!0}catch(r){return o||U(be(r),"error"),!1}}function Se(n,e,o="text/plain"){let r=globalThis,a=typeof e=="string"?new r.Blob([e],{type:o}):e,i=URL.createObjectURL(a),s=t("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function Wn(n,e){return new Promise(o=>{let r=t("input",{type:"file",accept:n,style:"display:none"});r.addEventListener("cancel",()=>{r.remove(),o(null)}),r.addEventListener("change",()=>{let a=r.files?.[0];if(r.remove(),!a)return o(null);let i=new FileReader;i.onload=()=>{let s=String(i.result??"");o({name:a.name,data:e==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>o(null),e==="base64"?i.readAsDataURL(a):i.readAsText(a)}),document.body.appendChild(r),r.click()})}function Ce(n,e){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let r=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),Mo(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(r);let a=n.getBoundingClientRect(),i=r.offsetWidth,s=r.offsetHeight;r.style.top=`${a.bottom+6+s>window.innerHeight-8&&a.top-6-s>8?a.top-6-s:a.bottom+6}px`,r.style.left=`${Math.max(8,Math.min(a.right-i,window.innerWidth-i-8))}px`;let l=u=>{!r.contains(u.target)&&!n.contains(u.target)&&p()},c=u=>{if(u.key==="Escape"||u.key==="Tab")return p();let w=[...r.querySelectorAll("button:not([disabled])")];if(!w.length||!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;u.preventDefault();let C=w.indexOf(document.activeElement),g=u.key==="Home"?0:u.key==="End"?w.length-1:u.key==="ArrowDown"?(C+1)%w.length:(C-1+w.length)%w.length;w[g].focus({preventScroll:!0})},d=$e(p);r.dlAnchor=n,r.dlClose=p;function p(){r.remove(),d(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",c,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",c,!0),window.addEventListener("scroll",p,!0)}),r.querySelector("button")?.focus({preventScroll:!0})}var lt=null,Je=null,Gn=0;function ft(){lt&&(lt.style.display="none"),Je=null,clearInterval(Gn),Gn=0}function me(n,e){let o=r=>{lt??(lt=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),lt.replaceChildren(...e().map(a=>typeof a=="string"?document.createTextNode(a):a)),lt.style.display="",lt.style.left=`${r.clientX}px`,lt.style.top=`${r.clientY-10}px`,Je=n,Gn||(Gn=window.setInterval(()=>{(!Je?.isConnected||!Je.getClientRects().length)&&ft()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",ft),n.addEventListener("pointerup",r=>{r.pointerType!=="mouse"&&(Je===n?ft():o(r))})}$e(ft);window.addEventListener("scroll",()=>Je&&ft(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{Je&&!Je.contains(n.target)&&ft()},!0);function X(n){if(!n||n<0)return"0 B";let e=["B","KB","MB","GB","TB"],o=0,r=n;for(;r>=1024&&o=100||o===0?Math.round(r):r.toFixed(1)} ${e[o]}`}function Oe(n){let e=n*8;return e<1e3?`${Math.round(e)} bit/s`:e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)} kbit/s`:e<1e9?`${(e/1e6).toFixed(e<1e7?1:0)} Mbit/s`:`${(e/1e9).toFixed(1)} Gbit/s`}function re(n,e=Date.now()/1e3){if(!n)return"never";let o=Math.max(0,Math.round(e-n));return o<60?"just now":o<3600?`${Math.floor(o/60)} min ago`:o<86400?`${Math.floor(o/3600)} h ago`:o<86400*30?`${Math.floor(o/86400)} d ago`:new Date(n*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function vt(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),o=Math.floor(n%86400/3600),r=Math.floor(n%3600/60);return e?`${e}d ${o}h`:o?`${o}h ${r}m`:`${r}m`}function zt(n){let e=new Date(n*1e3),o=new Date,r=e.toDateString()===o.toDateString(),a=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return r?a:`${e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${a}`}function je(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function bt(n){let[e,o,r]=n.split("-").map(Number);return new Date(e,(o||1)-1,r||1,12)}function Ue(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?bt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Me(n){return n?Ue(n):""}function Fn(n,e){let o=r=>{let[a,i,s]=r.split("-").map(Number);return Date.UTC(a,i-1,s)};return Math.round((o(n)-o(e))/864e5)}function Ht(n,e){let o=bt(n);return o.setDate(o.getDate()+e),je(o)}function gt(n,e){let[o,r,a]=n.split("-").map(Number),i=new Date(o,r-1+e,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(a,s)),je(i)}function Ie(n){return n?.length?n[n.length-1].day:je(new Date)}function So(n,e,o,r,a=30){let i=n||r;return e==="day"?Ht(i,o):e==="week"?Ht(i,7*o):e==="month"?gt(i,o):e==="year"?gt(i,12*o):Ht(i,a*o)}function Ve(n,e=Date.now()){if(!n)return null;let o=typeof e=="number"?je(new Date(e)):e,r=Fn(n,o);return r>=0?r+1:r}function Ye(n,e){return e!=null&&e>0&&n.expire_warn>0&&e<=n.expire_warn}function Xt(n){return n<=1?"ends today":n===2?"ends tomorrow":`ends in ${n} days`}function en(n,e,o=`${e}s`){return`${n.toLocaleString("en-GB")} ${n===1?e:o}`}function Nt(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var dt={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var _o=["computer","phone","tablet","router","other"],Ze={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Po={active:"Active",paused:"Paused",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server",server_off:"Server is turned off"};function He(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let o=e[0][0]??"",r=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(o+r).toUpperCase()}function tn(n){let e=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,r)=>[o,r]).sort((o,r)=>e(o[0])-e(r[0])||o[1]-r[1]).map(([o])=>o)}function Ee(n,e,o){return t("span",{class:`dl-pill ${n}`,title:o??null},e)}function li(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function di(n){return n.state==="server_off"&&n.paused?"paused":n.state}function Do(n){let e=di(n);return e==="active"||e==="server_off"?"":Ee(li({...n,state:e}),Po[e])}function Ao(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=t("span",{class:"dl-access","aria-label":dt[n.access]},e.map(r=>t("span",{class:`dl-ibadge ${r}`},b(r==="lan"?"home":"globe"))));return me(o,()=>[t("div",{class:"dl-tip-title"},dt[n.access]),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),o}var ci={paused:"Paused",expired:"Access ended",quota:"Data limit",hours:"Outside hours",server_off:"Server off",no_server:"No server"};function nn(n,e,o="Not set up yet",r){let a=n.handshake?`Last seen ${re(n.handshake,e)} · ${new Date(n.handshake*1e3).toLocaleString()}`:"";if(n.disabled)return t("span",{class:"dl-dstat",title:a},"Disabled");if(n.online)return t("span",{class:"dl-dstat ok"},"Connected");let i=r&&ci[r.state];return i?t("span",{class:"dl-dstat warn",title:a||"Not connected yet"},i):n.handshake?t("span",{class:"dl-dstat",title:new Date(n.handshake*1e3).toLocaleString()},`Last seen ${re(n.handshake,e)}`):t("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},o)}var on=null;function Ho(n,e,o,r){on?.close();let a=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>d()},b("x"))]),t("div",{class:"dl-drawer-body"},e),o?t("div",{class:"dl-drawer-foot"},o):""]),i=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===i&&d()}},a),s=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&d()},l=!1,c=$e(()=>d());function d(){l||(l=!0,c(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),on===p&&(on=null),r())}let p={close:d,panel:a};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),on=p,p}function de(n,e,o){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),o?t("span",{class:"dl-sub"},o):""]),t("div",{class:"dl-setrow-ctl"},e)])}function fe(n,e,o,r=e){let a=de(n,r," "),i=a.querySelector(".dl-sub"),s=()=>{let l=o();i.textContent=l.text,i.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),a.refresh=s,a.help=o,s(),a}function ye(n,e,o,r=e){let a=t("div",{class:"dl-sub"}),i=t("div",{class:"cbi-value dl-live"},[t("div",{class:"cbi-value-title"},[t("label",{},n),a]),t("div",{class:"cbi-value-field"},r)]),s=()=>{let l=o();a.textContent=l.text,a.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),e.addEventListener("change",s),i.refresh=s,i.help=o,s(),i}function ze(n,e=[]){for(let o of n){let r=o.help?.();if(r?.bad)return r.text}for(let o of e){let r=o();if(r.bad)return r.text}return null}function Rt(n,e,o,r=""){return t("section",{class:`dl-setsec ${r}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function ge(n,e,o,r){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},b(n)),t("span",{class:"dl-stack"},[t("b",{},e),o?t("span",{class:"dl-sub"},o):""])]),t("div",{class:"dl-group-body"},r.filter(a=>a!==""))])}function Qe(n,e,o,r,a){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},b(n)):b(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-sub"},r)]),a])}function ct(n,e){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${o}`},e)}function Xe(n,e=""){let o=t("div",{class:e});return o.innerHTML=n,o}function qn(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[o,r,a,i]=e.slice(1,5).map(Number),s=Number(e[5]);if([o,r,a,i].some(d=>d>255)||s<8||s>30)return null;let l=o*2**24+r*2**16+a*2**8+i,c=2**(32-s);return{net:l-l%c,size:c}}var pi=(n,e)=>n.netqn(n));function yt(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function rn(n){return`${n.trim()}.0/24`}function Jn(n,e,o){let r=n.trim(),a=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(r)?qn(rn(r)):null;if(!a)return{text:"Three numbers, like 10.77.0.",bad:!0};if(!mi.some(s=>a.net>=s.net&&a.net+a.size<=s.net+s.size))return{text:"Use a private range: 10.x.x, 172.16–31.x or 192.168.x.",bad:!0};let i=e.find(s=>{let l=qn(s.cidr);return l!=null&&pi(a,l)});if(i){let s=i.cidr.endsWith("/24")?`${yt(i.cidr)}.x`:i.cidr,l=o&&o!==r?` Try ${o}.`:"";return{text:`${i.name} already uses ${s}.${l}`,bad:!0}}return{text:`Devices get ${r}.2 – ${r}.254, the router ${r}.1.`,bad:!1}}var No=(n,e)=>e.find(o=>o.from<=n&&n<=o.to)?.who??null,hi=n=>Number.isInteger(n)&&n>=1&&n<=65535;function It(n,e,o){if(!hi(n))return{text:"Use a port from 1 to 65535.",bad:!0};let r=No(n,e);return r?{text:`Used by ${r}. Choose another port.`,bad:!0}:{text:o,bad:!1}}function an(n,e,o){let r=o?`HTTPS here, plain HTTP for links on IP addresses on ${n+1}.`:"HTTPS on this port, opened on WAN.",a=It(n,e,r);if(a.bad||!o)return a;if(n===65535)return{text:"Links on IP addresses also need the next port: choose a lower one.",bad:!0};let i=No(n+1,e);return i?{text:`Links on IP addresses also need ${n+1}, used by ${i}. Choose another port.`,bad:!0}:a}var xt=n=>Array.from(n).length,zo=48,fi=/[<>"\\\u0000-\u001f\u007f]/;function _e(n,e=[],o=""){let r=n.trim();return r?xt(n)>zo?{text:`Up to ${zo} characters (${xt(n)} now).`,bad:!0}:fi.test(n)?{text:'Names can’t contain < > " or \\.',bad:!0}:e.some(a=>a.toLowerCase()===r.toLowerCase())?{text:`“${r}” already exists — pick another name.`,bad:!0}:{text:o,bad:!1}:{text:"Enter a name.",bad:!0}}function Ro(n,e=[]){return xt(n)>32?{text:`Up to 32 characters (${xt(n)} now).`,bad:!0}:_e(n,e,"Shown on the person cards.")}var gi=/^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,vi=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function kt(n){let e=vi.exec(n);return!!e&&e.slice(1).every(o=>Number(o)<=255)}function Kn(n){return/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(n)&&!/:::/.test(n)}function wt(n,e,o=null){let r=n.trim();if(!r)return o!=null?{text:o,bad:!1}:{text:"Enter a hostname or IP address.",bad:!0};if(/^[a-z]+:\/\//i.test(r))return{text:"Leave out https:// — just the name.",bad:!0};if(/\/.*/.test(r))return{text:"Just the name, without a path.",bad:!0};if(/^[^:\[]+:\d+$/.test(r))return{text:"Just the name, without a port (the port is on AmneziaWG).",bad:!0};if(/\s/.test(r))return{text:"A hostname has no spaces.",bad:!0};if(r.length>253||!(gi.test(r)||kt(r)||Kn(r)))return{text:"Use a hostname or an IP address.",bad:!0};let a=Kn(r)?`[${r}]`:r;return{text:e?`Devices connect to ${a}:${e}.`:`Links use ${a}.`,bad:!1}}function Io(n,e){let o=n.split(/[ ,]+/).filter(Boolean);if(!o.length)return{text:`This router (${e}): queries go where your home network sends them, and home names work.`,bad:!1};let r=o.find(a=>!kt(a)&&!Kn(a));return r?{text:`“${r}” is not an IP address. Separate several with commas.`,bad:!0}:{text:`Devices use ${o.join(" and ")} — home names and your LAN’s DNS filters no longer apply to them.`,bad:!1}}function Bo(n,e){let o=n.trim();if(!o)return{text:`Automatic by device type and disguise: ${e.computer} for computers and routers, ${e.phone} for phones and tablets.`,bad:!1};if(!/^\d{1,4}$/.test(o)||Number(o)<1280||Number(o)>1500)return{text:"MTU must be 1280–1500, or empty for automatic.",bad:!0};let r=Number(o);return{text:`Computers and routers get ${r}, phones and tablets ${Math.min(r,1280)}.`,bad:!1}}function Oo(n){let e=n.trim();return e?!/^\d{1,3}$/.test(e)||Number(e)>600?{text:"Use 0–600 seconds.",bad:!0}:Number(e)===0?{text:"Off: NAT may close the tunnel when idle, and “Connected” lags.",bad:!1}:{text:`Devices send a packet every ${e} s to keep NAT open (a little battery on phones).`,bad:!1}:{text:"Default: a packet every 25 s keeps NAT open and “Connected” accurate.",bad:!1}}function sn(n,e=0){let o=n.trim();if(!/^\d{1,2}$/.test(o)||Number(o)<1||Number(o)>32)return{text:"Use 1–32.",bad:!0};let r=Number(o);return e>r?{text:`Already has ${e} devices: remove ${e-r===1?"one":`${e-r}`} first, or allow more.`,bad:!0}:{text:`They can add ${r} device${r===1?"":"s"} themselves.`,bad:!1}}function ln(n,e=!0){let o=n.trim();if(!o)return{text:"Optional. No data limit.",bad:!1};let r=Number(o);return!/^\d+(\.\d+)?$/.test(o)||r<0||r>1e5?{text:"A number of GB, up to 100000.",bad:!0}:r===0?{text:"Optional. No data limit.",bad:!1}:{text:e?`Paused after ${o} GB this month, resumed on the 1st.`:`Paused after ${o} GB in total.`,bad:!1}}function jo(n,e,o,r){let a=n.trim();if(!a)return{text:"Optional. No end date.",bad:!1};let i=o(a,e);return i==null?{text:"Use a date.",bad:!0}:i<0?{text:"That date has passed: access would end at once.",bad:!0}:{text:i===1?`Access ends today (${r(a)}).`:`Access ends in ${i} days (${r(a)}).`,bad:!1}}function Uo(n,e=null){let o=n.trim();return o?kt(o)?e&&!e(o)?{text:`${o} is not in any home network of this server: nobody would reach it.`,bad:!1}:{text:"",bad:!1}:{text:"Use an IPv4 address, like 192.168.1.10.",bad:!0}:{text:"The device’s address at home.",bad:!0}}function Wo(n){let e=n.split(/[ ,]+/).filter(Boolean);if(!e.length)return{text:"All ports.",bad:!1};let o=e.find(r=>!/^\d{1,5}$/.test(r)||Number(r)<1||Number(r)>65535);return o?{text:`“${o}” is not a port (1–65535).`,bad:!0}:{text:`Port${e.length===1?"":"s"} ${e.join(", ")}.`,bad:!1}}function Go(n){let e=n.trim();return e?/^https?:\/\//i.test(e)?e.length>300||!/^https?:\/\/[A-Za-z0-9.-]+(:[0-9]+)?(\/[^\s"'<>]*)?$/.test(e)?{text:"Not a usable address (no spaces or quotes).",bad:!0}:{text:"Wrong links are sent there instead of a “Not found”.",bad:!1}:{text:"Must start with http:// or https://.",bad:!0}:{text:"Wrong links get a bare “Not found”.",bad:!1}}function Fo(n){return xt(n)>64?{text:`Up to 64 characters (${xt(n)} now).`,bad:!0}:/[\u0000-\u001f\u007f]/.test(n)?{text:"One line, please.",bad:!0}:{text:"Shown in the browser tab and at the top of the portal.",bad:!1}}function qo(n,e="phone.myata"){let o=n.trim();return o?/^[a-z0-9-]{1,32}(\.[a-z0-9-]{1,32})*$/.test(o)?{text:`Devices get names like ${e}.${o}.`,bad:!1}:{text:/[A-Z]/.test(o)?"Lowercase only.":"Lowercase letters, digits, dashes and dots.",bad:!0}:{text:`The default, lan: devices get names like ${e}.lan.`,bad:!1}}function Ko(n){let e=n.trim();return e?kt(e)?{text:`${e} takes over when the tunnel is down.`,bad:!1}:{text:"Use an IPv4 address, or leave it empty.",bad:!0}:{text:"None: without the tunnel those devices have no DNS.",bad:!1}}function Jo(n){let e=n.trim();return/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{text:`Runs within an hour after ${e} (router time).`,bad:!1}:{text:"Use HH:MM, 00:00–23:59.",bad:!0}}function Vn(n,e,o,r={}){let a=0,i="",s=null;return{help:()=>{let{host:d,port:p}=n(),u=wt(d,p,r.empty??null);if(u.bad||!d.trim())return u;if(s&&s.host===d.trim())return{text:s.text,bad:s.bad};let w=r.idle?.();return{text:w?`${w} Checking where it points…`:`${u.text} Checking where it points…`,bad:!1}},schedule:()=>{let{host:d}=n(),p=wt(d,n().port,r.empty??null);p.bad||!d.trim()||d.trim()===s?.host||(clearTimeout(a),a=window.setTimeout(async()=>{let u=d.trim();i=u;try{let{id:w,port:C}=n(),g=await e(u,w,C);if(i!==u)return;s={host:u,text:g.text,bad:g.status==="error"}}catch{if(i!==u)return;s={host:u,text:p.text,bad:!1}}o()},700))}}}var er=ni(Qo(),1),bi=n=>``,Xo="#0a0a0a",Yn="#f2f2f2",xi=n=>n.length>300,$t=n=>+n.toFixed(2);function Zn(n,e,o,r,a){return`M${$t(n+a)} ${$t(e)}h${$t(o-2*a)}a${a} ${a} 0 0 1 ${a} ${a}v${$t(r-2*a)}a${a} ${a} 0 0 1 -${a} ${a}h-${$t(o-2*a)}a${a} ${a} 0 0 1 -${a} -${a}v-${$t(r-2*a)}a${a} ${a} 0 0 1 ${a} -${a}z`}function Ct(n,e=3,o=!0,r="plain"){let a=xi(n),i=r==="night",s=(0,er.default)(0,a?"L":"H");s.addData(n,"Byte"),s.make();let l=s.getModuleCount(),c=l+e*2,d=o&&!a?Math.round(l*.22):0;d&&(l-d)%2&&d++;let p=(l-d)/2,u=p+d,w=(x,v)=>d>0&&x>=p&&x=p&&vi&&(v<7&&x<7||v<7&&x>=l-7||v>=l-7&&x<7),g="";if(i){let x=a?.48:.42;for(let v=0;v${bi(i?Xo:"#fff")}`}let I=``;return i?`${I}${k}`:`${I}${k}`}var wi={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",expiring:"people",expired_kept:"people",portal_blocked:"problems"},Et=["connections","people","problems"],pt={connections:"Connections",people:"People",problems:"Problems"},tr={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)"},Bt=n=>wi[n]??"problems",Ot={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},yi=["person_added","person_removed","person_changed"];function Ne(n){return n.by?n.by:yi.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function nr(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var dn=n=>n.sys?["error","repair","down"].includes(n.sys.level):Bt(n.ev.type)==="problems";function cn(n){let e=n.keep_days>0?`${n.keep_days} day${n.keep_days===1?"":"s"}`:"no age limit",o=n.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${n.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${e}, up to ${n.max.toLocaleString("en-GB")} events, ${o}.`}function or(n,e=120,o=26,r=je(new Date)){let a=Math.max(1,...n),i=t("div",{class:"dl-spark"});return i.style.width=`${e}px`,i.style.height=`${o}px`,n.forEach((s,l)=>{let c=t("i");c.style.height=`${Math.max(6,s/a*100)}%`,s||c.classList.add("zero");let d=n.length-1-l;me(c,()=>[t("div",{class:"dl-tip-title"},d===0?"Today":d===1?"Yesterday":bt(Ht(r,-d)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},X(s))]),i.appendChild(c)}),i}function ki(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function rr(n,e){return[n.join(","),...e.map(o=>n.map(r=>ki(o[r])).join(","))].join(` +`)}function $i(n){let e=new Map(n.people.map(r=>[r.id,r.name])),o=new Map(n.people.flatMap(r=>r.devices.map(a=>[a.id,a.name])));return{people:e,devices:o}}function Fe(n,e,o,r="",a=[]){let i=$i(n),s=[...e.map(p=>({ts:p.ts,category:Bt(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:Ne(p)??""})),...a.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?` +${p.detail}`:""}`,where:Ot[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),l=new Date().toISOString().slice(0,10),c=`dawnline-activity${r?`-${r}`:""}-${l}.${o}`;if(o==="json"){Se(c,JSON.stringify(s,null,2),"application/json");return}Se(c,rr(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var Ci=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],ar=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function et(n,e,o,r,a,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...Et.map(c=>t("option",{value:c,selected:c===a?"selected":null},pt[c])),i?t("option",{value:"system",selected:a==="system"?"selected":null},"System"):""]),l=t("select",{class:"cbi-input-select"},Ci.map(([c,d])=>t("option",{value:c},d)));te(n,[t("p",{class:"dl-muted"},`${e} This cannot be undone; export first if you want a copy.`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Category"),s]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Which events"),l])],[ae()," ",H("Clear",async()=>{let c=0;if(s.value!=="system")try{c+=(await A.logsClear({...o,category:s.value,older_days:l.value})).removed}catch(d){U(be(d),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{c+=(await A.serviceLogClear(l.value)).removed}catch(d){oe(),U(`${s.value==="system"?"":`Activity: ${ar(c).toLowerCase()}. `}The service log was not cleared: ${be(d)}`,"error",1e4),r();return}oe(),U(ar(c),"success",3e3),r()},"negative")])}function Lt(n,e,o,r){let a=n==="device"?`Clears ${o}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${o}'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.";te(n==="all"?"Reset all traffic history?":`Reset traffic history for ${o}?`,[t("p",{class:"dl-muted"},a)],[ae()," ",H("Reset",async()=>{await W(()=>A.usageClear(n,e),"Traffic history reset")&&(oe(),r())},"negative")])}function ve(n,e,o){let r=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let a=!r.classList.contains("on");Qn(r,a),o?.(a)}},t("i"));return r}function Qn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var Pe=n=>n.classList.contains("on");function we(n,e,o={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let r=t("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":e}),a=()=>r.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===r.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)r.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==r.dataset.value&&(o.optimistic!==!1&&(r.dataset.value=i,a()),o.onChange?.(i))}},s));return a(),r}function qe(n,e,o,r={}){return t("button",{type:"button",...r,class:`dl-chipbtn${e?" on":""}${r.class?` ${r.class}`:""}`,"aria-pressed":e?"true":"false",click:o},n)}function pn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function ie(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var Ei={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:""},Li={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 Mi(n){let e={};for(let[o,r]of Object.entries(Li))n[o]!=null&&n[o]!==""&&(e[r]=String(n[o]));return e}function Ti(n,e){let o=n.amnezia,r=o.obfuscation??{},a=c=>r[c]!=null&&r[c]!==""?String(r[c]):Ei[c],i=o.host.replace(/^\[(.*)\]$/,"$1"),s={H1:a("h1"),H2:a("h2"),H3:a("h3"),H4:a("h4"),I1:a("i1"),I2:a("i2"),I3:a("i3"),I4:a("i4"),I5:a("i5"),Jc:a("jc"),Jmin:a("jmin"),Jmax:a("jmax"),S1:a("s1"),S2:a("s2"),S3:a("s3"),S4:a("s4"),...Mi(r),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r +`),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(o.port),protocol_version:r.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function Si(n){let e="";for(let o=0;o"u")return null;try{let o=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),r=new Uint8Array(await new e.Response(o).arrayBuffer()),a=new Uint8Array(4+r.length);return new DataView(a.buffer).setUint32(0,n.length,!1),a.set(r,4),a}catch{return null}}async function Xn(n,e,o=!0){let r=new TextEncoder().encode(JSON.stringify(Ti(n,e))),a=o?await _i(r):null;return`vpn://${Si(a??r)}`}var sr=[{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:"balanced",title:"Balanced",ic:"shield",stealth:3,speed:4,needs:"v2",text:"AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.",apps:"AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps",short:"AmneziaWG 2.0+ apps"},{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"}],jt=n=>sr.find(e=>e.id===n),un=n=>n.v3?"max":n.v2?"balanced":"off",Ut=n=>n==="standard"?"Standard (old)":n==="strong"?"Strong (old)":null,Pi={v2:"Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},Di={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function ir(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>t("i",{class:odom.content(i,sr.map(l=>{let c=!l.needs||n[l.needs],d=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":d?"true":"false","aria-disabled":c?null:"true",class:`dl-method${d?" on":""}${c?"":" off"}`,click:()=>{!c||d||(e=l.id,s(),o(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},b(l.ic)),t("b",{},l.title),l.id===r?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[ir(l.stealth,"Stealth"),ir(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},c?[b(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[b("alert"),t("span",{},(a?Pi:Di)[l.needs])])])}));return s(),i}function lr(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var dr=[["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 Ai(n){let e=d=>n[d]!=null&&n[d]!=="",o=dr.filter(([d])=>e(d));if(!o.length)return null;let r=(d,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},d==="header_protection_key"?`${n[d].slice(0,6)}••••`:n[d])]),a=(d,p,u,w)=>{let C=dr.filter(([g])=>w.includes(g)&&e(g));return C.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[b(p),t("b",{},d)]),t("p",{},u),t("div",{class:"dl-pvals"},C.map(([g,m])=>r(g,m)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=o.map(([d,p])=>`${p} = ${n[d]}`).join(` +`),c=t("div",{class:"dl-pgrid"},[a("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),a("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),a("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),a("Signatures","globe",s,["i1","i2","i3","i4","i5"]),a("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"]),a("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 t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(o.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:d=>{d.preventDefault(),pe(l,"Parameters copied")}},"Copy as config")]),c])}function cr(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let r=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},o[1])," ",r&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function Hi(n){let e=!1,o=t("pre",{class:"dl-conf"}),r=()=>dom.content(o,n.conf.split(` `).flatMap((s,l)=>l?[` -`,_o(s,e)]:[_o(s,e)])),r=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(r,[v(e?"x":"key"),e?"Hide key":"Show key"]),a()}},[v("key"),"Show key"]);a();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),D([v("download")," Download"],()=>Le(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),r,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),ue(n.conf,"Configuration copied")}},[v("copy"),"Copy"])]),o])])}async function Kr(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await An(n,`${n.server} · ${n.person} · ${n.name}`),a={qr:()=>t("div",{class:"dl-qr-pane"},[qe(ft(n.conf),"dl-qr"),t("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},o),D("Copy",()=>ue(o,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>qr(n)},r=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(c=>c.classList.toggle("on",c.dataset.id===l)),dom.content(r,a[l]())};for(let[l,c]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},c));return s(e),t("div",{class:"dl-stack gap12"},[i,r])}async function Jr(n,e,o,a){let r=Pt(o),s=n.st.people.filter(c=>c.server===e.id).reduce((c,d)=>c+d.devices.length,0);await re(a?"Generate new disguise values?":`Switch to ${r.title}?`,`${s} AmneziaWG device${s===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${o==="max"?" They need an app with AmneziaWG 3.1.":o==="balanced"?" They need an app with AmneziaWG 2.0 or newer.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await W(()=>P.serverObfuscation(e.id,o),a?"New values applied":`${r.title} applied`)&&(F("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function Vr(n,e){let o=n.st,a=se(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=se(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=`${e.mtus.computer} for computers and routers, ${e.mtus.phone} for phones and tablets`,s=e.mtu?`Now ${i}. Empty = automatic.`:`Automatic by device type and disguise: now ${i}. Lower it if some sites hang.`,l=se(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),c=Pt(e.preset)?e.preset:void 0,d=c??"standard",p=D("",()=>Jr(n,e,d,d===c),"neutral"),u=()=>dom.content(p,d===c?[v("reset")," Generate new values"]:[`Switch to ${Pt(d).title}`]);u();let w=o.awg_state?.tools!==!1;return Tt("",[So("AmneziaWG",e.ifname),he("globe","Listening","Where devices reach this core from the internet",[ne("UDP port",a,"Opened on the WAN firewall automatically.")]),he("file","In every device configuration","Changing these marks devices “Update config” until they import again",[ne("MTU",r,s),ne("Keep-alive",l,"Seconds between packets devices send to keep NAT open. 0 = off.")]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Qt(o.awg,d,g=>{d=g,u()},c,w),w&&!o.awg.v3?ht("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",Fr(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),p])]),t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ne("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ne("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),ne("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),D([v("copy")],()=>ue(e.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),D("Save",()=>n.save({port:a.value,mtu:r.value,keepalive:l.value},"AmneziaWG saved"),"positive")])}function Yr(n){let e=Pt(n.preset),o=n.obf??{},a=(s,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(c=>t("i",{class:c+o[s]).map(s=>`${s.toUpperCase()} ${o[s]}`);return i.length&&r.push(i.slice(0,2).join(" · ")+(i.length>2?` +${i.length-2}`:"")),["h1","h2","h3","h4"].some(s=>o[s]&&o[s]!==String(["h1","h2","h3","h4"].indexOf(s)+1))&&r.push("H1–H4 random"),o.i1&&r.push(/0x(8580|0100)0001/.test(o.i1)?"DNS-like first packets":"Signature packets"),o.header_protection_key&&r.push("Encrypted headers"),r.length||r.push(e?.id==="off"?"Plain WireGuard":"No values yet"),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Disguise"),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),t("div",{class:"dl-disg-id"},[t("span",{class:"dl-disg-ic"},v(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:"Custom"),t("span",{class:"dl-sub"},e?e.short:"Set by hand")])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},"Stealth"),a(e.stealth,"acc"),t("span",{},"Speed"),a(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},r.map(s=>t("span",{},s)))])}var zn={id:"awg",label:"AmneziaWG",settingsCard:Vr,overviewTile:Yr,connectBlock:Kr,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>An(n,`${n.server} · ${n.person} · ${n.name}`)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var Zr={awg:zn};function Ie(n){return Zr[n?.core||"awg"]??zn}function bt(n,e){return Ie(n.find(o=>o.id===e))}var Qr=2,Dt=new Set,Nn=null,Xt=null;async function Co(){if(document.visibilityState!=="visible"||!Dt.size)return;let n=await P.rev().catch(()=>null);if(!n)return;let e=Nn!=null&&n.rev!==Nn;Nn=n.rev,n.version&&(Xt&&n.version!==Xt?(F(`Dawnline was updated to ${n.version}: reload the page.`,"warning",15e3),Xt=null):Xt??(Xt=n.version)),e&&Dt.forEach(o=>o())}function en(n){return Dt.add(n),poll.add(Co,Qr),()=>{Dt.delete(n),Dt.size||poll.remove(Co)}}var Hn="https://unpkg.com/maplibre-gl@6.14.0/dist",Po={module:"sha384-q26X6R1yFeg0QR9SHHn6U3Nb0ddRRTtwxsahubv5R89/v5nijKpk9KviUp9ZLySk",css:"sha384-1TZtfVz7qtwR5vD7cMwjGT+9uiK4lqE3pbUOPwYO6OCpb+TYP0S9vLIhG02JCU04"},Do="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",Ao="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",Xr={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},At=null;function ei(n){if(n.appendChild(t("link",{rel:"stylesheet",href:`${Hn}/maplibre-gl.css`,integrity:Po.css,crossorigin:"anonymous"})),At)return At;let e=`${Hn}/maplibre-gl.mjs`;return At=new Promise((a,r)=>{let i=t("link",{rel:"modulepreload",href:e,integrity:Po.module,crossorigin:"anonymous"});i.addEventListener("load",()=>a()),i.addEventListener("error",()=>r(new Error("integrity"))),document.head.appendChild(i)}).then(()=>import(e)).then(a=>(a.getWorkerUrl()||a.setWorkerUrl(`${Hn}/maplibre-gl-worker.mjs`),a),a=>{throw At=null,new Error(a?.message==="integrity"?"The map library from the CDN is not the expected file: not loading it.":"Could not load the map library (no internet access from this browser?)")}),At}function tn(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}var ti=10,zo=30,ni=62,No=4.5,oi=7,Rn="#3b82f6",nn="#8a8a8a";function Ho(n,e,o=.2,a=64){let[r,i]=n,[s,l]=e,c=s-r,d=c>180?s-360:c<-180?s+360:s,p=d-r,u=l-i,w=Math.hypot(p,u);if(w===0||o===0)return[n,[d,l]];let g=-u/w,m=p/w,k=w*o,N=(r+d)/2+g*k,B=(i+l)/2+m*k,E=[],y=Math.max(2,Math.floor(a));for(let S=0;S<=y;S+=1){let b=S/y,x=1-b;E.push([x*x*r+2*x*b*N+b*b*d,x*x*i+2*x*b*B+b*b*l])}return E}function In(n,e){let o=new Map;for(let a of n.geo.points){if(n.person&&a.person!==n.person||n.device&&a.device!==n.device||(e==="online"?!a.online:n.now-a.ts>Xr[e]))continue;let r=n.device?`${a.city}|${a.cc}`:n.person?`${a.device}|${a.city}|${a.cc}`:a.device,i=o.get(r);(!i||a.online&&!i.online||a.online===i.online&&a.ts>i.ts)&&o.set(r,a)}return[...o.values()]}function Bn(n,e){let o=0;return In(n,e).sort((a,r)=>Number(r.online)-Number(a.online)||r.ts-a.ts).map(a=>({...a,n:a.online?0:++o}))}var Je=class{constructor(e,o="online",a=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.piles=new Map;this.dock=null;this.dockKey="";this.dockQuiet=!1;this.piledKeys=new Set;this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.range=o,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${a}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await ei(this.el)}catch(a){this.status.textContent=a.message;return}this.map=new this.gl.Map({container:this.el,style:tn()?Do:Ao,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let a=this.el.querySelector(".maplibregl-ctrl-attrib");a?.classList.remove("maplibregl-compact-show"),a?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let o=tn();this.theme=new MutationObserver(()=>{!this.map||tn()===o||(o=tn(),this.map.setStyle(o?Do:Ao))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),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"],Rn,nn],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],Rn,nn],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-trail",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-trail",type:"line",source:"dl-trail",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":nn,"line-width":1.5,"line-opacity":.85,"line-dasharray":[0,2.5]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?Rn:nn,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dropCard();for(let e of this.piles.values())e.marker.remove();this.piles.clear(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let o=new Map;for(let a of e){let r=`${a.person}|${a.city||`${a.lat.toFixed(1)},${a.lon.toFixed(1)}`}|${a.cc}`,i=o.get(r);i||(i={key:r,person:a.person,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:[]},o.set(r,i)),i.points.push(a),i.online||(i.online=a.online),i.ts=Math.max(i.ts,a.ts)}return[...o.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,o=this.groups(In(e,this.range)),a=e.person||e.device?null:e.geo.home;for(let d of this.markers)d.remove();this.markers=[];let r=e.person||e.device?null:ri(o,a),i=o.map(d=>({g:d,at:r?.get(d.key)??[d.lon,d.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:d})=>({type:"Feature",properties:{online:d.online,key:d.key},geometry:{type:"Point",coordinates:[d.lon,d.lat]}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?i.map(({g:d,at:p})=>({type:"Feature",properties:{online:d.online,person:d.person,key:d.key},geometry:{type:"LineString",coordinates:Ho([a.lon,a.lat],p)}})):[]}),a){let d=t("span",{class:"dl-mk-host"});d.innerHTML=`${$t("server","dl-mk-host-ic")}`,this.dock=d.appendChild(t("span",{class:"dl-mk-dock"})),this.dockQuiet=this.dockKey!=="",this.dockKey="";let p=t("div",{class:"dl-mk-hub",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`},[d,t("span",{class:"dl-mk-label chip"},a.city||"Home")]);p.addEventListener("mouseenter",()=>this.showMerged(a.city||"the server")),p.addEventListener("mouseleave",()=>this.focus(this.focused)),p.addEventListener("click",()=>this.zoomToMerged()),this.add(p,[a.lon,a.lat],!0)}let s=e.device?[...i].sort((d,p)=>Number(d.g.online)-Number(p.g.online)||d.g.ts-p.g.ts):[];this.map.getSource("dl-trail")?.setData({type:"FeatureCollection",features:s.length>1?[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:s.slice(1).flatMap((d,p)=>Ho(s[p].at,d.at))}}]:[]});let l=new Map(e.device?Bn(e,this.range).map(d=>[`${d.city}|${d.cc}`,d.n]):[]);this.people=[];for(let{g:d,at:p}of i){let u=d.points.length,w=e.people.find(N=>N.id===d.person);if(e.person){let N=e.device?this.stepMarker(d,p,w,l.get(`${d.points[0].city}|${d.points[0].cc}`)??0):this.placeMarker(d,p,w);this.add(N,p);continue}let g=d.points.map(N=>w?.devices.find(B=>B.id===N.device)?.kind??"other"),m=t("span",{class:"dl-mk-badge"});m.innerHTML=u<=2?g.map(N=>$t(N,"dl-mk-badge-ic")).join(""):String(u);let k=t("button",{type:"button",class:`dl-mk${d.online?" online":""}`,"aria-label":`${w?.name??"Someone"}: ${u} device${u===1?"":"s"} in ${d.city||"an unknown city"}`},[t("span",{class:"dl-mk-av"},[Pe(w?.name??"?"),m]),t("span",{class:"dl-mk-label below"},d.city||d.cc||"?")]);k.addEventListener("mouseenter",()=>this.focus(d.person)),k.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:k,person:d.person}),k.addEventListener("click",N=>{N.stopPropagation(),this.openPopup(d,p,k)}),this.add(k,p,!1,w?.name??"Someone",`${d.city||d.cc||"?"} · ${d.online?"now":ie(d.ts,e.now)}`,d.key,d)}this.declutter();let c=i.map(d=>d.g.key).sort().join(";");if(c!==this.fitKey&&!this.popup){let d=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=c,this.fitted=!0,a&&!i.length){let p={center:[a.lon,a.lat],zoom:12};d?this.glide(12,()=>this.map.flyTo({...p,duration:1200})):this.map.jumpTo(p)}else{let p=i.map(u=>u.at);a&&(p.length===0||this.range!=="online"||i.some(u=>u.g.online))&&p.push([a.lon,a.lat]),this.fit(p,d)}}this.status.textContent=i.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(d=>d.person===this.focused)?this.focused:null)}add(e,o,a=!1,r,i,s,l){s&&this.foldedKeys.has(s)&&e.classList.add("merged"),s&&this.piledKeys.has(s)&&e.classList.add("piled"),e.dataset.key=s??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let c=new this.gl.Marker({element:e}).setLngLat(o).addTo(this.map);this.markers.push(c),this.slots.push({marker:c,el:e,at:o,fixed:a,who:r,where:i,g:l})}declutter(){if(!this.map)return;let e=this.map.getZoom();this.el.classList.toggle("dl-lod-far",e=No&&e{let l=this.map.project(s.at),c=s.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:l.x,y:l.y,r:(c?.offsetWidth||24)/2+3,fixed:s.fixed}}),a=o.filter(s=>s.fixed);this.merged=[],this.foldedKeys.clear();let r=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));o.forEach((s,l)=>{if(s.fixed)return;let c=this.slots[l],d=c.el.classList.contains("merged")?12:6,p=a.find(u=>Math.hypot(u.x-s.x,u.y-s.y)*r{let d=this.slots[c];!d||d.fixed||(o[c].fixed&&([s,l]=[0,0]),d.marker.setOffset([s,l]),si(d.el,s,l))})}closePopup(e=!1){let o=this.popup;if(!o||o.card.classList.contains("leaving"))return;o.card.classList.add("leaving"),setTimeout(()=>{this.popup===o&&this.dropCard()},140);let a=this.before;if(this.before=null,!a)return;let r=()=>this.map?.flyTo({...a,duration:800});if(!e)return r();let i=!1,s=()=>{i||(i=!0,window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0),setTimeout(r,0))};window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),setTimeout(s,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},`Near ${e}`)," · click to zoom in"]),...this.merged.map(o=>t("div",{class:"dl-map-card-row"},[t("span",{},o.who),t("span",{class:"dl-faint"},o.where)]))]),this.card.classList.add("on"))}paintDock(){let e=this.dock;if(!e)return;let o=this.merged.map(r=>`${r.key}:${r.online?1:0}`).join("|");if(o===this.dockKey)return;this.dockKey=o,e.parentElement?.classList.toggle("docked",this.merged.length>0);let a=this.slots.find(r=>r.fixed).at;this.merged.length&&Io(e,this.merged,this.faceActions(()=>[a]),this.dockQuiet),this.dockQuiet=!1}faceActions(e){return{click:(o,a)=>this.openFace(o,a,e()),hover:o=>this.focus(o?.g?.person??null)}}pileUp(e){let o=new Set;if(!this.data?.person&&!this.data?.device){let a=e.flatMap((l,c)=>!l.fixed&&this.slots[c].el.querySelector(":scope > .dl-mk-av")?[c]:[]),r=new Map(a.map(l=>[l,l])),i=l=>r.get(l)===l?l:i(r.get(l));for(let l of a)for(let c of a){if(c<=l)continue;let d=this.slots[l].el.classList.contains("piled")&&this.slots[c].el.classList.contains("piled");Math.hypot(e[l].x-e[c].x,e[l].y-e[c].y)this.slots[k]),d=c.map(Ro),p=d.map(k=>k.key).sort().join(",");o.add(p);let u=[c.reduce((k,N)=>k+N.at[0],0)/c.length,c.reduce((k,N)=>k+N.at[1],0)/c.length],w=this.piles.get(p);if(!w){let k=t("span",{class:"dl-mk-pile-box"}),N=[...new Set(c.map(y=>y.g?.city||y.g?.cc||"?"))],B=t("div",{class:"dl-mk-pile"},[k,t("span",{class:"dl-mk-label below"},N.length===1?N[0]:`${c.length} people`)]);w={marker:new this.gl.Marker({element:B}).setLngLat(u).addTo(this.map),el:B,box:k,faces:d},B.addEventListener("mouseleave",()=>this.focus(this.focused));let E=w;B.addEventListener("click",y=>{y.stopPropagation(),this.zoomInTo(E.faces.map(S=>S.at),!1)}),this.piles.set(p,w)}w.faces=d;let g=w;Io(w.box,d,this.faceActions(()=>g.faces.map(k=>k.at)));for(let k of l)this.slots[k].el.classList.add("piled"),Object.assign(e[k],{r:0,fixed:!0});let m=this.map.project(u);e.push({x:m.x,y:m.y,r:(w.el.offsetWidth||60)/2+3,fixed:!0})}}this.piledKeys=new Set(this.slots.filter(a=>a.el.classList.contains("piled")).map(a=>a.el.dataset.key??"")),this.slots.forEach((a,r)=>{(!e[r].fixed||a.fixed||a.el.classList.contains("merged"))&&a.el.classList.remove("piled")});for(let[a,r]of this.piles)o.has(a)||(this.piles.delete(a),r.el.classList.add("out"),setTimeout(()=>r.marker.remove(),200))}zoomToMerged(){!this.map||!this.merged.length||this.zoomInTo([this.slots.find(e=>e.fixed).at,...this.merged.map(e=>e.at)],!1)}openFace(e,o,a){if(!e.g)return;if(a.every(i=>on(i,e.at)<1))return this.openPopup(e.g,e.at,o);let r=()=>{let i=this.slots.find(s=>s.el.dataset.key===e.key);i?.g&&!i.el.classList.contains("merged")&&!i.el.classList.contains("piled")&&this.openPopup(i.g,i.at,i.el)};this.zoomInTo(this.nearby(e.at),!0)?this.map.once("moveend",r):r()}nearby(e){return[e,...this.slots.filter(o=>!o.fixed&&o.at!==e&&on(o.at,e)<=zo).map(o=>o.at)]}zoomInTo(e,o){let a=new this.gl.LngLatBounds;for(let p of e)a.extend(p);let r=e.some(p=>e.some(u=>on(p,u)>zo)),i=this.map.cameraForBounds(a,{padding:50,maxZoom:r?12:ti}),s=this.map.getZoom(),l=e.map(p=>this.map.project(p)),c=0;l.forEach((p,u)=>l.slice(u+1).forEach(w=>{let g=Math.hypot(p.x-w.x,p.y-w.y),m=s+Math.log2(ni/Math.max(g,1e-6));m<=12&&(c=Math.max(c,m))}));let d=Math.min(12,Math.max(i?.zoom??0,c));return d<=s+.05?!1:(o&&!this.before&&(this.before={center:this.map.getCenter().toArray(),zoom:s}),this.map.flyTo({center:i?.center??a.getCenter(),zoom:d,duration:800}),!0)}placeMarker(e,o,a){let r=this.data.now,i=[...e.points].sort((u,w)=>Number(w.online)-Number(u.online)||w.ts-u.ts)[0],s=a?.devices.find(u=>u.id===i.device)?.kind??"other",l=e.points.length,c=t("span",{class:"dl-mk-tile"});c.innerHTML=$t(s,"dl-mk-tile-ic")+(l>1?`${l}`:"");let d=e.online?"now":ie(e.ts,r),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(r-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":`${l} device${l===1?"":"s"} in ${e.city||"an unknown city"}, ${d}`},[c,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},d)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,o,p)}),p}stepMarker(e,o,a,r){if(e.online)return this.placeMarker(e,o,a);let i=ie(e.ts,this.data.now),s=t("button",{type:"button",class:"dl-mk place step","aria-label":`${r}: ${e.city||"an unknown city"}, ${i}`},[t("span",{class:"dl-mk-tile sm"},String(r)),t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",` · ${i}`])]);return s.addEventListener("click",l=>{l.stopPropagation(),this.openPopup(e,o,s)}),s}focus(e){this.focused=e;for(let s of this.people)s.el.classList.toggle("dim",!!e&&s.person!==e),s.el.classList.toggle("hl",s.person===e);let o=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let s of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(s)&&this.map.setPaintProperty(s,"line-opacity",o);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let a=this.data,r=a.people.find(s=>s.id===e),i=In(a,this.range).filter(s=>s.person===e).sort((s,l)=>Number(l.online)-Number(s.online)||l.ts-s.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},r?.name??e),` · ${i.length} device${i.length===1?"":"s"}`]),...i.map(s=>t("div",{class:"dl-map-card-row"},[t("span",{},r?.devices.find(l=>l.id===s.device)?.name??"Device"),t("span",{class:"dl-faint"},`${s.city||s.cc||"?"} · ${s.online?"now":ie(s.ts,a.now)}`)]))])}fit(e,o=!1){if(!e.length)return;let a=(d,p)=>{let u=Math.PI/180,w=(p[1]-d[1])*u,g=(p[0]-d[0])*u,m=Math.sin(w/2)**2+Math.cos(d[1]*u)*Math.cos(p[1]*u)*Math.sin(g/2)**2;return 12742*Math.asin(Math.sqrt(m))},r=[e.reduce((d,p)=>d+p[0],0)/e.length,e.reduce((d,p)=>d+p[1],0)/e.length],i=e;if(e.length>=5){let d=[...e].sort((p,u)=>a(r,p)-a(r,u));i=d.slice(0,Math.ceil(d.length*.9))}let s=new this.gl.LngLatBounds(i[0],i[0]);i.forEach(d=>s.extend(d));let l=this.el.clientHeight||380,c={padding:{top:Math.min(60,l/5),bottom:Math.min(40,l/8),left:48,right:48},maxZoom:this.data?.person?11:12};o?this.glide(this.map.cameraForBounds(s,c)?.zoom??null,()=>this.map.fitBounds(s,{...c,duration:1200})):this.map.fitBounds(s,{...c,duration:0})}glide(e,o){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),o()}openPopup(e,o,a){let r=this.data,i=[e.city,e.cc||e.country].filter(Boolean).join(", "),s=[...new Set(e.points.map(y=>y.person))],l=e.points.sort((y,S)=>Number(S.online)-Number(y.online)||S.ts-y.ts).map(y=>{let S=r.people.find(x=>x.id===y.person),b=S?.devices.find(x=>x.id===y.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(y.person,y.device)},[t("span",{class:`dl-pop-dot${y.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},S?.name??y.person),` · ${b?.name??"device"}`]),t("span",{class:"dl-faint dl-nowrap"},y.online?"now":ie(y.ts,r.now))])}),c=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},v("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||"Unknown network"),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),t("div",{class:"dl-pop-list"},l),s.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${r.people.find(y=>y.id===s[0])?.name??"person"}`)]):""]);this.zoomInTo(this.nearby(o),!0),this.dropCard();let d=t("div",{class:"dl-root dl-popcard",role:"dialog"},[t("span",{class:"dl-popcard-tip"}),c]);document.body.appendChild(d);let p=this.el,u=a?.querySelector(".dl-mk-av, .dl-mk-tile")??a??null,w=()=>{if(!u)return;let y=u.getBoundingClientRect(),S=p.getBoundingClientRect(),b=y.left+y.width/2,x=y.top+y.height/2;d.classList.toggle("away",bS.right||xS.bottom);let M=d.offsetWidth,h=d.offsetHeight,f=y.top-h-12>=8||y.top>window.innerHeight-y.bottom,R=Math.min(Math.max(8,b-M/2),window.innerWidth-M-8);d.classList.toggle("above",f),d.classList.toggle("below",!f),d.style.left=`${R}px`,d.style.top=`${f?y.top-h-12:y.bottom+12}px`,d.style.setProperty("--tip-x",`${b-R}px`)},g=y=>{y.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},m=y=>{y.key==="Escape"&&this.closePopup()},k=y=>{y.target instanceof Element&&y.target.closest(".dl-popcard")||this.closePopup()},N=()=>this.closePopup();this.map.on("move",w),window.addEventListener("scroll",k,{capture:!0,passive:!0}),window.addEventListener("resize",w),document.addEventListener("pointerdown",g,!0),document.addEventListener("keydown",m);let B=Ee(N);window.addEventListener("pagehide",N),this.popup={card:d,off:()=>{this.map?.off("move",w),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",w),document.removeEventListener("pointerdown",g,!0),document.removeEventListener("keydown",m),B(),window.removeEventListener("pagehide",N)}};let E=window.setInterval(()=>{if(this.popup?.card!==d)return clearInterval(E);(!p.isConnected||!p.getClientRects().length)&&this.dropCard()},400);w()}};function ai(n,e=6){let o=n.map(a=>({x:a.x,y:a.y}));for(let a=0;a<16;a++){let r=!1;for(let i=0;i[a.x-n[r].x,a.y-n[r].y])}function ri(n,e){let o=new Map,a=e?[[e.lon,e.lat]]:[],r=i=>a.some(s=>on(i,s)<1.3);for(let i of[...n].sort((s,l)=>s.key>>12)/1048575),c=(s&4095)/4096*2*Math.PI,d=[i.lon,i.lat];for(let p=0;p<24;p++){let u=c+p*2.39996,w=Math.min(8,l+p*.25);if(d=[i.lon+w*Math.sin(u)/(111.32*Math.cos(i.lat*Math.PI/180)),i.lat+w*Math.cos(u)/111.32],!r(d))break}a.push(d),o.set(i.key,d)}return o}function ii(n){let e=2166136261;for(let o=0;o>>0}function Ro(n){return{key:n.el.dataset.key??"",who:n.who??"Someone",where:n.where??"",online:!!n.g?.online,at:n.at,badge:n.el.querySelector(".dl-mk-badge")?.innerHTML??"",g:n.g}}function Io(n,e,o,a=!1){let r=e.length>3,i=()=>[...n.children].filter(m=>!m.classList.contains("out")),s=new Map(i().map(m=>[m,m.getBoundingClientRect().left])),l=n.getBoundingClientRect().width,c=new Map;n.querySelectorAll(".dl-mk-face:not(.out)").forEach(m=>c.set(m.dataset.key??"",m));let d=n.querySelector(".dl-mk-more:not(.out)"),p=m=>{Object.assign(m.style,{position:"absolute",left:`${m.offsetLeft}px`,top:`${m.offsetTop}px`,transform:""}),m.classList.add("out"),setTimeout(()=>m.remove(),200)},u=[];for(let m of e.slice(0,r?2:3)){let k=c.get(m.key);if(c.delete(m.key),!k){let E=t("button",{type:"button",class:`dl-mk-face${a?"":" in"}`,"data-key":m.key},[t("span",{class:"dl-mk-av"},Pe(m.who)),t("span",{class:"dl-mk-badge"})]);E.addEventListener("animationend",()=>E.classList.remove("in"),{once:!0}),k=E}let N=k,B=N.querySelector(".dl-mk-badge");B.innerHTML!==m.badge&&(B.innerHTML=m.badge),N.title=`${m.who} · ${m.where}`,N.setAttribute("aria-label",`${m.who}, ${m.where}`),N.classList.toggle("on",m.online),N.onclick=E=>{E.stopPropagation(),o.click(m,N)},N.onmouseenter=()=>o.hover(m),N.onmouseleave=()=>o.hover(null),u.push(N)}for(let m of c.values())p(m);if(r){if(!d){d=t("span",{class:`dl-mk-more${a?"":" in"}`});let m=d;m.addEventListener("animationend",()=>m.classList.remove("in"),{once:!0})}d.textContent=`+${e.length-2}`,u.push(d)}else d&&p(d);let w=null;for(let m of u)(w?w.nextElementSibling:n.firstElementChild)!==m&&(w?w.after(m):n.prepend(m)),w=m;for(let m of u){let k=s.get(m);if(k==null)continue;let N=k-m.getBoundingClientRect().left;Math.abs(N)<.5||(m.style.transition="none",m.style.transform=`translateX(${N}px)`,m.offsetWidth,m.style.transition="",m.style.transform="")}n.style.width="";let g=n.getBoundingClientRect().width;if(l&&Math.abs(g-l)>.5){n.style.width=`${l}px`,n.offsetWidth,n.style.width=`${g}px`;let m=()=>{n.style.width="",n.removeEventListener("transitionend",m)};n.addEventListener("transitionend",m),setTimeout(m,400)}}function on(n,e){let o=Math.PI/180,a=Math.sin((e[1]-n[1])*o/2)**2+Math.cos(n[1]*o)*Math.cos(e[1]*o)*Math.sin((e[0]-n[0])*o/2)**2;return 12742*Math.asin(Math.min(1,Math.sqrt(a)))}function si(n,e,o){let a=n.querySelector(":scope > .dl-mk-ptr"),r=Math.hypot(e,o);if(r<1){a?.remove();return}a||(a=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(a));let i=a.firstElementChild,s=a.lastElementChild;i.style.width=`${r}px`,i.style.transform=`rotate(${Math.atan2(-o,-e)}rad)`,s.style.transform=`translate(${-e}px, ${-o}px)`}function xt(n,e,o=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],r=t("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of a)i==="online"&&!o||r.appendChild(t("button",{type:"button",role:"tab",class:i===n?"on":"","data-v":i,click:()=>{r.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===i)),e(i)}},s));return r}function wt(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function ke(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function li(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function Bo(n,e,o=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:"Copy",click:()=>ue(e,`${n} copied`)},[t("span",{},e),v("copy")])])}function an(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var Oo={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 di(n,e,o){let a=n.filter(r=>r.device===e&&Oo[r.type]).reverse().slice(0,12);return a.length?t("div",{class:"dl-dev-log"},a.map(r=>{let[i,s,l]=Oo[r.type],c=r.type==="connect"?[r.detail?t("span",{class:"dl-muted"},` from ${r.detail}`):"",r.where?t("span",{class:"dl-muted"},` · ${r.where}`):""]:r.type==="roam"?[t("span",{class:"dl-muted"},` · ${r.detail??""}`)]:r.type==="device_added"||r.type==="device_removed"||r.type==="device_keys"?[t("span",{class:"dl-muted"},De(r)==="portal"?" on the portal":De(r)==="admin"?" by you":"")]:[],d=new Date(r.ts*1e3);return t("div",{class:`dl-dev-log-row${De(r)==="admin"?" dl-ev-by-admin":""}`},[De(r)==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):t("span",{class:`dl-ev-tile ev ${i}`},v(l)),t("span",{class:"dl-row-main"},[t("span",{},s),...c]),t("span",{class:"dl-faint dl-nowrap",title:d.toLocaleString()},ie(r.ts,o))])})):t("div",{class:"dl-sub"},"No activity yet.")}async function jo(n,e,o){let a=await P.status(1).catch(()=>null),r=a?.people.find(s=>s.id===n),i=r?.devices.find(s=>s.id===e);a&&r&&i&&Be(r,i,{...o,geo:a.geo,now:a.now,today:Re(a.series),core:bt(a.servers,r.server)})}async function Be(n,e,o){let a=await W(()=>P.deviceConfig(e.id));if(!a)return;let r=o.core??Ie(null),i=e,s=n,l=o.geo,c=o.now,d=o.today??Ne(new Date),p=await r.connectBlock(a),u=t("div",{class:"dl-drawer-title"}),w=t("div",{}),g=t("div",{}),m=t("div",{},t("div",{class:"dl-sub"},"Loading…")),k=[],N=U=>{k=U.filter(q=>q.device===i.id),dom.content(m,di(U,i.id,c))},B=async(U=!1)=>{let q=o.events?.();if(q&&!U)return N(q);let oe=await P.events(2e3,n.id).catch(()=>null);oe&&N(oe.events)},E="30d",y=null,S=t("div",{class:"dl-dplaces"}),b=()=>({geo:l,people:[s],now:c??Date.now()/1e3,person:s.id,device:i.id}),x=()=>{if(!l?.enabled)return;let U=Bn(b(),E);dom.content(S,U.length?U.map(q=>t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${q.online?" live":""}`},q.online?v(i.kind):String(q.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[q.city||q.cc||"Unknown city",q.org?t("span",{class:"dl-muted"},` · ${q.org}`):""]),t("span",{class:"dl-mono dl-faint"},q.ip)]),t("span",{class:q.online?"dl-dplace-now":"dl-faint dl-nowrap"},q.online?"now":ie(q.ts,c))])):t("div",{class:"dl-sub"},"No locations in this period."))},M=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${i.online?" on":""}`},v(i.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},i.name),D([v("edit")],()=>R(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${s.name} · ${je[i.kind]}`)])]);let U=i.spark.reduce((q,oe)=>q+oe,0);dom.content(w,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},"Status"),Kt(i,c,"Waiting for the first connection")]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"This month"),t("b",{},te(i.month[0]+i.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${te(i.month[1])} ↑ ${te(i.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"Last 7 days"),t("b",{},te(U)),ko(i.spark,120,22,d)])])),dom.content(g,t("div",{class:"dl-kv2"},[Bo("Tunnel address",i.address),i.hostname&&s.access!=="internet"?Bo("Local address",i.hostname):"",i.endpoint&&!l?.points.some(q=>q.device===i.id&&q.ip===i.endpoint)?an("Client IP",i.endpoint):"",an("Total",t("span",{class:"dl-kv-act"},[`↓ ${te(i.total[1])} · ↑ ${te(i.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>vt("device",i.id,i.name,()=>setTimeout(f,300))},"Reset")])),an("Added",`${li(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),an("Public key",t("span",{class:"dl-mono dl-faint"},a.amnezia.client_pub_key?`${a.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(C,[D([v(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await W(()=>P.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await f()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),D([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;await W(()=>P.deviceRotate(i.id),"New keys generated")&&(o.refresh(),O.close(),await jo(s.id,i.id,o))}),t("span",{class:"dl-spacer"}),D([v("trash")," Remove"],async()=>{await re(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await W(()=>P.deviceDelete(i.id),"Device removed")&&(O.close(),o.refresh())},"negative")])},h=async()=>{let U=await P.status(1).catch(()=>null),q=U?.people.find(T=>T.id===s.id),oe=q?.devices.find(T=>T.id===i.id);!U||!q||!oe||(s=q,i=oe,l=U.geo,c=U.now,d=Re(U.series),M(),y?.update(b()),x())},f=async()=>{await h(),o.refresh()},R=()=>{let U=t("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48});ae(`Rename ${i.name}`,[t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Name"),t("div",{class:"cbi-value-field"},U)])],[le()," ",D("Save",async()=>{await W(()=>P.deviceUpdate(i.id,U.value,void 0),"Renamed")&&(de(),await f())},"positive")]),setTimeout(()=>U.select(),50)},C=t("div",{class:"dl-drawer-actions"}),I=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Connect")]),i.config_stale?t("div",{class:"dl-note warn"},[v("alert"),t("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.")]):"",p]),Q=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Activity"),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Ue({people:[s]},k,"csv",i.id)},"Export"),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Ke(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{B(!0),o.refresh()})},"Clear"),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),m]),G=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},"Details")),g]),Y="";l?.enabled&&(y=new Je({openPerson:U=>location.href=ke(U),openDevice:(U,q)=>location.href=ke(U,q)},E,220),Y=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Locations"),xt(E,U=>{E=U,y?.setRange(U),x()},!1)]),t("div",{class:"dl-dmap"},y.el),S]),x());let z=!i.handshake||i.config_stale,K=t("div",{class:"dl-stack gap16"},z?[w,I,G,Y,Q]:[w,G,Y,Q,I]);B();let X=()=>{h(),B()},ce=en(X),fe=window.setInterval(X,3e4),O=ho(u,K,C,()=>{clearInterval(fe),ce(),y?.destroy()});M(),y&&requestAnimationFrame(()=>y?.mount(b()))}function Uo(n,e,o,a){let r=a.core??Ie(null),i=()=>W(()=>P.deviceConfig(o.id)),s=[{label:"Show QR code",icon:v("qr"),run:async()=>{let l=await i();l&&ae(`${o.name} · QR code`,t("div",{class:"dl-qr-pane"},[qe(ft(r.qrText(l)),"dl-qr"),t("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),le("Close"))}},{label:r.file.label,icon:v("download"),run:async()=>{let l=await i();if(!l)return;let c=r.file.make(l);Le(c.name,c.text,"application/octet-stream")}},r.appKey?{label:r.appKey.label,icon:v("copy"),run:async()=>{let l=await i();l&&ue(await r.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:v("edit"),run:()=>Be(e,o,a)},{label:"New keys",icon:v("key"),run:async()=>{await re("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await W(()=>P.deviceRotate(o.id),"New keys generated")&&a.refresh()}},{label:o.disabled?"Enable":"Disable",icon:v(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await W(()=>P.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&a.refresh()}},{label:"Delete",icon:v("trash"),danger:!0,run:async()=>{await re(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await W(()=>P.deviceDelete(o.id),"Device removed")&&a.refresh()}}];we(n,s)}function it(n,e){let o=t("input",{type:"text",class:"cbi-input-text",placeholder:je.phone,maxlength:48}),a="phone",r=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},co.map(s=>t("button",{type:"button",role:"radio",class:s===a?"on":"","aria-checked":s===a?"true":"false","data-kind":s,click:()=>{a=s,r.querySelectorAll("button").forEach(l=>{let c=l.dataset.kind===s;l.classList.toggle("on",c),l.setAttribute("aria-checked",c?"true":"false")}),o.placeholder=je[s]}},[v(s),t("span",{},je[s])]))),i=n.devices.length>=n.device_limit;ae(`Add a device for ${n.name}`,[i?t("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Type"),r]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Name"),o])],[le()," ",D("Add device",async()=>{let s=o.value.trim()||o.placeholder.replace(/^e\.g\. /,""),l=await W(()=>P.deviceCreate(n.id,s,a));l&&(de(),F(`${s} added`,"success",3e3),e.refresh(),await jo(n.id,l.id,e))},"positive")]),setTimeout(()=>o.focus(),50)}var Ge=1080,Nt=1512,Oe=96,ci="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",pi="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",zt=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function mi(n,e,o){let a=new URL(o),r=a.pathname.slice(1),i=Math.min(92,Math.floor((Ge-2*Oe)/(.58*(4+n.name.length)))),s=Ge-2*Oe,l=392,c=40,d=ft(o,2).replace("`${k}`;return``+p(Oe+82,Oe+42,36,"#a3a3a3",zt(e))+p(Oe,276,i,"#ffffff",`Hi, ${zt(n.name)}`,'font-weight="600"')+p(Oe,340,40,"#8a8a8a",`Scan to connect to ${zt(e)}`)+``+d+`${zt(r)}`+p(Ge/2,l+s+156,34,"#737373",zt(a.host),'text-anchor="middle"')+""}async function hi(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let o=document.createElement("canvas");return o.width=Ge,o.height=Nt,o.getContext("2d").drawImage(e,0,0,Ge,Nt),new Promise((a,r)=>o.toBlob(i=>i?a(i):r(new Error("Could not draw the card")),"image/png"))}async function Wo(n){let e=await W(()=>P.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(F("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function rn(n){let e=await Wo(n);e&&await ue(e.link,"Personal link copied")}async function Ht(n,e,o={}){let a=n.link,r=n.links;if(a===void 0){let g=await Wo(n.id);if(!g)return;a=g.link,r=g.links}if(!a){F("The personal portal is off. Turn it on in Settings.","warning");return}let i=a,s=await W(()=>hi(mi(n,e,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),c=URL.createObjectURL(s),d=navigator,p=!!d.canShare?.({files:[l]}),u=()=>{URL.revokeObjectURL(c),de()},w=p?D([v("link")," Share card"],async()=>{try{await d.share({files:[l],title:`Invite ${n.name}`})}catch{}},"positive"):D([v("download")," Download card"],()=>Le(l.name,s),"positive");ae(o.title??`Invite ${n.name}`,t("div",{class:"dl-invite"},[t("img",{src:c,alt:`Invite card for ${n.name}`}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},o.lead??`Send ${n.name} the card or the link. They open it, add their devices and connect — no account needed.`),t("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>ue(i,"Personal link copied")},[t("span",{},i.replace(/^https:\/\//,"")),v("copy")]),...(r??[]).filter(g=>g!==i).map(g=>t("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>ue(g,"Link copied")},[t("span",{},g.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${g.startsWith("http:")?"warn":""}`},g.startsWith("http:")?"HTTP":"Also"),v("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},["Install ",t("b",{},"AmneziaVPN")," on the device"]),t("li",{},"Open the link or scan the code"),t("li",{},"Add the device and connect")]),t("div",{class:"dl-invite-actions"},[w,D([v("copy")," Copy link"],()=>ue(i,"Personal link copied"))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:u},"Done")],"wide")}function Rt(n,e){let o=n.servers.find(c=>c.id===e)??n.servers[0],a=n.people.filter(c=>c.server===o.id),r=new Set(a.map(c=>c.id)),i=a.flatMap(c=>c.devices),s=c=>a.reduce((d,p)=>{let u=c(p);return[d[0]+u[0],d[1]+u[1]]},[0,0]),l=o.series?.[o.series.length-1];return{...n,servers:[o],people:a,series:o.series??n.series,events:n.events.filter(c=>c.person?r.has(c.person):!0),geo:{...n.geo,points:n.geo.points.filter(c=>r.has(c.person))},totals:{people:a.length,devices:i.length,online:i.filter(c=>c.online).length,active:a.filter(c=>c.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(c=>c.month)}}}var Go=3,On=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let w=e.next(),g=null;try{g=await n.fetch(u),o>=Go&&F("The router answers again.","success",3e3),o=0}catch{return++o===Go&&F("The router is not answering: what you see may be out of date.","warning",8e3),null}return g==null||!e.take(w)?null:(n.apply(g,p),g)},r=(p=!1)=>a(p,!1),i=()=>document.visibilityState==="visible",s=()=>i()&&(n.active?.()??!0)?a(!0,!1):Promise.resolve(null);poll.add(s,n.every);let l=n.live?en(()=>void(i()&&(n.active?.()??!0)&&a(!0,!0))):null,c=()=>{poll.remove(s),l?.(),d()},d=Ee(c);return{refresh:r,claim:()=>e.claim(),stop:c}}function yt(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function Me(n,e,o=!1){return o&&yt(n)?!1:(dom.content(n,e),!0)}function Fo(n,e){let o=n,r=t("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(i=>t("button",{type:"button",class:`dl-choice${i.v===o?" selected":""}`,"data-v":i.v,click:()=>{o=i.v,r.querySelectorAll(".dl-choice").forEach(s=>s.classList.toggle("selected",s.dataset.v===i.v)),e?.(i.v)}},[t("span",{class:"dl-choice-title"},[v(i.ic),ot[i.v]]),t("span",{class:"dl-choice-text"},i.text)])));return{el:r,get:()=>o}}function fi(n){let e=n.devices.length,o=Math.max(1,n.device_limit,e),a=Math.min(160,o*22+(o-1)*3);return t("div",{class:"dl-slotbar",title:`${e} of ${n.device_limit} devices`},[t("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:o},(r,i)=>t("i",{class:i>=n.device_limit?"over":in.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),jn=n=>n.state==="server_off"?n.paused:n.state!=="active",Ko=n=>jn(n)?n.state==="server_off"?"paused":n.state:null;function gi(n,e){let o=nt(n.expires,e);return n.state==="quota"||n.state==="expired"||Fe(n,o)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function Jo(n,e){return ct(n&&Pn(n,e)>=0?n:e,1)}var Vo=n=>n.people.map(e=>e.id).sort().join(" "),Yo=!1,st=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return P.status(30)}scope(e){return this.serverId?Rt(e,this.serverId):e}embed(e,o){return this.serverId=o,this.render(e)}person(e){return this.st.people.find(o=>o.id===e)}get today(){return Re(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:bt(this.st.servers,e.server)}}take(e,o){let a=this.scope(e),r=Vo(a)!==Vo(this.st);this.st=a,r?this.rebuild():(this.paintCards(o),this.decorate(o))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await P.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let a of Array.from(this.list.children))a.dataset.sid&&e.set(a.dataset.sid,a);let o=this.st.people.map(a=>{let r=e.get(a.id)??t("div",{class:"dl-card",role:"listitem","data-sid":a.id});return this.renderCard(r,a.id)});dom.content(this.list,o.length?o:t("div",{class:"dl-plist-none"},this.st.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people.")),this.decorate()}paintCards(e=!1){for(let o of this.st.people){let a=this.card(o.id);a&&!(e&&yt(a))&&this.renderCard(a,o.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let o=this.scope(e);this.st=o;let a=this,r=t("select",{class:"dl-select","aria-label":"Sort",change:s=>{a.sort=s.target.value,a.decorate()}},[t("option",{value:"seen"},"Last seen"),t("option",{value:"name"},"Name"),t("option",{value:"usage"},"Usage")]),i=t("div",{class:"dl-root"},[a.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"People"),t("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?D([v("plus")," Add person"],()=>a.openCreate(),"add"):""]),o.servers.length?"":t("div",{class:"alert-message warning"},["No server yet. ",t("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[r,a.serverId?D([v("plus")," Add person"],()=>a.openCreate(),"add"):""])]),this.list]);return this.el=i,this.rebuild(),this.poller??(this.poller=Ve({fetch:()=>P.status(30),every:30,live:!0,active:()=>!!a.el?.isConnected,apply:(s,l)=>a.take(s,l)})),!Yo&&new URLSearchParams(location.search).get("add")&&(Yo=!0,setTimeout(()=>a.openCreate(),100)),Promise.resolve(i)}countText(){let e=this.st.totals;return`${e.people} ${e.people===1?"person":"people"} · ${e.devices} device${e.devices===1?"":"s"} · ${e.online} online`}decorate(e=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let a=this.st.people,r=this.today,i=g=>gi(g,r),s={all:a.length,online:a.filter(g=>g.online>0).length,attention:a.filter(i).length,paused:a.filter(g=>qo(g)).length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(e&&yt(l))){let g={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(g).map(m=>t("button",{type:"button",role:"tab",class:m===this.filter?"on":"",click:()=>{this.filter=m,this.decorate()}},[g[m],t("b",{class:m==="attention"&&s[m]?"warn":""},String(s[m]))])))}let c=g=>!(this.filter==="online"&&!g.online||this.filter==="attention"&&!i(g)||this.filter==="paused"&&!qo(g)),d=g=>Ko(g)==="paused"?2:jn(g)?1:0,p=[...a].sort((g,m)=>d(g)-d(m)||(this.sort==="name"?g.name.localeCompare(m.name):this.sort==="usage"?m.month[0]+m.month[1]-(g.month[0]+g.month[1]):m.online-g.online||m.last_seen-g.last_seen)),u=0;for(let g of p){let m=this.card(g.id);if(!m)continue;this.list.appendChild(m),m.classList.toggle("dl-off",jn(g));let k=c(g);m.classList.toggle("dl-filtered",!k),k&&u++}let w=this.el?.querySelector(".dl-people-none")??null;a.length&&!u?(w??(w=t("div",{class:"dl-empty dl-people-none"},t("p",{},"No one here right now."))),w.previousElementSibling!==this.list&&this.list.after(w)):w?.remove()}async quick(e,o,a){await W(()=>P.personUpdate(e.id,o),a)&&await this.update()}renderCard(e,o){let a=this.person(o);if(!a)return dom.content(e,t("em",{},"This person was just removed.")),e;let r=this.today,i=nt(a.expires,r),s=Math.max(0,a.device_limit-a.devices.length),l=a.has_link??this.st.settings.portal_enabled,c=[],d=Ko(a);if(a.expires&&d!=="expired"){let m=Fe(a,i),k=i!=null&&i<0;c.push(t("span",{class:`dl-pill-ic${k?" bad":m?" warn":""}`,title:`Access ends ${Ce(a.expires)}`},[v("calendar"),k?`ended ${Ce(a.expires)}`:m?Gt(i):`until ${Ce(a.expires)}`]))}a.hours&&d!=="hours"&&c.push(t("span",{class:"dl-pill-ic",title:"Allowed hours"},[v("clock"),a.hours.replace("-","–")]));let p=qt(a.devices).map(m=>t("button",{type:"button",class:`dl-chip${m.disabled?" disabled":""}${m.online?" live":""}`,title:`${je[m.kind]} · ${m.address}${m.online?` · online from ${m.endpoint}`:m.handshake?` · seen ${ie(m.handshake,this.st.now)}`:""}`,click:k=>{k.preventDefault(),Be(a,m,this.deviceOpts(a))}},[v(m.kind),t("span",{class:"dl-chip-name"},m.name),!m.handshake&&!m.disabled?t("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(t("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:s>0?"Add device":"Add device · over the limit, admins can still add",click:m=>{m.preventDefault(),it(a,this.deviceOpts(a))}},v("plus")));let u=[];a.expires&&Fe(a,i)&&d!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:Jo(a.expires,r)},"Extended by 1 month")},"Extend 1 month"));let w=$e("more","More",m=>we(m.currentTarget,[{label:"Open",icon:v("open"),run:()=>{location.href=ke(a.id)}},l?{label:"Invite card",icon:v("qr"),run:()=>Ht(a,this.st.servers.find(k=>k.id===a.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:v("plus"),run:()=>it(a,this.deviceOpts(a))}: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((k,N,B)=>k||N>0&&B[N-1])),"neutral","dl-icon-only"),g=t("div",{class:"dl-pcard-actions"},[l?$e("link","Copy link",()=>rn(a.id),"neutral","dl-icon-only"):"",w]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${a.online?" online":""}`},Pe(a.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:ke(a.id)},a.name),mo(a),...c]),fi(a)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(a,g),d?this.stopStrip(a,d):""])),e}stopStrip(e,o){let a=this.today,r=ct(`${a.slice(0,8)}01`,1),i=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month"),s={paused:["pause","warn","Paused","Devices can’t connect until you resume",["play","Resume",()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad","Data limit reached",`Paused until it resets on ${Ce(r)}`,["plus","+10 GB this month",i]]:["chart","bad","Data limit reached","Paused until the limit is raised",["edit","Change limit",()=>location.href=ke(e.id)]],expired:["calendar","bad",`Access ended ${Ce(e.expires)}`,"Devices can’t connect",["calendar","Extend 1 month",()=>this.quick(e,{expires:Jo(e.expires,a)},"Extended by 1 month")]],hours:["clock","warn","Outside allowed hours",`Access ${e.hours.replace("-","–")} (router time)`,null],no_server:["alert","warn","No server","Choose a server on their page",null]},[l,c,d,p,u]=s[o];return t("div",{class:`dl-pstrip ${c}`},[t("span",{class:`dl-need-ic ${c}`},v(l)),t("span",{class:"dl-pstrip-text"},[t("b",{},d),t("span",{class:"dl-faint"},p)]),u?D([v(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,o){let a=e.quota_used||e.month[0]+e.month[1],r=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,i=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??0),0),s=e.rate?.[e.rate.length-1],l=e.online&&s&&this.st.now-s[0]<180,c=t("div",{class:`dl-usebar${r>=100?" bad":r>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${r}%`,c.appendChild(p),me(c,()=>[t("div",{class:"dl-tip-title"},`${r.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${te(e.quota_used)} of ${te(e.quota_limit)} · ${te(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},e.quota_period==="total"?"In total":`This month${e.bonus_gb?` · includes +${e.bonus_gb} GB extra`:""}`)])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,w)=>w.v-u.v);p.forEach((u,w)=>{let g=t("i",{class:`c${Math.min(w,4)}`});g.style.flexGrow=String(u.v),c.appendChild(g)}),p.length&&me(c,()=>[t("div",{class:"dl-tip-title"},"This month by device"),...p.map((u,w)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(w,4)}`}),t("span",{},u.d.name),t("b",{},te(u.v))]))])}let d=e.quota_limit?`${te(Math.max(0,e.quota_limit-e.quota_used))} left`:"no limit";return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[l?t("span",{class:"dl-pside-state live"},"Online"):t("span",{class:"dl-pside-state"},e.online?"Online":e.last_seen?"Offline":"Never connected"),o]),t("div",{class:"dl-use-num"},[t("b",{class:a?"":"dl-faint"},te(a)),t("span",{class:"dl-faint"},e.quota_limit?`of ${te(e.quota_limit)}`:e.quota_period==="total"&&e.quota_gb?"in total":"this month")]),c,l?t("div",{class:"dl-use-live",title:"Right now"},[`↓ ${ze(s[2])}`,t("span",{class:"dl-faint"},`↑ ${ze(s[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},i?`today ${te(i)} · ${d}`:d)])}async togglePause(e){await W(()=>P.personPause(e.id,!e.paused),e.paused?`${e.name} resumed`:`${e.name} paused`)&&await this.refresh()}async remove(e){let o=this.person(e);await re(`Remove ${o?.name??e}?`,`All ${o?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await W(()=>P.personDelete(e),"Person removed")&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){F("Set up the server first.","warning");return}let o=t("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=Fo("internet"),r=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),i=t("input",{type:"date",class:"cbi-input-text"}),s=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),l=(u,w)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{i.value=w?ct(Re(e.series),w):""}},u),c=e.servers[0],d=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(u=>t("option",{value:u.id},u.name))):null,p=(u,w,g)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},u),t("div",{class:"cbi-value-field"},[w,g?t("div",{class:"cbi-value-description"},g):""])]);ae("Add person",[p("Name",o),d?p("Server",d):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},"Access"),t("div",{class:"cbi-value-field"},a.el)]),p("Devices",r,"How many devices they can add themselves."),p("End date",t("div",{class:"dl-actions"},[i,l("1 month",1),l("3 months",3),l("1 year",12),l("None",0)]),"Optional."),p("Monthly data (GB)",s,"Optional. They are paused when it runs out and resumed next month.")],[le()," ",D("Create and copy link",async()=>{let u=await W(()=>P.personCreate(o.value.trim(),"",d?.value??c.id,a.get(),String(Number(r.value)||e.settings.default_device_limit),i.value,s.value.trim(),"month"));u&&(u.link&&await ue(u.link,"Personal link copied"),this.showCreated(u.id,o.value.trim(),u.link,e.servers.find(w=>w.id===(d?.value??c.id))?.name??c.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(e,o,a,r){if(a){Ht({id:e,name:o,link:a},r,{title:`${o} is ready`,lead:`Send ${o} the card or the link. They open it, add their devices and connect — no account needed.`});return}ae(`${o} is ready`,[t("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[t("button",{class:"cbi-button cbi-button-positive",click:de},"Done")])}};function Un(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[o,a,r,i]=e.slice(1,5).map(Number),s=Number(e[5]);if([o,a,r,i].some(d=>d>255)||s<8||s>30)return null;let l=o*2**24+a*2**16+r*2**8+i,c=2**(32-s);return{net:l-l%c,size:c}}var vi=(n,e)=>n.netUn(n));function sn(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function Wn(n){return`${n.trim()}.0/24`}function Zo(n,e,o){let a=n.trim(),r=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(a)?Un(Wn(a)):null;if(!r)return{text:"Three numbers, like 10.77.0.",bad:!0};if(!bi.some(s=>r.net>=s.net&&r.net+r.size<=s.net+s.size))return{text:"Use a private range: 10.x.x, 172.16–31.x or 192.168.x.",bad:!0};let i=e.find(s=>{let l=Un(s.cidr);return l!=null&&vi(r,l)});if(i){let s=i.cidr.endsWith("/24")?`${sn(i.cidr)}.x`:i.cidr,l=o&&o!==a?` Try ${o}.`:"";return{text:`${i.name} already uses ${s}.${l}`,bad:!0}}return{text:`Devices get ${a}.2 – ${a}.254, the router ${a}.1.`,bad:!1}}var Qo=(n,e)=>e.find(o=>o.from<=n&&n<=o.to)?.who??null,xi=n=>Number.isInteger(n)&&n>=1&&n<=65535;function Gn(n,e,o){if(!xi(n))return{text:"Use a port from 1 to 65535.",bad:!0};let a=Qo(n,e);return a?{text:`Used by ${a}. Choose another port.`,bad:!0}:{text:o,bad:!1}}function It(n,e,o){let a=o?`HTTPS here, plain HTTP for links on IP addresses on ${n+1}.`:"HTTPS on this port, opened on WAN.",r=Gn(n,e,a);if(r.bad||!o)return r;if(n===65535)return{text:"Links on IP addresses also need the next port: choose a lower one.",bad:!0};let i=Qo(n+1,e);return i?{text:`Links on IP addresses also need ${n+1}, used by ${i}. Choose another port.`,bad:!0}:r}var ln=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],Fn=n=>t("i",{class:"dl-circle-dot",style:`background:${ln[n?.color??0]??ln[0]}`}),Ye=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function Xo(n,e,o){let a=se(n?.name??e.name??"",{placeholder:"NAS"}),r=se(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=se((n?.ports??e.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=(l,c)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},l),t("div",{class:"cbi-value-field"},c)]);ae(n?`Edit ${n.name}`:"Add service",[s("Name",a),s("Address",r),s("Ports",i)],[le()," ",D("Save",async()=>{let l=i.value.split(/[ ,]+/).filter(Boolean);await W(()=>P.serviceSet(n?.id??"",a.value,r.value,l),"Saved")&&(de(),o())},"positive")])}var wi={_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"},yi=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function ki(n){let e=new Map;for(let o of n.services){let a=wi[o.type.split(".")[0]];!a||!o.port||(e.get(a)??e.set(a,new Set).get(a)).add(String(o.port))}return e.size?[...e].map(([o,a])=>[o,[...a].sort((r,i)=>+r-+i)]):yi}function ea(n,e,o){let a=n,r=null,i=!1,s=null,l=new Set,c=t("div",{class:"dl-list"}),d=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},"Looking for devices at home…")),p=()=>{let k=a.services;dom.content(c,k.length?k.map(N=>t("div",{class:"dl-row"},[v("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},N.name),t("span",{class:"dl-mono dl-faint"},`${N.address}${N.ports.length?` · ports ${N.ports.join(", ")}`:" · all ports"}`)]),D("Edit",()=>Xo(N,{},o)),D([v("trash")],async()=>{await re(`Remove ${N.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await W(()=>P.serviceDelete(N.id),"Removed")&&await o()},"neutral",{title:"Remove","aria-label":`Remove ${N.name}`})])):[t("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function u(k,N){if(!l.has(k.address)){l.add(k.address),g();try{let B=a.services.find(y=>y.address===k.address);(N===null?B&&await W(()=>P.serviceDelete(B.id),`${B.name} removed`):await W(()=>P.serviceSet(B?.id??"",B?.name??(k.name||k.address),k.address,N),B?`${B.name} updated`:`${k.name||k.address} added`))&&await o()}finally{l.delete(k.address),g()}}}function w(k){let N=a.services.find(b=>b.address===k.address),B=!!N&&!N.ports.length,E=new Set(N?.ports??[]),y=l.has(k.address),S=(b,x,M)=>We(b,x,M,{disabled:y?"disabled":null,"aria-busy":y?"true":null});return t("div",{class:"dl-row"},[v(k.services.some(b=>b.type.startsWith("_ipp")||b.type.startsWith("_printer"))?"file":"computer"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},k.name||k.address),t("span",{class:"dl-mono dl-faint"},k.address)]),t("div",{class:"dl-chips-row dl-host-ports"},[S("All ports",B,()=>u(k,B?null:[])),...ki(k).map(([b,x])=>{let M=!B&&x.every(h=>E.has(h));return S(`${b} ${x.join(", ")}`,M,()=>{let h=new Set(B?[]:E);for(let f of x)M?h.delete(f):h.add(f);u(k,h.size?[...h]:null)})})])])}function g(){if(i)return dom.content(d,t("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!r)return;let k=r;if(!k.hosts.length)return dom.content(d,t("span",{class:"dl-sub"},"No devices found in the home network right now."));let N=t("details",{class:"dl-params",open:s??!a.services.length?"":null},[t("summary",{},[v("chevron"),t("span",{},"Add from devices at home"),t("span",{class:"dl-pcount"},String(k.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},k.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."),t("div",{class:"dl-list"},k.hosts.map(w))])]);N.addEventListener("toggle",()=>s=N.open),dom.content(d,N)}return P.homeHosts(e).then(k=>{r=k,g()}).catch(()=>{i=!0,g()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},"Home services"),D([v("plus")," Add service"],()=>Xo(null,{},o))]),t("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),c,d]),update(k){a=k,p(),g()}}}function dn(n,e,o,a){let r=new Set(n.circles.filter(g=>g.server===e).map(g=>g.color)),i=o?.color??ln.findIndex((g,m)=>!r.has(m));i<0&&(i=0);let s=se(o?.name??"",{placeholder:"Family"}),l=n.people.filter(g=>g.server===e).sort((g,m)=>g.name.localeCompare(m.name)),c=new Set(l.filter(g=>o&&g.circle===o.id).map(g=>g.id)),d=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),p=()=>dom.content(d,ln.map((g,m)=>t("button",{type:"button",role:"radio",class:`dl-swatch${m===i?" on":""}`,style:`--sw:${g}`,"aria-checked":m===i?"true":"false","aria-label":`Colour ${m+1}`,click:()=>{i=m,p()}})));p();let u=t("div",{class:"dl-chips-row"},l.map(g=>{let m=g.circle&&g.circle!==o?.id?n.circles.find(k=>k.id===g.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${c.has(g.id)?" on":""}`,title:Ye(g)?m?`Now in ${m.name}`:"":`${g.name} has no home access: their devices aren't reachable anyway`,click:k=>{c.delete(g.id)||c.add(g.id),k.currentTarget.classList.toggle("on",c.has(g.id))}},[g.name,Ye(g)?m?t("b",{},m.name):"":t("b",{},"internet")])})),w=(g,m)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},g),t("div",{class:"cbi-value-field"},m)]);ae(o?`Edit ${o.name}`:"New circle",[w("Name",s),w("Colour",d),w("People",u),t("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[o?D("Delete",async()=>{await W(()=>P.circleDelete(o.id),`${o.name} deleted`)&&(de(),a())},"negative"):"",t("span",{class:"dl-spacer"}),le()," ",D("Save",async()=>{await W(()=>P.circleSet(o?.id??"",e,s.value,i,[...c]),"Saved")&&(de(),a())},"positive")],"dl-circle-modal")}function ta(n,e,o){let a=n.circles.filter(r=>r.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...a.map(r=>{let i=n.people.filter(s=>s.circle===r.id).map(s=>s.name);return t("button",{type:"button",class:"dl-chip",title:`Edit ${r.name}`,click:()=>dn(n,e,r,o)},[Fn(r),t("b",{},r.name),t("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),t("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>dn(n,e,null,o)},v("plus"))])}function qn(n,e){let o=n.people.filter(p=>p.server===e.id),a=(p="")=>t("span",{class:"dl-yes"},[v("check"),p]),r=()=>t("span",{class:"dl-faint"},"—"),i=p=>{let u=new Set(p.map(w=>w.access==="lan"&&w.services?.length?"services":w.home_nets?.length?"some":"all"));return u.size||u.add("all"),a([...u].map(w=>({all:"all networks",some:"their networks",services:"services"})[w]).join(" / "))},s=()=>e.mesh==="off"?r():e.mesh==="circles"?a("circle"):a(),l=e.lan_like?"like home":"direct",c=(p,u,w)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},`${u.length} ${u.length===1?"person":"people"}`)]),...w.map(g=>t("td",{},g))]),d=p=>o.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Who reaches what"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"From the rules on this server")]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["","Internet","Home","This router","Each other"].map(p=>t("th",{},p))),c("Internet",d("internet"),[a(l),r(),t("span",{class:"dl-faint"},"DNS"),r()]),c("Home",d("lan"),[t("span",{class:"dl-faint"},"their own"),i(d("lan")),a(),s()]),c("Both",d("both"),[a(l),i(d("both")),a(),s()])])),t("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 na(n,e){let o=n.people.filter(d=>d.server===e.id).flatMap(d=>d.devices.map(p=>({id:p.id,label:`${d.name} · ${p.name}`}))).sort((d,p)=>d.label.localeCompare(p.label)),a="@addr",r=(d,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":d},[...o.map(k=>t("option",{value:k.id,selected:k.id===p?"selected":null},k.label)),t("option",{value:a,selected:p===a?"selected":null},"Address")]),w=se("",{placeholder:d,class:"cbi-input-text dl-mono"}),g=t("div",{class:"dl-check-end"},[u,w]),m=()=>w.hidden=u.value!==a;return u.addEventListener("change",m),m(),{el:g,value:()=>u.value===a?w.value.trim():u.value}},i=r("10.0.1.11",o[0]?.id??a),s=r("10.0.1.20:445",a),l=t("div",{class:"dl-stack gap8"}),c=async()=>{let d=await W(()=>P.accessCheck(i.value(),s.value()));if(!d)return;let p=d.steps.findIndex(u=>!u.ok);dom.content(l,[t("div",{class:`dl-verdict ${d.ok?"ok":"bad"}`},[t("b",{},d.ok?"Allowed":"Blocked"),t("span",{class:"dl-sub"},d.ok?"Every step lets it through":`Stops at step ${p+1} of ${d.steps.length}`)]),t("ul",{class:"dl-checks"},d.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},v(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Check access"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"Why something does or does not connect")]),t("div",{class:"dl-check-form"},[i.el,t("span",{class:"dl-faint"},"→"),s.el,D("Check",c)]),l])])}var cn={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function Ze(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function pn(n){return Ze(n.action==="check"?`check:${n.component??""}`:n.component??"")}function oa(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function aa(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function ra(n,e){let o=n.check?.components??{},a=e==="all"?["app","amneziawg","packages"]:[e],r=[],i;for(let l of a){let c=o[l];if(c){if(c.error)return{tone:"warn",text:c.error};l==="packages"&&c.updates?r.push(`${c.updates} system package${c.updates===1?"":"s"}`):l!=="packages"&&c.update&&c.installed&&c.latest&&(r.push(`${cn[l]} ${c.latest}`),e!=="all"&&(i=c.latest))}}if(r.length)return{tone:"acc",text:`Update available: ${r.join(", ")}`,update:i};let s=a.length===1?o[a[0]]:null;return s?.status==="dev"?{tone:"acc",text:`Installed version is newer than the release (${s.latest})`}:s?.note?{tone:"warn",text:s.note}:{tone:"ok",text:a.length>1?"Everything is up to date":"Latest version is installed"}}function ia(n,e,o,a){return e?n.id===e:o&&n.id===o?!1:n.state==="running"||a>0&&n.started>=a}var sa=n=>new Promise(e=>setTimeout(e,n));async function Bt(n,e,o){let a=o?pn(o):Ze(n),r=o?o.action==="check":n.startsWith("check"),i=Date.now(),s=t("b",{},cn[a]??(a==="all"?"All components":"Dawnline")),l=t("span",{class:"dl-pill dl-mono"},e.version??""),c=t("span",{class:"dl-pill info",hidden:!0}),d=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),u=t("div",{}),w=t("div",{class:"dl-op-actions"}),g=[],m=h=>dom.content(w,h),k=(h=!1)=>le("Close",h);ae(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[s,e.version?l:"",c,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[v("clock"),d])]),t("div",{class:"dl-op-loghead"},[t("b",{},"Operation log"),$e("copy","Copy log",()=>ue(g.join(` -`),"Log copied"))]),p,u]),[w],"wide"),m([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?"Checking…":"Working…")]);let N=o??null,B=o?.id,E,y=0,S=h=>{B!==h.id&&(B=h.id,e.onJob?.(h))};if(o)e.onJob?.(o);else try{let h=await P.updatesStatus().catch(()=>null);E=h?.job?.id,y=h?.now??0;let f=await P.updatesRun(n);f.job&&f.job.state==="running"&&f.job.id!==E&&(N=f.job,S(f.job))}catch(h){return g=[ve(h)],p.textContent=g[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[v("alert"),t("span",{},ve(h))])),m([k(!0)]),F(ve(h),"error"),null}let b=null,x=0;for(;;){if(await sa(1e3),b=await P.updatesStatus().catch(()=>null),!b){if(++x>60)break;continue}x=0;let h=b.job;if(!h||!ia(h,B,E,y)){if(Date.now()-i>15e3)break;continue}if(S(h),N=h,h.log.length){g=h.log;let f=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=g.join(` -`),f&&(p.scrollTop=p.scrollHeight)}if(l.textContent=aa(h,e.version??""),!l.isConnected&&l.textContent&&s.after(l),d.textContent=oa((h.finished??b.now)-h.started),h.state==="running"){c.hidden=!h.phase,c.textContent=h.phase;continue}break}if(p.scrollTop=p.scrollHeight,c.hidden=!1,!N||N.state==="running")return c.className="dl-pill warn",c.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[v("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),m([k()]),e.onDone?.(b),N;if(N.state==="failed")return c.className="dl-pill bad",c.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[v("x"),t("span",{},[t("b",{},N.error??"Operation failed"),r?"":". Nothing else was changed."])])),m([D("Copy log",()=>ue(g.join(` -`),"Log copied")),k(!0)]),F(`${cn[a]??"Update"}: ${N.error??"failed"}`,"error"),e.onDone?.(b),N;if(c.className="dl-pill ok",c.textContent="Finished",r&&b){let h=ra(b,a);if(dom.content(u,t("div",{class:`dl-comp-status ${h.tone}`},[v(h.tone==="ok"?"check":h.tone==="warn"?"alert":"download"),t("span",{},h.text)])),F(h.text,h.tone==="warn"?"warning":"success"),e.onDone?.(b),h.update&&e.onUpdate){let f=b;m([k(),D(`Update to ${h.update}`,()=>e.onUpdate(f),"positive")])}else m([k()]),h.tone==="ok"&&setTimeout(()=>u.isConnected&&de(),1200);return N}if(a==="app"&&N.to){let h=N.to,f=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},[t("b",{},`Dawnline ${h} is installed. `),f])]));let R=()=>{ui.menu?.flushCache(),location.reload()};m([k(),D("Reload now",R,"positive")]),F(`Dawnline updated to ${h}`,"success",6e3);for(let C=1;C<=30;C++)if(f.textContent=`Waiting for the router to restart its services (${C} of 30)…`,await sa(1500),(await P.updatesStatus().catch(()=>null))?.version===h)return f.textContent="Services are back. Reloading…",setTimeout(R,800),N;return f.textContent="Services restarted. Reload the page to use the new version.",N}let M=a==="pkgs"?`Updated ${[...N.result?.pkgs?.updated??[],...N.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:a==="amneziawg"?`AmneziaWG${N.to?` ${N.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},M)])),m([k()]),F(M,"success"),e.onDone?.(b),N}var $i={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function la(n,e,o,a){return!await re(`Install ${e}?`,o,"Install")||(await Bt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>a?.(),4e3),!0)}function un(n){return la("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Ot(n,e,o){return n==="awg"?un(o):e.length?la(`pkgs:${e.join(",")}`,$i[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function da(n,e){if(n==="awg")return un(e);let o=await W(()=>P.updatesStatus());return o?Ot(n,o.needs?.[n]??[],e):!1}var Ei=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Li={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function ca(n,e,o){let a=n.id,r=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,c="",d=!0,p=!0,u="all",w=!1,g=ea(r,a,o),m=new Set,k="",N=()=>JSON.stringify([p,l,l?"":c,d,[...m].sort()]),B=()=>s.detected.lan||s.saved.lan||"",E=()=>(l?s.detected.wan||s.saved.wan:c)||"",y=()=>new Map(s.devices.map(z=>[z.name,z])),S=()=>{let z=y();return[...d&&B()?[B()]:[],...[...m].filter(X=>X!==B())].filter(X=>X!==E()).map(X=>z.get(X)??{name:X,nets:[],missing:!0})},b=(z,K)=>{s=z,K&&(l=z.config.auto_wan,c=z.config.wan_device||z.detected.wan||z.saved.wan||"",d=z.config.auto_lan,p=z.config.lan_like,u=z.config.mesh??(z.config.device_mesh?"all":"off"),m=new Set(z.config.lan_devices),k=N()),G()},x=async z=>{let K=await P.interfaces(a).catch(X=>(F(X.message,"error"),null));K&&b(K,z)};function M(z){let K=d&&z.name===B(),X=!!z.own||!!z.master||z.name===E()||K;return K||m.has(z.name)||!X&&(z.nets.length>0||!!z.missing)}function h(z){let K=d&&z.name===B(),X=z.name===E(),ce=!K&&m.has(z.name),O=!(!!z.own||!!z.master||X||K)&&(z.nets.length>0||ce||!!z.missing),U=(ce||K)&&!z.zone&&!z.missing,q=z.missing?"Not present right now":z.own?"This server":z.master?`Port of ${z.master}`:X?`Internet${z.zone?` · zone ${z.zone}`:""}`:z.nets.length?z.nets.join(", "):"No IPv4 network",oe=t("button",{type:"button",class:`dl-if${ce?" sel":""}${K?" auto":""}${!O&&!ce&&!K?" off":""}${U?" warn":""}`,"aria-pressed":ce||K?"true":"false","aria-disabled":O?null:"true",click:()=>{O&&(m.has(z.name)?m.delete(z.name):m.add(z.name),G())}},[t("span",{class:"dl-if-ic"},v(Li[z.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},z.name),t("span",{class:"dl-if-sub"},q)]),K?t("span",{class:"dl-if-badge ok"},"Auto"):ce?t("span",{class:"dl-if-check"},v("check")):""]);return me(oe,()=>[t("div",{class:"dl-tip-title"},z.name),t("div",{class:"dl-muted"},[z.logical?`Interface ${z.logical}`:"No netifd interface",z.zone?` · zone ${z.zone}`:" · no firewall zone"]),z.members.length?t("div",{class:"dl-muted"},`Ports: ${z.members.join(", ")}`):"",z.nets.length?t("div",{class:"dl-mono"},z.nets.join(", ")):"",U?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",z.master?t("div",{class:"dl-muted"},`Choose ${z.master} to include it.`):""]),oe}function f(){let z=s.like_home;return!p||!s.config.lan_like||!n.enabled?"":!s.needs?.length&&z.active&&z.bridged?"ok":"warn"}function R(){let z=s.like_home;return p?s.needs?.length?[t("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?n.enabled?z.active&&z.bridged?["Internet traffic enters ",t("span",{class:"dl-mono"},z.dev??"")," as ",t("span",{class:"dl-mono"},z.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[t("span",{class:"dl-warn"},`Not working: ${z.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too."]:["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 C={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 I(z,K,X,ce,fe="",O){return t("div",{class:O?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${fe}`},v(z)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},K),t("span",{class:"dl-sub"},X),O??""])]),t("div",{class:"dl-setrow-ctl"},ce)])}let Q=(z,K)=>{let X=ce=>t("span",{class:"dl-mono"},ce);return z?t("span",{},[" Now: ",X(z),...K&&K!==z?[", was ",X(K)]:[],"."]):t("span",{},K?[" Not found now: using ",X(K),"."]:[" Not found."])};function G(){let z=t("select",{class:"cbi-input-select","aria-label":"Internet interface",change:_=>{c=_.target.value,G()}},s.devices.filter(_=>!_.own&&!_.master&&_.zone&&!_.missing).map(_=>t("option",{value:_.name,selected:_.name===c?"selected":null},`${_.name} · zone ${_.zone}`))),X=S().flatMap(_=>_.nets.map(j=>[j,_.name])),ce=JSON.parse(N()),fe=JSON.parse(k),O=(..._)=>_.some(j=>JSON.stringify(ce[j])!==JSON.stringify(fe[j])),U=O(0,1,2),q=O(3,4),oe=_=>D("Save",async()=>{let j=await W(()=>P.serverInterfaces(a,l,l?"":c,d,[...m],p,u!=="off",u),"Access saved");j&&(b(j,!0),j.nets_changed&&j.lan_only&&F(`${j.lan_only} ${j.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:!_}),T=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Internet"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Internet or Both")]),I("home","Internet like a home device",R(),[p&&s.needs?.length?D("Install",()=>Ot("home",s.needs,()=>x(!1)),"positive"):"",ge(p,"Internet like a home device",_=>{p=_,G()})],f()),I("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",Q(s.detected.wan,s.saved.wan)],[l?"":z,ge(l,"Auto-detect WAN",_=>{l=_,G()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?["Internet like a home device",E()?[" · leaves through ",t("span",{class:"dl-mono"},E())]:""]:E()?["Internet straight to ",t("span",{class:"dl-mono"},E())]:"No WAN found"),oe(U)])]),A=xe([["off","Off"],["all","Everyone"],["circles","Circles"]],u,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async _=>{let j={off:"Off",all:"Everyone",circles:"Circles"}[_];await W(()=>P.serverUpdate(a,{mesh:_}),`Devices reach each other: ${j}`)&&(u=_,s.config.mesh=_,G(),await o())}}),$=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Home network"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Home or Both"),D([v("reset")," Rescan"],()=>x(!1),"neutral",{title:"Read the interfaces again"})]),I("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.","","",Y()),I("link","Devices reach each other",C[u],A,"",u==="circles"?ta(r,a,o):void 0),g.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},X.length?["Home access reaches ",...X.flatMap(([_,j],Z)=>[Z?", ":"",t("span",{class:"dl-mono"},_),` (${j})`])]:"No home network: Home access reaches nothing but this router."),oe(q)])]),H=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[T,$]),i.style.minHeight="",window.scrollTo({top:H})}function Y(){let z=s.devices.filter(M),K=s.devices.filter(X=>!M(X));return t("div",{class:"dl-stack gap8 dl-netpick"},[z.length?t("div",{class:"dl-ifgrid"},z.map(h)):t("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},"Auto-detect LAN"),t("span",{class:"dl-sub"},["Adds the LAN this router uses.",Q(s.detected.lan,s.saved.lan)])]),ge(d,"Auto-detect LAN",X=>{d=X,G()})]),K.length?t("details",{class:"dl-params",open:w?"":null,toggle:X=>w=X.currentTarget.open},[t("summary",{},[v("chevron"),t("span",{},"Other interfaces"),t("span",{class:"dl-pcount"},String(K.length))]),t("div",{class:"dl-params-body"},[t("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."),...Ei.map(([X,ce])=>{let fe=K.filter(O=>O.category===X);return fe.length?t("div",{class:"dl-ifgroup"},[t("h4",{},ce),t("div",{class:"dl-ifgrid"},fe.map(h))]):""})])]):""])}return x(!0),{el:i,update(z){r=z,g.update(z),s&&G()}}}var Mi={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},Si={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play"};function Ti(n,e){return e.device?n.people.flatMap(a=>a.devices).find(a=>a.id===e.device)?.kind??e.dkind??"other":Si[e.type]??"activity"}function Kn(n,e){let o=n.people.find(m=>m.id===e.person),a=o?.name??e.pname??e.person??"",r=o?.devices.find(m=>m.id===e.device)?.name??e.dname??"",i=m=>t("b",{},m),s=m=>t("span",{class:"dl-muted"},m),l=m=>t("span",{class:"dl-mono"},m),c=m=>e.hosts?.[m]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[m]),t("span",{class:"dl-faint"},` (${m})`)])]:[l(m)],d=m=>t("span",{class:"dl-ev-kind"},`${m} `),p=r?`${a} · ${r}`:a,u=yo(e),w=u||r||"a device",g=m=>[t("span",{class:"dl-you"},"You"),s(` ${m} `)];if(De(e)==="admin")switch(e.type){case"device_added":return[...g("added"),d("device"),i(w),s(" for "),i(a)];case"device_removed":return[...g("removed"),d("device"),i(w),s(" from "),i(a)];case"paused":return[...g("paused"),d("person"),i(a)];case"resumed":return[...g("resumed"),d("person"),i(a)];case"device_changed":{let m=u.startsWith("renamed from ");return[...g(m?"renamed":u),d("device"),i(r||"a device"),s(" of "),i(a),...m?[s(` · was ${u.slice(13)}`)]:[]]}case"device_keys":return[...g("issued new keys for"),d("device"),i(w),s(" of "),i(a),s(" · it needs its new configuration")];case"link_changed":return[...g("issued a new link for"),d("person"),i(a),s(" · the old link stopped working")]}switch(e.type){case"connect":return[d("Device"),i(p),s(" connected"),...e.detail?[s(" from "),...c(e.detail)]:[],...e.where?[s(` · ${e.where}`)]:[]];case"disconnect":return[d("Device"),i(p),s(" went offline")];case"roam":return[d("Device"),i(p),s(" changed network "),...(e.detail??"").split(" → ").flatMap((m,k)=>k?[s(" → "),...c(m)]:c(m))];case"device_added":return[d("Person"),i(a),s(" added "),d("device"),i(w),...De(e)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[d("Person"),i(a),s(" removed "),d("device"),i(w),...De(e)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[d("Person"),i(a),s(" issued new keys for "),d("device"),i(w),s(" on their portal")];case"person_added":return[...g("added"),d("person"),i(e.detail??a)];case"person_removed":return[...g("removed"),d("person"),i(e.detail??a)];case"person_changed":return[...g("changed"),d("person"),i(a),...u?[s(` · ${u.replace(/_/g," ")}`)]:[]];case"paused":return[d("Person"),i(a),s(` paused — ${e.detail??""}`)];case"resumed":return[d("Person"),i(a),s(" resumed"),...e.detail&&e.detail!=="active"?[s(` — ${e.detail}`)]:[]];case"portal_blocked":return[t("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(e.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[d("Person"),i(a),s(" — all devices removed, end date reached")];default:return[s(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var _i={portal_blocked:["globe","bad"]};function Ci(n,e){if(n.servers.length<2||!e.person)return"";let o=n.people.find(r=>r.id===e.person),a=o&&n.servers.find(r=>r.id===o.server);return a?t("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function Qe(n,e,o={}){let a=_i[e.type],r=De(e);return t("div",{class:`dl-row${r==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[r==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):a?t("span",{class:"dl-ev-tile sys"},v(a[0])):t("span",{class:`dl-ev-tile ev ${Mi[e.type]??""}`},v(Ti(n,e))),t("span",{class:"dl-row-main"},Kn(n,e)),o.server===!1?"":Ci(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString()},o.time??ie(e.ts,n.now))])}var Pi={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Di={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function mn(n,e,o,a){let r=n.by==="admin",i=t("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${Pi[n.level]??""}`}${n.detail?" has-detail":""}`},[r?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):t("span",{class:"dl-ev-tile sys",title:n.level},v(Di[n.src]??"zap")),t("span",{class:"dl-row-main"},r?[t("span",{class:"dl-you"},"You"),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):"",n.note?t("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},"Server "):"",t("b",{class:"dl-sys-src",title:Ct[n.src]??n.src},n.who??Ct[n.src]??n.src)," ",t("span",{class:"dl-muted"},n.msg),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString()},a)]);return n.detail&&i.addEventListener("click",s=>{s.target.closest("pre")||o()}),i}function pa(n){let e=new Date(n*1e3),o=new Date,a=new Date;return a.setDate(o.getDate()-1),e.toDateString()===o.toDateString()?"Today":e.toDateString()===a.toDateString()?"Yesterday":e.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var kt=n=>ut(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function hn(n,e,o,a=!1){let r=n.slice(-15),i=r[r.length-1],s=i&&e-i[0]<180,l=s?i[2]:0,c=s?i[1]:0,[d,p]=o,u=200,w=40,g=Math.max(1,...r.map(y=>Math.max(y[1],y[2]))),m=y=>r.map((S,b)=>`${r.length>1?b/(r.length-1)*u:u},${w-2-S[y]/g*(w-6)}`),k=m(2),N=m(1),B=r.length>1&&!a?qe(``):t("div",{class:"dl-speed-wait"},[t("i"),a?"":t("span",{},"Collecting… 1 point a minute")]),E=(y,S,b,x)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:b},S),` ${y}`]),a?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},ze(x))]);return r.length>1&&!a&&me(B,()=>{let y=r[r.length-1];return[t("div",{class:"dl-tip-title"},new Date(y[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${ze(y[2])} · ↑ ${ze(y[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Speed now"),a?"":t("span",{class:"dl-sub"},"last 15 min")]),t("div",{class:"dl-speed-cols"},[E("Download","↓","dl-dn",l),E("Upload","↑","dl-up",c)]),B,t("div",{class:"dl-speed-today"},[t("span",{},["Today ",t("b",{},te(d+p))]),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${te(p)} `,t("span",{class:"dl-up"},"↑"),` ${te(d)}`])])])}function fn(n,e){let o=n.slice(-30),a=o.map(c=>c.rx+c.tx),r=Math.max(1,...a),i=a.reduce((c,d)=>c+d,0),s=a.reduce((c,d,p)=>d>a[c]?p:c,0),l=t("div",{class:"dl-bento-bars"},o.map((c,d)=>{let p=a[d],u=t("i",{class:d===o.length-1?"hi":"",style:`height:${Math.max(4,p/r*100)}%`});return me(u,()=>[t("div",{class:"dl-tip-title"},d===o.length-1?`Today · ${kt(c.day)}`:kt(c.day)),t("div",{},te(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${te(c.tx)} ↑ ${te(c.rx)}`)]),u}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},"Last 30 days"),t("b",{class:"dl-bento-total"},te(i))]),a[s]>0?t("span",{class:"dl-sub"},`peak ${te(a[s])} · ${kt(o[s].day)}`):""]),o.length?l:t("p",{class:"dl-muted"},"No traffic yet."),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},o.length?kt(o[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},"today")])])}function ua(n){let e=n.slice(-30),o=e.map(r=>r.rx+r.tx),a=Math.max(1,...o);return t("div",{class:"dl-dbars"},e.map((r,i)=>{let s=t("i",{class:`${o[i]?"":"zero"}${i===e.length-1?" hi":""}`});return s.style.height=`${Math.max(8,o[i]/a*100)}%`,me(s,()=>[t("div",{class:"dl-tip-title"},i===e.length-1?`Today · ${kt(r.day)}`:kt(r.day)),t("div",{},te(o[i]))]),s}))}var ma={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function gn(n){return n==="netrestart"&&!await re("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await W(()=>P.healthFix(n),"Done")??null}function Jn(n,e,o,a="action"){let r=n.fix;return r?r.startsWith("install:")?D("Install",()=>da(r.slice(8),o),a):r==="updates"?t("a",{class:`cbi-button cbi-button-${a}`,href:L.url("admin/network/dawnline/updates")},ma.updates):D(ma[r]??"Fix",()=>e(r),a):""}function Ai(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="flash"?"download":n==="nft"?"lock":n==="data"?"users":"alert"}function ha(n,e,o,a=3){let r=n.filter(s=>s.status==="error"||s.status==="warn").sort((s,l)=>s.status===l.status?0:s.status==="error"?-1:1);if(!r.length)return"";let i=r.length-a;return t("div",{class:"dl-list dl-notices"},[...r.slice(0,a).map(s=>at(Ai(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,Jn(s,e,o,s.status==="error"?"positive":"neutral"))),i>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,t("span",{class:"dl-spacer"}),"→"]):""])}function zi(n){let e=[],o=(s,l)=>t("a",{href:s},l),a=Re(n.series),r=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?e.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!r&&e.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});for(let s of n.people)if(s.state==="quota")e.push({tone:"warn",text:[o(ke(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")e.push({tone:"warn",text:[o(ke(s.id),s.name),"’s access has ended."]});else{let l=nt(s.expires,a);Fe(s,l)&&e.push({tone:"",text:[o(ke(s.id),s.name),`’s access ${Gt(l)}.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&e.push({tone:"",text:[o(ke(s.id),s.name)," has used 90% of the data limit."]})}let i=n.people.flatMap(s=>s.devices.filter(l=>l.config_stale).map(l=>[s,l]));return i.length&&e.push({tone:"warn",text:i.length===1?[o(ke(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)," needs its configuration again."]:[`${i.length} devices need their configuration again (networks or DNS changed).`]}),n.servers.some(s=>s.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[`Internet through the LAN is off: ${n.like_home.error} `,o(L.url("admin/network/dawnline/diagnostics"),"Details")]}),n.settings.portal_enabled||e.push({tone:"",text:["The personal portal is off. ",o(L.url("admin/network/dawnline/settings"),"Turn on")]}),e}var vn=class{constructor(e,o){this.srvId=e;this.go=o;this.el=t("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=Rt(e,this.srvId);for(let o of["health","bento","side","activity"])this.parts[o]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,o=!1){this.st=Rt(e,this.srvId),this.paint(o),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await P.health().catch(()=>null);if(!e)return;let o=()=>void this.loadHealth(),a=async r=>{await gn(r)&&(o(),r==="netrestart"&&setTimeout(o,5e3))};Me(this.parts.health,ha(e.checks,r=>void a(r),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let e=this.st,o=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},"Where people connect from"),t("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),t("span",{class:"dl-spacer"}),xt(this.range,s=>{this.range=s,this.map?.setRange(s)})]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map?.destroy(),this.map=new Je({openPerson:s=>location.href=ke(s),openDevice:(s,l)=>location.href=ke(s,l)},this.range);let a=Ee(()=>{a(),this.map?.destroy(),this.map=null}),r=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),"Live tunnel"]),t("span",{},[t("i",{class:"line"}),"Seen recently"])]),i=t("div",{class:"dl-map-wrap"},[this.map.el,r]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),t("div",{class:"dl-panel flush"},[o,i])}paint(e=!1){let o=this.st,a=o.servers[0];Me(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Ie(a).overviewTile(a),this.monthTile()]),e);let r=zi(o);Me(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Needs attention"),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),r.length?r.slice(0,8).map(s=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${s.tone}`}),t("span",{},s.text),s.action??""])):t("div",{class:"dl-row dl-muted"},[v("check"),"All good. Nothing needs you right now."])]),e);let i=[...o.events].reverse().slice(0,8);Me(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),i.length?i.map(s=>Qe(o,s)):t("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),e)}onlineTile(){let e=this.st,o=e.servers[0]?!e.servers[0].enabled:!1,a=12,r=B=>B.spark[B.spark.length-1]??0,i=B=>e.geo.points.find(E=>E.device===B.id&&E.city)?.city,s=B=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(B.endpoint??""),l=(B,E=!1)=>s(B)?E&&B.endpoint?`LAN · ${B.endpoint}`:"LAN":i(B)??"",c=B=>[...e.events].reverse().find(E=>E.type==="connect"&&E.device===B.id)?.ts??0,d=e.people.map(B=>({p:B,devs:B.devices.filter(E=>E.online).sort((E,y)=>r(y)-r(E))})).filter(B=>B.devs.length).sort((B,E)=>E.devs.reduce((y,S)=>y+r(S),0)-B.devs.reduce((y,S)=>y+r(S),0)),p=d.length<=2,u=({p:B,devs:E})=>{let y=E.map(c).filter(Boolean),S=y.length?Math.min(...y):0,b=(B.rate??[]).slice(-15),x=b[b.length-1],M=x&&e.now-x[0]<180?x:null,h=200,f=30,R=Math.max(1,...b.map(Y=>Math.max(Y[1],Y[2]))),C=Y=>b.map((z,K)=>`${b.length>1?K/(b.length-1)*h:h},${f-2-z[Y]/R*(f-6)}`),I=b.length>1?qe(``):"",Q=!M||M[1]<64&&M[2]<64,G=B.access==="both"?["home","globe"]:B.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},Pe(B.name)),t("span",{class:"dl-stack"},[t("b",{},B.name),t("span",{class:"dl-hc-since"},S?`online for ${ie(S,e.now).replace(" ago","")}`:"online")]),t("span",{class:"dl-hc-reach"},G.map(Y=>t("span",{class:`dl-ibadge ${Y==="home"?"lan":"inet"}`},v(Y))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},Q?[t("span",{class:"dl-faint"},"Idle right now")]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${ze(M[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${ze(M[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},"15 min")]),I]),t("div",{class:"dl-hc-devs"},E.map(Y=>t("span",{class:"dl-hc-dev"},[v(Y.kind),Y.name,l(Y)?[" · ",l(Y,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${te(E.reduce((Y,z)=>Y+r(z),0))} today · ${te(B.month[0]+B.month[1])} this month`)])])]},w=B=>{let{p:E,devs:y}=B,S=t("span",{class:"dl-onl-dev"},y.length>1?String(y.length):v(y[0].kind)),b=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:ke(E.id),"aria-label":`${E.name}, online`},[t("span",{class:"dl-onl-av"},[Pe(E.name),S]),p?t("span",{class:"dl-onl-name"},E.name):"",p?t("span",{class:"dl-onl-meta"},[...y.slice(0,3).map(x=>v(x.kind)),y.length>3?`+${y.length-3}`:"",l(y[0])?t("span",{},[" · ",l(y[0])]):""]):""]);return me(b,()=>u(B)),b},g=t("b",{class:`dl-onl-count${d.length?"":" none"}`},String(d.length)),m=d.reduce((B,E)=>B+E.devs.length,0);d.length&&me(g,()=>[`${d.length} ${d.length===1?"person":"people"} · ${m} device${m===1?"":"s"}`]);let k=d.length>a?d.slice(0,a-1):d,N=e.people.flatMap(B=>B.devices.map(E=>({p:B,d:E}))).filter(B=>B.d.handshake).sort((B,E)=>E.d.handshake-B.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Online"),g]),d.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...k.map(w),d.length>a?t("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:B=>{this.go&&(B.preventDefault(),this.go("people","online"))}},[t("span",{class:"dl-onl-av"},`+${d.length-k.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},o?"The server is turned off":"Nobody is connected"),N?t("span",{class:"dl-sub"},`Last: ${N.p.name}, ${ie(N.d.handshake,e.now)}`):t("span",{class:"dl-sub"},o?"Devices connect once it is on":"No device has connected yet")])])}speedTile(){let e=this.st.servers[0];return hn(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){return fn(this.st.series,"")}};var fa=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],Ni={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},Vn=(n,e)=>{let o=new URLSearchParams;n&&o.set("server",n),e&&e!=="overview"&&o.set("section",e);let a=o.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},jt=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await P.status(31),o=e.servers.length?null:await P.setupDefaults();return[e,o]}render([e,o]){if(this.st=e,!e.servers.length&&o)return this.wizard(o);let a=new URLSearchParams(location.search),r=a.get("section")??"",i=Ni[r]??r;return fa.some(([s])=>s===i)&&(this.section=i),this.srvId=(e.servers.find(s=>s.id===a.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller?.stop(),this.poller=Ve({fetch:()=>P.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(s,l)=>{s.servers.length&&(this.st=s,this.paintHead(l),this.ov[this.current().id]?.update(s,l))}}),this.root}paintHead(e=!1){Me(this.headEl,this.head(this.current()),e),(!e||!yt(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await P.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await P.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=Vn())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(o=>t("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===e.id?" on":""}`,"aria-selected":o.id===e.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[t("i",{class:`dot ${o.enabled?o.up?"ok":"bad":"warn"}`}),t("b",{},o.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[v("plus"),"Add server"])]))}paintSections(){let e=Ie(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},fa.map(([o,a])=>t("button",{type:"button",role:"tab","data-section":o,class:o===this.section?"on":"","aria-selected":o===this.section?"true":"false",click:()=>this.showSection(o)},o==="awg"?e.label:a))))}go(e,o){let a=this.pp[this.current().id];if(o&&a)a.filter=o,a.el&&a.decorate();else if(o){let r=this.pp[this.current().id]=new st;r.filter=o}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of e)o&&this.bodyEl.contains(o)&&o.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===e;s.classList.toggle("on",l),s.setAttribute("aria-selected",l?"true":"false")});let o=this.st,a=this.current(),i={overview:()=>{let s=this.ov[a.id];return s?(s.update(o),s.el):(this.ov[a.id]=new vn(a.id,(l,c)=>this.go(l,c))).mount(o)},people:()=>{var d,p;let s=this.pp[a.id];if(s?.el)return s.update(),s.el;let l=t("div",{},t("p",{class:"dl-muted"},"Loading people…"));return((d=this.pp)[p=a.id]??(d[p]=new st)).embed(o,a.id).then(u=>{l.isConnected?dom.content(l,u):l.replaceChildren(u)}).catch(u=>{delete this.pp[a.id],dom.content(l,t("p",{class:"dl-muted"},`Couldn't show people: ${ve(u)}`))}),l},connection:()=>this.connection(a),access:()=>this.access(a),awg:()=>this.awg(a)}[e]();this.detachKept(),dom.content(this.bodyEl,i)}head(e){let o=(i,s)=>t("span",{class:"dl-addrbar-seg"},[v(i),...s]),a=e.endpoint||"—",r=t("div",{class:"dl-actions"},[e.enabled?"":D([v("play")," Turn on"],()=>this.save(e,{enabled:"1"},"Server turned on"),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?"Running":e.blocked?"Can’t start":"Not running":"Turned off"),t("span",{class:"dl-spacer"}),r]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>ue(a,"Address copied")},[v("globe"),t("span",{class:"dl-mono"},a),v("copy")]),o("tunnel",[t("span",{class:"dl-mono"},`${Ie(e).label} :${e.port}`)]),e.up?o("clock",[`up ${pt(e.uptime)}`]):""]),e.blocked?t("div",{class:"dl-note warn"},[v("alert"),t("span",{},`${e.name} ${e.blocked}.`)]):""])}async save(e,o,a="Saved"){await W(()=>P.serverUpdate(e.id,o),a)&&await this.refresh()}connection(e){let o=se(e.name,{placeholder:"Home"}),a=se(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),r=se(e.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter(l=>l.server===e.id).length,s=D(e.enabled?"Turn off":"Turn on",async()=>{e.enabled&&!await re(`Turn off ${e.name}?`,`The tunnel stops and ${i} ${i===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?"Server turned off":"Server turned on")},e.enabled?"negative":"positive");return t("div",{class:"dl-stack gap16"},[Tt("Connection",[t("p",{class:"dl-muted"},"The name people see, where devices find the router, and DNS. The port is on AmneziaWG."),he("router","Server","What people see",[ne("Name",o,"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[ne("Public address",a,"Hostname or IP of the router on the internet. A DDNS name keeps links working when your IP changes. It must not go through Cloudflare: use a DNS-only name or an IP.")]),he("file","For every device","Changing it marks devices “Update config” until they import again",[ne("DNS for devices",r,"Empty = this router, which sends each query where your home network would.")])],[t("span"),D("Save",()=>this.save(e,{name:o.value,endpoint:a.value,dns:r.value}),"positive")]),Tt("Danger zone",[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?"Turn off this server":"This server is off"),t("span",{class:"dl-sub"},e.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.")]),t("div",{class:"dl-setrow-ctl"},s)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Remove server"),t("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),t("div",{class:"dl-setrow-ctl"},D([v("trash")," Remove"],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let o=qn(this.st,e),a=ca(e,this.st,async()=>{let r=await this.refreshStatus();if(!r)return;let i=r.servers.find(l=>l.id===e.id)??e;a.update(r);let s=qn(r,i);o.replaceWith(s),o=s});return t("div",{class:"dl-stack gap16"},[a.el,t("div",{class:"dl-health-cols"},[o,na(this.st,e)])])}awg(e){let o={st:this.st,save:(a,r)=>this.save(e,a,r),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[Ie(e).settingsCard(o,e)])}async addServer(){let e=await W(()=>P.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async remove(e){let o=this.st.people.filter(a=>a.server===e.id);ae(`Remove ${e.name}?`,[t("p",{},`This removes the tunnel, its firewall rules and ${o.length} ${o.length===1?"person":"people"} with all their devices. A backup is made first.`)],[le()," ",D("Remove",async()=>{de(),await W(()=>P.serverDelete(e.id),"Server removed")&&setTimeout(()=>{location.href=Vn()},800)},"negative")])}wizard(e,o=!1,a){let r={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:sn(e.subnet),preset:"standard",portal:!1,portal_port:e.portal_port||8443,lan_like:!0,lan_zone:e.lan_zone,wan_zone:e.wan_zone},i=0,s=!o&&r.portal_port===r.port,l=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(r.endpoint),c=()=>Gn(r.port,e.udp_taken??[],"Opened on the WAN firewall automatically."),d=()=>Zo(r.range,e.networks??[],sn(e.subnet)),p=()=>It(r.portal_port,e.tcp_taken??[],l()),u=t("div",{class:"dl-wizard"}),w=(b,x={})=>{let M=se(String(r[b]),x);return M.addEventListener("input",()=>{b==="port"||b==="portal_port"?r[b]=M.value.trim()===""?0:Number(M.value):r[b]=M.value.trim(),b==="port"&&s&&(r.portal_port=r.port),b==="portal_port"&&(s=r.portal_port===r.port)}),M},g={id:"server",title:"Server",render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),he("router","Server","What people see",[ne("Name",w("name"),"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[ne("Public address",w("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),"Hostname or IP address of your router on the internet. Not through Cloudflare: use a DNS-only name or an IP.")])]),check:()=>r.endpoint?null:"Fill in the public address."},m={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[he("globe","Listening","Where devices reach AmneziaWG from the internet",[mt("UDP port",w("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),c)]),he("network","Tunnel network","Addresses devices get inside the tunnel",[(()=>{let b=w("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":"First three numbers of the device addresses"});return mt("Device addresses",b,d,t("span",{class:"dl-suffixed"},[b,t("span",{class:"dl-mono"},".x")]))})()]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Qt(e.awg,r.preset,b=>r.preset=b,void 0,e.awg_state?.tools!==!1)])]),check:()=>{let b=c();if(b.bad)return`UDP port: ${b.text}`;let x=d();return x.bad?`Device addresses: ${x.text}`:null}},k={id:"portal",title:"Portal",render:()=>{let b=w("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),x=mt("Listening port",b,p);x.hidden=!r.portal;let M=xe([["off","Off"],["on","On"]],r.portal?"on":"off",{label:"Personal portal",onChange:h=>{r.portal=h==="on",x.hidden=!r.portal}});return t("div",{class:"dl-wizard-groups"},[he("home","Internet like a home device","How devices reach the internet",[ne("Through the home network",ge(r.lan_like,"Internet like a home device",h=>r.lan_like=h),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),he("link","Personal portal","A page where each person adds their own devices with their personal link",[ne("Portal",M,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),x])])},check:()=>{if(!r.portal)return null;let b=p();return b.bad?`Portal port: ${b.text}`:null}},N=()=>[g,m,o?null:k].filter(b=>b!=null),B=e.awg_state,E=B?.missing??[],y=E.length?t("div",{class:"dl-list dl-notices"},[at("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${E.join(" and ")}. Install the build made for this firmware, then create the server.`,D("Install",()=>un(()=>location.reload()),"positive"))]):B&&!B.loaded?t("div",{class:"dl-list dl-notices"},[at("shield","warn","AmneziaWG’s kernel module doesn’t load on this firmware","Try another build in Components, or update OpenWrt. The server can’t start until it loads.",t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",S=()=>{let b=N();i>=b.length&&(i=b.length-1),dom.content(u,[t("h2",{},o?"Add a server":"Set up Dawnline"),y,t("div",{class:"dl-steps"},b.map((x,M)=>t("span",{class:`dl-step${M===i?" current":M0?D("Back",()=>{i--,S()}):a?D("Cancel",a):"",t("span",{class:"dl-spacer"}),i{let x=b[i].check?.();if(x){F(x,"warning");return}i++,S()},"positive"):D("Create server",async()=>{for(let M of b){let h=M.check?.();if(h){F(h,"warning");return}}let x=await W(()=>P.serverCreate(r.id,r.name,e.ifname,r.port,Wn(r.range),r.endpoint,e.mtu,r.preset,r.lan_zone,r.wan_zone,r.lan_like,o?void 0:r.portal,o?void 0:r.portal_port),"Server created");x&&(x.network_restart&&F("Restarting the network so it knows AmneziaWG: back in a few seconds"),setTimeout(()=>{location.href=Vn(x.id)},x.network_restart?1e4:1500))},"positive",{disabled:E.length>0,title:E.length?"Install AmneziaWG first":null})])])};return S(),u}};function Xe(n){let e={el:n(),refresh(){let o=n();e.el.replaceWith(o),e.el=o}};return e}function Ae(n,e,o,a,r="",i=[]){return t("section",{class:`dl-setsec ${r}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[i.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...i]):t("h3",{},e),...o]),a.length?t("div",{class:"dl-setsec-foot"},a):""])}function ga(n){let e=n.filter(r=>r.status!=="skip"),o=e.filter(r=>r.status==="error"||r.status==="warn"),a=e.some(r=>r.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:a}}function va(n){let e=n.d.settings,o=n.d.effective,a=n.d.cert,r=ge(o.portal_enabled,"Enable portal"),i=se(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=se(e.portal_title,{placeholder:"Dawnline"}),l=se(e.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"}),d=O=>/^\d{1,3}(\.\d{1,3}){3}$/.test(O),p=[o.portal_host,...o.portal_alt??[]].filter((O,U,q)=>O&&q.indexOf(O)===U),u=!!n.portal,w=[],g=O=>{O&&!w.some(U=>U.host===O)&&w.push({host:O,kind:d(O)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},m=O=>{w=[...O,...w.filter(U=>!O.some(q=>q.host===U.host))],!p.length&&O[0]&&(p=[O[0].host])};n.portal&&m(n.portal.candidates),p.forEach(g);let k=O=>O.kind==="ip"?t("span",{class:"dl-addr-warn"},[v("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):t("span",{class:"dl-sub"},O.cloudflare?"Behind Cloudflare · often stalls in Russia":O.ips.length?O.here?`Points at this router${O.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${O.ips.join(", ")}, not this router`:u?"Your address":"Checking where it points…"),N=t("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),B=O=>{p.includes(O)?p.length>1&&(p=p.filter(U=>U!==O)):p=[...p,O],E(),b()},E=()=>dom.content(N,[...w.map(O=>{let U=p.includes(O.host),q=p[0]===O.host;return t("div",{class:`dl-addr-opt${U?" on":""}`,role:"checkbox","aria-checked":U?"true":"false",tabindex:"0",click:()=>B(O.host),keydown:oe=>{(oe.key===" "||oe.key==="Enter")&&(oe.preventDefault(),B(O.host))}},[t("i",{class:"dl-addr-check"},U?v("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},O.host),k(O)]),q?t("span",{class:"dl-pill info"},"Main"):U?t("button",{type:"button",class:"dl-linkbtn",click:oe=>{oe.stopPropagation(),p=[O.host,...p.filter(T=>T!==O.host)],E(),b()}},"Make main"):O.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):O.kind==="ip"?t("span",{class:"dl-pill"},"IP"):O.here&&O.cert?t("span",{class:"dl-pill ok"},"Recommended"):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},v("plus")),c,D("Add",()=>{let O=c.value.trim().toLowerCase();O&&(g(O),p.includes(O)||(p=[...p,O]),c.value="",E(),b())})])]);c.addEventListener("keydown",O=>{O.key==="Enter"&&(O.preventDefault(),c.nextElementSibling?.click())});let y=t("div",{class:"dl-links"}),S=()=>{},b=()=>{S();let O=Number(i.value)||o.portal_port;dom.content(y,p.map((U,q)=>{let oe=d(U),T=oe?O+1:O,A=`${oe?"http":"https"}://${U}${T===(oe?80:443)?"":`:${T}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${oe?"warn":"ok"}`},v(oe?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[A,t("b",{},"kamiro-telosu-bavine")]),q===0?t("span",{class:"dl-pill info"},"Main"):oe?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};E(),b(),i.addEventListener("input",()=>b());let x={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},M=n.d.needs??{https:[],acme:[],home:[]},h=O=>{if(!o.portal_enabled)return t("div",{hidden:!0});if(!O)return he("check","Ready to share","The portal’s checks from Health",[t("p",{class:"dl-muted dl-loading"},"Running checks…")]);let U=O.filter($=>$.status!=="skip");if(!U.length)return t("div",{hidden:!0});let{bad:q,worst:oe}=ga(O),T=t("div",{class:"dl-ready-details",hidden:!0},U.map($=>t("div",{class:`dl-ready-item ${$.status}`},[v($.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},$.title),t("span",{class:"dl-sub"},$.detail)])]))),A=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${oe}`},[v(oe==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},oe==="ok"?`All ${U.length} checks passed`:`${U.length-q.length} of ${U.length} checks passed`),q.length?t("span",{class:"dl-sub"},q.map($=>$.detail).join(" ")):t("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),t("button",{type:"button",class:"dl-linkbtn",click:$=>{T.hidden=!T.hidden,$.currentTarget.textContent=T.hidden?"Details":"Hide"}},"Details")]),t("div",{class:"dl-chips-row"},U.map($=>t("span",{class:`dl-check-chip ${$.status}`,title:$.detail},[v($.status==="ok"?"check":"alert"),x[$.id]??$.title]))),T]);return he("check","Ready to share","The portal’s checks from Health",[A])},f=O=>{if(!o.portal_enabled||!O&&!M.https.length)return t("span",{hidden:!0});if(M.https.length)return t("span",{class:"dl-pill bad"},"Can’t start");let{worst:U}=ga(O);return t("span",{class:`dl-pill ${U==="ok"?"ok":U==="error"?"bad":"warn"}`},U==="error"?"Needs attention":"Ready")},R=h(n.portal?.checks??null),C=f(n.portal?.checks??null);n.portalFill=O=>{u=!0,m(O.candidates),E(),b();let U=h(O.checks);R.replaceWith(U),R=U;let q=f(O.checks);C.replaceWith(q),C=q};let I=a&&!a.self_signed&&a.expires?He(a.expires):"",Q=mt("Listening port",i,()=>It(i.value.trim()===""?o.portal_port:Number(i.value),n.d.tcp_taken??[],p.some(d)));S=Q.refresh;let G=!!(e.portal_cert&&e.portal_key),Y=a?G?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",z=()=>{let O=se(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),U=se(e.portal_key,{placeholder:"/etc/ssl/…/key"});ae("Use your own certificate",[t("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),ne("Certificate file",O),ne("Key file",U)],[le()," ",D("Save",()=>{de(),n.save({portal_cert:O.value.trim(),portal_key:U.value.trim()},"Certificate saved","portal")},"positive")])},K=(O,U,q,oe,T,A)=>at(O,U,q,oe,D(A,()=>Ot(T,M[T],()=>n.reload("portal")),"positive")),X=M.https.length?K("lock","bad","HTTPS isn’t available on this router",`The portal needs ${M.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",ce=M.acme.length&&(!a||a.self_signed)?K("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${e.portal_host?` for ${e.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",fe=[t("div",{class:"dl-row"},[v("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[Y,I?t("span",{class:"dl-faint"},` · until ${I}`):""]),t("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.":`${G?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),t("div",{class:"dl-row"},[v("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Your own files"),t("span",{class:"dl-sub"},G?`${e.portal_cert} · ${e.portal_key}`:"Not set: the certificate is picked automatically.")]),G?D("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",D(G?"Change":"Use files",z)]),ce];return Ae("portal","Personal portal",[t("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),X?t("div",{class:"dl-list"},[X]):"",he("network","Port","How the portal listens (80 and 443 stay free)",[Q]),he("edit","Appearance","What people see",[ne("Title",s,"Shown at the top of the portal."),ne("Unknown links",l,"Where a wrong or old link goes, for example your website. Empty shows a plain “Not found”.")]),he("link","Addresses","Pick one or more; the first is the main link",[N,t("div",{class:"dl-stack gap8"},[y,t("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),he("lock","Certificate","Used for HTTPS links",fe),R],[t("span"),D("Save",()=>{let O=It(i.value.trim()===""?o.portal_port:Number(i.value),n.d.tcp_taken??[],p.some(d));if(O.bad){F(`Listening port: ${O.text}`,"warning");return}return n.save({portal_enabled:Se(r)?"1":"0",portal_host:p[0]??"",portal_alt:p.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:l.value.trim()},"Saved","portal")},"positive")],"",[C,r])}function ba(n){let e=n.d.settings,o=n.d.effective,a=se(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),r=ge(o.hostnames,"Device hostnames"),i=se(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=se(e.home_dns_fallback==="none"?"":e.home_dns_fallback||o.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"});return Ae("defaults","Defaults",[ne("Devices per person",a,"Pre-filled when you add someone."),ne("Device hostnames",t("div",{class:"dl-hostport"},[r,t("span",{class:"dl-faint dl-mono"},"phone.myata."),i]),"Name devices in your home DNS."),ne("Fallback DNS",s,"For Home-only devices using home names: the second DNS server, used by the device when the tunnel is down. Empty = none.")],[t("span"),D("Save",()=>n.save({default_device_limit:a.value,hostnames:Se(r)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults"),"positive")])}function xa(n){let e=n.d.effective,o=ge(e.geo_enabled,"Locations"),a=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Ae("map","Map & locations",[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),o]),ne("Provider",a)],[t("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."),D("Save",()=>n.save({geo_enabled:Se(o)?"1":"0",geo_provider:a.value},"Saved","map"),"positive")])}var Hi=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function wa(n){let e=n.d.effective.updates,o=ge(e.check,"Check automatically",m=>g(m,Se(r))),a=xe([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],e.interval,{label:"How often",cls:"sm"}),r=ge(e.auto,"Install automatically",m=>g(Se(o),m)),i=se(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":"Time"}),s=xe([["scheduled","At a set time"],["immediate","As soon as found"]],e.mode,{label:"When",cls:"sm",onChange:m=>i.hidden=m!=="scheduled"});i.hidden=e.mode!=="scheduled";let l=new Set(e.targets),c=t("div",{class:"dl-chips-row"},Hi.map(([m,k])=>{let N=We(k,l.has(m),()=>{l.delete(m)||l.add(m),Zt(N,l.has(m))});return N})),d=ge(e.keep,"Keep the previous version"),p=ge(e.mirrors,"GitHub mirrors"),u=ne("How often",a),w=[ne("When",t("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),ne("Components",c,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],g=(m,k)=>{u.hidden=!m;for(let N of w)N.hidden=!k};return g(e.check,e.auto),Ae("updates","Updates",[t("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),ne("Check automatically",o,"Looks for new versions in the background; Components shows what it found and the service log names it."),u,ne("Install automatically",r,"Downloads and installs new versions of the components below."),...w,ne("Keep the previous version",d,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),ne("GitHub mirrors",p,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[t("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),D("Save",()=>n.save({update_check:Se(o)?"1":"0",update_interval:a.dataset.value,update_auto:Se(r)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Se(d)?"1":"0",update_mirrors:Se(p)?"1":"0"},"Saved","updates"),"positive")])}function ya(n){let e=n.d.logs,o=e.policy,a=xe([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(o.keep_days),{label:"Keep activity",cls:"sm"}),r=xe([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(o.max),{label:"Maximum events",cls:"sm"}),i=xe([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],o.persist,{label:"Save to flash",cls:"sm"}),s=xe([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(o.usage_days),{label:"Daily traffic",cls:"sm"}),l=xe([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(o.usage_months),{label:"Monthly traffic",cls:"sm"}),c=new Set(o.categories),d=t("div",{class:"dl-chips-row"},gt.map(g=>{let m=We([rt[g],t("b",{},String(e.by_category[g]??0))],c.has(g),()=>{c.delete(g)||c.add(g),Zt(m,c.has(g))},{title:wo[g]});return m})),p=e.oldest?He(new Date(e.oldest*1e3)):"",u=(g,m,k,N)=>t("div",{class:"dl-row"},[v(g),t("span",{class:"dl-row-main dl-stack"},[t("b",{},m),t("span",{class:"dl-sub"},k)]),...N]),w=g=>D(g.toUpperCase(),async()=>{let[m,k]=await Promise.all([P.status(1),P.events(2e4)]);Ue(m,k.events,g)},"neutral",{title:`Download the log as ${g.toUpperCase()}`});return Ae("logs","Logs & history",[t("p",{class:"dl-muted"},Yt(o)),ne("Keep activity",a,"Older events are removed automatically."),ne("Maximum size",r,"Newest events are kept when the log is full."),ne("Record",d,"Switched-off categories are not logged from now on."),ne("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),ne("Daily traffic",s,"Per-day history behind the charts."),ne("Monthly traffic",l,"Per-month totals; data limits use the current month."),t("h4",{class:"dl-setsub"},"Stored data"),t("div",{class:"dl-list"},[u("activity","Activity log",e.events?`${Ft(e.events,"event")} since ${p} · ${St(e.log_ram)} in memory${o.persist==="off"?"":`, ${St(e.log_flash)} on flash`}`:"Empty",[w("csv"),w("json"),D("Clear",()=>Ke("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),u("chart","Traffic history",e.usage_days?`${Ft(e.usage_days,"day")} since ${He(e.usage_since)} · ${St(e.usage_flash)} on flash`:"Empty",[D("Reset",()=>vt("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),u("pin","Location cache",`${Ft(n.d.geo_cached,"address","addresses")} · ${St(e.geo_flash)} on flash`,[D("Clear",async()=>{await W(()=>P.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},"Clear one person or device from their own page."),D("Save",()=>n.save({log_keep_days:a.dataset.value,log_max:r.dataset.value,log_persist:i.dataset.value,usage_keep_days:s.dataset.value,usage_keep_months:l.dataset.value,log_category:[...c]},"Saved","logs"),"positive")])}var Ri={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},ka=3;function Yn(n){let e=new Date(n*1e3),o=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),a=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return`${a===0?"Today":a===1?"Yesterday":e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${o}`}async function Ii(n){let e=await W(()=>P.backupRead(n.name));if(!e)return;let o=atob(e.data),a=new Uint8Array(o.length);for(let i=0;iIi(n),"neutral","dl-icon-only"),$e("more","More",o=>we(o.currentTarget,[{label:"Restore",icon:v("reset"),run:async()=>{await re("Restore this backup?",`Everything returns to ${Yn(n.created)}. The current state is backed up first.`,"Restore",!0)&&await W(()=>P.backupRestore(n.name),"Restored")&&e(!0)}},{label:"Delete",icon:v("trash"),danger:!0,run:async()=>{await re("Delete this backup?",`The backup from ${Yn(n.created)} is removed from the router.`,"Delete",!0)&&await W(()=>P.backupDelete(n.name),"Backup deleted")&&e()}}]),"neutral","dl-icon-only")])])}function Ea(n,e){let o=n.slice(0,ka).map(c=>$a(c,e)),a=n.slice(ka),r=n.length?t("div",{class:"dl-list"},[...o,a.length?t("details",{class:"dl-bk-older"},[t("summary",{},[v("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(c=>$a(c,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=D("Restore from file",async()=>{let c=await _n(".tar.gz,.tgz,application/gzip","base64");if(!c)return;await re("Restore from file?",`Replace the current Dawnline configuration with ${c.name}? The current state is backed up first.`,"Restore",!0)&&await W(()=>P.backupUpload(c.data),"Restored")&&e(!0)}),s=D("Export JSON",async()=>{let c=await W(()=>P.exportJson());c&&Le(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(c,null,2),"application/json")}),l=D("Import JSON",async()=>{let c=await _n(".json,application/json","text");if(!c)return;let d;try{d=JSON.parse(c.data)}catch{F("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 W(()=>P.importJson(d),"Imported")&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},"Backups"),t("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),t("span",{class:"dl-spacer"}),D([v("plus")," Back up now"],async()=>{await W(()=>P.backupCreate(),"Backup created")&&e()},"positive")]),r]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),t("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function Bi(){let n=se("",{placeholder:"remove"}),e=D("Remove Dawnline",async()=>{await W(()=>P.uninstall(n.value.trim()),"Dawnline removed")&&(de(),setTimeout(()=>location.reload(),800))},"negative",{disabled:!0});n.addEventListener("input",()=>{e.disabled=n.value.trim()!=="remove"}),ae("Remove Dawnline?",[t("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[le()," ",e])}function La(){return Ae("danger","Remove Dawnline from this router",[t("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.")],[t("span"),D("Remove",()=>Bi(),"negative")],"danger")}var bn=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return P.settingsGet()}render(e){this.d=e,this.cards={portal:Xe(()=>va(this)),defaults:Xe(()=>ba(this)),map:Xe(()=>xa(this)),updates:Xe(()=>wa(this)),logs:Xe(()=>ya(this)),backups:Xe(()=>Ea(this.backups,r=>this.loadBackups(r))),danger:Xe(()=>La())};let o=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,o.map(r=>this.cards[r].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let a=new URLSearchParams(location.search).get("section");return a&&a!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${a}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(e,o,a){let r=await W(()=>P.settingsUpdate(e),o);r&&(this.d=r,this.cards[a].refresh(),a==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,o=await P.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let o=await P.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(e){let o=await P.settingsGet().catch(()=>null);if(o){if(this.d=o,e)this.cards[e].refresh();else for(let a of Object.values(this.cards))a.refresh();(!e||e==="portal")&&this.loadPortal()}}};function Ma(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function Sa(n){let e=[],o=l=>{let c=[],d=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=d.exec(l);)u.index>p&&c.push(l.slice(p,u.index)),u[1]?c.push(t("code",{},u[1].slice(1,-1))):u[2]?c.push(t("b",{},u[2].slice(2,-2))):u[3]?c.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&c.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{r.length&&e.push(t("p",{},o(r.join(" ")))),r=[],a=null};for(let l of n.replace(/\r/g,"").split(` +`,cr(s,e)]:[cr(s,e)])),a=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(a,[b(e?"x":"key"),e?"Hide key":"Show key"]),r()}},[b("key"),"Show key"]);r();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),H([b("download")," Download"],()=>Se(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),a,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),pe(n.conf,"Configuration copied")}},[b("copy"),"Copy"])]),o])])}function eo(n){let e=n.amnezia.obfuscation??{},o={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([r,a])=>a==null||a===""||a===(o[r]??"0"))}async function zi(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await Xn(n,`${n.server} · ${n.person} · ${n.name}`),r={qr:()=>t("div",{class:"dl-qr-pane"},[Xe(Ct(n.conf),"dl-qr"),t("span",{class:"dl-sub"},eo(n)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},o),H("Copy",()=>pe(o,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>Hi(n)},a=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(c=>c.classList.toggle("on",c.dataset.id===l)),dom.content(a,r[l]())};for(let[l,c]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},c));return s(e),t("div",{class:"dl-stack gap12"},[i,a])}async function Ni(n,e,o,r){let a=jt(o),s=n.st.people.filter(c=>c.server===e.id).reduce((c,d)=>c+d.devices.length,0);await se(r?"Generate new disguise values?":`Switch to ${a.title}?`,`${s} AmneziaWG device${s===1?" stops":"s stop"} connecting until ${s===1?"it imports its":"they import their"} configuration again (from their personal link or from you).${o==="max"?" They need an app with AmneziaWG 3.1.":o==="balanced"?" They need an app with AmneziaWG 2.0 or newer.":""}${n.st.servers.length===1&&s?" To keep the old disguise for some people, add a second server and move them there.":""}`,r?"Generate and apply":"Switch and apply",!0)&&await W(()=>A.serverObfuscation(e.id,o),r?"New values applied":`${a.title} applied`)&&(U("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function Ri(n,e){let o=n.st,r=ie(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=ie(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=ie(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=jt(e.preset)?e.preset:void 0,l=s??un(o.awg),c=H("",()=>Ni(n,e,l,l===s),"neutral"),d=()=>dom.content(c,l===s?[b("reset")," Generate new values"]:[`Switch to ${jt(l).title}`]);d();let p=o.awg_state?.tools!==!1,u=[],w=fe("UDP port",r,()=>It(Number(r.value),u,`Opened on the WAN firewall automatically.${Number(r.value)===4500?" 4500 is IPsec’s port: most networks let it through.":""}`));A.serverPorts(e.id).then(m=>{u=m.udp_taken??[],w.refresh()}).catch(()=>{});let C=fe("MTU",a,()=>Bo(a.value,e.mtus)),g=fe("Keep-alive",i,()=>Oo(i.value));return Rt("",[lr("AmneziaWG",e.ifname),ge("globe","Listening","Where devices reach this core from the internet",[w]),ge("file","In every device configuration","Changing these marks devices “Update config” until they import again",[C,g]),ge("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Ut(e.preset)?ct("warn",[t("b",{},Ut(e.preset))," is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to ",t("b",{},"Balanced")," or ",t("b",{},"Maximum"),": devices import their configuration again."]):"",mn(o.awg,l,m=>{l=m,d()},s,p),p&&!o.awg.v3?ct("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",Ai(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),c])]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[de("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),de("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),de("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),H([b("copy")],()=>pe(e.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),H("Save",()=>{let m=ze([w,C,g]);if(m){U(m,"warning");return}return n.save({port:r.value,mtu:a.value,keepalive:i.value},"AmneziaWG saved")},"positive")])}function Ii(n){let e=jt(n.preset),o=n.obf??{},r=(s,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(c=>t("i",{class:c+o[s]).map(s=>`${s.toUpperCase()} ${o[s]}`);return i.length&&a.push(i.slice(0,2).join(" · ")+(i.length>2?` +${i.length-2}`:"")),["h1","h2","h3","h4"].some(s=>o[s]&&o[s]!==String(["h1","h2","h3","h4"].indexOf(s)+1))&&a.push("H1–H4 random"),o.i1&&a.push(/0x(8580|0100)0001/.test(o.i1)?"DNS-like first packets":"Signature packets"),o.header_protection_key&&a.push("Encrypted headers"),a.length||a.push(e?.id==="off"?"Plain WireGuard":"No values yet"),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Disguise"),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),t("div",{class:"dl-disg-id"},[t("span",{class:"dl-disg-ic"},b(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:Ut(n.preset)??"Custom"),t("span",{class:"dl-sub"},e?e.short:Ut(n.preset)?"Switch to Balanced or Maximum":"Set by hand")])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},"Stealth"),r(e.stealth,"acc"),t("span",{},"Speed"),r(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},a.map(s=>t("span",{},s)))])}var to={id:"awg",label:"AmneziaWG",settingsCard:Ri,overviewTile:Ii,connectBlock:zi,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>Xn(n,`${n.server} · ${n.person} · ${n.name}`)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var Bi={awg:to};function Be(n){return Bi[n?.core||"awg"]??to}function Mt(n,e){return Be(n.find(o=>o.id===e))}var Oi=2,Wt=new Set,no=null,hn=null;async function pr(){if(document.visibilityState!=="visible"||!Wt.size)return;let n=await A.rev().catch(()=>null);if(!n)return;let e=no!=null&&n.rev!==no;no=n.rev,n.version&&(hn&&n.version!==hn?(U(`Dawnline was updated to ${n.version}: reload the page.`,"warning",15e3),hn=null):hn??(hn=n.version)),e&&Wt.forEach(o=>o())}function fn(n){return Wt.add(n),poll.add(pr,Oi),()=>{Wt.delete(n),Wt.size||poll.remove(pr)}}var oo="https://unpkg.com/maplibre-gl@6.14.0/dist",ur={module:"sha384-q26X6R1yFeg0QR9SHHn6U3Nb0ddRRTtwxsahubv5R89/v5nijKpk9KviUp9ZLySk",css:"sha384-1TZtfVz7qtwR5vD7cMwjGT+9uiK4lqE3pbUOPwYO6OCpb+TYP0S9vLIhG02JCU04"},mr="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",hr="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",ji={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Gt=null;function Ui(n){if(n.appendChild(t("link",{rel:"stylesheet",href:`${oo}/maplibre-gl.css`,integrity:ur.css,crossorigin:"anonymous"})),Gt)return Gt;let e=`${oo}/maplibre-gl.mjs`;return Gt=new Promise((r,a)=>{let i=t("link",{rel:"modulepreload",href:e,integrity:ur.module,crossorigin:"anonymous"});i.addEventListener("load",()=>r()),i.addEventListener("error",()=>a(new Error("integrity"))),document.head.appendChild(i)}).then(()=>import(e)).then(r=>(r.getWorkerUrl()||r.setWorkerUrl(`${oo}/maplibre-gl-worker.mjs`),r),r=>{throw Gt=null,new Error(r?.message==="integrity"?"The map library from the CDN is not the expected file: not loading it.":"Could not load the map library (no internet access from this browser?)")}),Gt}function gn(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}var Wi=10,fr=30,Gi=62,gr=4.5,Fi=7,ro="#3b82f6",vn="#8a8a8a";function vr(n,e,o=.2,r=64){let[a,i]=n,[s,l]=e,c=s-a,d=c>180?s-360:c<-180?s+360:s,p=d-a,u=l-i,w=Math.hypot(p,u);if(w===0||o===0)return[n,[d,l]];let C=-u/w,g=p/w,m=w*o,k=(a+d)/2+C*m,I=(i+l)/2+g*m,x=[],v=Math.max(2,Math.floor(r));for(let $=0;$<=v;$+=1){let E=$/v,y=1-E;x.push([y*y*a+2*y*E*k+E*E*d,y*y*i+2*y*E*I+E*E*l])}return x}function ao(n,e){let o=new Map;for(let r of n.geo.points){if(n.person&&r.person!==n.person||n.device&&r.device!==n.device||(e==="online"?!r.online:n.now-r.ts>ji[e]))continue;let a=n.device?`${r.city}|${r.cc}`:n.person?`${r.device}|${r.city}|${r.cc}`:r.device,i=o.get(a);(!i||r.online&&!i.online||r.online===i.online&&r.ts>i.ts)&&o.set(a,r)}return[...o.values()]}function io(n,e){let o=0;return ao(n,e).sort((r,a)=>Number(a.online)-Number(r.online)||a.ts-r.ts).map(r=>({...r,n:r.online?0:++o}))}var tt=class{constructor(e,o="online",r=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.piles=new Map;this.dock=null;this.dockKey="";this.dockQuiet=!1;this.piledKeys=new Set;this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.range=o,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${r}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await Ui(this.el)}catch(r){this.status.textContent=r.message;return}this.map=new this.gl.Map({container:this.el,style:gn()?mr:hr,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let r=this.el.querySelector(".maplibregl-ctrl-attrib");r?.classList.remove("maplibregl-compact-show"),r?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let o=gn();this.theme=new MutationObserver(()=>{!this.map||gn()===o||(o=gn(),this.map.setStyle(o?mr:hr))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),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"],ro,vn],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],ro,vn],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-trail",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-trail",type:"line",source:"dl-trail",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":vn,"line-width":1.5,"line-opacity":.85,"line-dasharray":[0,2.5]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?ro:vn,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dropCard();for(let e of this.piles.values())e.marker.remove();this.piles.clear(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let o=new Map;for(let r of e){let a=`${r.person}|${r.city||`${r.lat.toFixed(1)},${r.lon.toFixed(1)}`}|${r.cc}`,i=o.get(a);i||(i={key:a,person:r.person,lat:r.lat,lon:r.lon,city:r.city,country:r.country,cc:r.cc,asn:r.asn,org:r.org,online:!1,ts:0,points:[]},o.set(a,i)),i.points.push(r),i.online||(i.online=r.online),i.ts=Math.max(i.ts,r.ts)}return[...o.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,o=this.groups(ao(e,this.range)),r=e.person||e.device?null:e.geo.home;for(let d of this.markers)d.remove();this.markers=[];let a=e.person||e.device?null:Ki(o,r),i=o.map(d=>({g:d,at:a?.get(d.key)??[d.lon,d.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:d})=>({type:"Feature",properties:{online:d.online,key:d.key},geometry:{type:"Point",coordinates:[d.lon,d.lat]}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:r?i.map(({g:d,at:p})=>({type:"Feature",properties:{online:d.online,person:d.person,key:d.key},geometry:{type:"LineString",coordinates:vr([r.lon,r.lat],p)}})):[]}),r){let d=t("span",{class:"dl-mk-host"});d.innerHTML=`${At("server","dl-mk-host-ic")}`,this.dock=d.appendChild(t("span",{class:"dl-mk-dock"})),this.dockQuiet=this.dockKey!=="",this.dockKey="";let p=t("div",{class:"dl-mk-hub",title:`Home router${r.city?` · ${r.city}`:""}${r.org?` · ${r.org}`:""}`},[d,t("span",{class:"dl-mk-label chip"},r.city||"Home")]);p.addEventListener("mouseenter",()=>this.showMerged(r.city||"the server")),p.addEventListener("mouseleave",()=>this.focus(this.focused)),p.addEventListener("click",()=>this.zoomToMerged()),this.add(p,[r.lon,r.lat],!0)}let s=e.device?[...i].sort((d,p)=>Number(d.g.online)-Number(p.g.online)||d.g.ts-p.g.ts):[];this.map.getSource("dl-trail")?.setData({type:"FeatureCollection",features:s.length>1?[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:s.slice(1).flatMap((d,p)=>vr(s[p].at,d.at))}}]:[]});let l=new Map(e.device?io(e,this.range).map(d=>[`${d.city}|${d.cc}`,d.n]):[]);this.people=[];for(let{g:d,at:p}of i){let u=d.points.length,w=e.people.find(k=>k.id===d.person);if(e.person){let k=e.device?this.stepMarker(d,p,w,l.get(`${d.points[0].city}|${d.points[0].cc}`)??0):this.placeMarker(d,p,w);this.add(k,p);continue}let C=d.points.map(k=>w?.devices.find(I=>I.id===k.device)?.kind??"other"),g=t("span",{class:"dl-mk-badge"});g.innerHTML=u<=2?C.map(k=>At(k,"dl-mk-badge-ic")).join(""):String(u);let m=t("button",{type:"button",class:`dl-mk${d.online?" online":""}`,"aria-label":`${w?.name??"Someone"}: ${u} device${u===1?"":"s"} in ${d.city||"an unknown city"}`},[t("span",{class:"dl-mk-av"},[He(w?.name??"?"),g]),t("span",{class:"dl-mk-label below"},d.city||d.cc||"?")]);m.addEventListener("mouseenter",()=>this.focus(d.person)),m.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:m,person:d.person}),m.addEventListener("click",k=>{k.stopPropagation(),this.openPopup(d,p,m)}),this.add(m,p,!1,w?.name??"Someone",`${d.city||d.cc||"?"} · ${d.online?"now":re(d.ts,e.now)}`,d.key,d)}this.declutter();let c=i.map(d=>d.g.key).sort().join(";");if(c!==this.fitKey&&!this.popup){let d=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=c,this.fitted=!0,r&&!i.length){let p={center:[r.lon,r.lat],zoom:12};d?this.glide(12,()=>this.map.flyTo({...p,duration:1200})):this.map.jumpTo(p)}else{let p=i.map(u=>u.at);r&&(p.length===0||this.range!=="online"||i.some(u=>u.g.online))&&p.push([r.lon,r.lat]),this.fit(p,d)}}this.status.textContent=i.length||r?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(d=>d.person===this.focused)?this.focused:null)}add(e,o,r=!1,a,i,s,l){s&&this.foldedKeys.has(s)&&e.classList.add("merged"),s&&this.piledKeys.has(s)&&e.classList.add("piled"),e.dataset.key=s??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let c=new this.gl.Marker({element:e}).setLngLat(o).addTo(this.map);this.markers.push(c),this.slots.push({marker:c,el:e,at:o,fixed:r,who:a,where:i,g:l})}declutter(){if(!this.map)return;let e=this.map.getZoom();this.el.classList.toggle("dl-lod-far",e=gr&&e{let l=this.map.project(s.at),c=s.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:l.x,y:l.y,r:(c?.offsetWidth||24)/2+3,fixed:s.fixed}}),r=o.filter(s=>s.fixed);this.merged=[],this.foldedKeys.clear();let a=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));o.forEach((s,l)=>{if(s.fixed)return;let c=this.slots[l],d=c.el.classList.contains("merged")?12:6,p=r.find(u=>Math.hypot(u.x-s.x,u.y-s.y)*a{let d=this.slots[c];!d||d.fixed||(o[c].fixed&&([s,l]=[0,0]),d.marker.setOffset([s,l]),Vi(d.el,s,l))})}closePopup(e=!1){let o=this.popup;if(!o||o.card.classList.contains("leaving"))return;o.card.classList.add("leaving"),setTimeout(()=>{this.popup===o&&this.dropCard()},140);let r=this.before;if(this.before=null,!r)return;let a=()=>this.map?.flyTo({...r,duration:800});if(!e)return a();let i=!1,s=()=>{i||(i=!0,window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0),setTimeout(a,0))};window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),setTimeout(s,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},`Near ${e}`)," · click to zoom in"]),...this.merged.map(o=>t("div",{class:"dl-map-card-row"},[t("span",{},o.who),t("span",{class:"dl-faint"},o.where)]))]),this.card.classList.add("on"))}paintDock(){let e=this.dock;if(!e)return;let o=this.merged.map(a=>`${a.key}:${a.online?1:0}`).join("|");if(o===this.dockKey)return;this.dockKey=o,e.parentElement?.classList.toggle("docked",this.merged.length>0);let r=this.slots.find(a=>a.fixed).at;this.merged.length&&xr(e,this.merged,this.faceActions(()=>[r]),this.dockQuiet),this.dockQuiet=!1}faceActions(e){return{click:(o,r)=>this.openFace(o,r,e()),hover:o=>this.focus(o?.g?.person??null)}}pileUp(e){let o=new Set;if(!this.data?.person&&!this.data?.device){let r=e.flatMap((l,c)=>!l.fixed&&this.slots[c].el.querySelector(":scope > .dl-mk-av")?[c]:[]),a=new Map(r.map(l=>[l,l])),i=l=>a.get(l)===l?l:i(a.get(l));for(let l of r)for(let c of r){if(c<=l)continue;let d=this.slots[l].el.classList.contains("piled")&&this.slots[c].el.classList.contains("piled");Math.hypot(e[l].x-e[c].x,e[l].y-e[c].y)this.slots[m]),d=c.map(br),p=d.map(m=>m.key).sort().join(",");o.add(p);let u=[c.reduce((m,k)=>m+k.at[0],0)/c.length,c.reduce((m,k)=>m+k.at[1],0)/c.length],w=this.piles.get(p);if(!w){let m=t("span",{class:"dl-mk-pile-box"}),k=[...new Set(c.map(v=>v.g?.city||v.g?.cc||"?"))],I=t("div",{class:"dl-mk-pile"},[m,t("span",{class:"dl-mk-label below"},k.length===1?k[0]:`${c.length} people`)]);w={marker:new this.gl.Marker({element:I}).setLngLat(u).addTo(this.map),el:I,box:m,faces:d},I.addEventListener("mouseleave",()=>this.focus(this.focused));let x=w;I.addEventListener("click",v=>{v.stopPropagation(),this.zoomInTo(x.faces.map($=>$.at),!1)}),this.piles.set(p,w)}w.faces=d;let C=w;xr(w.box,d,this.faceActions(()=>C.faces.map(m=>m.at)));for(let m of l)this.slots[m].el.classList.add("piled"),Object.assign(e[m],{r:0,fixed:!0});let g=this.map.project(u);e.push({x:g.x,y:g.y,r:(w.el.offsetWidth||60)/2+3,fixed:!0})}}this.piledKeys=new Set(this.slots.filter(r=>r.el.classList.contains("piled")).map(r=>r.el.dataset.key??"")),this.slots.forEach((r,a)=>{(!e[a].fixed||r.fixed||r.el.classList.contains("merged"))&&r.el.classList.remove("piled")});for(let[r,a]of this.piles)o.has(r)||(this.piles.delete(r),a.el.classList.add("out"),setTimeout(()=>a.marker.remove(),200))}zoomToMerged(){!this.map||!this.merged.length||this.zoomInTo([this.slots.find(e=>e.fixed).at,...this.merged.map(e=>e.at)],!1)}openFace(e,o,r){if(!e.g)return;if(r.every(i=>bn(i,e.at)<1))return this.openPopup(e.g,e.at,o);let a=()=>{let i=this.slots.find(s=>s.el.dataset.key===e.key);i?.g&&!i.el.classList.contains("merged")&&!i.el.classList.contains("piled")&&this.openPopup(i.g,i.at,i.el)};this.zoomInTo(this.nearby(e.at),!0)?this.map.once("moveend",a):a()}nearby(e){return[e,...this.slots.filter(o=>!o.fixed&&o.at!==e&&bn(o.at,e)<=fr).map(o=>o.at)]}zoomInTo(e,o){let r=new this.gl.LngLatBounds;for(let p of e)r.extend(p);let a=e.some(p=>e.some(u=>bn(p,u)>fr)),i=this.map.cameraForBounds(r,{padding:50,maxZoom:a?12:Wi}),s=this.map.getZoom(),l=e.map(p=>this.map.project(p)),c=0;l.forEach((p,u)=>l.slice(u+1).forEach(w=>{let C=Math.hypot(p.x-w.x,p.y-w.y),g=s+Math.log2(Gi/Math.max(C,1e-6));g<=12&&(c=Math.max(c,g))}));let d=Math.min(12,Math.max(i?.zoom??0,c));return d<=s+.05?!1:(o&&!this.before&&(this.before={center:this.map.getCenter().toArray(),zoom:s}),this.map.flyTo({center:i?.center??r.getCenter(),zoom:d,duration:800}),!0)}placeMarker(e,o,r){let a=this.data.now,i=[...e.points].sort((u,w)=>Number(w.online)-Number(u.online)||w.ts-u.ts)[0],s=r?.devices.find(u=>u.id===i.device)?.kind??"other",l=e.points.length,c=t("span",{class:"dl-mk-tile"});c.innerHTML=At(s,"dl-mk-tile-ic")+(l>1?`${l}`:"");let d=e.online?"now":re(e.ts,a),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(a-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":`${l} device${l===1?"":"s"} in ${e.city||"an unknown city"}, ${d}`},[c,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},d)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,o,p)}),p}stepMarker(e,o,r,a){if(e.online)return this.placeMarker(e,o,r);let i=re(e.ts,this.data.now),s=t("button",{type:"button",class:"dl-mk place step","aria-label":`${a}: ${e.city||"an unknown city"}, ${i}`},[t("span",{class:"dl-mk-tile sm"},String(a)),t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",` · ${i}`])]);return s.addEventListener("click",l=>{l.stopPropagation(),this.openPopup(e,o,s)}),s}focus(e){this.focused=e;for(let s of this.people)s.el.classList.toggle("dim",!!e&&s.person!==e),s.el.classList.toggle("hl",s.person===e);let o=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let s of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(s)&&this.map.setPaintProperty(s,"line-opacity",o);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let r=this.data,a=r.people.find(s=>s.id===e),i=ao(r,this.range).filter(s=>s.person===e).sort((s,l)=>Number(l.online)-Number(s.online)||l.ts-s.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},a?.name??e),` · ${i.length} device${i.length===1?"":"s"}`]),...i.map(s=>t("div",{class:"dl-map-card-row"},[t("span",{},a?.devices.find(l=>l.id===s.device)?.name??"Device"),t("span",{class:"dl-faint"},`${s.city||s.cc||"?"} · ${s.online?"now":re(s.ts,r.now)}`)]))])}fit(e,o=!1){if(!e.length)return;let r=(d,p)=>{let u=Math.PI/180,w=(p[1]-d[1])*u,C=(p[0]-d[0])*u,g=Math.sin(w/2)**2+Math.cos(d[1]*u)*Math.cos(p[1]*u)*Math.sin(C/2)**2;return 12742*Math.asin(Math.sqrt(g))},a=[e.reduce((d,p)=>d+p[0],0)/e.length,e.reduce((d,p)=>d+p[1],0)/e.length],i=e;if(e.length>=5){let d=[...e].sort((p,u)=>r(a,p)-r(a,u));i=d.slice(0,Math.ceil(d.length*.9))}let s=new this.gl.LngLatBounds(i[0],i[0]);i.forEach(d=>s.extend(d));let l=this.el.clientHeight||380,c={padding:{top:Math.min(60,l/5),bottom:Math.min(40,l/8),left:48,right:48},maxZoom:this.data?.person?11:12};o?this.glide(this.map.cameraForBounds(s,c)?.zoom??null,()=>this.map.fitBounds(s,{...c,duration:1200})):this.map.fitBounds(s,{...c,duration:0})}glide(e,o){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),o()}openPopup(e,o,r){let a=this.data,i=[e.city,e.cc||e.country].filter(Boolean).join(", "),s=[...new Set(e.points.map(v=>v.person))],l=e.points.sort((v,$)=>Number($.online)-Number(v.online)||$.ts-v.ts).map(v=>{let $=a.people.find(y=>y.id===v.person),E=$?.devices.find(y=>y.id===v.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(v.person,v.device)},[t("span",{class:`dl-pop-dot${v.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},$?.name??v.person),` · ${E?.name??"device"}`]),t("span",{class:"dl-faint dl-nowrap"},v.online?"now":re(v.ts,a.now))])}),c=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},b("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||"Unknown network"),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),t("div",{class:"dl-pop-list"},l),s.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${a.people.find(v=>v.id===s[0])?.name??"person"}`)]):""]);this.zoomInTo(this.nearby(o),!0),this.dropCard();let d=t("div",{class:"dl-root dl-popcard",role:"dialog"},[t("span",{class:"dl-popcard-tip"}),c]);document.body.appendChild(d);let p=this.el,u=r?.querySelector(".dl-mk-av, .dl-mk-tile")??r??null,w=()=>{if(!u)return;let v=u.getBoundingClientRect(),$=p.getBoundingClientRect(),E=v.left+v.width/2,y=v.top+v.height/2;d.classList.toggle("away",E<$.left||E>$.right||y<$.top||y>$.bottom);let z=d.offsetWidth,h=d.offsetHeight,f=v.top-h-12>=8||v.top>window.innerHeight-v.bottom,T=Math.min(Math.max(8,E-z/2),window.innerWidth-z-8);d.classList.toggle("above",f),d.classList.toggle("below",!f),d.style.left=`${T}px`,d.style.top=`${f?v.top-h-12:v.bottom+12}px`,d.style.setProperty("--tip-x",`${E-T}px`)},C=v=>{v.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},g=v=>{v.key==="Escape"&&this.closePopup()},m=v=>{v.target instanceof Element&&v.target.closest(".dl-popcard")||this.closePopup()},k=()=>this.closePopup();this.map.on("move",w),window.addEventListener("scroll",m,{capture:!0,passive:!0}),window.addEventListener("resize",w),document.addEventListener("pointerdown",C,!0),document.addEventListener("keydown",g);let I=$e(k);window.addEventListener("pagehide",k),this.popup={card:d,off:()=>{this.map?.off("move",w),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",w),document.removeEventListener("pointerdown",C,!0),document.removeEventListener("keydown",g),I(),window.removeEventListener("pagehide",k)}};let x=window.setInterval(()=>{if(this.popup?.card!==d)return clearInterval(x);(!p.isConnected||!p.getClientRects().length)&&this.dropCard()},400);w()}};function qi(n,e=6){let o=n.map(r=>({x:r.x,y:r.y}));for(let r=0;r<16;r++){let a=!1;for(let i=0;i[r.x-n[a].x,r.y-n[a].y])}function Ki(n,e){let o=new Map,r=e?[[e.lon,e.lat]]:[],a=i=>r.some(s=>bn(i,s)<1.3);for(let i of[...n].sort((s,l)=>s.key>>12)/1048575),c=(s&4095)/4096*2*Math.PI,d=[i.lon,i.lat];for(let p=0;p<24;p++){let u=c+p*2.39996,w=Math.min(8,l+p*.25);if(d=[i.lon+w*Math.sin(u)/(111.32*Math.cos(i.lat*Math.PI/180)),i.lat+w*Math.cos(u)/111.32],!a(d))break}r.push(d),o.set(i.key,d)}return o}function Ji(n){let e=2166136261;for(let o=0;o>>0}function br(n){return{key:n.el.dataset.key??"",who:n.who??"Someone",where:n.where??"",online:!!n.g?.online,at:n.at,badge:n.el.querySelector(".dl-mk-badge")?.innerHTML??"",g:n.g}}function xr(n,e,o,r=!1){let a=e.length>3,i=()=>[...n.children].filter(g=>!g.classList.contains("out")),s=new Map(i().map(g=>[g,g.getBoundingClientRect().left])),l=n.getBoundingClientRect().width,c=new Map;n.querySelectorAll(".dl-mk-face:not(.out)").forEach(g=>c.set(g.dataset.key??"",g));let d=n.querySelector(".dl-mk-more:not(.out)"),p=g=>{Object.assign(g.style,{position:"absolute",left:`${g.offsetLeft}px`,top:`${g.offsetTop}px`,transform:""}),g.classList.add("out"),setTimeout(()=>g.remove(),200)},u=[];for(let g of e.slice(0,a?2:3)){let m=c.get(g.key);if(c.delete(g.key),!m){let x=t("button",{type:"button",class:`dl-mk-face${r?"":" in"}`,"data-key":g.key},[t("span",{class:"dl-mk-av"},He(g.who)),t("span",{class:"dl-mk-badge"})]);x.addEventListener("animationend",()=>x.classList.remove("in"),{once:!0}),m=x}let k=m,I=k.querySelector(".dl-mk-badge");I.innerHTML!==g.badge&&(I.innerHTML=g.badge),k.title=`${g.who} · ${g.where}`,k.setAttribute("aria-label",`${g.who}, ${g.where}`),k.classList.toggle("on",g.online),k.onclick=x=>{x.stopPropagation(),o.click(g,k)},k.onmouseenter=()=>o.hover(g),k.onmouseleave=()=>o.hover(null),u.push(k)}for(let g of c.values())p(g);if(a){if(!d){d=t("span",{class:`dl-mk-more${r?"":" in"}`});let g=d;g.addEventListener("animationend",()=>g.classList.remove("in"),{once:!0})}d.textContent=`+${e.length-2}`,u.push(d)}else d&&p(d);let w=null;for(let g of u)(w?w.nextElementSibling:n.firstElementChild)!==g&&(w?w.after(g):n.prepend(g)),w=g;for(let g of u){let m=s.get(g);if(m==null)continue;let k=m-g.getBoundingClientRect().left;Math.abs(k)<.5||(g.style.transition="none",g.style.transform=`translateX(${k}px)`,g.offsetWidth,g.style.transition="",g.style.transform="")}n.style.width="";let C=n.getBoundingClientRect().width;if(l&&Math.abs(C-l)>.5){n.style.width=`${l}px`,n.offsetWidth,n.style.width=`${C}px`;let g=()=>{n.style.width="",n.removeEventListener("transitionend",g)};n.addEventListener("transitionend",g),setTimeout(g,400)}}function bn(n,e){let o=Math.PI/180,r=Math.sin((e[1]-n[1])*o/2)**2+Math.cos(n[1]*o)*Math.cos(e[1]*o)*Math.sin((e[0]-n[0])*o/2)**2;return 12742*Math.asin(Math.min(1,Math.sqrt(r)))}function Vi(n,e,o){let r=n.querySelector(":scope > .dl-mk-ptr"),a=Math.hypot(e,o);if(a<1){r?.remove();return}r||(r=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(r));let i=r.firstElementChild,s=r.lastElementChild;i.style.width=`${a}px`,i.style.transform=`rotate(${Math.atan2(-o,-e)}rad)`,s.style.transform=`translate(${-e}px, ${-o}px)`}function Tt(n,e,o=!0){let r=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],a=t("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of r)i==="online"&&!o||a.appendChild(t("button",{type:"button",role:"tab",class:i===n?"on":"","data-v":i,click:()=>{a.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===i)),e(i)}},s));return a}function St(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function ke(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function Yi(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function so(n,e,o=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:"Copy",click:()=>pe(e,`${n} copied`)},[t("span",{},e),b("copy")])])}function xn(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var wr={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 Zi(n,e,o){let r=n.filter(a=>a.device===e&&wr[a.type]).reverse().slice(0,12);return r.length?t("div",{class:"dl-dev-log"},r.map(a=>{let[i,s,l]=wr[a.type],c=a.type==="connect"?[a.detail?t("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?t("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[t("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[t("span",{class:"dl-muted"},Ne(a)==="portal"?" on the portal":Ne(a)==="admin"?" by you":"")]:[],d=new Date(a.ts*1e3);return t("div",{class:`dl-dev-log-row${Ne(a)==="admin"?" dl-ev-by-admin":""}`},[Ne(a)==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):t("span",{class:`dl-ev-tile ev ${i}`},b(l)),t("span",{class:"dl-row-main"},[t("span",{},s),...c]),t("span",{class:"dl-faint dl-nowrap",title:d.toLocaleString()},re(a.ts,o))])})):t("div",{class:"dl-sub"},"No activity yet.")}async function yr(n,e,o){let r=await A.status(1).catch(()=>null),a=r?.people.find(s=>s.id===n),i=a?.devices.find(s=>s.id===e);r&&a&&i&&We(a,i,{...o,geo:r.geo,now:r.now,today:Ie(r.series),core:Mt(r.servers,a.server)})}async function We(n,e,o){let r=await W(()=>A.deviceConfig(e.id));if(!r)return;let a=o.core??Be(null),i=e,s=n,l=o.geo,c=o.now,d=o.today??je(new Date),p=await a.connectBlock(r,e.kind==="phone"||e.kind==="tablet"?"qr":"file"),u=t("div",{class:"dl-drawer-title"}),w=t("div",{}),C=t("div",{}),g=t("div",{},t("div",{class:"dl-sub"},"Loading…")),m=[],k=ne=>{m=ne.filter(O=>O.device===i.id),dom.content(g,Zi(ne,i.id,c))},I=async(ne=!1)=>{let O=o.events?.();if(O&&!ne)return k(O);let F=await A.events(2e3,n.id).catch(()=>null);F&&k(F.events)},x="30d",v=null,$=t("div",{class:"dl-dplaces"}),E=()=>({geo:l,people:[s],now:c??Date.now()/1e3,person:s.id,device:i.id}),y=()=>{if(!l?.enabled)return;let ne=io(E(),x);dom.content($,ne.length?ne.map(O=>t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${O.online?" live":""}`},O.online?b(i.kind):String(O.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[O.city||O.cc||"Unknown city",O.org?t("span",{class:"dl-muted"},` · ${O.org}`):""]),t("span",{class:"dl-mono dl-faint"},O.ip)]),t("span",{class:O.online?"dl-dplace-now":"dl-faint dl-nowrap"},O.online?"now":re(O.ts,c))])):t("div",{class:"dl-sub"},"No locations in this period."))},z=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${i.online?" on":""}`},b(i.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},i.name),H([b("edit")],()=>T(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${s.name} · ${Ze[i.kind]}`)])]);let ne=i.spark.reduce((O,F)=>O+F,0);dom.content(w,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},"Status"),nn(i,c,"Waiting for the first connection",s)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"This month"),t("b",{},X(i.month[0]+i.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${X(i.month[1])} ↑ ${X(i.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"Last 7 days"),t("b",{},X(ne)),or(i.spark,120,22,d)])])),dom.content(C,t("div",{class:"dl-kv2"},[so("Tunnel address",i.address),i.hostname&&s.access!=="internet"?so("Local address",i.hostname):"",i.endpoint&&!l?.points.some(O=>O.device===i.id&&O.ip===i.endpoint)?xn("Client IP",i.endpoint):"",xn("Total",t("span",{class:"dl-kv-act"},[`↓ ${X(i.total[1])} · ↑ ${X(i.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Lt("device",i.id,i.name,()=>setTimeout(f,300))},"Reset")])),xn("Added",`${Yi(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),r.amnezia.client_pub_key?so("Public key",r.amnezia.client_pub_key):xn("Public key","—")])),dom.content(S,[H([b(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await W(()=>A.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await f()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),H([b("key")," New keys"],async()=>{if(!await se("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await W(()=>A.deviceRotate(i.id),"New keys generated")&&(o.refresh(),ue.close(),await yr(s.id,i.id,o))}),t("span",{class:"dl-spacer"}),H([b("trash")," Remove"],async()=>{await se(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await W(()=>A.deviceDelete(i.id),"Device removed")&&(ue.close(),o.refresh())},"negative")])},h=async()=>{let ne=await A.status(1).catch(()=>null),O=ne?.people.find(P=>P.id===s.id),F=O?.devices.find(P=>P.id===i.id);!ne||!O||!F||(s=O,i=F,l=ne.geo,c=ne.now,d=Ie(ne.series),z(),v?.update(E()),y())},f=async()=>{await h(),o.refresh()},T=()=>{let ne=t("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48}),O=s.devices.filter(P=>P.id!==i.id).map(P=>P.name),F=ye("Name",ne,()=>_e(ne.value,O,"Shown in the portal and in the app."));te(`Rename ${i.name}`,[F],[ae()," ",H("Save",async()=>{let P=F.help();if(P.bad){U(P.text,"warning");return}await W(()=>A.deviceUpdate(i.id,ne.value,void 0),"Renamed")&&(oe(),await f())},"positive")]),setTimeout(()=>ne.select(),50)},S=t("div",{class:"dl-drawer-actions"}),N=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Connect")]),i.config_stale?t("div",{class:"dl-note warn"},[b("alert"),t("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.")]):"",p]),G=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Activity"),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Fe({people:[s]},m,"csv",i.id)},"Export"),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>et(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{I(!0),o.refresh()})},"Clear"),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),g]),q=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},"Details")),C]),V="";l?.enabled&&(v=new tt({openPerson:ne=>location.href=ke(ne),openDevice:(ne,O)=>location.href=ke(ne,O)},x,220),V=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Locations"),Tt(x,ne=>{x=ne,v?.setRange(ne),y()},!1)]),t("div",{class:"dl-dmap"},v.el),$]),y());let R=!i.handshake||i.config_stale,J=t("div",{class:"dl-stack gap16"},R?[w,N,q,V,G]:[w,q,V,G,N]);I();let Q=()=>{h(),I()},le=fn(Q),he=window.setInterval(Q,3e4),ue=Ho(u,J,S,()=>{clearInterval(he),le(),v?.destroy()});z(),v&&requestAnimationFrame(()=>v?.mount(E()))}function kr(n,e,o,r){let a=r.core??Be(null),i=()=>W(()=>A.deviceConfig(o.id)),s=[{label:"Show QR code",icon:b("qr"),run:async()=>{let l=await i();l&&te(`${o.name} · QR code`,t("div",{class:"dl-qr-pane"},[Xe(Ct(a.qrText(l)),"dl-qr"),t("span",{class:"dl-sub"},eo(l)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),ae("Close"))}},{label:a.file.label,icon:b("download"),run:async()=>{let l=await i();if(!l)return;let c=a.file.make(l);Se(c.name,c.text,"application/octet-stream")}},a.appKey?{label:a.appKey.label,icon:b("copy"),run:async()=>{let l=await i();l&&pe(await a.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:b("edit"),run:()=>We(e,o,r)},{label:"New keys",icon:b("key"),run:async()=>{await se("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await W(()=>A.deviceRotate(o.id),"New keys generated")&&r.refresh()}},{label:o.disabled?"Enable":"Disable",icon:b(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await W(()=>A.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&r.refresh()}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await se(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await W(()=>A.deviceDelete(o.id),"Device removed")&&r.refresh()}}];Ce(n,s)}function nt(n,e){let o=n.devices.map(d=>d.name),r=d=>{let p=Ze[d],u=1,w=p;for(;o.some(C=>C.toLowerCase()===w.toLowerCase());)w=`${p} ${++u}`;return w},a="phone",i=t("input",{type:"text",class:"cbi-input-text",placeholder:r(a),maxlength:48}),s=ye("Name",i,()=>i.value.trim()?_e(i.value,o,"Shown in the portal and in the app."):{text:`Named after its type: ${r(a)}.`,bad:!1}),l=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},_o.map(d=>t("button",{type:"button",role:"radio",class:d===a?"on":"","aria-checked":d===a?"true":"false","data-kind":d,click:()=>{a=d,l.querySelectorAll("button").forEach(p=>{let u=p.dataset.kind===d;p.classList.toggle("on",u),p.setAttribute("aria-checked",u?"true":"false")}),i.placeholder=r(d),s.refresh()}},[b(d),t("span",{},Ze[d])]))),c=n.devices.length>=n.device_limit;te(`Add a device for ${n.name}`,[c?t("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Type"),l]),s],[ae()," ",H("Add device",async()=>{let d=s.help();if(d.bad){U(d.text,"warning");return}let p=i.value.trim()||r(a),u=await W(()=>A.deviceCreate(n.id,p,a));u&&(oe(),U(`${p} added`,"success",3e3),e.refresh(),await yr(n.id,u.id,e))},"positive")]),setTimeout(()=>i.focus(),50)}var Ke=1080,qt=1512,Ge=96,Qi="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Xi="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Ft=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function es(n,e,o){let r=new URL(o),a=r.pathname.slice(1),i=Math.min(92,Math.floor((Ke-2*Ge)/(.58*(4+n.name.length)))),s=Ke-2*Ge,l=392,c=40,d=Ct(o,2).replace("`${m}`;return``+p(Ge+82,Ge+42,36,"#a3a3a3",Ft(e))+p(Ge,276,i,"#ffffff",`Hi, ${Ft(n.name)}`,'font-weight="600"')+p(Ge,340,40,"#8a8a8a",`Scan to connect to ${Ft(e)}`)+``+d+`${Ft(a)}`+p(Ke/2,l+s+156,34,"#737373",Ft(r.host),'text-anchor="middle"')+""}async function ts(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let o=document.createElement("canvas");return o.width=Ke,o.height=qt,o.getContext("2d").drawImage(e,0,0,Ke,qt),new Promise((r,a)=>o.toBlob(i=>i?r(i):a(new Error("Could not draw the card")),"image/png"))}async function $r(n){let e=await W(()=>A.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(U("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function wn(n){let e=await $r(n);e&&await pe(e.link,"Personal link copied")}async function _t(n,e,o={}){let r=n.link,a=n.links;if(r===void 0){let m=await $r(n.id);if(!m)return;r=m.link,a=m.links}if(!r){U("The personal portal is off. Turn it on in Settings.","warning");return}let i=r,s=await W(()=>ts(es(n,e,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),c=URL.createObjectURL(s),d=navigator,p=!!d.canShare?.({files:[l]}),u=!p&&typeof d.share=="function"&&(d.canShare?.({url:i})??!0),w=()=>{URL.revokeObjectURL(c),oe()},C=async m=>{try{await d.share(m)}catch{}},g=p?H([b("link")," Share card"],()=>C({files:[l],title:`Invite ${n.name}`}),"positive"):u?H([b("link")," Share link"],()=>C({url:i,title:`Invite ${n.name}`,text:"Your personal VPN link"}),"positive"):H([b("download")," Download card"],()=>Se(l.name,s),"positive");te(o.title??`Invite ${n.name}`,t("div",{class:"dl-invite"},[t("img",{src:c,alt:`Invite card for ${n.name}`}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},o.lead??`Send ${n.name} the card or the link. They open it, add their devices and connect — no account needed.`),t("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>pe(i,"Personal link copied")},[t("span",{},i.replace(/^https:\/\//,"")),b("copy")]),...(a??[]).filter(m=>m!==i).map(m=>t("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>pe(m,"Link copied")},[t("span",{},m.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${m.startsWith("http:")?"warn":""}`},m.startsWith("http:")?"HTTP":"Also"),b("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},["Install ",t("b",{},"AmneziaVPN")," on the device"]),t("li",{},"Open the link or scan the code"),t("li",{},"Add the device and connect")]),t("div",{class:"dl-invite-actions"},[g,H([b("copy")," Copy link"],()=>pe(i,"Personal link copied"))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:w},"Done")],"wide")}function Kt(n,e){let o=n.servers.find(c=>c.id===e)??n.servers[0],r=n.people.filter(c=>c.server===o.id),a=new Set(r.map(c=>c.id)),i=r.flatMap(c=>c.devices),s=c=>r.reduce((d,p)=>{let u=c(p);return[d[0]+u[0],d[1]+u[1]]},[0,0]),l=o.series?.[o.series.length-1];return{...n,servers:[o],people:r,series:o.series??n.series,events:n.events.filter(c=>c.person?a.has(c.person):!0),geo:{...n.geo,points:n.geo.points.filter(c=>a.has(c.person))},totals:{people:r.length,devices:i.length,online:i.filter(c=>c.online).length,active:r.filter(c=>c.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(c=>c.month)}}}var Cr=3,lo=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let w=e.next(),C=null;try{C=await n.fetch(u),o>=Cr&&U("The router answers again.","success",3e3),o=0}catch{return++o===Cr&&U("The router is not answering: what you see may be out of date.","warning",8e3),null}return C==null||!e.take(w)?null:(n.apply(C,p),C)},a=(p=!1)=>r(p,!1),i=()=>document.visibilityState==="visible",s=()=>i()&&(n.active?.()??!0)?r(!0,!1):Promise.resolve(null);poll.add(s,n.every);let l=n.live?fn(()=>void(i()&&(n.active?.()??!0)&&r(!0,!0))):null,c=()=>{poll.remove(s),l?.(),d()},d=$e(c);return{refresh:a,claim:()=>e.claim(),stop:c}}function Pt(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function Te(n,e,o=!1){return o&&Pt(n)?!1:(dom.content(n,e),!0)}function Er(n,e){let o=n,a=t("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(i=>t("button",{type:"button",class:`dl-choice${i.v===o?" selected":""}`,"data-v":i.v,click:()=>{o=i.v,a.querySelectorAll(".dl-choice").forEach(s=>s.classList.toggle("selected",s.dataset.v===i.v)),e?.(i.v)}},[t("span",{class:"dl-choice-title"},[b(i.ic),dt[i.v]]),t("span",{class:"dl-choice-text"},i.text)])));return{el:a,get:()=>o}}function co(n){try{return localStorage.getItem(n)}catch{return null}}function po(n,e){try{localStorage.setItem(n,e)}catch{}}function ns(n){let e=n.devices.length,o=Math.max(1,n.device_limit,e),r=Math.min(160,o*22+(o-1)*3);return t("div",{class:"dl-slotbar",title:`${e} of ${n.device_limit} devices`},[t("span",{class:"dl-slotbar-segs",style:`width: ${r}px`},Array.from({length:o},(a,i)=>t("i",{class:i>=n.device_limit?"over":in.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),yn=n=>n.state==="server_off"?n.paused:n.state!=="active",Mr=n=>yn(n)?n.state==="server_off"?"paused":n.state:null;function os(n,e){let o=Ve(n.expires,e);return n.state==="quota"||n.state==="expired"||Ye(n,o)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function Tr(n,e){return gt(n&&Fn(n,e)>=0?n:e,1)}var Sr=n=>n.people.map(e=>e.id).sort().join(" "),_r=!1,ut=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===(new URLSearchParams(location.search).get("filter")??co("dl.people.filter")))??"all";this.sort=["seen","name","usage"].find(e=>e===co("dl.people.sort"))??"seen";this.query="";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return A.status(30)}scope(e){return this.serverId?Kt(e,this.serverId):e}embed(e,o){return this.serverId=o,this.render(e)}person(e){return this.st.people.find(o=>o.id===e)}get today(){return Ie(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:Mt(this.st.servers,e.server)}}take(e,o){let r=this.scope(e),a=Sr(r)!==Sr(this.st);this.st=r,a?this.rebuild():(this.paintCards(o),this.decorate(o))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await A.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let r of Array.from(this.list.children))r.dataset.sid&&e.set(r.dataset.sid,r);let o=this.st.people.map(r=>{let a=e.get(r.id)??t("div",{class:"dl-card",role:"listitem","data-sid":r.id});return this.renderCard(a,r.id)});dom.content(this.list,o.length?o:t("div",{class:"dl-plist-none"},this.st.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people.")),this.decorate()}paintCards(e=!1){for(let o of this.st.people){let r=this.card(o.id);r&&!(e&&Pt(r))&&this.renderCard(r,o.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let o=this.scope(e);this.st=o;let r=this,a=t("select",{class:"dl-select","aria-label":"Sort",change:c=>{r.sort=c.target.value,po("dl.people.sort",r.sort),r.decorate()}},[t("option",{value:"seen",selected:r.sort==="seen"?"selected":null},"Last seen"),t("option",{value:"name",selected:r.sort==="name"?"selected":null},"Name"),t("option",{value:"usage",selected:r.sort==="usage"?"selected":null},"Usage")]),i=t("input",{type:"search",class:"cbi-input-text dl-people-find",placeholder:"Find…","aria-label":"Find a person or device",hidden:o.people.length>8?null:"hidden",input:c=>{r.query=c.target.value.trim().toLowerCase(),r.decorate()}}),s=c=>{let d=c.target;c.key==="/"&&!i.hidden&&!["INPUT","TEXTAREA","SELECT"].includes(d?.tagName)&&!d?.isContentEditable&&(c.preventDefault(),i.focus())};document.addEventListener("keydown",s),$e(()=>document.removeEventListener("keydown",s));let l=t("div",{class:"dl-root"},[r.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"People"),t("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?H([b("plus")," Add person"],()=>r.openCreate(),"add"):""]),o.servers.length?"":t("div",{class:"alert-message warning"},["No server yet. ",t("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[i,a,r.serverId?H([b("plus")," Add person"],()=>r.openCreate(),"add"):""])]),this.list]);return this.el=l,this.rebuild(),this.poller??(this.poller=ot({fetch:()=>A.status(30),every:30,live:!0,active:()=>!!r.el?.isConnected,apply:(c,d)=>r.take(c,d)})),!_r&&new URLSearchParams(location.search).get("add")&&(_r=!0,setTimeout(()=>r.openCreate(),100)),Promise.resolve(l)}countText(){let e=this.st.totals;return`${e.people} ${e.people===1?"person":"people"} · ${e.devices} device${e.devices===1?"":"s"} · ${e.online} online`}decorate(e=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let r=this.st.people,a=this.today,i=m=>os(m,a),s={all:r.length,online:r.filter(m=>m.online>0).length,attention:r.filter(i).length,paused:r.filter(m=>Lr(m)).length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(e&&Pt(l))){let m={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(m).map(k=>t("button",{type:"button",role:"tab",class:k===this.filter?"on":"",click:()=>{this.filter=k,po("dl.people.filter",k),this.decorate()}},[m[k],t("b",{class:k==="attention"&&s[k]?"warn":""},String(s[k]))])))}let c=this.query,d=m=>[m.name,m.note??"",...m.devices.flatMap(k=>[k.name,k.address,k.hostname,k.endpoint])].join(" ").toLowerCase(),p=m=>!(this.filter==="online"&&!m.online||this.filter==="attention"&&!i(m)||this.filter==="paused"&&!Lr(m)||c&&!d(m).includes(c)),u=m=>Mr(m)==="paused"?2:yn(m)?1:0,w=[...r].sort((m,k)=>u(m)-u(k)||(this.sort==="name"?m.name.localeCompare(k.name):this.sort==="usage"?k.month[0]+k.month[1]-(m.month[0]+m.month[1]):k.online-m.online||k.last_seen-m.last_seen)),C=0;for(let m of w){let k=this.card(m.id);if(!k)continue;this.list.appendChild(k),k.classList.toggle("dl-off",yn(m));let I=p(m);k.classList.toggle("dl-filtered",!I),I&&C++}let g=this.el?.querySelector(".dl-people-none")??null;r.length&&!C?(g??(g=t("div",{class:"dl-empty dl-people-none"},t("p",{},"No one here right now."))),g.previousElementSibling!==this.list&&this.list.after(g)):g?.remove()}async quick(e,o,r){await W(()=>A.personUpdate(e.id,o),r)&&await this.update()}renderCard(e,o){let r=this.person(o);if(!r)return dom.content(e,t("em",{},"This person was just removed.")),e;let a=this.today,i=Ve(r.expires,a),s=Math.max(0,r.device_limit-r.devices.length),l=r.has_link??this.st.settings.portal_enabled,c=[],d=Mr(r);if(r.expires&&d!=="expired"){let g=Ye(r,i),m=i!=null&&i<0;c.push(t("span",{class:`dl-pill-ic${m?" bad":g?" warn":""}`,title:`Access ends ${Me(r.expires)}`},[b("calendar"),m?`ended ${Me(r.expires)}`:g?Xt(i):`until ${Me(r.expires)}`]))}r.hours&&d!=="hours"&&c.push(t("span",{class:"dl-pill-ic",title:"Allowed hours"},[b("clock"),r.hours.replace("-","–")]));let p=tn(r.devices).map(g=>t("button",{type:"button",class:`dl-chip${g.disabled?" disabled":""}${g.online?" live":""}`,title:`${Ze[g.kind]} · ${g.address}${g.online?` · online from ${g.endpoint}`:g.handshake?` · seen ${re(g.handshake,this.st.now)}`:""}`,click:m=>{m.preventDefault(),We(r,g,this.deviceOpts(r))}},[b(g.kind),t("span",{class:"dl-chip-name"},g.name),!g.handshake&&!g.disabled?t("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(t("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:s>0?"Add device":"Add device · over the limit, admins can still add",click:g=>{g.preventDefault(),nt(r,this.deviceOpts(r))}},b("plus")));let u=[];!r.devices.length&&l&&!yn(r)&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>_t(r,this.st.servers.find(g=>g.id===r.server)?.name??"Home")},"Send invite")),r.expires&&Ye(r,i)&&d!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(r,{expires:Tr(r.expires,a)},"Extended by 1 month")},"Extend 1 month"));let w=Le("more","More",g=>Ce(g.currentTarget,[{label:"Open",icon:b("open"),run:()=>{location.href=ke(r.id)}},l?{label:"Invite card",icon:b("qr"),run:()=>_t(r,this.st.servers.find(m=>m.id===r.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:b("plus"),run:()=>nt(r,this.deviceOpts(r))}:null,null,{label:r.paused?"Resume":"Pause",icon:b(r.paused?"play":"pause"),warn:!r.paused,run:()=>this.togglePause(r)},{label:"Delete",icon:b("trash"),danger:!0,run:()=>this.remove(r.id)}].filter((m,k,I)=>m||k>0&&I[k-1])),"neutral","dl-icon-only"),C=t("div",{class:"dl-pcard-actions"},[l?Le("link","Copy link",()=>wn(r.id),"neutral","dl-icon-only"):"",w]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${r.online?" online":""}`},He(r.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:ke(r.id)},r.name),Ao(r),...c]),ns(r)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(r,C),d?this.stopStrip(r,d):""])),e}stopStrip(e,o){let r=this.today,a=gt(`${r.slice(0,8)}01`,1),i=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month"),s={paused:["pause","warn","Paused","Devices can’t connect until you resume",["play","Resume",()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad","Data limit reached",`Paused until it resets on ${Me(a)}`,["plus","+10 GB this month",i]]:["chart","bad","Data limit reached","Paused until the limit is raised",["edit","Change limit",()=>location.href=ke(e.id)]],expired:["calendar","bad",`Access ended ${Me(e.expires)}`,"Devices can’t connect",["calendar","Extend 1 month",()=>this.quick(e,{expires:Tr(e.expires,r)},"Extended by 1 month")]],hours:["clock","warn","Outside allowed hours",`Access ${e.hours.replace("-","–")} (router time)`,null],no_server:["alert","warn","No server","Choose a server on their page",null]},[l,c,d,p,u]=s[o];return t("div",{class:`dl-pstrip ${c}`},[t("span",{class:`dl-need-ic ${c}`},b(l)),t("span",{class:"dl-pstrip-text"},[t("b",{},d),t("span",{class:"dl-faint"},p)]),u?H([b(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,o){let r=e.quota_used||e.month[0]+e.month[1],a=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,i=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??0),0),s=e.rate?.[e.rate.length-1],l=e.online&&s&&this.st.now-s[0]<180,c=t("div",{class:`dl-usebar${a>=100?" bad":a>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${a}%`,c.appendChild(p),me(c,()=>[t("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${X(e.quota_used)} of ${X(e.quota_limit)} · ${X(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},e.quota_period==="total"?"In total":`This month${e.bonus_gb?` · includes +${e.bonus_gb} GB extra`:""}`)])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,w)=>w.v-u.v);p.forEach((u,w)=>{let C=t("i",{class:`c${Math.min(w,4)}`});C.style.flexGrow=String(u.v),c.appendChild(C)}),p.length&&me(c,()=>[t("div",{class:"dl-tip-title"},"This month by device"),...p.map((u,w)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(w,4)}`}),t("span",{},u.d.name),t("b",{},X(u.v))]))])}let d=e.quota_limit?`${X(Math.max(0,e.quota_limit-e.quota_used))} left`:"no limit";return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[l?t("span",{class:"dl-pside-state live"},"Online"):t("span",{class:"dl-pside-state"},e.online?"Online":e.last_seen?"Offline":"Never connected"),o]),t("div",{class:"dl-use-num"},[t("b",{class:r?"":"dl-faint"},X(r)),t("span",{class:"dl-faint"},e.quota_limit?`of ${X(e.quota_limit)}`:e.quota_period==="total"&&e.quota_gb?"in total":"this month")]),c,l?t("div",{class:"dl-use-live",title:"Right now"},[`↓ ${Oe(s[2])}`,t("span",{class:"dl-faint"},`↑ ${Oe(s[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},i?`today ${X(i)} · ${d}`:d)])}async togglePause(e){await W(()=>A.personPause(e.id,!e.paused),e.paused?`${e.name} resumed`:`${e.name} paused`)&&await this.refresh()}async remove(e){let o=this.person(e);await se(`Remove ${o?.name??e}?`,`All ${o?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await W(()=>A.personDelete(e),"Person removed")&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){U("Set up the server first.","warning");return}let o=t("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),r=(()=>{try{return JSON.parse(co("dl.person.last")??"{}")}catch{return{}}})(),a=Er(r.access??"internet"),i=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),s=t("input",{type:"date",class:"cbi-input-text"}),l=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited",value:r.quota??""}),c=(x,v)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{s.value=v?gt(Ie(e.series),v):"",s.dispatchEvent(new Event("change"))}},x),d=e.servers[0],p=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(x=>t("option",{value:x.id},x.name))):null,u=(x,v,$)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},x),t("div",{class:"cbi-value-field"},[v,$?t("div",{class:"cbi-value-description"},$):""])]),w=Ie(e.series),C=ye("Name",o,()=>_e(o.value,[],"Shown in their portal and apps.")),g=ye("Devices",i,()=>sn(i.value)),m=ye("End date",s,()=>jo(s.value,w,Ve,Me),t("div",{class:"dl-actions"},[s,c("1 month",1),c("3 months",3),c("1 year",12),c("None",0)])),k=ye("Monthly data (GB)",l,()=>ln(l.value));s.addEventListener("change",()=>m.refresh());let I=e.settings.portal_enabled;te("Add person",[C,p?u("Server",p):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},"Access"),t("div",{class:"cbi-value-field"},a.el)]),g,m,k],[ae()," ",H(I?"Create and copy link":"Create",async()=>{let x=ze([C,g,m,k]);if(x){U(x,"warning");return}let v=await W(()=>A.personCreate(o.value.trim(),"",p?.value??d.id,a.get(),i.value.trim(),s.value,l.value.trim(),"month"));v&&(po("dl.person.last",JSON.stringify({access:a.get(),quota:l.value.trim()})),v.link&&await pe(v.link,"Personal link copied",!0),this.showCreated(v.id,o.value.trim(),v.link,e.servers.find($=>$.id===(p?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(e,o,r,a){if(r){_t({id:e,name:o,link:r},a,{title:`${o} is ready`,lead:`Send ${o} the card or the link. They open it, add their devices and connect — no account needed.`});return}let i=this.person(e);te(`${o} is ready`,[t("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[t("button",{class:"cbi-button cbi-button-neutral",click:oe},"Done")," ",t("a",{class:"cbi-button cbi-button-neutral",href:`${L.url("admin/network/dawnline/settings")}?section=portal`},"Open Settings")," ",i?H("Add device",()=>{oe(),nt(i,this.deviceOpts(i))},"positive"):""])}};var kn=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],uo=n=>t("i",{class:"dl-circle-dot",style:`background:${kn[n?.color??0]??kn[0]}`}),rt=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function Pr(n,e,o){let r=ie(n?.name??e.name??"",{placeholder:"NAS"}),a=ie(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=ie((n?.ports??e.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=ye("Name",r,()=>_e(r.value,[],"Shown to people who may reach it.")),l=ye("Address",a,()=>Uo(a.value)),c=ye("Ports",i,()=>Wo(i.value));te(n?`Edit ${n.name}`:"Add service",[s,l,c],[ae()," ",H("Save",async()=>{let d=ze([s,l,c]);if(d){U(d,"warning");return}let p=i.value.split(/[ ,]+/).filter(Boolean);await W(()=>A.serviceSet(n?.id??"",r.value,a.value,p),"Saved")&&(oe(),o())},"positive")])}var rs={_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"},as=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function is(n){let e=new Map;for(let o of n.services){let r=rs[o.type.split(".")[0]];!r||!o.port||(e.get(r)??e.set(r,new Set).get(r)).add(String(o.port))}return e.size?[...e].map(([o,r])=>[o,[...r].sort((a,i)=>+a-+i)]):as}function Dr(n,e,o){let r=n,a=null,i=!1,s=null,l=new Set,c=t("div",{class:"dl-list"}),d=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},"Looking for devices at home…")),p=()=>{let m=r.services;dom.content(c,m.length?m.map(k=>t("div",{class:"dl-row"},[b("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},k.name),t("span",{class:"dl-mono dl-faint"},`${k.address}${k.ports.length?` · ports ${k.ports.join(", ")}`:" · all ports"}`)]),H("Edit",()=>Pr(k,{},o)),H([b("trash")],async()=>{await se(`Remove ${k.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await W(()=>A.serviceDelete(k.id),"Removed")&&await o()},"neutral",{title:"Remove","aria-label":`Remove ${k.name}`})])):[t("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function u(m,k){if(!l.has(m.address)){l.add(m.address),C();try{let I=r.services.find(v=>v.address===m.address);(k===null?I&&await W(()=>A.serviceDelete(I.id),`${I.name} removed`):await W(()=>A.serviceSet(I?.id??"",I?.name??(m.name||m.address),m.address,k),I?`${I.name} updated`:`${m.name||m.address} added`))&&await o()}finally{l.delete(m.address),C()}}}function w(m){let k=r.services.find(E=>E.address===m.address),I=!!k&&!k.ports.length,x=new Set(k?.ports??[]),v=l.has(m.address),$=(E,y,z)=>qe(E,y,z,{disabled:v?"disabled":null,"aria-busy":v?"true":null});return t("div",{class:"dl-row"},[b(m.services.some(E=>E.type.startsWith("_ipp")||E.type.startsWith("_printer"))?"file":"computer"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},m.name||m.address),t("span",{class:"dl-mono dl-faint"},m.address)]),t("div",{class:"dl-chips-row dl-host-ports"},[$("All ports",I,()=>u(m,I?null:[])),...is(m).map(([E,y])=>{let z=!I&&y.every(h=>x.has(h));return $(`${E} ${y.join(", ")}`,z,()=>{let h=new Set(I?[]:x);for(let f of y)z?h.delete(f):h.add(f);u(m,h.size?[...h]:null)})})])])}function C(){if(i)return dom.content(d,t("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!a)return;let m=a;if(!m.hosts.length)return dom.content(d,t("span",{class:"dl-sub"},"No devices found in the home network right now."));let k=t("details",{class:"dl-params",open:s??!r.services.length?"":null},[t("summary",{},[b("chevron"),t("span",{},"Add from devices at home"),t("span",{class:"dl-pcount"},String(m.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},m.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."),t("div",{class:"dl-list"},m.hosts.map(w))])]);k.addEventListener("toggle",()=>s=k.open),dom.content(d,k)}return A.homeHosts(e).then(m=>{a=m,C()}).catch(()=>{i=!0,C()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},"Home services"),H([b("plus")," Add service"],()=>Pr(null,{},o))]),t("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),c,d]),update(m){r=m,p(),C()}}}function $n(n,e,o,r){let a=new Set(n.circles.filter(m=>m.server===e).map(m=>m.color)),i=o?.color??kn.findIndex((m,k)=>!a.has(k));i<0&&(i=0);let s=ie(o?.name??"",{placeholder:"Family"}),l=n.people.filter(m=>m.server===e).sort((m,k)=>m.name.localeCompare(k.name)),c=new Set(l.filter(m=>o&&m.circle===o.id).map(m=>m.id)),d=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),p=()=>dom.content(d,kn.map((m,k)=>t("button",{type:"button",role:"radio",class:`dl-swatch${k===i?" on":""}`,style:`--sw:${m}`,"aria-checked":k===i?"true":"false","aria-label":`Colour ${k+1}`,click:()=>{i=k,p()}})));p();let u=t("div",{class:"dl-chips-row"},l.map(m=>{let k=m.circle&&m.circle!==o?.id?n.circles.find(I=>I.id===m.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${c.has(m.id)?" on":""}`,title:rt(m)?k?`Now in ${k.name}`:"":`${m.name} has no home access: their devices aren't reachable anyway`,click:I=>{c.delete(m.id)||c.add(m.id),I.currentTarget.classList.toggle("on",c.has(m.id))}},[m.name,rt(m)?k?t("b",{},k.name):"":t("b",{},"internet")])})),w=(m,k)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},m),t("div",{class:"cbi-value-field"},k)]),C=n.circles.filter(m=>m.server===e&&m.id!==o?.id).map(m=>m.name),g=ye("Name",s,()=>Ro(s.value,C));te(o?`Edit ${o.name}`:"New circle",[g,w("Colour",d),w("People",u),t("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[o?H("Delete",async()=>{await W(()=>A.circleDelete(o.id),`${o.name} deleted`)&&(oe(),r())},"negative"):"",t("span",{class:"dl-spacer"}),ae()," ",H("Save",async()=>{let m=g.help();if(m.bad){U(m.text,"warning");return}await W(()=>A.circleSet(o?.id??"",e,s.value,i,[...c]),"Saved")&&(oe(),r())},"positive")],"dl-circle-modal")}function Ar(n,e,o){let r=n.circles.filter(a=>a.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...r.map(a=>{let i=n.people.filter(s=>s.circle===a.id).map(s=>s.name);return t("button",{type:"button",class:"dl-chip",title:`Edit ${a.name}`,click:()=>$n(n,e,a,o)},[uo(a),t("b",{},a.name),t("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),t("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>$n(n,e,null,o)},b("plus"))])}function mo(n,e){let o=n.people.filter(p=>p.server===e.id),r=(p="")=>t("span",{class:"dl-yes"},[b("check"),p]),a=()=>t("span",{class:"dl-faint"},"—"),i=p=>{let u=new Set(p.map(w=>w.access==="lan"&&w.services?.length?"services":w.home_nets?.length?"some":"all"));return u.size||u.add("all"),r([...u].map(w=>({all:"all networks",some:"their networks",services:"services"})[w]).join(" / "))},s=()=>e.mesh==="off"?a():e.mesh==="circles"?r("circle"):r(),l=e.lan_like?"like home":"direct",c=(p,u,w)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},`${u.length} ${u.length===1?"person":"people"}`)]),...w.map(C=>t("td",{},C))]),d=p=>o.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Who reaches what"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"From the rules on this server")]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["","Internet","Home","This router","Each other"].map(p=>t("th",{},p))),c("Internet",d("internet"),[r(l),a(),t("span",{class:"dl-faint"},"DNS"),a()]),c("Home",d("lan"),[t("span",{class:"dl-faint"},"their own"),i(d("lan")),r(),s()]),c("Both",d("both"),[r(l),i(d("both")),r(),s()])])),t("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 Hr(n,e){let o=n.people.filter(d=>d.server===e.id).flatMap(d=>d.devices.map(p=>({id:p.id,label:`${d.name} · ${p.name}`}))).sort((d,p)=>d.label.localeCompare(p.label)),r="@addr",a=(d,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":d},[...o.map(m=>t("option",{value:m.id,selected:m.id===p?"selected":null},m.label)),t("option",{value:r,selected:p===r?"selected":null},"Address")]),w=ie("",{placeholder:d,class:"cbi-input-text dl-mono"}),C=t("div",{class:"dl-check-end"},[u,w]),g=()=>w.hidden=u.value!==r;return u.addEventListener("change",g),g(),{el:C,value:()=>u.value===r?w.value.trim():u.value}},i=a("10.0.1.11",o[0]?.id??r),s=a("10.0.1.20:445",r),l=t("div",{class:"dl-stack gap8"}),c=async()=>{let d=await W(()=>A.accessCheck(i.value(),s.value()));if(!d)return;let p=d.steps.findIndex(u=>!u.ok);dom.content(l,[t("div",{class:`dl-verdict ${d.ok?"ok":"bad"}`},[t("b",{},d.ok?"Allowed":"Blocked"),t("span",{class:"dl-sub"},d.ok?"Every step lets it through":`Stops at step ${p+1} of ${d.steps.length}`)]),t("ul",{class:"dl-checks"},d.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},b(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Check access"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"Why something does or does not connect")]),t("div",{class:"dl-check-form"},[i.el,t("span",{class:"dl-faint"},"→"),s.el,H("Check",c)]),l])])}var Cn={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function at(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function En(n){return at(n.action==="check"?`check:${n.component??""}`:n.component??"")}function zr(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function Nr(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function Rr(n,e){let o=n.check?.components??{},r=e==="all"?["app","amneziawg","packages"]:[e],a=[],i;for(let l of r){let c=o[l];if(c){if(c.error)return{tone:"warn",text:c.error};l==="packages"&&c.updates?a.push(`${c.updates} system package${c.updates===1?"":"s"}`):l!=="packages"&&c.update&&c.installed&&c.latest&&(a.push(`${Cn[l]} ${c.latest}`),e!=="all"&&(i=c.latest))}}if(a.length)return{tone:"acc",text:`Update available: ${a.join(", ")}`,update:i};let s=r.length===1?o[r[0]]:null;return s?.status==="dev"?{tone:"acc",text:`Installed version is newer than the release (${s.latest})`}:s?.note?{tone:"warn",text:s.note}:{tone:"ok",text:r.length>1?"Everything is up to date":"Latest version is installed"}}function Ir(n,e,o,r){return e?n.id===e:o&&n.id===o?!1:n.state==="running"||r>0&&n.started>=r}var Br=n=>new Promise(e=>setTimeout(e,n));async function Jt(n,e,o){let r=o?En(o):at(n),a=o?o.action==="check":n.startsWith("check"),i=Date.now(),s=t("b",{},Cn[r]??(r==="all"?"All components":"Dawnline")),l=t("span",{class:"dl-pill dl-mono"},e.version??""),c=t("span",{class:"dl-pill info",hidden:!0}),d=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),u=t("div",{}),w=t("div",{class:"dl-op-actions"}),C=[],g=h=>dom.content(w,h),m=(h=!1)=>ae("Close",h);te(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[s,e.version?l:"",c,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[b("clock"),d])]),t("div",{class:"dl-op-loghead"},[t("b",{},"Operation log"),Le("copy","Copy log",()=>pe(C.join(` +`),"Log copied"))]),p,u]),[w],"wide"),g([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},a?"Checking…":"Working…")]);let k=o??null,I=o?.id,x,v=0,$=h=>{I!==h.id&&(I=h.id,e.onJob?.(h))};if(o)e.onJob?.(o);else try{let h=await A.updatesStatus().catch(()=>null);x=h?.job?.id,v=h?.now??0;let f=await A.updatesRun(n);f.job&&f.job.state==="running"&&f.job.id!==x&&(k=f.job,$(f.job))}catch(h){return C=[be(h)],p.textContent=C[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},be(h))])),g([m(!0)]),U(be(h),"error"),null}let E=null,y=0;for(;;){if(await Br(1e3),E=await A.updatesStatus().catch(()=>null),!E){if(++y>60)break;continue}y=0;let h=E.job;if(!h||!Ir(h,I,x,v)){if(Date.now()-i>15e3)break;continue}if($(h),k=h,h.log.length){C=h.log;let f=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=C.join(` +`),f&&(p.scrollTop=p.scrollHeight)}if(l.textContent=Nr(h,e.version??""),!l.isConnected&&l.textContent&&s.after(l),d.textContent=zr((h.finished??E.now)-h.started),h.state==="running"){c.hidden=!h.phase,c.textContent=h.phase;continue}break}if(p.scrollTop=p.scrollHeight,c.hidden=!1,!k||k.state==="running")return c.className="dl-pill warn",c.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),g([m()]),e.onDone?.(E),k;if(k.state==="failed")return c.className="dl-pill bad",c.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[b("x"),t("span",{},[t("b",{},k.error??"Operation failed"),a?"":". Nothing else was changed."])])),g([H("Copy log",()=>pe(C.join(` +`),"Log copied")),m(!0)]),U(`${Cn[r]??"Update"}: ${k.error??"failed"}`,"error"),e.onDone?.(E),k;if(c.className="dl-pill ok",c.textContent="Finished",a&&E){let h=Rr(E,r);if(dom.content(u,t("div",{class:`dl-comp-status ${h.tone}`},[b(h.tone==="ok"?"check":h.tone==="warn"?"alert":"download"),t("span",{},h.text)])),U(h.text,h.tone==="warn"?"warning":"success"),e.onDone?.(E),h.update&&e.onUpdate){let f=E;g([m(),H(`Update to ${h.update}`,()=>e.onUpdate(f),"positive")])}else g([m()]),h.tone==="ok"&&setTimeout(()=>u.isConnected&&oe(),1200);return k}if(r==="app"&&k.to){let h=k.to,f=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},[t("b",{},`Dawnline ${h} is installed. `),f])]));let T=()=>{ui.menu?.flushCache(),location.reload()};g([m(),H("Reload now",T,"positive")]),U(`Dawnline updated to ${h}`,"success",6e3);for(let S=1;S<=30;S++)if(f.textContent=`Waiting for the router to restart its services (${S} of 30)…`,await Br(1500),(await A.updatesStatus().catch(()=>null))?.version===h)return f.textContent="Services are back. Reloading…",setTimeout(T,800),k;return f.textContent="Services restarted. Reload the page to use the new version.",k}let z=r==="pkgs"?`Updated ${[...k.result?.pkgs?.updated??[],...k.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:r==="amneziawg"?`AmneziaWG${k.to?` ${k.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},z)])),g([m()]),U(z,"success"),e.onDone?.(E),k}var ss={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function Or(n,e,o,r){return!await se(`Install ${e}?`,o,"Install")||(await Jt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>r?.(),4e3),!0)}function Ln(n){return Or("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Vt(n,e,o){return n==="awg"?Ln(o):e.length?Or(`pkgs:${e.join(",")}`,ss[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function jr(n,e){if(n==="awg")return Ln(e);let o=await W(()=>A.updatesStatus());return o?Vt(n,o.needs?.[n]??[],e):!1}var ls=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],ds={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function Ur(n,e,o){let r=n.id,a=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,c="",d=!0,p=!0,u="all",w=!1,C=Dr(a,r,o),g=new Set,m="",k=()=>JSON.stringify([p,l,l?"":c,d,[...g].sort()]),I=()=>s.detected.lan||s.saved.lan||"",x=()=>(l?s.detected.wan||s.saved.wan:c)||"",v=()=>new Map(s.devices.map(R=>[R.name,R])),$=()=>{let R=v();return[...d&&I()?[I()]:[],...[...g].filter(Q=>Q!==I())].filter(Q=>Q!==x()).map(Q=>R.get(Q)??{name:Q,nets:[],missing:!0})},E=(R,J)=>{s=R,J&&(l=R.config.auto_wan,c=R.config.wan_device||R.detected.wan||R.saved.wan||"",d=R.config.auto_lan,p=R.config.lan_like,u=R.config.mesh??(R.config.device_mesh?"all":"off"),g=new Set(R.config.lan_devices),m=k()),q()},y=async R=>{let J=await A.interfaces(r).catch(Q=>(U(Q.message,"error"),null));J&&E(J,R)};function z(R){let J=d&&R.name===I(),Q=!!R.own||!!R.master||R.name===x()||J;return J||g.has(R.name)||!Q&&(R.nets.length>0||!!R.missing)}function h(R){let J=d&&R.name===I(),Q=R.name===x(),le=!J&&g.has(R.name),ue=!(!!R.own||!!R.master||Q||J)&&(R.nets.length>0||le||!!R.missing),ne=(le||J)&&!R.zone&&!R.missing,O=R.missing?"Not present right now":R.own?"This server":R.master?`Port of ${R.master}`:Q?`Internet${R.zone?` · zone ${R.zone}`:""}`:R.nets.length?R.nets.join(", "):"No IPv4 network",F=t("button",{type:"button",class:`dl-if${le?" sel":""}${J?" auto":""}${!ue&&!le&&!J?" off":""}${ne?" warn":""}`,"aria-pressed":le||J?"true":"false","aria-disabled":ue?null:"true",click:()=>{ue&&(g.has(R.name)?g.delete(R.name):g.add(R.name),q())}},[t("span",{class:"dl-if-ic"},b(ds[R.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},R.name),t("span",{class:"dl-if-sub"},O)]),J?t("span",{class:"dl-if-badge ok"},"Auto"):le?t("span",{class:"dl-if-check"},b("check")):""]);return me(F,()=>[t("div",{class:"dl-tip-title"},R.name),t("div",{class:"dl-muted"},[R.logical?`Interface ${R.logical}`:"No netifd interface",R.zone?` · zone ${R.zone}`:" · no firewall zone"]),R.members.length?t("div",{class:"dl-muted"},`Ports: ${R.members.join(", ")}`):"",R.nets.length?t("div",{class:"dl-mono"},R.nets.join(", ")):"",ne?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",R.master?t("div",{class:"dl-muted"},`Choose ${R.master} to include it.`):""]),F}function f(){let R=s.like_home;return!p||!s.config.lan_like||!n.enabled?"":!s.needs?.length&&R.active&&R.bridged?"ok":"warn"}function T(){let R=s.like_home;return p?s.needs?.length?[t("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?n.enabled?R.active&&R.bridged?["Internet traffic enters ",t("span",{class:"dl-mono"},R.dev??"")," as ",t("span",{class:"dl-mono"},R.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[t("span",{class:"dl-warn"},`Not working: ${R.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too."]:["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 S={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 N(R,J,Q,le,he="",ue){return t("div",{class:ue?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${he}`},b(R)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},J),t("span",{class:"dl-sub"},Q),ue??""])]),t("div",{class:"dl-setrow-ctl"},le)])}let G=(R,J)=>{let Q=le=>t("span",{class:"dl-mono"},le);return R?t("span",{},[" Now: ",Q(R),...J&&J!==R?[", was ",Q(J)]:[],"."]):t("span",{},J?[" Not found now: using ",Q(J),"."]:[" Not found."])};function q(){let R=t("select",{class:"cbi-input-select","aria-label":"Internet interface",change:M=>{c=M.target.value,q()}},s.devices.filter(M=>!M.own&&!M.master&&M.zone&&!M.missing).map(M=>t("option",{value:M.name,selected:M.name===c?"selected":null},`${M.name} · zone ${M.zone}`))),Q=$().flatMap(M=>M.nets.map(j=>[j,M.name])),le=JSON.parse(k()),he=JSON.parse(m),ue=(...M)=>M.some(j=>JSON.stringify(le[j])!==JSON.stringify(he[j])),ne=ue(0,1,2),O=ue(3,4),F=M=>H("Save",async()=>{let j=await W(()=>A.serverInterfaces(r,l,l?"":c,d,[...g],p,u!=="off",u),"Access saved");j&&(E(j,!0),j.nets_changed&&j.lan_only&&U(`${j.lan_only} ${j.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:!M}),P=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Internet"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Internet or Both")]),N("home","Internet like a home device",T(),[p&&s.needs?.length?H("Install",()=>Vt("home",s.needs,()=>y(!1)),"positive"):"",ve(p,"Internet like a home device",M=>{p=M,q()})],f()),N("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",G(s.detected.wan,s.saved.wan)],[l?"":R,ve(l,"Auto-detect WAN",M=>{l=M,q()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?["Internet like a home device",x()?[" · leaves through ",t("span",{class:"dl-mono"},x())]:""]:x()?["Internet straight to ",t("span",{class:"dl-mono"},x())]:"No WAN found"),F(ne)])]),D=we([["off","Off"],["all","Everyone"],["circles","Circles"]],u,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async M=>{let j={off:"Off",all:"Everyone",circles:"Circles"}[M];await W(()=>A.serverUpdate(r,{mesh:M}),`Devices reach each other: ${j}`)&&(u=M,s.config.mesh=M,q(),await o())}}),_=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Home network"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Home or Both"),H([b("reset")," Rescan"],()=>y(!1),"neutral",{title:"Read the interfaces again"})]),N("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.","","",V()),N("link","Devices reach each other",S[u],D,"",u==="circles"?Ar(a,r,o):void 0),C.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},Q.length?["Home access reaches ",...Q.flatMap(([M,j],Z)=>[Z?", ":"",t("span",{class:"dl-mono"},M),` (${j})`])]:"No home network: Home access reaches nothing but this router."),F(O)])]),B=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[P,_]),i.style.minHeight="",window.scrollTo({top:B})}function V(){let R=s.devices.filter(z),J=s.devices.filter(Q=>!z(Q));return t("div",{class:"dl-stack gap8 dl-netpick"},[R.length?t("div",{class:"dl-ifgrid"},R.map(h)):t("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},"Auto-detect LAN"),t("span",{class:"dl-sub"},["Adds the LAN this router uses.",G(s.detected.lan,s.saved.lan)])]),ve(d,"Auto-detect LAN",Q=>{d=Q,q()})]),J.length?t("details",{class:"dl-params",open:w?"":null,toggle:Q=>w=Q.currentTarget.open},[t("summary",{},[b("chevron"),t("span",{},"Other interfaces"),t("span",{class:"dl-pcount"},String(J.length))]),t("div",{class:"dl-params-body"},[t("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."),...ls.map(([Q,le])=>{let he=J.filter(ue=>ue.category===Q);return he.length?t("div",{class:"dl-ifgroup"},[t("h4",{},le),t("div",{class:"dl-ifgrid"},he.map(h))]):""})])]):""])}return y(!0),{el:i,update(R){a=R,C.update(R),s&&q()}}}var cs={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",expiring:"warn",expired_kept:"",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},ps={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",expiring:"calendar",expired_kept:"calendar"};function us(n,e){return e.device?n.people.flatMap(r=>r.devices).find(r=>r.id===e.device)?.kind??e.dkind??"other":ps[e.type]??"activity"}function ho(n,e){let o=n.people.find(g=>g.id===e.person),r=o?.name??e.pname??e.person??"",a=o?.devices.find(g=>g.id===e.device)?.name??e.dname??"",i=g=>t("b",{},g),s=g=>t("span",{class:"dl-muted"},g),l=g=>t("span",{class:"dl-mono"},g),c=g=>e.hosts?.[g]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[g]),t("span",{class:"dl-faint"},` (${g})`)])]:[l(g)],d=g=>t("span",{class:"dl-ev-kind"},`${g} `),p=a?`${r} · ${a}`:r,u=nr(e),w=u||a||"a device",C=g=>[t("span",{class:"dl-you"},"You"),s(` ${g} `)];if(Ne(e)==="admin")switch(e.type){case"device_added":return[...C("added"),d("device"),i(w),s(" for "),i(r)];case"device_removed":return[...C("removed"),d("device"),i(w),s(" from "),i(r)];case"paused":return[...C("paused"),d("person"),i(r)];case"resumed":return[...C("resumed"),d("person"),i(r)];case"device_changed":{let g=u.startsWith("renamed from ");return[...C(g?"renamed":u),d("device"),i(a||"a device"),s(" of "),i(r),...g?[s(` · was ${u.slice(13)}`)]:[]]}case"device_keys":return[...C("issued new keys for"),d("device"),i(w),s(" of "),i(r),s(" · it needs its new configuration")];case"link_changed":return[...C("issued a new link for"),d("person"),i(r),s(" · the old link stopped working")]}switch(e.type){case"connect":return[d("Device"),i(p),s(" connected"),...e.detail?[s(" from "),...c(e.detail)]:[],...e.where?[s(` · ${e.where}`)]:[]];case"disconnect":return[d("Device"),i(p),s(" went offline")];case"roam":return[d("Device"),i(p),s(" changed network "),...(e.detail??"").split(" → ").flatMap((g,m)=>m?[s(" → "),...c(g)]:c(g))];case"device_added":return[d("Person"),i(r),s(" added "),d("device"),i(w),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[d("Person"),i(r),s(" removed "),d("device"),i(w),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[d("Person"),i(r),s(" issued new keys for "),d("device"),i(w),s(" on their portal")];case"person_added":return[...C("added"),d("person"),i(e.detail??r)];case"person_removed":return[...C("removed"),d("person"),i(e.detail??r)];case"person_changed":return[...C("changed"),d("person"),i(r),...u?[s(` · ${u.replace(/_/g," ")}`)]:[]];case"expiring":return[d("Person"),i(r),s(`’s access ends in ${e.detail??"a few days"}`)];case"expired_kept":return[d("Person"),i(r),s(`’s end date passed (${e.detail??""}) · access kept`)];case"paused":return[d("Person"),i(r),s(` paused — ${e.detail??""}`)];case"resumed":return[d("Person"),i(r),s(" resumed"),...e.detail&&e.detail!=="active"?[s(` — ${e.detail}`)]:[]];case"portal_blocked":return[t("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(e.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[d("Person"),i(r),s(" — all devices removed, end date reached")];default:return[s(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var ms={portal_blocked:["globe","bad"]};function hs(n,e){if(n.servers.length<2||!e.person)return"";let o=n.people.find(a=>a.id===e.person),r=o&&n.servers.find(a=>a.id===o.server);return r?t("span",{class:"dl-ev-srv",title:"Server"},r.name):""}function it(n,e,o={}){let r=ms[e.type],a=Ne(e);return t("div",{class:`dl-row${a==="admin"?" dl-ev-by-admin":r?` dl-ev-by-system ${r[1]}`:""}`},[a==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):r?t("span",{class:"dl-ev-tile sys"},b(r[0])):t("span",{class:`dl-ev-tile ev ${cs[e.type]??""}`},b(us(n,e))),t("span",{class:"dl-row-main"},ho(n,e)),o.server===!1?"":hs(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString()},o.time??re(e.ts,n.now))])}var fs={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},gs={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function Mn(n,e,o,r){let a=n.by==="admin",i=t("div",{class:`dl-row dl-slog-row ${a?"dl-ev-by-admin":`dl-ev-by-system ${fs[n.level]??""}`}${n.detail?" has-detail":""}`},[a?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):t("span",{class:"dl-ev-tile sys",title:n.level},b(gs[n.src]??"zap")),t("span",{class:"dl-row-main"},a?[t("span",{class:"dl-you"},"You"),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):"",n.note?t("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},b("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},"Server "):"",t("b",{class:"dl-sys-src",title:Ot[n.src]??n.src},n.who??Ot[n.src]??n.src)," ",t("span",{class:"dl-muted"},n.msg),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},b("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString()},r)]);return n.detail&&i.addEventListener("click",s=>{s.target.closest("pre")||o()}),i}function Wr(n){let e=new Date(n*1e3),o=new Date,r=new Date;return r.setDate(o.getDate()-1),e.toDateString()===o.toDateString()?"Today":e.toDateString()===r.toDateString()?"Yesterday":e.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var Dt=n=>bt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function Tn(n,e,o,r=!1){let a=n.slice(-15),i=a[a.length-1],s=i&&e-i[0]<180,l=s?i[2]:0,c=s?i[1]:0,[d,p]=o,u=200,w=40,C=Math.max(1,...a.map(v=>Math.max(v[1],v[2]))),g=v=>a.map(($,E)=>`${a.length>1?E/(a.length-1)*u:u},${w-2-$[v]/C*(w-6)}`),m=g(2),k=g(1),I=a.length>1&&!r?Xe(``):t("div",{class:"dl-speed-wait"},[t("i"),r?"":t("span",{},"Collecting… 1 point a minute")]),x=(v,$,E,y)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:E},$),` ${v}`]),r?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},Oe(y))]);return a.length>1&&!r&&me(I,()=>{let v=a[a.length-1];return[t("div",{class:"dl-tip-title"},new Date(v[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${Oe(v[2])} · ↑ ${Oe(v[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Speed now"),r?"":t("span",{class:"dl-sub"},"last 15 min")]),t("div",{class:"dl-speed-cols"},[x("Download","↓","dl-dn",l),x("Upload","↑","dl-up",c)]),I,t("div",{class:"dl-speed-today"},[t("span",{},["Today ",t("b",{},X(d+p))]),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${X(p)} `,t("span",{class:"dl-up"},"↑"),` ${X(d)}`])])])}function Sn(n,e){let o=n.slice(-30),r=o.map(c=>c.rx+c.tx),a=Math.max(1,...r),i=r.reduce((c,d)=>c+d,0),s=r.reduce((c,d,p)=>d>r[c]?p:c,0),l=t("div",{class:"dl-bento-bars"},o.map((c,d)=>{let p=r[d],u=t("i",{class:d===o.length-1?"hi":"",style:`height:${Math.max(4,p/a*100)}%`});return me(u,()=>[t("div",{class:"dl-tip-title"},d===o.length-1?`Today · ${Dt(c.day)}`:Dt(c.day)),t("div",{},X(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${X(c.tx)} ↑ ${X(c.rx)}`)]),u}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},"Last 30 days"),t("b",{class:"dl-bento-total"},X(i))]),r[s]>0?t("span",{class:"dl-sub"},`peak ${X(r[s])} · ${Dt(o[s].day)}`):""]),o.length?l:t("p",{class:"dl-muted"},"No traffic yet."),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},o.length?Dt(o[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},"today")])])}function Gr(n){let e=n.slice(-30),o=e.map(a=>a.rx+a.tx),r=Math.max(1,...o);return t("div",{class:"dl-dbars"},e.map((a,i)=>{let s=t("i",{class:`${o[i]?"":"zero"}${i===e.length-1?" hi":""}`});return s.style.height=`${Math.max(8,o[i]/r*100)}%`,me(s,()=>[t("div",{class:"dl-tip-title"},i===e.length-1?`Today · ${Dt(a.day)}`:Dt(a.day)),t("div",{},X(o[i]))]),s}))}var Fr={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function _n(n){return n==="netrestart"&&!await se("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await W(()=>A.healthFix(n),"Done")??null}function fo(n,e,o,r="action"){let a=n.fix;return a?a.startsWith("install:")?H("Install",()=>jr(a.slice(8),o),r):a==="updates"?t("a",{class:`cbi-button cbi-button-${r}`,href:L.url("admin/network/dawnline/updates")},Fr.updates):H(Fr[a]??"Fix",()=>e(a),r):""}function vs(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="flash"?"download":n==="nft"?"lock":n==="data"?"users":"alert"}function qr(n,e,o,r=3){let a=n.filter(s=>s.status==="error"||s.status==="warn").sort((s,l)=>s.status===l.status?0:s.status==="error"?-1:1);if(!a.length)return"";let i=a.length-r;return t("div",{class:"dl-list dl-notices"},[...a.slice(0,r).map(s=>Qe(vs(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,fo(s,e,o,s.status==="error"?"positive":"neutral"))),i>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,t("span",{class:"dl-spacer"}),"→"]):""])}function bs(n){let e=[],o=(s,l)=>t("a",{href:s},l),r=Ie(n.series),a=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?e.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!a&&e.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});for(let s of n.people)if(s.state==="quota")e.push({tone:"warn",text:[o(ke(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")e.push({tone:"warn",text:[o(ke(s.id),s.name),"’s access has ended."]});else{let l=Ve(s.expires,r);Ye(s,l)?e.push({tone:"",text:[o(ke(s.id),s.name),`’s access ${Xt(l)}.`]}):l!=null&&l<0&&s.expire_action==="notify"&&e.push({tone:"",text:[o(ke(s.id),s.name),`’s end date passed (${Me(s.expires)}) · access kept.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&e.push({tone:"",text:[o(ke(s.id),s.name)," has used 90% of the data limit."]})}let i=n.people.flatMap(s=>s.devices.filter(l=>l.config_stale).map(l=>[s,l]));i.length&&e.push({tone:"warn",text:i.length===1?[o(ke(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)," needs its configuration again."]:[`${i.length} devices need their configuration again (networks or DNS changed).`]});for(let s of n.servers)n.wan&&kt(s.endpoint)&&s.endpoint!==n.wan&&e.push({tone:"warn",text:[`Public address changed: ${s.name} still gives devices ${s.endpoint}, the router is ${n.wan} now. `,t("button",{type:"button",class:"dl-fix",click:async l=>{let c=l.currentTarget;c.disabled=!0,await W(()=>A.serverUpdate(s.id,{endpoint:n.wan}),`${s.name} uses ${n.wan} now — devices need their configuration again`),c.disabled=!1}},"Use the new address")," A DDNS name would follow it by itself."]});return n.servers.some(s=>s.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[`Internet through the LAN is off: ${n.like_home.error} `,o(L.url("admin/network/dawnline/diagnostics"),"Details")]}),!n.settings.portal_enabled&&!n.people.length&&e.push({tone:"",text:["The personal portal is off. ",o(L.url("admin/network/dawnline/settings"),"Turn on")]}),e}var Pn=class{constructor(e,o){this.srvId=e;this.go=o;this.el=t("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=Kt(e,this.srvId);for(let o of["health","bento","side","activity"])this.parts[o]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,o=!1){this.st=Kt(e,this.srvId),this.paint(o),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await A.health().catch(()=>null);if(!e)return;let o=()=>void this.loadHealth(),r=async a=>{await _n(a)&&(o(),a==="netrestart"&&setTimeout(o,5e3))};Te(this.parts.health,qr(e.checks,a=>void r(a),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let e=this.st,o=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},"Where people connect from"),t("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),t("span",{class:"dl-spacer"}),Tt(this.range,s=>{this.range=s,this.map?.setRange(s)})]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map?.destroy(),this.map=new tt({openPerson:s=>location.href=ke(s),openDevice:(s,l)=>location.href=ke(s,l)},this.range);let r=$e(()=>{r(),this.map?.destroy(),this.map=null}),a=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),"Live tunnel"]),t("span",{},[t("i",{class:"line"}),"Seen recently"])]),i=t("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),t("div",{class:"dl-panel flush"},[o,i])}paint(e=!1){let o=this.st,r=o.servers[0];Te(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Be(r).overviewTile(r),this.monthTile()]),e);let a=bs(o);Te(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Needs attention"),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),a.length?a.slice(0,8).map(s=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${s.tone}`}),t("span",{},s.text),s.action??""])):t("div",{class:"dl-row dl-muted"},[b("check"),"All good. Nothing needs you right now."])]),e);let i=[...o.events].reverse().slice(0,8);Te(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),i.length?i.map(s=>it(o,s)):t("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),e)}onlineTile(){let e=this.st,o=e.servers[0]?!e.servers[0].enabled:!1,r=12,a=I=>I.spark[I.spark.length-1]??0,i=I=>e.geo.points.find(x=>x.device===I.id&&x.city)?.city,s=I=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(I.endpoint??""),l=(I,x=!1)=>s(I)?x&&I.endpoint?`LAN · ${I.endpoint}`:"LAN":i(I)??"",c=I=>[...e.events].reverse().find(x=>x.type==="connect"&&x.device===I.id)?.ts??0,d=e.people.map(I=>({p:I,devs:I.devices.filter(x=>x.online).sort((x,v)=>a(v)-a(x))})).filter(I=>I.devs.length).sort((I,x)=>x.devs.reduce((v,$)=>v+a($),0)-I.devs.reduce((v,$)=>v+a($),0)),p=d.length<=2,u=({p:I,devs:x})=>{let v=x.map(c).filter(Boolean),$=v.length?Math.min(...v):0,E=(I.rate??[]).slice(-15),y=E[E.length-1],z=y&&e.now-y[0]<180?y:null,h=200,f=30,T=Math.max(1,...E.map(V=>Math.max(V[1],V[2]))),S=V=>E.map((R,J)=>`${E.length>1?J/(E.length-1)*h:h},${f-2-R[V]/T*(f-6)}`),N=E.length>1?Xe(``):"",G=!z||z[1]<64&&z[2]<64,q=I.access==="both"?["home","globe"]:I.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},He(I.name)),t("span",{class:"dl-stack"},[t("b",{},I.name),t("span",{class:"dl-hc-since"},$?`online for ${re($,e.now).replace(" ago","")}`:"online")]),t("span",{class:"dl-hc-reach"},q.map(V=>t("span",{class:`dl-ibadge ${V==="home"?"lan":"inet"}`},b(V))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},G?[t("span",{class:"dl-faint"},"Idle right now")]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${Oe(z[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${Oe(z[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},"15 min")]),N]),t("div",{class:"dl-hc-devs"},x.map(V=>t("span",{class:"dl-hc-dev"},[b(V.kind),V.name,l(V)?[" · ",l(V,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${X(x.reduce((V,R)=>V+a(R),0))} today · ${X(I.month[0]+I.month[1])} this month`)])])]},w=I=>{let{p:x,devs:v}=I,$=t("span",{class:"dl-onl-dev"},v.length>1?String(v.length):b(v[0].kind)),E=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:ke(x.id),"aria-label":`${x.name}, online`},[t("span",{class:"dl-onl-av"},[He(x.name),$]),p?t("span",{class:"dl-onl-name"},x.name):"",p?t("span",{class:"dl-onl-meta"},[...v.slice(0,3).map(y=>b(y.kind)),v.length>3?`+${v.length-3}`:"",l(v[0])?t("span",{},[" · ",l(v[0])]):""]):""]);return me(E,()=>u(I)),E},C=t("b",{class:`dl-onl-count${d.length?"":" none"}`},String(d.length)),g=d.reduce((I,x)=>I+x.devs.length,0);d.length&&me(C,()=>[`${d.length} ${d.length===1?"person":"people"} · ${g} device${g===1?"":"s"}`]);let m=d.length>r?d.slice(0,r-1):d,k=e.people.flatMap(I=>I.devices.map(x=>({p:I,d:x}))).filter(I=>I.d.handshake).sort((I,x)=>x.d.handshake-I.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Online"),C]),d.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...m.map(w),d.length>r?t("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"))}},[t("span",{class:"dl-onl-av"},`+${d.length-m.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},o?"The server is turned off":"Nobody is connected"),k?t("span",{class:"dl-sub"},`Last: ${k.p.name}, ${re(k.d.handshake,e.now)}`):t("span",{class:"dl-sub"},o?"Devices connect once it is on":"No device has connected yet")])])}speedTile(){let e=this.st.servers[0];return Tn(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){let e=[...this.st.people].map(o=>[o,o.month[0]+o.month[1]]).filter(([,o])=>o>0).sort((o,r)=>r[1]-o[1]).slice(0,2);return Sn(this.st.series,e.length?`Most: ${e.map(([o,r])=>`${o.name} ${X(r)}`).join(" · ")}`:"")}};var Kr=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],xs={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},go=(n,e)=>{let o=new URLSearchParams;n&&o.set("server",n),e&&e!=="overview"&&o.set("section",e);let r=o.toString();return`${L.url("admin/network/dawnline/server")}${r?`?${r}`:""}`},Yt=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await A.status(31),o=e.servers.length?null:await A.setupDefaults();return[e,o]}render([e,o]){if(this.st=e,!e.servers.length&&o)return this.wizard(o);let r=new URLSearchParams(location.search),a=r.get("section")??"",i=xs[a]??a;return Kr.some(([s])=>s===i)&&(this.section=i),this.srvId=(e.servers.find(s=>s.id===r.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller?.stop(),this.poller=ot({fetch:()=>A.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(s,l)=>{s.servers.length&&(this.st=s,this.paintHead(l),this.ov[this.current().id]?.update(s,l))}}),this.root}paintHead(e=!1){Te(this.headEl,this.head(this.current()),e),(!e||!Pt(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await A.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await A.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=go())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(o=>t("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===e.id?" on":""}`,"aria-selected":o.id===e.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[t("i",{class:`dot ${o.enabled?o.up?"ok":"bad":"warn"}`}),t("b",{},o.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[b("plus"),"Add server"])]))}paintSections(){let e=Be(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},Kr.map(([o,r])=>t("button",{type:"button",role:"tab","data-section":o,class:o===this.section?"on":"","aria-selected":o===this.section?"true":"false",click:()=>this.showSection(o)},o==="awg"?e.label:r))))}go(e,o){let r=this.pp[this.current().id];if(o&&r)r.filter=o,r.el&&r.decorate();else if(o){let a=this.pp[this.current().id]=new ut;a.filter=o}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of e)o&&this.bodyEl.contains(o)&&o.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===e;s.classList.toggle("on",l),s.setAttribute("aria-selected",l?"true":"false")});let o=this.st,r=this.current(),i={overview:()=>{let s=this.ov[r.id];return s?(s.update(o),s.el):(this.ov[r.id]=new Pn(r.id,(l,c)=>this.go(l,c))).mount(o)},people:()=>{var d,p;let s=this.pp[r.id];if(s?.el)return s.update(),s.el;let l=t("div",{},t("p",{class:"dl-muted"},"Loading people…"));return((d=this.pp)[p=r.id]??(d[p]=new ut)).embed(o,r.id).then(u=>{l.isConnected?dom.content(l,u):l.replaceChildren(u)}).catch(u=>{delete this.pp[r.id],dom.content(l,t("p",{class:"dl-muted"},`Couldn't show people: ${be(u)}`))}),l},connection:()=>this.connection(r),access:()=>this.access(r),awg:()=>this.awg(r)}[e]();this.detachKept(),dom.content(this.bodyEl,i)}head(e){let o=(i,s)=>t("span",{class:"dl-addrbar-seg"},[b(i),...s]),r=e.endpoint||"—",a=t("div",{class:"dl-actions"},[e.enabled?"":H([b("play")," Turn on"],()=>this.save(e,{enabled:"1"},"Server turned on"),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?"Running":e.blocked?"Can’t start":"Not running":"Turned off"),t("span",{class:"dl-spacer"}),a]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>pe(r,"Address copied")},[b("globe"),t("span",{class:"dl-mono"},r),b("copy")]),o(Be(e).id==="awg"?"amneziawg":"tunnel",[t("span",{class:"dl-mono"},`${Be(e).label} :${e.port}`)]),e.up?o("clock",[`up ${vt(e.uptime)}`]):""]),e.blocked?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},`${e.name} ${e.blocked}.`)]):""])}async save(e,o,r="Saved"){await W(()=>A.serverUpdate(e.id,o),r)&&await this.refresh()}connection(e){let o=ie(e.name,{placeholder:"Home"}),r=ie(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),a=ie(e.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter(C=>C.server===e.id).length,s=H([b(e.enabled?"pause":"play"),e.enabled?" Turn off":" Turn on"],async()=>{e.enabled&&!await se(`Turn off ${e.name}?`,`The tunnel stops and ${i} ${i===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?"Server turned off":"Server turned on")},e.enabled?"negative":"positive"),l=this.st.settings.portal_host,c=fe("Name",o,()=>_e(o.value,[],"Shown to people in their portal and apps.")),d=Vn(()=>({host:r.value,port:e.port,id:e.id}),(C,g,m)=>A.endpointProbe(C,g,m),()=>p.refresh(),{empty:l?`Empty = the portal’s address (${l}).`:"Empty = the portal’s address."}),p=fe("Public address",r,d.help);r.addEventListener("input",d.schedule),d.schedule();let u=e.reached?`Reached from the internet ${re(e.reached,this.st.now)}.`:"Never reached from the internet yet — test with a phone on mobile data.",w=fe("DNS for devices",a,()=>Io(a.value,e.address));return t("div",{class:"dl-stack gap16"},[Rt("Connection",[t("p",{class:"dl-muted"},"The name people see, where devices find the router, and DNS. The port is on AmneziaWG."),ge("router","Server","What people see",[c]),ge("globe","Devices connect to","A DDNS name keeps links working when your IP changes; not through Cloudflare (use a DNS-only name or an IP)",[p,t("div",{class:`dl-sub ${e.reached?"ok":"warn"}`},u)]),ge("file","For every device","Changing it marks devices “Update config” until they import again",[w])],[t("span"),H("Save",()=>{let C=ze([c,p,w]);if(C){U(C,"warning");return}return this.save(e,{name:o.value,endpoint:r.value,dns:a.value})},"positive")]),Rt("Danger zone",[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?"Turn off this server":"This server is off"),t("span",{class:"dl-sub"},e.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.")]),t("div",{class:"dl-setrow-ctl"},s)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Change the tunnel network"),t("span",{class:"dl-sub"},`Devices have ${yt(e.subnet)}.x addresses now. A new range when it clashes with a network you connect to; every device then needs its configuration again.`)]),t("div",{class:"dl-setrow-ctl"},H([b("edit")," Change"],()=>this.changeSubnet(e),"negative"))]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Remove server"),t("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),t("div",{class:"dl-setrow-ctl"},H([b("trash")," Remove"],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let o=mo(this.st,e),r=Ur(e,this.st,async()=>{let a=await this.refreshStatus();if(!a)return;let i=a.servers.find(l=>l.id===e.id)??e;r.update(a);let s=mo(a,i);o.replaceWith(s),o=s});return t("div",{class:"dl-stack gap16"},[r.el,t("div",{class:"dl-health-cols"},[o,Hr(this.st,e)])])}awg(e){let o={st:this.st,save:(r,a)=>this.save(e,r,a),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[Be(e).settingsCard(o,e)])}async addServer(){let e=await W(()=>A.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async changeSubnet(e){let o=await W(()=>A.serverPorts(e.id));if(!o)return;let r=o.networks??[],a=this.st.people.filter(l=>l.server===e.id).reduce((l,c)=>l+c.devices.length,0),i=ie(yt(e.subnet),{class:"cbi-input-text dl-mono dl-w-range"}),s=fe("Address range",i,()=>Jn(i.value,r,""));te("Change the tunnel network",[s,t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from their personal link or from you).`:"No devices on this server yet: nothing else changes.")],[ae()," ",H("Change",async()=>{let l=s.help();if(l.bad){U(l.text,"warning");return}let c=rn(i.value);if(c===e.subnet){oe();return}await W(()=>A.serverUpdate(e.id,{subnet:c}),"Tunnel network changed")&&(oe(),a&&U("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())},"negative")]),setTimeout(()=>i.select(),50)}async remove(e){let o=this.st.people.filter(r=>r.server===e.id);te(`Remove ${e.name}?`,[t("p",{},`This removes the tunnel, its firewall rules and ${o.length} ${o.length===1?"person":"people"} with all their devices. A backup is made first.`)],[ae()," ",H("Remove",async()=>{oe(),await W(()=>A.serverDelete(e.id),"Server removed")&&setTimeout(()=>{location.href=go()},800)},"negative")])}wizard(e,o=!1,r){let a={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:yt(e.subnet),preset:un(e.awg),portal:!1,portal_port:e.portal_port||8443,lan_like:!0,lan_zone:e.lan_zone,wan_zone:e.wan_zone},i=0,s=!o&&a.portal_port===a.port,l=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(a.endpoint),c=()=>It(a.port,e.udp_taken??[],`Opened on the WAN firewall automatically.${a.port===4500?" 4500 is IPsec’s port: most networks let it through.":""}`),d={ddns:"From your DDNS name.",cert:"From your Let’s Encrypt certificate.",wan:"Your WAN address now — it may change; a DDNS name is better.",portal:"The portal’s address."},p=Vn(()=>({host:a.endpoint,port:a.port}),(T,S,N)=>A.endpointProbe(T,"",N),()=>u?.refresh(),{idle:()=>a.endpoint===e.endpoint&&e.endpoint_from?d[e.endpoint_from]??"":""}),u=null,w=e.wan_kind==="cgnat"||e.wan_kind==="private"?Qe("alert","warn",e.wan_kind==="cgnat"?"Your router has no public address (CGNAT)":`Your router is behind another router (WAN ${e.wan_ip})`,e.wan_kind==="cgnat"?"The ISP shares one address: devices can only connect if the ISP gives you a public address or IPv6. Ask them, or use a DDNS name that points at an IPv6 address.":"Forward the UDP port on the upstream router to this one and use a DDNS name or that router’s public address here.",""):"",C=e.awg_state?.tools&&e.awg_state.handler===!1?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},"Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.")]):"",g=()=>Jn(a.range,e.networks??[],yt(e.subnet)),m=()=>an(a.portal_port,e.tcp_taken??[],l()),k=t("div",{class:"dl-wizard"}),I=(T,S={})=>{let N=ie(String(a[T]),S);return N.addEventListener("input",()=>{T==="port"||T==="portal_port"?a[T]=N.value.trim()===""?0:Number(N.value):a[T]=N.value.trim(),T==="port"&&s&&(a.portal_port=a.port),T==="portal_port"&&(s=a.portal_port===a.port)}),N},x={id:"server",title:"Server",render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},o?"One more server: another port or disguise for networks where the first does not get through, or its own home access rules. People are moved between servers from their page.":"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),ge("router","Server","What people see",[fe("Name",I("name"),()=>_e(a.name,[],"Shown to people in their portal and apps."))]),ge("globe","Devices connect to","A hostname or IP address of your router on the internet; not through Cloudflare (use a DNS-only name or an IP). IPv6 works too, and is the way out of CGNAT",[(()=>{let T=I("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"});return u=fe("Public address",T,p.help),T.addEventListener("input",p.schedule),p.schedule(),u})()]),w,C]),check:()=>{let T=_e(a.name);if(T.bad)return`Name: ${T.text}`;let S=wt(a.endpoint,a.port);return S.bad?`Public address: ${S.text}`:null}},v={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[ge("globe","Listening","Where devices reach AmneziaWG from the internet",[fe("UDP port",I("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),c)]),ge("network","Tunnel network","Addresses devices get inside the tunnel",[(()=>{let T=I("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":"First three numbers of the device addresses"});return fe("Device addresses",T,g,t("span",{class:"dl-suffixed"},[T,t("span",{class:"dl-mono"},".x")]))})()]),ge("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[mn(e.awg,a.preset,T=>a.preset=T,void 0,e.awg_state?.tools!==!1)])]),check:()=>{let T=c();if(T.bad)return`UDP port: ${T.text}`;let S=g();return S.bad?`Device addresses: ${S.text}`:null}},$={id:"portal",title:"Portal",render:()=>{let T=I("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),S=fe("Listening port",T,m);S.hidden=!a.portal;let N=we([["off","Off"],["on","On"]],a.portal?"on":"off",{label:"Personal portal",onChange:G=>{a.portal=G==="on",S.hidden=!a.portal}});return t("div",{class:"dl-wizard-groups"},[ge("home","Internet like a home device","How devices reach the internet",[de("Through the home network",ve(a.lan_like,"Internet like a home device",G=>a.lan_like=G),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),ge("link","Personal portal","A page where each person adds their own devices with their personal link",[de("Portal",N,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),S])])},check:()=>{if(!a.portal)return null;let T=m();return T.bad?`Portal port: ${T.text}`:null}},E=()=>[x,v,o?null:$].filter(T=>T!=null),y=e.awg_state,z=y?.missing??[],h=z.length?t("div",{class:"dl-list dl-notices"},[Qe("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${z.join(" and ")}. Install the build made for this firmware, then create the server.`,H("Install",()=>Ln(()=>location.reload()),"positive"))]):y&&!y.loaded?t("div",{class:"dl-list dl-notices"},[Qe("shield","warn","AmneziaWG’s kernel module doesn’t load on this firmware","Try another build in Components, or update OpenWrt. The server can’t start until it loads.",t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",f=()=>{let T=E();i>=T.length&&(i=T.length-1),dom.content(k,[t("h2",{},o?"Add a server":"Set up Dawnline"),h,t("div",{class:"dl-steps"},T.map((S,N)=>t("span",{class:`dl-step${N===i?" current":N0?H("Back",()=>{i--,f()}):r?H("Cancel",r):"",t("span",{class:"dl-spacer"}),i{let S=T[i].check?.();if(S){U(S,"warning");return}i++,f()},"positive"):H("Create server",async()=>{for(let N of T){let G=N.check?.();if(G){U(G,"warning");return}}let S=await W(()=>A.serverCreate(a.id,a.name,e.ifname,a.port,rn(a.range),a.endpoint,e.mtu,a.preset,a.lan_zone,a.wan_zone,a.lan_like,o?void 0:a.portal,o?void 0:a.portal_port),"Server created");S&&(S.network_restart&&U("Restarting the network so it knows AmneziaWG: back in a few seconds"),setTimeout(()=>{location.href=go(S.id)},S.network_restart?1e4:1500))},"positive",{disabled:z.length>0,title:z.length?"Install AmneziaWG first":null})])])};return f(),k}};function st(n){let e={el:n(),refresh(){let o=n();e.el.replaceWith(o),e.el=o}};return e}function Re(n,e,o,r,a="",i=[]){return t("section",{class:`dl-setsec ${a}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[i.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...i]):t("h3",{},e),...o]),r.length?t("div",{class:"dl-setsec-foot"},r):""])}function Jr(n){let e=n.filter(a=>a.status!=="skip"),o=e.filter(a=>a.status==="error"||a.status==="warn"),r=e.some(a=>a.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:r}}function Vr(n){let e=n.d.settings,o=n.d.effective,r=n.d.cert,a=ve(o.portal_enabled,"Enable portal"),i=ie(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=ie(e.portal_title,{placeholder:"Dawnline"}),l=ie(e.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),c=ie("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),d=O=>/^\d{1,3}(\.\d{1,3}){3}$/.test(O),p=[o.portal_host,...o.portal_alt??[]].filter((O,F,P)=>O&&P.indexOf(O)===F),u=!!n.portal,w=[],C=O=>{O&&!w.some(F=>F.host===O)&&w.push({host:O,kind:d(O)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},g=O=>{w=[...O,...w.filter(F=>!O.some(P=>P.host===F.host))],!p.length&&O[0]&&(p=[O[0].host])};n.portal&&g(n.portal.candidates),p.forEach(C);let m=O=>O.kind==="ip"?t("span",{class:"dl-addr-warn"},[b("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):t("span",{class:"dl-sub"},O.cloudflare?"Behind Cloudflare · often stalls in Russia":O.ips.length?O.here?`Points at this router${O.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${O.ips.join(", ")}, not this router`:u?"Your address":"Checking where it points…"),k=t("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),I=O=>{p.includes(O)?p.length>1&&(p=p.filter(F=>F!==O)):p=[...p,O],x(),E()},x=()=>dom.content(k,[...w.map(O=>{let F=p.includes(O.host),P=p[0]===O.host;return t("div",{class:`dl-addr-opt${F?" on":""}`,role:"checkbox","aria-checked":F?"true":"false",tabindex:"0",click:()=>I(O.host),keydown:D=>{(D.key===" "||D.key==="Enter")&&(D.preventDefault(),I(O.host))}},[t("i",{class:"dl-addr-check"},F?b("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},O.host),m(O)]),P?t("span",{class:"dl-pill info"},"Main"):F?t("button",{type:"button",class:"dl-linkbtn",click:D=>{D.stopPropagation(),p=[O.host,...p.filter(_=>_!==O.host)],x(),E()}},"Make main"):O.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):O.kind==="ip"?t("span",{class:"dl-pill"},"IP"):O.here&&O.cert?t("span",{class:"dl-pill ok"},"Recommended"):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},b("plus")),c,H("Add",()=>{let O=c.value.trim().toLowerCase();if(!O)return;let F=wt(O);if(F.bad){U(F.text,"warning");return}C(O),p.includes(O)||(p=[...p,O]),c.value="",x(),E()})])]);c.addEventListener("keydown",O=>{O.key==="Enter"&&(O.preventDefault(),c.nextElementSibling?.click())});let v=t("div",{class:"dl-links"}),$=()=>{},E=()=>{$();let O=Number(i.value)||o.portal_port;dom.content(v,p.map((F,P)=>{let D=d(F),_=D?O+1:O,B=`${D?"http":"https"}://${F}${_===(D?80:443)?"":`:${_}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${D?"warn":"ok"}`},b(D?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[B,t("b",{},"kamiro-telosu-bavine")]),P===0?t("span",{class:"dl-pill info"},"Main"):D?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};x(),E(),i.addEventListener("input",()=>E());let y={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},z=n.d.needs??{https:[],acme:[],home:[]},h=O=>{if(!o.portal_enabled)return t("div",{hidden:!0});if(!O)return ge("check","Ready to share","The portal’s checks from Health",[t("p",{class:"dl-muted dl-loading"},"Running checks…")]);let F=O.filter(M=>M.status!=="skip");if(!F.length)return t("div",{hidden:!0});let{bad:P,worst:D}=Jr(O),_=t("div",{class:"dl-ready-details",hidden:!0},F.map(M=>t("div",{class:`dl-ready-item ${M.status}`},[b(M.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},M.title),t("span",{class:"dl-sub"},M.detail)])]))),B=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${D}`},[b(D==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},D==="ok"?`All ${F.length} checks passed`:`${F.length-P.length} of ${F.length} checks passed`),P.length?t("span",{class:"dl-sub"},P.map(M=>M.detail).join(" ")):t("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),t("button",{type:"button",class:"dl-linkbtn",click:M=>{_.hidden=!_.hidden,M.currentTarget.textContent=_.hidden?"Details":"Hide"}},"Details")]),t("div",{class:"dl-chips-row"},F.map(M=>t("span",{class:`dl-check-chip ${M.status}`,title:M.detail},[b(M.status==="ok"?"check":"alert"),y[M.id]??M.title]))),_]);return ge("check","Ready to share","The portal’s checks from Health",[B])},f=O=>{if(!o.portal_enabled||!O&&!z.https.length)return t("span",{hidden:!0});if(z.https.length)return t("span",{class:"dl-pill bad"},"Can’t start");let{worst:F}=Jr(O);return t("span",{class:`dl-pill ${F==="ok"?"ok":F==="error"?"bad":"warn"}`},F==="error"?"Needs attention":"Ready")},T=h(n.portal?.checks??null),S=f(n.portal?.checks??null);n.portalFill=O=>{u=!0,g(O.candidates),x(),E();let F=h(O.checks);T.replaceWith(F),T=F;let P=f(O.checks);S.replaceWith(P),S=P};let N=r&&!r.self_signed&&r.expires?Ue(r.expires):"",G=fe("Listening port",i,()=>an(i.value.trim()===""?o.portal_port:Number(i.value),n.d.tcp_taken??[],p.some(d)));$=G.refresh;let q=fe("Title",s,()=>Fo(s.value)),V=fe("Unknown links",l,()=>Go(l.value)),R=!!(e.portal_cert&&e.portal_key),J=r?R?"Your files":r.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",Q=()=>{let O=ie(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),F=ie(e.portal_key,{placeholder:"/etc/ssl/…/key"});te("Use your own certificate",[t("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),de("Certificate file",O),de("Key file",F)],[ae()," ",H("Save",()=>{oe(),n.save({portal_cert:O.value.trim(),portal_key:F.value.trim()},"Certificate saved","portal")},"positive")])},le=(O,F,P,D,_,B)=>Qe(O,F,P,D,H(B,()=>Vt(_,z[_],()=>n.reload("portal")),"positive")),he=z.https.length?le("lock","bad","HTTPS isn’t available on this router",`The portal needs ${z.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",ue=z.acme.length&&(!r||r.self_signed)?le("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${e.portal_host?` for ${e.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",ne=[t("div",{class:"dl-row"},[b("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[J,N?t("span",{class:"dl-faint"},` · until ${N}`):""]),t("span",{class:"dl-sub dl-ellipsis",title:r?.path??""},r?r.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${R?"Your files":"Found automatically"} · ${r.path}`:"Turn the portal on to see its certificate.")])]),t("div",{class:"dl-row"},[b("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Your own files"),t("span",{class:"dl-sub"},R?`${e.portal_cert} · ${e.portal_key}`:"Not set: the certificate is picked automatically.")]),R?H("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",H(R?"Change":"Use files",Q)]),ue];return Re("portal","Personal portal",[t("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),he?t("div",{class:"dl-list"},[he]):"",ge("network","Port","How the portal listens (80 and 443 stay free)",[G]),ge("edit","Appearance","What people see",[q,V]),ge("link","Addresses","Pick one or more; the first is the main link",[k,t("div",{class:"dl-stack gap8"},[v,t("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),ge("lock","Certificate","Used for HTTPS links",ne),T],[t("span"),H("Save",()=>{let O=ze([G,q,V]);if(O){U(O,"warning");return}return n.save({portal_enabled:Pe(a)?"1":"0",portal_host:p[0]??"",portal_alt:p.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:l.value.trim()},"Saved","portal")},"positive")],"",[S,a])}function Yr(n){let e=n.d.settings,o=n.d.effective,r=ie(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),a=ve(o.hostnames,"Device hostnames"),i=ie(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=ie(e.home_dns_fallback==="none"?"":e.home_dns_fallback||o.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),l=fe("Devices per person",r,()=>{if(!r.value.trim())return{text:"The default, 3. Pre-filled when you add someone.",bad:!1};let p=sn(r.value);return p.bad?p:{text:"Pre-filled when you add someone.",bad:!1}}),c=fe("Device hostnames",i,()=>qo(i.value),t("div",{class:"dl-hostport"},[a,t("span",{class:"dl-faint dl-mono"},"phone.myata."),i])),d=fe("Fallback DNS",s,()=>{let p=Ko(s.value);return p.bad?p:{text:`For Home-only devices using home names: ${p.text}`,bad:!1}});return Re("defaults","New people",[l,c,d],[t("span"),H("Save",()=>{let p=ze([l,c,d]);if(p){U(p,"warning");return}return n.save({default_device_limit:r.value,hostnames:Pe(a)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults")},"positive")])}function Zr(n){let e=n.d.effective,o=ve(e.geo_enabled,"Locations"),r=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Re("map","Map & locations",[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),o]),de("Provider",r)],[t("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."),H("Save",()=>n.save({geo_enabled:Pe(o)?"1":"0",geo_provider:r.value},"Saved","map"),"positive")])}var ws=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function Qr(n){let e=n.d.effective.updates,o=ve(e.check,"Check automatically",g=>C(g,Pe(a))),r=we([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],e.interval,{label:"How often",cls:"sm"}),a=ve(e.auto,"Install automatically",g=>C(Pe(o),g)),i=ie(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":"Time"}),s=we([["scheduled","At a set time"],["immediate","As soon as found"]],e.mode,{label:"When",cls:"sm",onChange:g=>i.hidden=g!=="scheduled"});i.hidden=e.mode!=="scheduled";let l=new Set(e.targets),c=t("div",{class:"dl-chips-row"},ws.map(([g,m])=>{let k=qe(m,l.has(g),()=>{l.delete(g)||l.add(g),pn(k,l.has(g))});return k})),d=ve(e.keep,"Keep the previous version"),p=ve(e.mirrors,"GitHub mirrors"),u=de("How often",r),w=[de("When",t("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),de("Components",c,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],C=(g,m)=>{u.hidden=!g;for(let k of w)k.hidden=!m};return C(e.check,e.auto),Re("updates","Updates",[t("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),de("Check automatically",o,"Looks for new versions in the background; Components shows what it found and the service log names it."),u,de("Install automatically",a,"Downloads and installs new versions of the components below."),...w,de("Keep the previous version",d,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),de("GitHub mirrors",p,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[t("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),H("Save",()=>{if(s.dataset.value==="scheduled"){let g=Jo(i.value);if(g.bad){U(`Time: ${g.text}`,"warning");return}}return n.save({update_check:Pe(o)?"1":"0",update_interval:r.dataset.value,update_auto:Pe(a)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Pe(d)?"1":"0",update_mirrors:Pe(p)?"1":"0"},"Saved","updates")},"positive")])}function Xr(n){let e=n.d.logs,o=e.policy,r=we([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(o.keep_days),{label:"Keep activity",cls:"sm"}),a=we([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(o.max),{label:"Maximum events",cls:"sm"}),i=we([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],o.persist,{label:"Save to flash",cls:"sm"}),s=we([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(o.usage_days),{label:"Daily traffic",cls:"sm"}),l=we([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(o.usage_months),{label:"Monthly traffic",cls:"sm"}),c=new Set(o.categories),d=t("div",{class:"dl-chips-row"},Et.map(C=>{let g=qe([pt[C],t("b",{},String(e.by_category[C]??0))],c.has(C),()=>{c.delete(C)||c.add(C),pn(g,c.has(C))},{title:tr[C]});return g})),p=e.oldest?Ue(new Date(e.oldest*1e3)):"",u=(C,g,m,k)=>t("div",{class:"dl-row"},[b(C),t("span",{class:"dl-row-main dl-stack"},[t("b",{},g),t("span",{class:"dl-sub"},m)]),...k]),w=C=>H(C.toUpperCase(),async()=>{let[g,m]=await Promise.all([A.status(1),A.events(2e4)]);Fe(g,m.events,C)},"neutral",{title:`Download the log as ${C.toUpperCase()}`});return Re("logs","Logs & history",[t("p",{class:"dl-muted"},cn(o)),de("Keep activity",r,"Older events are removed automatically."),de("Maximum size",a,"Newest events are kept when the log is full."),de("Record",d,"Switched-off categories are not logged from now on."),de("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),de("Daily traffic",s,"Per-day history behind the charts."),de("Monthly traffic",l,"Per-month totals; data limits use the current month."),t("h4",{class:"dl-setsub"},"Stored data"),t("div",{class:"dl-list"},[u("activity","Activity log",e.events?`${en(e.events,"event")} since ${p} · ${Nt(e.log_ram)} in memory${o.persist==="off"?"":`, ${Nt(e.log_flash)} on flash`}`:"Empty",[w("csv"),w("json"),H("Clear",()=>et("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),u("chart","Traffic history",e.usage_days?`${en(e.usage_days,"day")} since ${Ue(e.usage_since)} · ${Nt(e.usage_flash)} on flash`:"Empty",[H("Reset",()=>Lt("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),u("pin","Location cache",`${en(n.d.geo_cached,"address","addresses")} · ${Nt(e.geo_flash)} on flash`,[H("Clear",async()=>{await W(()=>A.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},"Clear one person or device from their own page."),H("Save",()=>n.save({log_keep_days:r.dataset.value,log_max:a.dataset.value,log_persist:i.dataset.value,usage_keep_days:s.dataset.value,usage_keep_months:l.dataset.value,log_category:[...c]},"Saved","logs"),"positive")])}var ys={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},ea=3;function vo(n){let e=new Date(n*1e3),o=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),r=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return`${r===0?"Today":r===1?"Yesterday":e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${o}`}async function ks(n){let e=await W(()=>A.backupRead(n.name));if(!e)return;let o=atob(e.data),r=new Uint8Array(o.length);for(let i=0;iks(n),"neutral","dl-icon-only"),Le("more","More",o=>Ce(o.currentTarget,[{label:"Restore",icon:b("reset"),run:async()=>{await se("Restore this backup?",`Everything returns to ${vo(n.created)}. The current state is backed up first.`,"Restore",!0)&&await W(()=>A.backupRestore(n.name),"Restored")&&e(!0)}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await se("Delete this backup?",`The backup from ${vo(n.created)} is removed from the router.`,"Delete",!0)&&await W(()=>A.backupDelete(n.name),"Backup deleted")&&e()}}]),"neutral","dl-icon-only")])])}function na(n,e){let o=n.slice(0,ea).map(c=>ta(c,e)),r=n.slice(ea),a=n.length?t("div",{class:"dl-list"},[...o,r.length?t("details",{class:"dl-bk-older"},[t("summary",{},[b("chevron"),`${r.length} older backup${r.length===1?"":"s"}`]),...r.map(c=>ta(c,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=H("Restore from file",async()=>{let c=await Wn(".tar.gz,.tgz,application/gzip","base64");if(!c)return;await se("Restore from file?",`Replace the current Dawnline configuration with ${c.name}? The current state is backed up first.`,"Restore",!0)&&await W(()=>A.backupUpload(c.data),"Restored")&&e(!0)}),s=H("Export JSON",async()=>{let c=await W(()=>A.exportJson());c&&Se(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(c,null,2),"application/json")}),l=H("Import JSON",async()=>{let c=await Wn(".json,application/json","text");if(!c)return;let d;try{d=JSON.parse(c.data)}catch{U("Not a JSON file.","error");return}await se("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await W(()=>A.importJson(d),"Imported")&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},"Backups"),t("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),t("span",{class:"dl-spacer"}),H([b("plus")," Back up now"],async()=>{await W(()=>A.backupCreate(),"Backup created")&&e()},"positive")]),a]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),t("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function $s(){let n=ie("",{placeholder:"remove"}),e=H("Remove Dawnline",async()=>{await W(()=>A.uninstall(n.value.trim()),"Dawnline removed")&&(oe(),setTimeout(()=>location.reload(),800))},"negative",{disabled:!0});n.addEventListener("input",()=>{e.disabled=n.value.trim()!=="remove"}),te("Remove Dawnline?",[t("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[ae()," ",e])}function oa(){return Re("danger","Remove Dawnline from this router",[t("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.")],[t("span"),H("Remove",()=>$s(),"negative")],"danger")}var Dn=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return A.settingsGet()}render(e){this.d=e,this.cards={portal:st(()=>Vr(this)),defaults:st(()=>Yr(this)),map:st(()=>Zr(this)),updates:st(()=>Qr(this)),logs:st(()=>Xr(this)),backups:st(()=>na(this.backups,a=>this.loadBackups(a))),danger:st(()=>oa())};let o=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,o.map(a=>this.cards[a].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let r=new URLSearchParams(location.search).get("section");return r&&r!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${r}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(e,o,r){let a=await W(()=>A.settingsUpdate(e),o);a&&(this.d=a,this.cards[r].refresh(),r==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,o=await A.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let o=await A.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(e){let o=await A.settingsGet().catch(()=>null);if(o){if(this.d=o,e)this.cards[e].refresh();else for(let r of Object.values(this.cards))r.refresh();(!e||e==="portal")&&this.loadPortal()}}};function ra(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function aa(n){let e=[],o=l=>{let c=[],d=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=d.exec(l);)u.index>p&&c.push(l.slice(p,u.index)),u[1]?c.push(t("code",{},u[1].slice(1,-1))):u[2]?c.push(t("b",{},u[2].slice(2,-2))):u[3]?c.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&c.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{a.length&&e.push(t("p",{},o(a.join(" ")))),a=[],r=null};for(let l of n.replace(/\r/g,"").split(` `)){let c=l.trimEnd();if(i){/^```/.test(c.trim())?(e.push(t("pre",{},i.join(` -`))),i=null):i.push(l);continue}if(/^```/.test(c.trim())){s(),i=[];continue}let d=/^(#{1,6})\s+(.*)$/.exec(c),p=/^\s*[-*+]\s+(.*)$/.exec(c)??/^\s*\d+[.)]\s+(.*)$/.exec(c);d?(s(),e.push(t("h5",{},o(d[2])))):p?(r.length&&s(),a||(a=t("ul",{}),e.push(a)),a.appendChild(t("li",{},o(p[1])))):c.trim()?(a&&(a=null),r.push(c.trim())):s()}return i&&e.push(t("pre",{},i.join(` -`))),s(),e}function Ta(n){let e=[],o=!1;for(let a of n.replace(/\r/g,"").split(` -`)){let r=/^#{1,6}\s+(.*)$/.exec(a);if(r){if(o=/^install\b/i.test(r[1].trim()),/^what.s new$/i.test(r[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(a)&&(o=!1);o||e.push(a)}return e.join(` +`))),i=null):i.push(l);continue}if(/^```/.test(c.trim())){s(),i=[];continue}let d=/^(#{1,6})\s+(.*)$/.exec(c),p=/^\s*[-*+]\s+(.*)$/.exec(c)??/^\s*\d+[.)]\s+(.*)$/.exec(c);d?(s(),e.push(t("h5",{},o(d[2])))):p?(a.length&&s(),r||(r=t("ul",{}),e.push(r)),r.appendChild(t("li",{},o(p[1])))):c.trim()?(r&&(r=null),a.push(c.trim())):s()}return i&&e.push(t("pre",{},i.join(` +`))),s(),e}function ia(n){let e=[],o=!1;for(let r of n.replace(/\r/g,"").split(` +`)){let a=/^#{1,6}\s+(.*)$/.exec(r);if(a){if(o=/^install\b/i.test(a[1].trim()),/^what.s new$/i.test(a[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(r)&&(o=!1);o||e.push(r)}return e.join(` `).replace(/\n{3,}/g,` -`).trim()}async function Ut(n,e,o,a){let r=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";ae(o,[i,r],[D([v("copy")," Copy"],()=>ue(s,"Release notes copied"))," ",le("Close")],"wide");try{let l=await P.updatesNotes(n,e,a??"");s=Ta(l.body||"");let c=Ma(l.url);dom.content(i,[l.published?t("span",{class:"dl-pill"},He(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),c?t("a",{href:c,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",v("open")]):""]),dom.content(r,s.trim()?Sa(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(r,t("p",{class:"dl-muted"},ve(l)))}}var _a={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Zn=n=>n?He(n):"";function Oi(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function Pa(n,e){let o=n.st,a=o.policy,r=o.kept?.app,i=e?.update&&e.tag?e.tag:o.version,s=w=>()=>Ut("app",w,`What’s new in Dawnline ${w.replace(/^v/,"")}`),l=e?.tag&&(e.update||e.status==="latest")?ji(n,e.tag,e.update?o.version:""):null,c=e?.tag??i,d=a.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[a.interval]??24)*3600:0,p=(w,g)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},w),t("span",{class:"dl-comp-side-v"},g)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:`Reinstall ${o.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",o.version)},r?{label:`Roll back to ${r.version}`,ic:"archive",warn:!0,run:async()=>{await re(`Roll back to Dawnline ${r.version}?`,`The copy kept on the router replaces ${o.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",o.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},v("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[o.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},`release ${e.latest}`):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?`released ${Zn(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${Zn(e.published)}`:""}`:"not checked yet")])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(w=>t("li",{},w))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(c)},`+${l.total-l.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[D("Update now",()=>n.op("app","Updating Dawnline",o.version),"positive",{disabled:n.busy}),D("What’s new",s(i))]):"",Ui(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[v("globe"),t("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p("Auto-update",[a.auto?ye("ok","On"):ye("","Off"),t("span",{class:"dl-muted"},a.auto?a.mode==="immediate"?"as soon as found":`${_a[a.interval]==="weekly"?"weekly":"daily"} at ${a.time}`:a.check?`checks ${_a[a.interval]}`:"checks off")]),p("Last check",o.check?[ie(o.check.time,o.now),d>o.now?t("span",{class:"dl-faint"},`· next in ${pt(d-o.now)}`):""]:["Never"]),p("Rollback",r?[t("span",{class:"dl-mono"},r.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},a.keep?"Kept after the next update":"Off")])])])}function ji(n,e,o){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let a=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await P.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` -`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await P.updatesChanges(o,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>Oi(a(l))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Ui(n){let e=t("div",{class:"dl-params-body"}),o=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[v("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&xn(n,e)}),n.versOpen&&xn(n,e),o}async function xn(n,e){let o=se("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),a=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return F("Enter a release tag like 0.3.1","warning");Ca(n,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),a(o.value))});let r=t("div",{class:"dl-comp-tag"},[o,D("Install",()=>a(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),xn(n,e)},l=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),t("span",{class:"dl-faint"},`Page ${i}`),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>s(1)},"Older →")]),c=n.versCache.get(i);if(!c){dom.content(e,[r,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{c=(await P.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[r,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${ve(p)}`),D("Try again",()=>xn(n,e))]),l(!1)]);return}if(n.versCache.set(i,c),i!==n.versPage||!e.isConnected)return}if(!c.length)return dom.content(e,[r,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let d=n.st.version;dom.content(e,[r,...c.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},Zn(p.published)),p.prerelease?ye("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},$e("file","What’s new",()=>Ut("app",p.tag,`What’s new in Dawnline ${u}`))),u===d?ye("ok","Installed"):D("Install",()=>Ca(n,p.tag),"neutral",{disabled:n.busy})])}),l(c.length>=5)])}async function Ca(n,e){let o=e.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await re(`Install Dawnline ${o}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${e}`,`Installing Dawnline ${o}`,n.st.version)}function Da(n,e){let o=n.st,a=o.kept?.amneziawg,r=e?.sources??{},i=Object.keys(r),s=e?.current??null,l=s?r[s]:void 0,c=!!e?.ru,d=o.needs?.awg??[],p=d.length?null:e?.installed??null,u=[];s&&p&&u.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${c?":ru":""}`,"Reinstalling AmneziaWG",p)}),a&&u.push({label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await re(`Roll back AmneziaWG to ${a.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",p??void 0)}});let w=[e?.release?{label:"What’s new",ic:"file",run:()=>Ut("amneziawg",e.release,`What’s new in the ${l?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((h,f,R)=>h!==null||f>0&&R[f-1]!==null),g=o.tunnels??[],m=g.length?`Switching restarts ${g.length===1?"the tunnel":`${g.length} tunnels`} for a few seconds: ${g.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",k=g.length>1?`${g.slice(0,-1).join(", ")} and ${g[g.length-1]}`:g[0],N=g.length?`Switching restarts ${k} for a few seconds.`:"Switching takes a few seconds.",B=async h=>{let f=r[h];await re(p?`Switch to AmneziaWG ${f.gen}?`:`Install AmneziaWG ${f.gen}?`,`The ${f.label} build, ${f.version}. ${m}${f.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${h}${c?":ru":""}`,p?`Switching to AmneziaWG ${f.gen}`:"Installing AmneziaWG",p??void 0)},E=h=>{let f=r[h],R=s===h&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??"none yet"),t("span",{class:"dl-comp-bact"},R?ye("ok","Active"):f.version?D(p?"Switch":"Install",()=>B(h),p?"neutral":"positive",{disabled:n.busy}):ye("","No build"))])},y=i.map(h=>r[h]?.newer?`${r[h].label} moves to ${r[h].newer.gen} with OpenWrt ${r[h].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),S=ge(c,"Russian translation",h=>{s&&n.op(`amneziawg:${s}${h?":ru":""}`,h?"Adding the Russian translation":"Removing the Russian translation",p??void 0)});S.disabled=!s||!p||n.busy;let b=n.awgOpen??!p,x=t("details",{class:"dl-params dl-comp-fold",open:b?"open":null},[t("summary",{},[v("chevron"),t("span",{},"Build and translation")]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...i.length?i.map(E):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Russian translation"),t("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),t("span",{class:"dl-comp-bact"},S)])]),p&&i.length||y.length?t("div",{class:`dl-comp-status ${p&&i.length?"warn":"acc"}`},[v(p&&i.length?"alert":"download"),t("span",{},[p&&i.length?t("b",{},N):"",...y.map(h=>` ${h}`)])]):""])]);x.addEventListener("toggle",()=>n.awgOpen=x.open);let M=[];return e?.update&&p&&s?M.push(D(`Update to ${e.latest}`,()=>n.op(`amneziawg:${s}${c?":ru":""}`,"Updating AmneziaWG",p),"neutral",{disabled:n.busy})):M.push((e||d.length)&&!p?ye("warn","Not installed"):n.state("amneziawg",e,e?.latest??"")),M.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",p??void 0),w)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${e.release} build`:""}`:d.length?`missing ${d.join(", ")}`:e?"not installed":"version not checked"],M),t("div",{class:"dl-comp-foldwrap"},x)]}var Wi=[{title:"Home-like link",sub:"Policy routing and the veth pair",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"HTTPS for the portal",sub:"OpenSSL for uhttpd",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"Certificates (ACME)",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],Qn={home:"network",https:"lock",acme:"file"};function Aa(n,e){let o=n.st,a=e?.pkgs??{},r=Wi.filter(d=>d.feature==="home"?o.home:o.portal),i=async(d,p,u=d)=>{await re(`Update ${p}?`,`${u.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${d.join(",")}`,`Updating ${p}`)},s=[{label:"Check system packages",ic:"refresh",run:()=>n.op("check:packages","Checking system packages")},{label:"Open the OpenWrt package list",ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:r.map(d=>{let p=d.pkgs.filter(k=>a[k]?.installed),u=[...new Set(p.flatMap(k=>[...a[k]?.latest?[k]:[],...a[k]?.with??[]]))],w=o.needs?.[d.feature]??d.pkgs.filter(k=>!a[k]?.installed),g=p.find(k=>a[k]?.latest),m=p.map(k=>`${k} ${a[k]?.installed??""}`).join(", ");return w.length?n.row(Qn[d.feature],d.title,[`${d.optional?"not installed":`missing ${w.join(", ")}`}`],[D("Install",()=>n.op(`pkgs:${w.join(",")}`,`Installing ${d.title}`),d.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))]):e&&u.length?(l++,n.row(Qn[d.feature],d.title,g?[`${a[g].installed} → ${a[g].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[D("Update",()=>i(p.filter(k=>a[k]?.latest||a[k]?.with?.length),d.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))])):n.row(Qn[d.feature],d.title,[m||d.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:r.length}}var Gi={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function za(n){let e=n.st,o=r=>{let i=Ze(r.component??"app"),s=Gi[i]??"Components",l=r.auto?"automatically":"by you",c="ok",d="check",p;if(r.kind==="found")c="accent",d="download",p=[t("b",{},(r.items??[]).join(", ")),` found by ${r.auto?"the automatic check":"a check"}`];else if(r.state==="failed")c="bad",d="x",p=[t("b",{},s),` ${r.kind==="install"?"update":"check"} failed${r.error?` · ${r.error}`:""}`];else{let u=r.from&&r.to&&r.from!==r.to?` ${r.from} → ${r.to}`:r.to?` ${r.to}`:"";p=[t("b",{},s),`${u} ${u?"":"updated "}${l}${r.took?` · ${pt(r.took)}`:""}`.replace(/\s+/g," ")]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${c}`},v(d)),t("span",{class:"dl-row-main"},p),t("span",{class:"dl-faint dl-nowrap",title:new Date(r.ts*1e3).toLocaleString()},ie(r.ts,e.now))])},a=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),a.length?t("div",{},a.slice(0,8).map(o)):t("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var wn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null}load(){return P.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await P.updatesStatus().catch(()=>null);if(!o)return;let a=this.st;this.st=o,o.job?.state==="running"&&this.following!=="starting"&&o.job.id!==this.following&&this.follow(o.job),(o.job?.id!==a.job?.id||o.job?.state!==a.job?.state||o.job?.phase!==a.job?.phase||o.check?.time!==a.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await P.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,o,a){if(this.busy||this.following==="starting"){F("Another component action is already running","warning");return}this.following="starting",this.paint();let r=Ze(e),i=await Bt(e,{title:o,version:a,onJob:s=>this.following=s.id,onDone:s=>this.refresh(s),onUpdate:s=>{let l=s.check?.components??{};r==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,"Updating AmneziaWG",l.amneziawg.installed??void 0):this.op("app","Updating Dawnline",this.st.version)}});this.following==="starting"&&(this.following=i?.id??null),this.refresh()}async follow(e){this.following=e.id;let o=pn(e),a={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[o]??"components";await Bt(null,{title:`${e.action==="check"?"Checking":e.auto?"Automatic update:":"Updating"} ${a}`,onDone:r=>this.refresh(r)},e)}paint(){let e=this.st,o=e.check?.components??{},a=e.firmware,r=Aa(this,o.packages),i=(e.needs?.awg??[]).length>0,l=(!i&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+r.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Components"),t("span",{class:"dl-faint"},[a?.version?`OpenWrt ${a.version} · ${a.target}`:"",e.check?`checked ${ie(e.check.time,e.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[v("edit")," Settings"]),D([v("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),Pa(this,o.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Components"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},i?l?`AmneziaWG not installed · ${l} update${l===1?"":"s"}`:"AmneziaWG not installed":!o.amneziawg&&!o.packages?"":l?`${l} of ${1+r.total} need${l===1?"s":""} an update`:"Everything is up to date")]),t("div",{},[...Da(this,o.amneziawg),...r.rows])]),za(this)])])}state(e,o,a){let r=this.st.job;if(r?.state==="running"){let i=l=>l==="packages"?"pkgs":l,s=r.action==="check"?[i(r.component||"all")]:(r.component??"").split(" ").map(l=>i(Ze(l)));if(s.includes(e)||s.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:"Show progress",click:()=>this.follow(r)},[r.action==="check"?"Checking":"Updating","…"])}return o?o.error?ye("warn","Check failed",o.error):o.update?ye("info","Update available"):o.status==="dev"?ye("info","Newer than release",`The latest release is ${a}`):ye("ok","Up to date"):ye("","Not checked")}more(e){let o=D([v("more")],()=>we(o,e.filter((a,r,i)=>a!==null||r>0&&ra?{label:a.label,icon:v(a.ic),warn:a.warn,run:a.run}:null)),"neutral",{title:"More","aria-label":"More"});return o}round(e,o,a=!1){let r=this.busy?" is-busy":"",i;return a?i=D([v("refresh")," Check"],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${r}`,"aria-label":"Check for updates"}):(i=$e("refresh","Check for updates",e,"neutral",r.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),me(i,()=>["Check for updates"])),t("span",{class:"dl-comp-ic"},[i,this.more(o)])}row(e,o,a,r){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},v(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-mono dl-faint dl-comp-sub"},a)]),...r])}};var Na=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function Ha(n){let e=n.st.servers.find(o=>o.id===n.p.server)?.name??"Home";Ht(n.p,e)}async function Ra(n){let e=n.p,o=e.code_set??0,a=e.devices.filter(l=>l.created_by==="portal"&&l.created>=o),r=a.map(l=>t("input",{type:"checkbox",id:`dl-rm-${l.id}`,checked:"checked","data-id":l.id})),i=[t("p",{},"The old link stops working right away.")];a.length&&i.push(t("p",{},"Devices added through the old link keep working until they are removed. Remove them too:"),t("div",{class:"dl-checklist"},a.map((l,c)=>t("label",{for:`dl-rm-${l.id}`},[r[c],` ${l.name}`]))));let s=async()=>{let l=r.filter(d=>d.checked).map(d=>d.dataset.id),c=await W(()=>P.personRegen(e.id,l),l.length?`New link created, ${l.length} device${l.length===1?"":"s"} removed`:"New link created");c&&(de(),l.length&&await n.refresh(),c.link&&await ue(c.link,"New link copied"))};ae("Create a new link?",i,[le()," ",D("Create new link",s,"negative")])}function Xn(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");ae("Note",[e],[le()," ",D("Save",async()=>{de(),await n.patch({note:e.value.trim()},e.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>e.focus(),50)}function Ia(n){let e=n.p,o=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},"Pause access"),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},"Keep access"),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},"Remove their devices")]),a=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(r=>t("option",{value:r,selected:e.expire_warn===r?"selected":null},r?`${r} day${r===1?"":"s"} before`:"Don’t warn")));ae("When access ends",[Na("Then",o),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Warn"),t("div",{class:"cbi-value-field"},[a,t("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[le()," ",D("Save",async()=>{de(),await n.patch({expire_action:o.value,expire_warn:a.value},"Saved")},"positive")])}function Ba(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48});ae("Rename",[Na("Name",e)],[le()," ",D("Save",async()=>{await n.patch({name:e.value.trim()},"Renamed")&&de()},"positive")]),setTimeout(()=>e.select(),50)}async function Oa(n){let e=n.p;await re(`Delete ${e.name}?`,`All ${e.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await W(()=>P.personDelete(e.id),"Deleted")&&(location.href=wt(e.server))}function ja(n){let e=n.p,o=n.st,a=e.online?"online now":e.last_seen?`last seen ${ie(e.last_seen,o.now)}`:"never connected",r=e.created?`Added ${Ce(Ne(new Date(e.created*1e3)))}`:"",i=e.has_link??o.settings.portal_enabled,s=[{label:"Rename",icon:v("edit"),run:()=>Ba(n)},{label:e.note?"Edit note":"Add note",icon:v("file"),run:()=>Xn(n)},...i?[null,{label:"Invite card",icon:v("qr"),run:()=>Ha(n)},{label:"New link",icon:v("key"),run:()=>Ra(n)}]:[],null,...e.paused?[]:[{label:"Pause",icon:v("pause"),warn:!0,run:()=>n.patch({paused:!0},"Paused")}],{label:"Delete",icon:v("trash"),danger:!0,run:()=>Oa(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},Pe(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),uo(e)]),t("span",{class:"dl-faint",title:r},`${e.devices.length} of ${e.device_limit} devices · ${a}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?D([v("play")," Resume"],()=>n.patch({paused:!1},"Resumed"),"add"):"",i?$e("link","Copy link",()=>rn(e.id),"neutral","dl-icon-only"):"",$e("more","More",l=>we(l.currentTarget,s),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>Xn(n)},[v("file"),t("span",{},e.note)]):""])}function Ua(n){let e=n.p,o=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?hn(e.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",fn(n.series,`${te(e.month[0]+e.month[1])} this month`)])}async function Fi(n,e){let o=await W(()=>P.deviceConfig(e.id));o&&ae(`Set up ${e.name}`,[await n.core.connectBlock(o,"qr")],[le("Close")])}async function qi(n,e){let o=await W(()=>P.deviceConfig(e.id));if(!o)return;if(!o.has_private_key){F("This device made its own keys in the browser; its configuration only exists there.","warning");return}let a=n.core.file.make(o);Le(a.name,a.text,"application/octet-stream")}function Wa(n){let e=n.p,o=n.st.now,a=c=>Be(e,c,n.deviceOpts()),r=c=>d=>{d.target.closest("button:not(.dl-dcard-title), a")||a(c)},i=c=>D([v("more")],d=>Uo(d.currentTarget,e,c,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=qt(e.devices).map(c=>{let d=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},v(c.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>a(c)},[t("b",{},c.name),Kt(c,o),c.config_stale?t("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(c)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},te(c.month[0]+c.month[1])),t("span",{class:"dl-sub"},"this month")]),ua(n.devSeries[c.id]??[])]);return t("article",{class:`dl-dcard clickable${c.online?" online":""}${c.disabled?" off":""}`,click:r(c)},[d,c.handshake?p:c.disabled?t("div",{class:"dl-sub"},`${je[c.kind]} · created ${ie(c.created,o)} ${c.created_by==="portal"?"in the portal":"by you"}.`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>Fi(n,c)},[v("qr"),"Show QR"]),t("button",{type:"button",class:"dl-chipbtn",click:()=>qi(n,c)},[v("download"),"Config"])])])}),l=e.devices.length>=e.device_limit;return s.push(t("button",{type:"button",class:"dl-dslot add",click:()=>it(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},v("plus")),t("span",{class:"dl-stack"},[t("b",{},"Add device"),t("span",{class:"dl-sub"},l?`Over the limit · ${e.devices.length} of ${e.device_limit}`:`${e.devices.length} of ${e.device_limit}`)])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Devices"),t("span",{class:"dl-sub"},`${e.online} online`)]),t("div",{class:"dl-dgrid"},s)])}function Ga(n){let e=n.p,o=xe([["device","Device’s own DNS"],["home","Home names"]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:r=>n.patch({dns_mode:r},r==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")}),a=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),o]),t("span",{class:"dl-sub"},e.dns_mode==="home"?["Names like ",t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",a?[" (",t("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.")])}function Fa(n){let e=n.p,a=n.st.servers.find(i=>i.id===e.server)?.home??[];if(a.length<2)return"";let r=new Set(e.home_nets?.length?e.home_nets:a.map(i=>i.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},a.map(i=>We(i.dev,r.has(i.dev),()=>{let s=new Set(r);if(s.delete(i.dev)||s.add(i.dev),!s.size)return F("Keep at least one network, or choose Internet only.","warning",5e3);let l=s.size===a.length?[]:[...s];n.patch({home_nets:l},l.length?`${e.name} reaches ${l.join(", ")}`:`${e.name} reaches every home network`)},{title:i.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?`Home networks ${e.name} reaches. Networks added to the server later stay out.`:`Home networks ${e.name} reaches: all of them. Untick one to keep ${e.name} out of it.`)])}function qa(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(o=>We(o.name,e.has(o.id),()=>{let a=new Set(e);a.delete(o.id)||a.add(o.id),n.patch({services:[...a]},a.size?"Home services updated":"Whole home network")},{title:`${o.address}${o.ports.length?` · ${o.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function Ka(n){let e=n.p,o=n.st;if(o.servers.find(d=>d.id===e.server)?.mesh!=="circles"||!Ye(e))return"";let r=o.circles.filter(d=>d.server===e.server),i=r.find(d=>d.id===e.circle),s=i?o.people.filter(d=>d.id!==e.id&&d.circle===i.id&&Ye(d)).map(d=>d.name):[],l=t("button",{type:"button",class:"dl-chipbtn",click:()=>we(l,[...r.map(d=>({label:d.name,icon:Fn(d),run:()=>d.id!==e.circle&&n.patch({circle:d.id},`${e.name} is in ${d.name}`)})),e.circle?{label:"No circle",icon:v("x"),run:()=>n.patch({circle:""},`${e.name} is in no circle`)}:null,{label:"New circle",icon:v("plus"),run:()=>dn(o,e.server,null,()=>n.refresh())}])},"Change"),c=i?o.people.filter(d=>d.circle===i.id&&Ye(d)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Devices see each other"),l]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},i?i.name:"No circle"),t("span",{class:"dl-avstack",title:c.map(d=>d.name).join(", ")},c.slice(0,5).map(d=>t("span",{class:"dl-avatar sm"},Pe(d.name))))]),t("span",{class:"dl-sub"},i?s.length?[e.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${e.name}'s own devices`)])}function Ja(n){let e=n.p,o=n.st.now,a=t("div",{class:"dl-slots"});for(let s=0;s=e.device_limit,d=t("i",{class:c?"over":l?"used":""});me(d,()=>[t("div",{class:"dl-tip-title"},l?`${l.name}${c?" · over the limit":""}`:"Free slot"),t("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${ie(l.handshake,o)}`:"Not set up yet":"They can add a device here")]),a.appendChild(d)}let r=Math.max(1,e.devices.length),i=t("button",{type:"button","aria-label":"Allow fewer devices",disabled:e.device_limit<=r?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=r&&e.devices.length>1&&me(i,()=>[t("div",{class:"dl-tip-title"},`${e.devices.length} devices in use`),t("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},"Devices"),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[i,t("button",{type:"button","aria-label":"Allow more devices",disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),a])}var Ki={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."},Va=/^([01]\d|2[0-3]):[0-5]\d$/;function Ji(n){let e=n.p,o=n.today,a=nt(e.expires,o),r=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});r.addEventListener("change",()=>r.value&&n.patch({expires:r.value},`Access until ${Ce(r.value)}`));let i=(d,p)=>{let u=lo(e.expires&&(a??-1)>=0?e.expires:"",d,p,o);n.patch({expires:u},`Access until ${Ce(u)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([d,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>i(d,p)},u)),l=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{r.focus({preventScroll:!0});try{r.showPicker()}catch{}}},[v("calendar"),e.expires?Ce(e.expires):"Date"]),r]),c={pause:"pause access",notify:"keep access",remove:"remove their devices"}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Access ends"),e.expires?t("span",{class:a!=null&&a<0?"dl-bad":Fe(e,a)?"dl-warn":"dl-ok"},a!=null&&a<0?"ended":`${a} day${a===1?"":"s"} left`):t("span",{class:"dl-faint"},"no end date")]),t("div",{class:"dl-chips-row"},[...s,l,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`When it ends: ${c}${e.expire_warn?`, warn ${e.expire_warn} day${e.expire_warn===1?"":"s"} before`:""}`),t("a",{href:"#",click:d=>{d.preventDefault(),Ia(n)}},"Change")])])}function Vi(n){let e=n.p,o=e.quota_used||e.month[0]+e.month[1],a=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,r=t("div",{class:`dl-meter${a>=100?" bad":a>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:"Alert at 90%"}):""]);r.firstChild.style.width=`${a}%`,e.quota_limit&&me(r,()=>[t("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${te(e.quota_used)} of ${te(e.quota_limit)} · ${te(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},"Alert at 90%")]);let i=xe([["month","Monthly"],["total","Total"]],e.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=prompt("Data limit in GB",e.quota_gb?String(e.quota_gb):"");l!=null&&l.trim()!==""&&Number(l)>0&&n.patch({quota_gb:l.trim()},`Data limit ${l.trim()} GB`)}},"Custom")),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Data"),i]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[te(o),e.quota_limit?t("span",{class:"dl-faint"},` of ${te(e.quota_limit)}`):t("span",{class:"dl-faint"}," · no limit")]),e.quota_period==="month"?t("span",{class:"dl-sub"},"resets on the 1st"):""]),e.quota_limit?r:"",t("div",{class:"dl-chips-row"},s),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?`Includes +${e.bonus_gb} GB extra this month`:"Need a little more this month?"),t("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`${te(e.total[0]+e.total[1])} in total`),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>vt("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function Yi(n){let e=n.p,o=!!e.hours,[a,r]=(e.hours||"07:00-23:00").split("-"),i=t("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"From"}),s=t("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":"To"}),l=t("div",{class:"dl-tile2-row"},[i,t("span",{class:"dl-faint"},"to"),s]),c=()=>{let p=`${i.value}-${s.value}`;if(p!==e.hours){if(!Va.test(i.value)||!Va.test(s.value))return F("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return F("The start and the end must differ.","warning");n.patch({hours:p},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",p=>{l.contains(p.relatedTarget)||c()});for(let p of[i,s])p.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),c())});let d=t("button",{type:"button",role:"switch","aria-checked":o?"true":"false",class:`dl-switch${o?" on":""}`,"aria-label":"Limit hours",click:()=>n.patch({hours:o?"":"07:00-23:00"},o?"Any time":"Allowed 07:00–23:00")},t("i"));return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},"Allowed hours"),t("span",{},o?`${a} – ${r} (router time)`:"Any time")]),d]),o?l:""])}function Ya(n){let e=n.p,o=xe(["internet","lan","both"].map(a=>[a,[v(a==="internet"?"globe":a==="lan"?"home":"shield"),a==="internet"?"Internet":a==="lan"?"Home":"Both"]]),e.access,{label:"Access",cls:"wide",optimistic:!1,onChange:a=>n.patch({access:a},`Access: ${ot[a]}`)});return t("section",{class:"dl-devsec","aria-label":"Access and limits"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Access & limits")]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},"Can reach"),o,t("span",{class:"dl-sub"},Ki[e.access]),e.access==="lan"&&n.st.services.length?qa(n):"",Ye(e)?Fa(n):"",e.access==="lan"?Ga(n):""]),t("div",{class:"dl-tiles2"},[Ja(n),Ka(n),Ji(n),Vi(n),Yi(n)])])])}function Zi(n){let e=n.st,o=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Locations"),t("span",{class:"dl-spacer"}),e.geo.enabled?xt("30d",r=>n.map?.setRange(r),!1):"",D("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let a=new Je({openPerson:()=>{},openDevice:(r,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&Be(n.p,s,n.deviceOpts())}},"30d",280);return n.map=a,requestAnimationFrame(()=>a.mount(n.mapData())),t("div",{class:"dl-panel flush"},[o,a.el])}function Za(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[v("pin"),t("div",{class:"dl-stack"},[t("span",{},"Locations are off"),t("span",{class:"dl-sub"},"City-level, from the client IP")]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:Zi(n);let o=e.now-30*86400,a=e.geo.points.filter(s=>s.person===n.p.id&&s.ts>=o).sort((s,l)=>l.ts-s.ts),r=[...new Set(a.map(s=>s.city||s.country).filter(Boolean))],i=a[0];return t("div",{class:"dl-places"},[v("pin"),t("div",{class:"dl-stack"},[t("span",{},i?i.city||i.country:"No locations yet"),t("span",{class:"dl-sub"},i?`${r.length} place${r.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),t("span",{class:"dl-spacer"}),a.length?D("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function Qa(n){let e=n.p,o=n.st,a=n.events.filter(l=>l.person===e.id),r=[],i=[...a].reverse();for(let l=0;l1){let u=p.querySelector(".dl-row-main");dom.content(u,[...Kn(o,c).slice(0,3),t("span",{class:"dl-muted"},`${d} times`)]),u.title=i.slice(l,l+d).map(w=>w.detail??"").join(` -`)}r.push(p),l+=d-1}let s=D([v("more")],()=>we(s,[{label:"Export CSV",icon:v("download"),run:()=>Ue(o,a,"csv",e.id)},{label:"Export JSON",icon:v("download"),run:()=>Ue(o,a,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:v("trash"),danger:!0,run:()=>Ke(`Clear ${e.name}'s activity`,`Removes events about ${e.name} and their devices.`,{person:e.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-sub"},a.length>10?`latest 10 of ${a.length}`:""),t("span",{class:"dl-spacer"}),s]),r.length?r:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var yn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,a,r]=await Promise.all([P.status(30),e?P.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?P.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:a?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(s=>s.id===this.id);if(!o)return t("div",{class:"dl-empty"},[t("h3",{},"Person not found"),t("p",{},"They may have been removed."),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let a=t("div",{},[t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:wt(o.server)},this.st.servers.find(s=>s.id===o.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:wt(o.server)},"People"),t("span",{},"/"),t("span",{},o.name)]),this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(s=>s.id===r.get("device"));return i?setTimeout(()=>Be(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>it(this.p,this.deviceOpts()),50),this.poller=Ve({fetch:s=>{let l=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>a.isConnected,apply:(s,l)=>this.apply(s,l)}),a}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let a=this.st.people.find(r=>r.id===this.id);if(!a){o||(location.href=wt(this.p?.server));return}this.p=a,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var i;this.poller?.claim();let a=await W(()=>P.personUpdate(this.p.id,e),o);if(!a)return!1;this.poller?.claim();let r=this.st.people.findIndex(s=>s.id===this.p.id);return(i=a.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=a.person),this.p=a.person,this.paint(),!0}get today(){return Re(this.series.length?this.series:this.st.series)}get core(){return bt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}paint(e=!1){Me(this.parts.head,ja(this),e),Me(this.parts.traffic,Ua(this),e),Me(this.parts.devices,Wa(this),e),Me(this.parts.limits,Ya(this),e),this.paintPlaces(e),Me(this.parts.activity,Qa(this),e)}paintPlaces(e=!1){let o=Za(this);o&&Me(this.parts.places,o,e&&!this.mapOpen)}};var Qi={ok:"check",warn:"alert",error:"x",skip:"pause"},kn=class{constructor(e,o,a,r){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=a,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,a)}async run(e){let o=e?await gn(e):await P.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks")]),t("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=e.filter(s=>s.status==="error").length,a=e.filter(s=>s.status==="warn").length;dom.content(this.summary,o?ht("error",`${o} problem${o>1?"s":""} need attention.`):a?ht("warn",`${a} warning${a>1?"s":""}.`):ht("ok","All checks passed."));let r=new Map;for(let s of this.sl.watchdog.repairs)r.set(s.id,Math.max(r.get(s.id)??0,s.ts));let i=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks"),t("span",{class:"dl-spacer"}),D("Run again",i)]),t("ul",{class:"dl-checks"},e.map(s=>t("li",{},[t("span",{class:`dl-check-icon ${s.status}`},v(Qi[s.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},s.title),t("div",{class:"dl-check-detail"},s.detail),r.has(s.id)?t("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${Mt(r.get(s.id))}`):""]),Jn(s,l=>void this.run(l),i)])))])}paintLive(e,o){this.sl=e,this.events=o;let a=e.watchdog,r=a.beat!=null&&a.now-a.beat>180,i=a.repairs.filter(c=>a.now-c.ts<86400),s=i[i.length-1],l=ge(a.enabled,"Watchdog repairs",async c=>{await W(()=>P.settingsUpdate({watchdog:c?"1":"0"}),c?"Watchdog on":"Watchdog off")||Dn(l,!c);let p=await P.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${a.enabled?"":" off"}`},v("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},"Watchdog"),t("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.")]),t("span",{class:"dl-spacer"}),l]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},a.targets.map(c=>t("span",{class:`dl-check-chip${c.ok?"":" error"}`,title:c.ok?"OK":`Not working${c.tries?` · ${c.tries} repair${c.tries>1?"s":""}`:""}`},[v(c.ok?"check":"x"),c.name]))),t("span",{class:`dl-sub${r?" dl-warn-text":""}`},r?`The agent has not checked in for ${Math.round((a.now-a.beat)/60)} min; cron restarts it after 5.`:[a.last?`Looked ${ie(a.last,a.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${Mt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,o=[...this.events.map(r=>({ts:r.ts,ev:r})),...this.sl.log.map(r=>({ts:r.ts,sys:r}))].filter(r=>r.ts>=e&&Vt(r)).sort((r,i)=>i.ts-r.ts),a=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Recent problems"),t("span",{class:"dl-spacer"}),o.length?t("a",{href:"#",click:r=>(r.preventDefault(),this.toLog())},"All in Log →"):""]);if(!o.length){dom.content(this.recentEl,[a,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},v("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[a,...o.slice(0,8).map(r=>{if(r.sys){let i=r.sys,s=`${i.ts}|${i.msg}`;return mn(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},Mt(i.ts))}return Qe(this.st,r.ev,{time:Mt(r.ts)})})])}};var $n=300,Xi=["all","connections","people","system","problems"],En=class{constructor(e,o,a){this.events=[];this.system=[];this.kind="all";this.shown=$n;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(o),this.system=a,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,o=i=>()=>{let s=this.filtered().reverse();Ue(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,e(),s.filter(l=>l.sys).map(l=>l.sys))},a=D([v("download")," Export"],()=>we(a,[{label:"CSV (spreadsheet)",icon:v("download"),run:o("csv")},{label:"JSON",icon:v("download"),run:o("json")}])),r=D([v("trash")," Clear"],()=>Ke("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[a,r]}take(e){this.events=e.events,this.policy=e.policy;let o=gt.filter(a=>!e.policy.categories.includes(a));this.sub=`${Yt(e.policy)}${o.length?` Not recorded: ${o.map(a=>rt[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[e,o]=await Promise.all([P.events(2e4).catch(()=>null),P.serviceLog().catch(()=>null)]);e&&this.take(e),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,o)=>o.ts-e.ts)}matches(e,o){return o==="all"?!0:o==="problems"?Vt(e):o==="system"?!!e.sys:!!e.ev&&_t(e.ev.type)===o}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,Xi.map(o=>t("button",{type:"button",role:"tab",class:o===this.kind?"on":"","aria-selected":o===this.kind?"true":"false",click:()=>this.show(o)},[o==="all"?"All":o==="system"?"System":rt[o],t("b",{},String(e.filter(a=>this.matches(a,o)).length))])))}show(e){this.kind=e,this.shown=$n,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let o=[],a="",r=null;for(let i of e.slice(0,this.shown)){let s=pa(i.ts);s!==a&&(a=s,r=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},s))),o.push(r));let l=new Date(i.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(i.sys){let c=`${i.sys.ts}|${i.sys.msg}`;r.appendChild(mn(i.sys,this.open.has(c),()=>{this.open.delete(c)||this.open.add(c),this.paint()},l))}else r.appendChild(Qe(this.st,i.ev,{time:l}))}e.length>this.shown&&o.push(t("div",{class:"dl-more-row"},D(`Show ${Math.min($n,e.length-this.shown)} more of ${e.length-this.shown}`,()=>{this.shown+=$n,this.paint()}))),dom.content(this.list,o)}};var es=[["health","Health"],["log","Log"]],eo=2e4,Ln=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([P.status(1),P.events(eo),P.serviceLog()])}render([e,o,a]){return this.log=new En(e,o,a.log),this.health=new kn(e,a,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),Ve({fetch:async()=>{let r=this.tab==="log",[i,s]=await Promise.all([P.serviceLog().catch(()=>null),r?P.events(eo).catch(()=>null):Promise.resolve(null)]);return i||s?{n:i,e:s}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:r,e:i})=>this.take(r,i)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,o){o&&(this.log.take(o),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,es.map(([o,a])=>t("button",{type:"button",role:"tab",class:o===e?"on":"","aria-selected":o===e?"true":"false",click:()=>o!==this.tab&&this.show(o)},a))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&P.events(eo).then(o=>this.take(null,o)).catch(()=>null)):this.health.checks||this.health.run()}};var Xa=":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-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.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}";var er='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.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-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}';var tr="#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-warn{color:var(--dl-warn)}.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)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@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}";var nr=".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)}";var or=".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:-6.5px;bottom:-6.5px;width:20px;height:20px;border-radius:8.5px;border:1.5px solid transparent;background: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:hover .dl-onl-dev{background:linear-gradient(var(--dl-soft),var(--dl-soft)),var(--dl-card)}.dl-onl-p.sm:hover{background:none}.dl-onl-p.sm:hover .dl-onl-dev{background:var(--dl-card)}.dl-onl-p.sm .dl-onl-av{transition:box-shadow .15s ease}.dl-onl-p.sm:hover .dl-onl-av{box-shadow:0 0 0 2px var(--dl-ok),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm.more:hover .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line),0 0 0 6px var(--dl-soft)}.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-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.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-speed-val.off{color:var(--dl-fg-faint)}.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-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var ar='.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-checklist{display:flex;flex-direction:column;gap:6px;margin:4px 0 8px}.dl-checklist label{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer}.dl-checklist input{margin:0}.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}';var rr=".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}";var ir=".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)}";var sr=".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)}";var lr=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.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.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.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;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-badge:has(>svg:only-child){width:16px;min-width:0;padding:0}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged,.dl-mk.piled{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*,.dl-mk.piled>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host{transition:border-radius .22s ease,border-right-color .22s ease}.dl-mk-host.docked{border-top-right-radius:0;border-bottom-right-radius:0;border-right-color:transparent}.dl-mk-dock{position:absolute;left:100%;top:-1px;height:40px;box-sizing:border-box;display:flex;align-items:center;gap:6px;padding:0 10px 0 2px;border:1px solid var(--dl-line);border-left:0;border-radius:0 11px 11px 0;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;pointer-events:none;opacity:0;clip-path:inset(-24px 100% -24px 0);transition:clip-path .28s cubic-bezier(.2,.8,.2,1),opacity .2s ease}.dl-mk-host.docked .dl-mk-dock{pointer-events:auto;opacity:1;clip-path:inset(-24px -24px -24px 0)}.dl-mk-new .dl-mk-host,.dl-mk-new .dl-mk-dock{transition:none}.dl-mk-pile{position:relative;display:flex;justify-content:center}.dl-mk-pile-box{box-sizing:border-box;height:40px;display:flex;align-items:center;gap:6px;padding:0 10px 0 6px;border-radius:20px;cursor:zoom-in;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;animation:dl-plate-in .26s cubic-bezier(.2,.8,.2,1) both;transition:opacity .18s ease,transform .18s ease}.dl-mk-pile.out{pointer-events:none}.dl-mk-pile.out>*{opacity:0;transform:scale(.85);transition:opacity .18s ease,transform .18s ease}@keyframes dl-plate-in{0%{opacity:0;transform:scale(.85)}}.dl-mk-face{all:unset;position:relative;display:flex;cursor:pointer;transition:transform .18s ease,opacity .18s ease}.dl-mk-face>.dl-mk-badge{position:relative;left:auto;bottom:-8px;margin-left:-12px;align-self:center}.dl-mk-face.on .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-face.on .dl-mk-badge{background:#3b82f6}.dl-mk-face:hover .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-face.in{animation:dl-dock-in .24s cubic-bezier(.2,.8,.2,1) both}.dl-mk-face.out{transform:scale(.4);opacity:0;pointer-events:none}@keyframes dl-dock-in{0%{transform:scale(.4);opacity:0}}.dl-mk-more{font-size:11px;font-weight:600;color:var(--dl-fg-muted)}.dl-mk-av,.dl-mk-tile{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1)}.dl-mk.merged .dl-mk-av,.dl-mk.merged .dl-mk-tile,.dl-mk.piled .dl-mk-av{transform:scale(.5)}.dl-mk-host,.dl-mk-dock,.dl-mk-pile-box{transition-property:border-radius,border-right-color,clip-path,opacity,height,width,padding,gap}.dl-mk-dock,.dl-mk-pile-box{transition-duration:.22s;transition-timing-function:cubic-bezier(.2,.8,.2,1)}.dl-mk-pile-box{position:relative}.dl-mk-more{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease}.dl-mk-more.in{animation:dl-dock-in .24s ease both}.dl-mk-more.out{transform:scale(.4);opacity:0}.dl-mk-face .dl-mk-av{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1),width .2s ease,height .2s ease,font-size .2s ease}.dl-mk-face{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,margin .2s ease}.dl-mk-face>.dl-mk-badge{max-width:48px;overflow:hidden;transition:opacity .2s ease,transform .2s ease,max-width .22s ease,margin .22s ease,padding .22s ease,border-width .22s ease,height .22s ease,min-width .22s ease,width .22s ease,bottom .22s ease}.dl-lod-far .dl-mk-host{width:32px;height:32px;border-radius:9px}.dl-lod-far .dl-mk-host.docked{border-radius:9px 0 0 9px}.dl-lod-far .dl-mk-host-tile{width:20px;height:20px;border-radius:6px}.dl-lod-far .dl-mk-host-ic{width:11px;height:11px}.dl-lod-far .dl-mk-dock{height:32px;gap:0;padding:0 4px 0 0;border-radius:0 9px 9px 0}.dl-lod-far .dl-mk-pile-box{height:32px;gap:0;padding:0 4px;border-radius:16px}.dl-lod-far .dl-mk-face+.dl-mk-face{margin-left:-6px}.dl-lod-far .dl-mk-face .dl-mk-av{width:22px;height:22px;font-size:8px;box-shadow:0 0 0 2px var(--dl-elevated)}.dl-lod-far .dl-mk-face>.dl-mk-badge{max-width:0;min-width:0;padding:0;margin-left:0;border-width:0;opacity:0;transform:scale(.5);pointer-events:none}.dl-lod-far .dl-mk-more{margin-left:4px;font-size:10px}.dl-mk-label{transition:opacity .2s ease}.dl-lod-far .dl-mk-label{opacity:0}.dl-lod-mid .dl-mk-host{width:36px;height:36px}.dl-lod-mid .dl-mk-dock,.dl-lod-mid .dl-mk-pile-box{height:36px}.dl-lod-mid .dl-mk-face .dl-mk-av{width:24px;height:24px;font-size:9px}.dl-lod-mid .dl-mk-face>.dl-mk-badge{height:12px;min-width:12px;margin-left:-10px;bottom:-7px}.dl-lod-mid .dl-mk-face>.dl-mk-badge:has(>svg:only-child){width:12px}.dl-lod-mid .dl-mk-face>.dl-mk-badge .dl-mk-badge-ic{width:8px;height:8px}@media(prefers-reduced-motion:reduce){.dl-mk-dock,.dl-mk-pile-box,.dl-mk-face,.dl-mk-av,.dl-mk-tile,.dl-mk-host,.dl-mk-face>.dl-mk-badge{transition:none;animation:none}}.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host{cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.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-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 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.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}.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}`;var dr=`.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-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-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)}@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}`;var cr=".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}";var pr=".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>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.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-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.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-bad{color:var(--dl-bad)}";var ur=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var mr=".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)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var gs=[Xa,er,tr,nr,or,ar,rr,ir,sr,lr,dr,cr,pr,ur,mr].join(` -`);function hr(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=gs,n}function lt(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async a=>{let r=await e.render(a),i=document.createElement("div");return i.className="dl-root",i.append(hr(),r),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var zg=lt(jt),Ng=lt(st),Hg=lt(jt),Rg=lt(bn),Ig=lt(yn),Bg=lt(Ln),Og=lt(wn);function fr(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var jg=fr(""),Ug=fr("log");return baseclass.extend({ activity: Ug, diagnostics: Bg, health: jg, overview: zg, people: Ng, person: Ig, server: Hg, settings: Rg, updates: Og }); +`).trim()}async function Zt(n,e,o,r){let a=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";te(o,[i,a],[H([b("copy")," Copy"],()=>pe(s,"Release notes copied"))," ",ae("Close")],"wide");try{let l=await A.updatesNotes(n,e,r??"");s=ia(l.body||"");let c=ra(l.url);dom.content(i,[l.published?t("span",{class:"dl-pill"},Ue(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),c?t("a",{href:c,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",b("open")]):""]),dom.content(a,s.trim()?aa(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(a,t("p",{class:"dl-muted"},be(l)))}}var sa={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},bo=n=>n?Ue(n):"";function Cs(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function da(n,e){let o=n.st,r=o.policy,a=o.kept?.app,i=e?.update&&e.tag?e.tag:o.version,s=w=>()=>Zt("app",w,`What’s new in Dawnline ${w.replace(/^v/,"")}`),l=e?.tag&&(e.update||e.status==="latest")?Es(n,e.tag,e.update?o.version:""):null,c=e?.tag??i,d=r.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[r.interval]??24)*3600:0,p=(w,C)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},w),t("span",{class:"dl-comp-side-v"},C)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:`Reinstall ${o.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",o.version)},a?{label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await se(`Roll back to Dawnline ${a.version}?`,`The copy kept on the router replaces ${o.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",o.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},b("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[o.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},`release ${e.latest}`):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?`released ${bo(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${bo(e.published)}`:""}`:"not checked yet")])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(w=>t("li",{},w))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(c)},`+${l.total-l.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[H("Update now",()=>n.op("app","Updating Dawnline",o.version),"positive",{disabled:n.busy}),H("What’s new",s(i))]):"",Ls(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[b("globe"),t("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p("Auto-update",[r.auto?Ee("ok","On"):Ee("","Off"),t("span",{class:"dl-muted"},r.auto?r.mode==="immediate"?"as soon as found":`${sa[r.interval]==="weekly"?"weekly":"daily"} at ${r.time}`:r.check?`checks ${sa[r.interval]}`:"checks off")]),p("Last check",o.check?[re(o.check.time,o.now),d>o.now?t("span",{class:"dl-faint"},`· next in ${vt(d-o.now)}`):""]:["Never"]),p("Rollback",a?[t("span",{class:"dl-mono"},a.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},r.keep?"Kept after the next update":"Off")])])])}function Es(n,e,o){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let r=a=>a.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await A.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` +`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await A.updatesChanges(o,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>Cs(r(l))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Ls(n){let e=t("div",{class:"dl-params-body"}),o=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[b("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&An(n,e)}),n.versOpen&&An(n,e),o}async function An(n,e){let o=ie("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),r=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return U("Enter a release tag like 0.3.1","warning");la(n,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),r(o.value))});let a=t("div",{class:"dl-comp-tag"},[o,H("Install",()=>r(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),An(n,e)},l=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),t("span",{class:"dl-faint"},`Page ${i}`),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>s(1)},"Older →")]),c=n.versCache.get(i);if(!c){dom.content(e,[a,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{c=(await A.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[a,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${be(p)}`),H("Try again",()=>An(n,e))]),l(!1)]);return}if(n.versCache.set(i,c),i!==n.versPage||!e.isConnected)return}if(!c.length)return dom.content(e,[a,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let d=n.st.version;dom.content(e,[a,...c.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},bo(p.published)),p.prerelease?Ee("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},Le("file","What’s new",()=>Zt("app",p.tag,`What’s new in Dawnline ${u}`))),u===d?Ee("ok","Installed"):H("Install",()=>la(n,p.tag),"neutral",{disabled:n.busy})])}),l(c.length>=5)])}async function la(n,e){let o=e.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await se(`Install Dawnline ${o}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${e}`,`Installing Dawnline ${o}`,n.st.version)}function ca(n,e){let o=n.st,r=o.kept?.amneziawg,a=e?.sources??{},i=Object.keys(a),s=e?.current??null,l=s?a[s]:void 0,c=!!e?.ru,d=o.needs?.awg??[],p=d.length?null:e?.installed??null,u=[];s&&p&&u.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${c?":ru":""}`,"Reinstalling AmneziaWG",p)}),r&&u.push({label:`Roll back to ${r.version}`,ic:"archive",warn:!0,run:async()=>{await se(`Roll back AmneziaWG to ${r.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",p??void 0)}});let w=[e?.release?{label:"What’s new",ic:"file",run:()=>Zt("amneziawg",e.release,`What’s new in the ${l?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((h,f,T)=>h!==null||f>0&&T[f-1]!==null),C=o.tunnels??[],g=C.length?`Switching restarts ${C.length===1?"the tunnel":`${C.length} tunnels`} for a few seconds: ${C.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",m=C.length>1?`${C.slice(0,-1).join(", ")} and ${C[C.length-1]}`:C[0],k=C.length?`Switching restarts ${m} for a few seconds.`:"Switching takes a few seconds.",I=async h=>{let f=a[h];await se(p?`Switch to AmneziaWG ${f.gen}?`:`Install AmneziaWG ${f.gen}?`,`The ${f.label} build, ${f.version}. ${g}${f.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${h}${c?":ru":""}`,p?`Switching to AmneziaWG ${f.gen}`:"Installing AmneziaWG",p??void 0)},x=h=>{let f=a[h],T=s===h&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??"none yet"),t("span",{class:"dl-comp-bact"},T?Ee("ok","Active"):f.version?H(p?"Switch":"Install",()=>I(h),p?"neutral":"positive",{disabled:n.busy}):Ee("","No build"))])},v=i.map(h=>a[h]?.newer?`${a[h].label} moves to ${a[h].newer.gen} with OpenWrt ${a[h].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),$=ve(c,"Russian translation",h=>{s&&n.op(`amneziawg:${s}${h?":ru":""}`,h?"Adding the Russian translation":"Removing the Russian translation",p??void 0)});$.disabled=!s||!p||n.busy;let E=n.awgOpen??!p,y=t("details",{class:"dl-params dl-comp-fold",open:E?"open":null},[t("summary",{},[b("chevron"),t("span",{},"Build and translation")]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...i.length?i.map(x):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Russian translation"),t("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),t("span",{class:"dl-comp-bact"},$)])]),p&&i.length||v.length?t("div",{class:`dl-comp-status ${p&&i.length?"warn":"acc"}`},[b(p&&i.length?"alert":"download"),t("span",{},[p&&i.length?t("b",{},k):"",...v.map(h=>` ${h}`)])]):""])]);y.addEventListener("toggle",()=>n.awgOpen=y.open);let z=[];return e?.update&&p&&s?z.push(H(`Update to ${e.latest}`,()=>n.op(`amneziawg:${s}${c?":ru":""}`,"Updating AmneziaWG",p),"neutral",{disabled:n.busy})):z.push((e||d.length)&&!p?Ee("warn","Not installed"):n.state("amneziawg",e,e?.latest??"")),z.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",p??void 0),w)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${e.release} build`:""}`:d.length?`missing ${d.join(", ")}`:e?"not installed":"version not checked"],z),t("div",{class:"dl-comp-foldwrap"},y)]}var Ms=[{title:"Home-like link",sub:"Policy routing and the veth pair",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"HTTPS for the portal",sub:"OpenSSL for uhttpd",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"Certificates (ACME)",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],xo={home:"network",https:"lock",acme:"file"};function pa(n,e){let o=n.st,r=e?.pkgs??{},a=Ms.filter(d=>d.feature==="home"?o.home:o.portal),i=async(d,p,u=d)=>{await se(`Update ${p}?`,`${u.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${d.join(",")}`,`Updating ${p}`)},s=[{label:"Check system packages",ic:"refresh",run:()=>n.op("check:packages","Checking system packages")},{label:"Open the OpenWrt package list",ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:a.map(d=>{let p=d.pkgs.filter(m=>r[m]?.installed),u=[...new Set(p.flatMap(m=>[...r[m]?.latest?[m]:[],...r[m]?.with??[]]))],w=o.needs?.[d.feature]??d.pkgs.filter(m=>!r[m]?.installed),C=p.find(m=>r[m]?.latest),g=p.map(m=>`${m} ${r[m]?.installed??""}`).join(", ");return w.length?n.row(xo[d.feature],d.title,[`${d.optional?"not installed":`missing ${w.join(", ")}`}`],[H("Install",()=>n.op(`pkgs:${w.join(",")}`,`Installing ${d.title}`),d.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))]):e&&u.length?(l++,n.row(xo[d.feature],d.title,C?[`${r[C].installed} → ${r[C].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[H("Update",()=>i(p.filter(m=>r[m]?.latest||r[m]?.with?.length),d.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))])):n.row(xo[d.feature],d.title,[g||d.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:a.length}}var Ts={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function ua(n){let e=n.st,o=a=>{let i=at(a.component??"app"),s=Ts[i]??"Components",l=a.auto?"automatically":"by you",c="ok",d="check",p;if(a.kind==="found")c="accent",d="download",p=[t("b",{},(a.items??[]).join(", ")),` found by ${a.auto?"the automatic check":"a check"}`];else if(a.state==="failed")c="bad",d="x",p=[t("b",{},s),` ${a.kind==="install"?"update":"check"} failed${a.error?` · ${a.error}`:""}`];else{let u=a.from&&a.to&&a.from!==a.to?` ${a.from} → ${a.to}`:a.to?` ${a.to}`:"";p=[t("b",{},s),`${u} ${u?"":"updated "}${l}${a.took?` · ${vt(a.took)}`:""}`.replace(/\s+/g," ")]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${c}`},b(d)),t("span",{class:"dl-row-main"},p),t("span",{class:"dl-faint dl-nowrap",title:new Date(a.ts*1e3).toLocaleString()},re(a.ts,e.now))])},r=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),r.length?t("div",{},r.slice(0,8).map(o)):t("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var Hn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null}load(){return A.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await A.updatesStatus().catch(()=>null);if(!o)return;let r=this.st;this.st=o,o.job?.state==="running"&&this.following!=="starting"&&o.job.id!==this.following&&this.follow(o.job),(o.job?.id!==r.job?.id||o.job?.state!==r.job?.state||o.job?.phase!==r.job?.phase||o.check?.time!==r.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await A.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,o,r){if(this.busy||this.following==="starting"){U("Another component action is already running","warning");return}this.following="starting",this.paint();let a=at(e),i=await Jt(e,{title:o,version:r,onJob:s=>this.following=s.id,onDone:s=>this.refresh(s),onUpdate:s=>{let l=s.check?.components??{};a==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,"Updating AmneziaWG",l.amneziawg.installed??void 0):this.op("app","Updating Dawnline",this.st.version)}});this.following==="starting"&&(this.following=i?.id??null),this.refresh()}async follow(e){this.following=e.id;let o=En(e),r={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[o]??"components";await Jt(null,{title:`${e.action==="check"?"Checking":e.auto?"Automatic update:":"Updating"} ${r}`,onDone:a=>this.refresh(a)},e)}paint(){let e=this.st,o=e.check?.components??{},r=e.firmware,a=pa(this,o.packages),i=(e.needs?.awg??[]).length>0,l=(!i&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+a.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Components"),t("span",{class:"dl-faint"},[r?.version?`OpenWrt ${r.version} · ${r.target}`:"",e.check?`checked ${re(e.check.time,e.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[b("edit")," Settings"]),H([b("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),da(this,o.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Components"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},i?l?`AmneziaWG not installed · ${l} update${l===1?"":"s"}`:"AmneziaWG not installed":!o.amneziawg&&!o.packages?"":l?`${l} of ${1+a.total} need${l===1?"s":""} an update`:"Everything is up to date")]),t("div",{},[...ca(this,o.amneziawg),...a.rows])]),ua(this)])])}state(e,o,r){let a=this.st.job;if(a?.state==="running"){let i=l=>l==="packages"?"pkgs":l,s=a.action==="check"?[i(a.component||"all")]:(a.component??"").split(" ").map(l=>i(at(l)));if(s.includes(e)||s.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:"Show progress",click:()=>this.follow(a)},[a.action==="check"?"Checking":"Updating","…"])}return o?o.error?Ee("warn","Check failed",o.error):o.update?Ee("info","Update available"):o.status==="dev"?Ee("info","Newer than release",`The latest release is ${r}`):Ee("ok","Up to date"):Ee("","Not checked")}more(e){let o=H([b("more")],()=>Ce(o,e.filter((r,a,i)=>r!==null||a>0&&ar?{label:r.label,icon:b(r.ic),warn:r.warn,run:r.run}:null)),"neutral",{title:"More","aria-label":"More"});return o}round(e,o,r=!1){let a=this.busy?" is-busy":"",i;return r?i=H([b("refresh")," Check"],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${a}`,"aria-label":"Check for updates"}):(i=Le("refresh","Check for updates",e,"neutral",a.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),me(i,()=>["Check for updates"])),t("span",{class:"dl-comp-ic"},[i,this.more(o)])}row(e,o,r,a){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},b(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-mono dl-faint dl-comp-sub"},r)]),...a])}};var ma=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function ha(n){let e=n.st.servers.find(o=>o.id===n.p.server)?.name??"Home";_t(n.p,e)}async function fa(n){let e=n.p,o=e.code_set??0,r=e.devices.filter(l=>l.created_by==="portal"&&l.created>=o),a=r.map(l=>t("input",{type:"checkbox",id:`dl-rm-${l.id}`,checked:"checked","data-id":l.id})),i=[t("p",{},"The old link stops working right away.")];r.length&&i.push(t("p",{},"Devices added through the old link keep working until they are removed. Remove them too:"),t("div",{class:"dl-checklist"},r.map((l,c)=>t("label",{for:`dl-rm-${l.id}`},[a[c],` ${l.name}`]))));let s=async()=>{let l=a.filter(d=>d.checked).map(d=>d.dataset.id),c=await W(()=>A.personRegen(e.id,l),l.length?`New link created, ${l.length} device${l.length===1?"":"s"} removed`:"New link created");c&&(oe(),l.length&&await n.refresh(),c.link&&await pe(c.link,"New link copied"))};te("Create a new link?",i,[ae()," ",H("Create new link",s,"negative")])}function wo(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");te("Note",[e],[ae()," ",H("Save",async()=>{oe(),await n.patch({note:e.value.trim()},e.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>e.focus(),50)}function ga(n){let e=n.p,o=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},"Pause access"),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},"Keep access"),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},"Remove their devices")]),r=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(a=>t("option",{value:a,selected:e.expire_warn===a?"selected":null},a?`${a} day${a===1?"":"s"} before`:"Don’t warn")));te("When access ends",[ma("Then",o),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Warn"),t("div",{class:"cbi-value-field"},[r,t("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[ae()," ",H("Save",async()=>{oe(),await n.patch({expire_action:o.value,expire_warn:r.value},"Saved")},"positive")])}function va(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48}),o=ye("Name",e,()=>_e(e.value,[],"Shown in their portal and apps."));te("Rename",[o],[ae()," ",H("Save",async()=>{let r=o.help();if(r.bad){U(r.text,"warning");return}await n.patch({name:e.value.trim()},"Renamed")&&oe()},"positive")]),setTimeout(()=>e.select(),50)}function ba(n){let e=n.p,o=n.st.servers.filter(i=>i.id!==e.server),r=t("select",{class:"cbi-input-select"},o.map(i=>t("option",{value:i.id},`${i.name} · ${i.endpoint||"no address"}:${i.port}`))),a=e.devices.length;te(`Move ${e.name} to another server`,[ma("Server",r),t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from the personal link or from you). Circles and home networks of the old server are left behind.`:"They have no devices yet: nothing else changes.")],[ae()," ",H("Move",async()=>{await n.patch({server:r.value},`Moved to ${o.find(i=>i.id===r.value)?.name??"the server"}`)&&(oe(),a&&U("Devices are marked “Update config” until they import again.","info",6e3))},"positive")])}async function xa(n){let e=n.p;await se(`Delete ${e.name}?`,`All ${e.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await W(()=>A.personDelete(e.id),"Deleted")&&(location.href=St(e.server))}function wa(n){let e=n.p,o=n.st,r=e.online?"online now":e.last_seen?`last seen ${re(e.last_seen,o.now)}`:"never connected",a=e.created?`Added ${Me(je(new Date(e.created*1e3)))}`:"",i=e.has_link??o.settings.portal_enabled,s=[{label:"Rename",icon:b("edit"),run:()=>va(n)},{label:e.note?"Edit note":"Add note",icon:b("file"),run:()=>wo(n)},...o.servers.length>1?[{label:"Move to server…",icon:b("server"),run:()=>ba(n)}]:[],...i?[null,{label:"Invite card",icon:b("qr"),run:()=>ha(n)},{label:"New link",icon:b("key"),run:()=>fa(n)}]:[],null,...e.paused?[]:[{label:"Pause",icon:b("pause"),warn:!0,run:()=>n.patch({paused:!0},"Paused")}],{label:"Delete",icon:b("trash"),danger:!0,run:()=>xa(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},He(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),Do(e)]),t("span",{class:"dl-faint",title:a},`${e.devices.length} of ${e.device_limit} devices · ${r}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?H([b("play")," Resume"],()=>n.patch({paused:!1},"Resumed"),"add"):"",i?Le("link","Copy link",()=>wn(e.id),"neutral","dl-icon-only"):"",Le("more","More",l=>Ce(l.currentTarget,s),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>wo(n)},[b("file"),t("span",{},e.note)]):""])}function ya(n){let e=n.p,o=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?Tn(e.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",Sn(n.series,`${X(e.month[0]+e.month[1])} this month`)])}async function Ss(n,e){let o=await W(()=>A.deviceConfig(e.id));o&&te(`Set up ${e.name}`,[await n.core.connectBlock(o,"qr")],[ae("Close")])}async function _s(n,e){let o=await W(()=>A.deviceConfig(e.id));if(!o)return;if(!o.has_private_key){U("This device made its own keys in the browser; its configuration only exists there.","warning");return}let r=n.core.file.make(o);Se(r.name,r.text,"application/octet-stream")}function ka(n){let e=n.p,o=n.st.now,r=c=>We(e,c,n.deviceOpts()),a=c=>d=>{d.target.closest("button:not(.dl-dcard-title), a")||r(c)},i=c=>H([b("more")],d=>kr(d.currentTarget,e,c,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=tn(e.devices).map(c=>{let d=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},b(c.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>r(c)},[t("b",{},c.name),nn(c,o,void 0,e),c.config_stale?t("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(c)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},X(c.month[0]+c.month[1])),t("span",{class:"dl-sub"},"this month")]),Gr(n.devSeries[c.id]??[])]);return t("article",{class:`dl-dcard clickable${c.online?" online":""}${c.disabled?" off":""}`,click:a(c)},[d,c.handshake?p:c.disabled?t("div",{class:"dl-sub"},`${Ze[c.kind]} · created ${re(c.created,o)} ${c.created_by==="portal"?"in the portal":"by you"}.`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>Ss(n,c)},[b("qr"),"Show QR"]),t("button",{type:"button",class:"dl-chipbtn",click:()=>_s(n,c)},[b("download"),"Config"])])])}),l=e.devices.length>=e.device_limit;return s.push(t("button",{type:"button",class:"dl-dslot add",click:()=>nt(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},b("plus")),t("span",{class:"dl-stack"},[t("b",{},"Add device"),t("span",{class:"dl-sub"},l?`Over the limit · ${e.devices.length} of ${e.device_limit}`:`${e.devices.length} of ${e.device_limit}`)])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Devices"),t("span",{class:"dl-sub"},`${e.online} online`)]),t("div",{class:"dl-dgrid"},s)])}function $a(n){let e=n.p,o=we([["device","Device’s own DNS"],["home","Home names"]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:a=>n.patch({dns_mode:a},a==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")}),r=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),o]),t("span",{class:"dl-sub"},e.dns_mode==="home"?["Names like ",t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",r?[" (",t("span",{class:"dl-mono"},r)," 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.")])}function Ca(n){let e=n.p,r=n.st.servers.find(i=>i.id===e.server)?.home??[];if(r.length<2)return"";let a=new Set(e.home_nets?.length?e.home_nets:r.map(i=>i.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},r.map(i=>qe(i.dev,a.has(i.dev),()=>{let s=new Set(a);if(s.delete(i.dev)||s.add(i.dev),!s.size)return U("Keep at least one network, or choose Internet only.","warning",5e3);let l=s.size===r.length?[]:[...s];n.patch({home_nets:l},l.length?`${e.name} reaches ${l.join(", ")}`:`${e.name} reaches every home network`)},{title:i.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?`Home networks ${e.name} reaches. Networks added to the server later stay out.`:`Home networks ${e.name} reaches: all of them. Untick one to keep ${e.name} out of it.`)])}function Ea(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(o=>qe(o.name,e.has(o.id),()=>{let r=new Set(e);r.delete(o.id)||r.add(o.id),n.patch({services:[...r]},r.size?"Home services updated":"Whole home network")},{title:`${o.address}${o.ports.length?` · ${o.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function La(n){let e=n.p,o=n.st;if(o.servers.find(d=>d.id===e.server)?.mesh!=="circles"||!rt(e))return"";let a=o.circles.filter(d=>d.server===e.server),i=a.find(d=>d.id===e.circle),s=i?o.people.filter(d=>d.id!==e.id&&d.circle===i.id&&rt(d)).map(d=>d.name):[],l=t("button",{type:"button",class:"dl-chipbtn",click:()=>Ce(l,[...a.map(d=>({label:d.name,icon:uo(d),run:()=>d.id!==e.circle&&n.patch({circle:d.id},`${e.name} is in ${d.name}`)})),e.circle?{label:"No circle",icon:b("x"),run:()=>n.patch({circle:""},`${e.name} is in no circle`)}:null,{label:"New circle",icon:b("plus"),run:()=>$n(o,e.server,null,()=>n.refresh())}])},"Change"),c=i?o.people.filter(d=>d.circle===i.id&&rt(d)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Devices see each other"),l]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},i?i.name:"No circle"),t("span",{class:"dl-avstack",title:c.map(d=>d.name).join(", ")},c.slice(0,5).map(d=>t("span",{class:"dl-avatar sm"},He(d.name))))]),t("span",{class:"dl-sub"},i?s.length?[e.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${e.name}'s own devices`)])}function Ma(n){let e=n.p,o=n.st.now,r=t("div",{class:"dl-slots"});for(let s=0;s=e.device_limit,d=t("i",{class:c?"over":l?"used":""});me(d,()=>[t("div",{class:"dl-tip-title"},l?`${l.name}${c?" · over the limit":""}`:"Free slot"),t("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${re(l.handshake,o)}`:"Not set up yet":"They can add a device here")]),r.appendChild(d)}let a=Math.max(1,e.devices.length),i=t("button",{type:"button","aria-label":"Allow fewer devices",disabled:e.device_limit<=a?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=a&&e.devices.length>1&&me(i,()=>[t("div",{class:"dl-tip-title"},`${e.devices.length} devices in use`),t("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},"Devices"),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[i,t("button",{type:"button","aria-label":"Allow more devices",disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),r])}var Ps={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."},Ta=/^([01]\d|2[0-3]):[0-5]\d$/;function Ds(n){let e=n.p,o=n.today,r=Ve(e.expires,o),a=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});a.addEventListener("change",()=>a.value&&n.patch({expires:a.value},`Access until ${Me(a.value)}`));let i=(d,p)=>{let u=So(e.expires&&(r??-1)>=0?e.expires:"",d,p,o);n.patch({expires:u},`Access until ${Me(u)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([d,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>i(d,p)},u)),l=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{a.focus({preventScroll:!0});try{a.showPicker()}catch{}}},[b("calendar"),e.expires?Me(e.expires):"Date"]),a]),c={pause:"pause access",notify:"keep access",remove:"remove their devices"}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Access ends"),e.expires?t("span",{class:r!=null&&r<0?"dl-bad":Ye(e,r)?"dl-warn":"dl-ok"},r!=null&&r<0?"ended":`${r} day${r===1?"":"s"} left`):t("span",{class:"dl-faint"},"no end date")]),t("div",{class:"dl-chips-row"},[...s,l,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`When it ends: ${c}${e.expire_warn?`, warn ${e.expire_warn} day${e.expire_warn===1?"":"s"} before`:""}`),t("a",{href:"#",click:d=>{d.preventDefault(),ga(n)}},"Change")])])}function As(n){let e=n.p,o=e.quota_used||e.month[0]+e.month[1],r=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,a=t("div",{class:`dl-meter${r>=100?" bad":r>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:"Alert at 90%"}):""]);a.firstChild.style.width=`${r}%`,e.quota_limit&&me(a,()=>[t("div",{class:"dl-tip-title"},`${r.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${X(e.quota_used)} of ${X(e.quota_limit)} · ${X(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},"Alert at 90%")]);let i=we([["month","Monthly"],["total","Total"]],e.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=t("input",{type:"number",class:"cbi-input-text dl-w-port",min:0,step:"any",value:e.quota_gb?String(e.quota_gb):""}),c=ye("Data limit (GB)",l,()=>ln(l.value,e.quota_period==="month"));te("Data limit",[c],[ae()," ",H("Save",async()=>{let d=c.help();if(d.bad){U(d.text,"warning");return}let p=l.value.trim();await n.patch({quota_gb:p},p&&Number(p)>0?`Data limit ${p} GB`:"No data limit")&&oe()},"positive")]),setTimeout(()=>l.select(),50)}},"Custom")),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Data"),i]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[X(o),e.quota_limit?t("span",{class:"dl-faint"},` of ${X(e.quota_limit)}`):t("span",{class:"dl-faint"}," · no limit")]),e.quota_period==="month"?t("span",{class:"dl-sub"},"resets on the 1st"):""]),e.quota_limit?a:"",t("div",{class:"dl-chips-row"},s),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?`Includes +${e.bonus_gb} GB extra this month`:"Need a little more this month?"),t("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`${X(e.total[0]+e.total[1])} in total`),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Lt("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function Hs(n){let e=n.p,o=!!e.hours,[r,a]=(e.hours||"07:00-23:00").split("-"),i=t("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":"From"}),s=t("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"To"}),l=t("div",{class:"dl-tile2-row"},[i,t("span",{class:"dl-faint"},"to"),s]),c=()=>{let w=`${i.value}-${s.value}`;if(w!==e.hours){if(!Ta.test(i.value)||!Ta.test(s.value))return U("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return U("The start and the end must differ.","warning");n.patch({hours:w},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",w=>{l.contains(w.relatedTarget)||c()});for(let w of[i,s])w.addEventListener("keydown",C=>{C.key==="Enter"&&(C.preventDefault(),c())});let d=t("button",{type:"button",role:"switch","aria-checked":o?"true":"false",class:`dl-switch${o?" on":""}`,"aria-label":"Limit hours",click:()=>{if(o)return n.patch({hours:""},"Any time");d.classList.add("on"),d.setAttribute("aria-checked","true"),p.textContent="Set the hours, then press Enter",u.appendChild(l),i.focus()}},t("i")),p=t("span",{},o?`${r} – ${a} (router time)`:"Any time"),u=t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},"Allowed hours"),p]),d]),o?l:""]);return u}function Sa(n){let e=n.p,o=we(["internet","lan","both"].map(r=>[r,[b(r==="internet"?"globe":r==="lan"?"home":"shield"),r==="internet"?"Internet":r==="lan"?"Home":"Both"]]),e.access,{label:"Access",cls:"wide",optimistic:!1,onChange:r=>n.patch({access:r},`Access: ${dt[r]}`)});return t("section",{class:"dl-devsec","aria-label":"Access and limits"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Access & limits")]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},"Can reach"),o,t("span",{class:"dl-sub"},Ps[e.access]),e.access==="lan"&&n.st.services.length?Ea(n):"",rt(e)?Ca(n):"",e.access==="lan"?$a(n):""]),t("div",{class:"dl-tiles2"},[Ma(n),La(n),Ds(n),As(n),Hs(n)])])])}function zs(n){let e=n.st,o=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Locations"),t("span",{class:"dl-spacer"}),e.geo.enabled?Tt("30d",a=>n.map?.setRange(a),!1):"",H("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let r=new tt({openPerson:()=>{},openDevice:(a,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&We(n.p,s,n.deviceOpts())}},"30d",280);return n.map=r,requestAnimationFrame(()=>r.mount(n.mapData())),t("div",{class:"dl-panel flush"},[o,r.el])}function _a(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[b("pin"),t("div",{class:"dl-stack"},[t("span",{},"Locations are off"),t("span",{class:"dl-sub"},"City-level, from the client IP")]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:zs(n);let o=e.now-30*86400,r=e.geo.points.filter(s=>s.person===n.p.id&&s.ts>=o).sort((s,l)=>l.ts-s.ts),a=[...new Set(r.map(s=>s.city||s.country).filter(Boolean))],i=r[0];return t("div",{class:"dl-places"},[b("pin"),t("div",{class:"dl-stack"},[t("span",{},i?i.city||i.country:"No locations yet"),t("span",{class:"dl-sub"},i?`${a.length} place${a.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),t("span",{class:"dl-spacer"}),r.length?H("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function Pa(n){let e=n.p,o=n.st,r=n.events.filter(l=>l.person===e.id),a=[],i=[...r].reverse();for(let l=0;l1){let u=p.querySelector(".dl-row-main");dom.content(u,[...ho(o,c).slice(0,3),t("span",{class:"dl-muted"},`${d} times`)]),u.title=i.slice(l,l+d).map(w=>w.detail??"").join(` +`)}a.push(p),l+=d-1}let s=H([b("more")],()=>Ce(s,[{label:"Export CSV",icon:b("download"),run:()=>Fe(o,r,"csv",e.id)},{label:"Export JSON",icon:b("download"),run:()=>Fe(o,r,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:b("trash"),danger:!0,run:()=>et(`Clear ${e.name}'s activity`,`Removes events about ${e.name} and their devices.`,{person:e.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-sub"},r.length>10?`latest 10 of ${r.length}`:""),t("span",{class:"dl-spacer"}),s]),a.length?a:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var zn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,r,a]=await Promise.all([A.status(30),e?A.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?A.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:r?.events??null,use:a}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(s=>s.id===this.id);if(!o)return t("div",{class:"dl-empty"},[t("h3",{},"Person not found"),t("p",{},"They may have been removed."),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let r=t("div",{},[this.parts.crumbs,this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let a=new URLSearchParams(location.search),i=a.get("device")&&o.devices.find(s=>s.id===a.get("device"));return i?setTimeout(()=>We(this.p,i,this.deviceOpts()),50):a.get("add")&&setTimeout(()=>nt(this.p,this.deviceOpts()),50),this.poller=ot({fetch:s=>{let l=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>r.isConnected,apply:(s,l)=>this.apply(s,l)}),r}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let r=this.st.people.find(a=>a.id===this.id);if(!r){o||(location.href=St(this.p?.server));return}this.p=r,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var i;this.poller?.claim();let r=await W(()=>A.personUpdate(this.p.id,e),o);if(!r)return!1;this.poller?.claim();let a=this.st.people.findIndex(s=>s.id===this.p.id);return(i=r.person).rate??(i.rate=this.p.rate),a>=0&&(this.st.people[a]=r.person),this.p=r.person,this.paint(),!0}get today(){return Ie(this.series.length?this.series:this.st.series)}get core(){return Mt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:St(e.server)},this.st.servers.find(o=>o.id===e.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:St(e.server)},"People"),t("span",{},"/"),t("span",{},e.name)])}paint(e=!1){Te(this.parts.crumbs,this.crumbs(),e),Te(this.parts.head,wa(this),e),Te(this.parts.traffic,ya(this),e),Te(this.parts.devices,ka(this),e),Te(this.parts.limits,Sa(this),e),this.paintPlaces(e),Te(this.parts.activity,Pa(this),e)}paintPlaces(e=!1){let o=_a(this);o&&Te(this.parts.places,o,e&&!this.mapOpen)}};var Ns={ok:"check",warn:"alert",error:"x",skip:"pause"},Nn=class{constructor(e,o,r,a){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=r,this.toLog=a,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,r)}async run(e){let o=e?await _n(e):await A.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks")]),t("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=e.filter(s=>s.status==="error").length,r=e.filter(s=>s.status==="warn").length;dom.content(this.summary,o?ct("error",`${o} problem${o>1?"s":""} need attention.`):r?ct("warn",`${r} warning${r>1?"s":""}.`):ct("ok","All checks passed."));let a=new Map;for(let s of this.sl.watchdog.repairs)a.set(s.id,Math.max(a.get(s.id)??0,s.ts));let i=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks"),t("span",{class:"dl-spacer"}),H("Run again",i)]),t("ul",{class:"dl-checks"},e.map(s=>t("li",{},[t("span",{class:`dl-check-icon ${s.status}`},b(Ns[s.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},s.title),t("div",{class:"dl-check-detail"},s.detail),a.has(s.id)?t("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${zt(a.get(s.id))}`):""]),fo(s,l=>void this.run(l),i)])))])}paintLive(e,o){this.sl=e,this.events=o;let r=e.watchdog,a=r.beat!=null&&r.now-r.beat>180,i=r.repairs.filter(c=>r.now-c.ts<86400),s=i[i.length-1],l=ve(r.enabled,"Watchdog repairs",async c=>{await W(()=>A.settingsUpdate({watchdog:c?"1":"0"}),c?"Watchdog on":"Watchdog off")||Qn(l,!c);let p=await A.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${r.enabled?"":" off"}`},b("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},"Watchdog"),t("span",{class:"dl-sub"},r.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.")]),t("span",{class:"dl-spacer"}),l]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},r.targets.map(c=>t("span",{class:`dl-check-chip${c.ok?"":" error"}`,title:c.ok?"OK":`Not working${c.tries?` · ${c.tries} repair${c.tries>1?"s":""}`:""}`},[b(c.ok?"check":"x"),c.name]))),t("span",{class:`dl-sub${a?" dl-warn-text":""}`},a?`The agent has not checked in for ${Math.round((r.now-r.beat)/60)} min; cron restarts it after 5.`:[r.last?`Looked ${re(r.last,r.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${zt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,o=[...this.events.map(a=>({ts:a.ts,ev:a})),...this.sl.log.map(a=>({ts:a.ts,sys:a}))].filter(a=>a.ts>=e&&dn(a)).sort((a,i)=>i.ts-a.ts),r=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Recent problems"),t("span",{class:"dl-spacer"}),o.length?t("a",{href:"#",click:a=>(a.preventDefault(),this.toLog())},"All in Log →"):""]);if(!o.length){dom.content(this.recentEl,[r,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},b("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[r,...o.slice(0,8).map(a=>{if(a.sys){let i=a.sys,s=`${i.ts}|${i.msg}`;return Mn(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},zt(i.ts))}return it(this.st,a.ev,{time:zt(a.ts)})})])}};var Rn=300,Rs=["all","connections","people","system","problems"],In=class{constructor(e,o,r){this.events=[];this.system=[];this.kind="all";this.shown=Rn;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(o),this.system=r,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,o=i=>()=>{let s=this.filtered().reverse();Fe(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,e(),s.filter(l=>l.sys).map(l=>l.sys))},r=H([b("download")," Export"],()=>Ce(r,[{label:"CSV (spreadsheet)",icon:b("download"),run:o("csv")},{label:"JSON",icon:b("download"),run:o("json")}])),a=H([b("trash")," Clear"],()=>et("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[r,a]}take(e){this.events=e.events,this.policy=e.policy;let o=Et.filter(r=>!e.policy.categories.includes(r));this.sub=`${cn(e.policy)}${o.length?` Not recorded: ${o.map(r=>pt[r].toLowerCase()).join(", ")}.`:""}`}async reload(){let[e,o]=await Promise.all([A.events(2e4).catch(()=>null),A.serviceLog().catch(()=>null)]);e&&this.take(e),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,o)=>o.ts-e.ts)}matches(e,o){return o==="all"?!0:o==="problems"?dn(e):o==="system"?!!e.sys:!!e.ev&&Bt(e.ev.type)===o}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,Rs.map(o=>t("button",{type:"button",role:"tab",class:o===this.kind?"on":"","aria-selected":o===this.kind?"true":"false",click:()=>this.show(o)},[o==="all"?"All":o==="system"?"System":pt[o],t("b",{},String(e.filter(r=>this.matches(r,o)).length))])))}show(e){this.kind=e,this.shown=Rn,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let o=[],r="",a=null;for(let i of e.slice(0,this.shown)){let s=Wr(i.ts);s!==r&&(r=s,a=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},s))),o.push(a));let l=new Date(i.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(i.sys){let c=`${i.sys.ts}|${i.sys.msg}`;a.appendChild(Mn(i.sys,this.open.has(c),()=>{this.open.delete(c)||this.open.add(c),this.paint()},l))}else a.appendChild(it(this.st,i.ev,{time:l}))}e.length>this.shown&&o.push(t("div",{class:"dl-more-row"},H(`Show ${Math.min(Rn,e.length-this.shown)} more of ${e.length-this.shown}`,()=>{this.shown+=Rn,this.paint()}))),dom.content(this.list,o)}};var Is=[["health","Health"],["log","Log"]],yo=2e4,Bn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([A.status(1),A.events(yo),A.serviceLog()])}render([e,o,r]){return this.log=new In(e,o,r.log),this.health=new Nn(e,r,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),ot({fetch:async()=>{let a=this.tab==="log",[i,s]=await Promise.all([A.serviceLog().catch(()=>null),a?A.events(yo).catch(()=>null):Promise.resolve(null)]);return i||s?{n:i,e:s}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:a,e:i})=>this.take(a,i)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,o){o&&(this.log.take(o),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,Is.map(([o,r])=>t("button",{type:"button",role:"tab",class:o===e?"on":"","aria-selected":o===e?"true":"false",click:()=>o!==this.tab&&this.show(o)},r))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&A.events(yo).then(o=>this.take(null,o)).catch(()=>null)):this.health.checks||this.health.run()}};var Da=":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-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.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}";var Aa='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.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-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}.dl-people-find{width:160px;min-width:0}.dl-people-find[hidden]{display:none}';var Ha="#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-warn{color:var(--dl-warn)}.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)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@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}";var za=".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)}";var Na=".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:-6.5px;bottom:-6.5px;width:20px;height:20px;border-radius:8.5px;border:1.5px solid transparent;background: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:hover .dl-onl-dev{background:linear-gradient(var(--dl-soft),var(--dl-soft)),var(--dl-card)}.dl-onl-p.sm:hover{background:none}.dl-onl-p.sm:hover .dl-onl-dev{background:var(--dl-card)}.dl-onl-p.sm .dl-onl-av{transition:box-shadow .15s ease}.dl-onl-p.sm:hover .dl-onl-av{box-shadow:0 0 0 2px var(--dl-ok),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm.more:hover .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line),0 0 0 6px var(--dl-soft)}.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-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.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-speed-val.off{color:var(--dl-fg-faint)}.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-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var Ra='.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-modal .cbi-value.dl-live>.cbi-value-title{display:flex;flex-direction:column;gap:2px;text-align:left}.dl-modal .cbi-value.dl-live>.cbi-value-title>.dl-sub{white-space:normal}.dl-checklist{display:flex;flex-direction:column;gap:6px;margin:4px 0 8px}.dl-checklist label{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer}.dl-checklist input{margin:0}.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}';var Ia=".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}";var Ba=".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)}";var Oa=".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)}";var ja=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.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.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.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;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-badge:has(>svg:only-child){width:16px;min-width:0;padding:0}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged,.dl-mk.piled{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*,.dl-mk.piled>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host{transition:border-radius .22s ease,border-right-color .22s ease}.dl-mk-host.docked{border-top-right-radius:0;border-bottom-right-radius:0;border-right-color:transparent}.dl-mk-dock{position:absolute;left:100%;top:-1px;height:40px;box-sizing:border-box;display:flex;align-items:center;gap:6px;padding:0 10px 0 2px;border:1px solid var(--dl-line);border-left:0;border-radius:0 11px 11px 0;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;pointer-events:none;opacity:0;clip-path:inset(-24px 100% -24px 0);transition:clip-path .28s cubic-bezier(.2,.8,.2,1),opacity .2s ease}.dl-mk-host.docked .dl-mk-dock{pointer-events:auto;opacity:1;clip-path:inset(-24px -24px -24px 0)}.dl-mk-new .dl-mk-host,.dl-mk-new .dl-mk-dock{transition:none}.dl-mk-pile{position:relative;display:flex;justify-content:center}.dl-mk-pile-box{box-sizing:border-box;height:40px;display:flex;align-items:center;gap:6px;padding:0 10px 0 6px;border-radius:20px;cursor:zoom-in;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;animation:dl-plate-in .26s cubic-bezier(.2,.8,.2,1) both;transition:opacity .18s ease,transform .18s ease}.dl-mk-pile.out{pointer-events:none}.dl-mk-pile.out>*{opacity:0;transform:scale(.85);transition:opacity .18s ease,transform .18s ease}@keyframes dl-plate-in{0%{opacity:0;transform:scale(.85)}}.dl-mk-face{all:unset;position:relative;display:flex;cursor:pointer;transition:transform .18s ease,opacity .18s ease}.dl-mk-face>.dl-mk-badge{position:relative;left:auto;bottom:-8px;margin-left:-12px;align-self:center}.dl-mk-face.on .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-face.on .dl-mk-badge{background:#3b82f6}.dl-mk-face:hover .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-face.in{animation:dl-dock-in .24s cubic-bezier(.2,.8,.2,1) both}.dl-mk-face.out{transform:scale(.4);opacity:0;pointer-events:none}@keyframes dl-dock-in{0%{transform:scale(.4);opacity:0}}.dl-mk-more{font-size:11px;font-weight:600;color:var(--dl-fg-muted)}.dl-mk-av,.dl-mk-tile{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1)}.dl-mk.merged .dl-mk-av,.dl-mk.merged .dl-mk-tile,.dl-mk.piled .dl-mk-av{transform:scale(.5)}.dl-mk-host,.dl-mk-dock,.dl-mk-pile-box{transition-property:border-radius,border-right-color,clip-path,opacity,height,width,padding,gap}.dl-mk-dock,.dl-mk-pile-box{transition-duration:.22s;transition-timing-function:cubic-bezier(.2,.8,.2,1)}.dl-mk-pile-box{position:relative}.dl-mk-more{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease}.dl-mk-more.in{animation:dl-dock-in .24s ease both}.dl-mk-more.out{transform:scale(.4);opacity:0}.dl-mk-face .dl-mk-av{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1),width .2s ease,height .2s ease,font-size .2s ease}.dl-mk-face{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,margin .2s ease}.dl-mk-face>.dl-mk-badge{max-width:48px;overflow:hidden;transition:opacity .2s ease,transform .2s ease,max-width .22s ease,margin .22s ease,padding .22s ease,border-width .22s ease,height .22s ease,min-width .22s ease,width .22s ease,bottom .22s ease}.dl-lod-far .dl-mk-host{width:32px;height:32px;border-radius:9px}.dl-lod-far .dl-mk-host.docked{border-radius:9px 0 0 9px}.dl-lod-far .dl-mk-host-tile{width:20px;height:20px;border-radius:6px}.dl-lod-far .dl-mk-host-ic{width:11px;height:11px}.dl-lod-far .dl-mk-dock{height:32px;gap:0;padding:0 4px 0 0;border-radius:0 9px 9px 0}.dl-lod-far .dl-mk-pile-box{height:32px;gap:0;padding:0 4px;border-radius:16px}.dl-lod-far .dl-mk-face+.dl-mk-face{margin-left:-6px}.dl-lod-far .dl-mk-face .dl-mk-av{width:22px;height:22px;font-size:8px;box-shadow:0 0 0 2px var(--dl-elevated)}.dl-lod-far .dl-mk-face>.dl-mk-badge{max-width:0;min-width:0;padding:0;margin-left:0;border-width:0;opacity:0;transform:scale(.5);pointer-events:none}.dl-lod-far .dl-mk-more{margin-left:4px;font-size:10px}.dl-mk-label{transition:opacity .2s ease}.dl-lod-far .dl-mk-label{opacity:0}.dl-lod-mid .dl-mk-host{width:36px;height:36px}.dl-lod-mid .dl-mk-dock,.dl-lod-mid .dl-mk-pile-box{height:36px}.dl-lod-mid .dl-mk-face .dl-mk-av{width:24px;height:24px;font-size:9px}.dl-lod-mid .dl-mk-face>.dl-mk-badge{height:12px;min-width:12px;margin-left:-10px;bottom:-7px}.dl-lod-mid .dl-mk-face>.dl-mk-badge:has(>svg:only-child){width:12px}.dl-lod-mid .dl-mk-face>.dl-mk-badge .dl-mk-badge-ic{width:8px;height:8px}@media(prefers-reduced-motion:reduce){.dl-mk-dock,.dl-mk-pile-box,.dl-mk-face,.dl-mk-av,.dl-mk-tile,.dl-mk-host,.dl-mk-face>.dl-mk-badge{transition:none;animation:none}}.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host{cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.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-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 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.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}.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}`;var Ua=`.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-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-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)}@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}`;var Wa=".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}";var Ga=".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>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.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-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.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-bad{color:var(--dl-bad)}";var Fa=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var qa=".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)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var el=[Da,Aa,Ha,za,Na,Ra,Ia,Ba,Oa,ja,Ua,Wa,Ga,Fa,qa].join(` +`);function Ka(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=el,n}function mt(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async r=>{let a=await e.render(r),i=document.createElement("div");return i.className="dl-root",i.append(Ka(),a),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var Iv=mt(Yt),Bv=mt(ut),Ov=mt(Yt),jv=mt(Dn),Uv=mt(zn),Wv=mt(Bn),Gv=mt(Hn);function Ja(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var Fv=Ja(""),qv=Ja("log");return baseclass.extend({ activity: qv, diagnostics: Wv, health: Fv, overview: Iv, people: Bv, person: Uv, server: Ov, settings: jv, updates: Gv }); diff --git a/package/luci-app-dawnline/root/usr/bin/dawnline b/package/luci-app-dawnline/root/usr/bin/dawnline index 24bdcfd..a6529cc 100755 --- a/package/luci-app-dawnline/root/usr/bin/dawnline +++ b/package/luci-app-dawnline/root/usr/bin/dawnline @@ -12,11 +12,31 @@ import * as pc from 'dawnline.portalcert'; import * as watchdog from 'dawnline.watchdog'; import * as awg from 'dawnline.awg'; import * as store from 'dawnline.store'; +import * as devices from 'dawnline.devices'; import { - VERSION, slog, sh_out, q, take_iface_intent, read_json, write_json, ensure_dir, with_lock, RUN_DIR + VERSION, slog, slog_read, sh_out, q, take_iface_intent, read_json, write_json, ensure_dir, with_lock, RUN_DIR } from 'dawnline.util'; -const args = ARGV; +/** Options that take no value. */ +const FLAGS = [ 'json', 'yes', 'conf' ]; + +// Options (--name value, or a bare --flag) can go anywhere; what is left are the words. +const opts = {}; +const args = []; +for (let i = 0; i < length(ARGV); i++) { + let a = ARGV[i]; + if (a == '-n') + a = '--n'; + if (substr(a, 0, 2) == '--') { + let name = substr(a, 2); + if (index(FLAGS, name) >= 0) + opts[name] = true; + else + opts[name] = ARGV[++i] ?? ''; + } + else + push(args, a); +} const cmd = args[0] ?? 'help'; function out(v) { @@ -24,10 +44,41 @@ function out(v) { } function opt(name, dflt) { - for (let i = 1; i < length(args); i++) - if (args[i] == `--${name}`) - return args[i + 1]; - return dflt; + return opts[name] ?? dflt; +} + +/** Fixed-width columns: a header, then one line per row. */ +function table(cols, rows) { + let w = map(cols, (c) => length(c)); + for (let r in rows) + for (let i, v in r) + w[i] = max(w[i], length(`${v}`)); + let line = (r) => rtrim(join(' ', map(r, (v, i) => sprintf(`%-${w[i]}s`, `${v}`)))); + out(line(cols)); + for (let r in rows) + out(line(r)); +} + +/** `--since 30m|2h|3d|YYYY-MM-DD` as a time, or null. */ +function since_time(s) { + if (!s) + return null; + let m = match(s, /^([0-9]+)([mhd])$/); + if (m) + return time() - +m[1] * { m: 60, h: 3600, d: 86400 }[m[2]]; + m = match(s, /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/); + if (m) + return timelocal({ year: +m[1], mon: +m[2], mday: +m[3], hour: 0, min: 0, sec: 0 }); + die('--since takes 30m, 2h, 3d or a date like 2026-10-18.'); +} + +/** "5m", "3h", "2d": how long ago, for the lists. */ +function ago(secs) { + return secs < 3600 ? `${int(secs / 60)}m` : secs < 86400 ? `${int(secs / 3600)}h` : `${int(secs / 86400)}d`; +} + +function the_person(m, slug) { + return m.people[slug ?? ''] ?? die(slug ? `Unknown person: ${slug}.` : 'Which person? Give their id (dawnline person ls).'); } function help() { @@ -39,19 +90,24 @@ Usage: dawnline sync Push devices and access rules to the tunnels status People and devices with live state (JSON) health Run health checks (JSON) + person ls [--json] Everyone: id, name, access, state, devices, last seen person add [--slug s] [--access lan|internet|both] [--devices n] - [--expires YYYY-MM-DD] [--quota GB] - person link Print the personal portal link - person rm Remove a person and their devices - device add [--kind phone|computer|tablet|router] + [--expires YYYY-MM-DD] [--quota GB] [--server id] + person link Print the personal portal link + person rm [--yes] Remove a person and their devices (--yes when they have any) + device ls [person] [--json] + device add [--kind phone|computer|tablet|router] [--conf] device conf Print a device configuration (.conf) device rm Remove a device backup Create a backup in /etc/dawnline/backups portal-cert Print the certificate and key the portal uses portal-http-port Print the plain-HTTP port when an IP is among the portal addresses - log Service log: tunnel and service starts, stops, repairs (newest first) + log [-n N] [--since 2h|3d|date] [--level error|down|repair|up|info] [--src awg|dawnline|portal] [--json] + Service log: tunnel and service starts, stops, repairs (newest first) teardown Remove everything Dawnline created on the router - version`); + version + +Exit codes: 0 done, 1 refused or failed, 2 unknown command. health exits 1 when a check fails.`); } /* @@ -106,40 +162,100 @@ try { let m = core.load(), u = core.load_usage(), d = live.dump(m), st = view.states(m, u); out(map(values(m.people), (p) => view.person_view(m, p, u, d, st, { admin: true }))); } - else if (cmd == 'health') - out(health.health()); + else if (cmd == 'health') { + let checks = health.health(); + out(checks); + if (length(filter(checks, (c) => c.status == 'error'))) + exit(1); + } + else if (cmd == 'person' && args[1] == 'ls') { + let m = core.load(), u = core.load_usage(), d = live.dump(m), st = view.states(m, u); + let people = sort(map(values(m.people), (p) => view.person_view(m, p, u, d, st, { admin: true })), (a, b) => a.name < b.name ? -1 : 1); + if (opts.json) + out(people); + else + table([ 'ID', 'NAME', 'SERVER', 'ACCESS', 'STATE', 'DEVICES', 'LAST SEEN' ], map(people, (p) => [ + p.id, p.name, p.server, p.access, p.state, `${length(p.devices)}${p.online ? ` (${p.online} online)` : ''}`, + p.online ? 'now' : p.last_seen ? ago(time() - p.last_seen) + ' ago' : 'never', + ])); + } else if (cmd == 'person' && args[1] == 'add') { let id = store.transact((c, m) => core.create_person(c, m, { - name: args[2], slug: opt('slug'), access: opt('access', 'internet'), + name: args[2], slug: opt('slug'), access: opt('access', 'internet'), server: opt('server'), device_limit: opt('devices'), expires: opt('expires'), quota_gb: opt('quota'), })); let m2 = core.load(); - out(core.portal_url(m2, m2.people[id]) ?? id); + live.add_event({ type: 'person_added', person: id, detail: m2.people[id].name, by: 'admin' }); + out(`Added ${m2.people[id].name} (${id})`); + out(core.portal_url(m2, m2.people[id]) ?? 'No personal link: the portal is off.'); } else if (cmd == 'person' && args[1] == 'link') { let m = core.load(); - let p = m.people[args[2]] ?? die('Unknown person.'); - out(core.portal_url(m, p) ?? 'Set settings.portal_host first.'); + let p = the_person(m, args[2]); + out(core.portal_url(m, p) ?? 'No personal link: the portal is off.'); } else if (cmd == 'person' && args[1] == 'rm') { - store.transact((c, m) => core.delete_person(c, m, args[2])); - apply.sync(); + let m = core.load(); + let p = the_person(m, args[2]); + let n = length(p.devices); + if (n && !opts.yes) + die(`${p.name} has ${n} device${n == 1 ? '' : 's'}: add --yes to remove them too.`); + store.transact((c, m) => core.delete_person(c, m, p.id)); + live.add_event({ type: 'person_removed', person: p.id, detail: p.name, pname: p.name, by: 'admin' }); + let s = apply.sync(); + out(`Removed ${p.name}${n ? ` and ${n} device${n == 1 ? '' : 's'}` : ''}.`); + if (s.warning) + warn(`dawnline: ${s.warning}\n`); + } + else if (cmd == 'device' && args[1] == 'ls') { + let m = core.load(), d = live.dump(m); + let who = args[2] ? the_person(m, args[2]) : null; + let rows = []; + for (let id, dev in m.devices) { + let p = m.people[dev.person]; + if (!p || (who && p.id != who.id)) + continue; + let peer = d.peers[dev.public_key]; + let online = live.online(d, id, peer); + push(rows, { id, person: p.id, name: dev.name, kind: dev.kind, address: dev.address, disabled: dev.disabled, + online, handshake: +(peer?.handshake ?? 0) }); + } + rows = sort(rows, (a, b) => (a.person < b.person ? -1 : a.person > b.person ? 1 : 0) || (a.name < b.name ? -1 : 1)); + if (opts.json) + out(rows); + else + table([ 'ID', 'PERSON', 'NAME', 'KIND', 'ADDRESS', 'STATE' ], map(rows, (r) => [ + r.id, r.person, r.name, r.kind, r.address, + r.disabled ? 'off' : r.online ? 'online' : r.handshake ? `seen ${ago(time() - r.handshake)} ago` : 'never connected', + ])); } else if (cmd == 'device' && args[1] == 'add') { - // Keys first: generating them runs the awg tool, not worth holding the config lock for. - let keys = awg.new_keys(); - let id = store.transact((c, m) => core.create_device(c, m, args[2], args[3], opt('kind', 'phone'), { by: 'admin', keys })); - apply.sync(); - out(id); + // Through the same door as LuCI and the portal: event, "issued" marker, capability check. + let m = core.load(); + let p = the_person(m, args[2]); + if (!args[3]) + die('Which name? dawnline device add .'); + let r = devices.add(p.id, args[3], opt('kind', 'phone'), { by: 'admin' }); + if (opts.conf) + print(r.config.conf); + else + out(`${r.id} (dawnline device conf ${r.id} prints its configuration)`); + if (r.warning) + warn(`dawnline: ${r.warning}\n`); } else if (cmd == 'device' && args[1] == 'conf') { let m = core.load(); - let d = m.devices[args[2]] ?? die('Unknown device.'); + let d = m.devices[args[2] ?? ''] ?? die('Unknown device.'); + awg.mark_issued(m, d.id); print(awg.client_config(m, d).conf); } else if (cmd == 'device' && args[1] == 'rm') { - store.transact((c, m) => core.delete_device(c, m, args[2])); - apply.sync(); + let m = core.load(); + let d = m.devices[args[2] ?? ''] ?? die('Unknown device.'); + let r = devices.remove(d.id, { by: 'admin' }); + out(`Removed ${d.name} (${m.people[d.person]?.name ?? d.person}).`); + if (r.warning) + warn(`dawnline: ${r.warning}\n`); } else if (cmd == 'backup') out(backup.backup_create(opt('reason'))); @@ -153,7 +269,22 @@ try { out(`${core.portal_http_port(m)}`); } else if (cmd == 'log') { - for (let e in watchdog.view(core.load()).log) { + let n = +opt('n', 0) || 0; + let since = since_time(opt('since')); + let level = opt('level'), src = opt('src'); + if (level && index([ 'info', 'up', 'down', 'repair', 'error' ], level) < 0) + die('--level takes error, down, repair, up or info.'); + if (src && index([ 'awg', 'dawnline', 'portal' ], src) < 0) + die('--src takes awg, dawnline or portal.'); + let log = filter(slog_read(n && !since && !level && !src ? n : null), + (e) => (!since || e.ts >= since) && (!level || e.level == level) && (!src || e.src == src)); + if (n && length(log) > n) + log = slice(log, 0, n); + if (opts.json) { + out(log); + exit(0); + } + for (let e in log) { let t = localtime(e.ts); let text = e.by == 'admin' ? join(' ', filter([ 'You', e.msg, e.kind, e.who, e.note ? '· ' + e.note : null ], (x) => x)) @@ -197,8 +328,12 @@ try { apply.teardown(); else if (cmd == 'version') out(VERSION); - else + else if (cmd == 'help' || cmd == '--help' || cmd == '-h') help(); + else { + warn(`dawnline: unknown command "${join(' ', slice(args, 0, 2))}" (dawnline help)\n`); + exit(2); + } } catch (e) { warn(`dawnline: ${e.message}\n`); diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent index 067216e..7f4bb2a 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent @@ -13,7 +13,7 @@ import * as uloop from 'uloop'; import { open, readfile, writefile, stat, unlink } from 'fs'; import { - read_json, write_json, ensure_dir, sh_out, q, uniq, slog, slog_trim, slog_restore, DATA_DIR, RUN_DIR, VERSION + read_json, write_json, ensure_dir, sh_out, q, uniq, slog, slog_trim, slog_restore, date_end, DATA_DIR, RUN_DIR, VERSION } from 'dawnline.util'; import * as core from 'dawnline.core'; import * as live from 'dawnline.live'; @@ -306,6 +306,33 @@ function note(k, v) { write_json(NOTES, notes, 0o600); } +/* + * End dates in the activity log: a heads-up once per end date when its + * warning window opens, and "keep access" passing it (which changes no + * state, so nothing else would say it). Not on a clock that is not set. + */ +function check_expiry(m, events) { + let ts = time(); + if (localtime(ts).year < 2025) + return; + for (let id, p in m.people) { + if (!p.expires) + continue; + let end = date_end(p.expires); + if (end == null) + continue; + let left = end > ts ? int((end - ts) / 86400) + 1 : 0; + if (left > 0 && p.expire_warn > 0 && left <= p.expire_warn && notes[`warned:${id}`] != p.expires) { + note(`warned:${id}`, p.expires); + push(events, { type: 'expiring', person: id, detail: `${left} day${left == 1 ? '' : 's'}` }); + } + if (left == 0 && p.expire_action == 'notify' && notes[`kept:${id}`] != p.expires) { + note(`kept:${id}`, p.expires); + push(events, { type: 'expired_kept', person: id, detail: p.expires }); + } + } +} + /** "Jan 1 2027" from the certificate, or null. */ function cert_end(path) { let m = match(sh_out(`openssl x509 -enddate -noout -in ${q(path)} 2>/dev/null`) ?? '', /notAfter=([A-Za-z]+) +([0-9]+) [0-9:]+ ([0-9]+)/); @@ -464,6 +491,7 @@ const STEPS = [ { who: 'People', run: (t) => { t.states = apply.states_for(t.m, usage); check_people(t.m, t.states, t.events); + check_expiry(t.m, t.events); } }, { who: 'Access rules', run: (t) => { if (t.states) diff --git a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css index fd0ae0a..42e976f 100644 --- a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css +++ b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css @@ -1 +1 @@ -@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{--bg: #fcfcfc;--card: #ffffff;--elevated: #ffffff;--text: #0d0d0d;--muted: #5d5d5d;--faint: #8f8f8f;--line: #0000001a;--input: #00000026;--soft: #0d0d0d0d;--soft-hover: #0d0d0d1a;--primary: #0d0d0d;--primary-fg: #ffffff;--accent: #3a83f7;--info: #2c67c5;--ok: #00a240;--ok-wash: #00a24026;--warn: #e25507;--warn-wash: #e2550726;--bad: #e02e2a;--bad-wash: #e02e2a1f;--chart: #3a83f7;--track: #0d0d0d1a;--scrim: #00000040;--shadow: 0 1px 2px -1px #00000014;--shadow-xl: 0 8px 16px -4px #0000001f;--radius: 16px;--mono: "Geist Mono", ui-monospace, Menlo, monospace;color-scheme:light dark}@media(prefers-color-scheme:dark){:root{--bg: #000000;--card: #0a0a0a;--elevated: #131313;--text: #ededed;--muted: #edededa6;--faint: #ededed78;--line: #ededed13;--input: #ededed24;--soft: #ededed0d;--soft-hover: #ededed1a;--primary: #ededed;--primary-fg: #131313;--accent: #006efe;--info: #5ba2fe;--ok: #40c977;--ok-wash: #40c97726;--warn: #ff8549;--warn-wash: #ff854926;--bad: #ff6764;--bad-wash: #ff676422;--chart: #3a83f7;--track: #ededed1a;--scrim: #00000099;--shadow: none;--shadow-xl: 0 8px 16px -4px #00000080}}*{box-sizing:border-box}html,body{margin:0}body{background:var(--bg);color:var(--text);font:400 15px/22px Geist,-apple-system,system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh}body.locked{overflow:hidden}a{color:var(--info);text-decoration:none}a:hover{text-decoration:underline}h1,h2{margin:0;font-weight:500;letter-spacing:-.01em}h1{font-size:24px;line-height:32px}h2{font-size:16px;line-height:24px}.muted{color:var(--muted)}.faint{color:var(--faint)}.s{font-size:13px;line-height:18px}.ok{color:var(--ok)}.warn{color:var(--warn)}.strong{font-weight:500}.center{text-align:center}.mono{font-family:var(--mono);font-size:12px}.stack{display:flex;flex-direction:column;gap:2px;min-width:0}.stack.gap{gap:10px}.grow{flex:1}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.row.gap{gap:8px;flex-wrap:nowrap}.row-baseline{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.offscreen{position:fixed;left:-9999px;opacity:0}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:max(12px,env(safe-area-inset-top)) 16px 12px;border-bottom:1px solid var(--line);position:sticky;top:0;background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:saturate(180%) blur(12px);z-index:5}.brand{display:flex;align-items:center;gap:8px;font-weight:500;min-width:0}.brand .faint{font-weight:400}.logo{display:inline-flex;width:22px;height:22px;color:var(--text)}.logo svg{width:100%;height:100%}.wrap{width:100%;max-width:1048px;margin:0 auto;padding:20px 16px max(32px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:20px}.hello{display:flex;align-items:center;gap:12px}.avatar{width:44px;height:44px;border-radius:50%;background:var(--soft-hover);display:inline-flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;position:relative;flex:0 0 auto}.avatar.online:after{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px var(--bg)}.notice{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:12px;background:var(--warn-wash);font-size:14px}.notice.bad{background:var(--bad-wash)}.notice .ic{color:var(--warn)}.notice.bad .ic{color:var(--bad)}.alert{display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--line);border-radius:12px;background:var(--card);font-size:14px;line-height:20px}.alert-ic{width:30px;height:30px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:var(--warn-wash);color:var(--warn)}.alert-ic.bad{background:var(--bad-wash);color:var(--bad)}.alert-ic .ic-svg{width:15px;height:15px}.layout{display:grid;grid-template-columns:minmax(0,1fr);gap:20px;grid-template-areas:"access" "devices"}.access{grid-area:access}.devices{grid-area:devices;display:flex;flex-direction:column;gap:12px;min-width:0}.desktop-only{display:none!important}@media(min-width:960px){.top{padding-left:max(16px,calc((100vw - 1048px)/2 + 16px));padding-right:max(16px,calc((100vw - 1048px)/2 + 16px))}.layout{grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);grid-template-areas:"devices access";align-items:start;gap:16px}.desktop-only{display:inline-flex!important}.wrap{padding-top:28px}}.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow);min-width:0}.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.access{display:flex;flex-direction:column;gap:12px;min-width:0}.access-card{display:flex;flex-direction:column;gap:12px}.reach{display:flex;align-items:center;gap:12px;padding:12px;border-radius:12px;background:var(--soft)}.reach-ic{width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.tile{border:1px solid var(--line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:8px;min-width:0}.tiles2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.tile-label{display:flex;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--faint)}.tile-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.tile-value.sm{font-size:16px}.tile-value .faint{font-size:14px;font-weight:400}.meter{position:relative;height:6px;border-radius:999px;background:var(--track);cursor:default}.meter i{display:block;height:100%;border-radius:999px;background:var(--accent)}.meter.warn i{background:var(--warn)}.meter.bad i{background:var(--bad)}.slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.slots i{display:block;height:4px;border-radius:999px;background:var(--track)}.slots i.used{background:var(--text)}.slots i.over{background:color-mix(in srgb,var(--warn) 80%,transparent)}.dgrid{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}@media(min-width:640px){.dgrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}}.dgrid>.slot.add:only-child{grid-column:1 / -1}.dcard{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--shadow)}.dcard.online{border-color:color-mix(in srgb,var(--ok) 35%,transparent)}.dcard.off{opacity:.7}.dhead{display:flex;align-items:center;gap:12px}.dic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.dic .ic-svg{width:20px;height:20px}.dcard.online .dic{background:var(--ok-wash);color:var(--ok)}.dcard.here{border:1.5px dotted color-mix(in srgb,var(--accent) 80%,transparent)}.dcard.here .dic{background:color-mix(in srgb,var(--accent) 16%,transparent);color:var(--info)}.dstat.here{color:var(--info)}.dot.here{background:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 22%,transparent)}.dname{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dstat{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--muted)}.dstat.ok{color:var(--ok)}.dstat.warn{color:var(--warn)}.dot{width:6px;height:6px;border-radius:50%;background:var(--faint);display:inline-block;flex:0 0 auto}.dot.ok{background:var(--ok);box-shadow:0 0 0 3px var(--ok-wash)}.dot.warn{background:var(--warn)}.dot.pulse{animation:pulse 1.6s ease-in-out infinite}@keyframes pulse{0%,to{box-shadow:0 0 0 0 var(--warn-wash)}50%{box-shadow:0 0 0 6px transparent}}.duse{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.spark{display:flex;align-items:flex-end;gap:3px;height:26px;width:128px}.spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--chart);opacity:.85;cursor:default}.spark i.zero{opacity:.22}.spark i:hover{opacity:1;filter:brightness(1.2)}.names{display:flex;flex-direction:column;gap:10px;padding:12px;border-radius:12px;border:1px solid var(--line)}.names-head{display:flex;gap:10px;align-items:flex-start}.names-ic{width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.names-ic .ic-svg{width:15px;height:15px}.names-list{display:flex;flex-wrap:wrap;gap:6px}.name-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;height:28px;max-width:100%;padding:0 9px 0 10px;border-radius:999px;background:var(--soft)}.name-chip:hover{background:var(--soft-hover)}.name-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.name-chip .mono{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.name-chip .ic-svg{width:13px;height:13px;color:var(--faint)}.slot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:14px;padding:16px;min-height:72px;border:1px dashed var(--input);border-radius:var(--radius);color:var(--text);text-align:left;transition:background .15s,border-color .15s}.slot.add:hover{background:var(--soft);border-color:color-mix(in srgb,var(--text) 30%,transparent)}.slot-ic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.slot.add:hover .slot-ic{background:var(--primary);color:var(--primary-fg)}.slot.add:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(min-width:960px){.slot.add{flex-direction:column;justify-content:center;gap:10px;min-height:140px;text-align:center;color:var(--muted)}.slot.add .stack{align-items:center}.slot.add .strong{color:var(--text)}.slot.add .slot-ic{border-radius:999px;width:36px;height:36px}}.ic{display:inline-flex;line-height:0}.ic-svg{width:16px;height:16px}.btn{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 16px;border-radius:999px;font-size:14px;font-weight:500;background:var(--soft);color:var(--text);-webkit-tap-highlight-color:transparent;white-space:nowrap}.btn:hover{background:var(--soft-hover)}.btn.primary{background:var(--primary);color:var(--primary-fg)}.btn.primary:hover{opacity:.9}.btn.danger-solid{background:var(--bad);color:#fff}.btn.small{height:32px;padding:0 12px;font-size:13px}.btn.big{height:48px;font-size:15px}.btn.block{display:flex;width:100%}.btn[disabled]{opacity:.45;cursor:not-allowed}.btn:focus-visible,.kind:focus-visible,.icon-btn:focus-visible,.slot:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.icon-btn{all:unset;cursor:pointer;width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;color:var(--muted);flex:0 0 auto}.icon-btn:hover{background:var(--soft);color:var(--text)}.icon-btn.soft{background:var(--soft)}@media(pointer:coarse){.icon-btn{width:40px;height:40px}}input[type=text]{width:100%;font:inherit;color:var(--text);background:var(--card);border:1px solid var(--input);border-radius:10px;padding:0 12px;height:44px}input[type=text]:focus{outline:2px solid color-mix(in srgb,var(--accent) 60%,transparent);outline-offset:0;border-color:transparent}.lbl{display:block;font-size:13px;font-weight:500;color:var(--muted);margin:14px 2px 6px}.err{color:var(--bad);min-height:1.2em;margin:8px 2px;font-size:14px}.kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.kind{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;min-width:0;border-radius:12px;box-shadow:inset 0 0 0 1px var(--line);color:var(--muted);font-size:12.5px;font-weight:500;text-align:center}.kind .ic-svg{width:20px;height:20px}.kind:hover{color:var(--text);background:color-mix(in srgb,var(--text) 4%,transparent)}.kind.on{box-shadow:inset 0 0 0 1.5px var(--accent);color:var(--text);background:color-mix(in srgb,var(--accent) 10%,transparent)}.kind.on .ic{color:var(--accent)}.signin{text-align:center;max-width:420px;margin:8vh auto 0;width:100%;padding:28px 20px;display:flex;flex-direction:column;gap:10px}.hero-ic{width:52px;height:52px;margin:0 auto 6px;border-radius:16px;display:grid;place-items:center;background:var(--primary);color:var(--primary-fg)}.hero-ic .ic-svg{width:24px;height:24px}.signin input{text-align:center;margin-top:8px}.menu{position:absolute;z-index:30;width:230px;padding:4px;border-radius:14px;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl)}.menu-item{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;width:100%;height:40px;padding:0 12px;border-radius:10px;font-size:14px}.menu-item:hover,.menu-item:focus-visible{background:var(--soft-hover)}.menu-item .ic{color:var(--muted)}.menu-item.danger,.menu-item.danger .ic{color:var(--bad)}.menu-sep{height:1px;background:var(--line);margin:4px 8px}@media(pointer:coarse){.menu-item{height:44px}}.sheet{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-end;justify-content:center;background:transparent;transition:background .2s}.sheet.open{background:var(--scrim)}.sheet-panel{width:100%;max-width:520px;max-height:92vh;max-height:92dvh;overflow:auto;background:var(--elevated);border-radius:20px 20px 0 0;border:1px solid var(--line);border-bottom:0;padding:6px 16px max(20px,env(safe-area-inset-bottom));transform:translateY(100%);transition:transform .25s cubic-bezier(.2,.8,.2,1)}.sheet.open .sheet-panel{transform:none}.grab{width:36px;height:4px;border-radius:999px;background:var(--input);margin:4px auto 8px}.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;padding:4px 0 12px}.sheet-head h2{font-size:20px;line-height:28px;font-weight:600}.sheet-body{display:flex;flex-direction:column;gap:14px}@media(min-width:640px){.sheet{align-items:center}.sheet-panel{border-radius:16px;border-bottom:1px solid var(--line);padding:20px;max-width:480px;transform:scale(.97);opacity:0;transition:transform .18s ease,opacity .18s ease}.sheet.open .sheet-panel{transform:none;opacity:1}.grab{display:none}}.tabs{display:flex;gap:4px;padding:4px;background:var(--soft);border-radius:999px}.tabs button{all:unset;cursor:pointer;flex:1 1 auto;white-space:nowrap;text-align:center;padding:7px 10px;border-radius:999px;font-weight:500;font-size:13px;color:var(--muted)}.tabs button.on{background:var(--soft-hover);color:var(--text)}.pane{display:flex;flex-direction:column;gap:10px}.pane.center{align-items:center;text-align:center}.qr{width:min(240px,70vw);aspect-ratio:1;background:#fff;border-radius:12px;padding:10px;box-shadow:inset 0 0 0 1px var(--line)}.qr svg{display:block;width:100%;height:100%}.steps{margin:4px 0 0;padding:14px 16px 14px 34px;border-radius:14px;border:1px solid var(--line);background:var(--card);display:flex;flex-direction:column;gap:8px;font-size:14px}.keybox{display:flex;align-items:center;gap:8px;height:44px;padding:0 6px 0 12px;border:1px solid var(--input);border-radius:10px}.keybox .mono{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}.filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--soft);min-width:0}.filecard>.stack{flex:1;min-width:0}.filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--mono);color:var(--muted);background:var(--card);box-shadow:inset 0 0 0 1px var(--line)}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}@media(max-width:480px){.filecard .ellipsis{white-space:normal;overflow-wrap:anywhere}}.confbox{border:1px solid var(--line);border-radius:12px}.confbox>summary{list-style:none;display:flex;align-items:center;gap:8px;padding:8px 10px 8px 12px;color:var(--text)}.confbox>summary::-webkit-details-marker{display:none}.confbox>summary>.ic:first-child{transition:transform .15s;color:var(--muted)}.confbox[open]>summary>.ic:first-child{transform:rotate(90deg)}.confbox .grow{flex:1}.confbox>.conf{margin:0;border-top:1px solid var(--line);border-radius:0 0 12px 12px;background:none}.conf-sec{color:var(--accent, var(--info))}.conf-k{color:var(--faint)}.conf-mask{padding:0 6px;border-radius:4px;background:var(--soft);color:var(--muted)}.conf{white-space:pre-wrap;word-break:break-all;font:12px/18px var(--mono);background:var(--soft);border-radius:10px;padding:12px;max-height:16rem;overflow:auto}details>summary{cursor:pointer;color:var(--muted);font-size:13px;font-weight:500}.waiting{display:flex;align-items:center;gap:10px;padding:12px 14px;border-radius:12px;background:var(--soft);font-size:14px}.tip{position:fixed;z-index:50;transform:translate(-50%,-100%);padding:6px 10px;border-radius:10px;font-size:12px;line-height:17px;white-space:nowrap;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl);pointer-events:none}.tip-title{font-weight:500}.toast{position:fixed;left:50%;bottom:max(20px,env(safe-area-inset-bottom));transform:translate(-50%,20px);opacity:0;z-index:60;background:var(--primary);color:var(--primary-fg);padding:10px 16px;border-radius:999px;font-weight:500;font-size:14px;transition:all .25s;max-width:90vw}.toast.show{opacity:1;transform:translate(-50%)}.toast.bad{background:var(--bad);color:#fff}@media(prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}} +@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{--ease-out: cubic-bezier(.23, 1, .32, 1);--ease-in: cubic-bezier(.55, 0, 1, .45);--ease-drawer: cubic-bezier(.32, .72, 0, 1);--spring: linear( 0, .022, .079, .158, .249, .344, .438, .527, .61, .684, .749, .805, .852, .891, .923, .949, .969, .984, .996, 1.004, 1.009, 1.013, 1.014, 1.015, 1.015, 1.014, 1.013, 1.012, 1.01, 1.009, 1.008, 1.006, 1.005, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1 );--spring-pop: linear( 0, .034, .122, .244, .383, .526, .662, .785, .889, .974, 1.038, 1.083, 1.111, 1.124, 1.126, 1.119, 1.106, 1.09, 1.072, 1.054, 1.038, 1.023, 1.01, 1, .993, .988, .985, .984, .984, .985, .987, .989, .992, .994, .996, .998, .999, 1, 1.001, 1.002, 1 );--dur-press: .12s;--dur-hover: .15s;--dur-pop: .18s;--dur-swap: .26s;--dur-enter: .44s;--dur-sheet: .44s;--dur-exit: .16s;--bg: #fcfcfc;--card: #ffffff;--elevated: #ffffff;--text: #0d0d0d;--muted: #5d5d5d;--faint: #8f8f8f;--line: #0000001a;--input: #00000026;--soft: #0d0d0d0d;--soft-hover: #0d0d0d1a;--primary: #0d0d0d;--primary-fg: #ffffff;--accent: #3a83f7;--info: #2c67c5;--ok: #00a240;--ok-wash: #00a24026;--warn: #e25507;--warn-wash: #e2550726;--bad: #e02e2a;--bad-wash: #e02e2a1f;--chart: #3a83f7;--track: #0d0d0d1a;--scrim: #00000040;--shadow: 0 1px 2px -1px #00000014;--shadow-xl: 0 8px 16px -4px #0000001f;--radius: 16px;--mono: "Geist Mono", ui-monospace, Menlo, monospace;color-scheme:light dark}@media(prefers-color-scheme:dark){:root{--bg: #000000;--card: #0a0a0a;--elevated: #131313;--text: #ededed;--muted: #edededa6;--faint: #ededed78;--line: #ededed13;--input: #ededed24;--soft: #ededed0d;--soft-hover: #ededed1a;--primary: #ededed;--primary-fg: #131313;--accent: #006efe;--info: #5ba2fe;--ok: #40c977;--ok-wash: #40c97726;--warn: #ff8549;--warn-wash: #ff854926;--bad: #ff6764;--bad-wash: #ff676422;--chart: #3a83f7;--track: #ededed1a;--scrim: #00000099;--shadow: none;--shadow-xl: 0 8px 16px -4px #00000080}}*{box-sizing:border-box}html,body{margin:0}html{scrollbar-gutter:stable}body{background:var(--bg);color:var(--text);font:400 15px/22px Geist,-apple-system,system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh;cursor:default}input,textarea,.keybox .mono,.linkrow .mono,.conf{cursor:text}body.locked{overflow:hidden}a{color:var(--info);text-decoration:none}a:hover{text-decoration:underline}a.btn:hover,a.badge:hover{text-decoration:none}h1,h2{margin:0;font-weight:500;letter-spacing:-.01em}h1{font-size:24px;line-height:32px}h2{font-size:16px;line-height:24px}.muted{color:var(--muted)}.faint{color:var(--faint)}.s{font-size:13px;line-height:18px}.ok{color:var(--ok)}.warn{color:var(--warn)}.strong{font-weight:500}.center{text-align:center}.mono{font-family:var(--mono);font-size:12px}.stack{display:flex;flex-direction:column;gap:2px;min-width:0}.stack.gap{gap:10px}.grow{flex:1}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.row.gap{gap:8px;flex-wrap:nowrap}.row-baseline{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.offscreen{position:fixed;left:-9999px;opacity:0}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:max(12px,env(safe-area-inset-top)) 16px 12px;border-bottom:1px solid var(--line);position:sticky;top:0;background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:saturate(180%) blur(12px);z-index:5}.brand{display:flex;align-items:center;gap:8px;font-weight:500;min-width:0}.brand .faint{font-weight:400}.logo{display:inline-flex;width:22px;height:22px;color:var(--text)}.logo svg{width:100%;height:100%}.wrap{width:100%;max-width:1048px;margin:0 auto;padding:20px 16px max(32px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:20px}.hello{display:flex;align-items:center;gap:12px}.avatar{width:44px;height:44px;border-radius:50%;background:var(--soft-hover);display:inline-flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;position:relative;flex:0 0 auto}.avatar.online:after{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px var(--bg)}.notice{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:12px;background:var(--warn-wash);font-size:14px}.notice.bad{background:var(--bad-wash)}.notice .ic{color:var(--warn)}.notice.bad .ic{color:var(--bad)}.alert{display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--line);border-radius:12px;background:var(--card);font-size:14px;line-height:20px}.alert-ic{width:30px;height:30px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:var(--warn-wash);color:var(--warn)}.alert-ic.bad{background:var(--bad-wash);color:var(--bad)}.alert-ic .ic-svg{width:15px;height:15px}.layout{display:grid;grid-template-columns:minmax(0,1fr);gap:20px;grid-template-areas:"access" "devices"}.access{grid-area:access}.devices{grid-area:devices;display:flex;flex-direction:column;gap:12px;min-width:0}.desktop-only{display:none!important}@media(min-width:960px){.top{padding-left:max(16px,calc((100vw - 1048px)/2 + 16px));padding-right:max(16px,calc((100vw - 1048px)/2 + 16px))}.layout{grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);grid-template-areas:"devices access";align-items:start;gap:16px}.desktop-only{display:inline-flex!important}.wrap{padding-top:28px}}.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow);min-width:0}.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.access{display:flex;flex-direction:column;gap:12px;min-width:0}.access-card{display:flex;flex-direction:column;gap:12px}.reach{display:flex;align-items:center;gap:12px;padding:12px;border-radius:12px;background:var(--soft)}.reach-ic{width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.tile{border:1px solid var(--line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:8px;min-width:0}.tiles2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.tile-label{display:flex;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--faint)}.tile-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.tile-value.sm{font-size:16px}.tile-value .faint{font-size:14px;font-weight:400}.meter{position:relative;height:6px;border-radius:999px;background:var(--track);cursor:default}.meter i{display:block;height:100%;border-radius:999px;background:var(--accent)}.meter.warn i{background:var(--warn)}.meter.bad i{background:var(--bad)}.slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.slots i{display:block;height:4px;border-radius:999px;background:var(--track)}.slots i.used{background:var(--text)}.slots i.over{background:color-mix(in srgb,var(--warn) 80%,transparent)}.dgrid{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}@media(min-width:640px){.dgrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}}.dgrid>.slot.add:only-child{grid-column:1 / -1}.dcard{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--shadow)}.dcard.online{border-color:color-mix(in srgb,var(--ok) 35%,transparent)}.dcard.off{opacity:.7}.dhead{display:flex;align-items:center;gap:12px}.dic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.dic .ic-svg{width:20px;height:20px}.dcard.online .dic{background:var(--ok-wash);color:var(--ok)}.dcard.here{border:1.5px dotted color-mix(in srgb,var(--accent) 80%,transparent)}.dcard.here .dic{background:color-mix(in srgb,var(--accent) 16%,transparent);color:var(--info)}.dstat.here{color:var(--info)}.dname{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dstat{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--muted)}.dstat.ok{color:var(--ok)}.dstat.warn{color:var(--warn)}.duse{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.spark{display:flex;align-items:flex-end;gap:3px;height:26px;width:128px}.spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--chart);opacity:.85;cursor:default}.spark i.zero{opacity:.22}.spark i:hover{opacity:1;filter:brightness(1.2)}.names{display:flex;flex-direction:column;gap:10px;padding:12px;border-radius:12px;border:1px solid var(--line)}.names-head{display:flex;gap:10px;align-items:flex-start}.names-ic{width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.names-ic .ic-svg{width:15px;height:15px}.names-list{display:flex;flex-wrap:wrap;gap:6px}.name-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;height:28px;max-width:100%;padding:0 9px 0 10px;border-radius:999px;background:var(--soft)}.name-chip:hover{background:var(--soft-hover)}.name-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.name-chip .mono{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.name-chip .ic-svg{width:13px;height:13px;color:var(--faint)}.slot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:14px;padding:16px;min-height:72px;border:1px dashed var(--input);border-radius:var(--radius);color:var(--text);text-align:left}.slot.add:hover{background:var(--soft);border-color:color-mix(in srgb,var(--text) 30%,transparent)}.slot-ic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.slot.add:hover .slot-ic{background:var(--primary);color:var(--primary-fg)}.slot.add:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(min-width:960px){.slot.add{flex-direction:column;justify-content:center;gap:10px;min-height:140px;text-align:center;color:var(--muted)}.slot.add .stack{align-items:center}.slot.add .strong{color:var(--text)}.slot.add .slot-ic{border-radius:999px;width:36px;height:36px}}.ic{display:inline-flex;line-height:0}.ic-svg{width:16px;height:16px}.btn{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 16px;border-radius:999px;font-size:14px;font-weight:500;background:var(--soft);color:var(--text);-webkit-tap-highlight-color:transparent;white-space:nowrap}.btn:hover{background:var(--soft-hover)}.btn.primary{background:var(--primary);color:var(--primary-fg)}.btn.primary:hover{opacity:.9}.btn.danger-solid{background:var(--bad);color:#fff}.btn.small{height:32px;padding:0 12px;font-size:13px}.btn.big{height:48px;font-size:15px}.btn.block{display:flex;width:100%}.btn[disabled]{opacity:.45;cursor:not-allowed}.btn:focus-visible,.kind:focus-visible,.icon-btn:focus-visible,.slot:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.icon-btn{all:unset;cursor:pointer;width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;color:var(--muted);flex:0 0 auto}.icon-btn:hover{background:var(--soft);color:var(--text)}.icon-btn.soft{background:var(--soft)}@media(pointer:coarse){.icon-btn{width:40px;height:40px}}input[type=text]{width:100%;font:inherit;color:var(--text);background:var(--card);border:1px solid var(--input);border-radius:10px;padding:0 12px;height:44px}input[type=text]:focus{outline:none;border-color:transparent;box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 60%,transparent)}.lbl{display:block;font-size:13px;font-weight:500;color:var(--muted);margin:14px 2px 6px}.err{color:var(--bad);min-height:1.2em;margin:8px 2px;font-size:14px}.kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.kind{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:63px;min-width:0;border-radius:12px;box-shadow:inset 0 0 0 1px var(--line);color:var(--muted);font-size:12.5px;line-height:15px;font-weight:500;text-align:center}.kind .ic{display:inline-flex;line-height:0}.kind .ic-svg{width:20px;height:20px}.kind:hover{color:var(--text);background:color-mix(in srgb,var(--text) 4%,transparent)}.kind.on{box-shadow:inset 0 0 0 1.5px var(--accent);color:var(--text);background:color-mix(in srgb,var(--accent) 10%,transparent)}.kind.on .ic{color:var(--accent)}.signin{text-align:center;max-width:420px;margin:8vh auto 0;width:100%;padding:28px 20px;display:flex;flex-direction:column;gap:10px}.hero-ic{width:52px;height:52px;margin:0 auto 6px;border-radius:16px;display:grid;place-items:center;background:var(--primary);color:var(--primary-fg)}.hero-ic .ic-svg{width:24px;height:24px}.signin input{text-align:center;margin-top:8px}.menu{position:absolute;z-index:30;width:230px;padding:4px;border-radius:14px;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl)}.menu-item{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;width:100%;height:40px;padding:0 12px;border-radius:10px;font-size:14px}.menu-item:hover,.menu-item:focus-visible{background:var(--soft-hover)}.menu-item .ic{color:var(--muted)}.menu-item.danger,.menu-item.danger .ic{color:var(--bad)}.menu-sep{height:1px;background:var(--line);margin:4px 8px}@media(pointer:coarse){.menu-item{height:44px}}.sheet{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-end;justify-content:center}.scrim{position:absolute;inset:0;background:var(--scrim)}.sheet-panel{position:relative;width:100%;max-width:520px;max-height:92vh;max-height:92dvh;overflow:auto;background:var(--elevated);border-radius:20px 20px 0 0;border:1px solid var(--line);border-bottom:0;padding:6px 16px max(20px,env(safe-area-inset-bottom))}.grab{width:36px;height:4px;border-radius:999px;background:var(--input);margin:4px auto 8px}.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;padding:4px 0 12px}.sheet-head h2{font-size:20px;line-height:28px;font-weight:600}.sheet-body{display:flex;flex-direction:column;gap:14px}@media(min-width:640px){.sheet{align-items:center}.sheet-panel{border-radius:16px;border-bottom:1px solid var(--line);padding:20px;max-width:480px}.grab{display:none}}.ask{display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px;padding-top:6px}.ask h2{font-size:18px;line-height:24px;font-weight:600}.ask p{margin:0;font-size:14px;line-height:20px}.ask-ic{width:52px;height:52px;border-radius:16px;display:grid;place-items:center;margin-bottom:6px}.ask-ic .ic-svg{width:24px;height:24px}.ask-ic.bad{background:var(--bad-wash);color:var(--bad)}.ask-ic.warn{background:var(--warn-wash);color:var(--warn)}.ask-actions{width:100%;margin-top:10px}@media(min-width:640px){.sheet-panel.asks{max-width:360px;padding:24px 20px 20px}.ask{padding-top:0}}.tabs{display:flex;gap:4px;padding:4px;background:var(--soft);border-radius:999px}.tabs button{all:unset;cursor:pointer;flex:1 1 auto;white-space:nowrap;text-align:center;padding:7px 10px;border-radius:999px;font-weight:500;font-size:13px;color:var(--muted)}.tabs button.on{background:var(--soft-hover);color:var(--text)}.pane{display:flex;flex-direction:column;gap:10px}.pane.center{align-items:center;text-align:center}.qr{width:min(240px,70vw);aspect-ratio:1;background:#0a0a0a;border-radius:22px;padding:12px;box-shadow:inset 0 0 0 1px #ffffff2e}.qr.light{background:#fff;border-radius:12px;padding:10px;box-shadow:inset 0 0 0 1px var(--line)}.qr svg{display:block;width:100%;height:100%}.steps{margin:4px 0 0;padding:14px 16px 14px 34px;border-radius:14px;border:1px solid var(--line);background:var(--card);display:flex;flex-direction:column;gap:8px;font-size:14px}.keybox{display:flex;align-items:center;gap:8px;height:44px;padding:0 6px 0 12px;border:1px solid var(--input);border-radius:10px}.keybox .mono{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}.filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--soft);min-width:0}.filecard>.stack{flex:1;min-width:0}.filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--mono);color:var(--muted);background:var(--card);box-shadow:inset 0 0 0 1px var(--line)}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}@media(max-width:480px){.filecard .ellipsis{white-space:normal;overflow-wrap:anywhere}}.confbox{border:1px solid var(--line);border-radius:12px}.confbox>summary{list-style:none;display:flex;align-items:center;gap:8px;padding:8px 10px 8px 12px;color:var(--text)}.confbox>summary::-webkit-details-marker{display:none}.confbox>summary>.ic:first-child{transition:transform .2s var(--ease-out);color:var(--muted)}.confbox[open]>summary>.ic:first-child{transform:rotate(90deg)}.confbox .grow{flex:1}.confbox>.conf{margin:0;border-top:1px solid var(--line);border-radius:0 0 12px 12px;background:none}.conf-sec{color:var(--accent, var(--info))}.conf-k{color:var(--faint)}.conf-mask{padding:0 6px;border-radius:4px;background:var(--soft);color:var(--muted)}.conf{white-space:pre-wrap;word-break:break-all;font:12px/18px var(--mono);background:var(--soft);border-radius:10px;padding:12px;max-height:16rem;overflow:auto}details>summary{cursor:pointer;color:var(--muted);font-size:13px;font-weight:500}.waiting{display:flex;align-items:center;gap:10px;padding:12px 14px;border-radius:12px;background:var(--soft);font-size:14px}.tip{position:fixed;z-index:50;translate:-50% -100%;padding:6px 10px;border-radius:10px;font-size:12px;line-height:17px;white-space:nowrap;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl);pointer-events:none}.tip-title{font-weight:500}.toast{position:fixed;left:50%;bottom:max(20px,env(safe-area-inset-bottom));translate:-50% 0;z-index:60;background:var(--primary);color:var(--primary-fg);padding:10px 16px;border-radius:999px;font-weight:500;font-size:14px;max-width:90vw}.toast.bad{background:var(--bad);color:#fff}.firststeps{grid-column:1 / -1;display:flex;flex-direction:column;gap:12px}.firststeps p{margin:0;font-size:14px}.firststeps h2{margin:0;font-size:17px}.firststeps .steps{margin:0}.pane .seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--soft, rgba(127, 127, 127, .12));margin-bottom:10px}.pane .seg button{border:0;background:none;color:inherit;font:inherit;font-size:13px;padding:5px 12px;border-radius:999px;cursor:pointer}.pane .seg button.on{background:var(--card, #fff);box-shadow:0 1px 2px #0000001f}.setup{display:flex;flex-direction:column;gap:12px}.setup .center{display:flex;justify-content:center;text-align:center}.step{border:1px solid var(--line);border-radius:16px;background:var(--card);padding:14px 16px 16px;display:flex;flex-direction:column;gap:12px;min-width:0}.step-head{display:flex;align-items:center;gap:10px}.step-n{width:22px;height:22px;border-radius:50%;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;flex:none}.step-n:empty{display:none}.step-ic{width:28px;height:28px;border-radius:8px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:none}.step-title{font-weight:600;font-size:16px;display:flex;align-items:center;gap:10px;min-width:0;flex:1}.chip{font-size:11px;padding:2px 7px;border-radius:999px;background:#3a83f729;color:var(--accent);white-space:nowrap}.fold-link{all:unset;cursor:pointer;font-size:13px;color:var(--muted);padding:4px 0}.fold-link:hover{color:var(--text)}.badge{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:12px;padding:8px 12px 8px 8px;border-radius:12px;min-height:56px;background:var(--soft);color:var(--text);min-width:0}.badge:hover{background:var(--soft-hover)}.badge.primary{background:var(--primary);color:var(--primary-fg)}.badge-ic{width:36px;height:36px;border-radius:10px;flex:none;display:inline-flex;align-items:center;justify-content:center;background:#7f7f7f2e}.badge-ic .ic-svg{width:20px;height:20px}.badge-txt{display:flex;flex-direction:column;line-height:1.2;min-width:0;flex:1}.badge-top{font-size:11px;opacity:.7}.badge-main{font-size:15px;font-weight:600;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.badge-chev{opacity:.5;display:inline-flex;flex:none}.badges2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.badges2 .badge-chev{display:none}.pills{display:flex;flex-wrap:wrap;gap:6px}.pill{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;font-size:13px;padding:7px 10px 7px 9px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.pill .ic-svg{width:14px;height:14px}.pill.on{border-color:var(--accent);background:#3a83f71f;color:var(--text)}.howto{margin:0;padding:0 4px 0 22px;font-size:13px;color:var(--muted);display:flex;flex-direction:column;gap:4px}.howto b{font-weight:500;color:var(--text)}.linkrow{display:flex;align-items:center;gap:8px;padding:6px 6px 6px 12px;border-radius:12px;background:var(--soft);min-width:0}.linkrow .mono{flex:1;min-width:0;font-size:12px;color:var(--muted)}.qr.small{width:148px;flex:none}.code-row{display:flex;flex-direction:column;align-items:center;gap:12px}.code-row>.stack{align-self:stretch}.qr.big{width:100%}.pill-link{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;font-size:12px;font-weight:500;padding:5px 8px 5px 10px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.pill-link:hover{color:var(--text);background:var(--soft)}.pill-link .ic-svg{width:13px;height:13px;transform:rotate(90deg)}.step-sub{margin-top:-8px}.step-head.fold{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;width:100%;color:inherit}.fold-chev{display:inline-flex;color:var(--muted)}.fold-chev .ic-svg{width:16px;height:16px}.step.folded{padding-bottom:14px}.way{display:flex;flex-direction:column;gap:10px;padding:12px 14px;border-radius:14px;background:var(--soft)}.way-row{display:flex;align-items:center;gap:10px}.way-end{width:36px;height:36px;border-radius:10px;flex:none;display:inline-flex;align-items:center;justify-content:center;background:var(--soft-hover);color:var(--muted)}.way-end .ic-svg{width:18px;height:18px}.way-end.home{color:var(--info);background:color-mix(in srgb,var(--info) 14%,transparent)}.way-track{position:relative;flex:1;height:8px}.way-track:before,.way-glow,.way-fill{position:absolute;inset:0;-webkit-mask:radial-gradient(circle,#000 1.4px,transparent 1.9px) 0 50% / 9px 8px repeat-x;mask:radial-gradient(circle,#000 1.4px,transparent 1.9px) 0 50% / 9px 8px repeat-x}.way-track:before{content:"";background:var(--faint);opacity:.55}.way-glow{overflow:hidden}.way-glow i{position:absolute;inset:0;background:linear-gradient(90deg,transparent 32%,var(--info) 50%,transparent 68%);transform:translate(-70%)}.way-fill{background:var(--ok);clip-path:inset(0 100% 0 0)}.way-text{display:flex;flex-direction:column;align-items:center;text-align:center;gap:2px}.way-text>:empty{display:none}.way.done .way-end{background:var(--ok-wash);color:var(--ok)}.way.done .way-fill{clip-path:inset(0)}.way.done .way-glow,.way.stopped .way-glow{opacity:0}.btn,.badge,.pill,.kind,.icon-btn,.slot.add,.slot-ic,.name-chip,.fold-link,.pill-link,.tabs>button,.seg>button,.menu-item{transition:transform var(--dur-press) var(--ease-out),background-color var(--dur-hover) var(--ease-out),border-color var(--dur-hover) var(--ease-out),box-shadow var(--dur-hover) var(--ease-out),color var(--dur-hover) var(--ease-out),opacity var(--dur-hover) var(--ease-out)}.btn:active,.pill:active,.kind:active,.icon-btn:active,.fold-link:active,.pill-link:active,.tabs>button:active,.seg>button:active{transform:scale(.97)}.badge:active,.slot.add:active{transform:scale(.985)}.name-chip:active{transform:scale(.96)}.btn[disabled]:active{transform:none}.icon-btn[aria-expanded=true]{background:var(--soft-hover);color:var(--text)}.kind .ic,.menu-item .ic{transition:color var(--dur-hover) var(--ease-out)}.spark i{transition:opacity .12s var(--ease-out),filter .12s var(--ease-out)}input,textarea{transition:border-color var(--dur-hover) var(--ease-out),box-shadow var(--dur-hover) var(--ease-out)}.intro,.slot.add.intro{animation:rise-in var(--dur-enter) var(--ease-out) backwards;animation-delay:calc(40ms + var(--i, 0) * 45ms)}.top.first .sun{animation:sunrise .9s var(--ease-out) .12s backwards}.wrap.first .meter i{animation:fill-x .8s var(--ease-out) .3s backwards}.wrap.first .slots i.used,.wrap.first .slots i.over{animation:fill-x .48s var(--ease-out) backwards;animation-delay:calc(.32s + var(--i, 0) * 50ms)}.wrap.first .spark i{transform-origin:bottom;animation:grow-y .56s var(--ease-out) backwards;animation-delay:calc(.32s + var(--i, 0) * 30ms)}.wrap.first .avatar.online:after{animation:pop-in .48s var(--spring-pop) .42s backwards}.wrap.first .hero-ic{animation:pop-in .52s var(--spring-pop) .16s backwards}.enter,.slot.add.enter{animation:rise-in .36s var(--ease-out) backwards}.unfold{animation:rise-in .32s var(--ease-out) backwards;animation-delay:calc(30ms + var(--i, 0) * 40ms)}.swap{animation:focus-in var(--dur-swap) var(--ease-out) backwards}.swap-ic{animation:icon-in .28s var(--spring) backwards}.copied>.ic,.copied .badge-ic .ic{color:var(--ok)}.badge.primary.copied .badge-ic .ic{color:inherit}.menu{opacity:0;transform:translateY(-4px) scale(.96);transform-origin:top right;filter:blur(2px);transition:opacity var(--dur-pop) var(--ease-out),transform .22s var(--ease-out),filter var(--dur-pop) var(--ease-out)}.menu.up{transform:translateY(4px) scale(.96);transform-origin:bottom right}.menu.show{opacity:1;transform:none;filter:none}.menu.gone{opacity:0;transform:scale(.98);filter:none;pointer-events:none;transition-duration:.12s;transition-timing-function:var(--ease-in)}.tip{opacity:0;transform:translateY(4px) scale(.96);transform-origin:50% 100%;transition:opacity .12s var(--ease-out),transform var(--dur-pop) var(--ease-out)}.tip.show{opacity:1;transform:none}.toast{opacity:0;transform:translateY(12px) scale(.96);filter:blur(4px);transition:transform .38s var(--ease-out),opacity .24s var(--ease-out),filter .24s var(--ease-out)}.toast.show{opacity:1;transform:none;filter:none}.toast.gone{opacity:0;transform:translateY(4px) scale(.98);filter:blur(2px);transition-duration:var(--dur-exit);transition-timing-function:var(--ease-in)}.scrim{opacity:0;transition:opacity .3s var(--ease-out)}.sheet.open .scrim{opacity:1}.sheet.closing .scrim{transition-duration:.26s}.sheet-panel{transform:translateY(100%);transition:transform var(--dur-sheet) var(--ease-drawer)}.sheet.open .sheet-panel{transform:none}.sheet.closing .sheet-panel{transition-duration:.3s}.sheet-panel.dragging{transition:none}.sheet-panel.morphing{overflow:hidden}.sheet-panel.morphing-w{max-width:none}@media(max-width:639px){.grab,.sheet-head,.ask{touch-action:none}.grab{cursor:grab}}@media(min-width:640px){.sheet-panel{opacity:0;transform:translateY(8px) scale(.96);filter:blur(4px);transition:opacity .22s var(--ease-out),transform .32s var(--ease-out),filter .22s var(--ease-out)}.sheet.open .sheet-panel{opacity:1;transform:none;filter:none}.sheet.closing .sheet-panel{opacity:0;transform:scale(.98);filter:blur(2px);transition-duration:var(--dur-exit);transition-timing-function:var(--ease-in)}.sheet.closing .scrim{transition-duration:.18s}.sheet.fresh .sheet-inner>.sheet-head,.sheet.fresh .sheet-body>:not(.setup),.sheet.fresh .setup>*{animation:settle-in .28s var(--ease-out) backwards;animation-delay:calc(20ms + var(--i, 0) * 25ms)}}.sheet.fresh .ask-ic{animation:pop-in .52s var(--spring-pop) 80ms backwards}.sheet-inner,.tab-body,.setup{position:relative;isolation:isolate}.ghost{position:absolute;z-index:-1;pointer-events:none}.slides{position:relative}.slide-hl{position:absolute;inset:0;margin:0!important;pointer-events:none}.slide-hl.placed{transition:clip-path .3s var(--ease-out)}.tabs.slide-hl{background:var(--soft-hover)}.pane .seg.slide-hl{background:var(--card)}.slide-hl>button,.slide-hl>button.on{background:none;box-shadow:none;color:var(--text);transition:none}.tabs.slides>button.on,.pane .seg.slides>button.on{background:none;box-shadow:none}.fold.to-off .fold-chev{animation:icon-in .28s var(--spring) backwards}.pill.to-on{animation:pill-on var(--dur-pop) var(--ease-out)}.pill.to-off{animation:pill-off var(--dur-pop) var(--ease-out)}.pill.to-on .ic,.kind.on .ic{animation:pop-sm .34s var(--spring-pop)}.qr.swap{animation:qr-in .36s var(--ease-out) backwards}.conf-v.unmask{animation:unmask .42s var(--ease-out) backwards}.conf-mask.unmask{animation:focus-in .2s var(--ease-out) backwards}.confbox[open]>.conf{animation:rise-in .26s var(--ease-out) backwards}.way-glow i{animation:way-run 2s cubic-bezier(.45,0,.55,1) infinite}.way-glow{transition:opacity .2s var(--ease-out)}.way-fill{transition:clip-path .7s var(--ease-out) 80ms}.way-end{transition:background-color .3s var(--ease-out),color .3s var(--ease-out)}.way.done .way-end.home{transition-delay:.6s}.way.done .way-end.home .ic{animation:pop-sm .42s var(--spring-pop) .6s}.btn{--spin: var(--text)}.btn.primary{--spin: var(--primary-fg)}.btn.danger-solid{--spin: #fff}.btn.busy{position:relative;color:transparent!important;cursor:progress}.btn.busy[disabled]{opacity:1}.btn.busy:after{content:"";position:absolute;inset:0;margin:auto;width:16px;height:16px;border-radius:50%;border:2px solid color-mix(in srgb,var(--spin) 28%,transparent);border-top-color:var(--spin);animation:spin .7s linear infinite,focus-in var(--dur-hover) var(--ease-out)}.btn[disabled]{transition:opacity var(--dur-hover) var(--ease-out)}@keyframes rise-in{0%{opacity:0;transform:translateY(8px);filter:blur(4px)}}@keyframes settle-in{0%{opacity:0;transform:translateY(4px)}}@keyframes focus-in{0%{opacity:0;filter:blur(4px)}}@keyframes fade{0%{opacity:0}}@keyframes icon-in{0%{opacity:0;transform:scale(.7);filter:blur(3px)}}@keyframes pop-in{0%{opacity:0;transform:scale(.7);filter:blur(4px)}}@keyframes pop-sm{0%{transform:scale(.82)}}@keyframes sunrise{0%{transform:translateY(10px)}}@keyframes fill-x{0%{clip-path:inset(0 100% 0 0 round 999px)}to{clip-path:inset(0 0 0 0 round 999px)}}@keyframes grow-y{0%{transform:scaleY(0)}}@keyframes pill-on{0%{border-color:var(--line);background-color:transparent;color:var(--muted)}}@keyframes pill-off{0%{border-color:var(--accent);background-color:#3a83f71f;color:var(--text)}}@keyframes qr-in{0%{opacity:0;transform:scale(.98);filter:blur(6px)}}@keyframes unmask{0%{opacity:.25;filter:blur(5px)}}@keyframes way-run{0%{transform:translate(-70%)}72%,to{transform:translate(70%)}}@keyframes spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.intro,.slot.add.intro,.enter,.slot.add.enter,.unfold,.swap,.swap-ic,.qr.swap,.conf-v.unmask,.confbox[open]>.conf,.wrap.first .hero-ic,.wrap.first .avatar.online:after,.sheet.fresh .sheet-inner>.sheet-head,.sheet.fresh .sheet-body>:not(.setup),.sheet.fresh .setup>*,.sheet.fresh .ask-ic{animation-name:fade;animation-duration:.2s}.top.first .sun,.wrap.first .meter i,.wrap.first .slots i.used,.wrap.first .slots i.over,.wrap.first .spark i,.fold.to-off .fold-chev,.pill.to-on .ic,.kind.on .ic,.way.done .way-end.home .ic{animation:none}.way-glow{display:none}.way-fill{transition:none}.sheet-panel,.sheet.open .sheet-panel,.sheet.closing .sheet-panel,.menu,.menu.up,.menu.gone,.tip,.toast,.toast.gone{transform:none;filter:none}.sheet-panel{opacity:0;transition:opacity .2s var(--ease-out)}.sheet.open .sheet-panel{opacity:1}.slide-hl.placed,.confbox>summary>.ic:first-child{transition:none}.btn:active,.badge:active,.pill:active,.kind:active,.icon-btn:active,.slot.add:active,.name-chip:active,.fold-link:active,.pill-link:active,.tabs>button:active,.seg>button:active{transform:none}} diff --git a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js index 53e3199..28f680a 100644 --- a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js +++ b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js @@ -1,6 +1,6 @@ -"use strict";(()=>{var ut=Object.create;var Ke=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var ht=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var vt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var gt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of ft(t))!pt.call(e,l)&&l!==r&&Ke(e,l,{get:()=>t[l],enumerable:!(s=dt(t,l))||s.enumerable});return e};var mt=(e,t,r)=>(r=e!=null?ut(ht(e)):{},gt(t||!e||!e.__esModule?Ke(r,"default",{value:e,enumerable:!0}):r,e));var Qe=vt((ze,Je)=>{"use strict";var je=(function(){var e=function(x,k){var b=236,f=17,c=x,y=r[k],i=null,a=0,w=null,h=[],m={},L=function(u,d){a=c*4+17,i=(function(o){for(var p=new Array(o),g=0;g=7&&z(u),w==null&&(w=ct(c,y,h)),Q(w,d)},D=function(u,d){for(var o=-1;o<=7;o+=1)if(!(u+o<=-1||a<=u+o))for(var p=-1;p<=7;p+=1)d+p<=-1||a<=d+p||(0<=o&&o<=6&&(p==0||p==6)||0<=p&&p<=6&&(o==0||o==6)||2<=o&&o<=4&&2<=p&&p<=4?i[u+o][d+p]=!0:i[u+o][d+p]=!1)},S=function(){for(var u=0,d=0,o=0;o<8;o+=1){L(!0,o);var p=l.getLostPoint(m);(o==0||u>p)&&(u=p,d=o)}return d},K=function(){for(var u=8;u>o&1)==1;i[Math.floor(o/3)][o%3+a-8-3]=p}for(var o=0;o<18;o+=1){var p=!u&&(d>>o&1)==1;i[o%3+a-8-3][Math.floor(o/3)]=p}},J=function(u,d){for(var o=y<<3|d,p=l.getBCHTypeInfo(o),g=0;g<15;g+=1){var M=!u&&(p>>g&1)==1;g<6?i[g][8]=M:g<8?i[g+1][8]=M:i[a-15+g][8]=M}for(var g=0;g<15;g+=1){var M=!u&&(p>>g&1)==1;g<8?i[8][a-g-1]=M:g<9?i[8][15-g-1+1]=M:i[8][15-g-1]=M}i[a-8][8]=!u},Q=function(u,d){for(var o=-1,p=a-1,g=7,M=0,C=l.getMaskFunction(d),_=a-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var R=0;R<2;R+=1)if(i[p][_-R]==null){var F=!1;M>>g&1)==1);var T=C(p,_-R);T&&(F=!F),i[p][_-R]=F,g-=1,g==-1&&(M+=1,g=7)}if(p+=o,p<0||a<=p){p-=o,o=-o;break}}},re=function(u,d){for(var o=0,p=0,g=0,M=new Array(d.length),C=new Array(d.length),_=0;_=0?He.getAt(Ie):0}}for(var Oe=0,T=0;T_*8)throw"code length overflow. ("+g.getLengthInBits()+">"+_*8+")";for(g.getLengthInBits()+4<=_*8&&g.put(0,4);g.getLengthInBits()%8!=0;)g.putBit(!1);for(;!(g.getLengthInBits()>=_*8||(g.put(b,8),g.getLengthInBits()>=_*8));)g.put(f,8);return re(g,p)};m.addData=function(u,d){d=d||"Byte";var o=null;switch(d){case"Numeric":o=$(u);break;case"Alphanumeric":o=P(u);break;case"Byte":o=q(u);break;case"Kanji":o=O(u);break;default:throw"mode:"+d}h.push(o),w=null},m.isDark=function(u,d){if(u<0||a<=u||d<0||a<=d)throw u+","+d;return i[u][d]},m.getModuleCount=function(){return a},m.make=function(){if(c<1){for(var u=1;u<40;u++){for(var d=E.getRSBlocks(u,y),o=N(),p=0;p";for(var g=0;g';o+=""}return o+="",o+="",o},m.createSvgTag=function(u,d,o,p){var g={};typeof arguments[0]=="object"&&(g=arguments[0],u=g.cellSize,d=g.margin,o=g.alt,p=g.title),u=u||2,d=typeof d=="undefined"?u*4:d,o=typeof o=="string"?{text:o}:o||{},o.text=o.text||null,o.id=o.text?o.id||"qrcode-description":null,p=typeof p=="string"?{text:p}:p||{},p.text=p.text||null,p.id=p.text?p.id||"qrcode-title":null;var M=m.getModuleCount()*u+d*2,C,_,R,F,T="",Y;for(Y="l"+u+",0 0,"+u+" -"+u+",0 0,-"+u+"z ",T+=''+ae(p.text)+"":"",T+=o.text?''+ae(o.text)+"":"",T+='',T+='":d+=">";break;case"&":d+="&";break;case'"':d+=""";break;default:d+=p;break}}return d},lt=function(u){var d=1;u=typeof u=="undefined"?d*2:u;var o=m.getModuleCount()*d+u*2,p=u,g=o-u,M,C,_,R,F,T={"██":"█","█ ":"▀"," █":"▄"," ":" "},Y={"██":"▀","█ ":"▀"," █":" "," ":" "},j="";for(M=0;M=g?Y[F]:T[F];j+=` -`}return o%2&&u>0?j.substring(0,j.length-o-1)+Array(o+1).join("▀"):j.substring(0,j.length-1)};return m.createASCII=function(u,d){if(u=u||1,u<2)return lt(d);u-=1,d=typeof d=="undefined"?u*2:d;var o=m.getModuleCount()*u+d*2,p=d,g=o-d,M,C,_,R,F=Array(u+1).join("██"),T=Array(u+1).join(" "),Y="",j="";for(M=0;M>>8),y.push(w&255)):y.push(f)}}return y}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={L:1,M:0,Q:3,H:2},s={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l=(function(){var x=[[],[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]],k=1335,b=7973,f=21522,c={},y=function(i){for(var a=0;i!=0;)a+=1,i>>>=1;return a};return c.getBCHTypeInfo=function(i){for(var a=i<<10;y(a)-y(k)>=0;)a^=k<=0;)a^=b<5&&(w+=3+L-5)}for(var h=0;h=256;)c-=255;return x[c]},f})();function A(x,k){if(typeof x.length=="undefined")throw x.length+"/"+k;var b=(function(){for(var c=0;c>>7-f%8&1)==1},b.put=function(f,c){for(var y=0;y>>c-y-1&1)==1)},b.getLengthInBits=function(){return k},b.putBit=function(f){var c=Math.floor(k/8);x.length<=c&&x.push(0),f&&(x[c]|=128>>>k%8),k+=1},b},$=function(x){var k=t.MODE_NUMBER,b=x,f={};f.getMode=function(){return k},f.getLength=function(i){return b.length},f.write=function(i){for(var a=b,w=0;w+2>>8&255)*192+(h&255),i.put(h,13),w+=2}if(w>>8)},k.writeBytes=function(b,f,c){f=f||0,c=c||b.length;for(var y=0;y0&&(b+=","),b+=x[f];return b+="]",b},k},I=function(){var x=0,k=0,b=0,f="",c={},y=function(a){f+=String.fromCharCode(i(a&63))},i=function(a){if(!(a<0)){if(a<26)return 65+a;if(a<52)return 97+(a-26);if(a<62)return 48+(a-52);if(a==62)return 43;if(a==63)return 47}throw"n:"+a};return c.writeByte=function(a){for(x=x<<8|a&255,k+=8,b+=1;k>=6;)y(x>>>k-6),k-=6},c.flush=function(){if(k>0&&(y(x<<6-k),x=0,k=0),b%3!=0)for(var a=3-b%3,w=0;w=k.length){if(c==0)return-1;throw"unexpected end of file./"+c}var a=k.charAt(b);if(b+=1,a=="=")return c=0,-1;if(a.match(/^\s$/))continue;f=f<<6|i(a.charCodeAt(0)),c+=6}var w=f>>>c-8&255;return c-=8,w};var i=function(a){if(65<=a&&a<=90)return a-65;if(97<=a&&a<=122)return a-97+26;if(48<=a&&a<=57)return a-48+52;if(a==43)return 62;if(a==47)return 63;throw"c:"+a};return y},Z=function(x,k){var b=x,f=k,c=new Array(x*k),y={};y.setPixel=function(h,m,L){c[m*b+h]=L},y.write=function(h){h.writeString("GIF87a"),h.writeShort(b),h.writeShort(f),h.writeByte(128),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(255),h.writeByte(255),h.writeByte(255),h.writeString(","),h.writeShort(0),h.writeShort(0),h.writeShort(b),h.writeShort(f),h.writeByte(0);var m=2,L=a(m);h.writeByte(m);for(var D=0;L.length-D>255;)h.writeByte(255),h.writeBytes(L,D,255),D+=255;h.writeByte(L.length-D),h.writeBytes(L,D,L.length-D),h.writeByte(0),h.writeString(";")};var i=function(h){var m=h,L=0,D=0,S={};return S.write=function(K,G){if(K>>>G)throw"length over";for(;L+G>=8;)m.writeByte(255&(K<>>=8-L,D=0,L=0;D=K<0&&m.writeByte(D)},S},a=function(h){for(var m=1<>6,128|v&63):v<55296||v>=57344?s.push(224|v>>12,128|v>>6&63,128|v&63):(l++,v=65536+((v&1023)<<10|r.charCodeAt(l)&1023),s.push(240|v>>18,128|v>>12&63,128|v>>6&63,128|v&63))}return s}return t(e)}})();(function(e){typeof define=="function"&&define.amd?define([],e):typeof ze=="object"&&(Je.exports=e())})(function(){return je})});function se(e){if(!e||e<0)return"0 B";let t=["B","KB","MB","GB","TB"],r=0,s=e;for(;s>=1024&&r=100||r===0?Math.round(s):s.toFixed(1)} ${t[r]}`}function Me(e,t=Date.now()/1e3){if(!e)return"never";let r=Math.max(0,Math.round(t-e));return r<60?"just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} h ago`:r<86400*30?`${Math.floor(r/86400)} d ago`:new Date(e*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function pe(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function ve(e){let[t,r,s]=e.split("-").map(Number);return new Date(t,(r||1)-1,s||1,12)}function yt(e){return(typeof e=="string"?/^\d{4}-\d{2}-\d{2}$/.test(e)?ve(e):new Date(e):e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ke(e){return e?yt(e):""}function bt(e,t){let r=s=>{let[l,v,A]=s.split("-").map(Number);return Date.UTC(l,v-1,A)};return Math.round((r(e)-r(t))/864e5)}function Ue(e,t){let r=ve(e);return r.setDate(r.getDate()+t),pe(r)}function Ae(e,t=Date.now()){if(!e)return null;let r=typeof t=="number"?pe(new Date(t)):t,s=bt(e,r);return s>=0?s+1:s}function _e(e,t){return t!=null&&t>0&&e.expire_warn>0&&t<=e.expire_warn}function Fe(e){return e<=1?"ends today":e===2?"ends tomorrow":`ends in ${e} days`}var Ge={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var ge={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"};function qe(e){var l,v,A;let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let r=(l=t[0][0])!=null?l:"",s=t.length>1?(v=t[t.length-1][0])!=null?v:"":(A=t[0][1])!=null?A:"";return(r+s).toUpperCase()}function Ce(e){let t=r=>r.disabled?3:r.online?0:r.handshake?1:2;return e.map((r,s)=>[r,s]).sort((r,s)=>t(r[0])-t(s[0])||r[1]-s[1]).map(([r])=>r)}var Ve={phone:'',computer:'',tablet:'',router:'',server:'',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 Ye(e,t="dl-icon"){var s;let r=(s=Ve[e])!=null?s:Ve.phone;return``}var We=mt(Qe(),1),wt='';function Ze(e,t=3,r=!0){let s=(0,We.default)(0,e.length>300?"Q":"H");s.addData(e,"Byte"),s.make();let l=s.getModuleCount(),v=l+t*2,A=r?Math.round(l*.22):0;A&&(l-A)%2&&A++;let E=(l-A)/2,N=E+A,$=(O,H)=>A>0&&O>=E&&O=E&&H${wt}`}return`${q}`}var xt={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:""},Mt={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 kt(e){let t={};for(let[r,s]of Object.entries(Mt))e[r]!=null&&e[r]!==""&&(t[s]=String(e[r]));return t}function At(e,t){var N;let r=e.amnezia,s=(N=r.obfuscation)!=null?N:{},l=$=>s[$]!=null&&s[$]!==""?String(s[$]):xt[$],v=r.host.replace(/^\[(.*)\]$/,"$1"),A={H1:l("h1"),H2:l("h2"),H3:l("h3"),H4:l("h4"),I1:l("i1"),I2:l("i2"),I3:l("i3"),I4:l("i4"),I5:l("i5"),Jc:l("jc"),Jmin:l("jmin"),Jmax:l("jmax"),S1:l("s1"),S2:l("s2"),S3:l("s3"),S4:l("s4"),...kt(s),allowed_ips:r.allowed_ips,client_ip:r.client_ip,client_priv_key:r.client_priv_key,client_pub_key:r.client_pub_key,config:e.conf.replace(/\r?\n/g,`\r -`),hostName:v,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},E={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(A),port:String(r.port),protocol_version:s.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:v};return r.dns[0]&&(E.dns1=r.dns[0]),r.dns[1]&&(E.dns2=r.dns[1]),E}function _t(e){let t="";for(let r=0;r{var e;return(e=B==null?void 0:B.today)!=null?e:pe(new Date)};function n(e,t={},...r){let s=document.createElement(e);for(let[v,A]of Object.entries(t))A==null||A===!1||(v.startsWith("on")&&typeof A=="function"?s.addEventListener(v.slice(2),A):v==="class"?s.className=String(A):A===!0?s.setAttribute(v,""):s.setAttribute(v,String(A)));let l=v=>{v==null||v===!1||(Array.isArray(v)?v.forEach(l):s.appendChild(typeof v=="string"?document.createTextNode(v):v))};return r.forEach(l),s}function U(e){let t=n("span",{class:"ic"});return t.innerHTML=Ye(e,"ic-svg"),t}var Tt='',Se=document.getElementById("app"),tt,me=(tt=Se.dataset.base)!=null?tt:"",Lt=Se.dataset.title||"Dawnline",De=()=>window.matchMedia("(max-width: 959px)").matches||/Android|iPhone|iPad/.test(navigator.userAgent),B=null,Dt=/^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(me)?me.slice(1):"",Ee=class extends Error{constructor(r,s,l){super(s);this.status=r;this.httpsUrl=l}};async function ne(e,t){var l;let r=await fetch(`${me}/api/${e}`,{method:t===void 0?"GET":"POST",credentials:"omit",headers:t===void 0?{}:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t),cache:"no-store"}),s=null;try{s=await r.json()}catch{}if(!r.ok)throw new Ee(r.status,(l=s==null?void 0:s.error)!=null?l:`Request failed (${r.status})`,(s==null?void 0:s.https_url)||void 0);return s}function te(e,t=!1){let r=n("div",{class:`toast${t?" bad":""}`,role:"status"},e);document.body.appendChild(r),requestAnimationFrame(()=>r.classList.add("show")),setTimeout(()=>{r.classList.remove("show"),setTimeout(()=>r.remove(),300)},2600)}async function oe(e,t="Copied"){try{await navigator.clipboard.writeText(e)}catch{let r=n("textarea",{class:"offscreen"},e);document.body.appendChild(r),r.select();let s=document.execCommand("copy");if(r.remove(),!s)return te("Copying is blocked here. Select the text and copy it by hand.",!0)}te(t)}function nt(e,t){let r=URL.createObjectURL(new Blob([t],{type:"application/octet-stream"})),s=n("a",{href:r,download:e,class:"offscreen"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(r),s.remove()},1e3)}var W=null;function rt(e,t){let r=s=>{W!=null||(W=document.body.appendChild(n("div",{class:"tip"}))),W.replaceChildren(...t().map((l,v)=>n("div",{class:v?"muted":"tip-title"},l))),W.style.display="",W.style.left=`${s.clientX}px`,W.style.top=`${s.clientY-10}px`};e.addEventListener("mouseenter",r),e.addEventListener("mousemove",r),e.addEventListener("mouseleave",()=>W&&(W.style.display="none"))}function Et(e){let t=Math.max(1,...e),r=n("div",{class:"spark"});return e.forEach((s,l)=>{let v=n("i",{class:s?"":"zero"});v.style.height=`${Math.max(8,s/t*100)}%`;let A=e.length-1-l;rt(v,()=>[A===0?"Today":A===1?"Yesterday":ve(Ue($e(),-A)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),se(s)]),r.appendChild(v)}),r}async function Pe(e,t){if(!e.disabled){e.disabled=!0;try{await t()}finally{e.disabled=!1}}}var ie=null,ue=null;function ee(e=!1){if(!ie)return;let t=ie;if(ie=null,document.body.classList.remove("locked"),ue==null||ue(),ue=null,e){t.remove();return}t.classList.remove("open"),setTimeout(()=>t.remove(),250)}function ce(e,t,...r){let s=!!ie;ee(!0);let l=n("div",{class:"sheet-panel",role:"dialog","aria-modal":"true","aria-label":e},n("div",{class:"grab"}),n("div",{class:"sheet-head"},n("div",{class:"stack"},n("h2",{},e),t?n("span",{class:"muted s"},t):null),n("button",{class:"icon-btn","aria-label":"Close",onclick:()=>ee()},U("x"))),n("div",{class:"sheet-body"},...r)),v=n("div",{class:"sheet",onclick:A=>{A.target===v&&ee()}},l);return document.body.appendChild(v),document.body.classList.add("locked"),s?v.classList.add("open"):requestAnimationFrame(()=>v.classList.add("open")),ie=v,l}document.addEventListener("keydown",e=>{e.key==="Escape"&&(ye(),ee())});var X=null;function ye(){X==null||X.remove(),X=null}document.addEventListener("click",e=>{X&&!X.contains(e.target)&&ye()});function Bt(e,t){ye();let r=t.filter((A,E)=>A||E>0&&t[E-1]&&t.slice(E+1).some(Boolean)),s=n("div",{class:"menu",role:"menu"},r.map(A=>A?n("button",{type:"button",role:"menuitem",class:`menu-item${A.danger?" danger":""}`,onclick:()=>{ye(),A.run()}},U(A.icon),n("span",{},A.label)):n("div",{class:"menu-sep"})));document.body.appendChild(s);let l=e.getBoundingClientRect(),v=230;s.style.left=`${Math.max(8,Math.min(window.innerWidth-v-8,l.right-v))}px`,s.style.top=`${l.bottom+6+window.scrollY}px`,X=s}function Ne(...e){Se.replaceChildren(n("header",{class:"top"},n("div",{class:"brand"},(()=>{let t=n("span",{class:"logo"});return t.innerHTML=Tt,t})(),n("span",{},(B==null?void 0:B.server.name)||Lt),n("span",{class:"faint"},"· Dawnline"))),n("main",{class:"wrap"},...e))}function at(){Ne(n("div",{class:"card signin"},n("div",{class:"hero-ic"},U("key")),n("h1",{},"This link no longer works"),n("p",{class:"muted"},"Ask for a new personal link.")))}function $t(e){switch(e.state){case"server_off":return["server","The server is turned off","Your devices can’t connect until the admin turns it on again."];case"no_server":return["server","No server yet","Ask the admin to add you to a server."];case"quota":return["chart","You have used all your data","Your devices are paused until it resets."];case"expired":return["calendar","Your access has ended","Ask the admin to extend it."];case"hours":return["clock","Outside your hours",`Access is available ${e.hours.replace("-","–")} (router time).`];default:return["pause","Your access is paused by the admin","Your devices can’t connect until the admin resumes it."]}}function Xe(e,t,r,s){return n("div",{class:"alert"},n("span",{class:`alert-ic ${e}`},U(t)),n("div",{class:"stack"},n("span",{class:"strong"},r),n("span",{class:"muted s"},s)))}function St(e){return e.state==="active"?"ok":e.state==="quota"||e.state==="expired"?"bad":"warn"}var Pt={internet:"The internet, through the router",lan:"Devices at home",both:"Devices at home and the internet, through the router"};function Nt(e){let t=e.person,r=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,s=n("div",{class:`meter${r>=100?" bad":r>=90?" warn":""}`},n("i"));s.firstChild.style.width=`${r}%`,t.quota_limit&&rt(s,()=>[`${r.toFixed(1)}% used`,`${se(Math.max(0,t.quota_limit-t.quota_used))} left`]);let l=Ae(t.expires,$e()),v=n("div",{class:"slots"});for(let N=0;N=t.device_limit?"over":N=0?`${l} day${l===1?"":"s"} left`:"ended"):null)),n("span",{class:"faint s"},t.hours?`Available ${t.hours.replace("-","–")} (router time). Need a change? Ask the admin.`:"Need a change? Ask the admin.")))}function Rt(e){return e.disabled?n("span",{class:"dstat"},"Disabled by the admin"):e.online?n("span",{class:"dstat ok"},"Connected"):e.handshake?n("span",{class:"dstat"},`Last connected ${Me(e.handshake)}`):n("span",{class:"dstat warn"},"Not set up yet")}function st(e,t){return e.access!=="internet"&&e.state==="active"&&!t.disabled}function Ht(e,t){let r=Ce(e.devices).filter(v=>v.hostname&&st(e,v));if(!r.length)return null;let s=r[0].hostname,l=s.slice(s.indexOf("."));return n("div",{class:"names"},n("div",{class:"names-head"},n("span",{class:"names-ic"},U("home")),n("div",{class:"stack"},n("span",{class:"strong s"},"Names at home"),n("span",{class:"faint s"},t?"Devices at home and on this VPN reach yours as ":"Other devices at home reach yours as ",n("span",{class:"mono"},`name${l}`)))),n("div",{class:"names-list"},r.map(v=>{let A=v.hostname.indexOf(".");return n("button",{type:"button",class:"name-chip",title:v.name,"aria-label":`Copy ${v.hostname}`,onclick:()=>oe(v.hostname,"Address copied")},n("span",{class:"mono"},A>0?[v.hostname.slice(0,A),n("span",{class:"faint"},v.hostname.slice(A))]:v.hostname),U("copy"))})))}function It(e,t){let r=n("button",{type:"button",class:"icon-btn soft","aria-label":`${e.name} options`},U("more"));r.addEventListener("click",E=>{E.stopPropagation(),Bt(r,[{label:"Show QR code",icon:"qr",run:()=>de(e,"qr")},{label:"Copy AmneziaVPN key",icon:"key",run:()=>Ot(e)},{label:"Download .conf",icon:"download",run:()=>Kt(e)},null,...st(t.person,e)?[{label:"Copy IP address",icon:"copy",run:()=>oe(e.address,"IP address copied")},...e.hostname?[{label:"Copy local address",icon:"home",run:()=>oe(e.hostname,"Address copied")}]:[],null]:[],...e.disabled?[]:[{label:"Rename",icon:"edit",run:()=>Ft(e)},{label:"New keys",icon:"reset",run:()=>Gt(e,t)},{label:"Remove",icon:"trash",danger:!0,run:()=>qt(e)}]])});let s=e.spark.reduce((E,N)=>E+N,0),l=!e.handshake&&!e.disabled,v=!!t.locked,A=t.here===e.id;return n("article",{class:`dcard${e.online?" online":""}${e.disabled?" off":""}${A?" here":""}`},n("div",{class:"dhead"},n("span",{class:"dic"},U(e.kind)),n("div",{class:"stack grow"},n("span",{class:"dname"},e.name),A?n("span",{class:"dstat here"},"This device"):Rt(e)),v?null:r),l&&v?null:l?[n("button",{type:"button",class:"btn primary block",onclick:()=>de(e)},U(De()?"open":"qr"),n("span",{},De()?"Open in AmneziaVPN":"Connect this device"))]:n("div",{class:"duse"},n("div",{class:"stack"},n("span",{class:"faint s"},"Last 7 days"),n("span",{class:"mono"},se(s))),Et(e.spark)),e.config_stale&&!l&&!v?n("div",{class:"notice"},U("alert"),n("span",{class:"grow"},"Connection settings changed. Update this device to keep everything working."),n("button",{type:"button",class:"btn small",onclick:()=>de(e)},"Update")):null)}function fe(e){let t=e.person,r=Ae(t.expires,$e()),s=t.state!=="active"?Xe(St(t),...$t(t)):_e(t,r)?Xe("warn","calendar",`Your access ${Fe(r)}`,`On ${ke(t.expires)}. Ask the admin to extend it.`):null,v=Ce(t.devices).sort((N,$)=>+($.id===e.here)-+(N.id===e.here)).map(N=>It(N,e));(e.locked?0:Math.max(0,t.device_limit-t.devices.length))&&v.push(n("button",{type:"button",class:"slot add",onclick:zt},n("span",{class:"slot-ic"},U("plus")),n("span",{class:"strong"},"Add device")));let E=n("section",{class:"devices","aria-label":"Your devices"},n("div",{class:"card-head"},n("div",{class:"row-baseline"},n("h2",{},"Your devices"))),n("div",{class:"dgrid"},v),e.locked?null:[e.can_add?null:n("span",{class:"faint s"},`You have reached your limit of ${t.device_limit} devices. Remove one or ask the admin for more.`),n("span",{class:"faint s"},"New device? Install ",n("a",{href:"https://amnezia.org/downloads",target:"_blank",rel:"noopener noreferrer"},"AmneziaVPN")," on it first.")]);Ne(s,n("div",{class:"hello"},n("span",{class:`avatar${t.online?" online":""}`},qe(t.name)),n("h1",{},`Hi, ${t.name}`)),n("div",{class:"layout"},Nt(e),E))}function be(e){ce("Open the link securely","Connection settings only travel encrypted",n("div",{class:"stack gap"},n("p",{class:"muted"},"This page is open without encryption. To add or set up a device, open the same link over HTTPS:"),n("a",{class:"btn primary block big",href:e},U("lock"),n("span",{},"Open securely")),n("p",{class:"faint s"},"The browser may warn that the certificate is not trusted: it is this router’s own. Choose to continue (“Advanced” → “Proceed”).")))}var it=()=>(B==null?void 0:B.https_url)||null;async function Re(e){let t=it();if(t)return be(t),null;try{return await ne(`devices/${e.id}/config`)}catch(r){let s=r;return s.httpsUrl?be(s.httpsUrl):te(s.message,!0),null}}async function Ot(e){let t=await Re(e);t&&oe(await Te(t,`${t.server} · ${t.name}`),"Key copied")}async function Kt(e){let t=await Re(e);t&&nt(t.filename,t.conf)}function et(e,t){if(/^\s*\[.+\]\s*$/.test(e))return n("span",{class:"conf-sec"},e);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(e);if(!r)return document.createTextNode(e);let s=/^(\s*)(PrivateKey|PresharedKey)\b/.test(e);return n("span",{},n("span",{class:"conf-k"},r[1])," ",s&&!t?n("span",{class:"conf-mask"},"••••••••••••••••"):r[2])}function Ut(e){let t=!1,r=n("pre",{class:"conf"}),s=()=>r.replaceChildren(...e.conf.split(` -`).flatMap((v,A)=>A?[` -`,et(v,t)]:[et(v,t)])),l=n("button",{class:"btn small",onclick:v=>{v.preventDefault(),t=!t,l.replaceChildren(U(t?"x":"key"),n("span",{},t?"Hide key":"Show key")),s()}},U("key"),n("span",{},"Show key"));return s(),n("div",{class:"pane"},n("div",{class:"filecard"},n("span",{class:"filecard-ic"},".conf"),n("span",{class:"stack"},n("span",{class:"mono ellipsis"},e.filename),n("span",{class:"faint s"},"For computers and routers: import it in AmneziaWG or AmneziaVPN")),n("button",{class:"btn primary",onclick:()=>nt(e.filename,e.conf)},U("download"),n("span",{},"Download"))),n("details",{class:"confbox"},n("summary",{},U("chevron"),n("span",{},"Configuration"),n("span",{class:"grow"}),l,n("button",{class:"btn small",onclick:v=>{v.preventDefault(),oe(e.conf,"Configuration copied")}},U("copy"),n("span",{},"Copy"))),r))}async function de(e,t,r){let s=r!=null?r:await Re(e);if(!s)return;let l=await Te(s,`${s.server} · ${s.name}`),v=De(),A={app:()=>n("div",{class:"pane"},n("a",{class:"btn primary block big",href:l},U("open"),n("span",{},"Open in AmneziaVPN")),n("ol",{class:"steps"},n("li",{},"No AmneziaVPN yet? ",n("a",{href:"https://amnezia.org/downloads",target:"_blank",rel:"noopener noreferrer"},"Get it here"),"."),n("li",{},"Tap ",n("b",{},"Open in AmneziaVPN")," and confirm the import."),n("li",{},"Turn the connection on — this page shows ",n("span",{class:"ok"},"Connected")," within a minute."))),qr:()=>{let f=n("div",{class:"qr"});return f.innerHTML=Ze(s.conf),n("div",{class:"pane center"},f,n("p",{class:"muted s"},"Scan with the phone’s camera or AmneziaVPN / AmneziaWG."))},key:()=>n("div",{class:"pane"},n("p",{class:"muted s"},"In AmneziaVPN choose “Add server → Insert key”."),n("div",{class:"keybox"},n("span",{class:"mono"},l),n("button",{class:"btn small",onclick:()=>oe(l,"Key copied")},"Copy")),n("p",{class:"faint s"},"Keep it private: anyone with the key can use your connection.")),file:()=>Ut(s)},E=v?["app","qr","key","file"]:["qr","key","file"],N={app:"Open in app",qr:"QR code",key:"Key",file:"File"},$=n("div",{class:"tab-body"}),P=n("div",{class:"tabs",role:"tablist"}),q=f=>{P.querySelectorAll("button").forEach(c=>c.classList.toggle("on",c.dataset.id===f)),$.replaceChildren(A[f]())};for(let f of E)P.appendChild(n("button",{role:"tab","data-id":f,onclick:()=>q(f)},N[f]));q(t&&E.includes(t)?t:E[0]);let O=n("div",{class:"waiting"}),H=f=>{f!=null&&f.online?O.replaceChildren(n("span",{class:"ok"},`${e.name} is connected`)):f!=null&&f.handshake?O.replaceChildren(n("span",{class:"muted"},`Last connected ${Me(f.handshake)}`)):O.replaceChildren(n("span",{class:"warn"},"Waiting for the first connection…"))};H(e);let I=0,le=0,Z=!!e.handshake||e.disabled,we=Date.now(),x=async()=>{if(I=0,!(Z||Date.now()-we>6e5)){if(document.hidden){k();return}try{let f=await ne("state");B=f;let c=f.person.devices.find(y=>y.id===e.id);if(H(c),c!=null&&c.online||c!=null&&c.handshake){Z=!0;return}}catch(f){if(f.status===404||f.status===401){Z=!0;return}}le++,k()}},k=()=>{!Z&&!I&&(I=window.setTimeout(x,le<6?5e3:le<12?15e3:3e4))},b=()=>{!document.hidden&&!Z&&!I&&x()};document.addEventListener("visibilitychange",b),k(),ce(e.handshake?`Connect ${e.name}`:`${e.name} is ready`,v?"Add it to AmneziaVPN on this phone":"Scan with the phone’s camera or AmneziaVPN",P,$,O),ue=()=>{Z=!0,I&&clearTimeout(I),document.removeEventListener("visibilitychange",b),B&&fe(B)}}function Ft(e){let t=n("input",{type:"text",value:e.name,maxlength:48,"aria-label":"Device name"}),r=n("button",{class:"btn primary block",type:"submit"},"Save");ce(`Rename ${e.name}`,null,n("form",{class:"stack gap",onsubmit:s=>{s.preventDefault(),Pe(r,async()=>{try{B=(await ne(`devices/${e.id}`,{action:"rename",name:t.value})).state,ee(),fe(B),te("Renamed")}catch(l){te(l.message,!0)}})}},t,r)),setTimeout(()=>t.select(),50)}function Gt(e,t){let r=t.here===e.id;ce(`New keys for ${e.name}?`,null,n("p",{class:"muted"},r?"This device is connected through the configuration it has now: it disconnects a few seconds after you confirm. Import the new configuration that opens next.":"Its current configuration stops working. Set the device up again with the new one that opens next."),n("div",{class:"row gap"},n("button",{class:"btn block",onclick:()=>ee()},"Cancel"),n("button",{class:"btn primary block",onclick:s=>Pe(s.currentTarget,async()=>{try{let l=await ne(`devices/${e.id}`,{action:"rotate"});B=l.state,fe(B),await de(e,void 0,l.config)}catch(l){te(l.message,!0)}})},"New keys")))}function qt(e){ce(`Remove ${e.name}?`,null,n("p",{class:"muted"},"Its connection stops working immediately. You can add it again later."),n("div",{class:"row gap"},n("button",{class:"btn block",onclick:()=>ee()},"Cancel"),n("button",{class:"btn danger-solid block",onclick:t=>Pe(t.currentTarget,async()=>{try{B=(await ne(`devices/${e.id}`,{action:"delete"})).state,ee(),fe(B),te("Device removed")}catch(r){te(r.message,!0)}})},"Remove")))}var V=navigator.userAgent,ot=/iPad/.test(V)||/Macintosh/.test(V)&&navigator.maxTouchPoints>1;function Le(){return ot||/Tablet/i.test(V)||/Android/.test(V)&&!/Mobile/.test(V)?"tablet":/Android|iPhone|Mobile/i.test(V)?"phone":"computer"}var Vt=[[/^SM-S93/,"Galaxy S25"],[/^SM-S92/,"Galaxy S24"],[/^SM-S91/,"Galaxy S23"],[/^SM-S90/,"Galaxy S22"],[/^SM-G99/,"Galaxy S21"],[/^SM-F9/,"Galaxy Z Fold"],[/^SM-F7/,"Galaxy Z Flip"],[/^SM-A5/,"Galaxy A5x"],[/^SM-A3/,"Galaxy A3x"],[/^SM-X/,"Galaxy Tab"]],Be="",Yt=(async()=>{var t;let e=navigator.userAgentData;if(!e||!/Android/.test(V))return"";try{let r=((t=(await e.getHighEntropyValues(["model"])).model)!=null?t:"").trim();if(!r||r==="K")return"";let s=Vt.find(([l])=>l.test(r));Be=s?`${s[1]} (${r})`:/^SM-/.test(r)?`Galaxy ${r}`:r}catch{}return Be})();function jt(e){return/iPhone/.test(V)?"iPhone":ot?"iPad":/Android/.test(V)?Be||(e==="tablet"?"Android tablet":"Android phone"):/CrOS/.test(V)?"Chromebook":/Mac OS X/.test(V)?"Mac":/Windows/.test(V)?"Windows PC":/Linux/.test(V)?"Linux PC":ge[e]}function zt(){if(!B)return;let e=it();if(e){be(e);return}let t=Le(),r=new Set(B.person.devices.map($=>$.name.toLowerCase())),s=$=>{let P=$===Le()?jt($):ge[$];if(!r.has(P.toLowerCase()))return P;for(let q=2;q<20;q++)if(!r.has(`${P} ${q}`.toLowerCase()))return`${P} ${q}`;return P},l=n("input",{type:"text",value:s(t),maxlength:48,"aria-label":"Device name",required:!0}),v=!1;l.addEventListener("input",()=>v=!0),Yt.then(()=>{!v&&t===Le()&&(l.value=s(t))});let A=n("div",{class:"kinds"},B.kinds.map($=>n("button",{type:"button",class:`kind${$===t?" on":""}`,"data-k":$,onclick:()=>{t=$,A.querySelectorAll(".kind").forEach(P=>P.classList.toggle("on",P.dataset.k===$)),v||(l.value=s($))}},U($),n("span",{},ge[$])))),E=n("p",{class:"err"}),N=n("button",{class:"btn primary block",type:"submit"},"Create connection");ce("Add a device",`${B.person.device_limit-B.person.devices.length} of ${B.person.device_limit} slots free`,n("form",{class:"add",onsubmit:async $=>{$.preventDefault(),N.disabled=!0,E.textContent="";try{let P=await ne("devices",{name:l.value.trim(),kind:t});B=P.state;let q=P.state.person.devices.find(O=>O.id===P.id);await de(q,void 0,P.config)}catch(P){if(P.httpsUrl){be(P.httpsUrl);return}E.textContent=P.message,N.disabled=!1}}},n("label",{class:"lbl"},"What is it?"),A,n("label",{class:"lbl"},"Name"),l,E,N))}async function Jt(){try{B=await ne("state"),document.title=`${B.person.name} · ${B.title}`,!ie&&!X&&fe(B)}catch(e){let t=e;t.status===404||t.status===401?(B=null,at()):B||Ne(n("div",{class:"card"},n("p",{},t.message)))}}!me||!Dt?at():Jt();})(); +"use strict";(()=>{var Dn=Object.create;var xt=Object.defineProperty;var Hn=Object.getOwnPropertyDescriptor;var Bn=Object.getOwnPropertyNames;var Nn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var In=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var On=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Bn(t))!Rn.call(e,s)&&s!==r&&xt(e,s,{get:()=>t[s],enumerable:!(a=Hn(t,s))||a.enumerable});return e};var zn=(e,t,r)=>(r=e!=null?Dn(Nn(e)):{},On(t||!e||!e.__esModule?xt(r,"default",{value:e,enumerable:!0}):r,e));var St=In((Et,$t)=>{"use strict";var Tt=(function(){var e=function(v,f){var d=236,k=17,u=v,x=r[f],l=null,o=0,L=null,m=[],C={},B=function(p,g){o=u*4+17,l=(function(c){for(var y=new Array(c),b=0;b=7&&J(p),L==null&&(L=K(u,x,m)),X(L,g)},N=function(p,g){for(var c=-1;c<=7;c+=1)if(!(p+c<=-1||o<=p+c))for(var y=-1;y<=7;y+=1)g+y<=-1||o<=g+y||(0<=c&&c<=6&&(y==0||y==6)||0<=y&&y<=6&&(c==0||c==6)||2<=c&&c<=4&&2<=y&&y<=4?l[p+c][g+y]=!0:l[p+c][g+y]=!1)},O=function(){for(var p=0,g=0,c=0;c<8;c+=1){B(!0,c);var y=s.getLostPoint(C);(c==0||p>y)&&(p=y,g=c)}return g},W=function(){for(var p=8;p>c&1)==1;l[Math.floor(c/3)][c%3+o-8-3]=y}for(var c=0;c<18;c+=1){var y=!p&&(g>>c&1)==1;l[c%3+o-8-3][Math.floor(c/3)]=y}},ae=function(p,g){for(var c=x<<3|g,y=s.getBCHTypeInfo(c),b=0;b<15;b+=1){var E=!p&&(y>>b&1)==1;b<6?l[b][8]=E:b<8?l[b+1][8]=E:l[o-15+b][8]=E}for(var b=0;b<15;b+=1){var E=!p&&(y>>b&1)==1;b<8?l[8][o-b-1]=E:b<9?l[8][15-b-1+1]=E:l[8][15-b-1]=E}l[o-8][8]=!p},X=function(p,g){for(var c=-1,y=o-1,b=7,E=0,P=s.getMaskFunction(g),_=o-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var q=0;q<2;q+=1)if(l[y][_-q]==null){var Q=!1;E>>b&1)==1);var H=P(y,_-q);H&&(Q=!Q),l[y][_-q]=Q,b-=1,b==-1&&(E+=1,b=7)}if(y+=c,y<0||o<=y){y-=c,c=-c;break}}},$=function(p,g){for(var c=0,y=0,b=0,E=new Array(g.length),P=new Array(g.length),_=0;_=0?yt.getAt(wt):0}}for(var bt=0,H=0;H_*8)throw"code length overflow. ("+b.getLengthInBits()+">"+_*8+")";for(b.getLengthInBits()+4<=_*8&&b.put(0,4);b.getLengthInBits()%8!=0;)b.putBit(!1);for(;!(b.getLengthInBits()>=_*8||(b.put(d,8),b.getLengthInBits()>=_*8));)b.put(k,8);return $(b,y)};C.addData=function(p,g){g=g||"Byte";var c=null;switch(g){case"Numeric":c=A(p);break;case"Alphanumeric":c=D(p);break;case"Byte":c=T(p);break;case"Kanji":c=R(p);break;default:throw"mode:"+g}m.push(c),L=null},C.isDark=function(p,g){if(p<0||o<=p||g<0||o<=g)throw p+","+g;return l[p][g]},C.getModuleCount=function(){return o},C.make=function(){if(u<1){for(var p=1;p<40;p++){for(var g=h.getRSBlocks(p,x),c=M(),y=0;y";for(var b=0;b';c+=""}return c+="",c+="",c},C.createSvgTag=function(p,g,c,y){var b={};typeof arguments[0]=="object"&&(b=arguments[0],p=b.cellSize,g=b.margin,c=b.alt,y=b.title),p=p||2,g=typeof g=="undefined"?p*4:g,c=typeof c=="string"?{text:c}:c||{},c.text=c.text||null,c.id=c.text?c.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 E=C.getModuleCount()*p+g*2,P,_,q,Q,H="",ee;for(ee="l"+p+",0 0,"+p+" -"+p+",0 0,-"+p+"z ",H+=''+Y(y.text)+"":"",H+=c.text?''+Y(c.text)+"":"",H+='',H+='":g+=">";break;case"&":g+="&";break;case'"':g+=""";break;default:g+=y;break}}return g},qe=function(p){var g=1;p=typeof p=="undefined"?g*2:p;var c=C.getModuleCount()*g+p*2,y=p,b=c-p,E,P,_,q,Q,H={"██":"█","█ ":"▀"," █":"▄"," ":" "},ee={"██":"▀","█ ":"▀"," █":" "," ":" "},te="";for(E=0;E=b?ee[Q]:H[Q];te+=` +`}return c%2&&p>0?te.substring(0,te.length-c-1)+Array(c+1).join("▀"):te.substring(0,te.length-1)};return C.createASCII=function(p,g){if(p=p||1,p<2)return qe(g);p-=1,g=typeof g=="undefined"?p*2:g;var c=C.getModuleCount()*p+g*2,y=g,b=c-g,E,P,_,q,Q=Array(p+1).join("██"),H=Array(p+1).join(" "),ee="",te="";for(E=0;E>>8),x.push(L&255)):x.push(k)}}return x}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={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 v=[[],[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]],f=1335,d=7973,k=21522,u={},x=function(l){for(var o=0;l!=0;)o+=1,l>>>=1;return o};return u.getBCHTypeInfo=function(l){for(var o=l<<10;x(o)-x(f)>=0;)o^=f<=0;)o^=d<5&&(L+=3+B-5)}for(var m=0;m=256;)u-=255;return v[u]},k})();function w(v,f){if(typeof v.length=="undefined")throw v.length+"/"+f;var d=(function(){for(var u=0;u>>7-k%8&1)==1},d.put=function(k,u){for(var x=0;x>>u-x-1&1)==1)},d.getLengthInBits=function(){return f},d.putBit=function(k){var u=Math.floor(f/8);v.length<=u&&v.push(0),k&&(v[u]|=128>>>f%8),f+=1},d},A=function(v){var f=t.MODE_NUMBER,d=v,k={};k.getMode=function(){return f},k.getLength=function(l){return d.length},k.write=function(l){for(var o=d,L=0;L+2>>8&255)*192+(m&255),l.put(m,13),L+=2}if(L>>8)},f.writeBytes=function(d,k,u){k=k||0,u=u||d.length;for(var x=0;x0&&(d+=","),d+=v[k];return d+="]",d},f},U=function(){var v=0,f=0,d=0,k="",u={},x=function(o){k+=String.fromCharCode(l(o&63))},l=function(o){if(!(o<0)){if(o<26)return 65+o;if(o<52)return 97+(o-26);if(o<62)return 48+(o-52);if(o==62)return 43;if(o==63)return 47}throw"n:"+o};return u.writeByte=function(o){for(v=v<<8|o&255,f+=8,d+=1;f>=6;)x(v>>>f-6),f-=6},u.flush=function(){if(f>0&&(x(v<<6-f),v=0,f=0),d%3!=0)for(var o=3-d%3,L=0;L=f.length){if(u==0)return-1;throw"unexpected end of file./"+u}var o=f.charAt(d);if(d+=1,o=="=")return u=0,-1;if(o.match(/^\s$/))continue;k=k<<6|l(o.charCodeAt(0)),u+=6}var L=k>>>u-8&255;return u-=8,L};var l=function(o){if(65<=o&&o<=90)return o-65;if(97<=o&&o<=122)return o-97+26;if(48<=o&&o<=57)return o-48+52;if(o==43)return 62;if(o==47)return 63;throw"c:"+o};return x},V=function(v,f){var d=v,k=f,u=new Array(v*f),x={};x.setPixel=function(m,C,B){u[C*d+m]=B},x.write=function(m){m.writeString("GIF87a"),m.writeShort(d),m.writeShort(k),m.writeByte(128),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(255),m.writeByte(255),m.writeByte(255),m.writeString(","),m.writeShort(0),m.writeShort(0),m.writeShort(d),m.writeShort(k),m.writeByte(0);var C=2,B=o(C);m.writeByte(C);for(var N=0;B.length-N>255;)m.writeByte(255),m.writeBytes(B,N,255),N+=255;m.writeByte(B.length-N),m.writeBytes(B,N,B.length-N),m.writeByte(0),m.writeString(";")};var l=function(m){var C=m,B=0,N=0,O={};return O.write=function(W,j){if(W>>>j)throw"length over";for(;B+j>=8;)C.writeByte(255&(W<>>=8-B,N=0,B=0;N=W<0&&C.writeByte(N)},O},o=function(m){for(var C=1<>6,128|i&63):i<55296||i>=57344?a.push(224|i>>12,128|i>>6&63,128|i&63):(s++,i=65536+((i&1023)<<10|r.charCodeAt(s)&1023),a.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return a}return t(e)}})();(function(e){typeof define=="function"&&define.amd?define([],e):typeof Et=="object"&&($t.exports=e())})(function(){return Tt})});function we(e){if(!e||e<0)return"0 B";let t=["B","KB","MB","GB","TB"],r=0,a=e;for(;a>=1024&&r=100||r===0?Math.round(a):a.toFixed(1)} ${t[r]}`}function Ue(e,t=Date.now()/1e3){if(!e)return"never";let r=Math.max(0,Math.round(t-e));return r<60?"just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} h ago`:r<86400*30?`${Math.floor(r/86400)} d ago`:new Date(e*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function _e(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function Pe(e){let[t,r,a]=e.split("-").map(Number);return new Date(t,(r||1)-1,a||1,12)}function Gn(e){return(typeof e=="string"?/^\d{4}-\d{2}-\d{2}$/.test(e)?Pe(e):new Date(e):e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function We(e){return e?Gn(e):""}function Kn(e,t){let r=a=>{let[s,i,w]=a.split("-").map(Number);return Date.UTC(s,i-1,w)};return Math.round((r(e)-r(t))/864e5)}function Mt(e,t){let r=Pe(e);return r.setDate(r.getDate()+t),_e(r)}function Ve(e,t=Date.now()){if(!e)return null;let r=typeof t=="number"?_e(new Date(t)):t,a=Kn(e,r);return a>=0?a+1:a}function Ye(e,t){return t!=null&&t>0&&e.expire_warn>0&&t<=e.expire_warn}function Ct(e){return e<=1?"ends today":e===2?"ends tomorrow":`ends in ${e} days`}var kt={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var De={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"};function Lt(e){var s,i,w;let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let r=(s=t[0][0])!=null?s:"",a=t.length>1?(i=t[t.length-1][0])!=null?i:"":(w=t[0][1])!=null?w:"";return(r+a).toUpperCase()}function Qe(e){let t=r=>r.disabled?3:r.online?0:r.handshake?1:2;return e.map((r,a)=>[r,a]).sort((r,a)=>t(r[0])-t(a[0])||r[1]-a[1]).map(([r])=>r)}var At={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',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 He(e,t="dl-icon"){var a;let r=(a=At[e])!=null?a:At.phone;return``}var Pt=zn(St(),1),qn=e=>``,_t="#0a0a0a",je="#f2f2f2",Ze=e=>e.length>300,be=e=>+e.toFixed(2);function Je(e,t,r,a,s){return`M${be(e+s)} ${be(t)}h${be(r-2*s)}a${s} ${s} 0 0 1 ${s} ${s}v${be(a-2*s)}a${s} ${s} 0 0 1 -${s} ${s}h-${be(r-2*s)}a${s} ${s} 0 0 1 -${s} -${s}v-${be(a-2*s)}a${s} ${s} 0 0 1 ${s} -${s}z`}function Dt(e,t=3,r=!0,a="plain"){let s=Ze(e),i=a==="night",w=(0,Pt.default)(0,s?"L":"H");w.addData(e,"Byte"),w.make();let h=w.getModuleCount(),M=h+t*2,A=r&&!s?Math.round(h*.22):0;A&&(h-A)%2&&A++;let D=(h-A)/2,T=D+A,R=(v,f)=>A>0&&v>=D&&v=D&&fi&&(f<7&&v<7||f<7&&v>=h-7||f>=h-7&&v<7),U="";if(i){let v=s?.48:.42;for(let f=0;f${qn(i?_t:"#fff")}`}let G=``;return i?`${G}${V}`:`${G}${V}`}var Fn={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:""},Un={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 Wn(e){let t={};for(let[r,a]of Object.entries(Un))e[r]!=null&&e[r]!==""&&(t[a]=String(e[r]));return t}function Vn(e,t){var M;let r=e.amnezia,a=(M=r.obfuscation)!=null?M:{},s=A=>a[A]!=null&&a[A]!==""?String(a[A]):Fn[A],i=r.host.replace(/^\[(.*)\]$/,"$1"),w={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"),...Wn(a),allowed_ips:r.allowed_ips,client_ip:r.client_ip,client_priv_key:r.client_priv_key,client_pub_key:r.client_pub_key,config:e.conf.replace(/\r?\n/g,`\r +`),hostName:i,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},h={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(w),port:String(r.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:i};return r.dns[0]&&(h.dns1=r.dns[0]),r.dns[1]&&(h.dns2=r.dns[1]),h}function Yn(e){let t="";for(let r=0;r{i==null||i===!1||(Array.isArray(i)?i.forEach(s):a.appendChild(typeof i=="string"?document.createTextNode(i):i))};return r.forEach(s),a}function I(e){let t=n("span",{class:"ic"});return t.innerHTML=He(e,"ic-svg"),t}var ie=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,oe={out:"cubic-bezier(0.23, 1, 0.32, 1)",in:"cubic-bezier(0.55, 0, 1, 0.45)",drawer:"cubic-bezier(0.32, 0.72, 0, 1)"};function Ht(e){var r;let t=e.closest(".sheet-panel");return t?(t.dataset.hold=String(+((r=t.dataset.hold)!=null?r:0)+1),()=>{var s;let a=+((s=t.dataset.hold)!=null?s:1)-1;a>0?t.dataset.hold=String(a):delete t.dataset.hold}):()=>{}}function jn(e,t){return e<=0||t<=0?0:(1-1/(e*.55/t+1))*t}function Jn(e,t,r){return e<=0||t<-.1?!1:t>.4||e>r/3}var Bt=e=>Math.round(Math.min(380,Math.max(220,200+e*.35)));function ne(e,t){e.classList.remove(t),e.offsetWidth,e.classList.add(t)}function Nt(e,t){let r=0,a=0,s=!1,i=null,w=new ResizeObserver(()=>{if(e.dataset.hold){i==null||i.cancel(),e.classList.remove("morphing","morphing-w"),r=e.offsetHeight,a=e.offsetWidth;return}let h=getComputedStyle(e),M=i?parseFloat(h.height):r,A=i?parseFloat(h.width):a;i==null||i.cancel(),e.classList.remove("morphing","morphing-w");let D=e.offsetHeight,T=e.offsetWidth,R=e.dataset.morph==="width"||s;delete e.dataset.morph;let z=a!==0&&T!==a;if(r=D,a=T,!M||ie()||z&&!R)return;let U=Math.abs(D-M),F=R?Math.abs(T-A):0;if(U<2&&F<2)return;s=F>=2,e.classList.add("morphing"),e.classList.toggle("morphing-w",s);let V=e.animate(s?[{height:`${M}px`,width:`${A}px`},{height:`${D}px`,width:`${T}px`}]:[{height:`${M}px`},{height:`${D}px`}],{duration:Bt(Math.max(U,F)),easing:oe.out});i=V;let G=()=>{i===V&&(i=null,s=!1,e.classList.remove("morphing","morphing-w"))};V.onfinish=G,V.oncancel=G});return w.observe(t),()=>w.disconnect()}function et(e,t,r=0){let a=[...e.childNodes];if(!a.length||!e.isConnected){e.replaceChildren(...t);return}let s=getComputedStyle(e),i=document.createElement("div");i.className="ghost",i.setAttribute("aria-hidden","true"),i.inert=!0,Object.assign(i.style,{display:s.display==="flex"?"flex":"block",flexDirection:s.flexDirection,alignItems:s.alignItems,gap:s.gap,top:s.paddingTop,left:s.paddingLeft,right:s.paddingRight}),i.append(...a),e.replaceChildren(i,...t);let w=ie(),h=i.animate([{opacity:1,transform:"none"},{opacity:0,transform:w?"none":`translateX(${-r*8}px)`}],{duration:120,easing:oe.out,fill:"forwards"}),M=()=>i.remove();h.onfinish=M,h.oncancel=M;for(let A of t)A instanceof HTMLElement&&A.animate(w?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translate(${r*12}px, ${r?0:6}px)`,filter:"blur(4px)"},{opacity:1,transform:"none",filter:"blur(0)"}],{duration:w?160:280,delay:50,easing:oe.out,fill:"backwards"})}function Rt(e){return!e||!e.isConnected?Promise.resolve():e.animate(ie()?[{opacity:1},{opacity:0}]:[{opacity:1,transform:"none",filter:"blur(0)"},{opacity:0,transform:"scale(0.96)",filter:"blur(4px)"}],{duration:200,easing:oe.in,fill:"forwards"}).finished.then(()=>{},()=>{})}var It=e=>new Promise(t=>setTimeout(t,ie()?0:e)),Ce={ms:520,contentMs:300,blur:4,drift:6,scale:.98};async function Ot(e){if(!e.isConnected)return;let t=Ht(e),r=parseFloat(getComputedStyle(e.parentElement).rowGap)||0,a=e.offsetHeight;e.style.overflow="hidden",e.style.transformOrigin="50% 0",e.inert=!0;let s=()=>{};ie()?await e.animate([{opacity:1},{opacity:0}],{duration:160,easing:oe.out,fill:"forwards"}).finished.then(s,s):(e.animate([{opacity:1,filter:"blur(0px)",transform:"none"},{opacity:0,filter:`blur(${Ce.blur}px)`,transform:`translateY(${-Ce.drift}px) scale(${Ce.scale})`}],{duration:Ce.contentMs,easing:oe.out,fill:"forwards"}),await e.animate([{height:`${a}px`,marginTop:"0px"},{height:"0px",marginTop:`${-r}px`}],{duration:Ce.ms,easing:oe.drawer,fill:"forwards"}).finished.then(s,s)),e.remove(),t()}function zt(e){if(!e.isConnected||ie())return ne(e,"swap");let t=Ht(e),r=parseFloat(getComputedStyle(e.parentElement).rowGap)||0,a=e.offsetHeight;e.style.overflow="hidden";let s=e.animate([{height:"0px",marginTop:`${-r}px`,opacity:0,filter:"blur(4px)"},{height:`${a}px`,marginTop:"0px",opacity:1,filter:"blur(0px)"}],{duration:380,easing:oe.drawer}),i=()=>{e.style.overflow="",t()};s.onfinish=i,s.oncancel=i}function Gt(e,t){let r=[...e.querySelectorAll(t)].map(a=>({el:a,r:a.getBoundingClientRect()}));r.sort((a,s)=>Math.round(a.r.top-s.r.top)||a.r.left-s.r.left),r.forEach(({el:a},s)=>{a.style.setProperty("--i",String(Math.min(s,8))),a.classList.add("intro")})}function Kt(e){let t=new Map,r=new Map;return e.querySelectorAll("[data-key]").forEach(a=>{let s=a.getBoundingClientRect();t.set(a.dataset.key,{x:s.left+scrollX,y:s.top+scrollY})}),e.querySelectorAll("[data-v]").forEach(a=>{var s;return r.set(a.dataset.v,(s=a.textContent)!=null?s:"")}),{at:t,text:r}}function qt(e,t){let r=ie();e.querySelectorAll("[data-key]").forEach(a=>{let s=t.at.get(a.dataset.key);if(!s){a.classList.add("enter");return}if(r)return;let i=a.getBoundingClientRect(),w=s.x-(i.left+scrollX),h=s.y-(i.top+scrollY);Math.abs(w)<1&&Math.abs(h)<1||a.animate([{transform:`translate(${w}px, ${h}px)`},{transform:"none"}],{duration:Bt(Math.hypot(w,h)),easing:oe.out})}),e.querySelectorAll("[data-v]").forEach(a=>{let s=t.text.get(a.dataset.v);s!=null&&s!==a.textContent&&a.classList.add("swap")})}function Ft(e,t){let r=h=>h.classList.contains("on")||h.classList.contains("open"),a=h=>{var M,A;return(A=(M=h.dataset.sig)!=null?M:h.textContent)!=null?A:""},s=h=>{let M=h.getBoundingClientRect(),A=h.parentElement.getBoundingClientRect();return{x:M.left-A.left,y:M.top-A.top}},i=new Map;e.querySelectorAll("[data-m]").forEach(h=>i.set(h.dataset.m,{on:r(h),says:a(h)}));let w=new Map;e.querySelectorAll("[data-glide]").forEach(h=>w.set(h.dataset.glide,s(h))),t(),ie()||e.querySelectorAll("[data-glide]").forEach(h=>{let M=w.get(h.dataset.glide);if(!M)return;let A=s(h),D=M.x-A.x,T=M.y-A.y;(Math.abs(D)>=1||Math.abs(T)>=1)&&h.animate([{transform:`translate(${D}px, ${T}px)`},{transform:"none"}],{duration:280,easing:oe.out})}),e.querySelectorAll("[data-m]").forEach(h=>{let M=i.get(h.dataset.m);M&&(M.on!==r(h)?h.classList.add(r(h)?"to-on":"to-off"):M.says!==a(h)&&h.classList.add("swap"))})}function tt(e){let t=e.cloneNode(!0);t.classList.add("slide-hl"),t.setAttribute("aria-hidden","true"),t.inert=!0,t.removeAttribute("role"),t.querySelectorAll("[role]").forEach(s=>s.removeAttribute("role")),e.classList.add("slides"),e.appendChild(t);let r=!1,a=()=>{let s=e.querySelector(":scope > .on");if(!s||!e.isConnected)return;let i=e.clientWidth,w=e.clientHeight,h=s.offsetLeft,M=s.offsetTop;t.classList.toggle("placed",r),t.style.clipPath=`inset(${M}px ${i-h-s.offsetWidth}px ${w-M-s.offsetHeight}px ${h}px round 999px)`,r=!0};return new ResizeObserver(()=>{r=!1,a()}).observe(e),a}var Xe=new WeakMap;function Ut(e,t){var h,M,A,D,T,R;if(!e)return;let r=e.querySelector(".ic"),a=(M=(h=e.querySelector(".badge-main"))!=null?h:e.querySelector(":scope > span:not(.ic)"))!=null?M:e.children.length?null:e,s=(T=Xe.get(e))!=null?T:{timer:0,icon:(A=r==null?void 0:r.innerHTML)!=null?A:null,label:(D=a==null?void 0:a.textContent)!=null?D:null};clearTimeout(s.timer);let i=!!a&&(a.classList.contains("badge-main")||/^copy$/i.test((R=s.label)!=null?R:"")),w=(z,U)=>{r&&z!=null&&r.innerHTML!==z&&(r.innerHTML=z,ne(r,"swap-ic")),a&&i&&U!=null&&a.textContent!==U&&(a.textContent=U,ne(a,"swap"))};w(t,"Copied"),e.classList.add("copied"),s.timer=window.setTimeout(()=>{Xe.delete(e),e.classList.remove("copied"),w(s.icon,s.label)},1600),Xe.set(e,s)}function nt(e){let t=window.setTimeout(()=>e.classList.add("busy"),250);return()=>{clearTimeout(t),e.classList.remove("busy")}}function Wt(e,t,r,a){e.addEventListener("pointerdown",s=>{let i=s.target;if(!a()||s.button!==0||!i.closest(".grab, .sheet-head, .ask")||i.closest("button, a, input"))return;let w=s.clientY,h=e.offsetHeight,M=0,A=[{t:s.timeStamp,y:s.clientY}];try{e.setPointerCapture(s.pointerId)}catch{}e.classList.add("dragging");let D=R=>{let z=R.clientY-w;for(M=z<0?-jn(-z,h):z,e.style.transform=`translateY(${M}px)`,t.style.opacity=String(1-Math.max(0,M)/h),A.push({t:R.timeStamp,y:R.clientY});A.length>2&&R.timeStamp-A[0].t>100;)A.shift()},T=R=>{e.removeEventListener("pointermove",D),e.removeEventListener("pointerup",T),e.removeEventListener("pointercancel",T);let z=A[0],U=A[A.length-1],F=U.t>z.t?(U.y-z.y)/(U.t-z.t):0;e.classList.remove("dragging"),e.style.transform="",t.style.opacity="",R.type==="pointerup"&&Jn(M,F,h)&&r()};e.addEventListener("pointermove",D),e.addEventListener("pointerup",T),e.addEventListener("pointercancel",T)})}function rt(e){let t=n("span",{class:"strong s"},"Waiting for the connection"),r=n("span",{class:"faint s"}),a=n("span",{class:"way-end home"},I("server")),s=n("div",{class:"way",role:"status","aria-live":"polite"},n("div",{class:"way-row"},n("span",{class:"way-end"},I(e)),n("span",{class:"way-track"},n("span",{class:"way-glow"},n("i")),n("span",{class:"way-fill"})),a),n("div",{class:"way-text"},t,r)),i=(w,h)=>{if(t.textContent!==w&&(t.textContent=w,ne(t,"swap")),r.textContent===h)return;let M=!r.textContent;r.textContent=h,M?zt(r):ne(r,"swap")};return{el:s,connected:()=>{s.classList.add("done"),i("Connected","You’re all set.")},gaveUp:()=>{s.classList.add("stopped"),i("No connection yet","Close this and open it again to keep checking.")}}}var se={vpn:"AmneziaVPN",awg:"AmneziaWG",wg:"WireGuard"};function Yt(e,t=0){return/iPhone|iPad|iPod/.test(e)||/Macintosh/.test(e)&&t>1?"ios":/Android/.test(e)?"android":/Windows/.test(e)?"windows":/Mac OS X|Macintosh/.test(e)?"mac":/CrOS/.test(e)?"unknown":/Linux|X11/.test(e)?"linux":"unknown"}var Qt=e=>/Telegram|FBAN|FBAV|Instagram|VKClient|Line\//i.test(e);function jt(e,t){return e==="router"||t==="unknown"?!1:e==="phone"||e==="tablet"?t==="ios"||t==="android":e==="computer"?t==="windows"||t==="mac"||t==="linux":!0}var Jt=e=>e==="computer"||e==="other"?["windows","mac","linux"]:[];function Zt(e){let t={off:{vpn:"",awg:""},balanced:{vpn:"4.8.12",awg:"2.0"},max:{vpn:"current",awg:"3.1"},legacy:{vpn:"",awg:""}}[e],r=[{id:"vpn",name:se.vpn,need:t.vpn,sub:"Connects from a link, no files"},{id:"awg",name:se.awg,need:t.awg,sub:"The light client: a file or a QR code"}];return e==="off"&&r.push({id:"wg",name:se.wg,need:"",sub:"Any WireGuard app: this server has no disguise"}),r}function ke(e){return e.need?`This server needs ${e.need==="current"?`the current version of ${e.name}`:`${e.name} ${e.need} or newer`}. Installed a while ago? Update it in the store.`:""}var Ne="https://github.com/amnezia-vpn/amnezia-client/releases/latest",Vt={href:Ne,top:"APK file on",main:"GitHub",mark:"github",why:"The APK is for phones without Google Play, or where the store hides the app."};function at(e,t){var a;return(a={vpn:{ios:{href:"https://apps.apple.com/app/amneziavpn/id1600529900",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=org.amnezia.vpn",top:"Get it on",main:"Google Play",mark:"googleplay",alt:Vt},windows:{href:Ne,top:"Official release on GitHub",main:"Download for Windows",mark:"windows"},mac:{href:Ne,top:"Official release on GitHub",main:"Download for Mac",mark:"apple"},linux:{href:Ne,top:"Official release on GitHub",main:"Download for Linux",mark:"linux"}},awg:{ios:{href:"https://apps.apple.com/us/app/amneziawg/id6478942365",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=org.amnezia.awg",top:"Get it on",main:"Google Play",mark:"googleplay",alt:{...Vt,href:"https://github.com/amnezia-vpn/amneziawg-android/releases"}},windows:{href:"https://github.com/amnezia-vpn/amneziawg-windows-client/releases",top:"Official release on GitHub",main:"Download for Windows",mark:"windows"},mac:{href:"https://apps.apple.com/us/app/amneziawg/id6478942365",top:"Download on the",main:"Mac App Store",mark:"appstore"},linux:{href:"https://github.com/amnezia-vpn/amneziawg-tools",top:"On GitHub",main:"amneziawg-tools",mark:"linux"}},wg:{ios:{href:"https://apps.apple.com/app/wireguard/id1441195209",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=com.wireguard.android",top:"Get it on",main:"Google Play",mark:"googleplay"},windows:{href:"https://www.wireguard.com/install/",top:"Download from",main:"wireguard.com",mark:"windows"},mac:{href:"https://apps.apple.com/app/wireguard/id1451685025",top:"Download on the",main:"Mac App Store",mark:"appstore"},linux:{href:"https://www.wireguard.com/install/",top:"Install from",main:"wireguard.com",mark:"linux"}}}[e][t])!=null?a:null}var st=e=>e==="wg"?{href:"https://openwrt.org/docs/guide-user/services/vpn/wireguard/start",top:"OpenWrt packages",main:"wireguard-tools",mark:"openwrt"}:{href:"https://openwrt.org/packages/start",top:"OpenWrt packages",main:"amneziawg-tools + kmod",mark:"openwrt"},Xt=e=>e==="vpn"?"Add server → Scan QR":e==="awg"?"Add tunnel → Scan QR code":"Add tunnel → Create from QR code",ot=e=>e==="vpn"?"Add server → Insert key":"Add tunnel → Import from file",Re={ios:"iPhone / iPad",android:"Android",windows:"Windows",mac:"Mac",linux:"Linux",unknown:"this device"},en=(e,t)=>`${e}#setup=${t}`;function tn(e){var t,r;return(r=(t=/^#setup=(d_[0-9a-f]{8})$/.exec(e))==null?void 0:t[1])!=null?r:null}var nn=e=>({phone:"phone",tablet:"tablet",computer:"computer",router:"router",other:"device"})[e],rn=e=>({ios:"This iPhone",android:"This phone",windows:"This PC",mac:"This Mac",linux:"This PC",unknown:"This device"})[e];var ht=()=>{var e;return(e=S==null?void 0:S.today)!=null?e:_e(new Date)},mt=()=>{var e;return(e=S==null?void 0:S.now)!=null?e:Date.now()/1e3},Me=document.getElementById("app"),pn,Ie=(pn=Me.dataset.base)!=null?pn:"",Zn=Me.dataset.title||"Dawnline",fn=()=>window.matchMedia("(max-width: 959px)").matches||/Android|iPhone|iPad/.test(navigator.userAgent),S=null,Xn=/^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(Ie)?Ie.slice(1):"",ct=class extends Error{constructor(r,a,s){super(a);this.status=r;this.httpsUrl=s}};async function he(e,t){var s;let r=await fetch(`${Ie}/api/${e}`,{method:t===void 0?"GET":"POST",credentials:"omit",headers:t===void 0?{}:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t),cache:"no-store"}),a=null;try{a=await r.json()}catch{}if(!r.ok)throw new ct(r.status,(s=a==null?void 0:a.error)!=null?s:`Request failed (${r.status})`,(a==null?void 0:a.https_url)||void 0);return a}var Le=null;function an(e){Le===e&&(Le=null),e.classList.remove("show"),e.classList.add("gone"),setTimeout(()=>e.remove(),200)}function fe(e,t=!1){Le&&an(Le);let r=n("div",{class:`toast${t?" bad":""}`,role:"status"},e);document.body.appendChild(r),r.offsetWidth,r.classList.add("show"),Le=r,setTimeout(()=>an(r),2600)}async function ue(e,t="Copied",r){try{await navigator.clipboard.writeText(e)}catch{let a=n("textarea",{class:"offscreen"},e);document.body.appendChild(a),a.select();let s=document.execCommand("copy");if(a.remove(),!s)return fe("Copying is blocked here. Select the text and copy it by hand.",!0)}Ut(r instanceof HTMLElement?r:null,He("check","ic-svg")),fe(t)}function ut(e){var a;let t=navigator;if(!/Android|iPhone|iPad/.test(navigator.userAgent)||typeof t.share!="function"||typeof File=="undefined")return null;let r=new File([e.conf],e.filename,{type:"application/octet-stream"});return(a=t.canShare)!=null&&a.call(t,{files:[r]})?async()=>{try{await t.share({files:[r],title:e.filename})}catch(s){(s==null?void 0:s.name)!=="AbortError"&&ze(e.filename,e.conf)}}:null}function ze(e,t){let r=URL.createObjectURL(new Blob([t],{type:"application/octet-stream"})),a=n("a",{href:r,download:e,class:"offscreen"});document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),a.remove()},1e3)}var le=null;function hn(e,t){let r=a=>{le!=null||(le=document.body.appendChild(n("div",{class:"tip",role:"tooltip"}))),le.replaceChildren(...t().map((s,i)=>n("div",{class:i?"muted":"tip-title"},s))),le.style.left=`${a.clientX}px`,le.style.top=`${a.clientY-10}px`,le.classList.add("show")};e.addEventListener("mouseenter",r),e.addEventListener("mousemove",r),e.addEventListener("mouseleave",()=>le==null?void 0:le.classList.remove("show"))}function er(e){let t=Math.max(1,...e),r=n("div",{class:"spark"});return e.forEach((a,s)=>{let i=n("i",{class:a?"":"zero"});i.style.height=`${Math.max(8,a/t*100)}%`,i.style.setProperty("--i",String(s));let w=e.length-1-s;hn(i,()=>[w===0?"Today":w===1?"Yesterday":Pe(Mt(ht(),-w)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),we(a)]),r.appendChild(i)}),r}async function mn(e,t){if(e.disabled)return;e.disabled=!0;let r=nt(e);try{await t()}finally{r(),e.disabled=!1}}var re=null,ce=null,gn=()=>window.matchMedia("(max-width: 639px)").matches,Ee=!1;window.addEventListener("popstate",()=>{re&&(Ee=!1,de())});function de(e=!1){if(!re)return;let t=re;if(re=null,Ee&&(Ee=!1,history.back()),document.body.classList.remove("locked"),ce==null||ce(),ce=null,e){t.remove();return}t.classList.remove("open"),t.classList.add("closing"),setTimeout(()=>t.remove(),gn()?320:180)}function vn(e,t,r=!1){if(re){ce==null||ce(),ce=null;let h=re.querySelector(".sheet-panel");h.setAttribute("aria-label",e),h.setAttribute("role",r?"alertdialog":"dialog"),h.classList.contains("asks")!==r&&(h.dataset.morph="width",h.classList.toggle("asks",r)),h.scrollTop=0,et(h.querySelector(".sheet-inner"),t);return}let a=n("div",{class:"sheet-inner"},...t),s=n("div",{class:`sheet-panel${r?" asks":""}`,role:r?"alertdialog":"dialog","aria-modal":"true","aria-label":e},n("div",{class:"grab"}),a),i=n("div",{class:"scrim",onclick:()=>de()}),w=n("div",{class:"sheet fresh"},i,s);if(a.querySelectorAll(":scope > .sheet-head, .sheet-body > :not(.setup), .setup > *").forEach((h,M)=>h.style.setProperty("--i",String(Math.min(M,6)))),document.body.appendChild(w),document.body.classList.add("locked"),!Ee)try{history.pushState({sheet:!0},""),Ee=!0}catch{}Nt(s,a),Wt(s,i,()=>de(),gn),w.offsetWidth,w.classList.add("open"),setTimeout(()=>w.classList.remove("fresh"),700),re=w}function $e(e,t,...r){vn(e,[n("div",{class:"sheet-head"},n("div",{class:"stack"},n("h2",{},e),t?n("span",{class:"muted s"},t):null),n("button",{class:"icon-btn","aria-label":"Close",onclick:()=>de()},I("x"))),n("div",{class:"sheet-body"},...r)])}function yn(e){vn(e.title,[n("div",{class:"ask"},n("span",{class:`ask-ic ${e.tone}`},I(e.icon)),n("h2",{},e.title),n("p",{class:"muted"},e.text),n("div",{class:"row gap ask-actions"},n("button",{type:"button",class:"btn block",onclick:()=>de()},"Cancel"),n("button",{type:"button",class:`btn ${e.actionClass} block`,onclick:t=>mn(t.currentTarget,e.run)},e.action)))],!0)}document.addEventListener("keydown",e=>{e.key==="Escape"&&(Ae(!0),de(!0))});var ve=null,xe=null;function Ae(e=!1){let t=ve;if(t){if(ve=null,xe==null||xe.setAttribute("aria-expanded","false"),xe=null,e){t.remove();return}t.classList.remove("show"),t.classList.add("gone"),setTimeout(()=>t.remove(),150)}}document.addEventListener("click",e=>{ve&&!ve.contains(e.target)&&Ae()});function tr(e,t){if(xe===e)return Ae();Ae();let r=t.filter((M,A)=>M||A>0&&t[A-1]&&t.slice(A+1).some(Boolean)),a=n("div",{class:"menu",role:"menu"},r.map(M=>M?n("button",{type:"button",role:"menuitem",class:`menu-item${M.danger?" danger":""}`,onclick:()=>{Ae(),M.run()}},I(M.icon),n("span",{},M.label)):n("div",{class:"menu-sep"})));document.body.appendChild(a);let s=e.getBoundingClientRect(),i=230,w=a.offsetHeight,h=s.bottom+6+w>window.innerHeight-8&&s.top-6-w>8;a.classList.toggle("up",h),a.style.left=`${Math.max(8,Math.min(window.innerWidth-i-8,s.right-i))}px`,a.style.top=`${(h?s.top-6-w:s.bottom+6)+window.scrollY}px`,a.offsetWidth,a.classList.add("show"),e.setAttribute("aria-expanded","true"),ve=a,xe=e}var nr='',rr=".alert, .hello, .card-head, .access-card, .dcard, .slot.add, .firststeps, .devices > .faint, .signin, .wrap > .card",it=!1;function gt(...e){let t=it?Kt(Me):null,r=it?"":" first",a=n("main",{class:`wrap${r}`},...e);Me.replaceChildren(n("header",{class:`top${r}`},n("div",{class:"brand"},(()=>{let s=n("span",{class:"logo"});return s.innerHTML=nr,s})(),n("span",{},(S==null?void 0:S.server.name)||Zn),n("span",{class:"faint"},"· Dawnline"))),a),t?qt(Me,t):Gt(a,rr),it=!0}function wn(){gt(n("div",{class:"card signin","data-key":"gone"},n("div",{class:"hero-ic"},I("key")),n("h1",{},"This link no longer works"),n("p",{class:"muted"},"Ask for a new personal link.")))}function ar(e){switch(e.state){case"server_off":return["server","The server is turned off","Your devices can’t connect until the admin turns it on again."];case"no_server":return["server","No server yet","Ask the admin to add you to a server."];case"quota":return["chart","You have used all your data","Your devices stay connected but nothing gets through until it resets."];case"expired":return["calendar","Your access has ended","Ask the admin to extend it."];case"hours":return["clock","Outside your hours",`Access is available ${e.hours.replace("-","–")} (router time); until then nothing gets through.`];default:return["pause","Your access is paused by the admin","Your devices can’t connect until the admin resumes it."]}}function sn(e,t,r,a){return n("div",{class:"alert","data-key":"notice"},n("span",{class:`alert-ic ${e}`},I(t)),n("div",{class:"stack"},n("span",{class:"strong"},r),n("span",{class:"muted s"},a)))}function sr(e){return e.state==="active"?"ok":e.state==="quota"||e.state==="expired"?"bad":"warn"}var or={internet:"The internet, through the router",lan:"Devices at home",both:"Devices at home and the internet, through the router"};function ir(e){let t=e.person,r=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,a=n("div",{class:`meter${r>=100?" bad":r>=90?" warn":""}`},n("i"));a.firstChild.style.width=`${r}%`,t.quota_limit&&hn(a,()=>[`${r.toFixed(1)}% used`,`${we(Math.max(0,t.quota_limit-t.quota_used))} left`]);let s=Ve(t.expires,ht()),i=n("div",{class:"slots"});for(let M=0;M=t.device_limit?"over":M=0?`${s} day${s===1?"":"s"} left`:"ended"):null)),n("span",{class:"faint s"},t.hours?`Available ${t.hours.replace("-","–")} (router time). Need a change? Ask the admin.`:"Need a change? Ask the admin.")))}function lr(e,t){return e.disabled?n("span",{class:"dstat"},"Disabled by the admin"):e.config_stale&&e.handshake?n("span",{class:"dstat warn"},"Settings changed, update needed"):e.online&&t.state==="quota"?n("span",{class:"dstat warn"},"Connected, no data left"):e.online&&t.state==="hours"?n("span",{class:"dstat warn"},"Connected, outside your hours"):e.online?n("span",{class:"dstat ok"},"Connected"):e.handshake?n("span",{class:"dstat",title:new Date(e.handshake*1e3).toLocaleString()},`Last connected ${Ue(e.handshake,mt())}`):n("span",{class:"dstat warn"},"Not set up yet")}function bn(e,t){return e.access!=="internet"&&e.state==="active"&&!t.disabled}function cr(e,t){let r=Qe(e.devices).filter(i=>i.hostname&&bn(e,i));if(!r.length)return null;let a=r[0].hostname,s=a.slice(a.indexOf("."));return n("div",{class:"names"},n("div",{class:"names-head"},n("span",{class:"names-ic"},I("home")),n("div",{class:"stack"},n("span",{class:"strong s"},"Names at home"),n("span",{class:"faint s"},t?"Devices at home and on this VPN reach yours as ":"Other devices at home reach yours as ",n("span",{class:"mono"},`name${s}`)))),n("div",{class:"names-list"},r.map(i=>{let w=i.hostname.indexOf(".");return n("button",{type:"button",class:"name-chip",title:i.name,"aria-label":`Copy ${i.hostname}`,onclick:h=>ue(i.hostname,"Address copied",h.currentTarget)},n("span",{class:"mono"},w>0?[i.hostname.slice(0,w),n("span",{class:"faint"},i.hostname.slice(w))]:i.hostname),I("copy"))})))}function ur(e,t){let r=n("button",{type:"button",class:"icon-btn soft","aria-label":`${e.name} options`,"aria-haspopup":"menu","aria-expanded":"false"},I("more"));r.addEventListener("click",M=>{M.stopPropagation(),tr(r,[{label:"Show QR code",icon:"qr",run:()=>pt(e,"qr")},{label:"Copy AmneziaVPN key",icon:"key",run:()=>fr(e)},{label:"Download .conf",icon:"download",run:()=>hr(e)},null,...bn(t.person,e)?[{label:"Copy IP address",icon:"copy",run:()=>ue(e.address,"IP address copied")},...e.hostname?[{label:"Copy local address",icon:"home",run:()=>ue(e.hostname,"Address copied")}]:[],null]:[],...e.disabled?[]:[{label:"Rename",icon:"edit",run:()=>wr(e)},{label:"New keys",icon:"reset",run:()=>br(e,t)},{label:"Remove",icon:"trash",danger:!0,run:()=>xr(e)}]])});let a=e.spark.reduce((M,A)=>M+A,0),s=!e.handshake&&!e.disabled,i=!!t.locked,w=t.here===e.id,h=w?n("span",{class:"dstat here"},"This device"):lr(e,t.person);return h.dataset.v=`stat:${e.id}`,n("article",{class:`dcard${e.online?" online":""}${e.disabled?" off":""}${w?" here":""}`,"data-key":e.id},n("div",{class:"dhead"},n("span",{class:"dic"},I(e.kind)),n("div",{class:"stack grow"},n("span",{class:"dname","data-v":`name:${e.id}`},e.name),h),i?null:r),s&&i?null:s?[n("button",{type:"button",class:"btn primary block",onclick:()=>Ke(e)},I("arrow"),n("span",{},`Set up ${e.name}`))]:n("div",{class:"duse"},n("div",{class:"stack"},n("span",{class:"faint s"},"Last 7 days"),n("span",{class:"mono","data-v":`week:${e.id}`},we(a))),er(e.spark)),e.config_stale&&!s&&!i?n("button",{type:"button",class:"btn block",onclick:()=>pt(e)},I("refresh"),n("span",{},"Update the connection")):null)}function ye(e){let t=e.person,r=Ve(t.expires,ht()),a=t.state!=="active"?sn(sr(t),...ar(t)):Ye(t,r)?sn("warn","calendar",`Your access ${Ct(r)}`,`On ${We(t.expires)}. Ask the admin to extend it.`):null,i=Qe(t.devices).sort((M,A)=>+(A.id===e.here)-+(M.id===e.here)).map(M=>ur(M,e)),w=e.locked?0:Math.max(0,t.device_limit-t.devices.length);!t.devices.length&&w?i.push(n("div",{class:"card firststeps","data-key":"first"},n("h2",{},"Add your first device"),n("p",{class:"muted"},"Two steps, about a minute: get the app, then add the connection. The next screen shows both for the device you pick."),n("button",{type:"button",class:"btn primary block big",onclick:dn},I("plus"),n("span",{},fn()?"Add this phone":"Add this device")))):w&&i.push(n("button",{type:"button",class:"slot add",onclick:dn,"data-key":"add"},n("span",{class:"slot-ic"},I("plus")),n("span",{class:"strong"},"Add device")));let h=n("section",{class:"devices","aria-label":"Your devices"},n("div",{class:"card-head","data-key":"devices-head"},n("div",{class:"row-baseline"},n("h2",{},"Your devices"))),n("div",{class:"dgrid"},i),e.locked?null:[e.can_add?null:n("span",{class:"faint s","data-key":"limit"},`You have reached your limit of ${t.device_limit} devices. Remove one or ask the admin for more.`)]);gt(a,n("div",{class:"hello","data-key":"hello"},n("span",{class:`avatar${t.online?" online":""}`},Lt(t.name)),n("h1",{},`Hi, ${t.name}`)),n("div",{class:"layout"},ir(e),h))}function on(){var r;let e=xn(),t=at("vpn",e);return{href:(r=t==null?void 0:t.href)!=null?r:"https://github.com/amnezia-vpn/amnezia-client/releases/latest",label:`Get AmneziaVPN${e==="ios"?" for iPhone":e==="android"?" for Android":""}`}}var xn=()=>Yt(navigator.userAgent,navigator.maxTouchPoints),dr=()=>{var e;return(e=S==null?void 0:S.server.preset)!=null?e:Te()?"off":"max"},Te=()=>(S==null?void 0:S.server.awg_disguise)===!1,Mn="dl.qr.light",ge=(()=>{try{return localStorage.getItem(Mn)==="1"}catch{return!1}})(),Cn=new WeakMap;function vt(e,t){Cn.set(e,t),e.className=`qr${Ze(t)?" big":""}${ge?" light":""}`,e.innerHTML=Dt(t,3,!0,ge?"plain":"night")}function kn(e){e.replaceChildren(ge?"":"Not scanning? ",n("a",{href:"#",onclick:t=>{t.preventDefault(),pr()}},ge?"Show the dark code":"Show a light code"))}function dt(){let e=n("span",{class:"faint s qr-flip"});return kn(e),e}function pr(){ge=!ge;try{localStorage.setItem(Mn,ge?"1":"0")}catch{}document.querySelectorAll(".qr").forEach(e=>{let t=Cn.get(e);t&&(vt(e,t),ne(e,"swap"))}),document.querySelectorAll(".qr-flip").forEach(kn)}function Oe(e){$e("Open the link securely","Connection settings only travel encrypted",n("div",{class:"stack gap"},n("p",{class:"muted"},"This page is open without encryption. To add or set up a device, open the same link over HTTPS:"),n("a",{class:"btn primary block big",href:e},I("lock"),n("span",{},"Open securely")),n("p",{class:"faint s"},"The browser may warn that the certificate is not trusted: it is this router’s own. Choose to continue (“Advanced” → “Proceed”).")))}var Ln=()=>(S==null?void 0:S.https_url)||null;async function Ge(e){let t=Ln();if(t)return Oe(t),null;try{return await he(`devices/${e.id}/config`)}catch(r){let a=r;return a.httpsUrl?Oe(a.httpsUrl):fe(a.message,!0),null}}async function fr(e){let t=await Ge(e);t&&ue(await Be(t,`${t.server} · ${t.name}`),"Key copied")}async function hr(e){let t=await Ge(e);t&&ze(t.filename,t.conf)}function ln(e,t){if(/^\s*\[.+\]\s*$/.test(e))return n("span",{class:"conf-sec"},e);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(e);if(!r)return document.createTextNode(e);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(e);return n("span",{},n("span",{class:"conf-k"},r[1])," ",a?t?n("span",{class:"conf-v"},r[2]):n("span",{class:"conf-mask"},"••••••••••••••••"):r[2])}function An(e){let t=!1,r=n("pre",{class:"conf"}),a=(i=!1)=>{r.replaceChildren(...e.conf.split(` +`).flatMap((w,h)=>h?[` +`,ln(w,t)]:[ln(w,t)])),i&&r.querySelectorAll(".conf-v, .conf-mask").forEach(w=>w.classList.add("unmask"))},s=n("button",{class:"btn small",onclick:i=>{i.preventDefault(),t=!t,s.replaceChildren(I(t?"x":"key"),n("span",{},t?"Hide key":"Show key")),ne(s,"swap"),a(!0)}},I("key"),n("span",{},"Show key"));return a(),n("div",{class:"pane"},n("div",{class:"filecard"},n("span",{class:"filecard-ic"},".conf"),n("span",{class:"stack"},n("span",{class:"mono ellipsis"},e.filename),n("span",{class:"faint s"},Te()?"For computers and routers: import it in any WireGuard app":"For computers and routers: import it in AmneziaWG or AmneziaVPN")),ut(e)?n("button",{class:"btn primary",onclick:()=>ut(e)()},I("open"),n("span",{},"Share file")):n("button",{class:"btn primary",onclick:()=>ze(e.filename,e.conf)},I("download"),n("span",{},"Download"))),n("details",{class:"confbox"},n("summary",{},I("chevron"),n("span",{},"Configuration"),n("span",{class:"grow"}),s,n("button",{class:"btn small",onclick:i=>{i.preventDefault(),ue(e.conf,"Configuration copied",i.currentTarget)}},I("copy"),n("span",{},"Copy"))),r))}async function pt(e,t,r){let a=r!=null?r:await Ge(e);if(!a)return;let s=await Be(a,`${a.server} · ${a.name}`),i=fn(),w=e.kind==="phone"||e.kind==="tablet",h={app:()=>n("div",{class:"pane"},n("a",{class:"btn primary block big",href:s},I("amnezia"),n("span",{},"Open in AmneziaVPN")),n("ol",{class:"steps"},n("li",{},"No AmneziaVPN yet? ",n("a",{href:on().href,target:"_blank",rel:"noopener noreferrer"},on().label),"."),n("li",{},"Tap ",n("b",{},"Open in AmneziaVPN")," and confirm the import."),n("li",{},"Turn the connection on — this page shows ",n("span",{class:"ok"},"Connected")," within a minute."))),qr:()=>{let G=n("div",{class:"qr"}),v=n("p",{class:"muted s"}),f=n("div",{class:"seg"}),d=Te()?"conf":"vpn",k=()=>{},u=(x=!1)=>{let l=d==="vpn"?s:a.conf;vt(G,l),v.textContent=d==="vpn"?"Scan with the phone’s camera or inside AmneziaVPN.":Te()?"Scan inside the AmneziaWG, WireGuard or AmneziaVPN app.":"Scan inside the AmneziaWG app (or AmneziaVPN).",f.querySelectorAll(":scope > button").forEach(o=>o.classList.toggle("on",o.dataset.m===d)),k(),x&&(ne(G,"swap"),ne(v,"swap"))};for(let[x,l]of[["vpn","AmneziaVPN"],["conf",Te()?"WireGuard app":"AmneziaWG app"]])f.appendChild(n("button",{type:"button","data-m":x,onclick:()=>{d!==x&&(d=x,u(!0))}},l));return u(),k=tt(f),n("div",{class:"pane center"},f,G,v,dt())},key:()=>n("div",{class:"pane"},n("p",{class:"muted s"},"In AmneziaVPN choose “Add server → Insert key”."),n("div",{class:"keybox"},n("span",{class:"mono"},s),n("button",{class:"btn small",onclick:G=>ue(s,"Key copied",G.currentTarget)},"Copy")),n("p",{class:"faint s"},"Keep it private: anyone with the key can use your connection.")),file:()=>An(a)},M=i&&w?["app","qr","key","file"]:w?["qr","key","file"]:["file","key","qr"],A={app:"Open in app",qr:"QR code",key:"Key",file:"File"},D=n("div",{class:"tab-body"}),T=n("div",{class:"tabs",role:"tablist"}),R=-1,z=()=>{},U=G=>{let v=M.indexOf(G);T.querySelectorAll(":scope > button").forEach(f=>{f.classList.toggle("on",f.dataset.id===G),f.setAttribute("aria-selected",String(f.dataset.id===G))}),z(),R<0?D.replaceChildren(h[G]()):v!==R&&et(D,[h[G]()],Math.sign(v-R)),R=v};for(let G of M)T.appendChild(n("button",{role:"tab","data-id":G,onclick:()=>U(G)},A[G]));U(t&&M.includes(t)?t:M[0]),z=tt(T);let F=e.handshake||e.disabled?null:rt(e.kind),V=F?$n(e,()=>void Tn(F,[T,D]),F.gaveUp):()=>{};$e(e.handshake?`Connect ${e.name}`:`${e.name} is ready`,i&&w?"Add it to AmneziaVPN on this phone":w?"Scan with the phone’s camera or AmneziaVPN":"Import the file in AmneziaWG or AmneziaVPN",F==null?void 0:F.el,T,D,e.handshake?mr(e):null),ce=()=>{V(),S&&ye(S)}}function mr(e){return n("div",{class:"waiting"},e.online?n("span",{class:"ok"},"Connected"):n("span",{class:"muted"},`Last connected ${Ue(e.handshake,mt())}`))}async function Tn(e,t){var r;e.connected(),(r=e.el.closest(".sheet-panel"))==null||r.scrollTo({top:0,behavior:ie()?"auto":"smooth"}),await It(400),await Promise.all(t.map(a=>Ot(a))),await new Promise(a=>setTimeout(a,2e3)),re!=null&&re.contains(e.el)&&!e.el.closest(".ghost")&&de()}function En(e,t=4){window.setTimeout(async()=>{var r;try{let a=await he("state");S=a,!re&&!ve&&ye(a),!((r=a.person.devices.find(s=>s.id===e))!=null&&r.online)&&t>1&&En(e,t-1)}catch{}},1500)}function $n(e,t,r){let a=mt(),s=0,i=0,w=!1,h=Date.now(),M=async()=>{if(s=0,!w){if(Date.now()-h>6e5){w=!0,r();return}if(document.hidden){A();return}try{let T=await he("state");S=T;let R=T.person.devices.find(z=>z.id===e.id);if(R&&R.handshake>a){w=!0,t(),R.online||En(e.id);return}}catch(T){if(T.status===404||T.status===401){w=!0;return}}i++,A()}},A=()=>{!w&&!s&&(s=window.setTimeout(M,i<6?5e3:i<12?15e3:3e4))},D=()=>{!document.hidden&&!w&&!s&&M()};return document.addEventListener("visibilitychange",D),A(),()=>{w=!0,s&&clearTimeout(s),document.removeEventListener("visibilitychange",D)}}var Sn=e=>`dl.app.${e.id}`;function gr(e){try{let t=localStorage.getItem(Sn(e));return t==="vpn"||t==="awg"||t==="wg"?t:null}catch{return null}}function vr(e,t){try{localStorage.setItem(Sn(e),t)}catch{}}var cn={vpn:"amnezia",awg:"amneziawg",wg:"wireguard"};function pe(e,t=!1,r){var i;let a=[n("span",{class:"badge-ic"},I(e.mark)),n("span",{class:"badge-txt"},n("span",{class:"badge-top"},e.top),n("span",{class:"badge-main"},e.main)),n("span",{class:"badge-chev"},I("chevron"))],s=`badge${t?" primary":""}`;return e.onclick?n("button",{type:"button",class:s,onclick:e.onclick,"data-m":r},a):n("a",{class:s,href:e.href,target:(i=e.href)!=null&&i.startsWith("vpn:")?null:"_blank",rel:"noopener noreferrer","data-m":r},a)}function un(e,t){return n("div",{class:"pills"},t.map(r=>n("button",{type:"button",class:`pill${r.on?" on":""}`,onclick:r.pick,"data-m":`${e}:${r.id}`},r.icon?I(r.icon):null,n("span",{},r.label))))}var me=(e,t,...r)=>n("div",{class:"step"},n("div",{class:"step-head"},n("span",{class:"step-n"},e),n("span",{class:"step-title"},t)),...r);function yr(e){let t=typeof navigator.share=="function";return n("div",{class:"linkrow"},n("span",{class:"mono ellipsis"},e.replace(/^https?:\/\//,"")),n("button",{type:"button",class:"btn small",onclick:r=>ue(e,"Link copied",r.currentTarget)},"Copy"),t?n("button",{type:"button",class:"icon-btn soft","aria-label":"Share the link",onclick:()=>{var r;return navigator.share({url:e,title:(r=S==null?void 0:S.title)!=null?r:"Dawnline"}).catch(()=>{})}},I("share")):null)}async function Ke(e,t){var X;let r=t!=null?t:await Ge(e);if(!r)return;let a=await Be(r,`${r.server} · ${r.name}`),s=Zt(dr()),i=xn(),w=jt(e.kind,i),h=e.kind==="phone"||e.kind==="tablet",M=e.kind==="router",A=i==="ios"||i==="android",D=Jt(e.kind),T=(X=gr(e))!=null?X:M?"awg":"vpn";s.some($=>$.id===T)||(T=M?"awg":"vpn");let R=D.length?D.includes(i)?i:"windows":i,z=!1,U=!1,F="app",V=null,G=n("div",{class:"setup"}),v=rt(e.kind),f=nn(e.kind),d=!1,k=$=>{var K;return(K=s.find(Y=>Y.id===$))!=null?K:s[0]},u=()=>un("app",s.filter($=>!M||$.id!=="vpn").map($=>({id:$.id,label:$.name,icon:cn[$.id],on:$.id===T,pick:()=>{T=$.id,vr(e,T),J()}}))),x=()=>un("os",D.map($=>({id:$,label:$===i?rn($):Re[$],icon:$==="windows"?"windows":$==="mac"?"apple":"linux",on:$===R,pick:()=>{R=$,J()}}))),l=()=>{let $=M?st(T):at(T,R);return $?[$.alt?[n("div",{class:"badges2"},pe($,!1,"store"),pe($.alt,!1,"store-alt")),n("span",{class:"faint s"},$.alt.why)]:pe($,!1,"store"),ke(k(T))?n("span",{class:"faint s","data-m":"update"},ke(k(T))):null]:[n("span",{class:"muted s"},`Get ${se[T]} on the ${Re[R]} and come back here.`)]},o=()=>me("1",[n("span",{class:"grow","data-m":"get"},`Get ${se[T]}`),s.length>1&&!z?n("button",{type:"button",class:"pill-link",onclick:()=>{z=!0,V="picker",J()}},n("span",{},"Another app"),I("chevron")):null],z?n("div",{class:`stack gap${V==="picker"?" enter":""}`},u(),n("span",{class:"faint s","data-m":"app-sub"},k(T).sub)):null,D.length?x():null,...l()),L=()=>{let $=se[T];if(T==="vpn"&&A)return me("2","Add the connection",pe({href:a,top:"Then come back here and tap",main:"Open in AmneziaVPN",mark:"amnezia"},!0,"connect"),n("span",{class:"faint s"},"Nothing opened? ",n("a",{href:"#",onclick:Y=>(Y.preventDefault(),ue(a,"Key copied",Y.currentTarget))},"Copy the key")," and add it in the app."));if(T==="vpn")return me("2","Add the connection",pe({top:"The connection as one key",main:"Copy the key",mark:"copy",onclick:Y=>ue(a,"Key copied",Y.currentTarget)},!0,"connect"),n("ol",{class:"howto","data-m":"howto"},n("li",{},"Open AmneziaVPN"),n("li",{},"Add server → ",n("b",{},"Insert key")),n("li",{},"Paste the key and connect")),n("span",{class:"faint s"},"Have the app open? ",n("a",{href:a},"Open in AmneziaVPN")));let K=A?ut(r):null;return me("2","Add the connection",pe(K?{top:`Straight into ${$}`,main:"Share the file",mark:"share",onclick:()=>K()}:{top:"Then import it in the app",main:"Download the file",mark:"download",onclick:()=>ze(r.filename,r.conf)},!0,"connect"),n("ol",{class:"howto","data-m":"howto"},n("li",{},`Open ${$}`),n("li",{},ot(T).replace(/ → .*$/," → "),n("b",{},ot(T).replace(/^.* → /,""))),n("li",{},K?"Confirm the import and connect":"Pick the file and connect")))},m=($,...K)=>F===$?n("div",{class:"step-head open","data-m":`fold:${$}`},...K):n("button",{type:"button",class:"step-head fold","aria-expanded":"false","data-m":`fold:${$}`,onclick:()=>{F=$,V=$,J()}},...K,n("span",{class:"fold-chev"},I("chevron"))),C=($,K)=>{let Y=n("div",{"data-m":$,"data-sig":`${K.length}:${K.slice(-24)}`});return vt(Y,K),Y},B=($,K)=>($&&K.filter(Y=>!!Y).forEach((Y,qe)=>{Y.classList.add("unfold"),Y.style.setProperty("--i",String(qe))}),K),N=en(location.origin+location.pathname,e.id),O=($=!1,K=!1)=>n("div",{class:`step${K&&F!=="link"?" folded":""}`},K?m("link",n("span",{class:"step-title grow"},`Open your link on the ${f}`),$?n("span",{class:"chip","data-glide":"easiest"},"Easiest"):null):n("div",{class:"step-head"},n("span",{class:"step-title grow"},`Open your link on the ${f}`),$?n("span",{class:"chip"},"Easiest"):null),...K&&F!=="link"?[]:B(V==="link",[n("span",{class:"muted s step-sub"},"The same page there does both steps for that device."),h?n("div",{class:"code-row"},C("link-qr",N),n("span",{class:"stack gap"},n("span",{class:"muted s"},"Point its camera at the code: the link opens there."),dt())):null,yr(N)])),W=()=>U?(()=>{let $=O();return V==="away"&&$.classList.add("enter"),$})():n("div",{class:"center"},n("button",{type:"button",class:"fold-link",onclick:()=>{U=!0,V="away",J()}},`Not on the ${f} right now?`)),j=()=>n("div",{class:`step${F!=="app"?" folded":""}`},m("app",n("span",{class:"step-ic"},I(cn[T])),n("span",{class:"step-title grow"},"Already has the app")),...F!=="app"?[]:B(V==="app",[s.length>1?n("div",{},u()):null,n("div",{class:"code-row"},C("app-qr",T==="vpn"?a:r.conf),n("span",{class:"stack"},n("span",{class:"muted s"},`In ${se[T]}: `,n("b",{},Xt(T)),". The connection is added at once."),ke(k(T))?n("span",{class:"faint s"},ke(k(T))):null,dt())),n("span",{class:"faint s"},"Prefer the file or the key? ",n("a",{href:"#",onclick:$=>($.preventDefault(),pt(e,"file",r))},"Connection details"))])),J=()=>{if(d)return;let $=[];Qt(navigator.userAgent)&&$.push(n("div",{class:"notice"},I("alert"),n("span",{class:"grow"},"Open this page in Safari or Chrome: the store opens from here, but the app handoff does not."))),w?$.push(o(),L(),W()):M?$.push(me("1",[n("span",{class:"grow","data-m":"get"},`Get ${se[T]} on the router`)],s.length>2?u():null,pe(st(T),!1,"store")),me("2","Import the configuration",An(r))):h?$.push(O(!0,!0),j()):$.push(n("span",{class:"muted s"},`The app goes on the ${f}. Which one is it?`),x(),O(!0),me("",[n("span",{class:"grow","data-m":"get"},`${se[T]} for ${Re[R]}`)],n("span",{class:"faint s"},"Or download the installer here and move it to the PC"),...l()),n("span",{class:"faint s center"},`Already has ${se[T]}? `,n("a",{href:"#",onclick:K=>(K.preventDefault(),ue(a,"Key copied",K.currentTarget))},"Copy the key"))),Ft(G,()=>G.replaceChildren(...$.flat().filter(K=>K instanceof Node))),V=null};J();let ae=$n(e,()=>{d=!0,Tn(v,[G])},v.gaveUp);$e(`Set up ${e.name}`,w?"Two steps, about a minute":M?"The packages and the file for OpenWrt":null,v.el,G),ce=()=>{ae(),S&&ye(S)}}function wr(e){let t=n("input",{type:"text",value:e.name,maxlength:48,"aria-label":"Device name"}),r=n("button",{class:"btn primary block",type:"submit"},"Save");$e(`Rename ${e.name}`,null,n("form",{class:"stack gap",onsubmit:a=>{a.preventDefault(),mn(r,async()=>{try{S=(await he(`devices/${e.id}`,{action:"rename",name:t.value})).state,de(),ye(S),fe("Renamed")}catch(s){fe(s.message,!0)}})}},t,r)),setTimeout(()=>t.select(),50)}function br(e,t){yn({icon:"key",tone:"warn",title:`New keys for ${e.name}?`,text:t.here===e.id?"This device is connected through its current settings: it disconnects a few seconds after you confirm. Import the new ones that open next.":"Its current settings stop working. Set it up again with the new ones that open next.",action:"New keys",actionClass:"primary",run:async()=>{try{let r=await he(`devices/${e.id}`,{action:"rotate"});S=r.state,ye(S),await Ke({...e,handshake:0},r.config)}catch(r){fe(r.message,!0)}}})}function xr(e){yn({icon:"trash",tone:"bad",title:`Remove ${e.name}?`,text:"Its connection stops working at once. You can add it again later.",action:"Remove",actionClass:"danger-solid",run:async()=>{try{S=(await he(`devices/${e.id}`,{action:"delete"})).state,de(),await Rt(Me.querySelector(`[data-key="${CSS.escape(e.id)}"]`)),ye(S),fe("Device removed")}catch(t){fe(t.message,!0)}}})}var Z=navigator.userAgent,_n=/iPad/.test(Z)||/Macintosh/.test(Z)&&navigator.maxTouchPoints>1;function lt(){return _n||/Tablet/i.test(Z)||/Android/.test(Z)&&!/Mobile/.test(Z)?"tablet":/Android|iPhone|Mobile/i.test(Z)?"phone":"computer"}var Mr=[[/^SM-S93/,"Galaxy S25"],[/^SM-S92/,"Galaxy S24"],[/^SM-S91/,"Galaxy S23"],[/^SM-S90/,"Galaxy S22"],[/^SM-G99/,"Galaxy S21"],[/^SM-F9/,"Galaxy Z Fold"],[/^SM-F7/,"Galaxy Z Flip"],[/^SM-A5/,"Galaxy A5x"],[/^SM-A3/,"Galaxy A3x"],[/^SM-X/,"Galaxy Tab"]],ft="",Cr=(async()=>{var t;let e=navigator.userAgentData;if(!e||!/Android/.test(Z))return"";try{let r=((t=(await e.getHighEntropyValues(["model"])).model)!=null?t:"").trim();if(!r||r==="K")return"";let a=Mr.find(([s])=>s.test(r));ft=a?`${a[1]} (${r})`:/^SM-/.test(r)?`Galaxy ${r}`:r}catch{}return ft})();function kr(e){return/iPhone/.test(Z)?"iPhone":_n?"iPad":/Android/.test(Z)?ft||(e==="tablet"?"Android tablet":"Android phone"):/CrOS/.test(Z)?"Chromebook":/Mac OS X/.test(Z)?"Mac":/Windows/.test(Z)?"Windows PC":/Linux/.test(Z)?"Linux PC":De[e]}function dn(){if(!S)return;let e=Ln();if(e){Oe(e);return}let t=lt(),r=new Set(S.person.devices.map(A=>A.name.toLowerCase())),a=A=>{let D=A===lt()?kr(A):De[A];if(!r.has(D.toLowerCase()))return D;for(let T=2;T<20;T++)if(!r.has(`${D} ${T}`.toLowerCase()))return`${D} ${T}`;return D},s=n("input",{type:"text",value:a(t),maxlength:48,"aria-label":"Device name",required:!0}),i=!1;s.addEventListener("input",()=>i=!0),Cr.then(()=>{!i&&t===lt()&&(s.value=a(t))});let w=n("div",{class:"kinds"},S.kinds.map(A=>n("button",{type:"button",class:`kind${A===t?" on":""}`,"data-k":A,onclick:()=>{t=A,w.querySelectorAll(".kind").forEach(D=>D.classList.toggle("on",D.dataset.k===A)),i||(s.value=a(A))}},I(A),n("span",{},De[A])))),h=n("p",{class:"err"}),M=n("button",{class:"btn primary block",type:"submit"},"Create connection");$e("Add a device",`${S.person.device_limit-S.person.devices.length} of ${S.person.device_limit} slots free`,n("form",{class:"add",onsubmit:async A=>{A.preventDefault(),M.disabled=!0;let D=nt(M);h.textContent="";try{let T=await he("devices",{name:s.value.trim(),kind:t});S=T.state;let R=T.state.person.devices.find(z=>z.id===T.id);await Ke(R,T.config)}catch(T){if(T.httpsUrl){Oe(T.httpsUrl);return}h.textContent=T.message,ne(h,"enter"),M.disabled=!1}finally{D()}}},n("label",{class:"lbl"},"What is it?"),w,n("p",{class:"muted s"},"Phones and tablets get a smaller packet size that suits mobile networks."),n("label",{class:"lbl"},"Name"),s,h,M))}window.addEventListener("hashchange",()=>Pn());function Pn(){let e=tn(location.hash);if(!e)return;history.replaceState(null,"",location.pathname+location.search);let t=S==null?void 0:S.person.devices.find(r=>r.id===e);t&&!t.handshake&&!t.disabled&&!(S!=null&&S.locked)&&Ke(t)}async function Lr(){try{S=await he("state"),document.title=`${S.person.name} · ${S.title}`,!re&&!ve&&ye(S),Pn()}catch(e){let t=e;t.status===404||t.status===401?(S=null,wn()):S||gt(n("div",{class:"card"},n("p",{},t.message)))}}!Ie||!Xn?wn():Lr();})(); diff --git a/package/luci-app-dawnline/root/usr/share/rpcd/acl.d/luci-app-dawnline.json b/package/luci-app-dawnline/root/usr/share/rpcd/acl.d/luci-app-dawnline.json index 3451d2a..328e887 100644 --- a/package/luci-app-dawnline/root/usr/share/rpcd/acl.d/luci-app-dawnline.json +++ b/package/luci-app-dawnline/root/usr/share/rpcd/acl.d/luci-app-dawnline.json @@ -18,6 +18,8 @@ "settings_get", "portal_info", "interfaces", + "server_ports", + "endpoint_probe", "events" ] } diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc index 7ebc842..0e2fe2d 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc @@ -35,19 +35,17 @@ function log(who, msg, level, detail) { /* ---------- hostnames ---------- */ -function host_label(s) { - let l = replace(lc(s), /[^a-z0-9]+/g, '-'); - l = replace(l, /^-+|-+$/g, ''); - return substr(l, 0, 40) || 'device'; -} - export function sync_hosts(m) { let lines = []; if (m.settings.hostnames) - for (let id, d in m.devices) { - let p = m.people[d.person]; - if (p && ip2int(d.address) != null) - push(lines, `${d.address} ${host_label(d.name)}.${p.id}.${m.settings.domain}`); + for (let pid, p in m.people) { + // One label per device, unique within the person (the UI shows the same). + let labels = core.device_labels(m, p); + for (let id in p.devices) { + let d = m.devices[id]; + if (ip2int(d.address) != null) + push(lines, `${d.address} ${labels[id]}.${p.id}.${m.settings.domain}`); + } } let ls = loop.status(); if (ls.active) diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc index 08dfdc6..244cf90 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc @@ -6,7 +6,7 @@ import { readfile, stat, unlink } from 'fs'; import { - q, sh, sh_out, rand_int, rand_bytes, valid_key, ip2int, ensure_dir, write_file, read_json, write_json, lock, unlock, + q, sh, sh_out, rand_int, rand_bytes, valid_key, ip2int, translit, ensure_dir, write_file, read_json, write_json, lock, unlock, slog, iface_status, DATA_DIR, RUN_DIR } from 'dawnline.util'; import * as core from 'dawnline.core'; @@ -226,11 +226,14 @@ function dns_answer() { /** * Generate obfuscation parameters for a method: * off plain WireGuard-compatible packets - * standard junk packets and random headers (any AmneziaWG client) - * strong more and larger junk (any AmneziaWG client) + * balanced AmneziaWG 2.0: junk packets, random headers, padded cookie and + * data packets, DNS-shaped signature packets * max AmneziaWG 3.1: protected headers, random trailers, padding, * jittered timers and a DNS-like first packet — the values * AmneziaVPN itself uses for 3.1 servers + * Servers made before 0.8 may still carry the old "standard" or "strong" + * values (1.0-style junk only): they keep running as they are, the picker + * offers Balanced or Maximum instead. */ export function obf_preset(name) { if (name == 'max') @@ -247,12 +250,11 @@ export function obf_preset(name) { }; if (name == 'off') return { jc: '0', jmin: '0', jmax: '0', s1: '0', s2: '0', h1: '1', h2: '2', h3: '3', h4: '4' }; - let strong = name == 'strong', balanced = name == 'balanced'; let o = {}; - o.jc = `${strong ? rand_int(6, 10) : balanced ? rand_int(4, 8) : rand_int(3, 6)}`; - let jmin = rand_int(64, strong || balanced ? 128 : 96); + o.jc = `${rand_int(4, 8)}`; + let jmin = rand_int(64, 128); o.jmin = `${jmin}`; - o.jmax = `${jmin + rand_int(strong ? 200 : balanced ? 150 : 32, strong ? 600 : balanced ? 400 : 160)}`; + o.jmax = `${jmin + rand_int(150, 400)}`; let s1 = rand_int(15, 64), s2 = rand_int(15, 64); while (s1 + 56 == s2) s2 = rand_int(15, 64); @@ -261,15 +263,13 @@ export function obf_preset(name) { let used = {}; for (let k in [ 'h1', 'h2', 'h3', 'h4' ]) o[k] = rand_h(used); - if (balanced) { - // AmneziaWG 2.0: padded cookie and data packets (S4 costs MTU, kept - // small: core.tunnel_mtu) and DNS-shaped signature packets before each - // handshake — what 1.0 traffic lacks and gets recognised by. - o.s3 = `${rand_int(8, 48)}`; - o.s4 = `${rand_int(4, 16)}`; - o.i1 = dns_query(); - o.i2 = dns_answer(); - } + // AmneziaWG 2.0: padded cookie and data packets (S4 costs MTU, kept + // small: core.tunnel_mtu) and DNS-shaped signature packets before each + // handshake — what 1.0 traffic lacks and gets recognised by. + o.s3 = `${rand_int(8, 48)}`; + o.s4 = `${rand_int(4, 16)}`; + o.i1 = dns_query(); + o.i2 = dns_answer(); return o; }; @@ -342,7 +342,7 @@ export function obf_neutral(o) { * and a number when the cut would still make two of them alike. */ function conf_filename(m, p, dev) { - let label = (d) => trim(substr(trim(replace(lc(d.name + '-' + p.id), /[^a-z0-9]+/g, '-'), '-'), 0, 15), '-'); + let label = (d) => trim(substr(trim(replace(lc(translit(d.name + '-' + p.id)), /[^a-z0-9]+/g, '-'), '-'), 0, 15), '-'); let order = sort(map(p.devices, (id) => m.devices[id]), (a, b) => (a.created - b.created) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)); let seen = {}; @@ -464,6 +464,9 @@ export function netifd_options(srv) { return o; }; +/** Person states whose devices stay in the tunnel: active, and the limits the portal explains. */ +export const SOFT_STATES = [ 'active', 'quota', 'hours' ]; + /** Push the peer list of every server to the kernel without restarting it. */ export function sync_peers(m, states) { ensure_dir(RUN_DIR); @@ -480,8 +483,11 @@ export function sync_peers(m, states) { for (let did, d in m.devices) { let p = m.people[d.person]; // One malformed line makes syncconf refuse the whole server: such a device - // stays out (Health's Data check names it). - if (!p || p.server != id || d.disabled || states[p.id] != 'active' || !valid_key(d.public_key) || ip2int(d.address) == null) + // stays out (Health's Data check names it). Over the data limit or + // outside the allowed hours the tunnel stays: the access table blocks + // everything but the portal, which says why (a silent handshake failure + // would look like a broken VPN). + if (!p || p.server != id || d.disabled || index(SOFT_STATES, states[p.id]) < 0 || !valid_key(d.public_key) || ip2int(d.address) == null) continue; push(lines, '[Peer]', `PublicKey = ${d.public_key}`); if (d.preshared_key) 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 9fe96ff..f95b9a7 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 @@ -4,7 +4,7 @@ import { cursor } from 'uci'; import { - valid_name, valid_key, valid_host, valid_date, slugify, parse_cidr, cidr_overlaps, int2ip, ip2int, + valid_name, valid_key, valid_host, valid_date, slugify, host_label, ucut, NAME_RULE, parse_cidr, cidr_overlaps, int2ip, ip2int, rand_hex, rand_bytes, date_end, month_key, read_json, DATA_DIR, RUN_DIR, uniq } from 'dawnline.util'; import * as net from 'dawnline.net'; @@ -482,7 +482,7 @@ export function new_code() { export function create_person(c, m, a) { if (!valid_name(a.name)) - fail('Enter a name (up to 48 characters).'); + fail(NAME_RULE); // The id is a UCI section name: letters, digits and underscores only (a dash // makes uci drop the section). Repeated names get _2, _3, … let base = replace(a.slug ?? slugify(a.name), /-/g, '_'); @@ -540,7 +540,7 @@ export function update_person(c, m, id, a) { let set = (k, v) => (v == null || v == '') ? c.delete(CONFIG, id, k) : c.set(CONFIG, id, k, `${v}`); if (a.name != null) { if (!valid_name(a.name)) - fail('Enter a name (up to 48 characters).'); + fail(NAME_RULE); set('name', trim(a.name)); } if (a.access != null) { @@ -599,7 +599,7 @@ export function update_person(c, m, id, a) { set('hours', a.hours); } if (a.note != null) - set('note', substr(trim(a.note), 0, 500)); + set('note', ucut(trim(a.note), 500)); if (type(a.services) == 'array') { for (let sid in a.services) if (!m.services[sid]) @@ -615,6 +615,24 @@ export function update_person(c, m, id, a) { fail('Unknown circle.'); set('circle', a.circle); } + // Another server: every device gets an address in its tunnel (so each + // needs its configuration again); circles and home networks are the old + // server's and go. + if (a.server != null && a.server != '' && a.server != p.server) { + if (!m.servers[a.server]) + fail('Unknown server.'); + set('server', a.server); + p.server = a.server; + for (let did in p.devices) { + let addr = alloc_address(m, m.servers[a.server]); + if (!addr) + fail(`No free address left on ${m.servers[a.server].name}.`); + m.devices[did].address = addr; + c.set(CONFIG, did, 'address', addr); + } + c.delete(CONFIG, id, 'circle'); + c.delete(CONFIG, id, 'home_net'); + } if (type(a.home_nets) == 'array') { let nets = uniq(filter(map(a.home_nets, (x) => trim(`${x}`)), (x) => match(x, /^[A-Za-z0-9_.@-]{1,32}$/))); if (length(nets)) @@ -820,6 +838,50 @@ export function model_errors(m) { return errs; }; +/** + * Give every device on a server an address in `subnet` (the server's new + * tunnel network), lowest first: used by server_update when the network + * changes. Each device then needs its configuration again (the address is + * in it). Fails when the subnet cannot hold them. + */ +export function renumber_server(c, m, srv, subnet) { + srv.subnet = subnet; + for (let pid, p in m.people) + if (p.server == srv.id) + for (let did in p.devices) + m.devices[did].address = ''; + for (let pid, p in m.people) + if (p.server == srv.id) + for (let did in p.devices) { + let addr = alloc_address(m, srv); + if (!addr) + fail(`${subnet} has no room for every device on ${srv.name}.`); + m.devices[did].address = addr; + c.set(CONFIG, did, 'address', addr); + } + c.set(CONFIG, srv.id, 'subnet', subnet); +}; + +/** + * The DNS labels of a person's devices, { device id: label }, unique within + * the person: two devices whose names give one label ("iPhone" and + * "iPhone!", or two Cyrillic names) get -2, -3 by age. Hostnames in + * /tmp/hosts (dawnline.apply) and the ones the UI shows (dawnline.view) both + * come from here, so what is shown resolves. + */ +export function device_labels(m, p) { + let out = {}, used = {}; + let devs = sort(map(p.devices, (id) => m.devices[id]), (a, b) => (a.created - b.created) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)); + for (let d in devs) { + let base = host_label(d.name), l = base; + for (let n = 2; used[l]; n++) + l = `${substr(base, 0, 37)}-${n}`; + used[l] = true; + out[d.id] = l; + } + return out; +}; + /** * Port forwards from `zone` for `proto` that aren't Dawnline's: [{ from, to, name }]. * A forwarded port never reaches the router itself, so nothing here can listen on it. @@ -883,7 +945,9 @@ export function portal_link(m, p, host) { return `http://${host}${hp == 80 ? '' : `:${hp}`}/${p.code}`; } let pp = portal_public_port(m); - return `https://${host}${pp == 443 ? '' : `:${pp}`}/${p.code}`; + // An IPv6 address needs its brackets in a URL. + let h = index(host, ':') >= 0 && !match(host, /^\[/) ? `[${host}]` : host; + return `https://${h}${pp == 443 ? '' : `:${pp}`}/${p.code}`; }; /** The main link (QR, invite card, Copy link). */ diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc index 2b7a607..c53bf2d 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc @@ -233,23 +233,77 @@ function reply_check(id, title, proto, port, r) { const PRIVATE = map([ '100.64.0.0/10', '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16' ], parse_cidr); +/** What kind of IPv4 the WAN has: public, cgnat (100.64/10), private (behind another router), or none. */ +export function wan_kind(wan) { + let wc = wan ? ip2int(wan) : null; + if (wc == null) + return 'none'; + if (in_cidr(wc, PRIVATE[0])) + return 'cgnat'; + return length(filter(PRIVATE, (c) => in_cidr(wc, c))) ? 'private' : 'public'; +}; + +/** + * What a public address points at, for Health and the "as you type" check on + * the server page: { host, ips, ips4, ips6, wan, kind (wan_kind), cloudflare, + * here (an IPv4 of it is this router's WAN), v6_only }. + */ +export function endpoint_facts(srv, host) { + let ips = host ? lookup.resolve(host) : []; + let wan = srv ? (net.wan_address(srv) ?? lookup.wan_ipv4(srv.wan_zone)) : lookup.wan_ipv4('wan'); + let ips4 = filter(ips, (a) => ip2int(a) != null), ips6 = filter(ips, (a) => ip2int(a) == null); + return { + host, ips, ips4, ips6, wan: wan ?? null, kind: wan_kind(wan), + cloudflare: length(filter(ips, (a) => cloudflare_ip(a))) > 0, + here: wan != null && index(ips4, wan) >= 0, + v6_only: !length(ips4) && length(ips6) > 0, + }; +}; + +/** The facts in words: { status: ok|warn|error, text }. `proto_note` names what must get through ("UDP 4500"). */ +export function endpoint_words(f, proto_note) { + if (!f.host) + return { status: 'error', text: 'No public address: devices will not know where to connect.' }; + if (!length(f.ips)) + return { status: 'error', text: `${f.host} does not resolve.` }; + if (f.cloudflare) + return { status: 'error', text: `${f.host} → ${join(', ', f.ips)} (Cloudflare). ${proto_note} reaches the router only if this name is DNS-only there, or use the router's IP.` }; + if (f.v6_only) + return { status: f.kind == 'public' ? 'warn' : 'ok', text: `${f.host} → ${join(', ', f.ips6)}: IPv6 only, so only devices with IPv6 connect${f.kind == 'public' ? ` (the router's IPv4 ${f.wan} has no name)` : ''}.` }; + if (f.kind == 'cgnat' || f.kind == 'private') + return { status: 'warn', text: f.kind == 'cgnat' + ? `The WAN address ${f.wan} is CGNAT (shared by the ISP): ${proto_note} cannot be forwarded to this router from outside unless the ISP gives a public address or IPv6.` + : `The WAN address ${f.wan} is private: this router is behind another one. Forward ${proto_note} on it, or devices cannot connect.` }; + if (f.wan && !f.here) + return { status: 'warn', text: `${f.host} points at ${join(', ', f.ips4)}, not this router (WAN ${f.wan}). Check your DNS / DDNS.` }; + return { status: 'ok', text: f.here ? `${f.host} points at this router (${f.wan}).` : `${f.host} → ${join(', ', f.ips)}` }; +}; + /** What a public address resolves to and whether that reaches this router (for a core's protocol). */ function endpoint_check(id, title, srv, host, proto_note) { - if (!host) - return check(id, title, 'error', 'No public address: devices will not know where to connect.'); - let ips = lookup.resolve(host); - let wan = net.wan_address(srv) ?? lookup.wan_ipv4(srv.wan_zone); - let wc = wan ? ip2int(wan) : null; - let cgnat = wc != null && length(filter(PRIVATE, (c) => in_cidr(wc, c))) > 0; - if (!length(ips)) - return check(id, title, 'error', `${host} does not resolve.`); - if (cgnat) - return check(id, title, 'warn', `WAN address ${wan} is private: forward ${proto_note} on the upstream router, or devices cannot connect.`); - if (length(filter(ips, (a) => cloudflare_ip(a)))) - return check(id, title, 'error', `${host} → ${join(', ', ips)} (Cloudflare). ${proto_note} reaches the router only if this name is DNS-only there, or use the router's IP.`); - if (wan && index(ips, wan) < 0) - return check(id, title, 'warn', `${host} resolves to ${join(', ', ips)}, but the WAN address is ${wan}. Check your DNS / DDNS.`); - return check(id, title, 'ok', `${host} → ${join(', ', ips)}`); + let w = endpoint_words(endpoint_facts(srv, host), proto_note); + return check(id, title, w.status, w.text); +} + +/** + * Policy routing by another package (mwan3, pbr): an fwmark rule ahead of + * Dawnline's (pref < 5205) whose table has a default route of its own sends + * marked tunnel traffic straight out, past "like a home device". Reported, + * since those marks belong to that package. [] when none. + */ +function policy_routing() { + let out = []; + for (let line in split(sh_out('ip -4 rule show 2>/dev/null') ?? '', '\n')) { + let mm = match(line, /^(\d+):.*fwmark 0x([0-9a-f]+)(\/0x[0-9a-f]+)?.* lookup (\S+)/); + if (!mm || +mm[1] >= 5205) + continue; + let routes = sh_out(`ip -4 route show table ${q(mm[4])} 2>/dev/null`) ?? ''; + let def = match(routes, /(^|\n)default [^\n]*/)?.[0] ?? ''; + if (def == '' || match(def, /local default/) || index(def, `dev ${net.INTERNAL.transit}`) >= 0) + continue; + push(out, `pref ${mm[1]} fwmark 0x${mm[2]} → table ${mm[4]}`); + } + return out; } const NO_PROTO = "netifd doesn't know the amneziawg protocol (AmneziaWG missing, or the network wasn't restarted after installing it)."; @@ -301,19 +355,30 @@ function awg_checks(m, id, srv, label, fwc, dmp, rep) { (st ? `${srv.ifname} is down${length(codes) ? ': ' + join(', ', codes) : ''}.` : `${srv.ifname} does not exist.`), up ? null : (st ? 'ifup:' + srv.ifname : 'apply'))); if (up) { - let expected = 0; + // By key, not by count: a stale peer standing in for a missing one would + // make the numbers match. let states = apply.states_for(m, core.load_usage()); + let wanted = {}, expected = 0; for (let did, d in m.devices) { let p = m.people[d.person]; - if (p?.server == id && !d.disabled && states[d.person] == 'active') + if (p?.server == id && !d.disabled && index(awg.SOFT_STATES, states[d.person]) >= 0) { + wanted[d.public_key] = true; expected++; + } } - let actual = 0; + let loaded = {}, actual = 0; for (let k, p in dmp.peers) - if (p.ifname == srv.ifname) + if (p.ifname == srv.ifname) { + loaded[k] = true; actual++; - push(out, check(`peers_${id}`, `AmneziaWG devices loaded${label}`, expected == actual ? 'ok' : 'warn', - `${actual} of ${expected} active devices are loaded in the tunnel.`, expected == actual ? null : 'sync')); + } + let missing = length(filter(keys(wanted), (k) => !loaded[k])); + let extra = length(filter(keys(loaded), (k) => !wanted[k])); + let same = !missing && !extra; + push(out, check(`peers_${id}`, `AmneziaWG devices loaded${label}`, same ? 'ok' : 'warn', + same ? `${actual} device${actual == 1 ? ' is' : 's are'} loaded in the tunnel.` : + `${missing} of ${expected} device${expected == 1 ? '' : 's'} missing${extra ? `, ${extra} loaded that should not be` : ''}.`, + same ? null : 'sync')); } let rule = fwc.get('firewall', `dawnline_${id}_port`) == 'rule'; let zone = fwc.get('firewall', `dawnline_${id}_zone`) == 'zone'; @@ -431,6 +496,14 @@ export function health(m) { : 'Table inet dawnline is missing: no device is loaded into the tunnels until it is back.', nft_ok ? null : 'apply')); + if (length(filter(values(m.servers), (s) => s.lan_like && s.enabled))) { + let pr = policy_routing(); + push(out, check('policy', 'Internet like a home device not bypassed', length(pr) ? 'warn' : 'ok', + length(pr) ? `Policy routing on the router (${join('; ', pr)}) sends marked traffic straight out, past the home-device path: tunnel traffic it matches skips your LAN's proxies and filters.` + : 'No other policy routing ahead of the tunnel rules.', + null, 'Other policy routing bypasses the home-device path')); + } + // A device the sync has to leave out (a merged import, a hand-edited config). let data = core.model_errors(m); push(out, check('data', 'People and devices consistent', length(data) ? 'error' : 'ok', diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc index f0d72ae..d0009e7 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc @@ -29,7 +29,7 @@ export const CATEGORY = { 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: 'people', resumed: 'people', expiring: 'people', expired_kept: 'people', server_down: 'problems', server_up: 'problems', portal_blocked: 'problems', }; export const CATEGORIES = [ 'connections', 'people', 'problems' ]; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/lookup.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/lookup.uc index 108beca..fda9b9f 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/lookup.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/lookup.uc @@ -4,7 +4,7 @@ // time, so a slow DNS server must not hold up the whole admin UI. import { readfile } from 'fs'; -import { q, sh, ensure_dir, read_json, write_json, ip2int, rand_hex, RUN_DIR } from 'dawnline.util'; +import { q, sh, ensure_dir, read_json, write_json, ip2int, is_ip6, rand_hex, RUN_DIR } from 'dawnline.util'; import * as live from 'dawnline.live'; import * as net from 'dawnline.net'; @@ -23,9 +23,10 @@ function valid_name(h) { } /** - * IPv4 addresses of each name: { host: [ ip, … ] } (empty when it does not - * resolve). IP addresses map to themselves. Every uncached name is asked of - * every server at once; the first server (in SERVERS order) that answers wins. + * Addresses of each name, IPv4 and IPv6: { host: [ ip, … ] } (empty when it + * does not resolve). IP addresses map to themselves. Every uncached name is + * asked of every server at once, A and AAAA; the first server (in SERVERS + * order) that answers wins. */ export function resolve_all(hosts) { let out = {}, now = time(), todo = []; @@ -33,7 +34,7 @@ export function resolve_all(hosts) { for (let h in hosts) { if (h == null || out[h] != null) continue; - if (ip2int(h) != null) { + if (ip2int(h) != null || is_ip6(h)) { out[h] = [ h ]; continue; } @@ -55,15 +56,17 @@ export function resolve_all(hosts) { let cmds = []; for (let i = 0; i < length(todo); i++) for (let j = 0; j < length(SERVERS); j++) - // nslookup's own timeout: some firmware builds BusyBox without `timeout`. - push(cmds, `( nslookup -type=a -timeout=${TIMEOUT} -retry=1 ${q(todo[i])} ${SERVERS[j]} 2>/dev/null | awk '/^Address/ && NR>2 {print $NF}' > ${dir}/${i}.${j} ) &`); + for (let t in [ 'a', 'aaaa' ]) + // nslookup's own timeout: some firmware builds BusyBox without `timeout`. + push(cmds, `( nslookup -type=${t} -timeout=${TIMEOUT} -retry=1 ${q(todo[i])} ${SERVERS[j]} 2>/dev/null | awk '/^Address/ && NR>2 {print $NF}' > ${dir}/${i}.${j}.${t} ) &`); sh(`mkdir -p ${dir}; ${join(' ', cmds)} wait`); for (let i = 0; i < length(todo); i++) { let ips = []; - for (let j = 0; j < length(SERVERS) && !length(ips); j++) { - let r = readfile(`${dir}/${i}.${j}`) ?? ''; - ips = filter(split(trim(r), '\n'), (x) => ip2int(x) != null); - } + for (let j = 0; j < length(SERVERS) && !length(ips); j++) + for (let t in [ 'a', 'aaaa' ]) { + let r = readfile(`${dir}/${i}.${j}.${t}`) ?? ''; + push(ips, ...filter(split(trim(r), '\n'), (x) => ip2int(x) != null || is_ip6(x))); + } out[todo[i]] = ips; cache[todo[i]] = { ts: now, ips }; } diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc index 207ec25..eed83db 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc @@ -358,6 +358,8 @@ function state(r) { name: srv?.name, endpoint: srv ? core.endpoint_host(m, srv) : '', device_mesh: !!srv?.device_mesh, // AmneziaWG with the disguise off is plain WireGuard (any WireGuard app). awg_disguise: srv ? !awg.obf_neutral(srv.obf) : false, + // Which apps (and versions) connect: off, balanced (2.0), max (3.1); legacy = the old junk-only presets. + preset: !srv || awg.obf_neutral(srv.obf) ? 'off' : index([ 'balanced', 'max' ], srv.preset) >= 0 ? srv.preset : 'legacy', }, can_add: length(person.devices) < person.device_limit, locked: LOCKED[v.state] != null, @@ -366,6 +368,8 @@ function state(r) { kinds: core.KINDS, // The router's day: access ends and usage days follow its clock, not the browser's. today: today(), + // Its clock too: "last connected 3 min ago" is measured against it, not the phone's. + now: time(), version: VERSION, }; } diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/common.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/common.uc index fda8a93..90370f7 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/common.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/common.uc @@ -34,7 +34,13 @@ export function clamp_days(v) { return n >= 1 ? (n > 400 ? 400 : int(n)) : 30; }; -export const METHODS = [ 'off', 'standard', 'strong', 'balanced', 'max' ]; +export const METHODS = [ 'off', 'balanced', 'max' ]; + +/** The disguise a new server gets: the strongest this router can run. */ +export function default_method() { + let c = awg.caps(); + return c.v3 ? 'max' : c.v2 ? 'balanced' : 'off'; +}; /** A disguise method the installed AmneziaWG can run. */ export function check_method(name) { diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/home.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/home.uc index 06cc37a..5ea9129 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/home.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/home.uc @@ -4,7 +4,7 @@ import { readfile } from 'fs'; import { cursor } from 'uci'; -import { sh_out, ip2int, rand_int, rand_hex, admin_log } from 'dawnline.util'; +import { sh_out, ip2int, rand_int, rand_hex, admin_log, valid_name, ulength, NAME_RULE } from 'dawnline.util'; import * as core from 'dawnline.core'; import * as apply from 'dawnline.apply'; import * as net from 'dawnline.net'; @@ -27,8 +27,8 @@ function new_id(m, make) { function service_set(a) { let name = str(a.name); - if (name == '' || length(name) > 48) - die('Enter a service name.'); + if (!valid_name(name)) + die(`Service: ${NAME_RULE}`); let address = str(a.address); if (!schema.ipv4(address)) die('Address must be an IPv4 address.'); @@ -81,8 +81,8 @@ function service_delete(a) { /** Create or edit a circle; `members` (person ids) replaces who is in it. */ function circle_set(a) { let name = str(a.name); - if (name == '' || length(name) > 32) - die('Enter a circle name (up to 32 characters).'); + if (!valid_name(name) || ulength(name) > 32) + die('Enter a circle name: up to 32 characters, without < > " or \\.'); let res = store.transact((c, m) => { let ci = a.id ? m.circles[a.id] : null; if (a.id && !ci) diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc index 5bf55f6..ae8cd95 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc @@ -11,7 +11,7 @@ import * as devices from 'dawnline.devices'; import { wrap, str, clamp_days } from 'dawnline.rpc.common'; const PERSON_FIELDS = [ 'name', 'access', 'device_limit', 'expires', 'expire_action', 'expire_warn', 'quota_gb', 'quota_period', - 'bonus_gb', 'hours', 'note', 'dns_mode' ]; + 'bonus_gb', 'hours', 'note', 'dns_mode', 'server' ]; /* ---------- people ---------- */ @@ -39,12 +39,16 @@ function person_update(a) { fields.circle = a.circle; if (type(a.home_nets) == 'array') fields.home_nets = a.home_nets; + let m0 = null; let before = store.transact((c, m) => { let p = m.people[a.id]; + m0 = m; core.update_person(c, m, a.id, fields); return p; }); - let changes = join(', ', filter(keys(fields), (k) => k != 'note')); + // "moved to Test" says more than "server". + let changes = join(', ', map(filter(keys(fields), (k) => k != 'note'), + (k) => k == 'server' && m0?.servers[fields.server] ? `moved to ${m0.servers[fields.server].name}` : k)); if (changes) live.add_event_merged({ type: 'person_changed', person: a.id, detail: changes, by: 'admin' }, 120); // Access changes affect the nft sets and client AllowedIPs. @@ -156,7 +160,7 @@ export const methods = { }, person_update: { args: { id: '', name: '', access: '', device_limit: '', expires: '', expire_action: '', expire_warn: '', quota_gb: '', - quota_period: '', bonus_gb: '', hours: '', note: '', dns_mode: '', paused: false, services: [], circle: '', home_nets: [] }, + quota_period: '', bonus_gb: '', hours: '', note: '', dns_mode: '', paused: false, services: [], circle: '', home_nets: [], server: '' }, call: wrap(person_update), }, person_pause: { args: { id: '', paused: false }, call: wrap(person_pause) }, diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc index c4199ab..629e2c4 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc @@ -2,7 +2,7 @@ // Interfaces settings, its disguise, and removing it. import { cursor } from 'uci'; -import { sh_out, sh_bg, parse_cidr, cidr_str, cidr_overlaps, valid_host, rand_int, uniq, admin_log } from 'dawnline.util'; +import { sh_out, sh_bg, parse_cidr, cidr_str, cidr_overlaps, valid_host, valid_name, NAME_RULE, rand_int, uniq, admin_log } from 'dawnline.util'; import * as core from 'dawnline.core'; import * as live from 'dawnline.live'; import * as apply from 'dawnline.apply'; @@ -14,7 +14,7 @@ import * as schema from 'dawnline.schema'; import * as health from 'dawnline.health'; import * as backup from 'dawnline.backup'; import * as devices from 'dawnline.devices'; -import { wrap, str, check_method, check_portal, tcp_taken } from 'dawnline.rpc.common'; +import { wrap, str, check_method, default_method, check_portal, tcp_taken } from 'dawnline.rpc.common'; /** Server ids that would shadow a portal path. */ const PORTAL_PATHS = [ 'api', 'assets', 'cgi-bin' ]; @@ -77,8 +77,9 @@ function free_port(taken) { } function free_subnet(taken) { - for (let i = 0; i < 200; i++) { - let cand = parse_cidr(sprintf('10.%d.%d.0/24', rand_int(60, 250), rand_int(0, 250))); + for (let i = 0; i < 300; i++) { + // 10.x first; past 200 tries (a 10/8 LAN) the 172.16-31 range. + let cand = parse_cidr(i < 200 ? sprintf('10.%d.%d.0/24', rand_int(60, 250), rand_int(0, 250)) : sprintf('172.%d.%d.0/24', rand_int(16, 31), rand_int(0, 250))); let bad = false; for (let t in taken) { let tc = parse_cidr(t); @@ -164,21 +165,33 @@ function setup_defaults(a) { let fc = cursor(); fc.load('firewall'); fc.foreach('firewall', 'zone', (z) => push(zones, z.name)); - let host = m.settings.portal_host; + let snap = net.snapshot(true); + let wan_ip = snap.wan ? split(snap.devices[snap.wan]?.addrs?.[0] ?? '', '/')[0] : ''; + let kind = health.wan_kind(wan_ip || null); + let host = m.settings.portal_host, from = host ? 'portal' : ''; if (!host) { - // Prefer a DDNS name, then an ACME certificate's, then the WAN address. + // Prefer a DDNS name, then an ACME certificate's, then the WAN address — + // but never a private or CGNAT one: nobody on the internet reaches it. let dc = cursor(); if (dc.load('ddns')) dc.foreach('ddns', 'service', (s) => { - if (!host && s.lookup_host && s.enabled == '1') + if (!host && s.lookup_host && s.enabled == '1') { host = s.lookup_host; + from = 'ddns'; + } }); - if (!host) + if (!host) { host = sh_out("ls /etc/ssl/acme/ 2>/dev/null | sed -n 's/\\.fullchain\\.crt$//p' | head -n1") || ''; - if (!host) - host = live.iface_status('wan')?.['ipv4-address']?.[0]?.address ?? ''; + from = host ? 'cert' : ''; + } + if (!host && kind == 'public') { + host = wan_ip; + from = 'wan'; + } } - let wan_zone = index(zones, 'wan') >= 0 ? 'wan' : zones[1]; + // The zones the WAN and LAN devices are in, whatever they are called. + let wan_zone = snap.devices[snap.wan]?.zone ?? (index(zones, 'wan') >= 0 ? 'wan' : zones[1]); + let lan_zone = snap.devices[snap.lan]?.zone ?? (index(zones, 'lan') >= 0 ? 'lan' : zones[0]); let udp = udp_taken(m, null, wan_zone); let tcp = tcp_taken(m); let port = free_port(udp); @@ -189,10 +202,14 @@ function setup_defaults(a) { port, subnet: free_subnet(map(networks, (n) => n.cidr)), endpoint: host, + // Where the address came from (ddns, cert, wan, portal) and what the WAN is (public, private, cgnat, none). + endpoint_from: from, + wan_kind: kind, + wan_ip: wan_ip || null, // Automatic. mtu: 0, zones, - lan_zone: index(zones, 'lan') >= 0 ? 'lan' : zones[0], + lan_zone, wan_zone, // A portal already on keeps its port; a new one takes the server's number when it can. portal_port: m.settings.portal_enabled ? m.settings.portal_port : free_portal_port(port, m.settings.portal_port, tcp), @@ -204,6 +221,22 @@ function setup_defaults(a) { }; } +/** + * Where a public address points, as the admin types it (debounced in the + * UI): the same facts Health uses, in words. `id` names the server whose WAN + * to compare with (a new one: the default WAN). + */ +function endpoint_probe(a) { + let host = str(a.host); + if (host != '' && !valid_host(host)) + die('Public address must be a hostname or IP address.'); + let m = core.load(); + let srv = m.servers[str(a.id)] ?? null; + let f = health.endpoint_facts(srv, host); + let w = health.endpoint_words(f, `UDP ${srv?.port ?? +a.port || 4500}`); + return { ...f, status: w.status, text: w.text }; +} + /** AmneziaWG can run a server: installed, and its kernel module loads. */ function need_awg_loaded() { devices.need_awg(); @@ -244,7 +277,7 @@ function server_create(a) { } check_udp_port(port, udp); let mtu = check_mtu(a.mtu == 0 ? '' : a.mtu); - let preset = str(a.preset) || 'standard'; + let preset = str(a.preset) || default_method(); let srv = { id, ifname, port, subnet: str(a.subnet), endpoint: str(a.endpoint), obf: awg.obf_preset(check_method(preset)) }; let pc = parse_cidr(srv.subnet); if (pc) @@ -264,6 +297,8 @@ function server_create(a) { let set = (k, v) => c.set(core.CONFIG, id, k, v); c.set(core.CONFIG, 'settings', 'settings'); c.set(core.CONFIG, id, 'server'); + if (!valid_name(str(a.name) || 'Home')) + die(`Server: ${NAME_RULE}`); set('name', str(a.name) || 'Home'); set('ifname', ifname); set('port', `${port}`); @@ -465,12 +500,13 @@ function server_update(a) { die('Unknown server.'); let set = (k, val) => (val == null || val == '') ? c.delete(core.CONFIG, srv.id, k) : c.set(core.CONFIG, srv.id, k, val); if (v.name != null) { - if (str(v.name) == '') - die('Name cannot be empty.'); + if (!valid_name(str(v.name))) + die(`Server: ${NAME_RULE}`); set('name', str(v.name)); } + // Empty = the portal's address (core.endpoint_host), as at creation. if (v.endpoint != null) { - if (str(v.endpoint) == '' || !valid_host(str(v.endpoint))) + if (str(v.endpoint) != '' && !valid_host(str(v.endpoint))) die('Public address must be a hostname or IP address.'); set('endpoint', str(v.endpoint)); } @@ -504,10 +540,23 @@ function server_update(a) { else c.delete(core.CONFIG, srv.id, 'dns'); } + // A new tunnel network: private, free, and every device renumbered into it. + if (v.subnet != null && str(v.subnet) != '' && str(v.subnet) != srv.subnet) { + let pc = parse_cidr(str(v.subnet)); + if (!pc) + die('Subnet must look like 10.77.0.0/24.'); + if (!core.private_cidr(pc)) + die('Use a private range: 10.x.x.x, 172.16–31.x.x or 192.168.x.x.'); + let taken = map(filter(taken_networks(m), (n) => n.cidr != srv.subnet && n.name != srv.name), (n) => n.cidr); + for (let t in taken) + if (cidr_overlaps(pc, parse_cidr(t))) + die(`Subnet overlaps ${t}.`); + core.renumber_server(c, m, srv, cidr_str(pc)); + } return srv; }); // For the log: what changed, in words. Turning on or off is its own line. - let labels = { name: 'name', endpoint: 'public address', port: 'AmneziaWG port', mtu: 'MTU', keepalive: 'keep-alive', dns: 'DNS' }; + let labels = { name: 'name', endpoint: 'public address', port: 'AmneziaWG port', mtu: 'MTU', keepalive: 'keep-alive', dns: 'DNS', subnet: 'tunnel network' }; let what = []; for (let k, label in labels) { if (v[k] == null) @@ -529,8 +578,19 @@ function server_update(a) { return r; } +/** What the ports of an existing server must avoid (the AmneziaWG card checks as you type). */ +function server_ports(a) { + let m = core.load(); + let srv = m.servers[a.id]; + if (!srv) + die('Unknown server.'); + // `networks`: what a new tunnel network must not overlap (everything but this server's own). + return { udp_taken: udp_taken(m, srv, srv.wan_zone), tcp_taken: tcp_taken(m), + networks: filter(taken_networks(m), (n) => n.cidr != srv.subnet) }; +} + function server_obfuscation(a) { - let preset = str(a.preset) || 'standard'; + let preset = str(a.preset) || default_method(); let o = awg.obf_preset(check_method(preset)); let srv = store.transact((c, m) => { let srv = m.servers[a.id]; @@ -581,6 +641,8 @@ export const methods = { lan_like: true, portal_enabled: false, portal_port: 0 }, call: wrap(server_create), }, + server_ports: { args: { id: '' }, call: wrap(server_ports) }, + endpoint_probe: { args: { host: '', id: '', port: 0 }, call: wrap(endpoint_probe) }, server_obfuscation: { args: { id: '', preset: '' }, call: wrap(server_obfuscation) }, server_update: { args: { id: '', values: {} }, call: wrap(server_update) }, interfaces: { args: { id: '' }, call: wrap(interfaces_get) }, diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/status.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/status.uc index 2a1d6b1..1e9a0ab 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/status.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/status.uc @@ -11,8 +11,29 @@ import * as net from 'dawnline.net'; import * as loop from 'dawnline.loop'; import * as awg from 'dawnline.awg'; import * as lookup from 'dawnline.lookup'; +import * as health from 'dawnline.health'; import { wrap, str, clamp_days } from 'dawnline.rpc.common'; +/** The router's public IPv4 (null when none or private). */ +function wan_public(m) { + let w = lookup.router_wan(m); + return w && health.wan_kind(w) == 'public' ? w : null; +} + +/** The router's own public addresses: a device at home that reaches the server through the WAN address (NAT loopback) is not "outside". */ +function own_addresses(m) { + let own = {}; + for (let id, srv in m.servers) { + let a = net.wan_address(srv) ?? lookup.wan_ipv4(srv.wan_zone); + if (a) + own[a] = true; + } + let wan = lookup.wan_ipv4('wan'); + if (wan) + own[wan] = true; + return own; +} + /** Router location plus one point per (device, recent client address). */ function geo_view(m, usage, dmp) { if (!m.settings.geo_enabled) @@ -84,8 +105,17 @@ function server_view(m, srv, usage, dmp, rates, days) { online++; } let st = srv.private_key ? awg.server_state(srv) : { up: false, uptime: 0 }; + // The newest handshake from a public address that is not the router's own: + // proof that the port is reachable from the internet. + let own = own_addresses(m); + let reached = 0; + for (let id, d in m.devices) + if (m.people[d.person]?.server == srv.id) + for (let ip, ts in usage.devices?.[id]?.ips ?? {}) + if (geo.is_public(ip) && !own[ip] && ts > reached) + reached = ts; return { - id: srv.id, name: srv.name, ifname: srv.ifname, port: srv.port, subnet: srv.subnet, + id: srv.id, name: srv.name, ifname: srv.ifname, port: srv.port, subnet: srv.subnet, reached, endpoint: core.endpoint_host(m, srv), public_key: srv.public_key, enabled: srv.enabled, lan_like: srv.lan_like, device_mesh: srv.device_mesh, mesh: srv.mesh, preset: srv.preset, mtu: srv.mtu, keepalive: srv.keepalive, dns: srv.dns, // What devices get now, by kind (mtu 0 = automatic). @@ -169,9 +199,12 @@ function status(a) { like_home: loop.status(), awg: awg.caps(), awg_state: awg.state(), + // The router's public IPv4 (null when none or private): a server whose public address is an old one is told so. + wan: wan_public(m), }; } + /** The newest `limit` events; `person` keeps one person's only, `since` only those after a time. */ function events_list(a) { // Tunnel down/up events of older versions: the service log tells it better (names, reasons). diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc index fd71e78..d7acdef 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc @@ -6,7 +6,7 @@ // config_get_bool does, so the service and the code never disagree. import { stat } from 'fs'; -import { ip2int, valid_host } from 'dawnline.util'; +import { ip2int, valid_host, ulength } from 'dawnline.util'; import { INTERVALS, TARGETS } from 'dawnline.updates'; /* ---------- addresses ---------- */ @@ -114,7 +114,7 @@ export function to_int(v, dflt, lo, hi) { export const SETTINGS = { portal_enabled: { type: 'bool', dflt: false, restart: true }, portal_host: { type: 'host', dflt: '', restart: true, msg: 'Public address must be a hostname or IP address.' }, - portal_alt: { type: 'hosts', dflt: [], restart: true }, + portal_alt: { type: 'hosts', dflt: [], restart: true, msg: 'Other addresses must be hostnames or IP addresses.' }, portal_port: { type: 'int', dflt: 8443, min: 1, max: 65535, restart: true, msg: 'Choose a free port between 1 and 65535 (not 22, 53, 80 or 443).' }, portal_title: { type: 'text', dflt: 'Dawnline', max: 64, msg: 'Portal title: up to 64 characters on one line.' }, @@ -165,9 +165,13 @@ export function validate(key, val) { let t = spec.type; if (t == 'hosts') { let lst = []; - for (let x in (type(val) == 'array' ? val : [])) - if (type(x) == 'string' && valid_host(trim(x)) && index(lst, trim(x)) < 0) + for (let x in (type(val) == 'array' ? val : [])) { + // A typo must not vanish on Save: refused, like the main address. + if (type(x) != 'string' || (trim(x) != '' && !valid_host(trim(x)))) + bad(spec, key); + if (trim(x) != '' && index(lst, trim(x)) < 0) push(lst, trim(x)); + } return length(lst) ? lst : null; } if (t == 'targets') { @@ -223,7 +227,7 @@ export function validate(key, val) { bad(spec, key); } else if (t == 'text') { - if (length(val) > spec.max || match(val, /[[:cntrl:]]/)) + if (ulength(val) > spec.max || match(val, /[[:cntrl:]]/)) bad(spec, key); } return val; 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 9b01094..4ba9770 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 @@ -4,7 +4,7 @@ import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; -export const VERSION = '0.7.0'; +export const VERSION = '0.8.0'; /** GitHub repository with Dawnline releases (updates and the installer). */ export const REPO = 'tickcount/luci-app-dawnline'; export const RUN_DIR = '/var/run/dawnline'; @@ -455,38 +455,139 @@ export function in_cidr(ip, c) { return n != null && n >= c.net && n < c.net + c.size; }; +/* ---------- text ---------- */ + +/** Characters in a UTF-8 string (length() counts bytes: "Мама" is 8 of them). */ +export function ulength(s) { + let n = 0; + for (let i = 0; i < length(s); i++) + if ((ord(s, i) & 0xc0) != 0x80) + n++; + return n; +}; + +/** The first `n` characters of a UTF-8 string, never cut inside one. */ +export function ucut(s, n) { + let i = 0, c = 0; + while (i < length(s)) { + if ((ord(s, i) & 0xc0) != 0x80) { + if (c == n) + break; + c++; + } + i++; + } + return substr(s, 0, i); +}; + +// Cyrillic (Russian, Ukrainian) to Latin: а-я by code point from U+0430, then +// ё, і, ї, є, ґ; the rest of a string passes as it is. +const CYR_A = 0x430; +const CYRILLIC = [ 'a', 'b', 'v', 'g', 'd', 'e', 'zh', 'z', 'i', 'y', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', + 'f', 'kh', 'ts', 'ch', 'sh', 'shch', '', 'y', '', 'e', 'yu', 'ya' ]; +const CYRILLIC_MORE = { '1105': 'yo', '1110': 'i', '1111': 'yi', '1108': 'ye', '1169': 'g' }; + +/** + * Cyrillic letters written in Latin ("Мама" → "mama", "Юля" → "yulya"): + * ids, hostnames and file names are ASCII, and a person should recognise + * their own in them. Other characters are left alone. + */ +export function translit(s) { + let out = '', i = 0, n = length(s); + while (i < n) { + let b = ord(s, i); + if (b < 0x80) { + out += substr(s, i, 1); + i++; + continue; + } + let cp = 0, len = 1; + if ((b & 0xe0) == 0xc0 && i + 1 < n) { + cp = ((b & 0x1f) << 6) | (ord(s, i + 1) & 0x3f); + len = 2; + } + else if ((b & 0xf0) == 0xe0 && i + 2 < n) { + cp = ((b & 0x0f) << 12) | ((ord(s, i + 1) & 0x3f) << 6) | (ord(s, i + 2) & 0x3f); + len = 3; + } + else if ((b & 0xf8) == 0xf0 && i + 3 < n) + len = 4; + // Upper case to lower: А-Я, Ё, І, Ї, Є, Ґ. + if (cp >= 0x410 && cp <= 0x42f) + cp += 0x20; + else if (cp == 0x401) + cp = 0x451; + else if (cp == 0x406) + cp = 0x456; + else if (cp == 0x407) + cp = 0x457; + else if (cp == 0x404) + cp = 0x454; + else if (cp == 0x490) + cp = 0x491; + let t = cp >= CYR_A && cp < CYR_A + length(CYRILLIC) ? CYRILLIC[cp - CYR_A] : CYRILLIC_MORE[`${cp}`]; + out += t != null ? t : substr(s, i, len); + i += len; + } + return out; +}; + /* ---------- validation ---------- */ export function valid_slug(s) { return type(s) == 'string' && match(s, /^[a-z0-9][a-z0-9-]{0,30}[a-z0-9]$|^[a-z0-9]$/) != null; }; +/** A name people see: 1-48 characters (not bytes), none of < > " \ or control characters. */ export function valid_name(s) { - return type(s) == 'string' && length(trim(s)) > 0 && length(s) <= 48 && match(s, /[<>"\\[:cntrl:]]/) == null; + return type(s) == 'string' && ulength(trim(s)) > 0 && ulength(s) <= 48 && match(s, /[<>"\\[:cntrl:]]/) == null; }; +/** What valid_name wants, for the admin. */ +export const NAME_RULE = 'Enter a name: up to 48 characters, without < > " or \\.'; + export function valid_key(s) { return type(s) == 'string' && match(s, /^[A-Za-z0-9+\/]{42}[AEIMQUYcgkosw048]=$/) != null; }; +/** An IPv6 address in its usual spelling (no zone, no brackets). */ +export function is_ip6(s) { + return type(s) == 'string' && match(s, /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/) != null && match(s, /:::/) == null; +}; + export function valid_host(s) { return type(s) == 'string' && length(s) <= 253 && (match(s, /^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/) != null || - ip2int(s) != null || match(s, /^[0-9a-fA-F:]+$/) != null); + ip2int(s) != null || is_ip6(s)); }; +/** YYYY-MM-DD, and a day that exists (2026-02-30 does not). */ export function valid_date(s) { - return type(s) == 'string' && match(s, /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) != null; + let m = type(s) == 'string' ? match(s, /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/) : null; + if (!m) + return false; + let l = localtime(timelocal({ year: +m[1], mon: +m[2], mday: +m[3], hour: 12, min: 0, sec: 0 })); + return l.year == +m[1] && l.mon == +m[2] && l.mday == +m[3]; }; -/** Turn a display name into a portal slug candidate. */ +/** Turn a display name into a portal slug candidate ("Мама Таня" → "mama-tanya"). */ export function slugify(s) { - let out = lc(trim(`${s ?? ''}`)); + let out = lc(translit(trim(`${s ?? ''}`))); out = replace(out, /[^a-z0-9]+/g, '-'); out = replace(out, /^-+|-+$/g, ''); return substr(out, 0, 32) || 'user'; }; +/** + * A device's name as a DNS label ("Galaxy S24" → "galaxy-s24", "Телефон" → + * "telefon"): at most 40 characters, "device" when nothing is left. + */ +export function host_label(s) { + let l = replace(lc(translit(`${s ?? ''}`)), /[^a-z0-9]+/g, '-'); + l = replace(substr(replace(l, /^-+|-+$/g, ''), 0, 40), /-+$/g, ''); + return l || 'device'; +}; + /* ---------- time ---------- */ /** "YYYY-MM-DD" → epoch of the end of that local day (23:59:59). */ diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc index 76b9d8a..018ae72 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc @@ -29,6 +29,13 @@ export function device_view(m, d, usage, dmp) { let ts = time(); let hs = peer?.handshake || u?.handshake || 0; let p = m.people[d.person]; + // The same label /tmp/hosts carries (core.device_labels), so what is shown resolves. + let label = ''; + if (m.settings.hostnames && p) { + m._labels ??= {}; + m._labels[p.id] ??= core.device_labels(m, p); + label = m._labels[p.id][d.id] ?? 'device'; + } let v = { id: d.id, name: d.name, @@ -44,7 +51,7 @@ export function device_view(m, d, usage, dmp) { month: live.month(u), total: u?.total ?? [ 0, 0 ], spark: spark(u, 7), - hostname: m.settings.hostnames && p ? `${replace(replace(lc(d.name), /[^a-z0-9]+/g, '-'), /^-+|-+$/g, '') || 'device'}.${p.id}.${m.settings.domain}` : '', + hostname: label ? `${label}.${p.id}.${m.settings.domain}` : '', browser_key: d.private_key == '', // Its configuration changed since it was last shown or downloaded. config_stale: config_stale(m, d), diff --git a/tests/ucode/awg.test.uc b/tests/ucode/awg.test.uc index adf61a4..deef4b7 100644 --- a/tests/ucode/awg.test.uc +++ b/tests/ucode/awg.test.uc @@ -13,27 +13,17 @@ test('obf_preset off', () => { eq(awg.obf_errors(o), [], 'valid'); }); -test('obf_preset standard and strong', () => { - for (let name in [ 'standard', 'strong' ]) - for (let i = 0; i < 25; i++) { - let o = awg.obf_preset(name); - eq(awg.obf_errors(o), [], `${name} is valid`); - let jc = +o.jc, jmin = +o.jmin, jmax = +o.jmax; - ok(name == 'strong' ? jc >= 6 && jc <= 10 : jc >= 3 && jc <= 6, `${name} jc=${o.jc}`); - ok(jmin >= 64 && jmax > jmin && jmax <= 1024, `${name} junk sizes ${o.jmin}-${o.jmax}`); - ok(+o.s1 + 56 != +o.s2, 's1 + 56 != s2'); - eq(length(uniq([ o.h1, o.h2, o.h3, o.h4 ])), 4, 'distinct headers'); - for (let k in [ 'h1', 'h2', 'h3', 'h4' ]) - ok(+o[k] >= 5, `${k} above the reserved values`); - eq(o.s3, null, 'no 2.0 values'); - } -}); - test('obf_preset balanced', () => { for (let i = 0; i < 25; i++) { let o = awg.obf_preset('balanced'); eq(awg.obf_errors(o), [], 'balanced is valid'); ok(+o.jc >= 4 && +o.jc <= 8, `jc=${o.jc}`); + let jmin = +o.jmin, jmax = +o.jmax; + ok(jmin >= 64 && jmax > jmin && jmax <= 1024, `junk sizes ${o.jmin}-${o.jmax}`); + ok(+o.s1 + 56 != +o.s2, 's1 + 56 != s2'); + eq(length(uniq([ o.h1, o.h2, o.h3, o.h4 ])), 4, 'distinct headers'); + for (let k in [ 'h1', 'h2', 'h3', 'h4' ]) + ok(+o[k] >= 5, `${k} above the reserved values`); ok(+o.s3 >= 8 && +o.s3 <= 48 && +o.s4 >= 4 && +o.s4 <= 16, `padding ${o.s3}/${o.s4}`); ok(substr(o.i1, 0, 3) == ' { for (let i = 0; i < 20; i++) ok(match(core.new_code(), core.WORD_CODE), 'new_code is a word code'); }); + +test('renumber_server', () => { + let srv = { id: 'main', name: 'Main', subnet: '10.9.0.0/29' }; + let mm = { + servers: { main: srv, other: { id: 'other', subnet: '10.9.1.0/29' } }, + people: { a: { server: 'main', devices: [ 'a1', 'a2' ] }, o: { server: 'other', devices: [ 'o1' ] } }, + devices: { a1: { person: 'a', address: '10.9.0.5' }, a2: { person: 'a', address: '10.9.0.3' }, o1: { person: 'o', address: '10.9.1.2' } }, + }; + let set = {}; + let c = { set: (cfg, s, k, v) => { set[`${s}.${k}`] = v; }, delete: () => {} }; + core.renumber_server(c, mm, srv, '10.77.0.0/24'); + eq(srv.subnet, '10.77.0.0/24', 'the server moves'); + eq([ mm.devices.a1.address, mm.devices.a2.address ], [ '10.77.0.2', '10.77.0.3' ], 'devices renumbered lowest first'); + eq(mm.devices.o1.address, '10.9.1.2', 'another server untouched'); + eq(set, { 'a1.address': '10.77.0.2', 'a2.address': '10.77.0.3', 'main.subnet': '10.77.0.0/24' }, 'written to uci'); + let err = null; + try { core.renumber_server(c, mm, srv, '10.9.2.0/30'); } catch (e) { err = e; } + ok(err != null, 'refuses a subnet too small for the devices'); +}); + +test('device_labels', () => { + let mm = { devices: { + a: { id: 'a', name: 'iPhone', created: 1 }, b: { id: 'b', name: 'iPhone!', created: 2 }, + c: { id: 'c', name: 'Телефон', created: 3 }, d: { id: 'd', name: 'телефон', created: 4 }, + } }; + let p = { id: 'p', devices: [ 'd', 'c', 'b', 'a' ] }; + eq(core.device_labels(mm, p), { a: 'iphone', b: 'iphone-2', c: 'telefon', d: 'telefon-2' }, 'unique by age'); +}); diff --git a/tests/ucode/schema.test.uc b/tests/ucode/schema.test.uc index 0a6314b..6bf2252 100644 --- a/tests/ucode/schema.test.uc +++ b/tests/ucode/schema.test.uc @@ -34,8 +34,9 @@ test('validate: host and hosts', () => { eq(schema.validate('portal_host', 'vpn.example.com'), 'vpn.example.com', 'name'); eq(schema.validate('portal_host', '203.0.113.7'), '203.0.113.7', 'address'); throws(() => schema.validate('portal_host', 'bad host!'), /hostname or IP/, 'bad'); - eq(schema.validate('portal_alt', [ 'a.example.com', ' a.example.com ', 'bad host', 'b.example.com' ]), - [ 'a.example.com', 'b.example.com' ], 'trimmed, deduplicated, bad ones dropped'); + eq(schema.validate('portal_alt', [ 'a.example.com', ' a.example.com ', '', 'b.example.com' ]), + [ 'a.example.com', 'b.example.com' ], 'trimmed, deduplicated, empty ones dropped'); + throws(() => schema.validate('portal_alt', [ 'a.example.com', 'bad host' ]), /hostnames or IP/, 'a typo is refused, not dropped'); eq(schema.validate('portal_alt', []), null, 'empty list removes the option'); eq(schema.validate('portal_alt', 'a.example.com'), null, 'not a list'); }); diff --git a/tests/ucode/util.test.uc b/tests/ucode/util.test.uc index 0df0364..db7c77e 100644 --- a/tests/ucode/util.test.uc +++ b/tests/ucode/util.test.uc @@ -8,8 +8,10 @@ test('valid_name', () => { ok(!util.valid_name(' '), 'blank'); ok(!util.valid_name(null), 'null'); ok(!util.valid_name(42), 'number'); - ok(util.valid_name('a' + replace(sprintf('%47s', ''), ' ', 'b')), '48 bytes'); - ok(!util.valid_name('a' + replace(sprintf('%48s', ''), ' ', 'b')), '49 bytes'); + ok(util.valid_name('a' + replace(sprintf('%47s', ''), ' ', 'b')), '48 characters'); + ok(!util.valid_name('a' + replace(sprintf('%48s', ''), ' ', 'b')), '49 characters'); + ok(util.valid_name('ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧ'), '25 Cyrillic letters (50 bytes) are 25 characters'); + ok(!util.valid_name('Bob "B"'), 'quotes'); ok(!util.valid_name('a { eq(util.slugify(' --Bob!! '), 'bob', 'trimmed dashes'); eq(util.slugify(''), 'user', 'empty'); eq(util.slugify(null), 'user', 'null'); - eq(util.slugify('Мама'), 'user', 'nothing left'); + eq(util.slugify('Мама'), 'mama', 'Cyrillic written in Latin'); + eq(util.slugify('Юля Щукина'), 'yulya-shchukina', 'Cyrillic words'); + eq(util.slugify('日本'), 'user', 'nothing left'); eq(length(util.slugify(replace(sprintf('%40s', ''), ' ', 'x'))), 32, 'cut at 32'); }); @@ -112,3 +116,17 @@ test('dates', () => { eq(util.day_key_ago(0, noon), '2026-03-01', 'zero days'); eq(util.uniq([ 'a', 'b', 'a', 'c', 'b' ]), [ 'a', 'b', 'c' ], 'uniq'); }); + +test('text: ulength, ucut, translit, host_label', () => { + eq(util.ulength('Мама'), 4, 'characters, not bytes'); + eq(util.ulength('abc'), 3, 'ascii'); + eq(util.ucut('Привет', 3), 'При', 'cut by characters'); + eq(util.ucut('ab', 5), 'ab', 'shorter than the cut'); + eq(util.translit('Мама Таня'), 'mama tanya', 'Russian'); + eq(util.translit('Їжак Ґава ёж'), 'yizhak gava yozh', 'Ukrainian letters and ё'); + eq(util.translit('Mixed Текст 1'), 'Mixed tekst 1', 'Latin and digits pass'); + eq(util.host_label('Galaxy S24'), 'galaxy-s24', 'label'); + eq(util.host_label('Телефон Ёжика'), 'telefon-yozhika', 'Cyrillic label'); + eq(util.host_label('!!!'), 'device', 'nothing left'); + eq(length(util.host_label(replace(sprintf('%50s', ''), ' ', 'x'))), 40, 'cut at 40'); +}); diff --git a/web/package-lock.json b/web/package-lock.json index a16cf14..d486a98 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "dawnline-web", - "version": "0.7.0", + "version": "0.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dawnline-web", - "version": "0.7.0", + "version": "0.8.0", "license": "MIT", "dependencies": { "qrcode-generator": "1.4.4" diff --git a/web/package.json b/web/package.json index d578091..51d34a0 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dawnline-web", - "version": "0.7.0", + "version": "0.8.0", "private": true, "license": "MIT", "type": "module", diff --git a/web/src/admin/access.ts b/web/src/admin/access.ts index 995aad5..7b7a589 100644 --- a/web/src/admin/access.ts +++ b/web/src/admin/access.ts @@ -6,8 +6,10 @@ import { E } from './e'; import { api, type HomeHost } from './api'; import { button } from './ui/button'; import { cancelButton, closeModal, confirmDialog, modal } from './ui/modal'; -import { attempt } from './ui/toast'; +import { attempt, notify } from './ui/toast'; import { chipToggle, input } from './ui/controls'; +import { firstBad, liveField } from './ui/layout'; +import { circleNameHelp, ipv4Help, nameHelp, portsHelp } from './netcheck'; import { icon } from '../shared/icons'; type Service = Status['services'][number]; @@ -30,17 +32,23 @@ export function serviceDialog(sv: Service | null, prefill: Partial, onS placeholder: 'All ports, or e.g. 445, 5000', class: 'cbi-input-text dl-mono', }); - const field = (label: string, el: Node) => - E('div', { class: 'cbi-value' }, [E('label', { class: 'cbi-value-title' }, label), E('div', { class: 'cbi-value-field' }, el)]); + const nameRow = liveField('Name', name, () => nameHelp(name.value, [], 'Shown to people who may reach it.')); + const addrRow = liveField('Address', addr, () => ipv4Help(addr.value)); + const portsRow = liveField('Ports', ports, () => portsHelp(ports.value)); modal( sv ? `Edit ${sv.name}` : 'Add service', - [field('Name', name), field('Address', addr), field('Ports', ports)], + [nameRow, addrRow, portsRow], [ cancelButton(), ' ', button( 'Save', async () => { + const bad = firstBad([nameRow, addrRow, portsRow]); + if (bad) { + notify(bad, 'warning'); + return; + } const list = ports.value.split(/[ ,]+/).filter(Boolean); if (await attempt(() => api.serviceSet(sv?.id ?? '', name.value, addr.value, list), 'Saved')) { closeModal(); @@ -316,11 +324,13 @@ export function circleDialog(st: Status, serverId: string, ci: Circle | null, on ); const field = (label: string, el: Node) => E('div', { class: 'cbi-value' }, [E('label', { class: 'cbi-value-title' }, label), E('div', { class: 'cbi-value-field' }, el)]); + const others = st.circles.filter((c) => c.server === serverId && c.id !== ci?.id).map((c) => c.name); + const nameRow = liveField('Name', name, () => circleNameHelp(name.value, others)); modal( ci ? `Edit ${ci.name}` : 'New circle', [ - field('Name', name), + nameRow, field('Colour', swatches), field('People', chips), E('p', { class: 'dl-sub' }, 'Devices of people in one circle reach each other. A person is in one circle at a time.'), @@ -344,6 +354,11 @@ export function circleDialog(st: Status, serverId: string, ci: Circle | null, on button( 'Save', async () => { + const h = nameRow.help(); + if (h.bad) { + notify(h.text, 'warning'); + return; + } if (await attempt(() => api.circleSet(ci?.id ?? '', serverId, name.value, color, [...members]), 'Saved')) { closeModal(); onDone(); diff --git a/web/src/admin/api.ts b/web/src/admin/api.ts index 1da0aab..90360ff 100644 --- a/web/src/admin/api.ts +++ b/web/src/admin/api.ts @@ -39,6 +39,24 @@ export interface SetupDefaults { tcp_taken: PortHold[]; awg: AwgCaps; awg_state?: AwgState; + /** Where the suggested address came from: ddns, cert, wan, portal ('' = nothing found). */ + endpoint_from?: string; + /** What the WAN's IPv4 is: public, private (behind another router), cgnat, none. */ + wan_kind?: 'public' | 'private' | 'cgnat' | 'none'; + wan_ip?: string | null; +} + +/** Where a public address points (rpc endpoint_probe): the facts and their verdict in words. */ +export interface EndpointProbe { + host: string; + ips: string[]; + wan: string | null; + kind: 'public' | 'private' | 'cgnat' | 'none'; + cloudflare: boolean; + here: boolean; + v6_only: boolean; + status: 'ok' | 'warn' | 'error'; + text: string; } export interface Backup { @@ -323,7 +341,8 @@ export type PersonPatch = Partial< | 'bonus_gb' | 'hours' | 'note' - | 'dns_mode', + | 'dns_mode' + | 'server', string > > & { paused?: boolean; services?: string[]; circle?: string; home_nets?: string[] }; @@ -349,6 +368,7 @@ const personUpdateRaw = rpc.declare({ 'services', 'circle', 'home_nets', + 'server', ], }); @@ -367,7 +387,7 @@ async function personUpdate(id: string, patch: PersonPatch): Promise<{ person: P 'note', 'dns_mode', ] as const; - const args: unknown[] = [id, ...keys.map((k) => patch[k]), patch.paused, patch.services, patch.circle, patch.home_nets]; + const args: unknown[] = [id, ...keys.map((k) => patch[k]), patch.paused, patch.services, patch.circle, patch.home_nets, patch.server]; return settle(await personUpdateRaw(...args)); } @@ -452,6 +472,10 @@ export const api = { ]), serverObfuscation: call('server_obfuscation', ['id', 'preset']), serverUpdate: call('server_update', ['id', 'values']), + /** What an existing server's ports and a new tunnel network must avoid (checked as you type). */ + serverPorts: call<{ udp_taken: PortHold[]; tcp_taken: PortHold[]; networks?: Network[] }>('server_ports', ['id']), + /** Where a public address points, for the live help under the field (debounced by the caller). */ + endpointProbe: call('endpoint_probe', ['host', 'id', 'port']), serverDelete: call('server_delete', ['id']), /** The personal link, its code and every address it works on (main first); not part of the status. */ personLinks: call<{ code: string; link: string | null; links: string[] }>('person_links', ['id']), diff --git a/web/src/admin/cores/awg.ts b/web/src/admin/cores/awg.ts index b4ca03c..87dee90 100644 --- a/web/src/admin/cores/awg.ts +++ b/web/src/admin/cores/awg.ts @@ -10,11 +10,12 @@ import { confirmDialog } from '../ui/modal'; import { copyText, downloadFile } from '../ui/files'; import { attempt, notify } from '../ui/toast'; import { input } from '../ui/controls'; -import { callout, card, group, row, svg } from '../ui/layout'; +import { callout, card, firstBad, group, liveRow, row, svg } from '../ui/layout'; +import { keepaliveHelp, mtuHelp, portHelp, type PortHold } from '../netcheck'; import { qrSvg } from '../../shared/qr'; import { vpnKey } from '../../shared/vpnkey'; import { icon } from '../../shared/icons'; -import { methodInfo, methodPicker, type Method } from '../disguise'; +import { methodInfo, methodPicker, type Method, defaultMethod, legacyTitle } from '../disguise'; import { coreHead, type Core, type CoreCtx } from './common'; /** `.conf` names of the disguise parameters, in file order. */ @@ -198,6 +199,13 @@ function fileCard(cfg: AwgConfig): HTMLElement { ]); } +/** The configuration carries no disguise values: plain WireGuard, any WireGuard app takes it. */ +export function plainWg(cfg: AwgConfig): boolean { + const o = (cfg.amnezia.obfuscation ?? {}) as Record; + const neutral: Record = { h1: '1', h2: '2', h3: '3', h4: '4' }; + return Object.entries(o).every(([k, v]) => v == null || v === '' || v === (neutral[k] ?? '0')); +} + /** File / key / QR switcher for a client configuration; opens on the file unless asked otherwise. */ export async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr' = 'file'): Promise { if (!cfg.has_private_key) @@ -211,7 +219,11 @@ export async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr qr: () => E('div', { class: 'dl-qr-pane' }, [ svg(qrSvg(cfg.conf), 'dl-qr'), - E('span', { class: 'dl-sub' }, 'Scan with AmneziaVPN or AmneziaWG on the device.'), + E( + 'span', + { class: 'dl-sub' }, + plainWg(cfg) ? 'Scan with AmneziaVPN or any WireGuard app on the device.' : 'Scan with AmneziaVPN or AmneziaWG on the device.', + ), ]), key: () => E('div', { class: 'dl-stack gap8' }, [ @@ -243,7 +255,7 @@ async function applyDisguise(ctx: CoreCtx, srv: Server, m: Method, same: boolean const devices = people.reduce((n, p) => n + p.devices.length, 0); const ok = await confirmDialog( same ? 'Generate new disguise values?' : `Switch to ${info.title}?`, - `${devices} AmneziaWG device${devices === 1 ? '' : 's'} stop connecting until they import their configuration again (from their personal link or from you).${m === 'max' ? ' They need an app with AmneziaWG 3.1.' : m === 'balanced' ? ' They need an app with AmneziaWG 2.0 or newer.' : ''}`, + `${devices} AmneziaWG device${devices === 1 ? ' stops' : 's stop'} connecting until ${devices === 1 ? 'it imports its' : 'they import their'} configuration again (from their personal link or from you).${m === 'max' ? ' They need an app with AmneziaWG 3.1.' : m === 'balanced' ? ' They need an app with AmneziaWG 2.0 or newer.' : ''}${ctx.st.servers.length === 1 && devices ? ' To keep the old disguise for some people, add a second server and move them there.' : ''}`, same ? 'Generate and apply' : 'Switch and apply', true, ); @@ -263,30 +275,54 @@ export function settingsCard(ctx: CoreCtx, srv: Server): HTMLElement { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono', }); - const now = `${srv.mtus.computer} for computers and routers, ${srv.mtus.phone} for phones and tablets`; - const mtuHint = srv.mtu - ? `Now ${now}. Empty = automatic.` - : `Automatic by device type and disguise: now ${now}. Lower it if some sites hang.`; const ka = input(String(srv.keepalive ?? ''), { placeholder: '25', inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }); const current = methodInfo(srv.preset) ? (srv.preset as Method) : undefined; - let selected: Method = current ?? 'standard'; + let selected: Method = current ?? defaultMethod(st.awg); const apply = button('', () => applyDisguise(ctx, srv, selected, selected === current), 'neutral'); const label = () => dom.content(apply, selected === current ? [icon('reset'), ' Generate new values'] : [`Switch to ${methodInfo(selected)!.title}`]); label(); const tools = st.awg_state?.tools !== false; + // Who holds which port arrives once the card is built (netstat on the + // router); until then the port is only checked for its range. + let holds: PortHold[] = []; + const portRow = liveRow('UDP port', port, () => + portHelp( + Number(port.value), + holds, + `Opened on the WAN firewall automatically.${Number(port.value) === 4500 ? ' 4500 is IPsec’s port: most networks let it through.' : ''}`, + ), + ); + api + .serverPorts(srv.id) + .then((r) => { + holds = r.udp_taken ?? []; + portRow.refresh(); + }) + .catch(() => {}); + const mtuRow = liveRow('MTU', mtu, () => mtuHelp(mtu.value, srv.mtus)); + const kaRow = liveRow('Keep-alive', ka, () => keepaliveHelp(ka.value)); return card( '', [ coreHead('AmneziaWG', srv.ifname), - group('globe', 'Listening', 'Where devices reach this core from the internet', [ - row('UDP port', port, 'Opened on the WAN firewall automatically.'), - ]), + group('globe', 'Listening', 'Where devices reach this core from the internet', [portRow]), group('file', 'In every device configuration', 'Changing these marks devices “Update config” until they import again', [ - row('MTU', mtu, mtuHint), - row('Keep-alive', ka, 'Seconds between packets devices send to keep NAT open. 0 = off.'), + mtuRow, + kaRow, ]), group('shield', 'Disguise', 'So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard', [ + // A server from before 0.8 on the old junk-only disguise: it runs, but is no longer offered. + legacyTitle(srv.preset) + ? callout('warn', [ + E('b', {}, legacyTitle(srv.preset)!), + ' is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to ', + E('b', {}, 'Balanced'), + ' or ', + E('b', {}, 'Maximum'), + ': devices import their configuration again.', + ]) + : '', methodPicker( st.awg, selected, @@ -331,7 +367,19 @@ export function settingsCard(ctx: CoreCtx, srv: Server): HTMLElement { ], [ E('span', { class: 'dl-sub' }, 'Port, MTU and keep-alive apply at once.'), - button('Save', () => ctx.save({ port: port.value, mtu: mtu.value, keepalive: ka.value }, 'AmneziaWG saved'), 'positive'), + button( + 'Save', + () => { + // The help lines already say what is wrong: do not send it anyway. + const bad = firstBad([portRow, mtuRow, kaRow]); + if (bad) { + notify(bad, 'warning'); + return; + } + return ctx.save({ port: port.value, mtu: mtu.value, keepalive: ka.value }, 'AmneziaWG saved'); + }, + 'positive', + ), ], ); } @@ -361,7 +409,10 @@ function overviewTile(srv: Server): HTMLElement { ]), E('div', { class: 'dl-disg-id' }, [ E('span', { class: 'dl-disg-ic' }, icon(m?.ic ?? 'shield')), - E('span', { class: 'dl-stack' }, [E('b', {}, m ? m.title : 'Custom'), E('span', { class: 'dl-sub' }, m ? m.short : 'Set by hand')]), + E('span', { class: 'dl-stack' }, [ + E('b', {}, m ? m.title : (legacyTitle(srv.preset) ?? 'Custom')), + E('span', { class: 'dl-sub' }, m ? m.short : legacyTitle(srv.preset) ? 'Switch to Balanced or Maximum' : 'Set by hand'), + ]), ]), m ? E('div', { class: 'dl-disg-meters' }, [ diff --git a/web/src/admin/device.ts b/web/src/admin/device.ts index b2f2d5c..73f9fda 100644 --- a/web/src/admin/device.ts +++ b/web/src/admin/device.ts @@ -11,7 +11,8 @@ import { copyText, downloadFile } from './ui/files'; import { dropdown, type MenuItem } from './ui/menu'; import { drawer } from './ui/drawer'; import { attempt, notify } from './ui/toast'; -import { svg } from './ui/layout'; +import { liveField, svg } from './ui/layout'; +import { nameHelp } from './netcheck'; import { deviceStatus } from './ui/badges'; import { qrSvg } from '../shared/qr'; import { ago, bytes, isoDay, KIND_LABEL, KINDS, todayOf } from '../shared/format'; @@ -20,6 +21,7 @@ import { eventBy } from './events/model'; import { spark } from './widgets/spark'; import { clearLogDialog, exportEvents, resetUsageDialog } from './logs'; import { coreFor, coreOf, type Core } from './cores'; +import { plainWg } from './cores/awg'; import { onLiveChange } from './state/live'; import { ConnectionMap, devicePlaces, rangeControl, type MapData, type Range } from './map'; import { personUrl } from './urls'; @@ -123,7 +125,8 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { let geo = o.geo; let now = o.now; let today = o.today ?? isoDay(new Date()); - const connect = await core.connectBlock(cfg); + // Phones and tablets are set up by scanning; computers and routers by a file. + const connect = await core.connectBlock(cfg, dev.kind === 'phone' || dev.kind === 'tablet' ? 'qr' : 'file'); const titleEl = E('div', { class: 'dl-drawer-title' }); const stats = E('div', {}); const details = E('div', {}); @@ -183,7 +186,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { E('div', { class: 'dl-dstats' }, [ E('div', { class: 'dl-dstats-cell wide' }, [ E('span', { class: 'dl-metric-label' }, 'Status'), - deviceStatus(d, now, 'Waiting for the first connection'), + deviceStatus(d, now, 'Waiting for the first connection', p), ]), E('div', { class: 'dl-dstats-cell' }, [ E('span', { class: 'dl-metric-label' }, 'This month'), @@ -221,10 +224,8 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { ]), ), row('Added', `${when(d.created)} · ${d.created_by === 'portal' ? 'from the portal' : 'by you'}`), - row( - 'Public key', - E('span', { class: 'dl-mono dl-faint' }, cfg.amnezia.client_pub_key ? `${cfg.amnezia.client_pub_key.slice(0, 16)}…` : '—'), - ), + // The whole key, copyable: it is what another WireGuard server needs to add this device by hand. + cfg.amnezia.client_pub_key ? copyRow('Public key', cfg.amnezia.client_pub_key) : row('Public key', '—'), ]), ); dom.content(foot, [ @@ -300,15 +301,22 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { const rename = () => { const input = E('input', { type: 'text', class: 'cbi-input-text', value: d.name, maxlength: 48 }) as HTMLInputElement; + const taken = p.devices.filter((x) => x.id !== d.id).map((x) => x.name); + const nameRow = liveField('Name', input, () => nameHelp(input.value, taken, 'Shown in the portal and in the app.')); modal( `Rename ${d.name}`, - [E('div', { class: 'cbi-value' }, [E('label', { class: 'cbi-value-title' }, 'Name'), E('div', { class: 'cbi-value-field' }, input)])], + [nameRow], [ cancelButton(), ' ', button( 'Save', async () => { + const h = nameRow.help(); + if (h.bad) { + notify(h.text, 'warning'); + return; + } if (await attempt(() => api.deviceUpdate(d.id, input.value, undefined), 'Renamed')) { closeModal(); await changed(); @@ -426,7 +434,11 @@ export function quickMenu(anchor: HTMLElement, p: Person, d: Device, o: DeviceOp `${d.name} · QR code`, E('div', { class: 'dl-qr-pane' }, [ svg(qrSvg(core.qrText(c)), 'dl-qr'), - E('span', { class: 'dl-sub' }, 'Scan with AmneziaVPN or AmneziaWG on the device.'), + E( + 'span', + { class: 'dl-sub' }, + plainWg(c) ? 'Scan with AmneziaVPN or any WireGuard app on the device.' : 'Scan with AmneziaVPN or AmneziaWG on the device.', + ), ]), cancelButton('Close'), ); @@ -500,8 +512,22 @@ export function quickMenu(anchor: HTMLElement, p: Person, d: Device, o: DeviceOp /** Admin "Add device" dialog for a person; opens the new device's drawer. */ export function addDevice(person: Person, o: DeviceOpts) { - const nameInput = E('input', { type: 'text', class: 'cbi-input-text', placeholder: KIND_LABEL.phone, maxlength: 48 }) as HTMLInputElement; + const taken = person.devices.map((x) => x.name); + // The name a type gives when none is typed: "Phone", then "Phone 2" (as the portal does). + const suggest = (k: Kind) => { + const base = KIND_LABEL[k]; + let n = 1; + let name = base; + while (taken.some((t) => t.toLowerCase() === name.toLowerCase())) name = `${base} ${++n}`; + return name; + }; let kind: Kind = 'phone'; + const nameInput = E('input', { type: 'text', class: 'cbi-input-text', placeholder: suggest(kind), maxlength: 48 }) as HTMLInputElement; + const nameRow = liveField('Name', nameInput, () => + nameInput.value.trim() + ? nameHelp(nameInput.value, taken, 'Shown in the portal and in the app.') + : { text: `Named after its type: ${suggest(kind)}.`, bad: false }, + ); const kinds = E( 'div', { class: 'dl-kinds', role: 'radiogroup', 'aria-label': 'Type' }, @@ -521,7 +547,8 @@ export function addDevice(person: Person, o: DeviceOpts) { c.classList.toggle('on', on); c.setAttribute('aria-checked', on ? 'true' : 'false'); }); - nameInput.placeholder = KIND_LABEL[k]; + nameInput.placeholder = suggest(k); + nameRow.refresh(); }, }, [icon(k), E('span', {}, KIND_LABEL[k])], @@ -540,7 +567,7 @@ export function addDevice(person: Person, o: DeviceOpts) { ) : '', E('div', { class: 'dl-fld' }, [E('span', { class: 'dl-fld-label' }, 'Type'), kinds]), - E('label', { class: 'dl-fld' }, [E('span', { class: 'dl-fld-label' }, 'Name'), nameInput]), + nameRow, ], [ cancelButton(), @@ -548,7 +575,12 @@ export function addDevice(person: Person, o: DeviceOpts) { button( 'Add device', async () => { - const name = nameInput.value.trim() || nameInput.placeholder.replace(/^e\.g\. /, ''); + const h = nameRow.help(); + if (h.bad) { + notify(h.text, 'warning'); + return; + } + const name = nameInput.value.trim() || suggest(kind); const r = await attempt(() => api.deviceCreate(person.id, name, kind)); if (!r) return; closeModal(); diff --git a/web/src/admin/disguise.ts b/web/src/admin/disguise.ts index 97081a3..dec2b20 100644 --- a/web/src/admin/disguise.ts +++ b/web/src/admin/disguise.ts @@ -4,7 +4,7 @@ import type { AwgCaps } from '../shared/types'; import { E } from './e'; import { icon } from '../shared/icons'; -export type Method = 'standard' | 'strong' | 'balanced' | 'max' | 'off'; +export type Method = 'balanced' | 'max' | 'off'; /** The router features a method may need (the boolean ones of AwgCaps). */ export type AwgNeed = 'v2' | 'v3'; @@ -35,32 +35,12 @@ export const METHODS: MethodInfo[] = [ 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: 'balanced', title: 'Balanced', - ic: 'shieldplus', + ic: 'shield', stealth: 3, - speed: 3, + speed: 4, needs: 'v2', text: 'AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.', apps: 'AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps', @@ -81,6 +61,17 @@ export const METHODS: MethodInfo[] = [ export const methodInfo = (id: string): MethodInfo | undefined => METHODS.find((x) => x.id === id); +/** The disguise a new server gets: the strongest this router can run. */ +export const defaultMethod = (caps: AwgCaps): Method => (caps.v3 ? 'max' : caps.v2 ? 'balanced' : 'off'); + +/** + * Servers made before 0.8 may carry the old Standard or Strong disguise + * (1.0-style junk only, which networks learned to spot). They keep running; + * the picker offers Balanced or Maximum instead. The title for such a server, or null. + */ +export const legacyTitle = (preset: string): string | null => + preset === 'standard' ? 'Standard (old)' : preset === 'strong' ? 'Strong (old)' : null; + const NEEDS: Record = { v2: 'Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).', v3: 'Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1).', @@ -148,7 +139,9 @@ export function methodPicker( E( 'div', { class: 'dl-method-foot' }, - ok ? [icon('phone'), E('span', {}, m.apps)] : [icon('alert'), E('span', {}, (installed ? NEEDS : NEEDS_NONE)[m.needs!])], + ok + ? [icon(m.id === 'off' ? 'wireguard' : 'amneziawg'), E('span', {}, m.apps)] + : [icon('alert'), E('span', {}, (installed ? NEEDS : NEEDS_NONE)[m.needs!])], ), ], ); diff --git a/web/src/admin/events/model.ts b/web/src/admin/events/model.ts index 70afb87..3365374 100644 --- a/web/src/admin/events/model.ts +++ b/web/src/admin/events/model.ts @@ -20,6 +20,8 @@ const CATEGORY: Record = { person_changed: 'people', paused: 'people', resumed: 'people', + expiring: 'people', + expired_kept: 'people', portal_blocked: 'problems', }; diff --git a/web/src/admin/events/render.ts b/web/src/admin/events/render.ts index 58c3942..94eb796 100644 --- a/web/src/admin/events/render.ts +++ b/web/src/admin/events/render.ts @@ -21,6 +21,8 @@ const EVENT_TONE: Record = { person_removed: '', paused: 'warn', resumed: 'ok', + expiring: 'warn', + expired_kept: '', portal_blocked: 'bad', person_changed: '', devices_removed: 'warn', @@ -35,6 +37,8 @@ const EVENT_ICON: Record = { person_changed: 'edit', paused: 'pause', resumed: 'play', + expiring: 'calendar', + expired_kept: 'calendar', }; function eventIcon(st: Names, e: LogEvent): string { @@ -135,6 +139,10 @@ export function eventText(st: Pick, e: LogEvent): Node[] { case 'person_changed': // The detail lists changed fields by their option names (device_limit, expire_action). return [...you('changed'), kind('person'), b(who), ...(detail ? [m(` · ${detail.replace(/_/g, ' ')}`)] : [])]; + case 'expiring': + return [kind('Person'), b(who), m(`’s access ends in ${e.detail ?? 'a few days'}`)]; + case 'expired_kept': + return [kind('Person'), b(who), m(`’s end date passed (${e.detail ?? ''}) · access kept`)]; case 'paused': return [kind('Person'), b(who), m(` paused — ${e.detail ?? ''}`)]; case 'resumed': diff --git a/web/src/admin/invite.ts b/web/src/admin/invite.ts index a2cf9d4..29aa555 100644 --- a/web/src/admin/invite.ts +++ b/web/src/admin/invite.ts @@ -107,24 +107,30 @@ export async function inviteCard(p: Invitee, server: string, opts: { title?: str const file = new File([png], `${p.id}-invite.png`, { type: 'image/png' }); const url = URL.createObjectURL(png); const nav = navigator as Navigator & { canShare?: (d: unknown) => boolean }; - const canShare = !!nav.canShare?.({ files: [file] }); + // Three tiers: the card as a file, the link through the share sheet (older + // Android, Firefox on phones), else a download of the card. + const canShareFile = !!nav.canShare?.({ files: [file] }); + const canShareLink = !canShareFile && typeof nav.share === 'function' && (nav.canShare?.({ url: href }) ?? true); const close = () => { URL.revokeObjectURL(url); closeModal(); }; - const share = canShare - ? button( - [icon('link'), ' Share card'], - async () => { - try { - await nav.share({ files: [file], title: `Invite ${p.name}` }); - } catch { - /* cancelled */ - } - }, - 'positive', - ) - : button([icon('download'), ' Download card'], () => downloadFile(file.name, png), 'positive'); + const shareIt = async (data: ShareData) => { + try { + await nav.share(data); + } catch { + /* cancelled */ + } + }; + const share = canShareFile + ? button([icon('link'), ' Share card'], () => shareIt({ files: [file], title: `Invite ${p.name}` }), 'positive') + : canShareLink + ? button( + [icon('link'), ' Share link'], + () => shareIt({ url: href, title: `Invite ${p.name}`, text: `Your personal VPN link` }), + 'positive', + ) + : button([icon('download'), ' Download card'], () => downloadFile(file.name, png), 'positive'); modal( opts.title ?? `Invite ${p.name}`, E('div', { class: 'dl-invite' }, [ diff --git a/web/src/admin/netcheck.ts b/web/src/admin/netcheck.ts index 9bf873a..3f7fc43 100644 --- a/web/src/admin/netcheck.ts +++ b/web/src/admin/netcheck.ts @@ -91,3 +91,233 @@ export function portalPortHelp(port: number, taken: PortHold[], ipLinks: boolean const who = holder(port + 1, taken); return who ? { text: `Links on IP addresses also need ${port + 1}, used by ${who}. Choose another port.`, bad: true } : h; } + +/* ---------- other fields, mirroring the router's rules (dawnline.util, schema, core) ---------- */ + +/** Characters, not UTF-16 units or bytes: what the router counts (util.ulength). */ +export const chars = (s: string): number => Array.from(s).length; + +const NAME_MAX = 48; +const BAD_NAME = /[<>"\\\u0000-\u001f\u007f]/; + +/** + * A name people see (util.valid_name): 1–48 characters, none of < > " \. + * `taken` are names already used where it must be unique (case-insensitive). + */ +export function nameHelp(s: string, taken: string[] = [], good = ''): Help { + const t = s.trim(); + if (!t) return { text: 'Enter a name.', bad: true }; + if (chars(s) > NAME_MAX) return { text: `Up to ${NAME_MAX} characters (${chars(s)} now).`, bad: true }; + if (BAD_NAME.test(s)) return { text: 'Names can’t contain < > " or \\.', bad: true }; + if (taken.some((x) => x.toLowerCase() === t.toLowerCase())) return { text: `“${t}” already exists — pick another name.`, bad: true }; + return { text: good, bad: false }; +} + +/** A circle's name: like a name, up to 32 characters. */ +export function circleNameHelp(s: string, taken: string[] = []): Help { + if (chars(s) > 32) return { text: `Up to 32 characters (${chars(s)} now).`, bad: true }; + return nameHelp(s, taken, 'Shown on the person cards.'); +} + +const HOSTNAME = /^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/; +const IPV4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; + +export function isIpv4(s: string): boolean { + const m = IPV4.exec(s); + return !!m && m.slice(1).every((x) => Number(x) <= 255); +} + +export function isIpv6(s: string): boolean { + return /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(s) && !/:::/.test(s); +} + +/** + * The public address of a server or the portal (util.valid_host): a hostname + * or an IP address, nothing else. `port` names what devices connect to when + * it is fine; `empty` is what an empty field means (null: it is required). + */ +export function hostHelp(s: string, port?: number, empty: string | null = null): Help { + const t = s.trim(); + if (!t) return empty != null ? { text: empty, bad: false } : { text: 'Enter a hostname or IP address.', bad: true }; + if (/^[a-z]+:\/\//i.test(t)) return { text: 'Leave out https:// — just the name.', bad: true }; + if (/\/.*/.test(t)) return { text: 'Just the name, without a path.', bad: true }; + if (/^[^:\[]+:\d+$/.test(t)) return { text: 'Just the name, without a port (the port is on AmneziaWG).', bad: true }; + if (/\s/.test(t)) return { text: 'A hostname has no spaces.', bad: true }; + if (t.length > 253 || !(HOSTNAME.test(t) || isIpv4(t) || isIpv6(t))) return { text: 'Use a hostname or an IP address.', bad: true }; + const shown = isIpv6(t) ? `[${t}]` : t; + return { text: port ? `Devices connect to ${shown}:${port}.` : `Links use ${shown}.`, bad: false }; +} + +/** The DNS list a server hands to devices (rpc/servers.uc dns_list): IPs, comma-separated; empty = this router. */ +export function dnsHelp(s: string, routerAddr: string): Help { + const items = s.split(/[ ,]+/).filter(Boolean); + if (!items.length) + return { text: `This router (${routerAddr}): queries go where your home network sends them, and home names work.`, bad: false }; + const bad = items.find((x) => !isIpv4(x) && !isIpv6(x)); + if (bad) return { text: `“${bad}” is not an IP address. Separate several with commas.`, bad: true }; + return { text: `Devices use ${items.join(' and ')} — home names and your LAN’s DNS filters no longer apply to them.`, bad: false }; +} + +/** MTU (rpc/servers.uc check_mtu): empty = automatic, else 1280–1500. */ +export function mtuHelp(s: string, mtus: { computer: number; phone: number }): Help { + const t = s.trim(); + if (!t) + return { + text: `Automatic by device type and disguise: ${mtus.computer} for computers and routers, ${mtus.phone} for phones and tablets.`, + bad: false, + }; + if (!/^\d{1,4}$/.test(t) || Number(t) < 1280 || Number(t) > 1500) + return { text: 'MTU must be 1280–1500, or empty for automatic.', bad: true }; + const n = Number(t); + return { text: `Computers and routers get ${n}, phones and tablets ${Math.min(n, 1280)}.`, bad: false }; +} + +/** Keep-alive (rpc/servers.uc): 0–600 s; empty = 25. */ +export function keepaliveHelp(s: string): Help { + const t = s.trim(); + if (!t) return { text: 'Default: a packet every 25 s keeps NAT open and “Connected” accurate.', bad: false }; + if (!/^\d{1,3}$/.test(t) || Number(t) > 600) return { text: 'Use 0–600 seconds.', bad: true }; + if (Number(t) === 0) return { text: 'Off: NAT may close the tunnel when idle, and “Connected” lags.', bad: false }; + return { text: `Devices send a packet every ${t} s to keep NAT open (a little battery on phones).`, bad: false }; +} + +/** Device limit (core.create_person): 1–32; `have` is how many they have now (an edit). */ +export function limitHelp(s: string, have = 0): Help { + const t = s.trim(); + if (!/^\d{1,2}$/.test(t) || Number(t) < 1 || Number(t) > 32) return { text: 'Use 1–32.', bad: true }; + const n = Number(t); + if (have > n) + return { text: `Already has ${have} devices: remove ${have - n === 1 ? 'one' : `${have - n}`} first, or allow more.`, bad: true }; + return { text: `They can add ${n} device${n === 1 ? '' : 's'} themselves.`, bad: false }; +} + +/** Monthly data in GB (core.create_person): empty = unlimited, else 0–100000. */ +export function quotaHelp(s: string, monthly = true): Help { + const t = s.trim(); + if (!t) return { text: 'Optional. No data limit.', bad: false }; + const n = Number(t); + if (!/^\d+(\.\d+)?$/.test(t) || n < 0 || n > 100000) return { text: 'A number of GB, up to 100000.', bad: true }; + if (n === 0) return { text: 'Optional. No data limit.', bad: false }; + return { text: monthly ? `Paused after ${t} GB this month, resumed on the 1st.` : `Paused after ${t} GB in total.`, bad: false }; +} + +/** An end date (YYYY-MM-DD) against the router's day; empty = none. */ +export function expiresHelp( + s: string, + today: string, + daysLeft: (d: string, t: string) => number | null, + date: (d: string) => string, +): Help { + const t = s.trim(); + if (!t) return { text: 'Optional. No end date.', bad: false }; + const left = daysLeft(t, today); + if (left == null) return { text: 'Use a date.', bad: true }; + if (left < 0) return { text: 'That date has passed: access would end at once.', bad: true }; + return { text: left === 1 ? `Access ends today (${date(t)}).` : `Access ends in ${left} days (${date(t)}).`, bad: false }; +} + +/** A home service's address (rpc/home.uc): IPv4; `homeNets` warn when it is outside every home network. */ +export function ipv4Help(s: string, inHome: ((ip: string) => boolean) | null = null): Help { + const t = s.trim(); + if (!t) return { text: 'The device’s address at home.', bad: true }; + if (!isIpv4(t)) return { text: 'Use an IPv4 address, like 192.168.1.10.', bad: true }; + if (inHome && !inHome(t)) return { text: `${t} is not in any home network of this server: nobody would reach it.`, bad: false }; + return { text: '', bad: false }; +} + +/** A service's ports: empty = all, else numbers 1–65535. */ +export function portsHelp(s: string): Help { + const items = s.split(/[ ,]+/).filter(Boolean); + if (!items.length) return { text: 'All ports.', bad: false }; + const bad = items.find((x) => !/^\d{1,5}$/.test(x) || Number(x) < 1 || Number(x) > 65535); + if (bad) return { text: `“${bad}” is not a port (1–65535).`, bad: true }; + return { text: `Port${items.length === 1 ? '' : 's'} ${items.join(', ')}.`, bad: false }; +} + +/** The portal's redirect for unknown links (schema portal_redirect): a full http(s) URL, or empty. */ +export function urlHelp(s: string): Help { + const t = s.trim(); + if (!t) return { text: 'Wrong links get a bare “Not found”.', bad: false }; + if (!/^https?:\/\//i.test(t)) return { text: 'Must start with http:// or https://.', bad: true }; + if (t.length > 300 || !/^https?:\/\/[A-Za-z0-9.-]+(:[0-9]+)?(\/[^\s"'<>]*)?$/.test(t)) + return { text: 'Not a usable address (no spaces or quotes).', bad: true }; + return { text: 'Wrong links are sent there instead of a “Not found”.', bad: false }; +} + +/** The portal's title: up to 64 characters on one line. */ +export function titleHelp(s: string): Help { + if (chars(s) > 64) return { text: `Up to 64 characters (${chars(s)} now).`, bad: true }; + if (/[\u0000-\u001f\u007f]/.test(s)) return { text: 'One line, please.', bad: true }; + return { text: 'Shown in the browser tab and at the top of the portal.', bad: false }; +} + +/** The home domain for device hostnames (schema domain): lowercase letters, digits, dashes, dots. */ +export function domainHelp(s: string, example = 'phone.myata'): Help { + const t = s.trim(); + // Empty keeps the default (the router stores nothing then). + if (!t) return { text: `The default, lan: devices get names like ${example}.lan.`, bad: false }; + if (!/^[a-z0-9-]{1,32}(\.[a-z0-9-]{1,32})*$/.test(t)) + return { text: /[A-Z]/.test(t) ? 'Lowercase only.' : 'Lowercase letters, digits, dashes and dots.', bad: true }; + return { text: `Devices get names like ${example}.${t}.`, bad: false }; +} + +/** The fallback DNS for home-names devices: an IPv4 address, or empty for none. */ +export function fallbackDnsHelp(s: string): Help { + const t = s.trim(); + if (!t) return { text: 'None: without the tunnel those devices have no DNS.', bad: false }; + if (!isIpv4(t)) return { text: 'Use an IPv4 address, or leave it empty.', bad: true }; + return { text: `${t} takes over when the tunnel is down.`, bad: false }; +} + +/** The daily update time (schema update_time): HH:MM. */ +export function timeHelp(s: string): Help { + const t = s.trim(); + if (!/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(t)) return { text: 'Use HH:MM, 00:00–23:59.', bad: true }; + return { text: `Runs within an hour after ${t} (router time).`, bad: false }; +} + +/** + * A public address checked on the router as it is typed (rpc endpoint_probe: + * where it points, CGNAT, Cloudflare), debounced so a keystroke is not a + * lookup. `help()` is the row's: the syntax first (hostHelp), then the + * router's verdict once it arrives, "Checking…" in between. + */ +export function endpointProbe( + get: () => { host: string; port: number; id?: string }, + probe: (host: string, id: string | undefined, port: number) => Promise<{ text: string; status?: string }>, + onResult: () => void, + opts: { empty?: string | null; idle?: () => string } = {}, +) { + let timer = 0; + let asked = ''; + let result: { host: string; text: string; bad: boolean } | null = null; + const schedule = () => { + const { host } = get(); + const h = hostHelp(host, get().port, opts.empty ?? null); + if (h.bad || !host.trim() || host.trim() === result?.host) return; + clearTimeout(timer); + timer = window.setTimeout(async () => { + const want = host.trim(); + asked = want; + try { + const { id, port } = get(); + const r = await probe(want, id, port); + if (asked !== want) return; + result = { host: want, text: r.text, bad: r.status === 'error' }; + } catch { + if (asked !== want) return; + result = { host: want, text: h.text, bad: false }; + } + onResult(); + }, 700); + }; + const help = (): Help => { + const { host, port } = get(); + const h = hostHelp(host, port, opts.empty ?? null); + if (h.bad || !host.trim()) return h; + if (result && result.host === host.trim()) return { text: result.text, bad: result.bad }; + const idle = opts.idle?.(); + return { text: idle ? `${idle} Checking where it points…` : `${h.text} Checking where it points…`, bad: false }; + }; + return { help, schedule }; +} diff --git a/web/src/admin/pages/overview.ts b/web/src/admin/pages/overview.ts index 1a69c1b..5ad07a4 100644 --- a/web/src/admin/pages/overview.ts +++ b/web/src/admin/pages/overview.ts @@ -8,7 +8,7 @@ import { api } from '../api'; import { svg } from '../ui/layout'; import { attachTip } from '../ui/tooltip'; import { icon } from '../../shared/icons'; -import { ago, bits, bytes, daysLeft, endsIn, endsSoon, initials, todayOf } from '../../shared/format'; +import { ago, bits, bytes, date, daysLeft, endsIn, endsSoon, initials, todayOf } from '../../shared/format'; import { ConnectionMap, rangeControl, type Range } from '../map'; import { personUrl } from '../urls'; import { eventRow } from '../events/render'; @@ -17,6 +17,8 @@ import { repaint } from '../state/poller'; import { daysTile, speedTile } from '../widgets/tiles'; import { coreOf } from '../cores'; import { healthNotices, runFix } from '../widgets/health'; +import { attempt } from '../ui/toast'; +import { isIpv4 } from '../netcheck'; import { onNavigate } from '../ui/nav'; interface Attention { @@ -48,6 +50,9 @@ function attention(st: Status): Attention[] { else { const left = daysLeft(p.expires, today); if (endsSoon(p, left)) out.push({ tone: '', text: [link(personUrl(p.id), p.name), `’s access ${endsIn(left as number)}.`] }); + // "Keep access" at the end date: nothing changes on its own, so it is said here. + else if (left != null && left < 0 && p.expire_action === 'notify') + out.push({ tone: '', text: [link(personUrl(p.id), p.name), `’s end date passed (${date(p.expires)}) · access kept.`] }); if (p.quota_limit && p.quota_used >= p.quota_limit * 0.9) out.push({ tone: '', text: [link(personUrl(p.id), p.name), ' has used 90% of the data limit.'] }); } @@ -64,12 +69,40 @@ function attention(st: Status): Attention[] { ] : [`${stale.length} devices need their configuration again (networks or DNS changed).`], }); + // A server that gives devices an IPv4 that is no longer the router's: one click puts the new one in. + for (const s of st.servers) + if (st.wan && isIpv4(s.endpoint) && s.endpoint !== st.wan) + out.push({ + tone: 'warn', + text: [ + `Public address changed: ${s.name} still gives devices ${s.endpoint}, the router is ${st.wan} now. `, + E( + 'button', + { + type: 'button', + class: 'dl-fix', + click: async (ev: Event) => { + const b = ev.currentTarget as HTMLButtonElement; + b.disabled = true; + await attempt( + () => api.serverUpdate(s.id, { endpoint: st.wan }), + `${s.name} uses ${st.wan} now — devices need their configuration again`, + ); + b.disabled = false; + }, + }, + 'Use the new address', + ), + ' A DDNS name would follow it by itself.', + ], + }); if (st.servers.some((s) => s.lan_like) && st.like_home.error) out.push({ tone: 'warn', text: [`Internet through the LAN is off: ${st.like_home.error} `, link(L.url('admin/network/dawnline/diagnostics'), 'Details')], }); - if (!st.settings.portal_enabled) + // Only while setting up: an admin who keeps the portal off has decided so. + if (!st.settings.portal_enabled && !st.people.length) out.push({ tone: '', text: ['The personal portal is off. ', link(L.url('admin/network/dawnline/settings'), 'Turn on')] }); return out; } @@ -390,6 +423,12 @@ export class ServerOverview { /** The last 30 days, today on the right, with the peak. */ monthTile(): HTMLElement { - return daysTile(this.st.series, ''); + // Who used the most this month (the People sort has it too, a click away). + const top = [...this.st.people] + .map((p) => [p, p.month[0] + p.month[1]] as const) + .filter(([, n]) => n > 0) + .sort((a, b) => b[1] - a[1]) + .slice(0, 2); + return daysTile(this.st.series, top.length ? `Most: ${top.map(([p, n]) => `${p.name} ${bytes(n)}`).join(' · ')}` : ''); } } diff --git a/web/src/admin/pages/people.ts b/web/src/admin/pages/people.ts index 95b79e1..84678a2 100644 --- a/web/src/admin/pages/people.ts +++ b/web/src/admin/pages/people.ts @@ -17,7 +17,10 @@ import { copyPersonLink, inviteCard } from '../invite'; import { personUrl } from '../urls'; import { scoped } from '../state/scope'; import { createPoller, focusInside, type Poller } from '../state/poller'; +import { onNavigate } from '../ui/nav'; import { accessPicker } from '../widgets/access-picker'; +import { firstBad, liveField } from '../ui/layout'; +import { expiresHelp, limitHelp, nameHelp, quotaHelp } from '../netcheck'; import { coreFor } from '../cores'; import { icon } from '../../shared/icons'; import { @@ -38,6 +41,22 @@ import { type Sid = string; +/** Per-browser conveniences (a tab, a sort): storage may be absent or refuse. */ +function remembered(key: string): string | null { + try { + return localStorage.getItem(key); + } catch { + return null; + } +} +function remember(key: string, value: string) { + try { + localStorage.setItem(key, value); + } catch { + /* no storage */ + } +} + /** Device slots as a row of segments (one per allowed device, used ones lit) and "2 of 10". */ function slotBar(p: Person): HTMLElement { const used = p.devices.length; @@ -89,9 +108,14 @@ export class PeoplePage { /** The cards, one per person, in the current sort order. */ private list: HTMLElement = E('div', { class: 'dl-plist', role: 'list' }); // `?filter=online` (from Overview) preselects a tab. + // The tab and the sort are remembered in this browser; ?filter= (from Overview) wins for the tab. filter: Filter = - (['all', 'online', 'attention', 'paused'] as Filter[]).find((f) => f === new URLSearchParams(location.search).get('filter')) ?? 'all'; - sort: SortBy = 'seen'; + (['all', 'online', 'attention', 'paused'] as Filter[]).find( + (f) => f === (new URLSearchParams(location.search).get('filter') ?? remembered('dl.people.filter')), + ) ?? 'all'; + sort: SortBy = (['seen', 'name', 'usage'] as SortBy[]).find((x) => x === remembered('dl.people.sort')) ?? 'seen'; + /** What the admin typed into Find (name, note, device, address). */ + query = ''; noFooter = true; /** Set when shown as a server's People section: only that server's people. */ serverId: string | null = null; @@ -208,11 +232,37 @@ export class PeoplePage { 'aria-label': 'Sort', change: (ev: Event) => { page.sort = (ev.target as HTMLSelectElement).value as SortBy; + remember('dl.people.sort', page.sort); page.decorate(); }, }, - [E('option', { value: 'seen' }, 'Last seen'), E('option', { value: 'name' }, 'Name'), E('option', { value: 'usage' }, 'Usage')], + [ + E('option', { value: 'seen', selected: page.sort === 'seen' ? 'selected' : null }, 'Last seen'), + E('option', { value: 'name', selected: page.sort === 'name' ? 'selected' : null }, 'Name'), + E('option', { value: 'usage', selected: page.sort === 'usage' ? 'selected' : null }, 'Usage'), + ], ); + // Find, once the list is long enough to need it; "/" focuses it. + const find = E('input', { + type: 'search', + class: 'cbi-input-text dl-people-find', + placeholder: 'Find…', + 'aria-label': 'Find a person or device', + hidden: st.people.length > 8 ? null : 'hidden', + input: (ev: Event) => { + page.query = (ev.target as HTMLInputElement).value.trim().toLowerCase(); + page.decorate(); + }, + }) as HTMLInputElement; + const onSlash = (ev: KeyboardEvent) => { + const t = ev.target as HTMLElement; + if (ev.key === '/' && !find.hidden && !['INPUT', 'TEXTAREA', 'SELECT'].includes(t?.tagName) && !t?.isContentEditable) { + ev.preventDefault(); + find.focus(); + } + }; + document.addEventListener('keydown', onSlash); + onNavigate(() => document.removeEventListener('keydown', onSlash)); const wrap = E('div', { class: 'dl-root' }, [ page.serverId ? '' @@ -234,6 +284,7 @@ export class PeoplePage { E('div', { class: 'dl-seg dl-people-tabs', role: 'tablist' }), // Sort and add stay together on the right, wrapping as one group. E('div', { class: 'dl-toolbar-end' }, [ + find, sort, page.serverId ? button([icon('plus'), ' Add person'], () => page.openCreate(), 'add') : '', ]), @@ -290,6 +341,7 @@ export class PeoplePage { class: f === this.filter ? 'on' : '', click: () => { this.filter = f; + remember('dl.people.filter', f); this.decorate(); }, }, @@ -298,10 +350,14 @@ export class PeoplePage { ), ); } + const q = this.query; + const hay = (p: Person) => + [p.name, p.note ?? '', ...p.devices.flatMap((d) => [d.name, d.address, d.hostname, d.endpoint])].join(' ').toLowerCase(); const match = (p: Person) => { if (this.filter === 'online' && !p.online) return false; if (this.filter === 'attention' && !attn(p)) return false; if (this.filter === 'paused' && !paused(p)) return false; + if (q && !hay(p).includes(q)) return false; return true; }; // Whatever the sort: people who can connect, then those held by a limit or an end @@ -405,8 +461,17 @@ export class PeoplePage { ), ); - // Ending soon (the strip below handles an end that has passed). + // Ending soon (the strip below handles an end that has passed); someone new + // without a device yet gets a nudge to send the link. const fixes: Node[] = []; + if (!p.devices.length && portal && !stopped(p)) + fixes.push( + E( + 'button', + { type: 'button', class: 'dl-fix', click: () => inviteCard(p, this.st.servers.find((s) => s.id === p.server)?.name ?? 'Home') }, + 'Send invite', + ), + ); if (p.expires && endsSoon(p, left) && why !== 'expired') fixes.push( E( @@ -612,7 +677,15 @@ export class PeoplePage { return; } const name = E('input', { type: 'text', class: 'cbi-input-text', placeholder: 'e.g. Myata', maxlength: 48 }) as HTMLInputElement; - const access = accessPicker('internet'); + // The last person's access and data limit come back pre-filled (most are alike). + const last = (() => { + try { + return JSON.parse(remembered('dl.person.last') ?? '{}') as { access?: Person['access']; quota?: string }; + } catch { + return {} as { access?: Person['access']; quota?: string }; + } + })(); + const access = accessPicker(last.access ?? 'internet'); const limit = E('input', { type: 'number', class: 'cbi-input-text', @@ -627,6 +700,7 @@ export class PeoplePage { min: 0, step: 'any', placeholder: 'Unlimited', + value: last.quota ?? '', }) as HTMLInputElement; const quick = (label: string, months: number) => E( @@ -636,6 +710,7 @@ export class PeoplePage { class: 'cbi-button cbi-button-neutral', click: () => { expires.value = months ? addMonthsClamped(todayOf(st.series), months) : ''; + expires.dispatchEvent(new Event('change')); }, }, label, @@ -655,44 +730,62 @@ export class PeoplePage { E('label', { class: 'cbi-value-title' }, label), E('div', { class: 'cbi-value-field' }, [w, help ? E('div', { class: 'cbi-value-description' }, help) : '']), ]); + // Each field says what its value means, or what is wrong, as it is typed; Create refuses what the router would. + const today = todayOf(st.series); + const nameRow = liveField('Name', name, () => nameHelp(name.value, [], 'Shown in their portal and apps.')); + const limitRow = liveField('Devices', limit, () => limitHelp(limit.value)); + const expRow = liveField( + 'End date', + expires, + () => expiresHelp(expires.value, today, daysLeft, date), + E('div', { class: 'dl-actions' }, [expires, quick('1 month', 1), quick('3 months', 3), quick('1 year', 12), quick('None', 0)]), + ); + const quotaRow = liveField('Monthly data (GB)', quota, () => quotaHelp(quota.value)); + // The quick buttons set the date without an input event. + expires.addEventListener('change', () => expRow.refresh()); + const portalOn = st.settings.portal_enabled; modal( 'Add person', [ - row('Name', name), + nameRow, server ? row('Server', server) : '', E('div', { class: 'cbi-value dl-block' }, [ E('label', { class: 'cbi-value-title' }, 'Access'), E('div', { class: 'cbi-value-field' }, access.el), ]), - row('Devices', limit, 'How many devices they can add themselves.'), - row( - 'End date', - E('div', { class: 'dl-actions' }, [expires, quick('1 month', 1), quick('3 months', 3), quick('1 year', 12), quick('None', 0)]), - 'Optional.', - ), - row('Monthly data (GB)', quota, 'Optional. They are paused when it runs out and resumed next month.'), + limitRow, + expRow, + quotaRow, ], [ cancelButton(), ' ', button( - 'Create and copy link', + // Without the portal there is no link to copy. + portalOn ? 'Create and copy link' : 'Create', async () => { + const bad = firstBad([nameRow, limitRow, expRow, quotaRow]); + if (bad) { + notify(bad, 'warning'); + return; + } const r = await attempt(() => api.personCreate( name.value.trim(), '', server?.value ?? srv.id, access.get(), - String(Number(limit.value) || st.settings.default_device_limit), + limit.value.trim(), expires.value, quota.value.trim(), 'month', ), ); if (!r) return; - if (r.link) await copyText(r.link, 'Personal link copied'); + remember('dl.person.last', JSON.stringify({ access: access.get(), quota: quota.value.trim() })); + // After the await some browsers refuse the clipboard: the card has its own Copy. + if (r.link) await copyText(r.link, 'Personal link copied', true); this.showCreated(r.id, name.value.trim(), r.link, st.servers.find((x) => x.id === (server?.value ?? srv.id))?.name ?? srv.name); await this.refresh(); }, @@ -711,10 +804,31 @@ export class PeoplePage { }); return; } + // No portal, no link: the two ways on from here, as buttons. + const p = this.person(id); modal( `${name} 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: closeModal }, 'Done')], + [ + E('button', { class: 'cbi-button cbi-button-neutral', click: closeModal }, 'Done'), + ' ', + E( + 'a', + { class: 'cbi-button cbi-button-neutral', href: `${L.url('admin/network/dawnline/settings')}?section=portal` }, + 'Open Settings', + ), + ' ', + p + ? button( + 'Add device', + () => { + closeModal(); + addDevice(p, this.deviceOpts(p)); + }, + 'positive', + ) + : '', + ], ); } } diff --git a/web/src/admin/pages/person/devices.ts b/web/src/admin/pages/person/devices.ts index d8ef300..6fb4144 100644 --- a/web/src/admin/pages/person/devices.ts +++ b/web/src/admin/pages/person/devices.ts @@ -50,7 +50,7 @@ export function devicesPart(page: PersonPage): HTMLElement { E('span', { class: 'dl-dcard-ic' }, icon(d.kind)), E('button', { type: 'button', class: 'dl-dcard-title', click: () => open(d) }, [ E('b', {}, d.name), - deviceStatus(d, now), + deviceStatus(d, now, undefined, p), d.config_stale ? E('span', { class: 'dl-pill warn dl-stale' }, 'Update config') : '', ]), more(d), diff --git a/web/src/admin/pages/person/dialogs.ts b/web/src/admin/pages/person/dialogs.ts index 41114df..e1f7f82 100644 --- a/web/src/admin/pages/person/dialogs.ts +++ b/web/src/admin/pages/person/dialogs.ts @@ -1,11 +1,13 @@ -// Person page dialogs: rename, note, when access ends, new link, invite, delete. +// Person page dialogs: rename, note, when access ends, move to a server, new link, invite, delete. import { E } from '../../e'; import { api } from '../../api'; import { button } from '../../ui/button'; import { cancelButton, closeModal, confirmDialog, modal } from '../../ui/modal'; import { copyText } from '../../ui/files'; -import { attempt } from '../../ui/toast'; +import { attempt, notify } from '../../ui/toast'; +import { liveField } from '../../ui/layout'; +import { nameHelp } from '../../netcheck'; import { inviteCard } from '../../invite'; import { peopleUrl } from '../../urls'; import type { PersonPage } from './index'; @@ -126,15 +128,21 @@ export function endSettings(page: PersonPage) { export function rename(page: PersonPage) { const input = E('input', { type: 'text', class: 'cbi-input-text', value: page.p.name, maxlength: 48 }) as HTMLInputElement; + const nameRow = liveField('Name', input, () => nameHelp(input.value, [], 'Shown in their portal and apps.')); modal( 'Rename', - [field('Name', input)], + [nameRow], [ cancelButton(), ' ', button( 'Save', async () => { + const h = nameRow.help(); + if (h.bad) { + notify(h.text, 'warning'); + return; + } // The dialog stays open on a refusal, with the name still typed. if (await page.patch({ name: input.value.trim() }, 'Renamed')) closeModal(); }, @@ -145,6 +153,45 @@ export function rename(page: PersonPage) { setTimeout(() => input.select(), 50); } +/** Another server: every device gets an address there and needs its configuration again. */ +export function moveToServer(page: PersonPage) { + const p = page.p; + const others = page.st.servers.filter((s) => s.id !== p.server); + const sel = E( + 'select', + { class: 'cbi-input-select' }, + others.map((s) => E('option', { value: s.id }, `${s.name} · ${s.endpoint || 'no address'}:${s.port}`)), + ) as HTMLSelectElement; + const n = p.devices.length; + modal( + `Move ${p.name} to another server`, + [ + field('Server', sel), + E( + 'p', + { class: 'dl-muted' }, + n + ? `${n} device${n === 1 ? ' gets a new address and stops' : 's get new addresses and stop'} connecting until ${n === 1 ? 'it imports its' : 'they import their'} configuration again (from the personal link or from you). Circles and home networks of the old server are left behind.` + : 'They have no devices yet: nothing else changes.', + ), + ], + [ + cancelButton(), + ' ', + button( + 'Move', + async () => { + if (await page.patch({ server: sel.value }, `Moved to ${others.find((s) => s.id === sel.value)?.name ?? 'the server'}`)) { + closeModal(); + if (n) notify('Devices are marked “Update config” until they import again.', 'info', 6000); + } + }, + 'positive', + ), + ], + ); +} + export async function remove(page: PersonPage) { const p = page.p; const ok = await confirmDialog( diff --git a/web/src/admin/pages/person/header.ts b/web/src/admin/pages/person/header.ts index bb19f17..8b64ed5 100644 --- a/web/src/admin/pages/person/header.ts +++ b/web/src/admin/pages/person/header.ts @@ -8,7 +8,7 @@ import { icon } from '../../../shared/icons'; import { ago, bytes, date, initials, isoDay } from '../../../shared/format'; import { copyPersonLink } from '../../invite'; import { daysTile, speedTile } from '../../widgets/tiles'; -import { editNote, invite, newLink, remove, rename } from './dialogs'; +import { editNote, invite, moveToServer, newLink, remove, rename } from './dialogs'; import type { PersonPage } from './index'; export function headPart(page: PersonPage): HTMLElement { @@ -21,6 +21,8 @@ export function headPart(page: PersonPage): HTMLElement { const menu: (MenuItem | null)[] = [ { label: 'Rename', icon: icon('edit'), run: () => rename(page) }, { label: p.note ? 'Edit note' : 'Add note', icon: icon('file'), run: () => editNote(page) }, + // With one server there is nowhere to move to. + ...(st.servers.length > 1 ? [{ label: 'Move to server…', icon: icon('server'), run: () => moveToServer(page) }] : []), ...(portal ? [ null, diff --git a/web/src/admin/pages/person/index.ts b/web/src/admin/pages/person/index.ts index 4492962..b0eb614 100644 --- a/web/src/admin/pages/person/index.ts +++ b/web/src/admin/pages/person/index.ts @@ -18,7 +18,7 @@ import { devicesPart } from './devices'; import { limitsPart } from './limits'; import { activityPart, placesPart } from './activity'; -type Part = 'head' | 'devices' | 'traffic' | 'places' | 'activity' | 'limits'; +type Part = 'crumbs' | 'head' | 'devices' | 'traffic' | 'places' | 'activity' | 'limits'; interface Loaded { st: Status; @@ -69,16 +69,10 @@ export class PersonPage { E('a', { class: 'cbi-button', href: L.url('admin/network/dawnline/server') }, 'Back to Servers'), ]); this.p = p; - for (const k of ['head', 'devices', 'traffic', 'places', 'activity', 'limits'] as Part[]) this.parts[k] = E('div', {}); + for (const k of ['crumbs', 'head', 'devices', 'traffic', 'places', 'activity', 'limits'] as Part[]) this.parts[k] = E('div', {}); this.parts.devices.className = 'dl-person-devices'; const root = E('div', {}, [ - E('nav', { class: 'dl-crumbs', 'aria-label': 'Breadcrumb' }, [ - E('a', { href: peopleUrl(p.server) }, this.st.servers.find((x) => x.id === p.server)?.name ?? 'Servers'), - E('span', {}, '/'), - E('a', { href: peopleUrl(p.server) }, 'People'), - E('span', {}, '/'), - E('span', {}, p.name), - ]), + this.parts.crumbs, 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]), @@ -176,7 +170,20 @@ export class PersonPage { } /** Every part; a `quiet` (periodic) repaint leaves alone the parts that have the keyboard focus. */ + /** Server / People / name: the server changes when the person is moved. */ + private crumbs(): HTMLElement { + const p = this.p; + return E('nav', { class: 'dl-crumbs', 'aria-label': 'Breadcrumb' }, [ + E('a', { href: peopleUrl(p.server) }, this.st.servers.find((x) => x.id === p.server)?.name ?? 'Servers'), + E('span', {}, '/'), + E('a', { href: peopleUrl(p.server) }, 'People'), + E('span', {}, '/'), + E('span', {}, p.name), + ]); + } + paint(quiet = false) { + repaint(this.parts.crumbs, this.crumbs(), quiet); repaint(this.parts.head, headPart(this), quiet); repaint(this.parts.traffic, trafficPart(this), quiet); repaint(this.parts.devices, devicesPart(this), quiet); diff --git a/web/src/admin/pages/person/limits.ts b/web/src/admin/pages/person/limits.ts index 2909258..fb9cdbf 100644 --- a/web/src/admin/pages/person/limits.ts +++ b/web/src/admin/pages/person/limits.ts @@ -5,6 +5,10 @@ import type { Person } from '../../../shared/types'; import { E } from '../../e'; import { notify } from '../../ui/toast'; import { seg } from '../../ui/controls'; +import { button } from '../../ui/button'; +import { cancelButton, closeModal, modal } from '../../ui/modal'; +import { liveField } from '../../ui/layout'; +import { quotaHelp } from '../../netcheck'; import { attachTip } from '../../ui/tooltip'; import { icon } from '../../../shared/icons'; import { ACCESS_LABEL, bytes, date, daysLeft, endsSoon, shiftDay } from '../../../shared/format'; @@ -163,8 +167,36 @@ function dataTile(page: PersonPage): HTMLElement { type: 'button', class: 'dl-chipbtn', click: () => { - const v = prompt('Data limit in GB', p.quota_gb ? String(p.quota_gb) : ''); - if (v != null && v.trim() !== '' && Number(v) > 0) void page.patch({ quota_gb: v.trim() }, `Data limit ${v.trim()} GB`); + const inp = E('input', { + type: 'number', + class: 'cbi-input-text dl-w-port', + min: 0, + step: 'any', + value: p.quota_gb ? String(p.quota_gb) : '', + }) as HTMLInputElement; + const row = liveField('Data limit (GB)', inp, () => quotaHelp(inp.value, p.quota_period === 'month')); + modal( + 'Data limit', + [row], + [ + cancelButton(), + ' ', + button( + 'Save', + async () => { + const h = row.help(); + if (h.bad) { + notify(h.text, 'warning'); + return; + } + const v = inp.value.trim(); + if (await page.patch({ quota_gb: v }, v && Number(v) > 0 ? `Data limit ${v} GB` : 'No data limit')) closeModal(); + }, + 'positive', + ), + ], + ); + setTimeout(() => inp.select(), 50); }, }, 'Custom', @@ -249,20 +281,27 @@ function hoursTile(page: PersonPage): HTMLElement { 'aria-checked': hoursOn ? 'true' : 'false', class: `dl-switch${hoursOn ? ' on' : ''}`, 'aria-label': 'Limit hours', - click: () => page.patch({ hours: hoursOn ? '' : '07:00-23:00' }, hoursOn ? 'Any time' : 'Allowed 07:00–23:00'), + // Turning on shows the times to set; nothing is enforced until they are saved. + click: () => { + if (hoursOn) return page.patch({ hours: '' }, 'Any time'); + sw.classList.add('on'); + sw.setAttribute('aria-checked', 'true'); + label.textContent = 'Set the hours, then press Enter'; + tile.appendChild(times); + from.focus(); + }, }, E('i'), ); - return E('div', { class: 'dl-tile2' }, [ + const label = E('span', {}, hoursOn ? `${h1} – ${h2} (router time)` : 'Any time'); + const tile = 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', {}, hoursOn ? `${h1} – ${h2} (router time)` : 'Any time'), - ]), + E('div', { class: 'dl-stack' }, [E('span', { class: 'dl-tile2-label' }, 'Allowed hours'), label]), sw, ]), hoursOn ? times : '', ]); + return tile; } export function limitsPart(page: PersonPage): HTMLElement { diff --git a/web/src/admin/pages/server.ts b/web/src/admin/pages/server.ts index 59c93bb..2740d03 100644 --- a/web/src/admin/pages/server.ts +++ b/web/src/admin/pages/server.ts @@ -12,13 +12,13 @@ import { cancelButton, closeModal, confirmDialog, modal } from '../ui/modal'; import { copyText } from '../ui/files'; import { attempt, errorText, notify } from '../ui/toast'; import { input, seg, sw } from '../ui/controls'; -import { card, group, liveRow, needRow, row } from '../ui/layout'; -import { portalPortHelp, portHelp, rangeHelp, rangeOf, subnetOf } from '../netcheck'; +import { card, firstBad, group, liveRow, needRow, row } from '../ui/layout'; +import { dnsHelp, endpointProbe, hostHelp, nameHelp, portalPortHelp, portHelp, rangeHelp, rangeOf, subnetOf } from '../netcheck'; import { icon } from '../../shared/icons'; -import { duration } from '../../shared/format'; +import { ago, duration } from '../../shared/format'; import { accessCards } from '../interfaces'; import { checkAccess, whoReaches } from '../access'; -import { methodPicker, type Method } from '../disguise'; +import { defaultMethod, methodPicker } from '../disguise'; import { coreOf } from '../cores'; import { installAwg } from '../pkgs'; import { createPoller, focusInside, repaint, type Poller } from '../state/poller'; @@ -299,7 +299,7 @@ export class ServerPage { { type: 'button', class: 'dl-addrbar-seg main', title: 'Copy address', click: () => copyText(addr, 'Address copied') }, [icon('globe'), E('span', { class: 'dl-mono' }, addr), icon('copy')], ), - part('tunnel', [E('span', { class: 'dl-mono' }, `${coreOf(srv).label} :${srv.port}`)]), + part(coreOf(srv).id === 'awg' ? 'amneziawg' : 'tunnel', [E('span', { class: 'dl-mono' }, `${coreOf(srv).label} :${srv.port}`)]), srv.up ? part('clock', [`up ${duration(srv.uptime)}`]) : '', ]), // The reason the tunnel can't run at all ("can't use the network interface awg0: it exists and isn't Dawnline's"). @@ -318,7 +318,7 @@ export class ServerPage { const dns = input(srv.dns.join(', '), { placeholder: 'This router (recommended)', class: 'cbi-input-text dl-mono' }); const people = this.st.people.filter((p) => p.server === srv.id).length; const toggle = button( - srv.enabled ? 'Turn off' : 'Turn on', + [icon(srv.enabled ? 'pause' : 'play'), srv.enabled ? ' Turn off' : ' Turn on'], async () => { if ( srv.enabled && @@ -334,24 +334,51 @@ export class ServerPage { }, srv.enabled ? 'negative' : 'positive', ); + const portalHost = this.st.settings.portal_host; + const nameRow = liveRow('Name', name, () => nameHelp(name.value, [], 'Shown to people in their portal and apps.')); + // Where the address points is checked on the router as it is typed (debounced). + const ep = endpointProbe( + () => ({ host: endpoint.value, port: srv.port, id: srv.id }), + (h, id, port) => api.endpointProbe(h, id, port), + () => epRow.refresh(), + { empty: portalHost ? `Empty = the portal’s address (${portalHost}).` : 'Empty = the portal’s address.' }, + ); + const epRow = liveRow('Public address', endpoint, ep.help); + endpoint.addEventListener('input', ep.schedule); + ep.schedule(); + const reached = srv.reached + ? `Reached from the internet ${ago(srv.reached, this.st.now)}.` + : 'Never reached from the internet yet — test with a phone on mobile data.'; + const dnsRow = liveRow('DNS for devices', dns, () => dnsHelp(dns.value, srv.address)); return E('div', { class: 'dl-stack gap16' }, [ card( 'Connection', [ E('p', { class: 'dl-muted' }, 'The name people see, where devices find the router, and DNS. The port is on AmneziaWG.'), - group('router', 'Server', 'What people see', [row('Name', name, 'Shown to people in their portal and apps.')]), - group('globe', 'Devices connect to', 'Where the router answers from the internet', [ - row( - 'Public address', - endpoint, - 'Hostname or IP of the router on the internet. A DDNS name keeps links working when your IP changes. It must not go through Cloudflare: use a DNS-only name or an IP.', - ), - ]), - group('file', 'For every device', 'Changing it marks devices “Update config” until they import again', [ - row('DNS for devices', dns, 'Empty = this router, which sends each query where your home network would.'), - ]), + group('router', 'Server', 'What people see', [nameRow]), + group( + 'globe', + 'Devices connect to', + 'A DDNS name keeps links working when your IP changes; not through Cloudflare (use a DNS-only name or an IP)', + [epRow, E('div', { class: `dl-sub ${srv.reached ? 'ok' : 'warn'}` }, reached)], + ), + group('file', 'For every device', 'Changing it marks devices “Update config” until they import again', [dnsRow]), + ], + [ + E('span'), + button( + 'Save', + () => { + const bad = firstBad([nameRow, epRow, dnsRow]); + if (bad) { + notify(bad, 'warning'); + return; + } + return this.save(srv, { name: name.value, endpoint: endpoint.value, dns: dns.value }); + }, + 'positive', + ), ], - [E('span'), button('Save', () => this.save(srv, { name: name.value, endpoint: endpoint.value, dns: dns.value }), 'positive')], ), card( 'Danger zone', @@ -369,6 +396,21 @@ export class ServerPage { ]), E('div', { class: 'dl-setrow-ctl' }, toggle), ]), + E('div', { class: 'dl-setrow' }, [ + E('div', { class: 'dl-stack' }, [ + E('span', { class: 'dl-setrow-label' }, 'Change the tunnel network'), + E( + 'span', + { class: 'dl-sub' }, + `Devices have ${rangeOf(srv.subnet)}.x addresses now. A new range when it clashes with a network you connect to; every device then needs its configuration again.`, + ), + ]), + E( + 'div', + { class: 'dl-setrow-ctl' }, + button([icon('edit'), ' Change'], () => this.changeSubnet(srv), 'negative'), + ), + ]), E('div', { class: 'dl-setrow' }, [ E('div', { class: 'dl-stack' }, [ E('span', { class: 'dl-setrow-label' }, 'Remove server'), @@ -434,6 +476,55 @@ export class ServerPage { ); } + /** A new tunnel network: checked as you type against the router's networks, then every device renumbered. */ + async changeSubnet(srv: Server) { + const taken = await attempt(() => api.serverPorts(srv.id)); + if (!taken) return; + const nets = taken.networks ?? []; + const devices = this.st.people.filter((p) => p.server === srv.id).reduce((n, p) => n + p.devices.length, 0); + const range = input(rangeOf(srv.subnet), { class: 'cbi-input-text dl-mono dl-w-range' }); + const rangeRow = liveRow('Address range', range, () => rangeHelp(range.value, nets, '')); + modal( + 'Change the tunnel network', + [ + rangeRow, + E( + 'p', + { class: 'dl-muted' }, + devices + ? `${devices} device${devices === 1 ? ' gets a new address and stops' : 's get new addresses and stop'} connecting until ${devices === 1 ? 'it imports its' : 'they import their'} configuration again (from their personal link or from you).` + : 'No devices on this server yet: nothing else changes.', + ), + ], + [ + cancelButton(), + ' ', + button( + 'Change', + async () => { + const h = rangeRow.help(); + if (h.bad) { + notify(h.text, 'warning'); + return; + } + const subnet = subnetOf(range.value); + if (subnet === srv.subnet) { + closeModal(); + return; + } + if (await attempt(() => api.serverUpdate(srv.id, { subnet }), 'Tunnel network changed')) { + closeModal(); + if (devices) notify('Devices are marked “Update config” until they import again.', 'info', 6000); + await this.refresh(); + } + }, + 'negative', + ), + ], + ); + setTimeout(() => range.select(), 50); + } + async remove(srv: Server) { const people = this.st.people.filter((p) => p.server === srv.id); modal( @@ -477,7 +568,7 @@ export class ServerPage { port: d.port, // The tunnel's first three numbers ("10.77.0"): it is that /24. range: rangeOf(d.subnet), - preset: 'standard' as Method, + preset: defaultMethod(d.awg), // Off by default: the portal opens a port on WAN, so it is a choice. portal: false, portal_port: d.portal_port || 8443, @@ -489,7 +580,45 @@ export class ServerPage { // The portal takes the server's port number (TCP beside UDP) until it is changed by hand. let portalSame = !extra && state.portal_port === state.port; const ipLinks = () => /^\d{1,3}(\.\d{1,3}){3}$/.test(state.endpoint); - const portHelpNow = () => portHelp(state.port, d.udp_taken ?? [], 'Opened on the WAN firewall automatically.'); + const portHelpNow = () => + portHelp( + state.port, + d.udp_taken ?? [], + `Opened on the WAN firewall automatically.${state.port === 4500 ? ' 4500 is IPsec’s port: most networks let it through.' : ''}`, + ); + const FROM: Record = { + ddns: 'From your DDNS name.', + cert: 'From your Let’s Encrypt certificate.', + wan: 'Your WAN address now — it may change; a DDNS name is better.', + portal: 'The portal’s address.', + }; + const ep = endpointProbe( + () => ({ host: state.endpoint, port: state.port }), + (h, _id, port) => api.endpointProbe(h, '', port), + () => epRow?.refresh(), + { idle: () => (state.endpoint === d.endpoint && d.endpoint_from ? (FROM[d.endpoint_from] ?? '') : '') }, + ); + let epRow: ReturnType | null = null; + // Nobody on the internet reaches a private or CGNAT address: say it before the first step. + const wanNote = + d.wan_kind === 'cgnat' || d.wan_kind === 'private' + ? needRow( + 'alert', + 'warn', + d.wan_kind === 'cgnat' ? 'Your router has no public address (CGNAT)' : `Your router is behind another router (WAN ${d.wan_ip})`, + d.wan_kind === 'cgnat' + ? 'The ISP shares one address: devices can only connect if the ISP gives you a public address or IPv6. Ask them, or use a DDNS name that points at an IPv6 address.' + : 'Forward the UDP port on the upstream router to this one and use a DDNS name or that router’s public address here.', + '', + ) + : ''; + const restartNote = + d.awg_state?.tools && d.awg_state.handler === false + ? E('div', { class: 'dl-note warn' }, [ + icon('alert'), + E('span', {}, 'Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.'), + ]) + : ''; const rangeHelpNow = () => rangeHelp(state.range, d.networks ?? [], rangeOf(d.subnet)); const portalHelpNow = () => portalPortHelp(state.portal_port, d.tcp_taken ?? [], ipLinks()); const root = E('div', { class: 'dl-wizard' }); @@ -513,18 +642,36 @@ export class ServerPage { 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.', + extra + ? 'One more server: another port or disguise for networks where the first does not get through, or its own home access rules. People are moved between servers from their page.' + : 'Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes.', ), - group('router', 'Server', 'What people see', [row('Name', field('name'), 'Shown to people in their portal and apps.')]), - group('globe', 'Devices connect to', 'Where the router answers from the internet', [ - row( - 'Public address', - field('endpoint', { placeholder: 'vpn.example.com', class: 'cbi-input-text dl-mono' }), - 'Hostname or IP address of your router on the internet. Not through Cloudflare: use a DNS-only name or an IP.', - ), + group('router', 'Server', 'What people see', [ + liveRow('Name', field('name'), () => nameHelp(state.name, [], 'Shown to people in their portal and apps.')), ]), + group( + 'globe', + 'Devices connect to', + 'A hostname or IP address of your router on the internet; not through Cloudflare (use a DNS-only name or an IP). IPv6 works too, and is the way out of CGNAT', + [ + (() => { + const el = field('endpoint', { placeholder: 'vpn.example.com', class: 'cbi-input-text dl-mono' }); + epRow = liveRow('Public address', el, ep.help); + el.addEventListener('input', ep.schedule); + ep.schedule(); + return epRow; + })(), + ], + ), + wanNote, + restartNote, ]), - check: () => (!state.endpoint ? 'Fill in the public address.' : null), + check: () => { + const n = nameHelp(state.name); + if (n.bad) return `Name: ${n.text}`; + const h = hostHelp(state.endpoint, state.port); + return h.bad ? `Public address: ${h.text}` : null; + }, }; const awgPage: Page = { id: 'awg', diff --git a/web/src/admin/pages/settings/defaults.ts b/web/src/admin/pages/settings/defaults.ts index 8fa7ff5..23a8d20 100644 --- a/web/src/admin/pages/settings/defaults.ts +++ b/web/src/admin/pages/settings/defaults.ts @@ -3,7 +3,9 @@ import { E } from '../../e'; import { button } from '../../ui/button'; import { input, isOn, sw } from '../../ui/controls'; -import { row } from '../../ui/layout'; +import { firstBad, liveRow } from '../../ui/layout'; +import { notify } from '../../ui/toast'; +import { domainHelp, fallbackDnsHelp, limitHelp } from '../../netcheck'; import { section, type SettingsHost } from './common'; export function defaultsCard(host: SettingsHost): HTMLElement { @@ -17,28 +19,37 @@ export function defaultsCard(host: SettingsHost): HTMLElement { inputmode: 'decimal', class: 'cbi-input-text dl-w-ip dl-mono', }); + const limitRow = liveRow('Devices per person', limit, () => { + // Empty keeps the default (the router stores nothing then). + if (!limit.value.trim()) return { text: 'The default, 3. Pre-filled when you add someone.', bad: false }; + const h = limitHelp(limit.value); + return h.bad ? h : { text: 'Pre-filled when you add someone.', bad: false }; + }); + const domainRow = liveRow( + 'Device hostnames', + domain, + () => domainHelp(domain.value), + E('div', { class: 'dl-hostport' }, [hn, E('span', { class: 'dl-faint dl-mono' }, 'phone.myata.'), domain]), + ); + const fallbackRow = liveRow('Fallback DNS', fallback, () => { + const h = fallbackDnsHelp(fallback.value); + return h.bad ? h : { text: `For Home-only devices using home names: ${h.text}`, bad: false }; + }); return section( 'defaults', - 'Defaults', - [ - row('Devices per person', limit, 'Pre-filled when you add someone.'), - row( - 'Device hostnames', - E('div', { class: 'dl-hostport' }, [hn, E('span', { class: 'dl-faint dl-mono' }, 'phone.myata.'), domain]), - 'Name devices in your home DNS.', - ), - row( - 'Fallback DNS', - fallback, - 'For Home-only devices using home names: the second DNS server, used by the device when the tunnel is down. Empty = none.', - ), - ], + 'New people', + [limitRow, domainRow, fallbackRow], [ E('span'), button( 'Save', - () => - host.save( + () => { + const bad = firstBad([limitRow, domainRow, fallbackRow]); + if (bad) { + notify(bad, 'warning'); + return; + } + return host.save( { default_device_limit: limit.value, hostnames: isOn(hn) ? '1' : '0', @@ -47,7 +58,8 @@ export function defaultsCard(host: SettingsHost): HTMLElement { }, 'Saved', 'defaults', - ), + ); + }, 'positive', ), ], diff --git a/web/src/admin/pages/settings/portal.ts b/web/src/admin/pages/settings/portal.ts index 376b429..e63b43c 100644 --- a/web/src/admin/pages/settings/portal.ts +++ b/web/src/admin/pages/settings/portal.ts @@ -6,8 +6,8 @@ import { E } from '../../e'; import { button } from '../../ui/button'; import { cancelButton, closeModal, modal } from '../../ui/modal'; import { input, isOn, sw } from '../../ui/controls'; -import { group, liveRow, needRow, row } from '../../ui/layout'; -import { portalPortHelp } from '../../netcheck'; +import { firstBad, group, liveRow, needRow, row } from '../../ui/layout'; +import { hostHelp, portalPortHelp, titleHelp, urlHelp } from '../../netcheck'; import { icon } from '../../../shared/icons'; import { fmtDay } from '../../../shared/format'; import { installMissing } from '../../pkgs'; @@ -132,6 +132,12 @@ export function portalCard(host: SettingsHost): HTMLElement { button('Add', () => { const h = other.value.trim().toLowerCase(); if (!h) return; + // The router would refuse it on Save: say so here. + const check = hostHelp(h); + if (check.bad) { + notify(check.text, 'warning'); + return; + } addRow(h); if (!picked.includes(h)) picked = [...picked, h]; other.value = ''; @@ -273,6 +279,8 @@ export function portalCard(host: SettingsHost): HTMLElement { portalPortHelp(port.value.trim() === '' ? eff.portal_port : Number(port.value), host.d.tcp_taken ?? [], picked.some(isIp)), ); refreshPort = listenRow.refresh; + const titleRow = liveRow('Title', title, () => titleHelp(title.value)); + const redirectRow = liveRow('Unknown links', redirect, () => urlHelp(redirect.value)); const custom = !!(s.portal_cert && s.portal_key); const kind = !c ? 'Portal is off' : custom ? 'Your files' : c.self_signed ? 'Self-signed' : 'Let’s Encrypt'; const certFiles = () => { @@ -363,10 +371,7 @@ export function portalCard(host: SettingsHost): HTMLElement { E('span', { class: 'dl-muted' }, 'A page where each person adds and manages their devices with their personal link.'), httpsRow ? E('div', { class: 'dl-list' }, [httpsRow]) : '', group('network', 'Port', 'How the portal listens (80 and 443 stay free)', [listenRow]), - group('edit', 'Appearance', 'What people see', [ - row('Title', title, 'Shown at the top of the portal.'), - row('Unknown links', redirect, 'Where a wrong or old link goes, for example your website. Empty shows a plain “Not found”.'), - ]), + group('edit', 'Appearance', 'What people see', [titleRow, redirectRow]), group('link', 'Addresses', 'Pick one or more; the first is the main link', [ opts, E('div', { class: 'dl-stack gap8' }, [ @@ -382,14 +387,10 @@ export function portalCard(host: SettingsHost): HTMLElement { button( 'Save', () => { - // The port's help line already says what is wrong: do not send it anyway. - const h = portalPortHelp( - port.value.trim() === '' ? eff.portal_port : Number(port.value), - host.d.tcp_taken ?? [], - picked.some(isIp), - ); - if (h.bad) { - notify(`Listening port: ${h.text}`, 'warning'); + // The help lines already say what is wrong: do not send it anyway. + const bad = firstBad([listenRow, titleRow, redirectRow]); + if (bad) { + notify(bad, 'warning'); return; } return host.save( diff --git a/web/src/admin/pages/settings/updates.ts b/web/src/admin/pages/settings/updates.ts index 80f25ea..8c72e51 100644 --- a/web/src/admin/pages/settings/updates.ts +++ b/web/src/admin/pages/settings/updates.ts @@ -6,6 +6,8 @@ import { E } from '../../e'; import { button } from '../../ui/button'; import { chipToggle, input, isOn, seg, setChip, sw } from '../../ui/controls'; import { row } from '../../ui/layout'; +import { notify } from '../../ui/toast'; +import { timeHelp } from '../../netcheck'; import { section, type SettingsHost } from './common'; const TARGET: [string, string][] = [ @@ -99,8 +101,15 @@ export function updatesCard(host: SettingsHost): HTMLElement { E('span', { class: 'dl-sub' }, 'Run a check or an update by hand in Components.'), button( 'Save', - () => - host.save( + () => { + if (mode.dataset.value === 'scheduled') { + const h = timeHelp(at.value); + if (h.bad) { + notify(`Time: ${h.text}`, 'warning'); + return; + } + } + return host.save( { update_check: isOn(check) ? '1' : '0', update_interval: every.dataset.value!, @@ -113,7 +122,8 @@ export function updatesCard(host: SettingsHost): HTMLElement { }, 'Saved', 'updates', - ), + ); + }, 'positive', ), ], diff --git a/web/src/admin/styles/dialogs.css b/web/src/admin/styles/dialogs.css index fe39cb2..97beef6 100644 --- a/web/src/admin/styles/dialogs.css +++ b/web/src/admin/styles/dialogs.css @@ -16,6 +16,9 @@ /* dialogs */ .dl-modal .cbi-tabmenu { margin-bottom: 16px; } +/* A dialog field checked as you type: its help under the label, as on the cards. */ +.dl-modal .cbi-value.dl-live > .cbi-value-title { display: flex; flex-direction: column; gap: 2px; text-align: left; } +.dl-modal .cbi-value.dl-live > .cbi-value-title > .dl-sub { white-space: normal; } /* A list of things to tick (devices to remove with an old link). */ .dl-checklist { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; } .dl-checklist label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; } diff --git a/web/src/admin/styles/people.css b/web/src/admin/styles/people.css index 848e901..4465ab6 100644 --- a/web/src/admin/styles/people.css +++ b/web/src/admin/styles/people.css @@ -56,3 +56,6 @@ .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; } +/* Find (shown once the list is long): a compact search field beside the sort. */ +.dl-people-find { width: 160px; min-width: 0; } +.dl-people-find[hidden] { display: none; } diff --git a/web/src/admin/ui/badges.ts b/web/src/admin/ui/badges.ts index c8239f0..ed44721 100644 --- a/web/src/admin/ui/badges.ts +++ b/web/src/admin/ui/badges.ts @@ -49,13 +49,28 @@ export function accessBadge(p: Person): HTMLElement { return el; } +/** Why a person's devices cannot connect right now, in two words. */ +const STOPPED: Partial> = { + paused: 'Paused', + expired: 'Access ended', + quota: 'Data limit', + hours: 'Outside hours', + server_off: 'Server off', + no_server: 'No server', +}; + /** * A device's status as coloured text, no dots (only avatars carry one). `now` * is the router's clock; `waiting` is the text before the first connection. + * With the person, a device that cannot come back says why ("Paused", + * "Data limit") instead of a "Last seen" that reads like it might. */ -export function deviceStatus(d: Device, now?: number, waiting = 'Not set up yet'): HTMLElement { - if (d.disabled) return E('span', { class: 'dl-dstat' }, 'Disabled'); +export function deviceStatus(d: Device, now?: number, waiting = 'Not set up yet', p?: Person): HTMLElement { + const seen = d.handshake ? `Last seen ${ago(d.handshake, now)} · ${new Date(d.handshake * 1000).toLocaleString()}` : ''; + if (d.disabled) return E('span', { class: 'dl-dstat', title: seen }, 'Disabled'); if (d.online) return E('span', { class: 'dl-dstat ok' }, 'Connected'); + const why = p && STOPPED[p.state]; + if (why) return E('span', { class: 'dl-dstat warn', title: seen || 'Not connected yet' }, why); if (!d.handshake) return E('span', { class: 'dl-dstat warn', title: 'Waiting for the first connection' }, waiting); - return E('span', { class: 'dl-dstat' }, `Last seen ${ago(d.handshake, now)}`); + return E('span', { class: 'dl-dstat', title: new Date(d.handshake * 1000).toLocaleString() }, `Last seen ${ago(d.handshake, now)}`); } diff --git a/web/src/admin/ui/files.ts b/web/src/admin/ui/files.ts index 2856998..c194431 100644 --- a/web/src/admin/ui/files.ts +++ b/web/src/admin/ui/files.ts @@ -3,7 +3,13 @@ import { E } from '../e'; import { errorText, notify } from './toast'; -export async function copyText(text: string, what = 'Copied to clipboard') { +/** + * Copy to the clipboard and say so. `quiet`: a copy that is a convenience + * after something else (a link right after creating a person): browsers + * refuse a write outside the click that started it (Safari after an await), + * and then nothing is said — the link is on screen with its own Copy button. + */ +export async function copyText(text: string, what = 'Copied to clipboard', quiet = false): Promise { try { if (navigator.clipboard && window.isSecureContext) { await navigator.clipboard.writeText(text); @@ -16,8 +22,10 @@ export async function copyText(text: string, what = 'Copied to clipboard') { if (!ok) throw new Error('Copying is blocked here. Select the text and copy it by hand.'); } notify(what, 'success', 2500); + return true; } catch (e) { - notify(errorText(e), 'error'); + if (!quiet) notify(errorText(e), 'error'); + return false; } } diff --git a/web/src/admin/ui/layout.ts b/web/src/admin/ui/layout.ts index f9e75a7..58cde04 100644 --- a/web/src/admin/ui/layout.ts +++ b/web/src/admin/ui/layout.ts @@ -23,8 +23,8 @@ export function liveRow( el: HTMLInputElement, help: () => { text: string; bad: boolean }, control: Node = el, -): HTMLElement & { refresh: () => void } { - const r = row(label, control, ' ') as HTMLElement & { refresh: () => void }; +): HTMLElement & { refresh: () => void; help: () => { text: string; bad: boolean } } { + const r = row(label, control, ' ') as HTMLElement & { refresh: () => void; help: () => { text: string; bad: boolean } }; const sub = r.querySelector('.dl-sub') as HTMLElement; const paint = () => { const h = help(); @@ -34,10 +34,57 @@ export function liveRow( }; el.addEventListener('input', paint); r.refresh = paint; + r.help = help; paint(); return r; } +/** + * liveRow for a dialog field (LuCI's cbi-value layout: label beside the + * control, the help under the label as on the cards). Same contract: `help` + * repaints on input, `refresh()` when something else changes. + */ +export function liveField( + label: string, + el: HTMLInputElement | HTMLSelectElement, + help: () => { text: string; bad: boolean }, + control: Node = el, +): HTMLElement & { refresh: () => void; help: () => { text: string; bad: boolean } } { + const sub = E('div', { class: 'dl-sub' }); + const r = E('div', { class: 'cbi-value dl-live' }, [ + E('div', { class: 'cbi-value-title' }, [E('label', {}, label), sub]), + E('div', { class: 'cbi-value-field' }, control), + ]) as HTMLElement & { refresh: () => void; help: () => { text: string; bad: boolean } }; + const paint = () => { + const h = help(); + sub.textContent = h.text; + sub.classList.toggle('bad', h.bad); + el.classList.toggle('cbi-input-invalid', h.bad); + }; + el.addEventListener('input', paint); + el.addEventListener('change', paint); + r.refresh = paint; + r.help = help; + paint(); + return r; +} + +/** The first problem among live rows (their help as it stands), or null: what refuses a Save. */ +export function firstBad( + rows: { help?: () => { text: string; bad: boolean } }[], + helps: (() => { text: string; bad: boolean })[] = [], +): string | null { + for (const r of rows) { + const h = r.help?.(); + if (h?.bad) return h.text; + } + for (const f of helps) { + const h = f(); + if (h.bad) return h.text; + } + return null; +} + /** A section card with its own footer (Save etc.). */ export function card(title: string, body: (Node | string)[], foot: (Node | string)[], extra = ''): HTMLElement { return E('section', { class: `dl-setsec ${extra}` }, [ diff --git a/web/src/admin/ui/menu.ts b/web/src/admin/ui/menu.ts index e263971..2ce6e6c 100644 --- a/web/src/admin/ui/menu.ts +++ b/web/src/admin/ui/menu.ts @@ -53,7 +53,22 @@ export function dropdown(anchor: HTMLElement, items: (MenuItem | null)[]) { if (!menu.contains(ev.target as Node) && !anchor.contains(ev.target as Node)) close(); }; const onKey = (ev: KeyboardEvent) => { - if (ev.key === 'Escape') close(); + if (ev.key === 'Escape' || ev.key === 'Tab') return close(); + // Arrow keys walk the items (wrapping), Home/End jump; a menu that has the + // keyboard focus must not scroll the page under it. + const items = [...menu.querySelectorAll('button:not([disabled])')]; + if (!items.length || !['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(ev.key)) return; + ev.preventDefault(); + const i = items.indexOf(document.activeElement as HTMLButtonElement); + const next = + ev.key === 'Home' + ? 0 + : ev.key === 'End' + ? items.length - 1 + : ev.key === 'ArrowDown' + ? (i + 1) % items.length + : (i - 1 + items.length) % items.length; + items[next].focus({ preventScroll: true }); }; const offNav = onNavigate(close); menu.dlAnchor = anchor; diff --git a/web/src/admin/ui/modal.ts b/web/src/admin/ui/modal.ts index 41f129f..19bce67 100644 --- a/web/src/admin/ui/modal.ts +++ b/web/src/admin/ui/modal.ts @@ -17,7 +17,27 @@ function settle(ok = false) { export function modal(title: string, body: Child, actions: Child, cls = '') { settle(); - ui.showModal(title, [E('div', { class: `dl-modal ${cls}` }, body), E('div', { class: 'button-row' }, actions)]); + const bodyEl = E('div', { class: `dl-modal ${cls}` }, body); + const rowEl = E('div', { class: 'button-row' }, actions); + // Enter in a field submits: the dialog's positive button (buttons, selects + // and text areas keep their own Enter). + bodyEl.addEventListener('keydown', (ev: KeyboardEvent) => { + // Escape closes the dialog only: a drawer under it stays (it listens on the document). + if (ev.key === 'Escape') { + ev.preventDefault(); + ev.stopPropagation(); + closeModal(); + return; + } + if (ev.key !== 'Enter' || ev.shiftKey || ev.ctrlKey || ev.metaKey || ev.altKey) return; + const t = ev.target as HTMLElement; + if (!t || ['TEXTAREA', 'BUTTON', 'SELECT', 'A'].includes(t.tagName)) return; + const go = rowEl.querySelector('.cbi-button-positive'); + if (!go || go.disabled) return; + ev.preventDefault(); + go.click(); + }); + ui.showModal(title, [bodyEl, rowEl]); } export function closeModal() { diff --git a/web/src/admin/ui/tooltip.ts b/web/src/admin/ui/tooltip.ts index 29289e4..5ade61a 100644 --- a/web/src/admin/ui/tooltip.ts +++ b/web/src/admin/ui/tooltip.ts @@ -34,6 +34,13 @@ export function attachTip(el: HTMLElement, content: () => (Node | string)[]) { el.addEventListener('mouseenter', show); el.addEventListener('mousemove', show); el.addEventListener('mouseleave', hideTip); + // No hover on a touch screen: a tap on the anchor shows it, the next tap + // anywhere (the document listener below) hides it. + el.addEventListener('pointerup', (ev: PointerEvent) => { + if (ev.pointerType === 'mouse') return; + if (anchor === el) hideTip(); + else show(ev as unknown as MouseEvent); + }); } onNavigate(hideTip); diff --git a/web/src/portal/dom.ts b/web/src/portal/dom.ts new file mode 100644 index 0000000..d86190b --- /dev/null +++ b/web/src/portal/dom.ts @@ -0,0 +1,32 @@ +// The portal's two DOM builders: an element from a tag, attributes and +// children, and an icon. No framework; shared by the page (main.ts) and the +// pieces drawn outside it (waitpath.ts). + +import { iconSvg } from '../shared/icons'; + +export type Attrs = Record; +export type Kid = Node | string | null | undefined | false | Kid[]; + +export function h(tag: string, attrs: Attrs = {}, ...kids: Kid[]): HTMLElement { + const el = document.createElement(tag); + for (const [k, v] of Object.entries(attrs)) { + if (v == null || v === false) continue; + if (k.startsWith('on') && typeof v === 'function') el.addEventListener(k.slice(2), v as EventListener); + else if (k === 'class') el.className = String(v); + else if (v === true) el.setAttribute(k, ''); + else el.setAttribute(k, String(v)); + } + const add = (c: Kid) => { + if (c == null || c === false) return; + if (Array.isArray(c)) c.forEach(add); + else el.appendChild(typeof c === 'string' ? document.createTextNode(c) : c); + }; + kids.forEach(add); + return el; +} + +export function ic(name: string): HTMLElement { + const s = h('span', { class: 'ic' }); + s.innerHTML = iconSvg(name, 'ic-svg'); + return s; +} diff --git a/web/src/portal/main.ts b/web/src/portal/main.ts index a7384ae..a43f137 100644 --- a/web/src/portal/main.ts +++ b/web/src/portal/main.ts @@ -21,14 +21,56 @@ import { parseDay, } from '../shared/format'; import { iconSvg } from '../shared/icons'; -import { qrSvg } from '../shared/qr'; +import { denseQr, qrSvg } from '../shared/qr'; import { vpnKey } from '../shared/vpnkey'; +import { h, ic, type Kid } from './dom'; +import { waitPath, type Way } from './waitpath'; +import { + beat, + busy, + calm, + copied, + fold, + followHeight, + intro, + leave, + pullToClose, + replay, + restyle, + settle, + slider, + snap, + swap, +} from './motion'; +import { + APP_NAME, + appsFor, + hereLabel, + deviceNoun, + importPath, + setupFromHash, + setupLink, + inWebview, + osGroup, + PLATFORM_LABEL, + platformOf, + routerStore, + sameDevice, + scanPath, + storeFor, + updateLine, + type AppId, + type Platform, + type Preset, + type Store, +} from './setup'; interface State { title: string; person: Person; /** device_mesh: devices with home access reach each other through the tunnel. */ - server: { name: string; endpoint: string; device_mesh?: boolean }; + /** awg_disguise: false = plain WireGuard, any WireGuard app connects. */ + server: { name: string; endpoint: string; device_mesh?: boolean; awg_disguise?: boolean; preset?: Preset }; /** The device this page was opened from (through the tunnel), if any. */ here?: string | null; can_add: boolean; @@ -40,40 +82,14 @@ interface State { version: string; /** The router's day (YYYY-MM-DD) when it sends one; the browser's otherwise. */ today?: string; + /** The router's clock (epoch seconds): relative times are measured against it, not the phone's. */ + now?: number; } /** Today on the router, for days left and chart labels. */ const today = () => state?.today ?? isoDay(new Date()); - -type Attrs = Record; -type Kid = Node | string | null | undefined | false | Kid[]; - -function h(tag: string, attrs: Attrs = {}, ...kids: Kid[]): HTMLElement { - const el = document.createElement(tag); - for (const [k, v] of Object.entries(attrs)) { - if (v == null || v === false) continue; - if (k.startsWith('on') && typeof v === 'function') el.addEventListener(k.slice(2), v as EventListener); - else if (k === 'class') el.className = String(v); - else if (v === true) el.setAttribute(k, ''); - else el.setAttribute(k, String(v)); - } - const add = (c: Kid) => { - if (c == null || c === false) return; - if (Array.isArray(c)) c.forEach(add); - else el.appendChild(typeof c === 'string' ? document.createTextNode(c) : c); - }; - kids.forEach(add); - return el; -} - -function ic(name: string): HTMLElement { - const s = h('span', { class: 'ic' }); - s.innerHTML = iconSvg(name, 'ic-svg'); - return s; -} - -const LOGO = - ''; +/** Now on the router (seconds), for "last connected 3 min ago". */ +const now = () => state?.now ?? Date.now() / 1000; const app = document.getElementById('app')!; const base = app.dataset.base ?? ''; @@ -116,17 +132,27 @@ async function call(path: string, body?: unknown): Promise { /* ---------- small UI pieces ---------- */ -function toast(msg: string, bad = false) { - const t = h('div', { class: `toast${bad ? ' bad' : ''}`, role: 'status' }, msg); - document.body.appendChild(t); - requestAnimationFrame(() => t.classList.add('show')); - setTimeout(() => { - t.classList.remove('show'); - setTimeout(() => t.remove(), 300); - }, 2600); +/** One toast at a time: a new one sends the last away first. */ +let toastEl: HTMLElement | null = null; +function dropToast(t: HTMLElement) { + if (toastEl === t) toastEl = null; + t.classList.remove('show'); + t.classList.add('gone'); + setTimeout(() => t.remove(), 200); } -async function copy(text: string, what = 'Copied') { +function toast(msg: string, bad = false) { + if (toastEl) dropToast(toastEl); + const t = h('div', { class: `toast${bad ? ' bad' : ''}`, role: 'status' }, msg); + document.body.appendChild(t); + void t.offsetWidth; + t.classList.add('show'); + toastEl = t; + setTimeout(() => dropToast(t), 2600); +} + +/** `from`: the control that copied, which then shows a check for a moment. */ +async function copy(text: string, what = 'Copied', from?: EventTarget | null) { try { await navigator.clipboard.writeText(text); } catch { @@ -137,9 +163,33 @@ async function copy(text: string, what = 'Copied') { ta.remove(); if (!ok) return toast('Copying is blocked here. Select the text and copy it by hand.', true); } + copied(from instanceof HTMLElement ? from : null, iconSvg('check', 'ic-svg')); toast(what); } +/** + * On phones a share sheet hands the file straight to the VPN app, where a + * download would land in Files. Returns the action, or null where files + * cannot be shared. + */ +function shareFile(cfg: ClientConfig): (() => Promise) | null { + const nav = navigator as Navigator & { canShare?: (d: unknown) => boolean }; + // Desktop browsers claim they can share files and then do nothing, or open a + // sheet with nowhere useful: there a download is the right thing anyway. + if (!/Android|iPhone|iPad/.test(navigator.userAgent)) return null; + if (typeof nav.share !== 'function' || typeof File === 'undefined') return null; + const file = new File([cfg.conf], cfg.filename, { type: 'application/octet-stream' }); + if (!nav.canShare?.({ files: [file] })) return null; + return async () => { + try { + await nav.share({ files: [file], title: cfg.filename }); + } catch (e) { + // Cancelled: nothing to do. Refused by the browser: the file still has to get out. + if ((e as Error)?.name !== 'AbortError') download(cfg.filename, cfg.conf); + } + }; +} + function download(name: string, text: string) { // Not text/plain: Safari would save "name.conf.txt". const url = URL.createObjectURL(new Blob([text], { type: 'application/octet-stream' })); @@ -152,18 +202,20 @@ function download(name: string, text: string) { }, 1000); } +// One tooltip for the page: it fades in where the pointer is, then only follows it +// (moving from bar to bar never replays the entrance). let tipEl: HTMLElement | null = null; function tip(el: HTMLElement, lines: () => string[]) { const show = (ev: MouseEvent) => { - tipEl ??= document.body.appendChild(h('div', { class: 'tip' })); + tipEl ??= document.body.appendChild(h('div', { class: 'tip', role: 'tooltip' })); tipEl.replaceChildren(...lines().map((l, i) => h('div', { class: i ? 'muted' : 'tip-title' }, l))); - tipEl.style.display = ''; tipEl.style.left = `${ev.clientX}px`; tipEl.style.top = `${ev.clientY - 10}px`; + tipEl.classList.add('show'); }; el.addEventListener('mouseenter', show); el.addEventListener('mousemove', show); - el.addEventListener('mouseleave', () => tipEl && (tipEl.style.display = 'none')); + el.addEventListener('mouseleave', () => tipEl?.classList.remove('show')); } function spark(values: number[]): HTMLElement { @@ -172,6 +224,7 @@ function spark(values: number[]): HTMLElement { values.forEach((v, i) => { const b = h('i', { class: v ? '' : 'zero' }); b.style.height = `${Math.max(8, (v / max) * 100)}%`; + b.style.setProperty('--i', String(i)); const back = values.length - 1 - i; tip(b, () => [ back === 0 @@ -190,9 +243,11 @@ function spark(values: number[]): HTMLElement { async function once(btn: HTMLButtonElement, fn: () => Promise) { if (btn.disabled) return; btn.disabled = true; + const idle = busy(btn); try { await fn(); } finally { + idle(); btn.disabled = false; } } @@ -201,11 +256,27 @@ async function once(btn: HTMLButtonElement, fn: () => Promise) { let sheetEl: HTMLElement | null = null; let sheetClosed: (() => void) | null = null; +/** The sheet sits at the bottom (phones): it slides up and can be pulled down. */ +const bottomSheet = () => window.matchMedia('(max-width: 639px)').matches; +// A sheet is a history entry: the phone's back button closes it instead of leaving the page. +let sheetHistory = false; +window.addEventListener('popstate', () => { + if (sheetEl) { + sheetHistory = false; + closeSheet(); + } +}); + +/** `immediate`: gone at once (Escape: what the keyboard does never animates). */ function closeSheet(immediate = false) { if (!sheetEl) return; const s = sheetEl; sheetEl = null; + if (sheetHistory) { + sheetHistory = false; + history.back(); + } document.body.classList.remove('locked'); sheetClosed?.(); sheetClosed = null; @@ -214,16 +285,66 @@ function closeSheet(immediate = false) { return; } s.classList.remove('open'); - setTimeout(() => s.remove(), 250); + s.classList.add('closing'); + setTimeout(() => s.remove(), bottomSheet() ? 320 : 180); } -function sheet(title: string, sub: string | null, ...content: Kid[]) { - const replacing = !!sheetEl; - closeSheet(true); +/** + * Open a sheet with this content, or turn the open one into it: the panel then + * keeps its place (and its history entry) while the old content fades out, the + * new one comes in and the size follows, so a flow of sheets reads as one. + * `asks`: the narrow question look (ask), which the panel also morphs out of. + */ +function present(label: string, inner: Node[], asks = false) { + if (sheetEl) { + sheetClosed?.(); + sheetClosed = null; + const panel = sheetEl.querySelector('.sheet-panel') as HTMLElement; + panel.setAttribute('aria-label', label); + panel.setAttribute('role', asks ? 'alertdialog' : 'dialog'); + // A question that turns into a sheet (or back) changes width too: let the panel morph it. + if (panel.classList.contains('asks') !== asks) { + panel.dataset.morph = 'width'; + panel.classList.toggle('asks', asks); + } + panel.scrollTop = 0; + swap(panel.querySelector('.sheet-inner') as HTMLElement, inner); + return; + } + const box = h('div', { class: 'sheet-inner' }, ...inner); const panel = h( 'div', - { class: 'sheet-panel', role: 'dialog', 'aria-modal': 'true', 'aria-label': title }, + { class: `sheet-panel${asks ? ' asks' : ''}`, role: asks ? 'alertdialog' : 'dialog', 'aria-modal': 'true', 'aria-label': label }, h('div', { class: 'grab' }), + box, + ); + const scrim = h('div', { class: 'scrim', onclick: () => closeSheet() }); + const s = h('div', { class: 'sheet fresh' }, scrim, panel); + // On a dialog the content settles in just after it; on phones the slide is the motion. + box + .querySelectorAll(':scope > .sheet-head, .sheet-body > :not(.setup), .setup > *') + .forEach((el, i) => el.style.setProperty('--i', String(Math.min(i, 6)))); + document.body.appendChild(s); + document.body.classList.add('locked'); + if (!sheetHistory) { + try { + history.pushState({ sheet: true }, ''); + sheetHistory = true; + } catch { + /* no history */ + } + } + followHeight(panel, box); + pullToClose(panel, scrim, () => closeSheet(), bottomSheet); + void s.offsetWidth; + s.classList.add('open'); + setTimeout(() => s.classList.remove('fresh'), 700); + sheetEl = s; +} + +/** A sheet: a title (and a line under it), a close button, the content. */ +function sheet(title: string, sub: string | null, ...content: Kid[]) { + present(title, [ h( 'div', { class: 'sheet-head' }, @@ -231,44 +352,86 @@ function sheet(title: string, sub: string | null, ...content: Kid[]) { h('button', { class: 'icon-btn', 'aria-label': 'Close', onclick: () => closeSheet() }, ic('x')), ), h('div', { class: 'sheet-body' }, ...content), + ]); +} + +/** + * A question before something that cannot be undone (Remove, New keys): narrow + * and centred, the action's icon in its colour, one line of what happens, Cancel + * and the action (no ×: Cancel says it). `run` holds the action's button busy. + */ +function ask(o: { + icon: string; + tone: 'bad' | 'warn'; + title: string; + text: string; + action: string; + actionClass: string; + run: () => Promise; +}) { + present( + o.title, + [ + h( + 'div', + { class: 'ask' }, + h('span', { class: `ask-ic ${o.tone}` }, ic(o.icon)), + h('h2', {}, o.title), + h('p', { class: 'muted' }, o.text), + h( + 'div', + { class: 'row gap ask-actions' }, + h('button', { type: 'button', class: 'btn block', onclick: () => closeSheet() }, 'Cancel'), + h( + 'button', + { + type: 'button', + class: `btn ${o.actionClass} block`, + onclick: (ev: Event) => once(ev.currentTarget as HTMLButtonElement, o.run), + }, + o.action, + ), + ), + ), + ], + true, ); - const s = h( - 'div', - { - class: 'sheet', - onclick: (e: Event) => { - if (e.target === s) closeSheet(); - }, - }, - panel, - ); - document.body.appendChild(s); - document.body.classList.add('locked'); - if (replacing) s.classList.add('open'); - else requestAnimationFrame(() => s.classList.add('open')); - sheetEl = s; - return panel; } document.addEventListener('keydown', (e) => { if (e.key === 'Escape') { - closeMenu(); - closeSheet(); + closeMenu(true); + closeSheet(true); } }); /* ---------- dropdown menu ---------- */ let menuEl: HTMLElement | null = null; -function closeMenu() { - menuEl?.remove(); +/** The button the open menu belongs to: pressing it again closes the menu. */ +let menuFor: HTMLElement | null = null; + +/** `immediate`: gone at once (Escape). */ +function closeMenu(immediate = false) { + const m = menuEl; + if (!m) return; menuEl = null; + menuFor?.setAttribute('aria-expanded', 'false'); + menuFor = null; + if (immediate) { + m.remove(); + return; + } + m.classList.remove('show'); + m.classList.add('gone'); + setTimeout(() => m.remove(), 150); } document.addEventListener('click', (e) => { if (menuEl && !menuEl.contains(e.target as Node)) closeMenu(); }); function menu(anchor: HTMLElement, all: ({ label: string; icon: string; danger?: boolean; run: () => unknown } | null)[]) { + if (menuFor === anchor) return closeMenu(); closeMenu(); // Separators only between items. const items = all.filter((it, i) => it || (i > 0 && all[i - 1] && all.slice(i + 1).some(Boolean))); @@ -296,19 +459,45 @@ function menu(anchor: HTMLElement, all: ({ label: string; icon: string; danger?: ); document.body.appendChild(m); const r = anchor.getBoundingClientRect(); - const w = 230; + const w = 230, + mh = m.offsetHeight; + // Under the button, or over it where the screen ends: it grows out of the button either way. + const up = r.bottom + 6 + mh > window.innerHeight - 8 && r.top - 6 - mh > 8; + m.classList.toggle('up', up); m.style.left = `${Math.max(8, Math.min(window.innerWidth - w - 8, r.right - w))}px`; - m.style.top = `${r.bottom + 6 + window.scrollY}px`; + m.style.top = `${(up ? r.top - 6 - mh : r.bottom + 6) + window.scrollY}px`; + void m.offsetWidth; + m.classList.add('show'); + anchor.setAttribute('aria-expanded', 'true'); menuEl = m; + menuFor = anchor; } /* ---------- views ---------- */ +// The sun rises from behind the horizon once, on the visit's first paint. +const LOGO = + ''; + +/** The blocks of a page that come in on the first paint, in reading order. */ +const INTRO = '.alert, .hello, .card-head, .access-card, .dcard, .slot.add, .firststeps, .devices > .faint, .signin, .wrap > .card'; +let booted = false; + +/** + * Draw the page. The visit's first paint comes in (blocks rise in, the meters + * fill, the sun rises); a repaint only moves what changed: keyed blocks glide + * to their new places, new ones rise in, changed values come into focus. + */ function shell(...content: Kid[]) { + const before = booted ? snap(app) : null; + const first = !booted ? ' first' : ''; + const wrap = h('main', { class: `wrap${first}` }, ...content); app.replaceChildren( h( 'header', - { class: 'top' }, + { class: `top${first}` }, h( 'div', { class: 'brand' }, @@ -321,8 +510,11 @@ function shell(...content: Kid[]) { h('span', { class: 'faint' }, '· Dawnline'), ), ), - h('main', { class: 'wrap' }, ...content), + wrap, ); + if (before) settle(app, before); + else intro(wrap, INTRO); + booted = true; } /** The link stopped working while the page was open (code regenerated, person removed). */ @@ -330,7 +522,7 @@ function linkGone() { shell( h( 'div', - { class: 'card signin' }, + { class: 'card signin', 'data-key': 'gone' }, h('div', { class: 'hero-ic' }, ic('key')), h('h1', {}, 'This link no longer works'), h('p', { class: 'muted' }, 'Ask for a new personal link.'), @@ -346,11 +538,15 @@ function stateNotice(p: Person): [string, string, string] { case 'no_server': return ['server', 'No server yet', 'Ask the admin to add you to a server.']; case 'quota': - return ['chart', 'You have used all your data', 'Your devices are paused until it resets.']; + return ['chart', 'You have used all your data', 'Your devices stay connected but nothing gets through until it resets.']; case 'expired': return ['calendar', 'Your access has ended', 'Ask the admin to extend it.']; case 'hours': - return ['clock', 'Outside your hours', `Access is available ${p.hours.replace('-', '–')} (router time).`]; + return [ + 'clock', + 'Outside your hours', + `Access is available ${p.hours.replace('-', '–')} (router time); until then nothing gets through.`, + ]; default: return ['pause', 'Your access is paused by the admin', 'Your devices can’t connect until the admin resumes it.']; } @@ -360,7 +556,7 @@ function stateNotice(p: Person): [string, string, string] { function alertRow(tone: string, icon: string, title: string, sub: string): HTMLElement { return h( 'div', - { class: 'alert' }, + { class: 'alert', 'data-key': 'notice' }, h('span', { class: `alert-ic ${tone}` }, ic(icon)), h('div', { class: 'stack' }, h('span', { class: 'strong' }, title), h('span', { class: 'muted s' }, sub)), ); @@ -386,13 +582,15 @@ function accessCard(st: State): HTMLElement { const slots = h('div', { class: 'slots' }); // Devices the admin added over the limit get their own orange slots after the allowed ones. for (let i = 0; i < Math.max(p.device_limit, p.devices.length); i++) - slots.appendChild(h('i', { class: i >= p.device_limit ? 'over' : i < p.devices.length ? 'used' : '' })); + slots + .appendChild(h('i', { class: i >= p.device_limit ? 'over' : i < p.devices.length ? 'used' : '' })) + .style.setProperty('--i', String(i)); const used = p.quota_used || p.month[0] + p.month[1]; const icon = p.access === 'internet' ? 'globe' : p.access === 'lan' ? 'home' : 'shield'; // Heading outside the card, like "Your devices", so both columns line up. return h( 'section', - { class: 'access', 'aria-label': 'Your access' }, + { class: 'access', 'aria-label': 'Your access', 'data-key': 'access' }, h( 'div', { class: 'card-head' }, @@ -424,7 +622,7 @@ function accessCard(st: State): HTMLElement { ), h( 'span', - { class: 'tile-value' }, + { class: 'tile-value', 'data-v': 'used' }, bytes(used), h('span', { class: 'faint' }, p.quota_limit ? ` of ${bytes(p.quota_limit)}` : ' · no limit'), ), @@ -437,14 +635,19 @@ function accessCard(st: State): HTMLElement { 'div', { class: 'tile' }, h('div', { class: 'tile-label' }, 'Devices'), - h('span', { class: 'tile-value' }, String(p.devices.length), h('span', { class: 'faint' }, ` / ${p.device_limit}`)), + h( + 'span', + { class: 'tile-value', 'data-v': 'count' }, + String(p.devices.length), + h('span', { class: 'faint' }, ` / ${p.device_limit}`), + ), slots, ), h( 'div', { class: 'tile' }, h('div', { class: 'tile-label' }, 'Access until'), - h('span', { class: 'tile-value sm' }, p.expires ? date(p.expires) : 'No end date'), + h('span', { class: 'tile-value sm', 'data-v': 'until' }, p.expires ? date(p.expires) : 'No end date'), left != null ? h( 'span', @@ -463,12 +666,18 @@ function accessCard(st: State): HTMLElement { ); } -function deviceStatus(d: Device): HTMLElement { +function deviceStatus(d: Device, p: Person): HTMLElement { // Status as coloured text, no dots (only the avatar carries one). if (d.disabled) return h('span', { class: 'dstat' }, 'Disabled by the admin'); + // Settings the device carries changed: it keeps working on the old ones only until they stop matching. + if (d.config_stale && d.handshake) return h('span', { class: 'dstat warn' }, 'Settings changed, update needed'); + // Over the data limit or outside the hours the tunnel stays up but passes nothing: the app says + // "connected", so say here why nothing works. + if (d.online && p.state === 'quota') return h('span', { class: 'dstat warn' }, 'Connected, no data left'); + if (d.online && p.state === 'hours') return h('span', { class: 'dstat warn' }, 'Connected, outside your hours'); if (d.online) return h('span', { class: 'dstat ok' }, 'Connected'); if (!d.handshake) return h('span', { class: 'dstat warn' }, 'Not set up yet'); - return h('span', { class: 'dstat' }, `Last connected ${ago(d.handshake)}`); + return h('span', { class: 'dstat', title: new Date(d.handshake * 1000).toLocaleString() }, `Last connected ${ago(d.handshake, now())}`); } /** @@ -519,7 +728,7 @@ function namesAtHome(p: Person, mesh: boolean): HTMLElement | null { class: 'name-chip', title: d.name, 'aria-label': `Copy ${d.hostname}`, - onclick: () => copy(d.hostname, 'Address copied'), + onclick: (ev: Event) => copy(d.hostname, 'Address copied', ev.currentTarget), }, h( 'span', @@ -534,7 +743,11 @@ function namesAtHome(p: Person, mesh: boolean): HTMLElement | null { } function deviceCard(d: Device, st: State): HTMLElement { - const more = h('button', { type: 'button', class: 'icon-btn soft', 'aria-label': `${d.name} options` }, ic('more')); + const more = h( + 'button', + { type: 'button', class: 'icon-btn soft', 'aria-label': `${d.name} options`, 'aria-haspopup': 'menu', 'aria-expanded': 'false' }, + ic('more'), + ); more.addEventListener('click', (ev) => { ev.stopPropagation(); menu(more, [ @@ -566,20 +779,18 @@ function deviceCard(d: Device, st: State): HTMLElement { const locked = !!st.locked; // The device this page was opened from (through the tunnel): blue, and says so. const here = st.here === d.id; + // Opened through the tunnel, so it is connected: say which one it is instead. + // The home name is in the access card; the tunnel address says nothing to them. + const status = here ? h('span', { class: 'dstat here' }, 'This device') : deviceStatus(d, st.person); + status.dataset.v = `stat:${d.id}`; return h( 'article', - { class: `dcard${d.online ? ' online' : ''}${d.disabled ? ' off' : ''}${here ? ' here' : ''}` }, + { class: `dcard${d.online ? ' online' : ''}${d.disabled ? ' off' : ''}${here ? ' here' : ''}`, 'data-key': d.id }, h( 'div', { class: 'dhead' }, h('span', { class: 'dic' }, ic(d.kind)), - h( - 'div', - { class: 'stack grow' }, - h('span', { class: 'dname' }, d.name), - // Opened through the tunnel, so it is connected: say which one it is instead. - here ? h('span', { class: 'dstat here' }, 'This device') : deviceStatus(d), - ), + h('div', { class: 'stack grow' }, h('span', { class: 'dname', 'data-v': `name:${d.id}` }, d.name), status), locked ? null : more, ), setUp && locked @@ -588,24 +799,29 @@ function deviceCard(d: Device, st: State): HTMLElement { ? [ h( 'button', - { type: 'button', class: 'btn primary block', onclick: () => connect(d) }, - ic(isMobile() ? 'open' : 'qr'), - h('span', {}, isMobile() ? 'Open in AmneziaVPN' : 'Connect this device'), + { type: 'button', class: 'btn primary block', onclick: () => setup(d) }, + ic('arrow'), + h('span', {}, `Set up ${d.name}`), ), ] : h( 'div', { class: 'duse' }, - h('div', { class: 'stack' }, h('span', { class: 'faint s' }, 'Last 7 days'), h('span', { class: 'mono' }, bytes(week))), + h( + 'div', + { class: 'stack' }, + h('span', { class: 'faint s' }, 'Last 7 days'), + h('span', { class: 'mono', 'data-v': `week:${d.id}` }, bytes(week)), + ), spark(d.spark), ), + // The admin changed something the configuration carries: the status line says so, one button fixes it. d.config_stale && !setUp && !locked ? h( - 'div', - { class: 'notice' }, - ic('alert'), - h('span', { class: 'grow' }, 'Connection settings changed. Update this device to keep everything working.'), - h('button', { type: 'button', class: 'btn small', onclick: () => connect(d) }, 'Update'), + 'button', + { type: 'button', class: 'btn block', onclick: () => connect(d) }, + ic('refresh'), + h('span', {}, 'Update the connection'), ) : null, ); @@ -625,11 +841,31 @@ function main(st: State) { const order = byDeviceState(p.devices).sort((a, b) => Number(b.id === st.here) - Number(a.id === st.here)); const cards: HTMLElement[] = order.map((d) => deviceCard(d, st)); const free = st.locked ? 0 : Math.max(0, p.device_limit - p.devices.length); - if (free) + // Nothing yet: one card with the button; the set-up sheet behind it walks through the app and the connection. + if (!p.devices.length && free) { + cards.push( + h( + 'div', + { class: 'card firststeps', 'data-key': 'first' }, + h('h2', {}, 'Add your first device'), + h( + 'p', + { class: 'muted' }, + 'Two steps, about a minute: get the app, then add the connection. The next screen shows both for the device you pick.', + ), + h( + 'button', + { type: 'button', class: 'btn primary block big', onclick: addDevice }, + ic('plus'), + h('span', {}, isMobile() ? 'Add this phone' : 'Add this device'), + ), + ), + ); + } else if (free) cards.push( h( 'button', - { type: 'button', class: 'slot add', onclick: addDevice }, + { type: 'button', class: 'slot add', onclick: addDevice, 'data-key': 'add' }, h('span', { class: 'slot-ic' }, ic('plus')), // How many are left is in "Your devices 3 of 10" and the Devices tile. h('span', { class: 'strong' }, 'Add device'), @@ -641,7 +877,7 @@ function main(st: State) { { class: 'devices', 'aria-label': 'Your devices' }, h( 'div', - { class: 'card-head' }, + { class: 'card-head', 'data-key': 'devices-head' }, h( 'div', { class: 'row-baseline' }, @@ -656,17 +892,10 @@ function main(st: State) { !st.can_add ? h( 'span', - { class: 'faint s' }, + { class: 'faint s', 'data-key': 'limit' }, `You have reached your limit of ${p.device_limit} devices. Remove one or ask the admin for more.`, ) : null, - h( - 'span', - { class: 'faint s' }, - 'New device? Install ', - h('a', { href: 'https://amnezia.org/downloads', target: '_blank', rel: 'noopener noreferrer' }, 'AmneziaVPN'), - ' on it first.', - ), ], ); @@ -675,7 +904,7 @@ function main(st: State) { notice, h( 'div', - { class: 'hello' }, + { class: 'hello', 'data-key': 'hello' }, h('span', { class: `avatar${p.online ? ' online' : ''}` }, initials(p.name)), // What is wrong is in the notice above, not a pill here. h('h1', {}, `Hi, ${p.name}`), @@ -684,6 +913,86 @@ function main(st: State) { ); } +/** Where to get the app on this platform: the store on phones, the downloads page elsewhere. */ +function appLink(): { href: string; label: string } { + const pf = platform(); + const st = storeFor('vpn', pf); + return { + href: st?.href ?? 'https://github.com/amnezia-vpn/amnezia-client/releases/latest', + label: `Get AmneziaVPN${pf === 'ios' ? ' for iPhone' : pf === 'android' ? ' for Android' : ''}`, + }; +} + +/** The platform this page is open on (iPad on Safari says Mac; touch points tell). */ +const platform = (): Platform => platformOf(navigator.userAgent, navigator.maxTouchPoints); +/** The server's disguise generation, for which apps and versions connect. */ +const preset = (): Preset => state?.server.preset ?? (plainWg() ? 'off' : 'max'); + +/** The server's disguise is off: plain WireGuard, so any WireGuard app connects. */ +const plainWg = () => state?.server.awg_disguise === false; + +/* ---------- QR codes ---------- */ + +// The portal draws its codes in the night look (light dots on a black card). +// Some in-app scanners read only dark on light: one line under every code +// switches all of them to the plain look, and the choice is remembered here. +const QR_LIGHT = 'dl.qr.light'; +let lightQr = (() => { + try { + return localStorage.getItem(QR_LIGHT) === '1'; + } catch { + return false; + } +})(); +/** What each drawn code encodes, to draw it again in the other look. */ +const qrText = new WeakMap(); + +function paintQr(q: HTMLElement, text: string) { + qrText.set(q, text); + // A dense code is drawn as large as the sheet allows: a phone camera needs the modules. + q.className = `qr${denseQr(text) ? ' big' : ''}${lightQr ? ' light' : ''}`; + q.innerHTML = qrSvg(text, 3, true, lightQr ? 'plain' : 'night'); +} + +/** "Not scanning? Show a light code", or the way back. */ +function paintFlip(line: HTMLElement) { + line.replaceChildren( + lightQr ? '' : 'Not scanning? ', + h( + 'a', + { + href: '#', + onclick: (ev: Event) => { + ev.preventDefault(); + flipQr(); + }, + }, + lightQr ? 'Show the dark code' : 'Show a light code', + ), + ); +} +function qrFlip(): HTMLElement { + const line = h('span', { class: 'faint s qr-flip' }); + paintFlip(line); + return line; +} + +function flipQr() { + lightQr = !lightQr; + try { + localStorage.setItem(QR_LIGHT, lightQr ? '1' : '0'); + } catch { + /* private mode: for this page only */ + } + document.querySelectorAll('.qr').forEach((q) => { + const text = qrText.get(q); + if (!text) return; + paintQr(q, text); + replay(q, 'swap'); + }); + document.querySelectorAll('.qr-flip').forEach(paintFlip); +} + /* ---------- device flows ---------- */ /** @@ -750,7 +1059,7 @@ function confLine(line: string, reveal: boolean): Node { {}, h('span', { class: 'conf-k' }, m[1]), ' ', - secret && !reveal ? h('span', { class: 'conf-mask' }, '••••••••••••••••') : m[2], + secret ? (reveal ? h('span', { class: 'conf-v' }, m[2]) : h('span', { class: 'conf-mask' }, '••••••••••••••••')) : m[2], ); } @@ -758,8 +1067,11 @@ function confLine(line: string, reveal: boolean): Node { function filePane(cfg: ClientConfig): HTMLElement { let reveal = false; const pre = h('pre', { class: 'conf' }); - const paint = () => + // A key shown comes into focus out of a blur; hidden again, the mask fades back. + const paint = (toggled = false) => { pre.replaceChildren(...cfg.conf.split('\n').flatMap((l, i) => (i ? ['\n', confLine(l, reveal)] : [confLine(l, reveal)]))); + if (toggled) pre.querySelectorAll('.conf-v, .conf-mask').forEach((el) => el.classList.add('unmask')); + }; const eye = h( 'button', { @@ -768,7 +1080,8 @@ function filePane(cfg: ClientConfig): HTMLElement { ev.preventDefault(); reveal = !reveal; eye.replaceChildren(ic(reveal ? 'x' : 'key'), h('span', {}, reveal ? 'Hide key' : 'Show key')); - paint(); + replay(eye, 'swap'); + paint(true); }, }, ic('key'), @@ -786,9 +1099,17 @@ function filePane(cfg: ClientConfig): HTMLElement { 'span', { class: 'stack' }, h('span', { class: 'mono ellipsis' }, cfg.filename), - h('span', { class: 'faint s' }, 'For computers and routers: import it in AmneziaWG or AmneziaVPN'), + h( + 'span', + { class: 'faint s' }, + plainWg() + ? 'For computers and routers: import it in any WireGuard app' + : 'For computers and routers: import it in AmneziaWG or AmneziaVPN', + ), ), - h('button', { class: 'btn primary', onclick: () => download(cfg.filename, cfg.conf) }, ic('download'), h('span', {}, 'Download')), + shareFile(cfg) + ? h('button', { class: 'btn primary', onclick: () => shareFile(cfg)!() }, ic('open'), h('span', {}, 'Share file')) + : h('button', { class: 'btn primary', onclick: () => download(cfg.filename, cfg.conf) }, ic('download'), h('span', {}, 'Download')), ), h( 'details', @@ -806,7 +1127,7 @@ function filePane(cfg: ClientConfig): HTMLElement { class: 'btn small', onclick: (ev: Event) => { ev.preventDefault(); - copy(cfg.conf, 'Configuration copied'); + copy(cfg.conf, 'Configuration copied', ev.currentTarget); }, }, ic('copy'), @@ -823,12 +1144,16 @@ async function connect(d: Device, initial?: 'app' | 'qr' | 'key' | 'file', cfgIn if (!cfg) return; const key = await vpnKey(cfg, `${cfg.server} · ${cfg.name}`); const mobile = isMobile(); + // What is being set up decides what comes first: a phone from a phone opens + // the app, a phone seen from a computer shows the code, a computer or + // router takes the file. + const handheld = d.kind === 'phone' || d.kind === 'tablet'; const panes: Record HTMLElement> = { app: () => h( 'div', { class: 'pane' }, - h('a', { class: 'btn primary block big', href: key }, ic('open'), h('span', {}, 'Open in AmneziaVPN')), + h('a', { class: 'btn primary block big', href: key }, ic('amnezia'), h('span', {}, 'Open in AmneziaVPN')), h( 'ol', { class: 'steps' }, @@ -836,7 +1161,7 @@ async function connect(d: Device, initial?: 'app' | 'qr' | 'key' | 'file', cfgIn 'li', {}, 'No AmneziaVPN yet? ', - h('a', { href: 'https://amnezia.org/downloads', target: '_blank', rel: 'noopener noreferrer' }, 'Get it here'), + h('a', { href: appLink().href, target: '_blank', rel: 'noopener noreferrer' }, appLink().label), '.', ), h('li', {}, 'Tap ', h('b', {}, 'Open in AmneziaVPN'), ' and confirm the import.'), @@ -844,9 +1169,53 @@ async function connect(d: Device, initial?: 'app' | 'qr' | 'key' | 'file', cfgIn ), ), qr: () => { + // Two codes: AmneziaVPN reads its own key (the phone's camera opens it in + // the app); the AmneziaWG and WireGuard apps read the configuration text. const q = h('div', { class: 'qr' }); - q.innerHTML = qrSvg(cfg.conf); - return h('div', { class: 'pane center' }, q, h('p', { class: 'muted s' }, 'Scan with the phone’s camera or AmneziaVPN / AmneziaWG.')); + const cap = h('p', { class: 'muted s' }); + const seg = h('div', { class: 'seg' }); + let mode: 'vpn' | 'conf' = plainWg() ? 'conf' : 'vpn'; + let glide = () => {}; + // The other code comes into focus where the last one was. + const paint = (switched = false) => { + const text = mode === 'vpn' ? key : cfg.conf; + // A dense code is drawn as large as the sheet allows: a phone camera needs the modules. + paintQr(q, text); + cap.textContent = + mode === 'vpn' + ? 'Scan with the phone’s camera or inside AmneziaVPN.' + : plainWg() + ? 'Scan inside the AmneziaWG, WireGuard or AmneziaVPN app.' + : 'Scan inside the AmneziaWG app (or AmneziaVPN).'; + seg.querySelectorAll(':scope > button').forEach((b) => b.classList.toggle('on', b.dataset.m === mode)); + glide(); + if (switched) { + replay(q, 'swap'); + replay(cap, 'swap'); + } + }; + for (const [m, label] of [ + ['vpn', 'AmneziaVPN'], + ['conf', plainWg() ? 'WireGuard app' : 'AmneziaWG app'], + ] as const) + seg.appendChild( + h( + 'button', + { + type: 'button', + 'data-m': m, + onclick: () => { + if (mode === m) return; + mode = m; + paint(true); + }, + }, + label, + ), + ); + paint(); + glide = slider(seg); + return h('div', { class: 'pane center' }, seg, q, cap, qrFlip()); }, key: () => h( @@ -857,41 +1226,126 @@ async function connect(d: Device, initial?: 'app' | 'qr' | 'key' | 'file', cfgIn 'div', { class: 'keybox' }, h('span', { class: 'mono' }, key), - h('button', { class: 'btn small', onclick: () => copy(key, 'Key copied') }, 'Copy'), + h('button', { class: 'btn small', onclick: (ev: Event) => copy(key, 'Key copied', ev.currentTarget) }, 'Copy'), ), h('p', { class: 'faint s' }, 'Keep it private: anyone with the key can use your connection.'), ), file: () => filePane(cfg), }; - const order = mobile ? ['app', 'qr', 'key', 'file'] : ['qr', 'key', 'file']; + const order = mobile && handheld ? ['app', 'qr', 'key', 'file'] : handheld ? ['qr', 'key', 'file'] : ['file', 'key', 'qr']; const labels: Record = { app: 'Open in app', qr: 'QR code', key: 'Key', file: 'File' }; const body = h('div', { class: 'tab-body' }); const tabs = h('div', { class: 'tabs', role: 'tablist' }); + // The highlight slides to the tab; its pane comes in from that side. + let current = -1; + let glide = () => {}; const show = (id: string) => { - tabs.querySelectorAll('button').forEach((b) => b.classList.toggle('on', (b as HTMLElement).dataset.id === id)); - body.replaceChildren(panes[id]()); + const i = order.indexOf(id); + tabs.querySelectorAll(':scope > button').forEach((b) => { + b.classList.toggle('on', b.dataset.id === id); + b.setAttribute('aria-selected', String(b.dataset.id === id)); + }); + glide(); + if (current < 0) body.replaceChildren(panes[id]()); + else if (i !== current) swap(body, [panes[id]()], Math.sign(i - current)); + current = i; }; for (const id of order) tabs.appendChild(h('button', { role: 'tab', 'data-id': id, onclick: () => show(id) }, labels[id])); show(initial && order.includes(initial) ? initial : order[0]); + glide = slider(tabs); - const live = h('div', { class: 'waiting' }); - const paintLive = (dev: Device | undefined) => { - if (dev?.online) live.replaceChildren(h('span', { class: 'ok' }, `${d.name} is connected`)); - else if (dev?.handshake) live.replaceChildren(h('span', { class: 'muted' }, `Last connected ${ago(dev.handshake)}`)); - else live.replaceChildren(h('span', { class: 'warn' }, 'Waiting for the first connection…')); + // Never connected: the way to the router waits on top, and once it fills the + // code and the file have done their job and leave. Connected before: one line. + const way = d.handshake || d.disabled ? null : waitPath(d.kind); + const stop = way ? watchFirstConnection(d, () => void arrive(way, [tabs, body]), way.gaveUp) : () => undefined; + sheet( + d.handshake ? `Connect ${d.name}` : `${d.name} is ready`, + mobile && handheld + ? 'Add it to AmneziaVPN on this phone' + : handheld + ? 'Scan with the phone’s camera or AmneziaVPN' + : 'Import the file in AmneziaWG or AmneziaVPN', + way?.el, + tabs, + body, + d.handshake ? liveLine(d) : null, + ); + sheetClosed = () => { + stop(); + if (state) main(state); }; - paintLive(d); - // Only while the first connection is awaited (every poll is a process on - // the router): 5 s at first, then slower, for ten minutes at most, not - // while the tab is hidden, and never again once the link stopped working - // (a replaced link would otherwise count as guesses from this network). +} + +/** How a device that connected before is doing: one line under the sheet. */ +function liveLine(d: Device): HTMLElement { + return h( + 'div', + { class: 'waiting' }, + d.online ? h('span', { class: 'ok' }, 'Connected') : h('span', { class: 'muted' }, `Last connected ${ago(d.handshake, now())}`), + ); +} + +/** + * The first connection arrived. The way fills green (the sheet goes back up to + * it if it was scrolled) and says so; then everything under it, which did its + * job, folds shut like an accordion while the sheet's edge comes up with it. + * Two seconds to read the way, and the sheet closes by itself onto the page + * (repainted, see catchUp). + */ +async function arrive(way: Way, rest: HTMLElement[]) { + way.connected(); + way.el.closest('.sheet-panel')?.scrollTo({ top: 0, behavior: calm() ? 'auto' : 'smooth' }); + await beat(400); + await Promise.all(rest.map((el) => fold(el))); + // Reading time, not motion: the same with less motion. + await new Promise((r) => setTimeout(r, 2000)); + // Only this sheet: not one the visitor went on to (a swap leaves the way in a ghost). + if (sheetEl?.contains(way.el) && !way.el.closest('.ghost')) closeSheet(); +} + +/** + * The first connection was seen (a fresh handshake) before the agent's watcher + * marked the device online, a second at most: ask again shortly, a few times, + * and repaint the page with the answer (unless a sheet or menu is open; closing + * it repaints), so the card goes on to "Connected" instead of staying on + * "Last connected just now". + */ +function catchUp(id: string, tries = 4) { + window.setTimeout(async () => { + try { + const st = await call('state'); + state = st; + if (!sheetEl && !menuEl) main(st); + if (!st.person.devices.find((x) => x.id === id)?.online && tries > 1) catchUp(id, tries - 1); + } catch { + /* a hiccup: the page keeps the last answer, as on load */ + } + }, 1500); +} + +/** + * Poll for the first connection of a device that never connected: 5 s at + * first, then slower, for ten minutes at most (then `gaveUp`), not while the + * tab is hidden (every poll is a process on the router), and never again once + * the link stopped working. `arrived` runs once. Returns the stop function. + */ +function watchFirstConnection(d: Device, arrived: () => void, gaveUp: () => void): () => void { + // The first connection is a handshake newer than this sheet (router clock), not `online`: + // that follows the agent's watcher, which can lag the handshake by a poll, and a device + // set up again with new keys still reports the last handshake of its old ones. + const opened = now(); let timer = 0, polls = 0, - done = !!d.handshake || d.disabled; + done = false; const started = Date.now(); const poll = async () => { timer = 0; - if (done || Date.now() - started > 600_000) return; + if (done) return; + if (Date.now() - started > 600_000) { + done = true; + gaveUp(); + return; + } if (document.hidden) { schedule(); return; @@ -900,9 +1354,10 @@ async function connect(d: Device, initial?: 'app' | 'qr' | 'key' | 'file', cfgIn const st = await call('state'); state = st; const dev = st.person.devices.find((x) => x.id === d.id); - paintLive(dev); - if (dev?.online || dev?.handshake) { + if (dev && dev.handshake > opened) { done = true; + arrived(); + if (!dev.online) catchUp(d.id); return; } } catch (e) { @@ -922,17 +1377,476 @@ async function connect(d: Device, initial?: 'app' | 'qr' | 'key' | 'file', cfgIn }; document.addEventListener('visibilitychange', onVisible); schedule(); - sheet( - d.handshake ? `Connect ${d.name}` : `${d.name} is ready`, - mobile ? 'Add it to AmneziaVPN on this phone' : 'Scan with the phone’s camera or AmneziaVPN', - tabs, - body, - live, - ); - sheetClosed = () => { + return () => { done = true; if (timer) clearTimeout(timer); document.removeEventListener('visibilitychange', onVisible); + }; +} + +/* ---------- setting up a device: get the app, add the connection ---------- */ + +/** The app a device was set up with last time, so the sheet reopens on it. */ +const APP_MEMO = (d: Device) => `dl.app.${d.id}`; +function recallApp(d: Device): AppId | null { + try { + const v = localStorage.getItem(APP_MEMO(d)); + return v === 'vpn' || v === 'awg' || v === 'wg' ? v : null; + } catch { + return null; + } +} +function rememberApp(d: Device, app: AppId) { + try { + localStorage.setItem(APP_MEMO(d), app); + } catch { + /* private mode */ + } +} + +const APP_ICON: Record = { vpn: 'amnezia', awg: 'amneziawg', wg: 'wireguard' }; + +/** + * A store badge: the mark in a tile, two lines, a chevron. `primary` = the one thing to tap. + * `key` names it across repaints, so a badge that now says something else comes into focus. + */ +function badge( + st: { href?: string; top: string; main: string; mark: string; onclick?: (ev: Event) => void }, + primary = false, + key?: string, +): HTMLElement { + const inner = [ + h('span', { class: 'badge-ic' }, ic(st.mark)), + h('span', { class: 'badge-txt' }, h('span', { class: 'badge-top' }, st.top), h('span', { class: 'badge-main' }, st.main)), + h('span', { class: 'badge-chev' }, ic('chevron')), + ]; + const cls = `badge${primary ? ' primary' : ''}`; + return st.onclick + ? h('button', { type: 'button', class: cls, onclick: st.onclick, 'data-m': key }, inner) + : h( + 'a', + { class: cls, href: st.href, target: st.href?.startsWith('vpn:') ? null : '_blank', rel: 'noopener noreferrer', 'data-m': key }, + inner, + ); +} + +/** Choice pills: an icon and a label each, one on. `group` keys them across repaints. */ +function pills(group: string, items: { id: string; label: string; icon?: string; on: boolean; pick: () => void }[]): HTMLElement { + return h( + 'div', + { class: 'pills' }, + items.map((it) => + h( + 'button', + { type: 'button', class: `pill${it.on ? ' on' : ''}`, onclick: it.pick, 'data-m': `${group}:${it.id}` }, + it.icon ? ic(it.icon) : null, + h('span', {}, it.label), + ), + ), + ); +} + +/** The step card: a numbered head and its content. */ +const step = (n: string, title: Kid, ...content: Kid[]) => + h( + 'div', + { class: 'step' }, + h('div', { class: 'step-head' }, h('span', { class: 'step-n' }, n), h('span', { class: 'step-title' }, title)), + ...content, + ); + +/** A link as text with Copy and, where the browser has one, the share sheet. */ +function linkRow(url: string): HTMLElement { + const share = typeof navigator.share === 'function'; + return h( + 'div', + { class: 'linkrow' }, + h('span', { class: 'mono ellipsis' }, url.replace(/^https?:\/\//, '')), + h('button', { type: 'button', class: 'btn small', onclick: (ev: Event) => copy(url, 'Link copied', ev.currentTarget) }, 'Copy'), + share + ? h( + 'button', + { + type: 'button', + class: 'icon-btn soft', + 'aria-label': 'Share the link', + onclick: () => navigator.share({ url, title: state?.title ?? 'Dawnline' }).catch(() => undefined), + }, + ic('share'), + ) + : null, + ); +} + +/** + * Set up a device: one sheet, two numbered steps. Which app and where it comes + * from follow the server's disguise and the platform the page is open on; a + * device set up from another device gets its link (and code) to take there. + */ +async function setup(d: Device, cfgIn?: ClientConfig) { + const cfg = cfgIn ?? (await getConfig(d)); + if (!cfg) return; + const key = await vpnKey(cfg, `${cfg.server} · ${cfg.name}`); + const apps = appsFor(preset()); + const pf = platform(); + const same = sameDevice(d.kind, pf); + const handheld = d.kind === 'phone' || d.kind === 'tablet'; + const router = d.kind === 'router'; + const hereHandheld = pf === 'ios' || pf === 'android'; + const osChoices = osGroup(d.kind); + let app: AppId = recallApp(d) ?? (router ? 'awg' : 'vpn'); + if (!apps.some((a) => a.id === app)) app = router ? 'awg' : 'vpn'; + // Which system a computer runs is the person's call; the browser's guess comes first. + let os: Platform = osChoices.length ? (osChoices.includes(pf) ? pf : 'windows') : pf; + let picker = false, + away = false, + open: 'link' | 'app' = 'app', + entered: string | null = null; + const body = h('div', { class: 'setup' }); + const way = waitPath(d.kind); + // The title names the device; the lines under it say "the phone". + const there = deviceNoun(d.kind); + // The device connected: the instructions are leaving, no repaint brings them back. + let finished = false; + + const appOf = (id: AppId) => apps.find((a) => a.id === id) ?? apps[0]; + const appPills = () => + pills( + 'app', + apps + .filter((a) => !router || a.id !== 'vpn') + .map((a) => ({ + id: a.id, + label: a.name, + icon: APP_ICON[a.id], + on: a.id === app, + pick: () => { + app = a.id; + rememberApp(d, app); + paint(); + }, + })), + ); + const osPills = () => + pills( + 'os', + osChoices.map((o) => ({ + id: o, + label: o === pf ? hereLabel(o) : PLATFORM_LABEL[o], + icon: o === 'windows' ? 'windows' : o === 'mac' ? 'apple' : 'linux', + on: o === os, + pick: () => { + os = o; + paint(); + }, + })), + ); + const storeBlock = (): Kid[] => { + const st: Store | null = router ? routerStore(app) : storeFor(app, os); + if (!st) return [h('span', { class: 'muted s' }, `Get ${APP_NAME[app]} on the ${PLATFORM_LABEL[os]} and come back here.`)]; + return [ + st.alt + ? [ + h('div', { class: 'badges2' }, badge(st, false, 'store'), badge(st.alt, false, 'store-alt')), + h('span', { class: 'faint s' }, st.alt.why), + ] + : badge(st, false, 'store'), + updateLine(appOf(app)) ? h('span', { class: 'faint s', 'data-m': 'update' }, updateLine(appOf(app))) : null, + ]; + }; + const getStep = () => + step( + '1', + [ + h('span', { class: 'grow', 'data-m': 'get' }, `Get ${APP_NAME[app]}`), + apps.length > 1 && !picker + ? h( + 'button', + { + type: 'button', + class: 'pill-link', + onclick: () => { + picker = true; + entered = 'picker'; + paint(); + }, + }, + h('span', {}, 'Another app'), + ic('chevron'), + ) + : null, + ], + picker + ? h( + 'div', + { class: `stack gap${entered === 'picker' ? ' enter' : ''}` }, + appPills(), + h('span', { class: 'faint s', 'data-m': 'app-sub' }, appOf(app).sub), + ) + : null, + osChoices.length ? osPills() : null, + ...storeBlock(), + ); + + // Step 2 follows the app and the device: a link for AmneziaVPN, the file for the others. + const connectStep = () => { + const name = APP_NAME[app]; + if (app === 'vpn' && hereHandheld) + return step( + '2', + 'Add the connection', + badge({ href: key, top: 'Then come back here and tap', main: 'Open in AmneziaVPN', mark: 'amnezia' }, true, 'connect'), + h( + 'span', + { class: 'faint s' }, + 'Nothing opened? ', + h('a', { href: '#', onclick: (ev: Event) => (ev.preventDefault(), copy(key, 'Key copied', ev.currentTarget)) }, 'Copy the key'), + ' and add it in the app.', + ), + ); + if (app === 'vpn') + return step( + '2', + 'Add the connection', + badge( + { + top: 'The connection as one key', + main: 'Copy the key', + mark: 'copy', + onclick: (ev) => copy(key, 'Key copied', ev.currentTarget), + }, + true, + 'connect', + ), + h( + 'ol', + { class: 'howto', 'data-m': 'howto' }, + h('li', {}, 'Open AmneziaVPN'), + h('li', {}, 'Add server → ', h('b', {}, 'Insert key')), + h('li', {}, 'Paste the key and connect'), + ), + h('span', { class: 'faint s' }, 'Have the app open? ', h('a', { href: key }, 'Open in AmneziaVPN')), + ); + const share = hereHandheld ? shareFile(cfg) : null; + return step( + '2', + 'Add the connection', + share + ? badge({ top: `Straight into ${name}`, main: 'Share the file', mark: 'share', onclick: () => share() }, true, 'connect') + : badge( + { + top: 'Then import it in the app', + main: 'Download the file', + mark: 'download', + onclick: () => download(cfg.filename, cfg.conf), + }, + true, + 'connect', + ), + h( + 'ol', + { class: 'howto', 'data-m': 'howto' }, + h('li', {}, `Open ${name}`), + h('li', {}, importPath(app).replace(/ → .*$/, ' → '), h('b', {}, importPath(app).replace(/^.* → /, ''))), + h('li', {}, share ? 'Confirm the import and connect' : 'Pick the file and connect'), + ), + ); + }; + + /** + * Two cards that hold codes, one open at a time: a folded card's head is the + * button that opens it (and folds the other); the open card's head is just a head. + */ + const foldHead = (id: 'link' | 'app', ...title: Kid[]) => + open === id + ? h('div', { class: 'step-head open', 'data-m': `fold:${id}` }, ...title) + : h( + 'button', + { + type: 'button', + class: 'step-head fold', + 'aria-expanded': 'false', + 'data-m': `fold:${id}`, + onclick: () => { + open = id; + entered = id; + paint(); + }, + }, + ...title, + h('span', { class: 'fold-chev' }, ic('chevron')), + ); + // A code keyed by what it encodes: one that now holds something else comes into focus. + const qrOf = (mark: string, text: string) => { + const q = h('div', { 'data-m': mark, 'data-sig': `${text.length}:${text.slice(-24)}` }); + paintQr(q, text); + return q; + }; + + /** What a card just unfolded comes in one piece after the other. */ + const unfolded = (now: boolean, kids: (HTMLElement | null)[]) => { + if (now) + kids + .filter((k): k is HTMLElement => !!k) + .forEach((k, i) => { + k.classList.add('unfold'); + k.style.setProperty('--i', String(i)); + }); + return kids; + }; + + // Not on the device: the link goes there (as a code for a phone's camera), the rest happens there. + // It names the device, so the page there opens straight on its set-up. + const linkThere = setupLink(location.origin + location.pathname, d.id); + const awayCard = (easiest = false, fold = false) => + h( + 'div', + { class: `step${fold && open !== 'link' ? ' folded' : ''}` }, + fold + ? foldHead( + 'link', + h('span', { class: 'step-title grow' }, `Open your link on the ${there}`), + easiest ? h('span', { class: 'chip', 'data-glide': 'easiest' }, 'Easiest') : null, + ) + : h( + 'div', + { class: 'step-head' }, + h('span', { class: 'step-title grow' }, `Open your link on the ${there}`), + easiest ? h('span', { class: 'chip' }, 'Easiest') : null, + ), + ...(fold && open !== 'link' + ? [] + : unfolded(entered === 'link', [ + h('span', { class: 'muted s step-sub' }, 'The same page there does both steps for that device.'), + handheld + ? h( + 'div', + { class: 'code-row' }, + qrOf('link-qr', linkThere), + h( + 'span', + { class: 'stack gap' }, + h('span', { class: 'muted s' }, 'Point its camera at the code: the link opens there.'), + qrFlip(), + ), + ) + : null, + linkRow(linkThere), + ])), + ); + const awayFold = () => + away + ? (() => { + const c = awayCard(); + if (entered === 'away') c.classList.add('enter'); + return c; + })() + : h( + 'div', + { class: 'center' }, + h( + 'button', + { + type: 'button', + class: 'fold-link', + onclick: () => { + away = true; + entered = 'away'; + paint(); + }, + }, + `Not on the ${there} right now?`, + ), + ); + + // A phone set up from a computer: the link as a code, or the connection as a code for a phone that has the app. + const appCodeCard = () => + h( + 'div', + { class: `step${open !== 'app' ? ' folded' : ''}` }, + foldHead('app', h('span', { class: 'step-ic' }, ic(APP_ICON[app])), h('span', { class: 'step-title grow' }, 'Already has the app')), + ...(open !== 'app' + ? [] + : unfolded(entered === 'app', [ + apps.length > 1 ? h('div', {}, appPills()) : null, + h( + 'div', + { class: 'code-row' }, + qrOf('app-qr', app === 'vpn' ? key : cfg.conf), + h( + 'span', + { class: 'stack' }, + h('span', { class: 'muted s' }, `In ${APP_NAME[app]}: `, h('b', {}, scanPath(app)), '. The connection is added at once.'), + updateLine(appOf(app)) ? h('span', { class: 'faint s' }, updateLine(appOf(app))) : null, + qrFlip(), + ), + ), + h( + 'span', + { class: 'faint s' }, + 'Prefer the file or the key? ', + h('a', { href: '#', onclick: (ev: Event) => (ev.preventDefault(), connect(d, 'file', cfg)) }, 'Connection details'), + ), + ])), + ); + + const paint = () => { + if (finished) return; + const parts: Kid[] = []; + if (inWebview(navigator.userAgent)) + parts.push( + h( + 'div', + { class: 'notice' }, + ic('alert'), + h('span', { class: 'grow' }, 'Open this page in Safari or Chrome: the store opens from here, but the app handoff does not.'), + ), + ); + if (same) parts.push(getStep(), connectStep(), awayFold()); + else if (router) + parts.push( + step( + '1', + [h('span', { class: 'grow', 'data-m': 'get' }, `Get ${APP_NAME[app]} on the router`)], + apps.length > 2 ? appPills() : null, + badge(routerStore(app), false, 'store'), + ), + step('2', 'Import the configuration', filePane(cfg)), + ); + else if (handheld) parts.push(awayCard(true, true), appCodeCard()); + else + parts.push( + h('span', { class: 'muted s' }, `The app goes on the ${there}. Which one is it?`), + osPills(), + awayCard(true), + step( + '', + [h('span', { class: 'grow', 'data-m': 'get' }, `${APP_NAME[app]} for ${PLATFORM_LABEL[os]}`)], + h('span', { class: 'faint s' }, 'Or download the installer here and move it to the PC'), + ...storeBlock(), + ), + h( + 'span', + { class: 'faint s center' }, + `Already has ${APP_NAME[app]}? `, + h('a', { href: '#', onclick: (ev: Event) => (ev.preventDefault(), copy(key, 'Key copied', ev.currentTarget)) }, 'Copy the key'), + ), + ); + restyle(body, () => body.replaceChildren(...parts.flat().filter((x): x is Node => x instanceof Node))); + entered = null; + }; + paint(); + const stop = watchFirstConnection( + d, + () => { + finished = true; + void arrive(way, [body]); + }, + way.gaveUp, + ); + sheet(`Set up ${d.name}`, same ? 'Two steps, about a minute' : router ? 'The packages and the file for OpenWrt' : null, way.el, body); + sheetClosed = () => { + stop(); if (state) main(state); }; } @@ -971,73 +1885,51 @@ function rename(d: Device) { /** New keys for a device: the old configuration stops working, the new one is shown right away. */ function rotateKeys(d: Device, st: State) { - const here = st.here === d.id; - sheet( - `New keys for ${d.name}?`, - null, - h( - 'p', - { class: 'muted' }, - here - ? 'This device is connected through the configuration it has now: it disconnects a few seconds after you confirm. Import the new configuration that opens next.' - : 'Its current configuration stops working. Set the device up again with the new one that opens next.', - ), - h( - 'div', - { class: 'row gap' }, - h('button', { class: 'btn block', onclick: () => closeSheet() }, 'Cancel'), - h( - 'button', - { - class: 'btn primary block', - onclick: (ev: Event) => - once(ev.currentTarget as HTMLButtonElement, async () => { - try { - const r = await call<{ config: ClientConfig; state: State }>(`devices/${d.id}`, { action: 'rotate' }); - state = r.state; - main(state); - await connect(d, undefined, r.config); - } catch (er) { - toast((er as Error).message, true); - } - }), - }, - 'New keys', - ), - ), - ); + ask({ + icon: 'key', + tone: 'warn', + title: `New keys for ${d.name}?`, + text: + st.here === d.id + ? 'This device is connected through its current settings: it disconnects a few seconds after you confirm. Import the new ones that open next.' + : 'Its current settings stop working. Set it up again with the new ones that open next.', + action: 'New keys', + actionClass: 'primary', + run: async () => { + try { + const r = await call<{ config: ClientConfig; state: State }>(`devices/${d.id}`, { action: 'rotate' }); + state = r.state; + main(state); + await setup({ ...d, handshake: 0 }, r.config); + } catch (er) { + toast((er as Error).message, true); + } + }, + }); } function removeDevice(d: Device) { - sheet( - `Remove ${d.name}?`, - null, - h('p', { class: 'muted' }, 'Its connection stops working immediately. You can add it again later.'), - h( - 'div', - { class: 'row gap' }, - h('button', { class: 'btn block', onclick: () => closeSheet() }, 'Cancel'), - h( - 'button', - { - class: 'btn danger-solid block', - onclick: (ev: Event) => - once(ev.currentTarget as HTMLButtonElement, async () => { - try { - const r = await call<{ state: State }>(`devices/${d.id}`, { action: 'delete' }); - state = r.state; - closeSheet(); - main(state); - toast('Device removed'); - } catch (er) { - toast((er as Error).message, true); - } - }), - }, - 'Remove', - ), - ), - ); + ask({ + icon: 'trash', + tone: 'bad', + title: `Remove ${d.name}?`, + text: 'Its connection stops working at once. You can add it again later.', + action: 'Remove', + actionClass: 'danger-solid', + run: async () => { + try { + const r = await call<{ state: State }>(`devices/${d.id}`, { action: 'delete' }); + state = r.state; + closeSheet(); + // The card goes first; the rest then glide into its place. + await leave(app.querySelector(`[data-key="${CSS.escape(d.id)}"]`)); + main(state); + toast('Device removed'); + } catch (er) { + toast((er as Error).message, true); + } + }, + }); } // Best guess at the device this page is open on (the browser never tells its real name). @@ -1153,24 +2045,29 @@ function addDevice() { onsubmit: async (e: Event) => { e.preventDefault(); submit.disabled = true; + const idle = busy(submit); err.textContent = ''; try { const r = await call<{ id: string; config: ClientConfig; state: State }>('devices', { name: name.value.trim(), kind }); state = r.state; const dev = r.state.person.devices.find((d) => d.id === r.id)!; - await connect(dev, undefined, r.config); + await setup(dev, r.config); } catch (er) { if ((er as ApiError).httpsUrl) { secureSheet((er as ApiError).httpsUrl as string); return; } err.textContent = (er as Error).message; + replay(err, 'enter'); submit.disabled = false; + } finally { + idle(); } }, }, h('label', { class: 'lbl' }, 'What is it?'), kinds, + h('p', { class: 'muted s' }, 'Phones and tablets get a smaller packet size that suits mobile networks.'), h('label', { class: 'lbl' }, 'Name'), name, err, @@ -1181,11 +2078,27 @@ function addDevice() { /* ---------- boot ---------- */ +/** + * A link that names a device (`#setup=d_…`: the code and the link a set-up + * sheet hands to that device) opens its set-up at once, if it still waits for + * one: on load, or when the link is opened in a tab already on this page. + * Once: the fragment comes off the address (a reload shows the page). + */ +window.addEventListener('hashchange', () => openFromLink()); +function openFromLink() { + const id = setupFromHash(location.hash); + if (!id) return; + history.replaceState(null, '', location.pathname + location.search); + const d = state?.person.devices.find((x) => x.id === id); + if (d && !d.handshake && !d.disabled && !state?.locked) void setup(d); +} + async function refresh() { try { state = await call('state'); document.title = `${state.person.name} · ${state.title}`; if (!sheetEl && !menuEl) main(state); + openFromLink(); } catch (e) { const er = e as ApiError; if (er.status === 404 || er.status === 401) { diff --git a/web/src/portal/motion.ts b/web/src/portal/motion.ts new file mode 100644 index 0000000..e72b65e --- /dev/null +++ b/web/src/portal/motion.ts @@ -0,0 +1,496 @@ +// Portal motion: the moves between two states the DOM alone would snap +// between — a sheet's height following its content, cards that changed place +// after a repaint, a pane swapped for another, a sheet pulled down, a copy +// button saying it worked. This module measures and starts them; the curves, +// durations and every one-shot keyframe live in portal.css ("Motion"). +// +// Everything checks `calm()` (prefers-reduced-motion) and then only fades. +// The pure decisions (rubber band, when a pull dismisses) are exported for tests. + +/** The visitor asked for less motion: fades only, nothing travels. */ +export const calm = (): boolean => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches; + +/** The curves of portal.css, for animations started from script. */ +const EASE = { + out: 'cubic-bezier(0.23, 1, 0.32, 1)', + in: 'cubic-bezier(0.55, 0, 1, 0.45)', + drawer: 'cubic-bezier(0.32, 0.72, 0, 1)', +}; + +/** + * A block inside a sheet animating its own height: the sheet's edge follows it + * frame by frame on its own, so followHeight holds off meanwhile (a count: + * several such blocks may move at once). + */ +function hold(el: Element): () => void { + const panel = el.closest('.sheet-panel'); + if (!panel) return () => undefined; + panel.dataset.hold = String(+(panel.dataset.hold ?? 0) + 1); + return () => { + const n = +(panel.dataset.hold ?? 1) - 1; + if (n > 0) panel.dataset.hold = String(n); + else delete panel.dataset.hold; + }; +} + +/** Distance past an edge → how far it actually goes: resistance grows with the pull. */ +export function rubber(dist: number, dim: number): number { + return dist <= 0 || dim <= 0 ? 0 : (1 - 1 / ((dist * 0.55) / dim + 1)) * dim; +} + +/** + * Does a pulled sheet go away? A flick down (px/ms, as Vaul) or a pull past a + * third of its height does; a flick back up keeps it, however far it went. + */ +export function dismisses(dy: number, velocity: number, height: number): boolean { + if (dy <= 0 || velocity < -0.1) return false; + return velocity > 0.4 || dy > height / 3; +} + +/** A height change takes longer the further it goes, inside the house range. */ +export const morphMs = (dist: number): number => Math.round(Math.min(380, Math.max(220, 200 + dist * 0.35))); + +/** Restart a one-shot CSS animation class on an element that already had it. */ +export function replay(el: Element, cls: string) { + el.classList.remove(cls); + void (el as HTMLElement).offsetWidth; + el.classList.add(cls); +} + +/** + * Keep `panel`'s size following `content`: whatever changes inside (a tab, a + * fold, a whole new sheet), the panel eases from the height it shows to the new + * one instead of jumping. Interruptible: a change mid-way starts from where it + * is. A width change (a window resize) only records, unless the panel asked for + * it (`data-morph="width"`: a question turning into a sheet), and then width + * and height morph together. Returns the stop. + */ +export function followHeight(panel: HTMLElement, content: HTMLElement): () => void { + let lastH = 0, + lastW = 0, + widthToo = false; + let anim: Animation | null = null; + const ro = new ResizeObserver(() => { + // Something inside moves its own height (hold): only keep up with the size. + if (panel.dataset.hold) { + anim?.cancel(); + panel.classList.remove('morphing', 'morphing-w'); + lastH = panel.offsetHeight; + lastW = panel.offsetWidth; + return; + } + const cs = getComputedStyle(panel); + const shownH = anim ? parseFloat(cs.height) : lastH; + const shownW = anim ? parseFloat(cs.width) : lastW; + anim?.cancel(); + // Measure the natural size: without the uncapped width of a morph still under way. + panel.classList.remove('morphing', 'morphing-w'); + const h = panel.offsetHeight, + w = panel.offsetWidth; + // Asked now, or still on its way from an earlier ask. + const asked = panel.dataset.morph === 'width' || widthToo; + delete panel.dataset.morph; + const resized = lastW !== 0 && w !== lastW; + lastH = h; + lastW = w; + if (!shownH || calm() || (resized && !asked)) return; + const dh = Math.abs(h - shownH), + dw = asked ? Math.abs(w - shownW) : 0; + if (dh < 2 && dw < 2) return; + widthToo = dw >= 2; + panel.classList.add('morphing'); + panel.classList.toggle('morphing-w', widthToo); + const a = panel.animate( + widthToo + ? [ + { height: `${shownH}px`, width: `${shownW}px` }, + { height: `${h}px`, width: `${w}px` }, + ] + : [{ height: `${shownH}px` }, { height: `${h}px` }], + { duration: morphMs(Math.max(dh, dw)), easing: EASE.out }, + ); + anim = a; + const done = () => { + if (anim !== a) return; + anim = null; + widthToo = false; + panel.classList.remove('morphing', 'morphing-w'); + }; + a.onfinish = done; + a.oncancel = done; + }); + ro.observe(content); + return () => ro.disconnect(); +} + +/** + * Swap `box`'s content for `next`: the old content fades out where it was + * (lifted out of the flow, so the box already takes the new height) while the + * new one comes in. `dir` -1 / 1: the new content comes from the left / right. + */ +export function swap(box: HTMLElement, next: Node[], dir = 0) { + const old = [...box.childNodes]; + if (!old.length || !box.isConnected) { + box.replaceChildren(...next); + return; + } + // The ghost lays the old content out as the box did, over the box's padding edge. + const cs = getComputedStyle(box); + const ghost = document.createElement('div'); + ghost.className = 'ghost'; + ghost.setAttribute('aria-hidden', 'true'); + ghost.inert = true; + Object.assign(ghost.style, { + display: cs.display === 'flex' ? 'flex' : 'block', + flexDirection: cs.flexDirection, + alignItems: cs.alignItems, + gap: cs.gap, + top: cs.paddingTop, + left: cs.paddingLeft, + right: cs.paddingRight, + }); + ghost.append(...old); + box.replaceChildren(ghost, ...next); + // The old content drops away fast (it sits under the new one, see .ghost) so the two never read together. + const still = calm(); + const out = ghost.animate( + [ + { opacity: 1, transform: 'none' }, + { opacity: 0, transform: still ? 'none' : `translateX(${-dir * 8}px)` }, + ], + { duration: 120, easing: EASE.out, fill: 'forwards' }, + ); + const drop = () => ghost.remove(); + out.onfinish = drop; + out.oncancel = drop; + for (const n of next) + if (n instanceof HTMLElement) + n.animate( + still + ? [{ opacity: 0 }, { opacity: 1 }] + : [ + { opacity: 0, transform: `translate(${dir * 12}px, ${dir ? 0 : 6}px)`, filter: 'blur(4px)' }, + { opacity: 1, transform: 'none', filter: 'blur(0)' }, + ], + { duration: still ? 160 : 280, delay: 50, easing: EASE.out, fill: 'backwards' }, + ); +} + +/** Play an element's way out before it is removed (it keeps its place until then). */ +export function leave(el: Element | null | undefined): Promise { + if (!el || !el.isConnected) return Promise.resolve(); + const a = el.animate( + calm() + ? [{ opacity: 1 }, { opacity: 0 }] + : [ + { opacity: 1, transform: 'none', filter: 'blur(0)' }, + { opacity: 0, transform: 'scale(0.96)', filter: 'blur(4px)' }, + ], + { duration: 200, easing: EASE.in, fill: 'forwards' }, + ); + return a.finished.then( + () => undefined, + () => undefined, + ); +} + +/** A beat between the steps of a sequence; none when the visitor asked for less motion. */ +export const beat = (ms: number): Promise => new Promise((r) => setTimeout(r, calm() ? 0 : ms)); + +/** + * The accordion's look: the height closes on the drawer curve over `ms`; the + * content dissolves faster, from the start, as blocks leave elsewhere (blur, a + * small rise and shrink, on the strong ease-out over `contentMs`). + */ +const FOLD = { ms: 520, contentMs: 300, blur: 4, drift: 6, scale: 0.98 }; + +/** + * Fold a block shut like an accordion and take it out: its height closes from + * the bottom edge (the sheet's edge comes with it) while its content dissolves + * into a blur. Less motion: it fades. + */ +export async function fold(el: HTMLElement): Promise { + if (!el.isConnected) return; + const release = hold(el); + const gap = parseFloat(getComputedStyle(el.parentElement as HTMLElement).rowGap) || 0; + const h = el.offsetHeight; + el.style.overflow = 'hidden'; + el.style.transformOrigin = '50% 0'; + el.inert = true; + const done = () => undefined; + if (calm()) + await el.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 160, easing: EASE.out, fill: 'forwards' }).finished.then(done, done); + else { + el.animate( + [ + { opacity: 1, filter: 'blur(0px)', transform: 'none' }, + { opacity: 0, filter: `blur(${FOLD.blur}px)`, transform: `translateY(${-FOLD.drift}px) scale(${FOLD.scale})` }, + ], + { duration: FOLD.contentMs, easing: EASE.out, fill: 'forwards' }, + ); + await el + .animate( + [ + { height: `${h}px`, marginTop: '0px' }, + { height: '0px', marginTop: `${-gap}px` }, + ], + { duration: FOLD.ms, easing: EASE.drawer, fill: 'forwards' }, + ) + .finished.then(done, done); + } + el.remove(); + release(); +} + +/** + * The opposite, for a line that just got something to say: it opens from no + * height to its own (the sheet's edge comes with it) and comes into focus. + */ +export function grow(el: HTMLElement) { + if (!el.isConnected || calm()) return replay(el, 'swap'); + const release = hold(el); + const gap = parseFloat(getComputedStyle(el.parentElement as HTMLElement).rowGap) || 0; + const h = el.offsetHeight; + el.style.overflow = 'hidden'; + const a = el.animate( + [ + { height: '0px', marginTop: `${-gap}px`, opacity: 0, filter: 'blur(4px)' }, + { height: `${h}px`, marginTop: '0px', opacity: 1, filter: 'blur(0px)' }, + ], + { duration: 380, easing: EASE.drawer }, + ); + const end = () => { + el.style.overflow = ''; + release(); + }; + a.onfinish = end; + a.oncancel = end; +} + +/** + * The page's first paint: the blocks matching `selector` rise in, in reading + * order (top to bottom, then left to right, whatever the layout), at most + * eight steps apart. portal.css draws `.intro`; `--i` is the step. + */ +export function intro(root: ParentNode, selector: string) { + const els = [...root.querySelectorAll(selector)].map((el) => ({ el, r: el.getBoundingClientRect() })); + els.sort((a, b) => Math.round(a.r.top - b.r.top) || a.r.left - b.r.left); + els.forEach(({ el }, i) => { + el.style.setProperty('--i', String(Math.min(i, 8))); + el.classList.add('intro'); + }); +} + +/** Where the keyed blocks of a page are and what its keyed values say, before a repaint. */ +export interface Snap { + at: Map; + text: Map; +} + +export function snap(root: ParentNode): Snap { + const at = new Map(); + const text = new Map(); + root.querySelectorAll('[data-key]').forEach((el) => { + const r = el.getBoundingClientRect(); + at.set(el.dataset.key as string, { x: r.left + scrollX, y: r.top + scrollY }); + }); + root.querySelectorAll('[data-v]').forEach((el) => text.set(el.dataset.v as string, el.textContent ?? '')); + return { at, text }; +} + +/** + * After a repaint: a keyed block that moved glides from where it was (FLIP), + * one that is new rises in, a keyed value that changed comes into focus. + * Keyed blocks are never nested, so no move is counted twice. + */ +export function settle(root: ParentNode, before: Snap) { + const still = calm(); + root.querySelectorAll('[data-key]').forEach((el) => { + const was = before.at.get(el.dataset.key as string); + if (!was) { + el.classList.add('enter'); + return; + } + if (still) return; + const r = el.getBoundingClientRect(); + const dx = was.x - (r.left + scrollX), + dy = was.y - (r.top + scrollY); + if (Math.abs(dx) < 1 && Math.abs(dy) < 1) return; + el.animate([{ transform: `translate(${dx}px, ${dy}px)` }, { transform: 'none' }], { + duration: morphMs(Math.hypot(dx, dy)), + easing: EASE.out, + }); + }); + root.querySelectorAll('[data-v]').forEach((el) => { + const was = before.text.get(el.dataset.v as string); + if (was != null && was !== el.textContent) el.classList.add('swap'); + }); +} + +/** + * A repaint of a sheet's content that keeps its motion: keyed controls + * (`data-m`) that flipped on or off get `to-on` / `to-off`, whose keyframes + * start from the other look; one whose text changed comes into focus (`swap`); + * one marked `data-glide` that moved within its parent (a chip beside a chevron + * that went) glides there. + */ +export function restyle(root: ParentNode, paint: () => void) { + const state = (el: Element) => el.classList.contains('on') || el.classList.contains('open'); + // What it says: its text, or `data-sig` where the text says nothing (a QR code). + const says = (el: HTMLElement) => el.dataset.sig ?? el.textContent ?? ''; + const inParent = (el: HTMLElement) => { + const r = el.getBoundingClientRect(), + p = (el.parentElement as HTMLElement).getBoundingClientRect(); + return { x: r.left - p.left, y: r.top - p.top }; + }; + const before = new Map(); + root.querySelectorAll('[data-m]').forEach((el) => before.set(el.dataset.m as string, { on: state(el), says: says(el) })); + const placed = new Map(); + root.querySelectorAll('[data-glide]').forEach((el) => placed.set(el.dataset.glide as string, inParent(el))); + paint(); + if (!calm()) + root.querySelectorAll('[data-glide]').forEach((el) => { + const was = placed.get(el.dataset.glide as string); + if (!was) return; + const now = inParent(el); + const dx = was.x - now.x, + dy = was.y - now.y; + if (Math.abs(dx) >= 1 || Math.abs(dy) >= 1) + el.animate([{ transform: `translate(${dx}px, ${dy}px)` }, { transform: 'none' }], { duration: 280, easing: EASE.out }); + }); + root.querySelectorAll('[data-m]').forEach((el) => { + const was = before.get(el.dataset.m as string); + if (!was) return; + if (was.on !== state(el)) el.classList.add(state(el) ? 'to-on' : 'to-off'); + else if (was.says !== says(el)) el.classList.add('swap'); + }); +} + +/** + * A row of choices whose highlight slides to the one picked: a copy of the row + * drawn in the picked look on top, clipped to the picked button, so the colour + * changes exactly where the highlight is (clip-path tabs). The real buttons keep + * `.on`; call the returned function after changing it. + */ +export function slider(row: HTMLElement): () => void { + const hl = row.cloneNode(true) as HTMLElement; + hl.classList.add('slide-hl'); + hl.setAttribute('aria-hidden', 'true'); + hl.inert = true; + hl.removeAttribute('role'); + hl.querySelectorAll('[role]').forEach((b) => b.removeAttribute('role')); + row.classList.add('slides'); + row.appendChild(hl); + let placed = false; + const move = () => { + const on = row.querySelector(':scope > .on'); + if (!on || !row.isConnected) return; + const w = row.clientWidth, + h = row.clientHeight; + const l = on.offsetLeft, + t = on.offsetTop; + hl.classList.toggle('placed', placed); + hl.style.clipPath = `inset(${t}px ${w - l - on.offsetWidth}px ${h - t - on.offsetHeight}px ${l}px round 999px)`; + placed = true; + }; + // Fonts and the sheet's own layout settle after the first call: place it again, without a glide. + new ResizeObserver(() => { + placed = false; + move(); + }).observe(row); + return move; +} + +/** A copy button in its "Copied" moment: what to put back, and when. */ +const COPIED = new WeakMap(); + +/** + * A copy button says it worked where the finger is: its icon turns into a + * check and a "Copy" label into "Copied", for a moment. Other labels (a host + * name on a chip) stay. `check` is the check icon's markup. + */ +export function copied(btn: HTMLElement | null | undefined, check: string) { + if (!btn) return; + const icon = btn.querySelector('.ic'); + const label = + btn.querySelector('.badge-main') ?? + btn.querySelector(':scope > span:not(.ic)') ?? + (btn.children.length ? null : btn); + const was = COPIED.get(btn) ?? { timer: 0, icon: icon?.innerHTML ?? null, label: label?.textContent ?? null }; + clearTimeout(was.timer); + const says = !!label && (label.classList.contains('badge-main') || /^copy$/i.test(was.label ?? '')); + const show = (svg: string | null, text: string | null) => { + if (icon && svg != null && icon.innerHTML !== svg) { + icon.innerHTML = svg; + replay(icon, 'swap-ic'); + } + if (label && says && text != null && label.textContent !== text) { + label.textContent = text; + replay(label, 'swap'); + } + }; + show(check, 'Copied'); + btn.classList.add('copied'); + was.timer = window.setTimeout(() => { + COPIED.delete(btn); + btn.classList.remove('copied'); + show(was.icon, was.label); + }, 1600); + COPIED.set(btn, was); +} + +/** A button waiting for the router: after a beat (no flash on a quick answer) a spinner takes the label's place. */ +export function busy(btn: HTMLElement): () => void { + const t = window.setTimeout(() => btn.classList.add('busy'), 250); + return () => { + clearTimeout(t); + btn.classList.remove('busy'); + }; +} + +/** + * Let a bottom sheet be pulled down by its grab bar and head (a question: all of it): the panel + * follows the finger (with resistance upwards), the scrim fades with it, and + * on release it either goes (`close`) or springs back. Only while `bottom()` + * (the sheet sits at the bottom: phones). The release transitions start from + * the dragged spot because the inline transform and `.dragging` go together. + */ +export function pullToClose(panel: HTMLElement, scrim: HTMLElement, close: () => void, bottom: () => boolean) { + panel.addEventListener('pointerdown', (e) => { + const t = e.target as Element; + if (!bottom() || e.button !== 0 || !t.closest('.grab, .sheet-head, .ask') || t.closest('button, a, input')) return; + const y0 = e.clientY, + h = panel.offsetHeight; + let dy = 0; + const trail: { t: number; y: number }[] = [{ t: e.timeStamp, y: e.clientY }]; + try { + panel.setPointerCapture(e.pointerId); + } catch { + /* a pointer the browser no longer tracks: the pull still follows while it is over the panel */ + } + panel.classList.add('dragging'); + const move = (ev: PointerEvent) => { + const raw = ev.clientY - y0; + dy = raw < 0 ? -rubber(-raw, h) : raw; + panel.style.transform = `translateY(${dy}px)`; + scrim.style.opacity = String(1 - Math.max(0, dy) / h); + trail.push({ t: ev.timeStamp, y: ev.clientY }); + while (trail.length > 2 && ev.timeStamp - trail[0].t > 100) trail.shift(); + }; + const up = (ev: PointerEvent) => { + panel.removeEventListener('pointermove', move); + panel.removeEventListener('pointerup', up); + panel.removeEventListener('pointercancel', up); + const first = trail[0], + last = trail[trail.length - 1]; + const v = last.t > first.t ? (last.y - first.y) / (last.t - first.t) : 0; + panel.classList.remove('dragging'); + panel.style.transform = ''; + scrim.style.opacity = ''; + if (ev.type === 'pointerup' && dismisses(dy, v, h)) close(); + }; + panel.addEventListener('pointermove', move); + panel.addEventListener('pointerup', up); + panel.addEventListener('pointercancel', up); + }); +} diff --git a/web/src/portal/portal.css b/web/src/portal/portal.css index 098f4c2..840db65 100644 --- a/web/src/portal/portal.css +++ b/web/src/portal/portal.css @@ -22,6 +22,29 @@ } :root { + /* Motion (the rules are in the "Motion" section at the end): a strong ease-out for + arrivals, an ease-in for departures, iOS's sheet curve, and two springs sampled + into linear(): `--spring` settles with a 1.5% overshoot, `--spring-pop` with 12%. */ + --ease-out: cubic-bezier(0.23, 1, 0.32, 1); + --ease-in: cubic-bezier(0.55, 0, 1, 0.45); + --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); + /* prettier-ignore */ + --spring: linear( + 0, 0.022, 0.079, 0.158, 0.249, 0.344, 0.438, 0.527, 0.61, 0.684, 0.749, 0.805, 0.852, 0.891, 0.923, 0.949, 0.969, 0.984, 0.996, 1.004, + 1.009, 1.013, 1.014, 1.015, 1.015, 1.014, 1.013, 1.012, 1.01, 1.009, 1.008, 1.006, 1.005, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1 + ); + /* prettier-ignore */ + --spring-pop: linear( + 0, 0.034, 0.122, 0.244, 0.383, 0.526, 0.662, 0.785, 0.889, 0.974, 1.038, 1.083, 1.111, 1.124, 1.126, 1.119, 1.106, 1.09, 1.072, 1.054, + 1.038, 1.023, 1.01, 1, 0.993, 0.988, 0.985, 0.984, 0.984, 0.985, 0.987, 0.989, 0.992, 0.994, 0.996, 0.998, 0.999, 1, 1.001, 1.002, 1 + ); + --dur-press: 120ms; + --dur-hover: 150ms; + --dur-pop: 180ms; + --dur-swap: 260ms; + --dur-enter: 440ms; + --dur-sheet: 440ms; + --dur-exit: 160ms; --bg: #fcfcfc; --card: #ffffff; --elevated: #ffffff; @@ -87,6 +110,10 @@ html, body { margin: 0; } +/* The page keeps its width when a sheet locks the scroll: no sideways jump behind the scrim. */ +html { + scrollbar-gutter: stable; +} body { background: var(--bg); color: var(--text); @@ -99,6 +126,16 @@ body { -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh; + /* An app, not a document: the arrow over text. Controls set the hand; what is typed + or copied by hand (fields, the key, the link, the configuration) keeps the I-beam. */ + cursor: default; +} +input, +textarea, +.keybox .mono, +.linkrow .mono, +.conf { + cursor: text; } body.locked { overflow: hidden; @@ -110,6 +147,11 @@ a { a:hover { text-decoration: underline; } +/* Links drawn as controls (store badges, buttons) stay controls: no underline on hover. */ +a.btn:hover, +a.badge:hover { + text-decoration: none; +} h1, h2 { margin: 0; @@ -535,10 +577,6 @@ h2 { .dstat.here { color: var(--info); } -.dot.here { - background: var(--accent); - box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); -} .dname { font-weight: 500; white-space: nowrap; @@ -558,33 +596,6 @@ h2 { .dstat.warn { color: var(--warn); } -.dot { - width: 6px; - height: 6px; - border-radius: 50%; - background: var(--faint); - display: inline-block; - flex: 0 0 auto; -} -.dot.ok { - background: var(--ok); - box-shadow: 0 0 0 3px var(--ok-wash); -} -.dot.warn { - background: var(--warn); -} -.dot.pulse { - animation: pulse 1.6s ease-in-out infinite; -} -@keyframes pulse { - 0%, - 100% { - box-shadow: 0 0 0 0 var(--warn-wash); - } - 50% { - box-shadow: 0 0 0 6px transparent; - } -} .duse { display: flex; align-items: flex-end; @@ -691,9 +702,6 @@ h2 { border-radius: var(--radius); color: var(--text); text-align: left; - transition: - background 0.15s, - border-color 0.15s; } .slot.add:hover { background: var(--soft); @@ -843,9 +851,9 @@ input[type='text'] { height: 44px; } input[type='text']:focus { - outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); - outline-offset: 0; + outline: none; border-color: transparent; + box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); } .lbl { display: block; @@ -874,15 +882,22 @@ input[type='text']:focus { align-items: center; justify-content: center; gap: 6px; - height: 68px; + height: 63px; min-width: 0; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); font-size: 12.5px; + /* The body's 22px would leave its leading under the letters: the label sat low, more room under it than over the icon. */ + line-height: 15px; font-weight: 500; text-align: center; } +.kind .ic { + /* The icon wrapper carries the text's line height otherwise: a gap twice the one set. */ + display: inline-flex; + line-height: 0; +} .kind .ic-svg { width: 20px; height: 20px; @@ -986,13 +1001,14 @@ input[type='text']:focus { display: flex; align-items: flex-end; justify-content: center; - background: transparent; - transition: background 0.2s; } -.sheet.open { +.scrim { + position: absolute; + inset: 0; background: var(--scrim); } .sheet-panel { + position: relative; width: 100%; max-width: 520px; max-height: 92vh; @@ -1003,11 +1019,6 @@ input[type='text']:focus { border: 1px solid var(--line); border-bottom: 0; padding: 6px 16px max(20px, env(safe-area-inset-bottom)); - transform: translateY(100%); - transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); -} -.sheet.open .sheet-panel { - transform: none; } .grab { width: 36px; @@ -1042,20 +1053,64 @@ input[type='text']:focus { border-bottom: 1px solid var(--line); padding: 20px; max-width: 480px; - transform: scale(0.97); - opacity: 0; - transition: - transform 0.18s ease, - opacity 0.18s ease; - } - .sheet.open .sheet-panel { - transform: none; - opacity: 1; } .grab { display: none; } } +/* A question before something that cannot be undone (main.ts ask): narrow and centred, + the action's icon in its colour over the question, one line of what happens, two buttons. */ +.ask { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + gap: 8px; + padding-top: 6px; +} +.ask h2 { + font-size: 18px; + line-height: 24px; + font-weight: 600; +} +.ask p { + margin: 0; + font-size: 14px; + line-height: 20px; +} +.ask-ic { + width: 52px; + height: 52px; + border-radius: 16px; + display: grid; + place-items: center; + margin-bottom: 6px; +} +.ask-ic .ic-svg { + width: 24px; + height: 24px; +} +.ask-ic.bad { + background: var(--bad-wash); + color: var(--bad); +} +.ask-ic.warn { + background: var(--warn-wash); + color: var(--warn); +} +.ask-actions { + width: 100%; + margin-top: 10px; +} +@media (min-width: 640px) { + .sheet-panel.asks { + max-width: 360px; + padding: 24px 20px 20px; + } + .ask { + padding-top: 0; + } +} .tabs { display: flex; gap: 4px; @@ -1088,9 +1143,17 @@ input[type='text']:focus { align-items: center; text-align: center; } +/* The code, night look (shared/qr): light dots on a black card with a fine outline. + `.light`: the plain look, for scanners that read only dark on light. */ .qr { width: min(240px, 70vw); aspect-ratio: 1; + background: #0a0a0a; + border-radius: 22px; + padding: 12px; + box-shadow: inset 0 0 0 1px #ffffff2e; +} +.qr.light { background: #fff; border-radius: 12px; padding: 10px; @@ -1184,7 +1247,7 @@ input[type='text']:focus { display: none; } .confbox > summary > .ic:first-child { - transition: transform 0.15s; + transition: transform 200ms var(--ease-out); color: var(--muted); } .confbox[open] > summary > .ic:first-child { @@ -1241,7 +1304,7 @@ details > summary { .tip { position: fixed; z-index: 50; - transform: translate(-50%, -100%); + translate: -50% -100%; padding: 6px 10px; border-radius: 10px; font-size: 12px; @@ -1259,8 +1322,7 @@ details > summary { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); - transform: translate(-50%, 20px); - opacity: 0; + translate: -50% 0; z-index: 60; background: var(--primary); color: var(--primary-fg); @@ -1268,20 +1330,1004 @@ details > summary { border-radius: 999px; font-weight: 500; font-size: 14px; - transition: all 0.25s; max-width: 90vw; } -.toast.show { - opacity: 1; - transform: translate(-50%, 0); -} .toast.bad { background: var(--bad); color: #fff; } +/* First visit without a device: two steps and the add button, before the slot grid. */ +.firststeps { + grid-column: 1 / -1; + display: flex; + flex-direction: column; + gap: 12px; +} +.firststeps p { + margin: 0; + font-size: 14px; +} +.firststeps h2 { + margin: 0; + font-size: 17px; +} +.firststeps .steps { + margin: 0; +} + +/* Which app the code is for. */ +.pane .seg { + display: inline-flex; + gap: 2px; + padding: 3px; + border-radius: 999px; + background: var(--soft, rgba(127, 127, 127, 0.12)); + margin-bottom: 10px; +} +.pane .seg button { + border: 0; + background: none; + color: inherit; + font: inherit; + font-size: 13px; + padding: 5px 12px; + border-radius: 999px; + cursor: pointer; +} +.pane .seg button.on { + background: var(--card, #fff); + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); +} + +/* ---------- setting up a device: two numbered steps ---------- */ +.setup { + display: flex; + flex-direction: column; + gap: 12px; +} +.setup .center { + display: flex; + justify-content: center; + text-align: center; +} +.step { + border: 1px solid var(--line); + border-radius: 16px; + background: var(--card); + padding: 14px 16px 16px; + display: flex; + flex-direction: column; + gap: 12px; + min-width: 0; +} +.step-head { + display: flex; + align-items: center; + gap: 10px; +} +.step-n { + width: 22px; + height: 22px; + border-radius: 50%; + background: var(--soft); + display: inline-flex; + align-items: center; + justify-content: center; + font-size: 12px; + font-weight: 600; + flex: none; +} +.step-n:empty { + display: none; +} +.step-ic { + width: 28px; + height: 28px; + border-radius: 8px; + background: var(--soft); + display: inline-flex; + align-items: center; + justify-content: center; + flex: none; +} +.step-title { + font-weight: 600; + font-size: 16px; + display: flex; + align-items: center; + gap: 10px; + min-width: 0; + flex: 1; +} +.chip { + font-size: 11px; + padding: 2px 7px; + border-radius: 999px; + background: rgba(58, 131, 247, 0.16); + color: var(--accent); + white-space: nowrap; +} +.fold-link { + all: unset; + cursor: pointer; + font-size: 13px; + color: var(--muted); + padding: 4px 0; +} +.fold-link:hover { + color: var(--text); +} +.badge { + all: unset; + box-sizing: border-box; + cursor: pointer; + display: flex; + align-items: center; + gap: 12px; + padding: 8px 12px 8px 8px; + border-radius: 12px; + min-height: 56px; + background: var(--soft); + color: var(--text); + min-width: 0; +} +.badge:hover { + background: var(--soft-hover); +} +.badge.primary { + background: var(--primary); + color: var(--primary-fg); +} +.badge-ic { + width: 36px; + height: 36px; + border-radius: 10px; + flex: none; + display: inline-flex; + align-items: center; + justify-content: center; + background: rgba(127, 127, 127, 0.18); +} +.badge-ic .ic-svg { + width: 20px; + height: 20px; +} +.badge-txt { + display: flex; + flex-direction: column; + line-height: 1.2; + min-width: 0; + flex: 1; +} +.badge-top { + font-size: 11px; + opacity: 0.7; +} +.badge-main { + font-size: 15px; + font-weight: 600; + letter-spacing: -0.01em; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.badge-chev { + opacity: 0.5; + display: inline-flex; + flex: none; +} +.badges2 { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 8px; +} +.badges2 .badge-chev { + display: none; +} +.pills { + display: flex; + flex-wrap: wrap; + gap: 6px; +} +.pill { + all: unset; + box-sizing: border-box; + cursor: pointer; + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 13px; + padding: 7px 10px 7px 9px; + border-radius: 999px; + border: 1px solid var(--line); + color: var(--muted); + white-space: nowrap; +} +.pill .ic-svg { + width: 14px; + height: 14px; +} +.pill.on { + border-color: var(--accent); + background: rgba(58, 131, 247, 0.12); + color: var(--text); +} +.howto { + margin: 0; + padding: 0 4px 0 22px; + font-size: 13px; + color: var(--muted); + display: flex; + flex-direction: column; + gap: 4px; +} +.howto b { + font-weight: 500; + color: var(--text); +} +.linkrow { + display: flex; + align-items: center; + gap: 8px; + padding: 6px 6px 6px 12px; + border-radius: 12px; + background: var(--soft); + min-width: 0; +} +.linkrow .mono { + flex: 1; + min-width: 0; + font-size: 12px; + color: var(--muted); +} +.qr.small { + width: 148px; + flex: none; +} +/* A code and what to do with it, under it. (Not `.row.wrap`: `.wrap` is the page.) */ +.code-row { + display: flex; + flex-direction: column; + align-items: center; + gap: 12px; +} +.code-row > .stack { + align-self: stretch; +} +/* A dense code (an AmneziaVPN key): the full width of its card, edge to edge with the text, so a phone camera resolves the modules. */ +.qr.big { + width: 100%; +} +/* A small control that unfolds a choice, as opposed to a text link. */ +.pill-link { + all: unset; + box-sizing: border-box; + cursor: pointer; + display: inline-flex; + align-items: center; + gap: 4px; + font-size: 12px; + font-weight: 500; + padding: 5px 8px 5px 10px; + border-radius: 999px; + border: 1px solid var(--line); + color: var(--muted); + white-space: nowrap; +} +.pill-link:hover { + color: var(--text); + background: var(--soft); +} +.pill-link .ic-svg { + width: 13px; + height: 13px; + transform: rotate(90deg); +} +/* A line that belongs to the step's title, not to the content under it. */ +.step-sub { + margin-top: -8px; +} +/* A folded card: its head is the button that opens it, a chevron at the end. */ +.step-head.fold { + all: unset; + box-sizing: border-box; + cursor: pointer; + display: flex; + align-items: center; + gap: 10px; + width: 100%; + color: inherit; +} +.fold-chev { + display: inline-flex; + color: var(--muted); +} +.fold-chev .ic-svg { + width: 16px; + height: 16px; +} +.step.folded { + padding-bottom: 14px; +} + +/* Waiting for the first connection (waitpath.ts): the way from the device to the home router. */ +.way { + display: flex; + flex-direction: column; + gap: 10px; + padding: 12px 14px; + border-radius: 14px; + background: var(--soft); +} +.way-row { + display: flex; + align-items: center; + gap: 10px; +} +.way-end { + width: 36px; + height: 36px; + border-radius: 10px; + flex: none; + display: inline-flex; + align-items: center; + justify-content: center; + background: var(--soft-hover); + color: var(--muted); +} +.way-end .ic-svg { + width: 18px; + height: 18px; +} +.way-end.home { + color: var(--info); + background: color-mix(in srgb, var(--info) 14%, transparent); +} +.way-track { + position: relative; + flex: 1; + height: 8px; +} +/* One dotted line, three layers through the same dots: the dots, the light along them, the green that fills them. */ +.way-track::before, +.way-glow, +.way-fill { + position: absolute; + inset: 0; + -webkit-mask: radial-gradient(circle, #000 1.4px, transparent 1.9px) 0 50% / 9px 8px repeat-x; + mask: radial-gradient(circle, #000 1.4px, transparent 1.9px) 0 50% / 9px 8px repeat-x; +} +.way-track::before { + content: ''; + background: var(--faint); + opacity: 0.55; +} +.way-glow { + overflow: hidden; +} +.way-glow i { + position: absolute; + inset: 0; + background: linear-gradient(90deg, transparent 32%, var(--info) 50%, transparent 68%); + transform: translateX(-70%); +} +.way-fill { + background: var(--ok); + clip-path: inset(0 100% 0 0); +} +.way-text { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + gap: 2px; +} +.way-text > :empty { + display: none; +} +.way.done .way-end { + background: var(--ok-wash); + color: var(--ok); +} +.way.done .way-fill { + clip-path: inset(0); +} +.way.done .way-glow, +.way.stopped .way-glow { + opacity: 0; +} + +/* ---------- Motion ---------- */ +/* + * How the portal moves. A personal page opened now and then, so polish first + * (subtle, production-quiet), restraint where things are used often, and a + * little delight only where it is rare (the sunrise, the first connection): + * - arrivals ease out fast and come into focus: opacity, a short rise, a blur + * that clears; departures are shorter, smaller and ease in; + * - a press scales down at once; hover only changes colour; + * - Escape and other keys never animate; nothing loops except a spinner; + * - only transform, opacity, filter and clip-path move, plus a sheet's height + * (one fixed box, motion.ts followHeight); + * - prefers-reduced-motion keeps the fades and drops the travel (end of file). + * motion.ts measures and starts what needs script (heights, FLIP, swaps, pulls). + */ + +/* Press and hover: everything tappable. Placed last: the controls reset with `all: unset`. */ +.btn, +.badge, +.pill, +.kind, +.icon-btn, +.slot.add, +.slot-ic, +.name-chip, +.fold-link, +.pill-link, +.tabs > button, +.seg > button, +.menu-item { + transition: + transform var(--dur-press) var(--ease-out), + background-color var(--dur-hover) var(--ease-out), + border-color var(--dur-hover) var(--ease-out), + box-shadow var(--dur-hover) var(--ease-out), + color var(--dur-hover) var(--ease-out), + opacity var(--dur-hover) var(--ease-out); +} +.btn:active, +.pill:active, +.kind:active, +.icon-btn:active, +.fold-link:active, +.pill-link:active, +.tabs > button:active, +.seg > button:active { + transform: scale(0.97); +} +/* Wide surfaces give less: the same press reads larger on them. */ +.badge:active, +.slot.add:active { + transform: scale(0.985); +} +.name-chip:active { + transform: scale(0.96); +} +.btn[disabled]:active { + transform: none; +} +/* The ⋯ whose menu is open stays pressed. */ +.icon-btn[aria-expanded='true'] { + background: var(--soft-hover); + color: var(--text); +} +.kind .ic, +.menu-item .ic { + transition: color var(--dur-hover) var(--ease-out); +} +.spark i { + transition: + opacity 120ms var(--ease-out), + filter 120ms var(--ease-out); +} +input, +textarea { + transition: + border-color var(--dur-hover) var(--ease-out), + box-shadow var(--dur-hover) var(--ease-out); +} + +/* The visit's first paint: blocks rise in, in reading order (motion.ts intro sets --i). + The add slot's `all: unset` (two classes) would reset the animation: it is named here. */ +.intro, +.slot.add.intro { + animation: rise-in var(--dur-enter) var(--ease-out) backwards; + animation-delay: calc(40ms + var(--i, 0) * 45ms); +} +/* The sun rises from behind the horizon, once. */ +.top.first .sun { + animation: sunrise 900ms var(--ease-out) 120ms backwards; +} +/* The meters fill and the bars grow, after their cards have arrived. */ +.wrap.first .meter i { + animation: fill-x 800ms var(--ease-out) 300ms backwards; +} +.wrap.first .slots i.used, +.wrap.first .slots i.over { + animation: fill-x 480ms var(--ease-out) backwards; + animation-delay: calc(320ms + var(--i, 0) * 50ms); +} +.wrap.first .spark i { + transform-origin: bottom; + animation: grow-y 560ms var(--ease-out) backwards; + animation-delay: calc(320ms + var(--i, 0) * 30ms); +} +.wrap.first .avatar.online::after { + animation: pop-in 480ms var(--spring-pop) 420ms backwards; +} +.wrap.first .hero-ic { + animation: pop-in 520ms var(--spring-pop) 160ms backwards; +} + +/* A repaint: a new block rises in, a value that changed comes into focus, an icon swaps with a little spring. */ +.enter, +.slot.add.enter { + animation: rise-in 360ms var(--ease-out) backwards; +} +/* What a card just unfolded: one piece after the other (setup sheet). */ +.unfold { + animation: rise-in 320ms var(--ease-out) backwards; + animation-delay: calc(30ms + var(--i, 0) * 40ms); +} +.swap { + animation: focus-in var(--dur-swap) var(--ease-out) backwards; +} +.swap-ic { + animation: icon-in 280ms var(--spring) backwards; +} +.copied > .ic, +.copied .badge-ic .ic { + color: var(--ok); +} +.badge.primary.copied .badge-ic .ic { + color: inherit; +} + +/* Dropdown menu: grows out of its button, leaves quicker and smaller. */ +.menu { + opacity: 0; + transform: translateY(-4px) scale(0.96); + transform-origin: top right; + filter: blur(2px); + transition: + opacity var(--dur-pop) var(--ease-out), + transform 220ms var(--ease-out), + filter var(--dur-pop) var(--ease-out); +} +.menu.up { + transform: translateY(4px) scale(0.96); + transform-origin: bottom right; +} +.menu.show { + opacity: 1; + transform: none; + filter: none; +} +.menu.gone { + opacity: 0; + transform: scale(0.98); + filter: none; + pointer-events: none; + transition-duration: 120ms; + transition-timing-function: var(--ease-in); +} + +/* Tooltip: comes up out of the pointer once, then only follows it. */ +.tip { + opacity: 0; + transform: translateY(4px) scale(0.96); + transform-origin: 50% 100%; + transition: + opacity 120ms var(--ease-out), + transform var(--dur-pop) var(--ease-out); +} +.tip.show { + opacity: 1; + transform: none; +} + +/* Toast: rises into focus; goes quicker, barely moving. */ +.toast { + opacity: 0; + transform: translateY(12px) scale(0.96); + filter: blur(4px); + transition: + transform 380ms var(--ease-out), + opacity 240ms var(--ease-out), + filter 240ms var(--ease-out); +} +.toast.show { + opacity: 1; + transform: none; + filter: none; +} +.toast.gone { + opacity: 0; + transform: translateY(4px) scale(0.98); + filter: blur(2px); + transition-duration: var(--dur-exit); + transition-timing-function: var(--ease-in); +} + +/* Sheets. Phones: slides up on iOS's curve, can be pulled down (motion.ts pullToClose). */ +.scrim { + opacity: 0; + transition: opacity 300ms var(--ease-out); +} +.sheet.open .scrim { + opacity: 1; +} +.sheet.closing .scrim { + transition-duration: 260ms; +} +.sheet-panel { + transform: translateY(100%); + transition: transform var(--dur-sheet) var(--ease-drawer); +} +.sheet.open .sheet-panel { + transform: none; +} +.sheet.closing .sheet-panel { + transition-duration: 300ms; +} +.sheet-panel.dragging { + transition: none; +} +.sheet-panel.morphing { + overflow: hidden; +} +/* A question turning into a sheet: the width animates, the cap waits for the end. */ +.sheet-panel.morphing-w { + max-width: none; +} +@media (max-width: 639px) { + .grab, + .sheet-head, + .ask { + touch-action: none; + } + .grab { + cursor: grab; + } +} +/* Desktop: a dialog that comes into focus, its content settling just after it. */ +@media (min-width: 640px) { + .sheet-panel { + opacity: 0; + transform: translateY(8px) scale(0.96); + filter: blur(4px); + transition: + opacity 220ms var(--ease-out), + transform 320ms var(--ease-out), + filter 220ms var(--ease-out); + } + .sheet.open .sheet-panel { + opacity: 1; + transform: none; + filter: none; + } + .sheet.closing .sheet-panel { + opacity: 0; + transform: scale(0.98); + filter: blur(2px); + transition-duration: var(--dur-exit); + transition-timing-function: var(--ease-in); + } + .sheet.closing .scrim { + transition-duration: 180ms; + } + .sheet.fresh .sheet-inner > .sheet-head, + .sheet.fresh .sheet-body > :not(.setup), + .sheet.fresh .setup > * { + animation: settle-in 280ms var(--ease-out) backwards; + animation-delay: calc(20ms + var(--i, 0) * 25ms); + } +} +/* A question opens with its icon springing in. */ +.sheet.fresh .ask-ic { + animation: pop-in 520ms var(--spring-pop) 80ms backwards; +} +/* What a swap lifts out of the flow while it fades (motion.ts swap): under the new content, not over it. */ +.sheet-inner, +.tab-body, +.setup { + position: relative; + isolation: isolate; +} +.ghost { + position: absolute; + z-index: -1; + pointer-events: none; +} + +/* Tabs and segments: a copy of the row in the picked look, clipped to the pick, slides (motion.ts slider). */ +.slides { + position: relative; +} +.slide-hl { + position: absolute; + inset: 0; + margin: 0 !important; + pointer-events: none; +} +.slide-hl.placed { + transition: clip-path 300ms var(--ease-out); +} +.tabs.slide-hl { + background: var(--soft-hover); +} +.pane .seg.slide-hl { + background: var(--card); +} +.slide-hl > button, +.slide-hl > button.on { + background: none; + box-shadow: none; + color: var(--text); + transition: none; +} +.tabs.slides > button.on, +.pane .seg.slides > button.on { + background: none; + box-shadow: none; +} + +/* Setup repaints (motion.ts restyle): what flipped starts from its other look; a card that + just folded shows its chevron with a little spring. */ +.fold.to-off .fold-chev { + animation: icon-in 280ms var(--spring) backwards; +} +.pill.to-on { + animation: pill-on var(--dur-pop) var(--ease-out); +} +.pill.to-off { + animation: pill-off var(--dur-pop) var(--ease-out); +} +.pill.to-on .ic, +.kind.on .ic { + animation: pop-sm 340ms var(--spring-pop); +} +/* A code that now encodes something else comes into focus out of a blur. */ +.qr.swap { + animation: qr-in 360ms var(--ease-out) backwards; +} +/* A key shown comes into focus; the mask fades back. */ +.conf-v.unmask { + animation: unmask 420ms var(--ease-out) backwards; +} +.conf-mask.unmask { + animation: focus-in 200ms var(--ease-out) backwards; +} +.confbox[open] > .conf { + animation: rise-in 260ms var(--ease-out) backwards; +} + +/* The first connection (waitpath.ts): a light runs along the way while the page waits; + connected, the dots fill green from the device to the router, then the router end lights. */ +.way-glow i { + animation: way-run 2s cubic-bezier(0.45, 0, 0.55, 1) infinite; +} +.way-glow { + transition: opacity 200ms var(--ease-out); +} +.way-fill { + transition: clip-path 700ms var(--ease-out) 80ms; +} +.way-end { + transition: + background-color 300ms var(--ease-out), + color 300ms var(--ease-out); +} +/* The green reaches the server last: it lights up when the dots get there. */ +.way.done .way-end.home { + transition-delay: 600ms; +} +.way.done .way-end.home .ic { + animation: pop-sm 420ms var(--spring-pop) 600ms; +} + +/* A button waiting for the router: the label gives way to a spinner (motion.ts busy). */ +.btn { + --spin: var(--text); +} +.btn.primary { + --spin: var(--primary-fg); +} +.btn.danger-solid { + --spin: #fff; +} +.btn.busy { + position: relative; + color: transparent !important; + cursor: progress; +} +.btn.busy[disabled] { + opacity: 1; +} +.btn.busy::after { + content: ''; + position: absolute; + inset: 0; + margin: auto; + width: 16px; + height: 16px; + border-radius: 50%; + border: 2px solid color-mix(in srgb, var(--spin) 28%, transparent); + border-top-color: var(--spin); + animation: + spin 700ms linear infinite, + focus-in var(--dur-hover) var(--ease-out); +} +.btn[disabled] { + transition: opacity var(--dur-hover) var(--ease-out); +} + +@keyframes rise-in { + from { + opacity: 0; + transform: translateY(8px); + filter: blur(4px); + } +} +@keyframes settle-in { + from { + opacity: 0; + transform: translateY(4px); + } +} +@keyframes focus-in { + from { + opacity: 0; + filter: blur(4px); + } +} +@keyframes fade { + from { + opacity: 0; + } +} +@keyframes icon-in { + from { + opacity: 0; + transform: scale(0.7); + filter: blur(3px); + } +} +@keyframes pop-in { + from { + opacity: 0; + transform: scale(0.7); + filter: blur(4px); + } +} +@keyframes pop-sm { + from { + transform: scale(0.82); + } +} +@keyframes sunrise { + from { + transform: translateY(10px); + } +} +@keyframes fill-x { + from { + clip-path: inset(0 100% 0 0 round 999px); + } + to { + clip-path: inset(0 0 0 0 round 999px); + } +} +@keyframes grow-y { + from { + transform: scaleY(0); + } +} +@keyframes pill-on { + from { + border-color: var(--line); + background-color: transparent; + color: var(--muted); + } +} +@keyframes pill-off { + from { + border-color: var(--accent); + background-color: rgba(58, 131, 247, 0.12); + color: var(--text); + } +} +@keyframes qr-in { + from { + opacity: 0; + transform: scale(0.98); + filter: blur(6px); + } +} +@keyframes unmask { + from { + opacity: 0.25; + filter: blur(5px); + } +} +/* The light goes along the way, then rests a beat before the next run. */ +@keyframes way-run { + 0% { + transform: translateX(-70%); + } + 72%, + 100% { + transform: translateX(70%); + } +} +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +/* Less motion: what says "this changed" still fades in; nothing travels, scales, blurs or turns. */ @media (prefers-reduced-motion: reduce) { - * { - transition: none !important; - animation: none !important; + .intro, + .slot.add.intro, + .enter, + .slot.add.enter, + .unfold, + .swap, + .swap-ic, + .qr.swap, + .conf-v.unmask, + .confbox[open] > .conf, + .wrap.first .hero-ic, + .wrap.first .avatar.online::after, + .sheet.fresh .sheet-inner > .sheet-head, + .sheet.fresh .sheet-body > :not(.setup), + .sheet.fresh .setup > *, + .sheet.fresh .ask-ic { + animation-name: fade; + animation-duration: 200ms; + } + .top.first .sun, + .wrap.first .meter i, + .wrap.first .slots i.used, + .wrap.first .slots i.over, + .wrap.first .spark i, + .fold.to-off .fold-chev, + .pill.to-on .ic, + .kind.on .ic, + .way.done .way-end.home .ic { + animation: none; + } + /* The way holds still while waiting; connected, it turns green at once. */ + .way-glow { + display: none; + } + .way-fill { + transition: none; + } + .sheet-panel, + .sheet.open .sheet-panel, + .sheet.closing .sheet-panel, + .menu, + .menu.up, + .menu.gone, + .tip, + .toast, + .toast.gone { + transform: none; + filter: none; + } + .sheet-panel { + opacity: 0; + transition: opacity 200ms var(--ease-out); + } + .sheet.open .sheet-panel { + opacity: 1; + } + .slide-hl.placed, + .confbox > summary > .ic:first-child { + transition: none; + } + .btn:active, + .badge:active, + .pill:active, + .kind:active, + .icon-btn:active, + .slot.add:active, + .name-chip:active, + .fold-link:active, + .pill-link:active, + .tabs > button:active, + .seg > button:active { + transform: none; } } diff --git a/web/src/portal/setup.ts b/web/src/portal/setup.ts new file mode 100644 index 0000000..159796b --- /dev/null +++ b/web/src/portal/setup.ts @@ -0,0 +1,192 @@ +// Setting up a device: which app, where it comes from, and whether the page +// is open on the device being set up. Pure: the sheet in main.ts draws it. + +import type { Kind } from '../shared/types'; + +export type Platform = 'ios' | 'android' | 'windows' | 'mac' | 'linux' | 'unknown'; +export type AppId = 'vpn' | 'awg' | 'wg'; +/** The server's disguise generation as the portal sees it. */ +export type Preset = 'off' | 'balanced' | 'max' | 'legacy'; + +export const APP_NAME: Record = { vpn: 'AmneziaVPN', awg: 'AmneziaWG', wg: 'WireGuard' }; + +/** The platform the page is open on. iPadOS Safari calls itself a Mac; touch points tell. */ +export function platformOf(ua: string, touchPoints = 0): Platform { + if (/iPhone|iPad|iPod/.test(ua)) return 'ios'; + if (/Macintosh/.test(ua) && touchPoints > 1) return 'ios'; + if (/Android/.test(ua)) return 'android'; + if (/Windows/.test(ua)) return 'windows'; + if (/Mac OS X|Macintosh/.test(ua)) return 'mac'; + if (/CrOS/.test(ua)) return 'unknown'; + if (/Linux|X11/.test(ua)) return 'linux'; + return 'unknown'; +} + +/** A browser inside another app (Telegram, Instagram…): vpn:// and the share sheet do not work there. */ +export const inWebview = (ua: string): boolean => /Telegram|FBAN|FBAV|Instagram|VKClient|Line\//i.test(ua); + +/** Is the page open on the device being set up? A router never is; an unknown platform never counts. */ +export function sameDevice(kind: Kind, platform: Platform): boolean { + if (kind === 'router' || platform === 'unknown') return false; + if (kind === 'phone' || kind === 'tablet') return platform === 'ios' || platform === 'android'; + if (kind === 'computer') return platform === 'windows' || platform === 'mac' || platform === 'linux'; + return true; +} + +/** The systems a kind may run: a computer's is the person's call, the rest are read from the browser. */ +export const osGroup = (kind: Kind): Platform[] => (kind === 'computer' || kind === 'other' ? ['windows', 'mac', 'linux'] : []); + +export interface AppChoice { + id: AppId; + name: string; + /** The version this server needs, as "4.8.12" or ""; "current" when only the newest will do. */ + need: string; + sub: string; +} + +/** The apps that connect to a server with this disguise, the recommended one first. */ +export function appsFor(preset: Preset): AppChoice[] { + const need = { + off: { vpn: '', awg: '' }, + balanced: { vpn: '4.8.12', awg: '2.0' }, + max: { vpn: 'current', awg: '3.1' }, + legacy: { vpn: '', awg: '' }, + }[preset]; + const out: AppChoice[] = [ + { id: 'vpn', name: APP_NAME.vpn, need: need.vpn, sub: 'Connects from a link, no files' }, + { id: 'awg', name: APP_NAME.awg, need: need.awg, sub: 'The light client: a file or a QR code' }, + ]; + if (preset === 'off') out.push({ id: 'wg', name: APP_NAME.wg, need: '', sub: 'Any WireGuard app: this server has no disguise' }); + return out; +} + +/** "This server needs AmneziaVPN 4.8.12 or newer. …", or "" when any version will do. */ +export function updateLine(app: AppChoice): string { + if (!app.need) return ''; + const what = app.need === 'current' ? `the current version of ${app.name}` : `${app.name} ${app.need} or newer`; + return `This server needs ${what}. Installed a while ago? Update it in the store.`; +} + +export type Mark = 'appstore' | 'googleplay' | 'windows' | 'apple' | 'linux' | 'openwrt' | 'github' | 'site'; + +export interface Store { + href: string; + /** The small line and the bold line of the badge. */ + top: string; + main: string; + mark: Mark; + /** A second source shown beside the first, where the store can fail (Android). */ + alt?: { href: string; top: string; main: string; mark: Mark; why: string }; +} + +const GH_CLIENT = 'https://github.com/amnezia-vpn/amnezia-client/releases/latest'; +const APK: NonNullable = { + href: GH_CLIENT, + top: 'APK file on', + main: 'GitHub', + mark: 'github', + why: 'The APK is for phones without Google Play, or where the store hides the app.', +}; + +/** Where the app comes from on a platform: the store first, the official GitHub release where no store has it. */ +export function storeFor(app: AppId, platform: Platform): Store | null { + const S: Record>> = { + vpn: { + ios: { href: 'https://apps.apple.com/app/amneziavpn/id1600529900', top: 'Download on the', main: 'App Store', mark: 'appstore' }, + android: { + href: 'https://play.google.com/store/apps/details?id=org.amnezia.vpn', + top: 'Get it on', + main: 'Google Play', + mark: 'googleplay', + alt: APK, + }, + windows: { href: GH_CLIENT, top: 'Official release on GitHub', main: 'Download for Windows', mark: 'windows' }, + mac: { href: GH_CLIENT, top: 'Official release on GitHub', main: 'Download for Mac', mark: 'apple' }, + linux: { href: GH_CLIENT, top: 'Official release on GitHub', main: 'Download for Linux', mark: 'linux' }, + }, + awg: { + ios: { href: 'https://apps.apple.com/us/app/amneziawg/id6478942365', top: 'Download on the', main: 'App Store', mark: 'appstore' }, + android: { + href: 'https://play.google.com/store/apps/details?id=org.amnezia.awg', + top: 'Get it on', + main: 'Google Play', + mark: 'googleplay', + alt: { ...APK, href: 'https://github.com/amnezia-vpn/amneziawg-android/releases' }, + }, + windows: { + href: 'https://github.com/amnezia-vpn/amneziawg-windows-client/releases', + top: 'Official release on GitHub', + main: 'Download for Windows', + mark: 'windows', + }, + mac: { + href: 'https://apps.apple.com/us/app/amneziawg/id6478942365', + top: 'Download on the', + main: 'Mac App Store', + mark: 'appstore', + }, + linux: { href: 'https://github.com/amnezia-vpn/amneziawg-tools', top: 'On GitHub', main: 'amneziawg-tools', mark: 'linux' }, + }, + wg: { + ios: { href: 'https://apps.apple.com/app/wireguard/id1441195209', top: 'Download on the', main: 'App Store', mark: 'appstore' }, + android: { + href: 'https://play.google.com/store/apps/details?id=com.wireguard.android', + top: 'Get it on', + main: 'Google Play', + mark: 'googleplay', + }, + windows: { href: 'https://www.wireguard.com/install/', top: 'Download from', main: 'wireguard.com', mark: 'windows' }, + mac: { href: 'https://apps.apple.com/app/wireguard/id1451685025', top: 'Download on the', main: 'Mac App Store', mark: 'appstore' }, + linux: { href: 'https://www.wireguard.com/install/', top: 'Install from', main: 'wireguard.com', mark: 'linux' }, + }, + }; + return S[app][platform] ?? null; +} + +/** Where a router gets its client: OpenWrt packages. */ +export const routerStore = (app: AppId): Store => + app === 'wg' + ? { + href: 'https://openwrt.org/docs/guide-user/services/vpn/wireguard/start', + top: 'OpenWrt packages', + main: 'wireguard-tools', + mark: 'openwrt', + } + : { href: 'https://openwrt.org/packages/start', top: 'OpenWrt packages', main: 'amneziawg-tools + kmod', mark: 'openwrt' }; + +/** Inside the app: where the scanner and the importer are. */ +export const scanPath = (app: AppId): string => + app === 'vpn' ? 'Add server → Scan QR' : app === 'awg' ? 'Add tunnel → Scan QR code' : 'Add tunnel → Create from QR code'; +export const importPath = (app: AppId): string => (app === 'vpn' ? 'Add server → Insert key' : 'Add tunnel → Import from file'); + +export const PLATFORM_LABEL: Record = { + ios: 'iPhone / iPad', + android: 'Android', + windows: 'Windows', + mac: 'Mac', + linux: 'Linux', + unknown: 'this device', +}; + +/** + * The personal link that opens straight on one device's set-up: the page then + * starts it by itself. In the fragment, which never reaches the router: the + * link stays the key, the device only says where to start. + */ +export const setupLink = (page: string, id: string): string => `${page}#setup=${id}`; + +/** The device a link asks to set up (`#setup=d_…`), or null; anything else in the fragment is ignored. */ +export function setupFromHash(hash: string): string | null { + return /^#setup=(d_[0-9a-f]{8})$/.exec(hash)?.[1] ?? null; +} + +/** + * "the phone", "the computer": the device being set up, in a sentence. The + * sheet's title already names it; the lines under it do not repeat the name. + */ +export const deviceNoun = (kind: Kind): string => + ({ phone: 'phone', tablet: 'tablet', computer: 'computer', router: 'router', other: 'device' })[kind]; + +/** "This iPhone", "This Mac": the pill for the device in hand. */ +export const hereLabel = (platform: Platform): string => + ({ ios: 'This iPhone', android: 'This phone', windows: 'This PC', mac: 'This Mac', linux: 'This PC', unknown: 'This device' })[platform]; diff --git a/web/src/portal/waitpath.ts b/web/src/portal/waitpath.ts new file mode 100644 index 0000000..6d46478 --- /dev/null +++ b/web/src/portal/waitpath.ts @@ -0,0 +1,60 @@ +// The set-up sheets' "waiting for the first connection" card: the way from +// the device (its icon; the sheet's title names it) to the home server, a light +// running along its dots while the page waits; the dots fill green when it connects. +// It only draws and switches its states; main.ts (watchFirstConnection) +// decides when, and what leaves around it. A live region: the changes are read out. + +import type { Kind } from '../shared/types'; +import { h, ic } from './dom'; +import { grow, replay } from './motion'; + +export interface Way { + el: HTMLElement; + /** The first connection arrived. */ + connected(): void; + /** The page stopped asking (ten minutes): say so instead of waiting on forever. */ + gaveUp(): void; +} + +export function waitPath(kind: Kind): Way { + const title = h('span', { class: 'strong s' }, 'Waiting for the connection'); + // Nothing to add while it waits: the line comes with "You're all set" or the give-up. + const sub = h('span', { class: 'faint s' }); + // The router end: the server's icon, as on the admin's map. + const home = h('span', { class: 'way-end home' }, ic('server')); + const el = h( + 'div', + { class: 'way', role: 'status', 'aria-live': 'polite' }, + h( + 'div', + { class: 'way-row' }, + h('span', { class: 'way-end' }, ic(kind)), + h('span', { class: 'way-track' }, h('span', { class: 'way-glow' }, h('i')), h('span', { class: 'way-fill' })), + home, + ), + h('div', { class: 'way-text' }, title, sub), + ); + const say = (t: string, s: string) => { + if (title.textContent !== t) { + title.textContent = t; + replay(title, 'swap'); + } + if (sub.textContent === s) return; + // The line under the title only appears now: it opens rather than pushing the card. + const opens = !sub.textContent; + sub.textContent = s; + if (opens) grow(sub); + else replay(sub, 'swap'); + }; + return { + el, + connected: () => { + el.classList.add('done'); + say('Connected', 'You’re all set.'); + }, + gaveUp: () => { + el.classList.add('stopped'); + say('No connection yet', 'Close this and open it again to keep checking.'); + }, + }; +} diff --git a/web/src/shared/icons.ts b/web/src/shared/icons.ts index 605e98c..91e9be2 100644 --- a/web/src/shared/icons.ts +++ b/web/src/shared/icons.ts @@ -26,6 +26,31 @@ const P: Record = { copy: '', download: '', link: '', + // App logos: filled marks (the icon set is strokes), drawn at their 512 px art size and scaled to 24. + amnezia: + '', + amneziawg: + '', + wireguard: + '', + // Store and platform marks for the portal's set-up sheet (filled, 512 px art scaled to 24). + appstore: + '', + googleplay: + '', + github: + '', + openwrt: + '', + apple: + '', + windows: + '', + linux: + '', + eye: '', + share: '', + arrow: '', trash: '', edit: '', pause: '', diff --git a/web/src/shared/qr.ts b/web/src/shared/qr.ts index 5f6c0e5..b415807 100644 --- a/web/src/shared/qr.ts +++ b/web/src/shared/qr.ts @@ -1,49 +1,96 @@ -// QR codes rendered in the browser as a single-path SVG, with the Dawnline -// mark in the middle. The mark hides about 5% of the code; error correction -// H (30%) covers that for links, Q (25%) keeps long configurations scannable. +// QR codes rendered in the browser as SVG, with the Dawnline mark in the +// middle. The mark hides about 5% of the code; error correction H (30%) covers +// that for links. A long configuration (an AmneziaVPN key is about 1.5 KB) gets +// no mark and level L: every step up in correction adds modules, and a dense +// code fails on the camera before it fails on damage. +// +// Two looks. `plain`: black squares on white in one path (the admin's cards and +// the invite image). `night`: light dots on black with rounded finder eyes (the +// portal). Light dots on dark lose a dense code to blur sooner, so a dense night +// code gets fuller dots: checked with a QR reader, r 0.42 lost a 1.5 KB key at +// 1.2 px of blur where r 0.48 read as well as the plain code. import qrcode from 'qrcode-generator'; -/** The icon's dome and bar (64×64 viewBox, see portal/icon.svg). */ -const MARK = ''; +export type QrLook = 'plain' | 'night'; -export function qrSvg(text: string, margin = 3, logo = true): string { - const qr = qrcode(0, text.length > 300 ? 'Q' : 'H'); +/** The icon's dome and bar (64×64 viewBox, see portal/icon.svg), in a colour. */ +const mark = (fill: string) => + ``; + +const NIGHT_BG = '#0a0a0a'; +const NIGHT_FG = '#f2f2f2'; + +/** Long content: fewer modules matter more than the mark. */ +export const denseQr = (text: string): boolean => text.length > 300; + +const n2 = (v: number) => +v.toFixed(2); +/** A rounded rectangle as a sub-path. */ +function rrect(x: number, y: number, w: number, h: number, r: number): string { + return ( + `M${n2(x + r)} ${n2(y)}h${n2(w - 2 * r)}a${r} ${r} 0 0 1 ${r} ${r}v${n2(h - 2 * r)}a${r} ${r} 0 0 1 -${r} ${r}` + + `h-${n2(w - 2 * r)}a${r} ${r} 0 0 1 -${r} -${r}v-${n2(h - 2 * r)}a${r} ${r} 0 0 1 ${r} -${r}z` + ); +} + +export function qrSvg(text: string, margin = 3, logo = true, look: QrLook = 'plain'): string { + const dense = denseQr(text); + const night = look === 'night'; + const qr = qrcode(0, dense ? 'L' : 'H'); qr.addData(text, 'Byte'); qr.make(); const n = qr.getModuleCount(); const size = n + margin * 2; // A centred, module-aligned hole for the mark (same parity as n). - let hole = logo ? Math.round(n * 0.22) : 0; + let hole = logo && !dense ? Math.round(n * 0.22) : 0; if (hole && (n - hole) % 2) hole++; const h0 = (n - hole) / 2, h1 = h0 + hole; const inHole = (x: number, y: number) => hole > 0 && x >= h0 && x < h1 && y >= h0 && y < h1; + // The three finder patterns, drawn whole as eyes in the night look. + const inEye = (x: number, y: number) => night && ((y < 7 && x < 7) || (y < 7 && x >= n - 7) || (y >= n - 7 && x < 7)); let d = ''; - for (let y = 0; y < n; y++) { - let x = 0; - while (x < n) { - if (!qr.isDark(y, x) || inHole(x, y)) { - x++; - continue; + if (night) { + const r = dense ? 0.48 : 0.42; + for (let y = 0; y < n; y++) + for (let x = 0; x < n; x++) + if (qr.isDark(y, x) && !inHole(x, y) && !inEye(x, y)) + d += `M${x + margin + 0.5 - r} ${y + margin + 0.5}a${r} ${r} 0 1 0 ${2 * r} 0a${r} ${r} 0 1 0 -${2 * r} 0z`; + } else + for (let y = 0; y < n; y++) { + let x = 0; + while (x < n) { + if (!qr.isDark(y, x) || inHole(x, y)) { + x++; + continue; + } + let w = 1; + while (x + w < n && qr.isDark(y, x + w) && !inHole(x + w, y)) w++; + d += `M${x + margin} ${y + margin}h${w}v1h-${w}z`; + x += w; } - let w = 1; - while (x + w < n && qr.isDark(y, x + w) && !inHole(x + w, y)) w++; - d += `M${x + margin} ${y + margin}h${w}v1h-${w}z`; - x += w; } - } - let mark = ''; + // Each eye: a 7×7 ring around a gap and a 3×3 pupil, one even-odd path. + let eyes = ''; + if (night) + for (const [x, y] of [ + [margin, margin], + [margin + n - 7, margin], + [margin, margin + n - 7], + ]) + eyes += rrect(x, y, 7, 7, 2.6) + rrect(x + 1, y + 1, 5, 5, 1.8) + rrect(x + 2, y + 2, 3, 3, 1.5); + let logoTile = ''; if (hole) { const pad = 0.6, s = hole - pad * 2, o = h0 + margin + pad; - mark = - `` + - `${MARK}`; + logoTile = + `` + + `${mark(night ? NIGHT_BG : '#fff')}`; } - return ( - `` + - `${mark}` - ); + const open = ``; + return night + ? `${open}` + + `${logoTile}` + : `${open}${logoTile}`; } diff --git a/web/src/shared/types.ts b/web/src/shared/types.ts index 92df098..52142cb 100644 --- a/web/src/shared/types.ts +++ b/web/src/shared/types.ts @@ -116,6 +116,8 @@ export interface Server { up: boolean; uptime: number; peers: number; + /** The newest handshake from a public address that is not the router's own (0: never). */ + reached?: number; online: number; obf: Record; } @@ -218,6 +220,8 @@ export interface Status { awg: AwgCaps; /** Absent from routers that run an older backend: treat as fine. */ awg_state?: AwgState; + /** The router's public IPv4 (null when none or private). */ + wan?: string | null; like_home: { active: boolean; dev?: string; address?: string; bridged?: boolean; off?: boolean; error?: string }; } diff --git a/web/tests/motion.test.ts b/web/tests/motion.test.ts new file mode 100644 index 0000000..25f3008 --- /dev/null +++ b/web/tests/motion.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, it } from 'vitest'; +import { dismisses, morphMs, rubber } from '../src/portal/motion'; + +describe('motion', () => { + it('pulls past an edge with growing resistance, never further than the box', () => { + expect(rubber(0, 400)).toBe(0); + expect(rubber(-20, 400)).toBe(0); + expect(rubber(40, 400)).toBeLessThan(40); + expect(rubber(40, 400)).toBeGreaterThan(15); + // Each further step gives less than the one before. + expect(rubber(200, 400) - rubber(100, 400)).toBeLessThan(rubber(100, 400) - rubber(0, 400)); + expect(rubber(100_000, 400)).toBeLessThan(400); + }); + + it('dismisses a sheet on a flick down or a pull past a third, not on a flick back up', () => { + expect(dismisses(12, 0.6, 500)).toBe(true); + expect(dismisses(200, 0, 500)).toBe(true); + expect(dismisses(120, 0.1, 500)).toBe(false); + expect(dismisses(300, -0.5, 500)).toBe(false); + expect(dismisses(0, 1, 500)).toBe(false); + expect(dismisses(-40, 1, 500)).toBe(false); + }); + + it('times a height change by its distance, inside 220–380 ms', () => { + expect(morphMs(0)).toBe(220); + expect(morphMs(200)).toBe(270); + expect(morphMs(2000)).toBe(380); + }); +}); diff --git a/web/tests/netcheck.test.ts b/web/tests/netcheck.test.ts index a81cf0e..a19bcd8 100644 --- a/web/tests/netcheck.test.ts +++ b/web/tests/netcheck.test.ts @@ -62,3 +62,82 @@ describe('netcheck', () => { expect(portalPortHelp(8444, taken, false).bad).toBe(true); }); }); + +import { + chars, + circleNameHelp, + dnsHelp, + domainHelp, + expiresHelp, + fallbackDnsHelp, + hostHelp, + ipv4Help, + keepaliveHelp, + limitHelp, + mtuHelp, + nameHelp, + portsHelp, + quotaHelp, + timeHelp, + titleHelp, + urlHelp, +} from '../src/admin/netcheck'; +import { date, daysLeft } from '../src/shared/format'; + +describe('field helps', () => { + it('counts characters like the router', () => { + expect(chars('Мама')).toBe(4); + expect(nameHelp('ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧ').bad).toBe(false); + expect(nameHelp('a'.repeat(49)).bad).toBe(true); + expect(nameHelp('Bob "B"').bad).toBe(true); + expect(nameHelp(' ').bad).toBe(true); + expect(nameHelp('Phone', ['phone']).text).toContain('already exists'); + expect(circleNameHelp('x'.repeat(33)).bad).toBe(true); + }); + it('explains the public address', () => { + expect(hostHelp('https://vpn.example.com').text).toContain('Leave out https://'); + expect(hostHelp('vpn.example.com:4500').text).toContain('without a port'); + expect(hostHelp('vpn.example.com', 4500)).toEqual({ text: 'Devices connect to vpn.example.com:4500.', bad: false }); + expect(hostHelp('2001:db8::1', 4500).text).toBe('Devices connect to [2001:db8::1]:4500.'); + expect(hostHelp('', 4500).bad).toBe(true); + expect(hostHelp('', 4500, 'Empty = the portal address.').bad).toBe(false); + expect(hostHelp('bad_host!').bad).toBe(true); + }); + it('checks DNS, MTU, keep-alive', () => { + expect(dnsHelp('', '10.77.0.1').bad).toBe(false); + expect(dnsHelp('1.1.1.1, foo', '10.77.0.1').text).toContain('“foo” is not an IP address'); + expect(dnsHelp('1.1.1.1 8.8.8.8', '10.77.0.1').text).toContain('1.1.1.1 and 8.8.8.8'); + expect(mtuHelp('', { computer: 1368, phone: 1280 }).text).toContain('1368'); + expect(mtuHelp('1200', { computer: 1368, phone: 1280 }).bad).toBe(true); + expect(mtuHelp('1400', { computer: 1368, phone: 1280 }).text).toContain('phones and tablets 1280'); + expect(keepaliveHelp('601').bad).toBe(true); + expect(keepaliveHelp('0').bad).toBe(false); + }); + it('checks limits, quota and dates', () => { + expect(limitHelp('0').bad).toBe(true); + expect(limitHelp('33').bad).toBe(true); + expect(limitHelp('2', 4).text).toContain('Already has 4'); + expect(quotaHelp('').bad).toBe(false); + expect(quotaHelp('100001').bad).toBe(true); + expect(quotaHelp('50').text).toContain('Paused after 50 GB'); + expect(expiresHelp('2026-10-13', '2026-10-14', daysLeft, date).bad).toBe(true); + expect(expiresHelp('2026-10-14', '2026-10-14', daysLeft, date).text).toContain('ends today'); + expect(expiresHelp('2026-10-20', '2026-10-14', daysLeft, date).text).toContain('ends in 7 days'); + }); + it('checks services, portal and settings fields', () => { + expect(ipv4Help('10.0.1.300').bad).toBe(true); + expect(ipv4Help('10.0.1.5', () => false).text).toContain('not in any home network'); + expect(portsHelp('445, 5000').text).toBe('Ports 445, 5000.'); + expect(portsHelp('70000').bad).toBe(true); + expect(urlHelp('vpn.example.com').bad).toBe(true); + expect(urlHelp('https://example.com/x').bad).toBe(false); + expect(titleHelp('x'.repeat(65)).bad).toBe(true); + expect(domainHelp('').bad).toBe(false); + expect(domainHelp('').text).toContain('phone.myata.lan'); + expect(domainHelp('Home.LAN').text).toBe('Lowercase only.'); + expect(domainHelp('home.lan').text).toContain('phone.myata.home.lan'); + expect(fallbackDnsHelp('abc').bad).toBe(true); + expect(timeHelp('4:00').bad).toBe(false); + expect(timeHelp('24:00').bad).toBe(true); + }); +}); diff --git a/web/tests/qr.test.ts b/web/tests/qr.test.ts new file mode 100644 index 0000000..f421c2a --- /dev/null +++ b/web/tests/qr.test.ts @@ -0,0 +1,30 @@ +import { describe, expect, it } from 'vitest'; +import { denseQr, qrSvg } from '../src/shared/qr'; + +const LINK = 'https://engage.example.eu:4500/abcdef-ghijkl-mnopqr'; +const KEY = `vpn://${'A1b2C3d4'.repeat(180)}`; + +describe('qr', () => { + it('draws the plain look as black squares on white in one path', () => { + const svg = qrSvg(LINK); + expect(svg).toContain('fill="#fff"'); + expect(svg).toContain('shape-rendering="crispEdges"'); + expect(svg).not.toContain('evenodd'); + }); + + it('draws the night look as light dots on black with eyes, marked on links only', () => { + const link = qrSvg(LINK, 3, true, 'night'); + expect(link).toContain('fill="#0a0a0a"'); + expect(link).toContain('fill-rule="evenodd"'); + expect(link).not.toContain('crispEdges'); + // The mark's light tile on a short code, none on a dense one. + expect(link).toContain('fill="#f2f2f2"/> { + expect(qrSvg(LINK, 3, true, 'night')).toContain('a0.42 0.42'); + expect(qrSvg(KEY, 3, true, 'night')).toContain('a0.48 0.48'); + }); +}); diff --git a/web/tests/setup.test.ts b/web/tests/setup.test.ts new file mode 100644 index 0000000..8805700 --- /dev/null +++ b/web/tests/setup.test.ts @@ -0,0 +1,79 @@ +import { describe, expect, it } from 'vitest'; +import { + appsFor, + deviceNoun, + inWebview, + platformOf, + sameDevice, + setupFromHash, + setupLink, + storeFor, + updateLine, +} from '../src/portal/setup'; + +const IPHONE = + 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1'; +const IPAD_AS_MAC = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15'; +const ANDROID = 'Mozilla/5.0 (Linux; Android 14; SM-S921B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Mobile Safari/537.36'; +const WINDOWS = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36'; +const LINUX = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36'; + +describe('setup', () => { + it('reads the platform from the browser, iPad included', () => { + expect(platformOf(IPHONE)).toBe('ios'); + expect(platformOf(IPAD_AS_MAC, 5)).toBe('ios'); + expect(platformOf(IPAD_AS_MAC, 0)).toBe('mac'); + expect(platformOf(ANDROID)).toBe('android'); + expect(platformOf(WINDOWS)).toBe('windows'); + expect(platformOf(LINUX)).toBe('linux'); + expect(platformOf('Mozilla/5.0 (X11; CrOS x86_64)')).toBe('unknown'); + }); + + it('links straight to the set-up of a device through the fragment, and reads only that back', () => { + const page = 'https://engage.example.eu:4500/abcdef-ghijkl-mnopqr'; + expect(setupLink(page, 'd_bf0b30e9')).toBe(`${page}#setup=d_bf0b30e9`); + expect(setupFromHash('#setup=d_bf0b30e9')).toBe('d_bf0b30e9'); + expect(setupFromHash('')).toBeNull(); + expect(setupFromHash('#setup=')).toBeNull(); + expect(setupFromHash('#setup=d_bf0b30e9&x=1')).toBeNull(); + expect(setupFromHash('#setup=../../api')).toBeNull(); + }); + + it('names the device being set up by its kind, not its name', () => { + expect(deviceNoun('phone')).toBe('phone'); + expect(deviceNoun('computer')).toBe('computer'); + expect(deviceNoun('other')).toBe('device'); + }); + + it('knows whether the page is open on the device being set up', () => { + expect(sameDevice('phone', 'ios')).toBe(true); + expect(sameDevice('phone', 'mac')).toBe(false); + expect(sameDevice('computer', 'windows')).toBe(true); + expect(sameDevice('computer', 'android')).toBe(false); + expect(sameDevice('router', 'linux')).toBe(false); + expect(sameDevice('phone', 'unknown')).toBe(false); + }); + + it('lists the apps a disguise allows, AmneziaVPN first', () => { + expect(appsFor('max').map((a) => a.id)).toEqual(['vpn', 'awg']); + expect(appsFor('off').map((a) => a.id)).toEqual(['vpn', 'awg', 'wg']); + expect(appsFor('balanced')[0].need).toBe('4.8.12'); + expect(updateLine(appsFor('balanced')[0])).toContain('4.8.12 or newer'); + expect(updateLine(appsFor('max')[0])).toContain('the current version'); + expect(updateLine(appsFor('off')[0])).toBe(''); + }); + + it('sends people to the store first and to GitHub where no store has the app', () => { + expect(storeFor('vpn', 'ios')?.mark).toBe('appstore'); + expect(storeFor('vpn', 'android')?.alt?.mark).toBe('github'); + expect(storeFor('vpn', 'windows')?.href).toContain('github.com/amnezia-vpn/amnezia-client'); + expect(storeFor('awg', 'mac')?.main).toBe('Mac App Store'); + expect(storeFor('wg', 'ios')?.alt).toBeUndefined(); + expect(storeFor('vpn', 'unknown')).toBeNull(); + }); + + it('spots in-app browsers', () => { + expect(inWebview(`${ANDROID} Telegram-Android/10.0`)).toBe(true); + expect(inWebview(IPHONE)).toBe(false); + }); +});