From 29b1d7dfd74839b619ea929313aad2f317bbfced Mon Sep 17 00:00:00 2001 From: Aemeath <35622087+tickcount@users.noreply.github.com> Date: Fri, 16 Oct 2026 03:52:21 +0300 Subject: [PATCH] Dawnline 0.4.2 - Connections show up at once: the agent looks at the tunnels every second and, the moment a device connects or roams, writes it to the activity log, updates traffic and the map, and locates the new address - A device counts as gone when its WireGuard session expires (1-3 min after it leaves), so a phone asleep no longer flaps between disconnect and connect - The admin pages follow along within seconds: Overview, People, the person page and the device panel refresh when something happens, with a light check every 2 s instead of reloading everything every 10 s - The personal portal no longer refreshes itself in the background: every request costs the router a CGI process, so it loads once and after the visitor's own changes - Agent guidance and code standards (backend, frontend, shell, UI) now live in the repository: AGENTS.md and rules/ --- AGENTS.md | 35 +++++ package/luci-app-dawnline/Makefile | 2 +- .../luci-static/resources/dawnline/app.js | 32 ++-- .../root/usr/libexec/dawnline/agent | 145 +++++++++++++----- .../share/dawnline/portal/assets/portal.js | 10 +- .../share/rpcd/acl.d/luci-app-dawnline.json | 1 + .../root/usr/share/ucode/dawnline/access.uc | 2 +- .../root/usr/share/ucode/dawnline/live.uc | 39 ++++- .../usr/share/ucode/dawnline/rpc/status.uc | 19 ++- .../root/usr/share/ucode/dawnline/util.uc | 2 +- .../root/usr/share/ucode/dawnline/view.uc | 2 +- rules/backend.md | 30 ++++ rules/code-standards.md | 36 +++++ rules/frontend.md | 19 +++ rules/shell.md | 7 + rules/ui-design.md | 32 ++++ web/package-lock.json | 4 +- web/package.json | 2 +- web/src/admin/api.ts | 1 + web/src/admin/device.ts | 17 +- web/src/admin/pages/people.ts | 3 +- web/src/admin/pages/person/index.ts | 6 +- web/src/admin/pages/server.ts | 3 +- web/src/admin/state/live.ts | 31 ++++ web/src/admin/state/poller.ts | 25 ++- web/src/portal/main.ts | 18 +-- 26 files changed, 419 insertions(+), 104 deletions(-) create mode 100644 AGENTS.md create mode 100644 rules/backend.md create mode 100644 rules/code-standards.md create mode 100644 rules/frontend.md create mode 100644 rules/shell.md create mode 100644 rules/ui-design.md create mode 100644 web/src/admin/state/live.ts diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..ae85211 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,35 @@ +# AGENTS.md — Dawnline + +Guidance for coding agents working in this repository (`tickcount/luci-app-dawnline`): an AmneziaWG access server for OpenWrt with a LuCI admin UI and a personal portal. `CLAUDE.md` points here. + +## Rules + +- `rules/code-standards.md` — how all code is written: decomposition, one locked writer, fail closed, validation at the boundary, comments and commits. +- `rules/backend.md` — ucode on the router: module layers, conventions, what things cost there (CGI portal, rpcd, the agent's watcher). +- `rules/frontend.md` — TypeScript admin UI and portal: layout of `web/src`, pollers and the live revision. +- `rules/shell.md` — install, uninstall, init and CI scripts. +- `rules/ui-design.md` — how the admin UI and the portal look: modern product quality, mock first from the real CSS and components, verified in the browser. + +This repo usually sits inside the router-admin workspace (`../AGENTS.md`). Its rules apply to anything that touches the router: read-only first, backup before mutating, router shell as a literal stdin heredoc over SSH (`../rules/`). + +## Layout + +- `package/luci-app-dawnline/root/` — what lands on the router: ucode modules in `usr/share/ucode/dawnline/` (`rpc/` for the LuCI backend), the agent and updater in `usr/libexec/dawnline/`, the portal in `usr/share/dawnline/portal/`, the init script, rpcd ACL. +- `web/` — TypeScript sources of the admin UI (`src/admin`) and the portal (`src/portal`), shared code in `src/shared`; the built bundles are committed under `package/`. +- `install.sh`, `uninstall.sh` — the standalone installer and uninstaller (both have `--dry-run`). +- `scripts/` — `lint-ucode.py`, `check-ucode.sh` (compiles every module on the router without installing), `deploy.sh` (dev deploy over SSH), `build-packages.sh`, `build-release.sh`, `release-notes.sh`. + +## Checks before a commit or deploy + +- `python3 scripts/lint-ucode.py` and `scripts/check-ucode.sh` (needs the router); new ucode entry points are added to the compile list there and to the executables list in `.github/workflows/ci.yml`. +- In `web/`: `npm run format:check`, `npm run typecheck`, `npm test`, `npm run build` — and commit the rebuilt bundles. +- `shellcheck -S warning` for the shell scripts (CI runs it). + +## Releases + +- A release is one commit on `main` titled `Dawnline X.Y.Z`; its body is `- ` points, which become the GitHub release notes and the Components "What's new". Work from a branch is squashed into that one commit. +- Bump the version in `package/luci-app-dawnline/Makefile` (`PKG_VERSION`), `util.uc` (`VERSION`), `web/package.json` and `web/package-lock.json` (CI checks they agree). +- No `Co-Authored-By` or other agent attribution in commits. +- Push `main`, then an annotated tag `vX.Y.Z` ("Dawnline X.Y.Z"); the "Build packages" workflow publishes the `.ipk`, `.apk` and `sha256sums.txt`. +- Re-cutting a release (fixes before anyone installs) rewrites `main`: force-push, `gh release delete vX.Y.Z --cleanup-tag`, cancel a running build of the old tag, tag again. Only with the user's go-ahead. +- On the router, install a release the way Components does: `/usr/libexec/dawnline/updater install app@vX.Y.Z` (verified against the release's sha256). diff --git a/package/luci-app-dawnline/Makefile b/package/luci-app-dawnline/Makefile index 935562d..40d71d6 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.4.1 +PKG_VERSION:=0.4.2 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 746ad3f..2e158f2 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 Ra=Object.create;var jn=Object.defineProperty;var Ha=Object.getOwnPropertyDescriptor;var Ia=Object.getOwnPropertyNames;var Ba=Object.getPrototypeOf,Oa=Object.prototype.hasOwnProperty;var ja=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Ua=(n,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ia(t))!Oa.call(n,r)&&r!==o&&jn(n,r,{get:()=>t[r],enumerable:!(a=Ha(t,r))||a.enumerable});return n};var Wa=(n,t,o)=>(o=n!=null?Ra(Ba(n)):{},Ua(t||!n||!n.__esModule?jn(o,"default",{value:n,enumerable:!0}):o,n));var Qn=ja((Vn,Yn)=>{"use strict";var Jn=(function(){var n=function(w,H){var S=236,T=17,b=w,A=o[H],u=null,f=0,N=null,P=[],I={},J=function(M,_){f=b*4+17,u=(function(k){for(var z=new Array(k),y=0;y=7&&Q(M),N==null&&(N=me(b,A,P)),O(N,_)},W=function(M,_){for(var k=-1;k<=7;k+=1)if(!(M+k<=-1||f<=M+k))for(var z=-1;z<=7;z+=1)_+z<=-1||f<=_+z||(0<=k&&k<=6&&(z==0||z==6)||0<=z&&z<=6&&(k==0||k==6)||2<=k&&k<=4&&2<=z&&z<=4?u[M+k][_+z]=!0:u[M+k][_+z]=!1)},q=function(){for(var M=0,_=0,k=0;k<8;k+=1){J(!0,k);var z=r.getLostPoint(I);(k==0||M>z)&&(M=z,_=k)}return _},C=function(){for(var M=8;M>k&1)==1;u[Math.floor(k/3)][k%3+f-8-3]=z}for(var k=0;k<18;k+=1){var z=!M&&(_>>k&1)==1;u[k%3+f-8-3][Math.floor(k/3)]=z}},de=function(M,_){for(var k=A<<3|_,z=r.getBCHTypeInfo(k),y=0;y<15;y+=1){var B=!M&&(z>>y&1)==1;y<6?u[y][8]=B:y<8?u[y+1][8]=B:u[f-15+y][8]=B}for(var y=0;y<15;y+=1){var B=!M&&(z>>y&1)==1;y<8?u[8][f-y-1]=B:y<9?u[8][15-y-1+1]=B:u[8][15-y-1]=B}u[f-8][8]=!M},O=function(M,_){for(var k=-1,z=f-1,y=7,B=0,Y=r.getMaskFunction(_),V=f-1;V>0;V-=2)for(V==6&&(V-=1);;){for(var ce=0;ce<2;ce+=1)if(u[z][V-ce]==null){var be=!1;B>>y&1)==1);var ee=Y(z,V-ce);ee&&(be=!be),u[z][V-ce]=be,y-=1,y==-1&&(B+=1,y=7)}if(z+=k,z<0||f<=z){z-=k,k=-k;break}}},F=function(M,_){for(var k=0,z=0,y=0,B=new Array(_.length),Y=new Array(_.length),V=0;V<_.length;V+=1){var ce=_[V].dataCount,be=_[V].totalCount-ce;z=Math.max(z,ce),y=Math.max(y,be),B[V]=new Array(ce);for(var ee=0;ee=0?In.getAt(Bn):0}}for(var On=0,ee=0;ee<_.length;ee+=1)On+=_[ee].totalCount;for(var hn=new Array(On),Nt=0,ee=0;eeV*8)throw"code length overflow. ("+y.getLengthInBits()+">"+V*8+")";for(y.getLengthInBits()+4<=V*8&&y.put(0,4);y.getLengthInBits()%8!=0;)y.putBit(!1);for(;!(y.getLengthInBits()>=V*8||(y.put(S,8),y.getLengthInBits()>=V*8));)y.put(T,8);return F(y,z)};I.addData=function(M,_){_=_||"Byte";var k=null;switch(_){case"Numeric":k=p(M);break;case"Alphanumeric":k=c(M);break;case"Byte":k=m(M);break;case"Kanji":k=v(M);break;default:throw"mode:"+_}P.push(k),N=null},I.isDark=function(M,_){if(M<0||f<=M||_<0||f<=_)throw M+","+_;return u[M][_]},I.getModuleCount=function(){return f},I.make=function(){if(b<1){for(var M=1;M<40;M++){for(var _=l.getRSBlocks(M,A),k=d(),z=0;z"u"?M*4:_;var k="";k+='";for(var y=0;y';k+=""}return k+="",k+="
",k},I.createSvgTag=function(M,_,k,z){var y={};typeof arguments[0]=="object"&&(y=arguments[0],M=y.cellSize,_=y.margin,k=y.alt,z=y.title),M=M||2,_=typeof _>"u"?M*4:_,k=typeof k=="string"?{text:k}:k||{},k.text=k.text||null,k.id=k.text?k.id||"qrcode-description":null,z=typeof z=="string"?{text:z}:z||{},z.text=z.text||null,z.id=z.text?z.id||"qrcode-title":null;var B=I.getModuleCount()*M+_*2,Y,V,ce,be,ee="",Se;for(Se="l"+M+",0 0,"+M+" -"+M+",0 0,-"+M+"z ",ee+=''+re(z.text)+"":"",ee+=k.text?''+re(k.text)+"":"",ee+='',ee+='"u"?M*4:_;var k=I.getModuleCount()*M+_*2,z=_,y=k-_;return j(k,k,function(B,Y){if(z<=B&&B"u"?M*4:_;var z=I.getModuleCount()*M+_*2,y="";return y+="",y};var re=function(M){for(var _="",k=0;k":_+=">";break;case"&":_+="&";break;case'"':_+=""";break;default:_+=z;break}}return _},ge=function(M){var _=1;M=typeof M>"u"?_*2:M;var k=I.getModuleCount()*_+M*2,z=M,y=k-M,B,Y,V,ce,be,ee={"██":"█","█ ":"▀"," █":"▄"," ":" "},Se={"██":"▀","█ ":"▀"," █":" "," ":" "},Ce="";for(B=0;B=y?Se[be]:ee[be];Ce+=` -`}return k%2&&M>0?Ce.substring(0,Ce.length-k-1)+Array(k+1).join("▀"):Ce.substring(0,Ce.length-1)};return I.createASCII=function(M,_){if(M=M||1,M<2)return ge(_);M-=1,_=typeof _>"u"?M*2:_;var k=I.getModuleCount()*M+_*2,z=_,y=k-_,B,Y,V,ce,be=Array(M+1).join("██"),ee=Array(M+1).join(" "),Se="",Ce="";for(B=0;B>>8),A.push(N&255)):A.push(T)}}return A}};var t={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 w=[[],[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]],H=1335,S=7973,T=21522,b={},A=function(u){for(var f=0;u!=0;)f+=1,u>>>=1;return f};return b.getBCHTypeInfo=function(u){for(var f=u<<10;A(f)-A(H)>=0;)f^=H<=0;)f^=S<5&&(N+=3+J-5)}for(var P=0;P=256;)b-=255;return w[b]},T})();function s(w,H){if(typeof w.length>"u")throw w.length+"/"+H;var S=(function(){for(var b=0;b"u")throw"bad rs block @ typeNumber:"+b+"/errorCorrectionLevel:"+A;for(var f=u.length/3,N=[],P=0;P>>7-T%8&1)==1},S.put=function(T,b){for(var A=0;A>>b-A-1&1)==1)},S.getLengthInBits=function(){return H},S.putBit=function(T){var b=Math.floor(H/8);w.length<=b&&w.push(0),T&&(w[b]|=128>>>H%8),H+=1},S},p=function(w){var H=t.MODE_NUMBER,S=w,T={};T.getMode=function(){return H},T.getLength=function(u){return S.length},T.write=function(u){for(var f=S,N=0;N+2>>8&255)*192+(P&255),u.put(P,13),N+=2}if(N>>8)},H.writeBytes=function(S,T,b){T=T||0,b=b||S.length;for(var A=0;A0&&(S+=","),S+=w[T];return S+="]",S},H},x=function(){var w=0,H=0,S=0,T="",b={},A=function(f){T+=String.fromCharCode(u(f&63))},u=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 b.writeByte=function(f){for(w=w<<8|f&255,H+=8,S+=1;H>=6;)A(w>>>H-6),H-=6},b.flush=function(){if(H>0&&(A(w<<6-H),w=0,H=0),S%3!=0)for(var f=3-S%3,N=0;N=H.length){if(b==0)return-1;throw"unexpected end of file./"+b}var f=H.charAt(S);if(S+=1,f=="=")return b=0,-1;if(f.match(/^\s$/))continue;T=T<<6|u(f.charCodeAt(0)),b+=6}var N=T>>>b-8&255;return b-=8,N};var u=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 A},$=function(w,H){var S=w,T=H,b=new Array(w*H),A={};A.setPixel=function(P,I,J){b[I*S+P]=J},A.write=function(P){P.writeString("GIF87a"),P.writeShort(S),P.writeShort(T),P.writeByte(128),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(255),P.writeByte(255),P.writeByte(255),P.writeString(","),P.writeShort(0),P.writeShort(0),P.writeShort(S),P.writeShort(T),P.writeByte(0);var I=2,J=f(I);P.writeByte(I);for(var W=0;J.length-W>255;)P.writeByte(255),P.writeBytes(J,W,255),W+=255;P.writeByte(J.length-W),P.writeBytes(J,W,J.length-W),P.writeByte(0),P.writeString(";")};var u=function(P){var I=P,J=0,W=0,q={};return q.write=function(C,G){if(C>>>G)throw"length over";for(;J+G>=8;)I.writeByte(255&(C<>>=8-J,W=0,J=0;W=C<0&&I.writeByte(W)},q},f=function(P){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 t(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof Vn=="object"&&(Yn.exports=n())})(function(){return Jn})});function fn(n,t){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>fn(o,t)):t.push(n instanceof Node?n:String(n))),t}function e(n,t,o){let a=window.E,r=t!=null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Node);return!r&&o===void 0?a(n,{},fn(t,[])):a(n,r?t:{},fn(o,[]))}function K(n,t=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:t});return async(...a)=>{let r=await o(...a);if(r&&typeof r=="object"&&typeof r.error=="string")throw new Error(r.error);return r}}var Ga=K("logs_clear",["person","device","category","older_days"]),qa=(n={})=>Ga(n.person??"",n.device??"",n.category??"",n.older_days??""),Fa=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 Ka(n,t){let a=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(i=>t[i]),t.paused,t.services,t.circle,t.home_nets],r=await Fa(...a);if(r&&typeof r.error=="string")throw new Error(r.error);return r}var Ja=K("status",["days"]),E={personUpdate:Ka,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"]),logsClear:qa,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:Ja,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"]),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"]),personDelete:K("person_delete",["id"]),personUsage:K("person_usage",["id","days"]),pauseAll:K("pause_all",["paused"]),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"])};var Un={phone:'',computer:'',tablet:'',router:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function gn(n,t="dl-icon"){let o=Un[n]??Un.phone;return``}function g(n,t="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=gn(n,t),o}function Z(n,t="info",o=0){let a=document.querySelector(".dl-toasts");a||(a=e("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(a));let r=t==="error"?"x":t==="warning"?"alert":t==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=e("div",{class:`dl-toast ${t}`},[r?g(r):"",e("span",{},n),t==="error"?e("button",{type:"button","aria-label":"Close",click:i},g("x")):""]);a.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,o||(t==="error"?8e3:t==="warning"?5e3:2600))}function ve(n){return n instanceof Error?n.message:String(n)}async function U(n,t){try{let o=await n();return t&&Z(t,"success",3500),o}catch(o){Z(ve(o),"error",1e4);return}}function Wn(n){try{let t=n();t&&typeof t.then=="function"&&t.catch(o=>Z(ve(o),"error"))}catch(t){Z(ve(t),"error")}}function D(n,t,o="neutral",a={}){let{disabled:r,...i}=a,s=e("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 t(l)}catch(d){Z(ve(d),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!r,s}function ye(n,t,o,a="neutral",r=""){return D([g(n),e("span",{class:"dl-btn-label"},t)],o,a,{title:t,class:`cbi-button cbi-button-${a} dl-icon-btn ${r}`.trim()})}function Ge(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var it=null;function vn(n=!1){let t=it;it=null,t?.(n)}function oe(n,t,o,a=""){vn(),ui.showModal(n,[e("div",{class:`dl-modal ${a}`},t),e("div",{class:"button-row"},o)])}function se(){vn(),ui.hideModal()}function ie(n="Cancel",t=!1){return e("button",{class:`cbi-button ${t?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:se},n)}function ne(n,t,o="Confirm",a=!1){return new Promise(r=>{oe(n,t,[ie()," ",e("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=it;it=null,ui.hideModal(),i?.(!0)}},o)]),it=r})}Ge(()=>{it&&(vn(),ui.hideModal())});async function pe(n,t="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let o=e("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.")}Z(t,"success",2500)}catch(o){Z(ve(o),"error")}}function $e(n,t,o="text/plain"){let a=globalThis,r=typeof t=="string"?new a.Blob([t],{type:o}):t,i=URL.createObjectURL(r),s=e("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function bn(n,t){return new Promise(o=>{let a=e("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:t==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>o(null),t==="base64"?i.readAsDataURL(r):i.readAsText(r)}),document.body.appendChild(a),a.click()})}function we(n,t){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let a=e("div",{class:"dl-dd dl-root",role:"menu"},t.map(m=>m?e("button",{type:"button",role:"menuitem",class:m.danger?"danger":m.warn?"warn":"",click:()=>{c(),Wn(m.run)}},[m.icon??"",e("span",{},m.label)]):e("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=m=>{!a.contains(m.target)&&!n.contains(m.target)&&c()},d=m=>{m.key==="Escape"&&c()},p=Ge(c);a.dlAnchor=n,a.dlClose=c;function c(){a.remove(),p(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",c,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",c,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var Ze=null,xn=null,wn=0;function yn(){Ze&&(Ze.style.display="none"),xn=null,clearInterval(wn),wn=0}function ue(n,t){let o=a=>{Ze??(Ze=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),Ze.replaceChildren(...t().map(r=>typeof r=="string"?document.createTextNode(r):r)),Ze.style.display="",Ze.style.left=`${a.clientX}px`,Ze.style.top=`${a.clientY-10}px`,xn=n,wn||(wn=window.setInterval(()=>{xn?.isConnected||yn()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",yn)}Ge(yn);function te(n){if(!n||n<0)return"0 B";let t=["B","KB","MB","GB","TB"],o=0,a=n;for(;a>=1024&&o=100||o===0?Math.round(a):a.toFixed(1)} ${t[o]}`}function Pe(n){let t=n*8;return t<1e3?`${Math.round(t)} bit/s`:t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)} kbit/s`:t<1e9?`${(t/1e6).toFixed(t<1e7?1:0)} Mbit/s`:`${(t/1e9).toFixed(1)} Gbit/s`}function le(n,t=Date.now()/1e3){if(!n)return"never";let o=Math.max(0,Math.round(t-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 st(n){if(!n||n<0)return"—";let t=Math.floor(n/86400),o=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return t?`${t}d ${o}h`:o?`${o}h ${a}m`:`${a}m`}function wt(n){let t=new Date(n*1e3),o=new Date,a=t.toDateString()===o.toDateString(),r=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?r:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${r}`}function De(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function lt(n){let[t,o,a]=n.split("-").map(Number);return new Date(t,(o||1)-1,a||1,12)}function Ae(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?lt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ze(n){return n?Ae(n):""}function kn(n,t){let o=a=>{let[r,i,s]=a.split("-").map(Number);return Date.UTC(r,i-1,s)};return Math.round((o(n)-o(t))/864e5)}function bt(n,t){let o=lt(n);return o.setDate(o.getDate()+t),De(o)}function xt(n,t){let[o,a,r]=n.split("-").map(Number),i=new Date(o,a-1+t,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(r,s)),De(i)}function Ne(n){return n?.length?n[n.length-1].day:De(new Date)}function Gn(n,t,o,a,r=30){let i=n||a;return t==="day"?bt(i,o):t==="week"?bt(i,7*o):t==="month"?xt(i,o):t==="year"?xt(i,12*o):bt(i,r*o)}function Xe(n,t=Date.now()){if(!n)return null;let o=typeof t=="number"?De(new Date(t)):t,a=kn(n,o);return a>=0?a+1:a}function Rt(n,t,o=`${t}s`){return`${n.toLocaleString("en-GB")} ${n===1?t:o}`}function yt(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var et={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var qn=["computer","phone","tablet","router","other"],Be={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},$n={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Oe(n){let t=n.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let o=t[0][0]??"",a=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(o+a).toUpperCase()}function Ht(n){let t=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,a)=>[o,a]).sort((o,a)=>t(o[0])-t(a[0])||o[1]-a[1]).map(([o])=>o)}function ke(n,t,o){return e("span",{class:`dl-pill ${n}`,title:o??null},t)}var Va={active:"",paused:"pause",paused_all:"pause",expired:"calendar",quota:"chart",hours:"clock",no_server:"alert"};function Ya(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function It(n){if(n.state==="active")return"";let t=e("span",{class:`dl-ibadge ${Ya(n)}`,"aria-label":$n[n.state]},g(Va[n.state]||"alert"));return ue(t,()=>[e("div",{class:"dl-tip-title"},$n[n.state])]),t}function Fn(n){let t=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=e("span",{class:"dl-access","aria-label":et[n.access]},t.map(a=>e("span",{class:`dl-ibadge ${a}`},g(a==="lan"?"home":"globe"))));return ue(o,()=>[e("div",{class:"dl-tip-title"},et[n.access]),n.access==="lan"&&n.services?.length?e("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),o}function Bt(n,t,o="Not set up yet"){return n.disabled?e("span",{class:"dl-dstat"},"Disabled"):n.online?e("span",{class:"dl-dstat ok"},"Connected"):n.handshake?e("span",{class:"dl-dstat"},`Last seen ${le(n.handshake,t)}`):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},o)}var Ot=null;function Kn(n,t,o,a){Ot?.close();let r=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[n,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>p()},g("x"))]),e("div",{class:"dl-drawer-body"},t),o?e("div",{class:"dl-drawer-foot"},o):""]),i=e("div",{class:"dl-drawer-overlay dl-root",click:m=>{m.target===i&&p()}},r),s=m=>{m.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&p()},l=!1,d=Ge(()=>p());function p(){l||(l=!0,d(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),Ot===c&&(Ot=null),a())}let c={close:p,panel:r};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),Ot=c,c}function X(n,t,o){return e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},n),o?e("span",{class:"dl-sub"},o):""]),e("div",{class:"dl-setrow-ctl"},t)])}function kt(n,t,o,a=""){return e("section",{class:`dl-setsec ${a}`},[e("div",{class:"dl-setsec-body"},[n?e("h3",{},n):"",...t]),o.length?e("div",{class:"dl-setsec-foot"},o):""])}function he(n,t,o,a){return e("div",{class:"dl-group"},[e("div",{class:"dl-group-head"},[e("span",{class:"dl-group-ic"},g(n)),e("span",{class:"dl-stack"},[e("b",{},t),o?e("span",{class:"dl-sub"},o):""])]),e("div",{class:"dl-group-body"},a.filter(r=>r!==""))])}function tt(n,t,o,a,r){return e("div",{class:`dl-row dl-need-row ${t}`},[t?e("span",{class:"dl-need-ic"},g(n)):g(n),e("span",{class:"dl-row-main dl-stack"},[e("b",{},o),e("span",{class:"dl-sub"},a)]),r])}function dt(n,t){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return e("div",{class:`alert-message ${o}`},t)}function qe(n,t=""){let o=e("div",{class:t});return o.innerHTML=n,o}var Zn=Wa(Qn(),1),Qa='';function ct(n,t=3,o=!0){let a=(0,Zn.default)(0,n.length>300?"Q":"H");a.addData(n,"Byte"),a.make();let r=a.getModuleCount(),i=r+t*2,s=o?Math.round(r*.22):0;s&&(r-s)%2&&s++;let l=(r-s)/2,d=l+s,p=(v,h)=>s>0&&v>=l&&v=l&&h${Qa}`}return`${m}`}var Za={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",paused_all:"people",resumed_all:"people",portal_blocked:"problems"},pt=["connections","people","problems"],nt={connections:"Connections",people:"People",problems:"Problems"},Xn={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=>Za[n]??"problems",_t={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},Xa=["person_added","person_removed","person_changed","paused_all","resumed_all"];function Le(n){return n.by?n.by:Xa.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function eo(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var jt=n=>n.sys?["error","repair","down"].includes(n.sys.level):$t(n.ev.type)==="problems";function Ut(n){let t=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 ${t}, up to ${n.max.toLocaleString("en-GB")} events, ${o}.`}function to(n,t=120,o=26,a=De(new Date)){let r=Math.max(1,...n),i=e("div",{class:"dl-spark"});return i.style.width=`${t}px`,i.style.height=`${o}px`,n.forEach((s,l)=>{let d=e("i");d.style.height=`${Math.max(6,s/r*100)}%`,s||d.classList.add("zero");let p=n.length-1-l;ue(d,()=>[e("div",{class:"dl-tip-title"},p===0?"Today":p===1?"Yesterday":lt(bt(a,-p)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},te(s))]),i.appendChild(d)}),i}function er(n){let t=n==null?"":String(n);return/^[=+\-@\t\r]/.test(t)&&(t=`'${t}`),/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function no(n,t){return[n.join(","),...t.map(o=>n.map(a=>er(o[a])).join(","))].join(` -`)}function tr(n){let t=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:t,devices:o}}function je(n,t,o,a="",r=[]){let i=tr(n),s=[...t.map(c=>({ts:c.ts,category:$t(c.type),type:c.type,person:c.person?i.people.get(c.person)??c.pname??c.person:"",device:c.device?i.devices.get(c.device)??c.dname??c.device:"",detail:c.detail??"",where:c.where??"",by:Le(c)??""})),...r.map(c=>({ts:c.ts,category:"system",type:`${c.src}.${c.level}`,person:"",device:"",detail:`${c.who?`${c.who} `:""}${c.msg}${c.detail?` -${c.detail}`:""}`,where:_t[c.src]??c.src,by:""}))].sort((c,m)=>c.ts-m.ts).map(({ts:c,...m})=>({time:new Date(c*1e3).toISOString(),...m})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${a?`-${a}`:""}-${l}.${o}`;if(o==="json"){$e(d,JSON.stringify(s,null,2),"application/json");return}$e(d,no(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var nr=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],oo=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function Fe(n,t,o,a,r,i=!1){let s=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...pt.map(d=>e("option",{value:d,selected:d===r?"selected":null},nt[d])),i?e("option",{value:"system",selected:r==="system"?"selected":null},"System"):""]),l=e("select",{class:"cbi-input-select"},nr.map(([d,p])=>e("option",{value:d},p)));oe(n,[e("p",{class:"dl-muted"},`${t} This cannot be undone; export first if you want a copy.`),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Category"),s]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Which events"),l])],[ie()," ",D("Clear",async()=>{let d=0;if(s.value!=="system")try{d+=(await E.logsClear({...o,category:s.value,older_days:l.value})).removed}catch(p){Z(ve(p),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{d+=(await E.serviceLogClear(l.value)).removed}catch(p){se(),Z(`${s.value==="system"?"":`Activity: ${oo(d).toLowerCase()}. `}The service log was not cleared: ${ve(p)}`,"error",1e4),a();return}se(),Z(oo(d),"success",3e3),a()},"negative")])}function ut(n,t,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.";oe(n==="all"?"Reset all traffic history?":`Reset traffic history for ${o}?`,[e("p",{class:"dl-muted"},r)],[ie()," ",D("Reset",async()=>{await U(()=>E.usageClear(n,t),"Traffic history reset")&&(se(),a())},"negative")])}function fe(n,t,o){let a=e("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":t,click:()=>{let r=!a.classList.contains("on");_n(a,r),o?.(r)}},e("i"));return a}function _n(n,t){n.classList.toggle("on",t),n.setAttribute("aria-checked",t?"true":"false")}var Ee=n=>n.classList.contains("on");function xe(n,t,o={}){n.some(([i])=>i===t)||(n=[...n,[t,t]]);let a=e("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":t}),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(e("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 Ue(n,t,o,a={}){return e("button",{type:"button",...a,class:`dl-chipbtn${t?" on":""}${a.class?` ${a.class}`:""}`,"aria-pressed":t?"true":"false",click:o},n)}function Wt(n,t){n.classList.toggle("on",t),n.setAttribute("aria-pressed",t?"true":"false")}function ae(n,t={}){return e("input",{type:"text",class:"cbi-input-text",value:n,...t})}var or={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:""},ar={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 rr(n){let t={};for(let[o,a]of Object.entries(ar))n[o]!=null&&n[o]!==""&&(t[a]=String(n[o]));return t}function ir(n,t){let o=n.amnezia,a=o.obfuscation??{},r=d=>a[d]!=null&&a[d]!==""?String(a[d]):or[d],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"),...rr(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:t,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function sr(n){let t="";for(let o=0;o"u")return null;try{let o=new t.Blob([n]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.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 En(n,t,o=!0){let a=new TextEncoder().encode(JSON.stringify(ir(n,t))),r=o?await lr(a):null;return`vpn://${sr(r??a)}`}var ro=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"standard",title:"Standard",ic:"shield",stealth:2,speed:4,text:"Junk packets and random headers. Gets through most VPN blocking with no speed cost.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"strong",title:"Strong",ic:"shieldplus",stealth:3,speed:3,text:"More and larger junk packets for networks that block VPNs aggressively. Connects a little slower.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],Et=n=>ro.find(t=>t.id===n),dr={v2:"Needs AmneziaWG 1.5 or newer on the router.",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},cr={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function ao(n,t){return e("span",{class:"dl-dots",title:`${t}: ${n} of 4`},[e("span",{class:"dl-dots-label"},t),e("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>e("i",{class:odom.content(i,ro.map(l=>{let d=!l.needs||n[l.needs],p=l.id===t;return e("button",{type:"button",role:"radio","aria-checked":p?"true":"false","aria-disabled":d?null:"true",class:`dl-method${p?" on":""}${d?"":" off"}`,click:()=>{!d||p||(t=l.id,s(),o(l.id))}},[e("div",{class:"dl-method-head"},[e("span",{class:"dl-method-ic"},g(l.ic)),e("b",{},l.title),l.id===a?e("span",{class:"dl-pill ok"},"Current"):""]),e("p",{},l.text),e("div",{class:"dl-method-meters"},[ao(l.stealth,"Stealth"),ao(l.speed,"Speed")]),e("div",{class:"dl-method-foot"},d?[g("phone"),e("span",{},l.apps)]:[g("alert"),e("span",{},(r?dr:cr)[l.needs])])])}));return s(),i}function io(n,t,o,a){return e("div",{class:"dl-corehead"},[e("h3",{},n),e("span",{class:`dl-pill ${t}`},o),a?e("span",{class:"dl-sub"},a):""])}var so=[["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 pr(n){let t=p=>n[p]!=null&&n[p]!=="",o=so.filter(([p])=>t(p));if(!o.length)return null;let a=(p,c)=>e("span",{class:"dl-pv"},[e("i",{},c),e("b",{},p==="header_protection_key"?`${n[p].slice(0,6)}••••`:n[p])]),r=(p,c,m,v)=>{let h=so.filter(([x])=>v.includes(x)&&t(x));return h.length?e("div",{class:"dl-pgroup"},[e("div",{class:"dl-pgroup-head"},[g(c),e("b",{},p)]),e("p",{},m),e("div",{class:"dl-pvals"},h.map(([x,R])=>a(x,R)))]):""},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(([p,c])=>`${c} = ${n[p]}`).join(` -`),d=e("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 e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(o.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:p=>{p.preventDefault(),pe(l,"Parameters copied")}},"Copy as config")]),d])}function lo(n,t){if(/^\s*\[.+\]\s*$/.test(n))return e("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 e("span",{},[e("span",{class:"dl-conf-k"},o[1])," ",a&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function ur(n){let t=!1,o=e("pre",{class:"dl-conf"}),a=()=>dom.content(o,n.conf.split(` +var Oa=Object.create;var Gn=Object.defineProperty;var ja=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var Wa=Object.getPrototypeOf,Ga=Object.prototype.hasOwnProperty;var qa=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Fa=(n,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ua(t))!Ga.call(n,r)&&r!==o&&Gn(n,r,{get:()=>t[r],enumerable:!(a=ja(t,r))||a.enumerable});return n};var Ka=(n,t,o)=>(o=n!=null?Oa(Wa(n)):{},Fa(t||!n||!n.__esModule?Gn(o,"default",{value:n,enumerable:!0}):o,n));var eo=qa((Zn,Xn)=>{"use strict";var Qn=(function(){var n=function(w,I){var C=236,T=17,b=w,A=o[I],u=null,f=0,N=null,P=[],H={},J=function(M,E){f=b*4+17,u=(function(k){for(var z=new Array(k),y=0;y=7&&q(M),N==null&&(N=me(b,A,P)),O(N,E)},W=function(M,E){for(var k=-1;k<=7;k+=1)if(!(M+k<=-1||f<=M+k))for(var z=-1;z<=7;z+=1)E+z<=-1||f<=E+z||(0<=k&&k<=6&&(z==0||z==6)||0<=z&&z<=6&&(k==0||k==6)||2<=k&&k<=4&&2<=z&&z<=4?u[M+k][E+z]=!0:u[M+k][E+z]=!1)},te=function(){for(var M=0,E=0,k=0;k<8;k+=1){J(!0,k);var z=r.getLostPoint(H);(k==0||M>z)&&(M=z,E=k)}return E},$=function(){for(var M=8;M>k&1)==1;u[Math.floor(k/3)][k%3+f-8-3]=z}for(var k=0;k<18;k+=1){var z=!M&&(E>>k&1)==1;u[k%3+f-8-3][Math.floor(k/3)]=z}},oe=function(M,E){for(var k=A<<3|E,z=r.getBCHTypeInfo(k),y=0;y<15;y+=1){var B=!M&&(z>>y&1)==1;y<6?u[y][8]=B:y<8?u[y+1][8]=B:u[f-15+y][8]=B}for(var y=0;y<15;y+=1){var B=!M&&(z>>y&1)==1;y<8?u[8][f-y-1]=B:y<9?u[8][15-y-1+1]=B:u[8][15-y-1]=B}u[f-8][8]=!M},O=function(M,E){for(var k=-1,z=f-1,y=7,B=0,Y=r.getMaskFunction(E),V=f-1;V>0;V-=2)for(V==6&&(V-=1);;){for(var ce=0;ce<2;ce+=1)if(u[z][V-ce]==null){var be=!1;B>>y&1)==1);var X=Y(z,V-ce);X&&(be=!be),u[z][V-ce]=be,y-=1,y==-1&&(B+=1,y=7)}if(z+=k,z<0||f<=z){z-=k,k=-k;break}}},F=function(M,E){for(var k=0,z=0,y=0,B=new Array(E.length),Y=new Array(E.length),V=0;V=0?jn.getAt(Un):0}}for(var Wn=0,X=0;XV*8)throw"code length overflow. ("+y.getLengthInBits()+">"+V*8+")";for(y.getLengthInBits()+4<=V*8&&y.put(0,4);y.getLengthInBits()%8!=0;)y.putBit(!1);for(;!(y.getLengthInBits()>=V*8||(y.put(C,8),y.getLengthInBits()>=V*8));)y.put(T,8);return F(y,z)};H.addData=function(M,E){E=E||"Byte";var k=null;switch(E){case"Numeric":k=p(M);break;case"Alphanumeric":k=c(M);break;case"Byte":k=m(M);break;case"Kanji":k=v(M);break;default:throw"mode:"+E}P.push(k),N=null},H.isDark=function(M,E){if(M<0||f<=M||E<0||f<=E)throw M+","+E;return u[M][E]},H.getModuleCount=function(){return f},H.make=function(){if(b<1){for(var M=1;M<40;M++){for(var E=l.getRSBlocks(M,A),k=d(),z=0;z"u"?M*4:E;var k="";k+='";for(var y=0;y';k+=""}return k+="",k+="
",k},H.createSvgTag=function(M,E,k,z){var y={};typeof arguments[0]=="object"&&(y=arguments[0],M=y.cellSize,E=y.margin,k=y.alt,z=y.title),M=M||2,E=typeof E>"u"?M*4:E,k=typeof k=="string"?{text:k}:k||{},k.text=k.text||null,k.id=k.text?k.id||"qrcode-description":null,z=typeof z=="string"?{text:z}:z||{},z.text=z.text||null,z.id=z.text?z.id||"qrcode-title":null;var B=H.getModuleCount()*M+E*2,Y,V,ce,be,X="",Se;for(Se="l"+M+",0 0,"+M+" -"+M+",0 0,-"+M+"z ",X+=''+ie(z.text)+"":"",X+=k.text?''+ie(k.text)+"":"",X+='',X+='"u"?M*4:E;var k=H.getModuleCount()*M+E*2,z=E,y=k-E;return j(k,k,function(B,Y){if(z<=B&&B"u"?M*4:E;var z=H.getModuleCount()*M+E*2,y="";return y+="",y};var ie=function(M){for(var E="",k=0;k":E+=">";break;case"&":E+="&";break;case'"':E+=""";break;default:E+=z;break}}return E},ge=function(M){var E=1;M=typeof M>"u"?E*2:M;var k=H.getModuleCount()*E+M*2,z=M,y=k-M,B,Y,V,ce,be,X={"██":"█","█ ":"▀"," █":"▄"," ":" "},Se={"██":"▀","█ ":"▀"," █":" "," ":" "},Ce="";for(B=0;B=y?Se[be]:X[be];Ce+=` +`}return k%2&&M>0?Ce.substring(0,Ce.length-k-1)+Array(k+1).join("▀"):Ce.substring(0,Ce.length-1)};return H.createASCII=function(M,E){if(M=M||1,M<2)return ge(E);M-=1,E=typeof E>"u"?M*2:E;var k=H.getModuleCount()*M+E*2,z=E,y=k-E,B,Y,V,ce,be=Array(M+1).join("██"),X=Array(M+1).join(" "),Se="",Ce="";for(B=0;B>>8),A.push(N&255)):A.push(T)}}return A}};var t={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 w=[[],[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]],I=1335,C=7973,T=21522,b={},A=function(u){for(var f=0;u!=0;)f+=1,u>>>=1;return f};return b.getBCHTypeInfo=function(u){for(var f=u<<10;A(f)-A(I)>=0;)f^=I<=0;)f^=C<5&&(N+=3+J-5)}for(var P=0;P=256;)b-=255;return w[b]},T})();function s(w,I){if(typeof w.length>"u")throw w.length+"/"+I;var C=(function(){for(var b=0;b"u")throw"bad rs block @ typeNumber:"+b+"/errorCorrectionLevel:"+A;for(var f=u.length/3,N=[],P=0;P>>7-T%8&1)==1},C.put=function(T,b){for(var A=0;A>>b-A-1&1)==1)},C.getLengthInBits=function(){return I},C.putBit=function(T){var b=Math.floor(I/8);w.length<=b&&w.push(0),T&&(w[b]|=128>>>I%8),I+=1},C},p=function(w){var I=t.MODE_NUMBER,C=w,T={};T.getMode=function(){return I},T.getLength=function(u){return C.length},T.write=function(u){for(var f=C,N=0;N+2>>8&255)*192+(P&255),u.put(P,13),N+=2}if(N>>8)},I.writeBytes=function(C,T,b){T=T||0,b=b||C.length;for(var A=0;A0&&(C+=","),C+=w[T];return C+="]",C},I},x=function(){var w=0,I=0,C=0,T="",b={},A=function(f){T+=String.fromCharCode(u(f&63))},u=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 b.writeByte=function(f){for(w=w<<8|f&255,I+=8,C+=1;I>=6;)A(w>>>I-6),I-=6},b.flush=function(){if(I>0&&(A(w<<6-I),w=0,I=0),C%3!=0)for(var f=3-C%3,N=0;N=I.length){if(b==0)return-1;throw"unexpected end of file./"+b}var f=I.charAt(C);if(C+=1,f=="=")return b=0,-1;if(f.match(/^\s$/))continue;T=T<<6|u(f.charCodeAt(0)),b+=6}var N=T>>>b-8&255;return b-=8,N};var u=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 A},_=function(w,I){var C=w,T=I,b=new Array(w*I),A={};A.setPixel=function(P,H,J){b[H*C+P]=J},A.write=function(P){P.writeString("GIF87a"),P.writeShort(C),P.writeShort(T),P.writeByte(128),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(255),P.writeByte(255),P.writeByte(255),P.writeString(","),P.writeShort(0),P.writeShort(0),P.writeShort(C),P.writeShort(T),P.writeByte(0);var H=2,J=f(H);P.writeByte(H);for(var W=0;J.length-W>255;)P.writeByte(255),P.writeBytes(J,W,255),W+=255;P.writeByte(J.length-W),P.writeBytes(J,W,J.length-W),P.writeByte(0),P.writeString(";")};var u=function(P){var H=P,J=0,W=0,te={};return te.write=function($,G){if($>>>G)throw"length over";for(;J+G>=8;)H.writeByte(255&($<>>=8-J,W=0,J=0;W=$<0&&H.writeByte(W)},te},f=function(P){for(var H=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 t(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof Zn=="object"&&(Xn.exports=n())})(function(){return Qn})});function vn(n,t){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>vn(o,t)):t.push(n instanceof Node?n:String(n))),t}function e(n,t,o){let a=window.E,r=t!=null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Node);return!r&&o===void 0?a(n,{},vn(t,[])):a(n,r?t:{},vn(o,[]))}function K(n,t=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:t});return async(...a)=>{let r=await o(...a);if(r&&typeof r=="object"&&typeof r.error=="string")throw new Error(r.error);return r}}var Ja=K("logs_clear",["person","device","category","older_days"]),Va=(n={})=>Ja(n.person??"",n.device??"",n.category??"",n.older_days??""),Ya=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 Qa(n,t){let a=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(i=>t[i]),t.paused,t.services,t.circle,t.home_nets],r=await Ya(...a);if(r&&typeof r.error=="string")throw new Error(r.error);return r}var Za=K("status",["days"]),S={rev:K("rev"),personUpdate:Qa,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"]),logsClear:Va,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:Za,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"]),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"]),personDelete:K("person_delete",["id"]),personUsage:K("person_usage",["id","days"]),pauseAll:K("pause_all",["paused"]),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"])};var qn={phone:'',computer:'',tablet:'',router:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function bn(n,t="dl-icon"){let o=qn[n]??qn.phone;return``}function g(n,t="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=bn(n,t),o}function Q(n,t="info",o=0){let a=document.querySelector(".dl-toasts");a||(a=e("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(a));let r=t==="error"?"x":t==="warning"?"alert":t==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=e("div",{class:`dl-toast ${t}`},[r?g(r):"",e("span",{},n),t==="error"?e("button",{type:"button","aria-label":"Close",click:i},g("x")):""]);a.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,o||(t==="error"?8e3:t==="warning"?5e3:2600))}function ve(n){return n instanceof Error?n.message:String(n)}async function U(n,t){try{let o=await n();return t&&Q(t,"success",3500),o}catch(o){Q(ve(o),"error",1e4);return}}function Fn(n){try{let t=n();t&&typeof t.then=="function"&&t.catch(o=>Q(ve(o),"error"))}catch(t){Q(ve(t),"error")}}function D(n,t,o="neutral",a={}){let{disabled:r,...i}=a,s=e("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 t(l)}catch(d){Q(ve(d),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!r,s}function ye(n,t,o,a="neutral",r=""){return D([g(n),e("span",{class:"dl-btn-label"},t)],o,a,{title:t,class:`cbi-button cbi-button-${a} dl-icon-btn ${r}`.trim()})}function Ge(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var it=null;function xn(n=!1){let t=it;it=null,t?.(n)}function ae(n,t,o,a=""){xn(),ui.showModal(n,[e("div",{class:`dl-modal ${a}`},t),e("div",{class:"button-row"},o)])}function le(){xn(),ui.hideModal()}function se(n="Cancel",t=!1){return e("button",{class:`cbi-button ${t?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:le},n)}function ne(n,t,o="Confirm",a=!1){return new Promise(r=>{ae(n,t,[se()," ",e("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=it;it=null,ui.hideModal(),i?.(!0)}},o)]),it=r})}Ge(()=>{it&&(xn(),ui.hideModal())});async function pe(n,t="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let o=e("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.")}Q(t,"success",2500)}catch(o){Q(ve(o),"error")}}function $e(n,t,o="text/plain"){let a=globalThis,r=typeof t=="string"?new a.Blob([t],{type:o}):t,i=URL.createObjectURL(r),s=e("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function wn(n,t){return new Promise(o=>{let a=e("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:t==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>o(null),t==="base64"?i.readAsDataURL(r):i.readAsText(r)}),document.body.appendChild(a),a.click()})}function we(n,t){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let a=e("div",{class:"dl-dd dl-root",role:"menu"},t.map(m=>m?e("button",{type:"button",role:"menuitem",class:m.danger?"danger":m.warn?"warn":"",click:()=>{c(),Fn(m.run)}},[m.icon??"",e("span",{},m.label)]):e("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=m=>{!a.contains(m.target)&&!n.contains(m.target)&&c()},d=m=>{m.key==="Escape"&&c()},p=Ge(c);a.dlAnchor=n,a.dlClose=c;function c(){a.remove(),p(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",c,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",c,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var Ze=null,yn=null,kn=0;function $n(){Ze&&(Ze.style.display="none"),yn=null,clearInterval(kn),kn=0}function ue(n,t){let o=a=>{Ze??(Ze=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),Ze.replaceChildren(...t().map(r=>typeof r=="string"?document.createTextNode(r):r)),Ze.style.display="",Ze.style.left=`${a.clientX}px`,Ze.style.top=`${a.clientY-10}px`,yn=n,kn||(kn=window.setInterval(()=>{yn?.isConnected||$n()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",$n)}Ge($n);function ee(n){if(!n||n<0)return"0 B";let t=["B","KB","MB","GB","TB"],o=0,a=n;for(;a>=1024&&o=100||o===0?Math.round(a):a.toFixed(1)} ${t[o]}`}function Pe(n){let t=n*8;return t<1e3?`${Math.round(t)} bit/s`:t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)} kbit/s`:t<1e9?`${(t/1e6).toFixed(t<1e7?1:0)} Mbit/s`:`${(t/1e9).toFixed(1)} Gbit/s`}function de(n,t=Date.now()/1e3){if(!n)return"never";let o=Math.max(0,Math.round(t-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 st(n){if(!n||n<0)return"—";let t=Math.floor(n/86400),o=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return t?`${t}d ${o}h`:o?`${o}h ${a}m`:`${a}m`}function wt(n){let t=new Date(n*1e3),o=new Date,a=t.toDateString()===o.toDateString(),r=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?r:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${r}`}function De(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function lt(n){let[t,o,a]=n.split("-").map(Number);return new Date(t,(o||1)-1,a||1,12)}function Ae(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?lt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ze(n){return n?Ae(n):""}function _n(n,t){let o=a=>{let[r,i,s]=a.split("-").map(Number);return Date.UTC(r,i-1,s)};return Math.round((o(n)-o(t))/864e5)}function bt(n,t){let o=lt(n);return o.setDate(o.getDate()+t),De(o)}function xt(n,t){let[o,a,r]=n.split("-").map(Number),i=new Date(o,a-1+t,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(r,s)),De(i)}function Ne(n){return n?.length?n[n.length-1].day:De(new Date)}function Kn(n,t,o,a,r=30){let i=n||a;return t==="day"?bt(i,o):t==="week"?bt(i,7*o):t==="month"?xt(i,o):t==="year"?xt(i,12*o):bt(i,r*o)}function Xe(n,t=Date.now()){if(!n)return null;let o=typeof t=="number"?De(new Date(t)):t,a=_n(n,o);return a>=0?a+1:a}function Rt(n,t,o=`${t}s`){return`${n.toLocaleString("en-GB")} ${n===1?t:o}`}function yt(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var et={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var Jn=["computer","phone","tablet","router","other"],Be={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},En={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Oe(n){let t=n.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let o=t[0][0]??"",a=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(o+a).toUpperCase()}function Ht(n){let t=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,a)=>[o,a]).sort((o,a)=>t(o[0])-t(a[0])||o[1]-a[1]).map(([o])=>o)}function ke(n,t,o){return e("span",{class:`dl-pill ${n}`,title:o??null},t)}var Xa={active:"",paused:"pause",paused_all:"pause",expired:"calendar",quota:"chart",hours:"clock",no_server:"alert"};function er(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function It(n){if(n.state==="active")return"";let t=e("span",{class:`dl-ibadge ${er(n)}`,"aria-label":En[n.state]},g(Xa[n.state]||"alert"));return ue(t,()=>[e("div",{class:"dl-tip-title"},En[n.state])]),t}function Vn(n){let t=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=e("span",{class:"dl-access","aria-label":et[n.access]},t.map(a=>e("span",{class:`dl-ibadge ${a}`},g(a==="lan"?"home":"globe"))));return ue(o,()=>[e("div",{class:"dl-tip-title"},et[n.access]),n.access==="lan"&&n.services?.length?e("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),o}function Bt(n,t,o="Not set up yet"){return n.disabled?e("span",{class:"dl-dstat"},"Disabled"):n.online?e("span",{class:"dl-dstat ok"},"Connected"):n.handshake?e("span",{class:"dl-dstat"},`Last seen ${de(n.handshake,t)}`):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},o)}var Ot=null;function Yn(n,t,o,a){Ot?.close();let r=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[n,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>p()},g("x"))]),e("div",{class:"dl-drawer-body"},t),o?e("div",{class:"dl-drawer-foot"},o):""]),i=e("div",{class:"dl-drawer-overlay dl-root",click:m=>{m.target===i&&p()}},r),s=m=>{m.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&p()},l=!1,d=Ge(()=>p());function p(){l||(l=!0,d(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),Ot===c&&(Ot=null),a())}let c={close:p,panel:r};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),Ot=c,c}function Z(n,t,o){return e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},n),o?e("span",{class:"dl-sub"},o):""]),e("div",{class:"dl-setrow-ctl"},t)])}function kt(n,t,o,a=""){return e("section",{class:`dl-setsec ${a}`},[e("div",{class:"dl-setsec-body"},[n?e("h3",{},n):"",...t]),o.length?e("div",{class:"dl-setsec-foot"},o):""])}function he(n,t,o,a){return e("div",{class:"dl-group"},[e("div",{class:"dl-group-head"},[e("span",{class:"dl-group-ic"},g(n)),e("span",{class:"dl-stack"},[e("b",{},t),o?e("span",{class:"dl-sub"},o):""])]),e("div",{class:"dl-group-body"},a.filter(r=>r!==""))])}function tt(n,t,o,a,r){return e("div",{class:`dl-row dl-need-row ${t}`},[t?e("span",{class:"dl-need-ic"},g(n)):g(n),e("span",{class:"dl-row-main dl-stack"},[e("b",{},o),e("span",{class:"dl-sub"},a)]),r])}function dt(n,t){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return e("div",{class:`alert-message ${o}`},t)}function qe(n,t=""){let o=e("div",{class:t});return o.innerHTML=n,o}var to=Ka(eo(),1),tr='';function ct(n,t=3,o=!0){let a=(0,to.default)(0,n.length>300?"Q":"H");a.addData(n,"Byte"),a.make();let r=a.getModuleCount(),i=r+t*2,s=o?Math.round(r*.22):0;s&&(r-s)%2&&s++;let l=(r-s)/2,d=l+s,p=(v,h)=>s>0&&v>=l&&v=l&&h${tr}`}return`${m}`}var nr={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",paused_all:"people",resumed_all:"people",portal_blocked:"problems"},pt=["connections","people","problems"],nt={connections:"Connections",people:"People",problems:"Problems"},no={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=>nr[n]??"problems",_t={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},or=["person_added","person_removed","person_changed","paused_all","resumed_all"];function Le(n){return n.by?n.by:or.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function oo(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var jt=n=>n.sys?["error","repair","down"].includes(n.sys.level):$t(n.ev.type)==="problems";function Ut(n){let t=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 ${t}, up to ${n.max.toLocaleString("en-GB")} events, ${o}.`}function ao(n,t=120,o=26,a=De(new Date)){let r=Math.max(1,...n),i=e("div",{class:"dl-spark"});return i.style.width=`${t}px`,i.style.height=`${o}px`,n.forEach((s,l)=>{let d=e("i");d.style.height=`${Math.max(6,s/r*100)}%`,s||d.classList.add("zero");let p=n.length-1-l;ue(d,()=>[e("div",{class:"dl-tip-title"},p===0?"Today":p===1?"Yesterday":lt(bt(a,-p)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},ee(s))]),i.appendChild(d)}),i}function ar(n){let t=n==null?"":String(n);return/^[=+\-@\t\r]/.test(t)&&(t=`'${t}`),/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function ro(n,t){return[n.join(","),...t.map(o=>n.map(a=>ar(o[a])).join(","))].join(` +`)}function rr(n){let t=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:t,devices:o}}function je(n,t,o,a="",r=[]){let i=rr(n),s=[...t.map(c=>({ts:c.ts,category:$t(c.type),type:c.type,person:c.person?i.people.get(c.person)??c.pname??c.person:"",device:c.device?i.devices.get(c.device)??c.dname??c.device:"",detail:c.detail??"",where:c.where??"",by:Le(c)??""})),...r.map(c=>({ts:c.ts,category:"system",type:`${c.src}.${c.level}`,person:"",device:"",detail:`${c.who?`${c.who} `:""}${c.msg}${c.detail?` +${c.detail}`:""}`,where:_t[c.src]??c.src,by:""}))].sort((c,m)=>c.ts-m.ts).map(({ts:c,...m})=>({time:new Date(c*1e3).toISOString(),...m})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${a?`-${a}`:""}-${l}.${o}`;if(o==="json"){$e(d,JSON.stringify(s,null,2),"application/json");return}$e(d,ro(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var ir=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],io=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function Fe(n,t,o,a,r,i=!1){let s=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...pt.map(d=>e("option",{value:d,selected:d===r?"selected":null},nt[d])),i?e("option",{value:"system",selected:r==="system"?"selected":null},"System"):""]),l=e("select",{class:"cbi-input-select"},ir.map(([d,p])=>e("option",{value:d},p)));ae(n,[e("p",{class:"dl-muted"},`${t} This cannot be undone; export first if you want a copy.`),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Category"),s]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Which events"),l])],[se()," ",D("Clear",async()=>{let d=0;if(s.value!=="system")try{d+=(await S.logsClear({...o,category:s.value,older_days:l.value})).removed}catch(p){Q(ve(p),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{d+=(await S.serviceLogClear(l.value)).removed}catch(p){le(),Q(`${s.value==="system"?"":`Activity: ${io(d).toLowerCase()}. `}The service log was not cleared: ${ve(p)}`,"error",1e4),a();return}le(),Q(io(d),"success",3e3),a()},"negative")])}function ut(n,t,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}?`,[e("p",{class:"dl-muted"},r)],[se()," ",D("Reset",async()=>{await U(()=>S.usageClear(n,t),"Traffic history reset")&&(le(),a())},"negative")])}function fe(n,t,o){let a=e("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":t,click:()=>{let r=!a.classList.contains("on");Sn(a,r),o?.(r)}},e("i"));return a}function Sn(n,t){n.classList.toggle("on",t),n.setAttribute("aria-checked",t?"true":"false")}var Ee=n=>n.classList.contains("on");function xe(n,t,o={}){n.some(([i])=>i===t)||(n=[...n,[t,t]]);let a=e("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":t}),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(e("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 Ue(n,t,o,a={}){return e("button",{type:"button",...a,class:`dl-chipbtn${t?" on":""}${a.class?` ${a.class}`:""}`,"aria-pressed":t?"true":"false",click:o},n)}function Wt(n,t){n.classList.toggle("on",t),n.setAttribute("aria-pressed",t?"true":"false")}function re(n,t={}){return e("input",{type:"text",class:"cbi-input-text",value:n,...t})}var sr={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:""},lr={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 dr(n){let t={};for(let[o,a]of Object.entries(lr))n[o]!=null&&n[o]!==""&&(t[a]=String(n[o]));return t}function cr(n,t){let o=n.amnezia,a=o.obfuscation??{},r=d=>a[d]!=null&&a[d]!==""?String(a[d]):sr[d],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"),...dr(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:t,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function pr(n){let t="";for(let o=0;o"u")return null;try{let o=new t.Blob([n]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.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 Cn(n,t,o=!0){let a=new TextEncoder().encode(JSON.stringify(cr(n,t))),r=o?await ur(a):null;return`vpn://${pr(r??a)}`}var lo=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"standard",title:"Standard",ic:"shield",stealth:2,speed:4,text:"Junk packets and random headers. Gets through most VPN blocking with no speed cost.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"strong",title:"Strong",ic:"shieldplus",stealth:3,speed:3,text:"More and larger junk packets for networks that block VPNs aggressively. Connects a little slower.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],Et=n=>lo.find(t=>t.id===n),mr={v2:"Needs AmneziaWG 1.5 or newer on the router.",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},hr={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function so(n,t){return e("span",{class:"dl-dots",title:`${t}: ${n} of 4`},[e("span",{class:"dl-dots-label"},t),e("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>e("i",{class:odom.content(i,lo.map(l=>{let d=!l.needs||n[l.needs],p=l.id===t;return e("button",{type:"button",role:"radio","aria-checked":p?"true":"false","aria-disabled":d?null:"true",class:`dl-method${p?" on":""}${d?"":" off"}`,click:()=>{!d||p||(t=l.id,s(),o(l.id))}},[e("div",{class:"dl-method-head"},[e("span",{class:"dl-method-ic"},g(l.ic)),e("b",{},l.title),l.id===a?e("span",{class:"dl-pill ok"},"Current"):""]),e("p",{},l.text),e("div",{class:"dl-method-meters"},[so(l.stealth,"Stealth"),so(l.speed,"Speed")]),e("div",{class:"dl-method-foot"},d?[g("phone"),e("span",{},l.apps)]:[g("alert"),e("span",{},(r?mr:hr)[l.needs])])])}));return s(),i}function co(n,t,o,a){return e("div",{class:"dl-corehead"},[e("h3",{},n),e("span",{class:`dl-pill ${t}`},o),a?e("span",{class:"dl-sub"},a):""])}var po=[["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 t=p=>n[p]!=null&&n[p]!=="",o=po.filter(([p])=>t(p));if(!o.length)return null;let a=(p,c)=>e("span",{class:"dl-pv"},[e("i",{},c),e("b",{},p==="header_protection_key"?`${n[p].slice(0,6)}••••`:n[p])]),r=(p,c,m,v)=>{let h=po.filter(([x])=>v.includes(x)&&t(x));return h.length?e("div",{class:"dl-pgroup"},[e("div",{class:"dl-pgroup-head"},[g(c),e("b",{},p)]),e("p",{},m),e("div",{class:"dl-pvals"},h.map(([x,R])=>a(x,R)))]):""},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(([p,c])=>`${c} = ${n[p]}`).join(` +`),d=e("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 e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(o.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:p=>{p.preventDefault(),pe(l,"Parameters copied")}},"Copy as config")]),d])}function uo(n,t){if(/^\s*\[.+\]\s*$/.test(n))return e("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 e("span",{},[e("span",{class:"dl-conf-k"},o[1])," ",a&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function gr(n){let t=!1,o=e("pre",{class:"dl-conf"}),a=()=>dom.content(o,n.conf.split(` `).flatMap((s,l)=>l?[` -`,lo(s,t)]:[lo(s,t)])),r=e("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),t=!t,dom.content(r,[g(t?"x":"key"),t?"Hide key":"Show key"]),a()}},[g("key"),"Show key"]);a();let i=new Blob([n.conf]).size;return e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-filecard"},[e("span",{class:"dl-filecard-ic"},".conf"),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono dl-ellipsis"},n.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),D([g("download")," Download"],()=>$e(n.filename,n.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),r,e("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),pe(n.conf,"Configuration copied")}},[g("copy"),"Copy"])]),o])])}async function mr(n,t="file"){if(!n.has_private_key)return e("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await En(n,`${n.server} · ${n.person} · ${n.name}`),a={qr:()=>e("div",{class:"dl-qr-pane"},[qe(ct(n.conf),"dl-qr"),e("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-linkbox"},[e("span",{class:"dl-mono"},o),D("Copy",()=>pe(o,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>ur(n)},r=e("div",{class:"dl-connect-body"}),i=e("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(r,a[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(e("button",{type:"button","data-id":l,click:()=>s(l)},d));return s(t),e("div",{class:"dl-stack gap12"},[i,r])}async function hr(n,t,o,a){let r=Et(o),s=n.st.people.filter(d=>d.server===t.id).reduce((d,p)=>d+p.devices.length,0);await ne(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.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await U(()=>E.serverObfuscation(t.id,o),a?"New values applied":`${r.title} applied`)&&(Z("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function fr(n,t){let o=n.st,a=ae(String(t.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=ae(String(t.mtu??""),{placeholder:"1380",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=ae(String(t.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=Et(t.preset)?t.preset:void 0,l=s??"standard",d=D("",()=>hr(n,t,l,l===s),"neutral"),p=()=>dom.content(d,l===s?[g("reset")," Generate new values"]:[`Switch to ${Et(l).title}`]);p();let c=o.people.filter(v=>v.server===t.id).reduce((v,h)=>v+h.devices.length,0),m=o.awg_state?.tools!==!1;return kt("",[io("AmneziaWG",t.up?"ok":"bad",t.up?"Running":"Not running",`${t.ifname} · ${c} device${c===1?"":"s"}`),he("globe","Listening","Where devices reach this core from the internet",[X("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",[X("MTU",r,"Lower it if some sites hang on mobile networks."),X("Keep-alive",i,"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",[Gt(o.awg,l,v=>{l=v,p()},s,m),m&&!o.awg.v3?dt("info",["This router runs an older AmneziaWG. ",e("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",pr(t.obf??{})??"",e("div",{class:"dl-row-end"},[e("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),d])]),e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Tunnel"),e("span",{class:"dl-pcount"},"3")]),e("div",{class:"dl-params-body"},[X("Interface",e("span",{class:"dl-mono"},`${t.ifname} · router ${t.address}`)),X("Tunnel subnet",e("span",{class:"dl-mono"},t.subnet),"Device addresses come from it."),X("Server public key",e("span",{class:"dl-keyrow"},[e("code",{class:"dl-mono"},t.public_key),D([g("copy")],()=>pe(t.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[e("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),D("Save",()=>n.save({port:a.value,mtu:r.value,keepalive:i.value},"AmneziaWG saved"),"positive")])}function gr(n){let t=Et(n.preset),o=n.obf??{},a=(s,l)=>e("span",{class:`dl-segs ${l}`},[0,1,2,3].map(d=>e("i",{class:d+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(o.i1.includes("0x8580")?"DNS-like first packet":"Signature packets"),o.header_protection_key&&r.push("Encrypted headers"),r.length||r.push(t?.id==="off"?"Plain WireGuard":"No values yet"),e("div",{class:"dl-bento-tile dl-disg"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Disguise"),e("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),e("div",{class:"dl-disg-id"},[e("span",{class:"dl-disg-ic"},g(t?.ic??"shield")),e("span",{class:"dl-stack"},[e("b",{},t?t.title:"Custom"),e("span",{class:"dl-sub"},t?t.short:"Set by hand")])]),t?e("div",{class:"dl-disg-meters"},[e("span",{},"Stealth"),a(t.stealth,"acc"),e("span",{},"Speed"),a(t.speed,"ok")]):"",e("div",{class:"dl-disg-chips"},r.map(s=>e("span",{},s)))])}var Sn={id:"awg",label:"AmneziaWG",settingsCard:fr,overviewTile:gr,connectBlock:mr,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>En(n,`${n.server} · ${n.person} · ${n.name}`)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var vr={awg:Sn};function Re(n){return vr[n?.core||"awg"]??Sn}function mt(n,t){return Re(n.find(o=>o.id===t))}function br(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function co(n,t,o=!1){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},n),e("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:"Copy",click:()=>pe(t,`${n} copied`)},[e("span",{},t),g("copy")])])}function qt(n,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},n),e("span",{class:"dl-kvrow-v"},t)])}var po={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 xr(n,t,o){let a=n.filter(r=>r.device===t&&po[r.type]).reverse().slice(0,12);return a.length?e("div",{class:"dl-dev-log"},a.map(r=>{let[i,s,l]=po[r.type],d=r.type==="connect"?[r.detail?e("span",{class:"dl-muted"},` from ${r.detail}`):"",r.where?e("span",{class:"dl-muted"},` · ${r.where}`):""]:r.type==="roam"?[e("span",{class:"dl-muted"},` · ${r.detail??""}`)]:r.type==="device_added"||r.type==="device_removed"||r.type==="device_keys"?[e("span",{class:"dl-muted"},Le(r)==="portal"?" on the portal":Le(r)==="admin"?" by you":"")]:[],p=new Date(r.ts*1e3);return e("div",{class:`dl-dev-log-row${Le(r)==="admin"?" dl-ev-by-admin":""}`},[Le(r)==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):e("span",{class:`dl-ev-tile ev ${i}`},g(l)),e("span",{class:"dl-row-main"},[e("span",{},s),...d]),e("span",{class:"dl-faint dl-nowrap",title:p.toLocaleString()},le(r.ts,o))])})):e("div",{class:"dl-sub"},"No activity yet.")}async function uo(n,t,o){let a=await E.status(1).catch(()=>null),r=a?.people.find(s=>s.id===n),i=r?.devices.find(s=>s.id===t);a&&r&&i&&He(r,i,{...o,geo:a.geo,now:a.now,today:Ne(a.series),core:mt(a.servers,r.server)})}async function He(n,t,o){let a=await U(()=>E.deviceConfig(t.id));if(!a)return;let r=o.core??Re(null),i=t,s=n,l=o.geo,d=o.now,p=o.today??De(new Date),c=await r.connectBlock(a),m=e("div",{class:"dl-drawer-title"}),v=e("div",{}),h=e("div",{}),x=e("div",{},e("div",{class:"dl-sub"},"Loading…")),R=[],$=q=>{R=q.filter(C=>C.device===i.id),dom.content(x,xr(q,i.id,d))},j=async(q=!1)=>{let C=o.events?.();if(C&&!q)return $(C);let G=await E.events(5e3).catch(()=>null);G&&$(G.events)},w=()=>{let q=l?.points.find(G=>G.device===i.id&&G.ip===i.endpoint);dom.content(m,[e("span",{class:`dl-dcard-ic${i.online?" on":""}`},g(i.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},i.name),D([g("edit")],()=>T(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},`${s.name} · ${Be[i.kind]}`)])]);let C=i.spark.reduce((G,Q)=>G+Q,0);dom.content(v,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),Bt(i,d,"Waiting for the first connection")]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},te(i.month[0]+i.month[1])),e("span",{class:"dl-sub dl-mono"},`↓ ${te(i.month[1])} ↑ ${te(i.month[0])}`)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"Last 7 days"),e("b",{},te(C)),to(i.spark,120,22,p)])])),dom.content(h,e("div",{class:"dl-kv2"},[co("Tunnel address",i.address),i.hostname&&s.access!=="internet"?co("Local address",i.hostname):"",i.endpoint?qt("Client IP",e("span",{},[i.endpoint,q?e("span",{class:"dl-muted"},` · ${[q.city,q.org].filter(Boolean).join(" · ")}`):""])):"",qt("Total",e("span",{class:"dl-kv-act"},[`↓ ${te(i.total[1])} · ↑ ${te(i.total[0])}`,e("button",{type:"button",class:"dl-linkbtn danger",click:()=>ut("device",i.id,i.name,()=>setTimeout(S,300))},"Reset")])),qt("Added",`${br(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),qt("Public key",e("span",{class:"dl-mono dl-faint"},a.amnezia.client_pub_key?`${a.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(b,[D([g(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await U(()=>E.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await S()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),D([g("key")," New keys"],async()=>{if(!await ne("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await U(()=>E.deviceRotate(i.id),"New keys generated")&&(o.refresh(),W.close(),await uo(s.id,i.id,o))}),e("span",{class:"dl-spacer"}),D([g("trash")," Remove"],async()=>{await ne(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>E.deviceDelete(i.id),"Device removed")&&(W.close(),o.refresh())},"negative")])},H=async()=>{let q=await E.status(1).catch(()=>null),C=q?.people.find(Q=>Q.id===s.id),G=C?.devices.find(Q=>Q.id===i.id);!q||!C||!G||(s=C,i=G,l=q.geo,d=q.now,p=Ne(q.series),w())},S=async()=>{await H(),o.refresh()},T=()=>{let q=e("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48});oe(`Rename ${i.name}`,[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},q)])],[ie()," ",D("Save",async()=>{await U(()=>E.deviceUpdate(i.id,q.value,void 0),"Renamed")&&(se(),await S())},"positive")]),setTimeout(()=>q.select(),50)},b=e("div",{class:"dl-drawer-actions"}),A=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Connect")]),i.config_stale?e("div",{class:"dl-note warn"},[g("alert"),e("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",c]),u=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Activity"),e("div",{class:"dl-dsec-actions"},[e("button",{type:"button",class:"dl-linkbtn",click:()=>je({people:[s]},R,"csv",i.id)},"Export"),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{j(!0),o.refresh()})},"Clear"),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),x]),f=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},e("h4",{},"Details")),h]),N=!i.handshake||i.config_stale,P=e("div",{class:"dl-stack gap16"},N?[v,A,f,u]:[v,f,u,A]);j();let I=0,J=window.setInterval(()=>{H(),(o.events||++I%4===0)&&j()},8e3),W=Kn(m,P,b,()=>clearInterval(J));w()}function mo(n,t,o,a){let r=a.core??Re(null),i=()=>U(()=>E.deviceConfig(o.id)),s=[{label:"Show QR code",icon:g("qr"),run:async()=>{let l=await i();l&&oe(`${o.name} · QR code`,e("div",{class:"dl-qr-pane"},[qe(ct(r.qrText(l)),"dl-qr"),e("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),ie("Close"))}},{label:r.file.label,icon:g("download"),run:async()=>{let l=await i();if(!l)return;let d=r.file.make(l);$e(d.name,d.text,"application/octet-stream")}},r.appKey?{label:r.appKey.label,icon:g("copy"),run:async()=>{let l=await i();l&&pe(await r.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:g("edit"),run:()=>He(t,o,a)},{label:"New keys",icon:g("key"),run:async()=>{await ne("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await U(()=>E.deviceRotate(o.id),"New keys generated")&&a.refresh()}},{label:o.disabled?"Enable":"Disable",icon:g(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await U(()=>E.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&a.refresh()}},{label:"Delete",icon:g("trash"),danger:!0,run:async()=>{await ne(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>E.deviceDelete(o.id),"Device removed")&&a.refresh()}}];we(n,s)}function ot(n,t){let o=e("input",{type:"text",class:"cbi-input-text",placeholder:Be.phone,maxlength:48}),a="phone",r=e("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},qn.map(s=>e("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 d=l.dataset.kind===s;l.classList.toggle("on",d),l.setAttribute("aria-checked",d?"true":"false")}),o.placeholder=Be[s]}},[g(s),e("span",{},Be[s])]))),i=n.devices.length>=n.device_limit;oe(`Add a device for ${n.name}`,[i?e("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",e("div",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Type"),r]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Name"),o])],[ie()," ",D("Add device",async()=>{let s=o.value.trim()||o.placeholder.replace(/^e\.g\. /,""),l=await U(()=>E.deviceCreate(n.id,s,a));l&&(se(),Z(`${s} added`,"success",3e3),t.refresh(),await uo(n.id,l.id,t))},"positive")]),setTimeout(()=>o.focus(),50)}var We=1080,Ct=1512,Ie=96,wr="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",yr="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",St=n=>n.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function kr(n,t,o){let a=new URL(o),r=a.pathname.slice(1),i=Math.min(92,Math.floor((We-2*Ie)/(.58*(4+n.name.length)))),s=We-2*Ie,l=392,d=40,p=ct(o,2).replace("`${R}`;return``+c(Ie+82,Ie+42,36,"#a3a3a3",St(t))+c(Ie,276,i,"#ffffff",`Hi, ${St(n.name)}`,'font-weight="600"')+c(Ie,340,40,"#8a8a8a",`Scan to connect to ${St(t)}`)+``+p+`${St(r)}`+c(We/2,l+s+156,34,"#737373",St(a.host),'text-anchor="middle"')+""}async function $r(n){let t=new Image;t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await t.decode();let o=document.createElement("canvas");return o.width=We,o.height=Ct,o.getContext("2d").drawImage(t,0,0,We,Ct),new Promise((a,r)=>o.toBlob(i=>i?a(i):r(new Error("Could not draw the card")),"image/png"))}async function ho(n){let t=await U(()=>E.personLinks(n));return t?t.link?{link:t.link,links:t.links??[]}:(Z("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function Ft(n){let t=await ho(n);t&&await pe(t.link,"Personal link copied")}async function Lt(n,t,o={}){let a=n.link,r=n.links;if(a===void 0){let h=await ho(n.id);if(!h)return;a=h.link,r=h.links}if(!a){Z("The personal portal is off. Turn it on in Settings.","warning");return}let i=a,s=await U(()=>$r(kr(n,t,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),d=URL.createObjectURL(s),p=navigator,c=!!p.canShare?.({files:[l]}),m=()=>{URL.revokeObjectURL(d),se()},v=c?D([g("link")," Share card"],async()=>{try{await p.share({files:[l],title:`Invite ${n.name}`})}catch{}},"positive"):D([g("download")," Download card"],()=>$e(l.name,s),"positive");oe(o.title??`Invite ${n.name}`,e("div",{class:"dl-invite"},[e("img",{src:d,alt:`Invite card for ${n.name}`}),e("div",{class:"dl-invite-side"},[e("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.`),e("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>pe(i,"Personal link copied")},[e("span",{},i.replace(/^https:\/\//,"")),g("copy")]),...(r??[]).filter(h=>h!==i).map(h=>e("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>pe(h,"Link copied")},[e("span",{},h.replace(/^https?:\/\//,"")),e("span",{class:`dl-pill ${h.startsWith("http:")?"warn":""}`},h.startsWith("http:")?"HTTP":"Also"),g("copy")])),e("ol",{class:"dl-invite-steps"},[e("li",{},["Install ",e("b",{},"AmneziaVPN")," on the device"]),e("li",{},"Open the link or scan the code"),e("li",{},"Add the device and connect")]),e("div",{class:"dl-invite-actions"},[v,D([g("copy")," Copy link"],()=>pe(i,"Personal link copied"))])])]),[e("button",{class:"cbi-button cbi-button-neutral",click:m},"Done")],"wide")}function ht(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function Te(n,t){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${t?`&device=${encodeURIComponent(t)}`:""}`}function Tt(n,t){let o=n.servers.find(d=>d.id===t)??n.servers[0],a=n.people.filter(d=>d.server===o.id),r=new Set(a.map(d=>d.id)),i=a.flatMap(d=>d.devices),s=d=>a.reduce((p,c)=>{let m=d(c);return[p[0]+m[0],p[1]+m[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(d=>d.person?r.has(d.person):!0),geo:{...n.geo,points:n.geo.points.filter(d=>r.has(d.person))},totals:{people:a.length,devices:i.length,online:i.filter(d=>d.online).length,active:a.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(d=>d.month)}}}var Cn=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(t){return t{let i=t.next(),s=await n.fetch().catch(()=>null);return s==null||!t.take(i)?null:(n.apply(s,r),s)},a=()=>n.active?.()??!0?o(!0):Promise.resolve(null);return poll.add(a,n.every),{refresh:o,claim:()=>t.claim(),stop:()=>poll.remove(a)}}function ft(n){let t=document.activeElement;return!!n&&!!t&&t!==document.body&&n.contains(t)}function _e(n,t,o=!1){return o&&ft(n)?!1:(dom.content(n,t),!0)}function fo(n,t){let o=n,r=e("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(i=>e("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)),t?.(i.v)}},[e("span",{class:"dl-choice-title"},[g(i.ic),et[i.v]]),e("span",{class:"dl-choice-text"},i.text)])));return{el:r,get:()=>o}}function _r(n){let t=n.devices.length,o=Math.max(1,n.device_limit,t),a=Math.min(160,o*22+(o-1)*3);return e("div",{class:"dl-slotbar",title:`${t} of ${n.device_limit} devices`},[e("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:o},(r,i)=>e("i",{class:i>=n.device_limit?"over":i=n.quota_limit*.9}function Sr(n,t){return xt(n&&kn(n,t)>=0?n:t,1)}var go=n=>n.people.map(t=>t.id).sort().join(" "),vo=!1,at=class{constructor(){this.list=e("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(t=>t===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return E.status(30)}scope(t){return this.serverId?Tt(t,this.serverId):t}embed(t,o){return this.serverId=o,this.render(t)}person(t){return this.st.people.find(o=>o.id===t)}get today(){return Ne(this.st.series)}deviceOpts(t){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:mt(this.st.servers,t.server)}}take(t,o){let a=this.scope(t),r=go(a)!==go(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 t=await E.status(30).catch(()=>null);t&&(this.st=this.scope(t),this.rebuild())}rebuild(){let t=new Map;for(let a of Array.from(this.list.children))a.dataset.sid&&t.set(a.dataset.sid,a);let o=this.st.people.map(a=>{let r=t.get(a.id)??e("div",{class:"dl-card",role:"listitem","data-sid":a.id});return this.renderCard(r,a.id)});dom.content(this.list,o.length?o:e("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(t=!1){for(let o of this.st.people){let a=this.card(o.id);a&&!(t&&ft(a))&&this.renderCard(a,o.id)}}card(t){return this.list.querySelector(`[data-sid="${CSS.escape(t)}"]`)}render(t){let o=this.scope(t);this.st=o;let a=this,r=e("select",{class:"dl-select","aria-label":"Sort",change:s=>{a.sort=s.target.value,a.decorate()}},[e("option",{value:"seen"},"Last seen"),e("option",{value:"name"},"Name"),e("option",{value:"usage"},"Usage")]),i=e("div",{class:"dl-root"},[a.serverId?"":e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"People"),e("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?D([g("plus")," Add person"],()=>a.openCreate(),"add"):""]),o.servers.length?"":e("div",{class:"alert-message warning"},["No server yet. ",e("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),e("div",{class:"dl-toolbar"},[e("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),e("div",{class:"dl-toolbar-end"},[r,a.serverId?D([g("plus")," Add person"],()=>a.openCreate(),"add"):""])]),this.list]);return this.el=i,this.rebuild(),this.poller??(this.poller=Ke({fetch:()=>E.status(30),every:10,active:()=>!!a.el?.isConnected,apply:(s,l)=>a.take(s,l)})),!vo&&new URLSearchParams(location.search).get("add")&&(vo=!0,setTimeout(()=>a.openCreate(),100)),Promise.resolve(i)}countText(){let t=this.st.totals;return`${t.people} ${t.people===1?"person":"people"} · ${t.devices} device${t.devices===1?"":"s"} · ${t.online} online`}decorate(t=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let a=this.st.people,r=this.today,i=v=>Er(v,r),s={all:a.length,online:a.filter(v=>v.online>0).length,attention:a.filter(i).length,paused:a.filter(v=>v.state!=="active"&&v.state!=="quota"&&v.state!=="expired").length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(t&&ft(l))){let v={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(v).map(h=>e("button",{type:"button",role:"tab",class:h===this.filter?"on":"",click:()=>{this.filter=h,this.decorate()}},[v[h],e("b",{class:h==="attention"&&s[h]?"warn":""},String(s[h]))])))}let d=v=>!(this.filter==="online"&&!v.online||this.filter==="attention"&&!i(v)||this.filter==="paused"&&!(v.state!=="active"&&v.state!=="quota"&&v.state!=="expired")),p=[...a].sort((v,h)=>this.sort==="name"?v.name.localeCompare(h.name):this.sort==="usage"?h.month[0]+h.month[1]-(v.month[0]+v.month[1]):h.online-v.online||h.last_seen-v.last_seen),c=0;for(let v of p){let h=this.card(v.id);if(!h)continue;this.list.appendChild(h),h.classList.toggle("dl-off",v.state!=="active"),h.classList.toggle("dl-attn-row",v.state==="quota"||v.state==="expired");let x=d(v);h.classList.toggle("dl-filtered",!x),x&&c++}let m=this.el?.querySelector(".dl-people-none")??null;a.length&&!c?(m??(m=e("div",{class:"dl-empty dl-people-none"},e("p",{},"No one here right now."))),m.previousElementSibling!==this.list&&this.list.after(m)):m?.remove()}async quick(t,o,a){await U(()=>E.personUpdate(t.id,o),a)&&await this.update()}renderCard(t,o){let a=this.person(o);if(!a)return dom.content(t,e("em",{},"This person was just removed.")),t;let r=this.today,i=Xe(a.expires,r),s=Math.max(0,a.device_limit-a.devices.length),l=a.has_link??this.st.settings.portal_enabled,d=[];if(a.expires){let h=i!=null&&i>=0&&i<=Math.max(a.expire_warn,3),x=i!=null&&i<0;d.push(e("span",{class:`dl-pill-ic${x?" bad":h?" warn":""}`,title:`Access ends ${ze(a.expires)}`},[g("calendar"),x?`ended ${ze(a.expires)}`:h?`ends in ${i} day${i===1?"":"s"}`:`until ${ze(a.expires)}`]))}a.hours&&d.push(e("span",{class:"dl-pill-ic",title:"Allowed hours"},[g("clock"),a.hours.replace("-","–")]));let p=Ht(a.devices).map(h=>e("button",{type:"button",class:`dl-chip${h.disabled?" disabled":""}${h.online?" live":""}`,title:`${Be[h.kind]} · ${h.address}${h.online?` · online from ${h.endpoint}`:h.handshake?` · seen ${le(h.handshake,this.st.now)}`:""}`,click:x=>{x.preventDefault(),He(a,h,this.deviceOpts(a))}},[g(h.kind),e("span",{class:"dl-chip-name"},h.name),!h.handshake&&!h.disabled?e("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(e("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:h=>{h.preventDefault(),ot(a,this.deviceOpts(a))}},g("plus")));let c=[];a.state==="quota"&&a.quota_period==="month"&&c.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{bonus_gb:String((a.bonus_gb||0)+10)},"+10 GB this month")},"+10 GB this month")),a.expires&&i!=null&&i<=Math.max(a.expire_warn,3)&&c.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:Sr(a.expires,r)},"Extended by 1 month")},"Extend 1 month"));let m=ye("more","More",h=>we(h.currentTarget,[{label:"Open",icon:g("open"),run:()=>{location.href=Te(a.id)}},l?{label:"Invite card",icon:g("qr"),run:()=>Lt(a,this.st.servers.find(x=>x.id===a.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:g("plus"),run:()=>ot(a,this.deviceOpts(a))}:null,null,{label:a.paused?"Resume":"Pause",icon:g(a.paused?"play":"pause"),warn:!a.paused,run:()=>this.togglePause(a)},{label:"Delete",icon:g("trash"),danger:!0,run:()=>this.remove(a.id)}].filter((x,R,$)=>x||R>0&&$[R-1])),"neutral","dl-icon-only"),v=e("div",{class:"dl-pcard-actions"},[l?ye("link","Copy link",()=>Ft(a.id),"neutral","dl-icon-only"):"",m]);return dom.content(t,e("div",{class:"dl-pcard"},[e("div",{class:"dl-pcard-main"},[e("div",{class:"dl-pcard-top"},[e("span",{class:`dl-avatar${a.online?" online":""}`},Oe(a.name)),e("div",{class:"dl-pcard-who"},[e("div",{class:"dl-card-head"},[e("a",{class:"dl-card-name",href:Te(a.id)},a.name),It(a),Fn(a),...d]),_r(a)])]),e("div",{class:"dl-chips"},p),c.length?e("div",{class:"dl-fixes"},c):""]),this.usageSide(a,v)])),t}usageSide(t,o){let a=t.quota_used||t.month[0]+t.month[1],r=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,i=t.devices.reduce((c,m)=>c+(m.spark[m.spark.length-1]??0),0),s=t.rate?.[t.rate.length-1],l=t.online&&s&&this.st.now-s[0]<180,d=e("div",{class:`dl-usebar${r>=100?" bad":r>=90?" warn":""}`});if(t.quota_limit){let c=e("i",{class:"fill"});c.style.width=`${r}%`,d.appendChild(c),ue(d,()=>[e("div",{class:"dl-tip-title"},`${r.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${te(t.quota_used)} of ${te(t.quota_limit)} · ${te(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},t.quota_period==="total"?"In total":`This month${t.bonus_gb?` · includes +${t.bonus_gb} GB extra`:""}`)])}else{let c=t.devices.map(m=>({d:m,v:m.month[0]+m.month[1]})).filter(m=>m.v>0).sort((m,v)=>v.v-m.v);c.forEach((m,v)=>{let h=e("i",{class:`c${Math.min(v,4)}`});h.style.flexGrow=String(m.v),d.appendChild(h)}),c.length&&ue(d,()=>[e("div",{class:"dl-tip-title"},"This month by device"),...c.map((m,v)=>e("div",{class:"dl-tip-row"},[e("span",{class:`dl-swatch c${Math.min(v,4)}`}),e("span",{},m.d.name),e("b",{},te(m.v))]))])}let p=t.quota_limit?`${te(Math.max(0,t.quota_limit-t.quota_used))} left`:"no limit";return e("div",{class:"dl-pside"},[e("div",{class:"dl-pside-top"},[l?e("span",{class:"dl-pside-state live"},"Online"):e("span",{class:"dl-pside-state"},t.online?"Online":t.last_seen?"Offline":"Never connected"),o]),e("div",{class:"dl-use-num"},[e("b",{class:a?"":"dl-faint"},te(a)),e("span",{class:"dl-faint"},t.quota_limit?`of ${te(t.quota_limit)}`:t.quota_period==="total"&&t.quota_gb?"in total":"this month")]),d,l?e("div",{class:"dl-use-live",title:"Right now"},[`↓ ${Pe(s[2])}`,e("span",{class:"dl-faint"},`↑ ${Pe(s[1])}`)]):e("div",{class:"dl-faint dl-pside-foot"},i?`today ${te(i)} · ${p}`:p)])}async togglePause(t){await U(()=>E.personPause(t.id,!t.paused),t.paused?`${t.name} resumed`:`${t.name} paused`)&&await this.refresh()}async remove(t){let o=this.person(t);await ne(`Remove ${o?.name??t}?`,`All ${o?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await U(()=>E.personDelete(t),"Person removed")&&await this.refresh()}openCreate(){let t=this.st;if(!t.servers.length){Z("Set up the server first.","warning");return}let o=e("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=fo("internet"),r=e("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:t.settings.default_device_limit}),i=e("input",{type:"date",class:"cbi-input-text"}),s=e("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),l=(m,v)=>e("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{i.value=v?xt(Ne(t.series),v):""}},m),d=t.servers[0],p=!this.serverId&&t.servers.length>1?e("select",{class:"cbi-input-select"},t.servers.map(m=>e("option",{value:m.id},m.name))):null,c=(m,v,h)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},m),e("div",{class:"cbi-value-field"},[v,h?e("div",{class:"cbi-value-description"},h):""])]);oe("Add person",[c("Name",o),p?c("Server",p):"",e("div",{class:"cbi-value dl-block"},[e("label",{class:"cbi-value-title"},"Access"),e("div",{class:"cbi-value-field"},a.el)]),c("Devices",r,"How many devices they can add themselves."),c("End date",e("div",{class:"dl-actions"},[i,l("1 month",1),l("3 months",3),l("1 year",12),l("None",0)]),"Optional."),c("Monthly data (GB)",s,"Optional. They are paused when it runs out and resumed next month.")],[ie()," ",D("Create and copy link",async()=>{let m=await U(()=>E.personCreate(o.value.trim(),"",p?.value??d.id,a.get(),String(Number(r.value)||t.settings.default_device_limit),i.value,s.value.trim(),"month"));m&&(m.link&&await pe(m.link,"Personal link copied"),this.showCreated(m.id,o.value.trim(),m.link,t.servers.find(v=>v.id===(p?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(t,o,a,r){if(a){Lt({id:t,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}oe(`${o} 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:se},"Done")])}};var Kt=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],Ln=n=>e("i",{class:"dl-circle-dot",style:`background:${Kt[n?.color??0]??Kt[0]}`}),Je=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function bo(n,t,o){let a=ae(n?.name??t.name??"",{placeholder:"NAS"}),r=ae(n?.address??t.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=ae((n?.ports??t.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=(l,d)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},l),e("div",{class:"cbi-value-field"},d)]);oe(n?`Edit ${n.name}`:"Add service",[s("Name",a),s("Address",r),s("Ports",i)],[ie()," ",D("Save",async()=>{let l=i.value.split(/[ ,]+/).filter(Boolean);await U(()=>E.serviceSet(n?.id??"",a.value,r.value,l),"Saved")&&(se(),o())},"positive")])}var Cr={_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"},Lr=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function Tr(n){let t=new Map;for(let o of n.services){let a=Cr[o.type.split(".")[0]];!a||!o.port||(t.get(a)??t.set(a,new Set).get(a)).add(String(o.port))}return t.size?[...t].map(([o,a])=>[o,[...a].sort((r,i)=>+r-+i)]):Lr}function xo(n,t,o){let a=n,r=null,i=!1,s=null,l=new Set,d=e("div",{class:"dl-list"}),p=e("div",{class:"dl-stack gap8"},e("span",{class:"dl-sub"},"Looking for devices at home…")),c=()=>{let R=a.services;dom.content(d,R.length?R.map($=>e("div",{class:"dl-row"},[g("home"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},$.name),e("span",{class:"dl-mono dl-faint"},`${$.address}${$.ports.length?` · ports ${$.ports.join(", ")}`:" · all ports"}`)]),D("Edit",()=>bo($,{},o)),D([g("trash")],async()=>{await ne(`Remove ${$.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await U(()=>E.serviceDelete($.id),"Removed")&&await o()},"neutral",{title:"Remove","aria-label":`Remove ${$.name}`})])):[e("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function m(R,$){if(!l.has(R.address)){l.add(R.address),h();try{let j=a.services.find(H=>H.address===R.address);($===null?j&&await U(()=>E.serviceDelete(j.id),`${j.name} removed`):await U(()=>E.serviceSet(j?.id??"",j?.name??(R.name||R.address),R.address,$),j?`${j.name} updated`:`${R.name||R.address} added`))&&await o()}finally{l.delete(R.address),h()}}}function v(R){let $=a.services.find(T=>T.address===R.address),j=!!$&&!$.ports.length,w=new Set($?.ports??[]),H=l.has(R.address),S=(T,b,A)=>Ue(T,b,A,{disabled:H?"disabled":null,"aria-busy":H?"true":null});return e("div",{class:"dl-row"},[g(R.services.some(T=>T.type.startsWith("_ipp")||T.type.startsWith("_printer"))?"file":"computer"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},R.name||R.address),e("span",{class:"dl-mono dl-faint"},R.address)]),e("div",{class:"dl-chips-row dl-host-ports"},[S("All ports",j,()=>m(R,j?null:[])),...Tr(R).map(([T,b])=>{let A=!j&&b.every(u=>w.has(u));return S(`${T} ${b.join(", ")}`,A,()=>{let u=new Set(j?[]:w);for(let f of b)A?u.delete(f):u.add(f);m(R,u.size?[...u]:null)})})])])}function h(){if(i)return dom.content(p,e("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!r)return;let R=r;if(!R.hosts.length)return dom.content(p,e("span",{class:"dl-sub"},"No devices found in the home network right now."));let $=e("details",{class:"dl-params",open:s??!a.services.length?"":null},[e("summary",{},[g("chevron"),e("span",{},"Add from devices at home"),e("span",{class:"dl-pcount"},String(R.hosts.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},R.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),e("div",{class:"dl-list"},R.hosts.map(v))])]);$.addEventListener("toggle",()=>s=$.open),dom.content(p,$)}return E.homeHosts(t).then(R=>{r=R,h()}).catch(()=>{i=!0,h()}),c(),{el:e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-iflead"},[e("div",{class:"dl-iflead-row"},[e("b",{},"Home services"),D([g("plus")," Add service"],()=>bo(null,{},o))]),e("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),d,p]),update(R){a=R,c(),h()}}}function Jt(n,t,o,a){let r=new Set(n.circles.filter(h=>h.server===t).map(h=>h.color)),i=o?.color??Kt.findIndex((h,x)=>!r.has(x));i<0&&(i=0);let s=ae(o?.name??"",{placeholder:"Family"}),l=n.people.filter(h=>h.server===t).sort((h,x)=>h.name.localeCompare(x.name)),d=new Set(l.filter(h=>o&&h.circle===o.id).map(h=>h.id)),p=e("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),c=()=>dom.content(p,Kt.map((h,x)=>e("button",{type:"button",role:"radio",class:`dl-swatch${x===i?" on":""}`,style:`--sw:${h}`,"aria-checked":x===i?"true":"false","aria-label":`Colour ${x+1}`,click:()=>{i=x,c()}})));c();let m=e("div",{class:"dl-chips-row"},l.map(h=>{let x=h.circle&&h.circle!==o?.id?n.circles.find(R=>R.id===h.circle):void 0;return e("button",{type:"button",class:`dl-chipbtn${d.has(h.id)?" on":""}`,title:Je(h)?x?`Now in ${x.name}`:"":`${h.name} has no home access: their devices aren't reachable anyway`,click:R=>{d.delete(h.id)||d.add(h.id),R.currentTarget.classList.toggle("on",d.has(h.id))}},[h.name,Je(h)?x?e("b",{},x.name):"":e("b",{},"internet")])})),v=(h,x)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},h),e("div",{class:"cbi-value-field"},x)]);oe(o?`Edit ${o.name}`:"New circle",[v("Name",s),v("Colour",p),v("People",m),e("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 U(()=>E.circleDelete(o.id),`${o.name} deleted`)&&(se(),a())},"negative"):"",e("span",{class:"dl-spacer"}),ie()," ",D("Save",async()=>{await U(()=>E.circleSet(o?.id??"",t,s.value,i,[...d]),"Saved")&&(se(),a())},"positive")],"dl-circle-modal")}function wo(n,t,o){let a=n.circles.filter(r=>r.server===t);return e("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 e("button",{type:"button",class:"dl-chip",title:`Edit ${r.name}`,click:()=>Jt(n,t,r,o)},[Ln(r),e("b",{},r.name),e("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),e("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>Jt(n,t,null,o)},g("plus"))])}function Tn(n,t){let o=n.people.filter(c=>c.server===t.id),a=(c="")=>e("span",{class:"dl-yes"},[g("check"),c]),r=()=>e("span",{class:"dl-faint"},"—"),i=c=>{let m=new Set(c.map(v=>v.access==="lan"&&v.services?.length?"services":v.home_nets?.length?"some":"all"));return m.size||m.add("all"),a([...m].map(v=>({all:"all networks",some:"their networks",services:"services"})[v]).join(" / "))},s=()=>t.mesh==="off"?r():t.mesh==="circles"?a("circle"):a(),l=t.lan_like?"like home":"direct",d=(c,m,v)=>e("tr",{},[e("td",{},[e("b",{},c),e("div",{class:"dl-sub"},`${m.length} ${m.length===1?"person":"people"}`)]),...v.map(h=>e("td",{},h))]),p=c=>o.filter(m=>m.access===c);return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Who reaches what"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"From the rules on this server")]),e("div",{class:"dl-reach-wrap"},e("table",{class:"dl-table dl-reach"},[e("tr",{},["","Internet","Home","This router","Each other"].map(c=>e("th",{},c))),d("Internet",p("internet"),[a(l),r(),e("span",{class:"dl-faint"},"DNS"),r()]),d("Home",p("lan"),[e("span",{class:"dl-faint"},"their own"),i(p("lan")),a(),s()]),d("Both",p("both"),[a(l),i(p("both")),a(),s()])])),e("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function yo(n,t){let o=n.people.filter(p=>p.server===t.id).flatMap(p=>p.devices.map(c=>({id:c.id,label:`${p.name} · ${c.name}`}))).sort((p,c)=>p.label.localeCompare(c.label)),a="@addr",r=(p,c)=>{let m=e("select",{class:"cbi-input-select","aria-label":p},[...o.map(R=>e("option",{value:R.id,selected:R.id===c?"selected":null},R.label)),e("option",{value:a,selected:c===a?"selected":null},"Address")]),v=ae("",{placeholder:p,class:"cbi-input-text dl-mono"}),h=e("div",{class:"dl-check-end"},[m,v]),x=()=>v.hidden=m.value!==a;return m.addEventListener("change",x),x(),{el:h,value:()=>m.value===a?v.value.trim():m.value}},i=r("10.0.1.11",o[0]?.id??a),s=r("10.0.1.20:445",a),l=e("div",{class:"dl-stack gap8"}),d=async()=>{let p=await U(()=>E.accessCheck(i.value(),s.value()));if(!p)return;let c=p.steps.findIndex(m=>!m.ok);dom.content(l,[e("div",{class:`dl-verdict ${p.ok?"ok":"bad"}`},[e("b",{},p.ok?"Allowed":"Blocked"),e("span",{class:"dl-sub"},p.ok?"Every step lets it through":`Stops at step ${c+1} of ${p.steps.length}`)]),e("ul",{class:"dl-checks"},p.steps.map(m=>e("li",{},[e("span",{class:`dl-check-icon ${m.ok?"ok":"error"}`},g(m.ok?"check":"x")),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},m.title),m.detail?e("div",{class:"dl-check-detail"},m.detail):""])])))])};return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Check access"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"Why something does or does not connect")]),e("div",{class:"dl-check-form"},[i.el,e("span",{class:"dl-faint"},"→"),s.el,D("Check",d)]),l])])}var Vt={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function Ve(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function Yt(n){return Ve(n.action==="check"?`check:${n.component??""}`:n.component??"")}function ko(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function $o(n,t){return!n?.from&&!n?.to?t:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??t}function _o(n,t){let o=n.check?.components??{},a=t==="all"?["app","amneziawg","packages"]:[t],r=[],i;for(let l of a){let d=o[l];if(d){if(d.error)return{tone:"warn",text:d.error};l==="packages"&&d.updates?r.push(`${d.updates} system package${d.updates===1?"":"s"}`):l!=="packages"&&d.update&&d.installed&&d.latest&&(r.push(`${Vt[l]} ${d.latest}`),t!=="all"&&(i=d.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 Eo(n,t,o,a){return t?n.id===t:o&&n.id===o?!1:n.state==="running"||a>0&&n.started>=a}var So=n=>new Promise(t=>setTimeout(t,n));async function Mt(n,t,o){let a=o?Yt(o):Ve(n),r=o?o.action==="check":n.startsWith("check"),i=Date.now(),s=e("b",{},Vt[a]??(a==="all"?"All components":"Dawnline")),l=e("span",{class:"dl-pill dl-mono"},t.version??""),d=e("span",{class:"dl-pill info",hidden:!0}),p=e("span",{},"0:00"),c=e("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),m=e("div",{}),v=e("div",{class:"dl-op-actions"}),h=[],x=u=>dom.content(v,u),R=(u=!1)=>ie("Close",u);oe(t.title,e("div",{class:"dl-op"},[e("div",{class:"dl-op-head"},[s,t.version?l:"",d,e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint dl-op-timer"},[g("clock"),p])]),e("div",{class:"dl-op-loghead"},[e("b",{},"Operation log"),ye("copy","Copy log",()=>pe(h.join(` -`),"Log copied"))]),c,m]),[v],"wide"),x([e("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?"Checking…":"Working…")]);let $=o??null,j=o?.id,w,H=0,S=u=>{j!==u.id&&(j=u.id,t.onJob?.(u))};if(o)t.onJob?.(o);else try{let u=await E.updatesStatus().catch(()=>null);w=u?.job?.id,H=u?.now??0;let f=await E.updatesRun(n);f.job&&f.job.state==="running"&&f.job.id!==w&&($=f.job,S(f.job))}catch(u){return h=[ve(u)],c.textContent=h[0],dom.content(m,e("div",{class:"dl-comp-status warn"},[g("alert"),e("span",{},ve(u))])),x([R(!0)]),Z(ve(u),"error"),null}let T=null,b=0;for(;;){if(await So(1e3),T=await E.updatesStatus().catch(()=>null),!T){if(++b>60)break;continue}b=0;let u=T.job;if(!u||!Eo(u,j,w,H)){if(Date.now()-i>15e3)break;continue}if(S(u),$=u,u.log.length){h=u.log;let f=c.scrollTop+c.clientHeight>=c.scrollHeight-8;c.textContent=h.join(` -`),f&&(c.scrollTop=c.scrollHeight)}if(l.textContent=$o(u,t.version??""),!l.isConnected&&l.textContent&&s.after(l),p.textContent=ko((u.finished??T.now)-u.started),u.state==="running"){d.hidden=!u.phase,d.textContent=u.phase;continue}break}if(c.scrollTop=c.scrollHeight,d.hidden=!1,!$||$.state==="running")return d.className="dl-pill warn",d.textContent="No answer",dom.content(m,e("div",{class:"dl-comp-status warn"},[g("alert"),e("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),x([R()]),t.onDone?.(T),$;if($.state==="failed")return d.className="dl-pill bad",d.textContent="Failed",dom.content(m,e("div",{class:"dl-comp-status bad"},[g("x"),e("span",{},[e("b",{},$.error??"Operation failed"),r?"":". Nothing else was changed."])])),x([D("Copy log",()=>pe(h.join(` -`),"Log copied")),R(!0)]),Z(`${Vt[a]??"Update"}: ${$.error??"failed"}`,"error"),t.onDone?.(T),$;if(d.className="dl-pill ok",d.textContent="Finished",r&&T){let u=_o(T,a);if(dom.content(m,e("div",{class:`dl-comp-status ${u.tone}`},[g(u.tone==="ok"?"check":u.tone==="warn"?"alert":"download"),e("span",{},u.text)])),Z(u.text,u.tone==="warn"?"warning":"success"),t.onDone?.(T),u.update&&t.onUpdate){let f=T;x([R(),D(`Update to ${u.update}`,()=>t.onUpdate(f),"positive")])}else x([R()]),u.tone==="ok"&&setTimeout(()=>m.isConnected&&se(),1200);return $}if(a==="app"&&$.to){let u=$.to,f=e("span",{},"Waiting for the router to restart its services…");dom.content(m,e("div",{class:"dl-comp-status ok"},[g("check"),e("span",{},[e("b",{},`Dawnline ${u} is installed. `),f])]));let N=()=>{ui.menu?.flushCache(),location.reload()};x([R(),D("Reload now",N,"positive")]),Z(`Dawnline updated to ${u}`,"success",6e3);for(let P=1;P<=30;P++)if(f.textContent=`Waiting for the router to restart its services (${P} of 30)…`,await So(1500),(await E.updatesStatus().catch(()=>null))?.version===u)return f.textContent="Services are back. Reloading…",setTimeout(N,800),$;return f.textContent="Services restarted. Reload the page to use the new version.",$}let A=a==="pkgs"?`Updated ${[...$.result?.pkgs?.updated??[],...$.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:a==="amneziawg"?`AmneziaWG${$.to?` ${$.to}`:""} is installed`:"Operation completed";return dom.content(m,e("div",{class:"dl-comp-status ok"},[g("check"),e("span",{},A)])),x([R()]),Z(A,"success"),t.onDone?.(T),$}var Mr={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function Co(n,t,o,a){return!await ne(`Install ${t}?`,o,"Install")||(await Mt(n,{title:`Installing ${t}`}))?.state!=="done"?!1:(setTimeout(()=>a?.(),4e3),!0)}function Qt(n){return Co("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 Pt(n,t,o){return n==="awg"?Qt(o):t.length?Co(`pkgs:${t.join(",")}`,Mr[n],`${t.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function Lo(n,t){if(n==="awg")return Qt(t);let o=await U(()=>E.updatesStatus());return o?Pt(n,o.needs?.[n]??[],t):!1}var Pr=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Dr={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function To(n,t,o){let a=n.id,r=t,i=e("div",{class:"dl-stack gap16"},e("section",{class:"dl-setsec"},e("div",{class:"dl-setsec-body"},e("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,d="",p=!0,c=!0,m="all",v=!1,h=xo(r,a,o),x=new Set,R="",$=()=>JSON.stringify([c,l,l?"":d,p,[...x].sort()]),j=()=>s.detected.lan||s.saved.lan||"",w=()=>(l?s.detected.wan||s.saved.wan:d)||"",H=()=>new Map(s.devices.map(C=>[C.name,C])),S=()=>{let C=H();return[...p&&j()?[j()]:[],...[...x].filter(Q=>Q!==j())].filter(Q=>Q!==w()).map(Q=>C.get(Q)??{name:Q,nets:[],missing:!0})},T=(C,G)=>{s=C,G&&(l=C.config.auto_wan,d=C.config.wan_device||C.detected.wan||C.saved.wan||"",p=C.config.auto_lan,c=C.config.lan_like,m=C.config.mesh??(C.config.device_mesh?"all":"off"),x=new Set(C.config.lan_devices),R=$()),W()},b=async C=>{let G=await E.interfaces(a).catch(Q=>(Z(Q.message,"error"),null));G&&T(G,C)};function A(C){let G=p&&C.name===j(),Q=!!C.own||!!C.master||C.name===w()||G;return G||x.has(C.name)||!Q&&(C.nets.length>0||!!C.missing)}function u(C){let G=p&&C.name===j(),Q=C.name===w(),de=!G&&x.has(C.name),F=!(!!C.own||!!C.master||Q||G)&&(C.nets.length>0||de||!!C.missing),me=(de||G)&&!C.zone&&!C.missing,re=C.missing?"Not present right now":C.own?"This server":C.master?`Port of ${C.master}`:Q?`Internet${C.zone?` · zone ${C.zone}`:""}`:C.nets.length?C.nets.join(", "):"No IPv4 network",ge=e("button",{type:"button",class:`dl-if${de?" sel":""}${G?" auto":""}${!F&&!de&&!G?" off":""}${me?" warn":""}`,"aria-pressed":de||G?"true":"false","aria-disabled":F?null:"true",click:()=>{F&&(x.has(C.name)?x.delete(C.name):x.add(C.name),W())}},[e("span",{class:"dl-if-ic"},g(Dr[C.kind]??"link")),e("span",{class:"dl-if-main"},[e("span",{class:"dl-if-name"},C.name),e("span",{class:"dl-if-sub"},re)]),G?e("span",{class:"dl-if-badge ok"},"Auto"):de?e("span",{class:"dl-if-check"},g("check")):""]);return ue(ge,()=>[e("div",{class:"dl-tip-title"},C.name),e("div",{class:"dl-muted"},[C.logical?`Interface ${C.logical}`:"No netifd interface",C.zone?` · zone ${C.zone}`:" · no firewall zone"]),C.members.length?e("div",{class:"dl-muted"},`Ports: ${C.members.join(", ")}`):"",C.nets.length?e("div",{class:"dl-mono"},C.nets.join(", ")):"",me?e("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",C.master?e("div",{class:"dl-muted"},`Choose ${C.master} to include it.`):""]),ge}function f(){let C=s.like_home;return!c||!s.config.lan_like?"":!s.needs?.length&&C.active&&C.bridged?"ok":"warn"}function N(){let C=s.like_home;return c?s.needs?.length?[e("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?C.active&&C.bridged?["Internet traffic enters ",e("span",{class:"dl-mono"},C.dev??"")," as ",e("span",{class:"dl-mono"},C.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[e("span",{class:"dl-warn"},`Not working: ${C.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let P={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function I(C,G,Q,de,O="",F){return e("div",{class:F?"dl-setrow head":"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:`dl-need-ic ${O}`},g(C)),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},G),e("span",{class:"dl-sub"},Q),F??""])]),e("div",{class:"dl-setrow-ctl"},de)])}let J=(C,G)=>{let Q=de=>e("span",{class:"dl-mono"},de);return C?e("span",{},[" Now: ",Q(C),...G&&G!==C?[", was ",Q(G)]:[],"."]):e("span",{},G?[" Not found now: using ",Q(G),"."]:[" Not found."])};function W(){let C=e("select",{class:"cbi-input-select","aria-label":"Internet interface",change:y=>{d=y.target.value,W()}},s.devices.filter(y=>!y.own&&!y.master&&y.zone&&!y.missing).map(y=>e("option",{value:y.name,selected:y.name===d?"selected":null},`${y.name} · zone ${y.zone}`))),Q=S().flatMap(y=>y.nets.map(B=>[B,y.name])),de=JSON.parse($()),O=JSON.parse(R),F=(...y)=>y.some(B=>JSON.stringify(de[B])!==JSON.stringify(O[B])),me=F(0,1,2),re=F(3,4),ge=y=>D("Save",async()=>{let B=await U(()=>E.serverInterfaces(a,l,l?"":d,p,[...x],c,m!=="off",m),"Access saved");B&&(T(B,!0),B.nets_changed&&B.lan_only&&Z(`${B.lan_only} ${B.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!y}),M=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Internet"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Internet or Both")]),I("home","Internet like a home device",N(),[c&&s.needs?.length?D("Install",()=>Pt("home",s.needs,()=>b(!1)),"positive"):"",fe(c,"Internet like a home device",y=>{c=y,W()})],f()),I("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",J(s.detected.wan,s.saved.wan)],[l?"":C,fe(l,"Auto-detect WAN",y=>{l=y,W()})])]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},c?["Internet like a home device",w()?[" · leaves through ",e("span",{class:"dl-mono"},w())]:""]:w()?["Internet straight to ",e("span",{class:"dl-mono"},w())]:"No WAN found"),ge(me)])]),_=xe([["off","Off"],["all","Everyone"],["circles","Circles"]],m,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async y=>{let B={off:"Off",all:"Everyone",circles:"Circles"}[y];await U(()=>E.serverUpdate(a,{mesh:y}),`Devices reach each other: ${B}`)&&(m=y,s.config.mesh=y,W(),await o())}}),k=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Home network"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Home or Both"),D([g("reset")," Rescan"],()=>b(!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.","","",q()),I("link","Devices reach each other",P[m],_,"",m==="circles"?wo(r,a,o):void 0),h.el]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub dl-if-summary"},Q.length?["Home access reaches ",...Q.flatMap(([y,B],Y)=>[Y?", ":"",e("span",{class:"dl-mono"},y),` (${B})`])]:"No home network: Home access reaches nothing but this router."),ge(re)])]),z=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[M,k]),i.style.minHeight="",window.scrollTo({top:z})}function q(){let C=s.devices.filter(A),G=s.devices.filter(Q=>!A(Q));return e("div",{class:"dl-stack gap8 dl-netpick"},[C.length?e("div",{class:"dl-ifgrid"},C.map(u)):e("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),e("label",{class:"dl-boxrow"},[e("span",{class:"dl-stack"},[e("span",{},"Auto-detect LAN"),e("span",{class:"dl-sub"},["Adds the LAN this router uses.",J(s.detected.lan,s.saved.lan)])]),fe(p,"Auto-detect LAN",Q=>{p=Q,W()})]),G.length?e("details",{class:"dl-params",open:v?"":null,toggle:Q=>v=Q.currentTarget.open},[e("summary",{},[g("chevron"),e("span",{},"Other interfaces"),e("span",{class:"dl-pcount"},String(G.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...Pr.map(([Q,de])=>{let O=G.filter(F=>F.category===Q);return O.length?e("div",{class:"dl-ifgroup"},[e("h4",{},de),e("div",{class:"dl-ifgrid"},O.map(u))]):""})])]):""])}return b(!0),{el:i,update(C){r=C,h.update(C),s&&W()}}}var Mo="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl",Ar="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",zr="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",Nr={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Dt=null;function Rr(n){let t=window;return n.appendChild(e("link",{rel:"stylesheet",href:`${Mo}.css`})),t.maplibregl?Promise.resolve(t.maplibregl):Dt||(Dt=new Promise((o,a)=>{let r=e("script",{src:`${Mo}.js`});r.onload=()=>t.maplibregl?o(t.maplibregl):a(new Error("MapLibre failed to load")),r.onerror=()=>{Dt=null,a(new Error("Could not load the map library (no internet access from this browser?)"))},n.appendChild(r)}),Dt)}function Zt(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function Hr(n,t,o=48){let a=(n[0]+t[0])/2,r=(n[1]+t[1])/2,i=t[0]-n[0],s=t[1]-n[1],l=Math.hypot(i,s)||1,d=Math.min(.25*l,12),p=a-s/l*d,c=r+i/l*d,m=[];for(let v=0;v<=o;v++){let h=v/o,x=1-h;m.push([x*x*n[0]+2*x*h*p+h*h*t[0],x*x*n[1]+2*x*h*c+h*h*t[1]])}return m}function Ir(n,t){let o=new Map;for(let a of n.geo.points){if(n.person&&a.person!==n.person||(t==="online"?!a.online:n.now-a.ts>Nr[t]))continue;let r=o.get(a.device);(!r||a.online&&!r.online||a.online===r.online&&a.ts>r.ts)&&o.set(a.device,a)}return[...o.values()]}var gt=class{constructor(t,o="online",a=380){this.cb=t;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.anim=0;this.data=null;this.fitted=!1;this.range=o,this.status=e("div",{class:"dl-map-status"}),this.el=e("div",{class:"dl-geomap",style:`height:${a}px`},this.status)}async mount(t){this.data=t;try{this.gl=await Rr(this.el)}catch(o){this.status.textContent=o.message;return}this.map=new this.gl.Map({container:this.el,style:Zt()?Ar:zr,center:[t.geo.home?.lon??20,t.geo.home?.lat??50],zoom:3,attributionControl:{compact:!0},dragRotate:!1,pitchWithRotate:!1,cooperativeGestures:!0}),this.map.addControl(new this.gl.NavigationControl({showCompass:!1}),"bottom-right"),this.map.on("load",()=>{this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],"#40c977",Zt()?"#ededed":"#0d0d0d"],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],"#40c977",Zt()?"#ededed":"#0d0d0d"],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],!1],layout:{"line-cap":"round"},paint:{"line-color":Zt()?"#ededed":"#0d0d0d","line-opacity":.35,"line-width":1.5,"line-dasharray":[2,3]}}),this.map.addLayer({id:"dl-arc-glow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-opacity":.18,"line-width":7}}),this.map.addLayer({id:"dl-arc-live",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-width":2}}),this.map.addLayer({id:"dl-arc-flow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#ffffff","line-width":2,"line-opacity":.8,"line-dasharray":[0,4,3]}}),this.animate(),this.draw()})}setRange(t){this.range=t,this.fitted=!1,this.draw()}update(t){this.data=t,this.draw()}destroy(){cancelAnimationFrame(this.anim),this.map?.remove(),this.map=null}animate(){let t=[[0,4,3],[.5,4,2.5],[1,4,2],[1.5,4,1.5],[2,4,1],[2.5,4,.5],[3,4,0],[0,.5,3,3.5],[0,1,3,3],[0,1.5,3,2.5],[0,2,3,2],[0,2.5,3,1.5],[0,3,3,1],[0,3.5,3,.5]],o=-1,a=0,r=i=>{this.map&&(i-a>70&&(a=i,o=(o+1)%t.length,this.map.getLayer("dl-arc-flow")&&this.map.setPaintProperty("dl-arc-flow","line-dasharray",t[o])),this.anim=requestAnimationFrame(r))};this.anim=requestAnimationFrame(r)}groups(t){let o=new Map;for(let a of t){let r=`${a.asn||a.org||a.ip}|${a.city}|${a.cc}`,i=o.get(r);i||(i={key:r,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 t=this.data,o=this.groups(Ir(t,this.range)),a=t.geo.home;for(let s of this.markers)s.remove();this.markers=[];let r=new Map,i=o.map(s=>{let l=`${s.lat.toFixed(2)},${s.lon.toFixed(2)}`,d=r.get(l)??0;return r.set(l,d+1),{g:s,at:[s.lon+d*.25,s.lat]}});if(this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:s,at:l})=>({type:"Feature",properties:{online:s.online},geometry:{type:"Point",coordinates:l}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?i.map(({g:s,at:l})=>({type:"Feature",properties:{online:s.online},geometry:{type:"LineString",coordinates:Hr([a.lon,a.lat],l)}})):[]}),a){let s=e("div",{class:"dl-mk-home",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`});s.innerHTML=gn("home","dl-mk-home-ic"),this.markers.push(new this.gl.Marker({element:s}).setLngLat([a.lon,a.lat]).addTo(this.map))}for(let{g:s,at:l}of i){let d=s.points.length,p=e("button",{type:"button",class:`dl-mk${s.online?" online":""}${d>1?" multi":""}`,"aria-label":`${d} device${d===1?"":"s"} via ${s.org||"unknown network"} in ${s.city||"unknown city"}`},d>1?e("span",{class:"dl-mk-count"},String(d)):e("span",{class:"dl-mk-dot"})),m=!!a&&Math.abs(l[0]-a.lon)<.02&&Math.abs(l[1]-a.lat)<.02?[22,-16]:[0,0];p.addEventListener("click",v=>{v.stopPropagation(),this.openPopup(s,l,m)}),this.markers.push(new this.gl.Marker({element:p,offset:m}).setLngLat(l).addTo(this.map))}if(!this.fitted){let s=i.map(l=>l.at);a&&(s.length===0||this.range!=="online"||i.some(l=>l.g.online))&&s.push([a.lon,a.lat]),this.fit(s),this.fitted=!0}this.status.textContent=i.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none"}fit(t){if(!t.length)return;let o=(d,p)=>{let c=Math.PI/180,m=(p[1]-d[1])*c,v=(p[0]-d[0])*c,h=Math.sin(m/2)**2+Math.cos(d[1]*c)*Math.cos(p[1]*c)*Math.sin(v/2)**2;return 12742*Math.asin(Math.sqrt(h))},a=[t.reduce((d,p)=>d+p[0],0)/t.length,t.reduce((d,p)=>d+p[1],0)/t.length],r=t;if(t.length>=5){let d=[...t].sort((p,c)=>o(a,p)-o(a,c));r=d.slice(0,Math.ceil(d.length*.9))}if(Math.max(...r.map(d=>o(a,d)))<25){this.map.jumpTo({center:a,zoom:9.5});return}let s=new this.gl.LngLatBounds(r[0],r[0]);r.forEach(d=>s.extend(d));let l=this.el.clientHeight||380;this.map.fitBounds(s,{padding:{top:Math.min(90,l/4),bottom:Math.min(70,l/5),left:60,right:60},maxZoom:9,duration:0})}openPopup(t,o,a=[0,0]){let r=this.data;this.popup?.remove();let i=[t.city,t.cc||t.country].filter(Boolean).join(", "),s=[...new Set(t.points.map(c=>c.person))],l=t.points.sort((c,m)=>Number(m.online)-Number(c.online)||m.ts-c.ts).map(c=>{let m=r.people.find(h=>h.id===c.person),v=m?.devices.find(h=>h.id===c.device);return e("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(c.person,c.device)},[e("span",{class:`dl-pop-dot${c.online?" on":""}`}),e("span",{class:"dl-pop-name"},[e("b",{},m?.name??c.person),` · ${v?.name??"device"}`]),e("span",{class:"dl-faint dl-nowrap"},c.online?"now":le(c.ts,r.now))])}),d=e("div",{class:"dl-pop"},[e("div",{class:"dl-pop-head"},[e("span",{class:"dl-pop-net"},g("globe")),e("div",{class:"dl-stack"},[e("strong",{},t.org||"Unknown network"),e("span",{class:"dl-faint"},[t.asn?`AS${t.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),e("div",{class:"dl-pop-list"},l),s.length===1?e("div",{class:"dl-pop-actions"},[e("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${r.people.find(c=>c.id===s[0])?.name??"person"}`)]):""]),p=this.el.clientHeight||380;this.map.easeTo({center:o,offset:[0,Math.min(140,p*.32)],duration:300}),this.popup=new this.gl.Popup({offset:[a[0],a[1]-18],anchor:"bottom",closeButton:!1,focusAfterOpen:!1,maxWidth:"300px",className:"dl-popup"}).setLngLat(o).setDOMContent(d).addTo(this.map)}};function Xt(n,t,o=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],r=e("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of a)i==="online"&&!o||r.appendChild(e("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)),t(i)}},s));return r}var Br={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",paused_all:"warn",resumed_all:"ok",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},Or={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",paused_all:"pause",resumed_all:"play"};function jr(n,t){return t.device?n.people.flatMap(a=>a.devices).find(a=>a.id===t.device)?.kind??t.dkind??"other":Or[t.type]??"activity"}function Mn(n,t){let o=n.people.find(x=>x.id===t.person),a=o?.name??t.pname??t.person??"",r=o?.devices.find(x=>x.id===t.device)?.name??t.dname??"",i=x=>e("b",{},x),s=x=>e("span",{class:"dl-muted"},x),l=x=>e("span",{class:"dl-mono"},x),d=x=>t.hosts?.[x]?[e("span",{class:"dl-ev-host"},[e("b",{},t.hosts[x]),e("span",{class:"dl-faint"},` (${x})`)])]:[l(x)],p=x=>e("span",{class:"dl-ev-kind"},`${x} `),c=r?`${a} · ${r}`:a,m=eo(t),v=m||r||"a device",h=x=>[e("span",{class:"dl-you"},"You"),s(` ${x} `)];if(Le(t)==="admin")switch(t.type){case"device_added":return[...h("added"),p("device"),i(v),s(" for "),i(a)];case"device_removed":return[...h("removed"),p("device"),i(v),s(" from "),i(a)];case"paused":return[...h("paused"),p("person"),i(a)];case"resumed":return[...h("resumed"),p("person"),i(a)];case"device_changed":{let x=m.startsWith("renamed from ");return[...h(x?"renamed":m),p("device"),i(r||"a device"),s(" of "),i(a),...x?[s(` · was ${m.slice(13)}`)]:[]]}case"device_keys":return[...h("issued new keys for"),p("device"),i(v),s(" of "),i(a),s(" · it needs its new configuration")];case"link_changed":return[...h("issued a new link for"),p("person"),i(a),s(" · the old link stopped working")];case"paused_all":return[e("span",{class:"dl-you"},"You"),s(" paused everyone")];case"resumed_all":return[e("span",{class:"dl-you"},"You"),s(" resumed everyone")]}switch(t.type){case"connect":return[p("Device"),i(c),s(" connected"),...t.detail?[s(" from "),...d(t.detail)]:[],...t.where?[s(` · ${t.where}`)]:[]];case"disconnect":return[p("Device"),i(c),s(" went offline")];case"roam":return[p("Device"),i(c),s(" changed network "),...(t.detail??"").split(" → ").flatMap((x,R)=>R?[s(" → "),...d(x)]:d(x))];case"device_added":return[p("Person"),i(a),s(" added "),p("device"),i(v),...Le(t)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[p("Person"),i(a),s(" removed "),p("device"),i(v),...Le(t)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[p("Person"),i(a),s(" issued new keys for "),p("device"),i(v),s(" on their portal")];case"person_added":return[...h("added"),p("person"),i(t.detail??a)];case"person_removed":return[...h("removed"),p("person"),i(t.detail??a)];case"person_changed":return[...h("changed"),p("person"),i(a),...m?[s(` · ${m.replace(/_/g," ")}`)]:[]];case"paused":return[p("Person"),i(a),s(` paused — ${t.detail??""}`)];case"resumed":return[p("Person"),i(a),s(" resumed"),...t.detail&&t.detail!=="active"?[s(` — ${t.detail}`)]:[]];case"paused_all":return[s("Everyone paused")];case"resumed_all":return[s("Everyone resumed")];case"portal_blocked":return[e("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(t.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[p("Person"),i(a),s(" — all devices removed, end date reached")];default:return[s(`${t.type}${t.detail?`: ${t.detail}`:""}`)]}}var Ur={portal_blocked:["globe","bad"]};function Wr(n,t){if(n.servers.length<2||!t.person)return"";let o=n.people.find(r=>r.id===t.person),a=o&&n.servers.find(r=>r.id===o.server);return a?e("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function Ye(n,t,o={}){let a=Ur[t.type],r=Le(t);return e("div",{class:`dl-row${r==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[r==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):a?e("span",{class:"dl-ev-tile sys"},g(a[0])):e("span",{class:`dl-ev-tile ev ${Br[t.type]??""}`},g(jr(n,t))),e("span",{class:"dl-row-main"},Mn(n,t)),o.server===!1?"":Wr(n,t),e("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString()},o.time??le(t.ts,n.now))])}var Gr={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},qr={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function en(n,t,o,a){let r=n.by==="admin",i=e("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${Gr[n.level]??""}`}${n.detail?" has-detail":""}`},[r?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):e("span",{class:"dl-ev-tile sys",title:n.level},g(qr[n.src]??"zap")),e("span",{class:"dl-row-main"},r?[e("span",{class:"dl-you"},"You"),e("span",{class:"dl-muted"},` ${n.msg} `),n.kind?e("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?e("b",{},n.who):"",n.note?e("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?e("span",{class:`dl-slog-more${t?" open":""}`},g("chevron")):"",n.detail&&t?e("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?e("span",{class:"dl-ev-kind"},"Server "):"",e("b",{class:"dl-sys-src",title:_t[n.src]??n.src},n.who??_t[n.src]??n.src)," ",e("span",{class:"dl-muted"},n.msg),n.detail?e("span",{class:`dl-slog-more${t?" open":""}`},g("chevron")):"",n.detail&&t?e("pre",{class:"dl-slog-detail"},n.detail):""]),e("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 Po(n){let t=new Date(n*1e3),o=new Date,a=new Date;return a.setDate(o.getDate()-1),t.toDateString()===o.toDateString()?"Today":t.toDateString()===a.toDateString()?"Yesterday":t.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var vt=n=>lt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function tn(n,t,o){let a=n.slice(-15),r=a[a.length-1],i=r&&t-r[0]<180,s=i?r[2]:0,l=i?r[1]:0,[d,p]=o,c=200,m=40,v=Math.max(1,...a.map(w=>Math.max(w[1],w[2]))),h=w=>a.map((H,S)=>`${a.length>1?S/(a.length-1)*c:c},${m-2-H[w]/v*(m-6)}`),x=h(2),R=h(1),$=a.length>1?qe(``):e("div",{class:"dl-speed-wait"},[e("i"),e("span",{},"Collecting… 1 point a minute")]),j=(w,H,S,T)=>e("div",{class:"dl-speed-col"},[e("span",{class:"dl-sub"},[e("span",{class:S},H),` ${w}`]),e("span",{class:"dl-speed-val"},Pe(T))]);return a.length>1&&ue($,()=>{let w=a[a.length-1];return[e("div",{class:"dl-tip-title"},new Date(w[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),e("div",{},`↓ ${Pe(w[2])} · ↑ ${Pe(w[1])}`)]}),e("div",{class:"dl-bento-tile"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Speed now"),e("span",{class:"dl-sub"},"last 15 min")]),e("div",{class:"dl-speed-cols"},[j("Download","↓","dl-dn",s),j("Upload","↑","dl-up",l)]),$,e("div",{class:"dl-speed-today"},[e("span",{},["Today ",e("b",{},te(d+p))]),e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${te(p)} `,e("span",{class:"dl-up"},"↑"),` ${te(d)}`])])])}function nn(n,t){let o=n.slice(-30),a=o.map(d=>d.rx+d.tx),r=Math.max(1,...a),i=a.reduce((d,p)=>d+p,0),s=a.reduce((d,p,c)=>p>a[d]?c:d,0),l=e("div",{class:"dl-bento-bars"},o.map((d,p)=>{let c=a[p],m=e("i",{class:p===o.length-1?"hi":"",style:`height:${Math.max(4,c/r*100)}%`});return ue(m,()=>[e("div",{class:"dl-tip-title"},p===o.length-1?`Today · ${vt(d.day)}`:vt(d.day)),e("div",{},te(c)),e("div",{class:"dl-muted dl-mono"},`↓ ${te(d.tx)} ↑ ${te(d.rx)}`)]),m}));return e("div",{class:"dl-bento-tile month"},[e("div",{class:"dl-bento-head"},[e("span",{},[e("span",{class:"dl-metric-label"},"Last 30 days"),e("b",{class:"dl-bento-total"},te(i))]),a[s]>0?e("span",{class:"dl-sub"},`peak ${te(a[s])} · ${vt(o[s].day)}`):""]),o.length?l:e("p",{class:"dl-muted"},"No traffic yet."),e("div",{class:"dl-bento-head"},[e("span",{class:"dl-sub"},o.length?vt(o[0].day):""),e("span",{class:"dl-sub"},t),e("span",{class:"dl-sub"},"today")])])}function Do(n){let t=n.slice(-30),o=t.map(r=>r.rx+r.tx),a=Math.max(1,...o);return e("div",{class:"dl-dbars"},t.map((r,i)=>{let s=e("i",{class:`${o[i]?"":"zero"}${i===t.length-1?" hi":""}`});return s.style.height=`${Math.max(8,o[i]/a*100)}%`,ue(s,()=>[e("div",{class:"dl-tip-title"},i===t.length-1?`Today · ${vt(r.day)}`:vt(r.day)),e("div",{},te(o[i]))]),s}))}var Ao={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function on(n){return n==="netrestart"&&!await ne("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await U(()=>E.healthFix(n),"Done")??null}function Pn(n,t,o,a="action"){let r=n.fix;return r?r.startsWith("install:")?D("Install",()=>Lo(r.slice(8),o),a):r==="updates"?e("a",{class:`cbi-button cbi-button-${a}`,href:L.url("admin/network/dawnline/updates")},Ao.updates):D(Ao[r]??"Fix",()=>t(r),a):""}function Fr(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==="nft"?"lock":"alert"}function zo(n,t,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 e("div",{class:"dl-list dl-notices"},[...r.slice(0,a).map(s=>tt(Fr(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,Pn(s,t,o,s.status==="error"?"positive":"neutral"))),i>0?e("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,e("span",{class:"dl-spacer"}),"→"]):""])}function Kr(n){let t=[],o=(s,l)=>e("a",{href:s},l),a=Ne(n.series),r=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?t.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!r&&t.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});n.settings.paused_all&&t.push({tone:"warn",text:["Everyone is paused."]});for(let s of n.people)if(s.state==="quota")t.push({tone:"warn",text:[o(Te(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")t.push({tone:"warn",text:[o(Te(s.id),s.name),"’s access has ended."]});else{let l=Xe(s.expires,a);l!=null&&l>=0&&l<=Math.max(s.expire_warn,3)&&t.push({tone:"",text:[o(Te(s.id),s.name),`’s access ends in ${l} day${l===1?"":"s"}.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&t.push({tone:"",text:[o(Te(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&&t.push({tone:"warn",text:i.length===1?[o(Te(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&&t.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||t.push({tone:"",text:["The personal portal is off. ",o(L.url("admin/network/dawnline/settings"),"Turn on")]}),t}var an=class{constructor(t,o){this.srvId=t;this.go=o;this.el=e("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(t){this.st=Tt(t,this.srvId);for(let o of["health","bento","side","activity"])this.parts[o]=e("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),e("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(t,o=!1){this.st=Tt(t,this.srvId),this.paint(o),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let t=await E.health().catch(()=>null);if(!t)return;let o=()=>void this.loadHealth(),a=async r=>{await on(r)&&(o(),r==="netrestart"&&setTimeout(o,5e3))};_e(this.parts.health,zo(t.checks,r=>void a(r),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let t=this.st,o=e("div",{class:"dl-panel-head pad"},[e("div",{class:"dl-stack"},[e("h3",{},"Where people connect from"),e("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),e("span",{class:"dl-spacer"}),Xt(this.range,i=>{this.range=i,this.map?.setRange(i)})]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[o,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map=new gt({openPerson:i=>location.href=Te(i),openDevice:(i,s)=>location.href=Te(i,s)},this.range);let a=e("div",{class:"dl-map-legend"},[e("span",{},[e("i",{class:"dot ok"}),"Online"]),e("span",{},[e("i",{class:"dot"}),"Seen recently"]),e("span",{},[e("i",{class:"line"}),"Live tunnel"])]),r=e("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[o,r])}paint(t=!1){let o=this.st,a=o.servers[0],r=o.people.reduce((l,d)=>l+Math.max(0,d.device_limit-d.devices.length),0);_e(this.parts.bento,e("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Re(a).overviewTile(a),this.monthTile(r)]),t);let i=Kr(o);_e(this.parts.side,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Needs attention"),e("span",{class:"dl-spacer"}),e("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),i.length?i.slice(0,8).map(l=>e("div",{class:"dl-attn-item dl-row"},[e("span",{class:`dl-ev-dot ${l.tone}`}),e("span",{},l.text),l.action??""])):e("div",{class:"dl-row dl-muted"},[g("check"),"All good. Nothing needs you right now."])]),t);let s=[...o.events].reverse().slice(0,8);_e(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-spacer"}),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),s.length?s.map(l=>Ye(o,l)):e("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),t)}onlineTile(){let t=this.st,o=12,a=$=>$.spark[$.spark.length-1]??0,r=$=>t.geo.points.find(j=>j.device===$.id&&j.city)?.city,i=$=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test($.endpoint??""),s=$=>(i($)?"home":r($))??"",l=$=>[...t.events].reverse().find(j=>j.type==="connect"&&j.device===$.id)?.ts??0,d=t.people.map($=>({p:$,devs:$.devices.filter(j=>j.online).sort((j,w)=>a(w)-a(j))})).filter($=>$.devs.length).sort(($,j)=>j.devs.reduce((w,H)=>w+a(H),0)-$.devs.reduce((w,H)=>w+a(H),0)),p=d.length<=2,c=({p:$,devs:j})=>{let w=j.map(l).filter(Boolean),H=w.length?Math.min(...w):0,S=($.rate??[]).slice(-15),T=S[S.length-1],b=T&&t.now-T[0]<180?T:null,A=200,u=30,f=Math.max(1,...S.map(W=>Math.max(W[1],W[2]))),N=W=>S.map((q,C)=>`${S.length>1?C/(S.length-1)*A:A},${u-2-q[W]/f*(u-6)}`),P=S.length>1?qe(``):"",I=!b||b[1]<64&&b[2]<64,J=$.access==="both"?["home","globe"]:$.access==="lan"?["home"]:["globe"];return[e("div",{class:"dl-hc"},[e("div",{class:"dl-hc-head"},[e("span",{class:"dl-onl-av sm"},Oe($.name)),e("span",{class:"dl-stack"},[e("b",{},$.name),e("span",{class:"dl-hc-since"},H?`online for ${le(H,t.now).replace(" ago","")}`:"online")]),e("span",{class:"dl-hc-reach"},J.map(W=>e("span",{class:`dl-ibadge ${W==="home"?"lan":"inet"}`},g(W))))]),e("div",{class:"dl-hc-speed"},[e("div",{class:"dl-hc-speed-row"},I?[e("span",{class:"dl-faint"},"Idle right now")]:[e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${Pe(b[2])}`]),e("span",{},[e("span",{class:"dl-up"},"↑"),` ${Pe(b[1])}`]),e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint"},"15 min")]),P]),e("div",{class:"dl-hc-devs"},j.map(W=>e("span",{class:"dl-hc-dev"},[g(W.kind),[W.name,s(W)].filter(Boolean).join(" · ")]))),e("div",{class:"dl-hc-foot"},[e("span",{class:"dl-faint"},`${te(j.reduce((W,q)=>W+a(q),0))} today · ${te($.month[0]+$.month[1])} this month`)])])]},m=$=>{let{p:j,devs:w}=$,H=e("span",{class:"dl-onl-dev"},w.length>1?String(w.length):g(w[0].kind)),S=e("a",{class:`dl-onl-p${p?"":" sm"}`,href:Te(j.id),"aria-label":`${j.name}, online`},[e("span",{class:"dl-onl-av"},[Oe(j.name),H]),p?e("span",{class:"dl-onl-name"},j.name):"",p?e("span",{class:"dl-onl-meta"},[...w.slice(0,3).map(T=>g(T.kind)),w.length>3?`+${w.length-3}`:"",s(w[0])?e("span",{},` · ${s(w[0])}`):""]):""]);return ue(S,()=>c($)),S},v=e("b",{class:`dl-onl-count${d.length?"":" none"}`},String(d.length)),h=d.reduce(($,j)=>$+j.devs.length,0);d.length&&ue(v,()=>[`${d.length} ${d.length===1?"person":"people"} · ${h} device${h===1?"":"s"}`]);let x=d.length>o?d.slice(0,o-1):d,R=t.people.flatMap($=>$.devices.map(j=>({p:$,d:j}))).filter($=>$.d.handshake).sort(($,j)=>j.d.handshake-$.d.handshake)[0];return e("div",{class:"dl-bento-tile online"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Online"),v]),d.length?e("div",{class:`dl-onl-row${p?"":" grid"}`},[...x.map(m),d.length>o?e("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:$=>{this.go&&($.preventDefault(),this.go("people","online"))}},[e("span",{class:"dl-onl-av"},`+${d.length-x.length}`)]):""]):e("div",{class:"dl-onl-empty"},[e("span",{},"Nobody is connected"),R?e("span",{class:"dl-sub"},`Last: ${R.p.name}, ${le(R.d.handshake,t.now)}`):e("span",{class:"dl-sub"},"No device has connected yet")])])}speedTile(){return tn(this.st.servers[0]?.rate??[],this.st.now,this.st.totals.today)}monthTile(t){let o=this.st.totals,a=this.st.people.filter(r=>r.state!=="active").length;return nn(this.st.series,`${o.people} ${o.people===1?"person":"people"}${a?` · ${a} paused`:""} · ${t} device slot${t===1?"":"s"} free`)}};var No=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],Jr={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},Dn=(n,t)=>{let o=new URLSearchParams;n&&o.set("server",n),t&&t!=="overview"&&o.set("section",t);let a=o.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},At=class{constructor(){this.noFooter=!0;this.root=e("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=e("div",{});this.headEl=e("div",{});this.secEl=e("div",{});this.bodyEl=e("div",{class:"dl-srvbody"})}async load(){let t=await E.status(31),o=t.servers.length?null:await E.setupDefaults();return[t,o]}render([t,o]){if(this.st=t,!t.servers.length&&o)return this.wizard(o);let a=new URLSearchParams(location.search),r=a.get("section")??"",i=Jr[r]??r;return No.some(([s])=>s===i)&&(this.section=i),this.srvId=(t.servers.find(s=>s.id===a.get("server"))??t.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller=Ke({fetch:()=>E.status(31),every:10,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(t=!1){_e(this.headEl,this.head(this.current()),t),(!t||!ft(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let t=await E.status(31).catch(()=>null);return t?.servers.length?(this.st=t,this.paintHead(),t):null}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await E.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=Dn())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let t=this.current();dom.content(this.tabsEl,e("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(o=>e("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===t.id?" on":""}`,"aria-selected":o.id===t.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[e("i",{class:`dot ${o.up?"ok":"bad"}`}),e("b",{},o.name)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[g("plus"),"Add server"])]))}paintSections(){let t=Re(this.current());dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},No.map(([o,a])=>e("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"?t.label:a))))}go(t,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 at;r.filter=o}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let t=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of t)o&&this.bodyEl.contains(o)&&o.remove()}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===t;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 an(a.id,(l,d)=>this.go(l,d))).mount(o)},people:()=>{var p,c;let s=this.pp[a.id];if(s?.el)return s.update(),s.el;let l=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((p=this.pp)[c=a.id]??(p[c]=new at)).embed(o,a.id).then(m=>{l.isConnected?dom.content(l,m):l.replaceChildren(m)}).catch(m=>{delete this.pp[a.id],dom.content(l,e("p",{class:"dl-muted"},`Couldn't show people: ${ve(m)}`))}),l},connection:()=>this.connection(a),access:()=>this.access(a),awg:()=>this.awg(a)}[t]();this.detachKept(),dom.content(this.bodyEl,i)}head(t){let o=this.st,a=(l,d)=>e("span",{class:"dl-addrbar-seg"},[g(l),...d]),r=t.endpoint||"—",i=!t.enabled||o.settings.paused_all,s=e("div",{class:"dl-actions"},[i?D([g("play")," Turn on"],async()=>{o.settings.paused_all&&!await U(()=>E.pauseAll(!1))||(t.enabled?await this.refresh():await this.save(t,{enabled:"1"},"Server turned on"))},"positive"):""]);return e("div",{class:"dl-srvpagehead"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),e("span",{class:`dl-pill ${t.enabled?t.up?"ok":"bad":"off"}`},t.enabled?t.up?"Running":t.blocked?"Can’t start":"Not running":"Turned off"),o.settings.paused_all&&t.enabled?e("span",{class:"dl-pill warn"},"Off"):"",e("span",{class:"dl-spacer"}),s]),e("div",{class:"dl-addrbar"},[e("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>pe(r,"Address copied")},[g("globe"),e("span",{class:"dl-mono"},r),g("copy")]),a("tunnel",[e("span",{class:"dl-mono"},`${Re(t).label} :${t.port}`)]),t.up?a("clock",[`up ${st(t.uptime)}`]):""]),t.blocked?e("div",{class:"dl-note warn"},[g("alert"),e("span",{},`${t.name} ${t.blocked}.`)]):""])}async save(t,o,a="Saved"){await U(()=>E.serverUpdate(t.id,o),a)&&await this.refresh()}connection(t){let o=ae(t.name,{placeholder:"Home"}),a=ae(t.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),r=ae(t.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter(l=>l.server===t.id).length,s=D(t.enabled?"Turn off":"Turn on",async()=>{t.enabled&&!await ne(`Turn off ${t.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(t,{enabled:t.enabled?"0":"1"},t.enabled?"Server turned off":"Server turned on")},t.enabled?"negative":"positive");return e("div",{class:"dl-stack gap16"},[kt("Connection",[e("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",[X("Name",o,"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[X("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",[X("DNS for devices",r,"Empty = this router, which sends each query where your home network would.")])],[e("span"),D("Save",()=>this.save(t,{name:o.value,endpoint:a.value,dns:r.value}),"positive")]),kt("Danger zone",[e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},t.enabled?"Turn off this server":"This server is off"),e("span",{class:"dl-sub"},t.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),e("div",{class:"dl-setrow-ctl"},s)]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Remove server"),e("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),e("div",{class:"dl-setrow-ctl"},D([g("trash")," Remove"],()=>this.remove(t),"negative"))])],[],"danger")])}access(t){let o=Tn(this.st,t),a=To(t,this.st,async()=>{let r=await this.refreshStatus();if(!r)return;let i=r.servers.find(l=>l.id===t.id)??t;a.update(r);let s=Tn(r,i);o.replaceWith(s),o=s});return e("div",{class:"dl-stack gap16"},[a.el,e("div",{class:"dl-health-cols"},[o,yo(this.st,t)])])}awg(t){let o={st:this.st,save:(a,r)=>this.save(t,a,r),refresh:()=>this.refresh()};return e("div",{class:"dl-stack gap16"},[Re(t).settingsCard(o,t)])}async addServer(){let t=await U(()=>E.setupDefaults());t&&dom.content(this.root,this.wizard(t,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async remove(t){let o=this.st.people.filter(a=>a.server===t.id);oe(`Remove ${t.name}?`,[e("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.`)],[ie()," ",D("Remove",async()=>{se(),await U(()=>E.serverDelete(t.id),"Server removed")&&setTimeout(()=>{location.href=Dn()},800)},"negative")])}wizard(t,o=!1,a){let r={id:t.id,name:t.name,endpoint:t.endpoint,port:t.port,subnet:t.subnet,preset:"standard",portal:!1,portal_port:t.portal_port||8443,lan_like:!0,lan_zone:t.lan_zone,wan_zone:t.wan_zone},i=0,s=e("div",{class:"dl-wizard"}),l=($,j={})=>{let w=ae(String(r[$]),j);return w.addEventListener("input",()=>{r[$]=$==="port"||$==="portal_port"?Number(w.value):w.value.trim()}),w},d={id:"server",title:"Server",render:()=>e("div",{class:"dl-wizard-groups"},[e("p",{class:"dl-muted"},"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),he("router","Server","What people see",[X("Name",l("name"),"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[X("Public address",l("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."},p={id:"awg",title:"AmneziaWG",render:()=>e("div",{class:"dl-wizard-groups"},[he("globe","Listening","Where devices reach AmneziaWG from the internet",[X("UDP port",l("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),"Opened on the WAN firewall automatically. A random high port is fine.")]),he("network","Tunnel network","Addresses devices get inside the tunnel",[X("Tunnel subnet",l("subnet",{class:"cbi-input-text dl-mono"}),`Must not overlap your networks (${t.taken.join(", ")||"none found"}).`)]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Gt(t.awg,r.preset,$=>r.preset=$,void 0,t.awg_state?.tools!==!1)])]),check:()=>!r.port||!r.subnet?"Fill in the UDP port and subnet.":null},c={id:"portal",title:"Portal",render:()=>{let $=l("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),j=X("Listening port",$,"TCP port on WAN for the portal; the whole port belongs to it.");j.hidden=!r.portal;let w=xe([["off","Off"],["on","On"]],r.portal?"on":"off",{label:"Personal portal",onChange:H=>{r.portal=H==="on",j.hidden=!r.portal}});return e("div",{class:"dl-wizard-groups"},[he("home","Internet like a home device","How devices reach the internet",[X("Through the home network",fe(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",[X("Portal",w,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),j])])}},m=()=>[d,p,o?null:c].filter($=>$!=null),v=t.awg_state,h=v?.missing??[],x=h.length?e("div",{class:"dl-list dl-notices"},[tt("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${h.join(" and ")}. Install the build made for this firmware, then create the server.`,D("Install",()=>Qt(()=>location.reload()),"positive"))]):v&&!v.loaded?e("div",{class:"dl-list dl-notices"},[tt("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.",e("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",R=()=>{let $=m();i>=$.length&&(i=$.length-1),dom.content(s,[e("h2",{},o?"Add a server":"Set up Dawnline"),x,e("div",{class:"dl-steps"},$.map((j,w)=>e("span",{class:`dl-step${w===i?" current":w0?D("Back",()=>{i--,R()}):a?D("Cancel",a):"",e("span",{class:"dl-spacer"}),i<$.length-1?D("Next",()=>{let j=$[i].check?.();if(j){Z(j,"warning");return}i++,R()},"positive"):D("Create server",async()=>{for(let w of $){let H=w.check?.();if(H){Z(H,"warning");return}}let j=await U(()=>E.serverCreate(r.id,r.name,t.ifname,r.port,r.subnet,r.endpoint,t.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");j&&setTimeout(()=>{location.href=Dn(j.id)},1500)},"positive",{disabled:h.length>0,title:h.length?"Install AmneziaWG first":null})])])};return R(),s}};function Qe(n){let t={el:n(),refresh(){let o=n();t.el.replaceWith(o),t.el=o}};return t}function Me(n,t,o,a,r="",i=[]){return e("section",{class:`dl-setsec ${r}`,id:`dl-set-${n}`},[e("div",{class:"dl-setsec-body"},[i.length?e("div",{class:"dl-setsec-head"},[e("h3",{},t),e("span",{class:"dl-spacer"}),...i]):e("h3",{},t),...o]),a.length?e("div",{class:"dl-setsec-foot"},a):""])}function Ro(n){let t=n.filter(r=>r.status!=="skip"),o=t.filter(r=>r.status==="error"||r.status==="warn"),a=t.some(r=>r.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:a}}function Ho(n){let t=n.d.settings,o=n.d.effective,a=n.d.cert,r=fe(o.portal_enabled,"Enable portal"),i=ae(t.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=ae(t.portal_title,{placeholder:"Dawnline"}),l=ae(t.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),d=ae("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),p=O=>/^\d{1,3}(\.\d{1,3}){3}$/.test(O),c=[o.portal_host,...o.portal_alt??[]].filter((O,F,me)=>O&&me.indexOf(O)===F),m=!!n.portal,v=[],h=O=>{O&&!v.some(F=>F.host===O)&&v.push({host:O,kind:p(O)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},x=O=>{v=[...O,...v.filter(F=>!O.some(me=>me.host===F.host))],!c.length&&O[0]&&(c=[O[0].host])};n.portal&&x(n.portal.candidates),c.forEach(h);let R=O=>O.kind==="ip"?e("span",{class:"dl-addr-warn"},[g("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):e("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`:m?"Your address":"Checking where it points…"),$=e("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),j=O=>{c.includes(O)?c.length>1&&(c=c.filter(F=>F!==O)):c=[...c,O],w(),S()},w=()=>dom.content($,[...v.map(O=>{let F=c.includes(O.host),me=c[0]===O.host;return e("div",{class:`dl-addr-opt${F?" on":""}`,role:"checkbox","aria-checked":F?"true":"false",tabindex:"0",click:()=>j(O.host),keydown:re=>{(re.key===" "||re.key==="Enter")&&(re.preventDefault(),j(O.host))}},[e("i",{class:"dl-addr-check"},F?g("check"):""),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono"},O.host),R(O)]),me?e("span",{class:"dl-pill info"},"Main"):F?e("button",{type:"button",class:"dl-linkbtn",click:re=>{re.stopPropagation(),c=[O.host,...c.filter(ge=>ge!==O.host)],w(),S()}},"Make main"):O.cloudflare?e("span",{class:"dl-pill warn"},"Cloudflare"):O.kind==="ip"?e("span",{class:"dl-pill"},"IP"):O.here&&O.cert?e("span",{class:"dl-pill ok"},"Recommended"):""])}),e("div",{class:"dl-addr-opt other"},[e("i",{class:"dl-addr-check"},g("plus")),d,D("Add",()=>{let O=d.value.trim().toLowerCase();O&&(h(O),c.includes(O)||(c=[...c,O]),d.value="",w(),S())})])]);d.addEventListener("keydown",O=>{O.key==="Enter"&&(O.preventDefault(),d.nextElementSibling?.click())});let H=e("div",{class:"dl-links"}),S=()=>{let O=Number(i.value)||o.portal_port;dom.content(H,c.map((F,me)=>{let re=p(F),ge=re?O+1:O,M=`${re?"http":"https"}://${F}${ge===(re?80:443)?"":`:${ge}`}/`;return e("div",{class:"dl-link-row"},[e("span",{class:`dl-link-ic ${re?"warn":"ok"}`},g(re?"alert":"lock")),e("span",{class:"dl-mono dl-link-url"},[M,e("b",{},"kamiro-telosu-bavine")]),me===0?e("span",{class:"dl-pill info"},"Main"):re?e("span",{class:"dl-pill warn"},"HTTP"):""])}))};w(),S(),i.addEventListener("input",()=>S());let T={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},b=n.d.needs??{https:[],acme:[],home:[]},A=O=>{if(!o.portal_enabled)return e("div",{hidden:!0});if(!O)return he("check","Ready to share","The portal’s checks from Health",[e("p",{class:"dl-muted dl-loading"},"Running checks…")]);let F=O.filter(_=>_.status!=="skip");if(!F.length)return e("div",{hidden:!0});let{bad:me,worst:re}=Ro(O),ge=e("div",{class:"dl-ready-details",hidden:!0},F.map(_=>e("div",{class:`dl-ready-item ${_.status}`},[g(_.status==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("span",{},_.title),e("span",{class:"dl-sub"},_.detail)])]))),M=e("div",{class:"dl-stack gap8"},[e("div",{class:`dl-ready-sum ${re}`},[g(re==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("b",{},re==="ok"?`All ${F.length} checks passed`:`${F.length-me.length} of ${F.length} checks passed`),me.length?e("span",{class:"dl-sub"},me.map(_=>_.detail).join(" ")):e("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),e("button",{type:"button",class:"dl-linkbtn",click:_=>{ge.hidden=!ge.hidden,_.currentTarget.textContent=ge.hidden?"Details":"Hide"}},"Details")]),e("div",{class:"dl-chips-row"},F.map(_=>e("span",{class:`dl-check-chip ${_.status}`,title:_.detail},[g(_.status==="ok"?"check":"alert"),T[_.id]??_.title]))),ge]);return he("check","Ready to share","The portal’s checks from Health",[M])},u=O=>{if(!o.portal_enabled||!O&&!b.https.length)return e("span",{hidden:!0});if(b.https.length)return e("span",{class:"dl-pill bad"},"Can’t start");let{worst:F}=Ro(O);return e("span",{class:`dl-pill ${F==="ok"?"ok":F==="error"?"bad":"warn"}`},F==="error"?"Needs attention":"Ready")},f=A(n.portal?.checks??null),N=u(n.portal?.checks??null);n.portalFill=O=>{m=!0,x(O.candidates),w(),S();let F=A(O.checks);f.replaceWith(F),f=F;let me=u(O.checks);N.replaceWith(me),N=me};let P=a&&!a.self_signed&&a.expires?Ae(a.expires):"",I=X("Listening port",i,n.d.port_owners.length?`Port ${o.portal_port} is used by ${n.d.port_owners.join(", ")}.`:`Where the portal runs on the router: HTTPS here, plain HTTP for IP addresses on ${o.portal_port+1}.`),J=!!(t.portal_cert&&t.portal_key),W=a?J?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",q=()=>{let O=ae(t.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),F=ae(t.portal_key,{placeholder:"/etc/ssl/…/key"});oe("Use your own certificate",[e("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),X("Certificate file",O),X("Key file",F)],[ie()," ",D("Save",()=>{se(),n.save({portal_cert:O.value.trim(),portal_key:F.value.trim()},"Certificate saved","portal")},"positive")])},C=(O,F,me,re,ge,M)=>tt(O,F,me,re,D(M,()=>Pt(ge,b[ge],()=>n.reload("portal")),"positive")),G=b.https.length?C("lock","bad","HTTPS isn’t available on this router",`The portal needs ${b.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",Q=b.acme.length&&(!a||a.self_signed)?C("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${t.portal_host?` for ${t.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",de=[e("div",{class:"dl-row"},[g("lock"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},[W,P?e("span",{class:"dl-faint"},` · until ${P}`):""]),e("span",{class:"dl-sub dl-ellipsis",title:a?.path??""},a?a.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${J?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),e("div",{class:"dl-row"},[g("file"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Your own files"),e("span",{class:"dl-sub"},J?`${t.portal_cert} · ${t.portal_key}`:"Not set: the certificate is picked automatically.")]),J?D("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",D(J?"Change":"Use files",q)]),Q];return Me("portal","Personal portal",[e("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),G?e("div",{class:"dl-list"},[G]):"",he("network","Port","How the portal listens (80 and 443 stay free)",[I]),he("edit","Appearance","What people see",[X("Title",s,"Shown at the top of the portal."),X("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",[$,e("div",{class:"dl-stack gap8"},[H,e("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),he("lock","Certificate","Used for HTTPS links",de),f],[e("span"),D("Save",()=>n.save({portal_enabled:Ee(r)?"1":"0",portal_host:c[0]??"",portal_alt:c.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:l.value.trim()},"Saved","portal"),"positive")],"",[N,r])}function Io(n){let t=n.d.settings,o=n.d.effective,a=ae(t.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),r=fe(o.hostnames,"Device hostnames"),i=ae(t.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=ae(t.home_dns_fallback==="none"?"":t.home_dns_fallback||o.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"});return Me("defaults","Defaults",[X("Devices per person",a,"Pre-filled when you add someone."),X("Device hostnames",e("div",{class:"dl-hostport"},[r,e("span",{class:"dl-faint dl-mono"},"phone.myata."),i]),"Name devices in your home DNS."),X("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.")],[e("span"),D("Save",()=>n.save({default_device_limit:a.value,hostnames:Ee(r)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults"),"positive")])}function Bo(n){let t=n.d.effective,o=fe(t.geo_enabled,"Locations"),a=e("select",{class:"cbi-input-select"},[e("option",{value:"ipwho.is",selected:t.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),e("option",{value:"ipapi.co",selected:t.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Me("map","Map & locations",[e("div",{class:"dl-setrow head"},[e("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),o]),X("Provider",a)],[e("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),D("Save",()=>n.save({geo_enabled:Ee(o)?"1":"0",geo_provider:a.value},"Saved","map"),"positive")])}var Vr=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function Oo(n){let t=n.d.effective.updates,o=fe(t.check,"Check automatically",x=>h(x,Ee(r))),a=xe([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],t.interval,{label:"How often",cls:"sm"}),r=fe(t.auto,"Install automatically",x=>h(Ee(o),x)),i=ae(t.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"]],t.mode,{label:"When",cls:"sm",onChange:x=>i.hidden=x!=="scheduled"});i.hidden=t.mode!=="scheduled";let l=new Set(t.targets),d=e("div",{class:"dl-chips-row"},Vr.map(([x,R])=>{let $=Ue(R,l.has(x),()=>{l.delete(x)||l.add(x),Wt($,l.has(x))});return $})),p=fe(t.keep,"Keep the previous version"),c=fe(t.mirrors,"GitHub mirrors"),m=X("How often",a),v=[X("When",e("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),X("Components",d,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],h=(x,R)=>{m.hidden=!x;for(let $ of v)$.hidden=!R};return h(t.check,t.auto),Me("updates","Updates",[e("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),X("Check automatically",o,"Looks for new versions in the background; Components shows what it found and the service log names it."),m,X("Install automatically",r,"Downloads and installs new versions of the components below."),...v,X("Keep the previous version",p,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),X("GitHub mirrors",c,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[e("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),D("Save",()=>n.save({update_check:Ee(o)?"1":"0",update_interval:a.dataset.value,update_auto:Ee(r)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Ee(p)?"1":"0",update_mirrors:Ee(c)?"1":"0"},"Saved","updates"),"positive")])}function jo(n){let t=n.d.logs,o=t.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"}),d=new Set(o.categories),p=e("div",{class:"dl-chips-row"},pt.map(h=>{let x=Ue([nt[h],e("b",{},String(t.by_category[h]??0))],d.has(h),()=>{d.delete(h)||d.add(h),Wt(x,d.has(h))},{title:Xn[h]});return x})),c=t.oldest?Ae(new Date(t.oldest*1e3)):"",m=(h,x,R,$)=>e("div",{class:"dl-row"},[g(h),e("span",{class:"dl-row-main dl-stack"},[e("b",{},x),e("span",{class:"dl-sub"},R)]),...$]),v=h=>D(h.toUpperCase(),async()=>{let[x,R]=await Promise.all([E.status(1),E.events(2e4)]);je(x,R.events,h)},"neutral",{title:`Download the log as ${h.toUpperCase()}`});return Me("logs","Logs & history",[e("p",{class:"dl-muted"},Ut(o)),X("Keep activity",a,"Older events are removed automatically."),X("Maximum size",r,"Newest events are kept when the log is full."),X("Record",p,"Switched-off categories are not logged from now on."),X("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),X("Daily traffic",s,"Per-day history behind the charts."),X("Monthly traffic",l,"Per-month totals; data limits use the current month."),e("h4",{class:"dl-setsub"},"Stored data"),e("div",{class:"dl-list"},[m("activity","Activity log",t.events?`${Rt(t.events,"event")} since ${c} · ${yt(t.log_ram)} in memory${o.persist==="off"?"":`, ${yt(t.log_flash)} on flash`}`:"Empty",[v("csv"),v("json"),D("Clear",()=>Fe("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),m("chart","Traffic history",t.usage_days?`${Rt(t.usage_days,"day")} since ${Ae(t.usage_since)} · ${yt(t.usage_flash)} on flash`:"Empty",[D("Reset",()=>ut("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),m("pin","Location cache",`${Rt(n.d.geo_cached,"address","addresses")} · ${yt(t.geo_flash)} on flash`,[D("Clear",async()=>{await U(()=>E.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[e("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:[...d]},"Saved","logs"),"positive")])}var Yr={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},Uo=3;function An(n){let t=new Date(n*1e3),o=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),a=Math.round((new Date(new Date().toDateString()).getTime()-new Date(t.toDateString()).getTime())/864e5);return`${a===0?"Today":a===1?"Yesterday":t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${o}`}async function Qr(n){let t=await U(()=>E.backupRead(n.name));if(!t)return;let o=atob(t.data),a=new Uint8Array(o.length);for(let i=0;iQr(n),"neutral","dl-icon-only"),ye("more","More",o=>we(o.currentTarget,[{label:"Restore",icon:g("reset"),run:async()=>{await ne("Restore this backup?",`Everything returns to ${An(n.created)}. The current state is backed up first.`,"Restore",!0)&&await U(()=>E.backupRestore(n.name),"Restored")&&t(!0)}},{label:"Delete",icon:g("trash"),danger:!0,run:async()=>{await ne("Delete this backup?",`The backup from ${An(n.created)} is removed from the router.`,"Delete",!0)&&await U(()=>E.backupDelete(n.name),"Backup deleted")&&t()}}]),"neutral","dl-icon-only")])])}function Go(n,t){let o=n.slice(0,Uo).map(d=>Wo(d,t)),a=n.slice(Uo),r=n.length?e("div",{class:"dl-list"},[...o,a.length?e("details",{class:"dl-bk-older"},[e("summary",{},[g("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(d=>Wo(d,t))]):""]):e("div",{class:"dl-list"},[e("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=D("Restore from file",async()=>{let d=await bn(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await ne("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await U(()=>E.backupUpload(d.data),"Restored")&&t(!0)}),s=D("Export JSON",async()=>{let d=await U(()=>E.exportJson());d&&$e(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=D("Import JSON",async()=>{let d=await bn(".json,application/json","text");if(!d)return;let p;try{p=JSON.parse(d.data)}catch{Z("Not a JSON file.","error");return}await ne("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await U(()=>E.importJson(p),"Imported")&&t(!0)});return e("section",{class:"dl-setsec",id:"dl-set-backups"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-setsec-head"},[e("div",{class:"dl-stack"},[e("h3",{},"Backups"),e("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),e("span",{class:"dl-spacer"}),D([g("plus")," Back up now"],async()=>{await U(()=>E.backupCreate(),"Backup created")&&t()},"positive")]),r]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),e("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function Zr(){let n=ae("",{placeholder:"remove"});oe("Remove Dawnline?",[e("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[ie()," ",D("Remove Dawnline",async()=>{await U(()=>E.uninstall(n.value.trim()),"Dawnline removed")&&(se(),setTimeout(()=>location.reload(),800))},"negative")])}function qo(){return Me("danger","Remove Dawnline from this router",[e("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[e("span"),D("Remove",()=>Zr(),"negative")],"danger")}var rn=class{constructor(){this.root=e("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return E.settingsGet()}render(t){this.d=t,this.cards={portal:Qe(()=>Ho(this)),defaults:Qe(()=>Io(this)),map:Qe(()=>Bo(this)),updates:Qe(()=>Oo(this)),logs:Qe(()=>jo(this)),backups:Qe(()=>Go(this.backups,r=>this.loadBackups(r))),danger:Qe(()=>qo())};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"})),e("div",{},[e("div",{class:"dl-pagehead"},[e("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(t,o,a){let r=await U(()=>E.settingsUpdate(t),o);r&&(this.d=r,this.cards[a].refresh(),a==="portal"&&this.loadPortal())}async loadPortal(){let t=++this.portalSeq,o=await E.portalInfo().catch(()=>null);t===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(t=!1){t&&await this.reload();let o=await E.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(t){let o=await E.settingsGet().catch(()=>null);if(o){if(this.d=o,t)this.cards[t].refresh();else for(let a of Object.values(this.cards))a.refresh();(!t||t==="portal")&&this.loadPortal()}}};function Fo(n,t=!1){return n&&(t?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function Ko(n){let t=[],o=l=>{let d=[],p=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,c=0;for(let m;m=p.exec(l);)m.index>c&&d.push(l.slice(c,m.index)),m[1]?d.push(e("code",{},m[1].slice(1,-1))):m[2]?d.push(e("b",{},m[2].slice(2,-2))):m[3]?d.push(e("a",{href:m[4],target:"_blank",rel:"noopener"},m[3].replace(/^\[|\]\(.*$/g,""))):m[5]&&d.push(e("a",{href:m[5],target:"_blank",rel:"noopener"},m[5].replace(/^https?:\/\/(github\.com\/)?/,""))),c=m.index+m[0].length;return c{r.length&&t.push(e("p",{},o(r.join(" ")))),r=[],a=null};for(let l of n.replace(/\r/g,"").split(` +`,uo(s,t)]:[uo(s,t)])),r=e("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),t=!t,dom.content(r,[g(t?"x":"key"),t?"Hide key":"Show key"]),a()}},[g("key"),"Show key"]);a();let i=new Blob([n.conf]).size;return e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-filecard"},[e("span",{class:"dl-filecard-ic"},".conf"),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono dl-ellipsis"},n.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),D([g("download")," Download"],()=>$e(n.filename,n.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),r,e("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),pe(n.conf,"Configuration copied")}},[g("copy"),"Copy"])]),o])])}async function vr(n,t="file"){if(!n.has_private_key)return e("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await Cn(n,`${n.server} · ${n.person} · ${n.name}`),a={qr:()=>e("div",{class:"dl-qr-pane"},[qe(ct(n.conf),"dl-qr"),e("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-linkbox"},[e("span",{class:"dl-mono"},o),D("Copy",()=>pe(o,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>gr(n)},r=e("div",{class:"dl-connect-body"}),i=e("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(r,a[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(e("button",{type:"button","data-id":l,click:()=>s(l)},d));return s(t),e("div",{class:"dl-stack gap12"},[i,r])}async function br(n,t,o,a){let r=Et(o),s=n.st.people.filter(d=>d.server===t.id).reduce((d,p)=>d+p.devices.length,0);await ne(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.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await U(()=>S.serverObfuscation(t.id,o),a?"New values applied":`${r.title} applied`)&&(Q("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function xr(n,t){let o=n.st,a=re(String(t.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=re(String(t.mtu??""),{placeholder:"1380",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=re(String(t.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=Et(t.preset)?t.preset:void 0,l=s??"standard",d=D("",()=>br(n,t,l,l===s),"neutral"),p=()=>dom.content(d,l===s?[g("reset")," Generate new values"]:[`Switch to ${Et(l).title}`]);p();let c=o.people.filter(v=>v.server===t.id).reduce((v,h)=>v+h.devices.length,0),m=o.awg_state?.tools!==!1;return kt("",[co("AmneziaWG",t.up?"ok":"bad",t.up?"Running":"Not running",`${t.ifname} · ${c} device${c===1?"":"s"}`),he("globe","Listening","Where devices reach this core from the internet",[Z("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",[Z("MTU",r,"Lower it if some sites hang on mobile networks."),Z("Keep-alive",i,"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",[Gt(o.awg,l,v=>{l=v,p()},s,m),m&&!o.awg.v3?dt("info",["This router runs an older AmneziaWG. ",e("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",fr(t.obf??{})??"",e("div",{class:"dl-row-end"},[e("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),d])]),e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Tunnel"),e("span",{class:"dl-pcount"},"3")]),e("div",{class:"dl-params-body"},[Z("Interface",e("span",{class:"dl-mono"},`${t.ifname} · router ${t.address}`)),Z("Tunnel subnet",e("span",{class:"dl-mono"},t.subnet),"Device addresses come from it."),Z("Server public key",e("span",{class:"dl-keyrow"},[e("code",{class:"dl-mono"},t.public_key),D([g("copy")],()=>pe(t.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[e("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),D("Save",()=>n.save({port:a.value,mtu:r.value,keepalive:i.value},"AmneziaWG saved"),"positive")])}function wr(n){let t=Et(n.preset),o=n.obf??{},a=(s,l)=>e("span",{class:`dl-segs ${l}`},[0,1,2,3].map(d=>e("i",{class:d+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(o.i1.includes("0x8580")?"DNS-like first packet":"Signature packets"),o.header_protection_key&&r.push("Encrypted headers"),r.length||r.push(t?.id==="off"?"Plain WireGuard":"No values yet"),e("div",{class:"dl-bento-tile dl-disg"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Disguise"),e("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),e("div",{class:"dl-disg-id"},[e("span",{class:"dl-disg-ic"},g(t?.ic??"shield")),e("span",{class:"dl-stack"},[e("b",{},t?t.title:"Custom"),e("span",{class:"dl-sub"},t?t.short:"Set by hand")])]),t?e("div",{class:"dl-disg-meters"},[e("span",{},"Stealth"),a(t.stealth,"acc"),e("span",{},"Speed"),a(t.speed,"ok")]):"",e("div",{class:"dl-disg-chips"},r.map(s=>e("span",{},s)))])}var Ln={id:"awg",label:"AmneziaWG",settingsCard:xr,overviewTile:wr,connectBlock:vr,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>Cn(n,`${n.server} · ${n.person} · ${n.name}`)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var yr={awg:Ln};function Re(n){return yr[n?.core||"awg"]??Ln}function mt(n,t){return Re(n.find(o=>o.id===t))}var kr=2,qt=new Set,Tn=null,mo=!1;async function $r(){if(document.visibilityState!=="visible"||!qt.size)return;let n=await S.rev().catch(()=>null);if(!n)return;let t=Tn!=null&&n.rev!==Tn;Tn=n.rev,t&&qt.forEach(o=>o())}function Ft(n){return qt.add(n),mo||(mo=!0,poll.add($r,kr)),()=>qt.delete(n)}function _r(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function ho(n,t,o=!1){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},n),e("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:"Copy",click:()=>pe(t,`${n} copied`)},[e("span",{},t),g("copy")])])}function Kt(n,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},n),e("span",{class:"dl-kvrow-v"},t)])}var fo={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 Er(n,t,o){let a=n.filter(r=>r.device===t&&fo[r.type]).reverse().slice(0,12);return a.length?e("div",{class:"dl-dev-log"},a.map(r=>{let[i,s,l]=fo[r.type],d=r.type==="connect"?[r.detail?e("span",{class:"dl-muted"},` from ${r.detail}`):"",r.where?e("span",{class:"dl-muted"},` · ${r.where}`):""]:r.type==="roam"?[e("span",{class:"dl-muted"},` · ${r.detail??""}`)]:r.type==="device_added"||r.type==="device_removed"||r.type==="device_keys"?[e("span",{class:"dl-muted"},Le(r)==="portal"?" on the portal":Le(r)==="admin"?" by you":"")]:[],p=new Date(r.ts*1e3);return e("div",{class:`dl-dev-log-row${Le(r)==="admin"?" dl-ev-by-admin":""}`},[Le(r)==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):e("span",{class:`dl-ev-tile ev ${i}`},g(l)),e("span",{class:"dl-row-main"},[e("span",{},s),...d]),e("span",{class:"dl-faint dl-nowrap",title:p.toLocaleString()},de(r.ts,o))])})):e("div",{class:"dl-sub"},"No activity yet.")}async function go(n,t,o){let a=await S.status(1).catch(()=>null),r=a?.people.find(s=>s.id===n),i=r?.devices.find(s=>s.id===t);a&&r&&i&&He(r,i,{...o,geo:a.geo,now:a.now,today:Ne(a.series),core:mt(a.servers,r.server)})}async function He(n,t,o){let a=await U(()=>S.deviceConfig(t.id));if(!a)return;let r=o.core??Re(null),i=t,s=n,l=o.geo,d=o.now,p=o.today??De(new Date),c=await r.connectBlock(a),m=e("div",{class:"dl-drawer-title"}),v=e("div",{}),h=e("div",{}),x=e("div",{},e("div",{class:"dl-sub"},"Loading…")),R=[],_=$=>{R=$.filter(G=>G.device===i.id),dom.content(x,Er($,i.id,d))},j=async($=!1)=>{let G=o.events?.();if(G&&!$)return _(G);let q=await S.events(5e3).catch(()=>null);q&&_(q.events)},w=()=>{let $=l?.points.find(q=>q.device===i.id&&q.ip===i.endpoint);dom.content(m,[e("span",{class:`dl-dcard-ic${i.online?" on":""}`},g(i.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},i.name),D([g("edit")],()=>T(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},`${s.name} · ${Be[i.kind]}`)])]);let G=i.spark.reduce((q,oe)=>q+oe,0);dom.content(v,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),Bt(i,d,"Waiting for the first connection")]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},ee(i.month[0]+i.month[1])),e("span",{class:"dl-sub dl-mono"},`↓ ${ee(i.month[1])} ↑ ${ee(i.month[0])}`)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"Last 7 days"),e("b",{},ee(G)),ao(i.spark,120,22,p)])])),dom.content(h,e("div",{class:"dl-kv2"},[ho("Tunnel address",i.address),i.hostname&&s.access!=="internet"?ho("Local address",i.hostname):"",i.endpoint?Kt("Client IP",e("span",{},[i.endpoint,$?e("span",{class:"dl-muted"},` · ${[$.city,$.org].filter(Boolean).join(" · ")}`):""])):"",Kt("Total",e("span",{class:"dl-kv-act"},[`↓ ${ee(i.total[1])} · ↑ ${ee(i.total[0])}`,e("button",{type:"button",class:"dl-linkbtn danger",click:()=>ut("device",i.id,i.name,()=>setTimeout(C,300))},"Reset")])),Kt("Added",`${_r(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),Kt("Public key",e("span",{class:"dl-mono dl-faint"},a.amnezia.client_pub_key?`${a.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(b,[D([g(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await U(()=>S.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await C()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),D([g("key")," New keys"],async()=>{if(!await ne("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await U(()=>S.deviceRotate(i.id),"New keys generated")&&(o.refresh(),te.close(),await go(s.id,i.id,o))}),e("span",{class:"dl-spacer"}),D([g("trash")," Remove"],async()=>{await ne(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>S.deviceDelete(i.id),"Device removed")&&(te.close(),o.refresh())},"negative")])},I=async()=>{let $=await S.status(1).catch(()=>null),G=$?.people.find(oe=>oe.id===s.id),q=G?.devices.find(oe=>oe.id===i.id);!$||!G||!q||(s=G,i=q,l=$.geo,d=$.now,p=Ne($.series),w())},C=async()=>{await I(),o.refresh()},T=()=>{let $=e("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48});ae(`Rename ${i.name}`,[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},$)])],[se()," ",D("Save",async()=>{await U(()=>S.deviceUpdate(i.id,$.value,void 0),"Renamed")&&(le(),await C())},"positive")]),setTimeout(()=>$.select(),50)},b=e("div",{class:"dl-drawer-actions"}),A=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Connect")]),i.config_stale?e("div",{class:"dl-note warn"},[g("alert"),e("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",c]),u=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Activity"),e("div",{class:"dl-dsec-actions"},[e("button",{type:"button",class:"dl-linkbtn",click:()=>je({people:[s]},R,"csv",i.id)},"Export"),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{j(!0),o.refresh()})},"Clear"),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),x]),f=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},e("h4",{},"Details")),h]),N=!i.handshake||i.config_stale,P=e("div",{class:"dl-stack gap16"},N?[v,A,f,u]:[v,f,u,A]);j();let H=()=>{I(),j()},J=Ft(H),W=window.setInterval(H,3e4),te=Yn(m,P,b,()=>{clearInterval(W),J()});w()}function vo(n,t,o,a){let r=a.core??Re(null),i=()=>U(()=>S.deviceConfig(o.id)),s=[{label:"Show QR code",icon:g("qr"),run:async()=>{let l=await i();l&&ae(`${o.name} · QR code`,e("div",{class:"dl-qr-pane"},[qe(ct(r.qrText(l)),"dl-qr"),e("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),se("Close"))}},{label:r.file.label,icon:g("download"),run:async()=>{let l=await i();if(!l)return;let d=r.file.make(l);$e(d.name,d.text,"application/octet-stream")}},r.appKey?{label:r.appKey.label,icon:g("copy"),run:async()=>{let l=await i();l&&pe(await r.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:g("edit"),run:()=>He(t,o,a)},{label:"New keys",icon:g("key"),run:async()=>{await ne("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await U(()=>S.deviceRotate(o.id),"New keys generated")&&a.refresh()}},{label:o.disabled?"Enable":"Disable",icon:g(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await U(()=>S.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&a.refresh()}},{label:"Delete",icon:g("trash"),danger:!0,run:async()=>{await ne(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>S.deviceDelete(o.id),"Device removed")&&a.refresh()}}];we(n,s)}function ot(n,t){let o=e("input",{type:"text",class:"cbi-input-text",placeholder:Be.phone,maxlength:48}),a="phone",r=e("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},Jn.map(s=>e("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 d=l.dataset.kind===s;l.classList.toggle("on",d),l.setAttribute("aria-checked",d?"true":"false")}),o.placeholder=Be[s]}},[g(s),e("span",{},Be[s])]))),i=n.devices.length>=n.device_limit;ae(`Add a device for ${n.name}`,[i?e("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",e("div",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Type"),r]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Name"),o])],[se()," ",D("Add device",async()=>{let s=o.value.trim()||o.placeholder.replace(/^e\.g\. /,""),l=await U(()=>S.deviceCreate(n.id,s,a));l&&(le(),Q(`${s} added`,"success",3e3),t.refresh(),await go(n.id,l.id,t))},"positive")]),setTimeout(()=>o.focus(),50)}var We=1080,Ct=1512,Ie=96,Sr="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Cr="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",St=n=>n.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function Lr(n,t,o){let a=new URL(o),r=a.pathname.slice(1),i=Math.min(92,Math.floor((We-2*Ie)/(.58*(4+n.name.length)))),s=We-2*Ie,l=392,d=40,p=ct(o,2).replace("`${R}`;return``+c(Ie+82,Ie+42,36,"#a3a3a3",St(t))+c(Ie,276,i,"#ffffff",`Hi, ${St(n.name)}`,'font-weight="600"')+c(Ie,340,40,"#8a8a8a",`Scan to connect to ${St(t)}`)+``+p+`${St(r)}`+c(We/2,l+s+156,34,"#737373",St(a.host),'text-anchor="middle"')+""}async function Tr(n){let t=new Image;t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await t.decode();let o=document.createElement("canvas");return o.width=We,o.height=Ct,o.getContext("2d").drawImage(t,0,0,We,Ct),new Promise((a,r)=>o.toBlob(i=>i?a(i):r(new Error("Could not draw the card")),"image/png"))}async function bo(n){let t=await U(()=>S.personLinks(n));return t?t.link?{link:t.link,links:t.links??[]}:(Q("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function Jt(n){let t=await bo(n);t&&await pe(t.link,"Personal link copied")}async function Lt(n,t,o={}){let a=n.link,r=n.links;if(a===void 0){let h=await bo(n.id);if(!h)return;a=h.link,r=h.links}if(!a){Q("The personal portal is off. Turn it on in Settings.","warning");return}let i=a,s=await U(()=>Tr(Lr(n,t,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),d=URL.createObjectURL(s),p=navigator,c=!!p.canShare?.({files:[l]}),m=()=>{URL.revokeObjectURL(d),le()},v=c?D([g("link")," Share card"],async()=>{try{await p.share({files:[l],title:`Invite ${n.name}`})}catch{}},"positive"):D([g("download")," Download card"],()=>$e(l.name,s),"positive");ae(o.title??`Invite ${n.name}`,e("div",{class:"dl-invite"},[e("img",{src:d,alt:`Invite card for ${n.name}`}),e("div",{class:"dl-invite-side"},[e("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.`),e("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>pe(i,"Personal link copied")},[e("span",{},i.replace(/^https:\/\//,"")),g("copy")]),...(r??[]).filter(h=>h!==i).map(h=>e("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>pe(h,"Link copied")},[e("span",{},h.replace(/^https?:\/\//,"")),e("span",{class:`dl-pill ${h.startsWith("http:")?"warn":""}`},h.startsWith("http:")?"HTTP":"Also"),g("copy")])),e("ol",{class:"dl-invite-steps"},[e("li",{},["Install ",e("b",{},"AmneziaVPN")," on the device"]),e("li",{},"Open the link or scan the code"),e("li",{},"Add the device and connect")]),e("div",{class:"dl-invite-actions"},[v,D([g("copy")," Copy link"],()=>pe(i,"Personal link copied"))])])]),[e("button",{class:"cbi-button cbi-button-neutral",click:m},"Done")],"wide")}function ht(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function Te(n,t){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${t?`&device=${encodeURIComponent(t)}`:""}`}function Tt(n,t){let o=n.servers.find(d=>d.id===t)??n.servers[0],a=n.people.filter(d=>d.server===o.id),r=new Set(a.map(d=>d.id)),i=a.flatMap(d=>d.devices),s=d=>a.reduce((p,c)=>{let m=d(c);return[p[0]+m[0],p[1]+m[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(d=>d.person?r.has(d.person):!0),geo:{...n.geo,points:n.geo.points.filter(d=>r.has(d.person))},totals:{people:a.length,devices:i.length,online:i.filter(d=>d.online).length,active:a.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(d=>d.month)}}}var Mn=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(t){return t{let d=t.next(),p=await n.fetch(l).catch(()=>null);return p==null||!t.take(d)?null:(n.apply(p,s),p)},a=(s=!1)=>o(s,!1),r=()=>n.active?.()??!0?o(!0,!1):Promise.resolve(null);poll.add(r,n.every);let i=n.live?Ft(()=>void((n.active?.()??!0)&&o(!0,!0))):null;return{refresh:a,claim:()=>t.claim(),stop:()=>{poll.remove(r),i?.()}}}function ft(n){let t=document.activeElement;return!!n&&!!t&&t!==document.body&&n.contains(t)}function _e(n,t,o=!1){return o&&ft(n)?!1:(dom.content(n,t),!0)}function xo(n,t){let o=n,r=e("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(i=>e("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)),t?.(i.v)}},[e("span",{class:"dl-choice-title"},[g(i.ic),et[i.v]]),e("span",{class:"dl-choice-text"},i.text)])));return{el:r,get:()=>o}}function Mr(n){let t=n.devices.length,o=Math.max(1,n.device_limit,t),a=Math.min(160,o*22+(o-1)*3);return e("div",{class:"dl-slotbar",title:`${t} of ${n.device_limit} devices`},[e("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:o},(r,i)=>e("i",{class:i>=n.device_limit?"over":i=n.quota_limit*.9}function Dr(n,t){return xt(n&&_n(n,t)>=0?n:t,1)}var wo=n=>n.people.map(t=>t.id).sort().join(" "),yo=!1,at=class{constructor(){this.list=e("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(t=>t===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return S.status(30)}scope(t){return this.serverId?Tt(t,this.serverId):t}embed(t,o){return this.serverId=o,this.render(t)}person(t){return this.st.people.find(o=>o.id===t)}get today(){return Ne(this.st.series)}deviceOpts(t){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:mt(this.st.servers,t.server)}}take(t,o){let a=this.scope(t),r=wo(a)!==wo(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 t=await S.status(30).catch(()=>null);t&&(this.st=this.scope(t),this.rebuild())}rebuild(){let t=new Map;for(let a of Array.from(this.list.children))a.dataset.sid&&t.set(a.dataset.sid,a);let o=this.st.people.map(a=>{let r=t.get(a.id)??e("div",{class:"dl-card",role:"listitem","data-sid":a.id});return this.renderCard(r,a.id)});dom.content(this.list,o.length?o:e("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(t=!1){for(let o of this.st.people){let a=this.card(o.id);a&&!(t&&ft(a))&&this.renderCard(a,o.id)}}card(t){return this.list.querySelector(`[data-sid="${CSS.escape(t)}"]`)}render(t){let o=this.scope(t);this.st=o;let a=this,r=e("select",{class:"dl-select","aria-label":"Sort",change:s=>{a.sort=s.target.value,a.decorate()}},[e("option",{value:"seen"},"Last seen"),e("option",{value:"name"},"Name"),e("option",{value:"usage"},"Usage")]),i=e("div",{class:"dl-root"},[a.serverId?"":e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"People"),e("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?D([g("plus")," Add person"],()=>a.openCreate(),"add"):""]),o.servers.length?"":e("div",{class:"alert-message warning"},["No server yet. ",e("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),e("div",{class:"dl-toolbar"},[e("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),e("div",{class:"dl-toolbar-end"},[r,a.serverId?D([g("plus")," Add person"],()=>a.openCreate(),"add"):""])]),this.list]);return this.el=i,this.rebuild(),this.poller??(this.poller=Ke({fetch:()=>S.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 t=this.st.totals;return`${t.people} ${t.people===1?"person":"people"} · ${t.devices} device${t.devices===1?"":"s"} · ${t.online} online`}decorate(t=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let a=this.st.people,r=this.today,i=v=>Pr(v,r),s={all:a.length,online:a.filter(v=>v.online>0).length,attention:a.filter(i).length,paused:a.filter(v=>v.state!=="active"&&v.state!=="quota"&&v.state!=="expired").length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(t&&ft(l))){let v={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(v).map(h=>e("button",{type:"button",role:"tab",class:h===this.filter?"on":"",click:()=>{this.filter=h,this.decorate()}},[v[h],e("b",{class:h==="attention"&&s[h]?"warn":""},String(s[h]))])))}let d=v=>!(this.filter==="online"&&!v.online||this.filter==="attention"&&!i(v)||this.filter==="paused"&&!(v.state!=="active"&&v.state!=="quota"&&v.state!=="expired")),p=[...a].sort((v,h)=>this.sort==="name"?v.name.localeCompare(h.name):this.sort==="usage"?h.month[0]+h.month[1]-(v.month[0]+v.month[1]):h.online-v.online||h.last_seen-v.last_seen),c=0;for(let v of p){let h=this.card(v.id);if(!h)continue;this.list.appendChild(h),h.classList.toggle("dl-off",v.state!=="active"),h.classList.toggle("dl-attn-row",v.state==="quota"||v.state==="expired");let x=d(v);h.classList.toggle("dl-filtered",!x),x&&c++}let m=this.el?.querySelector(".dl-people-none")??null;a.length&&!c?(m??(m=e("div",{class:"dl-empty dl-people-none"},e("p",{},"No one here right now."))),m.previousElementSibling!==this.list&&this.list.after(m)):m?.remove()}async quick(t,o,a){await U(()=>S.personUpdate(t.id,o),a)&&await this.update()}renderCard(t,o){let a=this.person(o);if(!a)return dom.content(t,e("em",{},"This person was just removed.")),t;let r=this.today,i=Xe(a.expires,r),s=Math.max(0,a.device_limit-a.devices.length),l=a.has_link??this.st.settings.portal_enabled,d=[];if(a.expires){let h=i!=null&&i>=0&&i<=Math.max(a.expire_warn,3),x=i!=null&&i<0;d.push(e("span",{class:`dl-pill-ic${x?" bad":h?" warn":""}`,title:`Access ends ${ze(a.expires)}`},[g("calendar"),x?`ended ${ze(a.expires)}`:h?`ends in ${i} day${i===1?"":"s"}`:`until ${ze(a.expires)}`]))}a.hours&&d.push(e("span",{class:"dl-pill-ic",title:"Allowed hours"},[g("clock"),a.hours.replace("-","–")]));let p=Ht(a.devices).map(h=>e("button",{type:"button",class:`dl-chip${h.disabled?" disabled":""}${h.online?" live":""}`,title:`${Be[h.kind]} · ${h.address}${h.online?` · online from ${h.endpoint}`:h.handshake?` · seen ${de(h.handshake,this.st.now)}`:""}`,click:x=>{x.preventDefault(),He(a,h,this.deviceOpts(a))}},[g(h.kind),e("span",{class:"dl-chip-name"},h.name),!h.handshake&&!h.disabled?e("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(e("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:h=>{h.preventDefault(),ot(a,this.deviceOpts(a))}},g("plus")));let c=[];a.state==="quota"&&a.quota_period==="month"&&c.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{bonus_gb:String((a.bonus_gb||0)+10)},"+10 GB this month")},"+10 GB this month")),a.expires&&i!=null&&i<=Math.max(a.expire_warn,3)&&c.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:Dr(a.expires,r)},"Extended by 1 month")},"Extend 1 month"));let m=ye("more","More",h=>we(h.currentTarget,[{label:"Open",icon:g("open"),run:()=>{location.href=Te(a.id)}},l?{label:"Invite card",icon:g("qr"),run:()=>Lt(a,this.st.servers.find(x=>x.id===a.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:g("plus"),run:()=>ot(a,this.deviceOpts(a))}:null,null,{label:a.paused?"Resume":"Pause",icon:g(a.paused?"play":"pause"),warn:!a.paused,run:()=>this.togglePause(a)},{label:"Delete",icon:g("trash"),danger:!0,run:()=>this.remove(a.id)}].filter((x,R,_)=>x||R>0&&_[R-1])),"neutral","dl-icon-only"),v=e("div",{class:"dl-pcard-actions"},[l?ye("link","Copy link",()=>Jt(a.id),"neutral","dl-icon-only"):"",m]);return dom.content(t,e("div",{class:"dl-pcard"},[e("div",{class:"dl-pcard-main"},[e("div",{class:"dl-pcard-top"},[e("span",{class:`dl-avatar${a.online?" online":""}`},Oe(a.name)),e("div",{class:"dl-pcard-who"},[e("div",{class:"dl-card-head"},[e("a",{class:"dl-card-name",href:Te(a.id)},a.name),It(a),Vn(a),...d]),Mr(a)])]),e("div",{class:"dl-chips"},p),c.length?e("div",{class:"dl-fixes"},c):""]),this.usageSide(a,v)])),t}usageSide(t,o){let a=t.quota_used||t.month[0]+t.month[1],r=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,i=t.devices.reduce((c,m)=>c+(m.spark[m.spark.length-1]??0),0),s=t.rate?.[t.rate.length-1],l=t.online&&s&&this.st.now-s[0]<180,d=e("div",{class:`dl-usebar${r>=100?" bad":r>=90?" warn":""}`});if(t.quota_limit){let c=e("i",{class:"fill"});c.style.width=`${r}%`,d.appendChild(c),ue(d,()=>[e("div",{class:"dl-tip-title"},`${r.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${ee(t.quota_used)} of ${ee(t.quota_limit)} · ${ee(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},t.quota_period==="total"?"In total":`This month${t.bonus_gb?` · includes +${t.bonus_gb} GB extra`:""}`)])}else{let c=t.devices.map(m=>({d:m,v:m.month[0]+m.month[1]})).filter(m=>m.v>0).sort((m,v)=>v.v-m.v);c.forEach((m,v)=>{let h=e("i",{class:`c${Math.min(v,4)}`});h.style.flexGrow=String(m.v),d.appendChild(h)}),c.length&&ue(d,()=>[e("div",{class:"dl-tip-title"},"This month by device"),...c.map((m,v)=>e("div",{class:"dl-tip-row"},[e("span",{class:`dl-swatch c${Math.min(v,4)}`}),e("span",{},m.d.name),e("b",{},ee(m.v))]))])}let p=t.quota_limit?`${ee(Math.max(0,t.quota_limit-t.quota_used))} left`:"no limit";return e("div",{class:"dl-pside"},[e("div",{class:"dl-pside-top"},[l?e("span",{class:"dl-pside-state live"},"Online"):e("span",{class:"dl-pside-state"},t.online?"Online":t.last_seen?"Offline":"Never connected"),o]),e("div",{class:"dl-use-num"},[e("b",{class:a?"":"dl-faint"},ee(a)),e("span",{class:"dl-faint"},t.quota_limit?`of ${ee(t.quota_limit)}`:t.quota_period==="total"&&t.quota_gb?"in total":"this month")]),d,l?e("div",{class:"dl-use-live",title:"Right now"},[`↓ ${Pe(s[2])}`,e("span",{class:"dl-faint"},`↑ ${Pe(s[1])}`)]):e("div",{class:"dl-faint dl-pside-foot"},i?`today ${ee(i)} · ${p}`:p)])}async togglePause(t){await U(()=>S.personPause(t.id,!t.paused),t.paused?`${t.name} resumed`:`${t.name} paused`)&&await this.refresh()}async remove(t){let o=this.person(t);await ne(`Remove ${o?.name??t}?`,`All ${o?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await U(()=>S.personDelete(t),"Person removed")&&await this.refresh()}openCreate(){let t=this.st;if(!t.servers.length){Q("Set up the server first.","warning");return}let o=e("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=xo("internet"),r=e("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:t.settings.default_device_limit}),i=e("input",{type:"date",class:"cbi-input-text"}),s=e("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),l=(m,v)=>e("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{i.value=v?xt(Ne(t.series),v):""}},m),d=t.servers[0],p=!this.serverId&&t.servers.length>1?e("select",{class:"cbi-input-select"},t.servers.map(m=>e("option",{value:m.id},m.name))):null,c=(m,v,h)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},m),e("div",{class:"cbi-value-field"},[v,h?e("div",{class:"cbi-value-description"},h):""])]);ae("Add person",[c("Name",o),p?c("Server",p):"",e("div",{class:"cbi-value dl-block"},[e("label",{class:"cbi-value-title"},"Access"),e("div",{class:"cbi-value-field"},a.el)]),c("Devices",r,"How many devices they can add themselves."),c("End date",e("div",{class:"dl-actions"},[i,l("1 month",1),l("3 months",3),l("1 year",12),l("None",0)]),"Optional."),c("Monthly data (GB)",s,"Optional. They are paused when it runs out and resumed next month.")],[se()," ",D("Create and copy link",async()=>{let m=await U(()=>S.personCreate(o.value.trim(),"",p?.value??d.id,a.get(),String(Number(r.value)||t.settings.default_device_limit),i.value,s.value.trim(),"month"));m&&(m.link&&await pe(m.link,"Personal link copied"),this.showCreated(m.id,o.value.trim(),m.link,t.servers.find(v=>v.id===(p?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(t,o,a,r){if(a){Lt({id:t,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`,[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:le},"Done")])}};var Vt=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],Pn=n=>e("i",{class:"dl-circle-dot",style:`background:${Vt[n?.color??0]??Vt[0]}`}),Je=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function ko(n,t,o){let a=re(n?.name??t.name??"",{placeholder:"NAS"}),r=re(n?.address??t.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=re((n?.ports??t.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=(l,d)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},l),e("div",{class:"cbi-value-field"},d)]);ae(n?`Edit ${n.name}`:"Add service",[s("Name",a),s("Address",r),s("Ports",i)],[se()," ",D("Save",async()=>{let l=i.value.split(/[ ,]+/).filter(Boolean);await U(()=>S.serviceSet(n?.id??"",a.value,r.value,l),"Saved")&&(le(),o())},"positive")])}var Ar={_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"},zr=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function Nr(n){let t=new Map;for(let o of n.services){let a=Ar[o.type.split(".")[0]];!a||!o.port||(t.get(a)??t.set(a,new Set).get(a)).add(String(o.port))}return t.size?[...t].map(([o,a])=>[o,[...a].sort((r,i)=>+r-+i)]):zr}function $o(n,t,o){let a=n,r=null,i=!1,s=null,l=new Set,d=e("div",{class:"dl-list"}),p=e("div",{class:"dl-stack gap8"},e("span",{class:"dl-sub"},"Looking for devices at home…")),c=()=>{let R=a.services;dom.content(d,R.length?R.map(_=>e("div",{class:"dl-row"},[g("home"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},_.name),e("span",{class:"dl-mono dl-faint"},`${_.address}${_.ports.length?` · ports ${_.ports.join(", ")}`:" · all ports"}`)]),D("Edit",()=>ko(_,{},o)),D([g("trash")],async()=>{await ne(`Remove ${_.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await U(()=>S.serviceDelete(_.id),"Removed")&&await o()},"neutral",{title:"Remove","aria-label":`Remove ${_.name}`})])):[e("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function m(R,_){if(!l.has(R.address)){l.add(R.address),h();try{let j=a.services.find(I=>I.address===R.address);(_===null?j&&await U(()=>S.serviceDelete(j.id),`${j.name} removed`):await U(()=>S.serviceSet(j?.id??"",j?.name??(R.name||R.address),R.address,_),j?`${j.name} updated`:`${R.name||R.address} added`))&&await o()}finally{l.delete(R.address),h()}}}function v(R){let _=a.services.find(T=>T.address===R.address),j=!!_&&!_.ports.length,w=new Set(_?.ports??[]),I=l.has(R.address),C=(T,b,A)=>Ue(T,b,A,{disabled:I?"disabled":null,"aria-busy":I?"true":null});return e("div",{class:"dl-row"},[g(R.services.some(T=>T.type.startsWith("_ipp")||T.type.startsWith("_printer"))?"file":"computer"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},R.name||R.address),e("span",{class:"dl-mono dl-faint"},R.address)]),e("div",{class:"dl-chips-row dl-host-ports"},[C("All ports",j,()=>m(R,j?null:[])),...Nr(R).map(([T,b])=>{let A=!j&&b.every(u=>w.has(u));return C(`${T} ${b.join(", ")}`,A,()=>{let u=new Set(j?[]:w);for(let f of b)A?u.delete(f):u.add(f);m(R,u.size?[...u]:null)})})])])}function h(){if(i)return dom.content(p,e("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!r)return;let R=r;if(!R.hosts.length)return dom.content(p,e("span",{class:"dl-sub"},"No devices found in the home network right now."));let _=e("details",{class:"dl-params",open:s??!a.services.length?"":null},[e("summary",{},[g("chevron"),e("span",{},"Add from devices at home"),e("span",{class:"dl-pcount"},String(R.hosts.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},R.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),e("div",{class:"dl-list"},R.hosts.map(v))])]);_.addEventListener("toggle",()=>s=_.open),dom.content(p,_)}return S.homeHosts(t).then(R=>{r=R,h()}).catch(()=>{i=!0,h()}),c(),{el:e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-iflead"},[e("div",{class:"dl-iflead-row"},[e("b",{},"Home services"),D([g("plus")," Add service"],()=>ko(null,{},o))]),e("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),d,p]),update(R){a=R,c(),h()}}}function Yt(n,t,o,a){let r=new Set(n.circles.filter(h=>h.server===t).map(h=>h.color)),i=o?.color??Vt.findIndex((h,x)=>!r.has(x));i<0&&(i=0);let s=re(o?.name??"",{placeholder:"Family"}),l=n.people.filter(h=>h.server===t).sort((h,x)=>h.name.localeCompare(x.name)),d=new Set(l.filter(h=>o&&h.circle===o.id).map(h=>h.id)),p=e("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),c=()=>dom.content(p,Vt.map((h,x)=>e("button",{type:"button",role:"radio",class:`dl-swatch${x===i?" on":""}`,style:`--sw:${h}`,"aria-checked":x===i?"true":"false","aria-label":`Colour ${x+1}`,click:()=>{i=x,c()}})));c();let m=e("div",{class:"dl-chips-row"},l.map(h=>{let x=h.circle&&h.circle!==o?.id?n.circles.find(R=>R.id===h.circle):void 0;return e("button",{type:"button",class:`dl-chipbtn${d.has(h.id)?" on":""}`,title:Je(h)?x?`Now in ${x.name}`:"":`${h.name} has no home access: their devices aren't reachable anyway`,click:R=>{d.delete(h.id)||d.add(h.id),R.currentTarget.classList.toggle("on",d.has(h.id))}},[h.name,Je(h)?x?e("b",{},x.name):"":e("b",{},"internet")])})),v=(h,x)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},h),e("div",{class:"cbi-value-field"},x)]);ae(o?`Edit ${o.name}`:"New circle",[v("Name",s),v("Colour",p),v("People",m),e("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 U(()=>S.circleDelete(o.id),`${o.name} deleted`)&&(le(),a())},"negative"):"",e("span",{class:"dl-spacer"}),se()," ",D("Save",async()=>{await U(()=>S.circleSet(o?.id??"",t,s.value,i,[...d]),"Saved")&&(le(),a())},"positive")],"dl-circle-modal")}function _o(n,t,o){let a=n.circles.filter(r=>r.server===t);return e("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 e("button",{type:"button",class:"dl-chip",title:`Edit ${r.name}`,click:()=>Yt(n,t,r,o)},[Pn(r),e("b",{},r.name),e("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),e("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>Yt(n,t,null,o)},g("plus"))])}function Dn(n,t){let o=n.people.filter(c=>c.server===t.id),a=(c="")=>e("span",{class:"dl-yes"},[g("check"),c]),r=()=>e("span",{class:"dl-faint"},"—"),i=c=>{let m=new Set(c.map(v=>v.access==="lan"&&v.services?.length?"services":v.home_nets?.length?"some":"all"));return m.size||m.add("all"),a([...m].map(v=>({all:"all networks",some:"their networks",services:"services"})[v]).join(" / "))},s=()=>t.mesh==="off"?r():t.mesh==="circles"?a("circle"):a(),l=t.lan_like?"like home":"direct",d=(c,m,v)=>e("tr",{},[e("td",{},[e("b",{},c),e("div",{class:"dl-sub"},`${m.length} ${m.length===1?"person":"people"}`)]),...v.map(h=>e("td",{},h))]),p=c=>o.filter(m=>m.access===c);return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Who reaches what"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"From the rules on this server")]),e("div",{class:"dl-reach-wrap"},e("table",{class:"dl-table dl-reach"},[e("tr",{},["","Internet","Home","This router","Each other"].map(c=>e("th",{},c))),d("Internet",p("internet"),[a(l),r(),e("span",{class:"dl-faint"},"DNS"),r()]),d("Home",p("lan"),[e("span",{class:"dl-faint"},"their own"),i(p("lan")),a(),s()]),d("Both",p("both"),[a(l),i(p("both")),a(),s()])])),e("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function Eo(n,t){let o=n.people.filter(p=>p.server===t.id).flatMap(p=>p.devices.map(c=>({id:c.id,label:`${p.name} · ${c.name}`}))).sort((p,c)=>p.label.localeCompare(c.label)),a="@addr",r=(p,c)=>{let m=e("select",{class:"cbi-input-select","aria-label":p},[...o.map(R=>e("option",{value:R.id,selected:R.id===c?"selected":null},R.label)),e("option",{value:a,selected:c===a?"selected":null},"Address")]),v=re("",{placeholder:p,class:"cbi-input-text dl-mono"}),h=e("div",{class:"dl-check-end"},[m,v]),x=()=>v.hidden=m.value!==a;return m.addEventListener("change",x),x(),{el:h,value:()=>m.value===a?v.value.trim():m.value}},i=r("10.0.1.11",o[0]?.id??a),s=r("10.0.1.20:445",a),l=e("div",{class:"dl-stack gap8"}),d=async()=>{let p=await U(()=>S.accessCheck(i.value(),s.value()));if(!p)return;let c=p.steps.findIndex(m=>!m.ok);dom.content(l,[e("div",{class:`dl-verdict ${p.ok?"ok":"bad"}`},[e("b",{},p.ok?"Allowed":"Blocked"),e("span",{class:"dl-sub"},p.ok?"Every step lets it through":`Stops at step ${c+1} of ${p.steps.length}`)]),e("ul",{class:"dl-checks"},p.steps.map(m=>e("li",{},[e("span",{class:`dl-check-icon ${m.ok?"ok":"error"}`},g(m.ok?"check":"x")),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},m.title),m.detail?e("div",{class:"dl-check-detail"},m.detail):""])])))])};return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Check access"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"Why something does or does not connect")]),e("div",{class:"dl-check-form"},[i.el,e("span",{class:"dl-faint"},"→"),s.el,D("Check",d)]),l])])}var Qt={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function Ve(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function Zt(n){return Ve(n.action==="check"?`check:${n.component??""}`:n.component??"")}function So(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function Co(n,t){return!n?.from&&!n?.to?t:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??t}function Lo(n,t){let o=n.check?.components??{},a=t==="all"?["app","amneziawg","packages"]:[t],r=[],i;for(let l of a){let d=o[l];if(d){if(d.error)return{tone:"warn",text:d.error};l==="packages"&&d.updates?r.push(`${d.updates} system package${d.updates===1?"":"s"}`):l!=="packages"&&d.update&&d.installed&&d.latest&&(r.push(`${Qt[l]} ${d.latest}`),t!=="all"&&(i=d.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 To(n,t,o,a){return t?n.id===t:o&&n.id===o?!1:n.state==="running"||a>0&&n.started>=a}var Mo=n=>new Promise(t=>setTimeout(t,n));async function Mt(n,t,o){let a=o?Zt(o):Ve(n),r=o?o.action==="check":n.startsWith("check"),i=Date.now(),s=e("b",{},Qt[a]??(a==="all"?"All components":"Dawnline")),l=e("span",{class:"dl-pill dl-mono"},t.version??""),d=e("span",{class:"dl-pill info",hidden:!0}),p=e("span",{},"0:00"),c=e("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),m=e("div",{}),v=e("div",{class:"dl-op-actions"}),h=[],x=u=>dom.content(v,u),R=(u=!1)=>se("Close",u);ae(t.title,e("div",{class:"dl-op"},[e("div",{class:"dl-op-head"},[s,t.version?l:"",d,e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint dl-op-timer"},[g("clock"),p])]),e("div",{class:"dl-op-loghead"},[e("b",{},"Operation log"),ye("copy","Copy log",()=>pe(h.join(` +`),"Log copied"))]),c,m]),[v],"wide"),x([e("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?"Checking…":"Working…")]);let _=o??null,j=o?.id,w,I=0,C=u=>{j!==u.id&&(j=u.id,t.onJob?.(u))};if(o)t.onJob?.(o);else try{let u=await S.updatesStatus().catch(()=>null);w=u?.job?.id,I=u?.now??0;let f=await S.updatesRun(n);f.job&&f.job.state==="running"&&f.job.id!==w&&(_=f.job,C(f.job))}catch(u){return h=[ve(u)],c.textContent=h[0],dom.content(m,e("div",{class:"dl-comp-status warn"},[g("alert"),e("span",{},ve(u))])),x([R(!0)]),Q(ve(u),"error"),null}let T=null,b=0;for(;;){if(await Mo(1e3),T=await S.updatesStatus().catch(()=>null),!T){if(++b>60)break;continue}b=0;let u=T.job;if(!u||!To(u,j,w,I)){if(Date.now()-i>15e3)break;continue}if(C(u),_=u,u.log.length){h=u.log;let f=c.scrollTop+c.clientHeight>=c.scrollHeight-8;c.textContent=h.join(` +`),f&&(c.scrollTop=c.scrollHeight)}if(l.textContent=Co(u,t.version??""),!l.isConnected&&l.textContent&&s.after(l),p.textContent=So((u.finished??T.now)-u.started),u.state==="running"){d.hidden=!u.phase,d.textContent=u.phase;continue}break}if(c.scrollTop=c.scrollHeight,d.hidden=!1,!_||_.state==="running")return d.className="dl-pill warn",d.textContent="No answer",dom.content(m,e("div",{class:"dl-comp-status warn"},[g("alert"),e("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),x([R()]),t.onDone?.(T),_;if(_.state==="failed")return d.className="dl-pill bad",d.textContent="Failed",dom.content(m,e("div",{class:"dl-comp-status bad"},[g("x"),e("span",{},[e("b",{},_.error??"Operation failed"),r?"":". Nothing else was changed."])])),x([D("Copy log",()=>pe(h.join(` +`),"Log copied")),R(!0)]),Q(`${Qt[a]??"Update"}: ${_.error??"failed"}`,"error"),t.onDone?.(T),_;if(d.className="dl-pill ok",d.textContent="Finished",r&&T){let u=Lo(T,a);if(dom.content(m,e("div",{class:`dl-comp-status ${u.tone}`},[g(u.tone==="ok"?"check":u.tone==="warn"?"alert":"download"),e("span",{},u.text)])),Q(u.text,u.tone==="warn"?"warning":"success"),t.onDone?.(T),u.update&&t.onUpdate){let f=T;x([R(),D(`Update to ${u.update}`,()=>t.onUpdate(f),"positive")])}else x([R()]),u.tone==="ok"&&setTimeout(()=>m.isConnected&&le(),1200);return _}if(a==="app"&&_.to){let u=_.to,f=e("span",{},"Waiting for the router to restart its services…");dom.content(m,e("div",{class:"dl-comp-status ok"},[g("check"),e("span",{},[e("b",{},`Dawnline ${u} is installed. `),f])]));let N=()=>{ui.menu?.flushCache(),location.reload()};x([R(),D("Reload now",N,"positive")]),Q(`Dawnline updated to ${u}`,"success",6e3);for(let P=1;P<=30;P++)if(f.textContent=`Waiting for the router to restart its services (${P} of 30)…`,await Mo(1500),(await S.updatesStatus().catch(()=>null))?.version===u)return f.textContent="Services are back. Reloading…",setTimeout(N,800),_;return f.textContent="Services restarted. Reload the page to use the new version.",_}let A=a==="pkgs"?`Updated ${[..._.result?.pkgs?.updated??[],..._.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:a==="amneziawg"?`AmneziaWG${_.to?` ${_.to}`:""} is installed`:"Operation completed";return dom.content(m,e("div",{class:"dl-comp-status ok"},[g("check"),e("span",{},A)])),x([R()]),Q(A,"success"),t.onDone?.(T),_}var Rr={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function Po(n,t,o,a){return!await ne(`Install ${t}?`,o,"Install")||(await Mt(n,{title:`Installing ${t}`}))?.state!=="done"?!1:(setTimeout(()=>a?.(),4e3),!0)}function Xt(n){return Po("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 Pt(n,t,o){return n==="awg"?Xt(o):t.length?Po(`pkgs:${t.join(",")}`,Rr[n],`${t.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function Do(n,t){if(n==="awg")return Xt(t);let o=await U(()=>S.updatesStatus());return o?Pt(n,o.needs?.[n]??[],t):!1}var Hr=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Ir={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function Ao(n,t,o){let a=n.id,r=t,i=e("div",{class:"dl-stack gap16"},e("section",{class:"dl-setsec"},e("div",{class:"dl-setsec-body"},e("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,d="",p=!0,c=!0,m="all",v=!1,h=$o(r,a,o),x=new Set,R="",_=()=>JSON.stringify([c,l,l?"":d,p,[...x].sort()]),j=()=>s.detected.lan||s.saved.lan||"",w=()=>(l?s.detected.wan||s.saved.wan:d)||"",I=()=>new Map(s.devices.map($=>[$.name,$])),C=()=>{let $=I();return[...p&&j()?[j()]:[],...[...x].filter(q=>q!==j())].filter(q=>q!==w()).map(q=>$.get(q)??{name:q,nets:[],missing:!0})},T=($,G)=>{s=$,G&&(l=$.config.auto_wan,d=$.config.wan_device||$.detected.wan||$.saved.wan||"",p=$.config.auto_lan,c=$.config.lan_like,m=$.config.mesh??($.config.device_mesh?"all":"off"),x=new Set($.config.lan_devices),R=_()),W()},b=async $=>{let G=await S.interfaces(a).catch(q=>(Q(q.message,"error"),null));G&&T(G,$)};function A($){let G=p&&$.name===j(),q=!!$.own||!!$.master||$.name===w()||G;return G||x.has($.name)||!q&&($.nets.length>0||!!$.missing)}function u($){let G=p&&$.name===j(),q=$.name===w(),oe=!G&&x.has($.name),F=!(!!$.own||!!$.master||q||G)&&($.nets.length>0||oe||!!$.missing),me=(oe||G)&&!$.zone&&!$.missing,ie=$.missing?"Not present right now":$.own?"This server":$.master?`Port of ${$.master}`:q?`Internet${$.zone?` · zone ${$.zone}`:""}`:$.nets.length?$.nets.join(", "):"No IPv4 network",ge=e("button",{type:"button",class:`dl-if${oe?" sel":""}${G?" auto":""}${!F&&!oe&&!G?" off":""}${me?" warn":""}`,"aria-pressed":oe||G?"true":"false","aria-disabled":F?null:"true",click:()=>{F&&(x.has($.name)?x.delete($.name):x.add($.name),W())}},[e("span",{class:"dl-if-ic"},g(Ir[$.kind]??"link")),e("span",{class:"dl-if-main"},[e("span",{class:"dl-if-name"},$.name),e("span",{class:"dl-if-sub"},ie)]),G?e("span",{class:"dl-if-badge ok"},"Auto"):oe?e("span",{class:"dl-if-check"},g("check")):""]);return ue(ge,()=>[e("div",{class:"dl-tip-title"},$.name),e("div",{class:"dl-muted"},[$.logical?`Interface ${$.logical}`:"No netifd interface",$.zone?` · zone ${$.zone}`:" · no firewall zone"]),$.members.length?e("div",{class:"dl-muted"},`Ports: ${$.members.join(", ")}`):"",$.nets.length?e("div",{class:"dl-mono"},$.nets.join(", ")):"",me?e("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",$.master?e("div",{class:"dl-muted"},`Choose ${$.master} to include it.`):""]),ge}function f(){let $=s.like_home;return!c||!s.config.lan_like?"":!s.needs?.length&&$.active&&$.bridged?"ok":"warn"}function N(){let $=s.like_home;return c?s.needs?.length?[e("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?$.active&&$.bridged?["Internet traffic enters ",e("span",{class:"dl-mono"},$.dev??"")," as ",e("span",{class:"dl-mono"},$.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[e("span",{class:"dl-warn"},`Not working: ${$.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let P={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function H($,G,q,oe,O="",F){return e("div",{class:F?"dl-setrow head":"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:`dl-need-ic ${O}`},g($)),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},G),e("span",{class:"dl-sub"},q),F??""])]),e("div",{class:"dl-setrow-ctl"},oe)])}let J=($,G)=>{let q=oe=>e("span",{class:"dl-mono"},oe);return $?e("span",{},[" Now: ",q($),...G&&G!==$?[", was ",q(G)]:[],"."]):e("span",{},G?[" Not found now: using ",q(G),"."]:[" Not found."])};function W(){let $=e("select",{class:"cbi-input-select","aria-label":"Internet interface",change:y=>{d=y.target.value,W()}},s.devices.filter(y=>!y.own&&!y.master&&y.zone&&!y.missing).map(y=>e("option",{value:y.name,selected:y.name===d?"selected":null},`${y.name} · zone ${y.zone}`))),q=C().flatMap(y=>y.nets.map(B=>[B,y.name])),oe=JSON.parse(_()),O=JSON.parse(R),F=(...y)=>y.some(B=>JSON.stringify(oe[B])!==JSON.stringify(O[B])),me=F(0,1,2),ie=F(3,4),ge=y=>D("Save",async()=>{let B=await U(()=>S.serverInterfaces(a,l,l?"":d,p,[...x],c,m!=="off",m),"Access saved");B&&(T(B,!0),B.nets_changed&&B.lan_only&&Q(`${B.lan_only} ${B.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!y}),M=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Internet"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Internet or Both")]),H("home","Internet like a home device",N(),[c&&s.needs?.length?D("Install",()=>Pt("home",s.needs,()=>b(!1)),"positive"):"",fe(c,"Internet like a home device",y=>{c=y,W()})],f()),H("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",J(s.detected.wan,s.saved.wan)],[l?"":$,fe(l,"Auto-detect WAN",y=>{l=y,W()})])]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},c?["Internet like a home device",w()?[" · leaves through ",e("span",{class:"dl-mono"},w())]:""]:w()?["Internet straight to ",e("span",{class:"dl-mono"},w())]:"No WAN found"),ge(me)])]),E=xe([["off","Off"],["all","Everyone"],["circles","Circles"]],m,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async y=>{let B={off:"Off",all:"Everyone",circles:"Circles"}[y];await U(()=>S.serverUpdate(a,{mesh:y}),`Devices reach each other: ${B}`)&&(m=y,s.config.mesh=y,W(),await o())}}),k=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Home network"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Home or Both"),D([g("reset")," Rescan"],()=>b(!1),"neutral",{title:"Read the interfaces again"})]),H("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.","","",te()),H("link","Devices reach each other",P[m],E,"",m==="circles"?_o(r,a,o):void 0),h.el]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub dl-if-summary"},q.length?["Home access reaches ",...q.flatMap(([y,B],Y)=>[Y?", ":"",e("span",{class:"dl-mono"},y),` (${B})`])]:"No home network: Home access reaches nothing but this router."),ge(ie)])]),z=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[M,k]),i.style.minHeight="",window.scrollTo({top:z})}function te(){let $=s.devices.filter(A),G=s.devices.filter(q=>!A(q));return e("div",{class:"dl-stack gap8 dl-netpick"},[$.length?e("div",{class:"dl-ifgrid"},$.map(u)):e("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),e("label",{class:"dl-boxrow"},[e("span",{class:"dl-stack"},[e("span",{},"Auto-detect LAN"),e("span",{class:"dl-sub"},["Adds the LAN this router uses.",J(s.detected.lan,s.saved.lan)])]),fe(p,"Auto-detect LAN",q=>{p=q,W()})]),G.length?e("details",{class:"dl-params",open:v?"":null,toggle:q=>v=q.currentTarget.open},[e("summary",{},[g("chevron"),e("span",{},"Other interfaces"),e("span",{class:"dl-pcount"},String(G.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...Hr.map(([q,oe])=>{let O=G.filter(F=>F.category===q);return O.length?e("div",{class:"dl-ifgroup"},[e("h4",{},oe),e("div",{class:"dl-ifgrid"},O.map(u))]):""})])]):""])}return b(!0),{el:i,update($){r=$,h.update($),s&&W()}}}var zo="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl",Br="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",Or="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",jr={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Dt=null;function Ur(n){let t=window;return n.appendChild(e("link",{rel:"stylesheet",href:`${zo}.css`})),t.maplibregl?Promise.resolve(t.maplibregl):Dt||(Dt=new Promise((o,a)=>{let r=e("script",{src:`${zo}.js`});r.onload=()=>t.maplibregl?o(t.maplibregl):a(new Error("MapLibre failed to load")),r.onerror=()=>{Dt=null,a(new Error("Could not load the map library (no internet access from this browser?)"))},n.appendChild(r)}),Dt)}function en(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function Wr(n,t,o=48){let a=(n[0]+t[0])/2,r=(n[1]+t[1])/2,i=t[0]-n[0],s=t[1]-n[1],l=Math.hypot(i,s)||1,d=Math.min(.25*l,12),p=a-s/l*d,c=r+i/l*d,m=[];for(let v=0;v<=o;v++){let h=v/o,x=1-h;m.push([x*x*n[0]+2*x*h*p+h*h*t[0],x*x*n[1]+2*x*h*c+h*h*t[1]])}return m}function Gr(n,t){let o=new Map;for(let a of n.geo.points){if(n.person&&a.person!==n.person||(t==="online"?!a.online:n.now-a.ts>jr[t]))continue;let r=o.get(a.device);(!r||a.online&&!r.online||a.online===r.online&&a.ts>r.ts)&&o.set(a.device,a)}return[...o.values()]}var gt=class{constructor(t,o="online",a=380){this.cb=t;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.anim=0;this.data=null;this.fitted=!1;this.range=o,this.status=e("div",{class:"dl-map-status"}),this.el=e("div",{class:"dl-geomap",style:`height:${a}px`},this.status)}async mount(t){this.data=t;try{this.gl=await Ur(this.el)}catch(o){this.status.textContent=o.message;return}this.map=new this.gl.Map({container:this.el,style:en()?Br:Or,center:[t.geo.home?.lon??20,t.geo.home?.lat??50],zoom:3,attributionControl:{compact:!0},dragRotate:!1,pitchWithRotate:!1,cooperativeGestures:!0}),this.map.addControl(new this.gl.NavigationControl({showCompass:!1}),"bottom-right"),this.map.on("load",()=>{this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],"#40c977",en()?"#ededed":"#0d0d0d"],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],"#40c977",en()?"#ededed":"#0d0d0d"],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],!1],layout:{"line-cap":"round"},paint:{"line-color":en()?"#ededed":"#0d0d0d","line-opacity":.35,"line-width":1.5,"line-dasharray":[2,3]}}),this.map.addLayer({id:"dl-arc-glow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-opacity":.18,"line-width":7}}),this.map.addLayer({id:"dl-arc-live",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-width":2}}),this.map.addLayer({id:"dl-arc-flow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#ffffff","line-width":2,"line-opacity":.8,"line-dasharray":[0,4,3]}}),this.animate(),this.draw()})}setRange(t){this.range=t,this.fitted=!1,this.draw()}update(t){this.data=t,this.draw()}destroy(){cancelAnimationFrame(this.anim),this.map?.remove(),this.map=null}animate(){let t=[[0,4,3],[.5,4,2.5],[1,4,2],[1.5,4,1.5],[2,4,1],[2.5,4,.5],[3,4,0],[0,.5,3,3.5],[0,1,3,3],[0,1.5,3,2.5],[0,2,3,2],[0,2.5,3,1.5],[0,3,3,1],[0,3.5,3,.5]],o=-1,a=0,r=i=>{this.map&&(i-a>70&&(a=i,o=(o+1)%t.length,this.map.getLayer("dl-arc-flow")&&this.map.setPaintProperty("dl-arc-flow","line-dasharray",t[o])),this.anim=requestAnimationFrame(r))};this.anim=requestAnimationFrame(r)}groups(t){let o=new Map;for(let a of t){let r=`${a.asn||a.org||a.ip}|${a.city}|${a.cc}`,i=o.get(r);i||(i={key:r,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 t=this.data,o=this.groups(Gr(t,this.range)),a=t.geo.home;for(let s of this.markers)s.remove();this.markers=[];let r=new Map,i=o.map(s=>{let l=`${s.lat.toFixed(2)},${s.lon.toFixed(2)}`,d=r.get(l)??0;return r.set(l,d+1),{g:s,at:[s.lon+d*.25,s.lat]}});if(this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:s,at:l})=>({type:"Feature",properties:{online:s.online},geometry:{type:"Point",coordinates:l}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?i.map(({g:s,at:l})=>({type:"Feature",properties:{online:s.online},geometry:{type:"LineString",coordinates:Wr([a.lon,a.lat],l)}})):[]}),a){let s=e("div",{class:"dl-mk-home",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`});s.innerHTML=bn("home","dl-mk-home-ic"),this.markers.push(new this.gl.Marker({element:s}).setLngLat([a.lon,a.lat]).addTo(this.map))}for(let{g:s,at:l}of i){let d=s.points.length,p=e("button",{type:"button",class:`dl-mk${s.online?" online":""}${d>1?" multi":""}`,"aria-label":`${d} device${d===1?"":"s"} via ${s.org||"unknown network"} in ${s.city||"unknown city"}`},d>1?e("span",{class:"dl-mk-count"},String(d)):e("span",{class:"dl-mk-dot"})),m=!!a&&Math.abs(l[0]-a.lon)<.02&&Math.abs(l[1]-a.lat)<.02?[22,-16]:[0,0];p.addEventListener("click",v=>{v.stopPropagation(),this.openPopup(s,l,m)}),this.markers.push(new this.gl.Marker({element:p,offset:m}).setLngLat(l).addTo(this.map))}if(!this.fitted){let s=i.map(l=>l.at);a&&(s.length===0||this.range!=="online"||i.some(l=>l.g.online))&&s.push([a.lon,a.lat]),this.fit(s),this.fitted=!0}this.status.textContent=i.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none"}fit(t){if(!t.length)return;let o=(d,p)=>{let c=Math.PI/180,m=(p[1]-d[1])*c,v=(p[0]-d[0])*c,h=Math.sin(m/2)**2+Math.cos(d[1]*c)*Math.cos(p[1]*c)*Math.sin(v/2)**2;return 12742*Math.asin(Math.sqrt(h))},a=[t.reduce((d,p)=>d+p[0],0)/t.length,t.reduce((d,p)=>d+p[1],0)/t.length],r=t;if(t.length>=5){let d=[...t].sort((p,c)=>o(a,p)-o(a,c));r=d.slice(0,Math.ceil(d.length*.9))}if(Math.max(...r.map(d=>o(a,d)))<25){this.map.jumpTo({center:a,zoom:9.5});return}let s=new this.gl.LngLatBounds(r[0],r[0]);r.forEach(d=>s.extend(d));let l=this.el.clientHeight||380;this.map.fitBounds(s,{padding:{top:Math.min(90,l/4),bottom:Math.min(70,l/5),left:60,right:60},maxZoom:9,duration:0})}openPopup(t,o,a=[0,0]){let r=this.data;this.popup?.remove();let i=[t.city,t.cc||t.country].filter(Boolean).join(", "),s=[...new Set(t.points.map(c=>c.person))],l=t.points.sort((c,m)=>Number(m.online)-Number(c.online)||m.ts-c.ts).map(c=>{let m=r.people.find(h=>h.id===c.person),v=m?.devices.find(h=>h.id===c.device);return e("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(c.person,c.device)},[e("span",{class:`dl-pop-dot${c.online?" on":""}`}),e("span",{class:"dl-pop-name"},[e("b",{},m?.name??c.person),` · ${v?.name??"device"}`]),e("span",{class:"dl-faint dl-nowrap"},c.online?"now":de(c.ts,r.now))])}),d=e("div",{class:"dl-pop"},[e("div",{class:"dl-pop-head"},[e("span",{class:"dl-pop-net"},g("globe")),e("div",{class:"dl-stack"},[e("strong",{},t.org||"Unknown network"),e("span",{class:"dl-faint"},[t.asn?`AS${t.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),e("div",{class:"dl-pop-list"},l),s.length===1?e("div",{class:"dl-pop-actions"},[e("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${r.people.find(c=>c.id===s[0])?.name??"person"}`)]):""]),p=this.el.clientHeight||380;this.map.easeTo({center:o,offset:[0,Math.min(140,p*.32)],duration:300}),this.popup=new this.gl.Popup({offset:[a[0],a[1]-18],anchor:"bottom",closeButton:!1,focusAfterOpen:!1,maxWidth:"300px",className:"dl-popup"}).setLngLat(o).setDOMContent(d).addTo(this.map)}};function tn(n,t,o=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],r=e("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of a)i==="online"&&!o||r.appendChild(e("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)),t(i)}},s));return r}var qr={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",paused_all:"warn",resumed_all:"ok",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},Fr={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",paused_all:"pause",resumed_all:"play"};function Kr(n,t){return t.device?n.people.flatMap(a=>a.devices).find(a=>a.id===t.device)?.kind??t.dkind??"other":Fr[t.type]??"activity"}function An(n,t){let o=n.people.find(x=>x.id===t.person),a=o?.name??t.pname??t.person??"",r=o?.devices.find(x=>x.id===t.device)?.name??t.dname??"",i=x=>e("b",{},x),s=x=>e("span",{class:"dl-muted"},x),l=x=>e("span",{class:"dl-mono"},x),d=x=>t.hosts?.[x]?[e("span",{class:"dl-ev-host"},[e("b",{},t.hosts[x]),e("span",{class:"dl-faint"},` (${x})`)])]:[l(x)],p=x=>e("span",{class:"dl-ev-kind"},`${x} `),c=r?`${a} · ${r}`:a,m=oo(t),v=m||r||"a device",h=x=>[e("span",{class:"dl-you"},"You"),s(` ${x} `)];if(Le(t)==="admin")switch(t.type){case"device_added":return[...h("added"),p("device"),i(v),s(" for "),i(a)];case"device_removed":return[...h("removed"),p("device"),i(v),s(" from "),i(a)];case"paused":return[...h("paused"),p("person"),i(a)];case"resumed":return[...h("resumed"),p("person"),i(a)];case"device_changed":{let x=m.startsWith("renamed from ");return[...h(x?"renamed":m),p("device"),i(r||"a device"),s(" of "),i(a),...x?[s(` · was ${m.slice(13)}`)]:[]]}case"device_keys":return[...h("issued new keys for"),p("device"),i(v),s(" of "),i(a),s(" · it needs its new configuration")];case"link_changed":return[...h("issued a new link for"),p("person"),i(a),s(" · the old link stopped working")];case"paused_all":return[e("span",{class:"dl-you"},"You"),s(" paused everyone")];case"resumed_all":return[e("span",{class:"dl-you"},"You"),s(" resumed everyone")]}switch(t.type){case"connect":return[p("Device"),i(c),s(" connected"),...t.detail?[s(" from "),...d(t.detail)]:[],...t.where?[s(` · ${t.where}`)]:[]];case"disconnect":return[p("Device"),i(c),s(" went offline")];case"roam":return[p("Device"),i(c),s(" changed network "),...(t.detail??"").split(" → ").flatMap((x,R)=>R?[s(" → "),...d(x)]:d(x))];case"device_added":return[p("Person"),i(a),s(" added "),p("device"),i(v),...Le(t)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[p("Person"),i(a),s(" removed "),p("device"),i(v),...Le(t)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[p("Person"),i(a),s(" issued new keys for "),p("device"),i(v),s(" on their portal")];case"person_added":return[...h("added"),p("person"),i(t.detail??a)];case"person_removed":return[...h("removed"),p("person"),i(t.detail??a)];case"person_changed":return[...h("changed"),p("person"),i(a),...m?[s(` · ${m.replace(/_/g," ")}`)]:[]];case"paused":return[p("Person"),i(a),s(` paused — ${t.detail??""}`)];case"resumed":return[p("Person"),i(a),s(" resumed"),...t.detail&&t.detail!=="active"?[s(` — ${t.detail}`)]:[]];case"paused_all":return[s("Everyone paused")];case"resumed_all":return[s("Everyone resumed")];case"portal_blocked":return[e("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(t.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[p("Person"),i(a),s(" — all devices removed, end date reached")];default:return[s(`${t.type}${t.detail?`: ${t.detail}`:""}`)]}}var Jr={portal_blocked:["globe","bad"]};function Vr(n,t){if(n.servers.length<2||!t.person)return"";let o=n.people.find(r=>r.id===t.person),a=o&&n.servers.find(r=>r.id===o.server);return a?e("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function Ye(n,t,o={}){let a=Jr[t.type],r=Le(t);return e("div",{class:`dl-row${r==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[r==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):a?e("span",{class:"dl-ev-tile sys"},g(a[0])):e("span",{class:`dl-ev-tile ev ${qr[t.type]??""}`},g(Kr(n,t))),e("span",{class:"dl-row-main"},An(n,t)),o.server===!1?"":Vr(n,t),e("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString()},o.time??de(t.ts,n.now))])}var Yr={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Qr={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function nn(n,t,o,a){let r=n.by==="admin",i=e("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${Yr[n.level]??""}`}${n.detail?" has-detail":""}`},[r?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):e("span",{class:"dl-ev-tile sys",title:n.level},g(Qr[n.src]??"zap")),e("span",{class:"dl-row-main"},r?[e("span",{class:"dl-you"},"You"),e("span",{class:"dl-muted"},` ${n.msg} `),n.kind?e("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?e("b",{},n.who):"",n.note?e("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?e("span",{class:`dl-slog-more${t?" open":""}`},g("chevron")):"",n.detail&&t?e("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?e("span",{class:"dl-ev-kind"},"Server "):"",e("b",{class:"dl-sys-src",title:_t[n.src]??n.src},n.who??_t[n.src]??n.src)," ",e("span",{class:"dl-muted"},n.msg),n.detail?e("span",{class:`dl-slog-more${t?" open":""}`},g("chevron")):"",n.detail&&t?e("pre",{class:"dl-slog-detail"},n.detail):""]),e("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 No(n){let t=new Date(n*1e3),o=new Date,a=new Date;return a.setDate(o.getDate()-1),t.toDateString()===o.toDateString()?"Today":t.toDateString()===a.toDateString()?"Yesterday":t.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var vt=n=>lt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function on(n,t,o){let a=n.slice(-15),r=a[a.length-1],i=r&&t-r[0]<180,s=i?r[2]:0,l=i?r[1]:0,[d,p]=o,c=200,m=40,v=Math.max(1,...a.map(w=>Math.max(w[1],w[2]))),h=w=>a.map((I,C)=>`${a.length>1?C/(a.length-1)*c:c},${m-2-I[w]/v*(m-6)}`),x=h(2),R=h(1),_=a.length>1?qe(``):e("div",{class:"dl-speed-wait"},[e("i"),e("span",{},"Collecting… 1 point a minute")]),j=(w,I,C,T)=>e("div",{class:"dl-speed-col"},[e("span",{class:"dl-sub"},[e("span",{class:C},I),` ${w}`]),e("span",{class:"dl-speed-val"},Pe(T))]);return a.length>1&&ue(_,()=>{let w=a[a.length-1];return[e("div",{class:"dl-tip-title"},new Date(w[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),e("div",{},`↓ ${Pe(w[2])} · ↑ ${Pe(w[1])}`)]}),e("div",{class:"dl-bento-tile"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Speed now"),e("span",{class:"dl-sub"},"last 15 min")]),e("div",{class:"dl-speed-cols"},[j("Download","↓","dl-dn",s),j("Upload","↑","dl-up",l)]),_,e("div",{class:"dl-speed-today"},[e("span",{},["Today ",e("b",{},ee(d+p))]),e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${ee(p)} `,e("span",{class:"dl-up"},"↑"),` ${ee(d)}`])])])}function an(n,t){let o=n.slice(-30),a=o.map(d=>d.rx+d.tx),r=Math.max(1,...a),i=a.reduce((d,p)=>d+p,0),s=a.reduce((d,p,c)=>p>a[d]?c:d,0),l=e("div",{class:"dl-bento-bars"},o.map((d,p)=>{let c=a[p],m=e("i",{class:p===o.length-1?"hi":"",style:`height:${Math.max(4,c/r*100)}%`});return ue(m,()=>[e("div",{class:"dl-tip-title"},p===o.length-1?`Today · ${vt(d.day)}`:vt(d.day)),e("div",{},ee(c)),e("div",{class:"dl-muted dl-mono"},`↓ ${ee(d.tx)} ↑ ${ee(d.rx)}`)]),m}));return e("div",{class:"dl-bento-tile month"},[e("div",{class:"dl-bento-head"},[e("span",{},[e("span",{class:"dl-metric-label"},"Last 30 days"),e("b",{class:"dl-bento-total"},ee(i))]),a[s]>0?e("span",{class:"dl-sub"},`peak ${ee(a[s])} · ${vt(o[s].day)}`):""]),o.length?l:e("p",{class:"dl-muted"},"No traffic yet."),e("div",{class:"dl-bento-head"},[e("span",{class:"dl-sub"},o.length?vt(o[0].day):""),e("span",{class:"dl-sub"},t),e("span",{class:"dl-sub"},"today")])])}function Ro(n){let t=n.slice(-30),o=t.map(r=>r.rx+r.tx),a=Math.max(1,...o);return e("div",{class:"dl-dbars"},t.map((r,i)=>{let s=e("i",{class:`${o[i]?"":"zero"}${i===t.length-1?" hi":""}`});return s.style.height=`${Math.max(8,o[i]/a*100)}%`,ue(s,()=>[e("div",{class:"dl-tip-title"},i===t.length-1?`Today · ${vt(r.day)}`:vt(r.day)),e("div",{},ee(o[i]))]),s}))}var Ho={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function rn(n){return n==="netrestart"&&!await ne("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await U(()=>S.healthFix(n),"Done")??null}function zn(n,t,o,a="action"){let r=n.fix;return r?r.startsWith("install:")?D("Install",()=>Do(r.slice(8),o),a):r==="updates"?e("a",{class:`cbi-button cbi-button-${a}`,href:L.url("admin/network/dawnline/updates")},Ho.updates):D(Ho[r]??"Fix",()=>t(r),a):""}function Zr(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==="nft"?"lock":"alert"}function Io(n,t,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 e("div",{class:"dl-list dl-notices"},[...r.slice(0,a).map(s=>tt(Zr(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,zn(s,t,o,s.status==="error"?"positive":"neutral"))),i>0?e("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,e("span",{class:"dl-spacer"}),"→"]):""])}function Xr(n){let t=[],o=(s,l)=>e("a",{href:s},l),a=Ne(n.series),r=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?t.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!r&&t.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});n.settings.paused_all&&t.push({tone:"warn",text:["Everyone is paused."]});for(let s of n.people)if(s.state==="quota")t.push({tone:"warn",text:[o(Te(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")t.push({tone:"warn",text:[o(Te(s.id),s.name),"’s access has ended."]});else{let l=Xe(s.expires,a);l!=null&&l>=0&&l<=Math.max(s.expire_warn,3)&&t.push({tone:"",text:[o(Te(s.id),s.name),`’s access ends in ${l} day${l===1?"":"s"}.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&t.push({tone:"",text:[o(Te(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&&t.push({tone:"warn",text:i.length===1?[o(Te(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&&t.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||t.push({tone:"",text:["The personal portal is off. ",o(L.url("admin/network/dawnline/settings"),"Turn on")]}),t}var sn=class{constructor(t,o){this.srvId=t;this.go=o;this.el=e("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(t){this.st=Tt(t,this.srvId);for(let o of["health","bento","side","activity"])this.parts[o]=e("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),e("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(t,o=!1){this.st=Tt(t,this.srvId),this.paint(o),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let t=await S.health().catch(()=>null);if(!t)return;let o=()=>void this.loadHealth(),a=async r=>{await rn(r)&&(o(),r==="netrestart"&&setTimeout(o,5e3))};_e(this.parts.health,Io(t.checks,r=>void a(r),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let t=this.st,o=e("div",{class:"dl-panel-head pad"},[e("div",{class:"dl-stack"},[e("h3",{},"Where people connect from"),e("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),e("span",{class:"dl-spacer"}),tn(this.range,i=>{this.range=i,this.map?.setRange(i)})]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[o,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map=new gt({openPerson:i=>location.href=Te(i),openDevice:(i,s)=>location.href=Te(i,s)},this.range);let a=e("div",{class:"dl-map-legend"},[e("span",{},[e("i",{class:"dot ok"}),"Online"]),e("span",{},[e("i",{class:"dot"}),"Seen recently"]),e("span",{},[e("i",{class:"line"}),"Live tunnel"])]),r=e("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[o,r])}paint(t=!1){let o=this.st,a=o.servers[0],r=o.people.reduce((l,d)=>l+Math.max(0,d.device_limit-d.devices.length),0);_e(this.parts.bento,e("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Re(a).overviewTile(a),this.monthTile(r)]),t);let i=Xr(o);_e(this.parts.side,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Needs attention"),e("span",{class:"dl-spacer"}),e("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),i.length?i.slice(0,8).map(l=>e("div",{class:"dl-attn-item dl-row"},[e("span",{class:`dl-ev-dot ${l.tone}`}),e("span",{},l.text),l.action??""])):e("div",{class:"dl-row dl-muted"},[g("check"),"All good. Nothing needs you right now."])]),t);let s=[...o.events].reverse().slice(0,8);_e(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-spacer"}),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),s.length?s.map(l=>Ye(o,l)):e("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),t)}onlineTile(){let t=this.st,o=12,a=_=>_.spark[_.spark.length-1]??0,r=_=>t.geo.points.find(j=>j.device===_.id&&j.city)?.city,i=_=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(_.endpoint??""),s=_=>(i(_)?"home":r(_))??"",l=_=>[...t.events].reverse().find(j=>j.type==="connect"&&j.device===_.id)?.ts??0,d=t.people.map(_=>({p:_,devs:_.devices.filter(j=>j.online).sort((j,w)=>a(w)-a(j))})).filter(_=>_.devs.length).sort((_,j)=>j.devs.reduce((w,I)=>w+a(I),0)-_.devs.reduce((w,I)=>w+a(I),0)),p=d.length<=2,c=({p:_,devs:j})=>{let w=j.map(l).filter(Boolean),I=w.length?Math.min(...w):0,C=(_.rate??[]).slice(-15),T=C[C.length-1],b=T&&t.now-T[0]<180?T:null,A=200,u=30,f=Math.max(1,...C.map(W=>Math.max(W[1],W[2]))),N=W=>C.map((te,$)=>`${C.length>1?$/(C.length-1)*A:A},${u-2-te[W]/f*(u-6)}`),P=C.length>1?qe(``):"",H=!b||b[1]<64&&b[2]<64,J=_.access==="both"?["home","globe"]:_.access==="lan"?["home"]:["globe"];return[e("div",{class:"dl-hc"},[e("div",{class:"dl-hc-head"},[e("span",{class:"dl-onl-av sm"},Oe(_.name)),e("span",{class:"dl-stack"},[e("b",{},_.name),e("span",{class:"dl-hc-since"},I?`online for ${de(I,t.now).replace(" ago","")}`:"online")]),e("span",{class:"dl-hc-reach"},J.map(W=>e("span",{class:`dl-ibadge ${W==="home"?"lan":"inet"}`},g(W))))]),e("div",{class:"dl-hc-speed"},[e("div",{class:"dl-hc-speed-row"},H?[e("span",{class:"dl-faint"},"Idle right now")]:[e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${Pe(b[2])}`]),e("span",{},[e("span",{class:"dl-up"},"↑"),` ${Pe(b[1])}`]),e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint"},"15 min")]),P]),e("div",{class:"dl-hc-devs"},j.map(W=>e("span",{class:"dl-hc-dev"},[g(W.kind),[W.name,s(W)].filter(Boolean).join(" · ")]))),e("div",{class:"dl-hc-foot"},[e("span",{class:"dl-faint"},`${ee(j.reduce((W,te)=>W+a(te),0))} today · ${ee(_.month[0]+_.month[1])} this month`)])])]},m=_=>{let{p:j,devs:w}=_,I=e("span",{class:"dl-onl-dev"},w.length>1?String(w.length):g(w[0].kind)),C=e("a",{class:`dl-onl-p${p?"":" sm"}`,href:Te(j.id),"aria-label":`${j.name}, online`},[e("span",{class:"dl-onl-av"},[Oe(j.name),I]),p?e("span",{class:"dl-onl-name"},j.name):"",p?e("span",{class:"dl-onl-meta"},[...w.slice(0,3).map(T=>g(T.kind)),w.length>3?`+${w.length-3}`:"",s(w[0])?e("span",{},` · ${s(w[0])}`):""]):""]);return ue(C,()=>c(_)),C},v=e("b",{class:`dl-onl-count${d.length?"":" none"}`},String(d.length)),h=d.reduce((_,j)=>_+j.devs.length,0);d.length&&ue(v,()=>[`${d.length} ${d.length===1?"person":"people"} · ${h} device${h===1?"":"s"}`]);let x=d.length>o?d.slice(0,o-1):d,R=t.people.flatMap(_=>_.devices.map(j=>({p:_,d:j}))).filter(_=>_.d.handshake).sort((_,j)=>j.d.handshake-_.d.handshake)[0];return e("div",{class:"dl-bento-tile online"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Online"),v]),d.length?e("div",{class:`dl-onl-row${p?"":" grid"}`},[...x.map(m),d.length>o?e("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:_=>{this.go&&(_.preventDefault(),this.go("people","online"))}},[e("span",{class:"dl-onl-av"},`+${d.length-x.length}`)]):""]):e("div",{class:"dl-onl-empty"},[e("span",{},"Nobody is connected"),R?e("span",{class:"dl-sub"},`Last: ${R.p.name}, ${de(R.d.handshake,t.now)}`):e("span",{class:"dl-sub"},"No device has connected yet")])])}speedTile(){return on(this.st.servers[0]?.rate??[],this.st.now,this.st.totals.today)}monthTile(t){let o=this.st.totals,a=this.st.people.filter(r=>r.state!=="active").length;return an(this.st.series,`${o.people} ${o.people===1?"person":"people"}${a?` · ${a} paused`:""} · ${t} device slot${t===1?"":"s"} free`)}};var Bo=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],ei={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},Nn=(n,t)=>{let o=new URLSearchParams;n&&o.set("server",n),t&&t!=="overview"&&o.set("section",t);let a=o.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},At=class{constructor(){this.noFooter=!0;this.root=e("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=e("div",{});this.headEl=e("div",{});this.secEl=e("div",{});this.bodyEl=e("div",{class:"dl-srvbody"})}async load(){let t=await S.status(31),o=t.servers.length?null:await S.setupDefaults();return[t,o]}render([t,o]){if(this.st=t,!t.servers.length&&o)return this.wizard(o);let a=new URLSearchParams(location.search),r=a.get("section")??"",i=ei[r]??r;return Bo.some(([s])=>s===i)&&(this.section=i),this.srvId=(t.servers.find(s=>s.id===a.get("server"))??t.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller=Ke({fetch:()=>S.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(t=!1){_e(this.headEl,this.head(this.current()),t),(!t||!ft(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let t=await S.status(31).catch(()=>null);return t?.servers.length?(this.st=t,this.paintHead(),t):null}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await S.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=Nn())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let t=this.current();dom.content(this.tabsEl,e("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(o=>e("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===t.id?" on":""}`,"aria-selected":o.id===t.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[e("i",{class:`dot ${o.up?"ok":"bad"}`}),e("b",{},o.name)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[g("plus"),"Add server"])]))}paintSections(){let t=Re(this.current());dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},Bo.map(([o,a])=>e("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"?t.label:a))))}go(t,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 at;r.filter=o}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let t=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of t)o&&this.bodyEl.contains(o)&&o.remove()}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===t;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 sn(a.id,(l,d)=>this.go(l,d))).mount(o)},people:()=>{var p,c;let s=this.pp[a.id];if(s?.el)return s.update(),s.el;let l=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((p=this.pp)[c=a.id]??(p[c]=new at)).embed(o,a.id).then(m=>{l.isConnected?dom.content(l,m):l.replaceChildren(m)}).catch(m=>{delete this.pp[a.id],dom.content(l,e("p",{class:"dl-muted"},`Couldn't show people: ${ve(m)}`))}),l},connection:()=>this.connection(a),access:()=>this.access(a),awg:()=>this.awg(a)}[t]();this.detachKept(),dom.content(this.bodyEl,i)}head(t){let o=this.st,a=(l,d)=>e("span",{class:"dl-addrbar-seg"},[g(l),...d]),r=t.endpoint||"—",i=!t.enabled||o.settings.paused_all,s=e("div",{class:"dl-actions"},[i?D([g("play")," Turn on"],async()=>{o.settings.paused_all&&!await U(()=>S.pauseAll(!1))||(t.enabled?await this.refresh():await this.save(t,{enabled:"1"},"Server turned on"))},"positive"):""]);return e("div",{class:"dl-srvpagehead"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),e("span",{class:`dl-pill ${t.enabled?t.up?"ok":"bad":"off"}`},t.enabled?t.up?"Running":t.blocked?"Can’t start":"Not running":"Turned off"),o.settings.paused_all&&t.enabled?e("span",{class:"dl-pill warn"},"Off"):"",e("span",{class:"dl-spacer"}),s]),e("div",{class:"dl-addrbar"},[e("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>pe(r,"Address copied")},[g("globe"),e("span",{class:"dl-mono"},r),g("copy")]),a("tunnel",[e("span",{class:"dl-mono"},`${Re(t).label} :${t.port}`)]),t.up?a("clock",[`up ${st(t.uptime)}`]):""]),t.blocked?e("div",{class:"dl-note warn"},[g("alert"),e("span",{},`${t.name} ${t.blocked}.`)]):""])}async save(t,o,a="Saved"){await U(()=>S.serverUpdate(t.id,o),a)&&await this.refresh()}connection(t){let o=re(t.name,{placeholder:"Home"}),a=re(t.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),r=re(t.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter(l=>l.server===t.id).length,s=D(t.enabled?"Turn off":"Turn on",async()=>{t.enabled&&!await ne(`Turn off ${t.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(t,{enabled:t.enabled?"0":"1"},t.enabled?"Server turned off":"Server turned on")},t.enabled?"negative":"positive");return e("div",{class:"dl-stack gap16"},[kt("Connection",[e("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",[Z("Name",o,"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[Z("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",[Z("DNS for devices",r,"Empty = this router, which sends each query where your home network would.")])],[e("span"),D("Save",()=>this.save(t,{name:o.value,endpoint:a.value,dns:r.value}),"positive")]),kt("Danger zone",[e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},t.enabled?"Turn off this server":"This server is off"),e("span",{class:"dl-sub"},t.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),e("div",{class:"dl-setrow-ctl"},s)]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Remove server"),e("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),e("div",{class:"dl-setrow-ctl"},D([g("trash")," Remove"],()=>this.remove(t),"negative"))])],[],"danger")])}access(t){let o=Dn(this.st,t),a=Ao(t,this.st,async()=>{let r=await this.refreshStatus();if(!r)return;let i=r.servers.find(l=>l.id===t.id)??t;a.update(r);let s=Dn(r,i);o.replaceWith(s),o=s});return e("div",{class:"dl-stack gap16"},[a.el,e("div",{class:"dl-health-cols"},[o,Eo(this.st,t)])])}awg(t){let o={st:this.st,save:(a,r)=>this.save(t,a,r),refresh:()=>this.refresh()};return e("div",{class:"dl-stack gap16"},[Re(t).settingsCard(o,t)])}async addServer(){let t=await U(()=>S.setupDefaults());t&&dom.content(this.root,this.wizard(t,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async remove(t){let o=this.st.people.filter(a=>a.server===t.id);ae(`Remove ${t.name}?`,[e("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.`)],[se()," ",D("Remove",async()=>{le(),await U(()=>S.serverDelete(t.id),"Server removed")&&setTimeout(()=>{location.href=Nn()},800)},"negative")])}wizard(t,o=!1,a){let r={id:t.id,name:t.name,endpoint:t.endpoint,port:t.port,subnet:t.subnet,preset:"standard",portal:!1,portal_port:t.portal_port||8443,lan_like:!0,lan_zone:t.lan_zone,wan_zone:t.wan_zone},i=0,s=e("div",{class:"dl-wizard"}),l=(_,j={})=>{let w=re(String(r[_]),j);return w.addEventListener("input",()=>{r[_]=_==="port"||_==="portal_port"?Number(w.value):w.value.trim()}),w},d={id:"server",title:"Server",render:()=>e("div",{class:"dl-wizard-groups"},[e("p",{class:"dl-muted"},"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),he("router","Server","What people see",[Z("Name",l("name"),"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[Z("Public address",l("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."},p={id:"awg",title:"AmneziaWG",render:()=>e("div",{class:"dl-wizard-groups"},[he("globe","Listening","Where devices reach AmneziaWG from the internet",[Z("UDP port",l("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),"Opened on the WAN firewall automatically. A random high port is fine.")]),he("network","Tunnel network","Addresses devices get inside the tunnel",[Z("Tunnel subnet",l("subnet",{class:"cbi-input-text dl-mono"}),`Must not overlap your networks (${t.taken.join(", ")||"none found"}).`)]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Gt(t.awg,r.preset,_=>r.preset=_,void 0,t.awg_state?.tools!==!1)])]),check:()=>!r.port||!r.subnet?"Fill in the UDP port and subnet.":null},c={id:"portal",title:"Portal",render:()=>{let _=l("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),j=Z("Listening port",_,"TCP port on WAN for the portal; the whole port belongs to it.");j.hidden=!r.portal;let w=xe([["off","Off"],["on","On"]],r.portal?"on":"off",{label:"Personal portal",onChange:I=>{r.portal=I==="on",j.hidden=!r.portal}});return e("div",{class:"dl-wizard-groups"},[he("home","Internet like a home device","How devices reach the internet",[Z("Through the home network",fe(r.lan_like,"Internet like a home device",I=>r.lan_like=I),"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",[Z("Portal",w,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),j])])}},m=()=>[d,p,o?null:c].filter(_=>_!=null),v=t.awg_state,h=v?.missing??[],x=h.length?e("div",{class:"dl-list dl-notices"},[tt("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${h.join(" and ")}. Install the build made for this firmware, then create the server.`,D("Install",()=>Xt(()=>location.reload()),"positive"))]):v&&!v.loaded?e("div",{class:"dl-list dl-notices"},[tt("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.",e("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",R=()=>{let _=m();i>=_.length&&(i=_.length-1),dom.content(s,[e("h2",{},o?"Add a server":"Set up Dawnline"),x,e("div",{class:"dl-steps"},_.map((j,w)=>e("span",{class:`dl-step${w===i?" current":w0?D("Back",()=>{i--,R()}):a?D("Cancel",a):"",e("span",{class:"dl-spacer"}),i<_.length-1?D("Next",()=>{let j=_[i].check?.();if(j){Q(j,"warning");return}i++,R()},"positive"):D("Create server",async()=>{for(let w of _){let I=w.check?.();if(I){Q(I,"warning");return}}let j=await U(()=>S.serverCreate(r.id,r.name,t.ifname,r.port,r.subnet,r.endpoint,t.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");j&&setTimeout(()=>{location.href=Nn(j.id)},1500)},"positive",{disabled:h.length>0,title:h.length?"Install AmneziaWG first":null})])])};return R(),s}};function Qe(n){let t={el:n(),refresh(){let o=n();t.el.replaceWith(o),t.el=o}};return t}function Me(n,t,o,a,r="",i=[]){return e("section",{class:`dl-setsec ${r}`,id:`dl-set-${n}`},[e("div",{class:"dl-setsec-body"},[i.length?e("div",{class:"dl-setsec-head"},[e("h3",{},t),e("span",{class:"dl-spacer"}),...i]):e("h3",{},t),...o]),a.length?e("div",{class:"dl-setsec-foot"},a):""])}function Oo(n){let t=n.filter(r=>r.status!=="skip"),o=t.filter(r=>r.status==="error"||r.status==="warn"),a=t.some(r=>r.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:a}}function jo(n){let t=n.d.settings,o=n.d.effective,a=n.d.cert,r=fe(o.portal_enabled,"Enable portal"),i=re(t.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=re(t.portal_title,{placeholder:"Dawnline"}),l=re(t.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),d=re("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),p=O=>/^\d{1,3}(\.\d{1,3}){3}$/.test(O),c=[o.portal_host,...o.portal_alt??[]].filter((O,F,me)=>O&&me.indexOf(O)===F),m=!!n.portal,v=[],h=O=>{O&&!v.some(F=>F.host===O)&&v.push({host:O,kind:p(O)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},x=O=>{v=[...O,...v.filter(F=>!O.some(me=>me.host===F.host))],!c.length&&O[0]&&(c=[O[0].host])};n.portal&&x(n.portal.candidates),c.forEach(h);let R=O=>O.kind==="ip"?e("span",{class:"dl-addr-warn"},[g("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):e("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`:m?"Your address":"Checking where it points…"),_=e("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),j=O=>{c.includes(O)?c.length>1&&(c=c.filter(F=>F!==O)):c=[...c,O],w(),C()},w=()=>dom.content(_,[...v.map(O=>{let F=c.includes(O.host),me=c[0]===O.host;return e("div",{class:`dl-addr-opt${F?" on":""}`,role:"checkbox","aria-checked":F?"true":"false",tabindex:"0",click:()=>j(O.host),keydown:ie=>{(ie.key===" "||ie.key==="Enter")&&(ie.preventDefault(),j(O.host))}},[e("i",{class:"dl-addr-check"},F?g("check"):""),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono"},O.host),R(O)]),me?e("span",{class:"dl-pill info"},"Main"):F?e("button",{type:"button",class:"dl-linkbtn",click:ie=>{ie.stopPropagation(),c=[O.host,...c.filter(ge=>ge!==O.host)],w(),C()}},"Make main"):O.cloudflare?e("span",{class:"dl-pill warn"},"Cloudflare"):O.kind==="ip"?e("span",{class:"dl-pill"},"IP"):O.here&&O.cert?e("span",{class:"dl-pill ok"},"Recommended"):""])}),e("div",{class:"dl-addr-opt other"},[e("i",{class:"dl-addr-check"},g("plus")),d,D("Add",()=>{let O=d.value.trim().toLowerCase();O&&(h(O),c.includes(O)||(c=[...c,O]),d.value="",w(),C())})])]);d.addEventListener("keydown",O=>{O.key==="Enter"&&(O.preventDefault(),d.nextElementSibling?.click())});let I=e("div",{class:"dl-links"}),C=()=>{let O=Number(i.value)||o.portal_port;dom.content(I,c.map((F,me)=>{let ie=p(F),ge=ie?O+1:O,M=`${ie?"http":"https"}://${F}${ge===(ie?80:443)?"":`:${ge}`}/`;return e("div",{class:"dl-link-row"},[e("span",{class:`dl-link-ic ${ie?"warn":"ok"}`},g(ie?"alert":"lock")),e("span",{class:"dl-mono dl-link-url"},[M,e("b",{},"kamiro-telosu-bavine")]),me===0?e("span",{class:"dl-pill info"},"Main"):ie?e("span",{class:"dl-pill warn"},"HTTP"):""])}))};w(),C(),i.addEventListener("input",()=>C());let T={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},b=n.d.needs??{https:[],acme:[],home:[]},A=O=>{if(!o.portal_enabled)return e("div",{hidden:!0});if(!O)return he("check","Ready to share","The portal’s checks from Health",[e("p",{class:"dl-muted dl-loading"},"Running checks…")]);let F=O.filter(E=>E.status!=="skip");if(!F.length)return e("div",{hidden:!0});let{bad:me,worst:ie}=Oo(O),ge=e("div",{class:"dl-ready-details",hidden:!0},F.map(E=>e("div",{class:`dl-ready-item ${E.status}`},[g(E.status==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("span",{},E.title),e("span",{class:"dl-sub"},E.detail)])]))),M=e("div",{class:"dl-stack gap8"},[e("div",{class:`dl-ready-sum ${ie}`},[g(ie==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("b",{},ie==="ok"?`All ${F.length} checks passed`:`${F.length-me.length} of ${F.length} checks passed`),me.length?e("span",{class:"dl-sub"},me.map(E=>E.detail).join(" ")):e("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),e("button",{type:"button",class:"dl-linkbtn",click:E=>{ge.hidden=!ge.hidden,E.currentTarget.textContent=ge.hidden?"Details":"Hide"}},"Details")]),e("div",{class:"dl-chips-row"},F.map(E=>e("span",{class:`dl-check-chip ${E.status}`,title:E.detail},[g(E.status==="ok"?"check":"alert"),T[E.id]??E.title]))),ge]);return he("check","Ready to share","The portal’s checks from Health",[M])},u=O=>{if(!o.portal_enabled||!O&&!b.https.length)return e("span",{hidden:!0});if(b.https.length)return e("span",{class:"dl-pill bad"},"Can’t start");let{worst:F}=Oo(O);return e("span",{class:`dl-pill ${F==="ok"?"ok":F==="error"?"bad":"warn"}`},F==="error"?"Needs attention":"Ready")},f=A(n.portal?.checks??null),N=u(n.portal?.checks??null);n.portalFill=O=>{m=!0,x(O.candidates),w(),C();let F=A(O.checks);f.replaceWith(F),f=F;let me=u(O.checks);N.replaceWith(me),N=me};let P=a&&!a.self_signed&&a.expires?Ae(a.expires):"",H=Z("Listening port",i,n.d.port_owners.length?`Port ${o.portal_port} is used by ${n.d.port_owners.join(", ")}.`:`Where the portal runs on the router: HTTPS here, plain HTTP for IP addresses on ${o.portal_port+1}.`),J=!!(t.portal_cert&&t.portal_key),W=a?J?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",te=()=>{let O=re(t.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),F=re(t.portal_key,{placeholder:"/etc/ssl/…/key"});ae("Use your own certificate",[e("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),Z("Certificate file",O),Z("Key file",F)],[se()," ",D("Save",()=>{le(),n.save({portal_cert:O.value.trim(),portal_key:F.value.trim()},"Certificate saved","portal")},"positive")])},$=(O,F,me,ie,ge,M)=>tt(O,F,me,ie,D(M,()=>Pt(ge,b[ge],()=>n.reload("portal")),"positive")),G=b.https.length?$("lock","bad","HTTPS isn’t available on this router",`The portal needs ${b.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",q=b.acme.length&&(!a||a.self_signed)?$("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${t.portal_host?` for ${t.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",oe=[e("div",{class:"dl-row"},[g("lock"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},[W,P?e("span",{class:"dl-faint"},` · until ${P}`):""]),e("span",{class:"dl-sub dl-ellipsis",title:a?.path??""},a?a.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${J?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),e("div",{class:"dl-row"},[g("file"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Your own files"),e("span",{class:"dl-sub"},J?`${t.portal_cert} · ${t.portal_key}`:"Not set: the certificate is picked automatically.")]),J?D("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",D(J?"Change":"Use files",te)]),q];return Me("portal","Personal portal",[e("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),G?e("div",{class:"dl-list"},[G]):"",he("network","Port","How the portal listens (80 and 443 stay free)",[H]),he("edit","Appearance","What people see",[Z("Title",s,"Shown at the top of the portal."),Z("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",[_,e("div",{class:"dl-stack gap8"},[I,e("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),he("lock","Certificate","Used for HTTPS links",oe),f],[e("span"),D("Save",()=>n.save({portal_enabled:Ee(r)?"1":"0",portal_host:c[0]??"",portal_alt:c.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:l.value.trim()},"Saved","portal"),"positive")],"",[N,r])}function Uo(n){let t=n.d.settings,o=n.d.effective,a=re(t.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),r=fe(o.hostnames,"Device hostnames"),i=re(t.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=re(t.home_dns_fallback==="none"?"":t.home_dns_fallback||o.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"});return Me("defaults","Defaults",[Z("Devices per person",a,"Pre-filled when you add someone."),Z("Device hostnames",e("div",{class:"dl-hostport"},[r,e("span",{class:"dl-faint dl-mono"},"phone.myata."),i]),"Name devices in your home DNS."),Z("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.")],[e("span"),D("Save",()=>n.save({default_device_limit:a.value,hostnames:Ee(r)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults"),"positive")])}function Wo(n){let t=n.d.effective,o=fe(t.geo_enabled,"Locations"),a=e("select",{class:"cbi-input-select"},[e("option",{value:"ipwho.is",selected:t.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),e("option",{value:"ipapi.co",selected:t.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Me("map","Map & locations",[e("div",{class:"dl-setrow head"},[e("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),o]),Z("Provider",a)],[e("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),D("Save",()=>n.save({geo_enabled:Ee(o)?"1":"0",geo_provider:a.value},"Saved","map"),"positive")])}var ti=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function Go(n){let t=n.d.effective.updates,o=fe(t.check,"Check automatically",x=>h(x,Ee(r))),a=xe([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],t.interval,{label:"How often",cls:"sm"}),r=fe(t.auto,"Install automatically",x=>h(Ee(o),x)),i=re(t.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"]],t.mode,{label:"When",cls:"sm",onChange:x=>i.hidden=x!=="scheduled"});i.hidden=t.mode!=="scheduled";let l=new Set(t.targets),d=e("div",{class:"dl-chips-row"},ti.map(([x,R])=>{let _=Ue(R,l.has(x),()=>{l.delete(x)||l.add(x),Wt(_,l.has(x))});return _})),p=fe(t.keep,"Keep the previous version"),c=fe(t.mirrors,"GitHub mirrors"),m=Z("How often",a),v=[Z("When",e("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),Z("Components",d,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],h=(x,R)=>{m.hidden=!x;for(let _ of v)_.hidden=!R};return h(t.check,t.auto),Me("updates","Updates",[e("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),Z("Check automatically",o,"Looks for new versions in the background; Components shows what it found and the service log names it."),m,Z("Install automatically",r,"Downloads and installs new versions of the components below."),...v,Z("Keep the previous version",p,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),Z("GitHub mirrors",c,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[e("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),D("Save",()=>n.save({update_check:Ee(o)?"1":"0",update_interval:a.dataset.value,update_auto:Ee(r)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Ee(p)?"1":"0",update_mirrors:Ee(c)?"1":"0"},"Saved","updates"),"positive")])}function qo(n){let t=n.d.logs,o=t.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"}),d=new Set(o.categories),p=e("div",{class:"dl-chips-row"},pt.map(h=>{let x=Ue([nt[h],e("b",{},String(t.by_category[h]??0))],d.has(h),()=>{d.delete(h)||d.add(h),Wt(x,d.has(h))},{title:no[h]});return x})),c=t.oldest?Ae(new Date(t.oldest*1e3)):"",m=(h,x,R,_)=>e("div",{class:"dl-row"},[g(h),e("span",{class:"dl-row-main dl-stack"},[e("b",{},x),e("span",{class:"dl-sub"},R)]),..._]),v=h=>D(h.toUpperCase(),async()=>{let[x,R]=await Promise.all([S.status(1),S.events(2e4)]);je(x,R.events,h)},"neutral",{title:`Download the log as ${h.toUpperCase()}`});return Me("logs","Logs & history",[e("p",{class:"dl-muted"},Ut(o)),Z("Keep activity",a,"Older events are removed automatically."),Z("Maximum size",r,"Newest events are kept when the log is full."),Z("Record",p,"Switched-off categories are not logged from now on."),Z("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),Z("Daily traffic",s,"Per-day history behind the charts."),Z("Monthly traffic",l,"Per-month totals; data limits use the current month."),e("h4",{class:"dl-setsub"},"Stored data"),e("div",{class:"dl-list"},[m("activity","Activity log",t.events?`${Rt(t.events,"event")} since ${c} · ${yt(t.log_ram)} in memory${o.persist==="off"?"":`, ${yt(t.log_flash)} on flash`}`:"Empty",[v("csv"),v("json"),D("Clear",()=>Fe("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),m("chart","Traffic history",t.usage_days?`${Rt(t.usage_days,"day")} since ${Ae(t.usage_since)} · ${yt(t.usage_flash)} on flash`:"Empty",[D("Reset",()=>ut("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),m("pin","Location cache",`${Rt(n.d.geo_cached,"address","addresses")} · ${yt(t.geo_flash)} on flash`,[D("Clear",async()=>{await U(()=>S.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[e("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:[...d]},"Saved","logs"),"positive")])}var ni={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},Fo=3;function Rn(n){let t=new Date(n*1e3),o=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),a=Math.round((new Date(new Date().toDateString()).getTime()-new Date(t.toDateString()).getTime())/864e5);return`${a===0?"Today":a===1?"Yesterday":t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${o}`}async function oi(n){let t=await U(()=>S.backupRead(n.name));if(!t)return;let o=atob(t.data),a=new Uint8Array(o.length);for(let i=0;ioi(n),"neutral","dl-icon-only"),ye("more","More",o=>we(o.currentTarget,[{label:"Restore",icon:g("reset"),run:async()=>{await ne("Restore this backup?",`Everything returns to ${Rn(n.created)}. The current state is backed up first.`,"Restore",!0)&&await U(()=>S.backupRestore(n.name),"Restored")&&t(!0)}},{label:"Delete",icon:g("trash"),danger:!0,run:async()=>{await ne("Delete this backup?",`The backup from ${Rn(n.created)} is removed from the router.`,"Delete",!0)&&await U(()=>S.backupDelete(n.name),"Backup deleted")&&t()}}]),"neutral","dl-icon-only")])])}function Jo(n,t){let o=n.slice(0,Fo).map(d=>Ko(d,t)),a=n.slice(Fo),r=n.length?e("div",{class:"dl-list"},[...o,a.length?e("details",{class:"dl-bk-older"},[e("summary",{},[g("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(d=>Ko(d,t))]):""]):e("div",{class:"dl-list"},[e("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=D("Restore from file",async()=>{let d=await wn(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await ne("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await U(()=>S.backupUpload(d.data),"Restored")&&t(!0)}),s=D("Export JSON",async()=>{let d=await U(()=>S.exportJson());d&&$e(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=D("Import JSON",async()=>{let d=await wn(".json,application/json","text");if(!d)return;let p;try{p=JSON.parse(d.data)}catch{Q("Not a JSON file.","error");return}await ne("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await U(()=>S.importJson(p),"Imported")&&t(!0)});return e("section",{class:"dl-setsec",id:"dl-set-backups"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-setsec-head"},[e("div",{class:"dl-stack"},[e("h3",{},"Backups"),e("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),e("span",{class:"dl-spacer"}),D([g("plus")," Back up now"],async()=>{await U(()=>S.backupCreate(),"Backup created")&&t()},"positive")]),r]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),e("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function ai(){let n=re("",{placeholder:"remove"});ae("Remove Dawnline?",[e("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[se()," ",D("Remove Dawnline",async()=>{await U(()=>S.uninstall(n.value.trim()),"Dawnline removed")&&(le(),setTimeout(()=>location.reload(),800))},"negative")])}function Vo(){return Me("danger","Remove Dawnline from this router",[e("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[e("span"),D("Remove",()=>ai(),"negative")],"danger")}var ln=class{constructor(){this.root=e("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return S.settingsGet()}render(t){this.d=t,this.cards={portal:Qe(()=>jo(this)),defaults:Qe(()=>Uo(this)),map:Qe(()=>Wo(this)),updates:Qe(()=>Go(this)),logs:Qe(()=>qo(this)),backups:Qe(()=>Jo(this.backups,r=>this.loadBackups(r))),danger:Qe(()=>Vo())};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"})),e("div",{},[e("div",{class:"dl-pagehead"},[e("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(t,o,a){let r=await U(()=>S.settingsUpdate(t),o);r&&(this.d=r,this.cards[a].refresh(),a==="portal"&&this.loadPortal())}async loadPortal(){let t=++this.portalSeq,o=await S.portalInfo().catch(()=>null);t===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(t=!1){t&&await this.reload();let o=await S.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(t){let o=await S.settingsGet().catch(()=>null);if(o){if(this.d=o,t)this.cards[t].refresh();else for(let a of Object.values(this.cards))a.refresh();(!t||t==="portal")&&this.loadPortal()}}};function Yo(n,t=!1){return n&&(t?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function Qo(n){let t=[],o=l=>{let d=[],p=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,c=0;for(let m;m=p.exec(l);)m.index>c&&d.push(l.slice(c,m.index)),m[1]?d.push(e("code",{},m[1].slice(1,-1))):m[2]?d.push(e("b",{},m[2].slice(2,-2))):m[3]?d.push(e("a",{href:m[4],target:"_blank",rel:"noopener"},m[3].replace(/^\[|\]\(.*$/g,""))):m[5]&&d.push(e("a",{href:m[5],target:"_blank",rel:"noopener"},m[5].replace(/^https?:\/\/(github\.com\/)?/,""))),c=m.index+m[0].length;return c{r.length&&t.push(e("p",{},o(r.join(" ")))),r=[],a=null};for(let l of n.replace(/\r/g,"").split(` `)){let d=l.trimEnd();if(i){/^```/.test(d.trim())?(t.push(e("pre",{},i.join(` `))),i=null):i.push(l);continue}if(/^```/.test(d.trim())){s(),i=[];continue}let p=/^(#{1,6})\s+(.*)$/.exec(d),c=/^\s*[-*+]\s+(.*)$/.exec(d)??/^\s*\d+[.)]\s+(.*)$/.exec(d);p?(s(),t.push(e("h5",{},o(p[2])))):c?(r.length&&s(),a||(a=e("ul",{}),t.push(a)),a.appendChild(e("li",{},o(c[1])))):d.trim()?(a&&(a=null),r.push(d.trim())):s()}return i&&t.push(e("pre",{},i.join(` -`))),s(),t}function Jo(n){let t=[],o=!1;for(let a of n.replace(/\r/g,"").split(` +`))),s(),t}function Zo(n){let t=[],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||t.push(a)}return t.join(` `).replace(/\n{3,}/g,` -`).trim()}async function zt(n,t,o,a){let r=e("div",{class:"dl-notes"},e("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=e("div",{class:"dl-op-head"}),s="";oe(o,[i,r],[D([g("copy")," Copy"],()=>pe(s,"Release notes copied"))," ",ie("Close")],"wide");try{let l=await E.updatesNotes(n,t,a??"");s=Jo(l.body||"");let d=Fo(l.url);dom.content(i,[l.published?e("span",{class:"dl-pill"},Ae(l.published)):"",l.prerelease?e("span",{class:"dl-pill warn"},"Pre-release"):"",e("span",{class:"dl-spacer"}),d?e("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",g("open")]):""]),dom.content(r,s.trim()?Ko(s):e("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(r,e("p",{class:"dl-muted"},ve(l)))}}var Vo={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},zn=n=>n?Ae(n):"";function Xr(n){let t=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return t||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function Qo(n,t){let o=n.st,a=o.policy,r=o.kept?.app,i=t?.update&&t.tag?t.tag:o.version,s=v=>()=>zt("app",v,`What’s new in Dawnline ${v.replace(/^v/,"")}`),l=t?.tag&&(t.update||t.status==="latest")?ei(n,t.tag,t.update?o.version:""):null,d=t?.tag??i,p=a.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[a.interval]??24)*3600:0,c=(v,h)=>e("div",{class:"dl-stack gap4"},[e("span",{class:"dl-metric-label"},v),e("span",{class:"dl-comp-side-v"},h)]),m=[{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 ne(`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 e("section",{class:"dl-panel flush dl-comp-hero"},[e("div",{class:"dl-comp-hero-main"},[e("div",{class:"dl-comp-hero-head"},[e("span",{class:"dl-group-ic"},g("sunrise")),e("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",t,t?.latest??""),e("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),m,!0)]),e("div",{class:"dl-comp-verrow"},[e("div",{class:"dl-stack"},[e("div",{class:"dl-comp-big"},[o.version,t?.update?e("small",{},`→ ${t.latest}`):t?.status==="dev"&&t.latest?e("small",{class:"dl-faint"},`release ${t.latest}`):""]),e("span",{class:"dl-faint dl-comp-meta"},t?.error?"":t?.update?t.published?`released ${zn(t.published)}`:"":t?.status==="dev"?"ahead of the latest release":t?`latest release${t.published?` · released ${zn(t.published)}`:""}`:"not checked yet")])]),l?.items.length?e("div",{class:"dl-stack gap4"},[e("ul",{class:"dl-comp-bullets"},l.items.map(v=>e("li",{},v))),l.total>l.items.length?e("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(d)},`+${l.total-l.items.length} more in What’s new`):""]):"",t?.error?e("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},t.error):"",t?.update?e("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))]):"",ti(n)]),e("div",{class:"dl-comp-hero-side"},[c("Source",[g("globe"),e("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),c("Auto-update",[a.auto?ke("ok","On"):ke("","Off"),e("span",{class:"dl-muted"},a.auto?a.mode==="immediate"?"as soon as found":`${Vo[a.interval]==="weekly"?"weekly":"daily"} at ${a.time}`:a.check?`checks ${Vo[a.interval]}`:"checks off")]),c("Last check",o.check?[le(o.check.time,o.now),p>o.now?e("span",{class:"dl-faint"},`· next in ${st(p-o.now)}`):""]:["Never"]),c("Rollback",r?[e("span",{class:"dl-mono"},r.version),e("span",{class:"dl-faint"},"kept on flash")]:[e("span",{class:"dl-muted"},a.keep?"Kept after the next update":"Off")])])])}function ei(n,t,o){if(n.notes.has(t))return n.notes.get(t)??null;n.notes.set(t,null);let a=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await E.updatesNotes("app",t,"").catch(()=>null))?.body??"").split(` -`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await E.updatesChanges(o,t).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>Xr(a(l))),total:i.length};n.notes.set(t,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function ti(n){let t=e("div",{class:"dl-params-body"}),o=e("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[e("summary",{},[g("chevron"),e("span",{},"Versions"),e("span",{class:"dl-sub"},"install any release")]),t]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&sn(n,t)}),n.versOpen&&sn(n,t),o}async function sn(n,t){let o=ae("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),a=c=>{if(c=c.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(c))return Z("Enter a release tag like 0.3.1","warning");Yo(n,c)};o.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),a(o.value))});let r=e("div",{class:"dl-comp-tag"},[o,D("Install",()=>a(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=c=>{n.versPage=Math.max(1,n.versPage+c),sn(n,t)},l=c=>e("div",{class:"dl-comp-pager"},[e("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),e("span",{class:"dl-faint"},`Page ${i}`),e("button",{type:"button",class:"dl-linkbtn",disabled:c?null:"disabled",click:()=>s(1)},"Older →")]),d=n.versCache.get(i);if(!d){dom.content(t,[r,e("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{d=(await E.updatesReleases(i)).releases}catch(c){if(i!==n.versPage||!t.isConnected)return;dom.content(t,[r,e("div",{class:"dl-row-actions"},[e("span",{class:"dl-muted"},`Failed to load versions: ${ve(c)}`),D("Try again",()=>sn(n,t))]),l(!1)]);return}if(n.versCache.set(i,d),i!==n.versPage||!t.isConnected)return}if(!d.length)return dom.content(t,[r,e("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let p=n.st.version;dom.content(t,[r,...d.map(c=>{let m=c.tag.replace(/^v/,"");return e("div",{class:"dl-comp-ver"},[e("span",{class:"dl-mono"},m),e("span",{class:"dl-sub"},zn(c.published)),c.prerelease?ke("warn","Pre-release"):"",e("span",{class:"dl-comp-ic"},ye("file","What’s new",()=>zt("app",c.tag,`What’s new in Dawnline ${m}`))),m===p?ke("ok","Installed"):D("Install",()=>Yo(n,c.tag),"neutral",{disabled:n.busy})])}),l(d.length>=5)])}async function Yo(n,t){let o=t.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await ne(`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@${t}`,`Installing Dawnline ${o}`,n.st.version)}function Zo(n,t){let o=n.st,a=o.kept?.amneziawg,r=t?.sources??{},i=Object.keys(r),s=t?.current??null,l=s?r[s]:void 0,d=!!t?.ru,p=o.needs?.awg??[],c=p.length?null:t?.installed??null,m=[];s&&c&&m.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Reinstalling AmneziaWG",c)}),a&&m.push({label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await ne(`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",c??void 0)}});let v=[t?.release?{label:"What’s new",ic:"file",run:()=>zt("amneziawg",t.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")},...m.length?[null,...m]:[]].filter((u,f,N)=>u!==null||f>0&&N[f-1]!==null),h=o.tunnels??[],x=h.length?`Switching restarts ${h.length===1?"the tunnel":`${h.length} tunnels`} for a few seconds: ${h.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",R=h.length>1?`${h.slice(0,-1).join(", ")} and ${h[h.length-1]}`:h[0],$=h.length?`Switching restarts ${R} for a few seconds.`:"Switching takes a few seconds.",j=async u=>{let f=r[u];await ne(c?`Switch to AmneziaWG ${f.gen}?`:`Install AmneziaWG ${f.gen}?`,`The ${f.label} build, ${f.version}. ${x}${f.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,c?"Switch":"Install")&&n.op(`amneziawg:${u}${d?":ru":""}`,c?`Switching to AmneziaWG ${f.gen}`:"Installing AmneziaWG",c??void 0)},w=u=>{let f=r[u],N=s===u&&!!c;return e("div",{class:"dl-row"},[e("span",{class:"dl-row-main dl-stack"},[e("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),e("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),e("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??"none yet"),e("span",{class:"dl-comp-bact"},N?ke("ok","Active"):f.version?D(c?"Switch":"Install",()=>j(u),c?"neutral":"positive",{disabled:n.busy}):ke("","No build"))])},H=i.map(u=>r[u]?.newer?`${r[u].label} moves to ${r[u].newer.gen} with OpenWrt ${r[u].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),S=fe(d,"Russian translation",u=>{s&&n.op(`amneziawg:${s}${u?":ru":""}`,u?"Adding the Russian translation":"Removing the Russian translation",c??void 0)});S.disabled=!s||!c||n.busy;let T=n.awgOpen??!c,b=e("details",{class:"dl-params dl-comp-fold",open:T?"open":null},[e("summary",{},[g("chevron"),e("span",{},"Build and translation")]),e("div",{class:"dl-params-body"},[e("div",{class:"dl-list"},[...i.length?i.map(w):[e("div",{class:"dl-row"},e("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],e("div",{class:"dl-row"},[e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Russian translation"),e("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),e("span",{class:"dl-comp-bact"},S)])]),c&&i.length||H.length?e("div",{class:`dl-comp-status ${c&&i.length?"warn":"acc"}`},[g(c&&i.length?"alert":"download"),e("span",{},[c&&i.length?e("b",{},$):"",...H.map(u=>` ${u}`)])]):""])]);b.addEventListener("toggle",()=>n.awgOpen=b.open);let A=[];return t?.update&&c&&s?A.push(D(`Update to ${t.latest}`,()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Updating AmneziaWG",c),"neutral",{disabled:n.busy})):A.push((t||p.length)&&!c?ke("warn","Not installed"):n.state("amneziawg",t,t?.latest??"")),A.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",c??void 0),v)),[n.row("shield","AmneziaWG",[c?`${c}${t?.release?` · ${t.release} build`:""}`:p.length?`missing ${p.join(", ")}`:t?"not installed":"version not checked"],A),e("div",{class:"dl-comp-foldwrap"},b)]}var ni=[{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}],Nn={home:"network",https:"lock",acme:"file"};function Xo(n,t){let o=n.st,a=t?.pkgs??{},r=ni.filter(p=>p.feature==="home"?o.home:o.portal),i=async(p,c,m=p)=>{await ne(`Update ${c}?`,`${m.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${p.join(",")}`,`Updating ${c}`)},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(p=>{let c=p.pkgs.filter(R=>a[R]?.installed),m=[...new Set(c.flatMap(R=>[...a[R]?.latest?[R]:[],...a[R]?.with??[]]))],v=o.needs?.[p.feature]??p.pkgs.filter(R=>!a[R]?.installed),h=c.find(R=>a[R]?.latest),x=c.map(R=>`${R} ${a[R]?.installed??""}`).join(", ");return v.length?n.row(Nn[p.feature],p.title,[`${p.optional?"not installed":`missing ${v.join(", ")}`}`],[D("Install",()=>n.op(`pkgs:${v.join(",")}`,`Installing ${p.title}`),p.optional?"neutral":"positive",{disabled:n.busy}),e("span",{class:"dl-comp-ic"},n.more(s))]):t&&m.length?(l++,n.row(Nn[p.feature],p.title,h?[`${a[h].installed} → ${a[h].latest}`,m.length>1?` · +${m.length-1}`:""]:[m.join(", ")],[D("Update",()=>i(c.filter(R=>a[R]?.latest||a[R]?.with?.length),p.title,m),"neutral",{disabled:n.busy}),e("span",{class:"dl-comp-ic"},n.more(s))])):n.row(Nn[p.feature],p.title,[x||p.sub],[n.state("pkgs",t,""),e("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:r.length}}var oi={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function ea(n){let t=n.st,o=r=>{let i=Ve(r.component??"app"),s=oi[i]??"Components",l=r.auto?"automatically":"by you",d="ok",p="check",c;if(r.kind==="found")d="accent",p="download",c=[e("b",{},(r.items??[]).join(", ")),` found by ${r.auto?"the automatic check":"a check"}`];else if(r.state==="failed")d="bad",p="x",c=[e("b",{},s),` ${r.kind==="install"?"update":"check"} failed${r.error?` · ${r.error}`:""}`];else{let m=r.from&&r.to&&r.from!==r.to?` ${r.from} → ${r.to}`:r.to?` ${r.to}`:"";c=[e("b",{},s),`${m} ${m?"":"updated "}${l}${r.took?` · ${st(r.took)}`:""}`.replace(/\s+/g," ")]}return e("div",{class:"dl-row"},[e("span",{class:`dl-ev-tile ev ${d}`},g(p)),e("span",{class:"dl-row-main"},c),e("span",{class:"dl-faint dl-nowrap",title:new Date(r.ts*1e3).toLocaleString()},le(r.ts,t.now))])},a=t.history??[];return e("section",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-spacer"}),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),a.length?e("div",{},a.slice(0,8).map(o)):e("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var ln=class{constructor(){this.root=e("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 E.updatesStatus()}render(t){return this.st=t,this.paint(),t.job?.state==="running"&&this.follow(t.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await E.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(t){this.st=t??await E.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(t,o,a){if(this.busy||this.following==="starting"){Z("Another component action is already running","warning");return}this.following="starting",this.paint();let r=Ve(t),i=await Mt(t,{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(t){this.following=t.id;let o=Yt(t),a={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[o]??"components";await Mt(null,{title:`${t.action==="check"?"Checking":t.auto?"Automatic update:":"Updating"} ${a}`,onDone:r=>this.refresh(r)},t)}paint(){let t=this.st,o=t.check?.components??{},a=t.firmware,r=Xo(this,o.packages),i=(t.needs?.awg??[]).length>0,l=(!i&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+r.updates;dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Components"),e("span",{class:"dl-faint"},[a?.version?`OpenWrt ${a.version} · ${a.target}`:"",t.check?`checked ${le(t.check.time,t.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),e("div",{class:"dl-row-actions"},[e("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[g("edit")," Settings"]),D([g("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),Qo(this,o.app),e("div",{class:"dl-comp-cols"},[e("section",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Components"),e("span",{class:"dl-spacer"}),e("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")]),e("div",{},[...Zo(this,o.amneziawg),...r.rows])]),ea(this)])])}state(t,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(Ve(l)));if(s.includes(t)||s.includes("all"))return e("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?ke("warn","Check failed",o.error):o.update?ke("info","Update available"):o.status==="dev"?ke("info","Newer than release",`The latest release is ${a}`):ke("ok","Up to date"):ke("","Not checked")}more(t){let o=D([g("more")],()=>we(o,t.filter((a,r,i)=>a!==null||r>0&&ra?{label:a.label,icon:g(a.ic),warn:a.warn,run:a.run}:null)),"neutral",{title:"More","aria-label":"More"});return o}round(t,o,a=!1){let r=this.busy?" is-busy":"",i;return a?i=D([g("refresh")," Check"],t,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${r}`,"aria-label":"Check for updates"}):(i=ye("refresh","Check for updates",t,"neutral",r.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),ue(i,()=>["Check for updates"])),e("span",{class:"dl-comp-ic"},[i,this.more(o)])}row(t,o,a,r){return e("div",{class:"dl-row"},[e("span",{class:"dl-group-ic"},g(t)),e("span",{class:"dl-row-main dl-stack"},[e("b",{},o),e("span",{class:"dl-mono dl-faint dl-comp-sub"},a)]),...r])}};var ta=(n,t)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},n),e("div",{class:"cbi-value-field"},t)]);function na(n){let t=n.st.servers.find(o=>o.id===n.p.server)?.name??"Home";Lt(n.p,t)}async function oa(n){let t=n.p;if(!await ne("Create a new link?","The old link stops working right away.","Create new link",!0))return;let o=await U(()=>E.personRegen(t.id),"New link created");o?.link&&await pe(o.link,"New link copied")}function Rn(n){let t=e("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");oe("Note",[t],[ie()," ",D("Save",async()=>{se(),await n.patch({note:t.value.trim()},t.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>t.focus(),50)}function aa(n){let t=n.p,o=e("select",{class:"cbi-input-select"},[e("option",{value:"pause",selected:t.expire_action==="pause"?"selected":null},"Pause access"),e("option",{value:"notify",selected:t.expire_action==="notify"?"selected":null},"Keep access"),e("option",{value:"remove",selected:t.expire_action==="remove"?"selected":null},"Remove their devices")]),a=e("select",{class:"cbi-input-select"},[0,1,3,7,14].map(r=>e("option",{value:r,selected:t.expire_warn===r?"selected":null},r?`${r} day${r===1?"":"s"} before`:"Don’t warn")));oe("When access ends",[ta("Then",o),e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Warn"),e("div",{class:"cbi-value-field"},[a,e("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[ie()," ",D("Save",async()=>{se(),await n.patch({expire_action:o.value,expire_warn:a.value},"Saved")},"positive")])}function ra(n){let t=e("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48});oe("Rename",[ta("Name",t)],[ie()," ",D("Save",async()=>{se(),await n.patch({name:t.value},"Renamed")},"positive")]),setTimeout(()=>t.select(),50)}async function ia(n){let t=n.p;await ne(`Delete ${t.name}?`,`All ${t.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await U(()=>E.personDelete(t.id),"Deleted")&&(location.href=ht(t.server))}function sa(n){let t=n.p,o=n.st,a=t.online?"online now":t.last_seen?`last seen ${le(t.last_seen,o.now)}`:"never connected",r=t.created?`Added ${ze(De(new Date(t.created*1e3)))}`:"",i=t.has_link??o.settings.portal_enabled,s=[{label:"Rename",icon:g("edit"),run:()=>ra(n)},{label:t.note?"Edit note":"Add note",icon:g("file"),run:()=>Rn(n)},...i?[null,{label:"Invite card",icon:g("qr"),run:()=>na(n)},{label:"New link",icon:g("key"),run:()=>oa(n)}]:[],null,{label:t.paused?"Resume":"Pause",icon:g(t.paused?"play":"pause"),warn:!t.paused,run:()=>n.patch({paused:!t.paused},t.paused?"Resumed":"Paused")},{label:"Delete",icon:g("trash"),danger:!0,run:()=>ia(n)}];return e("div",{class:"dl-person-head"},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-person-id"},[e("span",{class:`dl-avatar lg${t.online?" online":""}`},Oe(t.name)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),It(t)]),e("span",{class:"dl-faint",title:r},`${t.devices.length} of ${t.device_limit} devices · ${a}`)])]),e("div",{class:"dl-pcard-actions"},[i?ye("link","Copy link",()=>Ft(t.id),"neutral","dl-icon-only"):"",ye("more","More",l=>we(l.currentTarget,s),"neutral","dl-icon-only")])]),t.note?e("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>Rn(n)},[g("file"),e("span",{},t.note)]):""])}function la(n){let t=n.p,o=n.series[n.series.length-1];return e("div",{class:`dl-person-live${t.online?"":" solo"}`},[t.online?tn(t.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",nn(n.series,`${te(t.month[0]+t.month[1])} this month`)])}async function ai(n,t){let o=await U(()=>E.deviceConfig(t.id));o&&oe(`Set up ${t.name}`,[await n.core.connectBlock(o,"qr")],[ie("Close")])}async function ri(n,t){let o=await U(()=>E.deviceConfig(t.id));if(!o)return;if(!o.has_private_key){Z("This device made its own keys in the browser; its configuration only exists there.","warning");return}let a=n.core.file.make(o);$e(a.name,a.text,"application/octet-stream")}function da(n){let t=n.p,o=n.st.now,a=d=>He(t,d,n.deviceOpts()),r=d=>p=>{p.target.closest("button:not(.dl-dcard-title), a")||a(d)},i=d=>D([g("more")],p=>mo(p.currentTarget,t,d,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=Ht(t.devices).map(d=>{let p=e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},g(d.kind)),e("button",{type:"button",class:"dl-dcard-title",click:()=>a(d)},[e("b",{},d.name),Bt(d,o),d.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(d)]),c=e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},te(d.month[0]+d.month[1])),e("span",{class:"dl-sub"},"this month")]),Do(n.devSeries[d.id]??[])]);return e("article",{class:`dl-dcard clickable${d.online?" online":""}${d.disabled?" off":""}`,click:r(d)},[p,d.handshake?c:d.disabled?e("div",{class:"dl-sub"},`${Be[d.kind]} · created ${le(d.created,o)} ${d.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>ai(n,d)},[g("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>ri(n,d)},[g("download"),"Config"])])])}),l=t.devices.length>=t.device_limit;return s.push(e("button",{type:"button",class:"dl-dslot add",click:()=>ot(t,n.deviceOpts())},[e("span",{class:"dl-dslot-ic"},g("plus")),e("span",{class:"dl-stack"},[e("b",{},"Add device"),e("span",{class:"dl-sub"},l?`Over the limit · ${t.devices.length} of ${t.device_limit}`:`${t.devices.length} of ${t.device_limit}`)])])),e("section",{class:"dl-devsec"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Devices"),e("span",{class:"dl-sub"},`${t.online} online`)]),e("div",{class:"dl-dgrid"},s)])}function ca(n){let t=n.p,o=xe([["device","Device’s own DNS"],["home","Home names"]],t.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 e("div",{class:"dl-stack gap4 dl-dnspick"},[e("div",{class:"dl-row-actions"},[e("span",{class:"dl-sub"},"DNS"),o]),e("span",{class:"dl-sub"},t.dns_mode==="home"?["Names like ",e("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",a?[" (",e("span",{class:"dl-mono"},a)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}function pa(n){let t=n.p,a=n.st.servers.find(i=>i.id===t.server)?.home??[];if(a.length<2)return"";let r=new Set(t.home_nets?.length?t.home_nets:a.map(i=>i.dev));return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},a.map(i=>Ue(i.dev,r.has(i.dev),()=>{let s=new Set(r);if(s.delete(i.dev)||s.add(i.dev),!s.size)return Z("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?`${t.name} reaches ${l.join(", ")}`:`${t.name} reaches every home network`)},{title:i.nets.join(", ")}))),e("span",{class:"dl-sub"},t.home_nets?.length?`Home networks ${t.name} reaches. Networks added to the server later stay out.`:`Home networks ${t.name} reaches: all of them. Untick one to keep ${t.name} out of it.`)])}function ua(n){let t=new Set(n.p.services??[]);return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},n.st.services.map(o=>Ue(o.name,t.has(o.id),()=>{let a=new Set(t);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(", ")}`:""}`}))),e("span",{class:"dl-sub"},t.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function ma(n){let t=n.p,o=n.st;if(o.servers.find(p=>p.id===t.server)?.mesh!=="circles"||!Je(t))return"";let r=o.circles.filter(p=>p.server===t.server),i=r.find(p=>p.id===t.circle),s=i?o.people.filter(p=>p.id!==t.id&&p.circle===i.id&&Je(p)).map(p=>p.name):[],l=e("button",{type:"button",class:"dl-chipbtn",click:()=>we(l,[...r.map(p=>({label:p.name,icon:Ln(p),run:()=>p.id!==t.circle&&n.patch({circle:p.id},`${t.name} is in ${p.name}`)})),t.circle?{label:"No circle",icon:g("x"),run:()=>n.patch({circle:""},`${t.name} is in no circle`)}:null,{label:"New circle",icon:g("plus"),run:()=>Jt(o,t.server,null,()=>n.refresh())}])},"Change"),d=i?o.people.filter(p=>p.circle===i.id&&Je(p)):[t];return e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Devices see each other"),l]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},i?i.name:"No circle"),e("span",{class:"dl-avstack",title:d.map(p=>p.name).join(", ")},d.slice(0,5).map(p=>e("span",{class:"dl-avatar sm"},Oe(p.name))))]),e("span",{class:"dl-sub"},i?s.length?[t.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${t.name}'s own devices`)])}function ha(n){let t=n.p,o=n.st.now,a=e("div",{class:"dl-slots"});for(let s=0;s=t.device_limit,p=e("i",{class:d?"over":l?"used":""});ue(p,()=>[e("div",{class:"dl-tip-title"},l?`${l.name}${d?" · over the limit":""}`:"Free slot"),e("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${le(l.handshake,o)}`:"Not set up yet":"They can add a device here")]),a.appendChild(p)}let r=Math.max(1,t.devices.length),i=e("button",{type:"button","aria-label":"Allow fewer devices",disabled:t.device_limit<=r?"disabled":null,click:()=>n.patch({device_limit:String(t.device_limit-1)})},"−");return t.device_limit<=r&&t.devices.length>1&&ue(i,()=>[e("div",{class:"dl-tip-title"},`${t.devices.length} devices in use`),e("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},"Devices"),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[String(t.devices.length),e("span",{class:"dl-faint"},` / ${t.device_limit}`)]),e("div",{class:"dl-stepper"},[i,e("button",{type:"button","aria-label":"Allow more devices",disabled:t.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(t.device_limit+1)})},"+")])]),a])}var ii={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."},fa=/^([01]\d|2[0-3]):[0-5]\d$/;function si(n){let t=n.p,o=n.today,a=Xe(t.expires,o),r=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});r.addEventListener("change",()=>r.value&&n.patch({expires:r.value},`Access until ${ze(r.value)}`));let i=(p,c)=>{let m=Gn(t.expires&&(a??-1)>=0?t.expires:"",p,c,o);n.patch({expires:m},`Access until ${ze(m)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([p,c,m])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>i(p,c)},m)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{r.focus({preventScroll:!0});try{r.showPicker()}catch{}}},[g("calendar"),t.expires?ze(t.expires):"Date"]),r]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[t.expire_action];return e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Access ends"),t.expires?e("span",{class:a!=null&&a<0?"dl-bad":a!=null&&a<=t.expire_warn?"dl-warn":"dl-ok"},a!=null&&a<0?"ended":`${a} day${a===1?"":"s"} left`):e("span",{class:"dl-faint"},"no end date")]),e("div",{class:"dl-chips-row"},[...s,l,t.expires?e("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`When it ends: ${d}${t.expire_warn?`, warn ${t.expire_warn} day${t.expire_warn===1?"":"s"} before`:""}`),e("a",{href:"#",click:p=>{p.preventDefault(),aa(n)}},"Change")])])}function li(n){let t=n.p,o=t.quota_used||t.month[0]+t.month[1],a=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,r=e("div",{class:`dl-meter${a>=100?" bad":a>=90?" warn":""}`},[e("i"),t.quota_limit?e("span",{class:"mark",title:"Alert at 90%"}):""]);r.firstChild.style.width=`${a}%`,t.quota_limit&&ue(r,()=>[e("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${te(t.quota_used)} of ${te(t.quota_limit)} · ${te(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},"Alert at 90%")]);let i=xe([["month","Monthly"],["total","Total"]],t.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>e("button",{type:"button",class:`dl-chipbtn${t.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(e("button",{type:"button",class:`dl-chipbtn${t.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(e("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=prompt("Data limit in GB",t.quota_gb?String(t.quota_gb):"");l!=null&&l.trim()!==""&&Number(l)>0&&n.patch({quota_gb:l.trim()},`Data limit ${l.trim()} GB`)}},"Custom")),e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Data"),i]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[te(o),t.quota_limit?e("span",{class:"dl-faint"},` of ${te(t.quota_limit)}`):e("span",{class:"dl-faint"}," · no limit")]),t.quota_period==="month"?e("span",{class:"dl-sub"},"resets on the 1st"):""]),t.quota_limit?r:"",e("div",{class:"dl-chips-row"},s),t.quota_gb&&t.quota_period==="month"?e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},t.bonus_gb?`Includes +${t.bonus_gb} GB extra this month`:"Need a little more this month?"),e("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((t.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`${te(t.total[0]+t.total[1])} in total`),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>ut("person",t.id,t.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function di(n){let t=n.p,o=!!t.hours,[a,r]=(t.hours||"07:00-23:00").split("-"),i=e("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"From"}),s=e("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":"To"}),l=e("div",{class:"dl-tile2-row"},[i,e("span",{class:"dl-faint"},"to"),s]),d=()=>{let c=`${i.value}-${s.value}`;if(c!==t.hours){if(!fa.test(i.value)||!fa.test(s.value))return Z("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return Z("The start and the end must differ.","warning");n.patch({hours:c},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",c=>{l.contains(c.relatedTarget)||d()});for(let c of[i,s])c.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),d())});let p=e("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")},e("i"));return 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",{},o?`${a} – ${r} (router time)`:"Any time")]),p]),o?l:""])}function ga(n){let t=n.p,o=xe(["internet","lan","both"].map(a=>[a,[g(a==="internet"?"globe":a==="lan"?"home":"shield"),a==="internet"?"Internet":a==="lan"?"Home":"Both"]]),t.access,{label:"Access",cls:"wide",optimistic:!1,onChange:a=>n.patch({access:a},`Access: ${et[a]}`)});return e("section",{class:"dl-devsec","aria-label":"Access and limits"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Access & limits")]),e("div",{class:"dl-panel"},[e("div",{class:"dl-stack gap8"},[e("span",{class:"dl-tile2-label"},"Can reach"),o,e("span",{class:"dl-sub"},ii[t.access]),t.access==="lan"&&n.st.services.length?ua(n):"",Je(t)?pa(n):"",t.access==="lan"?ca(n):""]),e("div",{class:"dl-tiles2"},[ha(n),ma(n),si(n),li(n),di(n)])])])}function ci(n){let t=n.st,o=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),t.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(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[o,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let a=new gt({openPerson:()=>{},openDevice:(r,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&He(n.p,s,n.deviceOpts())}},"30d",280);return n.map=a,requestAnimationFrame(()=>a.mount(n.mapData())),e("div",{class:"dl-panel flush"},[o,a.el])}function va(n){let t=n.st;if(!t.geo.enabled)return e("div",{class:"dl-places"},[g("pin"),e("div",{class:"dl-stack"},[e("span",{},"Locations are off"),e("span",{class:"dl-sub"},"City-level, from the client IP")]),e("span",{class:"dl-spacer"}),e("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:ci(n);let o=t.now-30*86400,a=t.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 e("div",{class:"dl-places"},[g("pin"),e("div",{class:"dl-stack"},[e("span",{},i?i.city||i.country:"No locations yet"),e("span",{class:"dl-sub"},i?`${r.length} place${r.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),e("span",{class:"dl-spacer"}),a.length?D("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function ba(n){let t=n.p,o=n.st,a=n.events.filter(l=>l.person===t.id),r=[],i=[...a].reverse();for(let l=0;l1){let m=c.querySelector(".dl-row-main");dom.content(m,[...Mn(o,d).slice(0,3),e("span",{class:"dl-muted"},`${p} times`)]),m.title=i.slice(l,l+p).map(v=>v.detail??"").join(` -`)}r.push(c),l+=p-1}let s=D([g("more")],()=>we(s,[{label:"Export CSV",icon:g("download"),run:()=>je(o,a,"csv",t.id)},{label:"Export JSON",icon:g("download"),run:()=>je(o,a,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:g("trash"),danger:!0,run:()=>Fe(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},a.length>10?`latest 10 of ${a.length}`:""),e("span",{class:"dl-spacer"}),s]),r.length?r:e("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var dn=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(t){let[o,a,r]=await Promise.all([E.status(30),t?E.events(5e3).catch(()=>null):Promise.resolve(null),t?E.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(t){this.take(t);let o=this.st.people.find(s=>s.id===this.id);if(!o)return e("div",{class:"dl-empty"},[e("h3",{},"Person not found"),e("p",{},"They may have been removed."),e("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["head","devices","traffic","places","activity","limits"])this.parts[s]=e("div",{});this.parts.devices.className="dl-person-devices";let a=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:ht(o.server)},this.st.servers.find(s=>s.id===o.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:ht(o.server)},"People"),e("span",{},"/"),e("span",{},o.name)]),this.parts.head,e("div",{class:"dl-grid-person"},[e("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),e("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(s=>s.id===r.get("device"));return i?setTimeout(()=>He(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>ot(this.p,this.deviceOpts()),50),this.poller=Ke({fetch:()=>{let s=this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(s)},every:15,active:()=>a.isConnected,apply:(s,l)=>this.apply(s,l)}),a}take(t){this.st=t.st,t.ev&&(this.events=t.ev),t.use&&(this.series=t.use.person,this.devSeries=t.use.devices)}apply(t,o){this.take(t);let a=this.st.people.find(r=>r.id===this.id);if(!a){o||(location.href=ht(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(t,o){var i;this.poller?.claim();let a=await U(()=>E.personUpdate(this.p.id,t),o);if(!a)return;this.poller?.claim();let r=this.st.people.findIndex(s=>s.id===this.p.id);(i=a.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=a.person),this.p=a.person,this.paint()}get today(){return Ne(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}}paint(t=!1){_e(this.parts.head,sa(this),t),_e(this.parts.traffic,la(this),t),_e(this.parts.devices,da(this),t),_e(this.parts.limits,ga(this),t),this.paintPlaces(t),_e(this.parts.activity,ba(this),t)}paintPlaces(t=!1){let o=va(this);o&&_e(this.parts.places,o,t&&!this.mapOpen)}};var pi={ok:"check",warn:"alert",error:"x",skip:"pause"},cn=class{constructor(t,o,a,r){this.el=e("div",{});this.wdEl=e("div",{});this.checksEl=e("div",{class:"dl-panel"});this.recentEl=e("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=e("div",{});this.open=new Set;this.st=t,this.sl=o,this.events=a,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,e("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,a)}async run(t){let o=t?await on(t):await E.health().catch(()=>null);o&&(this.take(o),t==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(t){this.checks=t.checks,this.paintChecks(),this.paintLive(t,this.events)}paintChecks(){let t=this.checks;if(!t){dom.content(this.summary,""),dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks")]),e("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=t.filter(s=>s.status==="error").length,a=t.filter(s=>s.status==="warn").length;dom.content(this.summary,o?dt("error",`${o} problem${o>1?"s":""} need attention.`):a?dt("warn",`${a} warning${a>1?"s":""}.`):dt("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,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks"),e("span",{class:"dl-spacer"}),D("Run again",i)]),e("ul",{class:"dl-checks"},t.map(s=>e("li",{},[e("span",{class:`dl-check-icon ${s.status}`},g(pi[s.status])),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},s.title),e("div",{class:"dl-check-detail"},s.detail),r.has(s.id)?e("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${wt(r.get(s.id))}`):""]),Pn(s,l=>void this.run(l),i)])))])}paintLive(t,o){this.sl=t,this.events=o;let a=t.watchdog,r=a.beat!=null&&a.now-a.beat>180,i=a.repairs.filter(d=>a.now-d.ts<86400),s=i[i.length-1],l=fe(a.enabled,"Watchdog repairs",async d=>{await U(()=>E.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||_n(l,!d);let c=await E.serviceLog().catch(()=>null);c&&this.paintLive(c,this.events)});dom.content(this.wdEl,e("div",{class:"dl-panel dl-wd"},[e("div",{class:"dl-wd-head"},[e("span",{class:`dl-wd-tile${a.enabled?"":" off"}`},g("shield")),e("div",{class:"dl-stack"},[e("span",{class:"dl-wd-title"},"Watchdog"),e("span",{class:"dl-sub"},a.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),e("span",{class:"dl-spacer"}),l]),e("div",{class:"dl-wd-foot"},[e("div",{class:"dl-wd-chips"},a.targets.map(d=>e("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?"OK":`Not working${d.tries?` · ${d.tries} repair${d.tries>1?"s":""}`:""}`},[g(d.ok?"check":"x"),d.name]))),e("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 ${le(a.last,a.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${wt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let t=(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>=t&&jt(r)).sort((r,i)=>i.ts-r.ts),a=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Recent problems"),e("span",{class:"dl-spacer"}),o.length?e("a",{href:"#",click:r=>(r.preventDefault(),this.toLog())},"All in Log →"):""]);if(!o.length){dom.content(this.recentEl,[a,e("div",{class:"dl-recent-empty"},[e("span",{class:"dl-check-icon ok"},g("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 en(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},wt(i.ts))}return Ye(this.st,r.ev,{time:wt(r.ts)})})])}};var pn=300,mi=["all","connections","people","system","problems"],un=class{constructor(t,o,a){this.events=[];this.system=[];this.kind="all";this.shown=pn;this.open=new Set;this.list=e("div",{});this.sub="";this.tabs=e("div",{class:"dl-seg",role:"tablist"});this.st=t,this.take(o),this.system=a,this.el=e("div",{},[e("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let t=()=>this.kind==="all"?"":this.kind,o=i=>()=>{let s=this.filtered().reverse();je(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,t(),s.filter(l=>l.sys).map(l=>l.sys))},a=D([g("download")," Export"],()=>we(a,[{label:"CSV (spreadsheet)",icon:g("download"),run:o("csv")},{label:"JSON",icon:g("download"),run:o("json")}])),r=D([g("trash")," Clear"],()=>Fe("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(t){this.events=t.events,this.policy=t.policy;let o=pt.filter(a=>!t.policy.categories.includes(a));this.sub=`${Ut(t.policy)}${o.length?` Not recorded: ${o.map(a=>nt[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[t,o]=await Promise.all([E.events(2e4).catch(()=>null),E.serviceLog().catch(()=>null)]);t&&this.take(t),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(t=>({ts:t.ts,ev:t})),...this.system.map(t=>({ts:t.ts,sys:t}))].sort((t,o)=>o.ts-t.ts)}matches(t,o){return o==="all"?!0:o==="problems"?jt(t):o==="system"?!!t.sys:!!t.ev&&$t(t.ev.type)===o}filtered(){return this.items().filter(t=>this.matches(t,this.kind))}paintTabs(t){dom.content(this.tabs,mi.map(o=>e("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":nt[o],e("b",{},String(t.filter(a=>this.matches(a,o)).length))])))}show(t){this.kind=t,this.shown=pn,this.paint()}paint(){this.paintTabs(this.items());let t=this.filtered();if(!t.length){dom.content(this.list,e("div",{class:"dl-empty"},[e("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let o=[],a="",r=null;for(let i of t.slice(0,this.shown)){let s=Po(i.ts);s!==a&&(a=s,r=e("div",{class:"dl-panel flush"},e("div",{class:"dl-panel-head pad"},e("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 d=`${i.sys.ts}|${i.sys.msg}`;r.appendChild(en(i.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else r.appendChild(Ye(this.st,i.ev,{time:l}))}t.length>this.shown&&o.push(e("div",{class:"dl-more-row"},D(`Show ${Math.min(pn,t.length-this.shown)} more of ${t.length-this.shown}`,()=>{this.shown+=pn,this.paint()}))),dom.content(this.list,o)}};var hi=[["health","Health"],["log","Log"]],Hn=2e4,mn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=e("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=e("span",{class:"dl-muted"});this.actionsEl=e("div",{class:"dl-row-actions"});this.bodyEl=e("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([E.status(1),E.events(Hn),E.serviceLog()])}render([t,o,a]){return this.log=new un(t,o,a.log),this.health=new cn(t,a,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),Ke({fetch:async()=>{let r=this.tab==="log",[i,s]=await Promise.all([E.serviceLog().catch(()=>null),r?E.events(Hn).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)}),e("div",{},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(t,o){o&&(this.log.take(o),this.eventsAt=Date.now()),t&&(this.log.system=t.log),t&&this.health.paintLive(t,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(t){this.tab=t,dom.content(this.segEl,hi.map(([o,a])=>e("button",{type:"button",role:"tab",class:o===t?"on":"","aria-selected":o===t?"true":"false",click:()=>o!==this.tab&&this.show(o)},a))),this.bodyEl.replaceChildren(t==="log"?this.log.el:this.health.el),this.subEl.textContent=t==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,t==="log"?this.log.actions():""),t==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&E.events(Hn).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-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 wa='.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 .dl-card-name,.dl-plist>.dl-card.dl-off .dl-avatar{opacity:.6}.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 ya="#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)}@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 ka=".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 $a=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-5px;bottom:-5px;width:20px;height:20px;border-radius:7px;background:var(--dl-card);box-shadow:0 0 0 1.5px var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-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-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 _a='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var Ea=".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 Sa=".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 Ca=".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 La='.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.dot{width:8px;height:8px;border-radius:50%;background:var(--dl-fg-faint)}.dl-map-legend i.dot.ok{background:var(--dl-ok)}.dl-map-legend i.line{width:14px;height:2px;border-radius:2px;background:var(--dl-ok)}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;position:relative}.dl-mk-dot{width:12px;height:12px;border-radius:50%;background:#8f8f8f;box-shadow:0 0 0 3px #0000008c}.dl-mk.online .dl-mk-dot{width:14px;height:14px;background:#40c977}.dl-mk.online:before{content:"";position:absolute;inset:-9px;border-radius:50%;background:#40c97747;animation:dl-pulse 2s ease-out infinite}@keyframes dl-pulse{0%{transform:scale(.5);opacity:1}to{transform:scale(1.4);opacity:0}}@media(prefers-reduced-motion:reduce){.dl-mk.online:before{animation:none}}.dl-mk-home{width:22px;height:22px;border-radius:7px;background:#ededed;display:flex;align-items:center;justify-content:center;box-shadow:0 0 0 4px #ededed2e,0 2px 6px #00000080;color:#131313}.dl-mk-home-ic{width:13px;height:13px}.dl-popup{z-index:4}.dl-popup .maplibregl-popup-content{background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);border-radius:12px;padding:12px;box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));font:inherit}.dl-popup .maplibregl-popup-tip{border-top-color:var(--dl-elevated)!important;border-bottom-color:var(--dl-elevated)!important}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-mk.multi{width:26px;height:26px}.dl-mk-count{min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:#8f8f8f;color:#0a0a0a;font:600 11px/22px var(--dl-mono);text-align:center;box-shadow:0 0 0 3px #0000008c;box-sizing:border-box}.dl-mk.online .dl-mk-count{background:#40c977}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px -4px 0}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:5px 4px;border-radius:6px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.maplibregl-ctrl-attrib{font-size:10px}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}';var Ta=`.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)}.dl-plist>.dl-card.dl-attn-row{border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)}@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 Ma=".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 Pa=".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-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 Da=".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 Aa=".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 Mi=[xa,wa,ya,ka,$a,_a,Ea,Sa,Ca,La,Ta,Ma,Pa,Da,Aa].join(` -`);function za(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=Mi,n}function rt(n){return()=>{let t=new n;return Object.assign({load:()=>t.load(),render:async a=>{let r=await t.render(a),i=document.createElement("div");return i.className="dl-root",i.append(za(),r),i},addFooter(){return t.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var Df=rt(At),Af=rt(at),zf=rt(At),Nf=rt(rn),Rf=rt(dn),Hf=rt(mn),If=rt(ln);function Na(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 Bf=Na(""),Of=Na("log");return baseclass.extend({ activity: Of, diagnostics: Hf, health: Bf, overview: Df, people: Af, person: Rf, server: zf, settings: Nf, updates: If }); +`).trim()}async function zt(n,t,o,a){let r=e("div",{class:"dl-notes"},e("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=e("div",{class:"dl-op-head"}),s="";ae(o,[i,r],[D([g("copy")," Copy"],()=>pe(s,"Release notes copied"))," ",se("Close")],"wide");try{let l=await S.updatesNotes(n,t,a??"");s=Zo(l.body||"");let d=Yo(l.url);dom.content(i,[l.published?e("span",{class:"dl-pill"},Ae(l.published)):"",l.prerelease?e("span",{class:"dl-pill warn"},"Pre-release"):"",e("span",{class:"dl-spacer"}),d?e("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",g("open")]):""]),dom.content(r,s.trim()?Qo(s):e("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(r,e("p",{class:"dl-muted"},ve(l)))}}var Xo={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Hn=n=>n?Ae(n):"";function ri(n){let t=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return t||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function ta(n,t){let o=n.st,a=o.policy,r=o.kept?.app,i=t?.update&&t.tag?t.tag:o.version,s=v=>()=>zt("app",v,`What’s new in Dawnline ${v.replace(/^v/,"")}`),l=t?.tag&&(t.update||t.status==="latest")?ii(n,t.tag,t.update?o.version:""):null,d=t?.tag??i,p=a.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[a.interval]??24)*3600:0,c=(v,h)=>e("div",{class:"dl-stack gap4"},[e("span",{class:"dl-metric-label"},v),e("span",{class:"dl-comp-side-v"},h)]),m=[{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 ne(`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 e("section",{class:"dl-panel flush dl-comp-hero"},[e("div",{class:"dl-comp-hero-main"},[e("div",{class:"dl-comp-hero-head"},[e("span",{class:"dl-group-ic"},g("sunrise")),e("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",t,t?.latest??""),e("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),m,!0)]),e("div",{class:"dl-comp-verrow"},[e("div",{class:"dl-stack"},[e("div",{class:"dl-comp-big"},[o.version,t?.update?e("small",{},`→ ${t.latest}`):t?.status==="dev"&&t.latest?e("small",{class:"dl-faint"},`release ${t.latest}`):""]),e("span",{class:"dl-faint dl-comp-meta"},t?.error?"":t?.update?t.published?`released ${Hn(t.published)}`:"":t?.status==="dev"?"ahead of the latest release":t?`latest release${t.published?` · released ${Hn(t.published)}`:""}`:"not checked yet")])]),l?.items.length?e("div",{class:"dl-stack gap4"},[e("ul",{class:"dl-comp-bullets"},l.items.map(v=>e("li",{},v))),l.total>l.items.length?e("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(d)},`+${l.total-l.items.length} more in What’s new`):""]):"",t?.error?e("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},t.error):"",t?.update?e("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))]):"",si(n)]),e("div",{class:"dl-comp-hero-side"},[c("Source",[g("globe"),e("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),c("Auto-update",[a.auto?ke("ok","On"):ke("","Off"),e("span",{class:"dl-muted"},a.auto?a.mode==="immediate"?"as soon as found":`${Xo[a.interval]==="weekly"?"weekly":"daily"} at ${a.time}`:a.check?`checks ${Xo[a.interval]}`:"checks off")]),c("Last check",o.check?[de(o.check.time,o.now),p>o.now?e("span",{class:"dl-faint"},`· next in ${st(p-o.now)}`):""]:["Never"]),c("Rollback",r?[e("span",{class:"dl-mono"},r.version),e("span",{class:"dl-faint"},"kept on flash")]:[e("span",{class:"dl-muted"},a.keep?"Kept after the next update":"Off")])])])}function ii(n,t,o){if(n.notes.has(t))return n.notes.get(t)??null;n.notes.set(t,null);let a=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await S.updatesNotes("app",t,"").catch(()=>null))?.body??"").split(` +`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await S.updatesChanges(o,t).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>ri(a(l))),total:i.length};n.notes.set(t,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function si(n){let t=e("div",{class:"dl-params-body"}),o=e("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[e("summary",{},[g("chevron"),e("span",{},"Versions"),e("span",{class:"dl-sub"},"install any release")]),t]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&dn(n,t)}),n.versOpen&&dn(n,t),o}async function dn(n,t){let o=re("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),a=c=>{if(c=c.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(c))return Q("Enter a release tag like 0.3.1","warning");ea(n,c)};o.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),a(o.value))});let r=e("div",{class:"dl-comp-tag"},[o,D("Install",()=>a(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=c=>{n.versPage=Math.max(1,n.versPage+c),dn(n,t)},l=c=>e("div",{class:"dl-comp-pager"},[e("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),e("span",{class:"dl-faint"},`Page ${i}`),e("button",{type:"button",class:"dl-linkbtn",disabled:c?null:"disabled",click:()=>s(1)},"Older →")]),d=n.versCache.get(i);if(!d){dom.content(t,[r,e("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{d=(await S.updatesReleases(i)).releases}catch(c){if(i!==n.versPage||!t.isConnected)return;dom.content(t,[r,e("div",{class:"dl-row-actions"},[e("span",{class:"dl-muted"},`Failed to load versions: ${ve(c)}`),D("Try again",()=>dn(n,t))]),l(!1)]);return}if(n.versCache.set(i,d),i!==n.versPage||!t.isConnected)return}if(!d.length)return dom.content(t,[r,e("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let p=n.st.version;dom.content(t,[r,...d.map(c=>{let m=c.tag.replace(/^v/,"");return e("div",{class:"dl-comp-ver"},[e("span",{class:"dl-mono"},m),e("span",{class:"dl-sub"},Hn(c.published)),c.prerelease?ke("warn","Pre-release"):"",e("span",{class:"dl-comp-ic"},ye("file","What’s new",()=>zt("app",c.tag,`What’s new in Dawnline ${m}`))),m===p?ke("ok","Installed"):D("Install",()=>ea(n,c.tag),"neutral",{disabled:n.busy})])}),l(d.length>=5)])}async function ea(n,t){let o=t.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await ne(`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@${t}`,`Installing Dawnline ${o}`,n.st.version)}function na(n,t){let o=n.st,a=o.kept?.amneziawg,r=t?.sources??{},i=Object.keys(r),s=t?.current??null,l=s?r[s]:void 0,d=!!t?.ru,p=o.needs?.awg??[],c=p.length?null:t?.installed??null,m=[];s&&c&&m.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Reinstalling AmneziaWG",c)}),a&&m.push({label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await ne(`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",c??void 0)}});let v=[t?.release?{label:"What’s new",ic:"file",run:()=>zt("amneziawg",t.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")},...m.length?[null,...m]:[]].filter((u,f,N)=>u!==null||f>0&&N[f-1]!==null),h=o.tunnels??[],x=h.length?`Switching restarts ${h.length===1?"the tunnel":`${h.length} tunnels`} for a few seconds: ${h.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",R=h.length>1?`${h.slice(0,-1).join(", ")} and ${h[h.length-1]}`:h[0],_=h.length?`Switching restarts ${R} for a few seconds.`:"Switching takes a few seconds.",j=async u=>{let f=r[u];await ne(c?`Switch to AmneziaWG ${f.gen}?`:`Install AmneziaWG ${f.gen}?`,`The ${f.label} build, ${f.version}. ${x}${f.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,c?"Switch":"Install")&&n.op(`amneziawg:${u}${d?":ru":""}`,c?`Switching to AmneziaWG ${f.gen}`:"Installing AmneziaWG",c??void 0)},w=u=>{let f=r[u],N=s===u&&!!c;return e("div",{class:"dl-row"},[e("span",{class:"dl-row-main dl-stack"},[e("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),e("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),e("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??"none yet"),e("span",{class:"dl-comp-bact"},N?ke("ok","Active"):f.version?D(c?"Switch":"Install",()=>j(u),c?"neutral":"positive",{disabled:n.busy}):ke("","No build"))])},I=i.map(u=>r[u]?.newer?`${r[u].label} moves to ${r[u].newer.gen} with OpenWrt ${r[u].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),C=fe(d,"Russian translation",u=>{s&&n.op(`amneziawg:${s}${u?":ru":""}`,u?"Adding the Russian translation":"Removing the Russian translation",c??void 0)});C.disabled=!s||!c||n.busy;let T=n.awgOpen??!c,b=e("details",{class:"dl-params dl-comp-fold",open:T?"open":null},[e("summary",{},[g("chevron"),e("span",{},"Build and translation")]),e("div",{class:"dl-params-body"},[e("div",{class:"dl-list"},[...i.length?i.map(w):[e("div",{class:"dl-row"},e("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],e("div",{class:"dl-row"},[e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Russian translation"),e("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),e("span",{class:"dl-comp-bact"},C)])]),c&&i.length||I.length?e("div",{class:`dl-comp-status ${c&&i.length?"warn":"acc"}`},[g(c&&i.length?"alert":"download"),e("span",{},[c&&i.length?e("b",{},_):"",...I.map(u=>` ${u}`)])]):""])]);b.addEventListener("toggle",()=>n.awgOpen=b.open);let A=[];return t?.update&&c&&s?A.push(D(`Update to ${t.latest}`,()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Updating AmneziaWG",c),"neutral",{disabled:n.busy})):A.push((t||p.length)&&!c?ke("warn","Not installed"):n.state("amneziawg",t,t?.latest??"")),A.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",c??void 0),v)),[n.row("shield","AmneziaWG",[c?`${c}${t?.release?` · ${t.release} build`:""}`:p.length?`missing ${p.join(", ")}`:t?"not installed":"version not checked"],A),e("div",{class:"dl-comp-foldwrap"},b)]}var li=[{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}],In={home:"network",https:"lock",acme:"file"};function oa(n,t){let o=n.st,a=t?.pkgs??{},r=li.filter(p=>p.feature==="home"?o.home:o.portal),i=async(p,c,m=p)=>{await ne(`Update ${c}?`,`${m.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${p.join(",")}`,`Updating ${c}`)},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(p=>{let c=p.pkgs.filter(R=>a[R]?.installed),m=[...new Set(c.flatMap(R=>[...a[R]?.latest?[R]:[],...a[R]?.with??[]]))],v=o.needs?.[p.feature]??p.pkgs.filter(R=>!a[R]?.installed),h=c.find(R=>a[R]?.latest),x=c.map(R=>`${R} ${a[R]?.installed??""}`).join(", ");return v.length?n.row(In[p.feature],p.title,[`${p.optional?"not installed":`missing ${v.join(", ")}`}`],[D("Install",()=>n.op(`pkgs:${v.join(",")}`,`Installing ${p.title}`),p.optional?"neutral":"positive",{disabled:n.busy}),e("span",{class:"dl-comp-ic"},n.more(s))]):t&&m.length?(l++,n.row(In[p.feature],p.title,h?[`${a[h].installed} → ${a[h].latest}`,m.length>1?` · +${m.length-1}`:""]:[m.join(", ")],[D("Update",()=>i(c.filter(R=>a[R]?.latest||a[R]?.with?.length),p.title,m),"neutral",{disabled:n.busy}),e("span",{class:"dl-comp-ic"},n.more(s))])):n.row(In[p.feature],p.title,[x||p.sub],[n.state("pkgs",t,""),e("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:r.length}}var di={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function aa(n){let t=n.st,o=r=>{let i=Ve(r.component??"app"),s=di[i]??"Components",l=r.auto?"automatically":"by you",d="ok",p="check",c;if(r.kind==="found")d="accent",p="download",c=[e("b",{},(r.items??[]).join(", ")),` found by ${r.auto?"the automatic check":"a check"}`];else if(r.state==="failed")d="bad",p="x",c=[e("b",{},s),` ${r.kind==="install"?"update":"check"} failed${r.error?` · ${r.error}`:""}`];else{let m=r.from&&r.to&&r.from!==r.to?` ${r.from} → ${r.to}`:r.to?` ${r.to}`:"";c=[e("b",{},s),`${m} ${m?"":"updated "}${l}${r.took?` · ${st(r.took)}`:""}`.replace(/\s+/g," ")]}return e("div",{class:"dl-row"},[e("span",{class:`dl-ev-tile ev ${d}`},g(p)),e("span",{class:"dl-row-main"},c),e("span",{class:"dl-faint dl-nowrap",title:new Date(r.ts*1e3).toLocaleString()},de(r.ts,t.now))])},a=t.history??[];return e("section",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-spacer"}),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),a.length?e("div",{},a.slice(0,8).map(o)):e("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var cn=class{constructor(){this.root=e("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 S.updatesStatus()}render(t){return this.st=t,this.paint(),t.job?.state==="running"&&this.follow(t.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await S.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(t){this.st=t??await S.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(t,o,a){if(this.busy||this.following==="starting"){Q("Another component action is already running","warning");return}this.following="starting",this.paint();let r=Ve(t),i=await Mt(t,{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(t){this.following=t.id;let o=Zt(t),a={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[o]??"components";await Mt(null,{title:`${t.action==="check"?"Checking":t.auto?"Automatic update:":"Updating"} ${a}`,onDone:r=>this.refresh(r)},t)}paint(){let t=this.st,o=t.check?.components??{},a=t.firmware,r=oa(this,o.packages),i=(t.needs?.awg??[]).length>0,l=(!i&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+r.updates;dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Components"),e("span",{class:"dl-faint"},[a?.version?`OpenWrt ${a.version} · ${a.target}`:"",t.check?`checked ${de(t.check.time,t.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),e("div",{class:"dl-row-actions"},[e("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[g("edit")," Settings"]),D([g("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),ta(this,o.app),e("div",{class:"dl-comp-cols"},[e("section",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Components"),e("span",{class:"dl-spacer"}),e("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")]),e("div",{},[...na(this,o.amneziawg),...r.rows])]),aa(this)])])}state(t,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(Ve(l)));if(s.includes(t)||s.includes("all"))return e("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?ke("warn","Check failed",o.error):o.update?ke("info","Update available"):o.status==="dev"?ke("info","Newer than release",`The latest release is ${a}`):ke("ok","Up to date"):ke("","Not checked")}more(t){let o=D([g("more")],()=>we(o,t.filter((a,r,i)=>a!==null||r>0&&ra?{label:a.label,icon:g(a.ic),warn:a.warn,run:a.run}:null)),"neutral",{title:"More","aria-label":"More"});return o}round(t,o,a=!1){let r=this.busy?" is-busy":"",i;return a?i=D([g("refresh")," Check"],t,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${r}`,"aria-label":"Check for updates"}):(i=ye("refresh","Check for updates",t,"neutral",r.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),ue(i,()=>["Check for updates"])),e("span",{class:"dl-comp-ic"},[i,this.more(o)])}row(t,o,a,r){return e("div",{class:"dl-row"},[e("span",{class:"dl-group-ic"},g(t)),e("span",{class:"dl-row-main dl-stack"},[e("b",{},o),e("span",{class:"dl-mono dl-faint dl-comp-sub"},a)]),...r])}};var ra=(n,t)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},n),e("div",{class:"cbi-value-field"},t)]);function ia(n){let t=n.st.servers.find(o=>o.id===n.p.server)?.name??"Home";Lt(n.p,t)}async function sa(n){let t=n.p;if(!await ne("Create a new link?","The old link stops working right away.","Create new link",!0))return;let o=await U(()=>S.personRegen(t.id),"New link created");o?.link&&await pe(o.link,"New link copied")}function Bn(n){let t=e("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");ae("Note",[t],[se()," ",D("Save",async()=>{le(),await n.patch({note:t.value.trim()},t.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>t.focus(),50)}function la(n){let t=n.p,o=e("select",{class:"cbi-input-select"},[e("option",{value:"pause",selected:t.expire_action==="pause"?"selected":null},"Pause access"),e("option",{value:"notify",selected:t.expire_action==="notify"?"selected":null},"Keep access"),e("option",{value:"remove",selected:t.expire_action==="remove"?"selected":null},"Remove their devices")]),a=e("select",{class:"cbi-input-select"},[0,1,3,7,14].map(r=>e("option",{value:r,selected:t.expire_warn===r?"selected":null},r?`${r} day${r===1?"":"s"} before`:"Don’t warn")));ae("When access ends",[ra("Then",o),e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Warn"),e("div",{class:"cbi-value-field"},[a,e("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[se()," ",D("Save",async()=>{le(),await n.patch({expire_action:o.value,expire_warn:a.value},"Saved")},"positive")])}function da(n){let t=e("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48});ae("Rename",[ra("Name",t)],[se()," ",D("Save",async()=>{le(),await n.patch({name:t.value},"Renamed")},"positive")]),setTimeout(()=>t.select(),50)}async function ca(n){let t=n.p;await ne(`Delete ${t.name}?`,`All ${t.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await U(()=>S.personDelete(t.id),"Deleted")&&(location.href=ht(t.server))}function pa(n){let t=n.p,o=n.st,a=t.online?"online now":t.last_seen?`last seen ${de(t.last_seen,o.now)}`:"never connected",r=t.created?`Added ${ze(De(new Date(t.created*1e3)))}`:"",i=t.has_link??o.settings.portal_enabled,s=[{label:"Rename",icon:g("edit"),run:()=>da(n)},{label:t.note?"Edit note":"Add note",icon:g("file"),run:()=>Bn(n)},...i?[null,{label:"Invite card",icon:g("qr"),run:()=>ia(n)},{label:"New link",icon:g("key"),run:()=>sa(n)}]:[],null,{label:t.paused?"Resume":"Pause",icon:g(t.paused?"play":"pause"),warn:!t.paused,run:()=>n.patch({paused:!t.paused},t.paused?"Resumed":"Paused")},{label:"Delete",icon:g("trash"),danger:!0,run:()=>ca(n)}];return e("div",{class:"dl-person-head"},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-person-id"},[e("span",{class:`dl-avatar lg${t.online?" online":""}`},Oe(t.name)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),It(t)]),e("span",{class:"dl-faint",title:r},`${t.devices.length} of ${t.device_limit} devices · ${a}`)])]),e("div",{class:"dl-pcard-actions"},[i?ye("link","Copy link",()=>Jt(t.id),"neutral","dl-icon-only"):"",ye("more","More",l=>we(l.currentTarget,s),"neutral","dl-icon-only")])]),t.note?e("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>Bn(n)},[g("file"),e("span",{},t.note)]):""])}function ua(n){let t=n.p,o=n.series[n.series.length-1];return e("div",{class:`dl-person-live${t.online?"":" solo"}`},[t.online?on(t.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",an(n.series,`${ee(t.month[0]+t.month[1])} this month`)])}async function ci(n,t){let o=await U(()=>S.deviceConfig(t.id));o&&ae(`Set up ${t.name}`,[await n.core.connectBlock(o,"qr")],[se("Close")])}async function pi(n,t){let o=await U(()=>S.deviceConfig(t.id));if(!o)return;if(!o.has_private_key){Q("This device made its own keys in the browser; its configuration only exists there.","warning");return}let a=n.core.file.make(o);$e(a.name,a.text,"application/octet-stream")}function ma(n){let t=n.p,o=n.st.now,a=d=>He(t,d,n.deviceOpts()),r=d=>p=>{p.target.closest("button:not(.dl-dcard-title), a")||a(d)},i=d=>D([g("more")],p=>vo(p.currentTarget,t,d,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=Ht(t.devices).map(d=>{let p=e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},g(d.kind)),e("button",{type:"button",class:"dl-dcard-title",click:()=>a(d)},[e("b",{},d.name),Bt(d,o),d.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(d)]),c=e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},ee(d.month[0]+d.month[1])),e("span",{class:"dl-sub"},"this month")]),Ro(n.devSeries[d.id]??[])]);return e("article",{class:`dl-dcard clickable${d.online?" online":""}${d.disabled?" off":""}`,click:r(d)},[p,d.handshake?c:d.disabled?e("div",{class:"dl-sub"},`${Be[d.kind]} · created ${de(d.created,o)} ${d.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>ci(n,d)},[g("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>pi(n,d)},[g("download"),"Config"])])])}),l=t.devices.length>=t.device_limit;return s.push(e("button",{type:"button",class:"dl-dslot add",click:()=>ot(t,n.deviceOpts())},[e("span",{class:"dl-dslot-ic"},g("plus")),e("span",{class:"dl-stack"},[e("b",{},"Add device"),e("span",{class:"dl-sub"},l?`Over the limit · ${t.devices.length} of ${t.device_limit}`:`${t.devices.length} of ${t.device_limit}`)])])),e("section",{class:"dl-devsec"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Devices"),e("span",{class:"dl-sub"},`${t.online} online`)]),e("div",{class:"dl-dgrid"},s)])}function ha(n){let t=n.p,o=xe([["device","Device’s own DNS"],["home","Home names"]],t.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 e("div",{class:"dl-stack gap4 dl-dnspick"},[e("div",{class:"dl-row-actions"},[e("span",{class:"dl-sub"},"DNS"),o]),e("span",{class:"dl-sub"},t.dns_mode==="home"?["Names like ",e("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",a?[" (",e("span",{class:"dl-mono"},a)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}function fa(n){let t=n.p,a=n.st.servers.find(i=>i.id===t.server)?.home??[];if(a.length<2)return"";let r=new Set(t.home_nets?.length?t.home_nets:a.map(i=>i.dev));return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},a.map(i=>Ue(i.dev,r.has(i.dev),()=>{let s=new Set(r);if(s.delete(i.dev)||s.add(i.dev),!s.size)return Q("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?`${t.name} reaches ${l.join(", ")}`:`${t.name} reaches every home network`)},{title:i.nets.join(", ")}))),e("span",{class:"dl-sub"},t.home_nets?.length?`Home networks ${t.name} reaches. Networks added to the server later stay out.`:`Home networks ${t.name} reaches: all of them. Untick one to keep ${t.name} out of it.`)])}function ga(n){let t=new Set(n.p.services??[]);return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},n.st.services.map(o=>Ue(o.name,t.has(o.id),()=>{let a=new Set(t);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(", ")}`:""}`}))),e("span",{class:"dl-sub"},t.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function va(n){let t=n.p,o=n.st;if(o.servers.find(p=>p.id===t.server)?.mesh!=="circles"||!Je(t))return"";let r=o.circles.filter(p=>p.server===t.server),i=r.find(p=>p.id===t.circle),s=i?o.people.filter(p=>p.id!==t.id&&p.circle===i.id&&Je(p)).map(p=>p.name):[],l=e("button",{type:"button",class:"dl-chipbtn",click:()=>we(l,[...r.map(p=>({label:p.name,icon:Pn(p),run:()=>p.id!==t.circle&&n.patch({circle:p.id},`${t.name} is in ${p.name}`)})),t.circle?{label:"No circle",icon:g("x"),run:()=>n.patch({circle:""},`${t.name} is in no circle`)}:null,{label:"New circle",icon:g("plus"),run:()=>Yt(o,t.server,null,()=>n.refresh())}])},"Change"),d=i?o.people.filter(p=>p.circle===i.id&&Je(p)):[t];return e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Devices see each other"),l]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},i?i.name:"No circle"),e("span",{class:"dl-avstack",title:d.map(p=>p.name).join(", ")},d.slice(0,5).map(p=>e("span",{class:"dl-avatar sm"},Oe(p.name))))]),e("span",{class:"dl-sub"},i?s.length?[t.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${t.name}'s own devices`)])}function ba(n){let t=n.p,o=n.st.now,a=e("div",{class:"dl-slots"});for(let s=0;s=t.device_limit,p=e("i",{class:d?"over":l?"used":""});ue(p,()=>[e("div",{class:"dl-tip-title"},l?`${l.name}${d?" · over the limit":""}`:"Free slot"),e("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${de(l.handshake,o)}`:"Not set up yet":"They can add a device here")]),a.appendChild(p)}let r=Math.max(1,t.devices.length),i=e("button",{type:"button","aria-label":"Allow fewer devices",disabled:t.device_limit<=r?"disabled":null,click:()=>n.patch({device_limit:String(t.device_limit-1)})},"−");return t.device_limit<=r&&t.devices.length>1&&ue(i,()=>[e("div",{class:"dl-tip-title"},`${t.devices.length} devices in use`),e("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},"Devices"),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[String(t.devices.length),e("span",{class:"dl-faint"},` / ${t.device_limit}`)]),e("div",{class:"dl-stepper"},[i,e("button",{type:"button","aria-label":"Allow more devices",disabled:t.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(t.device_limit+1)})},"+")])]),a])}var mi={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."},xa=/^([01]\d|2[0-3]):[0-5]\d$/;function hi(n){let t=n.p,o=n.today,a=Xe(t.expires,o),r=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});r.addEventListener("change",()=>r.value&&n.patch({expires:r.value},`Access until ${ze(r.value)}`));let i=(p,c)=>{let m=Kn(t.expires&&(a??-1)>=0?t.expires:"",p,c,o);n.patch({expires:m},`Access until ${ze(m)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([p,c,m])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>i(p,c)},m)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{r.focus({preventScroll:!0});try{r.showPicker()}catch{}}},[g("calendar"),t.expires?ze(t.expires):"Date"]),r]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[t.expire_action];return e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Access ends"),t.expires?e("span",{class:a!=null&&a<0?"dl-bad":a!=null&&a<=t.expire_warn?"dl-warn":"dl-ok"},a!=null&&a<0?"ended":`${a} day${a===1?"":"s"} left`):e("span",{class:"dl-faint"},"no end date")]),e("div",{class:"dl-chips-row"},[...s,l,t.expires?e("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`When it ends: ${d}${t.expire_warn?`, warn ${t.expire_warn} day${t.expire_warn===1?"":"s"} before`:""}`),e("a",{href:"#",click:p=>{p.preventDefault(),la(n)}},"Change")])])}function fi(n){let t=n.p,o=t.quota_used||t.month[0]+t.month[1],a=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,r=e("div",{class:`dl-meter${a>=100?" bad":a>=90?" warn":""}`},[e("i"),t.quota_limit?e("span",{class:"mark",title:"Alert at 90%"}):""]);r.firstChild.style.width=`${a}%`,t.quota_limit&&ue(r,()=>[e("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${ee(t.quota_used)} of ${ee(t.quota_limit)} · ${ee(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},"Alert at 90%")]);let i=xe([["month","Monthly"],["total","Total"]],t.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>e("button",{type:"button",class:`dl-chipbtn${t.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(e("button",{type:"button",class:`dl-chipbtn${t.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(e("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=prompt("Data limit in GB",t.quota_gb?String(t.quota_gb):"");l!=null&&l.trim()!==""&&Number(l)>0&&n.patch({quota_gb:l.trim()},`Data limit ${l.trim()} GB`)}},"Custom")),e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Data"),i]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[ee(o),t.quota_limit?e("span",{class:"dl-faint"},` of ${ee(t.quota_limit)}`):e("span",{class:"dl-faint"}," · no limit")]),t.quota_period==="month"?e("span",{class:"dl-sub"},"resets on the 1st"):""]),t.quota_limit?r:"",e("div",{class:"dl-chips-row"},s),t.quota_gb&&t.quota_period==="month"?e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},t.bonus_gb?`Includes +${t.bonus_gb} GB extra this month`:"Need a little more this month?"),e("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((t.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`${ee(t.total[0]+t.total[1])} in total`),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>ut("person",t.id,t.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function gi(n){let t=n.p,o=!!t.hours,[a,r]=(t.hours||"07:00-23:00").split("-"),i=e("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"From"}),s=e("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":"To"}),l=e("div",{class:"dl-tile2-row"},[i,e("span",{class:"dl-faint"},"to"),s]),d=()=>{let c=`${i.value}-${s.value}`;if(c!==t.hours){if(!xa.test(i.value)||!xa.test(s.value))return Q("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return Q("The start and the end must differ.","warning");n.patch({hours:c},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",c=>{l.contains(c.relatedTarget)||d()});for(let c of[i,s])c.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),d())});let p=e("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")},e("i"));return 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",{},o?`${a} – ${r} (router time)`:"Any time")]),p]),o?l:""])}function wa(n){let t=n.p,o=xe(["internet","lan","both"].map(a=>[a,[g(a==="internet"?"globe":a==="lan"?"home":"shield"),a==="internet"?"Internet":a==="lan"?"Home":"Both"]]),t.access,{label:"Access",cls:"wide",optimistic:!1,onChange:a=>n.patch({access:a},`Access: ${et[a]}`)});return e("section",{class:"dl-devsec","aria-label":"Access and limits"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Access & limits")]),e("div",{class:"dl-panel"},[e("div",{class:"dl-stack gap8"},[e("span",{class:"dl-tile2-label"},"Can reach"),o,e("span",{class:"dl-sub"},mi[t.access]),t.access==="lan"&&n.st.services.length?ga(n):"",Je(t)?fa(n):"",t.access==="lan"?ha(n):""]),e("div",{class:"dl-tiles2"},[ba(n),va(n),hi(n),fi(n),gi(n)])])])}function vi(n){let t=n.st,o=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),t.geo.enabled?tn("30d",r=>n.map?.setRange(r),!1):"",D("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[o,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let a=new gt({openPerson:()=>{},openDevice:(r,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&He(n.p,s,n.deviceOpts())}},"30d",280);return n.map=a,requestAnimationFrame(()=>a.mount(n.mapData())),e("div",{class:"dl-panel flush"},[o,a.el])}function ya(n){let t=n.st;if(!t.geo.enabled)return e("div",{class:"dl-places"},[g("pin"),e("div",{class:"dl-stack"},[e("span",{},"Locations are off"),e("span",{class:"dl-sub"},"City-level, from the client IP")]),e("span",{class:"dl-spacer"}),e("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:vi(n);let o=t.now-30*86400,a=t.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 e("div",{class:"dl-places"},[g("pin"),e("div",{class:"dl-stack"},[e("span",{},i?i.city||i.country:"No locations yet"),e("span",{class:"dl-sub"},i?`${r.length} place${r.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),e("span",{class:"dl-spacer"}),a.length?D("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function ka(n){let t=n.p,o=n.st,a=n.events.filter(l=>l.person===t.id),r=[],i=[...a].reverse();for(let l=0;l1){let m=c.querySelector(".dl-row-main");dom.content(m,[...An(o,d).slice(0,3),e("span",{class:"dl-muted"},`${p} times`)]),m.title=i.slice(l,l+p).map(v=>v.detail??"").join(` +`)}r.push(c),l+=p-1}let s=D([g("more")],()=>we(s,[{label:"Export CSV",icon:g("download"),run:()=>je(o,a,"csv",t.id)},{label:"Export JSON",icon:g("download"),run:()=>je(o,a,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:g("trash"),danger:!0,run:()=>Fe(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},a.length>10?`latest 10 of ${a.length}`:""),e("span",{class:"dl-spacer"}),s]),r.length?r:e("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var pn=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(t){let[o,a,r]=await Promise.all([S.status(30),t?S.events(5e3).catch(()=>null):Promise.resolve(null),t?S.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(t){this.take(t);let o=this.st.people.find(s=>s.id===this.id);if(!o)return e("div",{class:"dl-empty"},[e("h3",{},"Person not found"),e("p",{},"They may have been removed."),e("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["head","devices","traffic","places","activity","limits"])this.parts[s]=e("div",{});this.parts.devices.className="dl-person-devices";let a=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:ht(o.server)},this.st.servers.find(s=>s.id===o.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:ht(o.server)},"People"),e("span",{},"/"),e("span",{},o.name)]),this.parts.head,e("div",{class:"dl-grid-person"},[e("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),e("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(s=>s.id===r.get("device"));return i?setTimeout(()=>He(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>ot(this.p,this.deviceOpts()),50),this.poller=Ke({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(t){this.st=t.st,t.ev&&(this.events=t.ev),t.use&&(this.series=t.use.person,this.devSeries=t.use.devices)}apply(t,o){this.take(t);let a=this.st.people.find(r=>r.id===this.id);if(!a){o||(location.href=ht(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(t,o){var i;this.poller?.claim();let a=await U(()=>S.personUpdate(this.p.id,t),o);if(!a)return;this.poller?.claim();let r=this.st.people.findIndex(s=>s.id===this.p.id);(i=a.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=a.person),this.p=a.person,this.paint()}get today(){return Ne(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}}paint(t=!1){_e(this.parts.head,pa(this),t),_e(this.parts.traffic,ua(this),t),_e(this.parts.devices,ma(this),t),_e(this.parts.limits,wa(this),t),this.paintPlaces(t),_e(this.parts.activity,ka(this),t)}paintPlaces(t=!1){let o=ya(this);o&&_e(this.parts.places,o,t&&!this.mapOpen)}};var bi={ok:"check",warn:"alert",error:"x",skip:"pause"},un=class{constructor(t,o,a,r){this.el=e("div",{});this.wdEl=e("div",{});this.checksEl=e("div",{class:"dl-panel"});this.recentEl=e("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=e("div",{});this.open=new Set;this.st=t,this.sl=o,this.events=a,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,e("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,a)}async run(t){let o=t?await rn(t):await S.health().catch(()=>null);o&&(this.take(o),t==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(t){this.checks=t.checks,this.paintChecks(),this.paintLive(t,this.events)}paintChecks(){let t=this.checks;if(!t){dom.content(this.summary,""),dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks")]),e("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=t.filter(s=>s.status==="error").length,a=t.filter(s=>s.status==="warn").length;dom.content(this.summary,o?dt("error",`${o} problem${o>1?"s":""} need attention.`):a?dt("warn",`${a} warning${a>1?"s":""}.`):dt("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,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks"),e("span",{class:"dl-spacer"}),D("Run again",i)]),e("ul",{class:"dl-checks"},t.map(s=>e("li",{},[e("span",{class:`dl-check-icon ${s.status}`},g(bi[s.status])),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},s.title),e("div",{class:"dl-check-detail"},s.detail),r.has(s.id)?e("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${wt(r.get(s.id))}`):""]),zn(s,l=>void this.run(l),i)])))])}paintLive(t,o){this.sl=t,this.events=o;let a=t.watchdog,r=a.beat!=null&&a.now-a.beat>180,i=a.repairs.filter(d=>a.now-d.ts<86400),s=i[i.length-1],l=fe(a.enabled,"Watchdog repairs",async d=>{await U(()=>S.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||Sn(l,!d);let c=await S.serviceLog().catch(()=>null);c&&this.paintLive(c,this.events)});dom.content(this.wdEl,e("div",{class:"dl-panel dl-wd"},[e("div",{class:"dl-wd-head"},[e("span",{class:`dl-wd-tile${a.enabled?"":" off"}`},g("shield")),e("div",{class:"dl-stack"},[e("span",{class:"dl-wd-title"},"Watchdog"),e("span",{class:"dl-sub"},a.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),e("span",{class:"dl-spacer"}),l]),e("div",{class:"dl-wd-foot"},[e("div",{class:"dl-wd-chips"},a.targets.map(d=>e("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?"OK":`Not working${d.tries?` · ${d.tries} repair${d.tries>1?"s":""}`:""}`},[g(d.ok?"check":"x"),d.name]))),e("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 ${de(a.last,a.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${wt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let t=(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>=t&&jt(r)).sort((r,i)=>i.ts-r.ts),a=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Recent problems"),e("span",{class:"dl-spacer"}),o.length?e("a",{href:"#",click:r=>(r.preventDefault(),this.toLog())},"All in Log →"):""]);if(!o.length){dom.content(this.recentEl,[a,e("div",{class:"dl-recent-empty"},[e("span",{class:"dl-check-icon ok"},g("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 nn(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},wt(i.ts))}return Ye(this.st,r.ev,{time:wt(r.ts)})})])}};var mn=300,xi=["all","connections","people","system","problems"],hn=class{constructor(t,o,a){this.events=[];this.system=[];this.kind="all";this.shown=mn;this.open=new Set;this.list=e("div",{});this.sub="";this.tabs=e("div",{class:"dl-seg",role:"tablist"});this.st=t,this.take(o),this.system=a,this.el=e("div",{},[e("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let t=()=>this.kind==="all"?"":this.kind,o=i=>()=>{let s=this.filtered().reverse();je(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,t(),s.filter(l=>l.sys).map(l=>l.sys))},a=D([g("download")," Export"],()=>we(a,[{label:"CSV (spreadsheet)",icon:g("download"),run:o("csv")},{label:"JSON",icon:g("download"),run:o("json")}])),r=D([g("trash")," Clear"],()=>Fe("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(t){this.events=t.events,this.policy=t.policy;let o=pt.filter(a=>!t.policy.categories.includes(a));this.sub=`${Ut(t.policy)}${o.length?` Not recorded: ${o.map(a=>nt[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[t,o]=await Promise.all([S.events(2e4).catch(()=>null),S.serviceLog().catch(()=>null)]);t&&this.take(t),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(t=>({ts:t.ts,ev:t})),...this.system.map(t=>({ts:t.ts,sys:t}))].sort((t,o)=>o.ts-t.ts)}matches(t,o){return o==="all"?!0:o==="problems"?jt(t):o==="system"?!!t.sys:!!t.ev&&$t(t.ev.type)===o}filtered(){return this.items().filter(t=>this.matches(t,this.kind))}paintTabs(t){dom.content(this.tabs,xi.map(o=>e("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":nt[o],e("b",{},String(t.filter(a=>this.matches(a,o)).length))])))}show(t){this.kind=t,this.shown=mn,this.paint()}paint(){this.paintTabs(this.items());let t=this.filtered();if(!t.length){dom.content(this.list,e("div",{class:"dl-empty"},[e("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let o=[],a="",r=null;for(let i of t.slice(0,this.shown)){let s=No(i.ts);s!==a&&(a=s,r=e("div",{class:"dl-panel flush"},e("div",{class:"dl-panel-head pad"},e("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 d=`${i.sys.ts}|${i.sys.msg}`;r.appendChild(nn(i.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else r.appendChild(Ye(this.st,i.ev,{time:l}))}t.length>this.shown&&o.push(e("div",{class:"dl-more-row"},D(`Show ${Math.min(mn,t.length-this.shown)} more of ${t.length-this.shown}`,()=>{this.shown+=mn,this.paint()}))),dom.content(this.list,o)}};var wi=[["health","Health"],["log","Log"]],On=2e4,fn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=e("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=e("span",{class:"dl-muted"});this.actionsEl=e("div",{class:"dl-row-actions"});this.bodyEl=e("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([S.status(1),S.events(On),S.serviceLog()])}render([t,o,a]){return this.log=new hn(t,o,a.log),this.health=new un(t,a,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),Ke({fetch:async()=>{let r=this.tab==="log",[i,s]=await Promise.all([S.serviceLog().catch(()=>null),r?S.events(On).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)}),e("div",{},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(t,o){o&&(this.log.take(o),this.eventsAt=Date.now()),t&&(this.log.system=t.log),t&&this.health.paintLive(t,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(t){this.tab=t,dom.content(this.segEl,wi.map(([o,a])=>e("button",{type:"button",role:"tab",class:o===t?"on":"","aria-selected":o===t?"true":"false",click:()=>o!==this.tab&&this.show(o)},a))),this.bodyEl.replaceChildren(t==="log"?this.log.el:this.health.el),this.subEl.textContent=t==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,t==="log"?this.log.actions():""),t==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&S.events(On).then(o=>this.take(null,o)).catch(()=>null)):this.health.checks||this.health.run()}};var $a=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var _a='.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 .dl-card-name,.dl-plist>.dl-card.dl-off .dl-avatar{opacity:.6}.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 Ea="#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)}@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 Sa=".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 Ca=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-5px;bottom:-5px;width:20px;height:20px;border-radius:7px;background:var(--dl-card);box-shadow:0 0 0 1.5px var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-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-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 La='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var Ta=".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 Ma=".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 Pa=".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 Da='.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.dot{width:8px;height:8px;border-radius:50%;background:var(--dl-fg-faint)}.dl-map-legend i.dot.ok{background:var(--dl-ok)}.dl-map-legend i.line{width:14px;height:2px;border-radius:2px;background:var(--dl-ok)}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;position:relative}.dl-mk-dot{width:12px;height:12px;border-radius:50%;background:#8f8f8f;box-shadow:0 0 0 3px #0000008c}.dl-mk.online .dl-mk-dot{width:14px;height:14px;background:#40c977}.dl-mk.online:before{content:"";position:absolute;inset:-9px;border-radius:50%;background:#40c97747;animation:dl-pulse 2s ease-out infinite}@keyframes dl-pulse{0%{transform:scale(.5);opacity:1}to{transform:scale(1.4);opacity:0}}@media(prefers-reduced-motion:reduce){.dl-mk.online:before{animation:none}}.dl-mk-home{width:22px;height:22px;border-radius:7px;background:#ededed;display:flex;align-items:center;justify-content:center;box-shadow:0 0 0 4px #ededed2e,0 2px 6px #00000080;color:#131313}.dl-mk-home-ic{width:13px;height:13px}.dl-popup{z-index:4}.dl-popup .maplibregl-popup-content{background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);border-radius:12px;padding:12px;box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));font:inherit}.dl-popup .maplibregl-popup-tip{border-top-color:var(--dl-elevated)!important;border-bottom-color:var(--dl-elevated)!important}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-mk.multi{width:26px;height:26px}.dl-mk-count{min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:#8f8f8f;color:#0a0a0a;font:600 11px/22px var(--dl-mono);text-align:center;box-shadow:0 0 0 3px #0000008c;box-sizing:border-box}.dl-mk.online .dl-mk-count{background:#40c977}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px -4px 0}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:5px 4px;border-radius:6px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.maplibregl-ctrl-attrib{font-size:10px}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}';var Aa=`.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)}.dl-plist>.dl-card.dl-attn-row{border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)}@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 za=".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 Na=".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-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 Ra=".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 Ha=".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 Ri=[$a,_a,Ea,Sa,Ca,La,Ta,Ma,Pa,Da,Aa,za,Na,Ra,Ha].join(` +`);function Ia(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=Ri,n}function rt(n){return()=>{let t=new n;return Object.assign({load:()=>t.load(),render:async a=>{let r=await t.render(a),i=document.createElement("div");return i.className="dl-root",i.append(Ia(),r),i},addFooter(){return t.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var Uf=rt(At),Wf=rt(at),Gf=rt(At),qf=rt(ln),Ff=rt(pn),Kf=rt(fn),Jf=rt(cn);function Ba(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 Vf=Ba(""),Yf=Ba("log");return baseclass.extend({ activity: Yf, diagnostics: Kf, health: Vf, overview: Uf, people: Wf, person: Ff, server: Gf, settings: qf, updates: Jf }); diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent index 2b09607..f681d2c 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent @@ -1,9 +1,11 @@ #!/usr/bin/ucode -// Dawnline agent (procd instance). Every minute it: +// Dawnline agent (procd instance). Every second its watcher reads the tunnels +// and, the moment a device connects, its session expires or it roams, logs +// it, folds the counters, locates the new address and moves the revision the +// admin UI polls (presence.json, see dawnline.live). Every minute it: // * folds the tunnels' counters into usage (tmpfs; flushed to flash hourly) // * saves the activity log to flash as often as Settings says (or never) // * keeps the "like a home device" path and the Home-only resolver up -// * logs connects, disconnects and roaming // * enforces end dates, quotas, schedules and pauses (peers + nft sets) // * watches the tunnel interfaces and repairs what it can (dawnline.watchdog) 'use strict'; @@ -11,7 +13,7 @@ import * as uloop from 'uloop'; import { readfile, writefile, stat, unlink } from 'fs'; import { - read_json, write_json, ensure_dir, sh_out, q, 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, DATA_DIR, RUN_DIR, VERSION } from 'dawnline.util'; import * as core from 'dawnline.core'; import * as live from 'dawnline.live'; @@ -23,8 +25,10 @@ import * as watchdog from 'dawnline.watchdog'; import * as net from 'dawnline.net'; import * as store from 'dawnline.store'; import * as upd from 'dawnline.updates'; +import * as awg from 'dawnline.awg'; const TICK = 60 * 1000; +const WATCH = 1000; const FLUSH_EVERY = 3600; const LOG_FLUSH = { '10min': 600, hourly: 3600 }; const RESYNC_EVERY = 600; @@ -34,10 +38,11 @@ let usage = live.load_usage(); let last_states = null; // Who was online, kept in tmpfs so an agent restart (update, reload) does not // swallow connects that happened in between. -let presence = read_json(`${RUN_DIR}/presence.json`, {}); +let presence = read_json(live.PRESENCE, {}); let last_online = presence.online ?? {}; let last_endpoint = presence.endpoint ?? {}; -let offline_ticks = {}; +let rev = +(presence.rev ?? 0); +let person_rev = presence.people ?? {}; let last_flush = time(); let last_log_flush = time(); // The network as apply() last saw it (apply.NET_SIG; this when it never ran), @@ -165,41 +170,98 @@ function named(e) { return e; } -function check_devices(m, lv, events) { - for (let id, d in lv) { - let dev = m.devices[id]; +/* ---------- the watcher ---------- */ + +// Per device: its latest real handshake, kept when apply re-adds the peer +// (its counters and handshake restart from zero, or it is briefly missing). +let last_hs = {}; +// The model, read again only when the config file changes (the watcher runs every second). +let wm = null, wm_sig = null; + +function watch_model() { + // uci commits replace the file: a new inode even within the same second. + let st = stat(CONFIG_FILE); + let sig = st ? `${st.mtime}/${st.inode}` : null; + if (wm == null || sig != wm_sig) { + wm = core.load(); + wm_sig = sig; + } + return wm; +} + +/** Move the revisions (all, and these people's) and save who is online. */ +function save_presence(people) { + rev++; + for (let pid in people) + person_rev[pid] = rev; + ensure_dir(RUN_DIR); + write_json(live.PRESENCE, { online: last_online, endpoint: last_endpoint, rev, people: person_rev }, 0o600); +} + +/* + * One look at the tunnels. Connects (a new handshake from a device that was + * away), disconnects (its session expired: no handshake for live.ONLINE_WINDOW; + * a phone asleep looks the same as one switched off, so silence alone is not + * enough) and roaming (a new address) are acted on at + * once: the log, the counters and the map, then the revision the UI polls. + * Only from a complete read: a failed one says nothing about anyone. + */ +function watch() { + let d = awg.dump(); + if (!d.ok) + return; + let m = watch_model(); + let now = time(); + let events = [], people = {}, ips = []; + for (let id, dev in m.devices) { + let peer = d.peers[dev.public_key]; + let ep = ''; + if (peer) { + last_hs[id] = max(last_hs[id] ?? 0, peer.handshake); + ep = live.endpoint_ip(peer.endpoint); + } + let on = last_hs[id] > 0 && now - last_hs[id] < live.ONLINE_WINDOW; let was = last_online[id]; - // A device we have never seen before that is online now counts as a connect. - if (was == null && d.online && d.present) - was = false; - // Debounce: a device has to look offline on two ticks in a row before - // a disconnect is logged (handshakes are renewed only every 2-3 min). - if (was && !d.online) { - offline_ticks[id] = (offline_ticks[id] ?? 0) + 1; - if (offline_ticks[id] < 2) - continue; + if (on && !was) { + push(events, { type: 'connect', person: dev.person, device: id, detail: ep }); + push(ips, ep); } - else - delete offline_ticks[id]; - if (was != null && was != d.online) { - if (d.online) - push(events, named({ type: 'connect', person: dev.person, device: id, detail: d.endpoint, where: place_of(d.endpoint) })); - else - push(events, { type: 'disconnect', person: dev.person, device: id }); + else if (!on && was) + push(events, { type: 'disconnect', person: dev.person, device: id }); + else if (on && ep && last_endpoint[id] && ep != last_endpoint[id]) { + push(events, { type: 'roam', person: dev.person, device: id, detail: `${last_endpoint[id]} → ${ep}` }); + push(ips, ep); } - else if (d.online && last_endpoint[id] && d.endpoint && last_endpoint[id] != d.endpoint) - push(events, named({ type: 'roam', person: dev.person, device: id, detail: `${last_endpoint[id]} → ${d.endpoint}` })); - last_online[id] = d.online; - if (d.endpoint) - last_endpoint[id] = d.endpoint; + if (on != !!was || (ep && ep != last_endpoint[id])) + people[dev.person] = true; + last_online[id] = on; + if (ep) + last_endpoint[id] = ep; } for (let id in keys(last_online)) if (!m.devices[id]) { delete last_online[id]; delete last_endpoint[id]; + delete last_hs[id]; } - ensure_dir(RUN_DIR); - write_json(`${RUN_DIR}/presence.json`, { online: last_online, endpoint: last_endpoint }, 0o600); + if (!length(keys(people))) + return; + // The status first, then what takes longer (a geo lookup may wait on the network). + save_presence(keys(people)); + if (!length(events)) + return; + live.collect(m, usage, d); + live.save_usage(usage, false); + if (m.settings.geo_enabled && length(ips)) { + let cache = geo.load(); + if (geo.resolve(m.settings, cache, ips, length(ips))) + geo.save(cache); + } + for (let e in events) + if (e.type == 'connect') + e.where = place_of(e.detail); + live.add_events(map(events, (e) => e.type == 'disconnect' ? e : named(e)), live.policy(m.settings.retention)); + save_presence(keys(people)); } // What the service log was already told. On flash: the public address often @@ -361,15 +423,9 @@ const STEPS = [ } }, { who: 'Traffic', run: (t) => { t.reset = check_usage_reset(t.m); - t.dmp = live.dump(t.m); - t.lv = live.collect(t.m, usage, t.dmp); + live.collect(t.m, usage, live.dump(t.m)); } }, { who: 'Speed', quiet: true, run: (t) => record_rate(t.m) }, - // Connects and disconnects only from a complete read of the tunnels. - { who: 'Connections', run: (t) => { - if (t.lv && t.dmp?.ok) - check_devices(t.m, t.lv, t.events); - } }, { who: 'People', run: (t) => { t.states = apply.states_for(t.m, usage); check_people(t.m, t.states, t.events); @@ -379,7 +435,12 @@ const STEPS = [ sync_runtime(t); } }, // Tunnels going down and up are in the service log (hotplug, watchdog), with names and reasons. - { who: 'Activity', run: (t) => live.add_events(t.events, t.pol) }, + { who: 'Activity', run: (t) => { + live.add_events(t.events, t.pol); + // Pauses and resumes on their own: the UI shows them without waiting for its next poll. + if (length(t.events)) + save_presence(uniq(map(filter(t.events, (e) => e.person), (e) => e.person))); + } }, { who: 'Internet like a home device', run: (t) => apply.sync_loop(t.m, usage) }, { who: 'Router', run: check_network }, { who: 'Watchdog', run: (t) => watchdog.run(core.load()) }, @@ -479,6 +540,12 @@ timer = uloop.timer(1000, function() { timer.set(TICK); }); +let watcher; +watcher = uloop.timer(WATCH, function() { + step('watch', { who: 'Connections' }, watch); + watcher.set(WATCH); +}); + if (type(uloop.signal) == 'function') { uloop.signal('TERM', () => { shutdown(); uloop.end(); }); uloop.signal('INT', () => { shutdown(); uloop.end(); }); 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 9037512..ed4736f 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 ct=Object.create;var He=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty;var ht=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var pt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ut(t))!dt.call(e,u)&&u!==r&&He(e,u,{get:()=>t[u],enumerable:!(s=lt(t,u))||s.enumerable});return e};var vt=(e,t,r)=>(r=e!=null?ct(ft(e)):{},pt(t||!e||!e.__esModule?He(r,"default",{value:e,enumerable:!0}):r,e));var je=ht((Ve,Ye)=>{"use strict";var qe=(function(){var e=function(M,A){var b=236,w=17,c=M,m=r[A],i=null,a=0,y=null,d=[],g={},L=function(l,f){a=c*4+17,i=(function(o){for(var h=new Array(o),v=0;v=7&&z(l),y==null&&(y=st(c,m,d)),W(y,f)},D=function(l,f){for(var o=-1;o<=7;o+=1)if(!(l+o<=-1||a<=l+o))for(var h=-1;h<=7;h+=1)f+h<=-1||a<=f+h||(0<=o&&o<=6&&(h==0||h==6)||0<=h&&h<=6&&(o==0||o==6)||2<=o&&o<=4&&2<=h&&h<=4?i[l+o][f+h]=!0:i[l+o][f+h]=!1)},P=function(){for(var l=0,f=0,o=0;o<8;o+=1){L(!0,o);var h=u.getLostPoint(g);(o==0||l>h)&&(l=h,f=o)}return f},I=function(){for(var l=8;l>o&1)==1;i[Math.floor(o/3)][o%3+a-8-3]=h}for(var o=0;o<18;o+=1){var h=!l&&(f>>o&1)==1;i[o%3+a-8-3][Math.floor(o/3)]=h}},Q=function(l,f){for(var o=m<<3|f,h=u.getBCHTypeInfo(o),v=0;v<15;v+=1){var x=!l&&(h>>v&1)==1;v<6?i[v][8]=x:v<8?i[v+1][8]=x:i[a-15+v][8]=x}for(var v=0;v<15;v+=1){var x=!l&&(h>>v&1)==1;v<8?i[8][a-v-1]=x:v<9?i[8][15-v-1+1]=x:i[8][15-v-1]=x}i[a-8][8]=!l},W=function(l,f){for(var o=-1,h=a-1,v=7,x=0,C=u.getMaskFunction(f),_=a-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var N=0;N<2;N+=1)if(i[h][_-N]==null){var K=!1;x>>v&1)==1);var T=C(h,_-N);T&&(K=!K),i[h][_-N]=K,v-=1,v==-1&&(x+=1,v=7)}if(h+=o,h<0||a<=h){h-=o,o=-o;break}}},ae=function(l,f){for(var o=0,h=0,v=0,x=new Array(f.length),C=new Array(f.length),_=0;_=0?Pe.getAt(Ne):0}}for(var Re=0,T=0;T_*8)throw"code length overflow. ("+v.getLengthInBits()+">"+_*8+")";for(v.getLengthInBits()+4<=_*8&&v.put(0,4);v.getLengthInBits()%8!=0;)v.putBit(!1);for(;!(v.getLengthInBits()>=_*8||(v.put(b,8),v.getLengthInBits()>=_*8));)v.put(w,8);return ae(v,h)};g.addData=function(l,f){f=f||"Byte";var o=null;switch(f){case"Numeric":o=B(l);break;case"Alphanumeric":o=q(l);break;case"Byte":o=J(l);break;case"Kanji":o=U(l);break;default:throw"mode:"+f}d.push(o),y=null},g.isDark=function(l,f){if(l<0||a<=l||f<0||a<=f)throw l+","+f;return i[l][f]},g.getModuleCount=function(){return a},g.make=function(){if(c<1){for(var l=1;l<40;l++){for(var f=$.getRSBlocks(l,m),o=E(),h=0;h";for(var v=0;v';o+=""}return o+="",o+="",o},g.createSvgTag=function(l,f,o,h){var v={};typeof arguments[0]=="object"&&(v=arguments[0],l=v.cellSize,f=v.margin,o=v.alt,h=v.title),l=l||2,f=typeof f=="undefined"?l*4:f,o=typeof o=="string"?{text:o}:o||{},o.text=o.text||null,o.id=o.text?o.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 x=g.getModuleCount()*l+f*2,C,_,N,K,T="",Y;for(Y="l"+l+",0 0,"+l+" -"+l+",0 0,-"+l+"z ",T+=''+ie(h.text)+"":"",T+=o.text?''+ie(o.text)+"":"",T+='',T+='":f+=">";break;case"&":f+="&";break;case'"':f+=""";break;default:f+=h;break}}return f},ot=function(l){var f=1;l=typeof l=="undefined"?f*2:l;var o=g.getModuleCount()*f+l*2,h=l,v=o-l,x,C,_,N,K,T={"██":"█","█ ":"▀"," █":"▄"," ":" "},Y={"██":"▀","█ ":"▀"," █":" "," ":" "},j="";for(x=0;x=v?Y[K]:T[K];j+=` -`}return o%2&&l>0?j.substring(0,j.length-o-1)+Array(o+1).join("▀"):j.substring(0,j.length-1)};return g.createASCII=function(l,f){if(l=l||1,l<2)return ot(f);l-=1,f=typeof f=="undefined"?l*2:f;var o=g.getModuleCount()*l+f*2,h=f,v=o-f,x,C,_,N,K=Array(l+1).join("██"),T=Array(l+1).join(" "),Y="",j="";for(x=0;x>>8),m.push(y&255)):m.push(w)}}return m}};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},u=(function(){var M=[[],[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]],A=1335,b=7973,w=21522,c={},m=function(i){for(var a=0;i!=0;)a+=1,i>>>=1;return a};return c.getBCHTypeInfo=function(i){for(var a=i<<10;m(a)-m(A)>=0;)a^=A<=0;)a^=b<5&&(y+=3+L-5)}for(var d=0;d=256;)c-=255;return M[c]},w})();function k(M,A){if(typeof M.length=="undefined")throw M.length+"/"+A;var b=(function(){for(var c=0;c>>7-w%8&1)==1},b.put=function(w,c){for(var m=0;m>>c-m-1&1)==1)},b.getLengthInBits=function(){return A},b.putBit=function(w){var c=Math.floor(A/8);M.length<=c&&M.push(0),w&&(M[c]|=128>>>A%8),A+=1},b},B=function(M){var A=t.MODE_NUMBER,b=M,w={};w.getMode=function(){return A},w.getLength=function(i){return b.length},w.write=function(i){for(var a=b,y=0;y+2>>8&255)*192+(d&255),i.put(d,13),y+=2}if(y>>8)},A.writeBytes=function(b,w,c){w=w||0,c=c||b.length;for(var m=0;m0&&(b+=","),b+=M[w];return b+="]",b},A},F=function(){var M=0,A=0,b=0,w="",c={},m=function(a){w+=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(M=M<<8|a&255,A+=8,b+=1;A>=6;)m(M>>>A-6),A-=6},c.flush=function(){if(A>0&&(m(M<<6-A),M=0,A=0),b%3!=0)for(var a=3-b%3,y=0;y=A.length){if(c==0)return-1;throw"unexpected end of file./"+c}var a=A.charAt(b);if(b+=1,a=="=")return c=0,-1;if(a.match(/^\s$/))continue;w=w<<6|i(a.charCodeAt(0)),c+=6}var y=w>>>c-8&255;return c-=8,y};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 m},re=function(M,A){var b=M,w=A,c=new Array(M*A),m={};m.setPixel=function(d,g,L){c[g*b+d]=L},m.write=function(d){d.writeString("GIF87a"),d.writeShort(b),d.writeShort(w),d.writeByte(128),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(255),d.writeByte(255),d.writeByte(255),d.writeString(","),d.writeShort(0),d.writeShort(0),d.writeShort(b),d.writeShort(w),d.writeByte(0);var g=2,L=a(g);d.writeByte(g);for(var D=0;L.length-D>255;)d.writeByte(255),d.writeBytes(L,D,255),D+=255;d.writeByte(L.length-D),d.writeBytes(L,D,L.length-D),d.writeByte(0),d.writeString(";")};var i=function(d){var g=d,L=0,D=0,P={};return P.write=function(I,G){if(I>>>G)throw"length over";for(;L+G>=8;)g.writeByte(255&(I<>>=8-L,D=0,L=0;D=I<0&&g.writeByte(D)},P},a=function(d){for(var g=1<>6,128|p&63):p<55296||p>=57344?s.push(224|p>>12,128|p>>6&63,128|p&63):(u++,p=65536+((p&1023)<<10|r.charCodeAt(u)&1023),s.push(240|p>>18,128|p>>12&63,128|p>>6&63,128|p&63))}return s}return t(e)}})();(function(e){typeof define=="function"&&define.amd?define([],e):typeof Ve=="object"&&(Ye.exports=e())})(function(){return qe})});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 we(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 gt(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 xe(e){return e?gt(e):""}function mt(e,t){let r=s=>{let[u,p,k]=s.split("-").map(Number);return Date.UTC(u,p-1,k)};return Math.round((r(e)-r(t))/864e5)}function Ie(e,t){let r=ve(e);return r.setDate(r.getDate()+t),pe(r)}function Me(e,t=Date.now()){if(!e)return null;let r=typeof t=="number"?pe(new Date(t)):t,s=mt(e,r);return s>=0?s+1:s}var Oe={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var ge={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Ke={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Ue(e){var u,p,k;let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let r=(u=t[0][0])!=null?u:"",s=t.length>1?(p=t[t.length-1][0])!=null?p:"":(k=t[0][1])!=null?k:"";return(r+s).toUpperCase()}function ke(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 Fe={phone:'',computer:'',tablet:'',router:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function Ge(e,t="dl-icon"){var s;let r=(s=Fe[e])!=null?s:Fe.phone;return``}var ze=vt(je(),1),yt='';function Je(e,t=3,r=!0){let s=(0,ze.default)(0,e.length>300?"Q":"H");s.addData(e,"Byte"),s.make();let u=s.getModuleCount(),p=u+t*2,k=r?Math.round(u*.22):0;k&&(u-k)%2&&k++;let $=(u-k)/2,E=$+k,B=(U,R)=>k>0&&U>=$&&U=$&&R${yt}`}return`${J}`}var bt={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:""},wt={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 xt(e){let t={};for(let[r,s]of Object.entries(wt))e[r]!=null&&e[r]!==""&&(t[s]=String(e[r]));return t}function Mt(e,t){var E;let r=e.amnezia,s=(E=r.obfuscation)!=null?E:{},u=B=>s[B]!=null&&s[B]!==""?String(s[B]):bt[B],p=r.host.replace(/^\[(.*)\]$/,"$1"),k={H1:u("h1"),H2:u("h2"),H3:u("h3"),H4:u("h4"),I1:u("i1"),I2:u("i2"),I3:u("i3"),I4:u("i4"),I5:u("i5"),Jc:u("jc"),Jmin:u("jmin"),Jmax:u("jmax"),S1:u("s1"),S2:u("s2"),S3:u("s3"),S4:u("s4"),...xt(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:p,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},$={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(k),port:String(r.port),protocol_version:s.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:p};return r.dns[0]&&($.dns1=r.dns[0]),r.dns[1]&&($.dns2=r.dns[1]),$}function kt(e){let t="";for(let r=0;r{var e;return(e=S==null?void 0:S.today)!=null?e:pe(new Date)};function n(e,t={},...r){let s=document.createElement(e);for(let[p,k]of Object.entries(t))k==null||k===!1||(p.startsWith("on")&&typeof k=="function"?s.addEventListener(p.slice(2),k):p==="class"?s.className=String(k):k===!0?s.setAttribute(p,""):s.setAttribute(p,String(k)));let u=p=>{p==null||p===!1||(Array.isArray(p)?p.forEach(u):s.appendChild(typeof p=="string"?document.createTextNode(p):p))};return r.forEach(u),s}function O(e){let t=n("span",{class:"ic"});return t.innerHTML=Ge(e,"ic-svg"),t}var _t='',Ee=document.getElementById("app"),Ze,me=(Ze=Ee.dataset.base)!=null?Ze:"",Ct=Ee.dataset.title||"Dawnline",Ce=()=>window.matchMedia("(max-width: 959px)").matches||/Android|iPhone|iPad/.test(navigator.userAgent),S=null,Qe=0,Tt=/^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(me)?me.slice(1):"",Te=class extends Error{constructor(r,s){super(s);this.status=r}};async function ne(e,t){var u;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 Te(r.status,(u=s==null?void 0:s.error)!=null?u:`Request failed (${r.status})`);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 ce(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 Xe(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 Z=null;function et(e,t){let r=s=>{Z!=null||(Z=document.body.appendChild(n("div",{class:"tip"}))),Z.replaceChildren(...t().map((u,p)=>n("div",{class:p?"muted":"tip-title"},u))),Z.style.display="",Z.style.left=`${s.clientX}px`,Z.style.top=`${s.clientY-10}px`};e.addEventListener("mouseenter",r),e.addEventListener("mousemove",r),e.addEventListener("mouseleave",()=>Z&&(Z.style.display="none"))}function Lt(e){let t=Math.max(1,...e),r=n("div",{class:"spark"});return e.forEach((s,u)=>{let p=n("i",{class:s?"":"zero"});p.style.height=`${Math.max(8,s/t*100)}%`;let k=e.length-1-u;et(p,()=>[k===0?"Today":k===1?"Yesterday":ve(Ie(De(),-k)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),se(s)]),r.appendChild(p)}),r}async function Be(e,t){if(!e.disabled){e.disabled=!0;try{await t()}finally{e.disabled=!1}}}var oe=null,le=null;function ee(e=!1){if(!oe)return;let t=oe;if(oe=null,document.body.classList.remove("locked"),le==null||le(),le=null,e){t.remove();return}t.classList.remove("open"),setTimeout(()=>t.remove(),250)}function fe(e,t,...r){let s=!!oe;ee(!0);let u=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()},O("x"))),n("div",{class:"sheet-body"},...r)),p=n("div",{class:"sheet",onclick:k=>{k.target===p&&ee()}},u);return document.body.appendChild(p),document.body.classList.add("locked"),s?p.classList.add("open"):requestAnimationFrame(()=>p.classList.add("open")),oe=p,u}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 Dt(e,t){ye();let r=t.filter((k,$)=>k||$>0&&t[$-1]&&t.slice($+1).some(Boolean)),s=n("div",{class:"menu",role:"menu"},r.map(k=>k?n("button",{type:"button",role:"menuitem",class:`menu-item${k.danger?" danger":""}`,onclick:()=>{ye(),k.run()}},O(k.icon),n("span",{},k.label)):n("div",{class:"menu-sep"})));document.body.appendChild(s);let u=e.getBoundingClientRect(),p=230;s.style.left=`${Math.max(8,Math.min(window.innerWidth-p-8,u.right-p))}px`,s.style.top=`${u.bottom+6+window.scrollY}px`,X=s}function $e(...e){Ee.replaceChildren(n("header",{class:"top"},n("div",{class:"brand"},(()=>{let t=n("span",{class:"logo"});return t.innerHTML=_t,t})(),n("span",{},(S==null?void 0:S.server.name)||Ct),n("span",{class:"faint"},"· Dawnline"))),n("main",{class:"wrap"},...e))}function tt(){$e(n("div",{class:"card signin"},n("div",{class:"hero-ic"},O("key")),n("h1",{},"This link no longer works"),n("p",{class:"muted"},"Ask for a new personal link.")))}function Et(e){return e.state==="active"?"ok":e.state==="quota"||e.state==="expired"?"bad":"warn"}var Bt={internet:"The internet, through the router",lan:"Devices at home",both:"Devices at home and the internet, through the router"};function $t(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&&et(s,()=>[`${r.toFixed(1)}% used`,`${se(Math.max(0,t.quota_limit-t.quota_used))} left`]);let u=Me(t.expires,De()),p=n("div",{class:"slots"});for(let E=0;E=t.device_limit?"over":E=0?`${u} day${u===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 St(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 ${we(e.handshake)}`):n("span",{class:"dstat warn"},"Not set up yet")}function nt(e,t){return e.access!=="internet"&&e.state==="active"&&!t.disabled}function Pt(e,t){let r=ke(e.devices).filter(p=>p.hostname&&nt(e,p));if(!r.length)return null;let s=r[0].hostname,u=s.slice(s.indexOf("."));return n("div",{class:"names"},n("div",{class:"names-head"},n("span",{class:"names-ic"},O("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${u}`)))),n("div",{class:"names-list"},r.map(p=>{let k=p.hostname.indexOf(".");return n("button",{type:"button",class:"name-chip",title:p.name,"aria-label":`Copy ${p.hostname}`,onclick:()=>ce(p.hostname,"Address copied")},n("span",{class:"mono"},k>0?[p.hostname.slice(0,k),n("span",{class:"faint"},p.hostname.slice(k))]:p.hostname),O("copy"))})))}function Nt(e,t){let r=n("button",{type:"button",class:"icon-btn soft","aria-label":`${e.name} options`},O("more"));r.addEventListener("click",k=>{k.stopPropagation(),Dt(r,[{label:"Show QR code",icon:"qr",run:()=>ue(e,"qr")},{label:"Copy AmneziaVPN key",icon:"key",run:()=>Rt(e)},{label:"Download .conf",icon:"download",run:()=>Ht(e)},null,...nt(t.person,e)?[{label:"Copy IP address",icon:"copy",run:()=>ce(e.address,"IP address copied")},...e.hostname?[{label:"Copy local address",icon:"home",run:()=>ce(e.hostname,"Address copied")}]:[],null]:[],...e.disabled?[]:[{label:"Rename",icon:"edit",run:()=>Ot(e)},{label:"New keys",icon:"reset",run:()=>Kt(e,t)},{label:"Remove",icon:"trash",danger:!0,run:()=>Ut(e)}]])});let s=e.spark.reduce((k,$)=>k+$,0),u=!e.handshake&&!e.disabled,p=t.here===e.id;return n("article",{class:`dcard${e.online?" online":""}${e.disabled?" off":""}${p?" here":""}`},n("div",{class:"dhead"},n("span",{class:"dic"},O(e.kind)),n("div",{class:"stack grow"},n("span",{class:"dname"},e.name),p?n("span",{class:"dstat here"},"This device"):St(e)),r),u?[n("button",{type:"button",class:"btn primary block",onclick:()=>ue(e)},O(Ce()?"open":"qr"),n("span",{},Ce()?"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))),Lt(e.spark)),e.config_stale&&!u?n("div",{class:"notice"},O("alert"),n("span",{class:"grow"},"Connection settings changed. Update this device to keep everything working."),n("button",{type:"button",class:"btn small",onclick:()=>ue(e)},"Update")):null)}function de(e){let t=e.person,r=Me(t.expires,De()),s=t.state!=="active"?n("div",{class:"notice bad"},O("alert"),n("span",{},t.state==="quota"?"You have used all your data for this period. Your devices are paused until it resets.":t.state==="expired"?"Your access has ended. Ask the admin to extend it.":t.state==="hours"?`Access is available ${t.hours.replace("-","–")} (router time).`:"Your access is paused by the admin.")):r!=null&&r>=0&&r<=Math.max(t.expire_warn,1)?n("div",{class:"notice"},O("alert"),n("span",{},`Your access ends ${r===0?"today":`in ${r} day${r===1?"":"s"}`} (${xe(t.expires)}).`)):null,p=ke(t.devices).sort((E,B)=>+(B.id===e.here)-+(E.id===e.here)).map(E=>Nt(E,e));Math.max(0,t.device_limit-t.devices.length)&&p.push(n("button",{type:"button",class:"slot add",onclick:Vt},n("span",{class:"slot-ic"},O("plus")),n("span",{class:"strong"},"Add device")));let $=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"},p),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."));$e(n("div",{class:"hello"},n("span",{class:`avatar${t.online?" online":""}`},Ue(t.name)),n("div",{class:"stack"},n("div",{class:"row"},n("h1",{},`Hi, ${t.name}`),t.state==="active"?null:n("span",{class:`pill ${Et(t)}`},Ke[t.state])))),s,n("div",{class:"layout"},$t(e),$))}async function Se(e){try{return await ne(`devices/${e.id}/config`)}catch(t){return te(t.message,!0),null}}async function Rt(e){let t=await Se(e);t&&ce(await Ae(t,`${t.server} · ${t.name}`),"Key copied")}async function Ht(e){let t=await Se(e);t&&Xe(t.filename,t.conf)}function We(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 It(e){let t=!1,r=n("pre",{class:"conf"}),s=()=>r.replaceChildren(...e.conf.split(` +"use strict";(()=>{var it=Object.create;var He=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var ft=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var dt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ct(t))!ut.call(e,u)&&u!==r&&He(e,u,{get:()=>t[u],enumerable:!(i=ot(t,u))||i.enumerable});return e};var ht=(e,t,r)=>(r=e!=null?it(lt(e)):{},dt(t||!e||!e.__esModule?He(r,"default",{value:e,enumerable:!0}):r,e));var je=ft((Ve,Ye)=>{"use strict";var qe=(function(){var e=function(M,A){var b=236,x=17,c=M,m=r[A],s=null,a=0,y=null,d=[],g={},T=function(l,f){a=c*4+17,s=(function(o){for(var h=new Array(o),v=0;v=7&&z(l),y==null&&(y=at(c,m,d)),W(y,f)},D=function(l,f){for(var o=-1;o<=7;o+=1)if(!(l+o<=-1||a<=l+o))for(var h=-1;h<=7;h+=1)f+h<=-1||a<=f+h||(0<=o&&o<=6&&(h==0||h==6)||0<=h&&h<=6&&(o==0||o==6)||2<=o&&o<=4&&2<=h&&h<=4?s[l+o][f+h]=!0:s[l+o][f+h]=!1)},P=function(){for(var l=0,f=0,o=0;o<8;o+=1){T(!0,o);var h=u.getLostPoint(g);(o==0||l>h)&&(l=h,f=o)}return f},I=function(){for(var l=8;l>o&1)==1;s[Math.floor(o/3)][o%3+a-8-3]=h}for(var o=0;o<18;o+=1){var h=!l&&(f>>o&1)==1;s[o%3+a-8-3][Math.floor(o/3)]=h}},Q=function(l,f){for(var o=m<<3|f,h=u.getBCHTypeInfo(o),v=0;v<15;v+=1){var w=!l&&(h>>v&1)==1;v<6?s[v][8]=w:v<8?s[v+1][8]=w:s[a-15+v][8]=w}for(var v=0;v<15;v+=1){var w=!l&&(h>>v&1)==1;v<8?s[8][a-v-1]=w:v<9?s[8][15-v-1+1]=w:s[8][15-v-1]=w}s[a-8][8]=!l},W=function(l,f){for(var o=-1,h=a-1,v=7,w=0,C=u.getMaskFunction(f),_=a-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var N=0;N<2;N+=1)if(s[h][_-N]==null){var K=!1;w>>v&1)==1);var L=C(h,_-N);L&&(K=!K),s[h][_-N]=K,v-=1,v==-1&&(w+=1,v=7)}if(h+=o,h<0||a<=h){h-=o,o=-o;break}}},ae=function(l,f){for(var o=0,h=0,v=0,w=new Array(f.length),C=new Array(f.length),_=0;_=0?Pe.getAt(Ne):0}}for(var Re=0,L=0;L_*8)throw"code length overflow. ("+v.getLengthInBits()+">"+_*8+")";for(v.getLengthInBits()+4<=_*8&&v.put(0,4);v.getLengthInBits()%8!=0;)v.putBit(!1);for(;!(v.getLengthInBits()>=_*8||(v.put(b,8),v.getLengthInBits()>=_*8));)v.put(x,8);return ae(v,h)};g.addData=function(l,f){f=f||"Byte";var o=null;switch(f){case"Numeric":o=B(l);break;case"Alphanumeric":o=q(l);break;case"Byte":o=J(l);break;case"Kanji":o=U(l);break;default:throw"mode:"+f}d.push(o),y=null},g.isDark=function(l,f){if(l<0||a<=l||f<0||a<=f)throw l+","+f;return s[l][f]},g.getModuleCount=function(){return a},g.make=function(){if(c<1){for(var l=1;l<40;l++){for(var f=$.getRSBlocks(l,m),o=E(),h=0;h";for(var v=0;v';o+=""}return o+="",o+="",o},g.createSvgTag=function(l,f,o,h){var v={};typeof arguments[0]=="object"&&(v=arguments[0],l=v.cellSize,f=v.margin,o=v.alt,h=v.title),l=l||2,f=typeof f=="undefined"?l*4:f,o=typeof o=="string"?{text:o}:o||{},o.text=o.text||null,o.id=o.text?o.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 w=g.getModuleCount()*l+f*2,C,_,N,K,L="",Y;for(Y="l"+l+",0 0,"+l+" -"+l+",0 0,-"+l+"z ",L+=''+se(h.text)+"":"",L+=o.text?''+se(o.text)+"":"",L+='',L+='":f+=">";break;case"&":f+="&";break;case'"':f+=""";break;default:f+=h;break}}return f},st=function(l){var f=1;l=typeof l=="undefined"?f*2:l;var o=g.getModuleCount()*f+l*2,h=l,v=o-l,w,C,_,N,K,L={"██":"█","█ ":"▀"," █":"▄"," ":" "},Y={"██":"▀","█ ":"▀"," █":" "," ":" "},j="";for(w=0;w=v?Y[K]:L[K];j+=` +`}return o%2&&l>0?j.substring(0,j.length-o-1)+Array(o+1).join("▀"):j.substring(0,j.length-1)};return g.createASCII=function(l,f){if(l=l||1,l<2)return st(f);l-=1,f=typeof f=="undefined"?l*2:f;var o=g.getModuleCount()*l+f*2,h=f,v=o-f,w,C,_,N,K=Array(l+1).join("██"),L=Array(l+1).join(" "),Y="",j="";for(w=0;w>>8),m.push(y&255)):m.push(x)}}return m}};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},i={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},u=(function(){var M=[[],[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]],A=1335,b=7973,x=21522,c={},m=function(s){for(var a=0;s!=0;)a+=1,s>>>=1;return a};return c.getBCHTypeInfo=function(s){for(var a=s<<10;m(a)-m(A)>=0;)a^=A<=0;)a^=b<5&&(y+=3+T-5)}for(var d=0;d=256;)c-=255;return M[c]},x})();function k(M,A){if(typeof M.length=="undefined")throw M.length+"/"+A;var b=(function(){for(var c=0;c>>7-x%8&1)==1},b.put=function(x,c){for(var m=0;m>>c-m-1&1)==1)},b.getLengthInBits=function(){return A},b.putBit=function(x){var c=Math.floor(A/8);M.length<=c&&M.push(0),x&&(M[c]|=128>>>A%8),A+=1},b},B=function(M){var A=t.MODE_NUMBER,b=M,x={};x.getMode=function(){return A},x.getLength=function(s){return b.length},x.write=function(s){for(var a=b,y=0;y+2>>8&255)*192+(d&255),s.put(d,13),y+=2}if(y>>8)},A.writeBytes=function(b,x,c){x=x||0,c=c||b.length;for(var m=0;m0&&(b+=","),b+=M[x];return b+="]",b},A},F=function(){var M=0,A=0,b=0,x="",c={},m=function(a){x+=String.fromCharCode(s(a&63))},s=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(M=M<<8|a&255,A+=8,b+=1;A>=6;)m(M>>>A-6),A-=6},c.flush=function(){if(A>0&&(m(M<<6-A),M=0,A=0),b%3!=0)for(var a=3-b%3,y=0;y=A.length){if(c==0)return-1;throw"unexpected end of file./"+c}var a=A.charAt(b);if(b+=1,a=="=")return c=0,-1;if(a.match(/^\s$/))continue;x=x<<6|s(a.charCodeAt(0)),c+=6}var y=x>>>c-8&255;return c-=8,y};var s=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 m},re=function(M,A){var b=M,x=A,c=new Array(M*A),m={};m.setPixel=function(d,g,T){c[g*b+d]=T},m.write=function(d){d.writeString("GIF87a"),d.writeShort(b),d.writeShort(x),d.writeByte(128),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(255),d.writeByte(255),d.writeByte(255),d.writeString(","),d.writeShort(0),d.writeShort(0),d.writeShort(b),d.writeShort(x),d.writeByte(0);var g=2,T=a(g);d.writeByte(g);for(var D=0;T.length-D>255;)d.writeByte(255),d.writeBytes(T,D,255),D+=255;d.writeByte(T.length-D),d.writeBytes(T,D,T.length-D),d.writeByte(0),d.writeString(";")};var s=function(d){var g=d,T=0,D=0,P={};return P.write=function(I,G){if(I>>>G)throw"length over";for(;T+G>=8;)g.writeByte(255&(I<>>=8-T,D=0,T=0;D=I<0&&g.writeByte(D)},P},a=function(d){for(var g=1<>6,128|p&63):p<55296||p>=57344?i.push(224|p>>12,128|p>>6&63,128|p&63):(u++,p=65536+((p&1023)<<10|r.charCodeAt(u)&1023),i.push(240|p>>18,128|p>>12&63,128|p>>6&63,128|p&63))}return i}return t(e)}})();(function(e){typeof define=="function"&&define.amd?define([],e):typeof Ve=="object"&&(Ye.exports=e())})(function(){return qe})});function ie(e){if(!e||e<0)return"0 B";let t=["B","KB","MB","GB","TB"],r=0,i=e;for(;i>=1024&&r=100||r===0?Math.round(i):i.toFixed(1)} ${t[r]}`}function xe(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,i]=e.split("-").map(Number);return new Date(t,(r||1)-1,i||1,12)}function pt(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 we(e){return e?pt(e):""}function vt(e,t){let r=i=>{let[u,p,k]=i.split("-").map(Number);return Date.UTC(u,p-1,k)};return Math.round((r(e)-r(t))/864e5)}function Ie(e,t){let r=ve(e);return r.setDate(r.getDate()+t),pe(r)}function Me(e,t=Date.now()){if(!e)return null;let r=typeof t=="number"?pe(new Date(t)):t,i=vt(e,r);return i>=0?i+1:i}var Oe={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var ge={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Ke={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Ue(e){var u,p,k;let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let r=(u=t[0][0])!=null?u:"",i=t.length>1?(p=t[t.length-1][0])!=null?p:"":(k=t[0][1])!=null?k:"";return(r+i).toUpperCase()}function ke(e){let t=r=>r.disabled?3:r.online?0:r.handshake?1:2;return e.map((r,i)=>[r,i]).sort((r,i)=>t(r[0])-t(i[0])||r[1]-i[1]).map(([r])=>r)}var Fe={phone:'',computer:'',tablet:'',router:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function Ge(e,t="dl-icon"){var i;let r=(i=Fe[e])!=null?i:Fe.phone;return``}var ze=ht(je(),1),gt='';function Je(e,t=3,r=!0){let i=(0,ze.default)(0,e.length>300?"Q":"H");i.addData(e,"Byte"),i.make();let u=i.getModuleCount(),p=u+t*2,k=r?Math.round(u*.22):0;k&&(u-k)%2&&k++;let $=(u-k)/2,E=$+k,B=(U,R)=>k>0&&U>=$&&U=$&&R${gt}`}return`${J}`}var mt={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:""},yt={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 bt(e){let t={};for(let[r,i]of Object.entries(yt))e[r]!=null&&e[r]!==""&&(t[i]=String(e[r]));return t}function xt(e,t){var E;let r=e.amnezia,i=(E=r.obfuscation)!=null?E:{},u=B=>i[B]!=null&&i[B]!==""?String(i[B]):mt[B],p=r.host.replace(/^\[(.*)\]$/,"$1"),k={H1:u("h1"),H2:u("h2"),H3:u("h3"),H4:u("h4"),I1:u("i1"),I2:u("i2"),I3:u("i3"),I4:u("i4"),I5:u("i5"),Jc:u("jc"),Jmin:u("jmin"),Jmax:u("jmax"),S1:u("s1"),S2:u("s2"),S3:u("s3"),S4:u("s4"),...bt(i),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:p,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},$={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(k),port:String(r.port),protocol_version:i.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:p};return r.dns[0]&&($.dns1=r.dns[0]),r.dns[1]&&($.dns2=r.dns[1]),$}function wt(e){let t="";for(let r=0;r{var e;return(e=S==null?void 0:S.today)!=null?e:pe(new Date)};function n(e,t={},...r){let i=document.createElement(e);for(let[p,k]of Object.entries(t))k==null||k===!1||(p.startsWith("on")&&typeof k=="function"?i.addEventListener(p.slice(2),k):p==="class"?i.className=String(k):k===!0?i.setAttribute(p,""):i.setAttribute(p,String(k)));let u=p=>{p==null||p===!1||(Array.isArray(p)?p.forEach(u):i.appendChild(typeof p=="string"?document.createTextNode(p):p))};return r.forEach(u),i}function O(e){let t=n("span",{class:"ic"});return t.innerHTML=Ge(e,"ic-svg"),t}var kt='',Ee=document.getElementById("app"),We,me=(We=Ee.dataset.base)!=null?We:"",At=Ee.dataset.title||"Dawnline",Ce=()=>window.matchMedia("(max-width: 959px)").matches||/Android|iPhone|iPad/.test(navigator.userAgent),S=null,_t=/^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(me)?me.slice(1):"",Le=class extends Error{constructor(r,i){super(i);this.status=r}};async function ne(e,t){var u;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"}),i=null;try{i=await r.json()}catch{}if(!r.ok)throw new Le(r.status,(u=i==null?void 0:i.error)!=null?u:`Request failed (${r.status})`);return i}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 ce(e,t="Copied"){try{await navigator.clipboard.writeText(e)}catch{let r=n("textarea",{class:"offscreen"},e);document.body.appendChild(r),r.select();let i=document.execCommand("copy");if(r.remove(),!i)return te("Copying is blocked here. Select the text and copy it by hand.",!0)}te(t)}function Ze(e,t){let r=URL.createObjectURL(new Blob([t],{type:"application/octet-stream"})),i=n("a",{href:r,download:e,class:"offscreen"});document.body.appendChild(i),i.click(),setTimeout(()=>{URL.revokeObjectURL(r),i.remove()},1e3)}var Z=null;function Xe(e,t){let r=i=>{Z!=null||(Z=document.body.appendChild(n("div",{class:"tip"}))),Z.replaceChildren(...t().map((u,p)=>n("div",{class:p?"muted":"tip-title"},u))),Z.style.display="",Z.style.left=`${i.clientX}px`,Z.style.top=`${i.clientY-10}px`};e.addEventListener("mouseenter",r),e.addEventListener("mousemove",r),e.addEventListener("mouseleave",()=>Z&&(Z.style.display="none"))}function Ct(e){let t=Math.max(1,...e),r=n("div",{class:"spark"});return e.forEach((i,u)=>{let p=n("i",{class:i?"":"zero"});p.style.height=`${Math.max(8,i/t*100)}%`;let k=e.length-1-u;Xe(p,()=>[k===0?"Today":k===1?"Yesterday":ve(Ie(De(),-k)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),ie(i)]),r.appendChild(p)}),r}async function Be(e,t){if(!e.disabled){e.disabled=!0;try{await t()}finally{e.disabled=!1}}}var oe=null,le=null;function ee(e=!1){if(!oe)return;let t=oe;if(oe=null,document.body.classList.remove("locked"),le==null||le(),le=null,e){t.remove();return}t.classList.remove("open"),setTimeout(()=>t.remove(),250)}function fe(e,t,...r){let i=!!oe;ee(!0);let u=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()},O("x"))),n("div",{class:"sheet-body"},...r)),p=n("div",{class:"sheet",onclick:k=>{k.target===p&&ee()}},u);return document.body.appendChild(p),document.body.classList.add("locked"),i?p.classList.add("open"):requestAnimationFrame(()=>p.classList.add("open")),oe=p,u}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 Lt(e,t){ye();let r=t.filter((k,$)=>k||$>0&&t[$-1]&&t.slice($+1).some(Boolean)),i=n("div",{class:"menu",role:"menu"},r.map(k=>k?n("button",{type:"button",role:"menuitem",class:`menu-item${k.danger?" danger":""}`,onclick:()=>{ye(),k.run()}},O(k.icon),n("span",{},k.label)):n("div",{class:"menu-sep"})));document.body.appendChild(i);let u=e.getBoundingClientRect(),p=230;i.style.left=`${Math.max(8,Math.min(window.innerWidth-p-8,u.right-p))}px`,i.style.top=`${u.bottom+6+window.scrollY}px`,X=i}function $e(...e){Ee.replaceChildren(n("header",{class:"top"},n("div",{class:"brand"},(()=>{let t=n("span",{class:"logo"});return t.innerHTML=kt,t})(),n("span",{},(S==null?void 0:S.server.name)||At),n("span",{class:"faint"},"· Dawnline"))),n("main",{class:"wrap"},...e))}function et(){$e(n("div",{class:"card signin"},n("div",{class:"hero-ic"},O("key")),n("h1",{},"This link no longer works"),n("p",{class:"muted"},"Ask for a new personal link.")))}function Tt(e){return e.state==="active"?"ok":e.state==="quota"||e.state==="expired"?"bad":"warn"}var Dt={internet:"The internet, through the router",lan:"Devices at home",both:"Devices at home and the internet, through the router"};function Et(e){let t=e.person,r=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,i=n("div",{class:`meter${r>=100?" bad":r>=90?" warn":""}`},n("i"));i.firstChild.style.width=`${r}%`,t.quota_limit&&Xe(i,()=>[`${r.toFixed(1)}% used`,`${ie(Math.max(0,t.quota_limit-t.quota_used))} left`]);let u=Me(t.expires,De()),p=n("div",{class:"slots"});for(let E=0;E=t.device_limit?"over":E=0?`${u} day${u===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 Bt(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 ${xe(e.handshake)}`):n("span",{class:"dstat warn"},"Not set up yet")}function tt(e,t){return e.access!=="internet"&&e.state==="active"&&!t.disabled}function $t(e,t){let r=ke(e.devices).filter(p=>p.hostname&&tt(e,p));if(!r.length)return null;let i=r[0].hostname,u=i.slice(i.indexOf("."));return n("div",{class:"names"},n("div",{class:"names-head"},n("span",{class:"names-ic"},O("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${u}`)))),n("div",{class:"names-list"},r.map(p=>{let k=p.hostname.indexOf(".");return n("button",{type:"button",class:"name-chip",title:p.name,"aria-label":`Copy ${p.hostname}`,onclick:()=>ce(p.hostname,"Address copied")},n("span",{class:"mono"},k>0?[p.hostname.slice(0,k),n("span",{class:"faint"},p.hostname.slice(k))]:p.hostname),O("copy"))})))}function St(e,t){let r=n("button",{type:"button",class:"icon-btn soft","aria-label":`${e.name} options`},O("more"));r.addEventListener("click",k=>{k.stopPropagation(),Lt(r,[{label:"Show QR code",icon:"qr",run:()=>ue(e,"qr")},{label:"Copy AmneziaVPN key",icon:"key",run:()=>Pt(e)},{label:"Download .conf",icon:"download",run:()=>Nt(e)},null,...tt(t.person,e)?[{label:"Copy IP address",icon:"copy",run:()=>ce(e.address,"IP address copied")},...e.hostname?[{label:"Copy local address",icon:"home",run:()=>ce(e.hostname,"Address copied")}]:[],null]:[],...e.disabled?[]:[{label:"Rename",icon:"edit",run:()=>Ht(e)},{label:"New keys",icon:"reset",run:()=>It(e,t)},{label:"Remove",icon:"trash",danger:!0,run:()=>Ot(e)}]])});let i=e.spark.reduce((k,$)=>k+$,0),u=!e.handshake&&!e.disabled,p=t.here===e.id;return n("article",{class:`dcard${e.online?" online":""}${e.disabled?" off":""}${p?" here":""}`},n("div",{class:"dhead"},n("span",{class:"dic"},O(e.kind)),n("div",{class:"stack grow"},n("span",{class:"dname"},e.name),p?n("span",{class:"dstat here"},"This device"):Bt(e)),r),u?[n("button",{type:"button",class:"btn primary block",onclick:()=>ue(e)},O(Ce()?"open":"qr"),n("span",{},Ce()?"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"},ie(i))),Ct(e.spark)),e.config_stale&&!u?n("div",{class:"notice"},O("alert"),n("span",{class:"grow"},"Connection settings changed. Update this device to keep everything working."),n("button",{type:"button",class:"btn small",onclick:()=>ue(e)},"Update")):null)}function de(e){let t=e.person,r=Me(t.expires,De()),i=t.state!=="active"?n("div",{class:"notice bad"},O("alert"),n("span",{},t.state==="quota"?"You have used all your data for this period. Your devices are paused until it resets.":t.state==="expired"?"Your access has ended. Ask the admin to extend it.":t.state==="hours"?`Access is available ${t.hours.replace("-","–")} (router time).`:"Your access is paused by the admin.")):r!=null&&r>=0&&r<=Math.max(t.expire_warn,1)?n("div",{class:"notice"},O("alert"),n("span",{},`Your access ends ${r===0?"today":`in ${r} day${r===1?"":"s"}`} (${we(t.expires)}).`)):null,p=ke(t.devices).sort((E,B)=>+(B.id===e.here)-+(E.id===e.here)).map(E=>St(E,e));Math.max(0,t.device_limit-t.devices.length)&&p.push(n("button",{type:"button",class:"slot add",onclick:Gt},n("span",{class:"slot-ic"},O("plus")),n("span",{class:"strong"},"Add device")));let $=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"},p),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."));$e(n("div",{class:"hello"},n("span",{class:`avatar${t.online?" online":""}`},Ue(t.name)),n("div",{class:"stack"},n("div",{class:"row"},n("h1",{},`Hi, ${t.name}`),t.state==="active"?null:n("span",{class:`pill ${Tt(t)}`},Ke[t.state])))),i,n("div",{class:"layout"},Et(e),$))}async function Se(e){try{return await ne(`devices/${e.id}/config`)}catch(t){return te(t.message,!0),null}}async function Pt(e){let t=await Se(e);t&&ce(await Ae(t,`${t.server} · ${t.name}`),"Key copied")}async function Nt(e){let t=await Se(e);t&&Ze(t.filename,t.conf)}function Qe(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 i=/^(\s*)(PrivateKey|PresharedKey)\b/.test(e);return n("span",{},n("span",{class:"conf-k"},r[1])," ",i&&!t?n("span",{class:"conf-mask"},"••••••••••••••••"):r[2])}function Rt(e){let t=!1,r=n("pre",{class:"conf"}),i=()=>r.replaceChildren(...e.conf.split(` `).flatMap((p,k)=>k?[` -`,We(p,t)]:[We(p,t)])),u=n("button",{class:"btn small",onclick:p=>{p.preventDefault(),t=!t,u.replaceChildren(O(t?"x":"key"),n("span",{},t?"Hide key":"Show key")),s()}},O("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:()=>Xe(e.filename,e.conf)},O("download"),n("span",{},"Download"))),n("details",{class:"confbox"},n("summary",{},O("chevron"),n("span",{},"Configuration"),n("span",{class:"grow"}),u,n("button",{class:"btn small",onclick:p=>{p.preventDefault(),ce(e.conf,"Configuration copied")}},O("copy"),n("span",{},"Copy"))),r))}async function ue(e,t,r){let s=r!=null?r:await Se(e);if(!s)return;let u=await Ae(s,`${s.server} · ${s.name}`),p=Ce(),k={app:()=>n("div",{class:"pane"},n("a",{class:"btn primary block big",href:u},O("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 H=n("div",{class:"qr"});return H.innerHTML=Je(s.conf),n("div",{class:"pane center"},H,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"},u),n("button",{class:"btn small",onclick:()=>ce(u,"Key copied")},"Copy")),n("p",{class:"faint s"},"Keep it private: anyone with the key can use your connection.")),file:()=>It(s)},$=p?["app","qr","key","file"]:["qr","key","file"],E={app:"Open in app",qr:"QR code",key:"Key",file:"File"},B=n("div",{class:"tab-body"}),q=n("div",{class:"tabs",role:"tablist"}),J=H=>{q.querySelectorAll("button").forEach(re=>re.classList.toggle("on",re.dataset.id===H)),B.replaceChildren(k[H]())};for(let H of $)q.appendChild(n("button",{role:"tab","data-id":H,onclick:()=>J(H)},E[H]));J(t&&$.includes(t)?t:$[0]);let U=n("div",{class:"waiting"}),R=H=>{H!=null&&H.online?U.replaceChildren(n("span",{class:"ok"},`${e.name} is connected`)):H!=null&&H.handshake?U.replaceChildren(n("span",{class:"muted"},`Last connected ${we(H.handshake)}`)):U.replaceChildren(n("span",{class:"warn"},"Waiting for the first connection…"))};R(e);let F=window.setInterval(async()=>{try{let H=await ne("state");S=H,R(H.person.devices.find(re=>re.id===e.id))}catch{}},5e3);fe(e.handshake?`Connect ${e.name}`:`${e.name} is ready`,p?"Add it to AmneziaVPN on this phone":"Scan with the phone’s camera or AmneziaVPN",q,B,U),le=()=>{clearInterval(F),S&&de(S)}}function Ot(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");fe(`Rename ${e.name}`,null,n("form",{class:"stack gap",onsubmit:s=>{s.preventDefault(),Be(r,async()=>{try{S=(await ne(`devices/${e.id}`,{action:"rename",name:t.value})).state,ee(),de(S),te("Renamed")}catch(u){te(u.message,!0)}})}},t,r)),setTimeout(()=>t.select(),50)}function Kt(e,t){let r=t.here===e.id;fe(`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=>Be(s.currentTarget,async()=>{try{let u=await ne(`devices/${e.id}`,{action:"rotate"});S=u.state,de(S),await ue(e,void 0,u.config)}catch(u){te(u.message,!0)}})},"New keys")))}function Ut(e){fe(`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=>Be(t.currentTarget,async()=>{try{S=(await ne(`devices/${e.id}`,{action:"delete"})).state,ee(),de(S),te("Device removed")}catch(r){te(r.message,!0)}})},"Remove")))}var V=navigator.userAgent,rt=/iPad/.test(V)||/Macintosh/.test(V)&&navigator.maxTouchPoints>1;function _e(){return rt||/Tablet/i.test(V)||/Android/.test(V)&&!/Mobile/.test(V)?"tablet":/Android|iPhone|Mobile/i.test(V)?"phone":"computer"}var Ft=[[/^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"]],Le="",Gt=(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=Ft.find(([u])=>u.test(r));Le=s?`${s[1]} (${r})`:/^SM-/.test(r)?`Galaxy ${r}`:r}catch{}return Le})();function qt(e){return/iPhone/.test(V)?"iPhone":rt?"iPad":/Android/.test(V)?Le||(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 Vt(){if(!S)return;let e=_e(),t=new Set(S.person.devices.map(E=>E.name.toLowerCase())),r=E=>{let B=E===_e()?qt(E):ge[E];if(!t.has(B.toLowerCase()))return B;for(let q=2;q<20;q++)if(!t.has(`${B} ${q}`.toLowerCase()))return`${B} ${q}`;return B},s=n("input",{type:"text",value:r(e),maxlength:48,"aria-label":"Device name",required:!0}),u=!1;s.addEventListener("input",()=>u=!0),Gt.then(()=>{!u&&e===_e()&&(s.value=r(e))});let p=n("div",{class:"kinds"},S.kinds.map(E=>n("button",{type:"button",class:`kind${E===e?" on":""}`,"data-k":E,onclick:()=>{e=E,p.querySelectorAll(".kind").forEach(B=>B.classList.toggle("on",B.dataset.k===E)),u||(s.value=r(E))}},O(E),n("span",{},ge[E])))),k=n("p",{class:"err"}),$=n("button",{class:"btn primary block",type:"submit"},"Create connection");fe("Add a device",`${S.person.device_limit-S.person.devices.length} of ${S.person.device_limit} slots free`,n("form",{class:"add",onsubmit:async E=>{E.preventDefault(),$.disabled=!0,k.textContent="";try{let B=await ne("devices",{name:s.value.trim(),kind:e});S=B.state;let q=B.state.person.devices.find(J=>J.id===B.id);await ue(q,void 0,B.config)}catch(B){k.textContent=B.message,$.disabled=!1}}},n("label",{class:"lbl"},"What is it?"),p,n("label",{class:"lbl"},"Name"),s,k,$))}async function at(){try{S=await ne("state"),document.title=`${S.person.name} · ${S.title}`,!oe&&!X&&de(S)}catch(e){let t=e;t.status===404||t.status===401?(S=null,tt()):S||$e(n("div",{class:"card"},n("p",{},t.message)))}}function Yt(){clearInterval(Qe),Qe=window.setInterval(()=>{S&&document.visibilityState==="visible"&&at()},15e3)}!me||!Tt?tt():(at(),Yt());})(); +`,Qe(p,t)]:[Qe(p,t)])),u=n("button",{class:"btn small",onclick:p=>{p.preventDefault(),t=!t,u.replaceChildren(O(t?"x":"key"),n("span",{},t?"Hide key":"Show key")),i()}},O("key"),n("span",{},"Show key"));return i(),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:()=>Ze(e.filename,e.conf)},O("download"),n("span",{},"Download"))),n("details",{class:"confbox"},n("summary",{},O("chevron"),n("span",{},"Configuration"),n("span",{class:"grow"}),u,n("button",{class:"btn small",onclick:p=>{p.preventDefault(),ce(e.conf,"Configuration copied")}},O("copy"),n("span",{},"Copy"))),r))}async function ue(e,t,r){let i=r!=null?r:await Se(e);if(!i)return;let u=await Ae(i,`${i.server} · ${i.name}`),p=Ce(),k={app:()=>n("div",{class:"pane"},n("a",{class:"btn primary block big",href:u},O("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 H=n("div",{class:"qr"});return H.innerHTML=Je(i.conf),n("div",{class:"pane center"},H,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"},u),n("button",{class:"btn small",onclick:()=>ce(u,"Key copied")},"Copy")),n("p",{class:"faint s"},"Keep it private: anyone with the key can use your connection.")),file:()=>Rt(i)},$=p?["app","qr","key","file"]:["qr","key","file"],E={app:"Open in app",qr:"QR code",key:"Key",file:"File"},B=n("div",{class:"tab-body"}),q=n("div",{class:"tabs",role:"tablist"}),J=H=>{q.querySelectorAll("button").forEach(re=>re.classList.toggle("on",re.dataset.id===H)),B.replaceChildren(k[H]())};for(let H of $)q.appendChild(n("button",{role:"tab","data-id":H,onclick:()=>J(H)},E[H]));J(t&&$.includes(t)?t:$[0]);let U=n("div",{class:"waiting"}),R=H=>{H!=null&&H.online?U.replaceChildren(n("span",{class:"ok"},`${e.name} is connected`)):H!=null&&H.handshake?U.replaceChildren(n("span",{class:"muted"},`Last connected ${xe(H.handshake)}`)):U.replaceChildren(n("span",{class:"warn"},"Waiting for the first connection…"))};R(e);let F=window.setInterval(async()=>{try{let H=await ne("state");S=H,R(H.person.devices.find(re=>re.id===e.id))}catch{}},5e3);fe(e.handshake?`Connect ${e.name}`:`${e.name} is ready`,p?"Add it to AmneziaVPN on this phone":"Scan with the phone’s camera or AmneziaVPN",q,B,U),le=()=>{clearInterval(F),S&&de(S)}}function Ht(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");fe(`Rename ${e.name}`,null,n("form",{class:"stack gap",onsubmit:i=>{i.preventDefault(),Be(r,async()=>{try{S=(await ne(`devices/${e.id}`,{action:"rename",name:t.value})).state,ee(),de(S),te("Renamed")}catch(u){te(u.message,!0)}})}},t,r)),setTimeout(()=>t.select(),50)}function It(e,t){let r=t.here===e.id;fe(`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:i=>Be(i.currentTarget,async()=>{try{let u=await ne(`devices/${e.id}`,{action:"rotate"});S=u.state,de(S),await ue(e,void 0,u.config)}catch(u){te(u.message,!0)}})},"New keys")))}function Ot(e){fe(`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=>Be(t.currentTarget,async()=>{try{S=(await ne(`devices/${e.id}`,{action:"delete"})).state,ee(),de(S),te("Device removed")}catch(r){te(r.message,!0)}})},"Remove")))}var V=navigator.userAgent,nt=/iPad/.test(V)||/Macintosh/.test(V)&&navigator.maxTouchPoints>1;function _e(){return nt||/Tablet/i.test(V)||/Android/.test(V)&&!/Mobile/.test(V)?"tablet":/Android|iPhone|Mobile/i.test(V)?"phone":"computer"}var Kt=[[/^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"]],Te="",Ut=(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 i=Kt.find(([u])=>u.test(r));Te=i?`${i[1]} (${r})`:/^SM-/.test(r)?`Galaxy ${r}`:r}catch{}return Te})();function Ft(e){return/iPhone/.test(V)?"iPhone":nt?"iPad":/Android/.test(V)?Te||(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 Gt(){if(!S)return;let e=_e(),t=new Set(S.person.devices.map(E=>E.name.toLowerCase())),r=E=>{let B=E===_e()?Ft(E):ge[E];if(!t.has(B.toLowerCase()))return B;for(let q=2;q<20;q++)if(!t.has(`${B} ${q}`.toLowerCase()))return`${B} ${q}`;return B},i=n("input",{type:"text",value:r(e),maxlength:48,"aria-label":"Device name",required:!0}),u=!1;i.addEventListener("input",()=>u=!0),Ut.then(()=>{!u&&e===_e()&&(i.value=r(e))});let p=n("div",{class:"kinds"},S.kinds.map(E=>n("button",{type:"button",class:`kind${E===e?" on":""}`,"data-k":E,onclick:()=>{e=E,p.querySelectorAll(".kind").forEach(B=>B.classList.toggle("on",B.dataset.k===E)),u||(i.value=r(E))}},O(E),n("span",{},ge[E])))),k=n("p",{class:"err"}),$=n("button",{class:"btn primary block",type:"submit"},"Create connection");fe("Add a device",`${S.person.device_limit-S.person.devices.length} of ${S.person.device_limit} slots free`,n("form",{class:"add",onsubmit:async E=>{E.preventDefault(),$.disabled=!0,k.textContent="";try{let B=await ne("devices",{name:i.value.trim(),kind:e});S=B.state;let q=B.state.person.devices.find(J=>J.id===B.id);await ue(q,void 0,B.config)}catch(B){k.textContent=B.message,$.disabled=!1}}},n("label",{class:"lbl"},"What is it?"),p,n("label",{class:"lbl"},"Name"),i,k,$))}async function qt(){try{S=await ne("state"),document.title=`${S.person.name} · ${S.title}`,!oe&&!X&&de(S)}catch(e){let t=e;t.status===404||t.status===401?(S=null,et()):S||$e(n("div",{class:"card"},n("p",{},t.message)))}}!me||!_t?et():qt();})(); 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 84d45e0..3451d2a 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 @@ -4,6 +4,7 @@ "read": { "ubus": { "luci.dawnline": [ + "rev", "status", "setup_defaults", "health", diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc index 21dedd3..45ee7b1 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc @@ -97,7 +97,7 @@ function connected(dmp, d, who) { let peer = peer_of(dmp, d); if (!peer || !(peer.handshake > 0)) return step(false, `${who} has never connected`, 'There is no session the router could reach.'); - if (time() - peer.handshake >= live.ONLINE_WINDOW) + if (!live.online(dmp, d.id, peer)) return step(false, `${who} isn't connected right now`, 'The router reaches it only while its VPN is on.'); return step(true, `${who} is connected`, ''); } 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 eade22d..9e3998b 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 @@ -12,7 +12,10 @@ import { } from 'dawnline.util'; import * as awg from 'dawnline.awg'; -export const ONLINE_WINDOW = 300; +// Online while the WireGuard session lives: it is dropped 180 s after its +// handshake, and a device that is there renews it every 2 min (a little slack +// for a renewal that needs a retry). One that left goes offline 1-3 min later. +export const ONLINE_WINDOW = 190; const KEEP_DAYS = 62; const KEEP_MONTHS = 24; const KEEP_EVENTS = 2000; @@ -82,12 +85,42 @@ function trim_events(ev, pol) { /* ---------- live peers ---------- */ +/* ---------- presence (the agent's watcher) ---------- */ + +/** + * Written by the agent's watcher on every change: { online: { device id: bool }, + * endpoint: { device id: ip }, rev, people: { person id: rev } }. `rev` moves on + * any connect, disconnect, roam or logged change; `people` per person (the portal). + */ +export const PRESENCE = `${RUN_DIR}/presence.json`; +// The agent's heartbeat (dawnline.watchdog.BEAT): its presence counts while it runs. +const BEAT = `${RUN_DIR}/agent.beat`; +const BEAT_STALE = 180; + +/** What the watcher sees, or null when the agent isn't running. */ +export function presence() { + let beat = +(read_json(BEAT, 0) ?? 0); + if (!beat || time() - beat > BEAT_STALE) + return null; + return read_json(PRESENCE, null); +}; + /** * Peers of every tunnel: { ok, ifaces, peers: { public key: { ifname, endpoint, - * handshake, rx, tx } } }. See dawnline.awg. + * handshake, rx, tx } }, presence }. See dawnline.awg. */ export function dump(m) { - return awg.dump(); + let d = awg.dump(); + d.presence = presence(); + return d; +}; + +/** A device is online: as the agent's watcher says, or (without the agent) by a recent handshake. */ +export function online(dmp, id, peer) { + let p = dmp?.presence?.online; + if (p) + return !!(peer && p[id]); + return !!(peer && peer.handshake > 0 && time() - peer.handshake < ONLINE_WINDOW); }; export function endpoint_ip(ep) { 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 b773292..cac2eb9 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 @@ -1,5 +1,5 @@ -// Dawnline rpcd methods: the Overview status (servers, people, totals, map, -// recent activity), the activity log and traffic history. +// Dawnline rpcd methods: the live revision, the Overview status (servers, +// people, totals, map, recent activity), the activity log and traffic history. import { readfile } from 'fs'; import { read_json, write_json, ensure_dir, lock, unlock, admin_log, VERSION, RUN_DIR } from 'dawnline.util'; @@ -23,7 +23,7 @@ function geo_view(m, usage, dmp) { let rec = usage.devices?.[id]; let peer = dmp.peers[d.public_key]; let cur = live.endpoint_ip(peer?.endpoint); - let online = !!(peer && peer.handshake > 0 && now - peer.handshake < live.ONLINE_WINDOW); + let online = live.online(dmp, id, peer); for (let ip, ts in rec?.ips ?? {}) { // Local (LAN / CGNAT) client addresses are not shown on the map. let pl = geo.is_public(ip) ? geo.place(cache, ip) : null; @@ -60,12 +60,15 @@ function with_hosts(ev) { } function server_view(m, srv, usage, dmp, rates, days) { - let online = 0, peers = 0, now = time(); + let online = 0, peers = 0; let links = map(core.tunnels(srv), (t) => t.ifname); + let ids = {}; + for (let id, d in m.devices) + ids[d.public_key] = id; for (let k, p in dmp.peers) if (index(links, p.ifname) >= 0) { peers++; - if (p.handshake > 0 && now - p.handshake < live.ONLINE_WINDOW) + if (live.online(dmp, ids[k], p)) online++; } let st = srv.private_key ? awg.server_state(srv) : { up: false, uptime: 0 }; @@ -221,7 +224,13 @@ function usage_clear(a) { return { ok: true }; } +/** The live revision (dawnline.live.PRESENCE): pages refresh when it moves; 0 without the agent. */ +function rev() { + return { rev: +(live.presence()?.rev ?? 0) }; +} + export const methods = { + rev: { call: wrap(rev) }, status: { args: { days: 30 }, call: wrap(status) }, events: { args: { limit: 300 }, call: wrap(events_list) }, logs_clear: { args: { person: '', device: '', category: '', older_days: '' }, call: wrap(logs_clear) }, 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 7d14f95..790fbfe 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.4.1'; +export const VERSION = '0.4.2'; /** GitHub repository with Dawnline releases (updates and the installer). */ export const REPO = 'tickcount/luci-app-dawnline'; export const RUN_DIR = '/var/run/dawnline'; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc index d95cc6d..2223093 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 @@ -37,7 +37,7 @@ export function device_view(m, d, usage, dmp) { disabled: d.disabled, created: d.created, created_by: d.created_by, - online: !!(peer && peer.handshake > 0 && ts - peer.handshake < live.ONLINE_WINDOW), + online: live.online(dmp, d.id, peer), handshake: hs, endpoint: live.endpoint_ip(peer?.endpoint) || u?.endpoint || '', active: !!peer, diff --git a/rules/backend.md b/rules/backend.md new file mode 100644 index 0000000..e9e1b4e --- /dev/null +++ b/rules/backend.md @@ -0,0 +1,30 @@ +# Backend (ucode on the router) + +Read with `code-standards.md`. Everything here runs on a small router (2 × Cortex-A53 on the reference Cudy WR3000P): cost is part of correctness. + +## Layers + +- `util`, `schema` (validation) → `core` (model, allocation) → `store` (the only writer of `/etc/config/dawnline`) → domain modules (`net`, `nft`, `fw`, `netifd`, `awg`, `loop`, `resolver`, `live`, `health`, `backup`, …) → `apply` (reconciliation) → entry points (`rpc/*`, `portal`, the `dawnline` CLI, the agent, the updater). +- Read models for the UI live in `view`; RPC modules translate arguments and call down, they hold no business logic. +- The updater is a thin dispatcher over `upd_app` / `upd_awg` / `upd_pkgs`, with GitHub in `github`, the package manager in `pkg`, policy/locks/history in `updates`. +- Live state: the agent's watcher owns who is online (`live.PRESENCE`); readers ask `live.online()`, never re-derive it from handshake ages. Online means the WireGuard session lives (`live.ONLINE_WINDOW`): traffic silence is no signal, a phone asleep is silent too. + +## ucode + +- `'use strict'` in entry points; modules `import { … } from 'fs'` / `'dawnline.x'`. Subdirectories map to dots (`dawnline.rpc.status` → `dawnline/rpc/status.uc`). +- Exported functions end with `};` (the compiler requires it). No destructuring. Regexes are POSIX (no `(?:)`, `\s\S` classes, lazy quantifiers); anchor them. +- Modules with `export` cannot be loaded with `require()`: imports are static and compiled on every start of the script. +- Doc comments (`/** … */`) on every export: what it returns, including the null/empty case. +- Shell out through one small helper per module (`run()`/`sh()`), with `2>&1` captured and the exit code checked. +- nft changes load as one script (`nft.load()`, a transaction); tables Dawnline owns are named `dawnline*` and rebuilt whole (`table X` + `delete table X` + the table). + +## Cost on the router + +- **The portal is CGI:** every request starts ucode and compiles the module graph, about 140 ms of CPU before any work (a full `state` answer about 180 ms). No periodic polling from the portal; one request per user action. +- **rpcd keeps the admin backend loaded:** LuCI RPC calls are cheap, so the admin UI may poll small methods often (`rev`), and the heavy ones (`status`) only on change or rarely. +- **Code on the agent's 1-second watcher stays in the low milliseconds:** one `awg show all dump` (about 4 ms with process start), the model cached by the config file's mtime/inode (`core.load()` is about 4 ms), files written only when something changed. Slow work (geo lookups, apply) runs only on a transition. +- Measure before and after on the router (a loop of 20–200 calls, `/proc/self/stat` CPU ticks, system busy from `/proc/stat`) when adding anything periodic. + +## Checks + +- `scripts/lint-ucode.py` and `scripts/check-ucode.sh` (compiles on the router) pass before any deploy; new directories and entry points are added to both, and executables to the mode check in `.github/workflows/ci.yml`. diff --git a/rules/code-standards.md b/rules/code-standards.md new file mode 100644 index 0000000..eddcc0d --- /dev/null +++ b/rules/code-standards.md @@ -0,0 +1,36 @@ +# Code standards + +How code in our own projects (Dawnline first, the same spirit for Tachyon, liminal and the rest) is written. This file holds what applies everywhere; per area: + +- `backend.md` — ucode on the router: layers, conventions, what things cost there. +- `frontend.md` — TypeScript admin UI and portal: layout, live data. +- `shell.md` — install, uninstall, init and CI scripts. +- `ui-design.md` — how anything visible looks and how it gets approved. + +Match the code around you: its naming, comment density and idiom win over personal taste. + +## Decomposition + +- **One module, one job, named after it.** A file you cannot describe in one sentence is two files. Starting points: ~300–400 lines for a ucode/TS module, ~60 lines for a function. Past that, split by responsibility, not by line count. +- **Every module opens with a header comment**: what it owns, what it deliberately does not (and where that lives), and any invariant callers rely on (locks, files it writes, who may call it). +- **Layers point one way.** Pure helpers and the data model know nothing about the router or the UI; orchestration calls them, never the reverse. Dawnline's layers are in `backend.md`. +- **No god files, no grab-bag `ops`/`misc`/`kit` modules.** When a helper is used by one module, it stays private in that module. +- **Delete, don't deprecate.** When something is replaced, move every caller and remove the old code in the same change; no shims, no commented-out blocks. + +## Logic and state + +- **Validate at the boundary, trust inside.** RPC, portal, CLI and file input are checked once (types, ranges, ids, regexes anchored with `^…$`, length caps); inner code assumes valid data. Never build a shell command from unchecked input — quote with `q()` and prefer argument whitelists. +- **One writer per resource, under a lock.** Config changes go through `store.transact()` (load the model inside the lock, change, commit, chmod 600). Router state changes go through `apply` under the `apply` lock. Long jobs (updates) hold a `flock`; "is it running" comes from the lock, never from a pid file. Do not nest locks. +- **Reconcile, don't patch.** Derive router state from config and converge (idempotent: running twice changes nothing). Touch only objects you own (tagged/named `dawnline`), never foreign interfaces, zones or rules. +- **Fail closed.** If a filter or nft load fails, access stays blocked, not open. A missing dependency (no AmneziaWG, no curl, no openssl) is a reported state with a fix, never a crash: check capabilities (`awg.state()`, `health.needs()`) and gate the feature in the backend *and* the UI. +- **Atomic files.** Write JSON/state to a temp file and rename; keep runtime counters in tmpfs (`RUN_DIR`) and flush to flash (`DATA_DIR`) rarely. +- **Trust and downloads.** APIs only directly over TLS; files may come from mirrors only when their sha256 is known from the API, and every attempt is verified. No hash → direct only, or refuse. +- **Side effects at the end.** Collect restarts (network, uhttpd, re-apply) and run them once after the job, so a failure halfway never leaves half-restarted services. +- **Errors say what to do.** `die()` / thrown messages are shown to the admin: a full sentence with the cause and, where possible, the fix. Never swallow an error silently; a `catch` either handles it or logs why it is ignored. +- **Time and dates come from the router** (`localtime`, `util.today()`), not from the browser. + +## Comments, names, commits + +- Comments explain why and the contract, not what the next line does. English in code and UI copy. +- Names say what the thing is in the product's words (people, devices, servers, circles), not implementation words. +- Commits are reviewable pieces (one area or concern each), message says what changed and why; no push without the user's go-ahead. diff --git a/rules/frontend.md b/rules/frontend.md new file mode 100644 index 0000000..952be79 --- /dev/null +++ b/rules/frontend.md @@ -0,0 +1,19 @@ +# Frontend (TypeScript: admin UI and portal) + +Read with `code-standards.md` and, for anything visible, `ui-design.md`. + +## Code + +- Strict TS, no `any` without a comment; types for RPC answers live in `shared/types.ts` / `admin/api.ts` and mirror the backend's shapes. +- Layout of `web/src/admin`: `ui/` generic components (button, menu, modal, drawer, tooltip, toast, controls), `widgets/` composite house widgets, `state/` polling and scoping, `events/` the activity vocabulary (model without DOM, render separate), `updater/` the Components data layer, `cores/` per-protocol bits, `pages//` one folder per page split by section, `styles/*.css` one file per feature joined in `styles/index.ts`. Shared with the portal: `src/shared/`. +- Pages build from `ui/` and `widgets/`; a page never defines a generic component. Logic that does not touch the DOM (formatting, models, CSV, sorting) lives outside the render code and gets tests. + +## Live data + +- Admin pages use `createPoller` (`state/poller.ts`): newest answer wins, no repaint of a region that holds focus, every RPC failure shows a toast or an inline error, never a blank section. +- Changes reach open pages through the revision (`state/live.ts`): one small `rev` call every 2 s while the page is visible; pollers that opt in (`live: true`) refresh when it moves. Their own `every` stays as a slow fallback. +- The portal does not poll (each request is a CGI process on the router, see `backend.md`): it loads once, after the visitor's own changes, and while it waits for a new device's first connection. + +## Checks + +- In `web/`: `npm run format:check`, `npm run typecheck`, `npm test`, `npm run build`; the rebuilt bundles under `package/` are committed (CI fails otherwise). diff --git a/rules/shell.md b/rules/shell.md new file mode 100644 index 0000000..0e358da --- /dev/null +++ b/rules/shell.md @@ -0,0 +1,7 @@ +# Shell (install, uninstall, init, CI) + +Read with `code-standards.md`. Anything run on the router by hand follows the workspace's `../rules/router-shell.md` (a literal stdin heredoc over SSH). + +- POSIX `sh` (BusyBox ash), `set -eu` where the script allows; quote every expansion; `shellcheck -S warning` clean (CI runs it). +- Every mutating script has a `--dry-run` that prints what it would do; uninstall removes everything install created (cron, nft, firewall, routing, packages it added, files) and nothing else — including what older versions created (e.g. the priority-90 reply rules up to 0.4.0). +- BusyBox lacks GNU options (`ls -e`, `pkill`, `time` on shell functions): check on the router before relying on a flag. diff --git a/rules/ui-design.md b/rules/ui-design.md new file mode 100644 index 0000000..0e72e62 --- /dev/null +++ b/rules/ui-design.md @@ -0,0 +1,32 @@ +# UI design (Dawnline admin, portal and other panels) + +The bar is a modern product UI (Linear / Vercel / Raycast level), not a "native" LuCI form. A plain label + input row, a bare radio list, three columns of check marks or a text dump is a first draft, never the result. + +## Approach + +- **Mock first.** Any visible change beyond a one-line fix: show a mockup (2–4 genuinely different options when the direction is open) with a recommendation, then build the chosen one. Do not start coding a layout the user has not seen. +- **Think past the obvious.** When an option is rejected as "not it", propose new concepts, not variations of the same layout. +- **Structure over text.** Tiles, segmented controls, pills, round icon buttons, inline status, folded "Advanced" sections. Summaries first ("All 6 checks passed"), details on demand. +- **No duplication.** One place per fact (usage, device count, links). Remove what is repeated elsewhere on the page. +- **Reuse the house patterns** before inventing new ones: `dl-params` folded details with a rotating chevron, `dl-tile2` tiles, round icon buttons with tooltips, `⋯` menus (destructive and Pause inside, Pause in warn colour, "Delete" without an ellipsis), bottom toasts instead of LuCI banners, the same tiles on server and person pages. +- **Alignment and spacing are part of the design.** Shared margins and edges, equal heights in a row, controls pinned consistently (top, not centred, when the user says so), nothing clipped or overflowing, single-line labels where they fit. +- **No ellipsis on buttons or menu items** ("Remove", not "Remove…"), even when they open a dialog. "…" only for progress ("Loading…") and truncated values. +- **Colour means something:** ok = green, warn/pause = orange, danger = red, accent = blue. Icons for states instead of words where obvious. +- **Honest warnings** belong in the UI (e.g. plain HTTP, Cloudflare throttling), shown where the choice is made. + +## Mocks look like the real product + +A mock is judged against the page it will live on, so it must already look like it. Hand-drawn look-alikes with invented styles get rejected ("выбивается из дизайна"). + +- **Study the existing pages first** (the section being changed and its neighbours) and build only from their components: `dl-setsec` cards with `dl-setsec-foot`, `dl-setrow` rows with a `dl-need-ic` icon tile and `dl-switch`, `dl-seg` (`sm`, `wide`), `dl-chip` / `dl-chipbtn`, `dl-list` + `dl-row`, `dl-table`, `dl-checks` (the Health check list), `dl-tile2` tiles, `dl-panel`. A new class only when nothing fits, and then in the same tokens (`--dl-*`). +- **Buttons are `cbi-button`**: actions like Edit, Change, Rescan are `neutral` pills (as "Edit in Settings", "+ Add device"); Save and Install are `positive`. No blue text links for actions. +- **Show only what changes.** Do not add existing, unrelated controls (e.g. Devices or Access ends tiles) to a mock; say in the caption that the rest of the page stays. +- **Build it from the real code and CSS**, not from a copy: + - theme: `scp root@outline.lan:/www/luci-static/outline/{main.css,geist-*.woff2}` into the mock folder, strip `/luci-static/outline/` from the font URLs, ``; + - Dawnline CSS: the files in `web/src/admin/styles/*.css` concatenated in the order of `styles/index.ts` into `dl.css`; + - markup: a small `mock.ts` that imports the real `admin/e`, `shared/icons`, `admin/ui/*` and `admin/widgets/*` (stub the LuCI globals `window.E`, `dom.content`, `L.url`), bundled with `web/node_modules/.bin/esbuild --bundle --format=iife`. +- Keep mocks outside the product repo, serve them with `python3 -m http.server` started from Bash (the preview server cannot read `~/Documents` on macOS), open them in the built-in browser, and delete the folder when the feature ships. + +## Done means seen + +Deploy, then look at it in the browser (desktop width, and narrow when layout changes) before reporting. Check modals and drawers stack correctly and long values do not overflow. diff --git a/web/package-lock.json b/web/package-lock.json index 978a308..ec32c52 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "dawnline-web", - "version": "0.4.1", + "version": "0.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dawnline-web", - "version": "0.4.1", + "version": "0.4.2", "license": "MIT", "dependencies": { "qrcode-generator": "1.4.4" diff --git a/web/package.json b/web/package.json index b34ee4b..aa8a299 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dawnline-web", - "version": "0.4.1", + "version": "0.4.2", "private": true, "license": "MIT", "type": "module", diff --git a/web/src/admin/api.ts b/web/src/admin/api.ts index b3c47ba..94f77c2 100644 --- a/web/src/admin/api.ts +++ b/web/src/admin/api.ts @@ -393,6 +393,7 @@ export interface ServiceLog { export type Health = { checks: HealthCheck[] } & ServiceLog; export const api = { + rev: call<{ rev: number }>('rev'), personUpdate, settingsGet: call('settings_get'), portalInfo: call('portal_info'), diff --git a/web/src/admin/device.ts b/web/src/admin/device.ts index 0b334f7..d12bff2 100644 --- a/web/src/admin/device.ts +++ b/web/src/admin/device.ts @@ -20,6 +20,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 { onLiveChange } from './state/live'; /** What the page that opens a device hands over. */ export interface DeviceOpts { @@ -347,13 +348,17 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { setUp ? [stats, connectSec, detailsSec, activitySec] : [stats, detailsSec, activitySec, connectSec], ); void loadLog(); - // Live status every 8 s. The log follows the page's events, or is fetched every 32 s on its own. - let ticks = 0; - const watch = window.setInterval(() => { + // Live status and log: at once when something happens (state/live.ts), and every 30 s anyway. + const live = () => { void reload(); - if (o.events || ++ticks % 4 === 0) void loadLog(); - }, 8000); - const handle = drawer(titleEl, body, foot, () => clearInterval(watch)); + void loadLog(); + }; + const off = onLiveChange(live); + const watch = window.setInterval(live, 30000); + const handle = drawer(titleEl, body, foot, () => { + clearInterval(watch); + off(); + }); paint(); } diff --git a/web/src/admin/pages/people.ts b/web/src/admin/pages/people.ts index e23a050..073b62f 100644 --- a/web/src/admin/pages/people.ts +++ b/web/src/admin/pages/people.ts @@ -240,7 +240,8 @@ export class PeoplePage { // Only while visible (a server section may be swapped out). this.poller ??= createPoller({ fetch: () => api.status(30), - every: 10, + every: 30, + live: true, active: () => !!page.el?.isConnected, apply: (st, quiet) => page.take(st, quiet), }); diff --git a/web/src/admin/pages/person/index.ts b/web/src/admin/pages/person/index.ts index 0ffcc5f..be9940e 100644 --- a/web/src/admin/pages/person/index.ts +++ b/web/src/admin/pages/person/index.ts @@ -91,12 +91,14 @@ export class PersonPage { if (dev) setTimeout(() => openDevice(this.p, dev, this.deviceOpts()), 50); else if (q.get('add')) setTimeout(() => addDevice(this.p, this.deviceOpts()), 50); this.poller = createPoller({ - fetch: () => { - const full = this.fullNext || ++this.ticks % 4 === 0; + // The activity log comes with every fourth tick, and whenever something just happened. + fetch: (live) => { + const full = live || this.fullNext || ++this.ticks % 4 === 0; this.fullNext = false; return this.fetch(full); }, every: 15, + live: true, active: () => root.isConnected, apply: (data, quiet) => this.apply(data, quiet), }); diff --git a/web/src/admin/pages/server.ts b/web/src/admin/pages/server.ts index 738aff9..0da5945 100644 --- a/web/src/admin/pages/server.ts +++ b/web/src/admin/pages/server.ts @@ -89,7 +89,8 @@ export class ServerPage { // and so is anything that has the keyboard focus. this.poller = createPoller({ fetch: () => api.status(31), - every: 10, + every: 30, + live: true, active: () => this.section === 'overview' && this.root.isConnected, apply: (n, quiet) => { if (!n.servers.length) return; diff --git a/web/src/admin/state/live.ts b/web/src/admin/state/live.ts new file mode 100644 index 0000000..9b52ede --- /dev/null +++ b/web/src/admin/state/live.ts @@ -0,0 +1,31 @@ +// The live revision: one small `rev` call every 2 s while the page is visible. +// The agent moves it the moment a device connects, goes away or roams, or +// something is logged; pollers that opt in refresh then, so pages follow the +// router within seconds without fetching the full status that often. + +import { api } from '../api'; + +const EVERY = 2; + +const listeners = new Set<() => void>(); +let last: number | null = null; +let started = false; + +async function tick(): Promise { + if (document.visibilityState !== 'visible' || !listeners.size) return; + const r = await api.rev().catch(() => null); + if (!r) return; + const moved = last != null && r.rev !== last; + last = r.rev; + if (moved) listeners.forEach((f) => f()); +} + +/** Call `f` whenever the revision moves; returns the unsubscribe. */ +export function onLiveChange(f: () => void): () => void { + listeners.add(f); + if (!started) { + started = true; + poll.add(tick, EVERY); + } + return () => listeners.delete(f); +} diff --git a/web/src/admin/state/poller.ts b/web/src/admin/state/poller.ts index 0855431..d880469 100644 --- a/web/src/admin/state/poller.ts +++ b/web/src/admin/state/poller.ts @@ -2,6 +2,8 @@ // region alone while the keyboard focus is inside it (typing, a picker, a // focused button), so a background refresh never takes it away. +import { onLiveChange } from './live'; + /** * Request tickets: an answer is shown only if nothing newer was shown before * it. `claim()` invalidates everything in flight (an edit's own answer wins). @@ -24,14 +26,16 @@ export class Sequence { } export interface PollerOptions { - /** One request; rejections and null count as "no answer". */ - fetch: () => Promise; + /** One request (`live`: the live revision moved); rejections and null count as "no answer". */ + fetch: (live: boolean) => Promise; /** Paint an answer; `quiet` for the periodic ones. */ apply: (data: T, quiet: boolean) => void; /** Seconds between ticks. */ every: number; /** Ticks are skipped while this is false (e.g. the page is not on screen). */ active?: () => boolean; + /** Also refresh as soon as the live revision moves (state/live.ts); `every` is then the fallback. */ + live?: boolean; } export interface Poller { @@ -44,16 +48,25 @@ export interface Poller { export function createPoller(o: PollerOptions): Poller { const seq = new Sequence(); - const refresh = async (quiet = false): Promise => { + const load = async (quiet: boolean, live: boolean): Promise => { const t = seq.next(); - const d = await o.fetch().catch(() => null); + const d = await o.fetch(live).catch(() => null); if (d == null || !seq.take(t)) return null; o.apply(d, quiet); return d; }; - const tick = () => ((o.active?.() ?? true) ? refresh(true) : Promise.resolve(null)); + const refresh = (quiet = false) => load(quiet, false); + const tick = () => ((o.active?.() ?? true) ? load(true, false) : Promise.resolve(null)); poll.add(tick, o.every); - return { refresh, claim: () => seq.claim(), stop: () => poll.remove(tick) }; + const off = o.live ? onLiveChange(() => void ((o.active?.() ?? true) && load(true, true))) : null; + return { + refresh, + claim: () => seq.claim(), + stop: () => { + poll.remove(tick); + off?.(); + }, + }; } /** The keyboard focus (or an open native picker's input) is inside `el`. */ diff --git a/web/src/portal/main.ts b/web/src/portal/main.ts index 8d5c53a..dd24a2b 100644 --- a/web/src/portal/main.ts +++ b/web/src/portal/main.ts @@ -75,7 +75,6 @@ const base = app.dataset.base ?? ''; const pageTitle = app.dataset.title || 'Dawnline'; const isMobile = () => window.matchMedia('(max-width: 959px)').matches || /Android|iPhone|iPad/.test(navigator.userAgent); let state: State | null = null; -let pollTimer = 0; /** The personal link is the key: its path is the code (no sessions). */ const code = /^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(base) ? base.slice(1) : ''; @@ -1098,20 +1097,13 @@ async function refresh() { state = null; linkGone(); } - // A network hiccup: keep showing the last state and try again on the next poll. + // A network hiccup: keep showing the last state (the page loads fresh data on reload). else if (!state) shell(h('div', { class: 'card' }, h('p', {}, er.message))); } } -function startPolling() { - clearInterval(pollTimer); - pollTimer = window.setInterval(() => { - if (state && document.visibilityState === 'visible') void refresh(); - }, 15000); -} - +// No periodic refresh: every portal request runs a CGI process on the router. +// The page reloads its data after the visitor's own changes and while it waits +// for a new device's first connection. if (!base || !code) linkGone(); -else { - void refresh(); - startPolling(); -} +else void refresh();