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

- The map places everyone within their city: the IP gives the city
  alone, so each person gets a fixed spot of their own in it (1.5-5 km
  from its centre, clear of the server and of each other)
- People who would cover each other share one plate with their avatars
  and the city once, and people on top of the server ride in the
  server's plate (no more pointers, repeated labels or counts); zooming
  in they part to their own spots
- Avatars in a plate keep their device badges (round for one device);
  a click on an avatar opens that person's card, flying to them first
  when they are elsewhere, and a click on a plate brings its people into
  view, at city level when they share one, close enough to part
- Plates follow the zoom: compact far out (small avatars, no badges or
  place names), small badges at country level, full size closer in
- Plates slide, grow and shrink smoothly: avatars glide to their places,
  "+N" changes in place, and the plate's width follows
- Fixed: a hovered person could stay highlighted (everyone else faded)
  after their plate split under the pointer
- Overview's Online tile: small avatars light up with a halo round their
  ring, and the device badge no longer cuts a dark square into the hover
This commit is contained in:
Aemeath committed 2026-10-17 03:55:24 +03:00
1 parent 972e522518
commit 5768856d76
9 files changed
+539 -66

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.5.0 PKG_VERSION:=0.5.1
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=MIT PKG_LICENSE:=MIT
@@ -5,25 +5,25 @@
'require poll'; 'require poll';
'require rpc'; 'require rpc';
'require ui'; 'require ui';
var ir=Object.create;var eo=Object.defineProperty;var sr=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var dr=Object.getPrototypeOf,cr=Object.prototype.hasOwnProperty;var pr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var ur=(n,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of lr(e))!cr.call(n,r)&&r!==o&&eo(n,r,{get:()=>e[r],enumerable:!(a=sr(e,r))||a.enumerable});return n};var mr=(n,e,o)=>(o=n!=null?ir(dr(n)):{},ur(e||!n||!n.__esModule?eo(o,"default",{value:n,enumerable:!0}):o,n));var mo=pr((po,uo)=>{"use strict";var co=(function(){var n=function(E,T){var w=236,v=17,x=E,$=o[T],m=null,h=0,N=null,C=[],R={},Z=function(_,A){h=x*4+17,m=(function(y){for(var H=new Array(y),S=0;S<y;S+=1){H[S]=new Array(y);for(var O=0;O<y;O+=1)H[S][O]=null}return H})(h),G(0,0),G(h-7,0),G(0,h-7),F(),z(),de(_,A),x>=7&&X(_),N==null&&(N=U(x,$,C)),fe(N,A)},G=function(_,A){for(var y=-1;y<=7;y+=1)if(!(_+y<=-1||h<=_+y))for(var H=-1;H<=7;H+=1)A+H<=-1||h<=A+H||(0<=y&&y<=6&&(H==0||H==6)||0<=H&&H<=6&&(y==0||y==6)||2<=y&&y<=4&&2<=H&&H<=4?m[_+y][A+H]=!0:m[_+y][A+H]=!1)},V=function(){for(var _=0,A=0,y=0;y<8;y+=1){Z(!0,y);var H=r.getLostPoint(R);(y==0||_>H)&&(_=H,A=y)}return A},z=function(){for(var _=8;_<h-8;_+=1)m[_][6]==null&&(m[_][6]=_%2==0);for(var A=8;A<h-8;A+=1)m[6][A]==null&&(m[6][A]=A%2==0)},F=function(){for(var _=r.getPatternPosition(x),A=0;A<_.length;A+=1)for(var y=0;y<_.length;y+=1){var H=_[A],S=_[y];if(m[H][S]==null)for(var O=-2;O<=2;O+=1)for(var Y=-2;Y<=2;Y+=1)O==-2||O==2||Y==-2||Y==2||O==0&&Y==0?m[H+O][S+Y]=!0:m[H+O][S+Y]=!1}},X=function(_){for(var A=r.getBCHTypeNumber(x),y=0;y<18;y+=1){var H=!_&&(A>>y&1)==1;m[Math.floor(y/3)][y%3+h-8-3]=H}for(var y=0;y<18;y+=1){var H=!_&&(A>>y&1)==1;m[y%3+h-8-3][Math.floor(y/3)]=H}},de=function(_,A){for(var y=$<<3|A,H=r.getBCHTypeInfo(y),S=0;S<15;S+=1){var O=!_&&(H>>S&1)==1;S<6?m[S][8]=O:S<8?m[S+1][8]=O:m[h-15+S][8]=O}for(var S=0;S<15;S+=1){var O=!_&&(H>>S&1)==1;S<8?m[8][h-S-1]=O:S<9?m[8][15-S-1+1]=O:m[8][15-S-1]=O}m[h-8][8]=!_},fe=function(_,A){for(var y=-1,H=h-1,S=7,O=0,Y=r.getMaskFunction(A),J=h-1;J>0;J-=2)for(J==6&&(J-=1);;){for(var pe=0;pe<2;pe+=1)if(m[H][J-pe]==null){var be=!1;O<_.length&&(be=(_[O]>>>S&1)==1);var ee=Y(H,J-pe);ee&&(be=!be),m[H][J-pe]=be,S-=1,S==-1&&(O+=1,S=7)}if(H+=y,H<0||h<=H){H-=y,y=-y;break}}},B=function(_,A){for(var y=0,H=0,S=0,O=new Array(A.length),Y=new Array(A.length),J=0;J<A.length;J+=1){var pe=A[J].dataCount,be=A[J].totalCount-pe;H=Math.max(H,pe),S=Math.max(S,be),O[J]=new Array(pe);for(var ee=0;ee<O[J].length;ee+=1)O[J][ee]=255&_.getBuffer()[ee+y];y+=pe;var Se=r.getErrorCorrectPolynomial(be),Me=s(O[J],Se.getLength()-1),Zn=Me.mod(Se);Y[J]=new Array(Se.getLength()-1);for(var ee=0;ee<Y[J].length;ee+=1){var Qn=ee+Zn.getLength()-Y[J].length;Y[J][ee]=Qn>=0?Zn.getAt(Qn):0}}for(var Xn=0,ee=0;ee<A.length;ee+=1)Xn+=A[ee].totalCount;for(var kn=new Array(Xn),Ot=0,ee=0;ee<H;ee+=1)for(var J=0;J<A.length;J+=1)ee<O[J].length&&(kn[Ot]=O[J][ee],Ot+=1);for(var ee=0;ee<S;ee+=1)for(var J=0;J<A.length;J+=1)ee<Y[J].length&&(kn[Ot]=Y[J][ee],Ot+=1);return kn},U=function(_,A,y){for(var H=d.getRSBlocks(_,A),S=l(),O=0;O<y.length;O+=1){var Y=y[O];S.put(Y.getMode(),4),S.put(Y.getLength(),r.getLengthInBits(Y.getMode(),_)),Y.write(S)}for(var J=0,O=0;O<H.length;O+=1)J+=H[O].dataCount;if(S.getLengthInBits()>J*8)throw"code length overflow. ("+S.getLengthInBits()+">"+J*8+")";for(S.getLengthInBits()+4<=J*8&&S.put(0,4);S.getLengthInBits()%8!=0;)S.putBit(!1);for(;!(S.getLengthInBits()>=J*8||(S.put(w,8),S.getLengthInBits()>=J*8));)S.put(v,8);return B(S,H)};R.addData=function(_,A){A=A||"Byte";var y=null;switch(A){case"Numeric":y=c(_);break;case"Alphanumeric":y=p(_);break;case"Byte":y=u(_);break;case"Kanji":y=k(_);break;default:throw"mode:"+A}C.push(y),N=null},R.isDark=function(_,A){if(_<0||h<=_||A<0||h<=A)throw _+","+A;return m[_][A]},R.getModuleCount=function(){return h},R.make=function(){if(x<1){for(var _=1;_<40;_++){for(var A=d.getRSBlocks(_,$),y=l(),H=0;H<C.length;H++){var S=C[H];y.put(S.getMode(),4),y.put(S.getLength(),r.getLengthInBits(S.getMode(),_)),S.write(y)}for(var O=0,H=0;H<A.length;H++)O+=A[H].dataCount;if(y.getLengthInBits()<=O*8)break}x=_}Z(!1,V())},R.createTableTag=function(_,A){_=_||2,A=typeof A>"u"?_*4:A;var y="";y+='<table style="',y+=" border-width: 0px; border-style: none;",y+=" border-collapse: collapse;",y+=" padding: 0px; margin: "+A+"px;",y+='">',y+="<tbody>";for(var H=0;H<R.getModuleCount();H+=1){y+="<tr>";for(var S=0;S<R.getModuleCount();S+=1)y+='<td style="',y+=" border-width: 0px; border-style: none;",y+=" border-collapse: collapse;",y+=" padding: 0px; margin: 0px;",y+=" width: "+_+"px;",y+=" height: "+_+"px;",y+=" background-color: ",y+=R.isDark(H,S)?"#000000":"#ffffff",y+=";",y+='"/>';y+="</tr>"}return y+="</tbody>",y+="</table>",y},R.createSvgTag=function(_,A,y,H){var S={};typeof arguments[0]=="object"&&(S=arguments[0],_=S.cellSize,A=S.margin,y=S.alt,H=S.title),_=_||2,A=typeof A>"u"?_*4:A,y=typeof y=="string"?{text:y}:y||{},y.Line truncated var cr=Object.create;var to=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var fr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var gr=(n,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ur(e))!hr.call(n,r)&&r!==o&&to(n,r,{get:()=>e[r],enumerable:!(a=pr(e,r))||a.enumerable});return n};var vr=(n,e,o)=>(o=n!=null?cr(mr(n)):{},gr(e||!n||!n.__esModule?to(o,"default",{value:n,enumerable:!0}):o,n));var ho=fr((uo,mo)=>{"use strict";var po=(function(){var n=function(E,y){var S=236,b=17,x=E,M=o[y],h=null,f=0,R=null,C=[],I={},Z=function(_,A){f=x*4+17,h=(function($){for(var N=new Array($),T=0;T<$;T+=1){N[T]=new Array($);for(var j=0;j<$;j+=1)N[T][j]=null}return N})(f),G(0,0),G(f-7,0),G(0,f-7),q(),z(),de(_,A),x>=7&&X(_),R==null&&(R=U(x,M,C)),fe(R,A)},G=function(_,A){for(var $=-1;$<=7;$+=1)if(!(_+$<=-1||f<=_+$))for(var N=-1;N<=7;N+=1)A+N<=-1||f<=A+N||(0<=$&&$<=6&&(N==0||N==6)||0<=N&&N<=6&&($==0||$==6)||2<=$&&$<=4&&2<=N&&N<=4?h[_+$][A+N]=!0:h[_+$][A+N]=!1)},V=function(){for(var _=0,A=0,$=0;$<8;$+=1){Z(!0,$);var N=r.getLostPoint(I);($==0||_>N)&&(_=N,A=$)}return A},z=function(){for(var _=8;_<f-8;_+=1)h[_][6]==null&&(h[_][6]=_%2==0);for(var A=8;A<f-8;A+=1)h[6][A]==null&&(h[6][A]=A%2==0)},q=function(){for(var _=r.getPatternPosition(x),A=0;A<_.length;A+=1)for(var $=0;$<_.length;$+=1){var N=_[A],T=_[$];if(h[N][T]==null)for(var j=-2;j<=2;j+=1)for(var Y=-2;Y<=2;Y+=1)j==-2||j==2||Y==-2||Y==2||j==0&&Y==0?h[N+j][T+Y]=!0:h[N+j][T+Y]=!1}},X=function(_){for(var A=r.getBCHTypeNumber(x),$=0;$<18;$+=1){var N=!_&&(A>>$&1)==1;h[Math.floor($/3)][$%3+f-8-3]=N}for(var $=0;$<18;$+=1){var N=!_&&(A>>$&1)==1;h[$%3+f-8-3][Math.floor($/3)]=N}},de=function(_,A){for(var $=M<<3|A,N=r.getBCHTypeInfo($),T=0;T<15;T+=1){var j=!_&&(N>>T&1)==1;T<6?h[T][8]=j:T<8?h[T+1][8]=j:h[f-15+T][8]=j}for(var T=0;T<15;T+=1){var j=!_&&(N>>T&1)==1;T<8?h[8][f-T-1]=j:T<9?h[8][15-T-1+1]=j:h[8][15-T-1]=j}h[f-8][8]=!_},fe=function(_,A){for(var $=-1,N=f-1,T=7,j=0,Y=r.getMaskFunction(A),J=f-1;J>0;J-=2)for(J==6&&(J-=1);;){for(var pe=0;pe<2;pe+=1)if(h[N][J-pe]==null){var be=!1;j<_.length&&(be=(_[j]>>>T&1)==1);var ee=Y(N,J-pe);ee&&(be=!be),h[N][J-pe]=be,T-=1,T==-1&&(j+=1,T=7)}if(N+=$,N<0||f<=N){N-=$,$=-$;break}}},O=function(_,A){for(var $=0,N=0,T=0,j=new Array(A.length),Y=new Array(A.length),J=0;J<A.length;J+=1){var pe=A[J].dataCount,be=A[J].totalCount-pe;N=Math.max(N,pe),T=Math.max(T,be),j[J]=new Array(pe);for(var ee=0;ee<j[J].length;ee+=1)j[J][ee]=255&_.getBuffer()[ee+$];$+=pe;var Se=r.getErrorCorrectPolynomial(be),_e=s(j[J],Se.getLength()-1),Qn=_e.mod(Se);Y[J]=new Array(Se.getLength()-1);for(var ee=0;ee<Y[J].length;ee+=1){var Xn=ee+Qn.getLength()-Y[J].length;Y[J][ee]=Xn>=0?Qn.getAt(Xn):0}}for(var eo=0,ee=0;ee<A.length;ee+=1)eo+=A[ee].totalCount;for(var $n=new Array(eo),Ot=0,ee=0;ee<N;ee+=1)for(var J=0;J<A.length;J+=1)ee<j[J].length&&($n[Ot]=j[J][ee],Ot+=1);for(var ee=0;ee<T;ee+=1)for(var J=0;J<A.length;J+=1)ee<Y[J].length&&($n[Ot]=Y[J][ee],Ot+=1);return $n},U=function(_,A,$){for(var N=l.getRSBlocks(_,A),T=c(),j=0;j<$.length;j+=1){var Y=$[j];T.put(Y.getMode(),4),T.put(Y.getLength(),r.getLengthInBits(Y.getMode(),_)),Y.write(T)}for(var J=0,j=0;j<N.length;j+=1)J+=N[j].dataCount;if(T.getLengthInBits()>J*8)throw"code length overflow. ("+T.getLengthInBits()+">"+J*8+")";for(T.getLengthInBits()+4<=J*8&&T.put(0,4);T.getLengthInBits()%8!=0;)T.putBit(!1);for(;!(T.getLengthInBits()>=J*8||(T.put(S,8),T.getLengthInBits()>=J*8));)T.put(b,8);return O(T,N)};I.addData=function(_,A){A=A||"Byte";var $=null;switch(A){case"Numeric":$=d(_);break;case"Alphanumeric":$=p(_);break;case"Byte":$=u(_);break;case"Kanji":$=w(_);break;default:throw"mode:"+A}C.push($),R=null},I.isDark=function(_,A){if(_<0||f<=_||A<0||f<=A)throw _+","+A;return h[_][A]},I.getModuleCount=function(){return f},I.make=function(){if(x<1){for(var _=1;_<40;_++){for(var A=l.getRSBlocks(_,M),$=c(),N=0;N<C.length;N++){var T=C[N];$.put(T.getMode(),4),$.put(T.getLength(),r.getLengthInBits(T.getMode(),_)),T.write($)}for(var j=0,N=0;N<A.length;N++)j+=A[N].dataCount;if($.getLengthInBits()<=j*8)break}x=_}Z(!1,V())},I.createTableTag=function(_,A){_=_||2,A=typeof A>"u"?_*4:A;var $="";$+='<table style="',$+=" border-width: 0px; border-style: none;",$+=" border-collapse: collapse;",$+=" padding: 0px; margin: "+A+"px;",$+='">',$+="<tbody>";for(var N=0;N<I.getModuleCount();N+=1){$+="<tr>";for(var T=0;T<I.getModuleCount();T+=1)$+='<td style="',$+=" border-width: 0px; border-style: none;",$+=" border-collapse: collapse;",$+=" padding: 0px; margin: 0px;",$+=" width: "+_+"px;",$+=" height: "+_+"px;",$+=" background-color: ",$+=I.isDark(N,T)?"#000000":"#ffffff",$+=";",$+='"/>';$+="</tr>"}return $+="</tbody>",$+="</table>",$},I.createSvgTag=function(_,A,$,N){var T={};typeof arguments[0]=="object"&&(T=arguments[0],_=T.cellSize,A=T.margin,$=T.alt,N=T.title),_=_||2,A=typeof A>"u"?_*4:A,$=typeof $=="string"?{text:$}:$||{},$.Line truncated
`}return y%2&&_>0?Me.substring(0,Me.length-y-1)+Array(y+1).join("▀"):Me.substring(0,Me.length-1)};return R.createASCII=function(_,A){if(_=_||1,_<2)return oe(A);_-=1,A=typeof A>"u"?_*2:A;var y=R.getModuleCount()*_+A*2,H=A,S=y-A,O,Y,J,pe,be=Array(_+1).join("██"),ee=Array(_+1).join(" "),Se="",Me="";for(O=0;O<y;O+=1){for(J=Math.floor((O-H)/_),Me="",Y=0;Y<y;Y+=1)pe=1,H<=Y&&Y<S&&H<=O&&O<S&&R.isDark(J,Math.floor((Y-H)/_))&&(pe=0),Me+=pe?be:ee;for(J=0;J<_;J+=1)Se+=Me+` `}return $%2&&_>0?_e.substring(0,_e.length-$-1)+Array($+1).join("▀"):_e.substring(0,_e.length-1)};return I.createASCII=function(_,A){if(_=_||1,_<2)return oe(A);_-=1,A=typeof A>"u"?_*2:A;var $=I.getModuleCount()*_+A*2,N=A,T=$-A,j,Y,J,pe,be=Array(_+1).join("██"),ee=Array(_+1).join(" "),Se="",_e="";for(j=0;j<$;j+=1){for(J=Math.floor((j-N)/_),_e="",Y=0;Y<$;Y+=1)pe=1,N<=Y&&Y<T&&N<=j&&j<T&&I.isDark(J,Math.floor((Y-N)/_))&&(pe=0),_e+=pe?be:ee;for(J=0;J<_;J+=1)Se+=_e+`
`}return Se.substring(0,Se.length-1)},R.renderTo2dContext=function(_,A){A=A||2;for(var y=R.getModuleCount(),H=0;H<y;H++)for(var S=0;S<y;S++)_.fillStyle=R.isDark(H,S)?"black":"white",_.fillRect(H*A,S*A,A,A)},R};n.stringToBytesFuncs={default:function(E){for(var T=[],w=0;w<E.length;w+=1){var v=E.charCodeAt(w);T.push(v&255)}return T}},n.stringToBytes=n.stringToBytesFuncs.default,n.createStringToBytes=function(E,T){var w=(function(){for(var x=M(E),$=function(){var z=x.read();if(z==-1)throw"eof";return z},m=0,h={};;){var N=x.read();if(N==-1)break;var C=$(),R=$(),Z=$(),G=String.fromCharCode(N<<8|C),V=R<<8|Z;h[G]=V,m+=1}if(m!=T)throw m+" != "+T;return h})(),v=63;return function(x){for(var $=[],m=0;m<x.length;m+=1){var h=x.charCodeAt(m);if(h<128)$.push(h);else{var N=w[x.charAt(m)];typeof N=="number"?(N&255)==N?$.push(N):($.push(N>>>8),$.push(N&255)):$.push(v)}}return $}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var E=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],T=1335,w=7973,v=21522,x={},$=function(m){for(var h=0;m!=0;)h+=1,m>>>=1;return h};return x.getBCHTypeInfo=function(m){for(var h=m<<10;$(h)-$(T)>=0;)h^=T<<$(h)-$(T);return(m<<10|h)^v},x.getBCHTypeNumber=function(m){for(var h=m<<12;$(h)-$(w)>=0;)h^=w<<$(h)-$(w);return m<<12|h},x.getPatternPosition=function(m){return E[m-1]},x.getMaskFunction=function(m){switch(m){case a.PATTERN000:return function(h,N){return(h+N)%2==0};case a.PATTERN001:return function(h,N){return h%2==0};case a.PATTERN010:return function(h,N){return N%3==0};case a.PATTERN011:return function(h,N){return(h+N)%3==0};case a.PATTERN100:return function(h,N){return(Math.floor(h/2)+Math.floor(N/3))%2==0};case a.PATTERN101:return function(h,N){return h*N%2+h*N%3==0};case a.PATTERN110:return function(h,N){return(h*N%2+h*N%3)%2==0};case a.PATTERN111:return function(h,N){return(h*N%3+(h+N)%2)%2==0};default:throw"bad maskPattern:"+m}},x.getErrorCorrectPolynomial=function(m){for(var h=s([1],0),N=0;N<m;N+=1)h=h.multiply(s([1,i.gexp(N)],0));return h},x.getLengthInBits=function(m,h){if(1<=h&&h<10)switch(m){case e.MODE_NUMBER:return 10;case e.MODE_ALPHA_NUM:return 9;case e.MODE_8BIT_BYTE:return 8;case e.MODE_KANJI:return 8;default:throw"mode:"+m}else if(h<27)switch(m){case e.MODE_NUMBER:return 12;case e.MODE_ALPHA_NUM:return 11;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 10;default:throw"mode:"+m}else if(h<41)switch(m){case e.MODE_NUMBER:return 14;case e.MODE_ALPHA_NUM:return 13;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 12;default:throw"mode:"+m}else throw"type:"+h},x.getLostPoint=function(m){for(var h=m.getModuleCount(),N=0,C=0;C<h;C+=1)for(var R=0;R<h;R+=1){for(var Z=0,G=m.isDark(C,R),V=-1;V<=1;V+=1)if(!(C+V<0||h<=C+V))for(var z=-1;z<=1;z+=1)R+z<0||h<=R+z||V==0&&z==0||G==m.isDark(C+V,R+z)&&(Z+=1);Z>5&&(N+=3+Z-5)}for(var C=0;C<h-1;C+=1)for(var R=0;R<h-1;R+=1){var F=0;m.isDark(C,R)&&(F+=1),m.isDark(C+1,R)&&(F+=1),m.isDark(C,R+1)&&(F+=1),m.isDark(C+1,R+1)&&(F+=1),(F==0||F==4)&&(N+=3)}for(var C=0;C<h;C+=1)for(var R=0;R<h-6;R+=1)m.isDark(C,R)&&!m.isDark(C,R+1)&&m.isDark(C,R+2)&&m.isDark(C,R+3)&&m.isDark(C,R+4)&&!m.isDark(C,R+5)&&m.isDark(C,R+6)&&(N+=40);for(var R=0;R<h;R+=1)for(var C=0;C<h-6;C+=1)m.isDark(C,R)&&!m.isDark(C+1,R)&&m.isDark(C+2,R)&&m.isDark(C+3,R)&&m.isDark(C+4,R)&&!m.isDark(C+5,R)&&m.isDark(C+6,R)&&(N+=40);for(var X=0,R=0;R<h;R+=1)for(var C=0;C<h;C+=1)m.isDark(C,R)&&(X+=1);var de=Math.abs(100*X/h/h-50)/5;return N+=de*10,N},x})(),i=(function(){for(var E=new Array(256),T=new Array(256),w=0;w<8;w+=1)E[w]=1<<w;for(var w=8;w<256;w+=1)E[w]=E[w-4]^E[w-5]^E[w-6]^E[w-8];for(var w=0;w<255;w+=1)T[E[w]]=w;var v={};return v.glog=function(x){if(x<1)throw"glog("+x+")";return T[x]},v.gexp=function(x){for(;x<0;)x+=255;for(;x>=256;)x-=255;return E[x]},v})();function s(E,T){if(typeof E.length>"u")throw E.length+"/"+T;var w=(function(){for(var x=0;x<E.length&&E[x]==0;)x+=1;for(var $=new Array(E.length-x+T),m=0;m<E.length-x;m+=1)$[m]=E[m+x];return $})(),v={};return v.getAt=function(x){return w[x]},v.getLength=function(){return w.length},v.multiply=function(x){for(var $=new Array(v.getLength()+x.getLength()-1),m=0;m<v.getLength();m+=1)for(var h=0;h<x.getLength();h+=1)$[m+h]^=i.gexp(i.glog(v.getAt(m))+i.glog(x.getAt(h)));return s($,0)},v.mod=function(x){if(v.getLength() Line truncated `}return Se.substring(0,Se.length-1)},I.renderTo2dContext=function(_,A){A=A||2;for(var $=I.getModuleCount(),N=0;N<$;N++)for(var T=0;T<$;T++)_.fillStyle=I.isDark(N,T)?"black":"white",_.fillRect(N*A,T*A,A,A)},I};n.stringToBytesFuncs={default:function(E){for(var y=[],S=0;S<E.length;S+=1){var b=E.charCodeAt(S);y.push(b&255)}return y}},n.stringToBytes=n.stringToBytesFuncs.default,n.createStringToBytes=function(E,y){var S=(function(){for(var x=k(E),M=function(){var z=x.read();if(z==-1)throw"eof";return z},h=0,f={};;){var R=x.read();if(R==-1)break;var C=M(),I=M(),Z=M(),G=String.fromCharCode(R<<8|C),V=I<<8|Z;f[G]=V,h+=1}if(h!=y)throw h+" != "+y;return f})(),b=63;return function(x){for(var M=[],h=0;h<x.length;h+=1){var f=x.charCodeAt(h);if(f<128)M.push(f);else{var R=S[x.charAt(h)];typeof R=="number"?(R&255)==R?M.push(R):(M.push(R>>>8),M.push(R&255)):M.push(b)}}return M}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var E=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],y=1335,S=7973,b=21522,x={},M=function(h){for(var f=0;h!=0;)f+=1,h>>>=1;return f};return x.getBCHTypeInfo=function(h){for(var f=h<<10;M(f)-M(y)>=0;)f^=y<<M(f)-M(y);return(h<<10|f)^b},x.getBCHTypeNumber=function(h){for(var f=h<<12;M(f)-M(S)>=0;)f^=S<<M(f)-M(S);return h<<12|f},x.getPatternPosition=function(h){return E[h-1]},x.getMaskFunction=function(h){switch(h){case a.PATTERN000:return function(f,R){return(f+R)%2==0};case a.PATTERN001:return function(f,R){return f%2==0};case a.PATTERN010:return function(f,R){return R%3==0};case a.PATTERN011:return function(f,R){return(f+R)%3==0};case a.PATTERN100:return function(f,R){return(Math.floor(f/2)+Math.floor(R/3))%2==0};case a.PATTERN101:return function(f,R){return f*R%2+f*R%3==0};case a.PATTERN110:return function(f,R){return(f*R%2+f*R%3)%2==0};case a.PATTERN111:return function(f,R){return(f*R%3+(f+R)%2)%2==0};default:throw"bad maskPattern:"+h}},x.getErrorCorrectPolynomial=function(h){for(var f=s([1],0),R=0;R<h;R+=1)f=f.multiply(s([1,i.gexp(R)],0));return f},x.getLengthInBits=function(h,f){if(1<=f&&f<10)switch(h){case e.MODE_NUMBER:return 10;case e.MODE_ALPHA_NUM:return 9;case e.MODE_8BIT_BYTE:return 8;case e.MODE_KANJI:return 8;default:throw"mode:"+h}else if(f<27)switch(h){case e.MODE_NUMBER:return 12;case e.MODE_ALPHA_NUM:return 11;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 10;default:throw"mode:"+h}else if(f<41)switch(h){case e.MODE_NUMBER:return 14;case e.MODE_ALPHA_NUM:return 13;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 12;default:throw"mode:"+h}else throw"type:"+f},x.getLostPoint=function(h){for(var f=h.getModuleCount(),R=0,C=0;C<f;C+=1)for(var I=0;I<f;I+=1){for(var Z=0,G=h.isDark(C,I),V=-1;V<=1;V+=1)if(!(C+V<0||f<=C+V))for(var z=-1;z<=1;z+=1)I+z<0||f<=I+z||V==0&&z==0||G==h.isDark(C+V,I+z)&&(Z+=1);Z>5&&(R+=3+Z-5)}for(var C=0;C<f-1;C+=1)for(var I=0;I<f-1;I+=1){var q=0;h.isDark(C,I)&&(q+=1),h.isDark(C+1,I)&&(q+=1),h.isDark(C,I+1)&&(q+=1),h.isDark(C+1,I+1)&&(q+=1),(q==0||q==4)&&(R+=3)}for(var C=0;C<f;C+=1)for(var I=0;I<f-6;I+=1)h.isDark(C,I)&&!h.isDark(C,I+1)&&h.isDark(C,I+2)&&h.isDark(C,I+3)&&h.isDark(C,I+4)&&!h.isDark(C,I+5)&&h.isDark(C,I+6)&&(R+=40);for(var I=0;I<f;I+=1)for(var C=0;C<f-6;C+=1)h.isDark(C,I)&&!h.isDark(C+1,I)&&h.isDark(C+2,I)&&h.isDark(C+3,I)&&h.isDark(C+4,I)&&!h.isDark(C+5,I)&&h.isDark(C+6,I)&&(R+=40);for(var X=0,I=0;I<f;I+=1)for(var C=0;C<f;C+=1)h.isDark(C,I)&&(X+=1);var de=Math.abs(100*X/f/f-50)/5;return R+=de*10,R},x})(),i=(function(){for(var E=new Array(256),y=new Array(256),S=0;S<8;S+=1)E[S]=1<<S;for(var S=8;S<256;S+=1)E[S]=E[S-4]^E[S-5]^E[S-6]^E[S-8];for(var S=0;S<255;S+=1)y[E[S]]=S;var b={};return b.glog=function(x){if(x<1)throw"glog("+x+")";return y[x]},b.gexp=function(x){for(;x<0;)x+=255;for(;x>=256;)x-=255;return E[x]},b})();function s(E,y){if(typeof E.length>"u")throw E.length+"/"+y;var S=(function(){for(var x=0;x<E.length&&E[x]==0;)x+=1;for(var M=new Array(E.length-x+y),h=0;h<E.length-x;h+=1)M[h]=E[h+x];return M})(),b={};return b.getAt=function(x){return S[x]},b.getLength=function(){return S.length},b.multiply=function(x){for(var M=new Array(b.getLength()+x.getLength()-1),h=0;h<b.getLength();h+=1)for(var f=0;f<x.getLength();f+=1)M[h+f]^=i.gexp(i.glog(b.getAt(h))+i.glog(x.getAt(f)));return s(M,0)},b.mod=function(x){if(b.getLength() Line truncated
`)}function Lr(n){let e=new Map(n.people.map(a=>[a.id,a.name])),o=new Map(n.people.flatMap(a=>a.devices.map(r=>[r.id,r.name])));return{people:e,devices:o}}function Ue(n,e,o,a="",r=[]){let i=Lr(n),s=[...e.map(p=>({ts:p.ts,category:Mt(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:Te(p)??""})),...r.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?` `)}function Tr(n){let e=new Map(n.people.map(a=>[a.id,a.name])),o=new Map(n.people.flatMap(a=>a.devices.map(r=>[r.id,r.name])));return{people:e,devices:o}}function Ue(n,e,o,a="",r=[]){let i=Tr(n),s=[...e.map(p=>({ts:p.ts,category:_t(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:Pe(p)??""})),...r.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?`
${p.detail}`:""}`,where:Ct[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),d=new Date().toISOString().slice(0,10),l=`dawnline-activity${a?`-${a}`:""}-${d}.${o}`;if(o==="json"){Ee(l,JSON.stringify(s,null,2),"application/json");return}Ee(l,bo(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var _r=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],xo=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function Fe(n,e,o,a,r,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...ft.map(l=>t("option",{value:l,selected:l===r?"selected":null},at[l])),i?t("option",{value:"system",selected:r==="system"?"selected":null},"System"):""]),d=t("select",{class:"cbi-input-select"},_r.map(([l,c])=>t("option",{value:l},c)));re(n,[t("p",{class:"dl-muted"},`${e} This cannot be undone; export first if you want a copy.`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Category"),s]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Which events"),d])],[le()," ",D("Clear",async()=>{let l=0;if(s.value!=="system")try{l+=(await P.logsClear({...o,category:s.value,older_days:d.value})).removed}catch(c){Q(ve(c),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{l+=(await P.serviceLogClear(d.value)).removed}catch(c){ce(),Q(`${s.value==="system"?"":`Activity: ${xo(l).toLowerCase()}. `}The service log was not cleared: ${ve(c)}`,"error",1e4),a();return}ce(),Q(xo(l),"success",3e3),a()},"negative")])}function gt(n,e,o,a){let r=n==="device"?`Clears ${o}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${o}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";re(n==="all"?"Reset all traffic history?":`Reset traffic history for ${o}?`,[t("p",{class:"dl-muted"},r)],[le()," ",D("Reset",async()=>{await W(()=>P.usageClear(n,e),"Traffic history reset")&&(ce(),a())},"negative")])}function ge(n,e,o){let a=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let r=!a.classList.contains("on");Mn(a,r),o?.(r)}},t("i"));return a}function Mn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var _e=n=>n.classList.contains("on");function xe(n,e,o={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let a=t("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":e}),r=()=>a.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===a.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)a.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==a.dataset.value&&(o.optimistic!==!1&&(a.dataset.value=i,r()),o.onChange?.(i))}},s));return r(),a}function We(n,e,o,a={}){return t("button",{type:"button",...a,class:`dl-chipbtn${e?" on":""}${a.class?` ${a.class}`:""}`,"aria-pressed":e?"true":"false",click:o},n)}function Kt(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function se(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var Sr={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Mr={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function Cr(n){let e={};for(let[o,a]of Object.entries(Mr))n[o]!=null&&n[o]!==""&&(e[a]=String(n[o]));return e}function Tr(n,e){let o=n.amnezia,a=o.obfuscation??{},r=l=>a[l]!=null&&a[l]!==""?String(a[l]):Sr[l],i=o.host.replace(/^\[(.*)\]$/,"$1"),s={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),...Cr(a),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r ${p.detail}`:""}`,where:Tt[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),l=new Date().toISOString().slice(0,10),c=`dawnline-activity${a?`-${a}`:""}-${l}.${o}`;if(o==="json"){Ee(c,JSON.stringify(s,null,2),"application/json");return}Ee(c,xo(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var Cr=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],wo=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function qe(n,e,o,a,r,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...ft.map(c=>t("option",{value:c,selected:c===r?"selected":null},at[c])),i?t("option",{value:"system",selected:r==="system"?"selected":null},"System"):""]),l=t("select",{class:"cbi-input-select"},Cr.map(([c,d])=>t("option",{value:c},d)));re(n,[t("p",{class:"dl-muted"},`${e} This cannot be undone; export first if you want a copy.`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Category"),s]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Which events"),l])],[le()," ",D("Clear",async()=>{let c=0;if(s.value!=="system")try{c+=(await P.logsClear({...o,category:s.value,older_days:l.value})).removed}catch(d){Q(ve(d),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{c+=(await P.serviceLogClear(l.value)).removed}catch(d){ce(),Q(`${s.value==="system"?"":`Activity: ${wo(c).toLowerCase()}. `}The service log was not cleared: ${ve(d)}`,"error",1e4),a();return}ce(),Q(wo(c),"success",3e3),a()},"negative")])}function gt(n,e,o,a){let r=n==="device"?`Clears ${o}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${o}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";re(n==="all"?"Reset all traffic history?":`Reset traffic history for ${o}?`,[t("p",{class:"dl-muted"},r)],[le()," ",D("Reset",async()=>{await W(()=>P.usageClear(n,e),"Traffic history reset")&&(ce(),a())},"negative")])}function ge(n,e,o){let a=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let r=!a.classList.contains("on");Tn(a,r),o?.(r)}},t("i"));return a}function Tn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var Me=n=>n.classList.contains("on");function xe(n,e,o={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let a=t("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":e}),r=()=>a.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===a.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)a.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==a.dataset.value&&(o.optimistic!==!1&&(a.dataset.value=i,r()),o.onChange?.(i))}},s));return r(),a}function We(n,e,o,a={}){return t("button",{type:"button",...a,class:`dl-chipbtn${e?" on":""}${a.class?` ${a.class}`:""}`,"aria-pressed":e?"true":"false",click:o},n)}function Kt(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function se(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var Pr={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Dr={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function Ar(n){let e={};for(let[o,a]of Object.entries(Dr))n[o]!=null&&n[o]!==""&&(e[a]=String(n[o]));return e}function zr(n,e){let o=n.amnezia,a=o.obfuscation??{},r=c=>a[c]!=null&&a[c]!==""?String(a[c]):Pr[c],i=o.host.replace(/^\[(.*)\]$/,"$1"),s={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),...Ar(a),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r
`),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},d={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(o.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return o.dns[0]&&(d.dns1=o.dns[0]),o.dns[1]&&(d.dns2=o.dns[1]),d}function Pr(n){let e="";for(let o=0;o<n.length;o+=32768)e+=String.fromCharCode(...n.subarray(o,o+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Dr(n){let e=globalThis;if(typeof e.CompressionStream>"u")return null;try{let o=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),a=new Uint8Array(await new e.Response(o).arrayBuffer()),r=new Uint8Array(4+a.length);return new DataView(r.buffer).setUint32(0,n.length,!1),r.set(a,4),r}catch{return null}}async function Cn(n,e,o=!0){let a=new TextEncoder().encode(JSON.stringify(Tr(n,e))),r=o?await Dr(a):null;return`vpn://${Pr(r??a)}`}var yo=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"standard",title:"Standard",ic:"shield",stealth:2,speed:4,text:"Junk packets and random headers. Gets through most VPN blocking with no speed cost.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"strong",title:"Strong",ic:"shieldplus",stealth:3,speed:3,text:"More and larger junk packets for networks that block VPNs aggressively. Connects a little slower.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],Tt=n=>yo.find(e=>e.id===n),Ar={v2:"Needs AmneziaWG 1.5 or newer on the router.",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},zr={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function wo(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>t("i",{class:o<n?"on":""})))])}function Jt(n,e,o,a,r=!0){let i=t("div",{class:"dl-methods",role:"radiogroup","aria-label":"Disguise method"}),s=()=>dom.content(i,yo.map(d=>{let l=!d.needs||n[d.needs],c=d.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":l?null:"true",class:`dl-method${c?" on":""}${l?"":" off"}`,click:()=>{!l||c||(e=d.id,s(),o(d.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},g(d.ic)),t("b",{},d.title),d.id===a?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},d.text),t("div",{class:"dl-method-meters"},[wo(d.stealth,"Stealth"),wo(d.speed,"Speed")]),t("div",{class:"dl-method-foot"},l?[g("phone"),t("span",{},d.apps)]:[g("alert"),t("span",{},(r?Ar:zr)[d.needs])])])}));return s(),i}function ko(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var $o=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function Nr(n){let e=c=>n[c]!=null&&n[c]!=="",o=$o.filter(([c])=>e(c));if(!o.length)return null;let a=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),r=(c,p,u,k)=>{let f=$o.filter(([b])=>k.includes(b)&&e(b));return f.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[g(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},f.map(([b,M])=>a(b,M)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",d=o.map(([c,p])=>`${p} = ${n[c]}`).join(` `),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(o.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function Hr(n){let e="";for(let o=0;o<n.length;o+=32768)e+=String.fromCharCode(...n.subarray(o,o+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Nr(n){let e=globalThis;if(typeof e.CompressionStream>"u")return null;try{let o=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),a=new Uint8Array(await new e.Response(o).arrayBuffer()),r=new Uint8Array(4+a.length);return new DataView(r.buffer).setUint32(0,n.length,!1),r.set(a,4),r}catch{return null}}async function Cn(n,e,o=!0){let a=new TextEncoder().encode(JSON.stringify(zr(n,e))),r=o?await Nr(a):null;return`vpn://${Hr(r??a)}`}var ko=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"standard",title:"Standard",ic:"shield",stealth:2,speed:4,text:"Junk packets and random headers. Gets through most VPN blocking with no speed cost.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"strong",title:"Strong",ic:"shieldplus",stealth:3,speed:3,text:"More and larger junk packets for networks that block VPNs aggressively. Connects a little slower.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],Ct=n=>ko.find(e=>e.id===n),Rr={v2:"Needs AmneziaWG 1.5 or newer on the router.",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},Ir={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function yo(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>t("i",{class:o<n?"on":""})))])}function Jt(n,e,o,a,r=!0){let i=t("div",{class:"dl-methods",role:"radiogroup","aria-label":"Disguise method"}),s=()=>dom.content(i,ko.map(l=>{let c=!l.needs||n[l.needs],d=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":d?"true":"false","aria-disabled":c?null:"true",class:`dl-method${d?" on":""}${c?"":" off"}`,click:()=>{!c||d||(e=l.id,s(),o(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},v(l.ic)),t("b",{},l.title),l.id===a?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[yo(l.stealth,"Stealth"),yo(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},c?[v("phone"),t("span",{},l.apps)]:[v("alert"),t("span",{},(r?Rr:Ir)[l.needs])])])}));return s(),i}function $o(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var Eo=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function Br(n){let e=d=>n[d]!=null&&n[d]!=="",o=Eo.filter(([d])=>e(d));if(!o.length)return null;let a=(d,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},d==="header_protection_key"?`${n[d].slice(0,6)}••••`:n[d])]),r=(d,p,u,w)=>{let g=Eo.filter(([m])=>w.includes(m)&&e(m));return g.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[v(p),t("b",{},d)]),t("p",{},u),t("div",{class:"dl-pvals"},g.map(([m,k])=>a(m,k)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=o.map(([d,p])=>`${p} = ${n[d]}`).join(`
`),l=t("div",{class:"dl-pgrid"},[r("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),r("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),r("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),r("Signatures","globe",s,["i1","i2","i3","i4","i5"]),r("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),r("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(o.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),ue(d,"Parameters copied")}},"Copy as config")]),l])}function Eo(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},o[1])," ",a&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function Hr(n){let e=!1,o=t("pre",{class:"dl-conf"}),a=()=>dom.content(o,n.conf.split(` `),c=t("div",{class:"dl-pgrid"},[r("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),r("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),r("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),r("Signatures","globe",s,["i1","i2","i3","i4","i5"]),r("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),r("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(o.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:d=>{d.preventDefault(),ue(l,"Parameters copied")}},"Copy as config")]),c])}function Lo(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},o[1])," ",a&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function Or(n){let e=!1,o=t("pre",{class:"dl-conf"}),a=()=>dom.content(o,n.conf.split(`
`).flatMap((s,d)=>d?[` `).flatMap((s,l)=>l?[`
`,Eo(s,e)]:[Eo(s,e)])),r=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(r,[g(e?"x":"key"),e?"Hide key":"Show key"]),a()}},[g("key"),"Show key"]);a();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),D([g("download")," Download"],()=>Ee(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),r,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),ue(n.conf,"Configuration copied")}},[g("copy"),"Copy"])]),o])])}async function Rr(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await Cn(n,`${n.server} · ${n.person} · ${n.name}`),a={qr:()=>t("div",{class:"dl-qr-pane"},[qe(ht(n.conf),"dl-qr"),t("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},o),D("Copy",()=>ue(o,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>Hr(n)},r=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=d=>{i.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.id===d)),dom.content(r,a[d]())};for(let[d,l]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":d,click:()=>s(d)},l));return s(e),t("div",{class:"dl-stack gap12"},[i,r])}async function Ir(n,e,o,a){let r=Tt(o),s=n.st.people.filter(l=>l.server===e.id).reduce((l,c)=>l+c.devices.length,0);await ae(a?"Generate new disguise values?":`Switch to ${r.title}?`,`${s} AmneziaWG device${s===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${o==="max"?" They need an app with AmneziaWG 3.1.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await W(()=>P.serverObfuscation(e.id,o),a?"New values applied":`${r.title} applied`)&&(Q("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function Br(n,e){let o=n.st,a=se(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=se(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=`${e.mtus.computer} for computers and routers, ${e.mtus.phone} for phones and tablets`,s=e.mtu?`Now ${i}. Empty = automatic.`:`Automatic by device type and disguise: now ${i}. Lower it if some sites hang.`,d=se(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),l=Tt(e.preset)?e.preset:void 0,c=l??"standard",p=D("",()=>Ir(n,e,c,c===l),"neutral"),u=()=>dom.content(p,c===l?[g("reset")," Generate new values"]:[`Switch to ${Tt(c).title}`]);u();let k=o.awg_state?.tools!==!1;return St("",[ko("AmneziaWG",e.ifname),he("globe","Listening","Where devices reach this core from the internet",[ne("UDP port",a,"Opened on the WAN firewall automatically.")]),he("file","In every device configuration","Changing these marks devices “Update config” until they import again",[ne("MTU",r,s),ne("Keep-alive",d,"Seconds between packets devices send to keep NAT open. 0 = off.")]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Jt(o.awg,c,f=>{c=f,u()},l,k),k&&!o.awg.v3?mt("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",Nr(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),p])]),t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ne("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ne("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),ne("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),D([g("copy")],()=>ue(e.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),D("Save",()=>n.save({port:a.value,mtu:r.value,keepalive:d.value},"AmneziaWG saved"),"positive")])}function Or(n){let e=Tt(n.preset),o=n.obf??{},a=(s,d)=>t("span",{class:`dl-segs ${d}`},[0,1,2,3].map(l=>t("i",{class:l<s?"on":""}))),r=[];+o.jc&&r.push(`${o.jc} junk · ${o.jmin}–${o.jmax} B`);let i=["s1","s2" Line truncated `,Lo(s,e)]:[Lo(s,e)])),r=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(r,[v(e?"x":"key"),e?"Hide key":"Show key"]),a()}},[v("key"),"Show key"]);a();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),D([v("download")," Download"],()=>Ee(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),r,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),ue(n.conf,"Configuration copied")}},[v("copy"),"Copy"])]),o])])}async function jr(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await Cn(n,`${n.server} · ${n.person} · ${n.name}`),a={qr:()=>t("div",{class:"dl-qr-pane"},[Fe(ht(n.conf),"dl-qr"),t("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},o),D("Copy",()=>ue(o,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>Or(n)},r=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(c=>c.classList.toggle("on",c.dataset.id===l)),dom.content(r,a[l]())};for(let[l,c]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},c));return s(e),t("div",{class:"dl-stack gap12"},[i,r])}async function Ur(n,e,o,a){let r=Ct(o),s=n.st.people.filter(c=>c.server===e.id).reduce((c,d)=>c+d.devices.length,0);await ae(a?"Generate new disguise values?":`Switch to ${r.title}?`,`${s} AmneziaWG device${s===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${o==="max"?" They need an app with AmneziaWG 3.1.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await W(()=>P.serverObfuscation(e.id,o),a?"New values applied":`${r.title} applied`)&&(Q("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function Wr(n,e){let o=n.st,a=se(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=se(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=`${e.mtus.computer} for computers and routers, ${e.mtus.phone} for phones and tablets`,s=e.mtu?`Now ${i}. Empty = automatic.`:`Automatic by device type and disguise: now ${i}. Lower it if some sites hang.`,l=se(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),c=Ct(e.preset)?e.preset:void 0,d=c??"standard",p=D("",()=>Ur(n,e,d,d===c),"neutral"),u=()=>dom.content(p,d===c?[v("reset")," Generate new values"]:[`Switch to ${Ct(d).title}`]);u();let w=o.awg_state?.tools!==!1;return St("",[$o("AmneziaWG",e.ifname),he("globe","Listening","Where devices reach this core from the internet",[ne("UDP port",a,"Opened on the WAN firewall automatically.")]),he("file","In every device configuration","Changing these marks devices “Update config” until they import again",[ne("MTU",r,s),ne("Keep-alive",l,"Seconds between packets devices send to keep NAT open. 0 = off.")]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Jt(o.awg,d,g=>{d=g,u()},c,w),w&&!o.awg.v3?mt("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",Br(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),p])]),t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ne("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ne("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),ne("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),D([v("copy")],()=>ue(e.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),D("Save",()=>n.save({port:a.value,mtu:r.value,keepalive:l.value},"AmneziaWG saved"),"positive")])}function Gr(n){let e=Ct(n.preset),o=n.obf??{},a=(s,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(c=>t("i",{class:c<s?"on":""}))),r=[];+o.jc&&r.push(`${o.jc} junk · ${o.jmin}–${o.jmax} B`);let i=["s1","s2" Line truncated
`),"Log copied"))]),p,u]),[k],"wide"),b([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?"Checking…":"Working…")]);let j=o??null,I=o?.id,E,T=0,w=m=>{I!==m.id&&(I=m.id,e.onJob?.(m))};if(o)e.onJob?.(o);else try{let m=await P.updatesStatus().catch(()=>null);E=m?.job?.id,T=m?.now??0;let h=await P.updatesRun(n);h.job&&h.job.state==="running"&&h.job.id!==E&&(j=h.job,w(h.job))}catch(m){return f=[ve(m)],p.textContent=f[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[g("alert"),t("span",{},ve(m))])),b([M(!0)]),Q(ve(m),"error"),null}let v=null,x=0;for(;;){if(await Zo(1e3),v=await P.updatesStatus().catch(()=>null),!v){if(++x>60)break;continue}x=0;let m=v.job;if(!m||!Yo(m,I,E,T)){if(Date.now()-i>15e3)break;continue}if(w(m),j=m,m.log.length){f=m.log;let h=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=f.join(` `),"Log copied"))]),p,u]),[w],"wide"),m([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?"Checking…":"Working…")]);let H=o??null,B=o?.id,E,y=0,S=h=>{B!==h.id&&(B=h.id,e.onJob?.(h))};if(o)e.onJob?.(o);else try{let h=await P.updatesStatus().catch(()=>null);E=h?.job?.id,y=h?.now??0;let f=await P.updatesRun(n);f.job&&f.job.state==="running"&&f.job.id!==E&&(H=f.job,S(f.job))}catch(h){return g=[ve(h)],p.textContent=g[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[v("alert"),t("span",{},ve(h))])),m([k(!0)]),Q(ve(h),"error"),null}let b=null,x=0;for(;;){if(await ta(1e3),b=await P.updatesStatus().catch(()=>null),!b){if(++x>60)break;continue}x=0;let h=b.job;if(!h||!ea(h,B,E,y)){if(Date.now()-i>15e3)break;continue}if(S(h),H=h,h.log.length){g=h.log;let f=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=g.join(`
`),h&&(p.scrollTop=p.scrollHeight)}if(d.textContent=Jo(m,e.version??""),!d.isConnected&&d.textContent&&s.after(d),c.textContent=Ko((m.finished??v.now)-m.started),m.state==="running"){l.hidden=!m.phase,l.textContent=m.phase;continue}break}if(p.scrollTop=p.scrollHeight,l.hidden=!1,!j||j.state==="running")return l.className="dl-pill warn",l.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[g("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),b([M()]),e.onDone?.(v),j;if(j.state==="failed")return l.className="dl-pill bad",l.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[g("x"),t("span",{},[t("b",{},j.error??"Operation failed"),r?"":". Nothing else was changed."])])),b([D("Copy log",()=>ue(f.join(` `),f&&(p.scrollTop=p.scrollHeight)}if(l.textContent=Qo(h,e.version??""),!l.isConnected&&l.textContent&&s.after(l),d.textContent=Zo((h.finished??b.now)-h.started),h.state==="running"){c.hidden=!h.phase,c.textContent=h.phase;continue}break}if(p.scrollTop=p.scrollHeight,c.hidden=!1,!H||H.state==="running")return c.className="dl-pill warn",c.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[v("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),m([k()]),e.onDone?.(b),H;if(H.state==="failed")return c.className="dl-pill bad",c.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[v("x"),t("span",{},[t("b",{},H.error??"Operation failed"),r?"":". Nothing else was changed."])])),m([D("Copy log",()=>ue(g.join(`
`),"Log copied")),M(!0)]),Q(`${rn[a]??"Update"}: ${j.error??"failed"}`,"error"),e.onDone?.(v),j;if(l.className="dl-pill ok",l.textContent="Finished",r&&v){let m=Vo(v,a);if(dom.content(u,t("div",{class:`dl-comp-status ${m.tone}`},[g(m.tone==="ok"?"check":m.tone==="warn"?"alert":"download"),t("span",{},m.text)])),Q(m.text,m.tone==="warn"?"warning":"success"),e.onDone?.(v),m.update&&e.onUpdate){let h=v;b([M(),D(`Update to ${m.update}`,()=>e.onUpdate(h),"positive")])}else b([M()]),m.tone==="ok"&&setTimeout(()=>u.isConnected&&ce(),1200);return j}if(a==="app"&&j.to){let m=j.to,h=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[g("check"),t("span",{},[t("b",{},`Dawnline ${m} is installed. `),h])]));let N=()=>{ui.menu?.flushCache(),location.reload()};b([M(),D("Reload now",N,"positive")]),Q(`Dawnline updated to ${m}`,"success",6e3);for(let C=1;C<=30;C++)if(h.textContent=`Waiting for the router to restart its services (${C} of 30)…`,await Zo(1500),(await P.updatesStatus().catch(()=>null))?.version===m)return h.textContent="Services are back. Reloading…",setTimeout(N,800),j;return h.textContent="Services restarted. Reload the page to use the new version.",j}let $=a==="pkgs"?`Updated ${[...j.result?.pkgs?.updated??[],...j.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:a==="amneziawg"?`AmneziaWG${j.to?` ${j.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[g("check"),t("span",{},$)])),b([M()]),Q($,"success"),e.onDone?.(v),j}var li={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function Qo(n,e,o,a){return!await ae(`Install ${e}?`,o,"Install")||(await Ht(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>a?.(),4e3),!0)}function ln(n){return Qo("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Rt(n,e,o){return n==="awg"?ln(o):e.length?Qo(`pkgs:${e.join(",")}`,li[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function Xo(n,e){if(n==="awg")return ln(e);let o=await W(()=>P.updatesStatus());return o?Rt(n,o.needs?.[n]??[],e):!1}var di=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],ci={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function ea(n,e,o){let a=n.id,r=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,d=!0,l="",c=!0,p=!0,u="all",k=!1,f=Go(r,a,o),b=new Set,M="",j=()=>JSON.stringify([p,d,d?"":l,c,[...b].sort()]),I=()=>s.detected.lan||s.saved.lan||"",E=()=>(d?s.detected.wan||s.saved.wan:l)||"",T=()=>new Map(s.devices.map(z=>[z.name,z])),w=()=>{let z=T();return[...c&&I()?[I()]:[],...[...b].filter(X=>X!==I())].filter(X=>X!==E()).map(X=>z.get(X)??{name:X,nets:[],missing:!0})},v=(z,F)=>{s=z,F&&(d=z.config.auto_wan,l=z.config.wan_device||z.detected.wan||z.saved.wan||"",c=z.config.auto_lan,p=z.config.lan_like,u=z.config.mesh??(z.config.device_mesh?"all":"off"),b=new Set(z.config.lan_devices),M=j()),G()},x=async z=>{let F=await P.interfaces(a).catch(X=>(Q(X.message,"error"),null));F&&v(F,z)};function $(z){let F=c&&z.name===I(),X=!!z.own||!!z.master||z.name===E()||F;return F||b.has(z.name)||!X&&(z.nets.length>0||!!z.missing)}function m(z){let F=c&&z.name===I(),X=z.name===E(),de=!F&&b.has(z.name),B=!(!!z.own||!!z.master||X||F)&&(z.nets.length>0||de||!!z.missing),U=(de||F)&&!z.zone&&!z.missing,q=z.missing?"Not present right now":z.own?"This server":z.master?`Port of ${z.master}`:X?`Internet${z.zone?` · zone ${z.zone}`:""}`:z.nets.length?z.nets.join(", "):"No IPv4 network",oe=t("button",{type:"button",class:`dl-if${de?" sel":""}${F?" auto":""}${!B&&!de&&!F?" off":""}${U?" warn":""}`,"aria-pressed":de||F?"true":"false","aria-disabled":B?null:"true",click:()=>{B&&(b.has(z.name)?b.delete(z.name):b.add(z.name),G())}},[t("span",{class:"dl-if-ic"},g(ci[z.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},z.name),t("span",{class:"dl-if-sub"},q)]),F?t("span",{class:"dl-if-badge ok"},"Auto"):de?t("span",{class:"dl-if-check"},g("check")):""]);return me(oe,()=>[t("div",{class:"dl-tip-title"},z.name),t("div",{class:"dl-muted"},[z.logical?`Interface ${z.logical}`:"No netifd interface",z.zone?` · zone ${z.zone}`:" · no firewall zone"]),z.members.length?t("div",{class:"dl-muted"},`Ports: ${z.members.join(", ")}`):"",z.nets.length?t("div",{class:"dl-mono"},z.nets.join(", ")):"",U?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",z.master?t("div",{class:"dl-muted"},`Choose ${z.master} to include it.`):""]),oe}function h(){let z=s.like_home;return!p||!s.config.lan_like Line truncated `),"Log copied")),k(!0)]),Q(`${sn[a]??"Update"}: ${H.error??"failed"}`,"error"),e.onDone?.(b),H;if(c.className="dl-pill ok",c.textContent="Finished",r&&b){let h=Xo(b,a);if(dom.content(u,t("div",{class:`dl-comp-status ${h.tone}`},[v(h.tone==="ok"?"check":h.tone==="warn"?"alert":"download"),t("span",{},h.text)])),Q(h.text,h.tone==="warn"?"warning":"success"),e.onDone?.(b),h.update&&e.onUpdate){let f=b;m([k(),D(`Update to ${h.update}`,()=>e.onUpdate(f),"positive")])}else m([k()]),h.tone==="ok"&&setTimeout(()=>u.isConnected&&ce(),1200);return H}if(a==="app"&&H.to){let h=H.to,f=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},[t("b",{},`Dawnline ${h} is installed. `),f])]));let R=()=>{ui.menu?.flushCache(),location.reload()};m([k(),D("Reload now",R,"positive")]),Q(`Dawnline updated to ${h}`,"success",6e3);for(let C=1;C<=30;C++)if(f.textContent=`Waiting for the router to restart its services (${C} of 30)…`,await ta(1500),(await P.updatesStatus().catch(()=>null))?.version===h)return f.textContent="Services are back. Reloading…",setTimeout(R,800),H;return f.textContent="Services restarted. Reload the page to use the new version.",H}let M=a==="pkgs"?`Updated ${[...H.result?.pkgs?.updated??[],...H.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:a==="amneziawg"?`AmneziaWG${H.to?` ${H.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},M)])),m([k()]),Q(M,"success"),e.onDone?.(b),H}var bi={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function na(n,e,o,a){return!await ae(`Install ${e}?`,o,"Install")||(await Nt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>a?.(),4e3),!0)}function dn(n){return na("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Rt(n,e,o){return n==="awg"?dn(o):e.length?na(`pkgs:${e.join(",")}`,bi[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function oa(n,e){if(n==="awg")return dn(e);let o=await W(()=>P.updatesStatus());return o?Rt(n,o.needs?.[n]??[],e):!1}var xi=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],wi={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function aa(n,e,o){let a=n.id,r=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,c="",d=!0,p=!0,u="all",w=!1,g=Jo(r,a,o),m=new Set,k="",H=()=>JSON.stringify([p,l,l?"":c,d,[...m].sort()]),B=()=>s.detected.lan||s.saved.lan||"",E=()=>(l?s.detected.wan||s.saved.wan:c)||"",y=()=>new Map(s.devices.map(z=>[z.name,z])),S=()=>{let z=y();return[...d&&B()?[B()]:[],...[...m].filter(X=>X!==B())].filter(X=>X!==E()).map(X=>z.get(X)??{name:X,nets:[],missing:!0})},b=(z,q)=>{s=z,q&&(l=z.config.auto_wan,c=z.config.wan_device||z.detected.wan||z.saved.wan||"",d=z.config.auto_lan,p=z.config.lan_like,u=z.config.mesh??(z.config.device_mesh?"all":"off"),m=new Set(z.config.lan_devices),k=H()),G()},x=async z=>{let q=await P.interfaces(a).catch(X=>(Q(X.message,"error"),null));q&&b(q,z)};function M(z){let q=d&&z.name===B(),X=!!z.own||!!z.master||z.name===E()||q;return q||m.has(z.name)||!X&&(z.nets.length>0||!!z.missing)}function h(z){let q=d&&z.name===B(),X=z.name===E(),de=!q&&m.has(z.name),O=!(!!z.own||!!z.master||X||q)&&(z.nets.length>0||de||!!z.missing),U=(de||q)&&!z.zone&&!z.missing,F=z.missing?"Not present right now":z.own?"This server":z.master?`Port of ${z.master}`:X?`Internet${z.zone?` · zone ${z.zone}`:""}`:z.nets.length?z.nets.join(", "):"No IPv4 network",oe=t("button",{type:"button",class:`dl-if${de?" sel":""}${q?" auto":""}${!O&&!de&&!q?" off":""}${U?" warn":""}`,"aria-pressed":de||q?"true":"false","aria-disabled":O?null:"true",click:()=>{O&&(m.has(z.name)?m.delete(z.name):m.add(z.name),G())}},[t("span",{class:"dl-if-ic"},v(wi[z.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},z.name),t("span",{class:"dl-if-sub"},F)]),q?t("span",{class:"dl-if-badge ok"},"Auto"):de?t("span",{class:"dl-if-check"},v("check")):""]);return me(oe,()=>[t("div",{class:"dl-tip-title"},z.name),t("div",{class:"dl-muted"},[z.logical?`Interface ${z.logical}`:"No netifd interface",z.zone?` · zone ${z.zone}`:" · no firewall zone"]),z.members.length?t("div",{class:"dl-muted"},`Ports: ${z.members.join(", ")}`):"",z.nets.length?t("div",{class:"dl-mono"},z.nets.join(", ")):"",U?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",z.master?t("div",{class:"dl-muted"},`Choose ${z.master} to include it.`):""]),oe}function f(){let z=s.like_home;return!p||!s.config.lan_like Line truncated
`)){let l=d.trimEnd();if(i){/^```/.test(l.trim())?(e.push(t("pre",{},i.join(` `)){let c=l.trimEnd();if(i){/^```/.test(c.trim())?(e.push(t("pre",{},i.join(`
`))),i=null):i.push(d);continue}if(/^```/.test(l.trim())){s(),i=[];continue}let c=/^(#{1,6})\s+(.*)$/.exec(l),p=/^\s*[-*+]\s+(.*)$/.exec(l)??/^\s*\d+[.)]\s+(.*)$/.exec(l);c?(s(),e.push(t("h5",{},o(c[2])))):p?(r.length&&s(),a||(a=t("ul",{}),e.push(a)),a.appendChild(t("li",{},o(p[1])))):l.trim()?(a&&(a=null),r.push(l.trim())):s()}return i&&e.push(t("pre",{},i.join(` `))),i=null):i.push(l);continue}if(/^```/.test(c.trim())){s(),i=[];continue}let d=/^(#{1,6})\s+(.*)$/.exec(c),p=/^\s*[-*+]\s+(.*)$/.exec(c)??/^\s*\d+[.)]\s+(.*)$/.exec(c);d?(s(),e.push(t("h5",{},o(d[2])))):p?(r.length&&s(),a||(a=t("ul",{}),e.push(a)),a.appendChild(t("li",{},o(p[1])))):c.trim()?(a&&(a=null),r.push(c.trim())):s()}return i&&e.push(t("pre",{},i.join(`
`))),s(),e}function ba(n){let e=[],o=!1;for(let a of n.replace(/\r/g,"").split(` `))),s(),e}function ka(n){let e=[],o=!1;for(let a of n.replace(/\r/g,"").split(`
`)){let r=/^#{1,6}\s+(.*)$/.exec(a);if(r){if(o=/^install\b/i.test(r[1].trim()),/^what.s new$/i.test(r[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(a)&&(o=!1);o||e.push(a)}return e.join(` `)){let r=/^#{1,6}\s+(.*)$/.exec(a);if(r){if(o=/^install\b/i.test(r[1].trim()),/^what.s new$/i.test(r[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(a)&&(o=!1);o||e.push(a)}return e.join(`
`).replace(/\n{3,}/g,` `).replace(/\n{3,}/g,`
`).trim()}async function Bt(n,e,o,a){let r=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";re(o,[i,r],[D([g("copy")," Copy"],()=>ue(s,"Release notes copied"))," ",le("Close")],"wide");try{let d=await P.updatesNotes(n,e,a??"");s=ba(d.body||"");let l=ga(d.url);dom.content(i,[d.published?t("span",{class:"dl-pill"},He(d.published)):"",d.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),l?t("a",{href:l,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",g("open")]):""]),dom.content(r,s.trim()?va(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(d){dom.content(r,t("p",{class:"dl-muted"},ve(d)))}}var xa={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Kn=n=>n?He(n):"";function _i(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function ya(n,e){let o=n.st,a=o.policy,r=o.kept?.app,i=e?.update&&e.tag?e.tag:o.version,s=k=>()=>Bt("app",k,`What’s new in Dawnline ${k.replace(/^v/,"")}`),d=e?.tag&&(e.update||e.status==="latest")?Si(n,e.tag,e.update?o.version:""):null,l=e?.tag??i,c=a.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[a.interval]??24)*3600:0,p=(k,f)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},k),t("span",{class:"dl-comp-side-v"},f)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:`Reinstall ${o.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",o.version)},r?{label:`Roll back to ${r.version}`,ic:"archive",warn:!0,run:async()=>{await ae(`Roll back to Dawnline ${r.version}?`,`The copy kept on the router replaces ${o.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",o.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},g("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[o.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},`release ${e.latest}`):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?`released ${Kn(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${Kn(e.published)}`:""}`:"not checked yet")])]),d?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},d.items.map(k=>t("li",{},k))),d.total>d.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(l)},`+${d.total-d.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[D("Update now",()=>n.op("app","Updating Dawnline",o.version),"positive",{disabled:n.busy}),D("What’s new",s(i))]):"",Mi(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[g("globe"),t("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p("Auto-update",[a.auto?ye("ok","On"):ye("","Off"),t("span",{class:"dl-muted"},a.auto?a.mode==="immediate"?"as soon as found":`${xa[a.interval]==="weekly"?"weekly":"daily"} at ${a.time}`:a.check?`checks ${xa[a.interval]}`:"checks off")]),p("Last check",o.check?[ie(o.check.time,o.now),c>o.now?t("span",{class:"dl-faint"},`· next in ${ct(c-o.now)}`):""]:["Never"]),p("Rollback",r?[t("span",{class:"dl-mono"},r.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},a.keep?"Kept after the next update":"Off")])])])}function Si(n,e,o){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let a=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await P.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` `).trim()}async function Bt(n,e,o,a){let r=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";re(o,[i,r],[D([v("copy")," Copy"],()=>ue(s,"Release notes copied"))," ",le("Close")],"wide");try{let l=await P.updatesNotes(n,e,a??"");s=ka(l.body||"");let c=wa(l.url);dom.content(i,[l.published?t("span",{class:"dl-pill"},Ne(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),c?t("a",{href:c,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",v("open")]):""]),dom.content(r,s.trim()?ya(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(r,t("p",{class:"dl-muted"},ve(l)))}}var $a={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Jn=n=>n?Ne(n):"";function Hi(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function La(n,e){let o=n.st,a=o.policy,r=o.kept?.app,i=e?.update&&e.tag?e.tag:o.version,s=w=>()=>Bt("app",w,`What’s new in Dawnline ${w.replace(/^v/,"")}`),l=e?.tag&&(e.update||e.status==="latest")?Ni(n,e.tag,e.update?o.version:""):null,c=e?.tag??i,d=a.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[a.interval]??24)*3600:0,p=(w,g)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},w),t("span",{class:"dl-comp-side-v"},g)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:`Reinstall ${o.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",o.version)},r?{label:`Roll back to ${r.version}`,ic:"archive",warn:!0,run:async()=>{await ae(`Roll back to Dawnline ${r.version}?`,`The copy kept on the router replaces ${o.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",o.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},v("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[o.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},`release ${e.latest}`):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?`released ${Jn(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${Jn(e.published)}`:""}`:"not checked yet")])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(w=>t("li",{},w))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(c)},`+${l.total-l.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[D("Update now",()=>n.op("app","Updating Dawnline",o.version),"positive",{disabled:n.busy}),D("What’s new",s(i))]):"",Ri(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[v("globe"),t("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p("Auto-update",[a.auto?ye("ok","On"):ye("","Off"),t("span",{class:"dl-muted"},a.auto?a.mode==="immediate"?"as soon as found":`${$a[a.interval]==="weekly"?"weekly":"daily"} at ${a.time}`:a.check?`checks ${$a[a.interval]}`:"checks off")]),p("Last check",o.check?[ie(o.check.time,o.now),d>o.now?t("span",{class:"dl-faint"},`· next in ${ct(d-o.now)}`):""]:["Never"]),p("Rollback",r?[t("span",{class:"dl-mono"},r.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},a.keep?"Kept after the next update":"Off")])])])}function Ni(n,e,o){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let a=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await P.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(`
`).map(d=>/^\s*[-*+]\s+(.*)$/.exec(d)?.[1]).filter(d=>!!d);i.length||(i=(await P.updatesChanges(o,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(d=>_i(a(d))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Mi(n){let e=t("div",{class:"dl-params-body"}),o=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[g("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&fn(n,e)}),n.versOpen&&fn(n,e),o}async function fn(n,e){let o=se("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),a=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return Q("Enter a release tag like 0.3.1","warning");wa(n,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),a(o.value))});let r=t("div",{class:"dl-comp-tag"},[o,D("Install",()=>a(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),fn(n,e)},d=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),t("span",{class:"dl-faint"},`Page ${i}`),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>s(1)},"Older →")]),l=n.versCache.get(i);if(!l){dom.content(e,[r,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{l=(await P.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[r,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${ve(p)}`),D("Try again",()=>fn(n,e))]),d(!1)]);return}if(n.versCache.set(i,l),i!==n.versPage||!e.isConnected)return}if(!l.length)return dom.content(e,[r,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),d(!1)]);let c=n.st.version;dom.content(e,[r,...l.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},Kn(p.published)),p.prerelease?ye("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},$e("file","What’s new",()=>Bt("app",p.tag,`What’s new in Dawnline ${u}`))),u===c?ye("ok","Installed"):D("Install",()=>wa(n,p.tag),"neutral",{disabled:n.busy})])}),d(l.length>=5)])}async function wa(n,e){let o=e.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await ae(`Install Dawnline ${o}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${e}`,`Installing Dawnline ${o}`,n.st.version)}function ka(n,e){let o=n.st,a=o.kept?.amneziawg,r=e?.sources??{},i=Object.keys(r),s=e?.current??null,d=s?r[s]:void 0,l=!!e?.ru,c=o.needs?.awg??[],p=c.length?null:e?.installed??null,u=[];s&&p&&u.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${l?":ru":""}`,"Reinstalling AmneziaWG",p)}),a&&u.push({label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await ae(`Roll back AmneziaWG to ${a.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",p??void 0)}});let k=[e?.release?{label:"What’s new",ic:"file",run:()=>Bt("amneziawg",e.release,`What’s new in the ${d?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${d?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((m,h,N)=>m!==null||h>0&&N[h-1]!==null),f=o.tunnels??[],b=f.length?`Switching restarts ${f.length===1?"the tunnel":`${f.length} tunnels`} for a few seconds: ${f.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",M=f.length>1?`${f.slice(0,-1).join(", ")} and ${f[f.length-1]}`:f[0],j=f.length?`Switching restarts ${M} for a few seconds.`:"Switching takes a few seconds.",I=async m=>{let h=r[m];await ae(p?`Switch to AmneziaWG ${h.gen}?`:`Install AmneziaWG ${h.gen}?`,`The ${h.label} build, ${h.version}. ${b}${h.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${m}${l?":ru":""}`,p?`Switching to AmneziaWG ${h.gen}`:"Installing AmneziaWG",p??void 0)},E=m=>{let h=r[m],N=s===m&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},h.gen?`AmneziaWG ${h.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${h.label} · ${h.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},h.version??"none yet"),t("span",{class:"dl-comp-bact"},N?ye("ok","Active"):h.version?D(p?"Switch":"Install",()=>I(m),p?"neutral":"positive",{disabled:n.busy}):ye("","No build"))])},T=i.map(m=>r[m]?.newer?`${r[m].label} moves to ${r[m].newer.gen} with OpenWrt ${r[m].newer.tag.replace( Line truncated `).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await P.updatesChanges(o,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>Hi(a(l))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Ri(n){let e=t("div",{class:"dl-params-body"}),o=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[v("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&gn(n,e)}),n.versOpen&&gn(n,e),o}async function gn(n,e){let o=se("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),a=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return Q("Enter a release tag like 0.3.1","warning");Ea(n,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),a(o.value))});let r=t("div",{class:"dl-comp-tag"},[o,D("Install",()=>a(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),gn(n,e)},l=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),t("span",{class:"dl-faint"},`Page ${i}`),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>s(1)},"Older →")]),c=n.versCache.get(i);if(!c){dom.content(e,[r,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{c=(await P.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[r,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${ve(p)}`),D("Try again",()=>gn(n,e))]),l(!1)]);return}if(n.versCache.set(i,c),i!==n.versPage||!e.isConnected)return}if(!c.length)return dom.content(e,[r,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let d=n.st.version;dom.content(e,[r,...c.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},Jn(p.published)),p.prerelease?ye("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},$e("file","What’s new",()=>Bt("app",p.tag,`What’s new in Dawnline ${u}`))),u===d?ye("ok","Installed"):D("Install",()=>Ea(n,p.tag),"neutral",{disabled:n.busy})])}),l(c.length>=5)])}async function Ea(n,e){let o=e.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await ae(`Install Dawnline ${o}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${e}`,`Installing Dawnline ${o}`,n.st.version)}function Ma(n,e){let o=n.st,a=o.kept?.amneziawg,r=e?.sources??{},i=Object.keys(r),s=e?.current??null,l=s?r[s]:void 0,c=!!e?.ru,d=o.needs?.awg??[],p=d.length?null:e?.installed??null,u=[];s&&p&&u.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${c?":ru":""}`,"Reinstalling AmneziaWG",p)}),a&&u.push({label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await ae(`Roll back AmneziaWG to ${a.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",p??void 0)}});let w=[e?.release?{label:"What’s new",ic:"file",run:()=>Bt("amneziawg",e.release,`What’s new in the ${l?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((h,f,R)=>h!==null||f>0&&R[f-1]!==null),g=o.tunnels??[],m=g.length?`Switching restarts ${g.length===1?"the tunnel":`${g.length} tunnels`} for a few seconds: ${g.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",k=g.length>1?`${g.slice(0,-1).join(", ")} and ${g[g.length-1]}`:g[0],H=g.length?`Switching restarts ${k} for a few seconds.`:"Switching takes a few seconds.",B=async h=>{let f=r[h];await ae(p?`Switch to AmneziaWG ${f.gen}?`:`Install AmneziaWG ${f.gen}?`,`The ${f.label} build, ${f.version}. ${m}${f.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${h}${c?":ru":""}`,p?`Switching to AmneziaWG ${f.gen}`:"Installing AmneziaWG",p??void 0)},E=h=>{let f=r[h],R=s===h&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??"none yet"),t("span",{class:"dl-comp-bact"},R?ye("ok","Active"):f.version?D(p?"Switch":"Install",()=>B(h),p?"neutral":"positive",{disabled:n.busy}):ye("","No build"))])},y=i.map(h=>r[h]?.newer?`${r[h].label} moves to ${r[h].newer.gen} with OpenWrt ${r[h].newer.tag.replace( Line truncated
`)}r.push(p),d+=c-1}let s=D([g("more")],()=>we(s,[{label:"Export CSV",icon:g("download"),run:()=>Ue(o,a,"csv",e.id)},{label:"Export JSON",icon:g("download"),run:()=>Ue(o,a,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:g("trash"),danger:!0,run:()=>Fe(`Clear ${e.name}'s activity`,`Removes events about ${e.name} and their devices.`,{person:e.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-sub"},a.length>10?`latest 10 of ${a.length}`:""),t("span",{class:"dl-spacer"}),s]),r.length?r:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var vn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,a,r]=await Promise.all([P.status(30),e?P.events(5e3).catch(()=>null):Promise.resolve(null),e?P.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:a?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(s=>s.id===this.id);if(!o)return t("div",{class:"dl-empty"},[t("h3",{},"Person not found"),t("p",{},"They may have been removed."),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let a=t("div",{},[t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:xt(o.server)},this.st.servers.find(s=>s.id===o.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:xt(o.server)},"People"),t("span",{},"/"),t("span",{},o.name)]),this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(s=>s.id===r.get("device"));return i?setTimeout(()=>Be(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>rt(this.p,this.deviceOpts()),50),this.poller=Je({fetch:s=>{let d=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(d)},every:15,live:!0,active:()=>a.isConnected,apply:(s,d)=>this.apply(s,d)}),a}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let a=this.st.people.find(r=>r.id===this.id);if(!a){o||(location.href=xt(this.p?.server));return}this.p=a,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var i;this.poller?.claim();let a=await W(()=>P.personUpdate(this.p.id,e),o);if(!a)return;this.poller?.claim();let r=this.st.people.findIndex(s=>s.id===this.p.id);(i=a.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=a.person),this.p=a.person,this.paint()}get today(){return Re(this.series.length?this.series:this.st.series)}get core(){return vt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}paint(e=!1){Le(this.parts.head,Pa(this),e),Le(this.parts.traffic,Da(this),e),Le(this.parts.devices,Aa(this),e),Le(this.parts.limits,Oa(this),e),this.paintPlaces(e),Le(this.parts.activity,Ua(this),e)}paintPlaces(e=!1){let o=ja(this);o&&Le(this.parts.places,o,e&&!this.mapOpen)}};var Ii={ok:"check",warn:"alert",error:"x",skip:"pause"},bn=class{constructor(e,o,a,r){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=a,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,a)}async run(e){let o=e?await un(e):await P.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks")]),t("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=e.filter(s=>s.status==="error").length,a=e.filter(s=>s.status==="warn").length;dom.content(this.summary,o?mt("error",`${o} problem${o>1?"s":""} need attention.`):a?mt("warn",`${a} warning${a>1?"s":""}.`):mt("ok","All checks passed."));let r=new Map;for(let s of this.sl.watchdog.repairs)r.set(s.id Line truncated `)}r.push(p),l+=d-1}let s=D([v("more")],()=>we(s,[{label:"Export CSV",icon:v("download"),run:()=>Ue(o,a,"csv",e.id)},{label:"Export JSON",icon:v("download"),run:()=>Ue(o,a,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:v("trash"),danger:!0,run:()=>qe(`Clear ${e.name}'s activity`,`Removes events about ${e.name} and their devices.`,{person:e.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-sub"},a.length>10?`latest 10 of ${a.length}`:""),t("span",{class:"dl-spacer"}),s]),r.length?r:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var bn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,a,r]=await Promise.all([P.status(30),e?P.events(5e3).catch(()=>null):Promise.resolve(null),e?P.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:a?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(s=>s.id===this.id);if(!o)return t("div",{class:"dl-empty"},[t("h3",{},"Person not found"),t("p",{},"They may have been removed."),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let a=t("div",{},[t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:xt(o.server)},this.st.servers.find(s=>s.id===o.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:xt(o.server)},"People"),t("span",{},"/"),t("span",{},o.name)]),this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(s=>s.id===r.get("device"));return i?setTimeout(()=>Be(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>rt(this.p,this.deviceOpts()),50),this.poller=Je({fetch:s=>{let l=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>a.isConnected,apply:(s,l)=>this.apply(s,l)}),a}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let a=this.st.people.find(r=>r.id===this.id);if(!a){o||(location.href=xt(this.p?.server));return}this.p=a,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var i;this.poller?.claim();let a=await W(()=>P.personUpdate(this.p.id,e),o);if(!a)return;this.poller?.claim();let r=this.st.people.findIndex(s=>s.id===this.p.id);(i=a.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=a.person),this.p=a.person,this.paint()}get today(){return Re(this.series.length?this.series:this.st.series)}get core(){return vt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}paint(e=!1){Le(this.parts.head,Ha(this),e),Le(this.parts.traffic,Na(this),e),Le(this.parts.devices,Ra(this),e),Le(this.parts.limits,Ga(this),e),this.paintPlaces(e),Le(this.parts.activity,qa(this),e)}paintPlaces(e=!1){let o=Fa(this);o&&Le(this.parts.places,o,e&&!this.mapOpen)}};var Ki={ok:"check",warn:"alert",error:"x",skip:"pause"},xn=class{constructor(e,o,a,r){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=a,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,a)}async run(e){let o=e?await mn(e):await P.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks")]),t("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=e.filter(s=>s.status==="error").length,a=e.filter(s=>s.status==="warn").length;dom.content(this.summary,o?mt("error",`${o} problem${o>1?"s":""} need attention.`):a?mt("warn",`${a} warning${a>1?"s":""}.`):mt("ok","All checks passed."));let r=new Map;for(let s of this.sl.watchdog.repairs)r.set(s.id Line truncated
`);function ar(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=ns,n}function st(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async a=>{let r=await e.render(a),i=document.createElement("div");return i.className="dl-root",i.append(ar(),r),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var hg=st(It),fg=st(it),gg=st(It),vg=st(hn),bg=st(vn),xg=st(yn),wg=st(gn);function rr(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var yg=rr(""),kg=rr("log");return baseclass.extend({ activity: kg, diagnostics: xg, health: yg, overview: hg, people: fg, person: bg, server: gg, settings: vg, updates: wg }); `);function lr(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=ps,n}function st(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async a=>{let r=await e.render(a),i=document.createElement("div");return i.className="dl-root",i.append(lr(),r),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var $g=st(It),Eg=st(it),Lg=st(It),Mg=st(fn),Sg=st(bn),_g=st(kn),Tg=st(vn);function dr(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var Cg=dr(""),Pg=dr("log");return baseclass.extend({ activity: Pg, diagnostics: _g, health: Cg, overview: $g, people: Eg, person: Sg, server: Lg, settings: Mg, updates: Tg });
@@ -4,7 +4,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.5.0'; export const VERSION = '0.5.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';
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "dawnline-web", "name": "dawnline-web",
"version": "0.5.0", "version": "0.5.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "dawnline-web", "name": "dawnline-web",
"version": "0.5.0", "version": "0.5.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.5.0", "version": "0.5.1",
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
+389 -33
View File
@@ -53,6 +53,13 @@ function isDark(): boolean {
/** A click on a marker brings the map at least this close (a city). */ /** A click on a marker brings the map at least this close (a city). */
const CLICK_ZOOM = 10; const CLICK_ZOOM = 10;
/** Places closer than this are one city: a click shows them together at city level. */
const CITY_KM = 30;
/** Screen distance at which two markers stand clear of each other (the server's plate and an avatar, with room). */
const PART_PX = 62;
/** Below these zooms plates turn compact (a continent) or mid-sized (a country). */
const LOD_FAR = 4.5;
const LOD_MID = 7;
/** mapcn's arc colours: its default blue for live tunnels, a neutral gray for recently seen. */ /** mapcn's arc colours: its default blue for live tunnels, a neutral gray for recently seen. */
const LIVE = '#3b82f6'; const LIVE = '#3b82f6';
@@ -147,9 +154,18 @@ export class ConnectionMap {
/** People's markers, for the hover highlight; the person in focus, kept across redraws. */ /** People's markers, for the hover highlight; the person in focus, kept across redraws. */
private people: { el: HTMLElement; person: string }[] = []; private people: { el: HTMLElement; person: string }[] = [];
/** Markers on the map: the server stays put (`fixed`), the others move aside when crowded. */ /** Markers on the map: the server stays put (`fixed`), the others move aside when crowded. */
private slots: { marker: any; el: HTMLElement; at: [number, number]; fixed: boolean; who?: string; where?: string }[] = []; private slots: { marker: any; el: HTMLElement; at: [number, number]; fixed: boolean; who?: string; where?: string; g?: Group }[] = [];
/** People folded into the server while they would sit on top of it (their marker hidden). */ /** People docked in the server's plate while they would sit on top of it (their marker hidden). */
private merged: { at: [number, number]; who: string; where: string; need: number }[] = []; private merged: Face[] = [];
/** People crowding each other, one plate each (by who is in it); their own markers hidden. */
private piles = new Map<string, { marker: any; el: HTMLElement; box: HTMLElement; faces: Face[] }>();
/** The server plate's avatars, and what they show (repainted only when that changes). */
private dock: HTMLElement | null = null;
private dockKey = '';
/** A redraw's new plate fills in place: no pop for avatars that were already there. */
private dockQuiet = false;
/** Who was in a pile at the last declutter: a redrawn marker starts hidden, as it was. */
private piledKeys = new Set<string>();
/** Which markers were folded at the last redraw (by place key): a new marker starts that way. */ /** Which markers were folded at the last redraw (by place key): a new marker starts that way. */
private foldedKeys = new Set<string>(); private foldedKeys = new Set<string>();
/** The zoom a programmatic zoom-out is heading for: markers fold for it at once, not on the way. */ /** The zoom a programmatic zoom-out is heading for: markers fold for it at once, not on the way. */
@@ -281,6 +297,8 @@ export class ConnectionMap {
destroy() { destroy() {
this.dropCard(); this.dropCard();
for (const p of this.piles.values()) p.marker.remove();
this.piles.clear();
this.theme?.disconnect(); this.theme?.disconnect();
this.resize?.disconnect(); this.resize?.disconnect();
this.map?.remove(); this.map?.remove();
@@ -326,16 +344,19 @@ export class ConnectionMap {
for (const m of this.markers) m.remove(); for (const m of this.markers) m.remove();
this.markers = []; this.markers = [];
// Every marker at its real place; ones that would cover each other move aside on screen (declutter). // Every marker in its city: the IP gives no more, so people sharing a city (or the server's)
const placed = groups.map((g) => ({ g, at: [g.lon, g.lat] as [number, number] })); // each get their own spot in it; ones that would still cover each other share a plate (declutter).
const spots = data.person || data.device ? null : cityPlaces(groups, home);
const placed = groups.map((g) => ({ g, at: spots?.get(g.key) ?? ([g.lon, g.lat] as [number, number]) }));
this.slots = []; this.slots = [];
this.map.getSource('dl-areas').setData({ this.map.getSource('dl-areas').setData({
type: 'FeatureCollection', type: 'FeatureCollection',
features: placed.map(({ g, at }) => ({ // The accuracy zone stays on the city itself.
features: placed.map(({ g }) => ({
type: 'Feature', type: 'Feature',
properties: { online: g.online, key: g.key }, properties: { online: g.online, key: g.key },
geometry: { type: 'Point', coordinates: at }, geometry: { type: 'Point', coordinates: [g.lon, g.lat] },
})), })),
}); });
this.map.getSource('dl-arcs').setData({ this.map.getSource('dl-arcs').setData({
@@ -354,13 +375,16 @@ export class ConnectionMap {
// initials) and from what (a device badge), blue while live, gray when seen recently. // initials) and from what (a device badge), blue while live, gray when seen recently.
if (home) { if (home) {
const host = E('span', { class: 'dl-mk-host' }); const host = E('span', { class: 'dl-mk-host' });
host.innerHTML = `<span class="dl-mk-host-tile">${iconSvg('server', 'dl-mk-host-ic')}</span><span class="dl-mk-host-n"></span>`; host.innerHTML = `<span class="dl-mk-host-tile">${iconSvg('server', 'dl-mk-host-ic')}</span>`;
this.dock = host.appendChild(E('span', { class: 'dl-mk-dock' }));
this.dockQuiet = this.dockKey !== '';
this.dockKey = '';
const el = E( const el = E(
'div', 'div',
{ class: 'dl-mk-hub', title: `Home router${home.city ? ` · ${home.city}` : ''}${home.org ? ` · ${home.org}` : ''}` }, { class: 'dl-mk-hub', title: `Home router${home.city ? ` · ${home.city}` : ''}${home.org ? ` · ${home.org}` : ''}` },
[host, E('span', { class: 'dl-mk-label chip' }, home.city || 'Home')], [host, E('span', { class: 'dl-mk-label chip' }, home.city || 'Home')],
); );
// Who is folded in here: listed on hover; a click zooms in until they stand apart. // Who is docked here: listed on hover; a click on the plate zooms to them (an avatar opens its card).
el.addEventListener('mouseenter', () => this.showMerged(home.city || 'the server')); el.addEventListener('mouseenter', () => this.showMerged(home.city || 'the server'));
el.addEventListener('mouseleave', () => this.focus(this.focused)); el.addEventListener('mouseleave', () => this.focus(this.focused));
el.addEventListener('click', () => this.zoomToMerged()); el.addEventListener('click', () => this.zoomToMerged());
@@ -418,7 +442,7 @@ export class ConnectionMap {
ev.stopPropagation(); ev.stopPropagation();
this.openPopup(g, at, el); this.openPopup(g, at, el);
}); });
this.add(el, at, false, person?.name ?? 'Someone', `${g.city || g.cc || '?'} · ${g.online ? 'now' : ago(g.ts, data.now)}`, g.key); this.add(el, at, false, person?.name ?? 'Someone', `${g.city || g.cc || '?'} · ${g.online ? 'now' : ago(g.ts, data.now)}`, g.key, g);
} }
this.declutter(); this.declutter();
@@ -449,15 +473,16 @@ export class ConnectionMap {
this.focus(this.focused && this.people.some((x) => x.person === this.focused) ? this.focused : null); this.focus(this.focused && this.people.some((x) => x.person === this.focused) ? this.focused : null);
} }
private add(el: HTMLElement, at: [number, number], fixed = false, who?: string, where?: string, key?: string) { private add(el: HTMLElement, at: [number, number], fixed = false, who?: string, where?: string, key?: string, g?: Group) {
// A redrawn marker keeps how it was (folded or not), with no fade in its first frame. // A redrawn marker keeps how it was (folded or not), with no fade in its first frame.
if (key && this.foldedKeys.has(key)) el.classList.add('merged'); if (key && this.foldedKeys.has(key)) el.classList.add('merged');
if (key && this.piledKeys.has(key)) el.classList.add('piled');
el.dataset.key = key ?? ''; el.dataset.key = key ?? '';
el.classList.add('dl-mk-new'); el.classList.add('dl-mk-new');
requestAnimationFrame(() => requestAnimationFrame(() => el.classList.remove('dl-mk-new'))); requestAnimationFrame(() => requestAnimationFrame(() => el.classList.remove('dl-mk-new')));
const marker = new this.gl.Marker({ element: el }).setLngLat(at).addTo(this.map); const marker = new this.gl.Marker({ element: el }).setLngLat(at).addTo(this.map);
this.markers.push(marker); this.markers.push(marker);
this.slots.push({ marker, el, at, fixed, who, where }); this.slots.push({ marker, el, at, fixed, who, where, g });
} }
/** /**
@@ -469,6 +494,12 @@ export class ConnectionMap {
*/ */
private declutter() { private declutter() {
if (!this.map) return; if (!this.map) return;
// Plates by distance (sizes first: the spreading below measures them): compact far out
// (small avatars that overlap, no device badges), small round badges at country level,
// full size from a region in.
const zoom = this.map.getZoom();
this.el.classList.toggle('dl-lod-far', zoom < LOD_FAR);
this.el.classList.toggle('dl-lod-mid', zoom >= LOD_FAR && zoom < LOD_MID);
const items = this.slots.map((m) => { const items = this.slots.map((m) => {
const p = this.map.project(m.at); const p = this.map.project(m.at);
const body = m.el.querySelector(':scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile') as HTMLElement | null; const body = m.el.querySelector(':scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile') as HTMLElement | null;
@@ -488,11 +519,10 @@ export class ConnectionMap {
slot.el.classList.toggle('merged', !!near); slot.el.classList.toggle('merged', !!near);
if (!near) return; if (!near) return;
if (slot.el.dataset.key) this.foldedKeys.add(slot.el.dataset.key); if (slot.el.dataset.key) this.foldedKeys.add(slot.el.dataset.key);
// How much closer the map has to come for them to stand apart. this.merged.push(face(slot));
const need = (near.r + it.r + 14) / Math.max(1, Math.hypot(near.x - it.x, near.y - it.y));
this.merged.push({ at: slot.at, who: slot.who ?? 'Someone', where: slot.where ?? '', need });
Object.assign(it, { r: 0, fixed: true }); Object.assign(it, { r: 0, fixed: true });
}); });
this.pileUp(items);
// A folded person leaves no trace either: their accuracy zone and arc go with their marker. // A folded person leaves no trace either: their accuracy zone and arc go with their marker.
const hidden = [...this.foldedKeys].sort().join('|'); const hidden = [...this.foldedKeys].sort().join('|');
if (hidden !== this.hiddenKey) { if (hidden !== this.hiddenKey) {
@@ -504,14 +534,14 @@ export class ConnectionMap {
if (this.map.getLayer(id)) this.map.setFilter(id, ['all', ['==', ['get', 'online'], live], shown]); if (this.map.getLayer(id)) this.map.setFilter(id, ['all', ['==', ['get', 'online'], live], shown]);
} }
} }
const count = this.slots.find((m) => m.fixed)?.el.querySelector('.dl-mk-host-n') as HTMLElement | null; this.paintDock();
if (count) { // Hovering lights a person. A marker or avatar that went from under the pointer (a plate split
count.textContent = this.merged.length ? String(this.merged.length) : ''; // or closed as the map zoomed) sends no mouseleave: the light goes once nothing is hovered.
count.classList.toggle('on', this.merged.length > 0); if (this.focused && !this.el.querySelector('.dl-mk:hover, .dl-mk-face:hover')) this.focus(null);
} // Past the markers come the people plates (fixed, in the spreading only to be moved clear of).
separate(items).forEach(([dx, dy], i) => { separate(items).forEach(([dx, dy], i) => {
const m = this.slots[i]; const m = this.slots[i];
if (m.fixed) return; if (!m || m.fixed) return;
if (items[i].fixed) [dx, dy] = [0, 0]; if (items[i].fixed) [dx, dy] = [0, 0];
m.marker.setOffset([dx, dy]); m.marker.setOffset([dx, dy]);
pointer(m.el, dx, dy); pointer(m.el, dx, dy);
@@ -559,19 +589,179 @@ export class ConnectionMap {
private showMerged(place: string) { private showMerged(place: string) {
if (!this.merged.length) return; if (!this.merged.length) return;
dom.content(this.card, [ dom.content(this.card, [
E('div', { class: 'dl-map-card-head' }, [E('b', {}, `Near ${place}`), ' · zoom in to see them']), E('div', { class: 'dl-map-card-head' }, [E('b', {}, `Near ${place}`), ' · click to zoom in']),
...this.merged.map((m) => E('div', { class: 'dl-map-card-row' }, [E('span', {}, m.who), E('span', { class: 'dl-faint' }, m.where)])), ...this.merged.map((m) => E('div', { class: 'dl-map-card-row' }, [E('span', {}, m.who), E('span', { class: 'dl-faint' }, m.where)])),
]); ]);
this.card.classList.add('on'); this.card.classList.add('on');
} }
/** Close enough for everyone folded into the server to stand apart (never past zoom 12). */ /** The people on top of the server as avatars in its plate, which slides out for them and back. */
private paintDock() {
const dock = this.dock;
if (!dock) return;
const key = this.merged.map((m) => `${m.key}:${m.online ? 1 : 0}`).join('|');
if (key === this.dockKey) return;
this.dockKey = key;
dock.parentElement?.classList.toggle('docked', this.merged.length > 0);
// Emptied, it keeps its last avatars while it slides back.
const home = this.slots.find((x) => x.fixed)!.at;
if (this.merged.length)
fillFaces(
dock,
this.merged,
this.faceActions(() => [home]),
this.dockQuiet,
);
this.dockQuiet = false;
}
/** What an avatar in a plate does: a click opens its card, hovering lights its person. */
private faceActions(spot: () => [number, number][]) {
return {
click: (f: Face, b: HTMLElement) => this.openFace(f, b, spot()),
hover: (f: Face | null) => this.focus(f?.g?.person ?? null),
};
}
/**
* People whose markers would cover each other (one city, or close at this zoom): one plate with
* their avatars and the city once, where they are. Items of those in a plate leave the
* spreading; the plate takes their place. Not on a person's page (their places spread).
*/
private pileUp(items: { x: number; y: number; r: number; fixed: boolean }[]) {
const live = new Set<string>();
if (!this.data?.person && !this.data?.device) {
const free = items.flatMap((it, i) => (!it.fixed && this.slots[i].el.querySelector(':scope > .dl-mk-av') ? [i] : []));
const root = new Map(free.map((i) => [i, i]));
const find = (i: number): number => (root.get(i) === i ? i : find(root.get(i)!));
for (const a of free)
for (const b of free) {
if (b <= a) continue;
const was = this.slots[a].el.classList.contains('piled') && this.slots[b].el.classList.contains('piled');
if (Math.hypot(items[a].x - items[b].x, items[a].y - items[b].y) < items[a].r + items[b].r + (was ? 12 : 6))
root.set(find(b), find(a));
}
const sets = new Map<number, number[]>();
for (const i of free) sets.set(find(i), [...(sets.get(find(i)) ?? []), i]);
for (const idx of sets.values()) {
if (idx.length < 2) continue;
const slots = idx.map((i) => this.slots[i]);
const faces = slots.map(face);
const key = faces
.map((f) => f.key)
.sort()
.join(',');
live.add(key);
const at: [number, number] = [
slots.reduce((s, x) => s + x.at[0], 0) / slots.length,
slots.reduce((s, x) => s + x.at[1], 0) / slots.length,
];
let pile = this.piles.get(key);
if (!pile) {
const box = E('span', { class: 'dl-mk-pile-box' });
const cities = [...new Set(slots.map((x) => x.g?.city || x.g?.cc || '?'))];
const el = E('div', { class: 'dl-mk-pile' }, [
box,
E('span', { class: 'dl-mk-label below' }, cities.length === 1 ? cities[0] : `${slots.length} people`),
]);
pile = { marker: new this.gl.Marker({ element: el }).setLngLat(at).addTo(this.map), el, box, faces };
el.addEventListener('mouseleave', () => this.focus(this.focused));
const p = pile;
el.addEventListener('click', (ev) => {
ev.stopPropagation();
this.zoomInTo(
p.faces.map((f) => f.at),
false,
);
});
this.piles.set(key, pile);
}
pile.faces = faces;
const p = pile;
fillFaces(
pile.box,
faces,
this.faceActions(() => p.faces.map((x) => x.at)),
);
for (const i of idx) {
this.slots[i].el.classList.add('piled');
// In the spreading as the plate: it stays on its spot, others move clear of it.
Object.assign(items[i], { r: 0, fixed: true });
}
const c = this.map.project(at);
items.push({ x: c.x, y: c.y, r: (pile.el.offsetWidth || 60) / 2 + 3, fixed: true });
}
}
this.piledKeys = new Set(this.slots.filter((x) => x.el.classList.contains('piled')).map((x) => x.el.dataset.key ?? ''));
// Plates nobody is in any more fade out; their people show again.
this.slots.forEach((x, i) => {
if (!items[i].fixed || x.fixed || x.el.classList.contains('merged')) x.el.classList.remove('piled');
});
for (const [key, p] of this.piles)
if (!live.has(key)) {
this.piles.delete(key);
p.el.classList.add('out');
setTimeout(() => p.marker.remove(), 200);
}
}
/**
* The plate clicked: the server and everyone docked in it. All in the server's city: that city;
* someone further: the server and them filling the map.
*/
private zoomToMerged() { private zoomToMerged() {
if (!this.map || !this.merged.length) return; if (!this.map || !this.merged.length) return;
const step = Math.log2(Math.max(...this.merged.map((m) => m.need))) + 0.3; this.zoomInTo([this.slots.find((m) => m.fixed)!.at, ...this.merged.map((m) => m.at)], false);
const pts = [this.slots.find((m) => m.fixed)!.at, ...this.merged.map((m) => m.at)]; }
const center: [number, number] = [pts.reduce((s, p) => s + p[0], 0) / pts.length, pts.reduce((s, p) => s + p[1], 0) / pts.length];
this.map.flyTo({ center, zoom: Math.min(12, this.map.getZoom() + step), duration: 900 }); /**
* An avatar in a plate clicked: its card. Sharing the plate's spot (the same city as everyone
* else in it), it stays in the plate and the card opens there; further away, the map flies to
* them first and the card opens on their own marker once it stands apart.
*/
private openFace(f: Face, avatar: HTMLElement, spot: [number, number][]) {
if (!f.g) return;
if (spot.every((p) => km(p, f.at) < 1)) return this.openPopup(f.g, f.at, avatar);
const open = () => {
const slot = this.slots.find((x) => x.el.dataset.key === f.key);
if (slot?.g && !slot.el.classList.contains('merged') && !slot.el.classList.contains('piled'))
this.openPopup(slot.g, slot.at, slot.el);
};
if (this.zoomInTo(this.nearby(f.at), true)) this.map.once('moveend', open);
else open();
}
/** Where the people around a place are (in the same city, the place itself included). */
private nearby(at: [number, number]): [number, number][] {
return [at, ...this.slots.filter((x) => !x.fixed && x.at !== at && km(x.at, at) <= CITY_KM).map((x) => x.at)];
}
/**
* Closer, to show these places together: city level (zoom 10) when they are one city, else
* fitted (never past 12). Never zooms out. `remember` keeps the view to fly back to when the
* card closes. True when the map moves.
*/
private zoomInTo(pts: [number, number][], remember: boolean): boolean {
const b = new this.gl.LngLatBounds();
for (const p of pts) b.extend(p);
const wide = pts.some((p) => pts.some((q) => km(p, q) > CITY_KM));
const cam = this.map.cameraForBounds(b, { padding: 50, maxZoom: wide ? 12 : CLICK_ZOOM });
const zoom = this.map.getZoom();
// And close enough for markers on different spots to stand apart (those on one spot never do).
const px = pts.map((p) => this.map.project(p));
let part = 0;
px.forEach((a, i) =>
px.slice(i + 1).forEach((c) => {
const d = Math.hypot(a.x - c.x, a.y - c.y);
const z = zoom + Math.log2(PART_PX / Math.max(d, 1e-6));
if (z <= 12) part = Math.max(part, z);
}),
);
const target = Math.min(12, Math.max(cam?.zoom ?? 0, part));
if (target <= zoom + 0.05) return false;
if (remember && !this.before) this.before = { center: this.map.getCenter().toArray(), zoom };
this.map.flyTo({ center: cam?.center ?? b.getCenter(), zoom: target, duration: 800 });
return true;
} }
/** /**
@@ -734,12 +924,8 @@ export class ConnectionMap {
]) ])
: '', : '',
]); ]);
// Closer to a marker clicked from afar (city level); the card itself never moves the map. // Closer to a marker clicked from afar: its city, with whoever else is there; the card itself never moves the map.
const zoom = this.map.getZoom(); this.zoomInTo(this.nearby(at), true);
if (zoom < CLICK_ZOOM) {
if (!this.before) this.before = { center: this.map.getCenter().toArray(), zoom };
this.map.flyTo({ center: at, zoom: CLICK_ZOOM, duration: 800 });
}
this.dropCard(); this.dropCard();
const card = E('div', { class: 'dl-root dl-popcard', role: 'dialog' }, [E('span', { class: 'dl-popcard-tip' }), body]); const card = E('div', { class: 'dl-root dl-popcard', role: 'dialog' }, [E('span', { class: 'dl-popcard-tip' }), body]);
document.body.appendChild(card); document.body.appendChild(card);
@@ -842,6 +1028,176 @@ export function separate(items: { x: number; y: number; r: number; fixed?: boole
} }
/** The line from a moved marker back to its real spot, with a dot there (hidden when in place). */ /** The line from a moved marker back to its real spot, with a dot there (hidden when in place). */
/**
* Where each person stands in their city. The IP gives the city alone, so everyone gets their
* own spot in it, fixed by who they are and the city (a hash, the same on every redraw),
* 1.5-5 km from its centre. One that would land within 1.3 km of someone placed
* before (in key order) or of the server turns further round the city until clear, so all of
* them part by zoom 12.
*/
export function cityPlaces(
items: { key: string; lat: number; lon: number }[],
home: { lat: number; lon: number } | null,
): Map<string, [number, number]> {
const out = new Map<string, [number, number]>();
const taken: [number, number][] = home ? [[home.lon, home.lat]] : [];
const near = (p: [number, number]) => taken.some((q) => km(p, q) < 1.3);
for (const it of [...items].sort((a, b) => (a.key < b.key ? -1 : 1))) {
const h = hash(it.key);
const r0 = 1.5 + 3.5 * ((h >>> 12) / 0xfffff);
const a0 = ((h & 0xfff) / 0x1000) * 2 * Math.PI;
let at: [number, number] = [it.lon, it.lat];
// Golden-angle turns (and a little further out each time) until clear.
for (let i = 0; i < 24; i++) {
const a = a0 + i * 2.39996;
const r = Math.min(8, r0 + i * 0.25);
at = [it.lon + (r * Math.sin(a)) / (111.32 * Math.cos((it.lat * Math.PI) / 180)), it.lat + (r * Math.cos(a)) / 111.32];
if (!near(at)) break;
}
taken.push(at);
out.set(it.key, at);
}
return out;
}
/** FNV-1a: a small stable number for a string. */
function hash(s: string): number {
let h = 0x811c9dc5;
for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 0x01000193);
return h >>> 0;
}
/** Someone in a plate (the server's, or a pile of people): who, where, and their place. */
export interface Face {
key: string;
who: string;
where: string;
online: boolean;
at: [number, number];
/** The device badge of their own marker (one or two icons, or how many). */
badge: string;
g?: Group;
}
function face(slot: { el: HTMLElement; at: [number, number]; who?: string; where?: string; g?: Group }): Face {
return {
key: slot.el.dataset.key ?? '',
who: slot.who ?? 'Someone',
where: slot.where ?? '',
online: !!slot.g?.online,
at: slot.at,
badge: slot.el.querySelector('.dl-mk-badge')?.innerHTML ?? '',
g: slot.g,
};
}
/**
* Avatars in a plate, by person, each with their marker's device badge. Three at most (two and
* "+N"). Changes glide (FLIP): avatars that stay slide to their new places, new ones pop in (not
* when `quiet`: a redraw), gone ones leave the row at once and shrink away where they were, the
* "+N" is one element whose number changes, and the plate's width follows smoothly.
*/
export function fillFaces(
box: HTMLElement,
faces: Face[],
on: { click: (f: Face, b: HTMLElement) => void; hover: (f: Face | null) => void },
quiet = false,
) {
const many = faces.length > 3;
const live = () => [...box.children].filter((c) => !c.classList.contains('out')) as HTMLElement[];
const was = new Map(live().map((c) => [c, c.getBoundingClientRect().left]));
const width0 = box.getBoundingClientRect().width;
const keep = new Map<string, HTMLElement>();
box.querySelectorAll<HTMLElement>('.dl-mk-face:not(.out)').forEach((b) => keep.set(b.dataset.key ?? '', b));
let more = box.querySelector<HTMLElement>('.dl-mk-more:not(.out)');
const leave = (el: HTMLElement) => {
// Out of the row at once, where it was: the others close up while it shrinks away.
Object.assign(el.style, { position: 'absolute', left: `${el.offsetLeft}px`, top: `${el.offsetTop}px`, transform: '' });
el.classList.add('out');
setTimeout(() => el.remove(), 200);
};
const row: HTMLElement[] = [];
for (const f of faces.slice(0, many ? 2 : 3)) {
let b = keep.get(f.key);
keep.delete(f.key);
if (!b) {
const nb = E('button', { type: 'button', class: `dl-mk-face${quiet ? '' : ' in'}`, 'data-key': f.key }, [
E('span', { class: 'dl-mk-av' }, initials(f.who)),
// Beside the avatar, not over it: the plate makes room for one icon, two, or a number.
E('span', { class: 'dl-mk-badge' }),
]);
nb.addEventListener('animationend', () => nb.classList.remove('in'), { once: true });
b = nb;
}
const el = b;
const badge = el.querySelector('.dl-mk-badge') as HTMLElement;
if (badge.innerHTML !== f.badge) badge.innerHTML = f.badge;
el.title = `${f.who} · ${f.where}`;
el.setAttribute('aria-label', `${f.who}, ${f.where}`);
el.classList.toggle('on', f.online);
el.onclick = (ev) => {
ev.stopPropagation();
on.click(f, el);
};
el.onmouseenter = () => on.hover(f);
el.onmouseleave = () => on.hover(null);
row.push(el);
}
for (const b of keep.values()) leave(b);
if (many) {
if (!more) {
more = E('span', { class: `dl-mk-more${quiet ? '' : ' in'}` });
const m = more;
m.addEventListener('animationend', () => m.classList.remove('in'), { once: true });
}
more.textContent = `+${faces.length - 2}`;
row.push(more);
} else if (more) leave(more);
// In order, moving only what is out of place (moving a node restarts nothing, but costs a reflow).
let prev: Element | null = null;
for (const el of row) {
const want: Element | null = prev ? prev.nextElementSibling : box.firstElementChild;
if (want !== el) {
if (prev) prev.after(el);
else box.prepend(el);
}
prev = el;
}
// FLIP: from where each one was to where it is now.
for (const el of row) {
const x0 = was.get(el);
if (x0 == null) continue;
const dx = x0 - el.getBoundingClientRect().left;
if (Math.abs(dx) < 0.5) continue;
el.style.transition = 'none';
el.style.transform = `translateX(${dx}px)`;
void el.offsetWidth;
el.style.transition = '';
el.style.transform = '';
}
// And the plate's width, from what it was to what it now needs.
box.style.width = '';
const width1 = box.getBoundingClientRect().width;
if (width0 && Math.abs(width1 - width0) > 0.5) {
box.style.width = `${width0}px`;
void box.offsetWidth;
box.style.width = `${width1}px`;
const done = () => {
box.style.width = '';
box.removeEventListener('transitionend', done);
};
box.addEventListener('transitionend', done);
setTimeout(done, 400);
}
}
/** Great-circle distance in km. */
function km(a: [number, number], b: [number, number]): number {
const r = Math.PI / 180;
const h = Math.sin(((b[1] - a[1]) * r) / 2) ** 2 + Math.cos(a[1] * r) * Math.cos(b[1] * r) * Math.sin(((b[0] - a[0]) * r) / 2) ** 2;
return 12742 * Math.asin(Math.min(1, Math.sqrt(h)));
}
function pointer(el: HTMLElement, dx: number, dy: number) { function pointer(el: HTMLElement, dx: number, dy: number) {
let ptr = el.querySelector(':scope > .dl-mk-ptr') as HTMLElement | null; let ptr = el.querySelector(':scope > .dl-mk-ptr') as HTMLElement | null;
const len = Math.hypot(dx, dy); const len = Math.hypot(dx, dy);
+70 -7
View File
@@ -28,6 +28,8 @@
font-size: 9px; font-weight: 600; white-space: nowrap; box-sizing: content-box; } font-size: 9px; font-weight: 600; white-space: nowrap; box-sizing: content-box; }
.dl-mk.online .dl-mk-badge { background: #3b82f6; } .dl-mk.online .dl-mk-badge { background: #3b82f6; }
.dl-mk-badge-ic { width: 10px; height: 10px; stroke-width: 2.2; } .dl-mk-badge-ic { width: 10px; height: 10px; stroke-width: 2.2; }
/* One device: a round badge (two icons or a number stay a pill). */
.dl-mk-badge:has(> svg:only-child) { width: 16px; min-width: 0; padding: 0; }
/* A person's places (their page): rounded tiles without outlines, the live one blue. */ /* A person's places (their page): rounded tiles without outlines, the live one blue. */
.dl-mk-tile { position: relative; width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; .dl-mk-tile { position: relative; width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
background: color-mix(in srgb, var(--dl-fg) 18%, var(--dl-elevated)); color: var(--dl-fg); } background: color-mix(in srgb, var(--dl-fg) 18%, var(--dl-elevated)); color: var(--dl-fg); }
@@ -52,16 +54,77 @@
/* Someone on top of the server: folded into a count on its plate until there is room. */ /* Someone on top of the server: folded into a count on its plate until there is room. */
/* MapLibre writes the marker's own opacity (fading what is behind the globe): ours goes on its parts. */ /* MapLibre writes the marker's own opacity (fading what is behind the globe): ours goes on its parts. */
.dl-mk > * { transition: opacity .15s; opacity: var(--dl-mk-fade, 1); } .dl-mk > * { transition: opacity .15s; opacity: var(--dl-mk-fade, 1); }
.dl-mk.merged { pointer-events: none; } .dl-mk.merged, .dl-mk.piled { pointer-events: none; }
.dl-mk.dl-mk-new > * { transition: none; } .dl-mk.dl-mk-new > * { transition: none; }
.dl-mk.merged > * { opacity: 0; } .dl-mk.merged > *, .dl-mk.piled > * { opacity: 0; }
.dl-mk-hub { cursor: default; } .dl-mk-hub { cursor: default; }
.dl-mk-host { position: relative; } .dl-mk-host { position: relative; }
.dl-mk-host-n { position: absolute; right: -7px; top: -7px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; /* People on top of the server ride in its plate: it slides out to the right of the server (which
border: 2px solid var(--dl-elevated); background: #3b82f6; color: #fff; font-size: 10px; font-weight: 600; line-height: 14px; text-align: center; stays on its spot) with their avatars, and back when they leave. */
opacity: 0; transform: scale(.5); transition: opacity .15s, transform .15s; pointer-events: none; } .dl-mk-host { transition: border-radius .22s ease, border-right-color .22s ease; }
.dl-mk-host-n.on { opacity: 1; transform: none; } .dl-mk-host.docked { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-color: transparent; }
.dl-mk-hub:has(.dl-mk-host-n.on) { cursor: zoom-in; } .dl-mk-dock { position: absolute; left: 100%; top: -1px; height: 40px; box-sizing: border-box; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 2px;
border: 1px solid var(--dl-line); border-left: 0; border-radius: 0 11px 11px 0; background: color-mix(in srgb, var(--dl-elevated) 60%, transparent);
backdrop-filter: blur(6px); box-shadow: 0 6px 16px rgba(0,0,0,.35); pointer-events: none; opacity: 0;
clip-path: inset(-24px 100% -24px 0); transition: clip-path .28s cubic-bezier(.2, .8, .2, 1), opacity .2s ease; }
.dl-mk-host.docked .dl-mk-dock { pointer-events: auto; opacity: 1; clip-path: inset(-24px -24px -24px 0); }
.dl-mk-new .dl-mk-host, .dl-mk-new .dl-mk-dock { transition: none; }
/* People crowding each other (one city, or close at this zoom): one plate on their spot, the city once below. */
.dl-mk-pile { position: relative; display: flex; justify-content: center; }
.dl-mk-pile-box { box-sizing: border-box; height: 40px; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 6px; border-radius: 20px; cursor: zoom-in;
background: color-mix(in srgb, var(--dl-elevated) 60%, transparent); border: 1px solid var(--dl-line); backdrop-filter: blur(6px);
box-shadow: 0 6px 16px rgba(0,0,0,.35); animation: dl-plate-in .26s cubic-bezier(.2, .8, .2, 1) both; transition: opacity .18s ease, transform .18s ease; }
.dl-mk-pile.out { pointer-events: none; }
.dl-mk-pile.out > * { opacity: 0; transform: scale(.85); transition: opacity .18s ease, transform .18s ease; }
@keyframes dl-plate-in { from { opacity: 0; transform: scale(.85); } }
/* An avatar in a plate: a person marker's avatar and device badge, blue while live. */
.dl-mk-face { all: unset; position: relative; display: flex; cursor: pointer; transition: transform .18s ease, opacity .18s ease; }
.dl-mk-face > .dl-mk-badge { position: relative; left: auto; bottom: -8px; margin-left: -12px; align-self: center; }
.dl-mk-face.on .dl-mk-av { border-color: #3b82f6; background: color-mix(in srgb, #3b82f6 22%, var(--dl-elevated)); color: var(--dl-fg); }
.dl-mk-face.on .dl-mk-badge { background: #3b82f6; }
.dl-mk-face:hover .dl-mk-av { box-shadow: 0 0 0 4px rgba(59, 130, 246, .25); }
.dl-mk-face.in { animation: dl-dock-in .24s cubic-bezier(.2, .8, .2, 1) both; }
.dl-mk-face.out { transform: scale(.4); opacity: 0; pointer-events: none; }
@keyframes dl-dock-in { from { transform: scale(.4); opacity: 0; } }
.dl-mk-more { font-size: 11px; font-weight: 600; color: var(--dl-fg-muted); }
/* Leaving a plate for their own spot: the avatar grows in there (and shrinks back on the way in). */
.dl-mk-av, .dl-mk-tile { transition: box-shadow .2s, transform .24s cubic-bezier(.2, .8, .2, 1); }
.dl-mk.merged .dl-mk-av, .dl-mk.merged .dl-mk-tile, .dl-mk.piled .dl-mk-av { transform: scale(.5); }
/* Plates by distance (.dl-lod-* on the map): far out compact, small avatars that overlap and no
device badges (who, not on what); at country level small round badges; full size from a region in. */
.dl-mk-host, .dl-mk-dock, .dl-mk-pile-box { transition-property: border-radius, border-right-color, clip-path, opacity, height, width, padding, gap; }
/* The plate's width glides as avatars come and go (set inline for the move), leaving ones sit over it. */
.dl-mk-dock, .dl-mk-pile-box { transition-duration: .22s; transition-timing-function: cubic-bezier(.2, .8, .2, 1); }
.dl-mk-pile-box { position: relative; }
.dl-mk-more { transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s ease; }
.dl-mk-more.in { animation: dl-dock-in .24s ease both; }
.dl-mk-more.out { transform: scale(.4); opacity: 0; }
.dl-mk-face .dl-mk-av { transition: box-shadow .2s, transform .24s cubic-bezier(.2, .8, .2, 1), width .2s ease, height .2s ease, font-size .2s ease; }
.dl-mk-face { transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s ease, margin .2s ease; }
.dl-mk-face > .dl-mk-badge { max-width: 48px; overflow: hidden;
transition: opacity .2s ease, transform .2s ease, max-width .22s ease, margin .22s ease, padding .22s ease, border-width .22s ease, height .22s ease, min-width .22s ease, width .22s ease, bottom .22s ease; }
.dl-lod-far .dl-mk-host { width: 32px; height: 32px; border-radius: 9px; }
.dl-lod-far .dl-mk-host.docked { border-radius: 9px 0 0 9px; }
.dl-lod-far .dl-mk-host-tile { width: 20px; height: 20px; border-radius: 6px; }
.dl-lod-far .dl-mk-host-ic { width: 11px; height: 11px; }
/* No badges far out: the same 4px round the avatars as above and below them (32 - 2 - 22, halved). */
.dl-lod-far .dl-mk-dock { height: 32px; gap: 0; padding: 0 4px 0 0; border-radius: 0 9px 9px 0; }
.dl-lod-far .dl-mk-pile-box { height: 32px; gap: 0; padding: 0 4px; border-radius: 16px; }
.dl-lod-far .dl-mk-face + .dl-mk-face { margin-left: -6px; }
.dl-lod-far .dl-mk-face .dl-mk-av { width: 22px; height: 22px; font-size: 8px; box-shadow: 0 0 0 2px var(--dl-elevated); }
.dl-lod-far .dl-mk-face > .dl-mk-badge { max-width: 0; min-width: 0; padding: 0; margin-left: 0; border-width: 0; opacity: 0; transform: scale(.5); pointer-events: none; }
.dl-lod-far .dl-mk-more { margin-left: 4px; font-size: 10px; }
/* Place names only from the country level: far out they would crowd the plates. */
.dl-mk-label { transition: opacity .2s ease; }
.dl-lod-far .dl-mk-label { opacity: 0; }
.dl-lod-mid .dl-mk-host { width: 36px; height: 36px; }
.dl-lod-mid .dl-mk-dock, .dl-lod-mid .dl-mk-pile-box { height: 36px; }
.dl-lod-mid .dl-mk-face .dl-mk-av { width: 24px; height: 24px; font-size: 9px; }
.dl-lod-mid .dl-mk-face > .dl-mk-badge { height: 12px; min-width: 12px; margin-left: -10px; bottom: -7px; }
.dl-lod-mid .dl-mk-face > .dl-mk-badge:has(> svg:only-child) { width: 12px; }
.dl-lod-mid .dl-mk-face > .dl-mk-badge .dl-mk-badge-ic { width: 8px; height: 8px; }
@media (prefers-reduced-motion: reduce) { .dl-mk-dock, .dl-mk-pile-box, .dl-mk-face, .dl-mk-av, .dl-mk-tile, .dl-mk-host, .dl-mk-face > .dl-mk-badge { transition: none; animation: none; } }
.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host { cursor: zoom-in; }
/* A marker moved clear of a crowd: a line back to its real spot, and a dot there. */ /* A marker moved clear of a crowd: a line back to its real spot, and a dot there. */
.dl-mk-ptr { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: -1; pointer-events: none; } .dl-mk-ptr { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: -1; pointer-events: none; }
.dl-mk-ptr .line { position: absolute; left: 0; top: -0.5px; height: 1px; background: var(--dl-fg-faint); transform-origin: 0 50%; } .dl-mk-ptr .line { position: absolute; left: 0; top: -0.5px; height: 1px; background: var(--dl-fg-faint); transform-origin: 0 50%; }
+10 -1
View File
@@ -56,13 +56,22 @@
.dl-onl-av { position: relative; width: 42px; height: 42px; border-radius: 50%; background: var(--dl-soft); display: inline-flex; align-items: center; justify-content: center; .dl-onl-av { position: relative; width: 42px; height: 42px; border-radius: 50%; background: var(--dl-soft); display: inline-flex; align-items: center; justify-content: center;
font-size: 13px; font-weight: 500; box-shadow: 0 0 0 2px var(--dl-ok); } font-size: 13px; font-weight: 500; box-shadow: 0 0 0 2px var(--dl-ok); }
.dl-onl-p.more .dl-onl-av { box-shadow: 0 0 0 1px var(--dl-line); color: var(--dl-fg-muted); } .dl-onl-p.more .dl-onl-av { box-shadow: 0 0 0 1px var(--dl-line); color: var(--dl-fg-muted); }
.dl-onl-dev { position: absolute; right: -5px; bottom: -5px; width: 20px; height: 20px; border-radius: 7px; background: var(--dl-card); box-shadow: 0 0 0 1.5px var(--dl-card); /* The device badge cuts into the ring with the tile's colour (a border, so a hover tint can lie over it too). */
.dl-onl-dev { position: absolute; right: -6.5px; bottom: -6.5px; width: 20px; height: 20px; border-radius: 8.5px; border: 1.5px solid transparent; background: var(--dl-card);
display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: var(--dl-fg-muted); } display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: var(--dl-fg-muted); }
.dl-onl-dev .dl-icon-wrap { display: inline-flex; } .dl-onl-dev .dl-icon { width: 12px; height: 12px; } .dl-onl-dev .dl-icon-wrap { display: inline-flex; } .dl-onl-dev .dl-icon { width: 12px; height: 12px; }
.dl-onl-name { font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .dl-onl-name { font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-onl-p .dl-sub { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .dl-onl-p .dl-sub { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-onl-row.grid { flex-wrap: wrap; align-content: center; gap: 10px 8px; max-height: 108px; overflow: hidden; } .dl-onl-row.grid { flex-wrap: wrap; align-content: center; gap: 10px 8px; max-height: 108px; overflow: hidden; }
.dl-onl-p.sm { width: auto; padding: 4px; } .dl-onl-p.sm { width: auto; padding: 4px; }
/* Hovered, the badge takes the same tint as the highlight behind it (no dark square). */
.dl-onl-p:hover .dl-onl-dev { background: linear-gradient(var(--dl-soft), var(--dl-soft)), var(--dl-card); }
/* Small avatars light up with a soft halo round the ring instead: a box would cut the badge off. */
.dl-onl-p.sm:hover { background: none; }
.dl-onl-p.sm:hover .dl-onl-dev { background: var(--dl-card); }
.dl-onl-p.sm .dl-onl-av { transition: box-shadow .15s ease; }
.dl-onl-p.sm:hover .dl-onl-av { box-shadow: 0 0 0 2px var(--dl-ok), 0 0 0 6px var(--dl-soft); }
.dl-onl-p.sm.more:hover .dl-onl-av { box-shadow: 0 0 0 1px var(--dl-line), 0 0 0 6px var(--dl-soft); }
.dl-onl-p.sm .dl-onl-av { width: 36px; height: 36px; font-size: 11.5px; } .dl-onl-p.sm .dl-onl-av { width: 36px; height: 36px; font-size: 11.5px; }
.dl-onl-meta { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--dl-fg-faint); max-width: 100%; white-space: nowrap; overflow: hidden; } .dl-onl-meta { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--dl-fg-faint); max-width: 100%; white-space: nowrap; overflow: hidden; }
.dl-onl-meta .dl-icon-wrap { display: inline-flex; } .dl-onl-meta .dl-icon { width: 12px; height: 12px; } .dl-onl-meta .dl-icon-wrap { display: inline-flex; } .dl-onl-meta .dl-icon { width: 12px; height: 12px; }
+46 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { arc, devicePlaces, separate, type MapData } from '../src/admin/map'; import { arc, cityPlaces, devicePlaces, separate, type MapData } from '../src/admin/map';
describe('arc (mapcn buildArcCoordinates)', () => { describe('arc (mapcn buildArcCoordinates)', () => {
it('runs from one point to the other in 64 steps', () => { it('runs from one point to the other in 64 steps', () => {
@@ -133,3 +133,48 @@ describe('separate', () => {
for (let j = i + 1; j < 3; j++) expect(Math.hypot(same[i][0] - same[j][0], same[i][1] - same[j][1])).toBeGreaterThan(19); for (let j = i + 1; j < 3; j++) expect(Math.hypot(same[i][0] - same[j][0], same[i][1] - same[j][1])).toBeGreaterThan(19);
}); });
}); });
describe('cityPlaces', () => {
const km = (a: [number, number], b: [number, number]) => {
const r = Math.PI / 180;
const h = Math.sin(((b[1] - a[1]) * r) / 2) ** 2 + Math.cos(a[1] * r) * Math.cos(b[1] * r) * Math.sin(((b[0] - a[0]) * r) / 2) ** 2;
return 12742 * Math.asin(Math.sqrt(h));
};
const krd = { lat: 45.0355, lon: 38.9753 };
const msk = { lat: 55.7558, lon: 37.6173 };
it('gives someone alone in their city a spot of their own in it, the same every time', () => {
const a = cityPlaces([{ key: 'a', ...krd }], msk).get('a')!;
const d = km(a, [krd.lon, krd.lat]);
expect(d).toBeGreaterThan(1.4);
expect(d).toBeLessThan(5.1);
expect(
cityPlaces(
[
{ key: 'a', ...krd },
{ key: 'b', ...krd },
],
msk,
).get('a'),
).toEqual(a);
});
it('spreads people sharing a city, apart enough to part at zoom 12', () => {
const keys = ['a', 'b', 'c', 'd', 'e'];
const at = cityPlaces(
keys.map((key) => ({ key, ...krd })),
msk,
);
const pts = keys.map((k) => at.get(k)!);
for (let i = 0; i < pts.length; i++) {
expect(km(pts[i], [krd.lon, krd.lat])).toBeLessThan(6);
for (let j = i + 1; j < pts.length; j++) expect(km(pts[i], pts[j])).toBeGreaterThan(1.25);
}
});
it('moves anyone in the server’s city off its centre, the same way every time', () => {
const a = cityPlaces([{ key: 'a', ...msk }], msk).get('a')!;
expect(km(a, [msk.lon, msk.lat])).toBeGreaterThan(2.4);
expect(cityPlaces([{ key: 'a', ...msk }], msk).get('a')).toEqual(a);
});
});