Dawnline 0.1.1
Build packages / Version (push) Waiting to run

- Fix "Cannot set properties of undefined (setting '_class')" after adding
  a person on a server page: kept Overview/People tabs are taken out before
  dom.content() wipes their LuCI registry
- No portal links while the personal portal is off
- "Off" disguise writes a plain WireGuard config (no neutral Jc..H4 lines)
- Setup wizard: Settings-style groups, portal off by default, "Internet like
  a home device" switch; no "Link path" (server ids are picked by the router)
- Server ids and imported section names may not contain dashes
- Health: Cloudflare-proxied endpoint and portal address are not warnings
- Themes other than Outline: solid menus, drawer, palette, toasts and tooltips
  (Bootstrap colour tokens as fallbacks), custom select chevron
- Server section tabs scroll sideways instead of wrapping; centred empty
  People list; wider search; "1 device" in the palette
- lint-ucode: exported functions must end with "};"
This commit is contained in:
Aemeath committed 2026-10-15 04:58:28 +03:00
1 parent a3910f8b97
commit d0955e44b8
13 files changed
+168 -112

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-dawnline PKG_NAME:=luci-app-dawnline
PKG_VERSION:=0.1.0 PKG_VERSION:=0.1.1
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=MIT PKG_LICENSE:=MIT
@@ -7,13 +7,13 @@
'require rpc'; 'require rpc';
'require uci'; 'require uci';
'require ui'; 'require ui';
var yn=Object.create;var Ft=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var _n=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty;var Ln=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports);var Sn=(s,t,a,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $n(t))!Mn.call(s,i)&&i!==a&&Ft(s,i,{get:()=>t[i],enumerable:!(n=kn(t,i))||n.enumerable});return s};var Tn=(s,t,a)=>(a=s!=null?yn(_n(s)):{},Sn(t||!s||!s.__esModule?Ft(a,"default",{value:s,enumerable:!0}):a,s));var Jt=Ln((Vt,Yt)=>{"use strict";var Kt=(function(){var s=function(y,D){var T=236,f=17,g=y,k=a[D],c=null,p=0,C=null,v=[],b={},j=function(M,S){p=g*4+17,c=(function(x){for(var E=new Array(x),A=0;A<x;A+=1){E[A]=new Array(x);for(var I=0;I<x;I+=1)E[A][I]=null}return E})(p),q(0,0),q(p-7,0),q(0,p-7),ee(),Z(),ue(M,S),g>=7&&ie(M),C==null&&(C=yt(g,k,v)),he(C,S)},q=function(M,S){for(var x=-1;x<=7;x+=1)if(!(M+x<=-1||p<=M+x))for(var E=-1;E<=7;E+=1)S+E<=-1||p<=S+E||(0<=x&&x<=6&&(E==0||E==6)||0<=E&&E<=6&&(x==0||x==6)||2<=x&&x<=4&&2<=E&&E<=4?c[M+x][S+E]=!0:c[M+x][S+E]=!1)},H=function(){for(var M=0,S=0,x=0;x<8;x+=1){j(!0,x);var E=i.getLostPoint(b);(x==0||M>E)&&(M=E,S=x)}return S},Z=function(){for(var M=8;M<p-8;M+=1)c[M][6]==null&&(c[M][6]=M%2==0);for(var S=8;S<p-8;S+=1)c[6][S]==null&&(c[6][S]=S%2==0)},ee=function(){for(var M=i.getPatternPosition(g),S=0;S<M.length;S+=1)for(var x=0;x<M.length;x+=1){var E=M[S],A=M[x];if(c[E][A]==null)for(var I=-2;I<=2;I+=1)for(var G=-2;G<=2;G+=1)I==-2||I==2||G==-2||G==2||I==0&&G==0?c[E+I][A+G]=!0:c[E+I][A+G]=!1}},ie=function(M){for(var S=i.getBCHTypeNumber(g),x=0;x<18;x+=1){var E=!M&&(S>>x&1)==1;c[Math.floor(x/3)][x%3+p-8-3]=E}for(var x=0;x<18;x+=1){var E=!M&&(S>>x&1)==1;c[x%3+p-8-3][Math.floor(x/3)]=E}},ue=function(M,S){for(var x=k<<3|S,E=i.getBCHTypeInfo(x),A=0;A<15;A+=1){var I=!M&&(E>>A&1)==1;A<6?c[A][8]=I:A<8?c[A+1][8]=I:c[p-15+A][8]=I}for(var A=0;A<15;A+=1){var I=!M&&(E>>A&1)==1;A<8?c[8][p-A-1]=I:A<9?c[8][15-A-1+1]=I:c[8][15-A-1]=I}c[p-8][8]=!M},he=function(M,S){for(var x=-1,E=p-1,A=7,I=0,G=i.getMaskFunction(S),U=p-1;U>0;U-=2)for(U==6&&(U-=1);;){for(var te=0;te<2;te+=1)if(c[E][U-te]==null){var de=!1;I<M.length&&(de=(M[I]>>>A&1)==1);var F=G(E,U-te);F&&(de=!de),c[E][U-te]=de,A-=1,A==-1&&(I+=1,A=7)}if(E+=x,E<0||p<=E){E-=x,x=-x;break}}},Te=function(M,S){for(var x=0,E=0,A=0,I=new Array(S.length),G=new Array(S.length),U=0;U<S.length;U+=1){var te=S[U].dataCount,de=S[U].totalCount-te;E=Math.max(E,te),A=Math.max(A,de),I[U]=new Array(te);for(var F=0;F<I[U].length;F+=1)I[U][F]=255&M.getBuffer()[F+x];x+=te;var fe=i.getErrorCorrectPolynomial(de),me=r(I[U],fe.getLength()-1),qt=me.mod(fe);G[U]=new Array(fe.getLength()-1);for(var F=0;F<G[U].length;F+=1){var Ut=F+qt.getLength()-G[U].length;G[U][F]=Ut>=0?qt.getAt(Ut):0}}for(var Gt=0,F=0;F<S.length;F+=1)Gt+=S[F].totalCount;for(var kt=new Array(Gt),ot=0,F=0;F<E;F+=1)for(var U=0;U<S.length;U+=1)F<I[U].length&&(kt[ot]=I[U][F],ot+=1);for(var F=0;F<A;F+=1)for(var U=0;U<S.length;U+=1)F<G[U].length&&(kt[ot]=G[U][F],ot+=1);return kt},yt=function(M,S,x){for(var E=l.getRSBlocks(M,S),A=d(),I=0;I<x.length;I+=1){var G=x[I];A.put(G.getMode(),4),A.put(G.getLength(),i.getLengthInBits(G.getMode(),M)),G.write(A)}for(var U=0,I=0;I<E.length;I+=1)U+=E[I].dataCount;if(A.getLengthInBits()>U*8)throw"code length overflow. ("+A.getLengthInBits()+">"+U*8+")";for(A.getLengthInBits()+4<=U*8&&A.put(0,4);A.getLengthInBits()%8!=0;)A.putBit(!1);for(;!(A.getLengthInBits()>=U*8||(A.put(T,8),A.getLengthInBits()>=U*8));)A.put(f,8);return Te(A,E)};b.addData=function(M,S){S=S||"Byte";var x=null;switch(S){case"Numeric":x=h(M);break;case"Alphanumeric":x=m(M);break;case"Byte":x=u(M);break;case"Kanji":x=$(M);break;default:throw"mode:"+S}v.push(x),C=null},b.isDark=function(M,S){if(M<0||p<=M||S<0||p<=S)throw M+","+S;return c[M][S]},b.getModuleCount=function(){return p},b.make=function(){if(g<1){for(var M=1;M<40;M++){for(var S=l.getRSBlocks(M,k),x=d(),E=0;E<v.length;E++){var A=v[E];x.put(A.getMode(),4),x.put(A.getLength(),i.getLengthInBits(A.getMode(),M)),A.write(x)}for(var I=0,E=0;E<S.length;E++)I+=S[E].dataCount;if(x.getLengthInBits()<=I*8)break}g=M}j(!1,H())},b.createTableTag=function(M,S){M=M||2,S=typeof S>"u"?M*4:S;var x="";x+='<table style="',x+=" border-width: 0px; border-style: none;",x+=" border-collapse: collapse;",x+=" padding: 0px; margin: "+S+"px;",x+='">',x+="<tbody>";for(var E=0;E<b.getModuleCount();E+=1){x+="<tr>";for(var A=0;A<b.getModuleCount();A+=1)x+='<td style="',x+=" border-width: 0px; border-style: none;",x+=" border-collapse: collapse;",x+=" padding: 0px; margin: 0px;",x+=" width: "+M+"px;",x+=" height: "+M+"px;",x+=" background-color: ",x+=b.isDark(E,A)?"#000000":"#ffffff",x+=";",x+='"/>';x+="</tr>"}return x+="</tbody>",x+="</table>",x},b.createSvgTag=function(M,S,x,E){var A={};typeof arguments[0]=="object"&&(A=arguments[0],M=A.cellSize,S=A.margin,x=A.alt,E=A.title),M=M||2,S=typeof S>"u"?M*4:S,x=typeof x=="string"?{text:x}:x||{},x.text=x.text||null,Line truncated var yn=Object.create;var Ft=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var _n=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty;var Ln=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var Sn=(o,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $n(t))!Mn.call(o,i)&&i!==n&&Ft(o,i,{get:()=>t[i],enumerable:!(a=kn(t,i))||a.enumerable});return o};var Tn=(o,t,n)=>(n=o!=null?yn(_n(o)):{},Sn(t||!o||!o.__esModule?Ft(n,"default",{value:o,enumerable:!0}):n,o));var Jt=Ln((Vt,Yt)=>{"use strict";var Kt=(function(){var o=function(y,D){var T=236,f=17,g=y,_=n[D],c=null,u=0,C=null,v=[],b={},j=function(M,S){u=g*4+17,c=(function(x){for(var E=new Array(x),A=0;A<x;A+=1){E[A]=new Array(x);for(var B=0;B<x;B+=1)E[A][B]=null}return E})(u),q(0,0),q(u-7,0),q(0,u-7),ee(),Z(),he(M,S),g>=7&&ie(M),C==null&&(C=yt(g,_,v)),fe(C,S)},q=function(M,S){for(var x=-1;x<=7;x+=1)if(!(M+x<=-1||u<=M+x))for(var E=-1;E<=7;E+=1)S+E<=-1||u<=S+E||(0<=x&&x<=6&&(E==0||E==6)||0<=E&&E<=6&&(x==0||x==6)||2<=x&&x<=4&&2<=E&&E<=4?c[M+x][S+E]=!0:c[M+x][S+E]=!1)},I=function(){for(var M=0,S=0,x=0;x<8;x+=1){j(!0,x);var E=i.getLostPoint(b);(x==0||M>E)&&(M=E,S=x)}return S},Z=function(){for(var M=8;M<u-8;M+=1)c[M][6]==null&&(c[M][6]=M%2==0);for(var S=8;S<u-8;S+=1)c[6][S]==null&&(c[6][S]=S%2==0)},ee=function(){for(var M=i.getPatternPosition(g),S=0;S<M.length;S+=1)for(var x=0;x<M.length;x+=1){var E=M[S],A=M[x];if(c[E][A]==null)for(var B=-2;B<=2;B+=1)for(var G=-2;G<=2;G+=1)B==-2||B==2||G==-2||G==2||B==0&&G==0?c[E+B][A+G]=!0:c[E+B][A+G]=!1}},ie=function(M){for(var S=i.getBCHTypeNumber(g),x=0;x<18;x+=1){var E=!M&&(S>>x&1)==1;c[Math.floor(x/3)][x%3+u-8-3]=E}for(var x=0;x<18;x+=1){var E=!M&&(S>>x&1)==1;c[x%3+u-8-3][Math.floor(x/3)]=E}},he=function(M,S){for(var x=_<<3|S,E=i.getBCHTypeInfo(x),A=0;A<15;A+=1){var B=!M&&(E>>A&1)==1;A<6?c[A][8]=B:A<8?c[A+1][8]=B:c[u-15+A][8]=B}for(var A=0;A<15;A+=1){var B=!M&&(E>>A&1)==1;A<8?c[8][u-A-1]=B:A<9?c[8][15-A-1+1]=B:c[8][15-A-1]=B}c[u-8][8]=!M},fe=function(M,S){for(var x=-1,E=u-1,A=7,B=0,G=i.getMaskFunction(S),U=u-1;U>0;U-=2)for(U==6&&(U-=1);;){for(var te=0;te<2;te+=1)if(c[E][U-te]==null){var de=!1;B<M.length&&(de=(M[B]>>>A&1)==1);var W=G(E,U-te);W&&(de=!de),c[E][U-te]=de,A-=1,A==-1&&(B+=1,A=7)}if(E+=x,E<0||u<=E){E-=x,x=-x;break}}},Te=function(M,S){for(var x=0,E=0,A=0,B=new Array(S.length),G=new Array(S.length),U=0;U<S.length;U+=1){var te=S[U].dataCount,de=S[U].totalCount-te;E=Math.max(E,te),A=Math.max(A,de),B[U]=new Array(te);for(var W=0;W<B[U].length;W+=1)B[U][W]=255&M.getBuffer()[W+x];x+=te;var me=i.getErrorCorrectPolynomial(de),ge=r(B[U],me.getLength()-1),qt=ge.mod(me);G[U]=new Array(me.getLength()-1);for(var W=0;W<G[U].length;W+=1){var Ut=W+qt.getLength()-G[U].length;G[U][W]=Ut>=0?qt.getAt(Ut):0}}for(var Gt=0,W=0;W<S.length;W+=1)Gt+=S[W].totalCount;for(var kt=new Array(Gt),st=0,W=0;W<E;W+=1)for(var U=0;U<S.length;U+=1)W<B[U].length&&(kt[st]=B[U][W],st+=1);for(var W=0;W<A;W+=1)for(var U=0;U<S.length;U+=1)W<G[U].length&&(kt[st]=G[U][W],st+=1);return kt},yt=function(M,S,x){for(var E=l.getRSBlocks(M,S),A=d(),B=0;B<x.length;B+=1){var G=x[B];A.put(G.getMode(),4),A.put(G.getLength(),i.getLengthInBits(G.getMode(),M)),G.write(A)}for(var U=0,B=0;B<E.length;B+=1)U+=E[B].dataCount;if(A.getLengthInBits()>U*8)throw"code length overflow. ("+A.getLengthInBits()+">"+U*8+")";for(A.getLengthInBits()+4<=U*8&&A.put(0,4);A.getLengthInBits()%8!=0;)A.putBit(!1);for(;!(A.getLengthInBits()>=U*8||(A.put(T,8),A.getLengthInBits()>=U*8));)A.put(f,8);return Te(A,E)};b.addData=function(M,S){S=S||"Byte";var x=null;switch(S){case"Numeric":x=h(M);break;case"Alphanumeric":x=m(M);break;case"Byte":x=p(M);break;case"Kanji":x=$(M);break;default:throw"mode:"+S}v.push(x),C=null},b.isDark=function(M,S){if(M<0||u<=M||S<0||u<=S)throw M+","+S;return c[M][S]},b.getModuleCount=function(){return u},b.make=function(){if(g<1){for(var M=1;M<40;M++){for(var S=l.getRSBlocks(M,_),x=d(),E=0;E<v.length;E++){var A=v[E];x.put(A.getMode(),4),x.put(A.getLength(),i.getLengthInBits(A.getMode(),M)),A.write(x)}for(var B=0,E=0;E<S.length;E++)B+=S[E].dataCount;if(x.getLengthInBits()<=B*8)break}g=M}j(!1,I())},b.createTableTag=function(M,S){M=M||2,S=typeof S>"u"?M*4:S;var x="";x+='<table style="',x+=" border-width: 0px; border-style: none;",x+=" border-collapse: collapse;",x+=" padding: 0px; margin: "+S+"px;",x+='">',x+="<tbody>";for(var E=0;E<b.getModuleCount();E+=1){x+="<tr>";for(var A=0;A<b.getModuleCount();A+=1)x+='<td style="',x+=" border-width: 0px; border-style: none;",x+=" border-collapse: collapse;",x+=" padding: 0px; margin: 0px;",x+=" width: "+M+"px;",x+=" height: "+M+"px;",x+=" background-color: ",x+=b.isDark(E,A)?"#000000":"#ffffff",x+=";",x+='"/>';x+="</tr>"}return x+="</tbody>",x+="</table>",x},b.createSvgTag=function(M,S,x,E){var A={};typeof arguments[0]=="object"&&(A=arguments[0],M=A.cellSize,S=A.margin,x=A.alt,E=A.title),M=M||2,S=typeof S>"u"?M*4:S,x=typeof x=="string"?{text:x}:x||{},x.text=x.text||null,Line truncated
`}return x%2&&M>0?me.substring(0,me.length-x-1)+Array(x+1).join("▀"):me.substring(0,me.length-1)};return b.createASCII=function(M,S){if(M=M||1,M<2)return oe(S);M-=1,S=typeof S>"u"?M*2:S;var x=b.getModuleCount()*M+S*2,E=S,A=x-S,I,G,U,te,de=Array(M+1).join("██"),F=Array(M+1).join(" "),fe="",me="";for(I=0;I<x;I+=1){for(U=Math.floor((I-E)/M),me="",G=0;G<x;G+=1)te=1,E<=G&&G<A&&E<=I&&I<A&&b.isDark(U,Math.floor((G-E)/M))&&(te=0),me+=te?de:F;for(U=0;U<M;U+=1)fe+=me+` `}return x%2&&M>0?ge.substring(0,ge.length-x-1)+Array(x+1).join("▀"):ge.substring(0,ge.length-1)};return b.createASCII=function(M,S){if(M=M||1,M<2)return se(S);M-=1,S=typeof S>"u"?M*2:S;var x=b.getModuleCount()*M+S*2,E=S,A=x-S,B,G,U,te,de=Array(M+1).join("██"),W=Array(M+1).join(" "),me="",ge="";for(B=0;B<x;B+=1){for(U=Math.floor((B-E)/M),ge="",G=0;G<x;G+=1)te=1,E<=G&&G<A&&E<=B&&B<A&&b.isDark(U,Math.floor((G-E)/M))&&(te=0),ge+=te?de:W;for(U=0;U<M;U+=1)me+=ge+`
`}return fe.substring(0,fe.length-1)},b.renderTo2dContext=function(M,S){S=S||2;for(var x=b.getModuleCount(),E=0;E<x;E++)for(var A=0;A<x;A++)M.fillStyle=b.isDark(E,A)?"black":"white",M.fillRect(E*S,A*S,S,S)},b};s.stringToBytesFuncs={default:function(y){for(var D=[],T=0;T<y.length;T+=1){var f=y.charCodeAt(T);D.push(f&255)}return D}},s.stringToBytes=s.stringToBytesFuncs.default,s.createStringToBytes=function(y,D){var T=(function(){for(var g=J(y),k=function(){var Z=g.read();if(Z==-1)throw"eof";return Z},c=0,p={};;){var C=g.read();if(C==-1)break;var v=k(),b=k(),j=k(),q=String.fromCharCode(C<<8|v),H=b<<8|j;p[q]=H,c+=1}if(c!=D)throw c+" != "+D;return p})(),f=63;return function(g){for(var k=[],c=0;c<g.length;c+=1){var p=g.charCodeAt(c);if(p<128)k.push(p);else{var C=T[g.charAt(c)];typeof C=="number"?(C&255)==C?k.push(C):(k.push(C>>>8),k.push(C&255)):k.push(f)}}return k}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},a={L:1,M:0,Q:3,H:2},n={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},i=(function(){var y=[[],[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]],D=1335,T=7973,f=21522,g={},k=function(c){for(var p=0;c!=0;)p+=1,c>>>=1;return p};return g.getBCHTypeInfo=function(c){for(var p=c<<10;k(p)-k(D)>=0;)p^=D<<k(p)-k(D);return(c<<10|p)^f},g.getBCHTypeNumber=function(c){for(var p=c<<12;k(p)-k(T)>=0;)p^=T<<k(p)-k(T);return c<<12|p},g.getPatternPosition=function(c){return y[c-1]},g.getMaskFunction=function(c){switch(c){case n.PATTERN000:return function(p,C){return(p+C)%2==0};case n.PATTERN001:return function(p,C){return p%2==0};case n.PATTERN010:return function(p,C){return C%3==0};case n.PATTERN011:return function(p,C){return(p+C)%3==0};case n.PATTERN100:return function(p,C){return(Math.floor(p/2)+Math.floor(C/3))%2==0};case n.PATTERN101:return function(p,C){return p*C%2+p*C%3==0};case n.PATTERN110:return function(p,C){return(p*C%2+p*C%3)%2==0};case n.PATTERN111:return function(p,C){return(p*C%3+(p+C)%2)%2==0};default:throw"bad maskPattern:"+c}},g.getErrorCorrectPolynomial=function(c){for(var p=r([1],0),C=0;C<c;C+=1)p=p.multiply(r([1,o.gexp(C)],0));return p},g.getLengthInBits=function(c,p){if(1<=p&&p<10)switch(c){case t.MODE_NUMBER:return 10;case t.MODE_ALPHA_NUM:return 9;case t.MODE_8BIT_BYTE:return 8;case t.MODE_KANJI:return 8;default:throw"mode:"+c}else if(p<27)switch(c){case t.MODE_NUMBER:return 12;case t.MODE_ALPHA_NUM:return 11;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 10;default:throw"mode:"+c}else if(p<41)switch(c){case t.MODE_NUMBER:return 14;case t.MODE_ALPHA_NUM:return 13;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 12;default:throw"mode:"+c}else throw"type:"+p},g.getLostPoint=function(c){for(var p=c.getModuleCount(),C=0,v=0;v<p;v+=1)for(var b=0;b<p;b+=1){for(var j=0,q=c.isDark(v,b),H=-1;H<=1;H+=1)if(!(v+H<0||p<=v+H))for(var Z=-1;Z<=1;Z+=1)b+Z<0||p<=b+Z||H==0&&Z==0||q==c.isDark(v+H,b+Z)&&(j+=1);j>5&&(C+=3+j-5)}for(var v=0;v<p-1;v+=1)for(var b=0;b<p-1;b+=1){var ee=0;c.isDark(v,b)&&(ee+=1),c.isDark(v+1,b)&&(ee+=1),c.isDark(v,b+1)&&(ee+=1),c.isDark(v+1,b+1)&&(ee+=1),(ee==0||ee==4)&&(C+=3)}for(var v=0;v<p;v+=1)for(var b=0;b<p-6;b+=1)c.isDark(v,b)&&!c.isDark(v,b+1)&&c.isDark(v,b+2)&&c.isDark(v,b+3)&&c.isDark(v,b+4)&&!c.isDark(v,b+5)&&c.isDark(v,b+6)&&(C+=40);for(var b=0;b<p;b+=1)for(var v=0;v<p-6;v+=1)c.isDark(v,b)&&!c.isDark(v+1,b)&&c.isDark(v+2,b)&&c.isDark(v+3,b)&&c.isDark(v+4,b)&&!c.isDark(v+5,b)&&c.isDark(v+6,b)&&(C+=40);for(var ie=0,b=0;b<p;b+=1)for(var v=0;v<p;v+=1)c.isDark(v,b)&&(ie+=1);var ue=Math.abs(100*ie/p/p-50)/5;return C+=ue*10,C},g})(),o=(function(){for(var y=new Array(256),D=new Array(256),T=0;T<8;T+=1)y[T]=1<<T;for(var T=8;T<256;T+=1)y[T]=y[T-4]^y[T-5]^y[T-6]^y[T-8];for(var T=0;T<255;T+=1)D[y[T]]=T;var f={};return f.glog=function(g){if(g<1)throw"glog("+g+")";return D[g]},f.gexp=function(g){for(;g<0;)g+=255;for(;g>=256;)g-=255;return y[g]},f})();function r(y,D){if(typeof y.length>"u")throw y.length+"/"+D;var T=(function(){for(var g=0;g<y.length&&y[g]==0;)g+=1;for(var k=new Array(y.length-g+D),c=0;c<y.length-g;c+=1)k[c]=y[c+g];return k})(),f={};return f.getAt=function(g){return T[g]},f.getLength=function(){return T.length},f.multiply=function(g){for(var k=new Array(f.getLength()+g.getLength()-1),c=0;c<f.getLength();c+=1)for(var p=0;p<g.getLength();p+=1)k[c+p]^=o.gexp(o.glog(f.getAt(c))+o.glog(g.getAt(p)));return r(k,0)},f.mod=function(g){if(f.g Line truncated `}return me.substring(0,me.length-1)},b.renderTo2dContext=function(M,S){S=S||2;for(var x=b.getModuleCount(),E=0;E<x;E++)for(var A=0;A<x;A++)M.fillStyle=b.isDark(E,A)?"black":"white",M.fillRect(E*S,A*S,S,S)},b};o.stringToBytesFuncs={default:function(y){for(var D=[],T=0;T<y.length;T+=1){var f=y.charCodeAt(T);D.push(f&255)}return D}},o.stringToBytes=o.stringToBytesFuncs.default,o.createStringToBytes=function(y,D){var T=(function(){for(var g=Y(y),_=function(){var Z=g.read();if(Z==-1)throw"eof";return Z},c=0,u={};;){var C=g.read();if(C==-1)break;var v=_(),b=_(),j=_(),q=String.fromCharCode(C<<8|v),I=b<<8|j;u[q]=I,c+=1}if(c!=D)throw c+" != "+D;return u})(),f=63;return function(g){for(var _=[],c=0;c<g.length;c+=1){var u=g.charCodeAt(c);if(u<128)_.push(u);else{var C=T[g.charAt(c)];typeof C=="number"?(C&255)==C?_.push(C):(_.push(C>>>8),_.push(C&255)):_.push(f)}}return _}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},i=(function(){var y=[[],[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]],D=1335,T=7973,f=21522,g={},_=function(c){for(var u=0;c!=0;)u+=1,c>>>=1;return u};return g.getBCHTypeInfo=function(c){for(var u=c<<10;_(u)-_(D)>=0;)u^=D<<_(u)-_(D);return(c<<10|u)^f},g.getBCHTypeNumber=function(c){for(var u=c<<12;_(u)-_(T)>=0;)u^=T<<_(u)-_(T);return c<<12|u},g.getPatternPosition=function(c){return y[c-1]},g.getMaskFunction=function(c){switch(c){case a.PATTERN000:return function(u,C){return(u+C)%2==0};case a.PATTERN001:return function(u,C){return u%2==0};case a.PATTERN010:return function(u,C){return C%3==0};case a.PATTERN011:return function(u,C){return(u+C)%3==0};case a.PATTERN100:return function(u,C){return(Math.floor(u/2)+Math.floor(C/3))%2==0};case a.PATTERN101:return function(u,C){return u*C%2+u*C%3==0};case a.PATTERN110:return function(u,C){return(u*C%2+u*C%3)%2==0};case a.PATTERN111:return function(u,C){return(u*C%3+(u+C)%2)%2==0};default:throw"bad maskPattern:"+c}},g.getErrorCorrectPolynomial=function(c){for(var u=r([1],0),C=0;C<c;C+=1)u=u.multiply(r([1,s.gexp(C)],0));return u},g.getLengthInBits=function(c,u){if(1<=u&&u<10)switch(c){case t.MODE_NUMBER:return 10;case t.MODE_ALPHA_NUM:return 9;case t.MODE_8BIT_BYTE:return 8;case t.MODE_KANJI:return 8;default:throw"mode:"+c}else if(u<27)switch(c){case t.MODE_NUMBER:return 12;case t.MODE_ALPHA_NUM:return 11;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 10;default:throw"mode:"+c}else if(u<41)switch(c){case t.MODE_NUMBER:return 14;case t.MODE_ALPHA_NUM:return 13;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 12;default:throw"mode:"+c}else throw"type:"+u},g.getLostPoint=function(c){for(var u=c.getModuleCount(),C=0,v=0;v<u;v+=1)for(var b=0;b<u;b+=1){for(var j=0,q=c.isDark(v,b),I=-1;I<=1;I+=1)if(!(v+I<0||u<=v+I))for(var Z=-1;Z<=1;Z+=1)b+Z<0||u<=b+Z||I==0&&Z==0||q==c.isDark(v+I,b+Z)&&(j+=1);j>5&&(C+=3+j-5)}for(var v=0;v<u-1;v+=1)for(var b=0;b<u-1;b+=1){var ee=0;c.isDark(v,b)&&(ee+=1),c.isDark(v+1,b)&&(ee+=1),c.isDark(v,b+1)&&(ee+=1),c.isDark(v+1,b+1)&&(ee+=1),(ee==0||ee==4)&&(C+=3)}for(var v=0;v<u;v+=1)for(var b=0;b<u-6;b+=1)c.isDark(v,b)&&!c.isDark(v,b+1)&&c.isDark(v,b+2)&&c.isDark(v,b+3)&&c.isDark(v,b+4)&&!c.isDark(v,b+5)&&c.isDark(v,b+6)&&(C+=40);for(var b=0;b<u;b+=1)for(var v=0;v<u-6;v+=1)c.isDark(v,b)&&!c.isDark(v+1,b)&&c.isDark(v+2,b)&&c.isDark(v+3,b)&&c.isDark(v+4,b)&&!c.isDark(v+5,b)&&c.isDark(v+6,b)&&(C+=40);for(var ie=0,b=0;b<u;b+=1)for(var v=0;v<u;v+=1)c.isDark(v,b)&&(ie+=1);var he=Math.abs(100*ie/u/u-50)/5;return C+=he*10,C},g})(),s=(function(){for(var y=new Array(256),D=new Array(256),T=0;T<8;T+=1)y[T]=1<<T;for(var T=8;T<256;T+=1)y[T]=y[T-4]^y[T-5]^y[T-6]^y[T-8];for(var T=0;T<255;T+=1)D[y[T]]=T;var f={};return f.glog=function(g){if(g<1)throw"glog("+g+")";return D[g]},f.gexp=function(g){for(;g<0;)g+=255;for(;g>=256;)g-=255;return y[g]},f})();function r(y,D){if(typeof y.length>"u")throw y.length+"/"+D;var T=(function(){for(var g=0;g<y.length&&y[g]==0;)g+=1;for(var _=new Array(y.length-g+D),c=0;c<y.length-g;c+=1)_[c]=y[c+g];return _})(),f={};return f.getAt=function(g){return T[g]},f.getLength=function(){return T.length},f.multiply=function(g){for(var _=new Array(f.getLength()+g.getLength()-1),c=0;c<f.getLength();c+=1)for(var u=0;u<g.getLength();u+=1)_[c+u]^=s.gexp(s.glog(f.getAt(c))+s.glog(g.getAt(u)));return r(_,0)},f.mod=function(g){if(f.g Line truncated
`),hostName:o,mtu:a.mtu,persistent_keep_alive:a.persistent_keep_alive,port:Number(a.port),psk_key:a.psk_key,server_pub_key:a.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(r),port:String(a.port),protocol_version:n.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:o};return a.dns[0]&&(l.dns1=a.dns[0]),a.dns[1]&&(l.dns2=a.dns[1]),l}function On(s){let t="";for(let a=0;a<s.length;a+=32768)t+=String.fromCharCode(...s.subarray(a,a+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function qn(s){let t=globalThis;if(typeof t.CompressionStream>"u")return null;try{let a=new t.Blob([s]).stream().pipeThrough(new t.CompressionStream("deflate")),n=new Uint8Array(await new t.Response(a).arrayBuffer()),i=new Uint8Array(4+n.length);return new DataView(i.buffer).setUint32(0,s.length,!1),i.set(n,4),i}catch{return null}}async function Zt(s,t,a=!0){let n=new TextEncoder().encode(JSON.stringify(jn(s,t))),i=a?await qn(n):null;return`vpn://${On(i??n)}`}function K(s){if(!s||s<0)return"0 B";let t=["B","KB","MB","GB","TB"],a=0,n=s;for(;n>=1024&&a<t.length-1;)n/=1024,a++;return`${n>=100||a===0?Math.round(n):n.toFixed(1)} ${t[a]}`}function $e(s){let t=s*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 ce(s,t=Date.now()/1e3){if(!s)return"never";let a=Math.max(0,Math.round(t-s));return a<60?"just now":a<3600?`${Math.floor(a/60)} min ago`:a<86400?`${Math.floor(a/3600)} h ago`:a<86400*30?`${Math.floor(a/86400)} d ago`:new Date(s*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Xt(s){if(!s||s<0)return"—";let t=Math.floor(s/86400),a=Math.floor(s%86400/3600),n=Math.floor(s%3600/60);return t?`${t}d ${a}h`:a?`${a}h ${n}m`:`${n}m`}function St(s){let t=new Date(s*1e3),a=new Date,n=t.toDateString()===a.toDateString(),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return n?i:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${i}`}function _e(s){if(!s)return"";let[t,a,n]=s.split("-").map(Number);return new Date(t,a-1,n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ze(s,t=Date.now()){if(!s)return null;let[a,n,i]=s.split("-").map(Number),o=new Date(a,n-1,i,23,59,59).getTime();return Math.ceil((o-t)/864e5)}var Be={lan:"Home network",internet:"Internet",both:"Home network + Internet"},en={lan:"LAN",internet:"Internet",both:"LAN + Internet"},tn=["computer","phone","tablet","router","other"],Me={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Tt={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Le(s){let t=s.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let a=t[0][0]??"",n=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(a+n).toUpperCase()}var Ne=null;function le(s,t){let a=n=>{Ne??(Ne=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),Ne.replaceChildren(...t().map(i=>typeof i=="string"?document.createTextNode(i):i)),Ne.style.display="",Ne.style.left=`${n.clientX}px`,Ne.style.top=`${n.clientY-10}px`};s.addEventListener("mouseenter",a),s.addEventListener("mousemove",a),s.addEventListener("mouseleave",()=>Ne&&(Ne.style.display="none"))}function nn(s,t=120,a=26){let n=Math.max(1,...s),i=e("div",{class:"dl-spark"});i.style.width=`${t}px`,i.style.height=`${a}px`;let o=Date.now();return s.forEach((r,l)=>{let d=e("i");d.style.height=`${Math.max(6,r/n*100)}%`,r||d.classList.add("zero");let h=s.length-1-l,m=new Date(o-h*864e5);le(d,()=>[e("div",{class:"dl-tip-title"},h===0?"Today":h===1?"Yesterday":m.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},K(r))]),i.appendChild(d)}),i}var Un={connect:"connections",disconnect:"connections",roam:"connections",device_added:"devices",device_removed:"devices",devices_removed:"devices",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",paused_all:"people",resumed_all:"people",server_down:"problems",server_up:"problems",portal_blocked:"problems"},je=["connections","devices","people","problems"],Oe={connections:"Connections",devices:"Devices",people:"People",problems:"Problems"},an={connections:"Connects, disconnects and IP changes",devices:"Devices added and removed",people:"People added, changed, paused",problems:"Tunnel down, blocked portal sign-ins"},rt=s=>Un[s]??"problems";function Gn(s){let t=new Map(s.people.map(n=>[n.id,n.name])),a=new Map(s.people.flatMap(n=>n.devices.map(i=>[i.id,i.name])));return{people:t,devices:a}}function Fn(s){let t=s==null?"":String(s);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function ve(s,t,a,n=""){let i=Gn(s),o=t. Line truncated `),hostName:s,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(r),port:String(n.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:s};return n.dns[0]&&(l.dns1=n.dns[0]),n.dns[1]&&(l.dns2=n.dns[1]),l}function On(o){let t="";for(let n=0;n<o.length;n+=32768)t+=String.fromCharCode(...o.subarray(n,n+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function qn(o){let t=globalThis;if(typeof t.CompressionStream>"u")return null;try{let n=new t.Blob([o]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.Response(n).arrayBuffer()),i=new Uint8Array(4+a.length);return new DataView(i.buffer).setUint32(0,o.length,!1),i.set(a,4),i}catch{return null}}async function Zt(o,t,n=!0){let a=new TextEncoder().encode(JSON.stringify(jn(o,t))),i=n?await qn(a):null;return`vpn://${On(i??a)}`}function V(o){if(!o||o<0)return"0 B";let t=["B","KB","MB","GB","TB"],n=0,a=o;for(;a>=1024&&n<t.length-1;)a/=1024,n++;return`${a>=100||n===0?Math.round(a):a.toFixed(1)} ${t[n]}`}function $e(o){let t=o*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 ce(o,t=Date.now()/1e3){if(!o)return"never";let n=Math.max(0,Math.round(t-o));return n<60?"just now":n<3600?`${Math.floor(n/60)} min ago`:n<86400?`${Math.floor(n/3600)} h ago`:n<86400*30?`${Math.floor(n/86400)} d ago`:new Date(o*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Xt(o){if(!o||o<0)return"—";let t=Math.floor(o/86400),n=Math.floor(o%86400/3600),a=Math.floor(o%3600/60);return t?`${t}d ${n}h`:n?`${n}h ${a}m`:`${a}m`}function St(o){let t=new Date(o*1e3),n=new Date,a=t.toDateString()===n.toDateString(),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?i:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${i}`}function _e(o){if(!o)return"";let[t,n,a]=o.split("-").map(Number);return new Date(t,n-1,a).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ze(o,t=Date.now()){if(!o)return null;let[n,a,i]=o.split("-").map(Number),s=new Date(n,a-1,i,23,59,59).getTime();return Math.ceil((s-t)/864e5)}var je={lan:"Home network",internet:"Internet",both:"Home network + Internet"},en={lan:"LAN",internet:"Internet",both:"LAN + Internet"},tn=["computer","phone","tablet","router","other"],Me={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Tt={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Le(o){let t=o.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let n=t[0][0]??"",a=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(n+a).toUpperCase()}var Ne=null;function le(o,t){let n=a=>{Ne??(Ne=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),Ne.replaceChildren(...t().map(i=>typeof i=="string"?document.createTextNode(i):i)),Ne.style.display="",Ne.style.left=`${a.clientX}px`,Ne.style.top=`${a.clientY-10}px`};o.addEventListener("mouseenter",n),o.addEventListener("mousemove",n),o.addEventListener("mouseleave",()=>Ne&&(Ne.style.display="none"))}function nn(o,t=120,n=26){let a=Math.max(1,...o),i=e("div",{class:"dl-spark"});i.style.width=`${t}px`,i.style.height=`${n}px`;let s=Date.now();return o.forEach((r,l)=>{let d=e("i");d.style.height=`${Math.max(6,r/a*100)}%`,r||d.classList.add("zero");let h=o.length-1-l,m=new Date(s-h*864e5);le(d,()=>[e("div",{class:"dl-tip-title"},h===0?"Today":h===1?"Yesterday":m.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},V(r))]),i.appendChild(d)}),i}var Un={connect:"connections",disconnect:"connections",roam:"connections",device_added:"devices",device_removed:"devices",devices_removed:"devices",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",paused_all:"people",resumed_all:"people",server_down:"problems",server_up:"problems",portal_blocked:"problems"},Oe=["connections","devices","people","problems"],qe={connections:"Connections",devices:"Devices",people:"People",problems:"Problems"},an={connections:"Connects, disconnects and IP changes",devices:"Devices added and removed",people:"People added, changed, paused",problems:"Tunnel down, blocked portal sign-ins"},rt=o=>Un[o]??"problems";function Gn(o){let t=new Map(o.people.map(a=>[a.id,a.name])),n=new Map(o.people.flatMap(a=>a.devices.map(i=>[i.id,i.name])));return{people:t,devices:n}}function Fn(o){let t=o==null?"":String(o);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function be(o,t,n,a=""){let i=Gn(o),s=t. Line truncated
`);ge(l,h,"text/csv")}var Wn=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]];function Ce(s,t,a,n,i){let o=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...je.map(l=>e("option",{value:l,selected:l===i?"selected":null},Oe[l]))]),r=e("select",{class:"cbi-input-select"},Wn.map(([l,d])=>e("option",{value:l},d)));ne(s,[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"),o]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Which events"),r])],[e("button",{class:"cbi-button cbi-button-neutral",click:Y},"Cancel")," ",z("Clear",async()=>{let l=await O(()=>P.logsClear({...a,category:o.value,older_days:r.value}));l&&(Y(),X(l.removed?`${l.removed} event${l.removed===1?"":"s"} removed`:"Nothing matched","success",3e3),n())},"negative")])}function qe(s,t,a,n){let i=s==="device"?`Clears ${a}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:s==="person"?`Clears ${a}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";ne(s==="all"?"Reset all traffic history?":`Reset traffic history for ${a}?`,[e("p",{class:"dl-muted"},i)],[e("button",{class:"cbi-button cbi-button-neutral",click:Y},"Cancel")," ",z("Reset",async()=>{await O(()=>P.usageClear(s,t),"Traffic history reset")&&(Y(),n())},"negative")])}var lt=null;function Kn(s){return s?new Date(s*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function sn(s,t,a=!0){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},s),e("button",{type:"button",class:`dl-kvrow-v copy${a?" dl-mono":""}`,title:"Copy",click:()=>re(t,`${s} copied`)},[e("span",{},t),w("copy")])])}function dt(s,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},s),e("span",{class:"dl-kvrow-v"},t)])}function on(s,t){if(/^\s*\[.+\]\s*$/.test(s))return e("span",{class:"dl-conf-sec"},s);let a=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(s);if(!a)return document.createTextNode(s);let n=/^(\s*)(PrivateKey|PresharedKey)\b/.test(s);return e("span",{},[e("span",{class:"dl-conf-k"},a[1])," ",n&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):a[2]])}function Vn(s){let t=!1,a=e("pre",{class:"dl-conf"}),n=()=>dom.content(a,s.conf.split(` `);ve(l,h,"text/csv")}var Wn=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]];function Ee(o,t,n,a,i){let s=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...Oe.map(l=>e("option",{value:l,selected:l===i?"selected":null},qe[l]))]),r=e("select",{class:"cbi-input-select"},Wn.map(([l,d])=>e("option",{value:l},d)));ne(o,[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"),r])],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",N("Clear",async()=>{let l=await O(()=>P.logsClear({...n,category:s.value,older_days:r.value}));l&&(J(),X(l.removed?`${l.removed} event${l.removed===1?"":"s"} removed`:"Nothing matched","success",3e3),a())},"negative")])}function Ue(o,t,n,a){let i=o==="device"?`Clears ${n}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:o==="person"?`Clears ${n}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";ne(o==="all"?"Reset all traffic history?":`Reset traffic history for ${n}?`,[e("p",{class:"dl-muted"},i)],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",N("Reset",async()=>{await O(()=>P.usageClear(o,t),"Traffic history reset")&&(J(),a())},"negative")])}var lt=null;function Kn(o){return o?new Date(o*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function on(o,t,n=!0){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},o),e("button",{type:"button",class:`dl-kvrow-v copy${n?" dl-mono":""}`,title:"Copy",click:()=>re(t,`${o} copied`)},[e("span",{},t),w("copy")])])}function dt(o,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},o),e("span",{class:"dl-kvrow-v"},t)])}function sn(o,t){if(/^\s*\[.+\]\s*$/.test(o))return e("span",{class:"dl-conf-sec"},o);let n=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(o);if(!n)return document.createTextNode(o);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(o);return e("span",{},[e("span",{class:"dl-conf-k"},n[1])," ",a&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):n[2]])}function Vn(o){let t=!1,n=e("pre",{class:"dl-conf"}),a=()=>dom.content(n,o.conf.split(`
`).flatMap((r,l)=>l?[` `).flatMap((r,l)=>l?[`
`,on(r,t)]:[on(r,t)])),i=e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),t=!t,dom.content(i,[w(t?"x":"key"),t?"Hide key":"Show key"]),n()}},[w("key"),"Show key"]);n();let o=new Blob([s.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"},s.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${o} bytes · import it in the app`)]),z([w("download")," Download"],()=>ge(s.filename,s.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[w("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),i,e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),re(s.conf,"Configuration copied")}},[w("copy"),"Copy"])]),a])])}async function Et(s){if(!s.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 t=await Zt(s,`${s.server} · ${s.person} · ${s.name}`),a={qr:()=>e("div",{class:"dl-qr-pane"},[Pe(Ie(s.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"},t),z("Copy",()=>re(t,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>Vn(s)},n=e("div",{class:"dl-connect-body"}),i=e("div",{class:"dl-seg"}),o=r=>{i.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.id===r)),dom.content(n,a[r]())};for(let[r,l]of[["qr","QR code"],["key","Key"],["file","File"]])i.appendChild(e("button",{type:"button","data-id":r,click:()=>o(r)},l));return o("qr"),e("div",{class:"dl-stack gap12"},[i,n])}function Yn(s,t,a,n){lt?.close();let i=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[s,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>l()},w("x"))]),e("div",{class:"dl-drawer-body"},t),a?e("div",{class:"dl-drawer-foot"},a):""]),o=e("div",{class:"dl-drawer-overlay dl-root",click:h=>{h.target===o&&l()}},i),r=h=>{h.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&l()};function l(){document.removeEventListener("keydown",r),o.classList.remove("open"),setTimeout(()=>o.remove(),220),lt===d&&(lt=null),n()}let d={close:l,panel:i};return document.addEventListener("keydown",r),document.body.appendChild(o),requestAnimationFrame(()=>o.classList.add("open")),lt=d,d}var rn={connect:["ok","Connected"],disconnect:["","Went offline"],roam:["","Changed network"],device_added:["accent","Added"],device_removed:["","Removed"]};function Jn(s,t){let a=s.filter(n=>n.device===t&&rn[n.type]).reverse().slice(0,12);return a.length?e("div",{class:"dl-dev-log"},a.map(n=>{let[i,o]=rn[n.type],r=n.type==="connect"?[n.detail?e("span",{class:"dl-mono"},` ${n.detail}`):"",n.where?e("span",{class:"dl-faint"},` · ${n.where}`):""]:n.type==="roam"?[e("span",{class:"dl-mono dl-faint"},` ${n.detail??""}`)]:n.type==="device_added"?[e("span",{class:"dl-faint"},(n.detail??"").includes("(portal)")?" from the portal":" by you")]:[],l=new Date(n.ts*1e3);return e("div",{class:"dl-dev-log-row"},[e("span",{class:`dl-ev-dot ${i}`}),e("span",{class:"dl-row-main"},[e("span",{},o),...r]),e("span",{class:"dl-faint dl-nowrap",title:l.toLocaleString()},ce(n.ts))])})):e("div",{class:"dl-sub"},"No activity yet.")}function Qn(s){return s.disabled?e("span",{class:"dl-dstat"},[e("i",{class:"dot"}),"Disabled"]):s.online?e("span",{class:"dl-dstat ok"},[e("i",{class:"dot ok"}),`Online from ${s.endpoint}`]):s.handshake?e("span",{class:"dl-dstat"},[e("i",{class:"dot"}),`Last seen ${ce(s.handshake)}`]):e("span",{class:"dl-dstat warn"},[e("i",{class:"dot warn"}),"Waiting for the first connection"])}async function De(s,t,a,n){let i=await O(()=>P.deviceConfig(t.id));if(!i)return;let o=t,r=s,l=await Et(i),d=e("div",{class:"dl-drawer-title"}),h=e("div",{}),m=e("div",{}),u=e("div",{class:"dl-live"}),$=e("div",{},e("div",{class:"dl-sub"},"Loading…")),_=[],N=async()=>{let g=await P.events(5e3).catch(()=>null);g&&(_=g.events.filter(k=>k.device===o.id),dom.content($,Jn(g.events,o.id)))},J=()=>{let g=n?.points.find(c=>c.device===o.id&&c.ip===o.endpoint);dom.content(d,[e("span",{class:`dl-dcard-ic${o.online?" on":""}`},w(o.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},o.name),z([w("edit")],()=>B(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},[`${r.name} · ${Me[o.kind]}`])])]);let k=o.spark.reduce((c,p)=>c+p,0);dom.content(h,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),Qn(o)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},K(o.month[0]+o.month[1])),e("span", Line truncated `,sn(r,t)]:[sn(r,t)])),i=e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),t=!t,dom.content(i,[w(t?"x":"key"),t?"Hide key":"Show key"]),a()}},[w("key"),"Show key"]);a();let s=new Blob([o.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"},o.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${s} bytes · import it in the app`)]),N([w("download")," Download"],()=>ve(o.filename,o.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[w("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),i,e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),re(o.conf,"Configuration copied")}},[w("copy"),"Copy"])]),n])])}async function Et(o){if(!o.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 t=await Zt(o,`${o.server} · ${o.person} · ${o.name}`),n={qr:()=>e("div",{class:"dl-qr-pane"},[Pe(Be(o.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"},t),N("Copy",()=>re(t,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>Vn(o)},a=e("div",{class:"dl-connect-body"}),i=e("div",{class:"dl-seg"}),s=r=>{i.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.id===r)),dom.content(a,n[r]())};for(let[r,l]of[["qr","QR code"],["key","Key"],["file","File"]])i.appendChild(e("button",{type:"button","data-id":r,click:()=>s(r)},l));return s("qr"),e("div",{class:"dl-stack gap12"},[i,a])}function Yn(o,t,n,a){lt?.close();let i=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[o,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>l()},w("x"))]),e("div",{class:"dl-drawer-body"},t),n?e("div",{class:"dl-drawer-foot"},n):""]),s=e("div",{class:"dl-drawer-overlay dl-root",click:h=>{h.target===s&&l()}},i),r=h=>{h.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&l()};function l(){document.removeEventListener("keydown",r),s.classList.remove("open"),setTimeout(()=>s.remove(),220),lt===d&&(lt=null),a()}let d={close:l,panel:i};return document.addEventListener("keydown",r),document.body.appendChild(s),requestAnimationFrame(()=>s.classList.add("open")),lt=d,d}var rn={connect:["ok","Connected"],disconnect:["","Went offline"],roam:["","Changed network"],device_added:["accent","Added"],device_removed:["","Removed"]};function Jn(o,t){let n=o.filter(a=>a.device===t&&rn[a.type]).reverse().slice(0,12);return n.length?e("div",{class:"dl-dev-log"},n.map(a=>{let[i,s]=rn[a.type],r=a.type==="connect"?[a.detail?e("span",{class:"dl-mono"},` ${a.detail}`):"",a.where?e("span",{class:"dl-faint"},` · ${a.where}`):""]:a.type==="roam"?[e("span",{class:"dl-mono dl-faint"},` ${a.detail??""}`)]:a.type==="device_added"?[e("span",{class:"dl-faint"},(a.detail??"").includes("(portal)")?" from the portal":" by you")]:[],l=new Date(a.ts*1e3);return e("div",{class:"dl-dev-log-row"},[e("span",{class:`dl-ev-dot ${i}`}),e("span",{class:"dl-row-main"},[e("span",{},s),...r]),e("span",{class:"dl-faint dl-nowrap",title:l.toLocaleString()},ce(a.ts))])})):e("div",{class:"dl-sub"},"No activity yet.")}function Qn(o){return o.disabled?e("span",{class:"dl-dstat"},[e("i",{class:"dot"}),"Disabled"]):o.online?e("span",{class:"dl-dstat ok"},[e("i",{class:"dot ok"}),`Online from ${o.endpoint}`]):o.handshake?e("span",{class:"dl-dstat"},[e("i",{class:"dot"}),`Last seen ${ce(o.handshake)}`]):e("span",{class:"dl-dstat warn"},[e("i",{class:"dot warn"}),"Waiting for the first connection"])}async function Ce(o,t,n,a){let i=await O(()=>P.deviceConfig(t.id));if(!i)return;let s=t,r=o,l=await Et(i),d=e("div",{class:"dl-drawer-title"}),h=e("div",{}),m=e("div",{}),p=e("div",{class:"dl-live"}),$=e("div",{},e("div",{class:"dl-sub"},"Loading…")),k=[],z=async()=>{let g=await P.events(5e3).catch(()=>null);g&&(k=g.events.filter(_=>_.device===s.id),dom.content($,Jn(g.events,s.id)))},Y=()=>{let g=a?.points.find(c=>c.device===s.id&&c.ip===s.endpoint);dom.content(d,[e("span",{class:`dl-dcard-ic${s.online?" on":""}`},w(s.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},s.name),N([w("edit")],()=>H(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},[`${r.name} · ${Me[s.kind]}`])])]);let _=s.spark.reduce((c,u)=>c+u,0);dom.content(h,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),Qn(s)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},V(s.month[0]+s.month[1])),e("span", Line truncated
`),d=e("div",{class:"dl-pgrid"},[i("Junk packets","zap",o?`${o} random packet${o===1?"":"s"} of ${s.jmin}–${s.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),i("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),i("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),i("Signatures","globe",r,["i1","i2","i3","i4","i5"]),i("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"]),i("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",{},[w("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(a.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:h=>{h.preventDefault(),re(l,"Parameters copied")}},"Copy as config")]),d])}var Rt=(s,t)=>{let a=new URLSearchParams;s&&a.set("server",s),t&&t!=="overview"&&a.set("section",t);let n=a.toString();return`${L.url("admin/network/dawnline/server")}${n?`?${n}`:""}`},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 P.status(31),a=t.servers.length?null:await P.setupDefaults();return[t,a]}render([t,a]){if(this.st=t,!t.servers.length&&a)return this.wizard(a);let n=new URLSearchParams(location.search),i=n.get("section")??"",o=Ma[i]??i;return mn.some(([r])=>r===o)&&(this.section=o),this.srvId=(t.servers.find(r=>r.id===n.get("server"))??t.servers[0]).id,xe(t),dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),poll.add(async()=>{if(this.section!=="overview")return;let r=await P.status(31).catch(()=>null);if(!r||!r.servers.length)return;this.st=r;let l=this.current();dom.content(this.headEl,this.head(l)),this.paintTabs(),this.ov[l.id]?.update(r)},10),this.root}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await P.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=Rt())}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(a=>e("button",{type:"button",role:"tab",class:`dl-srvtab${a.id===t.id?" on":""}`,"aria-selected":a.id===t.id?"true":"false",click:()=>{a.id!==this.srvId&&(this.srvId=a.id,this.paint())}},[e("i",{class:`dot ${a.up?"ok":"bad"}`}),e("b",{},a.name),e("span",{class:"dl-mono dl-faint"},`:${a.port}`)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[w("plus"),"Add server"])]))}paintSections(){dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},mn.map(([t,a])=>e("button",{type:"button",role:"tab","data-section":t,class:t===this.section?"on":"","aria-selected":t===this.section?"true":"false",click:()=>this.showSection(t)},a))))}go(t,a){let n=this.pp[this.current().id];if(a&&n)n.filter=a,n.el&&n.decorate();else if(a){let i=this.pp[this.current().id]=new He;i.filter=a}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(o=>{let r=o.dataset.section===t;o.classList.toggle("on",r),o.setAttribute("aria-selected",r?"true":"false")});let a=this.st,n=this.current(),i={overview:()=>{let o=this.ov[n.id];return o?(o.update(a),o.el):(this.ov[n.id]=new ft(n.id,(r,l)=>this.go(r,l))).mount(a)},people:()=>{var d,h;let o=this.pp[n.id];if(o?.el)return o.poll(),o.el;let r=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((d=this.pp)[h=n.id]??(d[h]=new He)).embed(a,n.id).then(m=>{r.isConnected?dom.content(r,m):r.replaceChildren(m)}),r},connection:()=>this.connection(n),access:()=>this.access(n),disguise:()=>this.disguise(n),tunnel:()=>this.tunnel(n)};dom.content(this.bodyEl,i[t]())}head(t){let a=this.st,n=(l,d)=>e("span",{class:"dl-addrbar-seg"},[w(l),...d]),i=`${t.endpoint||"—"}:${t.port}`,o=!t.enabled||a.settings.paused_all,r=e("div",{class:"dl-actions"},[z([w("search")," Search ",e("kbd",{},"⌘K")],()=>Ct(),"neutral",{class:"cbi-button cbi-button-neutral dl-searchbtn"}),o?z([w("play")," Turn on"],async()=>{a.settings.paused_all&&!await O(()=>P.pauseAll(!1))||(t.enabled?await this.refresh():await this.save(t,{enabled:"1"},"Server turned on"))},"positive"):""]);r Line truncated `),d=e("div",{class:"dl-pgrid"},[i("Junk packets","zap",s?`${s} random packet${s===1?"":"s"} of ${o.jmin}–${o.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),i("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),i("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),i("Signatures","globe",r,["i1","i2","i3","i4","i5"]),i("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"]),i("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",{},[w("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(n.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:h=>{h.preventDefault(),re(l,"Parameters copied")}},"Copy as config")]),d])}var Rt=(o,t)=>{let n=new URLSearchParams;o&&n.set("server",o),t&&t!=="overview"&&n.set("section",t);let a=n.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 P.status(31),n=t.servers.length?null:await P.setupDefaults();return[t,n]}render([t,n]){if(this.st=t,!t.servers.length&&n)return this.wizard(n);let a=new URLSearchParams(location.search),i=a.get("section")??"",s=Ma[i]??i;return mn.some(([r])=>r===s)&&(this.section=s),this.srvId=(t.servers.find(r=>r.id===a.get("server"))??t.servers[0]).id,we(t),dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),poll.add(async()=>{if(this.section!=="overview")return;let r=await P.status(31).catch(()=>null);if(!r||!r.servers.length)return;this.st=r;let l=this.current();dom.content(this.headEl,this.head(l)),this.paintTabs(),this.ov[l.id]?.update(r)},10),this.root}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await P.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=Rt())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let t=this.current();dom.content(this.tabsEl,e("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(n=>e("button",{type:"button",role:"tab",class:`dl-srvtab${n.id===t.id?" on":""}`,"aria-selected":n.id===t.id?"true":"false",click:()=>{n.id!==this.srvId&&(this.srvId=n.id,this.paint())}},[e("i",{class:`dot ${n.up?"ok":"bad"}`}),e("b",{},n.name),e("span",{class:"dl-mono dl-faint"},`:${n.port}`)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[w("plus"),"Add server"])]))}paintSections(){dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},mn.map(([t,n])=>e("button",{type:"button",role:"tab","data-section":t,class:t===this.section?"on":"","aria-selected":t===this.section?"true":"false",click:()=>this.showSection(t)},n))))}go(t,n){let a=this.pp[this.current().id];if(n&&a)a.filter=n,a.el&&a.decorate();else if(n){let i=this.pp[this.current().id]=new He;i.filter=n}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let t=[...Object.values(this.ov).map(n=>n.el),...Object.values(this.pp).map(n=>n.el)];for(let n of t)n&&this.bodyEl.contains(n)&&n.remove()}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(r=>{let l=r.dataset.section===t;r.classList.toggle("on",l),r.setAttribute("aria-selected",l?"true":"false")});let n=this.st,a=this.current(),s={overview:()=>{let r=this.ov[a.id];return r?(r.update(n),r.el):(this.ov[a.id]=new ft(a.id,(l,d)=>this.go(l,d))).mount(n)},people:()=>{var h,m;let r=this.pp[a.id];if(r?.el)return r.poll(),r.el;let l=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((h=this.pp)[m=a.id]??(h[m]=new He)).embed(n,a.id).then(p=>{l.isConnected?dom.content(l,p):l.replaceChildren(p)}),l},connection:()=>this.connection(a),access:()=>this.access(a),disguise:()=>this.disguise(a),tunnel:()=>this.tunnel(a)}[t]();this.detachKept(),dom.content(this.bodyEl,s)}head(t){let n=this.st,a=(l,d)=>e("span",{class:"dl-addrbar-seg"},[w(l),...d]),i=`${t.endpoint||"—"}:${t.port}`,s=!t.enabled||n.settings.paused_all,r=e("div",{class:"dl-actions"},[N([w("search")," Search ",e("kbd",{},"⌘K")],()=>Ct(),"neutral",{class:"cbi-button cbi-button-neutral dl-searchbtn"}),s?N([w("play")," Turn o Line truncated
`))]):"",p=g.length+(o?.update?1:0)+(r?.update?1:0),C=[i?.version?`OpenWrt ${i.version} · ${i.target}`:"",t.check?p?`${p} update${p===1?"":"s"} ready`:"everything is current":"not checked yet",t.check?`checked ${St(t.check.time)}`:""].filter(Boolean).join(" · ");dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Updates"),e("span",{class:"dl-faint"},C)]),z([w("refresh")," Check now"],()=>this.run("check"),"neutral",d)]),_,B,k,c])}async runAwg(t,a,n){await ae(n?`Install AmneziaWG ${n}?`:"Install AmneziaWG?","Every AmneziaWG tunnel on the router restarts for a few seconds, HomeTunnel too. Devices stay configured.","Install")&&this.start(`amneziawg:${t}${a?":ru":""}`)}async runPkgs(t,a,n=t){await ae(`Update ${a}?`,`${n.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&this.start(`pkgs:${t.join(",")}`)}async run(t){t!=="check"&&!await ae(`Update ${t==="app"?"Dawnline":t}?`,"A backup is made first. The page reloads when it finishes.","Update")||this.start(t)}async start(t){if(await O(()=>P.updatesRun(t))){this.running=!0;let a=await P.updatesStatus().catch(()=>null);a&&this.paint(a)}}};function Ot(s){return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`}function Pa(s,t,a,n=30){let i=s?new Date(`${s}T12:00:00`):new Date;return t==="day"?i.setDate(i.getDate()+a):t==="week"?i.setDate(i.getDate()+7*a):t==="month"?i.setMonth(i.getMonth()+a):t==="year"?i.setFullYear(i.getFullYear()+a):i.setDate(i.getDate()+n*a),Ot(i)}var za={internet:"Browse the internet through your router. No access to devices at home.",lan:"Reach devices at home. Internet stays on their own connection.",both:"Home devices and the internet, all through your router."},wt=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.refreshSeq=0;this.refreshShown=0}async load(){this.id=new URLSearchParams(location.search).get("id")??"";let[t,a,n]=await Promise.all([P.status(30),P.events(5e3).catch(()=>({events:[]})),P.personUsage(this.id,30).catch(()=>null)]);return this.series=n?.person??[],this.devSeries=n?.devices??{},[t,a.events]}render([t,a]){this.st=t,this.events=a,xe(t);let n=t.people.find(l=>l.id===this.id);if(!n)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=n;for(let l of["head","devices","traffic","places","activity","limits"])this.parts[l]=e("div",{});this.parts.devices.className="dl-person-devices";let i=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:Qe(n.server)},t.servers.find(l=>l.id===n.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:Qe(n.server)},"People"),e("span",{},"/"),e("span",{},n.name)]),this.parts.head,e("div",{class:"dl-grid-person"},[e("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),e("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let o=new URLSearchParams(location.search),r=o.get("device")&&n.devices.find(l=>l.id===o.get("device"));return r?setTimeout(()=>De(this.p,r,()=>this.refresh(),this.st.geo),50):o.get("add")&&setTimeout(()=>Re(this.p,()=>this.refresh()),50),poll.add(()=>this.refresh(!0),15),i}async refresh(t=!1){let a=++this.refreshSeq,[n,i,o]=await Promise.all([P.status(30).catch(()=>null),P.events(5e3).catch(()=>null),P.personUsage(this.id,30).catch(()=>null)]);if(!n||a<this.refreshShown)return;this.refreshShown=a,this.st=n,i&&(this.events=i.events),o&&(this.series=o.person,this.devSeries=o.devices);let r=n.people.find(l=>l.id===this.id);if(!r){t||(location.href=Qe(this.p?.server));return}this.p=r,this.paint(),this.map?.update(this.mapData())}async patch(t,a){var o;let n=await O(()=>P.personUpdate(this.p.id,t),a);if(!n)return;let i=this.st.people.findIndex(r=>r.id===this.p.id);(o=n.person).rate??(o.rate=this.p.rate),i>=0&&(this.st.people[i]=n.person),this.p=n.person,this.paint()}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}mapCard(){let t=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),this.st.geo.enabled?ut("30d",a=>this.map?.setRange(a),!1):"",z("Hide",()=>{this.mapOpen=!1,this.map?.destroy(),this.map=null,this.paintPlaces()},"neutral")]);return this.st.geo.enabled?(this.map=new Ge({openPerson:()=>{},openDevice:(a,n)=>{let i=this.p.devices.find(o=>o.id===n);i&&De(this.p,i,()=>this.refresh(),this.st.geo)}},"30d",280),requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[t,this.map.el])):e("div",{class:"dl-panel flush"},[t,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])])}paint(){let t=this.p,a=this.st,n=t.online?"online now": Line truncated `))]):"",u=g.length+(s?.update?1:0)+(r?.update?1:0),C=[i?.version?`OpenWrt ${i.version} · ${i.target}`:"",t.check?u?`${u} update${u===1?"":"s"} ready`:"everything is current":"not checked yet",t.check?`checked ${St(t.check.time)}`:""].filter(Boolean).join(" · ");dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Updates"),e("span",{class:"dl-faint"},C)]),N([w("refresh")," Check now"],()=>this.run("check"),"neutral",d)]),k,H,_,c])}async runAwg(t,n,a){await ae(a?`Install AmneziaWG ${a}?`:"Install AmneziaWG?","Every AmneziaWG tunnel on the router restarts for a few seconds, HomeTunnel too. Devices stay configured.","Install")&&this.start(`amneziawg:${t}${n?":ru":""}`)}async runPkgs(t,n,a=t){await ae(`Update ${n}?`,`${a.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&this.start(`pkgs:${t.join(",")}`)}async run(t){t!=="check"&&!await ae(`Update ${t==="app"?"Dawnline":t}?`,"A backup is made first. The page reloads when it finishes.","Update")||this.start(t)}async start(t){if(await O(()=>P.updatesRun(t))){this.running=!0;let n=await P.updatesStatus().catch(()=>null);n&&this.paint(n)}}};function Ot(o){return`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-${String(o.getDate()).padStart(2,"0")}`}function Aa(o,t,n,a=30){let i=o?new Date(`${o}T12:00:00`):new Date;return t==="day"?i.setDate(i.getDate()+n):t==="week"?i.setDate(i.getDate()+7*n):t==="month"?i.setMonth(i.getMonth()+n):t==="year"?i.setFullYear(i.getFullYear()+n):i.setDate(i.getDate()+a*n),Ot(i)}var Pa={internet:"Browse the internet through your router. No access to devices at home.",lan:"Reach devices at home. Internet stays on their own connection.",both:"Home devices and the internet, all through your router."},wt=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.refreshSeq=0;this.refreshShown=0}async load(){this.id=new URLSearchParams(location.search).get("id")??"";let[t,n,a]=await Promise.all([P.status(30),P.events(5e3).catch(()=>({events:[]})),P.personUsage(this.id,30).catch(()=>null)]);return this.series=a?.person??[],this.devSeries=a?.devices??{},[t,n.events]}render([t,n]){this.st=t,this.events=n,we(t);let a=t.people.find(l=>l.id===this.id);if(!a)return e("div",{class:"dl-empty"},[e("h3",{},"Person not found"),e("p",{},"They may have been removed."),e("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=a;for(let l of["head","devices","traffic","places","activity","limits"])this.parts[l]=e("div",{});this.parts.devices.className="dl-person-devices";let i=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:Ze(a.server)},t.servers.find(l=>l.id===a.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:Ze(a.server)},"People"),e("span",{},"/"),e("span",{},a.name)]),this.parts.head,e("div",{class:"dl-grid-person"},[e("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),e("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let s=new URLSearchParams(location.search),r=s.get("device")&&a.devices.find(l=>l.id===s.get("device"));return r?setTimeout(()=>Ce(this.p,r,()=>this.refresh(),this.st.geo),50):s.get("add")&&setTimeout(()=>Re(this.p,()=>this.refresh()),50),poll.add(()=>this.refresh(!0),15),i}async refresh(t=!1){let n=++this.refreshSeq,[a,i,s]=await Promise.all([P.status(30).catch(()=>null),P.events(5e3).catch(()=>null),P.personUsage(this.id,30).catch(()=>null)]);if(!a||n<this.refreshShown)return;this.refreshShown=n,this.st=a,i&&(this.events=i.events),s&&(this.series=s.person,this.devSeries=s.devices);let r=a.people.find(l=>l.id===this.id);if(!r){t||(location.href=Ze(this.p?.server));return}this.p=r,this.paint(),this.map?.update(this.mapData())}async patch(t,n){var s;let a=await O(()=>P.personUpdate(this.p.id,t),n);if(!a)return;let i=this.st.people.findIndex(r=>r.id===this.p.id);(s=a.person).rate??(s.rate=this.p.rate),i>=0&&(this.st.people[i]=a.person),this.p=a.person,this.paint()}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}mapCard(){let t=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),this.st.geo.enabled?ut("30d",n=>this.map?.setRange(n),!1):"",N("Hide",()=>{this.mapOpen=!1,this.map?.destroy(),this.map=null,this.paintPlaces()},"neutral")]);return this.st.geo.enabled?(this.map=new Fe({openPerson:()=>{},openDevice:(n,a)=>{let i=this.p.devices.find(s=>s.id===a);i&&Ce(this.p,i,()=>this.refresh(),this.st.geo)}},"30d",280),requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[t,this.map.el])):e("div",{class:"dl-panel flush"},[t,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])])}paint(){let t=this.p,n=this.st,a=t.online?"online now": Line truncated
`)}d.push(N),u+=_-1}let m=z([w("more")],()=>ke(m,[{label:"Export CSV",icon:w("download"),run:()=>ve(this.st,l,"csv",t.id)},{label:"Export JSON",icon:w("download"),run:()=>ve(this.st,l,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:w("trash"),danger:!0,run:()=>Ce(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>this.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});dom.content(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},l.length>10?`latest 10 of ${l.length}`:""),e("span",{class:"dl-spacer"}),m]),d.length?d:e("div",{class:"dl-row dl-muted"},"Nothing yet.")]))}deviceStatus(t){return t.disabled?e("span",{class:"dl-dstat"},[e("i",{class:"dot"}),"Disabled"]):t.online?e("span",{class:"dl-dstat ok"},[e("i",{class:"dot ok"}),`Online · ${ce(t.handshake,this.st.now).replace(" ago","")}`]):t.handshake?e("span",{class:"dl-dstat"},[e("i",{class:"dot"}),`Last seen ${ce(t.handshake,this.st.now)}`]):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},[e("i",{class:"dot warn"}),"Not set up yet"])}addrs(t){if(!t.online||!t.endpoint)return"";let a=this.st.geo?.points.find(o=>o.device===t.id&&o.ip===t.endpoint),n=a?.city?`Client IP · ${a.city}${a.org?` · ${a.org}`:""}`:"Client IP",i=e("button",{type:"button",class:"dl-addr wan","aria-label":`Copy ${t.endpoint}`,click:()=>re(t.endpoint,"Client IP copied")},[w("globe"),e("span",{},t.endpoint)]);return le(i,()=>[e("div",{class:"dl-tip-title"},n),e("div",{class:"dl-muted"},"Click to copy")]),e("div",{class:"dl-addrs"},i)}deviceBars(t){let a=(this.devSeries[t]??[]).slice(-30),n=a.map(r=>r.rx+r.tx),i=Math.max(1,...n),o=r=>new Date(`${r}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"});return e("div",{class:"dl-dbars"},a.map((r,l)=>{let d=e("i",{class:`${n[l]?"":"zero"}${l===a.length-1?" hi":""}`});return d.style.height=`${Math.max(8,n[l]/i*100)}%`,le(d,()=>[e("div",{class:"dl-tip-title"},l===a.length-1?`Today · ${o(r.day)}`:o(r.day)),e("div",{},K(n[l]))]),d}))}paintDevices(){let t=this.p,a=()=>this.refresh(),n=t.devices.map(o=>{let r=()=>De(t,o,a,this.st.geo);return e("article",{class:`dl-dcard${o.online?" online":""}${o.disabled?" off":""}`},[e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},w(o.kind)),e("button",{type:"button",class:"dl-dcard-title",click:r},[e("b",{},o.name),this.deviceStatus(o),o.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),z([w("more")],r,"neutral",{title:`${o.name}: connect, rename, keys, remove`,class:"cbi-button cbi-button-neutral dl-icon-only"})]),o.handshake?e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},K(o.month[0]+o.month[1])),e("span",{class:"dl-sub"},"this month")]),this.deviceBars(o.id)]):o.disabled?e("div",{class:"dl-sub"},`${Me[o.kind]} · created ${ce(o.created,this.st.now)} ${o.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>this.showDeviceQr(o)},[w("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>this.downloadConfig(o)},[w("download"),"Config"])]),this.addrs(o)])}),i=Math.max(0,t.device_limit-t.devices.length);i&&n.push(e("button",{type:"button",class:"dl-dslot add",click:()=>Re(t,a)},[e("span",{class:"dl-dslot-ic"},w("plus")),e("b",{},"Add device")])),dom.content(this.parts.devices,e("section",{class:"dl-devsec"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Devices"),e("span",{class:"dl-sub"},`${t.online} online`),e("span",{class:"dl-spacer"}),i?"":z([w("plus")," Add device"],()=>Re(t,a),"neutral",{title:"Over the limit — admins can still add"})]),e("div",{class:"dl-dgrid"},n)]))}paintLimits(){let t=this.p,a=e("div",{class:"dl-seg wide",role:"radiogroup","aria-label":"Access"},["internet","lan","both"].map(c=>e("button",{type:"button",role:"radio",class:t.access===c?"on":"","aria-checked":t.access===c?"true":"false",click:()=>t.access!==c&&this.patch({access:c},`Access: ${Be[c]}`)},[w(c==="internet"?"globe":c==="lan"?"home":"shield"),c==="internet"?"Internet":c==="lan"?"Home":"Both"]))),n=ze(t.expires),i=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});i.addEventListener("change",()=>i.value&&this.patch({expires:i.value},`Access until ${_e(i.value)}`));let o=(c,p,C)=>{let v=Pa(t.expires&&(n??-1)>=0?t.expires:"",c,p);return this.patch({expires:v},`Access until ${_e(v)}`),C},r=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([c,p,C])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>o(c,p,C)},C)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{try{i.showPicker()}catch{i.focus()}}},[w("calendar"),t.expires?_e(t.expires):"Date"]),i]),d={pause:"pause access",notify:"keep acc Line truncated `)}d.push(z),p+=k-1}let m=N([w("more")],()=>ke(m,[{label:"Export CSV",icon:w("download"),run:()=>be(this.st,l,"csv",t.id)},{label:"Export JSON",icon:w("download"),run:()=>be(this.st,l,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:w("trash"),danger:!0,run:()=>Ee(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>this.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});dom.content(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},l.length>10?`latest 10 of ${l.length}`:""),e("span",{class:"dl-spacer"}),m]),d.length?d:e("div",{class:"dl-row dl-muted"},"Nothing yet.")]))}deviceStatus(t){return t.disabled?e("span",{class:"dl-dstat"},[e("i",{class:"dot"}),"Disabled"]):t.online?e("span",{class:"dl-dstat ok"},[e("i",{class:"dot ok"}),`Online · ${ce(t.handshake,this.st.now).replace(" ago","")}`]):t.handshake?e("span",{class:"dl-dstat"},[e("i",{class:"dot"}),`Last seen ${ce(t.handshake,this.st.now)}`]):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},[e("i",{class:"dot warn"}),"Not set up yet"])}addrs(t){if(!t.online||!t.endpoint)return"";let n=this.st.geo?.points.find(s=>s.device===t.id&&s.ip===t.endpoint),a=n?.city?`Client IP · ${n.city}${n.org?` · ${n.org}`:""}`:"Client IP",i=e("button",{type:"button",class:"dl-addr wan","aria-label":`Copy ${t.endpoint}`,click:()=>re(t.endpoint,"Client IP copied")},[w("globe"),e("span",{},t.endpoint)]);return le(i,()=>[e("div",{class:"dl-tip-title"},a),e("div",{class:"dl-muted"},"Click to copy")]),e("div",{class:"dl-addrs"},i)}deviceBars(t){let n=(this.devSeries[t]??[]).slice(-30),a=n.map(r=>r.rx+r.tx),i=Math.max(1,...a),s=r=>new Date(`${r}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"});return e("div",{class:"dl-dbars"},n.map((r,l)=>{let d=e("i",{class:`${a[l]?"":"zero"}${l===n.length-1?" hi":""}`});return d.style.height=`${Math.max(8,a[l]/i*100)}%`,le(d,()=>[e("div",{class:"dl-tip-title"},l===n.length-1?`Today · ${s(r.day)}`:s(r.day)),e("div",{},V(a[l]))]),d}))}paintDevices(){let t=this.p,n=()=>this.refresh(),a=t.devices.map(s=>{let r=()=>Ce(t,s,n,this.st.geo);return e("article",{class:`dl-dcard${s.online?" online":""}${s.disabled?" off":""}`},[e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},w(s.kind)),e("button",{type:"button",class:"dl-dcard-title",click:r},[e("b",{},s.name),this.deviceStatus(s),s.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),N([w("more")],r,"neutral",{title:`${s.name}: connect, rename, keys, remove`,class:"cbi-button cbi-button-neutral dl-icon-only"})]),s.handshake?e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},V(s.month[0]+s.month[1])),e("span",{class:"dl-sub"},"this month")]),this.deviceBars(s.id)]):s.disabled?e("div",{class:"dl-sub"},`${Me[s.kind]} · created ${ce(s.created,this.st.now)} ${s.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>this.showDeviceQr(s)},[w("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>this.downloadConfig(s)},[w("download"),"Config"])]),this.addrs(s)])}),i=Math.max(0,t.device_limit-t.devices.length);i&&a.push(e("button",{type:"button",class:"dl-dslot add",click:()=>Re(t,n)},[e("span",{class:"dl-dslot-ic"},w("plus")),e("b",{},"Add device")])),dom.content(this.parts.devices,e("section",{class:"dl-devsec"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Devices"),e("span",{class:"dl-sub"},`${t.online} online`),e("span",{class:"dl-spacer"}),i?"":N([w("plus")," Add device"],()=>Re(t,n),"neutral",{title:"Over the limit — admins can still add"})]),e("div",{class:"dl-dgrid"},a)]))}paintLimits(){let t=this.p,n=e("div",{class:"dl-seg wide",role:"radiogroup","aria-label":"Access"},["internet","lan","both"].map(c=>e("button",{type:"button",role:"radio",class:t.access===c?"on":"","aria-checked":t.access===c?"true":"false",click:()=>t.access!==c&&this.patch({access:c},`Access: ${je[c]}`)},[w(c==="internet"?"globe":c==="lan"?"home":"shield"),c==="internet"?"Internet":c==="lan"?"Home":"Both"]))),a=ze(t.expires),i=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});i.addEventListener("change",()=>i.value&&this.patch({expires:i.value},`Access until ${_e(i.value)}`));let s=(c,u,C)=>{let v=Aa(t.expires&&(a??-1)>=0?t.expires:"",c,u);return this.patch({expires:v},`Access until ${_e(v)}`),C},r=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([c,u,C])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>s(c,u,C)},C)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{try{i.showPicker()}catch{i.focus()}}},[w("calendar"),t.expires?_e(t.expires):"Date"]),i]),d={pause:"pause access",notify:"keep acc Line truncated
@@ -231,6 +231,16 @@ function free_ifname(m) {
return 'dawnx'; return 'dawnx';
} }
/** A free server id: home, then server2, server3, … (never a person, device or service id). */
function free_server_id(m) {
let taken = (id) => m.servers[id] || m.people[id] || m.devices[id] || m.services[id] || index([ 'settings', 'api', 'assets', 'cgi-bin' ], id) >= 0;
if (!taken('home'))
return 'home';
for (let n = 2; ; n++)
if (!taken(`server${n}`))
return `server${n}`;
}
function setup_defaults(a) { function setup_defaults(a) {
let m = core.load(); let m = core.load();
let taken = ops.used_subnets(null); let taken = ops.used_subnets(null);
@@ -258,7 +268,7 @@ function setup_defaults(a) {
host = live.iface_status('wan')?.['ipv4-address']?.[0]?.address ?? ''; host = live.iface_status('wan')?.['ipv4-address']?.[0]?.address ?? '';
} }
return { return {
id: length(m.servers) ? `server${length(m.servers) + 1}` : 'home', id: free_server_id(m),
name: length(m.servers) ? `Server ${length(m.servers) + 1}` : 'Home', name: length(m.servers) ? `Server ${length(m.servers) + 1}` : 'Home',
ifname: free_ifname(m), ifname: free_ifname(m),
port: free_port(m), port: free_port(m),
@@ -472,6 +472,19 @@ export function allowed_ips(m, srv, p) {
}; };
/** Everything a client needs; `conf` is the .conf text. */ /** Everything a client needs; `conf` is the .conf text. */
/** True when the obfuscation settings change nothing on the wire (plain WireGuard). */
export function obf_neutral(o) {
for (let k in OBF_KEYS) {
let v = o?.[k];
if (v == null || v == '')
continue;
let want = { h1: '1', h2: '2', h3: '3', h4: '4' }[k] ?? '0';
if (`${v}` != want)
return false;
}
return true;
};
export function client_config(m, dev) { export function client_config(m, dev) {
let p = m.people[dev.person]; let p = m.people[dev.person];
let srv = p ? m.servers[p.server] : null; let srv = p ? m.servers[p.server] : null;
@@ -487,9 +500,12 @@ export function client_config(m, dev) {
if (length(dns)) if (length(dns))
push(lines, `DNS = ${join(', ', dns)}`); push(lines, `DNS = ${join(', ', dns)}`);
push(lines, `MTU = ${srv.mtu}`); push(lines, `MTU = ${srv.mtu}`);
for (let k in OBF_KEYS) // "Off" is plain WireGuard: neutral values (no junk, H1-H4 = 1-4) are left
if (srv.obf[k] != null && srv.obf[k] != '') // out, so any WireGuard app accepts the file.
push(lines, `${OBF_CONF[k]} = ${srv.obf[k]}`); if (!obf_neutral(srv.obf))
for (let k in OBF_KEYS)
if (srv.obf[k] != null && srv.obf[k] != '')
push(lines, `${OBF_CONF[k]} = ${srv.obf[k]}`);
push(lines, '', '[Peer]'); push(lines, '', '[Peer]');
push(lines, `PublicKey = ${srv.public_key}`); push(lines, `PublicKey = ${srv.public_key}`);
if (dev.preshared_key) if (dev.preshared_key)
@@ -916,7 +932,8 @@ export function portal_public_port(m) {
/** The link on one address: https for names, plain http for IP addresses. */ /** The link on one address: https for names, plain http for IP addresses. */
export function portal_link(m, p, host) { export function portal_link(m, p, host) {
if (!host || !m.servers[p.server] || !match(p.code ?? '', WORD_CODE)) // No portal, no link: the page would not answer.
if (!m.settings.portal_enabled || !host || !m.servers[p.server] || !match(p.code ?? '', WORD_CODE))
return null; return null;
if (ip2int(host) != null) { if (ip2int(host) != null) {
let hp = portal_http_public(m); let hp = portal_http_public(m);
@@ -377,6 +377,8 @@ export function health(m) {
stv = 'warn'; stv = 'warn';
det = `WAN address ${wan} is private: forward UDP ${srv.port} on the upstream router, or clients cannot connect.`; det = `WAN address ${wan} is private: forward UDP ${srv.port} on the upstream router, or clients cannot connect.`;
} }
else if (length(filter(ips, (a) => cloudflare_ip(a))))
det = `${host} → ${join(', ', ips)} (Cloudflare). The tunnel is UDP: it reaches the router only if this name is DNS-only there.`;
else if (wan && index(ips, wan) < 0) { else if (wan && index(ips, wan) < 0) {
stv = 'warn'; stv = 'warn';
det = `${host} resolves to ${join(', ', ips)}, but the WAN address is ${wan}. Check your DNS / DDNS.`; det = `${host} resolves to ${join(', ', ips)}, but the WAN address is ${wan}. Check your DNS / DDNS.`;
@@ -425,7 +427,7 @@ export function health(m) {
else { else {
let ips = resolve(s.portal_host), wan = router_wan(m); let ips = resolve(s.portal_host), wan = router_wan(m);
let cf = filter(ips, (x) => cloudflare_ip(x)); let cf = filter(ips, (x) => cloudflare_ip(x));
push(out, check('portal_dns', 'Portal address points here', !length(ips) ? 'error' : length(cf) ? 'warn' : wan && index(ips, wan) < 0 ? 'warn' : 'ok', push(out, check('portal_dns', 'Portal address points here', !length(ips) ? 'error' : length(cf) ? 'ok' : wan && index(ips, wan) < 0 ? 'warn' : 'ok',
!length(ips) ? `${s.portal_host} does not resolve.` : !length(ips) ? `${s.portal_host} does not resolve.` :
length(cf) ? `${s.portal_host} goes through Cloudflare; in Russia such connections often stall after ~16 KB.` : length(cf) ? `${s.portal_host} goes through Cloudflare; in Russia such connections often stall after ~16 KB.` :
wan && index(ips, wan) < 0 ? `${s.portal_host} points at ${join(', ', ips)}, not this router (${wan}).` : wan && index(ips, wan) < 0 ? `${s.portal_host} points at ${join(', ', ips)}, not this router (${wan}).` :
@@ -3,7 +3,7 @@
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
export const VERSION = '0.1.0'; export const VERSION = '0.1.1';
/** GitHub repository with Dawnline releases (updates and the installer). */ /** GitHub repository with Dawnline releases (updates and the installer). */
export const REPO = 'tickcount/luci-app-dawnline'; export const REPO = 'tickcount/luci-app-dawnline';
export const RUN_DIR = '/var/run/dawnline'; export const RUN_DIR = '/var/run/dawnline';
+12
View File
@@ -32,5 +32,17 @@ for f in files:
line = code[: m.start()].count('\n') + 1 line = code[: m.start()].count('\n') + 1
print(f"{f}:{line}: {name}() is used before its definition") print(f"{f}:{line}: {name}() is used before its definition")
bad = 1 bad = 1
# In a module an exported function is an expression statement: its closing
# brace needs a semicolon ("Expecting ';'" breaks the whole module).
lines = open(f, encoding='utf-8').read().split('\n')
inside = None
for n, text in enumerate(lines, 1):
if inside is None and re.match(r'^export function \w+\(', text):
inside = n
elif inside is not None and re.match(r'^}', text):
if not text.startswith('};'):
print(f"{f}:{n}: exported function from line {inside} must end with '}};'")
bad = 1
inside = None
print(f"lint-ucode: {checked} files checked" + (", problems found" if bad else ", ok")) print(f"lint-ucode: {checked} files checked" + (", problems found" if bad else ", ok"))
sys.exit(bad) sys.exit(bad)
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "dawnline-web", "name": "dawnline-web",
"version": "0.1.0", "version": "0.1.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "dawnline-web", "name": "dawnline-web",
"version": "0.1.0", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"qrcode-generator": "1.4.4" "qrcode-generator": "1.4.4"
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "dawnline-web", "name": "dawnline-web",
"version": "0.1.0", "version": "0.1.1",
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
+1 -5
View File
@@ -115,11 +115,7 @@ export function methodPicker(caps: AwgCaps, selected: Method, onSelect: (m: Meth
E('div', { class: 'dl-method-head' }, [ E('div', { class: 'dl-method-head' }, [
E('span', { class: 'dl-method-ic' }, icon(m.ic)), E('span', { class: 'dl-method-ic' }, icon(m.ic)),
E('b', {}, m.title), E('b', {}, m.title),
m.id === current m.id === current ? E('span', { class: 'dl-pill ok' }, 'Current') : '',
? E('span', { class: 'dl-pill ok' }, 'Current')
: m.id === 'standard' && !current
? E('span', { class: 'dl-pill' }, 'Recommended')
: '',
]), ]),
E('p', {}, m.text), E('p', {}, m.text),
E('div', { class: 'dl-method-meters' }, [dots(m.stealth, 'Stealth'), dots(m.speed, 'Speed')]), E('div', { class: 'dl-method-meters' }, [dots(m.stealth, 'Stealth'), dots(m.speed, 'Speed')]),
+80 -70
View File
@@ -10,7 +10,7 @@ import { attempt, button, callout, closeModal, confirmDialog, copyText, modal, n
import { icon } from '../../shared/icons'; import { icon } from '../../shared/icons';
import { duration } from '../../shared/format'; import { duration } from '../../shared/format';
import { interfacesCard } from '../interfaces'; import { interfacesCard } from '../interfaces';
import { card, group, input, row } from '../kit'; import { card, group, input, row, sw } from '../kit';
import { methodInfo, methodPicker, type Method } from '../disguise'; import { methodInfo, methodPicker, type Method } from '../disguise';
import { ServerOverview } from './overview'; import { ServerOverview } from './overview';
import { PeoplePage } from './people'; import { PeoplePage } from './people';
@@ -27,29 +27,6 @@ const SECTIONS: [Section, string][] = [
]; ];
/** Section names from before the regrouping, for old links. */ /** Section names from before the regrouping, for old links. */
const OLD_SECTIONS: Record<string, Section> = { general: 'connection', network: 'connection', interfaces: 'access', advanced: 'tunnel' }; const OLD_SECTIONS: Record<string, Section> = { general: 'connection', network: 'connection', interfaces: 'access', advanced: 'tunnel' };
function choices<T extends string>(items: { v: T; title: string; text: string; ic?: string }[], initial: T, onChange: (v: T) => void) {
const el = E(
'div',
{ class: 'dl-choices' },
items.map((o) =>
E(
'button',
{
type: 'button',
class: `dl-choice${o.v === initial ? ' selected' : ''}`,
'data-v': o.v,
click: () => {
el.querySelectorAll('.dl-choice').forEach((c) => c.classList.toggle('selected', (c as HTMLElement).dataset.v === o.v));
onChange(o.v);
},
},
[E('span', { class: 'dl-choice-title' }, [o.ic ? icon(o.ic) : '', o.title]), E('span', { class: 'dl-choice-text' }, o.text)],
),
),
);
return el;
}
/** `.conf` names of the disguise parameters, in file order. */ /** `.conf` names of the disguise parameters, in file order. */
const CONF: [string, string][] = [ const CONF: [string, string][] = [
['jc', 'Jc'], ['jc', 'Jc'],
@@ -303,6 +280,16 @@ export class ServerPage {
window.scrollTo({ top: 0, behavior: 'smooth' }); window.scrollTo({ top: 0, behavior: 'smooth' });
} }
/**
* Overview and People stay alive between tab switches. Take them out before
* dom.content() runs: it forgets LuCI's registry of every node it removes,
* and a form put back afterwards fails on its next render ("setting '_class'").
*/
detachKept() {
const kept = [...Object.values(this.ov).map((o) => o.el), ...Object.values(this.pp).map((p) => p.el)];
for (const el of kept) if (el && this.bodyEl.contains(el)) el.remove();
}
/** Swap only the section body; the rest of the page stays as it is. */ /** Swap only the section body; the rest of the page stays as it is. */
showSection(k: Section) { showSection(k: Section) {
this.section = k; this.section = k;
@@ -339,7 +326,9 @@ export class ServerPage {
disguise: () => this.disguise(srv), disguise: () => this.disguise(srv),
tunnel: () => this.tunnel(srv), tunnel: () => this.tunnel(srv),
}; };
dom.content(this.bodyEl, body[k]()); const node = body[k]();
this.detachKept();
dom.content(this.bodyEl, node);
} }
/** Name and state, the address bar, and the page actions. */ /** Name and state, the address bar, and the page actions. */
@@ -579,7 +568,6 @@ export class ServerPage {
}), }),
]), ]),
), ),
row('Link path', E('span', { class: 'dl-mono' }, `/${srv.id}/`), 'Changing it would break every personal link already sent.'),
], ],
[], [],
), ),
@@ -678,8 +666,10 @@ export class ServerPage {
port: d.port, port: d.port,
subnet: d.subnet, subnet: d.subnet,
preset: 'standard' as Method, preset: 'standard' as Method,
portal: true, // Off by default: the portal opens a port on WAN, so it is a choice.
portal: false,
portal_port: d.portal_port || 8443, portal_port: d.portal_port || 8443,
lan_like: true,
lan_zone: d.lan_zone, lan_zone: d.lan_zone,
wan_zone: d.wan_zone, wan_zone: d.wan_zone,
}; };
@@ -696,33 +686,32 @@ export class ServerPage {
const steps = extra ? ['Connection', 'Disguise'] : ['Connection', 'Disguise', 'Portal']; const steps = extra ? ['Connection', 'Disguise'] : ['Connection', 'Disguise', 'Portal'];
const pages: (() => Node)[] = [ const pages: (() => Node)[] = [
() => () =>
E('div', {}, [ E('div', { class: 'dl-wizard-groups' }, [
E( E(
'p', 'p',
{}, { class: 'dl-muted' },
'Where devices connect to. Use a hostname that always points at your router (DDNS), so links keep working when your IP changes.', 'Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes.',
),
row('Name', field('name'), 'Shown to people in their portal.'),
row(
'Link path',
field('id', { maxlength: 24, class: 'cbi-input-text dl-mono' }),
'First part of personal links: https://address:port/<path>/<person>.',
),
row(
'Public address',
field('endpoint', { placeholder: 'vpn.example.com', class: 'cbi-input-text dl-mono' }),
'Hostname or IP address of your router on the internet.',
),
row(
'UDP port',
field('port', { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }),
'Opened on the WAN firewall automatically. A random high port is fine.',
),
row(
'Tunnel subnet',
field('subnet', { class: 'cbi-input-text dl-mono' }),
`Addresses for devices. Must not overlap your networks (${d.taken.join(', ') || 'none found'}).`,
), ),
group('router', 'Server', 'What people see', [row('Name', field('name'), 'Shown to people in their portal.')]),
group('globe', 'Devices connect to', 'Where the tunnel answers from the internet', [
row(
'Public address',
field('endpoint', { placeholder: 'vpn.example.com', class: 'cbi-input-text dl-mono' }),
'Hostname or IP address of your router on the internet.',
),
row(
'UDP port',
field('port', { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }),
'Opened on the WAN firewall automatically. A random high port is fine.',
),
]),
group('network', 'Tunnel network', 'Addresses devices get inside the tunnel', [
row(
'Tunnel subnet',
field('subnet', { class: 'cbi-input-text dl-mono' }),
`Must not overlap your networks (${d.taken.join(', ') || 'none found'}).`,
),
]),
]), ]),
() => () =>
E('div', {}, [ E('div', {}, [
@@ -735,25 +724,46 @@ export class ServerPage {
]), ]),
() => { () => {
const portalPort = field('portal_port', { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }); const portalPort = field('portal_port', { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' });
return E('div', {}, [ const portRow = row('Listening port', portalPort, 'TCP port on WAN for the portal; the whole port belongs to it.');
callout( portRow.hidden = !state.portal;
'info', // Off | On, Off first: the same segmented control as in Settings.
'Devices reach the internet the way devices on your home network do: whatever handles home traffic on this router handles theirs too. You can change this later under Servers → Access.', const onOff = E(
'div',
{ class: 'dl-seg', role: 'radiogroup', 'aria-label': 'Personal portal' },
(['off', 'on'] as const).map((v) =>
E(
'button',
{
type: 'button',
role: 'radio',
class: (v === 'on') === state.portal ? 'on' : '',
'aria-checked': (v === 'on') === state.portal ? 'true' : 'false',
click: (ev: Event) => {
state.portal = v === 'on';
portRow.hidden = !state.portal;
onOff.querySelectorAll('button').forEach((x) => {
const sel = x === ev.currentTarget;
x.classList.toggle('on', sel);
x.setAttribute('aria-checked', sel ? 'true' : 'false');
});
},
},
v === 'on' ? 'On' : 'Off',
),
), ),
E('h4', {}, 'Personal portal'), );
E('p', {}, 'A small page where each person adds their own devices, with their personal link. It gets its own HTTPS port on WAN.'), return E('div', { class: 'dl-wizard-groups' }, [
choices( group('home', 'Internet like a home device', 'How devices reach the internet', [
[ row(
{ v: 'on', title: 'On', ic: 'link', text: 'People manage their devices themselves within the limits you set.' }, 'Through the home network',
{ v: 'off', title: 'Off', ic: 'x', text: 'Only you add devices, from LuCI.' }, sw(state.lan_like, 'Internet like a home device', (v) => (state.lan_like = v)),
], 'Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.',
'on', ),
(v) => { ]),
state.portal = v === 'on'; group('link', 'Personal portal', 'A page where each person adds their own devices with their personal link', [
portalPort.disabled = !state.portal; row('Portal', onOff, 'Off: only you add devices, from LuCI. On: people manage their devices within the limits you set.'),
}, portRow,
), ]),
row('Portal port', portalPort, 'TCP port on WAN. The whole port belongs to the portal.'),
]); ]);
}, },
]; ];
@@ -812,7 +822,7 @@ export class ServerPage {
state.preset, state.preset,
state.lan_zone, state.lan_zone,
state.wan_zone, state.wan_zone,
true, state.lan_like,
extra ? undefined : state.portal, extra ? undefined : state.portal,
extra ? undefined : state.portal_port, extra ? undefined : state.portal_port,
), ),
+1 -1
View File
@@ -77,7 +77,7 @@ function build(st: Status, q: string, done: () => void): Item[] {
items.push({ items.push({
group: 'People', group: 'People',
label: p.name, label: p.name,
hint: `${ACCESS_SHORT[p.access]} · ${p.online ? `${p.online} online` : `${p.devices.length} devices`}`, hint: `${ACCESS_SHORT[p.access]} · ${p.online ? `${p.online} online` : `${p.devices.length} device${p.devices.length === 1 ? '' : 's'}`}`,
avatar: initials(p.name), avatar: initials(p.name),
run: () => (location.href = personUrl(p.id)), run: () => (location.href = personUrl(p.id)),
}); });
+25 -16
View File
@@ -9,11 +9,13 @@
const CSS = ` const CSS = `
:root { :root {
--dl-card: var(--panel-bg, transparent); /* Outline's tokens first, then LuCI Bootstrap's, then something that works anywhere. */
--dl-line: var(--border, color-mix(in srgb, currentColor 14%, transparent)); --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: var(--muted, color-mix(in srgb, currentColor 5%, transparent));
--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent)); --dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));
--dl-fg: var(--foreground, inherit); --dl-fg: var(--foreground, var(--text-color-highest, inherit));
--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent)); --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-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));
--dl-accent: var(--accent, #3a83f7); --dl-accent: var(--accent, #3a83f7);
@@ -110,7 +112,8 @@ const CSS = `
.dl-map .cbi-section-table-row > .td.cbi-section-actions > div { display: flex; flex-wrap: nowrap; gap: 6px; justify-content: flex-end; } .dl-map .cbi-section-table-row > .td.cbi-section-actions > div { display: flex; flex-wrap: nowrap; gap: 6px; justify-content: flex-end; }
.dl-map .cbi-section-table-row > .td.cbi-section-actions > div > * { margin: 0 !important; flex: 0 0 auto; } .dl-map .cbi-section-table-row > .td.cbi-section-actions > div > * { margin: 0 !important; flex: 0 0 auto; }
.dl-map .cbi-section-table-row > .td::before { display: none !important; } .dl-map .cbi-section-table-row > .td::before { display: none !important; }
.dl-map .cbi-section-table-row.placeholder { color: var(--dl-fg-muted); justify-content: center; } .dl-map .cbi-section-table-row.placeholder { color: var(--dl-fg-muted); display: flex !important; justify-content: center; align-items: center; min-height: 0 !important; height: auto !important; padding: 28px 16px !important; text-align: center; }
.dl-map .cbi-section-table-row.placeholder > * { position: static !important; padding: 0 !important; margin: 0 !important; border: 0 !important; flex: 0 1 auto !important; }
.dl-map .cbi-section-table-row.dl-off .dl-card-name, .dl-map .cbi-section-table-row.dl-off .dl-avatar { opacity: .6; } .dl-map .cbi-section-table-row.dl-off .dl-card-name, .dl-map .cbi-section-table-row.dl-off .dl-avatar { opacity: .6; }
.dl-card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; } .dl-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; .dl-avatar { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
@@ -160,7 +163,7 @@ const CSS = `
/* choice cards */ /* choice cards */
/* LuCI's modal above the device drawer (900); menus above both. */ /* LuCI's modal above the device drawer (900); menus above both. */
#modal_overlay { z-index: 1100 !important; } #modal_overlay { z-index: 1100 !important; }
.dl-dd { position: fixed; z-index: 1200; min-width: 200px; padding: 4px; border-radius: 12px; background: var(--elevated, var(--dl-card)); border: 1px solid var(--dl-line); .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; } 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 { 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 .dl-icon { width: 15px; height: 15px; color: var(--dl-fg-muted); }
@@ -281,7 +284,8 @@ const CSS = `
.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.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 { cursor: not-allowed; opacity: .55; }
.dl-method.off:hover { background: var(--dl-card); } .dl-method.off:hover { background: var(--dl-card); }
.dl-method-head { display: flex; align-items: center; gap: 10px; } .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-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 { 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-ic .dl-icon { width: 17px; height: 17px; }
@@ -454,7 +458,7 @@ const CSS = `
.dl-searchbtn { display: inline-flex !important; align-items: center; gap: 6px; } .dl-searchbtn { display: inline-flex !important; align-items: center; gap: 6px; }
.dl-searchbtn kbd { font-size: 11px; padding: 1px 5px; border-radius: 5px; background: var(--dl-soft); color: var(--dl-fg-muted); font-family: inherit; } .dl-searchbtn kbd { font-size: 11px; padding: 1px 5px; border-radius: 5px; background: var(--dl-soft); color: var(--dl-fg-muted); font-family: inherit; }
.dl-toolbar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: nowrap; min-width: 0; } .dl-toolbar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: nowrap; min-width: 0; }
.dl-toolbar-end .dl-search { flex: 0 1 260px; min-width: 160px; } .dl-toolbar-end .dl-search { flex: 0 1 300px; min-width: 160px; }
@media (max-width: 640px) { .dl-toolbar-end { flex-wrap: wrap; width: 100%; } .dl-toolbar-end .dl-search { flex: 1 1 100%; } } @media (max-width: 640px) { .dl-toolbar-end { flex-wrap: wrap; width: 100%; } .dl-toolbar-end .dl-search { flex: 1 1 100%; } }
.dl-healthstrip { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 9px 14px; margin: 0 0 12px; border-radius: 12px; .dl-healthstrip { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 9px 14px; margin: 0 0 12px; border-radius: 12px;
border: 1px solid color-mix(in srgb, var(--dl-warn) 45%, transparent); background: var(--dl-warn-wash); font-size: 13px; color: var(--dl-fg-muted); } border: 1px solid color-mix(in srgb, var(--dl-warn) 45%, transparent); background: var(--dl-warn-wash); font-size: 13px; color: var(--dl-fg-muted); }
@@ -682,6 +686,10 @@ const CSS = `
font-size: 13px; font-weight: 500; color: var(--dl-fg-muted); white-space: nowrap; } 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:hover { color: var(--dl-fg); }
.dl-seg button.on { background: var(--dl-soft-hover); color: var(--dl-fg); } .dl-seg button.on { background: var(--dl-soft-hover); color: var(--dl-fg); }
/* Server sections: one row that scrolls sideways on narrow screens */
.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: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 { 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 button b.warn { background: var(--dl-warn-wash); color: var(--dl-warn); }
@@ -711,9 +719,9 @@ const CSS = `
box-shadow: 0 0 0 4px rgba(237, 237, 237, .18), 0 2px 6px rgba(0,0,0,.5); color: #131313; } box-shadow: 0 0 0 4px rgba(237, 237, 237, .18), 0 2px 6px rgba(0,0,0,.5); color: #131313; }
.dl-mk-home-ic { width: 13px; height: 13px; } .dl-mk-home-ic { width: 13px; height: 13px; }
.dl-popup { z-index: 4; } .dl-popup { z-index: 4; }
.dl-popup .maplibregl-popup-content { background: var(--elevated, #131313); color: var(--dl-fg); border: 1px solid var(--dl-line); border-radius: 12px; padding: 12px; .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; } 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(--elevated, #131313) !important; border-bottom-color: var(--elevated, #131313) !important; } .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 { display: flex; flex-direction: column; gap: 4px; font-size: 12px; line-height: 18px; min-width: 210px; }
.dl-pop-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 2px; } .dl-pop-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 2px; }
.dl-mk.multi { width: 26px; height: 26px; } .dl-mk.multi { width: 26px; height: 26px; }
@@ -744,7 +752,7 @@ const CSS = `
.dl-bar:hover i { filter: brightness(1.25); } .dl-bar:hover i { filter: brightness(1.25); }
.dl-bar.empty { background: linear-gradient(to top, var(--dl-line) 2px, transparent 2px); } .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; .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(--elevated, #131313); 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; } 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-title { font-weight: 500; }
.dl-tip-float { position: fixed; z-index: 2000; color: var(--dl-fg); } .dl-tip-float { position: fixed; z-index: 2000; color: var(--dl-fg); }
.dl-spark i:hover { opacity: 1; filter: brightness(1.25); } .dl-spark i:hover { opacity: 1; filter: brightness(1.25); }
@@ -851,7 +859,7 @@ const CSS = `
.dl-pside-state.live { color: var(--dl-ok); } .dl-pside-state.live { color: var(--dl-ok); }
.dl-pside-foot { font-size: 12px; } .dl-pside-foot { font-size: 12px; }
.dl-pside .dl-use-num b { font-size: 20px; } .dl-pside .dl-use-num b { font-size: 20px; }
.dl-map .cbi-section-table-row > .td:has(.dl-pcard) { flex: 1 1 100%; max-width: none !important; width: 100% !important; } .dl-map .cbi-section-table-row > .td:has(.dl-pcard) { flex: 1 1 100%; max-width: none !important; width: 100% !important; margin: 0 !important; }
.dl-none { display: none !important; } .dl-none { display: none !important; }
.dl-pcard-actions { display: flex; gap: 6px; flex: 0 0 auto; } .dl-pcard-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.dl-pcard-actions .cbi-button { height: 32px !important; } .dl-pcard-actions .cbi-button { height: 32px !important; }
@@ -891,11 +899,12 @@ const CSS = `
@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; } } @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-search { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 12px; border: 1px solid var(--input, var(--dl-line)); border-radius: 999px; .dl-search { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 12px; border: 1px solid var(--input, var(--dl-line)); border-radius: 999px;
background: var(--input-bg, transparent); width: 280px; max-width: 100%; color: var(--dl-fg-faint); box-sizing: border-box; min-width: 0; } background: var(--input-bg, transparent); width: 280px; max-width: 100%; color: var(--dl-fg-faint); box-sizing: border-box; min-width: 0; }
.dl-search-input { border: 0 !important; background: transparent !important; box-shadow: none !important; outline: none; flex: 1; min-width: 0; color: var(--dl-fg); .dl-search-input { text-overflow: ellipsis; border: 0 !important; background: transparent !important; box-shadow: none !important; outline: none; flex: 1; min-width: 0; color: var(--dl-fg);
font: inherit; font-size: 13px; padding: 0 !important; height: 32px !important; } font: inherit; font-size: 13px; padding: 0 !important; height: 32px !important; }
.dl-select { height: 34px !important; border-radius: 999px !important; min-width: 0 !important; padding: 0 30px 0 12px !important; } .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; .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(--elevated, #131313); border: 1px solid var(--dl-line); 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; } 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%, 0); opacity: 1; pointer-events: auto; } .dl-savebar.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.dl-savebar-text { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; } .dl-savebar-text { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
@@ -908,7 +917,7 @@ const CSS = `
/* device drawer */ /* device drawer */
.dl-drawer-overlay { position: fixed; inset: 0; z-index: 900; display: flex; justify-content: flex-end; background: transparent; transition: background .2s; } .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-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(--elevated, #111)); color: var(--dl-fg); .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: translateX(100%); border-left: 1px solid var(--dl-line); box-shadow: var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5)); transform: translateX(100%);
transition: transform .22s cubic-bezier(.2,.8,.2,1); } transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.dl-drawer-overlay.open .dl-drawer { transform: none; } .dl-drawer-overlay.open .dl-drawer { transform: none; }
@@ -958,7 +967,7 @@ const CSS = `
/* command menu */ /* command menu */
.dl-pal-overlay { position: fixed; inset: 0; z-index: 1000; background: var(--scrim, rgba(0,0,0,.5)); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 0; } .dl-pal-overlay { position: fixed; inset: 0; z-index: 1000; background: var(--scrim, rgba(0,0,0,.5)); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 0; }
.dl-pal { width: min(640px, 100%); background: var(--elevated, #131313); color: var(--dl-fg); border-radius: 16px; overflow: hidden; .dl-pal { width: min(640px, 100%); background: var(--dl-elevated); color: var(--dl-fg); border-radius: 16px; overflow: hidden;
box-shadow: var(--shadow-menu, 0 16px 32px -8px rgba(0,0,0,.6)); border: 1px solid var(--dl-line); } box-shadow: var(--shadow-menu, 0 16px 32px -8px rgba(0,0,0,.6)); border: 1px solid var(--dl-line); }
.dl-pal-search { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--dl-line); color: var(--dl-fg-faint); } .dl-pal-search { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--dl-line); color: var(--dl-fg-faint); }
.dl-pal-input { flex: 1; border: 0 !important; background: transparent !important; box-shadow: none !important; outline: none; font: inherit; font-size: 16px; color: var(--dl-fg); padding: 0 !important; } .dl-pal-input { flex: 1; border: 0 !important; background: transparent !important; box-shadow: none !important; outline: none; font: inherit; font-size: 16px; color: var(--dl-fg); padding: 0 !important; }