diff --git a/package/luci-app-dawnline/Makefile b/package/luci-app-dawnline/Makefile index c5c6d12..f1ec519 100644 --- a/package/luci-app-dawnline/Makefile +++ b/package/luci-app-dawnline/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-dawnline -PKG_VERSION:=0.8.0 +PKG_VERSION:=0.8.1 PKG_RELEASE:=1 PKG_LICENSE:=MIT diff --git a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js index 8e1da82..344994c 100644 --- a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js +++ b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js @@ -5,25 +5,25 @@ 'require poll'; 'require rpc'; 'require ui'; -var Va=Object.create;var Eo=Object.defineProperty;var Ya=Object.getOwnPropertyDescriptor;var Za=Object.getOwnPropertyNames;var Qa=Object.getPrototypeOf,Xa=Object.prototype.hasOwnProperty;var ei=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var ti=(n,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Za(e))!Xa.call(n,a)&&a!==o&&Eo(n,a,{get:()=>e[a],enumerable:!(r=Ya(e,a))||r.enumerable});return n};var ni=(n,e,o)=>(o=n!=null?Va(Qa(n)):{},ti(e||!n||!n.__esModule?Eo(o,"default",{value:n,enumerable:!0}):o,n));var Qo=ei((Yo,Zo)=>{"use strict";var Vo=(function(){var n=function(x,v){var $=236,E=17,y=x,z=o[v],h=null,f=0,T=null,S=[],N={},G=function(P,D){f=y*4+17,h=(function(_){for(var B=new Array(_),M=0;M<_;M+=1){B[M]=new Array(_);for(var j=0;j<_;j+=1)B[M][j]=null}return B})(f),q(0,0),q(f-7,0),q(0,f-7),J(),R(),le(P,D),y>=7&&Q(P),T==null&&(T=ne(y,z,S)),he(T,D)},q=function(P,D){for(var _=-1;_<=7;_+=1)if(!(P+_<=-1||f<=P+_))for(var B=-1;B<=7;B+=1)D+B<=-1||f<=D+B||(0<=_&&_<=6&&(B==0||B==6)||0<=B&&B<=6&&(_==0||_==6)||2<=_&&_<=4&&2<=B&&B<=4?h[P+_][D+B]=!0:h[P+_][D+B]=!1)},V=function(){for(var P=0,D=0,_=0;_<8;_+=1){G(!0,_);var B=a.getLostPoint(N);(_==0||P>B)&&(P=B,D=_)}return D},R=function(){for(var P=8;P>_&1)==1;h[Math.floor(_/3)][_%3+f-8-3]=B}for(var _=0;_<18;_+=1){var B=!P&&(D>>_&1)==1;h[_%3+f-8-3][Math.floor(_/3)]=B}},le=function(P,D){for(var _=z<<3|D,B=a.getBCHTypeInfo(_),M=0;M<15;M+=1){var j=!P&&(B>>M&1)==1;M<6?h[M][8]=j:M<8?h[M+1][8]=j:h[f-15+M][8]=j}for(var M=0;M<15;M+=1){var j=!P&&(B>>M&1)==1;M<8?h[8][f-M-1]=j:M<9?h[8][15-M-1+1]=j:h[8][15-M-1]=j}h[f-8][8]=!P},he=function(P,D){for(var _=-1,B=f-1,M=7,j=0,Z=a.getMaskFunction(D),Y=f-1;Y>0;Y-=2)for(Y==6&&(Y-=1);;){for(var ce=0;ce<2;ce+=1)if(h[B][Y-ce]==null){var xe=!1;j>>M&1)==1);var ee=Z(B,Y-ce);ee&&(xe=!xe),h[B][Y-ce]=xe,M-=1,M==-1&&(j+=1,M=7)}if(B+=_,B<0||f<=B){B-=_,_=-_;break}}},ue=function(P,D){for(var _=0,B=0,M=0,j=new Array(D.length),Z=new Array(D.length),Y=0;Y=0?ko.getAt($o):0}}for(var Co=0,ee=0;eeY*8)throw"code length overflow. ("+M.getLengthInBits()+">"+Y*8+")";for(M.getLengthInBits()+4<=Y*8&&M.put(0,4);M.getLengthInBits()%8!=0;)M.putBit(!1);for(;!(M.getLengthInBits()>=Y*8||(M.put($,8),M.getLengthInBits()>=Y*8));)M.put(E,8);return ue(M,B)};N.addData=function(P,D){D=D||"Byte";var _=null;switch(D){case"Numeric":_=d(P);break;case"Alphanumeric":_=p(P);break;case"Byte":_=u(P);break;case"Kanji":_=w(P);break;default:throw"mode:"+D}S.push(_),T=null},N.isDark=function(P,D){if(P<0||f<=P||D<0||f<=D)throw P+","+D;return h[P][D]},N.getModuleCount=function(){return f},N.make=function(){if(y<1){for(var P=1;P<40;P++){for(var D=l.getRSBlocks(P,z),_=c(),B=0;B"u"?P*4:D;var _="";_+='";for(var M=0;M';_+=""}return _+="",_+="
",_},N.createSvgTag=function(P,D,_,B){var M={};typeof arguments[0]=="object"&&(M=arguments[0],P=M.cellSize,D=M.margin,_=M.alt,B=M.title),P=P||2,D=typeof D>"u"?P*4:D,_=typeof _=="string"?{text:_}:_||{},_.text=_.text||null,_.id=_.text?_.id||"qrcode-description":null,B=typeof B=="string"?{text:B}:B||{},B.text=B.text||null,B.id=B.text?B.id||"qrcode-title":null;var j=N.getModuleCount()*P+D*2,Z,Y,ce,xe,ee="",De;for(De="l"+P+",0 0,"+P+" -"+P+",0 0,-"+P+"z ",ee+=''+O(B.text)+"":"",ee+=_.text?''+O(_.text)+"":"",ee+='',ee+='"u"?P*4:D;var _=N.getModuleCount()*P+D*2,B=D,M=_-D;return I(_,_,function(j,Z){if(B<=j&&j"u"?P*4:D;var B=N.getModuleCount()*P+D*2,M="";return M+="",M};var O=function(P){for(var D="",_=0;_":D+=">";break;case"&":D+="&";break;case'"':D+=""";break;default:D+=B;break}}return D},F=function(P){var D=1;P=typeof P>"u"?D*2:P;var _=N.getModuleCount()*D+P*2,B=P,M=_-P,j,Z,Y,ce,xe,ee={"██":"█","█ ":"▀"," █":"▄"," ":" "},De={"██":"▀","█ ":"▀"," █":" "," ":" "},Ae="";for(j=0;j<_;j+=2){for(Y=Math.floor((j-B)/D),ce=Math.floor((j+1-B)/D),Z=0;Z<_;Z+=1)xe="█",B<=Z&&Z=M?De[xe]:ee[xe];Ae+=` -`}return _%2&&P>0?Ae.substring(0,Ae.length-_-1)+Array(_+1).join("▀"):Ae.substring(0,Ae.length-1)};return N.createASCII=function(P,D){if(P=P||1,P<2)return F(D);P-=1,D=typeof D>"u"?P*2:D;var _=N.getModuleCount()*P+D*2,B=D,M=_-D,j,Z,Y,ce,xe=Array(P+1).join("██"),ee=Array(P+1).join(" "),De="",Ae="";for(j=0;j<_;j+=1){for(Y=Math.floor((j-B)/P),Ae="",Z=0;Z<_;Z+=1)ce=1,B<=Z&&Z>>8),z.push(T&255)):z.push(E)}}return z}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},r={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},a=(function(){var x=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],v=1335,$=7973,E=21522,y={},z=function(h){for(var f=0;h!=0;)f+=1,h>>>=1;return f};return y.getBCHTypeInfo=function(h){for(var f=h<<10;z(f)-z(v)>=0;)f^=v<=0;)f^=$<5&&(T+=3+G-5)}for(var S=0;S=256;)y-=255;return x[y]},E})();function s(x,v){if(typeof x.length>"u")throw x.length+"/"+v;var $=(function(){for(var y=0;y"u")throw"bad rs block @ typeNumber:"+y+"/errorCorrectionLevel:"+z;for(var f=h.length/3,T=[],S=0;S>>7-E%8&1)==1},$.put=function(E,y){for(var z=0;z>>y-z-1&1)==1)},$.getLengthInBits=function(){return v},$.putBit=function(E){var y=Math.floor(v/8);x.length<=y&&x.push(0),E&&(x[y]|=128>>>v%8),v+=1},$},d=function(x){var v=e.MODE_NUMBER,$=x,E={};E.getMode=function(){return v},E.getLength=function(h){return $.length},E.write=function(h){for(var f=$,T=0;T+2>>8&255)*192+(S&255),h.put(S,13),T+=2}if(T>>8)},v.writeBytes=function($,E,y){E=E||0,y=y||$.length;for(var z=0;z0&&($+=","),$+=x[E];return $+="]",$},v},g=function(){var x=0,v=0,$=0,E="",y={},z=function(f){E+=String.fromCharCode(h(f&63))},h=function(f){if(!(f<0)){if(f<26)return 65+f;if(f<52)return 97+(f-26);if(f<62)return 48+(f-52);if(f==62)return 43;if(f==63)return 47}throw"n:"+f};return y.writeByte=function(f){for(x=x<<8|f&255,v+=8,$+=1;v>=6;)z(x>>>v-6),v-=6},y.flush=function(){if(v>0&&(z(x<<6-v),x=0,v=0),$%3!=0)for(var f=3-$%3,T=0;T=v.length){if(y==0)return-1;throw"unexpected end of file./"+y}var f=v.charAt($);if($+=1,f=="=")return y=0,-1;if(f.match(/^\s$/))continue;E=E<<6|h(f.charCodeAt(0)),y+=6}var T=E>>>y-8&255;return y-=8,T};var h=function(f){if(65<=f&&f<=90)return f-65;if(97<=f&&f<=122)return f-97+26;if(48<=f&&f<=57)return f-48+52;if(f==43)return 62;if(f==47)return 63;throw"c:"+f};return z},k=function(x,v){var $=x,E=v,y=new Array(x*v),z={};z.setPixel=function(S,N,G){y[N*$+S]=G},z.write=function(S){S.writeString("GIF87a"),S.writeShort($),S.writeShort(E),S.writeByte(128),S.writeByte(0),S.writeByte(0),S.writeByte(0),S.writeByte(0),S.writeByte(0),S.writeByte(255),S.writeByte(255),S.writeByte(255),S.writeString(","),S.writeShort(0),S.writeShort(0),S.writeShort($),S.writeShort(E),S.writeByte(0);var N=2,G=f(N);S.writeByte(N);for(var q=0;G.length-q>255;)S.writeByte(255),S.writeBytes(G,q,255),q+=255;S.writeByte(G.length-q),S.writeBytes(G,q,G.length-q),S.writeByte(0),S.writeString(";")};var h=function(S){var N=S,G=0,q=0,V={};return V.write=function(R,J){if(R>>>J)throw"length over";for(;G+J>=8;)N.writeByte(255&(R<>>=8-G,q=0,G=0;q=R<0&&N.writeByte(q)},V},f=function(S){for(var N=1<>6,128|i&63):i<55296||i>=57344?r.push(224|i>>12,128|i>>6&63,128|i&63):(a++,i=65536+((i&1023)<<10|o.charCodeAt(a)&1023),r.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return r}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof Yo=="object"&&(Zo.exports=n())})(function(){return Vo})});function jn(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>jn(o,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,o){let r=window.E,a=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!a&&o===void 0?r(n,{},jn(e,[])):r(n,a?e:{},jn(o,[]))}var Lo={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function At(n,e="dl-icon"){let o=Lo[n]??Lo.phone;return``}function b(n,e="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=At(n,e),o}function U(n,e="info",o=0){let r=document.querySelector(".dl-toasts");r||(r=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(r));let a=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=t("div",{class:`dl-toast ${e}`},[a?b(a):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":"Close",click:i},b("x")):""]);r.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,o||(e==="error"?8e3:e==="warning"?5e3:2600))}function be(n){return n instanceof Error?n.message:String(n)}async function W(n,e){try{let o=await n();return e&&U(e,"success",3500),o}catch(o){U(be(o),"error",1e4);return}}function Mo(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(o=>U(be(o),"error"))}catch(e){U(be(e),"error")}}function To(n){if(n&&typeof n=="object"){if(typeof n.error=="string")throw new Error(n.error);typeof n.warning=="string"&&n.warning&&U(n.warning,"warning",12e3)}return n}function K(n,e=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:e});return async(...r)=>To(await o(...r))}var oi=K("logs_clear",["person","device","category","older_days"]),ri=(n={})=>oi(n.person??"",n.device??"",n.category??"",n.older_days??""),ai=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets","server"]});async function ii(n,e){let r=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(a=>e[a]),e.paused,e.services,e.circle,e.home_nets,e.server];return To(await ai(...r))}var si=K("status",["days"]),A={rev:K("rev"),personUpdate:ii,settingsGet:K("settings_get"),portalInfo:K("portal_info"),settingsUpdate:K("settings_update",["values"]),serviceSet:K("service_set",["id","name","address","ports"]),serviceDelete:K("service_delete",["id"]),geoClear:K("geo_clear"),events:K("events",["limit","person","since"]),logsClear:ri,interfaces:K("interfaces",["id"]),serverInterfaces:K("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:K("circle_set",["id","server","name","color","members"]),circleDelete:K("circle_delete",["id"]),accessCheck:K("access_check",["from","to"]),homeHosts:K("home_hosts",["id"]),usageClear:K("usage_clear",["scope","id"]),uninstall:K("uninstall",["confirm"]),status:si,setupDefaults:K("setup_defaults"),serverCreate:K("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:K("server_obfuscation",["id","preset"]),serverUpdate:K("server_update",["id","values"]),serverPorts:K("server_ports",["id"]),endpointProbe:K("endpoint_probe",["host","id","port"]),serverDelete:K("server_delete",["id"]),personLinks:K("person_links",["id"]),personCreate:K("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:K("person_pause",["id","paused"]),personRegen:K("person_regen",["id","remove"]),personDelete:K("person_delete",["id"]),personUsage:K("person_usage",["id","days"]),deviceCreate:K("device_create",["person","name","kind"]),deviceConfig:K("device_config",["id"]),deviceUpdate:K("device_update",["id","name","disabled"]),deviceDelete:K("device_delete",["id"]),deviceRotate:K("device_rotate",["id"]),apply:K("apply"),health:K("health"),healthFix:K("health_fix",["id"]),serviceLog:K("service_log"),serviceLogClear:K("service_log_clear",["older_days"]),backupList:K("backup_list"),backupCreate:K("backup_create"),backupRestore:K("backup_restore",["name"]),backupDelete:K("backup_delete",["name"]),backupRead:K("backup_read",["name"]),backupUpload:K("backup_upload",["data"]),exportJson:K("export"),importJson:K("import",["data"]),updatesStatus:K("updates_status"),updatesRun:K("updates_run",["what"]),updatesReleases:K("updates_releases",["page"]),updatesNotes:K("updates_notes",["component","tag","build"]),updatesChanges:K("updates_changes",["from","to"])};function H(n,e,o="neutral",r={}){let{disabled:a,...i}=r,s=t("button",{class:`cbi-button cbi-button-${o}`,type:"button",...i,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!s.disabled){s.disabled=!0,s.classList.add("spinning");try{await e(l)}catch(c){U(be(c),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!a,s}function Le(n,e,o,r="neutral",a=""){return H([b(n),t("span",{class:"dl-btn-label"},e)],o,r,{title:e,class:`cbi-button cbi-button-${r} dl-icon-btn ${a}`.trim()})}function $e(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var ht=null;function Un(n=!1){let e=ht;ht=null,e?.(n)}function te(n,e,o,r=""){Un();let a=t("div",{class:`dl-modal ${r}`},e),i=t("div",{class:"button-row"},o);a.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),oe();return}if(s.key!=="Enter"||s.shiftKey||s.ctrlKey||s.metaKey||s.altKey)return;let l=s.target;if(!l||["TEXTAREA","BUTTON","SELECT","A"].includes(l.tagName))return;let c=i.querySelector(".cbi-button-positive");!c||c.disabled||(s.preventDefault(),c.click())}),ui.showModal(n,[a,i])}function oe(){Un(),ui.hideModal()}function ae(n="Cancel",e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:oe},n)}function se(n,e,o="Confirm",r=!1){return new Promise(a=>{te(n,e,[ae()," ",t("button",{class:`cbi-button ${r?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=ht;ht=null,ui.hideModal(),i?.(!0)}},o)]),ht=a})}$e(()=>{ht&&(Un(),ui.hideModal())});async function pe(n,e="Copied to clipboard",o=!1){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let r=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(r),r.select();let a=document.execCommand("copy");if(r.remove(),!a)throw new Error("Copying is blocked here. Select the text and copy it by hand.")}return U(e,"success",2500),!0}catch(r){return o||U(be(r),"error"),!1}}function Se(n,e,o="text/plain"){let r=globalThis,a=typeof e=="string"?new r.Blob([e],{type:o}):e,i=URL.createObjectURL(a),s=t("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function Wn(n,e){return new Promise(o=>{let r=t("input",{type:"file",accept:n,style:"display:none"});r.addEventListener("cancel",()=>{r.remove(),o(null)}),r.addEventListener("change",()=>{let a=r.files?.[0];if(r.remove(),!a)return o(null);let i=new FileReader;i.onload=()=>{let s=String(i.result??"");o({name:a.name,data:e==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>o(null),e==="base64"?i.readAsDataURL(a):i.readAsText(a)}),document.body.appendChild(r),r.click()})}function Ce(n,e){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let r=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),Mo(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(r);let a=n.getBoundingClientRect(),i=r.offsetWidth,s=r.offsetHeight;r.style.top=`${a.bottom+6+s>window.innerHeight-8&&a.top-6-s>8?a.top-6-s:a.bottom+6}px`,r.style.left=`${Math.max(8,Math.min(a.right-i,window.innerWidth-i-8))}px`;let l=u=>{!r.contains(u.target)&&!n.contains(u.target)&&p()},c=u=>{if(u.key==="Escape"||u.key==="Tab")return p();let w=[...r.querySelectorAll("button:not([disabled])")];if(!w.length||!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;u.preventDefault();let C=w.indexOf(document.activeElement),g=u.key==="Home"?0:u.key==="End"?w.length-1:u.key==="ArrowDown"?(C+1)%w.length:(C-1+w.length)%w.length;w[g].focus({preventScroll:!0})},d=$e(p);r.dlAnchor=n,r.dlClose=p;function p(){r.remove(),d(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",c,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",c,!0),window.addEventListener("scroll",p,!0)}),r.querySelector("button")?.focus({preventScroll:!0})}var lt=null,Je=null,Gn=0;function ft(){lt&&(lt.style.display="none"),Je=null,clearInterval(Gn),Gn=0}function me(n,e){let o=r=>{lt??(lt=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),lt.replaceChildren(...e().map(a=>typeof a=="string"?document.createTextNode(a):a)),lt.style.display="",lt.style.left=`${r.clientX}px`,lt.style.top=`${r.clientY-10}px`,Je=n,Gn||(Gn=window.setInterval(()=>{(!Je?.isConnected||!Je.getClientRects().length)&&ft()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",ft),n.addEventListener("pointerup",r=>{r.pointerType!=="mouse"&&(Je===n?ft():o(r))})}$e(ft);window.addEventListener("scroll",()=>Je&&ft(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{Je&&!Je.contains(n.target)&&ft()},!0);function X(n){if(!n||n<0)return"0 B";let e=["B","KB","MB","GB","TB"],o=0,r=n;for(;r>=1024&&o=100||o===0?Math.round(r):r.toFixed(1)} ${e[o]}`}function Oe(n){let e=n*8;return e<1e3?`${Math.round(e)} bit/s`:e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)} kbit/s`:e<1e9?`${(e/1e6).toFixed(e<1e7?1:0)} Mbit/s`:`${(e/1e9).toFixed(1)} Gbit/s`}function re(n,e=Date.now()/1e3){if(!n)return"never";let o=Math.max(0,Math.round(e-n));return o<60?"just now":o<3600?`${Math.floor(o/60)} min ago`:o<86400?`${Math.floor(o/3600)} h ago`:o<86400*30?`${Math.floor(o/86400)} d ago`:new Date(n*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function vt(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),o=Math.floor(n%86400/3600),r=Math.floor(n%3600/60);return e?`${e}d ${o}h`:o?`${o}h ${r}m`:`${r}m`}function zt(n){let e=new Date(n*1e3),o=new Date,r=e.toDateString()===o.toDateString(),a=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return r?a:`${e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${a}`}function je(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function bt(n){let[e,o,r]=n.split("-").map(Number);return new Date(e,(o||1)-1,r||1,12)}function Ue(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?bt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Me(n){return n?Ue(n):""}function Fn(n,e){let o=r=>{let[a,i,s]=r.split("-").map(Number);return Date.UTC(a,i-1,s)};return Math.round((o(n)-o(e))/864e5)}function Ht(n,e){let o=bt(n);return o.setDate(o.getDate()+e),je(o)}function gt(n,e){let[o,r,a]=n.split("-").map(Number),i=new Date(o,r-1+e,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(a,s)),je(i)}function Ie(n){return n?.length?n[n.length-1].day:je(new Date)}function So(n,e,o,r,a=30){let i=n||r;return e==="day"?Ht(i,o):e==="week"?Ht(i,7*o):e==="month"?gt(i,o):e==="year"?gt(i,12*o):Ht(i,a*o)}function Ve(n,e=Date.now()){if(!n)return null;let o=typeof e=="number"?je(new Date(e)):e,r=Fn(n,o);return r>=0?r+1:r}function Ye(n,e){return e!=null&&e>0&&n.expire_warn>0&&e<=n.expire_warn}function Xt(n){return n<=1?"ends today":n===2?"ends tomorrow":`ends in ${n} days`}function en(n,e,o=`${e}s`){return`${n.toLocaleString("en-GB")} ${n===1?e:o}`}function Nt(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var dt={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var _o=["computer","phone","tablet","router","other"],Ze={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Po={active:"Active",paused:"Paused",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server",server_off:"Server is turned off"};function He(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let o=e[0][0]??"",r=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(o+r).toUpperCase()}function tn(n){let e=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,r)=>[o,r]).sort((o,r)=>e(o[0])-e(r[0])||o[1]-r[1]).map(([o])=>o)}function Ee(n,e,o){return t("span",{class:`dl-pill ${n}`,title:o??null},e)}function li(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function di(n){return n.state==="server_off"&&n.paused?"paused":n.state}function Do(n){let e=di(n);return e==="active"||e==="server_off"?"":Ee(li({...n,state:e}),Po[e])}function Ao(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=t("span",{class:"dl-access","aria-label":dt[n.access]},e.map(r=>t("span",{class:`dl-ibadge ${r}`},b(r==="lan"?"home":"globe"))));return me(o,()=>[t("div",{class:"dl-tip-title"},dt[n.access]),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),o}var ci={paused:"Paused",expired:"Access ended",quota:"Data limit",hours:"Outside hours",server_off:"Server off",no_server:"No server"};function nn(n,e,o="Not set up yet",r){let a=n.handshake?`Last seen ${re(n.handshake,e)} · ${new Date(n.handshake*1e3).toLocaleString()}`:"";if(n.disabled)return t("span",{class:"dl-dstat",title:a},"Disabled");if(n.online)return t("span",{class:"dl-dstat ok"},"Connected");let i=r&&ci[r.state];return i?t("span",{class:"dl-dstat warn",title:a||"Not connected yet"},i):n.handshake?t("span",{class:"dl-dstat",title:new Date(n.handshake*1e3).toLocaleString()},`Last seen ${re(n.handshake,e)}`):t("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},o)}var on=null;function Ho(n,e,o,r){on?.close();let a=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>d()},b("x"))]),t("div",{class:"dl-drawer-body"},e),o?t("div",{class:"dl-drawer-foot"},o):""]),i=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===i&&d()}},a),s=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&d()},l=!1,c=$e(()=>d());function d(){l||(l=!0,c(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),on===p&&(on=null),r())}let p={close:d,panel:a};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),on=p,p}function de(n,e,o){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),o?t("span",{class:"dl-sub"},o):""]),t("div",{class:"dl-setrow-ctl"},e)])}function fe(n,e,o,r=e){let a=de(n,r," "),i=a.querySelector(".dl-sub"),s=()=>{let l=o();i.textContent=l.text,i.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),a.refresh=s,a.help=o,s(),a}function ye(n,e,o,r=e){let a=t("div",{class:"dl-sub"}),i=t("div",{class:"cbi-value dl-live"},[t("div",{class:"cbi-value-title"},[t("label",{},n),a]),t("div",{class:"cbi-value-field"},r)]),s=()=>{let l=o();a.textContent=l.text,a.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),e.addEventListener("change",s),i.refresh=s,i.help=o,s(),i}function ze(n,e=[]){for(let o of n){let r=o.help?.();if(r?.bad)return r.text}for(let o of e){let r=o();if(r.bad)return r.text}return null}function Rt(n,e,o,r=""){return t("section",{class:`dl-setsec ${r}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function ge(n,e,o,r){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},b(n)),t("span",{class:"dl-stack"},[t("b",{},e),o?t("span",{class:"dl-sub"},o):""])]),t("div",{class:"dl-group-body"},r.filter(a=>a!==""))])}function Qe(n,e,o,r,a){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},b(n)):b(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-sub"},r)]),a])}function ct(n,e){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${o}`},e)}function Xe(n,e=""){let o=t("div",{class:e});return o.innerHTML=n,o}function qn(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[o,r,a,i]=e.slice(1,5).map(Number),s=Number(e[5]);if([o,r,a,i].some(d=>d>255)||s<8||s>30)return null;let l=o*2**24+r*2**16+a*2**8+i,c=2**(32-s);return{net:l-l%c,size:c}}var pi=(n,e)=>n.netqn(n));function yt(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function rn(n){return`${n.trim()}.0/24`}function Jn(n,e,o){let r=n.trim(),a=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(r)?qn(rn(r)):null;if(!a)return{text:"Three numbers, like 10.77.0.",bad:!0};if(!mi.some(s=>a.net>=s.net&&a.net+a.size<=s.net+s.size))return{text:"Use a private range: 10.x.x, 172.16–31.x or 192.168.x.",bad:!0};let i=e.find(s=>{let l=qn(s.cidr);return l!=null&&pi(a,l)});if(i){let s=i.cidr.endsWith("/24")?`${yt(i.cidr)}.x`:i.cidr,l=o&&o!==r?` Try ${o}.`:"";return{text:`${i.name} already uses ${s}.${l}`,bad:!0}}return{text:`Devices get ${r}.2 – ${r}.254, the router ${r}.1.`,bad:!1}}var No=(n,e)=>e.find(o=>o.from<=n&&n<=o.to)?.who??null,hi=n=>Number.isInteger(n)&&n>=1&&n<=65535;function It(n,e,o){if(!hi(n))return{text:"Use a port from 1 to 65535.",bad:!0};let r=No(n,e);return r?{text:`Used by ${r}. Choose another port.`,bad:!0}:{text:o,bad:!1}}function an(n,e,o){let r=o?`HTTPS here, plain HTTP for links on IP addresses on ${n+1}.`:"HTTPS on this port, opened on WAN.",a=It(n,e,r);if(a.bad||!o)return a;if(n===65535)return{text:"Links on IP addresses also need the next port: choose a lower one.",bad:!0};let i=No(n+1,e);return i?{text:`Links on IP addresses also need ${n+1}, used by ${i}. Choose another port.`,bad:!0}:a}var xt=n=>Array.from(n).length,zo=48,fi=/[<>"\\\u0000-\u001f\u007f]/;function _e(n,e=[],o=""){let r=n.trim();return r?xt(n)>zo?{text:`Up to ${zo} characters (${xt(n)} now).`,bad:!0}:fi.test(n)?{text:'Names can’t contain < > " or \\.',bad:!0}:e.some(a=>a.toLowerCase()===r.toLowerCase())?{text:`“${r}” already exists — pick another name.`,bad:!0}:{text:o,bad:!1}:{text:"Enter a name.",bad:!0}}function Ro(n,e=[]){return xt(n)>32?{text:`Up to 32 characters (${xt(n)} now).`,bad:!0}:_e(n,e,"Shown on the person cards.")}var gi=/^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,vi=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function kt(n){let e=vi.exec(n);return!!e&&e.slice(1).every(o=>Number(o)<=255)}function Kn(n){return/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(n)&&!/:::/.test(n)}function wt(n,e,o=null){let r=n.trim();if(!r)return o!=null?{text:o,bad:!1}:{text:"Enter a hostname or IP address.",bad:!0};if(/^[a-z]+:\/\//i.test(r))return{text:"Leave out https:// — just the name.",bad:!0};if(/\/.*/.test(r))return{text:"Just the name, without a path.",bad:!0};if(/^[^:\[]+:\d+$/.test(r))return{text:"Just the name, without a port (the port is on AmneziaWG).",bad:!0};if(/\s/.test(r))return{text:"A hostname has no spaces.",bad:!0};if(r.length>253||!(gi.test(r)||kt(r)||Kn(r)))return{text:"Use a hostname or an IP address.",bad:!0};let a=Kn(r)?`[${r}]`:r;return{text:e?`Devices connect to ${a}:${e}.`:`Links use ${a}.`,bad:!1}}function Io(n,e){let o=n.split(/[ ,]+/).filter(Boolean);if(!o.length)return{text:`This router (${e}): queries go where your home network sends them, and home names work.`,bad:!1};let r=o.find(a=>!kt(a)&&!Kn(a));return r?{text:`“${r}” is not an IP address. Separate several with commas.`,bad:!0}:{text:`Devices use ${o.join(" and ")} — home names and your LAN’s DNS filters no longer apply to them.`,bad:!1}}function Bo(n,e){let o=n.trim();if(!o)return{text:`Automatic by device type and disguise: ${e.computer} for computers and routers, ${e.phone} for phones and tablets.`,bad:!1};if(!/^\d{1,4}$/.test(o)||Number(o)<1280||Number(o)>1500)return{text:"MTU must be 1280–1500, or empty for automatic.",bad:!0};let r=Number(o);return{text:`Computers and routers get ${r}, phones and tablets ${Math.min(r,1280)}.`,bad:!1}}function Oo(n){let e=n.trim();return e?!/^\d{1,3}$/.test(e)||Number(e)>600?{text:"Use 0–600 seconds.",bad:!0}:Number(e)===0?{text:"Off: NAT may close the tunnel when idle, and “Connected” lags.",bad:!1}:{text:`Devices send a packet every ${e} s to keep NAT open (a little battery on phones).`,bad:!1}:{text:"Default: a packet every 25 s keeps NAT open and “Connected” accurate.",bad:!1}}function sn(n,e=0){let o=n.trim();if(!/^\d{1,2}$/.test(o)||Number(o)<1||Number(o)>32)return{text:"Use 1–32.",bad:!0};let r=Number(o);return e>r?{text:`Already has ${e} devices: remove ${e-r===1?"one":`${e-r}`} first, or allow more.`,bad:!0}:{text:`They can add ${r} device${r===1?"":"s"} themselves.`,bad:!1}}function ln(n,e=!0){let o=n.trim();if(!o)return{text:"Optional. No data limit.",bad:!1};let r=Number(o);return!/^\d+(\.\d+)?$/.test(o)||r<0||r>1e5?{text:"A number of GB, up to 100000.",bad:!0}:r===0?{text:"Optional. No data limit.",bad:!1}:{text:e?`Paused after ${o} GB this month, resumed on the 1st.`:`Paused after ${o} GB in total.`,bad:!1}}function jo(n,e,o,r){let a=n.trim();if(!a)return{text:"Optional. No end date.",bad:!1};let i=o(a,e);return i==null?{text:"Use a date.",bad:!0}:i<0?{text:"That date has passed: access would end at once.",bad:!0}:{text:i===1?`Access ends today (${r(a)}).`:`Access ends in ${i} days (${r(a)}).`,bad:!1}}function Uo(n,e=null){let o=n.trim();return o?kt(o)?e&&!e(o)?{text:`${o} is not in any home network of this server: nobody would reach it.`,bad:!1}:{text:"",bad:!1}:{text:"Use an IPv4 address, like 192.168.1.10.",bad:!0}:{text:"The device’s address at home.",bad:!0}}function Wo(n){let e=n.split(/[ ,]+/).filter(Boolean);if(!e.length)return{text:"All ports.",bad:!1};let o=e.find(r=>!/^\d{1,5}$/.test(r)||Number(r)<1||Number(r)>65535);return o?{text:`“${o}” is not a port (1–65535).`,bad:!0}:{text:`Port${e.length===1?"":"s"} ${e.join(", ")}.`,bad:!1}}function Go(n){let e=n.trim();return e?/^https?:\/\//i.test(e)?e.length>300||!/^https?:\/\/[A-Za-z0-9.-]+(:[0-9]+)?(\/[^\s"'<>]*)?$/.test(e)?{text:"Not a usable address (no spaces or quotes).",bad:!0}:{text:"Wrong links are sent there instead of a “Not found”.",bad:!1}:{text:"Must start with http:// or https://.",bad:!0}:{text:"Wrong links get a bare “Not found”.",bad:!1}}function Fo(n){return xt(n)>64?{text:`Up to 64 characters (${xt(n)} now).`,bad:!0}:/[\u0000-\u001f\u007f]/.test(n)?{text:"One line, please.",bad:!0}:{text:"Shown in the browser tab and at the top of the portal.",bad:!1}}function qo(n,e="phone.myata"){let o=n.trim();return o?/^[a-z0-9-]{1,32}(\.[a-z0-9-]{1,32})*$/.test(o)?{text:`Devices get names like ${e}.${o}.`,bad:!1}:{text:/[A-Z]/.test(o)?"Lowercase only.":"Lowercase letters, digits, dashes and dots.",bad:!0}:{text:`The default, lan: devices get names like ${e}.lan.`,bad:!1}}function Ko(n){let e=n.trim();return e?kt(e)?{text:`${e} takes over when the tunnel is down.`,bad:!1}:{text:"Use an IPv4 address, or leave it empty.",bad:!0}:{text:"None: without the tunnel those devices have no DNS.",bad:!1}}function Jo(n){let e=n.trim();return/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{text:`Runs within an hour after ${e} (router time).`,bad:!1}:{text:"Use HH:MM, 00:00–23:59.",bad:!0}}function Vn(n,e,o,r={}){let a=0,i="",s=null;return{help:()=>{let{host:d,port:p}=n(),u=wt(d,p,r.empty??null);if(u.bad||!d.trim())return u;if(s&&s.host===d.trim())return{text:s.text,bad:s.bad};let w=r.idle?.();return{text:w?`${w} Checking where it points…`:`${u.text} Checking where it points…`,bad:!1}},schedule:()=>{let{host:d}=n(),p=wt(d,n().port,r.empty??null);p.bad||!d.trim()||d.trim()===s?.host||(clearTimeout(a),a=window.setTimeout(async()=>{let u=d.trim();i=u;try{let{id:w,port:C}=n(),g=await e(u,w,C);if(i!==u)return;s={host:u,text:g.text,bad:g.status==="error"}}catch{if(i!==u)return;s={host:u,text:p.text,bad:!1}}o()},700))}}}var er=ni(Qo(),1),bi=n=>``,Xo="#0a0a0a",Yn="#f2f2f2",xi=n=>n.length>300,$t=n=>+n.toFixed(2);function Zn(n,e,o,r,a){return`M${$t(n+a)} ${$t(e)}h${$t(o-2*a)}a${a} ${a} 0 0 1 ${a} ${a}v${$t(r-2*a)}a${a} ${a} 0 0 1 -${a} ${a}h-${$t(o-2*a)}a${a} ${a} 0 0 1 -${a} -${a}v-${$t(r-2*a)}a${a} ${a} 0 0 1 ${a} -${a}z`}function Ct(n,e=3,o=!0,r="plain"){let a=xi(n),i=r==="night",s=(0,er.default)(0,a?"L":"H");s.addData(n,"Byte"),s.make();let l=s.getModuleCount(),c=l+e*2,d=o&&!a?Math.round(l*.22):0;d&&(l-d)%2&&d++;let p=(l-d)/2,u=p+d,w=(x,v)=>d>0&&x>=p&&x=p&&vi&&(v<7&&x<7||v<7&&x>=l-7||v>=l-7&&x<7),g="";if(i){let x=a?.48:.42;for(let v=0;v${bi(i?Xo:"#fff")}`}let I=``;return i?`${I}${k}`:`${I}${k}`}var wi={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",expiring:"people",expired_kept:"people",portal_blocked:"problems"},Et=["connections","people","problems"],pt={connections:"Connections",people:"People",problems:"Problems"},tr={connections:"Connects, disconnects and IP changes",people:"People and their devices added, changed, paused, removed",problems:"Blocked portal sign-ins (tunnels and services are in the service log)"},Bt=n=>wi[n]??"problems",Ot={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},yi=["person_added","person_removed","person_changed"];function Ne(n){return n.by?n.by:yi.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function nr(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var dn=n=>n.sys?["error","repair","down"].includes(n.sys.level):Bt(n.ev.type)==="problems";function cn(n){let e=n.keep_days>0?`${n.keep_days} day${n.keep_days===1?"":"s"}`:"no age limit",o=n.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${n.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${e}, up to ${n.max.toLocaleString("en-GB")} events, ${o}.`}function or(n,e=120,o=26,r=je(new Date)){let a=Math.max(1,...n),i=t("div",{class:"dl-spark"});return i.style.width=`${e}px`,i.style.height=`${o}px`,n.forEach((s,l)=>{let c=t("i");c.style.height=`${Math.max(6,s/a*100)}%`,s||c.classList.add("zero");let d=n.length-1-l;me(c,()=>[t("div",{class:"dl-tip-title"},d===0?"Today":d===1?"Yesterday":bt(Ht(r,-d)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},X(s))]),i.appendChild(c)}),i}function ki(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function rr(n,e){return[n.join(","),...e.map(o=>n.map(r=>ki(o[r])).join(","))].join(` -`)}function $i(n){let e=new Map(n.people.map(r=>[r.id,r.name])),o=new Map(n.people.flatMap(r=>r.devices.map(a=>[a.id,a.name])));return{people:e,devices:o}}function Fe(n,e,o,r="",a=[]){let i=$i(n),s=[...e.map(p=>({ts:p.ts,category:Bt(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:Ne(p)??""})),...a.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?` -${p.detail}`:""}`,where:Ot[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),l=new Date().toISOString().slice(0,10),c=`dawnline-activity${r?`-${r}`:""}-${l}.${o}`;if(o==="json"){Se(c,JSON.stringify(s,null,2),"application/json");return}Se(c,rr(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var Ci=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],ar=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function et(n,e,o,r,a,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...Et.map(c=>t("option",{value:c,selected:c===a?"selected":null},pt[c])),i?t("option",{value:"system",selected:a==="system"?"selected":null},"System"):""]),l=t("select",{class:"cbi-input-select"},Ci.map(([c,d])=>t("option",{value:c},d)));te(n,[t("p",{class:"dl-muted"},`${e} This cannot be undone; export first if you want a copy.`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Category"),s]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Which events"),l])],[ae()," ",H("Clear",async()=>{let c=0;if(s.value!=="system")try{c+=(await A.logsClear({...o,category:s.value,older_days:l.value})).removed}catch(d){U(be(d),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{c+=(await A.serviceLogClear(l.value)).removed}catch(d){oe(),U(`${s.value==="system"?"":`Activity: ${ar(c).toLowerCase()}. `}The service log was not cleared: ${be(d)}`,"error",1e4),r();return}oe(),U(ar(c),"success",3e3),r()},"negative")])}function Lt(n,e,o,r){let a=n==="device"?`Clears ${o}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${o}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";te(n==="all"?"Reset all traffic history?":`Reset traffic history for ${o}?`,[t("p",{class:"dl-muted"},a)],[ae()," ",H("Reset",async()=>{await W(()=>A.usageClear(n,e),"Traffic history reset")&&(oe(),r())},"negative")])}function ve(n,e,o){let r=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let a=!r.classList.contains("on");Qn(r,a),o?.(a)}},t("i"));return r}function Qn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var Pe=n=>n.classList.contains("on");function we(n,e,o={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let r=t("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":e}),a=()=>r.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===r.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)r.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==r.dataset.value&&(o.optimistic!==!1&&(r.dataset.value=i,a()),o.onChange?.(i))}},s));return a(),r}function qe(n,e,o,r={}){return t("button",{type:"button",...r,class:`dl-chipbtn${e?" on":""}${r.class?` ${r.class}`:""}`,"aria-pressed":e?"true":"false",click:o},n)}function pn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function ie(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var Ei={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Li={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function Mi(n){let e={};for(let[o,r]of Object.entries(Li))n[o]!=null&&n[o]!==""&&(e[r]=String(n[o]));return e}function Ti(n,e){let o=n.amnezia,r=o.obfuscation??{},a=c=>r[c]!=null&&r[c]!==""?String(r[c]):Ei[c],i=o.host.replace(/^\[(.*)\]$/,"$1"),s={H1:a("h1"),H2:a("h2"),H3:a("h3"),H4:a("h4"),I1:a("i1"),I2:a("i2"),I3:a("i3"),I4:a("i4"),I5:a("i5"),Jc:a("jc"),Jmin:a("jmin"),Jmax:a("jmax"),S1:a("s1"),S2:a("s2"),S3:a("s3"),S4:a("s4"),...Mi(r),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r -`),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(o.port),protocol_version:r.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function Si(n){let e="";for(let o=0;o"u")return null;try{let o=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),r=new Uint8Array(await new e.Response(o).arrayBuffer()),a=new Uint8Array(4+r.length);return new DataView(a.buffer).setUint32(0,n.length,!1),a.set(r,4),a}catch{return null}}async function Xn(n,e,o=!0){let r=new TextEncoder().encode(JSON.stringify(Ti(n,e))),a=o?await _i(r):null;return`vpn://${Si(a??r)}`}var sr=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"balanced",title:"Balanced",ic:"shield",stealth:3,speed:4,needs:"v2",text:"AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.",apps:"AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps",short:"AmneziaWG 2.0+ apps"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],jt=n=>sr.find(e=>e.id===n),un=n=>n.v3?"max":n.v2?"balanced":"off",Ut=n=>n==="standard"?"Standard (old)":n==="strong"?"Strong (old)":null,Pi={v2:"Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},Di={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function ir(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>t("i",{class:odom.content(i,sr.map(l=>{let c=!l.needs||n[l.needs],d=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":d?"true":"false","aria-disabled":c?null:"true",class:`dl-method${d?" on":""}${c?"":" off"}`,click:()=>{!c||d||(e=l.id,s(),o(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},b(l.ic)),t("b",{},l.title),l.id===r?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[ir(l.stealth,"Stealth"),ir(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},c?[b(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[b("alert"),t("span",{},(a?Pi:Di)[l.needs])])])}));return s(),i}function lr(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var dr=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function Ai(n){let e=d=>n[d]!=null&&n[d]!=="",o=dr.filter(([d])=>e(d));if(!o.length)return null;let r=(d,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},d==="header_protection_key"?`${n[d].slice(0,6)}••••`:n[d])]),a=(d,p,u,w)=>{let C=dr.filter(([g])=>w.includes(g)&&e(g));return C.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[b(p),t("b",{},d)]),t("p",{},u),t("div",{class:"dl-pvals"},C.map(([g,m])=>r(g,m)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=o.map(([d,p])=>`${p} = ${n[d]}`).join(` -`),c=t("div",{class:"dl-pgrid"},[a("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),a("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),a("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),a("Signatures","globe",s,["i1","i2","i3","i4","i5"]),a("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),a("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(o.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:d=>{d.preventDefault(),pe(l,"Parameters copied")}},"Copy as config")]),c])}function cr(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let r=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},o[1])," ",r&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function Hi(n){let e=!1,o=t("pre",{class:"dl-conf"}),r=()=>dom.content(o,n.conf.split(` +var bi=Object.create;var Po=Object.defineProperty;var xi=Object.getOwnPropertyDescriptor;var wi=Object.getOwnPropertyNames;var yi=Object.getPrototypeOf,ki=Object.prototype.hasOwnProperty;var $i=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Ci=(n,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of wi(e))!ki.call(n,a)&&a!==r&&Po(n,a,{get:()=>e[a],enumerable:!(o=xi(e,a))||o.enumerable});return n};var Ei=(n,e,r)=>(r=n!=null?bi(yi(n)):{},Ci(e||!n||!n.__esModule?Po(r,"default",{value:n,enumerable:!0}):r,n));var rr=$i((nr,or)=>{"use strict";var tr=(function(){var n=function(w,v){var y=236,E=17,k=w,z=r[v],f=null,g=0,S=null,T=[],N={},W=function(P,D){g=k*4+17,f=(function(_){for(var I=new Array(_),M=0;M<_;M+=1){I[M]=new Array(_);for(var j=0;j<_;j+=1)I[M][j]=null}return I})(g),q(0,0),q(g-7,0),q(0,g-7),K(),R(),de(P,D),k>=7&&Z(P),S==null&&(S=ge(k,z,T)),Q(S,D)},q=function(P,D){for(var _=-1;_<=7;_+=1)if(!(P+_<=-1||g<=P+_))for(var I=-1;I<=7;I+=1)D+I<=-1||g<=D+I||(0<=_&&_<=6&&(I==0||I==6)||0<=I&&I<=6&&(_==0||_==6)||2<=_&&_<=4&&2<=I&&I<=4?f[P+_][D+I]=!0:f[P+_][D+I]=!1)},Y=function(){for(var P=0,D=0,_=0;_<8;_+=1){W(!0,_);var I=a.getLostPoint(N);(_==0||P>I)&&(P=I,D=_)}return D},R=function(){for(var P=8;P>_&1)==1;f[Math.floor(_/3)][_%3+g-8-3]=I}for(var _=0;_<18;_+=1){var I=!P&&(D>>_&1)==1;f[_%3+g-8-3][Math.floor(_/3)]=I}},de=function(P,D){for(var _=z<<3|D,I=a.getBCHTypeInfo(_),M=0;M<15;M+=1){var j=!P&&(I>>M&1)==1;M<6?f[M][8]=j:M<8?f[M+1][8]=j:f[g-15+M][8]=j}for(var M=0;M<15;M+=1){var j=!P&&(I>>M&1)==1;M<8?f[8][g-M-1]=j:M<9?f[8][15-M-1+1]=j:f[8][15-M-1]=j}f[g-8][8]=!P},Q=function(P,D){for(var _=-1,I=g-1,M=7,j=0,J=a.getMaskFunction(D),V=g-1;V>0;V-=2)for(V==6&&(V-=1);;){for(var pe=0;pe<2;pe+=1)if(f[I][V-pe]==null){var xe=!1;j>>M&1)==1);var ne=J(I,V-pe);ne&&(xe=!xe),f[I][V-pe]=xe,M-=1,M==-1&&(j+=1,M=7)}if(I+=_,I<0||g<=I){I-=_,_=-_;break}}},te=function(P,D){for(var _=0,I=0,M=0,j=new Array(D.length),J=new Array(D.length),V=0;V=0?So.getAt(To):0}}for(var _o=0,ne=0;neV*8)throw"code length overflow. ("+M.getLengthInBits()+">"+V*8+")";for(M.getLengthInBits()+4<=V*8&&M.put(0,4);M.getLengthInBits()%8!=0;)M.putBit(!1);for(;!(M.getLengthInBits()>=V*8||(M.put(y,8),M.getLengthInBits()>=V*8));)M.put(E,8);return te(M,I)};N.addData=function(P,D){D=D||"Byte";var _=null;switch(D){case"Numeric":_=c(P);break;case"Alphanumeric":_=p(P);break;case"Byte":_=u(P);break;case"Kanji":_=x(P);break;default:throw"mode:"+D}T.push(_),S=null},N.isDark=function(P,D){if(P<0||g<=P||D<0||g<=D)throw P+","+D;return f[P][D]},N.getModuleCount=function(){return g},N.make=function(){if(k<1){for(var P=1;P<40;P++){for(var D=l.getRSBlocks(P,z),_=d(),I=0;I"u"?P*4:D;var _="";_+='";for(var M=0;M';_+=""}return _+="",_+="
",_},N.createSvgTag=function(P,D,_,I){var M={};typeof arguments[0]=="object"&&(M=arguments[0],P=M.cellSize,D=M.margin,_=M.alt,I=M.title),P=P||2,D=typeof D>"u"?P*4:D,_=typeof _=="string"?{text:_}:_||{},_.text=_.text||null,_.id=_.text?_.id||"qrcode-description":null,I=typeof I=="string"?{text:I}:I||{},I.text=I.text||null,I.id=I.text?I.id||"qrcode-title":null;var j=N.getModuleCount()*P+D*2,J,V,pe,xe,ne="",De;for(De="l"+P+",0 0,"+P+" -"+P+",0 0,-"+P+"z ",ne+=''+O(I.text)+"":"",ne+=_.text?''+O(_.text)+"":"",ne+='',ne+='"u"?P*4:D;var _=N.getModuleCount()*P+D*2,I=D,M=_-D;return B(_,_,function(j,J){if(I<=j&&j"u"?P*4:D;var I=N.getModuleCount()*P+D*2,M="";return M+="",M};var O=function(P){for(var D="",_=0;_":D+=">";break;case"&":D+="&";break;case'"':D+=""";break;default:D+=I;break}}return D},X=function(P){var D=1;P=typeof P>"u"?D*2:P;var _=N.getModuleCount()*D+P*2,I=P,M=_-P,j,J,V,pe,xe,ne={"██":"█","█ ":"▀"," █":"▄"," ":" "},De={"██":"▀","█ ":"▀"," █":" "," ":" "},Ae="";for(j=0;j<_;j+=2){for(V=Math.floor((j-I)/D),pe=Math.floor((j+1-I)/D),J=0;J<_;J+=1)xe="█",I<=J&&J=M?De[xe]:ne[xe];Ae+=` +`}return _%2&&P>0?Ae.substring(0,Ae.length-_-1)+Array(_+1).join("▀"):Ae.substring(0,Ae.length-1)};return N.createASCII=function(P,D){if(P=P||1,P<2)return X(D);P-=1,D=typeof D>"u"?P*2:D;var _=N.getModuleCount()*P+D*2,I=D,M=_-D,j,J,V,pe,xe=Array(P+1).join("██"),ne=Array(P+1).join(" "),De="",Ae="";for(j=0;j<_;j+=1){for(V=Math.floor((j-I)/P),Ae="",J=0;J<_;J+=1)pe=1,I<=J&&J>>8),z.push(S&255)):z.push(E)}}return z}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={L:1,M:0,Q:3,H:2},o={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},a=(function(){var w=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],v=1335,y=7973,E=21522,k={},z=function(f){for(var g=0;f!=0;)g+=1,f>>>=1;return g};return k.getBCHTypeInfo=function(f){for(var g=f<<10;z(g)-z(v)>=0;)g^=v<=0;)g^=y<5&&(S+=3+W-5)}for(var T=0;T=256;)k-=255;return w[k]},E})();function s(w,v){if(typeof w.length>"u")throw w.length+"/"+v;var y=(function(){for(var k=0;k"u")throw"bad rs block @ typeNumber:"+k+"/errorCorrectionLevel:"+z;for(var g=f.length/3,S=[],T=0;T>>7-E%8&1)==1},y.put=function(E,k){for(var z=0;z>>k-z-1&1)==1)},y.getLengthInBits=function(){return v},y.putBit=function(E){var k=Math.floor(v/8);w.length<=k&&w.push(0),E&&(w[k]|=128>>>v%8),v+=1},y},c=function(w){var v=e.MODE_NUMBER,y=w,E={};E.getMode=function(){return v},E.getLength=function(f){return y.length},E.write=function(f){for(var g=y,S=0;S+2>>8&255)*192+(T&255),f.put(T,13),S+=2}if(S>>8)},v.writeBytes=function(y,E,k){E=E||0,k=k||y.length;for(var z=0;z0&&(y+=","),y+=w[E];return y+="]",y},v},h=function(){var w=0,v=0,y=0,E="",k={},z=function(g){E+=String.fromCharCode(f(g&63))},f=function(g){if(!(g<0)){if(g<26)return 65+g;if(g<52)return 97+(g-26);if(g<62)return 48+(g-52);if(g==62)return 43;if(g==63)return 47}throw"n:"+g};return k.writeByte=function(g){for(w=w<<8|g&255,v+=8,y+=1;v>=6;)z(w>>>v-6),v-=6},k.flush=function(){if(v>0&&(z(w<<6-v),w=0,v=0),y%3!=0)for(var g=3-y%3,S=0;S=v.length){if(k==0)return-1;throw"unexpected end of file./"+k}var g=v.charAt(y);if(y+=1,g=="=")return k=0,-1;if(g.match(/^\s$/))continue;E=E<<6|f(g.charCodeAt(0)),k+=6}var S=E>>>k-8&255;return k-=8,S};var f=function(g){if(65<=g&&g<=90)return g-65;if(97<=g&&g<=122)return g-97+26;if(48<=g&&g<=57)return g-48+52;if(g==43)return 62;if(g==47)return 63;throw"c:"+g};return z},C=function(w,v){var y=w,E=v,k=new Array(w*v),z={};z.setPixel=function(T,N,W){k[N*y+T]=W},z.write=function(T){T.writeString("GIF87a"),T.writeShort(y),T.writeShort(E),T.writeByte(128),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(255),T.writeByte(255),T.writeByte(255),T.writeString(","),T.writeShort(0),T.writeShort(0),T.writeShort(y),T.writeShort(E),T.writeByte(0);var N=2,W=g(N);T.writeByte(N);for(var q=0;W.length-q>255;)T.writeByte(255),T.writeBytes(W,q,255),q+=255;T.writeByte(W.length-q),T.writeBytes(W,q,W.length-q),T.writeByte(0),T.writeString(";")};var f=function(T){var N=T,W=0,q=0,Y={};return Y.write=function(R,K){if(R>>>K)throw"length over";for(;W+K>=8;)N.writeByte(255&(R<>>=8-W,q=0,W=0;q=R<0&&N.writeByte(q)},Y},g=function(T){for(var N=1<>6,128|i&63):i<55296||i>=57344?o.push(224|i>>12,128|i>>6&63,128|i&63):(a++,i=65536+((i&1023)<<10|r.charCodeAt(a)&1023),o.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return o}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof nr=="object"&&(or.exports=n())})(function(){return tr})});function Gn(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(r=>Gn(r,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,r){let o=window.E,a=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!a&&r===void 0?o(n,{},Gn(e,[])):o(n,a?e:{},Gn(r,[]))}var Do={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function ft(n,e="dl-icon"){let r=Do[n]??Do.phone;return``}function b(n,e="dl-icon"){let r=document.createElement("span");return r.className="dl-icon-wrap",r.innerHTML=ft(n,e),r}function U(n,e="info",r=0){let o=document.querySelector(".dl-toasts");o||(o=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(o));let a=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=t("div",{class:`dl-toast ${e}`},[a?b(a):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":"Close",click:i},b("x")):""]);o.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,r||(e==="error"?8e3:e==="warning"?5e3:2600))}function be(n){return n instanceof Error?n.message:String(n)}async function G(n,e){try{let r=await n();return e&&U(e,"success",3500),r}catch(r){U(be(r),"error",1e4);return}}function Ao(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(r=>U(be(r),"error"))}catch(e){U(be(e),"error")}}function Ho(n){if(n&&typeof n=="object"){if(typeof n.error=="string")throw new Error(n.error);typeof n.warning=="string"&&n.warning&&U(n.warning,"warning",12e3)}return n}function F(n,e=[]){let r=rpc.declare({object:"luci.dawnline",method:n,params:e});return async(...o)=>Ho(await r(...o))}var Li=F("logs_clear",["person","device","category","older_days"]),Mi=(n={})=>Li(n.person??"",n.device??"",n.category??"",n.older_days??""),Si=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets","server"]});async function Ti(n,e){let o=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(a=>e[a]),e.paused,e.services,e.circle,e.home_nets,e.server];return Ho(await Si(...o))}var _i=F("status",["days"]),A={rev:F("rev"),personUpdate:Ti,settingsGet:F("settings_get"),portalInfo:F("portal_info"),settingsUpdate:F("settings_update",["values"]),serviceSet:F("service_set",["id","name","address","ports"]),serviceDelete:F("service_delete",["id"]),geoClear:F("geo_clear"),events:F("events",["limit","person","since"]),logsClear:Mi,interfaces:F("interfaces",["id"]),serverInterfaces:F("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:F("circle_set",["id","server","name","color","members"]),circleDelete:F("circle_delete",["id"]),accessCheck:F("access_check",["from","to"]),homeHosts:F("home_hosts",["id"]),usageClear:F("usage_clear",["scope","id"]),uninstall:F("uninstall",["confirm"]),status:_i,setupDefaults:F("setup_defaults"),serverCreate:F("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:F("server_obfuscation",["id","preset"]),serverUpdate:F("server_update",["id","values"]),serverPorts:F("server_ports",["id"]),endpointProbe:F("endpoint_probe",["host","id","port"]),serverDelete:F("server_delete",["id"]),personLinks:F("person_links",["id"]),personCreate:F("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:F("person_pause",["id","paused"]),personRegen:F("person_regen",["id","remove"]),personDelete:F("person_delete",["id"]),personUsage:F("person_usage",["id","days"]),deviceCreate:F("device_create",["person","name","kind"]),deviceConfig:F("device_config",["id"]),deviceUpdate:F("device_update",["id","name","disabled"]),deviceDelete:F("device_delete",["id"]),deviceRotate:F("device_rotate",["id"]),apply:F("apply"),health:F("health"),healthFix:F("health_fix",["id"]),serviceLog:F("service_log"),serviceLogClear:F("service_log_clear",["older_days"]),backupList:F("backup_list"),backupCreate:F("backup_create"),backupRestore:F("backup_restore",["name"]),backupDelete:F("backup_delete",["name"]),backupRead:F("backup_read",["name"]),backupUpload:F("backup_upload",["data"]),exportJson:F("export"),importJson:F("import",["data"]),updatesStatus:F("updates_status"),updatesRun:F("updates_run",["what"]),updatesReleases:F("updates_releases",["page"]),updatesNotes:F("updates_notes",["component","tag","build"]),updatesChanges:F("updates_changes",["from","to"])};function H(n,e,r="neutral",o={}){let{disabled:a,...i}=o,s=t("button",{class:`cbi-button cbi-button-${r}`,type:"button",...i,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!s.disabled){s.disabled=!0,s.classList.add("spinning");try{await e(l)}catch(d){U(be(d),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!a,s}function Le(n,e,r,o="neutral",a=""){return H([b(n),t("span",{class:"dl-btn-label"},e)],r,o,{title:e,class:`cbi-button cbi-button-${o} dl-icon-btn ${a}`.trim()})}function $e(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var gt=null;function Wn(n=!1){let e=gt;gt=null,e?.(n)}function oe(n,e,r,o=""){Wn();let a=t("div",{class:`dl-modal ${o}`},e),i=t("div",{class:"button-row"},r);a.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),ae();return}if(s.key!=="Enter"||s.shiftKey||s.ctrlKey||s.metaKey||s.altKey)return;let l=s.target;if(!l||["TEXTAREA","BUTTON","SELECT","A"].includes(l.tagName))return;let d=i.querySelector(".cbi-button-positive");!d||d.disabled||(s.preventDefault(),d.click())}),ui.showModal(n,[a,i])}function ae(){Wn(),ui.hideModal()}function ie(n="Cancel",e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:ae},n)}function le(n,e,r="Confirm",o=!1){return new Promise(a=>{oe(n,e,[ie()," ",t("button",{class:`cbi-button ${o?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=gt;gt=null,ui.hideModal(),i?.(!0)}},r)]),gt=a})}$e(()=>{gt&&(Wn(),ui.hideModal())});async function ue(n,e="Copied to clipboard",r=!1){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let o=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(o),o.select();let a=document.execCommand("copy");if(o.remove(),!a)throw new Error("Copying is blocked here. Select the text and copy it by hand.")}return U(e,"success",2500),!0}catch(o){return r||U(be(o),"error"),!1}}function Te(n,e,r="text/plain"){let o=globalThis,a=typeof e=="string"?new o.Blob([e],{type:r}):e,i=URL.createObjectURL(a),s=t("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function Fn(n,e){return new Promise(r=>{let o=t("input",{type:"file",accept:n,style:"display:none"});o.addEventListener("cancel",()=>{o.remove(),r(null)}),o.addEventListener("change",()=>{let a=o.files?.[0];if(o.remove(),!a)return r(null);let i=new FileReader;i.onload=()=>{let s=String(i.result??"");r({name:a.name,data:e==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>r(null),e==="base64"?i.readAsDataURL(a):i.readAsText(a)}),document.body.appendChild(o),o.click()})}function Ce(n,e){let r=document.querySelector(".dl-dd");if(r&&(r.dlClose?r.dlClose():r.remove(),r.dlAnchor===n))return;let o=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),Ao(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(o);let a=n.getBoundingClientRect(),i=o.offsetWidth,s=o.offsetHeight;o.style.top=`${a.bottom+6+s>window.innerHeight-8&&a.top-6-s>8?a.top-6-s:a.bottom+6}px`,o.style.left=`${Math.max(8,Math.min(a.right-i,window.innerWidth-i-8))}px`;let l=u=>{!o.contains(u.target)&&!n.contains(u.target)&&p()},d=u=>{if(u.key==="Escape"||u.key==="Tab")return p();let x=[...o.querySelectorAll("button:not([disabled])")];if(!x.length||!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;u.preventDefault();let $=x.indexOf(document.activeElement),h=u.key==="Home"?0:u.key==="End"?x.length-1:u.key==="ArrowDown"?($+1)%x.length:($-1+x.length)%x.length;x[h].focus({preventScroll:!0})},c=$e(p);o.dlAnchor=n,o.dlClose=p;function p(){o.remove(),c(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",p,!0)}),o.querySelector("button")?.focus({preventScroll:!0})}var dt=null,Je=null,qn=0;function vt(){dt&&(dt.style.display="none"),Je=null,clearInterval(qn),qn=0}function me(n,e){let r=o=>{dt??(dt=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),dt.replaceChildren(...e().map(a=>typeof a=="string"?document.createTextNode(a):a)),dt.style.display="",dt.style.left=`${o.clientX}px`,dt.style.top=`${o.clientY-10}px`,Je=n,qn||(qn=window.setInterval(()=>{(!Je?.isConnected||!Je.getClientRects().length)&&vt()},400))};n.addEventListener("mouseenter",r),n.addEventListener("mousemove",r),n.addEventListener("mouseleave",vt),n.addEventListener("pointerup",o=>{o.pointerType!=="mouse"&&(Je===n?vt():r(o))})}$e(vt);window.addEventListener("scroll",()=>Je&&vt(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{Je&&!Je.contains(n.target)&&vt()},!0);function ee(n){if(!n||n<0)return"0 B";let e=["B","KB","MB","GB","TB"],r=0,o=n;for(;o>=1024&&r=100||r===0?Math.round(o):o.toFixed(1)} ${e[r]}`}function Oe(n){let e=n*8;return e<1e3?`${Math.round(e)} bit/s`:e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)} kbit/s`:e<1e9?`${(e/1e6).toFixed(e<1e7?1:0)} Mbit/s`:`${(e/1e9).toFixed(1)} Gbit/s`}function re(n,e=Date.now()/1e3){if(!n)return"never";let r=Math.max(0,Math.round(e-n));return r<60?"just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} h ago`:r<86400*30?`${Math.floor(r/86400)} d ago`:new Date(n*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function xt(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),r=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return e?`${e}d ${r}h`:r?`${r}h ${o}m`:`${o}m`}function zt(n){let e=new Date(n*1e3),r=new Date,o=e.toDateString()===r.toDateString(),a=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return o?a:`${e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${a}`}function je(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function wt(n){let[e,r,o]=n.split("-").map(Number);return new Date(e,(r||1)-1,o||1,12)}function Ue(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?wt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Me(n){return n?Ue(n):""}function Kn(n,e){let r=o=>{let[a,i,s]=o.split("-").map(Number);return Date.UTC(a,i-1,s)};return Math.round((r(n)-r(e))/864e5)}function Ht(n,e){let r=wt(n);return r.setDate(r.getDate()+e),je(r)}function bt(n,e){let[r,o,a]=n.split("-").map(Number),i=new Date(r,o-1+e,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(a,s)),je(i)}function Ie(n){return n?.length?n[n.length-1].day:je(new Date)}function zo(n,e,r,o,a=30){let i=n||o;return e==="day"?Ht(i,r):e==="week"?Ht(i,7*r):e==="month"?bt(i,r):e==="year"?bt(i,12*r):Ht(i,a*r)}function Ye(n,e=Date.now()){if(!n)return null;let r=typeof e=="number"?je(new Date(e)):e,o=Kn(n,r);return o>=0?o+1:o}function Ze(n,e){return e!=null&&e>0&&n.expire_warn>0&&e<=n.expire_warn}function en(n){return n<=1?"ends today":n===2?"ends tomorrow":`ends in ${n} days`}function tn(n,e,r=`${e}s`){return`${n.toLocaleString("en-GB")} ${n===1?e:r}`}function Nt(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var ct={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var No=["computer","phone","tablet","router","other"],Qe={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Ro={active:"Active",paused:"Paused",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server",server_off:"Server is turned off"};function He(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let r=e[0][0]??"",o=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(r+o).toUpperCase()}function nn(n){let e=r=>r.disabled?3:r.online?0:r.handshake?1:2;return n.map((r,o)=>[r,o]).sort((r,o)=>e(r[0])-e(o[0])||r[1]-o[1]).map(([r])=>r)}function Ee(n,e,r){return t("span",{class:`dl-pill ${n}`,title:r??null},e)}function Pi(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function Di(n){return n.state==="server_off"&&n.paused?"paused":n.state}function Io(n){let e=Di(n);return e==="active"||e==="server_off"?"":Ee(Pi({...n,state:e}),Ro[e])}function Bo(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],r=t("span",{class:"dl-access","aria-label":ct[n.access]},e.map(o=>t("span",{class:`dl-ibadge ${o}`},b(o==="lan"?"home":"globe"))));return me(r,()=>[t("div",{class:"dl-tip-title"},ct[n.access]),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),r}var Ai={paused:"Paused",expired:"Access ended",quota:"Data limit",hours:"Outside hours",server_off:"Server off",no_server:"No server"};function on(n,e,r="Not set up yet",o){let a=n.handshake?`Last seen ${re(n.handshake,e)} · ${new Date(n.handshake*1e3).toLocaleString()}`:"";if(n.disabled)return t("span",{class:"dl-dstat",title:a},"Disabled");if(n.online)return t("span",{class:"dl-dstat ok"},"Connected");let i=o&&Ai[o.state];return i?t("span",{class:"dl-dstat warn",title:a||"Not connected yet"},i):n.handshake?t("span",{class:"dl-dstat",title:new Date(n.handshake*1e3).toLocaleString()},`Last seen ${re(n.handshake,e)}`):t("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},r)}var rn=null;function Oo(n,e,r,o){rn?.close();let a=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>c()},b("x"))]),t("div",{class:"dl-drawer-body"},e),r?t("div",{class:"dl-drawer-foot"},r):""]),i=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===i&&c()}},a),s=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&c()},l=!1,d=$e(()=>c());function c(){l||(l=!0,d(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),rn===p&&(rn=null),o())}let p={close:c,panel:a};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),rn=p,p}function ce(n,e,r){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),r?t("span",{class:"dl-sub"},r):""]),t("div",{class:"dl-setrow-ctl"},e)])}function he(n,e,r,o=e){let a=ce(n,o," "),i=a.querySelector(".dl-sub"),s=()=>{let l=r();i.textContent=l.text,i.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),a.refresh=s,a.help=r,s(),a}function ye(n,e,r,o=e){let a=t("div",{class:"dl-sub"}),i=t("div",{class:"cbi-value dl-live"},[t("div",{class:"cbi-value-title"},[t("label",{},n),a]),t("div",{class:"cbi-value-field"},o)]),s=()=>{let l=r();a.textContent=l.text,a.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),e.addEventListener("change",s),i.refresh=s,i.help=r,s(),i}function ze(n,e=[]){for(let r of n){let o=r.help?.();if(o?.bad)return o.text}for(let r of e){let o=r();if(o.bad)return o.text}return null}function Rt(n,e,r,o=""){return t("section",{class:`dl-setsec ${o}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),r.length?t("div",{class:"dl-setsec-foot"},r):""])}function fe(n,e,r,o){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},b(n)),t("span",{class:"dl-stack"},[t("b",{},e),r?t("span",{class:"dl-sub"},r):""])]),t("div",{class:"dl-group-body"},o.filter(a=>a!==""))])}function Xe(n,e,r,o,a){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},b(n)):b(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},r),t("span",{class:"dl-sub"},o)]),a])}function pt(n,e){let r={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${r}`},e)}function et(n,e=""){let r=t("div",{class:e});return r.innerHTML=n,r}function Vn(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[r,o,a,i]=e.slice(1,5).map(Number),s=Number(e[5]);if([r,o,a,i].some(c=>c>255)||s<8||s>30)return null;let l=r*2**24+o*2**16+a*2**8+i,d=2**(32-s);return{net:l-l%d,size:d}}var Hi=(n,e)=>n.netVn(n));function $t(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function an(n){return`${n.trim()}.0/24`}function Yn(n,e,r){let o=n.trim(),a=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o)?Vn(an(o)):null;if(!a)return{text:"Three numbers, like 10.77.0.",bad:!0};if(!zi.some(s=>a.net>=s.net&&a.net+a.size<=s.net+s.size))return{text:"Use a private range: 10.x.x, 172.16–31.x or 192.168.x.",bad:!0};let i=e.find(s=>{let l=Vn(s.cidr);return l!=null&&Hi(a,l)});if(i){let s=i.cidr.endsWith("/24")?`${$t(i.cidr)}.x`:i.cidr,l=r&&r!==o?` Try ${r}.`:"";return{text:`${i.name} already uses ${s}.${l}`,bad:!0}}return{text:`Devices get ${o}.2 – ${o}.254, the router ${o}.1.`,bad:!1}}var Uo=(n,e)=>e.find(r=>r.from<=n&&n<=r.to)?.who??null,Ni=n=>Number.isInteger(n)&&n>=1&&n<=65535;function It(n,e,r){if(!Ni(n))return{text:"Use a port from 1 to 65535.",bad:!0};let o=Uo(n,e);return o?{text:`Used by ${o}. Choose another port.`,bad:!0}:{text:r,bad:!1}}function sn(n,e,r){let o=r?`HTTPS here, plain HTTP for links on IP addresses on ${n+1}.`:"HTTPS on this port, opened on WAN.",a=It(n,e,o);if(a.bad||!r)return a;if(n===65535)return{text:"Links on IP addresses also need the next port: choose a lower one.",bad:!0};let i=Uo(n+1,e);return i?{text:`Links on IP addresses also need ${n+1}, used by ${i}. Choose another port.`,bad:!0}:a}var yt=n=>Array.from(n).length,jo=48,Ri=/[<>"\\\u0000-\u001f\u007f]/;function _e(n,e=[],r=""){let o=n.trim();return o?yt(n)>jo?{text:`Up to ${jo} characters (${yt(n)} now).`,bad:!0}:Ri.test(n)?{text:'Names can’t contain < > " or \\.',bad:!0}:e.some(a=>a.toLowerCase()===o.toLowerCase())?{text:`“${o}” already exists — pick another name.`,bad:!0}:{text:r,bad:!1}:{text:"Enter a name.",bad:!0}}function Go(n,e=[]){return yt(n)>32?{text:`Up to 32 characters (${yt(n)} now).`,bad:!0}:_e(n,e,"Shown on the person cards.")}var Ii=/^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,Bi=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Ct(n){let e=Bi.exec(n);return!!e&&e.slice(1).every(r=>Number(r)<=255)}function Jn(n){return/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(n)&&!/:::/.test(n)}function kt(n,e,r=null){let o=n.trim();if(!o)return r!=null?{text:r,bad:!1}:{text:"Enter a hostname or IP address.",bad:!0};if(/^[a-z]+:\/\//i.test(o))return{text:"Leave out https:// — just the name.",bad:!0};if(/\/.*/.test(o))return{text:"Just the name, without a path.",bad:!0};if(/^[^:\[]+:\d+$/.test(o))return{text:"Just the name, without a port (the port is on AmneziaWG).",bad:!0};if(/\s/.test(o))return{text:"A hostname has no spaces.",bad:!0};if(o.length>253||!(Ii.test(o)||Ct(o)||Jn(o)))return{text:"Use a hostname or an IP address.",bad:!0};let a=Jn(o)?`[${o}]`:o;return{text:e?`Devices connect to ${a}:${e}.`:`Links use ${a}.`,bad:!1}}function Wo(n,e){let r=n.split(/[ ,]+/).filter(Boolean);if(!r.length)return{text:`This router (${e}): queries go where your home network sends them, and home names work.`,bad:!1};let o=r.find(a=>!Ct(a)&&!Jn(a));return o?{text:`“${o}” is not an IP address. Separate several with commas.`,bad:!0}:{text:`Devices use ${r.join(" and ")} — home names and your LAN’s DNS filters no longer apply to them.`,bad:!1}}function Fo(n,e){let r=n.trim();if(!r)return{text:`Automatic by device type and disguise: ${e.computer} for computers and routers, ${e.phone} for phones and tablets.`,bad:!1};if(!/^\d{1,4}$/.test(r)||Number(r)<1280||Number(r)>1500)return{text:"MTU must be 1280–1500, or empty for automatic.",bad:!0};let o=Number(r);return{text:`Computers and routers get ${o}, phones and tablets ${Math.min(o,1280)}.`,bad:!1}}function qo(n){let e=n.trim();return e?!/^\d{1,3}$/.test(e)||Number(e)>600?{text:"Use 0–600 seconds.",bad:!0}:Number(e)===0?{text:"Off: NAT may close the tunnel when idle, and “Connected” lags.",bad:!1}:{text:`Devices send a packet every ${e} s to keep NAT open (a little battery on phones).`,bad:!1}:{text:"Default: a packet every 25 s keeps NAT open and “Connected” accurate.",bad:!1}}function ln(n,e=0){let r=n.trim();if(!/^\d{1,2}$/.test(r)||Number(r)<1||Number(r)>32)return{text:"Use 1–32.",bad:!0};let o=Number(r);return e>o?{text:`Already has ${e} devices: remove ${e-o===1?"one":`${e-o}`} first, or allow more.`,bad:!0}:{text:`They can add ${o} device${o===1?"":"s"} themselves.`,bad:!1}}function dn(n,e=!0){let r=n.trim();if(!r)return{text:"Optional. No data limit.",bad:!1};let o=Number(r);return!/^\d+(\.\d+)?$/.test(r)||o<0||o>1e5?{text:"A number of GB, up to 100000.",bad:!0}:o===0?{text:"Optional. No data limit.",bad:!1}:{text:e?`Paused after ${r} GB this month, resumed on the 1st.`:`Paused after ${r} GB in total.`,bad:!1}}function Ko(n,e,r,o){let a=n.trim();if(!a)return{text:"Optional. No end date.",bad:!1};let i=r(a,e);return i==null?{text:"Use a date.",bad:!0}:i<0?{text:"That date has passed: access would end at once.",bad:!0}:{text:i===1?`Access ends today (${o(a)}).`:`Access ends in ${i} days (${o(a)}).`,bad:!1}}function Vo(n,e=null){let r=n.trim();return r?Ct(r)?e&&!e(r)?{text:`${r} is not in any home network of this server: nobody would reach it.`,bad:!1}:{text:"",bad:!1}:{text:"Use an IPv4 address, like 192.168.1.10.",bad:!0}:{text:"The device’s address at home.",bad:!0}}function Jo(n){let e=n.split(/[ ,]+/).filter(Boolean);if(!e.length)return{text:"All ports.",bad:!1};let r=e.find(o=>!/^\d{1,5}$/.test(o)||Number(o)<1||Number(o)>65535);return r?{text:`“${r}” is not a port (1–65535).`,bad:!0}:{text:`Port${e.length===1?"":"s"} ${e.join(", ")}.`,bad:!1}}function Yo(n){let e=n.trim();return e?/^https?:\/\//i.test(e)?e.length>300||!/^https?:\/\/[A-Za-z0-9.-]+(:[0-9]+)?(\/[^\s"'<>]*)?$/.test(e)?{text:"Not a usable address (no spaces or quotes).",bad:!0}:{text:"Wrong links are sent there instead of a “Not found”.",bad:!1}:{text:"Must start with http:// or https://.",bad:!0}:{text:"Wrong links get a bare “Not found”.",bad:!1}}function Zo(n){return yt(n)>64?{text:`Up to 64 characters (${yt(n)} now).`,bad:!0}:/[\u0000-\u001f\u007f]/.test(n)?{text:"One line, please.",bad:!0}:{text:"Shown in the browser tab and at the top of the portal.",bad:!1}}function Qo(n,e="phone.myata"){let r=n.trim();return r?/^[a-z0-9-]{1,32}(\.[a-z0-9-]{1,32})*$/.test(r)?{text:`Devices get names like ${e}.${r}.`,bad:!1}:{text:/[A-Z]/.test(r)?"Lowercase only.":"Lowercase letters, digits, dashes and dots.",bad:!0}:{text:`The default, lan: devices get names like ${e}.lan.`,bad:!1}}function Xo(n){let e=n.trim();return e?Ct(e)?{text:`${e} takes over when the tunnel is down.`,bad:!1}:{text:"Use an IPv4 address, or leave it empty.",bad:!0}:{text:"None: without the tunnel those devices have no DNS.",bad:!1}}function er(n){let e=n.trim();return/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{text:`Runs within an hour after ${e} (router time).`,bad:!1}:{text:"Use HH:MM, 00:00–23:59.",bad:!0}}function Zn(n,e,r,o={}){let a=0,i="",s=null;return{help:()=>{let{host:c,port:p}=n(),u=kt(c,p,o.empty??null);if(u.bad||!c.trim())return u;if(s&&s.host===c.trim())return{text:s.text,bad:s.bad};let x=o.idle?.();return{text:x?`${x} Checking where it points…`:`${u.text} Checking where it points…`,bad:!1}},schedule:()=>{let{host:c}=n(),p=kt(c,n().port,o.empty??null);p.bad||!c.trim()||c.trim()===s?.host||(clearTimeout(a),a=window.setTimeout(async()=>{let u=c.trim();i=u;try{let{id:x,port:$}=n(),h=await e(u,x,$);if(i!==u)return;s={host:u,text:h.text,bad:h.status==="error"}}catch{if(i!==u)return;s={host:u,text:p.text,bad:!1}}r()},700))}}}var ir=Ei(rr(),1),Oi=n=>``,ar="#0a0a0a",Qn="#f2f2f2",ji=n=>n.length>300,Et=n=>+n.toFixed(2);function Xn(n,e,r,o,a){return`M${Et(n+a)} ${Et(e)}h${Et(r-2*a)}a${a} ${a} 0 0 1 ${a} ${a}v${Et(o-2*a)}a${a} ${a} 0 0 1 -${a} ${a}h-${Et(r-2*a)}a${a} ${a} 0 0 1 -${a} -${a}v-${Et(o-2*a)}a${a} ${a} 0 0 1 ${a} -${a}z`}function Lt(n,e=3,r=!0,o="plain"){let a=ji(n),i=o==="night",s=(0,ir.default)(0,a?"L":"H");s.addData(n,"Byte"),s.make();let l=s.getModuleCount(),d=l+e*2,c=r&&!a?Math.round(l*.22):0;c&&(l-c)%2&&c++;let p=(l-c)/2,u=p+c,x=(w,v)=>c>0&&w>=p&&w=p&&vi&&(v<7&&w<7||v<7&&w>=l-7||v>=l-7&&w<7),h="";if(i){let w=a?.48:.42;for(let v=0;v${Oi(i?ar:"#fff")}`}let B=``;return i?`${B}${C}`:`${B}${C}`}var Ui={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",expiring:"people",expired_kept:"people",portal_blocked:"problems"},Mt=["connections","people","problems"],ut={connections:"Connections",people:"People",problems:"Problems"},sr={connections:"Connects, disconnects and IP changes",people:"People and their devices added, changed, paused, removed",problems:"Blocked portal sign-ins (tunnels and services are in the service log)"},Bt=n=>Ui[n]??"problems",Ot={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},Gi=["person_added","person_removed","person_changed"];function Ne(n){return n.by?n.by:Gi.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function lr(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var cn=n=>n.sys?["error","repair","down"].includes(n.sys.level):Bt(n.ev.type)==="problems";function pn(n){let e=n.keep_days>0?`${n.keep_days} day${n.keep_days===1?"":"s"}`:"no age limit",r=n.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${n.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${e}, up to ${n.max.toLocaleString("en-GB")} events, ${r}.`}function dr(n,e=120,r=26,o=je(new Date)){let a=Math.max(1,...n),i=t("div",{class:"dl-spark"});return i.style.width=`${e}px`,i.style.height=`${r}px`,n.forEach((s,l)=>{let d=t("i");d.style.height=`${Math.max(6,s/a*100)}%`,s||d.classList.add("zero");let c=n.length-1-l;me(d,()=>[t("div",{class:"dl-tip-title"},c===0?"Today":c===1?"Yesterday":wt(Ht(o,-c)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},ee(s))]),i.appendChild(d)}),i}function Wi(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function cr(n,e){return[n.join(","),...e.map(r=>n.map(o=>Wi(r[o])).join(","))].join(` +`)}function Fi(n){let e=new Map(n.people.map(o=>[o.id,o.name])),r=new Map(n.people.flatMap(o=>o.devices.map(a=>[a.id,a.name])));return{people:e,devices:r}}function Fe(n,e,r,o="",a=[]){let i=Fi(n),s=[...e.map(p=>({ts:p.ts,category:Bt(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:Ne(p)??""})),...a.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?` +${p.detail}`:""}`,where:Ot[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${o?`-${o}`:""}-${l}.${r}`;if(r==="json"){Te(d,JSON.stringify(s,null,2),"application/json");return}Te(d,cr(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var qi=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],pr=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function tt(n,e,r,o,a,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...Mt.map(d=>t("option",{value:d,selected:d===a?"selected":null},ut[d])),i?t("option",{value:"system",selected:a==="system"?"selected":null},"System"):""]),l=t("select",{class:"cbi-input-select"},qi.map(([d,c])=>t("option",{value:d},c)));oe(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])],[ie()," ",H("Clear",async()=>{let d=0;if(s.value!=="system")try{d+=(await A.logsClear({...r,category:s.value,older_days:l.value})).removed}catch(c){U(be(c),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{d+=(await A.serviceLogClear(l.value)).removed}catch(c){ae(),U(`${s.value==="system"?"":`Activity: ${pr(d).toLowerCase()}. `}The service log was not cleared: ${be(c)}`,"error",1e4),o();return}ae(),U(pr(d),"success",3e3),o()},"negative")])}function St(n,e,r,o){let a=n==="device"?`Clears ${r}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${r}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";oe(n==="all"?"Reset all traffic history?":`Reset traffic history for ${r}?`,[t("p",{class:"dl-muted"},a)],[ie()," ",H("Reset",async()=>{await G(()=>A.usageClear(n,e),"Traffic history reset")&&(ae(),o())},"negative")])}function ve(n,e,r){let o=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let a=!o.classList.contains("on");eo(o,a),r?.(a)}},t("i"));return o}function eo(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var Pe=n=>n.classList.contains("on");function we(n,e,r={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let o=t("div",{class:`dl-seg${r.cls?` ${r.cls}`:""}`,role:"radiogroup","aria-label":r.label??null,"data-value":e}),a=()=>o.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===o.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)o.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==o.dataset.value&&(r.optimistic!==!1&&(o.dataset.value=i,a()),r.onChange?.(i))}},s));return a(),o}function qe(n,e,r,o={}){return t("button",{type:"button",...o,class:`dl-chipbtn${e?" on":""}${o.class?` ${o.class}`:""}`,"aria-pressed":e?"true":"false",click:r},n)}function un(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 Ki={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:""},Vi={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 Ji(n){let e={};for(let[r,o]of Object.entries(Vi))n[r]!=null&&n[r]!==""&&(e[o]=String(n[r]));return e}function Yi(n,e){let r=n.amnezia,o=r.obfuscation??{},a=d=>o[d]!=null&&o[d]!==""?String(o[d]):Ki[d],i=r.host.replace(/^\[(.*)\]$/,"$1"),s={H1:a("h1"),H2:a("h2"),H3:a("h3"),H4:a("h4"),I1:a("i1"),I2:a("i2"),I3:a("i3"),I4:a("i4"),I5:a("i5"),Jc:a("jc"),Jmin:a("jmin"),Jmax:a("jmax"),S1:a("s1"),S2:a("s2"),S3:a("s3"),S4:a("s4"),...Ji(o),allowed_ips:r.allowed_ips,client_ip:r.client_ip,client_priv_key:r.client_priv_key,client_pub_key:r.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r +`),hostName:i,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(r.port),protocol_version:o.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return r.dns[0]&&(l.dns1=r.dns[0]),r.dns[1]&&(l.dns2=r.dns[1]),l}function Zi(n){let e="";for(let r=0;r"u")return null;try{let r=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),o=new Uint8Array(await new e.Response(r).arrayBuffer()),a=new Uint8Array(4+o.length);return new DataView(a.buffer).setUint32(0,n.length,!1),a.set(o,4),a}catch{return null}}async function to(n,e,r=!0){let o=new TextEncoder().encode(JSON.stringify(Yi(n,e))),a=r?await Qi(o):null;return`vpn://${Zi(a??o)}`}var mr=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"balanced",title:"Balanced",ic:"shield",stealth:3,speed:4,needs:"v2",text:"AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.",apps:"AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps",short:"AmneziaWG 2.0+ apps"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],jt=n=>mr.find(e=>e.id===n),mn=n=>n.v3?"max":n.v2?"balanced":"off",Ut=n=>n==="standard"?"Standard (old)":n==="strong"?"Strong (old)":null,Xi={v2:"Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},es={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function ur(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(r=>t("i",{class:rdom.content(i,mr.map(l=>{let d=!l.needs||n[l.needs],c=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,s(),r(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},b(l.ic)),t("b",{},l.title),l.id===o?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[ur(l.stealth,"Stealth"),ur(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},d?[b(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[b("alert"),t("span",{},(a?Xi:es)[l.needs])])])}));return s(),i}function hr(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var fr=[["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 ts(n){let e=c=>n[c]!=null&&n[c]!=="",r=fr.filter(([c])=>e(c));if(!r.length)return null;let o=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),a=(c,p,u,x)=>{let $=fr.filter(([h])=>x.includes(h)&&e(h));return $.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[b(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},$.map(([h,m])=>o(h,m)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=r.map(([c,p])=>`${p} = ${n[c]}`).join(` +`),d=t("div",{class:"dl-pgrid"},[a("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),a("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),a("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),a("Signatures","globe",s,["i1","i2","i3","i4","i5"]),a("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),a("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(r.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),ue(l,"Parameters copied")}},"Copy as config")]),d])}function gr(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!r)return document.createTextNode(n);let o=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},r[1])," ",o&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):r[2]])}function ns(n){let e=!1,r=t("pre",{class:"dl-conf"}),o=()=>dom.content(r,n.conf.split(` `).flatMap((s,l)=>l?[` -`,cr(s,e)]:[cr(s,e)])),a=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(a,[b(e?"x":"key"),e?"Hide key":"Show key"]),r()}},[b("key"),"Show key"]);r();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),H([b("download")," Download"],()=>Se(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),a,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),pe(n.conf,"Configuration copied")}},[b("copy"),"Copy"])]),o])])}function eo(n){let e=n.amnezia.obfuscation??{},o={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([r,a])=>a==null||a===""||a===(o[r]??"0"))}async function zi(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await Xn(n,`${n.server} · ${n.person} · ${n.name}`),r={qr:()=>t("div",{class:"dl-qr-pane"},[Xe(Ct(n.conf),"dl-qr"),t("span",{class:"dl-sub"},eo(n)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},o),H("Copy",()=>pe(o,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>Hi(n)},a=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(c=>c.classList.toggle("on",c.dataset.id===l)),dom.content(a,r[l]())};for(let[l,c]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},c));return s(e),t("div",{class:"dl-stack gap12"},[i,a])}async function Ni(n,e,o,r){let a=jt(o),s=n.st.people.filter(c=>c.server===e.id).reduce((c,d)=>c+d.devices.length,0);await se(r?"Generate new disguise values?":`Switch to ${a.title}?`,`${s} AmneziaWG device${s===1?" stops":"s stop"} connecting until ${s===1?"it imports its":"they import their"} configuration again (from their personal link or from you).${o==="max"?" They need an app with AmneziaWG 3.1.":o==="balanced"?" They need an app with AmneziaWG 2.0 or newer.":""}${n.st.servers.length===1&&s?" To keep the old disguise for some people, add a second server and move them there.":""}`,r?"Generate and apply":"Switch and apply",!0)&&await W(()=>A.serverObfuscation(e.id,o),r?"New values applied":`${a.title} applied`)&&(U("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function Ri(n,e){let o=n.st,r=ie(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=ie(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=ie(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=jt(e.preset)?e.preset:void 0,l=s??un(o.awg),c=H("",()=>Ni(n,e,l,l===s),"neutral"),d=()=>dom.content(c,l===s?[b("reset")," Generate new values"]:[`Switch to ${jt(l).title}`]);d();let p=o.awg_state?.tools!==!1,u=[],w=fe("UDP port",r,()=>It(Number(r.value),u,`Opened on the WAN firewall automatically.${Number(r.value)===4500?" 4500 is IPsec’s port: most networks let it through.":""}`));A.serverPorts(e.id).then(m=>{u=m.udp_taken??[],w.refresh()}).catch(()=>{});let C=fe("MTU",a,()=>Bo(a.value,e.mtus)),g=fe("Keep-alive",i,()=>Oo(i.value));return Rt("",[lr("AmneziaWG",e.ifname),ge("globe","Listening","Where devices reach this core from the internet",[w]),ge("file","In every device configuration","Changing these marks devices “Update config” until they import again",[C,g]),ge("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Ut(e.preset)?ct("warn",[t("b",{},Ut(e.preset))," is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to ",t("b",{},"Balanced")," or ",t("b",{},"Maximum"),": devices import their configuration again."]):"",mn(o.awg,l,m=>{l=m,d()},s,p),p&&!o.awg.v3?ct("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",Ai(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),c])]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[de("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),de("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),de("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),H([b("copy")],()=>pe(e.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),H("Save",()=>{let m=ze([w,C,g]);if(m){U(m,"warning");return}return n.save({port:r.value,mtu:a.value,keepalive:i.value},"AmneziaWG saved")},"positive")])}function Ii(n){let e=jt(n.preset),o=n.obf??{},r=(s,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(c=>t("i",{class:c+o[s]).map(s=>`${s.toUpperCase()} ${o[s]}`);return i.length&&a.push(i.slice(0,2).join(" · ")+(i.length>2?` +${i.length-2}`:"")),["h1","h2","h3","h4"].some(s=>o[s]&&o[s]!==String(["h1","h2","h3","h4"].indexOf(s)+1))&&a.push("H1–H4 random"),o.i1&&a.push(/0x(8580|0100)0001/.test(o.i1)?"DNS-like first packets":"Signature packets"),o.header_protection_key&&a.push("Encrypted headers"),a.length||a.push(e?.id==="off"?"Plain WireGuard":"No values yet"),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Disguise"),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),t("div",{class:"dl-disg-id"},[t("span",{class:"dl-disg-ic"},b(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:Ut(n.preset)??"Custom"),t("span",{class:"dl-sub"},e?e.short:Ut(n.preset)?"Switch to Balanced or Maximum":"Set by hand")])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},"Stealth"),r(e.stealth,"acc"),t("span",{},"Speed"),r(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},a.map(s=>t("span",{},s)))])}var to={id:"awg",label:"AmneziaWG",settingsCard:Ri,overviewTile:Ii,connectBlock:zi,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>Xn(n,`${n.server} · ${n.person} · ${n.name}`)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var Bi={awg:to};function Be(n){return Bi[n?.core||"awg"]??to}function Mt(n,e){return Be(n.find(o=>o.id===e))}var Oi=2,Wt=new Set,no=null,hn=null;async function pr(){if(document.visibilityState!=="visible"||!Wt.size)return;let n=await A.rev().catch(()=>null);if(!n)return;let e=no!=null&&n.rev!==no;no=n.rev,n.version&&(hn&&n.version!==hn?(U(`Dawnline was updated to ${n.version}: reload the page.`,"warning",15e3),hn=null):hn??(hn=n.version)),e&&Wt.forEach(o=>o())}function fn(n){return Wt.add(n),poll.add(pr,Oi),()=>{Wt.delete(n),Wt.size||poll.remove(pr)}}var oo="https://unpkg.com/maplibre-gl@6.14.0/dist",ur={module:"sha384-q26X6R1yFeg0QR9SHHn6U3Nb0ddRRTtwxsahubv5R89/v5nijKpk9KviUp9ZLySk",css:"sha384-1TZtfVz7qtwR5vD7cMwjGT+9uiK4lqE3pbUOPwYO6OCpb+TYP0S9vLIhG02JCU04"},mr="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",hr="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",ji={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Gt=null;function Ui(n){if(n.appendChild(t("link",{rel:"stylesheet",href:`${oo}/maplibre-gl.css`,integrity:ur.css,crossorigin:"anonymous"})),Gt)return Gt;let e=`${oo}/maplibre-gl.mjs`;return Gt=new Promise((r,a)=>{let i=t("link",{rel:"modulepreload",href:e,integrity:ur.module,crossorigin:"anonymous"});i.addEventListener("load",()=>r()),i.addEventListener("error",()=>a(new Error("integrity"))),document.head.appendChild(i)}).then(()=>import(e)).then(r=>(r.getWorkerUrl()||r.setWorkerUrl(`${oo}/maplibre-gl-worker.mjs`),r),r=>{throw Gt=null,new Error(r?.message==="integrity"?"The map library from the CDN is not the expected file: not loading it.":"Could not load the map library (no internet access from this browser?)")}),Gt}function gn(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}var Wi=10,fr=30,Gi=62,gr=4.5,Fi=7,ro="#3b82f6",vn="#8a8a8a";function vr(n,e,o=.2,r=64){let[a,i]=n,[s,l]=e,c=s-a,d=c>180?s-360:c<-180?s+360:s,p=d-a,u=l-i,w=Math.hypot(p,u);if(w===0||o===0)return[n,[d,l]];let C=-u/w,g=p/w,m=w*o,k=(a+d)/2+C*m,I=(i+l)/2+g*m,x=[],v=Math.max(2,Math.floor(r));for(let $=0;$<=v;$+=1){let E=$/v,y=1-E;x.push([y*y*a+2*y*E*k+E*E*d,y*y*i+2*y*E*I+E*E*l])}return x}function ao(n,e){let o=new Map;for(let r of n.geo.points){if(n.person&&r.person!==n.person||n.device&&r.device!==n.device||(e==="online"?!r.online:n.now-r.ts>ji[e]))continue;let a=n.device?`${r.city}|${r.cc}`:n.person?`${r.device}|${r.city}|${r.cc}`:r.device,i=o.get(a);(!i||r.online&&!i.online||r.online===i.online&&r.ts>i.ts)&&o.set(a,r)}return[...o.values()]}function io(n,e){let o=0;return ao(n,e).sort((r,a)=>Number(a.online)-Number(r.online)||a.ts-r.ts).map(r=>({...r,n:r.online?0:++o}))}var tt=class{constructor(e,o="online",r=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.piles=new Map;this.dock=null;this.dockKey="";this.dockQuiet=!1;this.piledKeys=new Set;this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.range=o,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${r}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await Ui(this.el)}catch(r){this.status.textContent=r.message;return}this.map=new this.gl.Map({container:this.el,style:gn()?mr:hr,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let r=this.el.querySelector(".maplibregl-ctrl-attrib");r?.classList.remove("maplibregl-compact-show"),r?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let o=gn();this.theme=new MutationObserver(()=>{!this.map||gn()===o||(o=gn(),this.map.setStyle(o?mr:hr))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],ro,vn],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],ro,vn],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-trail",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-trail",type:"line",source:"dl-trail",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":vn,"line-width":1.5,"line-opacity":.85,"line-dasharray":[0,2.5]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?ro:vn,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dropCard();for(let e of this.piles.values())e.marker.remove();this.piles.clear(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let o=new Map;for(let r of e){let a=`${r.person}|${r.city||`${r.lat.toFixed(1)},${r.lon.toFixed(1)}`}|${r.cc}`,i=o.get(a);i||(i={key:a,person:r.person,lat:r.lat,lon:r.lon,city:r.city,country:r.country,cc:r.cc,asn:r.asn,org:r.org,online:!1,ts:0,points:[]},o.set(a,i)),i.points.push(r),i.online||(i.online=r.online),i.ts=Math.max(i.ts,r.ts)}return[...o.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,o=this.groups(ao(e,this.range)),r=e.person||e.device?null:e.geo.home;for(let d of this.markers)d.remove();this.markers=[];let a=e.person||e.device?null:Ki(o,r),i=o.map(d=>({g:d,at:a?.get(d.key)??[d.lon,d.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:d})=>({type:"Feature",properties:{online:d.online,key:d.key},geometry:{type:"Point",coordinates:[d.lon,d.lat]}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:r?i.map(({g:d,at:p})=>({type:"Feature",properties:{online:d.online,person:d.person,key:d.key},geometry:{type:"LineString",coordinates:vr([r.lon,r.lat],p)}})):[]}),r){let d=t("span",{class:"dl-mk-host"});d.innerHTML=`${At("server","dl-mk-host-ic")}`,this.dock=d.appendChild(t("span",{class:"dl-mk-dock"})),this.dockQuiet=this.dockKey!=="",this.dockKey="";let p=t("div",{class:"dl-mk-hub",title:`Home router${r.city?` · ${r.city}`:""}${r.org?` · ${r.org}`:""}`},[d,t("span",{class:"dl-mk-label chip"},r.city||"Home")]);p.addEventListener("mouseenter",()=>this.showMerged(r.city||"the server")),p.addEventListener("mouseleave",()=>this.focus(this.focused)),p.addEventListener("click",()=>this.zoomToMerged()),this.add(p,[r.lon,r.lat],!0)}let s=e.device?[...i].sort((d,p)=>Number(d.g.online)-Number(p.g.online)||d.g.ts-p.g.ts):[];this.map.getSource("dl-trail")?.setData({type:"FeatureCollection",features:s.length>1?[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:s.slice(1).flatMap((d,p)=>vr(s[p].at,d.at))}}]:[]});let l=new Map(e.device?io(e,this.range).map(d=>[`${d.city}|${d.cc}`,d.n]):[]);this.people=[];for(let{g:d,at:p}of i){let u=d.points.length,w=e.people.find(k=>k.id===d.person);if(e.person){let k=e.device?this.stepMarker(d,p,w,l.get(`${d.points[0].city}|${d.points[0].cc}`)??0):this.placeMarker(d,p,w);this.add(k,p);continue}let C=d.points.map(k=>w?.devices.find(I=>I.id===k.device)?.kind??"other"),g=t("span",{class:"dl-mk-badge"});g.innerHTML=u<=2?C.map(k=>At(k,"dl-mk-badge-ic")).join(""):String(u);let m=t("button",{type:"button",class:`dl-mk${d.online?" online":""}`,"aria-label":`${w?.name??"Someone"}: ${u} device${u===1?"":"s"} in ${d.city||"an unknown city"}`},[t("span",{class:"dl-mk-av"},[He(w?.name??"?"),g]),t("span",{class:"dl-mk-label below"},d.city||d.cc||"?")]);m.addEventListener("mouseenter",()=>this.focus(d.person)),m.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:m,person:d.person}),m.addEventListener("click",k=>{k.stopPropagation(),this.openPopup(d,p,m)}),this.add(m,p,!1,w?.name??"Someone",`${d.city||d.cc||"?"} · ${d.online?"now":re(d.ts,e.now)}`,d.key,d)}this.declutter();let c=i.map(d=>d.g.key).sort().join(";");if(c!==this.fitKey&&!this.popup){let d=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=c,this.fitted=!0,r&&!i.length){let p={center:[r.lon,r.lat],zoom:12};d?this.glide(12,()=>this.map.flyTo({...p,duration:1200})):this.map.jumpTo(p)}else{let p=i.map(u=>u.at);r&&(p.length===0||this.range!=="online"||i.some(u=>u.g.online))&&p.push([r.lon,r.lat]),this.fit(p,d)}}this.status.textContent=i.length||r?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(d=>d.person===this.focused)?this.focused:null)}add(e,o,r=!1,a,i,s,l){s&&this.foldedKeys.has(s)&&e.classList.add("merged"),s&&this.piledKeys.has(s)&&e.classList.add("piled"),e.dataset.key=s??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let c=new this.gl.Marker({element:e}).setLngLat(o).addTo(this.map);this.markers.push(c),this.slots.push({marker:c,el:e,at:o,fixed:r,who:a,where:i,g:l})}declutter(){if(!this.map)return;let e=this.map.getZoom();this.el.classList.toggle("dl-lod-far",e=gr&&e{let l=this.map.project(s.at),c=s.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:l.x,y:l.y,r:(c?.offsetWidth||24)/2+3,fixed:s.fixed}}),r=o.filter(s=>s.fixed);this.merged=[],this.foldedKeys.clear();let a=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));o.forEach((s,l)=>{if(s.fixed)return;let c=this.slots[l],d=c.el.classList.contains("merged")?12:6,p=r.find(u=>Math.hypot(u.x-s.x,u.y-s.y)*a{let d=this.slots[c];!d||d.fixed||(o[c].fixed&&([s,l]=[0,0]),d.marker.setOffset([s,l]),Vi(d.el,s,l))})}closePopup(e=!1){let o=this.popup;if(!o||o.card.classList.contains("leaving"))return;o.card.classList.add("leaving"),setTimeout(()=>{this.popup===o&&this.dropCard()},140);let r=this.before;if(this.before=null,!r)return;let a=()=>this.map?.flyTo({...r,duration:800});if(!e)return a();let i=!1,s=()=>{i||(i=!0,window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0),setTimeout(a,0))};window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),setTimeout(s,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},`Near ${e}`)," · click to zoom in"]),...this.merged.map(o=>t("div",{class:"dl-map-card-row"},[t("span",{},o.who),t("span",{class:"dl-faint"},o.where)]))]),this.card.classList.add("on"))}paintDock(){let e=this.dock;if(!e)return;let o=this.merged.map(a=>`${a.key}:${a.online?1:0}`).join("|");if(o===this.dockKey)return;this.dockKey=o,e.parentElement?.classList.toggle("docked",this.merged.length>0);let r=this.slots.find(a=>a.fixed).at;this.merged.length&&xr(e,this.merged,this.faceActions(()=>[r]),this.dockQuiet),this.dockQuiet=!1}faceActions(e){return{click:(o,r)=>this.openFace(o,r,e()),hover:o=>this.focus(o?.g?.person??null)}}pileUp(e){let o=new Set;if(!this.data?.person&&!this.data?.device){let r=e.flatMap((l,c)=>!l.fixed&&this.slots[c].el.querySelector(":scope > .dl-mk-av")?[c]:[]),a=new Map(r.map(l=>[l,l])),i=l=>a.get(l)===l?l:i(a.get(l));for(let l of r)for(let c of r){if(c<=l)continue;let d=this.slots[l].el.classList.contains("piled")&&this.slots[c].el.classList.contains("piled");Math.hypot(e[l].x-e[c].x,e[l].y-e[c].y)this.slots[m]),d=c.map(br),p=d.map(m=>m.key).sort().join(",");o.add(p);let u=[c.reduce((m,k)=>m+k.at[0],0)/c.length,c.reduce((m,k)=>m+k.at[1],0)/c.length],w=this.piles.get(p);if(!w){let m=t("span",{class:"dl-mk-pile-box"}),k=[...new Set(c.map(v=>v.g?.city||v.g?.cc||"?"))],I=t("div",{class:"dl-mk-pile"},[m,t("span",{class:"dl-mk-label below"},k.length===1?k[0]:`${c.length} people`)]);w={marker:new this.gl.Marker({element:I}).setLngLat(u).addTo(this.map),el:I,box:m,faces:d},I.addEventListener("mouseleave",()=>this.focus(this.focused));let x=w;I.addEventListener("click",v=>{v.stopPropagation(),this.zoomInTo(x.faces.map($=>$.at),!1)}),this.piles.set(p,w)}w.faces=d;let C=w;xr(w.box,d,this.faceActions(()=>C.faces.map(m=>m.at)));for(let m of l)this.slots[m].el.classList.add("piled"),Object.assign(e[m],{r:0,fixed:!0});let g=this.map.project(u);e.push({x:g.x,y:g.y,r:(w.el.offsetWidth||60)/2+3,fixed:!0})}}this.piledKeys=new Set(this.slots.filter(r=>r.el.classList.contains("piled")).map(r=>r.el.dataset.key??"")),this.slots.forEach((r,a)=>{(!e[a].fixed||r.fixed||r.el.classList.contains("merged"))&&r.el.classList.remove("piled")});for(let[r,a]of this.piles)o.has(r)||(this.piles.delete(r),a.el.classList.add("out"),setTimeout(()=>a.marker.remove(),200))}zoomToMerged(){!this.map||!this.merged.length||this.zoomInTo([this.slots.find(e=>e.fixed).at,...this.merged.map(e=>e.at)],!1)}openFace(e,o,r){if(!e.g)return;if(r.every(i=>bn(i,e.at)<1))return this.openPopup(e.g,e.at,o);let a=()=>{let i=this.slots.find(s=>s.el.dataset.key===e.key);i?.g&&!i.el.classList.contains("merged")&&!i.el.classList.contains("piled")&&this.openPopup(i.g,i.at,i.el)};this.zoomInTo(this.nearby(e.at),!0)?this.map.once("moveend",a):a()}nearby(e){return[e,...this.slots.filter(o=>!o.fixed&&o.at!==e&&bn(o.at,e)<=fr).map(o=>o.at)]}zoomInTo(e,o){let r=new this.gl.LngLatBounds;for(let p of e)r.extend(p);let a=e.some(p=>e.some(u=>bn(p,u)>fr)),i=this.map.cameraForBounds(r,{padding:50,maxZoom:a?12:Wi}),s=this.map.getZoom(),l=e.map(p=>this.map.project(p)),c=0;l.forEach((p,u)=>l.slice(u+1).forEach(w=>{let C=Math.hypot(p.x-w.x,p.y-w.y),g=s+Math.log2(Gi/Math.max(C,1e-6));g<=12&&(c=Math.max(c,g))}));let d=Math.min(12,Math.max(i?.zoom??0,c));return d<=s+.05?!1:(o&&!this.before&&(this.before={center:this.map.getCenter().toArray(),zoom:s}),this.map.flyTo({center:i?.center??r.getCenter(),zoom:d,duration:800}),!0)}placeMarker(e,o,r){let a=this.data.now,i=[...e.points].sort((u,w)=>Number(w.online)-Number(u.online)||w.ts-u.ts)[0],s=r?.devices.find(u=>u.id===i.device)?.kind??"other",l=e.points.length,c=t("span",{class:"dl-mk-tile"});c.innerHTML=At(s,"dl-mk-tile-ic")+(l>1?`${l}`:"");let d=e.online?"now":re(e.ts,a),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(a-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":`${l} device${l===1?"":"s"} in ${e.city||"an unknown city"}, ${d}`},[c,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},d)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,o,p)}),p}stepMarker(e,o,r,a){if(e.online)return this.placeMarker(e,o,r);let i=re(e.ts,this.data.now),s=t("button",{type:"button",class:"dl-mk place step","aria-label":`${a}: ${e.city||"an unknown city"}, ${i}`},[t("span",{class:"dl-mk-tile sm"},String(a)),t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",` · ${i}`])]);return s.addEventListener("click",l=>{l.stopPropagation(),this.openPopup(e,o,s)}),s}focus(e){this.focused=e;for(let s of this.people)s.el.classList.toggle("dim",!!e&&s.person!==e),s.el.classList.toggle("hl",s.person===e);let o=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let s of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(s)&&this.map.setPaintProperty(s,"line-opacity",o);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let r=this.data,a=r.people.find(s=>s.id===e),i=ao(r,this.range).filter(s=>s.person===e).sort((s,l)=>Number(l.online)-Number(s.online)||l.ts-s.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},a?.name??e),` · ${i.length} device${i.length===1?"":"s"}`]),...i.map(s=>t("div",{class:"dl-map-card-row"},[t("span",{},a?.devices.find(l=>l.id===s.device)?.name??"Device"),t("span",{class:"dl-faint"},`${s.city||s.cc||"?"} · ${s.online?"now":re(s.ts,r.now)}`)]))])}fit(e,o=!1){if(!e.length)return;let r=(d,p)=>{let u=Math.PI/180,w=(p[1]-d[1])*u,C=(p[0]-d[0])*u,g=Math.sin(w/2)**2+Math.cos(d[1]*u)*Math.cos(p[1]*u)*Math.sin(C/2)**2;return 12742*Math.asin(Math.sqrt(g))},a=[e.reduce((d,p)=>d+p[0],0)/e.length,e.reduce((d,p)=>d+p[1],0)/e.length],i=e;if(e.length>=5){let d=[...e].sort((p,u)=>r(a,p)-r(a,u));i=d.slice(0,Math.ceil(d.length*.9))}let s=new this.gl.LngLatBounds(i[0],i[0]);i.forEach(d=>s.extend(d));let l=this.el.clientHeight||380,c={padding:{top:Math.min(60,l/5),bottom:Math.min(40,l/8),left:48,right:48},maxZoom:this.data?.person?11:12};o?this.glide(this.map.cameraForBounds(s,c)?.zoom??null,()=>this.map.fitBounds(s,{...c,duration:1200})):this.map.fitBounds(s,{...c,duration:0})}glide(e,o){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),o()}openPopup(e,o,r){let a=this.data,i=[e.city,e.cc||e.country].filter(Boolean).join(", "),s=[...new Set(e.points.map(v=>v.person))],l=e.points.sort((v,$)=>Number($.online)-Number(v.online)||$.ts-v.ts).map(v=>{let $=a.people.find(y=>y.id===v.person),E=$?.devices.find(y=>y.id===v.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(v.person,v.device)},[t("span",{class:`dl-pop-dot${v.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},$?.name??v.person),` · ${E?.name??"device"}`]),t("span",{class:"dl-faint dl-nowrap"},v.online?"now":re(v.ts,a.now))])}),c=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},b("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||"Unknown network"),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),t("div",{class:"dl-pop-list"},l),s.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${a.people.find(v=>v.id===s[0])?.name??"person"}`)]):""]);this.zoomInTo(this.nearby(o),!0),this.dropCard();let d=t("div",{class:"dl-root dl-popcard",role:"dialog"},[t("span",{class:"dl-popcard-tip"}),c]);document.body.appendChild(d);let p=this.el,u=r?.querySelector(".dl-mk-av, .dl-mk-tile")??r??null,w=()=>{if(!u)return;let v=u.getBoundingClientRect(),$=p.getBoundingClientRect(),E=v.left+v.width/2,y=v.top+v.height/2;d.classList.toggle("away",E<$.left||E>$.right||y<$.top||y>$.bottom);let z=d.offsetWidth,h=d.offsetHeight,f=v.top-h-12>=8||v.top>window.innerHeight-v.bottom,T=Math.min(Math.max(8,E-z/2),window.innerWidth-z-8);d.classList.toggle("above",f),d.classList.toggle("below",!f),d.style.left=`${T}px`,d.style.top=`${f?v.top-h-12:v.bottom+12}px`,d.style.setProperty("--tip-x",`${E-T}px`)},C=v=>{v.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},g=v=>{v.key==="Escape"&&this.closePopup()},m=v=>{v.target instanceof Element&&v.target.closest(".dl-popcard")||this.closePopup()},k=()=>this.closePopup();this.map.on("move",w),window.addEventListener("scroll",m,{capture:!0,passive:!0}),window.addEventListener("resize",w),document.addEventListener("pointerdown",C,!0),document.addEventListener("keydown",g);let I=$e(k);window.addEventListener("pagehide",k),this.popup={card:d,off:()=>{this.map?.off("move",w),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",w),document.removeEventListener("pointerdown",C,!0),document.removeEventListener("keydown",g),I(),window.removeEventListener("pagehide",k)}};let x=window.setInterval(()=>{if(this.popup?.card!==d)return clearInterval(x);(!p.isConnected||!p.getClientRects().length)&&this.dropCard()},400);w()}};function qi(n,e=6){let o=n.map(r=>({x:r.x,y:r.y}));for(let r=0;r<16;r++){let a=!1;for(let i=0;i[r.x-n[a].x,r.y-n[a].y])}function Ki(n,e){let o=new Map,r=e?[[e.lon,e.lat]]:[],a=i=>r.some(s=>bn(i,s)<1.3);for(let i of[...n].sort((s,l)=>s.key>>12)/1048575),c=(s&4095)/4096*2*Math.PI,d=[i.lon,i.lat];for(let p=0;p<24;p++){let u=c+p*2.39996,w=Math.min(8,l+p*.25);if(d=[i.lon+w*Math.sin(u)/(111.32*Math.cos(i.lat*Math.PI/180)),i.lat+w*Math.cos(u)/111.32],!a(d))break}r.push(d),o.set(i.key,d)}return o}function Ji(n){let e=2166136261;for(let o=0;o>>0}function br(n){return{key:n.el.dataset.key??"",who:n.who??"Someone",where:n.where??"",online:!!n.g?.online,at:n.at,badge:n.el.querySelector(".dl-mk-badge")?.innerHTML??"",g:n.g}}function xr(n,e,o,r=!1){let a=e.length>3,i=()=>[...n.children].filter(g=>!g.classList.contains("out")),s=new Map(i().map(g=>[g,g.getBoundingClientRect().left])),l=n.getBoundingClientRect().width,c=new Map;n.querySelectorAll(".dl-mk-face:not(.out)").forEach(g=>c.set(g.dataset.key??"",g));let d=n.querySelector(".dl-mk-more:not(.out)"),p=g=>{Object.assign(g.style,{position:"absolute",left:`${g.offsetLeft}px`,top:`${g.offsetTop}px`,transform:""}),g.classList.add("out"),setTimeout(()=>g.remove(),200)},u=[];for(let g of e.slice(0,a?2:3)){let m=c.get(g.key);if(c.delete(g.key),!m){let x=t("button",{type:"button",class:`dl-mk-face${r?"":" in"}`,"data-key":g.key},[t("span",{class:"dl-mk-av"},He(g.who)),t("span",{class:"dl-mk-badge"})]);x.addEventListener("animationend",()=>x.classList.remove("in"),{once:!0}),m=x}let k=m,I=k.querySelector(".dl-mk-badge");I.innerHTML!==g.badge&&(I.innerHTML=g.badge),k.title=`${g.who} · ${g.where}`,k.setAttribute("aria-label",`${g.who}, ${g.where}`),k.classList.toggle("on",g.online),k.onclick=x=>{x.stopPropagation(),o.click(g,k)},k.onmouseenter=()=>o.hover(g),k.onmouseleave=()=>o.hover(null),u.push(k)}for(let g of c.values())p(g);if(a){if(!d){d=t("span",{class:`dl-mk-more${r?"":" in"}`});let g=d;g.addEventListener("animationend",()=>g.classList.remove("in"),{once:!0})}d.textContent=`+${e.length-2}`,u.push(d)}else d&&p(d);let w=null;for(let g of u)(w?w.nextElementSibling:n.firstElementChild)!==g&&(w?w.after(g):n.prepend(g)),w=g;for(let g of u){let m=s.get(g);if(m==null)continue;let k=m-g.getBoundingClientRect().left;Math.abs(k)<.5||(g.style.transition="none",g.style.transform=`translateX(${k}px)`,g.offsetWidth,g.style.transition="",g.style.transform="")}n.style.width="";let C=n.getBoundingClientRect().width;if(l&&Math.abs(C-l)>.5){n.style.width=`${l}px`,n.offsetWidth,n.style.width=`${C}px`;let g=()=>{n.style.width="",n.removeEventListener("transitionend",g)};n.addEventListener("transitionend",g),setTimeout(g,400)}}function bn(n,e){let o=Math.PI/180,r=Math.sin((e[1]-n[1])*o/2)**2+Math.cos(n[1]*o)*Math.cos(e[1]*o)*Math.sin((e[0]-n[0])*o/2)**2;return 12742*Math.asin(Math.min(1,Math.sqrt(r)))}function Vi(n,e,o){let r=n.querySelector(":scope > .dl-mk-ptr"),a=Math.hypot(e,o);if(a<1){r?.remove();return}r||(r=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(r));let i=r.firstElementChild,s=r.lastElementChild;i.style.width=`${a}px`,i.style.transform=`rotate(${Math.atan2(-o,-e)}rad)`,s.style.transform=`translate(${-e}px, ${-o}px)`}function Tt(n,e,o=!0){let r=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],a=t("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of r)i==="online"&&!o||a.appendChild(t("button",{type:"button",role:"tab",class:i===n?"on":"","data-v":i,click:()=>{a.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===i)),e(i)}},s));return a}function St(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function ke(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function Yi(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function so(n,e,o=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:"Copy",click:()=>pe(e,`${n} copied`)},[t("span",{},e),b("copy")])])}function xn(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var wr={connect:["ok","Connected","plug"],disconnect:["","Went offline","plug"],roam:["","Changed network","network"],device_added:["ok","Added","plus"],device_removed:["","Removed","trash"],device_keys:["","New keys","reset"]};function Zi(n,e,o){let r=n.filter(a=>a.device===e&&wr[a.type]).reverse().slice(0,12);return r.length?t("div",{class:"dl-dev-log"},r.map(a=>{let[i,s,l]=wr[a.type],c=a.type==="connect"?[a.detail?t("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?t("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[t("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[t("span",{class:"dl-muted"},Ne(a)==="portal"?" on the portal":Ne(a)==="admin"?" by you":"")]:[],d=new Date(a.ts*1e3);return t("div",{class:`dl-dev-log-row${Ne(a)==="admin"?" dl-ev-by-admin":""}`},[Ne(a)==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):t("span",{class:`dl-ev-tile ev ${i}`},b(l)),t("span",{class:"dl-row-main"},[t("span",{},s),...c]),t("span",{class:"dl-faint dl-nowrap",title:d.toLocaleString()},re(a.ts,o))])})):t("div",{class:"dl-sub"},"No activity yet.")}async function yr(n,e,o){let r=await A.status(1).catch(()=>null),a=r?.people.find(s=>s.id===n),i=a?.devices.find(s=>s.id===e);r&&a&&i&&We(a,i,{...o,geo:r.geo,now:r.now,today:Ie(r.series),core:Mt(r.servers,a.server)})}async function We(n,e,o){let r=await W(()=>A.deviceConfig(e.id));if(!r)return;let a=o.core??Be(null),i=e,s=n,l=o.geo,c=o.now,d=o.today??je(new Date),p=await a.connectBlock(r,e.kind==="phone"||e.kind==="tablet"?"qr":"file"),u=t("div",{class:"dl-drawer-title"}),w=t("div",{}),C=t("div",{}),g=t("div",{},t("div",{class:"dl-sub"},"Loading…")),m=[],k=ne=>{m=ne.filter(O=>O.device===i.id),dom.content(g,Zi(ne,i.id,c))},I=async(ne=!1)=>{let O=o.events?.();if(O&&!ne)return k(O);let F=await A.events(2e3,n.id).catch(()=>null);F&&k(F.events)},x="30d",v=null,$=t("div",{class:"dl-dplaces"}),E=()=>({geo:l,people:[s],now:c??Date.now()/1e3,person:s.id,device:i.id}),y=()=>{if(!l?.enabled)return;let ne=io(E(),x);dom.content($,ne.length?ne.map(O=>t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${O.online?" live":""}`},O.online?b(i.kind):String(O.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[O.city||O.cc||"Unknown city",O.org?t("span",{class:"dl-muted"},` · ${O.org}`):""]),t("span",{class:"dl-mono dl-faint"},O.ip)]),t("span",{class:O.online?"dl-dplace-now":"dl-faint dl-nowrap"},O.online?"now":re(O.ts,c))])):t("div",{class:"dl-sub"},"No locations in this period."))},z=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${i.online?" on":""}`},b(i.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},i.name),H([b("edit")],()=>T(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${s.name} · ${Ze[i.kind]}`)])]);let ne=i.spark.reduce((O,F)=>O+F,0);dom.content(w,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},"Status"),nn(i,c,"Waiting for the first connection",s)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"This month"),t("b",{},X(i.month[0]+i.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${X(i.month[1])} ↑ ${X(i.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"Last 7 days"),t("b",{},X(ne)),or(i.spark,120,22,d)])])),dom.content(C,t("div",{class:"dl-kv2"},[so("Tunnel address",i.address),i.hostname&&s.access!=="internet"?so("Local address",i.hostname):"",i.endpoint&&!l?.points.some(O=>O.device===i.id&&O.ip===i.endpoint)?xn("Client IP",i.endpoint):"",xn("Total",t("span",{class:"dl-kv-act"},[`↓ ${X(i.total[1])} · ↑ ${X(i.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Lt("device",i.id,i.name,()=>setTimeout(f,300))},"Reset")])),xn("Added",`${Yi(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),r.amnezia.client_pub_key?so("Public key",r.amnezia.client_pub_key):xn("Public key","—")])),dom.content(S,[H([b(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await W(()=>A.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await f()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),H([b("key")," New keys"],async()=>{if(!await se("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await W(()=>A.deviceRotate(i.id),"New keys generated")&&(o.refresh(),ue.close(),await yr(s.id,i.id,o))}),t("span",{class:"dl-spacer"}),H([b("trash")," Remove"],async()=>{await se(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await W(()=>A.deviceDelete(i.id),"Device removed")&&(ue.close(),o.refresh())},"negative")])},h=async()=>{let ne=await A.status(1).catch(()=>null),O=ne?.people.find(P=>P.id===s.id),F=O?.devices.find(P=>P.id===i.id);!ne||!O||!F||(s=O,i=F,l=ne.geo,c=ne.now,d=Ie(ne.series),z(),v?.update(E()),y())},f=async()=>{await h(),o.refresh()},T=()=>{let ne=t("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48}),O=s.devices.filter(P=>P.id!==i.id).map(P=>P.name),F=ye("Name",ne,()=>_e(ne.value,O,"Shown in the portal and in the app."));te(`Rename ${i.name}`,[F],[ae()," ",H("Save",async()=>{let P=F.help();if(P.bad){U(P.text,"warning");return}await W(()=>A.deviceUpdate(i.id,ne.value,void 0),"Renamed")&&(oe(),await f())},"positive")]),setTimeout(()=>ne.select(),50)},S=t("div",{class:"dl-drawer-actions"}),N=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Connect")]),i.config_stale?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",p]),G=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Activity"),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Fe({people:[s]},m,"csv",i.id)},"Export"),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>et(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{I(!0),o.refresh()})},"Clear"),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),g]),q=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},"Details")),C]),V="";l?.enabled&&(v=new tt({openPerson:ne=>location.href=ke(ne),openDevice:(ne,O)=>location.href=ke(ne,O)},x,220),V=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Locations"),Tt(x,ne=>{x=ne,v?.setRange(ne),y()},!1)]),t("div",{class:"dl-dmap"},v.el),$]),y());let R=!i.handshake||i.config_stale,J=t("div",{class:"dl-stack gap16"},R?[w,N,q,V,G]:[w,q,V,G,N]);I();let Q=()=>{h(),I()},le=fn(Q),he=window.setInterval(Q,3e4),ue=Ho(u,J,S,()=>{clearInterval(he),le(),v?.destroy()});z(),v&&requestAnimationFrame(()=>v?.mount(E()))}function kr(n,e,o,r){let a=r.core??Be(null),i=()=>W(()=>A.deviceConfig(o.id)),s=[{label:"Show QR code",icon:b("qr"),run:async()=>{let l=await i();l&&te(`${o.name} · QR code`,t("div",{class:"dl-qr-pane"},[Xe(Ct(a.qrText(l)),"dl-qr"),t("span",{class:"dl-sub"},eo(l)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),ae("Close"))}},{label:a.file.label,icon:b("download"),run:async()=>{let l=await i();if(!l)return;let c=a.file.make(l);Se(c.name,c.text,"application/octet-stream")}},a.appKey?{label:a.appKey.label,icon:b("copy"),run:async()=>{let l=await i();l&&pe(await a.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:b("edit"),run:()=>We(e,o,r)},{label:"New keys",icon:b("key"),run:async()=>{await se("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await W(()=>A.deviceRotate(o.id),"New keys generated")&&r.refresh()}},{label:o.disabled?"Enable":"Disable",icon:b(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await W(()=>A.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&r.refresh()}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await se(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await W(()=>A.deviceDelete(o.id),"Device removed")&&r.refresh()}}];Ce(n,s)}function nt(n,e){let o=n.devices.map(d=>d.name),r=d=>{let p=Ze[d],u=1,w=p;for(;o.some(C=>C.toLowerCase()===w.toLowerCase());)w=`${p} ${++u}`;return w},a="phone",i=t("input",{type:"text",class:"cbi-input-text",placeholder:r(a),maxlength:48}),s=ye("Name",i,()=>i.value.trim()?_e(i.value,o,"Shown in the portal and in the app."):{text:`Named after its type: ${r(a)}.`,bad:!1}),l=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},_o.map(d=>t("button",{type:"button",role:"radio",class:d===a?"on":"","aria-checked":d===a?"true":"false","data-kind":d,click:()=>{a=d,l.querySelectorAll("button").forEach(p=>{let u=p.dataset.kind===d;p.classList.toggle("on",u),p.setAttribute("aria-checked",u?"true":"false")}),i.placeholder=r(d),s.refresh()}},[b(d),t("span",{},Ze[d])]))),c=n.devices.length>=n.device_limit;te(`Add a device for ${n.name}`,[c?t("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Type"),l]),s],[ae()," ",H("Add device",async()=>{let d=s.help();if(d.bad){U(d.text,"warning");return}let p=i.value.trim()||r(a),u=await W(()=>A.deviceCreate(n.id,p,a));u&&(oe(),U(`${p} added`,"success",3e3),e.refresh(),await yr(n.id,u.id,e))},"positive")]),setTimeout(()=>i.focus(),50)}var Ke=1080,qt=1512,Ge=96,Qi="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Xi="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Ft=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function es(n,e,o){let r=new URL(o),a=r.pathname.slice(1),i=Math.min(92,Math.floor((Ke-2*Ge)/(.58*(4+n.name.length)))),s=Ke-2*Ge,l=392,c=40,d=Ct(o,2).replace("`${m}`;return``+p(Ge+82,Ge+42,36,"#a3a3a3",Ft(e))+p(Ge,276,i,"#ffffff",`Hi, ${Ft(n.name)}`,'font-weight="600"')+p(Ge,340,40,"#8a8a8a",`Scan to connect to ${Ft(e)}`)+``+d+`${Ft(a)}`+p(Ke/2,l+s+156,34,"#737373",Ft(r.host),'text-anchor="middle"')+""}async function ts(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let o=document.createElement("canvas");return o.width=Ke,o.height=qt,o.getContext("2d").drawImage(e,0,0,Ke,qt),new Promise((r,a)=>o.toBlob(i=>i?r(i):a(new Error("Could not draw the card")),"image/png"))}async function $r(n){let e=await W(()=>A.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(U("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function wn(n){let e=await $r(n);e&&await pe(e.link,"Personal link copied")}async function _t(n,e,o={}){let r=n.link,a=n.links;if(r===void 0){let m=await $r(n.id);if(!m)return;r=m.link,a=m.links}if(!r){U("The personal portal is off. Turn it on in Settings.","warning");return}let i=r,s=await W(()=>ts(es(n,e,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),c=URL.createObjectURL(s),d=navigator,p=!!d.canShare?.({files:[l]}),u=!p&&typeof d.share=="function"&&(d.canShare?.({url:i})??!0),w=()=>{URL.revokeObjectURL(c),oe()},C=async m=>{try{await d.share(m)}catch{}},g=p?H([b("link")," Share card"],()=>C({files:[l],title:`Invite ${n.name}`}),"positive"):u?H([b("link")," Share link"],()=>C({url:i,title:`Invite ${n.name}`,text:"Your personal VPN link"}),"positive"):H([b("download")," Download card"],()=>Se(l.name,s),"positive");te(o.title??`Invite ${n.name}`,t("div",{class:"dl-invite"},[t("img",{src:c,alt:`Invite card for ${n.name}`}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},o.lead??`Send ${n.name} the card or the link. They open it, add their devices and connect — no account needed.`),t("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>pe(i,"Personal link copied")},[t("span",{},i.replace(/^https:\/\//,"")),b("copy")]),...(a??[]).filter(m=>m!==i).map(m=>t("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>pe(m,"Link copied")},[t("span",{},m.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${m.startsWith("http:")?"warn":""}`},m.startsWith("http:")?"HTTP":"Also"),b("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},["Install ",t("b",{},"AmneziaVPN")," on the device"]),t("li",{},"Open the link or scan the code"),t("li",{},"Add the device and connect")]),t("div",{class:"dl-invite-actions"},[g,H([b("copy")," Copy link"],()=>pe(i,"Personal link copied"))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:w},"Done")],"wide")}function Kt(n,e){let o=n.servers.find(c=>c.id===e)??n.servers[0],r=n.people.filter(c=>c.server===o.id),a=new Set(r.map(c=>c.id)),i=r.flatMap(c=>c.devices),s=c=>r.reduce((d,p)=>{let u=c(p);return[d[0]+u[0],d[1]+u[1]]},[0,0]),l=o.series?.[o.series.length-1];return{...n,servers:[o],people:r,series:o.series??n.series,events:n.events.filter(c=>c.person?a.has(c.person):!0),geo:{...n.geo,points:n.geo.points.filter(c=>a.has(c.person))},totals:{people:r.length,devices:i.length,online:i.filter(c=>c.online).length,active:r.filter(c=>c.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(c=>c.month)}}}var Cr=3,lo=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let w=e.next(),C=null;try{C=await n.fetch(u),o>=Cr&&U("The router answers again.","success",3e3),o=0}catch{return++o===Cr&&U("The router is not answering: what you see may be out of date.","warning",8e3),null}return C==null||!e.take(w)?null:(n.apply(C,p),C)},a=(p=!1)=>r(p,!1),i=()=>document.visibilityState==="visible",s=()=>i()&&(n.active?.()??!0)?r(!0,!1):Promise.resolve(null);poll.add(s,n.every);let l=n.live?fn(()=>void(i()&&(n.active?.()??!0)&&r(!0,!0))):null,c=()=>{poll.remove(s),l?.(),d()},d=$e(c);return{refresh:a,claim:()=>e.claim(),stop:c}}function Pt(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function Te(n,e,o=!1){return o&&Pt(n)?!1:(dom.content(n,e),!0)}function Er(n,e){let o=n,a=t("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(i=>t("button",{type:"button",class:`dl-choice${i.v===o?" selected":""}`,"data-v":i.v,click:()=>{o=i.v,a.querySelectorAll(".dl-choice").forEach(s=>s.classList.toggle("selected",s.dataset.v===i.v)),e?.(i.v)}},[t("span",{class:"dl-choice-title"},[b(i.ic),dt[i.v]]),t("span",{class:"dl-choice-text"},i.text)])));return{el:a,get:()=>o}}function co(n){try{return localStorage.getItem(n)}catch{return null}}function po(n,e){try{localStorage.setItem(n,e)}catch{}}function ns(n){let e=n.devices.length,o=Math.max(1,n.device_limit,e),r=Math.min(160,o*22+(o-1)*3);return t("div",{class:"dl-slotbar",title:`${e} of ${n.device_limit} devices`},[t("span",{class:"dl-slotbar-segs",style:`width: ${r}px`},Array.from({length:o},(a,i)=>t("i",{class:i>=n.device_limit?"over":in.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),yn=n=>n.state==="server_off"?n.paused:n.state!=="active",Mr=n=>yn(n)?n.state==="server_off"?"paused":n.state:null;function os(n,e){let o=Ve(n.expires,e);return n.state==="quota"||n.state==="expired"||Ye(n,o)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function Tr(n,e){return gt(n&&Fn(n,e)>=0?n:e,1)}var Sr=n=>n.people.map(e=>e.id).sort().join(" "),_r=!1,ut=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===(new URLSearchParams(location.search).get("filter")??co("dl.people.filter")))??"all";this.sort=["seen","name","usage"].find(e=>e===co("dl.people.sort"))??"seen";this.query="";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return A.status(30)}scope(e){return this.serverId?Kt(e,this.serverId):e}embed(e,o){return this.serverId=o,this.render(e)}person(e){return this.st.people.find(o=>o.id===e)}get today(){return Ie(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:Mt(this.st.servers,e.server)}}take(e,o){let r=this.scope(e),a=Sr(r)!==Sr(this.st);this.st=r,a?this.rebuild():(this.paintCards(o),this.decorate(o))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await A.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let r of Array.from(this.list.children))r.dataset.sid&&e.set(r.dataset.sid,r);let o=this.st.people.map(r=>{let a=e.get(r.id)??t("div",{class:"dl-card",role:"listitem","data-sid":r.id});return this.renderCard(a,r.id)});dom.content(this.list,o.length?o:t("div",{class:"dl-plist-none"},this.st.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people.")),this.decorate()}paintCards(e=!1){for(let o of this.st.people){let r=this.card(o.id);r&&!(e&&Pt(r))&&this.renderCard(r,o.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let o=this.scope(e);this.st=o;let r=this,a=t("select",{class:"dl-select","aria-label":"Sort",change:c=>{r.sort=c.target.value,po("dl.people.sort",r.sort),r.decorate()}},[t("option",{value:"seen",selected:r.sort==="seen"?"selected":null},"Last seen"),t("option",{value:"name",selected:r.sort==="name"?"selected":null},"Name"),t("option",{value:"usage",selected:r.sort==="usage"?"selected":null},"Usage")]),i=t("input",{type:"search",class:"cbi-input-text dl-people-find",placeholder:"Find…","aria-label":"Find a person or device",hidden:o.people.length>8?null:"hidden",input:c=>{r.query=c.target.value.trim().toLowerCase(),r.decorate()}}),s=c=>{let d=c.target;c.key==="/"&&!i.hidden&&!["INPUT","TEXTAREA","SELECT"].includes(d?.tagName)&&!d?.isContentEditable&&(c.preventDefault(),i.focus())};document.addEventListener("keydown",s),$e(()=>document.removeEventListener("keydown",s));let l=t("div",{class:"dl-root"},[r.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"People"),t("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?H([b("plus")," Add person"],()=>r.openCreate(),"add"):""]),o.servers.length?"":t("div",{class:"alert-message warning"},["No server yet. ",t("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[i,a,r.serverId?H([b("plus")," Add person"],()=>r.openCreate(),"add"):""])]),this.list]);return this.el=l,this.rebuild(),this.poller??(this.poller=ot({fetch:()=>A.status(30),every:30,live:!0,active:()=>!!r.el?.isConnected,apply:(c,d)=>r.take(c,d)})),!_r&&new URLSearchParams(location.search).get("add")&&(_r=!0,setTimeout(()=>r.openCreate(),100)),Promise.resolve(l)}countText(){let e=this.st.totals;return`${e.people} ${e.people===1?"person":"people"} · ${e.devices} device${e.devices===1?"":"s"} · ${e.online} online`}decorate(e=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let r=this.st.people,a=this.today,i=m=>os(m,a),s={all:r.length,online:r.filter(m=>m.online>0).length,attention:r.filter(i).length,paused:r.filter(m=>Lr(m)).length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(e&&Pt(l))){let m={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(m).map(k=>t("button",{type:"button",role:"tab",class:k===this.filter?"on":"",click:()=>{this.filter=k,po("dl.people.filter",k),this.decorate()}},[m[k],t("b",{class:k==="attention"&&s[k]?"warn":""},String(s[k]))])))}let c=this.query,d=m=>[m.name,m.note??"",...m.devices.flatMap(k=>[k.name,k.address,k.hostname,k.endpoint])].join(" ").toLowerCase(),p=m=>!(this.filter==="online"&&!m.online||this.filter==="attention"&&!i(m)||this.filter==="paused"&&!Lr(m)||c&&!d(m).includes(c)),u=m=>Mr(m)==="paused"?2:yn(m)?1:0,w=[...r].sort((m,k)=>u(m)-u(k)||(this.sort==="name"?m.name.localeCompare(k.name):this.sort==="usage"?k.month[0]+k.month[1]-(m.month[0]+m.month[1]):k.online-m.online||k.last_seen-m.last_seen)),C=0;for(let m of w){let k=this.card(m.id);if(!k)continue;this.list.appendChild(k),k.classList.toggle("dl-off",yn(m));let I=p(m);k.classList.toggle("dl-filtered",!I),I&&C++}let g=this.el?.querySelector(".dl-people-none")??null;r.length&&!C?(g??(g=t("div",{class:"dl-empty dl-people-none"},t("p",{},"No one here right now."))),g.previousElementSibling!==this.list&&this.list.after(g)):g?.remove()}async quick(e,o,r){await W(()=>A.personUpdate(e.id,o),r)&&await this.update()}renderCard(e,o){let r=this.person(o);if(!r)return dom.content(e,t("em",{},"This person was just removed.")),e;let a=this.today,i=Ve(r.expires,a),s=Math.max(0,r.device_limit-r.devices.length),l=r.has_link??this.st.settings.portal_enabled,c=[],d=Mr(r);if(r.expires&&d!=="expired"){let g=Ye(r,i),m=i!=null&&i<0;c.push(t("span",{class:`dl-pill-ic${m?" bad":g?" warn":""}`,title:`Access ends ${Me(r.expires)}`},[b("calendar"),m?`ended ${Me(r.expires)}`:g?Xt(i):`until ${Me(r.expires)}`]))}r.hours&&d!=="hours"&&c.push(t("span",{class:"dl-pill-ic",title:"Allowed hours"},[b("clock"),r.hours.replace("-","–")]));let p=tn(r.devices).map(g=>t("button",{type:"button",class:`dl-chip${g.disabled?" disabled":""}${g.online?" live":""}`,title:`${Ze[g.kind]} · ${g.address}${g.online?` · online from ${g.endpoint}`:g.handshake?` · seen ${re(g.handshake,this.st.now)}`:""}`,click:m=>{m.preventDefault(),We(r,g,this.deviceOpts(r))}},[b(g.kind),t("span",{class:"dl-chip-name"},g.name),!g.handshake&&!g.disabled?t("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(t("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:s>0?"Add device":"Add device · over the limit, admins can still add",click:g=>{g.preventDefault(),nt(r,this.deviceOpts(r))}},b("plus")));let u=[];!r.devices.length&&l&&!yn(r)&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>_t(r,this.st.servers.find(g=>g.id===r.server)?.name??"Home")},"Send invite")),r.expires&&Ye(r,i)&&d!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(r,{expires:Tr(r.expires,a)},"Extended by 1 month")},"Extend 1 month"));let w=Le("more","More",g=>Ce(g.currentTarget,[{label:"Open",icon:b("open"),run:()=>{location.href=ke(r.id)}},l?{label:"Invite card",icon:b("qr"),run:()=>_t(r,this.st.servers.find(m=>m.id===r.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:b("plus"),run:()=>nt(r,this.deviceOpts(r))}:null,null,{label:r.paused?"Resume":"Pause",icon:b(r.paused?"play":"pause"),warn:!r.paused,run:()=>this.togglePause(r)},{label:"Delete",icon:b("trash"),danger:!0,run:()=>this.remove(r.id)}].filter((m,k,I)=>m||k>0&&I[k-1])),"neutral","dl-icon-only"),C=t("div",{class:"dl-pcard-actions"},[l?Le("link","Copy link",()=>wn(r.id),"neutral","dl-icon-only"):"",w]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${r.online?" online":""}`},He(r.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:ke(r.id)},r.name),Ao(r),...c]),ns(r)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(r,C),d?this.stopStrip(r,d):""])),e}stopStrip(e,o){let r=this.today,a=gt(`${r.slice(0,8)}01`,1),i=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month"),s={paused:["pause","warn","Paused","Devices can’t connect until you resume",["play","Resume",()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad","Data limit reached",`Paused until it resets on ${Me(a)}`,["plus","+10 GB this month",i]]:["chart","bad","Data limit reached","Paused until the limit is raised",["edit","Change limit",()=>location.href=ke(e.id)]],expired:["calendar","bad",`Access ended ${Me(e.expires)}`,"Devices can’t connect",["calendar","Extend 1 month",()=>this.quick(e,{expires:Tr(e.expires,r)},"Extended by 1 month")]],hours:["clock","warn","Outside allowed hours",`Access ${e.hours.replace("-","–")} (router time)`,null],no_server:["alert","warn","No server","Choose a server on their page",null]},[l,c,d,p,u]=s[o];return t("div",{class:`dl-pstrip ${c}`},[t("span",{class:`dl-need-ic ${c}`},b(l)),t("span",{class:"dl-pstrip-text"},[t("b",{},d),t("span",{class:"dl-faint"},p)]),u?H([b(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,o){let r=e.quota_used||e.month[0]+e.month[1],a=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,i=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??0),0),s=e.rate?.[e.rate.length-1],l=e.online&&s&&this.st.now-s[0]<180,c=t("div",{class:`dl-usebar${a>=100?" bad":a>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${a}%`,c.appendChild(p),me(c,()=>[t("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${X(e.quota_used)} of ${X(e.quota_limit)} · ${X(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},e.quota_period==="total"?"In total":`This month${e.bonus_gb?` · includes +${e.bonus_gb} GB extra`:""}`)])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,w)=>w.v-u.v);p.forEach((u,w)=>{let C=t("i",{class:`c${Math.min(w,4)}`});C.style.flexGrow=String(u.v),c.appendChild(C)}),p.length&&me(c,()=>[t("div",{class:"dl-tip-title"},"This month by device"),...p.map((u,w)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(w,4)}`}),t("span",{},u.d.name),t("b",{},X(u.v))]))])}let d=e.quota_limit?`${X(Math.max(0,e.quota_limit-e.quota_used))} left`:"no limit";return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[l?t("span",{class:"dl-pside-state live"},"Online"):t("span",{class:"dl-pside-state"},e.online?"Online":e.last_seen?"Offline":"Never connected"),o]),t("div",{class:"dl-use-num"},[t("b",{class:r?"":"dl-faint"},X(r)),t("span",{class:"dl-faint"},e.quota_limit?`of ${X(e.quota_limit)}`:e.quota_period==="total"&&e.quota_gb?"in total":"this month")]),c,l?t("div",{class:"dl-use-live",title:"Right now"},[`↓ ${Oe(s[2])}`,t("span",{class:"dl-faint"},`↑ ${Oe(s[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},i?`today ${X(i)} · ${d}`:d)])}async togglePause(e){await W(()=>A.personPause(e.id,!e.paused),e.paused?`${e.name} resumed`:`${e.name} paused`)&&await this.refresh()}async remove(e){let o=this.person(e);await se(`Remove ${o?.name??e}?`,`All ${o?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await W(()=>A.personDelete(e),"Person removed")&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){U("Set up the server first.","warning");return}let o=t("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),r=(()=>{try{return JSON.parse(co("dl.person.last")??"{}")}catch{return{}}})(),a=Er(r.access??"internet"),i=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),s=t("input",{type:"date",class:"cbi-input-text"}),l=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited",value:r.quota??""}),c=(x,v)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{s.value=v?gt(Ie(e.series),v):"",s.dispatchEvent(new Event("change"))}},x),d=e.servers[0],p=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(x=>t("option",{value:x.id},x.name))):null,u=(x,v,$)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},x),t("div",{class:"cbi-value-field"},[v,$?t("div",{class:"cbi-value-description"},$):""])]),w=Ie(e.series),C=ye("Name",o,()=>_e(o.value,[],"Shown in their portal and apps.")),g=ye("Devices",i,()=>sn(i.value)),m=ye("End date",s,()=>jo(s.value,w,Ve,Me),t("div",{class:"dl-actions"},[s,c("1 month",1),c("3 months",3),c("1 year",12),c("None",0)])),k=ye("Monthly data (GB)",l,()=>ln(l.value));s.addEventListener("change",()=>m.refresh());let I=e.settings.portal_enabled;te("Add person",[C,p?u("Server",p):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},"Access"),t("div",{class:"cbi-value-field"},a.el)]),g,m,k],[ae()," ",H(I?"Create and copy link":"Create",async()=>{let x=ze([C,g,m,k]);if(x){U(x,"warning");return}let v=await W(()=>A.personCreate(o.value.trim(),"",p?.value??d.id,a.get(),i.value.trim(),s.value,l.value.trim(),"month"));v&&(po("dl.person.last",JSON.stringify({access:a.get(),quota:l.value.trim()})),v.link&&await pe(v.link,"Personal link copied",!0),this.showCreated(v.id,o.value.trim(),v.link,e.servers.find($=>$.id===(p?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(e,o,r,a){if(r){_t({id:e,name:o,link:r},a,{title:`${o} is ready`,lead:`Send ${o} the card or the link. They open it, add their devices and connect — no account needed.`});return}let i=this.person(e);te(`${o} is ready`,[t("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[t("button",{class:"cbi-button cbi-button-neutral",click:oe},"Done")," ",t("a",{class:"cbi-button cbi-button-neutral",href:`${L.url("admin/network/dawnline/settings")}?section=portal`},"Open Settings")," ",i?H("Add device",()=>{oe(),nt(i,this.deviceOpts(i))},"positive"):""])}};var kn=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],uo=n=>t("i",{class:"dl-circle-dot",style:`background:${kn[n?.color??0]??kn[0]}`}),rt=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function Pr(n,e,o){let r=ie(n?.name??e.name??"",{placeholder:"NAS"}),a=ie(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=ie((n?.ports??e.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=ye("Name",r,()=>_e(r.value,[],"Shown to people who may reach it.")),l=ye("Address",a,()=>Uo(a.value)),c=ye("Ports",i,()=>Wo(i.value));te(n?`Edit ${n.name}`:"Add service",[s,l,c],[ae()," ",H("Save",async()=>{let d=ze([s,l,c]);if(d){U(d,"warning");return}let p=i.value.split(/[ ,]+/).filter(Boolean);await W(()=>A.serviceSet(n?.id??"",r.value,a.value,p),"Saved")&&(oe(),o())},"positive")])}var rs={_smb:"SMB",_afpovertcp:"AFP",_http:"Web",_https:"Web",_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:"Printer",_ipps:"Printer",_printer:"Printer","_pdl-datastream":"Printer",_airplay:"AirPlay",_raop:"AirPlay",_rfb:"Screen sharing",_googlecast:"Cast",_hap:"HomeKit",_rdp:"Remote desktop",_ftp:"FTP"},as=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function is(n){let e=new Map;for(let o of n.services){let r=rs[o.type.split(".")[0]];!r||!o.port||(e.get(r)??e.set(r,new Set).get(r)).add(String(o.port))}return e.size?[...e].map(([o,r])=>[o,[...r].sort((a,i)=>+a-+i)]):as}function Dr(n,e,o){let r=n,a=null,i=!1,s=null,l=new Set,c=t("div",{class:"dl-list"}),d=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},"Looking for devices at home…")),p=()=>{let m=r.services;dom.content(c,m.length?m.map(k=>t("div",{class:"dl-row"},[b("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},k.name),t("span",{class:"dl-mono dl-faint"},`${k.address}${k.ports.length?` · ports ${k.ports.join(", ")}`:" · all ports"}`)]),H("Edit",()=>Pr(k,{},o)),H([b("trash")],async()=>{await se(`Remove ${k.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await W(()=>A.serviceDelete(k.id),"Removed")&&await o()},"neutral",{title:"Remove","aria-label":`Remove ${k.name}`})])):[t("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function u(m,k){if(!l.has(m.address)){l.add(m.address),C();try{let I=r.services.find(v=>v.address===m.address);(k===null?I&&await W(()=>A.serviceDelete(I.id),`${I.name} removed`):await W(()=>A.serviceSet(I?.id??"",I?.name??(m.name||m.address),m.address,k),I?`${I.name} updated`:`${m.name||m.address} added`))&&await o()}finally{l.delete(m.address),C()}}}function w(m){let k=r.services.find(E=>E.address===m.address),I=!!k&&!k.ports.length,x=new Set(k?.ports??[]),v=l.has(m.address),$=(E,y,z)=>qe(E,y,z,{disabled:v?"disabled":null,"aria-busy":v?"true":null});return t("div",{class:"dl-row"},[b(m.services.some(E=>E.type.startsWith("_ipp")||E.type.startsWith("_printer"))?"file":"computer"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},m.name||m.address),t("span",{class:"dl-mono dl-faint"},m.address)]),t("div",{class:"dl-chips-row dl-host-ports"},[$("All ports",I,()=>u(m,I?null:[])),...is(m).map(([E,y])=>{let z=!I&&y.every(h=>x.has(h));return $(`${E} ${y.join(", ")}`,z,()=>{let h=new Set(I?[]:x);for(let f of y)z?h.delete(f):h.add(f);u(m,h.size?[...h]:null)})})])])}function C(){if(i)return dom.content(d,t("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!a)return;let m=a;if(!m.hosts.length)return dom.content(d,t("span",{class:"dl-sub"},"No devices found in the home network right now."));let k=t("details",{class:"dl-params",open:s??!r.services.length?"":null},[t("summary",{},[b("chevron"),t("span",{},"Add from devices at home"),t("span",{class:"dl-pcount"},String(m.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},m.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),t("div",{class:"dl-list"},m.hosts.map(w))])]);k.addEventListener("toggle",()=>s=k.open),dom.content(d,k)}return A.homeHosts(e).then(m=>{a=m,C()}).catch(()=>{i=!0,C()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},"Home services"),H([b("plus")," Add service"],()=>Pr(null,{},o))]),t("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),c,d]),update(m){r=m,p(),C()}}}function $n(n,e,o,r){let a=new Set(n.circles.filter(m=>m.server===e).map(m=>m.color)),i=o?.color??kn.findIndex((m,k)=>!a.has(k));i<0&&(i=0);let s=ie(o?.name??"",{placeholder:"Family"}),l=n.people.filter(m=>m.server===e).sort((m,k)=>m.name.localeCompare(k.name)),c=new Set(l.filter(m=>o&&m.circle===o.id).map(m=>m.id)),d=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),p=()=>dom.content(d,kn.map((m,k)=>t("button",{type:"button",role:"radio",class:`dl-swatch${k===i?" on":""}`,style:`--sw:${m}`,"aria-checked":k===i?"true":"false","aria-label":`Colour ${k+1}`,click:()=>{i=k,p()}})));p();let u=t("div",{class:"dl-chips-row"},l.map(m=>{let k=m.circle&&m.circle!==o?.id?n.circles.find(I=>I.id===m.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${c.has(m.id)?" on":""}`,title:rt(m)?k?`Now in ${k.name}`:"":`${m.name} has no home access: their devices aren't reachable anyway`,click:I=>{c.delete(m.id)||c.add(m.id),I.currentTarget.classList.toggle("on",c.has(m.id))}},[m.name,rt(m)?k?t("b",{},k.name):"":t("b",{},"internet")])})),w=(m,k)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},m),t("div",{class:"cbi-value-field"},k)]),C=n.circles.filter(m=>m.server===e&&m.id!==o?.id).map(m=>m.name),g=ye("Name",s,()=>Ro(s.value,C));te(o?`Edit ${o.name}`:"New circle",[g,w("Colour",d),w("People",u),t("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[o?H("Delete",async()=>{await W(()=>A.circleDelete(o.id),`${o.name} deleted`)&&(oe(),r())},"negative"):"",t("span",{class:"dl-spacer"}),ae()," ",H("Save",async()=>{let m=g.help();if(m.bad){U(m.text,"warning");return}await W(()=>A.circleSet(o?.id??"",e,s.value,i,[...c]),"Saved")&&(oe(),r())},"positive")],"dl-circle-modal")}function Ar(n,e,o){let r=n.circles.filter(a=>a.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...r.map(a=>{let i=n.people.filter(s=>s.circle===a.id).map(s=>s.name);return t("button",{type:"button",class:"dl-chip",title:`Edit ${a.name}`,click:()=>$n(n,e,a,o)},[uo(a),t("b",{},a.name),t("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),t("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>$n(n,e,null,o)},b("plus"))])}function mo(n,e){let o=n.people.filter(p=>p.server===e.id),r=(p="")=>t("span",{class:"dl-yes"},[b("check"),p]),a=()=>t("span",{class:"dl-faint"},"—"),i=p=>{let u=new Set(p.map(w=>w.access==="lan"&&w.services?.length?"services":w.home_nets?.length?"some":"all"));return u.size||u.add("all"),r([...u].map(w=>({all:"all networks",some:"their networks",services:"services"})[w]).join(" / "))},s=()=>e.mesh==="off"?a():e.mesh==="circles"?r("circle"):r(),l=e.lan_like?"like home":"direct",c=(p,u,w)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},`${u.length} ${u.length===1?"person":"people"}`)]),...w.map(C=>t("td",{},C))]),d=p=>o.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Who reaches what"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"From the rules on this server")]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["","Internet","Home","This router","Each other"].map(p=>t("th",{},p))),c("Internet",d("internet"),[r(l),a(),t("span",{class:"dl-faint"},"DNS"),a()]),c("Home",d("lan"),[t("span",{class:"dl-faint"},"their own"),i(d("lan")),r(),s()]),c("Both",d("both"),[r(l),i(d("both")),r(),s()])])),t("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function Hr(n,e){let o=n.people.filter(d=>d.server===e.id).flatMap(d=>d.devices.map(p=>({id:p.id,label:`${d.name} · ${p.name}`}))).sort((d,p)=>d.label.localeCompare(p.label)),r="@addr",a=(d,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":d},[...o.map(m=>t("option",{value:m.id,selected:m.id===p?"selected":null},m.label)),t("option",{value:r,selected:p===r?"selected":null},"Address")]),w=ie("",{placeholder:d,class:"cbi-input-text dl-mono"}),C=t("div",{class:"dl-check-end"},[u,w]),g=()=>w.hidden=u.value!==r;return u.addEventListener("change",g),g(),{el:C,value:()=>u.value===r?w.value.trim():u.value}},i=a("10.0.1.11",o[0]?.id??r),s=a("10.0.1.20:445",r),l=t("div",{class:"dl-stack gap8"}),c=async()=>{let d=await W(()=>A.accessCheck(i.value(),s.value()));if(!d)return;let p=d.steps.findIndex(u=>!u.ok);dom.content(l,[t("div",{class:`dl-verdict ${d.ok?"ok":"bad"}`},[t("b",{},d.ok?"Allowed":"Blocked"),t("span",{class:"dl-sub"},d.ok?"Every step lets it through":`Stops at step ${p+1} of ${d.steps.length}`)]),t("ul",{class:"dl-checks"},d.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},b(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Check access"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"Why something does or does not connect")]),t("div",{class:"dl-check-form"},[i.el,t("span",{class:"dl-faint"},"→"),s.el,H("Check",c)]),l])])}var Cn={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function at(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function En(n){return at(n.action==="check"?`check:${n.component??""}`:n.component??"")}function zr(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function Nr(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function Rr(n,e){let o=n.check?.components??{},r=e==="all"?["app","amneziawg","packages"]:[e],a=[],i;for(let l of r){let c=o[l];if(c){if(c.error)return{tone:"warn",text:c.error};l==="packages"&&c.updates?a.push(`${c.updates} system package${c.updates===1?"":"s"}`):l!=="packages"&&c.update&&c.installed&&c.latest&&(a.push(`${Cn[l]} ${c.latest}`),e!=="all"&&(i=c.latest))}}if(a.length)return{tone:"acc",text:`Update available: ${a.join(", ")}`,update:i};let s=r.length===1?o[r[0]]:null;return s?.status==="dev"?{tone:"acc",text:`Installed version is newer than the release (${s.latest})`}:s?.note?{tone:"warn",text:s.note}:{tone:"ok",text:r.length>1?"Everything is up to date":"Latest version is installed"}}function Ir(n,e,o,r){return e?n.id===e:o&&n.id===o?!1:n.state==="running"||r>0&&n.started>=r}var Br=n=>new Promise(e=>setTimeout(e,n));async function Jt(n,e,o){let r=o?En(o):at(n),a=o?o.action==="check":n.startsWith("check"),i=Date.now(),s=t("b",{},Cn[r]??(r==="all"?"All components":"Dawnline")),l=t("span",{class:"dl-pill dl-mono"},e.version??""),c=t("span",{class:"dl-pill info",hidden:!0}),d=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),u=t("div",{}),w=t("div",{class:"dl-op-actions"}),C=[],g=h=>dom.content(w,h),m=(h=!1)=>ae("Close",h);te(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[s,e.version?l:"",c,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[b("clock"),d])]),t("div",{class:"dl-op-loghead"},[t("b",{},"Operation log"),Le("copy","Copy log",()=>pe(C.join(` -`),"Log copied"))]),p,u]),[w],"wide"),g([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},a?"Checking…":"Working…")]);let k=o??null,I=o?.id,x,v=0,$=h=>{I!==h.id&&(I=h.id,e.onJob?.(h))};if(o)e.onJob?.(o);else try{let h=await A.updatesStatus().catch(()=>null);x=h?.job?.id,v=h?.now??0;let f=await A.updatesRun(n);f.job&&f.job.state==="running"&&f.job.id!==x&&(k=f.job,$(f.job))}catch(h){return C=[be(h)],p.textContent=C[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},be(h))])),g([m(!0)]),U(be(h),"error"),null}let E=null,y=0;for(;;){if(await Br(1e3),E=await A.updatesStatus().catch(()=>null),!E){if(++y>60)break;continue}y=0;let h=E.job;if(!h||!Ir(h,I,x,v)){if(Date.now()-i>15e3)break;continue}if($(h),k=h,h.log.length){C=h.log;let f=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=C.join(` -`),f&&(p.scrollTop=p.scrollHeight)}if(l.textContent=Nr(h,e.version??""),!l.isConnected&&l.textContent&&s.after(l),d.textContent=zr((h.finished??E.now)-h.started),h.state==="running"){c.hidden=!h.phase,c.textContent=h.phase;continue}break}if(p.scrollTop=p.scrollHeight,c.hidden=!1,!k||k.state==="running")return c.className="dl-pill warn",c.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),g([m()]),e.onDone?.(E),k;if(k.state==="failed")return c.className="dl-pill bad",c.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[b("x"),t("span",{},[t("b",{},k.error??"Operation failed"),a?"":". Nothing else was changed."])])),g([H("Copy log",()=>pe(C.join(` -`),"Log copied")),m(!0)]),U(`${Cn[r]??"Update"}: ${k.error??"failed"}`,"error"),e.onDone?.(E),k;if(c.className="dl-pill ok",c.textContent="Finished",a&&E){let h=Rr(E,r);if(dom.content(u,t("div",{class:`dl-comp-status ${h.tone}`},[b(h.tone==="ok"?"check":h.tone==="warn"?"alert":"download"),t("span",{},h.text)])),U(h.text,h.tone==="warn"?"warning":"success"),e.onDone?.(E),h.update&&e.onUpdate){let f=E;g([m(),H(`Update to ${h.update}`,()=>e.onUpdate(f),"positive")])}else g([m()]),h.tone==="ok"&&setTimeout(()=>u.isConnected&&oe(),1200);return k}if(r==="app"&&k.to){let h=k.to,f=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},[t("b",{},`Dawnline ${h} is installed. `),f])]));let T=()=>{ui.menu?.flushCache(),location.reload()};g([m(),H("Reload now",T,"positive")]),U(`Dawnline updated to ${h}`,"success",6e3);for(let S=1;S<=30;S++)if(f.textContent=`Waiting for the router to restart its services (${S} of 30)…`,await Br(1500),(await A.updatesStatus().catch(()=>null))?.version===h)return f.textContent="Services are back. Reloading…",setTimeout(T,800),k;return f.textContent="Services restarted. Reload the page to use the new version.",k}let z=r==="pkgs"?`Updated ${[...k.result?.pkgs?.updated??[],...k.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:r==="amneziawg"?`AmneziaWG${k.to?` ${k.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},z)])),g([m()]),U(z,"success"),e.onDone?.(E),k}var ss={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function Or(n,e,o,r){return!await se(`Install ${e}?`,o,"Install")||(await Jt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>r?.(),4e3),!0)}function Ln(n){return Or("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Vt(n,e,o){return n==="awg"?Ln(o):e.length?Or(`pkgs:${e.join(",")}`,ss[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function jr(n,e){if(n==="awg")return Ln(e);let o=await W(()=>A.updatesStatus());return o?Vt(n,o.needs?.[n]??[],e):!1}var ls=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],ds={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function Ur(n,e,o){let r=n.id,a=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,c="",d=!0,p=!0,u="all",w=!1,C=Dr(a,r,o),g=new Set,m="",k=()=>JSON.stringify([p,l,l?"":c,d,[...g].sort()]),I=()=>s.detected.lan||s.saved.lan||"",x=()=>(l?s.detected.wan||s.saved.wan:c)||"",v=()=>new Map(s.devices.map(R=>[R.name,R])),$=()=>{let R=v();return[...d&&I()?[I()]:[],...[...g].filter(Q=>Q!==I())].filter(Q=>Q!==x()).map(Q=>R.get(Q)??{name:Q,nets:[],missing:!0})},E=(R,J)=>{s=R,J&&(l=R.config.auto_wan,c=R.config.wan_device||R.detected.wan||R.saved.wan||"",d=R.config.auto_lan,p=R.config.lan_like,u=R.config.mesh??(R.config.device_mesh?"all":"off"),g=new Set(R.config.lan_devices),m=k()),q()},y=async R=>{let J=await A.interfaces(r).catch(Q=>(U(Q.message,"error"),null));J&&E(J,R)};function z(R){let J=d&&R.name===I(),Q=!!R.own||!!R.master||R.name===x()||J;return J||g.has(R.name)||!Q&&(R.nets.length>0||!!R.missing)}function h(R){let J=d&&R.name===I(),Q=R.name===x(),le=!J&&g.has(R.name),ue=!(!!R.own||!!R.master||Q||J)&&(R.nets.length>0||le||!!R.missing),ne=(le||J)&&!R.zone&&!R.missing,O=R.missing?"Not present right now":R.own?"This server":R.master?`Port of ${R.master}`:Q?`Internet${R.zone?` · zone ${R.zone}`:""}`:R.nets.length?R.nets.join(", "):"No IPv4 network",F=t("button",{type:"button",class:`dl-if${le?" sel":""}${J?" auto":""}${!ue&&!le&&!J?" off":""}${ne?" warn":""}`,"aria-pressed":le||J?"true":"false","aria-disabled":ue?null:"true",click:()=>{ue&&(g.has(R.name)?g.delete(R.name):g.add(R.name),q())}},[t("span",{class:"dl-if-ic"},b(ds[R.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},R.name),t("span",{class:"dl-if-sub"},O)]),J?t("span",{class:"dl-if-badge ok"},"Auto"):le?t("span",{class:"dl-if-check"},b("check")):""]);return me(F,()=>[t("div",{class:"dl-tip-title"},R.name),t("div",{class:"dl-muted"},[R.logical?`Interface ${R.logical}`:"No netifd interface",R.zone?` · zone ${R.zone}`:" · no firewall zone"]),R.members.length?t("div",{class:"dl-muted"},`Ports: ${R.members.join(", ")}`):"",R.nets.length?t("div",{class:"dl-mono"},R.nets.join(", ")):"",ne?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",R.master?t("div",{class:"dl-muted"},`Choose ${R.master} to include it.`):""]),F}function f(){let R=s.like_home;return!p||!s.config.lan_like||!n.enabled?"":!s.needs?.length&&R.active&&R.bridged?"ok":"warn"}function T(){let R=s.like_home;return p?s.needs?.length?[t("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?n.enabled?R.active&&R.bridged?["Internet traffic enters ",t("span",{class:"dl-mono"},R.dev??"")," as ",t("span",{class:"dl-mono"},R.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[t("span",{class:"dl-warn"},`Not working: ${R.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let S={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function N(R,J,Q,le,he="",ue){return t("div",{class:ue?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${he}`},b(R)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},J),t("span",{class:"dl-sub"},Q),ue??""])]),t("div",{class:"dl-setrow-ctl"},le)])}let G=(R,J)=>{let Q=le=>t("span",{class:"dl-mono"},le);return R?t("span",{},[" Now: ",Q(R),...J&&J!==R?[", was ",Q(J)]:[],"."]):t("span",{},J?[" Not found now: using ",Q(J),"."]:[" Not found."])};function q(){let R=t("select",{class:"cbi-input-select","aria-label":"Internet interface",change:M=>{c=M.target.value,q()}},s.devices.filter(M=>!M.own&&!M.master&&M.zone&&!M.missing).map(M=>t("option",{value:M.name,selected:M.name===c?"selected":null},`${M.name} · zone ${M.zone}`))),Q=$().flatMap(M=>M.nets.map(j=>[j,M.name])),le=JSON.parse(k()),he=JSON.parse(m),ue=(...M)=>M.some(j=>JSON.stringify(le[j])!==JSON.stringify(he[j])),ne=ue(0,1,2),O=ue(3,4),F=M=>H("Save",async()=>{let j=await W(()=>A.serverInterfaces(r,l,l?"":c,d,[...g],p,u!=="off",u),"Access saved");j&&(E(j,!0),j.nets_changed&&j.lan_only&&U(`${j.lan_only} ${j.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!M}),P=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Internet"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Internet or Both")]),N("home","Internet like a home device",T(),[p&&s.needs?.length?H("Install",()=>Vt("home",s.needs,()=>y(!1)),"positive"):"",ve(p,"Internet like a home device",M=>{p=M,q()})],f()),N("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",G(s.detected.wan,s.saved.wan)],[l?"":R,ve(l,"Auto-detect WAN",M=>{l=M,q()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?["Internet like a home device",x()?[" · leaves through ",t("span",{class:"dl-mono"},x())]:""]:x()?["Internet straight to ",t("span",{class:"dl-mono"},x())]:"No WAN found"),F(ne)])]),D=we([["off","Off"],["all","Everyone"],["circles","Circles"]],u,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async M=>{let j={off:"Off",all:"Everyone",circles:"Circles"}[M];await W(()=>A.serverUpdate(r,{mesh:M}),`Devices reach each other: ${j}`)&&(u=M,s.config.mesh=M,q(),await o())}}),_=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Home network"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Home or Both"),H([b("reset")," Rescan"],()=>y(!1),"neutral",{title:"Read the interfaces again"})]),N("network","Networks","Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it.","","",V()),N("link","Devices reach each other",S[u],D,"",u==="circles"?Ar(a,r,o):void 0),C.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},Q.length?["Home access reaches ",...Q.flatMap(([M,j],Z)=>[Z?", ":"",t("span",{class:"dl-mono"},M),` (${j})`])]:"No home network: Home access reaches nothing but this router."),F(O)])]),B=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[P,_]),i.style.minHeight="",window.scrollTo({top:B})}function V(){let R=s.devices.filter(z),J=s.devices.filter(Q=>!z(Q));return t("div",{class:"dl-stack gap8 dl-netpick"},[R.length?t("div",{class:"dl-ifgrid"},R.map(h)):t("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},"Auto-detect LAN"),t("span",{class:"dl-sub"},["Adds the LAN this router uses.",G(s.detected.lan,s.saved.lan)])]),ve(d,"Auto-detect LAN",Q=>{d=Q,q()})]),J.length?t("details",{class:"dl-params",open:w?"":null,toggle:Q=>w=Q.currentTarget.open},[t("summary",{},[b("chevron"),t("span",{},"Other interfaces"),t("span",{class:"dl-pcount"},String(J.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...ls.map(([Q,le])=>{let he=J.filter(ue=>ue.category===Q);return he.length?t("div",{class:"dl-ifgroup"},[t("h4",{},le),t("div",{class:"dl-ifgrid"},he.map(h))]):""})])]):""])}return y(!0),{el:i,update(R){a=R,C.update(R),s&&q()}}}var cs={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",expiring:"warn",expired_kept:"",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},ps={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",expiring:"calendar",expired_kept:"calendar"};function us(n,e){return e.device?n.people.flatMap(r=>r.devices).find(r=>r.id===e.device)?.kind??e.dkind??"other":ps[e.type]??"activity"}function ho(n,e){let o=n.people.find(g=>g.id===e.person),r=o?.name??e.pname??e.person??"",a=o?.devices.find(g=>g.id===e.device)?.name??e.dname??"",i=g=>t("b",{},g),s=g=>t("span",{class:"dl-muted"},g),l=g=>t("span",{class:"dl-mono"},g),c=g=>e.hosts?.[g]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[g]),t("span",{class:"dl-faint"},` (${g})`)])]:[l(g)],d=g=>t("span",{class:"dl-ev-kind"},`${g} `),p=a?`${r} · ${a}`:r,u=nr(e),w=u||a||"a device",C=g=>[t("span",{class:"dl-you"},"You"),s(` ${g} `)];if(Ne(e)==="admin")switch(e.type){case"device_added":return[...C("added"),d("device"),i(w),s(" for "),i(r)];case"device_removed":return[...C("removed"),d("device"),i(w),s(" from "),i(r)];case"paused":return[...C("paused"),d("person"),i(r)];case"resumed":return[...C("resumed"),d("person"),i(r)];case"device_changed":{let g=u.startsWith("renamed from ");return[...C(g?"renamed":u),d("device"),i(a||"a device"),s(" of "),i(r),...g?[s(` · was ${u.slice(13)}`)]:[]]}case"device_keys":return[...C("issued new keys for"),d("device"),i(w),s(" of "),i(r),s(" · it needs its new configuration")];case"link_changed":return[...C("issued a new link for"),d("person"),i(r),s(" · the old link stopped working")]}switch(e.type){case"connect":return[d("Device"),i(p),s(" connected"),...e.detail?[s(" from "),...c(e.detail)]:[],...e.where?[s(` · ${e.where}`)]:[]];case"disconnect":return[d("Device"),i(p),s(" went offline")];case"roam":return[d("Device"),i(p),s(" changed network "),...(e.detail??"").split(" → ").flatMap((g,m)=>m?[s(" → "),...c(g)]:c(g))];case"device_added":return[d("Person"),i(r),s(" added "),d("device"),i(w),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[d("Person"),i(r),s(" removed "),d("device"),i(w),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[d("Person"),i(r),s(" issued new keys for "),d("device"),i(w),s(" on their portal")];case"person_added":return[...C("added"),d("person"),i(e.detail??r)];case"person_removed":return[...C("removed"),d("person"),i(e.detail??r)];case"person_changed":return[...C("changed"),d("person"),i(r),...u?[s(` · ${u.replace(/_/g," ")}`)]:[]];case"expiring":return[d("Person"),i(r),s(`’s access ends in ${e.detail??"a few days"}`)];case"expired_kept":return[d("Person"),i(r),s(`’s end date passed (${e.detail??""}) · access kept`)];case"paused":return[d("Person"),i(r),s(` paused — ${e.detail??""}`)];case"resumed":return[d("Person"),i(r),s(" resumed"),...e.detail&&e.detail!=="active"?[s(` — ${e.detail}`)]:[]];case"portal_blocked":return[t("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(e.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[d("Person"),i(r),s(" — all devices removed, end date reached")];default:return[s(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var ms={portal_blocked:["globe","bad"]};function hs(n,e){if(n.servers.length<2||!e.person)return"";let o=n.people.find(a=>a.id===e.person),r=o&&n.servers.find(a=>a.id===o.server);return r?t("span",{class:"dl-ev-srv",title:"Server"},r.name):""}function it(n,e,o={}){let r=ms[e.type],a=Ne(e);return t("div",{class:`dl-row${a==="admin"?" dl-ev-by-admin":r?` dl-ev-by-system ${r[1]}`:""}`},[a==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):r?t("span",{class:"dl-ev-tile sys"},b(r[0])):t("span",{class:`dl-ev-tile ev ${cs[e.type]??""}`},b(us(n,e))),t("span",{class:"dl-row-main"},ho(n,e)),o.server===!1?"":hs(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString()},o.time??re(e.ts,n.now))])}var fs={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},gs={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function Mn(n,e,o,r){let a=n.by==="admin",i=t("div",{class:`dl-row dl-slog-row ${a?"dl-ev-by-admin":`dl-ev-by-system ${fs[n.level]??""}`}${n.detail?" has-detail":""}`},[a?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):t("span",{class:"dl-ev-tile sys",title:n.level},b(gs[n.src]??"zap")),t("span",{class:"dl-row-main"},a?[t("span",{class:"dl-you"},"You"),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):"",n.note?t("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},b("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},"Server "):"",t("b",{class:"dl-sys-src",title:Ot[n.src]??n.src},n.who??Ot[n.src]??n.src)," ",t("span",{class:"dl-muted"},n.msg),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},b("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString()},r)]);return n.detail&&i.addEventListener("click",s=>{s.target.closest("pre")||o()}),i}function Wr(n){let e=new Date(n*1e3),o=new Date,r=new Date;return r.setDate(o.getDate()-1),e.toDateString()===o.toDateString()?"Today":e.toDateString()===r.toDateString()?"Yesterday":e.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var Dt=n=>bt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function Tn(n,e,o,r=!1){let a=n.slice(-15),i=a[a.length-1],s=i&&e-i[0]<180,l=s?i[2]:0,c=s?i[1]:0,[d,p]=o,u=200,w=40,C=Math.max(1,...a.map(v=>Math.max(v[1],v[2]))),g=v=>a.map(($,E)=>`${a.length>1?E/(a.length-1)*u:u},${w-2-$[v]/C*(w-6)}`),m=g(2),k=g(1),I=a.length>1&&!r?Xe(``):t("div",{class:"dl-speed-wait"},[t("i"),r?"":t("span",{},"Collecting… 1 point a minute")]),x=(v,$,E,y)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:E},$),` ${v}`]),r?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},Oe(y))]);return a.length>1&&!r&&me(I,()=>{let v=a[a.length-1];return[t("div",{class:"dl-tip-title"},new Date(v[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${Oe(v[2])} · ↑ ${Oe(v[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Speed now"),r?"":t("span",{class:"dl-sub"},"last 15 min")]),t("div",{class:"dl-speed-cols"},[x("Download","↓","dl-dn",l),x("Upload","↑","dl-up",c)]),I,t("div",{class:"dl-speed-today"},[t("span",{},["Today ",t("b",{},X(d+p))]),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${X(p)} `,t("span",{class:"dl-up"},"↑"),` ${X(d)}`])])])}function Sn(n,e){let o=n.slice(-30),r=o.map(c=>c.rx+c.tx),a=Math.max(1,...r),i=r.reduce((c,d)=>c+d,0),s=r.reduce((c,d,p)=>d>r[c]?p:c,0),l=t("div",{class:"dl-bento-bars"},o.map((c,d)=>{let p=r[d],u=t("i",{class:d===o.length-1?"hi":"",style:`height:${Math.max(4,p/a*100)}%`});return me(u,()=>[t("div",{class:"dl-tip-title"},d===o.length-1?`Today · ${Dt(c.day)}`:Dt(c.day)),t("div",{},X(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${X(c.tx)} ↑ ${X(c.rx)}`)]),u}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},"Last 30 days"),t("b",{class:"dl-bento-total"},X(i))]),r[s]>0?t("span",{class:"dl-sub"},`peak ${X(r[s])} · ${Dt(o[s].day)}`):""]),o.length?l:t("p",{class:"dl-muted"},"No traffic yet."),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},o.length?Dt(o[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},"today")])])}function Gr(n){let e=n.slice(-30),o=e.map(a=>a.rx+a.tx),r=Math.max(1,...o);return t("div",{class:"dl-dbars"},e.map((a,i)=>{let s=t("i",{class:`${o[i]?"":"zero"}${i===e.length-1?" hi":""}`});return s.style.height=`${Math.max(8,o[i]/r*100)}%`,me(s,()=>[t("div",{class:"dl-tip-title"},i===e.length-1?`Today · ${Dt(a.day)}`:Dt(a.day)),t("div",{},X(o[i]))]),s}))}var Fr={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function _n(n){return n==="netrestart"&&!await se("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await W(()=>A.healthFix(n),"Done")??null}function fo(n,e,o,r="action"){let a=n.fix;return a?a.startsWith("install:")?H("Install",()=>jr(a.slice(8),o),r):a==="updates"?t("a",{class:`cbi-button cbi-button-${r}`,href:L.url("admin/network/dawnline/updates")},Fr.updates):H(Fr[a]??"Fix",()=>e(a),r):""}function vs(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="flash"?"download":n==="nft"?"lock":n==="data"?"users":"alert"}function qr(n,e,o,r=3){let a=n.filter(s=>s.status==="error"||s.status==="warn").sort((s,l)=>s.status===l.status?0:s.status==="error"?-1:1);if(!a.length)return"";let i=a.length-r;return t("div",{class:"dl-list dl-notices"},[...a.slice(0,r).map(s=>Qe(vs(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,fo(s,e,o,s.status==="error"?"positive":"neutral"))),i>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,t("span",{class:"dl-spacer"}),"→"]):""])}function bs(n){let e=[],o=(s,l)=>t("a",{href:s},l),r=Ie(n.series),a=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?e.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!a&&e.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});for(let s of n.people)if(s.state==="quota")e.push({tone:"warn",text:[o(ke(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")e.push({tone:"warn",text:[o(ke(s.id),s.name),"’s access has ended."]});else{let l=Ve(s.expires,r);Ye(s,l)?e.push({tone:"",text:[o(ke(s.id),s.name),`’s access ${Xt(l)}.`]}):l!=null&&l<0&&s.expire_action==="notify"&&e.push({tone:"",text:[o(ke(s.id),s.name),`’s end date passed (${Me(s.expires)}) · access kept.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&e.push({tone:"",text:[o(ke(s.id),s.name)," has used 90% of the data limit."]})}let i=n.people.flatMap(s=>s.devices.filter(l=>l.config_stale).map(l=>[s,l]));i.length&&e.push({tone:"warn",text:i.length===1?[o(ke(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)," needs its configuration again."]:[`${i.length} devices need their configuration again (networks or DNS changed).`]});for(let s of n.servers)n.wan&&kt(s.endpoint)&&s.endpoint!==n.wan&&e.push({tone:"warn",text:[`Public address changed: ${s.name} still gives devices ${s.endpoint}, the router is ${n.wan} now. `,t("button",{type:"button",class:"dl-fix",click:async l=>{let c=l.currentTarget;c.disabled=!0,await W(()=>A.serverUpdate(s.id,{endpoint:n.wan}),`${s.name} uses ${n.wan} now — devices need their configuration again`),c.disabled=!1}},"Use the new address")," A DDNS name would follow it by itself."]});return n.servers.some(s=>s.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[`Internet through the LAN is off: ${n.like_home.error} `,o(L.url("admin/network/dawnline/diagnostics"),"Details")]}),!n.settings.portal_enabled&&!n.people.length&&e.push({tone:"",text:["The personal portal is off. ",o(L.url("admin/network/dawnline/settings"),"Turn on")]}),e}var Pn=class{constructor(e,o){this.srvId=e;this.go=o;this.el=t("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=Kt(e,this.srvId);for(let o of["health","bento","side","activity"])this.parts[o]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,o=!1){this.st=Kt(e,this.srvId),this.paint(o),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await A.health().catch(()=>null);if(!e)return;let o=()=>void this.loadHealth(),r=async a=>{await _n(a)&&(o(),a==="netrestart"&&setTimeout(o,5e3))};Te(this.parts.health,qr(e.checks,a=>void r(a),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let e=this.st,o=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},"Where people connect from"),t("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),t("span",{class:"dl-spacer"}),Tt(this.range,s=>{this.range=s,this.map?.setRange(s)})]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map?.destroy(),this.map=new tt({openPerson:s=>location.href=ke(s),openDevice:(s,l)=>location.href=ke(s,l)},this.range);let r=$e(()=>{r(),this.map?.destroy(),this.map=null}),a=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),"Live tunnel"]),t("span",{},[t("i",{class:"line"}),"Seen recently"])]),i=t("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),t("div",{class:"dl-panel flush"},[o,i])}paint(e=!1){let o=this.st,r=o.servers[0];Te(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Be(r).overviewTile(r),this.monthTile()]),e);let a=bs(o);Te(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Needs attention"),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),a.length?a.slice(0,8).map(s=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${s.tone}`}),t("span",{},s.text),s.action??""])):t("div",{class:"dl-row dl-muted"},[b("check"),"All good. Nothing needs you right now."])]),e);let i=[...o.events].reverse().slice(0,8);Te(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),i.length?i.map(s=>it(o,s)):t("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),e)}onlineTile(){let e=this.st,o=e.servers[0]?!e.servers[0].enabled:!1,r=12,a=I=>I.spark[I.spark.length-1]??0,i=I=>e.geo.points.find(x=>x.device===I.id&&x.city)?.city,s=I=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(I.endpoint??""),l=(I,x=!1)=>s(I)?x&&I.endpoint?`LAN · ${I.endpoint}`:"LAN":i(I)??"",c=I=>[...e.events].reverse().find(x=>x.type==="connect"&&x.device===I.id)?.ts??0,d=e.people.map(I=>({p:I,devs:I.devices.filter(x=>x.online).sort((x,v)=>a(v)-a(x))})).filter(I=>I.devs.length).sort((I,x)=>x.devs.reduce((v,$)=>v+a($),0)-I.devs.reduce((v,$)=>v+a($),0)),p=d.length<=2,u=({p:I,devs:x})=>{let v=x.map(c).filter(Boolean),$=v.length?Math.min(...v):0,E=(I.rate??[]).slice(-15),y=E[E.length-1],z=y&&e.now-y[0]<180?y:null,h=200,f=30,T=Math.max(1,...E.map(V=>Math.max(V[1],V[2]))),S=V=>E.map((R,J)=>`${E.length>1?J/(E.length-1)*h:h},${f-2-R[V]/T*(f-6)}`),N=E.length>1?Xe(``):"",G=!z||z[1]<64&&z[2]<64,q=I.access==="both"?["home","globe"]:I.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},He(I.name)),t("span",{class:"dl-stack"},[t("b",{},I.name),t("span",{class:"dl-hc-since"},$?`online for ${re($,e.now).replace(" ago","")}`:"online")]),t("span",{class:"dl-hc-reach"},q.map(V=>t("span",{class:`dl-ibadge ${V==="home"?"lan":"inet"}`},b(V))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},G?[t("span",{class:"dl-faint"},"Idle right now")]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${Oe(z[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${Oe(z[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},"15 min")]),N]),t("div",{class:"dl-hc-devs"},x.map(V=>t("span",{class:"dl-hc-dev"},[b(V.kind),V.name,l(V)?[" · ",l(V,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${X(x.reduce((V,R)=>V+a(R),0))} today · ${X(I.month[0]+I.month[1])} this month`)])])]},w=I=>{let{p:x,devs:v}=I,$=t("span",{class:"dl-onl-dev"},v.length>1?String(v.length):b(v[0].kind)),E=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:ke(x.id),"aria-label":`${x.name}, online`},[t("span",{class:"dl-onl-av"},[He(x.name),$]),p?t("span",{class:"dl-onl-name"},x.name):"",p?t("span",{class:"dl-onl-meta"},[...v.slice(0,3).map(y=>b(y.kind)),v.length>3?`+${v.length-3}`:"",l(v[0])?t("span",{},[" · ",l(v[0])]):""]):""]);return me(E,()=>u(I)),E},C=t("b",{class:`dl-onl-count${d.length?"":" none"}`},String(d.length)),g=d.reduce((I,x)=>I+x.devs.length,0);d.length&&me(C,()=>[`${d.length} ${d.length===1?"person":"people"} · ${g} device${g===1?"":"s"}`]);let m=d.length>r?d.slice(0,r-1):d,k=e.people.flatMap(I=>I.devices.map(x=>({p:I,d:x}))).filter(I=>I.d.handshake).sort((I,x)=>x.d.handshake-I.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Online"),C]),d.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...m.map(w),d.length>r?t("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:I=>{this.go&&(I.preventDefault(),this.go("people","online"))}},[t("span",{class:"dl-onl-av"},`+${d.length-m.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},o?"The server is turned off":"Nobody is connected"),k?t("span",{class:"dl-sub"},`Last: ${k.p.name}, ${re(k.d.handshake,e.now)}`):t("span",{class:"dl-sub"},o?"Devices connect once it is on":"No device has connected yet")])])}speedTile(){let e=this.st.servers[0];return Tn(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){let e=[...this.st.people].map(o=>[o,o.month[0]+o.month[1]]).filter(([,o])=>o>0).sort((o,r)=>r[1]-o[1]).slice(0,2);return Sn(this.st.series,e.length?`Most: ${e.map(([o,r])=>`${o.name} ${X(r)}`).join(" · ")}`:"")}};var Kr=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],xs={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},go=(n,e)=>{let o=new URLSearchParams;n&&o.set("server",n),e&&e!=="overview"&&o.set("section",e);let r=o.toString();return`${L.url("admin/network/dawnline/server")}${r?`?${r}`:""}`},Yt=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await A.status(31),o=e.servers.length?null:await A.setupDefaults();return[e,o]}render([e,o]){if(this.st=e,!e.servers.length&&o)return this.wizard(o);let r=new URLSearchParams(location.search),a=r.get("section")??"",i=xs[a]??a;return Kr.some(([s])=>s===i)&&(this.section=i),this.srvId=(e.servers.find(s=>s.id===r.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller?.stop(),this.poller=ot({fetch:()=>A.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(s,l)=>{s.servers.length&&(this.st=s,this.paintHead(l),this.ov[this.current().id]?.update(s,l))}}),this.root}paintHead(e=!1){Te(this.headEl,this.head(this.current()),e),(!e||!Pt(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await A.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await A.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=go())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(o=>t("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===e.id?" on":""}`,"aria-selected":o.id===e.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[t("i",{class:`dot ${o.enabled?o.up?"ok":"bad":"warn"}`}),t("b",{},o.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[b("plus"),"Add server"])]))}paintSections(){let e=Be(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},Kr.map(([o,r])=>t("button",{type:"button",role:"tab","data-section":o,class:o===this.section?"on":"","aria-selected":o===this.section?"true":"false",click:()=>this.showSection(o)},o==="awg"?e.label:r))))}go(e,o){let r=this.pp[this.current().id];if(o&&r)r.filter=o,r.el&&r.decorate();else if(o){let a=this.pp[this.current().id]=new ut;a.filter=o}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of e)o&&this.bodyEl.contains(o)&&o.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===e;s.classList.toggle("on",l),s.setAttribute("aria-selected",l?"true":"false")});let o=this.st,r=this.current(),i={overview:()=>{let s=this.ov[r.id];return s?(s.update(o),s.el):(this.ov[r.id]=new Pn(r.id,(l,c)=>this.go(l,c))).mount(o)},people:()=>{var d,p;let s=this.pp[r.id];if(s?.el)return s.update(),s.el;let l=t("div",{},t("p",{class:"dl-muted"},"Loading people…"));return((d=this.pp)[p=r.id]??(d[p]=new ut)).embed(o,r.id).then(u=>{l.isConnected?dom.content(l,u):l.replaceChildren(u)}).catch(u=>{delete this.pp[r.id],dom.content(l,t("p",{class:"dl-muted"},`Couldn't show people: ${be(u)}`))}),l},connection:()=>this.connection(r),access:()=>this.access(r),awg:()=>this.awg(r)}[e]();this.detachKept(),dom.content(this.bodyEl,i)}head(e){let o=(i,s)=>t("span",{class:"dl-addrbar-seg"},[b(i),...s]),r=e.endpoint||"—",a=t("div",{class:"dl-actions"},[e.enabled?"":H([b("play")," Turn on"],()=>this.save(e,{enabled:"1"},"Server turned on"),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?"Running":e.blocked?"Can’t start":"Not running":"Turned off"),t("span",{class:"dl-spacer"}),a]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>pe(r,"Address copied")},[b("globe"),t("span",{class:"dl-mono"},r),b("copy")]),o(Be(e).id==="awg"?"amneziawg":"tunnel",[t("span",{class:"dl-mono"},`${Be(e).label} :${e.port}`)]),e.up?o("clock",[`up ${vt(e.uptime)}`]):""]),e.blocked?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},`${e.name} ${e.blocked}.`)]):""])}async save(e,o,r="Saved"){await W(()=>A.serverUpdate(e.id,o),r)&&await this.refresh()}connection(e){let o=ie(e.name,{placeholder:"Home"}),r=ie(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),a=ie(e.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter(C=>C.server===e.id).length,s=H([b(e.enabled?"pause":"play"),e.enabled?" Turn off":" Turn on"],async()=>{e.enabled&&!await se(`Turn off ${e.name}?`,`The tunnel stops and ${i} ${i===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?"Server turned off":"Server turned on")},e.enabled?"negative":"positive"),l=this.st.settings.portal_host,c=fe("Name",o,()=>_e(o.value,[],"Shown to people in their portal and apps.")),d=Vn(()=>({host:r.value,port:e.port,id:e.id}),(C,g,m)=>A.endpointProbe(C,g,m),()=>p.refresh(),{empty:l?`Empty = the portal’s address (${l}).`:"Empty = the portal’s address."}),p=fe("Public address",r,d.help);r.addEventListener("input",d.schedule),d.schedule();let u=e.reached?`Reached from the internet ${re(e.reached,this.st.now)}.`:"Never reached from the internet yet — test with a phone on mobile data.",w=fe("DNS for devices",a,()=>Io(a.value,e.address));return t("div",{class:"dl-stack gap16"},[Rt("Connection",[t("p",{class:"dl-muted"},"The name people see, where devices find the router, and DNS. The port is on AmneziaWG."),ge("router","Server","What people see",[c]),ge("globe","Devices connect to","A DDNS name keeps links working when your IP changes; not through Cloudflare (use a DNS-only name or an IP)",[p,t("div",{class:`dl-sub ${e.reached?"ok":"warn"}`},u)]),ge("file","For every device","Changing it marks devices “Update config” until they import again",[w])],[t("span"),H("Save",()=>{let C=ze([c,p,w]);if(C){U(C,"warning");return}return this.save(e,{name:o.value,endpoint:r.value,dns:a.value})},"positive")]),Rt("Danger zone",[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?"Turn off this server":"This server is off"),t("span",{class:"dl-sub"},e.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),t("div",{class:"dl-setrow-ctl"},s)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Change the tunnel network"),t("span",{class:"dl-sub"},`Devices have ${yt(e.subnet)}.x addresses now. A new range when it clashes with a network you connect to; every device then needs its configuration again.`)]),t("div",{class:"dl-setrow-ctl"},H([b("edit")," Change"],()=>this.changeSubnet(e),"negative"))]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Remove server"),t("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),t("div",{class:"dl-setrow-ctl"},H([b("trash")," Remove"],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let o=mo(this.st,e),r=Ur(e,this.st,async()=>{let a=await this.refreshStatus();if(!a)return;let i=a.servers.find(l=>l.id===e.id)??e;r.update(a);let s=mo(a,i);o.replaceWith(s),o=s});return t("div",{class:"dl-stack gap16"},[r.el,t("div",{class:"dl-health-cols"},[o,Hr(this.st,e)])])}awg(e){let o={st:this.st,save:(r,a)=>this.save(e,r,a),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[Be(e).settingsCard(o,e)])}async addServer(){let e=await W(()=>A.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async changeSubnet(e){let o=await W(()=>A.serverPorts(e.id));if(!o)return;let r=o.networks??[],a=this.st.people.filter(l=>l.server===e.id).reduce((l,c)=>l+c.devices.length,0),i=ie(yt(e.subnet),{class:"cbi-input-text dl-mono dl-w-range"}),s=fe("Address range",i,()=>Jn(i.value,r,""));te("Change the tunnel network",[s,t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from their personal link or from you).`:"No devices on this server yet: nothing else changes.")],[ae()," ",H("Change",async()=>{let l=s.help();if(l.bad){U(l.text,"warning");return}let c=rn(i.value);if(c===e.subnet){oe();return}await W(()=>A.serverUpdate(e.id,{subnet:c}),"Tunnel network changed")&&(oe(),a&&U("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())},"negative")]),setTimeout(()=>i.select(),50)}async remove(e){let o=this.st.people.filter(r=>r.server===e.id);te(`Remove ${e.name}?`,[t("p",{},`This removes the tunnel, its firewall rules and ${o.length} ${o.length===1?"person":"people"} with all their devices. A backup is made first.`)],[ae()," ",H("Remove",async()=>{oe(),await W(()=>A.serverDelete(e.id),"Server removed")&&setTimeout(()=>{location.href=go()},800)},"negative")])}wizard(e,o=!1,r){let a={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:yt(e.subnet),preset:un(e.awg),portal:!1,portal_port:e.portal_port||8443,lan_like:!0,lan_zone:e.lan_zone,wan_zone:e.wan_zone},i=0,s=!o&&a.portal_port===a.port,l=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(a.endpoint),c=()=>It(a.port,e.udp_taken??[],`Opened on the WAN firewall automatically.${a.port===4500?" 4500 is IPsec’s port: most networks let it through.":""}`),d={ddns:"From your DDNS name.",cert:"From your Let’s Encrypt certificate.",wan:"Your WAN address now — it may change; a DDNS name is better.",portal:"The portal’s address."},p=Vn(()=>({host:a.endpoint,port:a.port}),(T,S,N)=>A.endpointProbe(T,"",N),()=>u?.refresh(),{idle:()=>a.endpoint===e.endpoint&&e.endpoint_from?d[e.endpoint_from]??"":""}),u=null,w=e.wan_kind==="cgnat"||e.wan_kind==="private"?Qe("alert","warn",e.wan_kind==="cgnat"?"Your router has no public address (CGNAT)":`Your router is behind another router (WAN ${e.wan_ip})`,e.wan_kind==="cgnat"?"The ISP shares one address: devices can only connect if the ISP gives you a public address or IPv6. Ask them, or use a DDNS name that points at an IPv6 address.":"Forward the UDP port on the upstream router to this one and use a DDNS name or that router’s public address here.",""):"",C=e.awg_state?.tools&&e.awg_state.handler===!1?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},"Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.")]):"",g=()=>Jn(a.range,e.networks??[],yt(e.subnet)),m=()=>an(a.portal_port,e.tcp_taken??[],l()),k=t("div",{class:"dl-wizard"}),I=(T,S={})=>{let N=ie(String(a[T]),S);return N.addEventListener("input",()=>{T==="port"||T==="portal_port"?a[T]=N.value.trim()===""?0:Number(N.value):a[T]=N.value.trim(),T==="port"&&s&&(a.portal_port=a.port),T==="portal_port"&&(s=a.portal_port===a.port)}),N},x={id:"server",title:"Server",render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},o?"One more server: another port or disguise for networks where the first does not get through, or its own home access rules. People are moved between servers from their page.":"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),ge("router","Server","What people see",[fe("Name",I("name"),()=>_e(a.name,[],"Shown to people in their portal and apps."))]),ge("globe","Devices connect to","A hostname or IP address of your router on the internet; not through Cloudflare (use a DNS-only name or an IP). IPv6 works too, and is the way out of CGNAT",[(()=>{let T=I("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"});return u=fe("Public address",T,p.help),T.addEventListener("input",p.schedule),p.schedule(),u})()]),w,C]),check:()=>{let T=_e(a.name);if(T.bad)return`Name: ${T.text}`;let S=wt(a.endpoint,a.port);return S.bad?`Public address: ${S.text}`:null}},v={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[ge("globe","Listening","Where devices reach AmneziaWG from the internet",[fe("UDP port",I("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),c)]),ge("network","Tunnel network","Addresses devices get inside the tunnel",[(()=>{let T=I("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":"First three numbers of the device addresses"});return fe("Device addresses",T,g,t("span",{class:"dl-suffixed"},[T,t("span",{class:"dl-mono"},".x")]))})()]),ge("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[mn(e.awg,a.preset,T=>a.preset=T,void 0,e.awg_state?.tools!==!1)])]),check:()=>{let T=c();if(T.bad)return`UDP port: ${T.text}`;let S=g();return S.bad?`Device addresses: ${S.text}`:null}},$={id:"portal",title:"Portal",render:()=>{let T=I("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),S=fe("Listening port",T,m);S.hidden=!a.portal;let N=we([["off","Off"],["on","On"]],a.portal?"on":"off",{label:"Personal portal",onChange:G=>{a.portal=G==="on",S.hidden=!a.portal}});return t("div",{class:"dl-wizard-groups"},[ge("home","Internet like a home device","How devices reach the internet",[de("Through the home network",ve(a.lan_like,"Internet like a home device",G=>a.lan_like=G),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),ge("link","Personal portal","A page where each person adds their own devices with their personal link",[de("Portal",N,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),S])])},check:()=>{if(!a.portal)return null;let T=m();return T.bad?`Portal port: ${T.text}`:null}},E=()=>[x,v,o?null:$].filter(T=>T!=null),y=e.awg_state,z=y?.missing??[],h=z.length?t("div",{class:"dl-list dl-notices"},[Qe("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${z.join(" and ")}. Install the build made for this firmware, then create the server.`,H("Install",()=>Ln(()=>location.reload()),"positive"))]):y&&!y.loaded?t("div",{class:"dl-list dl-notices"},[Qe("shield","warn","AmneziaWG’s kernel module doesn’t load on this firmware","Try another build in Components, or update OpenWrt. The server can’t start until it loads.",t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",f=()=>{let T=E();i>=T.length&&(i=T.length-1),dom.content(k,[t("h2",{},o?"Add a server":"Set up Dawnline"),h,t("div",{class:"dl-steps"},T.map((S,N)=>t("span",{class:`dl-step${N===i?" current":N0?H("Back",()=>{i--,f()}):r?H("Cancel",r):"",t("span",{class:"dl-spacer"}),i{let S=T[i].check?.();if(S){U(S,"warning");return}i++,f()},"positive"):H("Create server",async()=>{for(let N of T){let G=N.check?.();if(G){U(G,"warning");return}}let S=await W(()=>A.serverCreate(a.id,a.name,e.ifname,a.port,rn(a.range),a.endpoint,e.mtu,a.preset,a.lan_zone,a.wan_zone,a.lan_like,o?void 0:a.portal,o?void 0:a.portal_port),"Server created");S&&(S.network_restart&&U("Restarting the network so it knows AmneziaWG: back in a few seconds"),setTimeout(()=>{location.href=go(S.id)},S.network_restart?1e4:1500))},"positive",{disabled:z.length>0,title:z.length?"Install AmneziaWG first":null})])])};return f(),k}};function st(n){let e={el:n(),refresh(){let o=n();e.el.replaceWith(o),e.el=o}};return e}function Re(n,e,o,r,a="",i=[]){return t("section",{class:`dl-setsec ${a}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[i.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...i]):t("h3",{},e),...o]),r.length?t("div",{class:"dl-setsec-foot"},r):""])}function Jr(n){let e=n.filter(a=>a.status!=="skip"),o=e.filter(a=>a.status==="error"||a.status==="warn"),r=e.some(a=>a.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:r}}function Vr(n){let e=n.d.settings,o=n.d.effective,r=n.d.cert,a=ve(o.portal_enabled,"Enable portal"),i=ie(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=ie(e.portal_title,{placeholder:"Dawnline"}),l=ie(e.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),c=ie("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),d=O=>/^\d{1,3}(\.\d{1,3}){3}$/.test(O),p=[o.portal_host,...o.portal_alt??[]].filter((O,F,P)=>O&&P.indexOf(O)===F),u=!!n.portal,w=[],C=O=>{O&&!w.some(F=>F.host===O)&&w.push({host:O,kind:d(O)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},g=O=>{w=[...O,...w.filter(F=>!O.some(P=>P.host===F.host))],!p.length&&O[0]&&(p=[O[0].host])};n.portal&&g(n.portal.candidates),p.forEach(C);let m=O=>O.kind==="ip"?t("span",{class:"dl-addr-warn"},[b("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):t("span",{class:"dl-sub"},O.cloudflare?"Behind Cloudflare · often stalls in Russia":O.ips.length?O.here?`Points at this router${O.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${O.ips.join(", ")}, not this router`:u?"Your address":"Checking where it points…"),k=t("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),I=O=>{p.includes(O)?p.length>1&&(p=p.filter(F=>F!==O)):p=[...p,O],x(),E()},x=()=>dom.content(k,[...w.map(O=>{let F=p.includes(O.host),P=p[0]===O.host;return t("div",{class:`dl-addr-opt${F?" on":""}`,role:"checkbox","aria-checked":F?"true":"false",tabindex:"0",click:()=>I(O.host),keydown:D=>{(D.key===" "||D.key==="Enter")&&(D.preventDefault(),I(O.host))}},[t("i",{class:"dl-addr-check"},F?b("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},O.host),m(O)]),P?t("span",{class:"dl-pill info"},"Main"):F?t("button",{type:"button",class:"dl-linkbtn",click:D=>{D.stopPropagation(),p=[O.host,...p.filter(_=>_!==O.host)],x(),E()}},"Make main"):O.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):O.kind==="ip"?t("span",{class:"dl-pill"},"IP"):O.here&&O.cert?t("span",{class:"dl-pill ok"},"Recommended"):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},b("plus")),c,H("Add",()=>{let O=c.value.trim().toLowerCase();if(!O)return;let F=wt(O);if(F.bad){U(F.text,"warning");return}C(O),p.includes(O)||(p=[...p,O]),c.value="",x(),E()})])]);c.addEventListener("keydown",O=>{O.key==="Enter"&&(O.preventDefault(),c.nextElementSibling?.click())});let v=t("div",{class:"dl-links"}),$=()=>{},E=()=>{$();let O=Number(i.value)||o.portal_port;dom.content(v,p.map((F,P)=>{let D=d(F),_=D?O+1:O,B=`${D?"http":"https"}://${F}${_===(D?80:443)?"":`:${_}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${D?"warn":"ok"}`},b(D?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[B,t("b",{},"kamiro-telosu-bavine")]),P===0?t("span",{class:"dl-pill info"},"Main"):D?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};x(),E(),i.addEventListener("input",()=>E());let y={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},z=n.d.needs??{https:[],acme:[],home:[]},h=O=>{if(!o.portal_enabled)return t("div",{hidden:!0});if(!O)return ge("check","Ready to share","The portal’s checks from Health",[t("p",{class:"dl-muted dl-loading"},"Running checks…")]);let F=O.filter(M=>M.status!=="skip");if(!F.length)return t("div",{hidden:!0});let{bad:P,worst:D}=Jr(O),_=t("div",{class:"dl-ready-details",hidden:!0},F.map(M=>t("div",{class:`dl-ready-item ${M.status}`},[b(M.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},M.title),t("span",{class:"dl-sub"},M.detail)])]))),B=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${D}`},[b(D==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},D==="ok"?`All ${F.length} checks passed`:`${F.length-P.length} of ${F.length} checks passed`),P.length?t("span",{class:"dl-sub"},P.map(M=>M.detail).join(" ")):t("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),t("button",{type:"button",class:"dl-linkbtn",click:M=>{_.hidden=!_.hidden,M.currentTarget.textContent=_.hidden?"Details":"Hide"}},"Details")]),t("div",{class:"dl-chips-row"},F.map(M=>t("span",{class:`dl-check-chip ${M.status}`,title:M.detail},[b(M.status==="ok"?"check":"alert"),y[M.id]??M.title]))),_]);return ge("check","Ready to share","The portal’s checks from Health",[B])},f=O=>{if(!o.portal_enabled||!O&&!z.https.length)return t("span",{hidden:!0});if(z.https.length)return t("span",{class:"dl-pill bad"},"Can’t start");let{worst:F}=Jr(O);return t("span",{class:`dl-pill ${F==="ok"?"ok":F==="error"?"bad":"warn"}`},F==="error"?"Needs attention":"Ready")},T=h(n.portal?.checks??null),S=f(n.portal?.checks??null);n.portalFill=O=>{u=!0,g(O.candidates),x(),E();let F=h(O.checks);T.replaceWith(F),T=F;let P=f(O.checks);S.replaceWith(P),S=P};let N=r&&!r.self_signed&&r.expires?Ue(r.expires):"",G=fe("Listening port",i,()=>an(i.value.trim()===""?o.portal_port:Number(i.value),n.d.tcp_taken??[],p.some(d)));$=G.refresh;let q=fe("Title",s,()=>Fo(s.value)),V=fe("Unknown links",l,()=>Go(l.value)),R=!!(e.portal_cert&&e.portal_key),J=r?R?"Your files":r.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",Q=()=>{let O=ie(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),F=ie(e.portal_key,{placeholder:"/etc/ssl/…/key"});te("Use your own certificate",[t("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),de("Certificate file",O),de("Key file",F)],[ae()," ",H("Save",()=>{oe(),n.save({portal_cert:O.value.trim(),portal_key:F.value.trim()},"Certificate saved","portal")},"positive")])},le=(O,F,P,D,_,B)=>Qe(O,F,P,D,H(B,()=>Vt(_,z[_],()=>n.reload("portal")),"positive")),he=z.https.length?le("lock","bad","HTTPS isn’t available on this router",`The portal needs ${z.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",ue=z.acme.length&&(!r||r.self_signed)?le("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${e.portal_host?` for ${e.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",ne=[t("div",{class:"dl-row"},[b("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[J,N?t("span",{class:"dl-faint"},` · until ${N}`):""]),t("span",{class:"dl-sub dl-ellipsis",title:r?.path??""},r?r.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${R?"Your files":"Found automatically"} · ${r.path}`:"Turn the portal on to see its certificate.")])]),t("div",{class:"dl-row"},[b("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Your own files"),t("span",{class:"dl-sub"},R?`${e.portal_cert} · ${e.portal_key}`:"Not set: the certificate is picked automatically.")]),R?H("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",H(R?"Change":"Use files",Q)]),ue];return Re("portal","Personal portal",[t("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),he?t("div",{class:"dl-list"},[he]):"",ge("network","Port","How the portal listens (80 and 443 stay free)",[G]),ge("edit","Appearance","What people see",[q,V]),ge("link","Addresses","Pick one or more; the first is the main link",[k,t("div",{class:"dl-stack gap8"},[v,t("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),ge("lock","Certificate","Used for HTTPS links",ne),T],[t("span"),H("Save",()=>{let O=ze([G,q,V]);if(O){U(O,"warning");return}return n.save({portal_enabled:Pe(a)?"1":"0",portal_host:p[0]??"",portal_alt:p.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:l.value.trim()},"Saved","portal")},"positive")],"",[S,a])}function Yr(n){let e=n.d.settings,o=n.d.effective,r=ie(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),a=ve(o.hostnames,"Device hostnames"),i=ie(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=ie(e.home_dns_fallback==="none"?"":e.home_dns_fallback||o.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),l=fe("Devices per person",r,()=>{if(!r.value.trim())return{text:"The default, 3. Pre-filled when you add someone.",bad:!1};let p=sn(r.value);return p.bad?p:{text:"Pre-filled when you add someone.",bad:!1}}),c=fe("Device hostnames",i,()=>qo(i.value),t("div",{class:"dl-hostport"},[a,t("span",{class:"dl-faint dl-mono"},"phone.myata."),i])),d=fe("Fallback DNS",s,()=>{let p=Ko(s.value);return p.bad?p:{text:`For Home-only devices using home names: ${p.text}`,bad:!1}});return Re("defaults","New people",[l,c,d],[t("span"),H("Save",()=>{let p=ze([l,c,d]);if(p){U(p,"warning");return}return n.save({default_device_limit:r.value,hostnames:Pe(a)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults")},"positive")])}function Zr(n){let e=n.d.effective,o=ve(e.geo_enabled,"Locations"),r=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Re("map","Map & locations",[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),o]),de("Provider",r)],[t("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),H("Save",()=>n.save({geo_enabled:Pe(o)?"1":"0",geo_provider:r.value},"Saved","map"),"positive")])}var ws=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function Qr(n){let e=n.d.effective.updates,o=ve(e.check,"Check automatically",g=>C(g,Pe(a))),r=we([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],e.interval,{label:"How often",cls:"sm"}),a=ve(e.auto,"Install automatically",g=>C(Pe(o),g)),i=ie(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":"Time"}),s=we([["scheduled","At a set time"],["immediate","As soon as found"]],e.mode,{label:"When",cls:"sm",onChange:g=>i.hidden=g!=="scheduled"});i.hidden=e.mode!=="scheduled";let l=new Set(e.targets),c=t("div",{class:"dl-chips-row"},ws.map(([g,m])=>{let k=qe(m,l.has(g),()=>{l.delete(g)||l.add(g),pn(k,l.has(g))});return k})),d=ve(e.keep,"Keep the previous version"),p=ve(e.mirrors,"GitHub mirrors"),u=de("How often",r),w=[de("When",t("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),de("Components",c,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],C=(g,m)=>{u.hidden=!g;for(let k of w)k.hidden=!m};return C(e.check,e.auto),Re("updates","Updates",[t("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),de("Check automatically",o,"Looks for new versions in the background; Components shows what it found and the service log names it."),u,de("Install automatically",a,"Downloads and installs new versions of the components below."),...w,de("Keep the previous version",d,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),de("GitHub mirrors",p,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[t("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),H("Save",()=>{if(s.dataset.value==="scheduled"){let g=Jo(i.value);if(g.bad){U(`Time: ${g.text}`,"warning");return}}return n.save({update_check:Pe(o)?"1":"0",update_interval:r.dataset.value,update_auto:Pe(a)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Pe(d)?"1":"0",update_mirrors:Pe(p)?"1":"0"},"Saved","updates")},"positive")])}function Xr(n){let e=n.d.logs,o=e.policy,r=we([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(o.keep_days),{label:"Keep activity",cls:"sm"}),a=we([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(o.max),{label:"Maximum events",cls:"sm"}),i=we([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],o.persist,{label:"Save to flash",cls:"sm"}),s=we([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(o.usage_days),{label:"Daily traffic",cls:"sm"}),l=we([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(o.usage_months),{label:"Monthly traffic",cls:"sm"}),c=new Set(o.categories),d=t("div",{class:"dl-chips-row"},Et.map(C=>{let g=qe([pt[C],t("b",{},String(e.by_category[C]??0))],c.has(C),()=>{c.delete(C)||c.add(C),pn(g,c.has(C))},{title:tr[C]});return g})),p=e.oldest?Ue(new Date(e.oldest*1e3)):"",u=(C,g,m,k)=>t("div",{class:"dl-row"},[b(C),t("span",{class:"dl-row-main dl-stack"},[t("b",{},g),t("span",{class:"dl-sub"},m)]),...k]),w=C=>H(C.toUpperCase(),async()=>{let[g,m]=await Promise.all([A.status(1),A.events(2e4)]);Fe(g,m.events,C)},"neutral",{title:`Download the log as ${C.toUpperCase()}`});return Re("logs","Logs & history",[t("p",{class:"dl-muted"},cn(o)),de("Keep activity",r,"Older events are removed automatically."),de("Maximum size",a,"Newest events are kept when the log is full."),de("Record",d,"Switched-off categories are not logged from now on."),de("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),de("Daily traffic",s,"Per-day history behind the charts."),de("Monthly traffic",l,"Per-month totals; data limits use the current month."),t("h4",{class:"dl-setsub"},"Stored data"),t("div",{class:"dl-list"},[u("activity","Activity log",e.events?`${en(e.events,"event")} since ${p} · ${Nt(e.log_ram)} in memory${o.persist==="off"?"":`, ${Nt(e.log_flash)} on flash`}`:"Empty",[w("csv"),w("json"),H("Clear",()=>et("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),u("chart","Traffic history",e.usage_days?`${en(e.usage_days,"day")} since ${Ue(e.usage_since)} · ${Nt(e.usage_flash)} on flash`:"Empty",[H("Reset",()=>Lt("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),u("pin","Location cache",`${en(n.d.geo_cached,"address","addresses")} · ${Nt(e.geo_flash)} on flash`,[H("Clear",async()=>{await W(()=>A.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},"Clear one person or device from their own page."),H("Save",()=>n.save({log_keep_days:r.dataset.value,log_max:a.dataset.value,log_persist:i.dataset.value,usage_keep_days:s.dataset.value,usage_keep_months:l.dataset.value,log_category:[...c]},"Saved","logs"),"positive")])}var ys={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},ea=3;function vo(n){let e=new Date(n*1e3),o=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),r=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return`${r===0?"Today":r===1?"Yesterday":e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${o}`}async function ks(n){let e=await W(()=>A.backupRead(n.name));if(!e)return;let o=atob(e.data),r=new Uint8Array(o.length);for(let i=0;iks(n),"neutral","dl-icon-only"),Le("more","More",o=>Ce(o.currentTarget,[{label:"Restore",icon:b("reset"),run:async()=>{await se("Restore this backup?",`Everything returns to ${vo(n.created)}. The current state is backed up first.`,"Restore",!0)&&await W(()=>A.backupRestore(n.name),"Restored")&&e(!0)}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await se("Delete this backup?",`The backup from ${vo(n.created)} is removed from the router.`,"Delete",!0)&&await W(()=>A.backupDelete(n.name),"Backup deleted")&&e()}}]),"neutral","dl-icon-only")])])}function na(n,e){let o=n.slice(0,ea).map(c=>ta(c,e)),r=n.slice(ea),a=n.length?t("div",{class:"dl-list"},[...o,r.length?t("details",{class:"dl-bk-older"},[t("summary",{},[b("chevron"),`${r.length} older backup${r.length===1?"":"s"}`]),...r.map(c=>ta(c,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=H("Restore from file",async()=>{let c=await Wn(".tar.gz,.tgz,application/gzip","base64");if(!c)return;await se("Restore from file?",`Replace the current Dawnline configuration with ${c.name}? The current state is backed up first.`,"Restore",!0)&&await W(()=>A.backupUpload(c.data),"Restored")&&e(!0)}),s=H("Export JSON",async()=>{let c=await W(()=>A.exportJson());c&&Se(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(c,null,2),"application/json")}),l=H("Import JSON",async()=>{let c=await Wn(".json,application/json","text");if(!c)return;let d;try{d=JSON.parse(c.data)}catch{U("Not a JSON file.","error");return}await se("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await W(()=>A.importJson(d),"Imported")&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},"Backups"),t("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),t("span",{class:"dl-spacer"}),H([b("plus")," Back up now"],async()=>{await W(()=>A.backupCreate(),"Backup created")&&e()},"positive")]),a]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),t("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function $s(){let n=ie("",{placeholder:"remove"}),e=H("Remove Dawnline",async()=>{await W(()=>A.uninstall(n.value.trim()),"Dawnline removed")&&(oe(),setTimeout(()=>location.reload(),800))},"negative",{disabled:!0});n.addEventListener("input",()=>{e.disabled=n.value.trim()!=="remove"}),te("Remove Dawnline?",[t("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[ae()," ",e])}function oa(){return Re("danger","Remove Dawnline from this router",[t("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[t("span"),H("Remove",()=>$s(),"negative")],"danger")}var Dn=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return A.settingsGet()}render(e){this.d=e,this.cards={portal:st(()=>Vr(this)),defaults:st(()=>Yr(this)),map:st(()=>Zr(this)),updates:st(()=>Qr(this)),logs:st(()=>Xr(this)),backups:st(()=>na(this.backups,a=>this.loadBackups(a))),danger:st(()=>oa())};let o=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,o.map(a=>this.cards[a].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let r=new URLSearchParams(location.search).get("section");return r&&r!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${r}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(e,o,r){let a=await W(()=>A.settingsUpdate(e),o);a&&(this.d=a,this.cards[r].refresh(),r==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,o=await A.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let o=await A.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(e){let o=await A.settingsGet().catch(()=>null);if(o){if(this.d=o,e)this.cards[e].refresh();else for(let r of Object.values(this.cards))r.refresh();(!e||e==="portal")&&this.loadPortal()}}};function ra(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function aa(n){let e=[],o=l=>{let c=[],d=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=d.exec(l);)u.index>p&&c.push(l.slice(p,u.index)),u[1]?c.push(t("code",{},u[1].slice(1,-1))):u[2]?c.push(t("b",{},u[2].slice(2,-2))):u[3]?c.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&c.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{a.length&&e.push(t("p",{},o(a.join(" ")))),a=[],r=null};for(let l of n.replace(/\r/g,"").split(` -`)){let c=l.trimEnd();if(i){/^```/.test(c.trim())?(e.push(t("pre",{},i.join(` -`))),i=null):i.push(l);continue}if(/^```/.test(c.trim())){s(),i=[];continue}let d=/^(#{1,6})\s+(.*)$/.exec(c),p=/^\s*[-*+]\s+(.*)$/.exec(c)??/^\s*\d+[.)]\s+(.*)$/.exec(c);d?(s(),e.push(t("h5",{},o(d[2])))):p?(a.length&&s(),r||(r=t("ul",{}),e.push(r)),r.appendChild(t("li",{},o(p[1])))):c.trim()?(r&&(r=null),a.push(c.trim())):s()}return i&&e.push(t("pre",{},i.join(` -`))),s(),e}function ia(n){let e=[],o=!1;for(let r of n.replace(/\r/g,"").split(` -`)){let a=/^#{1,6}\s+(.*)$/.exec(r);if(a){if(o=/^install\b/i.test(a[1].trim()),/^what.s new$/i.test(a[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(r)&&(o=!1);o||e.push(r)}return e.join(` +`,gr(s,e)]:[gr(s,e)])),a=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(a,[b(e?"x":"key"),e?"Hide key":"Show key"]),o()}},[b("key"),"Show key"]);o();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),H([b("download")," Download"],()=>Te(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),a,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),ue(n.conf,"Configuration copied")}},[b("copy"),"Copy"])]),r])])}function no(n){let e=n.amnezia.obfuscation??{},r={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([o,a])=>a==null||a===""||a===(r[o]??"0"))}async function os(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 r=await to(n,`${n.server} · ${n.person} · ${n.name}`),o={qr:()=>t("div",{class:"dl-qr-pane"},[et(Lt(n.conf),"dl-qr"),t("span",{class:"dl-sub"},no(n)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},r),H("Copy",()=>ue(r,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>ns(n)},a=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(a,o[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},d));return s(e),t("div",{class:"dl-stack gap12"},[i,a])}async function rs(n,e,r,o){let a=jt(r),s=n.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await le(o?"Generate new disguise values?":`Switch to ${a.title}?`,`${s} AmneziaWG device${s===1?" stops":"s stop"} connecting until ${s===1?"it imports its":"they import their"} configuration again (from their personal link or from you).${r==="max"?" They need an app with AmneziaWG 3.1.":r==="balanced"?" They need an app with AmneziaWG 2.0 or newer.":""}${n.st.servers.length===1&&s?" To keep the old disguise for some people, add a second server and move them there.":""}`,o?"Generate and apply":"Switch and apply",!0)&&await G(()=>A.serverObfuscation(e.id,r),o?"New values applied":`${a.title} applied`)&&(U("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function as(n,e){let r=n.st,o=se(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=se(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=se(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=jt(e.preset)?e.preset:void 0,l=s??mn(r.awg),d=H("",()=>rs(n,e,l,l===s),"neutral"),c=()=>dom.content(d,l===s?[b("reset")," Generate new values"]:[`Switch to ${jt(l).title}`]);c();let p=r.awg_state?.tools!==!1,u=[],x=he("UDP port",o,()=>It(Number(o.value),u,`Opened on the WAN firewall automatically.${Number(o.value)===4500?" 4500 is IPsec’s port: most networks let it through.":""}`));A.serverPorts(e.id).then(m=>{u=m.udp_taken??[],x.refresh()}).catch(()=>{});let $=he("MTU",a,()=>Fo(a.value,e.mtus)),h=he("Keep-alive",i,()=>qo(i.value));return Rt("",[hr("AmneziaWG",e.ifname),fe("globe","Listening","Where devices reach this core from the internet",[x]),fe("file","In every device configuration","Changing these marks devices “Update config” until they import again",[$,h]),fe("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Ut(e.preset)?pt("warn",[t("b",{},Ut(e.preset))," is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to ",t("b",{},"Balanced")," or ",t("b",{},"Maximum"),": devices import their configuration again."]):"",hn(r.awg,l,m=>{l=m,c()},s,p),p&&!r.awg.v3?pt("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",ts(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),d])]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ce("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ce("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),ce("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),H([b("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."),H("Save",()=>{let m=ze([x,$,h]);if(m){U(m,"warning");return}return n.save({port:o.value,mtu:a.value,keepalive:i.value},"AmneziaWG saved")},"positive")])}function is(n){let e=jt(n.preset),r=n.obf??{},o=(s,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(d=>t("i",{class:d+r[s]).map(s=>`${s.toUpperCase()} ${r[s]}`);return i.length&&a.push(i.slice(0,2).join(" · ")+(i.length>2?` +${i.length-2}`:"")),["h1","h2","h3","h4"].some(s=>r[s]&&r[s]!==String(["h1","h2","h3","h4"].indexOf(s)+1))&&a.push("H1–H4 random"),r.i1&&a.push(/0x(8580|0100)0001/.test(r.i1)?"DNS-like first packets":"Signature packets"),r.header_protection_key&&a.push("Encrypted headers"),a.length||a.push(e?.id==="off"?"Plain WireGuard":"No values yet"),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Disguise"),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),t("div",{class:"dl-disg-id"},[t("span",{class:`dl-disg-ic${e?.id==="off"?" off":""}`},b(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:Ut(n.preset)??"Custom"),t("span",{class:"dl-sub"},e?e.short:Ut(n.preset)?"Switch to Balanced or Maximum":"Set by hand")])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},"Stealth"),o(e.stealth,"acc"),t("span",{},"Speed"),o(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},a.map(s=>t("span",{},s)))])}var oo={id:"awg",label:"AmneziaWG",settingsCard:as,overviewTile:is,connectBlock:os,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>to(n,`${n.server} · ${n.person} · ${n.name}`)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var ss={awg:oo};function Be(n){return ss[n?.core||"awg"]??oo}function Tt(n,e){return Be(n.find(r=>r.id===e))}var ls=2,Gt=new Set,ro=null,fn=null;async function vr(){if(document.visibilityState!=="visible"||!Gt.size)return;let n=await A.rev().catch(()=>null);if(!n)return;let e=ro!=null&&n.rev!==ro;ro=n.rev,n.version&&(fn&&n.version!==fn?(U(`Dawnline was updated to ${n.version}: reload the page.`,"warning",15e3),fn=null):fn??(fn=n.version)),e&&Gt.forEach(r=>r())}function gn(n){return Gt.add(n),poll.add(vr,ls),()=>{Gt.delete(n),Gt.size||poll.remove(vr)}}function wr(n,e,r,o,a=0){let i=[],s=null,l=p=>{s&&p>s.from&&i.push({...s,to:p}),s=null},d=n.filter(p=>p.device===e).sort((p,u)=>p.ts-u.ts);for(let p of d)if(p.type==="connect")l(p.ts),p.detail&&(s={ip:p.detail,from:p.ts,to:p.ts,live:!1});else if(p.type==="roam"){let u=p.detail?.split("→")[1]?.trim();l(p.ts),u&&(s={ip:u,from:p.ts,to:p.ts,live:!1})}else p.type==="disconnect"&&l(p.ts);let c=s;return c&&o?i.push({...c,to:Math.max(r,c.from),live:!0}):l(Math.min(r,a)),i}function Ke(n){return`${n.city||`${n.lat.toFixed(1)},${n.lon.toFixed(1)}`}|${n.cc}`}function yr(n,e,r,o){let a=new Map;for(let s of e)(s.device===r||!a.has(s.ip))&&a.set(s.ip,s);let i=[];for(let s of n){let l=a.get(s.ip);!l||s.to<=o||i.push({key:Ke(l),point:l,from:Math.max(s.from,o),to:s.to,live:s.live})}return i}function kr(n){let e=new Map,r=0;for(let o of n)e.set(o.key,(e.get(o.key)??0)+(o.to-o.from)),r+=o.to-o.from;return new Map([...e].map(([o,a])=>[o,r?a/r:0]))}function br(n,e=2700){let r=[];for(let o of n){let a=r[r.length-1];if(a&&o.key!==a.key&&!o.live&&o.to-o.from{i&&(r.push({kind:"move",k:i,start:o,ms:e}),o+=e);let s=Math.min(1100,Math.max(350,(a.to-a.from)/3600*45));r.push({kind:"stay",k:i,start:o,ms:s}),o+=s}),{steps:r,total:o}}function Lr(n,e,r){let o=e.findIndex(l=>r>=l.start&&rr>=s.from&&rs.kind==="stay"&&s.k===o),i=n[o];return a.start+a.ms*Math.min(.999,Math.max(0,(r-i.from)/Math.max(1,i.to-i.from)))}var ds=n=>n<=0?0:n>=1?1:n<.5?2*n*n:1-(-2*n+2)**2/2;function Sr(n){return-ao/2+(1+ao)*ds((n-xr)/(1-xr))}var Tr=n=>n+Cr>=1;function _r(n){return["interpolate",["linear"],["abs",["-",["get","pos"],n]],0,1,Cr,1,ao/2,0]}function Pr(n,e){let r=n==="24h"?86400:n==="7d"?604800:2592e3,o=e-r,a=[],i=(l,d)=>{let c=(l-o)/r;c>.02&&c<.98&&a.push([c,d])},s=new Date(o*1e3);if(n==="24h")for(s.setMinutes(0,0,0);s.getTime()/1e3<=e;)s.getHours()%6===0&&i(s.getTime()/1e3,`${String(s.getHours()).padStart(2,"0")}:00`),s.setHours(s.getHours()+1);else if(n==="7d")for(s.setHours(12,0,0,0);s.getTime()/1e3<=e;s.setDate(s.getDate()+1))i(s.getTime()/1e3,s.toLocaleDateString("en-GB",{weekday:"short"}));else{let l=new Date(e*1e3);l.setHours(0,0,0,0);for(let d=0;d<5;d++){let c=new Date(l);c.setDate(l.getDate()-7*d),i(c.getTime()/1e3,c.toLocaleDateString("en-GB",{day:"numeric",month:"short"}))}a.reverse()}return a}var vn=n=>new Date(n*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});function Dr(n,e){let r=o=>new Date(o*1e3).toDateString();return r(n)===r(e)?"Today":r(n)===r(e-86400)?"Yesterday":new Date(n*1e3).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}var so="https://unpkg.com/maplibre-gl@6.14.0/dist",Ar={module:"sha384-q26X6R1yFeg0QR9SHHn6U3Nb0ddRRTtwxsahubv5R89/v5nijKpk9KviUp9ZLySk",css:"sha384-1TZtfVz7qtwR5vD7cMwjGT+9uiK4lqE3pbUOPwYO6OCpb+TYP0S9vLIhG02JCU04"},Hr="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",zr="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",cs={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Wt=null;function ps(n){if(n.appendChild(t("link",{rel:"stylesheet",href:`${so}/maplibre-gl.css`,integrity:Ar.css,crossorigin:"anonymous"})),Wt)return Wt;let e=`${so}/maplibre-gl.mjs`;return Wt=new Promise((o,a)=>{let i=t("link",{rel:"modulepreload",href:e,integrity:Ar.module,crossorigin:"anonymous"});i.addEventListener("load",()=>o()),i.addEventListener("error",()=>a(new Error("integrity"))),document.head.appendChild(i)}).then(()=>import(e)).then(o=>(o.getWorkerUrl()||o.setWorkerUrl(`${so}/maplibre-gl-worker.mjs`),o),o=>{throw Wt=null,new Error(o?.message==="integrity"?"The map library from the CDN is not the expected file: not loading it.":"Could not load the map library (no internet access from this browser?)")}),Wt}function bn(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}var us=10,Nr=30,ms=62,hs=4,Rr=4.5,fs=7,xn="#3b82f6",lo="#8a8a8a";function Ir(n,e,r=.2,o=64){let[a,i]=n,[s,l]=e,d=s-a,c=d>180?s-360:d<-180?s+360:s,p=c-a,u=l-i,x=Math.hypot(p,u);if(x===0||r===0)return[n,[c,l]];let $=-u/x,h=p/x,m=x*r,C=(a+c)/2+$*m,B=(i+l)/2+h*m,w=[],v=Math.max(2,Math.floor(o));for(let y=0;y<=v;y+=1){let E=y/v,k=1-E;w.push([k*k*a+2*k*E*C+E*E*c,k*k*i+2*k*E*B+E*E*l])}return w}function co(n,e){let r=new Map;for(let o of n.geo.points){if(n.person&&o.person!==n.person||n.device&&o.device!==n.device||(e==="online"?!o.online:n.now-o.ts>cs[e]))continue;let a=n.device?Ke(o):n.person?`${o.device}|${o.city}|${o.cc}`:o.device,i=r.get(a);(!i||o.online&&!i.online||o.online===i.online&&o.ts>i.ts)&&r.set(a,o)}return[...r.values()]}function po(n,e){let r=0;return co(n,e).sort((o,a)=>Number(a.online)-Number(o.online)||a.ts-o.ts).map(o=>({...o,n:o.online?0:++r}))}var nt=class{constructor(e,r="online",o=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.piles=new Map;this.dock=null;this.dockKey="";this.dockQuiet=!1;this.piledKeys=new Set;this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.dead=!1;this.places=new Map;this.replaying=null;this.bandDots=[];this.range=r,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${o}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await ps(this.el)}catch(o){this.status.textContent=o.message;return}if(this.dead)return;this.map=new this.gl.Map({container:this.el,style:bn()?Hr:zr,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let o=this.el.querySelector(".maplibregl-ctrl-attrib");o?.classList.remove("maplibregl-compact-show"),o?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let r=bn();this.theme=new MutationObserver(()=>{!this.map||bn()===r||(r=bn(),this.map.setStyle(r?Hr:zr))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],xn,lo],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],xn,lo],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-band",{type:"geojson",data:{type:"FeatureCollection",features:this.bandDots}}),this.map.addLayer({id:"dl-band",type:"circle",source:"dl-band",paint:{"circle-radius":1.4,"circle-color":xn,"circle-opacity":0}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?xn:lo,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dead=!0,this.dropCard();for(let e of this.piles.values())e.marker.remove();this.piles.clear(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let r=new Map;for(let o of e){let a=`${o.person}|${Ke(o)}`,i=r.get(a);i||(i={key:a,person:o.person,lat:o.lat,lon:o.lon,city:o.city,country:o.country,cc:o.cc,asn:o.asn,org:o.org,online:!1,ts:0,points:[]},r.set(a,i)),i.points.push(o),i.online||(i.online=o.online),i.ts=Math.max(i.ts,o.ts)}return[...r.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,r=this.groups(co(e,this.range)),o=e.person||e.device?null:e.geo.home;for(let d of this.markers)d.remove();this.markers=[];let a=e.person||e.device?null:vs(r,o),i=r.map(d=>({g:d,at:a?.get(d.key)??[d.lon,d.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:d})=>({type:"Feature",properties:{online:d.online,key:d.key},geometry:{type:"Point",coordinates:[d.lon,d.lat]}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:o?i.map(({g:d,at:c})=>({type:"Feature",properties:{online:d.online,person:d.person,key:d.key},geometry:{type:"LineString",coordinates:Ir([o.lon,o.lat],c)}})):[]}),o){let d=t("span",{class:"dl-mk-host"});d.innerHTML=`${ft("server","dl-mk-host-ic")}`,this.dock=d.appendChild(t("span",{class:"dl-mk-dock"})),this.dockQuiet=this.dockKey!=="",this.dockKey="";let c=t("div",{class:"dl-mk-hub",title:`Home router${o.city?` · ${o.city}`:""}${o.org?` · ${o.org}`:""}`},[d,t("span",{class:"dl-mk-label chip"},o.city||"Home")]);c.addEventListener("mouseenter",()=>this.showMerged(o.city||"the server")),c.addEventListener("mouseleave",()=>this.focus(this.focused)),c.addEventListener("click",()=>this.zoomToMerged()),this.add(c,[o.lon,o.lat],!0)}let s=new Map(e.device?po(e,this.range).map(d=>[Ke(d),d.n]):[]);this.people=[],this.places.clear();for(let{g:d,at:c}of i){let p=d.points.length,u=e.people.find(m=>m.id===d.person);if(e.person){let m=e.device?this.deviceMarker(d,c,u,s.get(Ke(d))??0):this.placeMarker(d,c,u);this.add(m,c);continue}let x=d.points.map(m=>u?.devices.find(C=>C.id===m.device)?.kind??"other"),$=t("span",{class:"dl-mk-badge"});$.innerHTML=p<=2?x.map(m=>ft(m,"dl-mk-badge-ic")).join(""):String(p);let h=t("button",{type:"button",class:`dl-mk${d.online?" online":""}`,"aria-label":`${u?.name??"Someone"}: ${p} device${p===1?"":"s"} in ${d.city||"an unknown city"}`},[t("span",{class:"dl-mk-av"},[He(u?.name??"?"),$]),t("span",{class:"dl-mk-label below"},d.city||d.cc||"?")]);h.addEventListener("mouseenter",()=>this.focus(d.person)),h.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:h,person:d.person}),h.addEventListener("click",m=>{m.stopPropagation(),this.openPopup(d,c,h)}),this.add(h,c,!1,u?.name??"Someone",`${d.city||d.cc||"?"} · ${d.online?"now":re(d.ts,e.now)}`,d.key,d)}this.declutter();let l=i.map(d=>d.g.key).sort().join(";");if(l!==this.fitKey&&!this.popup){let d=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=l,this.fitted=!0,o&&!i.length){let c={center:[o.lon,o.lat],zoom:12};d?this.glide(12,()=>this.map.flyTo({...c,duration:1200})):this.map.jumpTo(c)}else{let c=i.map(p=>p.at);o&&(c.length===0||this.range!=="online"||i.some(p=>p.g.online))&&c.push([o.lon,o.lat]),this.fit(c,d)}}this.status.textContent=i.length||o?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(d=>d.person===this.focused)?this.focused:null)}add(e,r,o=!1,a,i,s,l){s&&this.foldedKeys.has(s)&&e.classList.add("merged"),s&&this.piledKeys.has(s)&&e.classList.add("piled"),e.dataset.key=s??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let d=new this.gl.Marker({element:e}).setLngLat(r).addTo(this.map);this.markers.push(d),this.slots.push({marker:d,el:e,at:r,fixed:o,who:a,where:i,g:l})}declutter(){if(!this.map)return;let e=this.map.getZoom();this.el.classList.toggle("dl-lod-far",e=Rr&&e{let l=this.map.project(s.at),d=s.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:l.x,y:l.y,r:(d?.offsetWidth||24)/2+3,fixed:s.fixed}}),o=r.filter(s=>s.fixed);this.merged=[],this.foldedKeys.clear();let a=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));r.forEach((s,l)=>{if(s.fixed)return;let d=this.slots[l],c=d.el.classList.contains("merged")?12:6,p=o.find(u=>Math.hypot(u.x-s.x,u.y-s.y)*a{let c=this.slots[d];!c||c.fixed||(r[d].fixed&&([s,l]=[0,0]),c.marker.setOffset([s,l]),xs(c.el,s,l))})}closePopup(e=!1){let r=this.popup;if(!r||r.card.classList.contains("leaving"))return;r.card.classList.add("leaving"),setTimeout(()=>{this.popup===r&&this.dropCard()},140);let o=this.before;if(this.before=null,!o)return;let a=()=>this.map?.flyTo({...o,duration:800});if(!e)return a();let i=!1,s=()=>{i||(i=!0,window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0),setTimeout(a,0))};window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),setTimeout(s,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},`Near ${e}`)," · click to zoom in"]),...this.merged.map(r=>t("div",{class:"dl-map-card-row"},[t("span",{},r.who),t("span",{class:"dl-faint"},r.where)]))]),this.card.classList.add("on"))}paintDock(){let e=this.dock;if(!e)return;let r=this.merged.map(a=>`${a.key}:${a.online?1:0}`).join("|");if(r===this.dockKey)return;this.dockKey=r,e.parentElement?.classList.toggle("docked",this.merged.length>0);let o=this.slots.find(a=>a.fixed).at;this.merged.length&&Or(e,this.merged,this.faceActions(()=>[o]),this.dockQuiet),this.dockQuiet=!1}faceActions(e){return{click:(r,o)=>this.openFace(r,o,e()),hover:r=>this.focus(r?.g?.person??null)}}pileUp(e){let r=new Set;if(!this.data?.person&&!this.data?.device){let o=e.flatMap((l,d)=>!l.fixed&&this.slots[d].el.querySelector(":scope > .dl-mk-av")?[d]:[]),a=new Map(o.map(l=>[l,l])),i=l=>a.get(l)===l?l:i(a.get(l));for(let l of o)for(let d of o){if(d<=l)continue;let c=this.slots[l].el.classList.contains("piled")&&this.slots[d].el.classList.contains("piled");Math.hypot(e[l].x-e[d].x,e[l].y-e[d].y)this.slots[m]),c=d.map(Br),p=c.map(m=>m.key).sort().join(",");r.add(p);let u=[d.reduce((m,C)=>m+C.at[0],0)/d.length,d.reduce((m,C)=>m+C.at[1],0)/d.length],x=this.piles.get(p);if(!x){let m=t("span",{class:"dl-mk-pile-box"}),C=[...new Set(d.map(v=>v.g?.city||v.g?.cc||"?"))],B=t("div",{class:"dl-mk-pile"},[m,t("span",{class:"dl-mk-label below"},C.length===1?C[0]:`${d.length} people`)]);x={marker:new this.gl.Marker({element:B}).setLngLat(u).addTo(this.map),el:B,box:m,faces:c},B.addEventListener("mouseleave",()=>this.focus(this.focused));let w=x;B.addEventListener("click",v=>{v.stopPropagation(),this.zoomInTo(w.faces.map(y=>y.at),!1)}),this.piles.set(p,x)}x.faces=c;let $=x;Or(x.box,c,this.faceActions(()=>$.faces.map(m=>m.at)));for(let m of l)this.slots[m].el.classList.add("piled"),Object.assign(e[m],{r:0,fixed:!0});let h=this.map.project(u);e.push({x:h.x,y:h.y,r:(x.el.offsetWidth||60)/2+3,fixed:!0})}}this.piledKeys=new Set(this.slots.filter(o=>o.el.classList.contains("piled")).map(o=>o.el.dataset.key??"")),this.slots.forEach((o,a)=>{(!e[a].fixed||o.fixed||o.el.classList.contains("merged"))&&o.el.classList.remove("piled")});for(let[o,a]of this.piles)r.has(o)||(this.piles.delete(o),a.el.classList.add("out"),setTimeout(()=>a.marker.remove(),200))}zoomToMerged(){!this.map||!this.merged.length||this.zoomInTo([this.slots.find(e=>e.fixed).at,...this.merged.map(e=>e.at)],!1)}openFace(e,r,o){if(!e.g)return;if(o.every(i=>wn(i,e.at)<1))return this.openPopup(e.g,e.at,r);let a=()=>{let i=this.slots.find(s=>s.el.dataset.key===e.key);i?.g&&!i.el.classList.contains("merged")&&!i.el.classList.contains("piled")&&this.openPopup(i.g,i.at,i.el)};this.zoomInTo(this.nearby(e.at),!0)?this.map.once("moveend",a):a()}nearby(e){return[e,...this.slots.filter(r=>!r.fixed&&r.at!==e&&wn(r.at,e)<=Nr).map(r=>r.at)]}zoomInTo(e,r){let o=new this.gl.LngLatBounds;for(let p of e)o.extend(p);let a=e.some(p=>e.some(u=>wn(p,u)>Nr)),i=this.map.cameraForBounds(o,{padding:50,maxZoom:a?12:us}),s=this.map.getZoom(),l=e.map(p=>this.map.project(p)),d=0;l.forEach((p,u)=>l.slice(u+1).forEach(x=>{let $=Math.hypot(p.x-x.x,p.y-x.y),h=s+Math.log2(ms/Math.max($,1e-6));h<=12&&(d=Math.max(d,h))}));let c=Math.min(12,Math.max(i?.zoom??0,d));return c<=s+.05?!1:(r&&!this.before&&(this.before={center:this.map.getCenter().toArray(),zoom:s}),this.map.flyTo({center:i?.center??o.getCenter(),zoom:c,duration:800}),!0)}placeMarker(e,r,o){let a=this.data.now,i=[...e.points].sort((u,x)=>Number(x.online)-Number(u.online)||x.ts-u.ts)[0],s=o?.devices.find(u=>u.id===i.device)?.kind??"other",l=e.points.length,d=t("span",{class:"dl-mk-tile"});d.innerHTML=ft(s,"dl-mk-tile-ic")+(l>1?`${l}`:"");let c=e.online?"now":re(e.ts,a),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(a-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":`${l} device${l===1?"":"s"} in ${e.city||"an unknown city"}, ${c}`},[d,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},c)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,r,p)}),p}deviceMarker(e,r,o,a){let i=o?.devices.find(p=>p.id===e.points[0].device)?.kind??"other",s=t("span",{class:"dl-mk-tile"}),l=t("span",{class:"dl-mk-label below"}),d=t("button",{type:"button",class:"dl-mk place step"},[s,l]);d.addEventListener("click",p=>{p.stopPropagation(),this.openPopup(e,r,d)});let c=Ke(e);return this.places.set(c,{el:d,tile:s,label:l,when:null,g:e,n:a,kind:i}),this.paintPlace(c,!1),d}paintPlace(e,r){let o=this.places.get(e);if(!o)return;let a=this.replaying,i=a?a.active===e:o.g.online,s=o.el.classList.contains("online"),l=o.g.city||o.g.cc||"?";o.el.classList.toggle("online",i),o.el.classList.toggle("faded",!!a&&!i),o.tile.classList.toggle("sm",!i),i||!o.n?o.tile.innerHTML=ft(o.kind,"dl-mk-tile-ic"):o.tile.textContent=String(o.n),o.when=null,i?(o.when=t("span",{class:`dl-mk-when${a?" inline":""}`},a?a.when:"now"),o.label.replaceChildren(l,a?" · ":"",o.when)):o.label.replaceChildren(`${l} · ${o.g.online?"now":re(o.g.ts,this.data.now)}`);let d=i?a?a.when:"now":o.g.online?"now":re(o.g.ts,this.data.now);o.el.setAttribute("aria-label",`${o.n?`${o.n}: `:""}${o.g.city||"an unknown city"}, ${d}`),r&&i&&!s&&(o.el.classList.remove("arrive"),o.el.offsetWidth,o.el.classList.add("arrive"),setTimeout(()=>o.el.classList.remove("arrive"),500))}replay(e,r=!0){let o=this.replaying;if(this.replaying=e,o&&e&&o.active===e.active){let a=e.active?this.places.get(e.active):null;a?.when&&(a.when.textContent=e.when);return}for(let a of this.places.keys())a!==e?.active&&this.paintPlace(a,r);e?.active&&this.paintPlace(e.active,r),this.declutter(),setTimeout(()=>this.declutter(),320)}hoverPlace(e){for(let[r,o]of this.places)o.el.classList.toggle("hl",r===e)}band(e,r){if(this.bandDots=[],this.map&&e&&r){let o=Ir(e,r),a=o.map(c=>this.map.project(c)),i=[0];for(let c=1;ci[d]?(p-i[d])/(i[d+1]-i[d]):0,x=[o[d][0]+(o[d+1][0]-o[d][0])*u,o[d][1]+(o[d+1][1]-o[d][1])*u];this.bandDots.push({type:"Feature",properties:{pos:c/l},geometry:{type:"Point",coordinates:x}})}}this.map?.getLayer("dl-band")&&(this.map.setPaintProperty("dl-band","circle-opacity",0),this.map.getSource("dl-band").setData({type:"FeatureCollection",features:this.bandDots}))}bandAt(e){this.map?.getLayer("dl-band")&&this.map.setPaintProperty("dl-band","circle-opacity",_r(e))}focus(e){this.focused=e;for(let s of this.people)s.el.classList.toggle("dim",!!e&&s.person!==e),s.el.classList.toggle("hl",s.person===e);let r=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let s of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(s)&&this.map.setPaintProperty(s,"line-opacity",r);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let o=this.data,a=o.people.find(s=>s.id===e),i=co(o,this.range).filter(s=>s.person===e).sort((s,l)=>Number(l.online)-Number(s.online)||l.ts-s.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},a?.name??e),` · ${i.length} device${i.length===1?"":"s"}`]),...i.map(s=>t("div",{class:"dl-map-card-row"},[t("span",{},a?.devices.find(l=>l.id===s.device)?.name??"Device"),t("span",{class:"dl-faint"},`${s.city||s.cc||"?"} · ${s.online?"now":re(s.ts,o.now)}`)]))])}fit(e,r=!1){if(!e.length)return;let o=(p,u)=>{let x=Math.PI/180,$=(u[1]-p[1])*x,h=(u[0]-p[0])*x,m=Math.sin($/2)**2+Math.cos(p[1]*x)*Math.cos(u[1]*x)*Math.sin(h/2)**2;return 12742*Math.asin(Math.sqrt(m))},a=[e.reduce((p,u)=>p+u[0],0)/e.length,e.reduce((p,u)=>p+u[1],0)/e.length],i=e;if(e.length>=5){let p=[...e].sort((u,x)=>o(a,u)-o(a,x));i=p.slice(0,Math.ceil(p.length*.9))}let s=new this.gl.LngLatBounds(i[0],i[0]);i.forEach(p=>s.extend(p));let l=this.el.clientHeight||380,d=!!this.data?.person,c={padding:{top:this.data?.device?Math.min(56,l/4):Math.min(60,l/5),bottom:d?Math.min(52,l/4):Math.min(40,l/8),left:48,right:48},maxZoom:this.data?.person?11:12};r?this.glide(this.map.cameraForBounds(s,c)?.zoom??null,()=>this.map.fitBounds(s,{...c,duration:1200})):this.map.fitBounds(s,{...c,duration:0})}glide(e,r){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),r()}openPopup(e,r,o){let a=this.data,i=[e.city,e.cc||e.country].filter(Boolean).join(", "),s=[...new Set(e.points.map(v=>v.person))],l=e.points.sort((v,y)=>Number(y.online)-Number(v.online)||y.ts-v.ts).map(v=>{let y=a.people.find(k=>k.id===v.person),E=y?.devices.find(k=>k.id===v.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(v.person,v.device)},[t("span",{class:`dl-pop-dot${v.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},y?.name??v.person),` · ${E?.name??"device"}`]),t("span",{class:"dl-faint dl-nowrap"},v.online?"now":re(v.ts,a.now))])}),d=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},b("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||"Unknown network"),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),t("div",{class:"dl-pop-list"},l),s.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${a.people.find(v=>v.id===s[0])?.name??"person"}`)]):""]);this.zoomInTo(this.nearby(r),!0),this.dropCard();let c=t("div",{class:"dl-root dl-popcard",role:"dialog"},[t("span",{class:"dl-popcard-tip"}),d]);document.body.appendChild(c);let p=this.el,u=o?.querySelector(".dl-mk-av, .dl-mk-tile")??o??null,x=()=>{if(!u)return;let v=u.getBoundingClientRect(),y=p.getBoundingClientRect(),E=v.left+v.width/2,k=v.top+v.height/2;c.classList.toggle("away",Ey.right||ky.bottom);let z=c.offsetWidth,f=c.offsetHeight,g=v.top-f-12>=8||v.top>window.innerHeight-v.bottom,S=Math.min(Math.max(8,E-z/2),window.innerWidth-z-8);c.classList.toggle("above",g),c.classList.toggle("below",!g),c.style.left=`${S}px`,c.style.top=`${g?v.top-f-12:v.bottom+12}px`,c.style.setProperty("--tip-x",`${E-S}px`)},$=v=>{v.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},h=v=>{v.key==="Escape"&&this.closePopup()},m=v=>{v.target instanceof Element&&v.target.closest(".dl-popcard")||this.closePopup()},C=()=>this.closePopup();this.map.on("move",x),window.addEventListener("scroll",m,{capture:!0,passive:!0}),window.addEventListener("resize",x),document.addEventListener("pointerdown",$,!0),document.addEventListener("keydown",h);let B=$e(C);window.addEventListener("pagehide",C),this.popup={card:c,off:()=>{this.map?.off("move",x),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",x),document.removeEventListener("pointerdown",$,!0),document.removeEventListener("keydown",h),B(),window.removeEventListener("pagehide",C)}};let w=window.setInterval(()=>{if(this.popup?.card!==c)return clearInterval(w);(!p.isConnected||!p.getClientRects().length)&&this.dropCard()},400);x()}};function gs(n,e=6){let r=n.map(o=>({x:o.x,y:o.y}));for(let o=0;o<16;o++){let a=!1;for(let i=0;i[o.x-n[a].x,o.y-n[a].y])}function vs(n,e){let r=new Map,o=e?[[e.lon,e.lat]]:[],a=i=>o.some(s=>wn(i,s)<1.3);for(let i of[...n].sort((s,l)=>s.key>>12)/1048575),d=(s&4095)/4096*2*Math.PI,c=[i.lon,i.lat];for(let p=0;p<24;p++){let u=d+p*2.39996,x=Math.min(8,l+p*.25);if(c=[i.lon+x*Math.sin(u)/(111.32*Math.cos(i.lat*Math.PI/180)),i.lat+x*Math.cos(u)/111.32],!a(c))break}o.push(c),r.set(i.key,c)}return r}function bs(n){let e=2166136261;for(let r=0;r>>0}function Br(n){return{key:n.el.dataset.key??"",who:n.who??"Someone",where:n.where??"",online:!!n.g?.online,at:n.at,badge:n.el.querySelector(".dl-mk-badge")?.innerHTML??"",g:n.g}}function Or(n,e,r,o=!1){let a=e.length>3,i=()=>[...n.children].filter(h=>!h.classList.contains("out")),s=new Map(i().map(h=>[h,h.getBoundingClientRect().left])),l=n.getBoundingClientRect().width,d=new Map;n.querySelectorAll(".dl-mk-face:not(.out)").forEach(h=>d.set(h.dataset.key??"",h));let c=n.querySelector(".dl-mk-more:not(.out)"),p=h=>{Object.assign(h.style,{position:"absolute",left:`${h.offsetLeft}px`,top:`${h.offsetTop}px`,transform:""}),h.classList.add("out"),setTimeout(()=>h.remove(),200)},u=[];for(let h of e.slice(0,a?2:3)){let m=d.get(h.key);if(d.delete(h.key),!m){let w=t("button",{type:"button",class:`dl-mk-face${o?"":" in"}`,"data-key":h.key},[t("span",{class:"dl-mk-av"},He(h.who)),t("span",{class:"dl-mk-badge"})]);w.addEventListener("animationend",()=>w.classList.remove("in"),{once:!0}),m=w}let C=m,B=C.querySelector(".dl-mk-badge");B.innerHTML!==h.badge&&(B.innerHTML=h.badge),C.title=`${h.who} · ${h.where}`,C.setAttribute("aria-label",`${h.who}, ${h.where}`),C.classList.toggle("on",h.online),C.onclick=w=>{w.stopPropagation(),r.click(h,C)},C.onmouseenter=()=>r.hover(h),C.onmouseleave=()=>r.hover(null),u.push(C)}for(let h of d.values())p(h);if(a){if(!c){c=t("span",{class:`dl-mk-more${o?"":" in"}`});let h=c;h.addEventListener("animationend",()=>h.classList.remove("in"),{once:!0})}c.textContent=`+${e.length-2}`,u.push(c)}else c&&p(c);let x=null;for(let h of u)(x?x.nextElementSibling:n.firstElementChild)!==h&&(x?x.after(h):n.prepend(h)),x=h;for(let h of u){let m=s.get(h);if(m==null)continue;let C=m-h.getBoundingClientRect().left;Math.abs(C)<.5||(h.style.transition="none",h.style.transform=`translateX(${C}px)`,h.offsetWidth,h.style.transition="",h.style.transform="")}n.style.width="";let $=n.getBoundingClientRect().width;if(l&&Math.abs($-l)>.5){n.style.width=`${l}px`,n.offsetWidth,n.style.width=`${$}px`;let h=()=>{n.style.width="",n.removeEventListener("transitionend",h)};n.addEventListener("transitionend",h),setTimeout(h,400)}}function wn(n,e){let r=Math.PI/180,o=Math.sin((e[1]-n[1])*r/2)**2+Math.cos(n[1]*r)*Math.cos(e[1]*r)*Math.sin((e[0]-n[0])*r/2)**2;return 12742*Math.asin(Math.min(1,Math.sqrt(o)))}function xs(n,e,r){let o=n.querySelector(":scope > .dl-mk-ptr"),a=Math.hypot(e,r);if(a<1){o?.remove();return}o||(o=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(o));let i=o.firstElementChild,s=o.lastElementChild;i.style.width=`${a}px`,i.style.transform=`rotate(${Math.atan2(-r,-e)}rad)`,s.style.transform=`translate(${-e}px, ${-r}px)`}function _t(n,e,r=!0){let o=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],a=t("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of o)i==="online"&&!r||a.appendChild(t("button",{type:"button",role:"tab",class:i===n?"on":"","data-v":i,click:()=>{a.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===i)),e(i)}},s));return a}var jr={"24h":86400,"7d":7*86400,"30d":30*86400},uo=(n,e)=>`${(n/e*100).toFixed(3)}%`,yn=class{constructor(e,r,o){this.map=e;this.range=r;this.el=t("div",{class:"dl-dplaces"});this.controls=t("div",{class:"dl-map-replay"});this.pending=null;this.rows=new Map;this.st=[];this.steps=[];this.total=0;this.ms=0;this.stepI=-1;this.on=!1;this.playing=!1;this.raf=0;this.last=0;this.endTimer=0;this.play=t("button",{type:"button",class:"dl-map-btn"});this.chip=t("span",{class:"dl-map-chip"});this.stop=t("button",{type:"button",class:"dl-map-btn",title:"Back to now","aria-label":"Back to now"},b("x"));this.reduced=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;this.data=o,this.play.addEventListener("click",()=>this.toggle()),this.stop.addEventListener("click",()=>this.end()),this.paint()}mapData(){let e=this.data;return{geo:e.geo,people:[e.person],now:e.now,person:e.person.id,device:e.device.id}}update(e){let r={...this.pending??this.data,...e};if(this.on){this.pending=r;return}this.data=r,this.map.update(this.mapData()),this.paint()}setRange(e){this.end(),this.range=e,this.map.setRange(e),this.paint()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.endTimer)}paint(){let e=this.data,r=jr[this.range],o=e.now-r,a=yr(wr(e.events??[],e.device.id,e.now,e.device.online,e.device.handshake),e.geo.points,e.device.id,o),i=kr(a);this.st=$r(a);let s=po(this.mapData(),this.range),l=a.length>0;this.el.classList.toggle("strips",l),this.el.classList.toggle("can-replay",this.st.length>1),this.rows.clear(),dom.content(this.el,s.length?[...s.map(d=>{let c=Ke(d),p=i.get(c),u=l?t("div",{class:`dl-dplace-strip${d.online?" live":""}`},a.filter($=>$.key===c).map($=>t("i",{style:`left:${uo($.from-o,r)};width:${uo($.to-$.from,r)}`}))):"",x=t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${d.online?" live":""}`},d.online?b(e.device.kind):String(d.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[d.city||d.cc||"Unknown city",d.org?t("span",{class:"dl-muted"},` · ${d.org}`):""]),t("span",{class:"dl-faint"},[t("span",{class:"dl-mono"},d.ip),p!=null?` · ${p>0&&p<.005?"<1":Math.round(p*100)}% of the time`:""])]),t("span",{class:d.online?"dl-dplace-now":"dl-faint dl-nowrap"},d.online?"now":re(d.ts,e.now)),u]);if(x.addEventListener("mouseenter",()=>this.map.hoverPlace(c)),x.addEventListener("mouseleave",()=>this.map.hoverPlace(null)),u){let $=h=>{let m=u.getBoundingClientRect();this.seek(o+r*Math.min(1,Math.max(0,(h.clientX-m.left)/m.width)))};u.addEventListener("pointerdown",h=>{u.setPointerCapture(h.pointerId),$(h)}),u.addEventListener("pointermove",h=>h.buttons&&$(h))}return this.rows.set(c,x),x}),l?t("div",{class:"dl-dplace-axis"},Pr(this.range,e.now).map(([d,c])=>t("span",{style:`left:${(d*100).toFixed(2)}%`},c))):""]:t("div",{class:"dl-sub"},"No locations in this period.")),this.paintControls()}paintControls(){dom.content(this.play,b(this.playing?"pause":"play")),this.play.title=this.playing?"Pause":"Replay this period",this.play.setAttribute("aria-label",this.play.title),dom.content(this.controls,this.on?[this.play,this.chip,this.stop]:this.st.length>1?[this.play]:[])}begin(){this.on=!0,{steps:this.steps,total:this.total}=Er(this.st,this.reduced?400:io),this.ms=0,this.stepI=-1,this.map.replay({active:null,when:""},!0)}toggle(){if(this.playing){this.playing=!1,cancelAnimationFrame(this.raf),this.paintControls();return}clearTimeout(this.endTimer),(!this.on||this.ms>=this.total)&&this.begin(),this.playing=!0,this.last=performance.now(),this.paintControls(),this.raf=requestAnimationFrame(e=>this.frame(e))}frame(e){if(this.playing){if(this.ms=Math.min(this.total,this.ms+(e-this.last)),this.last=e,this.show(!0),this.msthis.frame(r));return}this.playing=!1,this.paintControls(),this.endTimer=window.setTimeout(()=>this.end(),1500)}}seek(e){this.st.length<2||(clearTimeout(this.endTimer),this.on||this.begin(),this.ms=Mr(this.st,this.steps,e),this.stepI=-1,this.show(!1),this.paintControls())}show(e){let r=Lr(this.st,this.steps,this.ms),o=this.st[r.step.k];if(r.step.kind==="move"){let s=this.st[r.step.k-1];r.i!==this.stepI&&(this.map.replay({active:null,when:""},e),this.map.band([s.point.lon,s.point.lat],[o.point.lon,o.point.lat]));let l=Sr(r.q);this.reduced||this.map.bandAt(l),(this.reduced?r.q>=.5:Tr(l))&&this.map.replay({active:o.key,when:vn(r.t)},e)}else r.i!==this.stepI&&this.map.band(),this.map.replay({active:o.key,when:vn(r.t)},e);this.stepI=r.i;let a=this.data,i=a.now-jr[this.range];this.el.classList.add("replay"),this.el.style.setProperty("--at",uo(r.t-i,a.now-i));for(let[s,l]of this.rows)l.classList.toggle("cur",s===o.key);this.chip.textContent=`${Dr(r.t,a.now)}, ${vn(r.t)} · ${o.point.city||o.point.cc||"?"}`}end(){if(cancelAnimationFrame(this.raf),clearTimeout(this.endTimer),!!this.on){this.on=!1,this.playing=!1,this.ms=0,this.stepI=-1,this.map.band(),this.map.replay(null,!1),this.el.classList.remove("replay");for(let e of this.rows.values())e.classList.remove("cur");this.pending?(this.data=this.pending,this.pending=null,this.map.update(this.mapData()),this.paint()):this.paintControls()}}};function Pt(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function ke(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function ws(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function mo(n,e,r=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${r?" dl-mono":""}`,title:"Copy",click:()=>ue(e,`${n} copied`)},[t("span",{},e),b("copy")])])}function kn(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var Ur={connect:["ok","Connected","plug"],disconnect:["","Went offline","plug"],roam:["","Changed network","network"],device_added:["ok","Added","plus"],device_removed:["","Removed","trash"],device_keys:["","New keys","reset"]};function ys(n,e,r){let o=n.filter(a=>a.device===e&&Ur[a.type]).reverse().slice(0,12);return o.length?t("div",{class:"dl-dev-log"},o.map(a=>{let[i,s,l]=Ur[a.type],d=a.type==="connect"?[a.detail?t("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?t("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[t("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[t("span",{class:"dl-muted"},Ne(a)==="portal"?" on the portal":Ne(a)==="admin"?" by you":"")]:[],c=new Date(a.ts*1e3);return t("div",{class:`dl-dev-log-row${Ne(a)==="admin"?" dl-ev-by-admin":""}`},[Ne(a)==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):t("span",{class:`dl-ev-tile ev ${i}`},b(l)),t("span",{class:"dl-row-main"},[t("span",{},s),...d]),t("span",{class:"dl-faint dl-nowrap",title:c.toLocaleString()},re(a.ts,r))])})):t("div",{class:"dl-sub"},"No activity yet.")}async function Gr(n,e,r){let o=await A.status(1).catch(()=>null),a=o?.people.find(s=>s.id===n),i=a?.devices.find(s=>s.id===e);o&&a&&i&&Ge(a,i,{...r,geo:o.geo,now:o.now,today:Ie(o.series),core:Tt(o.servers,a.server)})}async function Ge(n,e,r){let o=await G(()=>A.deviceConfig(e.id));if(!o)return;let a=r.core??Be(null),i=e,s=n,l=r.geo,d=r.now,c=r.today??je(new Date),p=await a.connectBlock(o,e.kind==="phone"||e.kind==="tablet"?"qr":"file"),u=t("div",{class:"dl-drawer-title"}),x=t("div",{}),$=t("div",{}),h=t("div",{},t("div",{class:"dl-sub"},"Loading…")),m=[],C=Q=>{m=Q.filter(te=>te.device===i.id),dom.content(h,ys(Q,i.id,d)),y?.update({events:Q})},B=async(Q=!1)=>{let te=r.events?.();if(te&&!Q)return C(te);let ge=await A.events(2e3,n.id).catch(()=>null);ge&&C(ge.events)},w="30d",v=null,y=null,E=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${i.online?" on":""}`},b(i.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},i.name),H([b("edit")],()=>f(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${s.name} · ${Qe[i.kind]}`)])]);let Q=i.spark.reduce((te,ge)=>te+ge,0);dom.content(x,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},"Status"),on(i,d,"Waiting for the first connection",s)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"This month"),t("b",{},ee(i.month[0]+i.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${ee(i.month[1])} ↑ ${ee(i.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"Last 7 days"),t("b",{},ee(Q)),dr(i.spark,120,22,c)])])),dom.content($,t("div",{class:"dl-kv2"},[mo("Tunnel address",i.address),i.hostname&&s.access!=="internet"?mo("Local address",i.hostname):"",i.endpoint&&!l?.points.some(te=>te.device===i.id&&te.ip===i.endpoint)?kn("Client IP",i.endpoint):"",kn("Total",t("span",{class:"dl-kv-act"},[`↓ ${ee(i.total[1])} · ↑ ${ee(i.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>St("device",i.id,i.name,()=>setTimeout(z,300))},"Reset")])),kn("Added",`${ws(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),o.amnezia.client_pub_key?mo("Public key",o.amnezia.client_pub_key):kn("Public key","—")])),dom.content(g,[H([b(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await G(()=>A.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await z()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),H([b("key")," New keys"],async()=>{if(!await le("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await G(()=>A.deviceRotate(i.id),"New keys generated")&&(r.refresh(),de.close(),await Gr(s.id,i.id,r))}),t("span",{class:"dl-spacer"}),H([b("trash")," Remove"],async()=>{await le(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await G(()=>A.deviceDelete(i.id),"Device removed")&&(de.close(),r.refresh())},"negative")])},k=async()=>{let Q=await A.status(1).catch(()=>null),te=Q?.people.find(O=>O.id===s.id),ge=te?.devices.find(O=>O.id===i.id);!Q||!te||!ge||(s=te,i=ge,l=Q.geo,d=Q.now,c=Ie(Q.series),E(),y?.update({geo:Q.geo,now:Q.now,person:s,device:i}))},z=async()=>{await k(),r.refresh()},f=()=>{let Q=t("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48}),te=s.devices.filter(O=>O.id!==i.id).map(O=>O.name),ge=ye("Name",Q,()=>_e(Q.value,te,"Shown in the portal and in the app."));oe(`Rename ${i.name}`,[ge],[ie()," ",H("Save",async()=>{let O=ge.help();if(O.bad){U(O.text,"warning");return}await G(()=>A.deviceUpdate(i.id,Q.value,void 0),"Renamed")&&(ae(),await z())},"positive")]),setTimeout(()=>Q.select(),50)},g=t("div",{class:"dl-drawer-actions"}),S=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Connect")]),i.config_stale?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",p]),T=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Activity"),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Fe({people:[s]},m,"csv",i.id)},"Export"),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>tt(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{B(!0),r.refresh()})},"Clear"),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),h]),N=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},"Details")),$]),W="";if(l?.enabled){v=new nt({openPerson:te=>location.href=ke(te),openDevice:(te,ge)=>location.href=ke(te,ge)},w,220);let Q=y=new yn(v,w,{geo:l,now:d??Date.now()/1e3,person:s,device:i,events:r.events?.()??null});W=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Locations"),_t(w,te=>{w=te,Q.setRange(te)},!1)]),t("div",{class:"dl-dmap"},[v.el,Q.controls]),Q.el])}let q=!i.handshake||i.config_stale,Y=t("div",{class:"dl-stack gap16"},q?[x,S,N,W,T]:[x,N,W,T,S]);B();let R=()=>{k(),B()},K=gn(R),Z=window.setInterval(R,3e4),de=Oo(u,Y,g,()=>{clearInterval(Z),K(),y?.destroy(),v?.destroy()});E(),v&&y&&requestAnimationFrame(()=>y&&v?.mount(y.mapData()))}function Wr(n,e,r,o){let a=o.core??Be(null),i=()=>G(()=>A.deviceConfig(r.id)),s=[{label:"Show QR code",icon:b("qr"),run:async()=>{let l=await i();l&&oe(`${r.name} · QR code`,t("div",{class:"dl-qr-pane"},[et(Lt(a.qrText(l)),"dl-qr"),t("span",{class:"dl-sub"},no(l)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),ie("Close"))}},{label:a.file.label,icon:b("download"),run:async()=>{let l=await i();if(!l)return;let d=a.file.make(l);Te(d.name,d.text,"application/octet-stream")}},a.appKey?{label:a.appKey.label,icon:b("copy"),run:async()=>{let l=await i();l&&ue(await a.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:b("edit"),run:()=>Ge(e,r,o)},{label:"New keys",icon:b("key"),run:async()=>{await le("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await G(()=>A.deviceRotate(r.id),"New keys generated")&&o.refresh()}},{label:r.disabled?"Enable":"Disable",icon:b(r.disabled?"play":"pause"),warn:!r.disabled,run:async()=>{await G(()=>A.deviceUpdate(r.id,void 0,!r.disabled),r.disabled?"Device enabled":"Device disabled")&&o.refresh()}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await le(`Remove ${r.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await G(()=>A.deviceDelete(r.id),"Device removed")&&o.refresh()}}];Ce(n,s)}function ot(n,e){let r=n.devices.map(c=>c.name),o=c=>{let p=Qe[c],u=1,x=p;for(;r.some($=>$.toLowerCase()===x.toLowerCase());)x=`${p} ${++u}`;return x},a="phone",i=t("input",{type:"text",class:"cbi-input-text",placeholder:o(a),maxlength:48}),s=ye("Name",i,()=>i.value.trim()?_e(i.value,r,"Shown in the portal and in the app."):{text:`Named after its type: ${o(a)}.`,bad:!1}),l=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},No.map(c=>t("button",{type:"button",role:"radio",class:c===a?"on":"","aria-checked":c===a?"true":"false","data-kind":c,click:()=>{a=c,l.querySelectorAll("button").forEach(p=>{let u=p.dataset.kind===c;p.classList.toggle("on",u),p.setAttribute("aria-checked",u?"true":"false")}),i.placeholder=o(c),s.refresh()}},[b(c),t("span",{},Qe[c])]))),d=n.devices.length>=n.device_limit;oe(`Add a device for ${n.name}`,[d?t("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Type"),l]),s],[ie()," ",H("Add device",async()=>{let c=s.help();if(c.bad){U(c.text,"warning");return}let p=i.value.trim()||o(a),u=await G(()=>A.deviceCreate(n.id,p,a));u&&(ae(),U(`${p} added`,"success",3e3),e.refresh(),await Gr(n.id,u.id,e))},"positive")]),setTimeout(()=>i.focus(),50)}var Ve=1080,qt=1512,We=96,ks="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",$s="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Ft=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function Cs(n,e,r){let o=new URL(r),a=o.pathname.slice(1),i=Math.min(92,Math.floor((Ve-2*We)/(.58*(4+n.name.length)))),s=Ve-2*We,l=392,d=40,c=Lt(r,2).replace("`${m}`;return``+p(We+82,We+42,36,"#a3a3a3",Ft(e))+p(We,276,i,"#ffffff",`Hi, ${Ft(n.name)}`,'font-weight="600"')+p(We,340,40,"#8a8a8a",`Scan to connect to ${Ft(e)}`)+``+c+`${Ft(a)}`+p(Ve/2,l+s+156,34,"#737373",Ft(o.host),'text-anchor="middle"')+""}async function Es(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let r=document.createElement("canvas");return r.width=Ve,r.height=qt,r.getContext("2d").drawImage(e,0,0,Ve,qt),new Promise((o,a)=>r.toBlob(i=>i?o(i):a(new Error("Could not draw the card")),"image/png"))}async function Fr(n){let e=await G(()=>A.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(U("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function $n(n){let e=await Fr(n);e&&await ue(e.link,"Personal link copied")}async function Kt(n,e,r={}){let o=n.link,a=n.links;if(o===void 0){let m=await Fr(n.id);if(!m)return;o=m.link,a=m.links}if(!o){U("The personal portal is off. Turn it on in Settings.","warning");return}let i=o,s=await G(()=>Es(Cs(n,e,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),d=URL.createObjectURL(s),c=navigator,p=!!c.canShare?.({files:[l]}),u=!p&&typeof c.share=="function"&&(c.canShare?.({url:i})??!0),x=()=>{URL.revokeObjectURL(d),ae()},$=async m=>{try{await c.share(m)}catch{}},h=p?H([b("link")," Share card"],()=>$({files:[l],title:`Invite ${n.name}`}),"positive"):u?H([b("link")," Share link"],()=>$({url:i,title:`Invite ${n.name}`,text:"Your personal VPN link"}),"positive"):H([b("download")," Download card"],()=>Te(l.name,s),"positive");oe(r.title??`Invite ${n.name}`,t("div",{class:"dl-invite"},[t("img",{src:d,alt:`Invite card for ${n.name}`}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},r.lead??`Send ${n.name} the card or the link. They open it, add their devices and connect — no account needed.`),t("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>ue(i,"Personal link copied")},[t("span",{},i.replace(/^https:\/\//,"")),b("copy")]),...(a??[]).filter(m=>m!==i).map(m=>t("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>ue(m,"Link copied")},[t("span",{},m.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${m.startsWith("http:")?"warn":""}`},m.startsWith("http:")?"HTTP":"Also"),b("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},["Install ",t("b",{},"AmneziaVPN")," on the device"]),t("li",{},"Open the link or scan the code"),t("li",{},"Add the device and connect")]),t("div",{class:"dl-invite-actions"},[h,H([b("copy")," Copy link"],()=>ue(i,"Personal link copied"))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:x},"Done")],"wide")}function Vt(n,e){let r=n.servers.find(d=>d.id===e)??n.servers[0],o=n.people.filter(d=>d.server===r.id),a=new Set(o.map(d=>d.id)),i=o.flatMap(d=>d.devices),s=d=>o.reduce((c,p)=>{let u=d(p);return[c[0]+u[0],c[1]+u[1]]},[0,0]),l=r.series?.[r.series.length-1];return{...n,servers:[r],people:o,series:r.series??n.series,events:n.events.filter(d=>d.person?a.has(d.person):!0),geo:{...n.geo,points:n.geo.points.filter(d=>a.has(d.person))},totals:{people:o.length,devices:i.length,online:i.filter(d=>d.online).length,active:o.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(d=>d.month)}}}var qr=3,ho=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let x=e.next(),$=null;try{$=await n.fetch(u),r>=qr&&U("The router answers again.","success",3e3),r=0}catch{return++r===qr&&U("The router is not answering: what you see may be out of date.","warning",8e3),null}return $==null||!e.take(x)?null:(n.apply($,p),$)},a=(p=!1)=>o(p,!1),i=()=>document.visibilityState==="visible",s=()=>i()&&(n.active?.()??!0)?o(!0,!1):Promise.resolve(null);poll.add(s,n.every);let l=n.live?gn(()=>void(i()&&(n.active?.()??!0)&&o(!0,!0))):null,d=()=>{poll.remove(s),l?.(),c()},c=$e(d);return{refresh:a,claim:()=>e.claim(),stop:d}}function Dt(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function Se(n,e,r=!1){return r&&Dt(n)?!1:(dom.content(n,e),!0)}function Kr(n,e){let r=n,a=t("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(i=>t("button",{type:"button",class:`dl-choice${i.v===r?" selected":""}`,"data-v":i.v,click:()=>{r=i.v,a.querySelectorAll(".dl-choice").forEach(s=>s.classList.toggle("selected",s.dataset.v===i.v)),e?.(i.v)}},[t("span",{class:"dl-choice-title"},[b(i.ic),ct[i.v]]),t("span",{class:"dl-choice-text"},i.text)])));return{el:a,get:()=>r}}function fo(n){try{return localStorage.getItem(n)}catch{return null}}function go(n,e){try{localStorage.setItem(n,e)}catch{}}function Ls(n){let e=n.devices.length,r=Math.max(1,n.device_limit,e),o=Math.min(160,r*22+(r-1)*3);return t("div",{class:"dl-slotbar",title:`${e} of ${n.device_limit} devices`},[t("span",{class:"dl-slotbar-segs",style:`width: ${o}px`},Array.from({length:r},(a,i)=>t("i",{class:i>=n.device_limit?"over":in.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),vo=n=>n.state==="server_off"?n.paused:n.state!=="active",Jr=n=>vo(n)?n.state==="server_off"?"paused":n.state:null;function Ms(n,e){let r=Ye(n.expires,e);return n.state==="quota"||n.state==="expired"||Ze(n,r)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function Yr(n,e){return bt(n&&Kn(n,e)>=0?n:e,1)}var Zr=n=>n.people.map(e=>e.id).sort().join(" "),Qr=!1,mt=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===(new URLSearchParams(location.search).get("filter")??fo("dl.people.filter")))??"all";this.sort=["seen","name","usage"].find(e=>e===fo("dl.people.sort"))??"seen";this.query="";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return A.status(30)}scope(e){return this.serverId?Vt(e,this.serverId):e}embed(e,r){return this.serverId=r,this.render(e)}person(e){return this.st.people.find(r=>r.id===e)}get today(){return Ie(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:Tt(this.st.servers,e.server)}}take(e,r){let o=this.scope(e),a=Zr(o)!==Zr(this.st);this.st=o,a?this.rebuild():(this.paintCards(r),this.decorate(r))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await A.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let o of Array.from(this.list.children))o.dataset.sid&&e.set(o.dataset.sid,o);let r=this.st.people.map(o=>{let a=e.get(o.id)??t("div",{class:"dl-card",role:"listitem","data-sid":o.id});return this.renderCard(a,o.id)});dom.content(this.list,r.length?r:t("div",{class:"dl-plist-none"},this.st.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people.")),this.decorate()}paintCards(e=!1){for(let r of this.st.people){let o=this.card(r.id);o&&!(e&&Dt(o))&&this.renderCard(o,r.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let r=this.scope(e);this.st=r;let o=this,a=t("select",{class:"dl-select","aria-label":"Sort",change:d=>{o.sort=d.target.value,go("dl.people.sort",o.sort),o.decorate()}},[t("option",{value:"seen",selected:o.sort==="seen"?"selected":null},"Last seen"),t("option",{value:"name",selected:o.sort==="name"?"selected":null},"Name"),t("option",{value:"usage",selected:o.sort==="usage"?"selected":null},"Usage")]),i=t("input",{type:"search",class:"cbi-input-text dl-people-find",placeholder:"Find…","aria-label":"Find a person or device",hidden:r.people.length>8?null:"hidden",input:d=>{o.query=d.target.value.trim().toLowerCase(),o.decorate()}}),s=d=>{let c=d.target;d.key==="/"&&!i.hidden&&!["INPUT","TEXTAREA","SELECT"].includes(c?.tagName)&&!c?.isContentEditable&&(d.preventDefault(),i.focus())};document.addEventListener("keydown",s),$e(()=>document.removeEventListener("keydown",s));let l=t("div",{class:"dl-root"},[o.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"People"),t("span",{class:"dl-muted dl-people-count"},this.countText())]),r.servers.length?H([b("plus")," Add person"],()=>o.openCreate(),"add"):""]),r.servers.length?"":t("div",{class:"alert-message warning"},["No server yet. ",t("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[i,a,o.serverId?H([b("plus")," Add person"],()=>o.openCreate(),"add"):""])]),this.list]);return this.el=l,this.rebuild(),this.poller??(this.poller=rt({fetch:()=>A.status(30),every:30,live:!0,active:()=>!!o.el?.isConnected,apply:(d,c)=>o.take(d,c)})),!Qr&&new URLSearchParams(location.search).get("add")&&(Qr=!0,setTimeout(()=>o.openCreate(),100)),Promise.resolve(l)}countText(){let e=this.st.totals;return`${e.people} ${e.people===1?"person":"people"} · ${e.devices} device${e.devices===1?"":"s"} · ${e.online} online`}decorate(e=!1){let r=this.el?.querySelector(".dl-people-count");r&&(r.textContent=this.countText());let o=this.st.people,a=this.today,i=m=>Ms(m,a),s={all:o.length,online:o.filter(m=>m.online>0).length,attention:o.filter(i).length,paused:o.filter(m=>Vr(m)).length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(e&&Dt(l))){let m={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(m).map(C=>t("button",{type:"button",role:"tab",class:C===this.filter?"on":"",click:()=>{this.filter=C,go("dl.people.filter",C),this.decorate()}},[m[C],t("b",{class:C==="attention"&&s[C]?"warn":""},String(s[C]))])))}let d=this.query,c=m=>[m.name,m.note??"",...m.devices.flatMap(C=>[C.name,C.address,C.hostname,C.endpoint])].join(" ").toLowerCase(),p=m=>!(this.filter==="online"&&!m.online||this.filter==="attention"&&!i(m)||this.filter==="paused"&&!Vr(m)||d&&!c(m).includes(d)),u=m=>Jr(m)==="paused"?2:vo(m)?1:0,x=[...o].sort((m,C)=>u(m)-u(C)||(this.sort==="name"?m.name.localeCompare(C.name):this.sort==="usage"?C.month[0]+C.month[1]-(m.month[0]+m.month[1]):C.online-m.online||C.last_seen-m.last_seen)),$=0;for(let m of x){let C=this.card(m.id);if(!C)continue;this.list.appendChild(C),C.classList.toggle("dl-off",vo(m));let B=p(m);C.classList.toggle("dl-filtered",!B),B&&$++}let h=this.el?.querySelector(".dl-people-none")??null;o.length&&!$?(h??(h=t("div",{class:"dl-empty dl-people-none"},t("p",{},"No one here right now."))),h.previousElementSibling!==this.list&&this.list.after(h)):h?.remove()}async quick(e,r,o){await G(()=>A.personUpdate(e.id,r),o)&&await this.update()}renderCard(e,r){let o=this.person(r);if(!o)return dom.content(e,t("em",{},"This person was just removed.")),e;let a=this.today,i=Ye(o.expires,a),s=Math.max(0,o.device_limit-o.devices.length),l=o.has_link??this.st.settings.portal_enabled,d=[],c=Jr(o);if(o.expires&&c!=="expired"){let h=Ze(o,i),m=i!=null&&i<0;d.push(t("span",{class:`dl-pill-ic${m?" bad":h?" warn":""}`,title:`Access ends ${Me(o.expires)}`},[b("calendar"),m?`ended ${Me(o.expires)}`:h?en(i):`until ${Me(o.expires)}`]))}o.hours&&c!=="hours"&&d.push(t("span",{class:"dl-pill-ic",title:"Allowed hours"},[b("clock"),o.hours.replace("-","–")]));let p=nn(o.devices).map(h=>t("button",{type:"button",class:`dl-chip${h.disabled?" disabled":""}${h.online?" live":""}`,title:`${Qe[h.kind]} · ${h.address}${h.online?` · online from ${h.endpoint}`:h.handshake?` · seen ${re(h.handshake,this.st.now)}`:""}`,click:m=>{m.preventDefault(),Ge(o,h,this.deviceOpts(o))}},[b(h.kind),t("span",{class:"dl-chip-name"},h.name),!h.handshake&&!h.disabled?t("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(t("button",{type:"button",class:"dl-chip add",title:s>0?"Add device":"Over the limit: admins can still add",click:h=>{h.preventDefault(),ot(o,this.deviceOpts(o))}},[b("plus"),"Add device"]));let u=[];o.expires&&Ze(o,i)&&c!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(o,{expires:Yr(o.expires,a)},"Extended by 1 month")},"Extend 1 month"));let x=Le("more","More",h=>Ce(h.currentTarget,[{label:"Open",icon:b("open"),run:()=>{location.href=ke(o.id)}},l?{label:"Invite card",icon:b("qr"),run:()=>Kt(o,this.st.servers.find(m=>m.id===o.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:b("plus"),run:()=>ot(o,this.deviceOpts(o))}:null,null,{label:o.paused?"Resume":"Pause",icon:b(o.paused?"play":"pause"),warn:!o.paused,run:()=>this.togglePause(o)},{label:"Delete",icon:b("trash"),danger:!0,run:()=>this.remove(o.id)}].filter((m,C,B)=>m||C>0&&B[C-1])),"neutral","dl-icon-only"),$=t("div",{class:"dl-pcard-actions"},[l?Le("link","Copy link",()=>$n(o.id),"neutral","dl-icon-only"):"",x]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${o.online?" online":""}`},He(o.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:ke(o.id)},o.name),Bo(o),...d]),Ls(o)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(o,$),c?this.stopStrip(o,c):""])),e}stopStrip(e,r){let o=this.today,a=bt(`${o.slice(0,8)}01`,1),i=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month"),s={paused:["pause","warn","Paused","Devices can’t connect until you resume",["play","Resume",()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad","Data limit reached",`Paused until it resets on ${Me(a)}`,["plus","+10 GB this month",i]]:["chart","bad","Data limit reached","Paused until the limit is raised",["edit","Change limit",()=>location.href=ke(e.id)]],expired:["calendar","bad",`Access ended ${Me(e.expires)}`,"Devices can’t connect",["calendar","Extend 1 month",()=>this.quick(e,{expires:Yr(e.expires,o)},"Extended by 1 month")]],hours:["clock","warn","Outside allowed hours",`Access ${e.hours.replace("-","–")} (router time)`,null],no_server:["alert","warn","No server","Choose a server on their page",null]},[l,d,c,p,u]=s[r];return t("div",{class:`dl-pstrip ${d}`},[t("span",{class:`dl-need-ic ${d}`},b(l)),t("span",{class:"dl-pstrip-text"},[t("b",{},c),t("span",{class:"dl-faint"},p)]),u?H([b(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,r){let o=e.quota_used||e.month[0]+e.month[1],a=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,i=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??0),0),s=e.rate?.[e.rate.length-1],l=e.online&&s&&this.st.now-s[0]<180,d=t("div",{class:`dl-usebar${a>=100?" bad":a>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${a}%`,d.appendChild(p),me(d,()=>[t("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${ee(e.quota_used)} of ${ee(e.quota_limit)} · ${ee(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},e.quota_period==="total"?"In total":`This month${e.bonus_gb?` · includes +${e.bonus_gb} GB extra`:""}`)])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,x)=>x.v-u.v);p.forEach((u,x)=>{let $=t("i",{class:`c${Math.min(x,4)}`});$.style.flexGrow=String(u.v),d.appendChild($)}),p.length&&me(d,()=>[t("div",{class:"dl-tip-title"},"This month by device"),...p.map((u,x)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(x,4)}`}),t("span",{},u.d.name),t("b",{},ee(u.v))]))])}let c=e.quota_limit?`${ee(Math.max(0,e.quota_limit-e.quota_used))} left`:"no limit";return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[l?t("span",{class:"dl-pside-state live"},"Online"):t("span",{class:"dl-pside-state"},e.online?"Online":e.last_seen?"Offline":"Never connected"),r]),t("div",{class:"dl-use-num"},[t("b",{class:o?"":"dl-faint"},ee(o)),t("span",{class:"dl-faint"},e.quota_limit?`of ${ee(e.quota_limit)}`:e.quota_period==="total"&&e.quota_gb?"in total":"this month")]),d,l?t("div",{class:"dl-use-live",title:"Right now"},[`↓ ${Oe(s[2])}`,t("span",{class:"dl-faint"},`↑ ${Oe(s[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},i?`today ${ee(i)} · ${c}`:c)])}async togglePause(e){await G(()=>A.personPause(e.id,!e.paused),e.paused?`${e.name} resumed`:`${e.name} paused`)&&await this.refresh()}async remove(e){let r=this.person(e);await le(`Remove ${r?.name??e}?`,`All ${r?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await G(()=>A.personDelete(e),"Person removed")&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){U("Set up the server first.","warning");return}let r=t("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),o=(()=>{try{return JSON.parse(fo("dl.person.last")??"{}")}catch{return{}}})(),a=Kr(o.access??"internet"),i=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),s=t("input",{type:"date",class:"cbi-input-text"}),l=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited",value:o.quota??""}),d=(w,v)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{s.value=v?bt(Ie(e.series),v):"",s.dispatchEvent(new Event("change"))}},w),c=e.servers[0],p=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(w=>t("option",{value:w.id},w.name))):null,u=(w,v,y)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},w),t("div",{class:"cbi-value-field"},[v,y?t("div",{class:"cbi-value-description"},y):""])]),x=Ie(e.series),$=ye("Name",r,()=>_e(r.value,[],"Shown in their portal and apps.")),h=ye("Devices",i,()=>ln(i.value)),m=ye("End date",s,()=>Ko(s.value,x,Ye,Me),t("div",{class:"dl-actions"},[s,d("1 month",1),d("3 months",3),d("1 year",12),d("None",0)])),C=ye("Monthly data (GB)",l,()=>dn(l.value));s.addEventListener("change",()=>m.refresh());let B=e.settings.portal_enabled;oe("Add person",[$,p?u("Server",p):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},"Access"),t("div",{class:"cbi-value-field"},a.el)]),h,m,C],[ie()," ",H(B?"Create and copy link":"Create",async()=>{let w=ze([$,h,m,C]);if(w){U(w,"warning");return}let v=await G(()=>A.personCreate(r.value.trim(),"",p?.value??c.id,a.get(),i.value.trim(),s.value,l.value.trim(),"month"));v&&(go("dl.person.last",JSON.stringify({access:a.get(),quota:l.value.trim()})),v.link&&await ue(v.link,"Personal link copied",!0),this.showCreated(v.id,r.value.trim(),v.link,e.servers.find(y=>y.id===(p?.value??c.id))?.name??c.name),await this.refresh())},"positive")]),setTimeout(()=>r.focus(),50)}showCreated(e,r,o,a){if(o){Kt({id:e,name:r,link:o},a,{title:`${r} is ready`,lead:`Send ${r} the card or the link. They open it, add their devices and connect — no account needed.`});return}let i=this.person(e);oe(`${r} is ready`,[t("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[t("button",{class:"cbi-button cbi-button-neutral",click:ae},"Done")," ",t("a",{class:"cbi-button cbi-button-neutral",href:`${L.url("admin/network/dawnline/settings")}?section=portal`},"Open Settings")," ",i?H("Add device",()=>{ae(),ot(i,this.deviceOpts(i))},"positive"):""])}};var Cn=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],bo=n=>t("i",{class:"dl-circle-dot",style:`background:${Cn[n?.color??0]??Cn[0]}`}),at=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function Xr(n,e,r){let o=se(n?.name??e.name??"",{placeholder:"NAS"}),a=se(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=se((n?.ports??e.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=ye("Name",o,()=>_e(o.value,[],"Shown to people who may reach it.")),l=ye("Address",a,()=>Vo(a.value)),d=ye("Ports",i,()=>Jo(i.value));oe(n?`Edit ${n.name}`:"Add service",[s,l,d],[ie()," ",H("Save",async()=>{let c=ze([s,l,d]);if(c){U(c,"warning");return}let p=i.value.split(/[ ,]+/).filter(Boolean);await G(()=>A.serviceSet(n?.id??"",o.value,a.value,p),"Saved")&&(ae(),r())},"positive")])}var Ss={_smb:"SMB",_afpovertcp:"AFP",_http:"Web",_https:"Web",_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:"Printer",_ipps:"Printer",_printer:"Printer","_pdl-datastream":"Printer",_airplay:"AirPlay",_raop:"AirPlay",_rfb:"Screen sharing",_googlecast:"Cast",_hap:"HomeKit",_rdp:"Remote desktop",_ftp:"FTP"},Ts=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function _s(n){let e=new Map;for(let r of n.services){let o=Ss[r.type.split(".")[0]];!o||!r.port||(e.get(o)??e.set(o,new Set).get(o)).add(String(r.port))}return e.size?[...e].map(([r,o])=>[r,[...o].sort((a,i)=>+a-+i)]):Ts}function ea(n,e,r){let o=n,a=null,i=!1,s=null,l=new Set,d=t("div",{class:"dl-list"}),c=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},"Looking for devices at home…")),p=()=>{let m=o.services;dom.content(d,m.length?m.map(C=>t("div",{class:"dl-row"},[b("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},C.name),t("span",{class:"dl-mono dl-faint"},`${C.address}${C.ports.length?` · ports ${C.ports.join(", ")}`:" · all ports"}`)]),H("Edit",()=>Xr(C,{},r)),H([b("trash")],async()=>{await le(`Remove ${C.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await G(()=>A.serviceDelete(C.id),"Removed")&&await r()},"neutral",{title:"Remove","aria-label":`Remove ${C.name}`})])):[t("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function u(m,C){if(!l.has(m.address)){l.add(m.address),$();try{let B=o.services.find(v=>v.address===m.address);(C===null?B&&await G(()=>A.serviceDelete(B.id),`${B.name} removed`):await G(()=>A.serviceSet(B?.id??"",B?.name??(m.name||m.address),m.address,C),B?`${B.name} updated`:`${m.name||m.address} added`))&&await r()}finally{l.delete(m.address),$()}}}function x(m){let C=o.services.find(E=>E.address===m.address),B=!!C&&!C.ports.length,w=new Set(C?.ports??[]),v=l.has(m.address),y=(E,k,z)=>qe(E,k,z,{disabled:v?"disabled":null,"aria-busy":v?"true":null});return t("div",{class:"dl-row"},[b(m.services.some(E=>E.type.startsWith("_ipp")||E.type.startsWith("_printer"))?"file":"computer"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},m.name||m.address),t("span",{class:"dl-mono dl-faint"},m.address)]),t("div",{class:"dl-chips-row dl-host-ports"},[y("All ports",B,()=>u(m,B?null:[])),..._s(m).map(([E,k])=>{let z=!B&&k.every(f=>w.has(f));return y(`${E} ${k.join(", ")}`,z,()=>{let f=new Set(B?[]:w);for(let g of k)z?f.delete(g):f.add(g);u(m,f.size?[...f]:null)})})])])}function $(){if(i)return dom.content(c,t("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!a)return;let m=a;if(!m.hosts.length)return dom.content(c,t("span",{class:"dl-sub"},"No devices found in the home network right now."));let C=t("details",{class:"dl-params",open:s??!o.services.length?"":null},[t("summary",{},[b("chevron"),t("span",{},"Add from devices at home"),t("span",{class:"dl-pcount"},String(m.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},m.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),t("div",{class:"dl-list"},m.hosts.map(x))])]);C.addEventListener("toggle",()=>s=C.open),dom.content(c,C)}return A.homeHosts(e).then(m=>{a=m,$()}).catch(()=>{i=!0,$()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},"Home services"),H([b("plus")," Add service"],()=>Xr(null,{},r))]),t("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),d,c]),update(m){o=m,p(),$()}}}function En(n,e,r,o){let a=new Set(n.circles.filter(m=>m.server===e).map(m=>m.color)),i=r?.color??Cn.findIndex((m,C)=>!a.has(C));i<0&&(i=0);let s=se(r?.name??"",{placeholder:"Family"}),l=n.people.filter(m=>m.server===e).sort((m,C)=>m.name.localeCompare(C.name)),d=new Set(l.filter(m=>r&&m.circle===r.id).map(m=>m.id)),c=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),p=()=>dom.content(c,Cn.map((m,C)=>t("button",{type:"button",role:"radio",class:`dl-swatch${C===i?" on":""}`,style:`--sw:${m}`,"aria-checked":C===i?"true":"false","aria-label":`Colour ${C+1}`,click:()=>{i=C,p()}})));p();let u=t("div",{class:"dl-chips-row"},l.map(m=>{let C=m.circle&&m.circle!==r?.id?n.circles.find(B=>B.id===m.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${d.has(m.id)?" on":""}`,title:at(m)?C?`Now in ${C.name}`:"":`${m.name} has no home access: their devices aren't reachable anyway`,click:B=>{d.delete(m.id)||d.add(m.id),B.currentTarget.classList.toggle("on",d.has(m.id))}},[m.name,at(m)?C?t("b",{},C.name):"":t("b",{},"internet")])})),x=(m,C)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},m),t("div",{class:"cbi-value-field"},C)]),$=n.circles.filter(m=>m.server===e&&m.id!==r?.id).map(m=>m.name),h=ye("Name",s,()=>Go(s.value,$));oe(r?`Edit ${r.name}`:"New circle",[h,x("Colour",c),x("People",u),t("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[r?H("Delete",async()=>{await G(()=>A.circleDelete(r.id),`${r.name} deleted`)&&(ae(),o())},"negative"):"",t("span",{class:"dl-spacer"}),ie()," ",H("Save",async()=>{let m=h.help();if(m.bad){U(m.text,"warning");return}await G(()=>A.circleSet(r?.id??"",e,s.value,i,[...d]),"Saved")&&(ae(),o())},"positive")],"dl-circle-modal")}function ta(n,e,r){let o=n.circles.filter(a=>a.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...o.map(a=>{let i=n.people.filter(s=>s.circle===a.id).map(s=>s.name);return t("button",{type:"button",class:"dl-chip",title:`Edit ${a.name}`,click:()=>En(n,e,a,r)},[bo(a),t("b",{},a.name),t("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),t("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>En(n,e,null,r)},b("plus"))])}function xo(n,e){let r=n.people.filter(p=>p.server===e.id),o=(p="")=>t("span",{class:"dl-yes"},[b("check"),p]),a=()=>t("span",{class:"dl-faint"},"—"),i=p=>{let u=new Set(p.map(x=>x.access==="lan"&&x.services?.length?"services":x.home_nets?.length?"some":"all"));return u.size||u.add("all"),o([...u].map(x=>({all:"all networks",some:"their networks",services:"services"})[x]).join(" / "))},s=()=>e.mesh==="off"?a():e.mesh==="circles"?o("circle"):o(),l=e.lan_like?"like home":"direct",d=(p,u,x)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},`${u.length} ${u.length===1?"person":"people"}`)]),...x.map($=>t("td",{},$))]),c=p=>r.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Who reaches what"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"From the rules on this server")]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["","Internet","Home","This router","Each other"].map(p=>t("th",{},p))),d("Internet",c("internet"),[o(l),a(),t("span",{class:"dl-faint"},"DNS"),a()]),d("Home",c("lan"),[t("span",{class:"dl-faint"},"their own"),i(c("lan")),o(),s()]),d("Both",c("both"),[o(l),i(c("both")),o(),s()])])),t("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function na(n,e){let r=n.people.filter(c=>c.server===e.id).flatMap(c=>c.devices.map(p=>({id:p.id,label:`${c.name} · ${p.name}`}))).sort((c,p)=>c.label.localeCompare(p.label)),o="@addr",a=(c,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":c},[...r.map(m=>t("option",{value:m.id,selected:m.id===p?"selected":null},m.label)),t("option",{value:o,selected:p===o?"selected":null},"Address")]),x=se("",{placeholder:c,class:"cbi-input-text dl-mono"}),$=t("div",{class:"dl-check-end"},[u,x]),h=()=>x.hidden=u.value!==o;return u.addEventListener("change",h),h(),{el:$,value:()=>u.value===o?x.value.trim():u.value}},i=a("10.0.1.11",r[0]?.id??o),s=a("10.0.1.20:445",o),l=t("div",{class:"dl-stack gap8"}),d=async()=>{let c=await G(()=>A.accessCheck(i.value(),s.value()));if(!c)return;let p=c.steps.findIndex(u=>!u.ok);dom.content(l,[t("div",{class:`dl-verdict ${c.ok?"ok":"bad"}`},[t("b",{},c.ok?"Allowed":"Blocked"),t("span",{class:"dl-sub"},c.ok?"Every step lets it through":`Stops at step ${p+1} of ${c.steps.length}`)]),t("ul",{class:"dl-checks"},c.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},b(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Check access"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"Why something does or does not connect")]),t("div",{class:"dl-check-form"},[i.el,t("span",{class:"dl-faint"},"→"),s.el,H("Check",d)]),l])])}var Ln={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function it(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function Mn(n){return it(n.action==="check"?`check:${n.component??""}`:n.component??"")}function oa(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function ra(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function aa(n,e){let r=n.check?.components??{},o=e==="all"?["app","amneziawg","packages"]:[e],a=[],i;for(let l of o){let d=r[l];if(d){if(d.error)return{tone:"warn",text:d.error};l==="packages"&&d.updates?a.push(`${d.updates} system package${d.updates===1?"":"s"}`):l!=="packages"&&d.update&&d.installed&&d.latest&&(a.push(`${Ln[l]} ${d.latest}`),e!=="all"&&(i=d.latest))}}if(a.length)return{tone:"acc",text:`Update available: ${a.join(", ")}`,update:i};let s=o.length===1?r[o[0]]:null;return s?.status==="dev"?{tone:"acc",text:`Installed version is newer than the release (${s.latest})`}:s?.note?{tone:"warn",text:s.note}:{tone:"ok",text:o.length>1?"Everything is up to date":"Latest version is installed"}}function ia(n,e,r,o){return e?n.id===e:r&&n.id===r?!1:n.state==="running"||o>0&&n.started>=o}var sa=n=>new Promise(e=>setTimeout(e,n));async function Jt(n,e,r){let o=r?Mn(r):it(n),a=r?r.action==="check":n.startsWith("check"),i=Date.now(),s=t("b",{},Ln[o]??(o==="all"?"All components":"Dawnline")),l=t("span",{class:"dl-pill dl-mono"},e.version??""),d=t("span",{class:"dl-pill info",hidden:!0}),c=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),u=t("div",{}),x=t("div",{class:"dl-op-actions"}),$=[],h=f=>dom.content(x,f),m=(f=!1)=>ie("Close",f);oe(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[s,e.version?l:"",d,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[b("clock"),c])]),t("div",{class:"dl-op-loghead"},[t("b",{},"Operation log"),Le("copy","Copy log",()=>ue($.join(` +`),"Log copied"))]),p,u]),[x],"wide"),h([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},a?"Checking…":"Working…")]);let C=r??null,B=r?.id,w,v=0,y=f=>{B!==f.id&&(B=f.id,e.onJob?.(f))};if(r)e.onJob?.(r);else try{let f=await A.updatesStatus().catch(()=>null);w=f?.job?.id,v=f?.now??0;let g=await A.updatesRun(n);g.job&&g.job.state==="running"&&g.job.id!==w&&(C=g.job,y(g.job))}catch(f){return $=[be(f)],p.textContent=$[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},be(f))])),h([m(!0)]),U(be(f),"error"),null}let E=null,k=0;for(;;){if(await sa(1e3),E=await A.updatesStatus().catch(()=>null),!E){if(++k>60)break;continue}k=0;let f=E.job;if(!f||!ia(f,B,w,v)){if(Date.now()-i>15e3)break;continue}if(y(f),C=f,f.log.length){$=f.log;let g=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=$.join(` +`),g&&(p.scrollTop=p.scrollHeight)}if(l.textContent=ra(f,e.version??""),!l.isConnected&&l.textContent&&s.after(l),c.textContent=oa((f.finished??E.now)-f.started),f.state==="running"){d.hidden=!f.phase,d.textContent=f.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!C||C.state==="running")return d.className="dl-pill warn",d.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),h([m()]),e.onDone?.(E),C;if(C.state==="failed")return d.className="dl-pill bad",d.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[b("x"),t("span",{},[t("b",{},C.error??"Operation failed"),a?"":". Nothing else was changed."])])),h([H("Copy log",()=>ue($.join(` +`),"Log copied")),m(!0)]),U(`${Ln[o]??"Update"}: ${C.error??"failed"}`,"error"),e.onDone?.(E),C;if(d.className="dl-pill ok",d.textContent="Finished",a&&E){let f=aa(E,o);if(dom.content(u,t("div",{class:`dl-comp-status ${f.tone}`},[b(f.tone==="ok"?"check":f.tone==="warn"?"alert":"download"),t("span",{},f.text)])),U(f.text,f.tone==="warn"?"warning":"success"),e.onDone?.(E),f.update&&e.onUpdate){let g=E;h([m(),H(`Update to ${f.update}`,()=>e.onUpdate(g),"positive")])}else h([m()]),f.tone==="ok"&&setTimeout(()=>u.isConnected&&ae(),1200);return C}if(o==="app"&&C.to){let f=C.to,g=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},[t("b",{},`Dawnline ${f} is installed. `),g])]));let S=()=>{ui.menu?.flushCache(),location.reload()};h([m(),H("Reload now",S,"positive")]),U(`Dawnline updated to ${f}`,"success",6e3);for(let T=1;T<=30;T++)if(g.textContent=`Waiting for the router to restart its services (${T} of 30)…`,await sa(1500),(await A.updatesStatus().catch(()=>null))?.version===f)return g.textContent="Services are back. Reloading…",setTimeout(S,800),C;return g.textContent="Services restarted. Reload the page to use the new version.",C}let z=o==="pkgs"?`Updated ${[...C.result?.pkgs?.updated??[],...C.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:o==="amneziawg"?`AmneziaWG${C.to?` ${C.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},z)])),h([m()]),U(z,"success"),e.onDone?.(E),C}var Ps={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function la(n,e,r,o){return!await le(`Install ${e}?`,r,"Install")||(await Jt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>o?.(),4e3),!0)}function Sn(n){return la("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Yt(n,e,r){return n==="awg"?Sn(r):e.length?la(`pkgs:${e.join(",")}`,Ps[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,r):!0}async function da(n,e){if(n==="awg")return Sn(e);let r=await G(()=>A.updatesStatus());return r?Yt(n,r.needs?.[n]??[],e):!1}var Ds=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],As={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function ca(n,e,r){let o=n.id,a=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,d="",c=!0,p=!0,u="all",x=!1,$=ea(a,o,r),h=new Set,m="",C=()=>JSON.stringify([p,l,l?"":d,c,[...h].sort()]),B=()=>s.detected.lan||s.saved.lan||"",w=()=>(l?s.detected.wan||s.saved.wan:d)||"",v=()=>new Map(s.devices.map(R=>[R.name,R])),y=()=>{let R=v();return[...c&&B()?[B()]:[],...[...h].filter(Z=>Z!==B())].filter(Z=>Z!==w()).map(Z=>R.get(Z)??{name:Z,nets:[],missing:!0})},E=(R,K)=>{s=R,K&&(l=R.config.auto_wan,d=R.config.wan_device||R.detected.wan||R.saved.wan||"",c=R.config.auto_lan,p=R.config.lan_like,u=R.config.mesh??(R.config.device_mesh?"all":"off"),h=new Set(R.config.lan_devices),m=C()),q()},k=async R=>{let K=await A.interfaces(o).catch(Z=>(U(Z.message,"error"),null));K&&E(K,R)};function z(R){let K=c&&R.name===B(),Z=!!R.own||!!R.master||R.name===w()||K;return K||h.has(R.name)||!Z&&(R.nets.length>0||!!R.missing)}function f(R){let K=c&&R.name===B(),Z=R.name===w(),de=!K&&h.has(R.name),te=!(!!R.own||!!R.master||Z||K)&&(R.nets.length>0||de||!!R.missing),ge=(de||K)&&!R.zone&&!R.missing,O=R.missing?"Not present right now":R.own?"This server":R.master?`Port of ${R.master}`:Z?`Internet${R.zone?` · zone ${R.zone}`:""}`:R.nets.length?R.nets.join(", "):"No IPv4 network",X=t("button",{type:"button",class:`dl-if${de?" sel":""}${K?" auto":""}${!te&&!de&&!K?" off":""}${ge?" warn":""}`,"aria-pressed":de||K?"true":"false","aria-disabled":te?null:"true",click:()=>{te&&(h.has(R.name)?h.delete(R.name):h.add(R.name),q())}},[t("span",{class:"dl-if-ic"},b(As[R.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},R.name),t("span",{class:"dl-if-sub"},O)]),K?t("span",{class:"dl-if-badge ok"},"Auto"):de?t("span",{class:"dl-if-check"},b("check")):""]);return me(X,()=>[t("div",{class:"dl-tip-title"},R.name),t("div",{class:"dl-muted"},[R.logical?`Interface ${R.logical}`:"No netifd interface",R.zone?` · zone ${R.zone}`:" · no firewall zone"]),R.members.length?t("div",{class:"dl-muted"},`Ports: ${R.members.join(", ")}`):"",R.nets.length?t("div",{class:"dl-mono"},R.nets.join(", ")):"",ge?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",R.master?t("div",{class:"dl-muted"},`Choose ${R.master} to include it.`):""]),X}function g(){let R=s.like_home;return!p||!s.config.lan_like||!n.enabled?"":!s.needs?.length&&R.active&&R.bridged?"ok":"warn"}function S(){let R=s.like_home;return p?s.needs?.length?[t("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?n.enabled?R.active&&R.bridged?["Internet traffic enters ",t("span",{class:"dl-mono"},R.dev??"")," as ",t("span",{class:"dl-mono"},R.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[t("span",{class:"dl-warn"},`Not working: ${R.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let T={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function N(R,K,Z,de,Q="",te){return t("div",{class:te?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${Q}`},b(R)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},K),t("span",{class:"dl-sub"},Z),te??""])]),t("div",{class:"dl-setrow-ctl"},de)])}let W=(R,K)=>{let Z=de=>t("span",{class:"dl-mono"},de);return R?t("span",{},[" Now: ",Z(R),...K&&K!==R?[", was ",Z(K)]:[],"."]):t("span",{},K?[" Not found now: using ",Z(K),"."]:[" Not found."])};function q(){let R=t("select",{class:"cbi-input-select","aria-label":"Internet interface",change:M=>{d=M.target.value,q()}},s.devices.filter(M=>!M.own&&!M.master&&M.zone&&!M.missing).map(M=>t("option",{value:M.name,selected:M.name===d?"selected":null},`${M.name} · zone ${M.zone}`))),Z=y().flatMap(M=>M.nets.map(j=>[j,M.name])),de=JSON.parse(C()),Q=JSON.parse(m),te=(...M)=>M.some(j=>JSON.stringify(de[j])!==JSON.stringify(Q[j])),ge=te(0,1,2),O=te(3,4),X=M=>H("Save",async()=>{let j=await G(()=>A.serverInterfaces(o,l,l?"":d,c,[...h],p,u!=="off",u),"Access saved");j&&(E(j,!0),j.nets_changed&&j.lan_only&&U(`${j.lan_only} ${j.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!M}),P=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Internet"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Internet or Both")]),N("home","Internet like a home device",S(),[p&&s.needs?.length?H("Install",()=>Yt("home",s.needs,()=>k(!1)),"positive"):"",ve(p,"Internet like a home device",M=>{p=M,q()})],g()),N("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",W(s.detected.wan,s.saved.wan)],[l?"":R,ve(l,"Auto-detect WAN",M=>{l=M,q()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?["Internet like a home device",w()?[" · leaves through ",t("span",{class:"dl-mono"},w())]:""]:w()?["Internet straight to ",t("span",{class:"dl-mono"},w())]:"No WAN found"),X(ge)])]),D=we([["off","Off"],["all","Everyone"],["circles","Circles"]],u,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async M=>{let j={off:"Off",all:"Everyone",circles:"Circles"}[M];await G(()=>A.serverUpdate(o,{mesh:M}),`Devices reach each other: ${j}`)&&(u=M,s.config.mesh=M,q(),await r())}}),_=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Home network"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Home or Both"),H([b("reset")," Rescan"],()=>k(!1),"neutral",{title:"Read the interfaces again"})]),N("network","Networks","Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it.","","",Y()),N("link","Devices reach each other",T[u],D,"",u==="circles"?ta(a,o,r):void 0),$.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},Z.length?["Home access reaches ",...Z.flatMap(([M,j],J)=>[J?", ":"",t("span",{class:"dl-mono"},M),` (${j})`])]:"No home network: Home access reaches nothing but this router."),X(O)])]),I=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[P,_]),i.style.minHeight="",window.scrollTo({top:I})}function Y(){let R=s.devices.filter(z),K=s.devices.filter(Z=>!z(Z));return t("div",{class:"dl-stack gap8 dl-netpick"},[R.length?t("div",{class:"dl-ifgrid"},R.map(f)):t("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},"Auto-detect LAN"),t("span",{class:"dl-sub"},["Adds the LAN this router uses.",W(s.detected.lan,s.saved.lan)])]),ve(c,"Auto-detect LAN",Z=>{c=Z,q()})]),K.length?t("details",{class:"dl-params",open:x?"":null,toggle:Z=>x=Z.currentTarget.open},[t("summary",{},[b("chevron"),t("span",{},"Other interfaces"),t("span",{class:"dl-pcount"},String(K.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...Ds.map(([Z,de])=>{let Q=K.filter(te=>te.category===Z);return Q.length?t("div",{class:"dl-ifgroup"},[t("h4",{},de),t("div",{class:"dl-ifgrid"},Q.map(f))]):""})])]):""])}return k(!0),{el:i,update(R){a=R,$.update(R),s&&q()}}}var Hs={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",expiring:"warn",expired_kept:"",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},zs={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",expiring:"calendar",expired_kept:"calendar"};function Ns(n,e){return e.device?n.people.flatMap(o=>o.devices).find(o=>o.id===e.device)?.kind??e.dkind??"other":zs[e.type]??"activity"}function wo(n,e){let r=n.people.find(h=>h.id===e.person),o=r?.name??e.pname??e.person??"",a=r?.devices.find(h=>h.id===e.device)?.name??e.dname??"",i=h=>t("b",{},h),s=h=>t("span",{class:"dl-muted"},h),l=h=>t("span",{class:"dl-mono"},h),d=h=>e.hosts?.[h]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[h]),t("span",{class:"dl-faint"},` (${h})`)])]:[l(h)],c=h=>t("span",{class:"dl-ev-kind"},`${h} `),p=a?`${o} · ${a}`:o,u=lr(e),x=u||a||"a device",$=h=>[t("span",{class:"dl-you"},"You"),s(` ${h} `)];if(Ne(e)==="admin")switch(e.type){case"device_added":return[...$("added"),c("device"),i(x),s(" for "),i(o)];case"device_removed":return[...$("removed"),c("device"),i(x),s(" from "),i(o)];case"paused":return[...$("paused"),c("person"),i(o)];case"resumed":return[...$("resumed"),c("person"),i(o)];case"device_changed":{let h=u.startsWith("renamed from ");return[...$(h?"renamed":u),c("device"),i(a||"a device"),s(" of "),i(o),...h?[s(` · was ${u.slice(13)}`)]:[]]}case"device_keys":return[...$("issued new keys for"),c("device"),i(x),s(" of "),i(o),s(" · it needs its new configuration")];case"link_changed":return[...$("issued a new link for"),c("person"),i(o),s(" · the old link stopped working")]}switch(e.type){case"connect":return[c("Device"),i(p),s(" connected"),...e.detail?[s(" from "),...d(e.detail)]:[],...e.where?[s(` · ${e.where}`)]:[]];case"disconnect":return[c("Device"),i(p),s(" went offline")];case"roam":return[c("Device"),i(p),s(" changed network "),...(e.detail??"").split(" → ").flatMap((h,m)=>m?[s(" → "),...d(h)]:d(h))];case"device_added":return[c("Person"),i(o),s(" added "),c("device"),i(x),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[c("Person"),i(o),s(" removed "),c("device"),i(x),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[c("Person"),i(o),s(" issued new keys for "),c("device"),i(x),s(" on their portal")];case"person_added":return[...$("added"),c("person"),i(e.detail??o)];case"person_removed":return[...$("removed"),c("person"),i(e.detail??o)];case"person_changed":return[...$("changed"),c("person"),i(o),...u?[s(` · ${u.replace(/_/g," ")}`)]:[]];case"expiring":return[c("Person"),i(o),s(`’s access ends in ${e.detail??"a few days"}`)];case"expired_kept":return[c("Person"),i(o),s(`’s end date passed (${e.detail??""}) · access kept`)];case"paused":return[c("Person"),i(o),s(` paused — ${e.detail??""}`)];case"resumed":return[c("Person"),i(o),s(" resumed"),...e.detail&&e.detail!=="active"?[s(` — ${e.detail}`)]:[]];case"portal_blocked":return[t("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(e.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[c("Person"),i(o),s(" — all devices removed, end date reached")];default:return[s(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var Rs={portal_blocked:["globe","bad"]};function Is(n,e){if(n.servers.length<2||!e.person)return"";let r=n.people.find(a=>a.id===e.person),o=r&&n.servers.find(a=>a.id===r.server);return o?t("span",{class:"dl-ev-srv",title:"Server"},o.name):""}function st(n,e,r={}){let o=Rs[e.type],a=Ne(e);return t("div",{class:`dl-row${a==="admin"?" dl-ev-by-admin":o?` dl-ev-by-system ${o[1]}`:""}`},[a==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):o?t("span",{class:"dl-ev-tile sys"},b(o[0])):t("span",{class:`dl-ev-tile ev ${Hs[e.type]??""}`},b(Ns(n,e))),t("span",{class:"dl-row-main"},wo(n,e)),r.server===!1?"":Is(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString()},r.time??re(e.ts,n.now))])}var Bs={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Os={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function Tn(n,e,r,o){let a=n.by==="admin",i=t("div",{class:`dl-row dl-slog-row ${a?"dl-ev-by-admin":`dl-ev-by-system ${Bs[n.level]??""}`}${n.detail?" has-detail":""}`},[a?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):t("span",{class:"dl-ev-tile sys",title:n.level},b(Os[n.src]??"zap")),t("span",{class:"dl-row-main"},a?[t("span",{class:"dl-you"},"You"),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):"",n.note?t("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},b("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},"Server "):"",t("b",{class:"dl-sys-src",title:Ot[n.src]??n.src},n.who??Ot[n.src]??n.src)," ",t("span",{class:"dl-muted"},n.msg),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},b("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString()},o)]);return n.detail&&i.addEventListener("click",s=>{s.target.closest("pre")||r()}),i}function pa(n){let e=new Date(n*1e3),r=new Date,o=new Date;return o.setDate(r.getDate()-1),e.toDateString()===r.toDateString()?"Today":e.toDateString()===o.toDateString()?"Yesterday":e.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var At=n=>wt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function _n(n,e,r,o=!1){let a=n.slice(-15),i=a[a.length-1],s=i&&e-i[0]<180,l=s?i[2]:0,d=s?i[1]:0,[c,p]=r,u=200,x=40,$=Math.max(1,...a.map(v=>Math.max(v[1],v[2]))),h=v=>a.map((y,E)=>`${a.length>1?E/(a.length-1)*u:u},${x-2-y[v]/$*(x-6)}`),m=h(2),C=h(1),B=a.length>1&&!o?et(``):t("div",{class:"dl-speed-wait"},[t("i"),o?"":t("span",{},"Collecting… 1 point a minute")]),w=(v,y,E,k)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:E},y),` ${v}`]),o?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},Oe(k))]);return a.length>1&&!o&&me(B,()=>{let v=a[a.length-1];return[t("div",{class:"dl-tip-title"},new Date(v[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${Oe(v[2])} · ↑ ${Oe(v[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Speed now"),o?"":t("span",{class:"dl-sub"},"last 15 min")]),t("div",{class:"dl-speed-cols"},[w("Download","↓","dl-dn",l),w("Upload","↑","dl-up",d)]),B,t("div",{class:"dl-speed-today"},[t("span",{},["Today ",t("b",{},ee(c+p))]),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${ee(p)} `,t("span",{class:"dl-up"},"↑"),` ${ee(c)}`])])])}function Pn(n,e){let r=n.slice(-30),o=r.map(d=>d.rx+d.tx),a=Math.max(1,...o),i=o.reduce((d,c)=>d+c,0),s=o.reduce((d,c,p)=>c>o[d]?p:d,0),l=t("div",{class:"dl-bento-bars"},r.map((d,c)=>{let p=o[c],u=t("i",{class:c===r.length-1?"hi":"",style:`height:${Math.max(4,p/a*100)}%`});return me(u,()=>[t("div",{class:"dl-tip-title"},c===r.length-1?`Today · ${At(d.day)}`:At(d.day)),t("div",{},ee(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${ee(d.tx)} ↑ ${ee(d.rx)}`)]),u}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},"Last 30 days"),t("b",{class:"dl-bento-total"},ee(i))]),o[s]>0?t("span",{class:"dl-sub"},`peak ${ee(o[s])} · ${At(r[s].day)}`):""]),r.length?l:t("p",{class:"dl-muted"},"No traffic yet."),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},r.length?At(r[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},"today")])])}function ua(n){let e=n.slice(-30),r=e.map(a=>a.rx+a.tx),o=Math.max(1,...r);return t("div",{class:"dl-dbars"},e.map((a,i)=>{let s=t("i",{class:`${r[i]?"":"zero"}${i===e.length-1?" hi":""}`});return s.style.height=`${Math.max(8,r[i]/o*100)}%`,me(s,()=>[t("div",{class:"dl-tip-title"},i===e.length-1?`Today · ${At(a.day)}`:At(a.day)),t("div",{},ee(r[i]))]),s}))}var ma={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function Dn(n){return n==="netrestart"&&!await le("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await G(()=>A.healthFix(n),"Done")??null}function yo(n,e,r,o="action"){let a=n.fix;return a?a.startsWith("install:")?H("Install",()=>da(a.slice(8),r),o):a==="updates"?t("a",{class:`cbi-button cbi-button-${o}`,href:L.url("admin/network/dawnline/updates")},ma.updates):H(ma[a]??"Fix",()=>e(a),o):""}function js(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="flash"?"download":n==="nft"?"lock":n==="data"?"users":"alert"}function ha(n,e,r,o=3){let a=n.filter(s=>s.status==="error"||s.status==="warn").sort((s,l)=>s.status===l.status?0:s.status==="error"?-1:1);if(!a.length)return"";let i=a.length-o;return t("div",{class:"dl-list dl-notices"},[...a.slice(0,o).map(s=>Xe(js(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,yo(s,e,r,s.status==="error"?"positive":"neutral"))),i>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,t("span",{class:"dl-spacer"}),"→"]):""])}function Us(n){let e=[],r=(s,l)=>t("a",{href:s},l),o=Ie(n.series),a=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?e.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,r(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!a&&e.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,r(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});for(let s of n.people)if(s.state==="quota")e.push({tone:"warn",text:[r(ke(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")e.push({tone:"warn",text:[r(ke(s.id),s.name),"’s access has ended."]});else{let l=Ye(s.expires,o);Ze(s,l)?e.push({tone:"",text:[r(ke(s.id),s.name),`’s access ${en(l)}.`]}):l!=null&&l<0&&s.expire_action==="notify"&&e.push({tone:"",text:[r(ke(s.id),s.name),`’s end date passed (${Me(s.expires)}) · access kept.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&e.push({tone:"",text:[r(ke(s.id),s.name)," has used 90% of the data limit."]})}let i=n.people.flatMap(s=>s.devices.filter(l=>l.config_stale).map(l=>[s,l]));i.length&&e.push({tone:"warn",text:i.length===1?[r(ke(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)," needs its configuration again."]:[`${i.length} devices need their configuration again (networks or DNS changed).`]});for(let s of n.servers)n.wan&&Ct(s.endpoint)&&s.endpoint!==n.wan&&e.push({tone:"warn",text:[`Public address changed: ${s.name} still gives devices ${s.endpoint}, the router is ${n.wan} now. `,t("button",{type:"button",class:"dl-fix",click:async l=>{let d=l.currentTarget;d.disabled=!0,await G(()=>A.serverUpdate(s.id,{endpoint:n.wan}),`${s.name} uses ${n.wan} now — devices need their configuration again`),d.disabled=!1}},"Use the new address")," A DDNS name would follow it by itself."]});return n.servers.some(s=>s.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[`Internet through the LAN is off: ${n.like_home.error} `,r(L.url("admin/network/dawnline/diagnostics"),"Details")]}),!n.settings.portal_enabled&&!n.people.length&&e.push({tone:"",text:["The personal portal is off. ",r(L.url("admin/network/dawnline/settings"),"Turn on")]}),e}var An=class{constructor(e,r){this.srvId=e;this.go=r;this.el=t("div",{class:"dl-srvov"});this.map=null;this.mapOn=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=Vt(e,this.srvId);for(let r of["health","bento","map","side","activity"])this.parts[r]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.parts.map,t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,r=!1){this.st=Vt(e,this.srvId),this.paint(r),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await A.health().catch(()=>null);if(!e)return;let r=()=>void this.loadHealth(),o=async a=>{await Dn(a)&&(r(),a==="netrestart"&&setTimeout(r,5e3))};Se(this.parts.health,ha(e.checks,a=>void o(a),r),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}paintMap(){let e=this.st.geo.enabled;if(e===this.mapOn&&(!e||this.map)){this.map?.update(this.mapData());return}this.mapOn=e,dom.content(this.parts.map,this.mapCard())}mapCard(){let e=this.st,r=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},"Where people connect from"),t("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),t("span",{class:"dl-spacer"}),_t(this.range,l=>{this.range=l,this.map?.setRange(l)})]);if(this.map?.destroy(),this.map=null,!e.geo.enabled)return t("div",{class:"dl-panel flush"},[r,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let o=this.map=new nt({openPerson:l=>location.href=ke(l),openDevice:(l,d)=>location.href=ke(l,d)},this.range),a=$e(()=>{a(),o.destroy(),this.map===o&&(this.map=null)}),i=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),"Live tunnel"]),t("span",{},[t("i",{class:"line"}),"Seen recently"])]),s=t("div",{class:"dl-map-wrap"},[o.el,i]);return requestAnimationFrame(()=>o.mount(this.mapData())),t("div",{class:"dl-panel flush"},[r,s])}paint(e=!1){let r=this.st,o=r.servers[0];this.paintMap(),Se(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Be(o).overviewTile(o),this.monthTile()]),e);let a=Us(r);Se(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Needs attention"),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),a.length?a.slice(0,8).map(s=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${s.tone}`}),t("span",{},s.text),s.action??""])):t("div",{class:"dl-row dl-muted"},[b("check"),"All good. Nothing needs you right now."])]),e);let i=[...r.events].reverse().slice(0,8);Se(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),i.length?i.map(s=>st(r,s)):t("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),e)}onlineTile(){let e=this.st,r=e.servers[0]?!e.servers[0].enabled:!1,o=12,a=B=>B.spark[B.spark.length-1]??0,i=B=>e.geo.points.find(w=>w.device===B.id&&w.city)?.city,s=B=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(B.endpoint??""),l=(B,w=!1)=>s(B)?w&&B.endpoint?`LAN · ${B.endpoint}`:"LAN":i(B)??"",d=B=>[...e.events].reverse().find(w=>w.type==="connect"&&w.device===B.id)?.ts??0,c=e.people.map(B=>({p:B,devs:B.devices.filter(w=>w.online).sort((w,v)=>a(v)-a(w))})).filter(B=>B.devs.length).sort((B,w)=>w.devs.reduce((v,y)=>v+a(y),0)-B.devs.reduce((v,y)=>v+a(y),0)),p=c.length<=2,u=({p:B,devs:w})=>{let v=w.map(d).filter(Boolean),y=v.length?Math.min(...v):0,E=(B.rate??[]).slice(-15),k=E[E.length-1],z=k&&e.now-k[0]<180?k:null,f=200,g=30,S=Math.max(1,...E.map(Y=>Math.max(Y[1],Y[2]))),T=Y=>E.map((R,K)=>`${E.length>1?K/(E.length-1)*f:f},${g-2-R[Y]/S*(g-6)}`),N=E.length>1?et(``):"",W=!z||z[1]<64&&z[2]<64,q=B.access==="both"?["home","globe"]:B.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},He(B.name)),t("span",{class:"dl-stack"},[t("b",{},B.name),t("span",{class:"dl-hc-since"},y?`online for ${re(y,e.now).replace(" ago","")}`:"online")]),t("span",{class:"dl-hc-reach"},q.map(Y=>t("span",{class:`dl-ibadge ${Y==="home"?"lan":"inet"}`},b(Y))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},W?[t("span",{class:"dl-faint"},"Idle right now")]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${Oe(z[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${Oe(z[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},"15 min")]),N]),t("div",{class:"dl-hc-devs"},w.map(Y=>t("span",{class:"dl-hc-dev"},[b(Y.kind),Y.name,l(Y)?[" · ",l(Y,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${ee(w.reduce((Y,R)=>Y+a(R),0))} today · ${ee(B.month[0]+B.month[1])} this month`)])])]},x=B=>{let{p:w,devs:v}=B,y=t("span",{class:"dl-onl-dev"},v.length>1?String(v.length):b(v[0].kind)),E=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:ke(w.id),"aria-label":`${w.name}, online`},[t("span",{class:"dl-onl-av"},[He(w.name),y]),p?t("span",{class:"dl-onl-name"},w.name):"",p?t("span",{class:"dl-onl-meta"},[...v.slice(0,3).map(k=>b(k.kind)),v.length>3?`+${v.length-3}`:"",l(v[0])?t("span",{},[" · ",l(v[0])]):""]):""]);return me(E,()=>u(B)),E},$=t("b",{class:`dl-onl-count${c.length?"":" none"}`},String(c.length)),h=c.reduce((B,w)=>B+w.devs.length,0);c.length&&me($,()=>[`${c.length} ${c.length===1?"person":"people"} · ${h} device${h===1?"":"s"}`]);let m=c.length>o?c.slice(0,o-1):c,C=e.people.flatMap(B=>B.devices.map(w=>({p:B,d:w}))).filter(B=>B.d.handshake).sort((B,w)=>w.d.handshake-B.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Online"),$]),c.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...m.map(x),c.length>o?t("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:B=>{this.go&&(B.preventDefault(),this.go("people","online"))}},[t("span",{class:"dl-onl-av"},`+${c.length-m.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},r?"The server is turned off":"Nobody is connected"),C?t("span",{class:"dl-sub"},`Last: ${C.p.name}, ${re(C.d.handshake,e.now)}`):t("span",{class:"dl-sub"},r?"Devices connect once it is on":"No device has connected yet")])])}speedTile(){let e=this.st.servers[0];return _n(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){let e=[...this.st.people].map(r=>[r,r.month[0]+r.month[1]]).filter(([,r])=>r>0).sort((r,o)=>o[1]-r[1]).slice(0,2);return Pn(this.st.series,e.length?`Most: ${e.map(([r,o])=>`${r.name} ${ee(o)}`).join(" · ")}`:"")}};var fa=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],Gs={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},ko=(n,e)=>{let r=new URLSearchParams;n&&r.set("server",n),e&&e!=="overview"&&r.set("section",e);let o=r.toString();return`${L.url("admin/network/dawnline/server")}${o?`?${o}`:""}`},Zt=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await A.status(31),r=e.servers.length?null:await A.setupDefaults();return[e,r]}render([e,r]){if(this.st=e,!e.servers.length&&r)return this.wizard(r);let o=new URLSearchParams(location.search),a=o.get("section")??"",i=Gs[a]??a;return fa.some(([s])=>s===i)&&(this.section=i),this.srvId=(e.servers.find(s=>s.id===o.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller?.stop(),this.poller=rt({fetch:()=>A.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(s,l)=>{s.servers.length&&(this.st=s,this.paintHead(l),this.ov[this.current().id]?.update(s,l))}}),this.root}paintHead(e=!1){Se(this.headEl,this.head(this.current()),e),(!e||!Dt(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await A.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await A.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=ko())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(r=>t("button",{type:"button",role:"tab",class:`dl-srvtab${r.id===e.id?" on":""}`,"aria-selected":r.id===e.id?"true":"false",click:()=>{r.id!==this.srvId&&(this.srvId=r.id,this.paint())}},[t("i",{class:`dot ${r.enabled?r.up?"ok":"bad":"warn"}`}),t("b",{},r.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[b("plus"),"Add server"])]))}paintSections(){let e=Be(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},fa.map(([r,o])=>t("button",{type:"button",role:"tab","data-section":r,class:r===this.section?"on":"","aria-selected":r===this.section?"true":"false",click:()=>this.showSection(r)},r==="awg"?e.label:o))))}go(e,r){let o=this.pp[this.current().id];if(r&&o)o.filter=r,o.el&&o.decorate();else if(r){let a=this.pp[this.current().id]=new mt;a.filter=r}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(r=>r.el),...Object.values(this.pp).map(r=>r.el)];for(let r of e)r&&this.bodyEl.contains(r)&&r.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===e;s.classList.toggle("on",l),s.setAttribute("aria-selected",l?"true":"false")});let r=this.st,o=this.current(),i={overview:()=>{let s=this.ov[o.id];return s?(s.update(r),s.el):(this.ov[o.id]=new An(o.id,(l,d)=>this.go(l,d))).mount(r)},people:()=>{var c,p;let s=this.pp[o.id];if(s?.el)return s.update(),s.el;let l=t("div",{},t("p",{class:"dl-muted"},"Loading people…"));return((c=this.pp)[p=o.id]??(c[p]=new mt)).embed(r,o.id).then(u=>{l.isConnected?dom.content(l,u):l.replaceChildren(u)}).catch(u=>{delete this.pp[o.id],dom.content(l,t("p",{class:"dl-muted"},`Couldn't show people: ${be(u)}`))}),l},connection:()=>this.connection(o),access:()=>this.access(o),awg:()=>this.awg(o)}[e]();this.detachKept(),dom.content(this.bodyEl,i)}head(e){let r=(i,s)=>t("span",{class:"dl-addrbar-seg"},[b(i),...s]),o=e.endpoint||"—",a=t("div",{class:"dl-actions"},[e.enabled?"":H([b("play")," Turn on"],()=>this.save(e,{enabled:"1"},"Server turned on"),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?"Running":e.blocked?"Can’t start":"Not running":"Turned off"),t("span",{class:"dl-spacer"}),a]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>ue(o,"Address copied")},[b("globe"),t("span",{class:"dl-mono"},o),b("copy")]),r(Be(e).id==="awg"?"amneziawg":"tunnel",[t("span",{class:"dl-mono"},`${Be(e).label} :${e.port}`)]),e.up?r("clock",[`up ${xt(e.uptime)}`]):""]),e.blocked?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},`${e.name} ${e.blocked}.`)]):""])}async save(e,r,o="Saved"){await G(()=>A.serverUpdate(e.id,r),o)&&await this.refresh()}connection(e){let r=se(e.name,{placeholder:"Home"}),o=se(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),a=se(e.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter($=>$.server===e.id).length,s=H([b(e.enabled?"pause":"play"),e.enabled?" Turn off":" Turn on"],async()=>{e.enabled&&!await le(`Turn off ${e.name}?`,`The tunnel stops and ${i} ${i===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?"Server turned off":"Server turned on")},e.enabled?"negative":"positive"),l=this.st.settings.portal_host,d=he("Name",r,()=>_e(r.value,[],"Shown to people in their portal and apps.")),c=Zn(()=>({host:o.value,port:e.port,id:e.id}),($,h,m)=>A.endpointProbe($,h,m),()=>p.refresh(),{empty:l?`Empty = the portal’s address (${l}).`:"Empty = the portal’s address."}),p=he("Public address",o,c.help);o.addEventListener("input",c.schedule),c.schedule();let u=e.reached?`Reached from the internet ${re(e.reached,this.st.now)}.`:"Never reached from the internet yet — test with a phone on mobile data.",x=he("DNS for devices",a,()=>Wo(a.value,e.address));return t("div",{class:"dl-stack gap16"},[Rt("Connection",[t("p",{class:"dl-muted"},"The name people see, where devices find the router, and DNS. The port is on AmneziaWG."),fe("router","Server","What people see",[d]),fe("globe","Devices connect to","A DDNS name keeps links working when your IP changes; not through Cloudflare (use a DNS-only name or an IP)",[p,t("div",{class:`dl-sub ${e.reached?"ok":"warn"}`},u)]),fe("file","For every device","Changing it marks devices “Update config” until they import again",[x])],[t("span"),H("Save",()=>{let $=ze([d,p,x]);if($){U($,"warning");return}return this.save(e,{name:r.value,endpoint:o.value,dns:a.value})},"positive")]),Rt("Danger zone",[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?"Turn off this server":"This server is off"),t("span",{class:"dl-sub"},e.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),t("div",{class:"dl-setrow-ctl"},s)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Change the tunnel network"),t("span",{class:"dl-sub"},`Devices have ${$t(e.subnet)}.x addresses now. A new range when it clashes with a network you connect to; every device then needs its configuration again.`)]),t("div",{class:"dl-setrow-ctl"},H([b("edit")," Change"],()=>this.changeSubnet(e),"negative"))]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Remove server"),t("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),t("div",{class:"dl-setrow-ctl"},H([b("trash")," Remove"],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let r=xo(this.st,e),o=ca(e,this.st,async()=>{let a=await this.refreshStatus();if(!a)return;let i=a.servers.find(l=>l.id===e.id)??e;o.update(a);let s=xo(a,i);r.replaceWith(s),r=s});return t("div",{class:"dl-stack gap16"},[o.el,t("div",{class:"dl-health-cols"},[r,na(this.st,e)])])}awg(e){let r={st:this.st,save:(o,a)=>this.save(e,o,a),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[Be(e).settingsCard(r,e)])}async addServer(){let e=await G(()=>A.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async changeSubnet(e){let r=await G(()=>A.serverPorts(e.id));if(!r)return;let o=r.networks??[],a=this.st.people.filter(l=>l.server===e.id).reduce((l,d)=>l+d.devices.length,0),i=se($t(e.subnet),{class:"cbi-input-text dl-mono dl-w-range"}),s=he("Address range",i,()=>Yn(i.value,o,""));oe("Change the tunnel network",[s,t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from their personal link or from you).`:"No devices on this server yet: nothing else changes.")],[ie()," ",H("Change",async()=>{let l=s.help();if(l.bad){U(l.text,"warning");return}let d=an(i.value);if(d===e.subnet){ae();return}await G(()=>A.serverUpdate(e.id,{subnet:d}),"Tunnel network changed")&&(ae(),a&&U("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())},"negative")]),setTimeout(()=>i.select(),50)}async remove(e){let r=this.st.people.filter(o=>o.server===e.id);oe(`Remove ${e.name}?`,[t("p",{},`This removes the tunnel, its firewall rules and ${r.length} ${r.length===1?"person":"people"} with all their devices. A backup is made first.`)],[ie()," ",H("Remove",async()=>{ae(),await G(()=>A.serverDelete(e.id),"Server removed")&&setTimeout(()=>{location.href=ko()},800)},"negative")])}wizard(e,r=!1,o){let a={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:$t(e.subnet),preset:mn(e.awg),portal:!1,portal_port:e.portal_port||8443,lan_like:!0,lan_zone:e.lan_zone,wan_zone:e.wan_zone},i=0,s=!r&&a.portal_port===a.port,l=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(a.endpoint),d=()=>It(a.port,e.udp_taken??[],`Opened on the WAN firewall automatically.${a.port===4500?" 4500 is IPsec’s port: most networks let it through.":""}`),c={ddns:"From your DDNS name.",cert:"From your Let’s Encrypt certificate.",wan:"Your WAN address now — it may change; a DDNS name is better.",portal:"The portal’s address."},p=Zn(()=>({host:a.endpoint,port:a.port}),(S,T,N)=>A.endpointProbe(S,"",N),()=>u?.refresh(),{idle:()=>a.endpoint===e.endpoint&&e.endpoint_from?c[e.endpoint_from]??"":""}),u=null,x=e.wan_kind==="cgnat"||e.wan_kind==="private"?Xe("alert","warn",e.wan_kind==="cgnat"?"Your router has no public address (CGNAT)":`Your router is behind another router (WAN ${e.wan_ip})`,e.wan_kind==="cgnat"?"The ISP shares one address: devices can only connect if the ISP gives you a public address or IPv6. Ask them, or use a DDNS name that points at an IPv6 address.":"Forward the UDP port on the upstream router to this one and use a DDNS name or that router’s public address here.",""):"",$=e.awg_state?.tools&&e.awg_state.handler===!1?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},"Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.")]):"",h=()=>Yn(a.range,e.networks??[],$t(e.subnet)),m=()=>sn(a.portal_port,e.tcp_taken??[],l()),C=t("div",{class:"dl-wizard"}),B=(S,T={})=>{let N=se(String(a[S]),T);return N.addEventListener("input",()=>{S==="port"||S==="portal_port"?a[S]=N.value.trim()===""?0:Number(N.value):a[S]=N.value.trim(),S==="port"&&s&&(a.portal_port=a.port),S==="portal_port"&&(s=a.portal_port===a.port)}),N},w={id:"server",title:"Server",render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},r?"One more server: another port or disguise for networks where the first does not get through, or its own home access rules. People are moved between servers from their page.":"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),fe("router","Server","What people see",[he("Name",B("name"),()=>_e(a.name,[],"Shown to people in their portal and apps."))]),fe("globe","Devices connect to","A hostname or IP address of your router on the internet; not through Cloudflare (use a DNS-only name or an IP). IPv6 works too, and is the way out of CGNAT",[(()=>{let S=B("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"});return u=he("Public address",S,p.help),S.addEventListener("input",p.schedule),p.schedule(),u})()]),x,$]),check:()=>{let S=_e(a.name);if(S.bad)return`Name: ${S.text}`;let T=kt(a.endpoint,a.port);return T.bad?`Public address: ${T.text}`:null}},v={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[fe("globe","Listening","Where devices reach AmneziaWG from the internet",[he("UDP port",B("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),d)]),fe("network","Tunnel network","Addresses devices get inside the tunnel",[(()=>{let S=B("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":"First three numbers of the device addresses"});return he("Device addresses",S,h,t("span",{class:"dl-suffixed"},[S,t("span",{class:"dl-mono"},".x")]))})()]),fe("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[hn(e.awg,a.preset,S=>a.preset=S,void 0,e.awg_state?.tools!==!1)])]),check:()=>{let S=d();if(S.bad)return`UDP port: ${S.text}`;let T=h();return T.bad?`Device addresses: ${T.text}`:null}},y={id:"portal",title:"Portal",render:()=>{let S=B("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),T=he("Listening port",S,m);T.hidden=!a.portal;let N=we([["off","Off"],["on","On"]],a.portal?"on":"off",{label:"Personal portal",onChange:W=>{a.portal=W==="on",T.hidden=!a.portal}});return t("div",{class:"dl-wizard-groups"},[fe("home","Internet like a home device","How devices reach the internet",[ce("Through the home network",ve(a.lan_like,"Internet like a home device",W=>a.lan_like=W),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),fe("link","Personal portal","A page where each person adds their own devices with their personal link",[ce("Portal",N,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),T])])},check:()=>{if(!a.portal)return null;let S=m();return S.bad?`Portal port: ${S.text}`:null}},E=()=>[w,v,r?null:y].filter(S=>S!=null),k=e.awg_state,z=k?.missing??[],f=z.length?t("div",{class:"dl-list dl-notices"},[Xe("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${z.join(" and ")}. Install the build made for this firmware, then create the server.`,H("Install",()=>Sn(()=>location.reload()),"positive"))]):k&&!k.loaded?t("div",{class:"dl-list dl-notices"},[Xe("shield","warn","AmneziaWG’s kernel module doesn’t load on this firmware","Try another build in Components, or update OpenWrt. The server can’t start until it loads.",t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",g=()=>{let S=E();i>=S.length&&(i=S.length-1),dom.content(C,[t("h2",{},r?"Add a server":"Set up Dawnline"),f,t("div",{class:"dl-steps"},S.map((T,N)=>t("span",{class:`dl-step${N===i?" current":N0?H("Back",()=>{i--,g()}):o?H("Cancel",o):"",t("span",{class:"dl-spacer"}),i{let T=S[i].check?.();if(T){U(T,"warning");return}i++,g()},"positive"):H("Create server",async()=>{for(let N of S){let W=N.check?.();if(W){U(W,"warning");return}}let T=await G(()=>A.serverCreate(a.id,a.name,e.ifname,a.port,an(a.range),a.endpoint,e.mtu,a.preset,a.lan_zone,a.wan_zone,a.lan_like,r?void 0:a.portal,r?void 0:a.portal_port),"Server created");T&&(T.network_restart&&U("Restarting the network so it knows AmneziaWG: back in a few seconds"),setTimeout(()=>{location.href=ko(T.id)},T.network_restart?1e4:1500))},"positive",{disabled:z.length>0,title:z.length?"Install AmneziaWG first":null})])])};return g(),C}};function lt(n){let e={el:n(),refresh(){let r=n();e.el.replaceWith(r),e.el=r}};return e}function Re(n,e,r,o,a="",i=[]){return t("section",{class:`dl-setsec ${a}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[i.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...i]):t("h3",{},e),...r]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function ga(n){let e=n.filter(a=>a.status!=="skip"),r=e.filter(a=>a.status==="error"||a.status==="warn"),o=e.some(a=>a.status==="error")?"error":r.length?"warn":"ok";return{bad:r,worst:o}}function va(n){let e=n.d.settings,r=n.d.effective,o=n.d.cert,a=ve(r.portal_enabled,"Enable portal"),i=se(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=se(e.portal_title,{placeholder:"Dawnline"}),l=se(e.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),d=se("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),c=O=>/^\d{1,3}(\.\d{1,3}){3}$/.test(O),p=[r.portal_host,...r.portal_alt??[]].filter((O,X,P)=>O&&P.indexOf(O)===X),u=!!n.portal,x=[],$=O=>{O&&!x.some(X=>X.host===O)&&x.push({host:O,kind:c(O)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},h=O=>{x=[...O,...x.filter(X=>!O.some(P=>P.host===X.host))],!p.length&&O[0]&&(p=[O[0].host])};n.portal&&h(n.portal.candidates),p.forEach($);let m=O=>O.kind==="ip"?t("span",{class:"dl-addr-warn"},[b("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):t("span",{class:"dl-sub"},O.cloudflare?"Behind Cloudflare · often stalls in Russia":O.ips.length?O.here?`Points at this router${O.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${O.ips.join(", ")}, not this router`:u?"Your address":"Checking where it points…"),C=t("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),B=O=>{p.includes(O)?p.length>1&&(p=p.filter(X=>X!==O)):p=[...p,O],w(),E()},w=()=>dom.content(C,[...x.map(O=>{let X=p.includes(O.host),P=p[0]===O.host;return t("div",{class:`dl-addr-opt${X?" on":""}`,role:"checkbox","aria-checked":X?"true":"false",tabindex:"0",click:()=>B(O.host),keydown:D=>{(D.key===" "||D.key==="Enter")&&(D.preventDefault(),B(O.host))}},[t("i",{class:"dl-addr-check"},X?b("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},O.host),m(O)]),P?t("span",{class:"dl-pill info"},"Main"):X?t("button",{type:"button",class:"dl-linkbtn",click:D=>{D.stopPropagation(),p=[O.host,...p.filter(_=>_!==O.host)],w(),E()}},"Make main"):O.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):O.kind==="ip"?t("span",{class:"dl-pill"},"IP"):O.here&&O.cert?t("span",{class:"dl-pill ok"},"Recommended"):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},b("plus")),d,H("Add",()=>{let O=d.value.trim().toLowerCase();if(!O)return;let X=kt(O);if(X.bad){U(X.text,"warning");return}$(O),p.includes(O)||(p=[...p,O]),d.value="",w(),E()})])]);d.addEventListener("keydown",O=>{O.key==="Enter"&&(O.preventDefault(),d.nextElementSibling?.click())});let v=t("div",{class:"dl-links"}),y=()=>{},E=()=>{y();let O=Number(i.value)||r.portal_port;dom.content(v,p.map((X,P)=>{let D=c(X),_=D?O+1:O,I=`${D?"http":"https"}://${X}${_===(D?80:443)?"":`:${_}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${D?"warn":"ok"}`},b(D?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[I,t("b",{},"kamiro-telosu-bavine")]),P===0?t("span",{class:"dl-pill info"},"Main"):D?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};w(),E(),i.addEventListener("input",()=>E());let k={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},z=n.d.needs??{https:[],acme:[],home:[]},f=O=>{if(!r.portal_enabled)return t("div",{hidden:!0});if(!O)return fe("check","Ready to share","The portal’s checks from Health",[t("p",{class:"dl-muted dl-loading"},"Running checks…")]);let X=O.filter(M=>M.status!=="skip");if(!X.length)return t("div",{hidden:!0});let{bad:P,worst:D}=ga(O),_=t("div",{class:"dl-ready-details",hidden:!0},X.map(M=>t("div",{class:`dl-ready-item ${M.status}`},[b(M.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},M.title),t("span",{class:"dl-sub"},M.detail)])]))),I=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${D}`},[b(D==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},D==="ok"?`All ${X.length} checks passed`:`${X.length-P.length} of ${X.length} checks passed`),P.length?t("span",{class:"dl-sub"},P.map(M=>M.detail).join(" ")):t("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),t("button",{type:"button",class:"dl-linkbtn",click:M=>{_.hidden=!_.hidden,M.currentTarget.textContent=_.hidden?"Details":"Hide"}},"Details")]),t("div",{class:"dl-chips-row"},X.map(M=>t("span",{class:`dl-check-chip ${M.status}`,title:M.detail},[b(M.status==="ok"?"check":"alert"),k[M.id]??M.title]))),_]);return fe("check","Ready to share","The portal’s checks from Health",[I])},g=O=>{if(!r.portal_enabled||!O&&!z.https.length)return t("span",{hidden:!0});if(z.https.length)return t("span",{class:"dl-pill bad"},"Can’t start");let{worst:X}=ga(O);return t("span",{class:`dl-pill ${X==="ok"?"ok":X==="error"?"bad":"warn"}`},X==="error"?"Needs attention":"Ready")},S=f(n.portal?.checks??null),T=g(n.portal?.checks??null);n.portalFill=O=>{u=!0,h(O.candidates),w(),E();let X=f(O.checks);S.replaceWith(X),S=X;let P=g(O.checks);T.replaceWith(P),T=P};let N=o&&!o.self_signed&&o.expires?Ue(o.expires):"",W=he("Listening port",i,()=>sn(i.value.trim()===""?r.portal_port:Number(i.value),n.d.tcp_taken??[],p.some(c)));y=W.refresh;let q=he("Title",s,()=>Zo(s.value)),Y=he("Unknown links",l,()=>Yo(l.value)),R=!!(e.portal_cert&&e.portal_key),K=o?R?"Your files":o.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",Z=()=>{let O=se(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),X=se(e.portal_key,{placeholder:"/etc/ssl/…/key"});oe("Use your own certificate",[t("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),ce("Certificate file",O),ce("Key file",X)],[ie()," ",H("Save",()=>{ae(),n.save({portal_cert:O.value.trim(),portal_key:X.value.trim()},"Certificate saved","portal")},"positive")])},de=(O,X,P,D,_,I)=>Xe(O,X,P,D,H(I,()=>Yt(_,z[_],()=>n.reload("portal")),"positive")),Q=z.https.length?de("lock","bad","HTTPS isn’t available on this router",`The portal needs ${z.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",te=z.acme.length&&(!o||o.self_signed)?de("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${e.portal_host?` for ${e.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",ge=[t("div",{class:"dl-row"},[b("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[K,N?t("span",{class:"dl-faint"},` · until ${N}`):""]),t("span",{class:"dl-sub dl-ellipsis",title:o?.path??""},o?o.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${R?"Your files":"Found automatically"} · ${o.path}`:"Turn the portal on to see its certificate.")])]),t("div",{class:"dl-row"},[b("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Your own files"),t("span",{class:"dl-sub"},R?`${e.portal_cert} · ${e.portal_key}`:"Not set: the certificate is picked automatically.")]),R?H("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",H(R?"Change":"Use files",Z)]),te];return Re("portal","Personal portal",[t("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),Q?t("div",{class:"dl-list"},[Q]):"",fe("network","Port","How the portal listens (80 and 443 stay free)",[W]),fe("edit","Appearance","What people see",[q,Y]),fe("link","Addresses","Pick one or more; the first is the main link",[C,t("div",{class:"dl-stack gap8"},[v,t("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),fe("lock","Certificate","Used for HTTPS links",ge),S],[t("span"),H("Save",()=>{let O=ze([W,q,Y]);if(O){U(O,"warning");return}return n.save({portal_enabled:Pe(a)?"1":"0",portal_host:p[0]??"",portal_alt:p.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:l.value.trim()},"Saved","portal")},"positive")],"",[T,a])}function ba(n){let e=n.d.settings,r=n.d.effective,o=se(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),a=ve(r.hostnames,"Device hostnames"),i=se(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=se(e.home_dns_fallback==="none"?"":e.home_dns_fallback||r.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),l=he("Devices per person",o,()=>{if(!o.value.trim())return{text:"The default, 3. Pre-filled when you add someone.",bad:!1};let p=ln(o.value);return p.bad?p:{text:"Pre-filled when you add someone.",bad:!1}}),d=he("Device hostnames",i,()=>Qo(i.value),t("div",{class:"dl-hostport"},[a,t("span",{class:"dl-faint dl-mono"},"phone.myata."),i])),c=he("Fallback DNS",s,()=>{let p=Xo(s.value);return p.bad?p:{text:`For Home-only devices using home names: ${p.text}`,bad:!1}});return Re("defaults","New people",[l,d,c],[t("span"),H("Save",()=>{let p=ze([l,d,c]);if(p){U(p,"warning");return}return n.save({default_device_limit:o.value,hostnames:Pe(a)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults")},"positive")])}function xa(n){let e=n.d.effective,r=ve(e.geo_enabled,"Locations"),o=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Re("map","Map & locations",[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),r]),ce("Provider",o)],[t("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),H("Save",()=>n.save({geo_enabled:Pe(r)?"1":"0",geo_provider:o.value},"Saved","map"),"positive")])}var Ws=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function wa(n){let e=n.d.effective.updates,r=ve(e.check,"Check automatically",h=>$(h,Pe(a))),o=we([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],e.interval,{label:"How often",cls:"sm"}),a=ve(e.auto,"Install automatically",h=>$(Pe(r),h)),i=se(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":"Time"}),s=we([["scheduled","At a set time"],["immediate","As soon as found"]],e.mode,{label:"When",cls:"sm",onChange:h=>i.hidden=h!=="scheduled"});i.hidden=e.mode!=="scheduled";let l=new Set(e.targets),d=t("div",{class:"dl-chips-row"},Ws.map(([h,m])=>{let C=qe(m,l.has(h),()=>{l.delete(h)||l.add(h),un(C,l.has(h))});return C})),c=ve(e.keep,"Keep the previous version"),p=ve(e.mirrors,"GitHub mirrors"),u=ce("How often",o),x=[ce("When",t("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),ce("Components",d,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],$=(h,m)=>{u.hidden=!h;for(let C of x)C.hidden=!m};return $(e.check,e.auto),Re("updates","Updates",[t("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),ce("Check automatically",r,"Looks for new versions in the background; Components shows what it found and the service log names it."),u,ce("Install automatically",a,"Downloads and installs new versions of the components below."),...x,ce("Keep the previous version",c,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),ce("GitHub mirrors",p,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[t("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),H("Save",()=>{if(s.dataset.value==="scheduled"){let h=er(i.value);if(h.bad){U(`Time: ${h.text}`,"warning");return}}return n.save({update_check:Pe(r)?"1":"0",update_interval:o.dataset.value,update_auto:Pe(a)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Pe(c)?"1":"0",update_mirrors:Pe(p)?"1":"0"},"Saved","updates")},"positive")])}function ya(n){let e=n.d.logs,r=e.policy,o=we([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(r.keep_days),{label:"Keep activity",cls:"sm"}),a=we([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(r.max),{label:"Maximum events",cls:"sm"}),i=we([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],r.persist,{label:"Save to flash",cls:"sm"}),s=we([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(r.usage_days),{label:"Daily traffic",cls:"sm"}),l=we([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(r.usage_months),{label:"Monthly traffic",cls:"sm"}),d=new Set(r.categories),c=t("div",{class:"dl-chips-row"},Mt.map($=>{let h=qe([ut[$],t("b",{},String(e.by_category[$]??0))],d.has($),()=>{d.delete($)||d.add($),un(h,d.has($))},{title:sr[$]});return h})),p=e.oldest?Ue(new Date(e.oldest*1e3)):"",u=($,h,m,C)=>t("div",{class:"dl-row"},[b($),t("span",{class:"dl-row-main dl-stack"},[t("b",{},h),t("span",{class:"dl-sub"},m)]),...C]),x=$=>H($.toUpperCase(),async()=>{let[h,m]=await Promise.all([A.status(1),A.events(2e4)]);Fe(h,m.events,$)},"neutral",{title:`Download the log as ${$.toUpperCase()}`});return Re("logs","Logs & history",[t("p",{class:"dl-muted"},pn(r)),ce("Keep activity",o,"Older events are removed automatically."),ce("Maximum size",a,"Newest events are kept when the log is full."),ce("Record",c,"Switched-off categories are not logged from now on."),ce("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),ce("Daily traffic",s,"Per-day history behind the charts."),ce("Monthly traffic",l,"Per-month totals; data limits use the current month."),t("h4",{class:"dl-setsub"},"Stored data"),t("div",{class:"dl-list"},[u("activity","Activity log",e.events?`${tn(e.events,"event")} since ${p} · ${Nt(e.log_ram)} in memory${r.persist==="off"?"":`, ${Nt(e.log_flash)} on flash`}`:"Empty",[x("csv"),x("json"),H("Clear",()=>tt("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),u("chart","Traffic history",e.usage_days?`${tn(e.usage_days,"day")} since ${Ue(e.usage_since)} · ${Nt(e.usage_flash)} on flash`:"Empty",[H("Reset",()=>St("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),u("pin","Location cache",`${tn(n.d.geo_cached,"address","addresses")} · ${Nt(e.geo_flash)} on flash`,[H("Clear",async()=>{await G(()=>A.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},"Clear one person or device from their own page."),H("Save",()=>n.save({log_keep_days:o.dataset.value,log_max:a.dataset.value,log_persist:i.dataset.value,usage_keep_days:s.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]},"Saved","logs"),"positive")])}var Fs={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},ka=3;function $o(n){let e=new Date(n*1e3),r=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),o=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return`${o===0?"Today":o===1?"Yesterday":e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${r}`}async function qs(n){let e=await G(()=>A.backupRead(n.name));if(!e)return;let r=atob(e.data),o=new Uint8Array(r.length);for(let i=0;iqs(n),"neutral","dl-icon-only"),Le("more","More",r=>Ce(r.currentTarget,[{label:"Restore",icon:b("reset"),run:async()=>{await le("Restore this backup?",`Everything returns to ${$o(n.created)}. The current state is backed up first.`,"Restore",!0)&&await G(()=>A.backupRestore(n.name),"Restored")&&e(!0)}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await le("Delete this backup?",`The backup from ${$o(n.created)} is removed from the router.`,"Delete",!0)&&await G(()=>A.backupDelete(n.name),"Backup deleted")&&e()}}]),"neutral","dl-icon-only")])])}function Ca(n,e){let r=n.slice(0,ka).map(d=>$a(d,e)),o=n.slice(ka),a=n.length?t("div",{class:"dl-list"},[...r,o.length?t("details",{class:"dl-bk-older"},[t("summary",{},[b("chevron"),`${o.length} older backup${o.length===1?"":"s"}`]),...o.map(d=>$a(d,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=H("Restore from file",async()=>{let d=await Fn(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await le("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await G(()=>A.backupUpload(d.data),"Restored")&&e(!0)}),s=H("Export JSON",async()=>{let d=await G(()=>A.exportJson());d&&Te(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=H("Import JSON",async()=>{let d=await Fn(".json,application/json","text");if(!d)return;let c;try{c=JSON.parse(d.data)}catch{U("Not a JSON file.","error");return}await le("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await G(()=>A.importJson(c),"Imported")&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},"Backups"),t("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),t("span",{class:"dl-spacer"}),H([b("plus")," Back up now"],async()=>{await G(()=>A.backupCreate(),"Backup created")&&e()},"positive")]),a]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),t("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function Ks(){let n=se("",{placeholder:"remove"}),e=H("Remove Dawnline",async()=>{await G(()=>A.uninstall(n.value.trim()),"Dawnline removed")&&(ae(),setTimeout(()=>location.reload(),800))},"negative",{disabled:!0});n.addEventListener("input",()=>{e.disabled=n.value.trim()!=="remove"}),oe("Remove Dawnline?",[t("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[ie()," ",e])}function Ea(){return Re("danger","Remove Dawnline from this router",[t("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[t("span"),H("Remove",()=>Ks(),"negative")],"danger")}var Hn=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return A.settingsGet()}render(e){this.d=e,this.cards={portal:lt(()=>va(this)),defaults:lt(()=>ba(this)),map:lt(()=>xa(this)),updates:lt(()=>wa(this)),logs:lt(()=>ya(this)),backups:lt(()=>Ca(this.backups,a=>this.loadBackups(a))),danger:lt(()=>Ea())};let r=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,r.map(a=>this.cards[a].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let o=new URLSearchParams(location.search).get("section");return o&&o!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${o}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(e,r,o){let a=await G(()=>A.settingsUpdate(e),r);a&&(this.d=a,this.cards[o].refresh(),o==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,r=await A.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=r??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let r=await A.backupList().catch(()=>null);r&&(this.backups=r.backups,this.cards.backups?.refresh())}async reload(e){let r=await A.settingsGet().catch(()=>null);if(r){if(this.d=r,e)this.cards[e].refresh();else for(let o of Object.values(this.cards))o.refresh();(!e||e==="portal")&&this.loadPortal()}}};function La(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function Ma(n){let e=[],r=l=>{let d=[],c=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=c.exec(l);)u.index>p&&d.push(l.slice(p,u.index)),u[1]?d.push(t("code",{},u[1].slice(1,-1))):u[2]?d.push(t("b",{},u[2].slice(2,-2))):u[3]?d.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&d.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{a.length&&e.push(t("p",{},r(a.join(" ")))),a=[],o=null};for(let l of n.replace(/\r/g,"").split(` +`)){let d=l.trimEnd();if(i){/^```/.test(d.trim())?(e.push(t("pre",{},i.join(` +`))),i=null):i.push(l);continue}if(/^```/.test(d.trim())){s(),i=[];continue}let c=/^(#{1,6})\s+(.*)$/.exec(d),p=/^\s*[-*+]\s+(.*)$/.exec(d)??/^\s*\d+[.)]\s+(.*)$/.exec(d);c?(s(),e.push(t("h5",{},r(c[2])))):p?(a.length&&s(),o||(o=t("ul",{}),e.push(o)),o.appendChild(t("li",{},r(p[1])))):d.trim()?(o&&(o=null),a.push(d.trim())):s()}return i&&e.push(t("pre",{},i.join(` +`))),s(),e}function Sa(n){let e=[],r=!1;for(let o of n.replace(/\r/g,"").split(` +`)){let a=/^#{1,6}\s+(.*)$/.exec(o);if(a){if(r=/^install\b/i.test(a[1].trim()),/^what.s new$/i.test(a[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(o)&&(r=!1);r||e.push(o)}return e.join(` `).replace(/\n{3,}/g,` -`).trim()}async function Zt(n,e,o,r){let a=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";te(o,[i,a],[H([b("copy")," Copy"],()=>pe(s,"Release notes copied"))," ",ae("Close")],"wide");try{let l=await A.updatesNotes(n,e,r??"");s=ia(l.body||"");let c=ra(l.url);dom.content(i,[l.published?t("span",{class:"dl-pill"},Ue(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),c?t("a",{href:c,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",b("open")]):""]),dom.content(a,s.trim()?aa(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(a,t("p",{class:"dl-muted"},be(l)))}}var sa={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},bo=n=>n?Ue(n):"";function Cs(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function da(n,e){let o=n.st,r=o.policy,a=o.kept?.app,i=e?.update&&e.tag?e.tag:o.version,s=w=>()=>Zt("app",w,`What’s new in Dawnline ${w.replace(/^v/,"")}`),l=e?.tag&&(e.update||e.status==="latest")?Es(n,e.tag,e.update?o.version:""):null,c=e?.tag??i,d=r.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[r.interval]??24)*3600:0,p=(w,C)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},w),t("span",{class:"dl-comp-side-v"},C)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:`Reinstall ${o.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",o.version)},a?{label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await se(`Roll back to Dawnline ${a.version}?`,`The copy kept on the router replaces ${o.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",o.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},b("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[o.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},`release ${e.latest}`):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?`released ${bo(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${bo(e.published)}`:""}`:"not checked yet")])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(w=>t("li",{},w))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(c)},`+${l.total-l.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[H("Update now",()=>n.op("app","Updating Dawnline",o.version),"positive",{disabled:n.busy}),H("What’s new",s(i))]):"",Ls(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[b("globe"),t("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p("Auto-update",[r.auto?Ee("ok","On"):Ee("","Off"),t("span",{class:"dl-muted"},r.auto?r.mode==="immediate"?"as soon as found":`${sa[r.interval]==="weekly"?"weekly":"daily"} at ${r.time}`:r.check?`checks ${sa[r.interval]}`:"checks off")]),p("Last check",o.check?[re(o.check.time,o.now),d>o.now?t("span",{class:"dl-faint"},`· next in ${vt(d-o.now)}`):""]:["Never"]),p("Rollback",a?[t("span",{class:"dl-mono"},a.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},r.keep?"Kept after the next update":"Off")])])])}function Es(n,e,o){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let r=a=>a.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await A.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` -`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await A.updatesChanges(o,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>Cs(r(l))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Ls(n){let e=t("div",{class:"dl-params-body"}),o=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[b("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&An(n,e)}),n.versOpen&&An(n,e),o}async function An(n,e){let o=ie("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),r=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return U("Enter a release tag like 0.3.1","warning");la(n,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),r(o.value))});let a=t("div",{class:"dl-comp-tag"},[o,H("Install",()=>r(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),An(n,e)},l=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),t("span",{class:"dl-faint"},`Page ${i}`),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>s(1)},"Older →")]),c=n.versCache.get(i);if(!c){dom.content(e,[a,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{c=(await A.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[a,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${be(p)}`),H("Try again",()=>An(n,e))]),l(!1)]);return}if(n.versCache.set(i,c),i!==n.versPage||!e.isConnected)return}if(!c.length)return dom.content(e,[a,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let d=n.st.version;dom.content(e,[a,...c.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},bo(p.published)),p.prerelease?Ee("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},Le("file","What’s new",()=>Zt("app",p.tag,`What’s new in Dawnline ${u}`))),u===d?Ee("ok","Installed"):H("Install",()=>la(n,p.tag),"neutral",{disabled:n.busy})])}),l(c.length>=5)])}async function la(n,e){let o=e.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await se(`Install Dawnline ${o}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${e}`,`Installing Dawnline ${o}`,n.st.version)}function ca(n,e){let o=n.st,r=o.kept?.amneziawg,a=e?.sources??{},i=Object.keys(a),s=e?.current??null,l=s?a[s]:void 0,c=!!e?.ru,d=o.needs?.awg??[],p=d.length?null:e?.installed??null,u=[];s&&p&&u.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${c?":ru":""}`,"Reinstalling AmneziaWG",p)}),r&&u.push({label:`Roll back to ${r.version}`,ic:"archive",warn:!0,run:async()=>{await se(`Roll back AmneziaWG to ${r.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",p??void 0)}});let w=[e?.release?{label:"What’s new",ic:"file",run:()=>Zt("amneziawg",e.release,`What’s new in the ${l?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((h,f,T)=>h!==null||f>0&&T[f-1]!==null),C=o.tunnels??[],g=C.length?`Switching restarts ${C.length===1?"the tunnel":`${C.length} tunnels`} for a few seconds: ${C.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",m=C.length>1?`${C.slice(0,-1).join(", ")} and ${C[C.length-1]}`:C[0],k=C.length?`Switching restarts ${m} for a few seconds.`:"Switching takes a few seconds.",I=async h=>{let f=a[h];await se(p?`Switch to AmneziaWG ${f.gen}?`:`Install AmneziaWG ${f.gen}?`,`The ${f.label} build, ${f.version}. ${g}${f.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${h}${c?":ru":""}`,p?`Switching to AmneziaWG ${f.gen}`:"Installing AmneziaWG",p??void 0)},x=h=>{let f=a[h],T=s===h&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??"none yet"),t("span",{class:"dl-comp-bact"},T?Ee("ok","Active"):f.version?H(p?"Switch":"Install",()=>I(h),p?"neutral":"positive",{disabled:n.busy}):Ee("","No build"))])},v=i.map(h=>a[h]?.newer?`${a[h].label} moves to ${a[h].newer.gen} with OpenWrt ${a[h].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),$=ve(c,"Russian translation",h=>{s&&n.op(`amneziawg:${s}${h?":ru":""}`,h?"Adding the Russian translation":"Removing the Russian translation",p??void 0)});$.disabled=!s||!p||n.busy;let E=n.awgOpen??!p,y=t("details",{class:"dl-params dl-comp-fold",open:E?"open":null},[t("summary",{},[b("chevron"),t("span",{},"Build and translation")]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...i.length?i.map(x):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Russian translation"),t("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),t("span",{class:"dl-comp-bact"},$)])]),p&&i.length||v.length?t("div",{class:`dl-comp-status ${p&&i.length?"warn":"acc"}`},[b(p&&i.length?"alert":"download"),t("span",{},[p&&i.length?t("b",{},k):"",...v.map(h=>` ${h}`)])]):""])]);y.addEventListener("toggle",()=>n.awgOpen=y.open);let z=[];return e?.update&&p&&s?z.push(H(`Update to ${e.latest}`,()=>n.op(`amneziawg:${s}${c?":ru":""}`,"Updating AmneziaWG",p),"neutral",{disabled:n.busy})):z.push((e||d.length)&&!p?Ee("warn","Not installed"):n.state("amneziawg",e,e?.latest??"")),z.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",p??void 0),w)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${e.release} build`:""}`:d.length?`missing ${d.join(", ")}`:e?"not installed":"version not checked"],z),t("div",{class:"dl-comp-foldwrap"},y)]}var Ms=[{title:"Home-like link",sub:"Policy routing and the veth pair",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"HTTPS for the portal",sub:"OpenSSL for uhttpd",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"Certificates (ACME)",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],xo={home:"network",https:"lock",acme:"file"};function pa(n,e){let o=n.st,r=e?.pkgs??{},a=Ms.filter(d=>d.feature==="home"?o.home:o.portal),i=async(d,p,u=d)=>{await se(`Update ${p}?`,`${u.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${d.join(",")}`,`Updating ${p}`)},s=[{label:"Check system packages",ic:"refresh",run:()=>n.op("check:packages","Checking system packages")},{label:"Open the OpenWrt package list",ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:a.map(d=>{let p=d.pkgs.filter(m=>r[m]?.installed),u=[...new Set(p.flatMap(m=>[...r[m]?.latest?[m]:[],...r[m]?.with??[]]))],w=o.needs?.[d.feature]??d.pkgs.filter(m=>!r[m]?.installed),C=p.find(m=>r[m]?.latest),g=p.map(m=>`${m} ${r[m]?.installed??""}`).join(", ");return w.length?n.row(xo[d.feature],d.title,[`${d.optional?"not installed":`missing ${w.join(", ")}`}`],[H("Install",()=>n.op(`pkgs:${w.join(",")}`,`Installing ${d.title}`),d.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))]):e&&u.length?(l++,n.row(xo[d.feature],d.title,C?[`${r[C].installed} → ${r[C].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[H("Update",()=>i(p.filter(m=>r[m]?.latest||r[m]?.with?.length),d.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))])):n.row(xo[d.feature],d.title,[g||d.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:a.length}}var Ts={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function ua(n){let e=n.st,o=a=>{let i=at(a.component??"app"),s=Ts[i]??"Components",l=a.auto?"automatically":"by you",c="ok",d="check",p;if(a.kind==="found")c="accent",d="download",p=[t("b",{},(a.items??[]).join(", ")),` found by ${a.auto?"the automatic check":"a check"}`];else if(a.state==="failed")c="bad",d="x",p=[t("b",{},s),` ${a.kind==="install"?"update":"check"} failed${a.error?` · ${a.error}`:""}`];else{let u=a.from&&a.to&&a.from!==a.to?` ${a.from} → ${a.to}`:a.to?` ${a.to}`:"";p=[t("b",{},s),`${u} ${u?"":"updated "}${l}${a.took?` · ${vt(a.took)}`:""}`.replace(/\s+/g," ")]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${c}`},b(d)),t("span",{class:"dl-row-main"},p),t("span",{class:"dl-faint dl-nowrap",title:new Date(a.ts*1e3).toLocaleString()},re(a.ts,e.now))])},r=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),r.length?t("div",{},r.slice(0,8).map(o)):t("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var Hn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null}load(){return A.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await A.updatesStatus().catch(()=>null);if(!o)return;let r=this.st;this.st=o,o.job?.state==="running"&&this.following!=="starting"&&o.job.id!==this.following&&this.follow(o.job),(o.job?.id!==r.job?.id||o.job?.state!==r.job?.state||o.job?.phase!==r.job?.phase||o.check?.time!==r.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await A.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,o,r){if(this.busy||this.following==="starting"){U("Another component action is already running","warning");return}this.following="starting",this.paint();let a=at(e),i=await Jt(e,{title:o,version:r,onJob:s=>this.following=s.id,onDone:s=>this.refresh(s),onUpdate:s=>{let l=s.check?.components??{};a==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,"Updating AmneziaWG",l.amneziawg.installed??void 0):this.op("app","Updating Dawnline",this.st.version)}});this.following==="starting"&&(this.following=i?.id??null),this.refresh()}async follow(e){this.following=e.id;let o=En(e),r={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[o]??"components";await Jt(null,{title:`${e.action==="check"?"Checking":e.auto?"Automatic update:":"Updating"} ${r}`,onDone:a=>this.refresh(a)},e)}paint(){let e=this.st,o=e.check?.components??{},r=e.firmware,a=pa(this,o.packages),i=(e.needs?.awg??[]).length>0,l=(!i&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+a.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Components"),t("span",{class:"dl-faint"},[r?.version?`OpenWrt ${r.version} · ${r.target}`:"",e.check?`checked ${re(e.check.time,e.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[b("edit")," Settings"]),H([b("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),da(this,o.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Components"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},i?l?`AmneziaWG not installed · ${l} update${l===1?"":"s"}`:"AmneziaWG not installed":!o.amneziawg&&!o.packages?"":l?`${l} of ${1+a.total} need${l===1?"s":""} an update`:"Everything is up to date")]),t("div",{},[...ca(this,o.amneziawg),...a.rows])]),ua(this)])])}state(e,o,r){let a=this.st.job;if(a?.state==="running"){let i=l=>l==="packages"?"pkgs":l,s=a.action==="check"?[i(a.component||"all")]:(a.component??"").split(" ").map(l=>i(at(l)));if(s.includes(e)||s.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:"Show progress",click:()=>this.follow(a)},[a.action==="check"?"Checking":"Updating","…"])}return o?o.error?Ee("warn","Check failed",o.error):o.update?Ee("info","Update available"):o.status==="dev"?Ee("info","Newer than release",`The latest release is ${r}`):Ee("ok","Up to date"):Ee("","Not checked")}more(e){let o=H([b("more")],()=>Ce(o,e.filter((r,a,i)=>r!==null||a>0&&ar?{label:r.label,icon:b(r.ic),warn:r.warn,run:r.run}:null)),"neutral",{title:"More","aria-label":"More"});return o}round(e,o,r=!1){let a=this.busy?" is-busy":"",i;return r?i=H([b("refresh")," Check"],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${a}`,"aria-label":"Check for updates"}):(i=Le("refresh","Check for updates",e,"neutral",a.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),me(i,()=>["Check for updates"])),t("span",{class:"dl-comp-ic"},[i,this.more(o)])}row(e,o,r,a){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},b(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-mono dl-faint dl-comp-sub"},r)]),...a])}};var ma=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function ha(n){let e=n.st.servers.find(o=>o.id===n.p.server)?.name??"Home";_t(n.p,e)}async function fa(n){let e=n.p,o=e.code_set??0,r=e.devices.filter(l=>l.created_by==="portal"&&l.created>=o),a=r.map(l=>t("input",{type:"checkbox",id:`dl-rm-${l.id}`,checked:"checked","data-id":l.id})),i=[t("p",{},"The old link stops working right away.")];r.length&&i.push(t("p",{},"Devices added through the old link keep working until they are removed. Remove them too:"),t("div",{class:"dl-checklist"},r.map((l,c)=>t("label",{for:`dl-rm-${l.id}`},[a[c],` ${l.name}`]))));let s=async()=>{let l=a.filter(d=>d.checked).map(d=>d.dataset.id),c=await W(()=>A.personRegen(e.id,l),l.length?`New link created, ${l.length} device${l.length===1?"":"s"} removed`:"New link created");c&&(oe(),l.length&&await n.refresh(),c.link&&await pe(c.link,"New link copied"))};te("Create a new link?",i,[ae()," ",H("Create new link",s,"negative")])}function wo(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");te("Note",[e],[ae()," ",H("Save",async()=>{oe(),await n.patch({note:e.value.trim()},e.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>e.focus(),50)}function ga(n){let e=n.p,o=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},"Pause access"),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},"Keep access"),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},"Remove their devices")]),r=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(a=>t("option",{value:a,selected:e.expire_warn===a?"selected":null},a?`${a} day${a===1?"":"s"} before`:"Don’t warn")));te("When access ends",[ma("Then",o),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Warn"),t("div",{class:"cbi-value-field"},[r,t("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[ae()," ",H("Save",async()=>{oe(),await n.patch({expire_action:o.value,expire_warn:r.value},"Saved")},"positive")])}function va(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48}),o=ye("Name",e,()=>_e(e.value,[],"Shown in their portal and apps."));te("Rename",[o],[ae()," ",H("Save",async()=>{let r=o.help();if(r.bad){U(r.text,"warning");return}await n.patch({name:e.value.trim()},"Renamed")&&oe()},"positive")]),setTimeout(()=>e.select(),50)}function ba(n){let e=n.p,o=n.st.servers.filter(i=>i.id!==e.server),r=t("select",{class:"cbi-input-select"},o.map(i=>t("option",{value:i.id},`${i.name} · ${i.endpoint||"no address"}:${i.port}`))),a=e.devices.length;te(`Move ${e.name} to another server`,[ma("Server",r),t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from the personal link or from you). Circles and home networks of the old server are left behind.`:"They have no devices yet: nothing else changes.")],[ae()," ",H("Move",async()=>{await n.patch({server:r.value},`Moved to ${o.find(i=>i.id===r.value)?.name??"the server"}`)&&(oe(),a&&U("Devices are marked “Update config” until they import again.","info",6e3))},"positive")])}async function xa(n){let e=n.p;await se(`Delete ${e.name}?`,`All ${e.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await W(()=>A.personDelete(e.id),"Deleted")&&(location.href=St(e.server))}function wa(n){let e=n.p,o=n.st,r=e.online?"online now":e.last_seen?`last seen ${re(e.last_seen,o.now)}`:"never connected",a=e.created?`Added ${Me(je(new Date(e.created*1e3)))}`:"",i=e.has_link??o.settings.portal_enabled,s=[{label:"Rename",icon:b("edit"),run:()=>va(n)},{label:e.note?"Edit note":"Add note",icon:b("file"),run:()=>wo(n)},...o.servers.length>1?[{label:"Move to server…",icon:b("server"),run:()=>ba(n)}]:[],...i?[null,{label:"Invite card",icon:b("qr"),run:()=>ha(n)},{label:"New link",icon:b("key"),run:()=>fa(n)}]:[],null,...e.paused?[]:[{label:"Pause",icon:b("pause"),warn:!0,run:()=>n.patch({paused:!0},"Paused")}],{label:"Delete",icon:b("trash"),danger:!0,run:()=>xa(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},He(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),Do(e)]),t("span",{class:"dl-faint",title:a},`${e.devices.length} of ${e.device_limit} devices · ${r}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?H([b("play")," Resume"],()=>n.patch({paused:!1},"Resumed"),"add"):"",i?Le("link","Copy link",()=>wn(e.id),"neutral","dl-icon-only"):"",Le("more","More",l=>Ce(l.currentTarget,s),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>wo(n)},[b("file"),t("span",{},e.note)]):""])}function ya(n){let e=n.p,o=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?Tn(e.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",Sn(n.series,`${X(e.month[0]+e.month[1])} this month`)])}async function Ss(n,e){let o=await W(()=>A.deviceConfig(e.id));o&&te(`Set up ${e.name}`,[await n.core.connectBlock(o,"qr")],[ae("Close")])}async function _s(n,e){let o=await W(()=>A.deviceConfig(e.id));if(!o)return;if(!o.has_private_key){U("This device made its own keys in the browser; its configuration only exists there.","warning");return}let r=n.core.file.make(o);Se(r.name,r.text,"application/octet-stream")}function ka(n){let e=n.p,o=n.st.now,r=c=>We(e,c,n.deviceOpts()),a=c=>d=>{d.target.closest("button:not(.dl-dcard-title), a")||r(c)},i=c=>H([b("more")],d=>kr(d.currentTarget,e,c,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=tn(e.devices).map(c=>{let d=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},b(c.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>r(c)},[t("b",{},c.name),nn(c,o,void 0,e),c.config_stale?t("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(c)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},X(c.month[0]+c.month[1])),t("span",{class:"dl-sub"},"this month")]),Gr(n.devSeries[c.id]??[])]);return t("article",{class:`dl-dcard clickable${c.online?" online":""}${c.disabled?" off":""}`,click:a(c)},[d,c.handshake?p:c.disabled?t("div",{class:"dl-sub"},`${Ze[c.kind]} · created ${re(c.created,o)} ${c.created_by==="portal"?"in the portal":"by you"}.`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>Ss(n,c)},[b("qr"),"Show QR"]),t("button",{type:"button",class:"dl-chipbtn",click:()=>_s(n,c)},[b("download"),"Config"])])])}),l=e.devices.length>=e.device_limit;return s.push(t("button",{type:"button",class:"dl-dslot add",click:()=>nt(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},b("plus")),t("span",{class:"dl-stack"},[t("b",{},"Add device"),t("span",{class:"dl-sub"},l?`Over the limit · ${e.devices.length} of ${e.device_limit}`:`${e.devices.length} of ${e.device_limit}`)])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Devices"),t("span",{class:"dl-sub"},`${e.online} online`)]),t("div",{class:"dl-dgrid"},s)])}function $a(n){let e=n.p,o=we([["device","Device’s own DNS"],["home","Home names"]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:a=>n.patch({dns_mode:a},a==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")}),r=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),o]),t("span",{class:"dl-sub"},e.dns_mode==="home"?["Names like ",t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",r?[" (",t("span",{class:"dl-mono"},r)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}function Ca(n){let e=n.p,r=n.st.servers.find(i=>i.id===e.server)?.home??[];if(r.length<2)return"";let a=new Set(e.home_nets?.length?e.home_nets:r.map(i=>i.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},r.map(i=>qe(i.dev,a.has(i.dev),()=>{let s=new Set(a);if(s.delete(i.dev)||s.add(i.dev),!s.size)return U("Keep at least one network, or choose Internet only.","warning",5e3);let l=s.size===r.length?[]:[...s];n.patch({home_nets:l},l.length?`${e.name} reaches ${l.join(", ")}`:`${e.name} reaches every home network`)},{title:i.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?`Home networks ${e.name} reaches. Networks added to the server later stay out.`:`Home networks ${e.name} reaches: all of them. Untick one to keep ${e.name} out of it.`)])}function Ea(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(o=>qe(o.name,e.has(o.id),()=>{let r=new Set(e);r.delete(o.id)||r.add(o.id),n.patch({services:[...r]},r.size?"Home services updated":"Whole home network")},{title:`${o.address}${o.ports.length?` · ${o.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function La(n){let e=n.p,o=n.st;if(o.servers.find(d=>d.id===e.server)?.mesh!=="circles"||!rt(e))return"";let a=o.circles.filter(d=>d.server===e.server),i=a.find(d=>d.id===e.circle),s=i?o.people.filter(d=>d.id!==e.id&&d.circle===i.id&&rt(d)).map(d=>d.name):[],l=t("button",{type:"button",class:"dl-chipbtn",click:()=>Ce(l,[...a.map(d=>({label:d.name,icon:uo(d),run:()=>d.id!==e.circle&&n.patch({circle:d.id},`${e.name} is in ${d.name}`)})),e.circle?{label:"No circle",icon:b("x"),run:()=>n.patch({circle:""},`${e.name} is in no circle`)}:null,{label:"New circle",icon:b("plus"),run:()=>$n(o,e.server,null,()=>n.refresh())}])},"Change"),c=i?o.people.filter(d=>d.circle===i.id&&rt(d)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Devices see each other"),l]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},i?i.name:"No circle"),t("span",{class:"dl-avstack",title:c.map(d=>d.name).join(", ")},c.slice(0,5).map(d=>t("span",{class:"dl-avatar sm"},He(d.name))))]),t("span",{class:"dl-sub"},i?s.length?[e.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${e.name}'s own devices`)])}function Ma(n){let e=n.p,o=n.st.now,r=t("div",{class:"dl-slots"});for(let s=0;s=e.device_limit,d=t("i",{class:c?"over":l?"used":""});me(d,()=>[t("div",{class:"dl-tip-title"},l?`${l.name}${c?" · over the limit":""}`:"Free slot"),t("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${re(l.handshake,o)}`:"Not set up yet":"They can add a device here")]),r.appendChild(d)}let a=Math.max(1,e.devices.length),i=t("button",{type:"button","aria-label":"Allow fewer devices",disabled:e.device_limit<=a?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=a&&e.devices.length>1&&me(i,()=>[t("div",{class:"dl-tip-title"},`${e.devices.length} devices in use`),t("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},"Devices"),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[i,t("button",{type:"button","aria-label":"Allow more devices",disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),r])}var Ps={internet:"Browse the internet through your router. No access to devices at home, and home cannot reach theirs.",lan:"Reach devices at home, and home reaches theirs. Internet stays on their own connection.",both:"Home devices and the internet, all through your router. Home reaches their devices too."},Ta=/^([01]\d|2[0-3]):[0-5]\d$/;function Ds(n){let e=n.p,o=n.today,r=Ve(e.expires,o),a=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});a.addEventListener("change",()=>a.value&&n.patch({expires:a.value},`Access until ${Me(a.value)}`));let i=(d,p)=>{let u=So(e.expires&&(r??-1)>=0?e.expires:"",d,p,o);n.patch({expires:u},`Access until ${Me(u)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([d,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>i(d,p)},u)),l=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{a.focus({preventScroll:!0});try{a.showPicker()}catch{}}},[b("calendar"),e.expires?Me(e.expires):"Date"]),a]),c={pause:"pause access",notify:"keep access",remove:"remove their devices"}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Access ends"),e.expires?t("span",{class:r!=null&&r<0?"dl-bad":Ye(e,r)?"dl-warn":"dl-ok"},r!=null&&r<0?"ended":`${r} day${r===1?"":"s"} left`):t("span",{class:"dl-faint"},"no end date")]),t("div",{class:"dl-chips-row"},[...s,l,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`When it ends: ${c}${e.expire_warn?`, warn ${e.expire_warn} day${e.expire_warn===1?"":"s"} before`:""}`),t("a",{href:"#",click:d=>{d.preventDefault(),ga(n)}},"Change")])])}function As(n){let e=n.p,o=e.quota_used||e.month[0]+e.month[1],r=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,a=t("div",{class:`dl-meter${r>=100?" bad":r>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:"Alert at 90%"}):""]);a.firstChild.style.width=`${r}%`,e.quota_limit&&me(a,()=>[t("div",{class:"dl-tip-title"},`${r.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${X(e.quota_used)} of ${X(e.quota_limit)} · ${X(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},"Alert at 90%")]);let i=we([["month","Monthly"],["total","Total"]],e.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=t("input",{type:"number",class:"cbi-input-text dl-w-port",min:0,step:"any",value:e.quota_gb?String(e.quota_gb):""}),c=ye("Data limit (GB)",l,()=>ln(l.value,e.quota_period==="month"));te("Data limit",[c],[ae()," ",H("Save",async()=>{let d=c.help();if(d.bad){U(d.text,"warning");return}let p=l.value.trim();await n.patch({quota_gb:p},p&&Number(p)>0?`Data limit ${p} GB`:"No data limit")&&oe()},"positive")]),setTimeout(()=>l.select(),50)}},"Custom")),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Data"),i]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[X(o),e.quota_limit?t("span",{class:"dl-faint"},` of ${X(e.quota_limit)}`):t("span",{class:"dl-faint"}," · no limit")]),e.quota_period==="month"?t("span",{class:"dl-sub"},"resets on the 1st"):""]),e.quota_limit?a:"",t("div",{class:"dl-chips-row"},s),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?`Includes +${e.bonus_gb} GB extra this month`:"Need a little more this month?"),t("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`${X(e.total[0]+e.total[1])} in total`),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Lt("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function Hs(n){let e=n.p,o=!!e.hours,[r,a]=(e.hours||"07:00-23:00").split("-"),i=t("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":"From"}),s=t("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"To"}),l=t("div",{class:"dl-tile2-row"},[i,t("span",{class:"dl-faint"},"to"),s]),c=()=>{let w=`${i.value}-${s.value}`;if(w!==e.hours){if(!Ta.test(i.value)||!Ta.test(s.value))return U("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return U("The start and the end must differ.","warning");n.patch({hours:w},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",w=>{l.contains(w.relatedTarget)||c()});for(let w of[i,s])w.addEventListener("keydown",C=>{C.key==="Enter"&&(C.preventDefault(),c())});let d=t("button",{type:"button",role:"switch","aria-checked":o?"true":"false",class:`dl-switch${o?" on":""}`,"aria-label":"Limit hours",click:()=>{if(o)return n.patch({hours:""},"Any time");d.classList.add("on"),d.setAttribute("aria-checked","true"),p.textContent="Set the hours, then press Enter",u.appendChild(l),i.focus()}},t("i")),p=t("span",{},o?`${r} – ${a} (router time)`:"Any time"),u=t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},"Allowed hours"),p]),d]),o?l:""]);return u}function Sa(n){let e=n.p,o=we(["internet","lan","both"].map(r=>[r,[b(r==="internet"?"globe":r==="lan"?"home":"shield"),r==="internet"?"Internet":r==="lan"?"Home":"Both"]]),e.access,{label:"Access",cls:"wide",optimistic:!1,onChange:r=>n.patch({access:r},`Access: ${dt[r]}`)});return t("section",{class:"dl-devsec","aria-label":"Access and limits"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Access & limits")]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},"Can reach"),o,t("span",{class:"dl-sub"},Ps[e.access]),e.access==="lan"&&n.st.services.length?Ea(n):"",rt(e)?Ca(n):"",e.access==="lan"?$a(n):""]),t("div",{class:"dl-tiles2"},[Ma(n),La(n),Ds(n),As(n),Hs(n)])])])}function zs(n){let e=n.st,o=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Locations"),t("span",{class:"dl-spacer"}),e.geo.enabled?Tt("30d",a=>n.map?.setRange(a),!1):"",H("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let r=new tt({openPerson:()=>{},openDevice:(a,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&We(n.p,s,n.deviceOpts())}},"30d",280);return n.map=r,requestAnimationFrame(()=>r.mount(n.mapData())),t("div",{class:"dl-panel flush"},[o,r.el])}function _a(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[b("pin"),t("div",{class:"dl-stack"},[t("span",{},"Locations are off"),t("span",{class:"dl-sub"},"City-level, from the client IP")]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:zs(n);let o=e.now-30*86400,r=e.geo.points.filter(s=>s.person===n.p.id&&s.ts>=o).sort((s,l)=>l.ts-s.ts),a=[...new Set(r.map(s=>s.city||s.country).filter(Boolean))],i=r[0];return t("div",{class:"dl-places"},[b("pin"),t("div",{class:"dl-stack"},[t("span",{},i?i.city||i.country:"No locations yet"),t("span",{class:"dl-sub"},i?`${a.length} place${a.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),t("span",{class:"dl-spacer"}),r.length?H("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function Pa(n){let e=n.p,o=n.st,r=n.events.filter(l=>l.person===e.id),a=[],i=[...r].reverse();for(let l=0;l1){let u=p.querySelector(".dl-row-main");dom.content(u,[...ho(o,c).slice(0,3),t("span",{class:"dl-muted"},`${d} times`)]),u.title=i.slice(l,l+d).map(w=>w.detail??"").join(` -`)}a.push(p),l+=d-1}let s=H([b("more")],()=>Ce(s,[{label:"Export CSV",icon:b("download"),run:()=>Fe(o,r,"csv",e.id)},{label:"Export JSON",icon:b("download"),run:()=>Fe(o,r,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:b("trash"),danger:!0,run:()=>et(`Clear ${e.name}'s activity`,`Removes events about ${e.name} and their devices.`,{person:e.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-sub"},r.length>10?`latest 10 of ${r.length}`:""),t("span",{class:"dl-spacer"}),s]),a.length?a:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var zn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,r,a]=await Promise.all([A.status(30),e?A.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?A.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:r?.events??null,use:a}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(s=>s.id===this.id);if(!o)return t("div",{class:"dl-empty"},[t("h3",{},"Person not found"),t("p",{},"They may have been removed."),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let r=t("div",{},[this.parts.crumbs,this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let a=new URLSearchParams(location.search),i=a.get("device")&&o.devices.find(s=>s.id===a.get("device"));return i?setTimeout(()=>We(this.p,i,this.deviceOpts()),50):a.get("add")&&setTimeout(()=>nt(this.p,this.deviceOpts()),50),this.poller=ot({fetch:s=>{let l=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>r.isConnected,apply:(s,l)=>this.apply(s,l)}),r}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let r=this.st.people.find(a=>a.id===this.id);if(!r){o||(location.href=St(this.p?.server));return}this.p=r,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var i;this.poller?.claim();let r=await W(()=>A.personUpdate(this.p.id,e),o);if(!r)return!1;this.poller?.claim();let a=this.st.people.findIndex(s=>s.id===this.p.id);return(i=r.person).rate??(i.rate=this.p.rate),a>=0&&(this.st.people[a]=r.person),this.p=r.person,this.paint(),!0}get today(){return Ie(this.series.length?this.series:this.st.series)}get core(){return Mt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:St(e.server)},this.st.servers.find(o=>o.id===e.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:St(e.server)},"People"),t("span",{},"/"),t("span",{},e.name)])}paint(e=!1){Te(this.parts.crumbs,this.crumbs(),e),Te(this.parts.head,wa(this),e),Te(this.parts.traffic,ya(this),e),Te(this.parts.devices,ka(this),e),Te(this.parts.limits,Sa(this),e),this.paintPlaces(e),Te(this.parts.activity,Pa(this),e)}paintPlaces(e=!1){let o=_a(this);o&&Te(this.parts.places,o,e&&!this.mapOpen)}};var Ns={ok:"check",warn:"alert",error:"x",skip:"pause"},Nn=class{constructor(e,o,r,a){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=r,this.toLog=a,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,r)}async run(e){let o=e?await _n(e):await A.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks")]),t("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=e.filter(s=>s.status==="error").length,r=e.filter(s=>s.status==="warn").length;dom.content(this.summary,o?ct("error",`${o} problem${o>1?"s":""} need attention.`):r?ct("warn",`${r} warning${r>1?"s":""}.`):ct("ok","All checks passed."));let a=new Map;for(let s of this.sl.watchdog.repairs)a.set(s.id,Math.max(a.get(s.id)??0,s.ts));let i=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks"),t("span",{class:"dl-spacer"}),H("Run again",i)]),t("ul",{class:"dl-checks"},e.map(s=>t("li",{},[t("span",{class:`dl-check-icon ${s.status}`},b(Ns[s.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},s.title),t("div",{class:"dl-check-detail"},s.detail),a.has(s.id)?t("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${zt(a.get(s.id))}`):""]),fo(s,l=>void this.run(l),i)])))])}paintLive(e,o){this.sl=e,this.events=o;let r=e.watchdog,a=r.beat!=null&&r.now-r.beat>180,i=r.repairs.filter(c=>r.now-c.ts<86400),s=i[i.length-1],l=ve(r.enabled,"Watchdog repairs",async c=>{await W(()=>A.settingsUpdate({watchdog:c?"1":"0"}),c?"Watchdog on":"Watchdog off")||Qn(l,!c);let p=await A.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${r.enabled?"":" off"}`},b("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},"Watchdog"),t("span",{class:"dl-sub"},r.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),t("span",{class:"dl-spacer"}),l]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},r.targets.map(c=>t("span",{class:`dl-check-chip${c.ok?"":" error"}`,title:c.ok?"OK":`Not working${c.tries?` · ${c.tries} repair${c.tries>1?"s":""}`:""}`},[b(c.ok?"check":"x"),c.name]))),t("span",{class:`dl-sub${a?" dl-warn-text":""}`},a?`The agent has not checked in for ${Math.round((r.now-r.beat)/60)} min; cron restarts it after 5.`:[r.last?`Looked ${re(r.last,r.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${zt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,o=[...this.events.map(a=>({ts:a.ts,ev:a})),...this.sl.log.map(a=>({ts:a.ts,sys:a}))].filter(a=>a.ts>=e&&dn(a)).sort((a,i)=>i.ts-a.ts),r=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Recent problems"),t("span",{class:"dl-spacer"}),o.length?t("a",{href:"#",click:a=>(a.preventDefault(),this.toLog())},"All in Log →"):""]);if(!o.length){dom.content(this.recentEl,[r,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},b("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[r,...o.slice(0,8).map(a=>{if(a.sys){let i=a.sys,s=`${i.ts}|${i.msg}`;return Mn(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},zt(i.ts))}return it(this.st,a.ev,{time:zt(a.ts)})})])}};var Rn=300,Rs=["all","connections","people","system","problems"],In=class{constructor(e,o,r){this.events=[];this.system=[];this.kind="all";this.shown=Rn;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(o),this.system=r,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,o=i=>()=>{let s=this.filtered().reverse();Fe(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,e(),s.filter(l=>l.sys).map(l=>l.sys))},r=H([b("download")," Export"],()=>Ce(r,[{label:"CSV (spreadsheet)",icon:b("download"),run:o("csv")},{label:"JSON",icon:b("download"),run:o("json")}])),a=H([b("trash")," Clear"],()=>et("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[r,a]}take(e){this.events=e.events,this.policy=e.policy;let o=Et.filter(r=>!e.policy.categories.includes(r));this.sub=`${cn(e.policy)}${o.length?` Not recorded: ${o.map(r=>pt[r].toLowerCase()).join(", ")}.`:""}`}async reload(){let[e,o]=await Promise.all([A.events(2e4).catch(()=>null),A.serviceLog().catch(()=>null)]);e&&this.take(e),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,o)=>o.ts-e.ts)}matches(e,o){return o==="all"?!0:o==="problems"?dn(e):o==="system"?!!e.sys:!!e.ev&&Bt(e.ev.type)===o}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,Rs.map(o=>t("button",{type:"button",role:"tab",class:o===this.kind?"on":"","aria-selected":o===this.kind?"true":"false",click:()=>this.show(o)},[o==="all"?"All":o==="system"?"System":pt[o],t("b",{},String(e.filter(r=>this.matches(r,o)).length))])))}show(e){this.kind=e,this.shown=Rn,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let o=[],r="",a=null;for(let i of e.slice(0,this.shown)){let s=Wr(i.ts);s!==r&&(r=s,a=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},s))),o.push(a));let l=new Date(i.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(i.sys){let c=`${i.sys.ts}|${i.sys.msg}`;a.appendChild(Mn(i.sys,this.open.has(c),()=>{this.open.delete(c)||this.open.add(c),this.paint()},l))}else a.appendChild(it(this.st,i.ev,{time:l}))}e.length>this.shown&&o.push(t("div",{class:"dl-more-row"},H(`Show ${Math.min(Rn,e.length-this.shown)} more of ${e.length-this.shown}`,()=>{this.shown+=Rn,this.paint()}))),dom.content(this.list,o)}};var Is=[["health","Health"],["log","Log"]],yo=2e4,Bn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([A.status(1),A.events(yo),A.serviceLog()])}render([e,o,r]){return this.log=new In(e,o,r.log),this.health=new Nn(e,r,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),ot({fetch:async()=>{let a=this.tab==="log",[i,s]=await Promise.all([A.serviceLog().catch(()=>null),a?A.events(yo).catch(()=>null):Promise.resolve(null)]);return i||s?{n:i,e:s}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:a,e:i})=>this.take(a,i)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,o){o&&(this.log.take(o),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,Is.map(([o,r])=>t("button",{type:"button",role:"tab",class:o===e?"on":"","aria-selected":o===e?"true":"false",click:()=>o!==this.tab&&this.show(o)},r))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&A.events(yo).then(o=>this.take(null,o)).catch(()=>null)):this.health.checks||this.health.run()}};var Da=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var Aa='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;box-shadow:inset 0 0 0 1px var(--dl-line);color:var(--dl-fg-muted);aspect-ratio:1;padding:0;justify-content:center}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}.dl-people-find{width:160px;min-width:0}.dl-people-find[hidden]{display:none}';var Ha="#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-warn{color:var(--dl-warn)}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}";var za=".dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}";var Na=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-6.5px;bottom:-6.5px;width:20px;height:20px;border-radius:8.5px;border:1.5px solid transparent;background:var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p:hover .dl-onl-dev{background:linear-gradient(var(--dl-soft),var(--dl-soft)),var(--dl-card)}.dl-onl-p.sm:hover{background:none}.dl-onl-p.sm:hover .dl-onl-dev{background:var(--dl-card)}.dl-onl-p.sm .dl-onl-av{transition:box-shadow .15s ease}.dl-onl-p.sm:hover .dl-onl-av{box-shadow:0 0 0 2px var(--dl-ok),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm.more:hover .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-speed-val.off{color:var(--dl-fg-faint)}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var Ra='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-modal .cbi-value.dl-live>.cbi-value-title{display:flex;flex-direction:column;gap:2px;text-align:left}.dl-modal .cbi-value.dl-live>.cbi-value-title>.dl-sub{white-space:normal}.dl-checklist{display:flex;flex-direction:column;gap:6px;margin:4px 0 8px}.dl-checklist label{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer}.dl-checklist input{margin:0}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var Ia=".dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#fff;padding:8px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}";var Ba=".dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}.dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}";var Oa=".dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}";var ja=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-badge:has(>svg:only-child){width:16px;min-width:0;padding:0}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged,.dl-mk.piled{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*,.dl-mk.piled>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host{transition:border-radius .22s ease,border-right-color .22s ease}.dl-mk-host.docked{border-top-right-radius:0;border-bottom-right-radius:0;border-right-color:transparent}.dl-mk-dock{position:absolute;left:100%;top:-1px;height:40px;box-sizing:border-box;display:flex;align-items:center;gap:6px;padding:0 10px 0 2px;border:1px solid var(--dl-line);border-left:0;border-radius:0 11px 11px 0;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;pointer-events:none;opacity:0;clip-path:inset(-24px 100% -24px 0);transition:clip-path .28s cubic-bezier(.2,.8,.2,1),opacity .2s ease}.dl-mk-host.docked .dl-mk-dock{pointer-events:auto;opacity:1;clip-path:inset(-24px -24px -24px 0)}.dl-mk-new .dl-mk-host,.dl-mk-new .dl-mk-dock{transition:none}.dl-mk-pile{position:relative;display:flex;justify-content:center}.dl-mk-pile-box{box-sizing:border-box;height:40px;display:flex;align-items:center;gap:6px;padding:0 10px 0 6px;border-radius:20px;cursor:zoom-in;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;animation:dl-plate-in .26s cubic-bezier(.2,.8,.2,1) both;transition:opacity .18s ease,transform .18s ease}.dl-mk-pile.out{pointer-events:none}.dl-mk-pile.out>*{opacity:0;transform:scale(.85);transition:opacity .18s ease,transform .18s ease}@keyframes dl-plate-in{0%{opacity:0;transform:scale(.85)}}.dl-mk-face{all:unset;position:relative;display:flex;cursor:pointer;transition:transform .18s ease,opacity .18s ease}.dl-mk-face>.dl-mk-badge{position:relative;left:auto;bottom:-8px;margin-left:-12px;align-self:center}.dl-mk-face.on .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-face.on .dl-mk-badge{background:#3b82f6}.dl-mk-face:hover .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-face.in{animation:dl-dock-in .24s cubic-bezier(.2,.8,.2,1) both}.dl-mk-face.out{transform:scale(.4);opacity:0;pointer-events:none}@keyframes dl-dock-in{0%{transform:scale(.4);opacity:0}}.dl-mk-more{font-size:11px;font-weight:600;color:var(--dl-fg-muted)}.dl-mk-av,.dl-mk-tile{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1)}.dl-mk.merged .dl-mk-av,.dl-mk.merged .dl-mk-tile,.dl-mk.piled .dl-mk-av{transform:scale(.5)}.dl-mk-host,.dl-mk-dock,.dl-mk-pile-box{transition-property:border-radius,border-right-color,clip-path,opacity,height,width,padding,gap}.dl-mk-dock,.dl-mk-pile-box{transition-duration:.22s;transition-timing-function:cubic-bezier(.2,.8,.2,1)}.dl-mk-pile-box{position:relative}.dl-mk-more{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease}.dl-mk-more.in{animation:dl-dock-in .24s ease both}.dl-mk-more.out{transform:scale(.4);opacity:0}.dl-mk-face .dl-mk-av{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1),width .2s ease,height .2s ease,font-size .2s ease}.dl-mk-face{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,margin .2s ease}.dl-mk-face>.dl-mk-badge{max-width:48px;overflow:hidden;transition:opacity .2s ease,transform .2s ease,max-width .22s ease,margin .22s ease,padding .22s ease,border-width .22s ease,height .22s ease,min-width .22s ease,width .22s ease,bottom .22s ease}.dl-lod-far .dl-mk-host{width:32px;height:32px;border-radius:9px}.dl-lod-far .dl-mk-host.docked{border-radius:9px 0 0 9px}.dl-lod-far .dl-mk-host-tile{width:20px;height:20px;border-radius:6px}.dl-lod-far .dl-mk-host-ic{width:11px;height:11px}.dl-lod-far .dl-mk-dock{height:32px;gap:0;padding:0 4px 0 0;border-radius:0 9px 9px 0}.dl-lod-far .dl-mk-pile-box{height:32px;gap:0;padding:0 4px;border-radius:16px}.dl-lod-far .dl-mk-face+.dl-mk-face{margin-left:-6px}.dl-lod-far .dl-mk-face .dl-mk-av{width:22px;height:22px;font-size:8px;box-shadow:0 0 0 2px var(--dl-elevated)}.dl-lod-far .dl-mk-face>.dl-mk-badge{max-width:0;min-width:0;padding:0;margin-left:0;border-width:0;opacity:0;transform:scale(.5);pointer-events:none}.dl-lod-far .dl-mk-more{margin-left:4px;font-size:10px}.dl-mk-label{transition:opacity .2s ease}.dl-lod-far .dl-mk-label{opacity:0}.dl-lod-mid .dl-mk-host{width:36px;height:36px}.dl-lod-mid .dl-mk-dock,.dl-lod-mid .dl-mk-pile-box{height:36px}.dl-lod-mid .dl-mk-face .dl-mk-av{width:24px;height:24px;font-size:9px}.dl-lod-mid .dl-mk-face>.dl-mk-badge{height:12px;min-width:12px;margin-left:-10px;bottom:-7px}.dl-lod-mid .dl-mk-face>.dl-mk-badge:has(>svg:only-child){width:12px}.dl-lod-mid .dl-mk-face>.dl-mk-badge .dl-mk-badge-ic{width:8px;height:8px}@media(prefers-reduced-motion:reduce){.dl-mk-dock,.dl-mk-pile-box,.dl-mk-face,.dl-mk-av,.dl-mk-tile,.dl-mk-host,.dl-mk-face>.dl-mk-badge{transition:none;animation:none}}.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host{cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}`;var Ua=`.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}`;var Wa=".dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";var Ga=".dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-bad{color:var(--dl-bad)}";var Fa=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var qa=".dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var el=[Da,Aa,Ha,za,Na,Ra,Ia,Ba,Oa,ja,Ua,Wa,Ga,Fa,qa].join(` -`);function Ka(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=el,n}function mt(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async r=>{let a=await e.render(r),i=document.createElement("div");return i.className="dl-root",i.append(Ka(),a),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var Iv=mt(Yt),Bv=mt(ut),Ov=mt(Yt),jv=mt(Dn),Uv=mt(zn),Wv=mt(Bn),Gv=mt(Hn);function Ja(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var Fv=Ja(""),qv=Ja("log");return baseclass.extend({ activity: qv, diagnostics: Wv, health: Fv, overview: Iv, people: Bv, person: Uv, server: Ov, settings: jv, updates: Gv }); +`).trim()}async function Qt(n,e,r,o){let a=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";oe(r,[i,a],[H([b("copy")," Copy"],()=>ue(s,"Release notes copied"))," ",ie("Close")],"wide");try{let l=await A.updatesNotes(n,e,o??"");s=Sa(l.body||"");let d=La(l.url);dom.content(i,[l.published?t("span",{class:"dl-pill"},Ue(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),d?t("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",b("open")]):""]),dom.content(a,s.trim()?Ma(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(a,t("p",{class:"dl-muted"},be(l)))}}var Ta={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Co=n=>n?Ue(n):"";function Vs(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function Pa(n,e){let r=n.st,o=r.policy,a=r.kept?.app,i=e?.update&&e.tag?e.tag:r.version,s=x=>()=>Qt("app",x,`What’s new in Dawnline ${x.replace(/^v/,"")}`),l=e?.tag&&(e.update||e.status==="latest")?Js(n,e.tag,e.update?r.version:""):null,d=e?.tag??i,c=o.check&&r.auto?.check?r.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[o.interval]??24)*3600:0,p=(x,$)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},x),t("span",{class:"dl-comp-side-v"},$)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${r.repo}`,"_blank","noopener")},null,{label:`Reinstall ${r.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",r.version)},a?{label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await le(`Roll back to Dawnline ${a.version}?`,`The copy kept on the router replaces ${r.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",r.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},b("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",r.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[r.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 ${Co(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${Co(e.published)}`:""}`:"not checked yet")])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(x=>t("li",{},x))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(d)},`+${l.total-l.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[H("Update now",()=>n.op("app","Updating Dawnline",r.version),"positive",{disabled:n.busy}),H("What’s new",s(i))]):"",Ys(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[b("globe"),t("a",{href:`https://github.com/${r.repo}`,target:"_blank",rel:"noopener"},r.repo)]),p("Auto-update",[o.auto?Ee("ok","On"):Ee("","Off"),t("span",{class:"dl-muted"},o.auto?o.mode==="immediate"?"as soon as found":`${Ta[o.interval]==="weekly"?"weekly":"daily"} at ${o.time}`:o.check?`checks ${Ta[o.interval]}`:"checks off")]),p("Last check",r.check?[re(r.check.time,r.now),c>r.now?t("span",{class:"dl-faint"},`· next in ${xt(c-r.now)}`):""]:["Never"]),p("Rollback",a?[t("span",{class:"dl-mono"},a.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},o.keep?"Kept after the next update":"Off")])])])}function Js(n,e,r){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let o=a=>a.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await A.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` +`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await A.updatesChanges(r,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>Vs(o(l))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Ys(n){let e=t("div",{class:"dl-params-body"}),r=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[b("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return r.addEventListener("toggle",()=>{n.versOpen=r.open,n.versOpen&&zn(n,e)}),n.versOpen&&zn(n,e),r}async function zn(n,e){let r=se("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),o=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return U("Enter a release tag like 0.3.1","warning");_a(n,p)};r.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),o(r.value))});let a=t("div",{class:"dl-comp-tag"},[r,H("Install",()=>o(r.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),zn(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 →")]),d=n.versCache.get(i);if(!d){dom.content(e,[a,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{d=(await A.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[a,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${be(p)}`),H("Try again",()=>zn(n,e))]),l(!1)]);return}if(n.versCache.set(i,d),i!==n.versPage||!e.isConnected)return}if(!d.length)return dom.content(e,[a,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let c=n.st.version;dom.content(e,[a,...d.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"},Co(p.published)),p.prerelease?Ee("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},Le("file","What’s new",()=>Qt("app",p.tag,`What’s new in Dawnline ${u}`))),u===c?Ee("ok","Installed"):H("Install",()=>_a(n,p.tag),"neutral",{disabled:n.busy})])}),l(d.length>=5)])}async function _a(n,e){let r=e.replace(/^v/,"");r.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await le(`Install Dawnline ${r}?`,`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 ${r}`,n.st.version)}function Da(n,e){let r=n.st,o=r.kept?.amneziawg,a=e?.sources??{},i=Object.keys(a),s=e?.current??null,l=s?a[s]:void 0,d=!!e?.ru,c=r.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}${d?":ru":""}`,"Reinstalling AmneziaWG",p)}),o&&u.push({label:`Roll back to ${o.version}`,ic:"archive",warn:!0,run:async()=>{await le(`Roll back AmneziaWG to ${o.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 x=[e?.release?{label:"What’s new",ic:"file",run:()=>Qt("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((f,g,S)=>f!==null||g>0&&S[g-1]!==null),$=r.tunnels??[],h=$.length?`Switching restarts ${$.length===1?"the tunnel":`${$.length} tunnels`} for a few seconds: ${$.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",m=$.length>1?`${$.slice(0,-1).join(", ")} and ${$[$.length-1]}`:$[0],C=$.length?`Switching restarts ${m} for a few seconds.`:"Switching takes a few seconds.",B=async f=>{let g=a[f];await le(p?`Switch to AmneziaWG ${g.gen}?`:`Install AmneziaWG ${g.gen}?`,`The ${g.label} build, ${g.version}. ${h}${g.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${f}${d?":ru":""}`,p?`Switching to AmneziaWG ${g.gen}`:"Installing AmneziaWG",p??void 0)},w=f=>{let g=a[f],S=s===f&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},g.gen?`AmneziaWG ${g.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${g.label} · ${g.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},g.version??"none yet"),t("span",{class:"dl-comp-bact"},S?Ee("ok","Active"):g.version?H(p?"Switch":"Install",()=>B(f),p?"neutral":"positive",{disabled:n.busy}):Ee("","No build"))])},v=i.map(f=>a[f]?.newer?`${a[f].label} moves to ${a[f].newer.gen} with OpenWrt ${a[f].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),y=ve(d,"Russian translation",f=>{s&&n.op(`amneziawg:${s}${f?":ru":""}`,f?"Adding the Russian translation":"Removing the Russian translation",p??void 0)});y.disabled=!s||!p||n.busy;let E=n.awgOpen??!p,k=t("details",{class:"dl-params dl-comp-fold",open:E?"open":null},[t("summary",{},[b("chevron"),t("span",{},"Build and translation")]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...i.length?i.map(w):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Russian translation"),t("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),t("span",{class:"dl-comp-bact"},y)])]),p&&i.length||v.length?t("div",{class:`dl-comp-status ${p&&i.length?"warn":"acc"}`},[b(p&&i.length?"alert":"download"),t("span",{},[p&&i.length?t("b",{},C):"",...v.map(f=>` ${f}`)])]):""])]);k.addEventListener("toggle",()=>n.awgOpen=k.open);let z=[];return e?.update&&p&&s?z.push(H(`Update to ${e.latest}`,()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Updating AmneziaWG",p),"neutral",{disabled:n.busy})):z.push((e||c.length)&&!p?Ee("warn","Not installed"):n.state("amneziawg",e,e?.latest??"")),z.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",p??void 0),x)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${e.release} build`:""}`:c.length?`missing ${c.join(", ")}`:e?"not installed":"version not checked"],z),t("div",{class:"dl-comp-foldwrap"},k)]}var Zs=[{title:"Home-like link",sub:"Policy routing and the veth pair",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"HTTPS for the portal",sub:"OpenSSL for uhttpd",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"Certificates (ACME)",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],Eo={home:"network",https:"lock",acme:"file"};function Aa(n,e){let r=n.st,o=e?.pkgs??{},a=Zs.filter(c=>c.feature==="home"?r.home:r.portal),i=async(c,p,u=c)=>{await le(`Update ${p}?`,`${u.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${c.join(",")}`,`Updating ${p}`)},s=[{label:"Check system packages",ic:"refresh",run:()=>n.op("check:packages","Checking system packages")},{label:"Open the OpenWrt package list",ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:a.map(c=>{let p=c.pkgs.filter(m=>o[m]?.installed),u=[...new Set(p.flatMap(m=>[...o[m]?.latest?[m]:[],...o[m]?.with??[]]))],x=r.needs?.[c.feature]??c.pkgs.filter(m=>!o[m]?.installed),$=p.find(m=>o[m]?.latest),h=p.map(m=>`${m} ${o[m]?.installed??""}`).join(", ");return x.length?n.row(Eo[c.feature],c.title,[`${c.optional?"not installed":`missing ${x.join(", ")}`}`],[H("Install",()=>n.op(`pkgs:${x.join(",")}`,`Installing ${c.title}`),c.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))]):e&&u.length?(l++,n.row(Eo[c.feature],c.title,$?[`${o[$].installed} → ${o[$].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[H("Update",()=>i(p.filter(m=>o[m]?.latest||o[m]?.with?.length),c.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))])):n.row(Eo[c.feature],c.title,[h||c.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:a.length}}var Qs={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function Ha(n){let e=n.st,r=a=>{let i=it(a.component??"app"),s=Qs[i]??"Components",l=a.auto?"automatically":"by you",d="ok",c="check",p;if(a.kind==="found")d="accent",c="download",p=[t("b",{},(a.items??[]).join(", ")),` found by ${a.auto?"the automatic check":"a check"}`];else if(a.state==="failed")d="bad",c="x",p=[t("b",{},s),` ${a.kind==="install"?"update":"check"} failed${a.error?` · ${a.error}`:""}`];else{let u=a.from&&a.to&&a.from!==a.to?` ${a.from} → ${a.to}`:a.to?` ${a.to}`:"";p=[t("b",{},s),`${u} ${u?"":"updated "}${l}${a.took?` · ${xt(a.took)}`:""}`.replace(/\s+/g," ")]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${d}`},b(c)),t("span",{class:"dl-row-main"},p),t("span",{class:"dl-faint dl-nowrap",title:new Date(a.ts*1e3).toLocaleString()},re(a.ts,e.now))])},o=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),o.length?t("div",{},o.slice(0,8).map(r)):t("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var Nn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null}load(){return A.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let r=await A.updatesStatus().catch(()=>null);if(!r)return;let o=this.st;this.st=r,r.job?.state==="running"&&this.following!=="starting"&&r.job.id!==this.following&&this.follow(r.job),(r.job?.id!==o.job?.id||r.job?.state!==o.job?.state||r.job?.phase!==o.job?.phase||r.check?.time!==o.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await A.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,r,o){if(this.busy||this.following==="starting"){U("Another component action is already running","warning");return}this.following="starting",this.paint();let a=it(e),i=await Jt(e,{title:r,version:o,onJob:s=>this.following=s.id,onDone:s=>this.refresh(s),onUpdate:s=>{let l=s.check?.components??{};a==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,"Updating AmneziaWG",l.amneziawg.installed??void 0):this.op("app","Updating Dawnline",this.st.version)}});this.following==="starting"&&(this.following=i?.id??null),this.refresh()}async follow(e){this.following=e.id;let r=Mn(e),o={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[r]??"components";await Jt(null,{title:`${e.action==="check"?"Checking":e.auto?"Automatic update:":"Updating"} ${o}`,onDone:a=>this.refresh(a)},e)}paint(){let e=this.st,r=e.check?.components??{},o=e.firmware,a=Aa(this,r.packages),i=(e.needs?.awg??[]).length>0,l=(!i&&r.amneziawg?.update&&r.amneziawg.installed?1:0)+a.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Components"),t("span",{class:"dl-faint"},[o?.version?`OpenWrt ${o.version} · ${o.target}`:"",e.check?`checked ${re(e.check.time,e.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[b("edit")," Settings"]),H([b("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),Pa(this,r.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Components"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},i?l?`AmneziaWG not installed · ${l} update${l===1?"":"s"}`:"AmneziaWG not installed":!r.amneziawg&&!r.packages?"":l?`${l} of ${1+a.total} need${l===1?"s":""} an update`:"Everything is up to date")]),t("div",{},[...Da(this,r.amneziawg),...a.rows])]),Ha(this)])])}state(e,r,o){let a=this.st.job;if(a?.state==="running"){let i=l=>l==="packages"?"pkgs":l,s=a.action==="check"?[i(a.component||"all")]:(a.component??"").split(" ").map(l=>i(it(l)));if(s.includes(e)||s.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:"Show progress",click:()=>this.follow(a)},[a.action==="check"?"Checking":"Updating","…"])}return r?r.error?Ee("warn","Check failed",r.error):r.update?Ee("info","Update available"):r.status==="dev"?Ee("info","Newer than release",`The latest release is ${o}`):Ee("ok","Up to date"):Ee("","Not checked")}more(e){let r=H([b("more")],()=>Ce(r,e.filter((o,a,i)=>o!==null||a>0&&ao?{label:o.label,icon:b(o.ic),warn:o.warn,run:o.run}:null)),"neutral",{title:"More","aria-label":"More"});return r}round(e,r,o=!1){let a=this.busy?" is-busy":"",i;return o?i=H([b("refresh")," Check"],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${a}`,"aria-label":"Check for updates"}):(i=Le("refresh","Check for updates",e,"neutral",a.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),me(i,()=>["Check for updates"])),t("span",{class:"dl-comp-ic"},[i,this.more(r)])}row(e,r,o,a){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},b(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},r),t("span",{class:"dl-mono dl-faint dl-comp-sub"},o)]),...a])}};var za=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function Na(n){let e=n.st.servers.find(r=>r.id===n.p.server)?.name??"Home";Kt(n.p,e)}async function Ra(n){let e=n.p,r=e.code_set??0,o=e.devices.filter(l=>l.created_by==="portal"&&l.created>=r),a=o.map(l=>t("input",{type:"checkbox",id:`dl-rm-${l.id}`,checked:"checked","data-id":l.id})),i=[t("p",{},"The old link stops working right away.")];o.length&&i.push(t("p",{},"Devices added through the old link keep working until they are removed. Remove them too:"),t("div",{class:"dl-checklist"},o.map((l,d)=>t("label",{for:`dl-rm-${l.id}`},[a[d],` ${l.name}`]))));let s=async()=>{let l=a.filter(c=>c.checked).map(c=>c.dataset.id),d=await G(()=>A.personRegen(e.id,l),l.length?`New link created, ${l.length} device${l.length===1?"":"s"} removed`:"New link created");d&&(ae(),l.length&&await n.refresh(),d.link&&await ue(d.link,"New link copied"))};oe("Create a new link?",i,[ie()," ",H("Create new link",s,"negative")])}function Lo(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");oe("Note",[e],[ie()," ",H("Save",async()=>{ae(),await n.patch({note:e.value.trim()},e.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>e.focus(),50)}function Ia(n){let e=n.p,r=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},"Pause access"),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},"Keep access"),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},"Remove their devices")]),o=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(a=>t("option",{value:a,selected:e.expire_warn===a?"selected":null},a?`${a} day${a===1?"":"s"} before`:"Don’t warn")));oe("When access ends",[za("Then",r),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Warn"),t("div",{class:"cbi-value-field"},[o,t("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[ie()," ",H("Save",async()=>{ae(),await n.patch({expire_action:r.value,expire_warn:o.value},"Saved")},"positive")])}function Ba(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48}),r=ye("Name",e,()=>_e(e.value,[],"Shown in their portal and apps."));oe("Rename",[r],[ie()," ",H("Save",async()=>{let o=r.help();if(o.bad){U(o.text,"warning");return}await n.patch({name:e.value.trim()},"Renamed")&&ae()},"positive")]),setTimeout(()=>e.select(),50)}function Oa(n){let e=n.p,r=n.st.servers.filter(i=>i.id!==e.server),o=t("select",{class:"cbi-input-select"},r.map(i=>t("option",{value:i.id},`${i.name} · ${i.endpoint||"no address"}:${i.port}`))),a=e.devices.length;oe(`Move ${e.name} to another server`,[za("Server",o),t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from the personal link or from you). Circles and home networks of the old server are left behind.`:"They have no devices yet: nothing else changes.")],[ie()," ",H("Move",async()=>{await n.patch({server:o.value},`Moved to ${r.find(i=>i.id===o.value)?.name??"the server"}`)&&(ae(),a&&U("Devices are marked “Update config” until they import again.","info",6e3))},"positive")])}async function ja(n){let e=n.p;await le(`Delete ${e.name}?`,`All ${e.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await G(()=>A.personDelete(e.id),"Deleted")&&(location.href=Pt(e.server))}function Ua(n){let e=n.p,r=n.st,o=e.online?"online now":e.last_seen?`last seen ${re(e.last_seen,r.now)}`:"never connected",a=e.created?`Added ${Me(je(new Date(e.created*1e3)))}`:"",i=e.has_link??r.settings.portal_enabled,s=[{label:"Rename",icon:b("edit"),run:()=>Ba(n)},{label:e.note?"Edit note":"Add note",icon:b("file"),run:()=>Lo(n)},...r.servers.length>1?[{label:"Move to server…",icon:b("server"),run:()=>Oa(n)}]:[],...i?[null,{label:"Invite card",icon:b("qr"),run:()=>Na(n)},{label:"New link",icon:b("key"),run:()=>Ra(n)}]:[],null,...e.paused?[]:[{label:"Pause",icon:b("pause"),warn:!0,run:()=>n.patch({paused:!0},"Paused")}],{label:"Delete",icon:b("trash"),danger:!0,run:()=>ja(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},He(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),Io(e)]),t("span",{class:"dl-faint",title:a},`${e.devices.length} of ${e.device_limit} devices · ${o}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?H([b("play")," Resume"],()=>n.patch({paused:!1},"Resumed"),"add"):"",i?Le("link","Copy link",()=>$n(e.id),"neutral","dl-icon-only"):"",Le("more","More",l=>Ce(l.currentTarget,s),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>Lo(n)},[b("file"),t("span",{},e.note)]):""])}function Ga(n){let e=n.p,r=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?_n(e.rate??[],n.st.now,r?[r.rx,r.tx]:[0,0]):"",Pn(n.series,`${ee(e.month[0]+e.month[1])} this month`)])}async function Xs(n,e){let r=await G(()=>A.deviceConfig(e.id));r&&oe(`Set up ${e.name}`,[await n.core.connectBlock(r,"qr")],[ie("Close")])}async function el(n,e){let r=await G(()=>A.deviceConfig(e.id));if(!r)return;if(!r.has_private_key){U("This device made its own keys in the browser; its configuration only exists there.","warning");return}let o=n.core.file.make(r);Te(o.name,o.text,"application/octet-stream")}function Wa(n){let e=n.p,r=n.st.now,o=d=>Ge(e,d,n.deviceOpts()),a=d=>c=>{c.target.closest("button:not(.dl-dcard-title), a")||o(d)},i=d=>H([b("more")],c=>Wr(c.currentTarget,e,d,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=nn(e.devices).map(d=>{let c=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},b(d.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>o(d)},[t("b",{},d.name),on(d,r,void 0,e),d.config_stale?t("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(d)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},ee(d.month[0]+d.month[1])),t("span",{class:"dl-sub"},"this month")]),ua(n.devSeries[d.id]??[])]);return t("article",{class:`dl-dcard clickable${d.online?" online":""}${d.disabled?" off":""}`,click:a(d)},[c,d.handshake?p:d.disabled?t("div",{class:"dl-sub"},`${Qe[d.kind]} · created ${re(d.created,r)} ${d.created_by==="portal"?"in the portal":"by you"}.`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>Xs(n,d)},[b("qr"),"Show QR"]),t("button",{type:"button",class:"dl-chipbtn",click:()=>el(n,d)},[b("download"),"Config"])])])}),l=e.devices.length>=e.device_limit;return s.push(t("button",{type:"button",class:"dl-dslot add",click:()=>ot(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},b("plus")),t("span",{class:"dl-stack"},[t("b",{},"Add device"),t("span",{class:"dl-sub"},l?`Over the limit · ${e.devices.length} of ${e.device_limit}`:`${e.devices.length} of ${e.device_limit}`)])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Devices"),t("span",{class:"dl-sub"},`${e.online} online`)]),t("div",{class:"dl-dgrid"},s)])}function Fa(n){let e=n.p,r=we([["device","Device’s own DNS"],["home","Home names"]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:a=>n.patch({dns_mode:a},a==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")}),o=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),r]),t("span",{class:"dl-sub"},e.dns_mode==="home"?["Names like ",t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",o?[" (",t("span",{class:"dl-mono"},o)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}function qa(n){let e=n.p,o=n.st.servers.find(i=>i.id===e.server)?.home??[];if(o.length<2)return"";let a=new Set(e.home_nets?.length?e.home_nets:o.map(i=>i.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},o.map(i=>qe(i.dev,a.has(i.dev),()=>{let s=new Set(a);if(s.delete(i.dev)||s.add(i.dev),!s.size)return U("Keep at least one network, or choose Internet only.","warning",5e3);let l=s.size===o.length?[]:[...s];n.patch({home_nets:l},l.length?`${e.name} reaches ${l.join(", ")}`:`${e.name} reaches every home network`)},{title:i.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?`Home networks ${e.name} reaches. Networks added to the server later stay out.`:`Home networks ${e.name} reaches: all of them. Untick one to keep ${e.name} out of it.`)])}function Ka(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(r=>qe(r.name,e.has(r.id),()=>{let o=new Set(e);o.delete(r.id)||o.add(r.id),n.patch({services:[...o]},o.size?"Home services updated":"Whole home network")},{title:`${r.address}${r.ports.length?` · ${r.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function Va(n){let e=n.p,r=n.st;if(r.servers.find(c=>c.id===e.server)?.mesh!=="circles"||!at(e))return"";let a=r.circles.filter(c=>c.server===e.server),i=a.find(c=>c.id===e.circle),s=i?r.people.filter(c=>c.id!==e.id&&c.circle===i.id&&at(c)).map(c=>c.name):[],l=t("button",{type:"button",class:"dl-chipbtn",click:()=>Ce(l,[...a.map(c=>({label:c.name,icon:bo(c),run:()=>c.id!==e.circle&&n.patch({circle:c.id},`${e.name} is in ${c.name}`)})),e.circle?{label:"No circle",icon:b("x"),run:()=>n.patch({circle:""},`${e.name} is in no circle`)}:null,{label:"New circle",icon:b("plus"),run:()=>En(r,e.server,null,()=>n.refresh())}])},"Change"),d=i?r.people.filter(c=>c.circle===i.id&&at(c)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Devices see each other"),l]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},i?i.name:"No circle"),t("span",{class:"dl-avstack",title:d.map(c=>c.name).join(", ")},d.slice(0,5).map(c=>t("span",{class:"dl-avatar sm"},He(c.name))))]),t("span",{class:"dl-sub"},i?s.length?[e.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${e.name}'s own devices`)])}function Ja(n){let e=n.p,r=n.st.now,o=t("div",{class:"dl-slots"});for(let s=0;s=e.device_limit,c=t("i",{class:d?"over":l?"used":""});me(c,()=>[t("div",{class:"dl-tip-title"},l?`${l.name}${d?" · over the limit":""}`:"Free slot"),t("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${re(l.handshake,r)}`:"Not set up yet":"They can add a device here")]),o.appendChild(c)}let a=Math.max(1,e.devices.length),i=t("button",{type:"button","aria-label":"Allow fewer devices",disabled:e.device_limit<=a?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=a&&e.devices.length>1&&me(i,()=>[t("div",{class:"dl-tip-title"},`${e.devices.length} devices in use`),t("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},"Devices"),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[i,t("button",{type:"button","aria-label":"Allow more devices",disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),o])}var tl={internet:"Browse the internet through your router. No access to devices at home, and home cannot reach theirs.",lan:"Reach devices at home, and home reaches theirs. Internet stays on their own connection.",both:"Home devices and the internet, all through your router. Home reaches their devices too."},Ya=/^([01]\d|2[0-3]):[0-5]\d$/;function nl(n){let e=n.p,r=n.today,o=Ye(e.expires,r),a=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});a.addEventListener("change",()=>a.value&&n.patch({expires:a.value},`Access until ${Me(a.value)}`));let i=(c,p)=>{let u=zo(e.expires&&(o??-1)>=0?e.expires:"",c,p,r);n.patch({expires:u},`Access until ${Me(u)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([c,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>i(c,p)},u)),l=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{a.focus({preventScroll:!0});try{a.showPicker()}catch{}}},[b("calendar"),e.expires?Me(e.expires):"Date"]),a]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Access ends"),e.expires?t("span",{class:o!=null&&o<0?"dl-bad":Ze(e,o)?"dl-warn":"dl-ok"},o!=null&&o<0?"ended":`${o} day${o===1?"":"s"} left`):t("span",{class:"dl-faint"},"no end date")]),t("div",{class:"dl-chips-row"},[...s,l,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`When it ends: ${d}${e.expire_warn?`, warn ${e.expire_warn} day${e.expire_warn===1?"":"s"} before`:""}`),t("a",{href:"#",click:c=>{c.preventDefault(),Ia(n)}},"Change")])])}function ol(n){let e=n.p,r=e.quota_used||e.month[0]+e.month[1],o=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,a=t("div",{class:`dl-meter${o>=100?" bad":o>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:"Alert at 90%"}):""]);a.firstChild.style.width=`${o}%`,e.quota_limit&&me(a,()=>[t("div",{class:"dl-tip-title"},`${o.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${ee(e.quota_used)} of ${ee(e.quota_limit)} · ${ee(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},"Alert at 90%")]);let i=we([["month","Monthly"],["total","Total"]],e.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=t("input",{type:"number",class:"cbi-input-text dl-w-port",min:0,step:"any",value:e.quota_gb?String(e.quota_gb):""}),d=ye("Data limit (GB)",l,()=>dn(l.value,e.quota_period==="month"));oe("Data limit",[d],[ie()," ",H("Save",async()=>{let c=d.help();if(c.bad){U(c.text,"warning");return}let p=l.value.trim();await n.patch({quota_gb:p},p&&Number(p)>0?`Data limit ${p} GB`:"No data limit")&&ae()},"positive")]),setTimeout(()=>l.select(),50)}},"Custom")),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Data"),i]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[ee(r),e.quota_limit?t("span",{class:"dl-faint"},` of ${ee(e.quota_limit)}`):t("span",{class:"dl-faint"}," · no limit")]),e.quota_period==="month"?t("span",{class:"dl-sub"},"resets on the 1st"):""]),e.quota_limit?a:"",t("div",{class:"dl-chips-row"},s),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?`Includes +${e.bonus_gb} GB extra this month`:"Need a little more this month?"),t("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`${ee(e.total[0]+e.total[1])} in total`),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>St("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function rl(n){let e=n.p,r=!!e.hours,[o,a]=(e.hours||"07:00-23:00").split("-"),i=t("input",{type:"time",class:"cbi-input-text",value:o,"aria-label":"From"}),s=t("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"To"}),l=t("div",{class:"dl-tile2-row"},[i,t("span",{class:"dl-faint"},"to"),s]),d=()=>{let x=`${i.value}-${s.value}`;if(x!==e.hours){if(!Ya.test(i.value)||!Ya.test(s.value))return U("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return U("The start and the end must differ.","warning");n.patch({hours:x},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",x=>{l.contains(x.relatedTarget)||d()});for(let x of[i,s])x.addEventListener("keydown",$=>{$.key==="Enter"&&($.preventDefault(),d())});let c=t("button",{type:"button",role:"switch","aria-checked":r?"true":"false",class:`dl-switch${r?" on":""}`,"aria-label":"Limit hours",click:()=>{if(r)return n.patch({hours:""},"Any time");c.classList.add("on"),c.setAttribute("aria-checked","true"),p.textContent="Set the hours, then press Enter",u.appendChild(l),i.focus()}},t("i")),p=t("span",{},r?`${o} – ${a} (router time)`:"Any time"),u=t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},"Allowed hours"),p]),c]),r?l:""]);return u}function Za(n){let e=n.p,r=we(["internet","lan","both"].map(o=>[o,[b(o==="internet"?"globe":o==="lan"?"home":"shield"),o==="internet"?"Internet":o==="lan"?"Home":"Both"]]),e.access,{label:"Access",cls:"wide",optimistic:!1,onChange:o=>n.patch({access:o},`Access: ${ct[o]}`)});return t("section",{class:"dl-devsec","aria-label":"Access and limits"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Access & limits")]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},"Can reach"),r,t("span",{class:"dl-sub"},tl[e.access]),e.access==="lan"&&n.st.services.length?Ka(n):"",at(e)?qa(n):"",e.access==="lan"?Fa(n):""]),t("div",{class:"dl-tiles2"},[Ja(n),Va(n),nl(n),ol(n),rl(n)])])])}function al(n){let e=n.st,r=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Locations"),t("span",{class:"dl-spacer"}),e.geo.enabled?_t("30d",a=>n.map?.setRange(a),!1):"",H("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[r,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let o=new nt({openPerson:()=>{},openDevice:(a,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&Ge(n.p,s,n.deviceOpts())}},"30d",280);return n.map=o,requestAnimationFrame(()=>o.mount(n.mapData())),t("div",{class:"dl-panel flush"},[r,o.el])}function Qa(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[b("pin"),t("div",{class:"dl-stack"},[t("span",{},"Locations are off"),t("span",{class:"dl-sub"},"City-level, from the client IP")]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:al(n);let r=e.now-30*86400,o=e.geo.points.filter(s=>s.person===n.p.id&&s.ts>=r).sort((s,l)=>l.ts-s.ts),a=[...new Set(o.map(s=>s.city||s.country).filter(Boolean))],i=o[0];return t("div",{class:"dl-places"},[b("pin"),t("div",{class:"dl-stack"},[t("span",{},i?i.city||i.country:"No locations yet"),t("span",{class:"dl-sub"},i?`${a.length} place${a.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),t("span",{class:"dl-spacer"}),o.length?H("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function Xa(n){let e=n.p,r=n.st,o=n.events.filter(l=>l.person===e.id),a=[],i=[...o].reverse();for(let l=0;l1){let u=p.querySelector(".dl-row-main");dom.content(u,[...wo(r,d).slice(0,3),t("span",{class:"dl-muted"},`${c} times`)]),u.title=i.slice(l,l+c).map(x=>x.detail??"").join(` +`)}a.push(p),l+=c-1}let s=H([b("more")],()=>Ce(s,[{label:"Export CSV",icon:b("download"),run:()=>Fe(r,o,"csv",e.id)},{label:"Export JSON",icon:b("download"),run:()=>Fe(r,o,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:b("trash"),danger:!0,run:()=>tt(`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"},o.length>10?`latest 10 of ${o.length}`:""),t("span",{class:"dl-spacer"}),s]),a.length?a:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var Rn=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[r,o,a]=await Promise.all([A.status(30),e?A.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?A.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:r,ev:o?.events??null,use:a}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let r=this.st.people.find(s=>s.id===this.id);if(!r)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=r;for(let s of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let o=t("div",{},[this.parts.crumbs,this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let a=new URLSearchParams(location.search),i=a.get("device")&&r.devices.find(s=>s.id===a.get("device"));return i?setTimeout(()=>Ge(this.p,i,this.deviceOpts()),50):a.get("add")&&setTimeout(()=>ot(this.p,this.deviceOpts()),50),this.poller=rt({fetch:s=>{let l=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>o.isConnected,apply:(s,l)=>this.apply(s,l)}),o}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,r){this.take(e);let o=this.st.people.find(a=>a.id===this.id);if(!o){r||(location.href=Pt(this.p?.server));return}this.p=o,this.paint(r),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,r){var i;this.poller?.claim();let o=await G(()=>A.personUpdate(this.p.id,e),r);if(!o)return!1;this.poller?.claim();let a=this.st.people.findIndex(s=>s.id===this.p.id);return(i=o.person).rate??(i.rate=this.p.rate),a>=0&&(this.st.people[a]=o.person),this.p=o.person,this.paint(),!0}get today(){return Ie(this.series.length?this.series:this.st.series)}get core(){return Tt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:Pt(e.server)},this.st.servers.find(r=>r.id===e.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:Pt(e.server)},"People"),t("span",{},"/"),t("span",{},e.name)])}paint(e=!1){Se(this.parts.crumbs,this.crumbs(),e),Se(this.parts.head,Ua(this),e),Se(this.parts.traffic,Ga(this),e),Se(this.parts.devices,Wa(this),e),Se(this.parts.limits,Za(this),e),this.paintPlaces(e),Se(this.parts.activity,Xa(this),e)}paintPlaces(e=!1){let r=Qa(this);r&&Se(this.parts.places,r,e&&!this.mapOpen)}};var il={ok:"check",warn:"alert",error:"x",skip:"pause"},In=class{constructor(e,r,o,a){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=r,this.events=o,this.toLog=a,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(r,o)}async run(e){let r=e?await Dn(e):await A.health().catch(()=>null);r&&(this.take(r),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 r=e.filter(s=>s.status==="error").length,o=e.filter(s=>s.status==="warn").length;dom.content(this.summary,r?pt("error",`${r} problem${r>1?"s":""} need attention.`):o?pt("warn",`${o} warning${o>1?"s":""}.`):pt("ok","All checks passed."));let a=new Map;for(let s of this.sl.watchdog.repairs)a.set(s.id,Math.max(a.get(s.id)??0,s.ts));let i=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks"),t("span",{class:"dl-spacer"}),H("Run again",i)]),t("ul",{class:"dl-checks"},e.map(s=>t("li",{},[t("span",{class:`dl-check-icon ${s.status}`},b(il[s.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},s.title),t("div",{class:"dl-check-detail"},s.detail),a.has(s.id)?t("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${zt(a.get(s.id))}`):""]),yo(s,l=>void this.run(l),i)])))])}paintLive(e,r){this.sl=e,this.events=r;let o=e.watchdog,a=o.beat!=null&&o.now-o.beat>180,i=o.repairs.filter(d=>o.now-d.ts<86400),s=i[i.length-1],l=ve(o.enabled,"Watchdog repairs",async d=>{await G(()=>A.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||eo(l,!d);let p=await A.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${o.enabled?"":" off"}`},b("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},"Watchdog"),t("span",{class:"dl-sub"},o.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),t("span",{class:"dl-spacer"}),l]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},o.targets.map(d=>t("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?"OK":`Not working${d.tries?` · ${d.tries} repair${d.tries>1?"s":""}`:""}`},[b(d.ok?"check":"x"),d.name]))),t("span",{class:`dl-sub${a?" dl-warn-text":""}`},a?`The agent has not checked in for ${Math.round((o.now-o.beat)/60)} min; cron restarts it after 5.`:[o.last?`Looked ${re(o.last,o.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${zt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,r=[...this.events.map(a=>({ts:a.ts,ev:a})),...this.sl.log.map(a=>({ts:a.ts,sys:a}))].filter(a=>a.ts>=e&&cn(a)).sort((a,i)=>i.ts-a.ts),o=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Recent problems"),t("span",{class:"dl-spacer"}),r.length?t("a",{href:"#",click:a=>(a.preventDefault(),this.toLog())},"All in Log →"):""]);if(!r.length){dom.content(this.recentEl,[o,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},b("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[o,...r.slice(0,8).map(a=>{if(a.sys){let i=a.sys,s=`${i.ts}|${i.msg}`;return Tn(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},zt(i.ts))}return st(this.st,a.ev,{time:zt(a.ts)})})])}};var Bn=300,sl=["all","connections","people","system","problems"],On=class{constructor(e,r,o){this.events=[];this.system=[];this.kind="all";this.shown=Bn;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(r),this.system=o,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,r=i=>()=>{let s=this.filtered().reverse();Fe(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,e(),s.filter(l=>l.sys).map(l=>l.sys))},o=H([b("download")," Export"],()=>Ce(o,[{label:"CSV (spreadsheet)",icon:b("download"),run:r("csv")},{label:"JSON",icon:b("download"),run:r("json")}])),a=H([b("trash")," Clear"],()=>tt("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[o,a]}take(e){this.events=e.events,this.policy=e.policy;let r=Mt.filter(o=>!e.policy.categories.includes(o));this.sub=`${pn(e.policy)}${r.length?` Not recorded: ${r.map(o=>ut[o].toLowerCase()).join(", ")}.`:""}`}async reload(){let[e,r]=await Promise.all([A.events(2e4).catch(()=>null),A.serviceLog().catch(()=>null)]);e&&this.take(e),r&&(this.system=r.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,r)=>r.ts-e.ts)}matches(e,r){return r==="all"?!0:r==="problems"?cn(e):r==="system"?!!e.sys:!!e.ev&&Bt(e.ev.type)===r}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,sl.map(r=>t("button",{type:"button",role:"tab",class:r===this.kind?"on":"","aria-selected":r===this.kind?"true":"false",click:()=>this.show(r)},[r==="all"?"All":r==="system"?"System":ut[r],t("b",{},String(e.filter(o=>this.matches(o,r)).length))])))}show(e){this.kind=e,this.shown=Bn,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let r=[],o="",a=null;for(let i of e.slice(0,this.shown)){let s=pa(i.ts);s!==o&&(o=s,a=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},s))),r.push(a));let l=new Date(i.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(i.sys){let d=`${i.sys.ts}|${i.sys.msg}`;a.appendChild(Tn(i.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else a.appendChild(st(this.st,i.ev,{time:l}))}e.length>this.shown&&r.push(t("div",{class:"dl-more-row"},H(`Show ${Math.min(Bn,e.length-this.shown)} more of ${e.length-this.shown}`,()=>{this.shown+=Bn,this.paint()}))),dom.content(this.list,r)}};var ll=[["health","Health"],["log","Log"]],Mo=2e4,jn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([A.status(1),A.events(Mo),A.serviceLog()])}render([e,r,o]){return this.log=new On(e,r,o.log),this.health=new In(e,o,r.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),rt({fetch:async()=>{let a=this.tab==="log",[i,s]=await Promise.all([A.serviceLog().catch(()=>null),a?A.events(Mo).catch(()=>null):Promise.resolve(null)]);return i||s?{n:i,e:s}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:a,e:i})=>this.take(a,i)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,r){r&&(this.log.take(r),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,r?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,ll.map(([r,o])=>t("button",{type:"button",role:"tab",class:r===e?"on":"","aria-selected":r===e?"true":"false",click:()=>r!==this.tab&&this.show(r)},o))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&A.events(Mo).then(r=>this.take(null,r)).catch(()=>null)):this.health.checks||this.health.run()}};var ei=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var ti='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;border:1px dashed color-mix(in srgb,var(--dl-fg) 28%,transparent);color:var(--dl-fg-muted)}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg);border-color:color-mix(in srgb,var(--dl-fg) 45%,transparent)}.dl-chip.add:hover .dl-icon{color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}.dl-people-find{width:160px;min-width:0}.dl-people-find[hidden]{display:none}';var ni="#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-warn{color:var(--dl-warn)}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}";var oi=".dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}";var ri=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-6.5px;bottom:-6.5px;width:20px;height:20px;border-radius:8.5px;border:1.5px solid transparent;background:var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p:hover .dl-onl-dev{background:linear-gradient(var(--dl-soft),var(--dl-soft)),var(--dl-card)}.dl-onl-p.sm:hover{background:none}.dl-onl-p.sm:hover .dl-onl-dev{background:var(--dl-card)}.dl-onl-p.sm .dl-onl-av{transition:box-shadow .15s ease}.dl-onl-p.sm:hover .dl-onl-av{box-shadow:0 0 0 2px var(--dl-ok),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm.more:hover .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-ic.off{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-speed-val.off{color:var(--dl-fg-faint)}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var ai='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-modal .cbi-value.dl-live>.cbi-value-title{display:flex;flex-direction:column;gap:2px;text-align:left}.dl-modal .cbi-value.dl-live>.cbi-value-title>.dl-sub{white-space:normal}.dl-checklist{display:flex;flex-direction:column;gap:6px;margin:4px 0 8px}.dl-checklist label{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer}.dl-checklist input{margin:0}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var ii=".dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#fff;padding:8px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}";var si=".dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}.dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}";var li=".dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}";var di=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-badge:has(>svg:only-child){width:16px;min-width:0;padding:0}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-dplaces.strips .dl-dplace-row{position:relative;display:grid;grid-template-columns:20px minmax(0,1fr) auto;column-gap:10px;row-gap:9px;margin:0 -10px;padding:11px 10px;border-top:0;border-radius:10px;transition:background .15s}.dl-dplaces.strips .dl-dplace-row+.dl-dplace-row:before{content:"";position:absolute;left:10px;right:10px;top:0;height:1px;background:var(--dl-line)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur){background:var(--dl-soft)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur):before,.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur)+.dl-dplace-row:before{opacity:0}.dl-dplace-strip{grid-column:2 / 4;position:relative;height:6px;border-radius:3px;background:var(--dl-track)}.dl-dplaces.can-replay .dl-dplace-strip{cursor:ew-resize;touch-action:none}.dl-dplace-strip i{position:absolute;top:0;bottom:0;min-width:2px;border-radius:2px;background:#8a8a8a}.dl-dplace-strip.live i{background:#3b82f6}.dl-dplaces.replay .dl-dplace-strip:after{content:"";position:absolute;left:var(--at);top:-4px;bottom:-4px;width:2px;margin-left:-1px;border-radius:1px;background:var(--dl-fg);box-shadow:0 0 0 2px var(--dialog-bg, var(--dl-elevated));pointer-events:none}.dl-dplace-axis{position:relative;height:16px;margin:4px 0 0 30px;font-size:11px;line-height:16px;color:var(--dl-fg-faint)}.dl-dplace-axis span{position:absolute;top:0;transform:translate(-50%);white-space:nowrap}.dl-dmap{position:relative}.dl-map-replay{position:absolute;left:10px;top:10px;z-index:3;display:flex;align-items:center;gap:6px}.dl-map-btn{all:unset;box-sizing:border-box;cursor:pointer;width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg)}.dl-map-btn:hover{background:color-mix(in srgb,var(--dl-fg) 8%,var(--dl-elevated))}.dl-map-btn:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-btn .dl-icon{width:13px;height:13px}.dl-map-chip{display:inline-flex;align-items:center;height:28px;box-sizing:border-box;padding:0 10px;border-radius:8px;font-size:11.5px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg);font-variant-numeric:tabular-nums}.dl-mk.step .dl-mk-tile{transition:width .3s cubic-bezier(.2,.8,.2,1),height .3s cubic-bezier(.2,.8,.2,1),border-radius .3s,background-color .3s,color .3s,box-shadow .3s,transform .24s}.dl-mk.step .dl-mk-tile.sm .dl-mk-tile-ic{width:11px;height:11px}.dl-mk.step.faded>*{opacity:.5}.dl-mk.step:is(.online,.hl){z-index:2}.dl-mk.step.hl .dl-mk-tile{box-shadow:0 0 0 3px color-mix(in srgb,#3b82f6 55%,transparent)}.dl-mk.step.arrive .dl-mk-tile{animation:dl-mk-arrive .45s cubic-bezier(.2,.8,.2,1)}@keyframes dl-mk-arrive{0%{transform:scale(.8)}55%{transform:scale(1.12)}to{transform:scale(1)}}.dl-mk-when.inline{display:inline}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged,.dl-mk.piled{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*,.dl-mk.piled>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host{transition:border-radius .22s ease,border-right-color .22s ease}.dl-mk-host.docked{border-top-right-radius:0;border-bottom-right-radius:0;border-right-color:transparent}.dl-mk-dock{position:absolute;left:100%;top:-1px;height:40px;box-sizing:border-box;display:flex;align-items:center;gap:6px;padding:0 10px 0 2px;border:1px solid var(--dl-line);border-left:0;border-radius:0 11px 11px 0;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;pointer-events:none;opacity:0;clip-path:inset(-24px 100% -24px 0);transition:clip-path .28s cubic-bezier(.2,.8,.2,1),opacity .2s ease}.dl-mk-host.docked .dl-mk-dock{pointer-events:auto;opacity:1;clip-path:inset(-24px -24px -24px 0)}.dl-mk-new .dl-mk-host,.dl-mk-new .dl-mk-dock{transition:none}.dl-mk-pile{position:relative;display:flex;justify-content:center}.dl-mk-pile-box{box-sizing:border-box;height:40px;display:flex;align-items:center;gap:6px;padding:0 10px 0 6px;border-radius:20px;cursor:zoom-in;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;animation:dl-plate-in .26s cubic-bezier(.2,.8,.2,1) both;transition:opacity .18s ease,transform .18s ease}.dl-mk-pile.out{pointer-events:none}.dl-mk-pile.out>*{opacity:0;transform:scale(.85);transition:opacity .18s ease,transform .18s ease}@keyframes dl-plate-in{0%{opacity:0;transform:scale(.85)}}.dl-mk-face{all:unset;position:relative;display:flex;cursor:pointer;transition:transform .18s ease,opacity .18s ease}.dl-mk-face>.dl-mk-badge{position:relative;left:auto;bottom:-8px;margin-left:-12px;align-self:center}.dl-mk-face.on .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-face.on .dl-mk-badge{background:#3b82f6}.dl-mk-face:hover .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-face.in{animation:dl-dock-in .24s cubic-bezier(.2,.8,.2,1) both}.dl-mk-face.out{transform:scale(.4);opacity:0;pointer-events:none}@keyframes dl-dock-in{0%{transform:scale(.4);opacity:0}}.dl-mk-more{font-size:11px;font-weight:600;color:var(--dl-fg-muted)}.dl-mk-av,.dl-mk-tile{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1)}.dl-mk.merged .dl-mk-av,.dl-mk.merged .dl-mk-tile,.dl-mk.piled .dl-mk-av{transform:scale(.5)}.dl-mk-host,.dl-mk-dock,.dl-mk-pile-box{transition-property:border-radius,border-right-color,clip-path,opacity,height,width,padding,gap}.dl-mk-dock,.dl-mk-pile-box{transition-duration:.22s;transition-timing-function:cubic-bezier(.2,.8,.2,1)}.dl-mk-pile-box{position:relative}.dl-mk-more{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease}.dl-mk-more.in{animation:dl-dock-in .24s ease both}.dl-mk-more.out{transform:scale(.4);opacity:0}.dl-mk-face .dl-mk-av{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1),width .2s ease,height .2s ease,font-size .2s ease}.dl-mk-face{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,margin .2s ease}.dl-mk-face>.dl-mk-badge{max-width:48px;overflow:hidden;transition:opacity .2s ease,transform .2s ease,max-width .22s ease,margin .22s ease,padding .22s ease,border-width .22s ease,height .22s ease,min-width .22s ease,width .22s ease,bottom .22s ease}.dl-lod-far .dl-mk-host{width:32px;height:32px;border-radius:9px}.dl-lod-far .dl-mk-host.docked{border-radius:9px 0 0 9px}.dl-lod-far .dl-mk-host-tile{width:20px;height:20px;border-radius:6px}.dl-lod-far .dl-mk-host-ic{width:11px;height:11px}.dl-lod-far .dl-mk-dock{height:32px;gap:0;padding:0 4px 0 0;border-radius:0 9px 9px 0}.dl-lod-far .dl-mk-pile-box{height:32px;gap:0;padding:0 4px;border-radius:16px}.dl-lod-far .dl-mk-face+.dl-mk-face{margin-left:-6px}.dl-lod-far .dl-mk-face .dl-mk-av{width:22px;height:22px;font-size:8px;box-shadow:0 0 0 2px var(--dl-elevated)}.dl-lod-far .dl-mk-face>.dl-mk-badge{max-width:0;min-width:0;padding:0;margin-left:0;border-width:0;opacity:0;transform:scale(.5);pointer-events:none}.dl-lod-far .dl-mk-more{margin-left:4px;font-size:10px}.dl-mk-label{transition:opacity .2s ease}.dl-lod-far .dl-mk:not(.step) .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.step .dl-mk-tile,.dl-mk-host,.dl-mk-face>.dl-mk-badge{transition:none;animation:none}}.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host{cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}`;var ci=`.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}`;var pi=".dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";var mi=".dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-bad{color:var(--dl-bad)}";var hi=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var fi=".dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var Cl=[ei,ti,ni,oi,ri,ai,ii,si,li,di,ci,pi,mi,hi,fi].join(` +`);function gi(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=Cl,n}function ht(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async o=>{let a=await e.render(o),i=document.createElement("div");return i.className="dl-root",i.append(gi(),a),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var v1=ht(Zt),b1=ht(mt),x1=ht(Zt),w1=ht(Hn),y1=ht(Rn),k1=ht(jn),$1=ht(Nn);function vi(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 C1=vi(""),E1=vi("log");return baseclass.extend({ activity: E1, diagnostics: k1, health: C1, overview: v1, people: b1, person: y1, server: x1, settings: w1, updates: $1 }); diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent index 7f4bb2a..48ec997 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent @@ -154,41 +154,6 @@ function check_people(m, states, events) { } } -let last_home = 0; -// Addresses the watcher saw connect since the last tick: looked up first. -let geo_pending = {}; - -/** - * Locate client addresses for the admin map: the ones that just connected - * first, then anything still shown that is missing or stale — a few per - * minute, within a time budget, so a slow service never holds the tick. - */ -function check_geo(m) { - if (!m.settings.geo_enabled) { - geo_pending = {}; - return; - } - let cache = geo.load(); - let ips = keys(geo_pending); - geo_pending = {}; - for (let id, rec in usage.devices) - for (let ip in keys(rec.ips ?? {})) - push(ips, ip); - let changed = geo.resolve(m.settings, cache, uniq(ips), 3, 12); - if (time() - last_home > 3600) { - last_home = time(); - let wan = live.iface_status('wan')?.['ipv4-address']?.[0]?.address; - changed = geo.resolve_home(m.settings, cache, wan) || changed; - } - if (changed) - geo.save(cache); -} - -function place_of(ip) { - let pl = geo.place(geo.load(), ip); - return pl ? join(' · ', filter([ pl.city, pl.org ], (x) => x)) : null; -} - /** Connections from home: the DHCP name of the address, as it is now. */ function named(e) { let h = net.event_hosts(e, net.lan_names()); @@ -225,6 +190,116 @@ function save_presence(people) { write_json(live.PRESENCE, { online: last_online, endpoint: last_endpoint, rev, people: person_rev }, 0o600); } +/* ---------- locations ---------- */ + +// A lookup run: this many addresses at most, within this many seconds; a run +// still going after GEO_KILL seconds (past every timeout) is given up. +const GEO_PER_RUN = 3; +const GEO_BUDGET = 12; +const GEO_KILL = 60; + +let last_home = 0; +// Addresses the watcher saw connect or roam that wait for a run. +let geo_pending = {}; +// The run in a child process (uloop.task) and when it started; null when none. +let geo_task = null, geo_since = 0; + +/** Every client address still shown on the map (the cache never pushes these out). */ +function geo_shown() { + let ips = []; + for (let id, rec in usage.devices) + for (let ip in keys(rec.ips ?? {})) + push(ips, ip); + return uniq(ips); +} + +/* + * A run's results: into the cache (the agent is its only writer), onto the + * connections in the activity log that were logged before their place was + * known, and to open pages at once: the revision moves for the people seen + * from those addresses. + */ +function geo_done(found) { + let cache = geo.load(); + if (type(found) != 'object' || !geo.merge(cache, found, geo_shown())) + return; + geo.save(cache); + let where = {}; + for (let ip, r in found) + if (r) + where[ip] = geo.label(r); + if (!length(keys(where))) + return; + let m = watch_model(), people = {}; + for (let id, rec in usage.devices) + for (let ip in keys(where)) + if (rec.ips?.[ip] && m.devices[id]) + people[m.devices[id].person] = true; + live.set_places(where, time() - 3600); + save_presence(keys(people)); +} + +/* + * Locate client addresses for the admin map in a child process: a lookup + * waits on the network for seconds, and neither the 1-second watcher nor the + * tick may wait with it. Addresses that just connected go first, at once + * (the watcher calls this on a connect); the tick adds anything still shown + * that is missing or stale (`more`). One run at a time, a few addresses each; + * what just connected and did not fit waits for the next run. + */ +function geo_lookup(m, more) { + if (!m.settings.geo_enabled) { + geo_pending = {}; + return; + } + if (geo_task && !geo_task.finished()) { + if (time() - geo_since < GEO_KILL) + return; + geo_task.kill(); + } + geo_task = null; + let todo = geo.stale(geo.load(), [ ...keys(geo_pending), ...(more ?? []) ]); + let want = slice(todo, 0, GEO_PER_RUN); + let rest = {}; + for (let ip in slice(todo, GEO_PER_RUN)) + if (geo_pending[ip]) + rest[ip] = true; + geo_pending = rest; + if (!length(want)) + return; + let provider = m.settings.geo_provider; + let t = null; + t = uloop.task(() => { + // The child shares the instance lock: it must not keep it past the agent (a restart would find it taken). + instance.close(); + return geo.lookup_all(provider, want, GEO_PER_RUN, GEO_BUDGET); + }, (found) => { + if (geo_task == t) + geo_task = null; + geo_done(found); + if (length(keys(geo_pending))) + geo_lookup(watch_model()); + }); + geo_task = t; + geo_since = time(); +} + +/** The tick: shown addresses missing or stale get a run; the router's own place about hourly. */ +function check_geo(m) { + geo_lookup(m, geo_shown()); + if (!m.settings.geo_enabled || time() - last_home <= 3600) + return; + last_home = time(); + let cache = geo.load(); + let wan = live.iface_status('wan')?.['ipv4-address']?.[0]?.address; + if (geo.resolve_home(m.settings, cache, wan)) + geo.save(cache); +} + +function place_of(ip) { + return geo.label(geo.place(geo.load(), ip)); +} + /* * One look at the tunnels. Connects (a new handshake from a device that was * away), disconnects (its session expired: no handshake for live.ONLINE_WINDOW; @@ -282,16 +357,19 @@ function watch() { return; live.collect(m, usage, d); live.save_usage(usage, false); - // A location lookup waits on the network: never here, on the next tick - // (check_geo). The event carries the place when the cache already knows it. - if (m.settings.geo_enabled) - for (let ip in ips) - geo_pending[ip] = true; + // The event carries the place when the cache already knows it. A new + // address is looked up at once, in a child process (geo_lookup): its place + // goes onto this event and the revision moves again when it is known. for (let e in events) if (e.type == 'connect') e.where = place_of(e.detail); live.add_events(map(events, (e) => e.type == 'disconnect' ? e : named(e)), live.policy(m.settings.retention)); save_presence(keys(people)); + if (m.settings.geo_enabled && length(ips)) { + for (let ip in ips) + geo_pending[ip] = true; + geo_lookup(m); + } } // What the service log was already told. On flash: the public address often diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/geo.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/geo.uc index 8ad781c..3cfe5d9 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/geo.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/geo.uc @@ -3,8 +3,9 @@ // Client addresses are looked up once with a third-party service (ipwho.is, // ipapi.co as fallback) and cached: the live copy in RUN_DIR (tmpfs), put on // flash (DATA_DIR/geo.json) by flush() about hourly, like the usage -// counters. Only the agent performs lookups, on its minute tick and within a -// time budget, never on the 1-second watcher; the UI reads the cache. +// counters. Only the agent performs lookups, in a child process (the network +// may take seconds; neither its watcher nor its tick waits for them) and +// merges them into the cache itself; the UI reads the cache. import { stat } from 'fs'; import { read_json, write_json, sh_out, q, ensure_dir, ip2int, DATA_DIR, RUN_DIR } from 'dawnline.util'; @@ -13,7 +14,7 @@ const CACHE = `${RUN_DIR}/geo.json`; const SAVED = `${DATA_DIR}/geo.json`; const TTL = 30 * 86400; const RETRY = 86400; -// Entries kept at least; addresses still shown are never pushed out (resolve). +// Entries kept at least; addresses still shown are never pushed out (merge). const CAP = 500; // [base, prefix] of ranges with no meaningful location (private, CGNAT, multicast, …). @@ -99,40 +100,64 @@ export function lookup(provider, ip) { }; /** - * Resolve up to `max` of `ips` that are missing or stale, within `budget` - * seconds (each lookup may wait on the network). Returns true when the cache - * changed (the caller saves it). `ips` is also what is still shown: the cache - * is kept bounded by dropping other entries only, oldest first, so a lookup - * is never repeated for an address that is still on the map. + * The public addresses of `ips` the cache does not know or knows from too + * long ago (a failed lookup is retried after a day), once each and in order. + * Returns an empty array when there is nothing to look up. */ -export function resolve(settings, cache, ips, max, budget) { - let now = time(), changed = false, done = 0; - let started = now; +export function stale(cache, ips, ts) { + let now = ts ?? time(), out = [], seen = {}; for (let ip in ips) { - if (done >= max || (budget != null && time() - started >= budget)) - break; - if (!is_public(ip)) + if (seen[ip] || !is_public(ip)) continue; + seen[ip] = true; let c = cache.ips[ip]; if (c && ((c.fail && now - c.fail < RETRY) || (!c.fail && c.asn != null && now - c.ts < TTL))) continue; - let r = lookup(settings.geo_provider, ip); - done++; - changed = true; - if (r) { - delete r.ip; - r.ts = now; - cache.ips[ip] = r; - } - else - cache.ips[ip] = { fail: now }; + push(out, ip); } - let shown = {}; - for (let ip in ips) - shown[ip] = true; + return out; +}; + +/** + * Look up at most `max` of `ips`, within `budget` seconds (each lookup may + * wait on the network). Returns { ip: place, or false when the services had + * nothing } for the ones tried. Network only, no cache: the agent runs it in + * a child process and merges the result itself. + */ +export function lookup_all(provider, ips, max, budget) { + let started = time(), out = {}, done = 0; + for (let ip in ips) { + if (done >= max || (budget != null && time() - started >= budget)) + break; + let r = lookup(provider, ip); + done++; + if (r) + delete r.ip; + out[ip] = r ?? false; + } + return out; +}; + +/** + * Put lookup_all() results into the cache. Returns true when the cache + * changed (the caller saves it). `shown` is what is still on the map: the + * cache is kept bounded by dropping other entries only, oldest first, so a + * lookup is never repeated for an address that is still on the map. + */ +export function merge(cache, found, shown, ts) { + let now = ts ?? time(), changed = false; + for (let ip, r in found) { + if (!is_public(ip)) + continue; + cache.ips[ip] = r ? { ...r, ts: now } : { fail: now }; + changed = true; + } + let keep = {}; + for (let ip in shown) + keep[ip] = true; let all = keys(cache.ips); if (length(all) > CAP) { - let other = sort(filter(all, (ip) => !shown[ip]), + let other = sort(filter(all, (ip) => !keep[ip]), (a, b) => (cache.ips[a].ts ?? cache.ips[a].fail ?? 0) - (cache.ips[b].ts ?? cache.ips[b].fail ?? 0)); for (let i = 0; i < length(all) - CAP && i < length(other); i++) { delete cache.ips[other[i]]; @@ -159,6 +184,11 @@ export function place(cache, ip) { return (c && !c.fail) ? c : null; }; +/** "City · ISP" for the activity log; null for no place. */ +export function label(pl) { + return pl ? join(' · ', filter([ pl.city, pl.org ], (x) => x)) : null; +}; + export function clear() { save({ ips: {}, home: null }); ensure_dir(DATA_DIR, 0o700); diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc index d0009e7..0f134fb 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc @@ -395,6 +395,35 @@ export function add_event_merged(e, window) { unlock(l); }; +/** + * Places for connections logged before their address was located (the + * lookup finishes after the event): connect events since `since` from an + * address in `where` ({ ip: "City · ISP" }) that have no place yet get it. + * Returns true when `ev` changed. + */ +export function fill_places(ev, where, since) { + let changed = false; + for (let i = length(ev) - 1; i >= 0 && ev[i].ts >= since; i--) { + let e = ev[i]; + if (e.type == 'connect' && !e.where && where[e.detail]) { + e.where = where[e.detail]; + changed = true; + } + } + return changed; +}; + +/** fill_places() on the live log, written only when something changed. */ +export function set_places(where, since) { + let l = lock('events'); + let ev = load_events(); + if (fill_places(ev, where, since)) { + ensure_dir(RUN_DIR); + write_json(`${RUN_DIR}/events.json`, ev, 0o600); + } + unlock(l); +}; + /** Save the log to flash, or drop the flash copy when it is kept in RAM only. */ export function persist_events(pol) { pol ??= policy(); diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc index 4ba9770..a25af91 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc @@ -4,7 +4,7 @@ import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; -export const VERSION = '0.8.0'; +export const VERSION = '0.8.1'; /** GitHub repository with Dawnline releases (updates and the installer). */ export const REPO = 'tickcount/luci-app-dawnline'; export const RUN_DIR = '/var/run/dawnline'; diff --git a/tests/ucode/geo.test.uc b/tests/ucode/geo.test.uc new file mode 100644 index 0000000..e0d1eb7 --- /dev/null +++ b/tests/ucode/geo.test.uc @@ -0,0 +1,52 @@ +// dawnline.geo: which addresses need a lookup, how results go into the cache +// (bounded, never pushing out what is still shown) and the activity-log label. +import * as geo from 'dawnline.geo'; + +const NOW = 1790000000; +const PLACE = { lat: 45.04, lon: 38.98, city: 'Krasnodar', country: 'Russia', cc: 'RU', asn: 12389, org: 'Rostelecom' }; + +test('stale', () => { + let cache = { ips: { + '37.78.36.76': { ...PLACE, ts: NOW - 86400 }, + '212.233.85.1': { ...PLACE, ts: NOW - 31 * 86400 }, + '185.135.150.35': { fail: NOW - 3600 }, + '185.135.150.28': { fail: NOW - 2 * 86400 }, + '83.239.111.148': { lat: 1, lon: 2, city: 'Old', ts: NOW }, + }, home: null }; + eq(geo.stale(cache, [ '37.78.36.76' ], NOW), [], 'fresh: known'); + eq(geo.stale(cache, [ '212.233.85.1' ], NOW), [ '212.233.85.1' ], 'older than the TTL'); + eq(geo.stale(cache, [ '185.135.150.35' ], NOW), [], 'failed today: not again yet'); + eq(geo.stale(cache, [ '185.135.150.28' ], NOW), [ '185.135.150.28' ], 'failed two days ago: retried'); + eq(geo.stale(cache, [ '83.239.111.148' ], NOW), [ '83.239.111.148' ], 'an entry from before ASNs were kept'); + eq(geo.stale(cache, [ '10.0.1.164', '100.64.1.1', '', null, 'fe80::1' ], NOW), [], 'local addresses never'); + eq(geo.stale(cache, [ '1.1.1.1', '8.8.8.8', '1.1.1.1' ], NOW), [ '1.1.1.1', '8.8.8.8' ], 'once each, in order'); +}); + +test('merge', () => { + let cache = { ips: {}, home: null }; + ok(geo.merge(cache, { '1.1.1.1': { ...PLACE }, '8.8.8.8': false }, [], NOW), 'changed'); + eq(cache.ips['1.1.1.1'], { ...PLACE, ts: NOW }, 'a place, stamped'); + eq(cache.ips['8.8.8.8'], { fail: NOW }, 'nothing found: a failure, retried later'); + ok(!geo.merge(cache, {}, [], NOW), 'no results: unchanged'); + ok(!geo.merge(cache, { '10.0.0.1': PLACE }, [], NOW) && !cache.ips['10.0.0.1'], 'a local address is not kept'); + eq(geo.place(cache, '1.1.1.1')?.city, 'Krasnodar', 'place'); + eq(geo.place(cache, '8.8.8.8'), null, 'no place for a failure'); +}); + +test('merge keeps the cache bounded, what is shown stays', () => { + let cache = { ips: {}, home: null }; + for (let i = 0; i < 500; i++) + cache.ips[`1.0.${int(i / 250)}.${i % 250 + 1}`] = { ...PLACE, ts: NOW - 1000 + i }; + let oldest = '1.0.0.1', second = '1.0.0.2'; + ok(geo.merge(cache, { '9.9.9.9': PLACE }, [ oldest ], NOW), 'changed'); + eq(length(keys(cache.ips)), 500, 'back to the cap'); + ok(cache.ips[oldest] != null, 'the oldest is still shown: kept'); + ok(cache.ips[second] == null, 'the oldest not shown went'); + ok(cache.ips['9.9.9.9'] != null, 'the new one is in'); +}); + +test('label', () => { + eq(geo.label(PLACE), 'Krasnodar · Rostelecom', 'city and ISP'); + eq(geo.label({ city: '', org: 'Rostelecom' }), 'Rostelecom', 'no city'); + eq(geo.label(null), null, 'no place'); +}); diff --git a/tests/ucode/live.test.uc b/tests/ucode/live.test.uc index 2e74180..5c4aa63 100644 --- a/tests/ucode/live.test.uc +++ b/tests/ucode/live.test.uc @@ -48,3 +48,21 @@ test('endpoint_ip', () => { eq(live.endpoint_ip('[2001:db8::1]:41821'), '2001:db8::1', 'v6'); eq(live.endpoint_ip(''), '', 'none'); }); + +// A connect is logged before its new address is located; the place comes later. +test('fill_places', () => { + let ev = [ + { type: 'connect', detail: '1.1.1.1', where: null, ts: 100 }, + { type: 'connect', detail: '1.1.1.1', where: null, ts: 200 }, + { type: 'disconnect', detail: null, ts: 210 }, + { type: 'connect', detail: '8.8.8.8', where: 'Mountain View · Google', ts: 220 }, + { type: 'connect', detail: '9.9.9.9', where: null, ts: 230 }, + ]; + ok(live.fill_places(ev, { '1.1.1.1': 'Sydney · Cloudflare', '8.8.8.8': 'Elsewhere' }, 150), 'changed'); + eq(ev[1].where, 'Sydney · Cloudflare', 'the waiting connect gets its place'); + eq(ev[0].where, null, 'older than `since`: left alone'); + eq(ev[3].where, 'Mountain View · Google', 'a place already there stays'); + eq(ev[4].where, null, 'another address'); + ok(!live.fill_places(ev, { '7.7.7.7': 'X' }, 0), 'nothing to fill: unchanged'); + ok(!live.fill_places([], { '1.1.1.1': 'X' }, 0), 'empty log'); +}); diff --git a/web/package-lock.json b/web/package-lock.json index d486a98..4eedb41 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "dawnline-web", - "version": "0.8.0", + "version": "0.8.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dawnline-web", - "version": "0.8.0", + "version": "0.8.1", "license": "MIT", "dependencies": { "qrcode-generator": "1.4.4" diff --git a/web/package.json b/web/package.json index 51d34a0..d20a307 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dawnline-web", - "version": "0.8.0", + "version": "0.8.1", "private": true, "license": "MIT", "type": "module", diff --git a/web/src/admin/cores/awg.ts b/web/src/admin/cores/awg.ts index 87dee90..00ebc4e 100644 --- a/web/src/admin/cores/awg.ts +++ b/web/src/admin/cores/awg.ts @@ -408,7 +408,7 @@ function overviewTile(srv: Server): HTMLElement { E('a', { href: `${L.url('admin/network/dawnline/server')}?server=${encodeURIComponent(srv.id)}§ion=awg` }, 'Change'), ]), E('div', { class: 'dl-disg-id' }, [ - E('span', { class: 'dl-disg-ic' }, icon(m?.ic ?? 'shield')), + E('span', { class: `dl-disg-ic${m?.id === 'off' ? ' off' : ''}` }, icon(m?.ic ?? 'shield')), E('span', { class: 'dl-stack' }, [ E('b', {}, m ? m.title : (legacyTitle(srv.preset) ?? 'Custom')), E('span', { class: 'dl-sub' }, m ? m.short : legacyTitle(srv.preset) ? 'Switch to Balanced or Maximum' : 'Set by hand'), diff --git a/web/src/admin/device.ts b/web/src/admin/device.ts index 73f9fda..112dd0b 100644 --- a/web/src/admin/device.ts +++ b/web/src/admin/device.ts @@ -23,7 +23,8 @@ import { clearLogDialog, exportEvents, resetUsageDialog } from './logs'; import { coreFor, coreOf, type Core } from './cores'; import { plainWg } from './cores/awg'; import { onLiveChange } from './state/live'; -import { ConnectionMap, devicePlaces, rangeControl, type MapData, type Range } from './map'; +import { ConnectionMap, rangeControl, type Range } from './map'; +import { PlacesView } from './places/render'; import { personUrl } from './urls'; /** What the page that opens a device hands over. */ @@ -135,6 +136,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { const showLog = (events: LogEvent[]) => { logEvents = events.filter((e) => e.device === d.id); dom.content(log, deviceEvents(events, d.id, now)); + view?.update({ events }); }; /** The page's events when it has them; otherwise a fetch (`force` after clearing). */ const loadLog = async (force = false) => { @@ -144,31 +146,11 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { if (ev) showLog(ev.events); }; - // Where this device connected from, in time order (option B): a map with its trail and the list. + // Where this device connected from: the map, a row per place with a strip of when it was + // there (from the log's connections), and a replay of the period on the map. let range: Range = '30d'; let map: ConnectionMap | null = null; - const places = E('div', { class: 'dl-dplaces' }); - const mapData = (): MapData => ({ geo: geo!, people: [p], now: now ?? Date.now() / 1000, person: p.id, device: d.id }); - const paintPlaces = () => { - if (!geo?.enabled) return; - const list = devicePlaces(mapData(), range); - dom.content( - places, - list.length - ? list.map((x) => - E('div', { class: 'dl-dplace-row' }, [ - E('span', { class: `dl-dplace-n${x.online ? ' live' : ''}` }, x.online ? icon(d.kind) : String(x.n)), - E('span', { class: 'dl-row-main dl-stack' }, [ - E('span', {}, [x.city || x.cc || 'Unknown city', x.org ? E('span', { class: 'dl-muted' }, ` · ${x.org}`) : '']), - E('span', { class: 'dl-mono dl-faint' }, x.ip), - ]), - E('span', { class: x.online ? 'dl-dplace-now' : 'dl-faint dl-nowrap' }, x.online ? 'now' : ago(x.ts, now)), - ]), - ) - : E('div', { class: 'dl-sub' }, 'No locations in this period.'), - ); - }; - + let view: PlacesView | null = null; const paint = () => { dom.content(titleEl, [ E('span', { class: `dl-dcard-ic${d.online ? ' on' : ''}` }, icon(d.kind)), @@ -290,8 +272,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { now = st.now; today = todayOf(st.series); paint(); - map?.update(mapData()); - paintPlaces(); + view?.update({ geo: st.geo, now: st.now, person: p, device: d }); }; /** After a change made here: this drawer and the page. */ const changed = async () => { @@ -376,6 +357,13 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { range, 220, ); + const v = (view = new PlacesView(map, range, { + geo, + now: now ?? Date.now() / 1000, + person: p, + device: d, + events: o.events?.() ?? null, + })); locationsSec = E('section', { class: 'dl-dsec' }, [ E('div', { class: 'dl-dsec-head' }, [ E('h4', {}, 'Locations'), @@ -383,16 +371,14 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { range, (r) => { range = r; - map?.setRange(r); - paintPlaces(); + v.setRange(r); }, false, ), ]), - E('div', { class: 'dl-dmap' }, map.el), - places, + E('div', { class: 'dl-dmap' }, [map.el, v.controls]), + v.el, ]); - paintPlaces(); } // Connecting is what the drawer is for until the device is set up (or its configuration is old); // after that it goes to the bottom. @@ -413,10 +399,11 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { const handle = drawer(titleEl, body, foot, () => { clearInterval(watch); off(); + view?.destroy(); map?.destroy(); }); paint(); - if (map) requestAnimationFrame(() => map?.mount(mapData())); + if (map && view) requestAnimationFrame(() => view && map?.mount(view.mapData())); } /** ⋯ on a device card: quick actions (everything else is in the panel; click the card). */ diff --git a/web/src/admin/map.ts b/web/src/admin/map.ts index 3242bb0..9b22dcc 100644 --- a/web/src/admin/map.ts +++ b/web/src/admin/map.ts @@ -10,6 +10,7 @@ import { E } from './e'; import { ago, initials } from '../shared/format'; import { icon, iconSvg } from '../shared/icons'; import { onNavigate } from './ui/nav'; +import { placeKey, shimmerOpacity } from './places/model'; // mapcn requires maplibre-gl ^6 (the globe projection came with 5): an ES module, its worker beside it. const MAPLIBRE = 'https://unpkg.com/maplibre-gl@6.14.0/dist'; @@ -82,6 +83,8 @@ const CLICK_ZOOM = 10; 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; +/** The replay's dotted arc: a dot every this many screen pixels. */ +const DOT_PX = 4; /** Below these zooms plates turn compact (a continent) or mid-sized (a country). */ const LOD_FAR = 4.5; const LOD_MID = 7; @@ -146,7 +149,7 @@ export function visiblePoints(data: MapData, range: Range): GeoPoint[] { if (data.device && p.device !== data.device) continue; if (range === 'online' ? !p.online : data.now - p.ts > WINDOW[range]) continue; // Where people are: each device once. A person's page: every city each device was in. - const key = data.device ? `${p.city}|${p.cc}` : data.person ? `${p.device}|${p.city}|${p.cc}` : p.device; + const key = data.device ? placeKey(p) : data.person ? `${p.device}|${p.city}|${p.cc}` : p.device; const cur = best.get(key); if (!cur || (p.online && !cur.online) || (p.online === cur.online && p.ts > cur.ts)) best.set(key, p); } @@ -200,6 +203,17 @@ export class ConnectionMap { /** The folded keys the layers were last filtered for (a filter only changes when they do). */ private hiddenKey = ''; private focused: string | null = null; + /** Destroyed: a mount still waiting for the library stops there instead of drawing into a dropped element. */ + private dead = false; + /** A device's places (its window) by placeKey: what the replay switches on and off. */ + private places = new Map< + string, + { el: HTMLElement; tile: HTMLElement; label: HTMLElement; when: HTMLElement | null; g: Group; n: number; kind: string } + >(); + /** The replay of a device's moves: the place the light is on and the time under it; null outside it. */ + private replaying: { active: string | null; when: string } | null = null; + /** The replay's arc dots, kept for a style reload (a theme switch) in the middle of a move. */ + private bandDots: unknown[] = []; private card: HTMLElement; readonly el: HTMLElement; private status: HTMLElement; @@ -223,6 +237,7 @@ export class ConnectionMap { this.status.textContent = (e as Error).message; return; } + if (this.dead) return; this.map = new this.gl.Map({ container: this.el, style: isDark() ? STYLE_DARK : STYLE_LIGHT, @@ -285,14 +300,13 @@ export class ConnectionMap { 'circle-stroke-opacity': ['case', ['get', 'online'], 0.35, 0.15], }, }); - // A device's trail through its places in time order (its window): fine gray dots. - this.map.addSource('dl-trail', { type: 'geojson', data: { type: 'FeatureCollection', features: [] } }); + // A device's move in its replay: a dotted arc, transparent but where the shimmer is (band, bandAt). + this.map.addSource('dl-band', { type: 'geojson', data: { type: 'FeatureCollection', features: this.bandDots } }); this.map.addLayer({ - id: 'dl-trail', - type: 'line', - source: 'dl-trail', - layout: { 'line-join': 'round', 'line-cap': 'round' }, - paint: { 'line-color': RECENT, 'line-width': 1.5, 'line-opacity': 0.85, 'line-dasharray': [0, 2.5] }, + id: 'dl-band', + type: 'circle', + source: 'dl-band', + paint: { 'circle-radius': 1.4, 'circle-color': LIVE, 'circle-opacity': 0 }, }); // mapcn's MapArc paint (width 2, opacity 0.85, rounded) with the Basic Arc example's dashes; // recent arcs under live ones. @@ -321,6 +335,7 @@ export class ConnectionMap { } destroy() { + this.dead = true; this.dropCard(); for (const p of this.piles.values()) p.marker.remove(); this.piles.clear(); @@ -334,7 +349,7 @@ export class ConnectionMap { private groups(pts: GeoPoint[]): Group[] { const map = new Map(); for (const p of pts) { - const key = `${p.person}|${p.city || `${p.lat.toFixed(1)},${p.lon.toFixed(1)}`}|${p.cc}`; + const key = `${p.person}|${placeKey(p)}`; let g = map.get(key); if (!g) { g = { @@ -416,31 +431,16 @@ export class ConnectionMap { this.add(el, [home.lon, home.lat], true); } - // A device's places joined oldest to newest, each step bowed like an arc. - const steps = data.device ? [...placed].sort((a, b) => Number(a.g.online) - Number(b.g.online) || a.g.ts - b.g.ts) : []; - this.map.getSource('dl-trail')?.setData({ - type: 'FeatureCollection', - features: - steps.length > 1 - ? [ - { - type: 'Feature', - properties: {}, - geometry: { type: 'LineString', coordinates: steps.slice(1).flatMap((x, i) => arc(steps[i].at, x.at)) }, - }, - ] - : [], - }); - const numbers = new Map(data.device ? devicePlaces(data, this.range).map((p) => [`${p.city}|${p.cc}`, p.n]) : []); + // A device's places, numbered as the list under the map (its strips say when it was where). + const numbers = new Map(data.device ? devicePlaces(data, this.range).map((p) => [placeKey(p), p.n]) : []); this.people = []; + this.places.clear(); for (const { g, at } of placed) { const n = g.points.length; const person = data.people.find((x) => x.id === g.person); if (data.person) { - const el = data.device - ? this.stepMarker(g, at, person, numbers.get(`${g.points[0].city}|${g.points[0].cc}`) ?? 0) - : this.placeMarker(g, at, person); + const el = data.device ? this.deviceMarker(g, at, person, numbers.get(placeKey(g)) ?? 0) : this.placeMarker(g, at, person); this.add(el, at); continue; } @@ -820,23 +820,111 @@ export class ConnectionMap { } /** - * A place in a device's window: the live one as a blue tile with the device's icon and - * "now", the earlier ones as small gray tiles numbered by recency (1 = most recent). + * A place in a device's window: on, a blue tile with the device's icon and "now" (the live + * place); off, a small gray tile numbered by recency (1 = most recent). One element whose + * state changes, so the replay can move the light from place to place (paintPlace). */ - private stepMarker(g: Group, at: [number, number], person: Person | undefined, n: number): HTMLElement { - if (g.online) return this.placeMarker(g, at, person); - const when = ago(g.ts, this.data!.now); - const el = E('button', { type: 'button', class: 'dl-mk place step', 'aria-label': `${n}: ${g.city || 'an unknown city'}, ${when}` }, [ - E('span', { class: 'dl-mk-tile sm' }, String(n)), - E('span', { class: 'dl-mk-label below' }, [g.city || g.cc || '?', ` · ${when}`]), - ]); + private deviceMarker(g: Group, at: [number, number], person: Person | undefined, n: number): HTMLElement { + const kind = person?.devices.find((d) => d.id === g.points[0].device)?.kind ?? 'other'; + const tile = E('span', { class: 'dl-mk-tile' }); + const label = E('span', { class: 'dl-mk-label below' }); + const el = E('button', { type: 'button', class: 'dl-mk place step' }, [tile, label]); el.addEventListener('click', (ev) => { ev.stopPropagation(); this.openPopup(g, at, el); }); + const key = placeKey(g); + this.places.set(key, { el, tile, label, when: null, g, n, kind }); + this.paintPlace(key, false); return el; } + /** A device's place as the replay has it (or, outside it, as it is now); `animate` lets the light come in. */ + private paintPlace(key: string, animate: boolean) { + const x = this.places.get(key); + if (!x) return; + const r = this.replaying; + const on = r ? r.active === key : x.g.online; + const was = x.el.classList.contains('online'); + const city = x.g.city || x.g.cc || '?'; + x.el.classList.toggle('online', on); + x.el.classList.toggle('faded', !!r && !on); + x.tile.classList.toggle('sm', !on); + if (on || !x.n) x.tile.innerHTML = iconSvg(x.kind, 'dl-mk-tile-ic'); + else x.tile.textContent = String(x.n); + x.when = null; + if (on) { + // In the replay the time goes on the city's line (two lines would run into a place below). + x.when = E('span', { class: `dl-mk-when${r ? ' inline' : ''}` }, r ? r.when : 'now'); + x.label.replaceChildren(city, r ? ' · ' : '', x.when); + } else x.label.replaceChildren(`${city} · ${x.g.online ? 'now' : ago(x.g.ts, this.data!.now)}`); + const when = on ? (r ? r.when : 'now') : x.g.online ? 'now' : ago(x.g.ts, this.data!.now); + x.el.setAttribute('aria-label', `${x.n ? `${x.n}: ` : ''}${x.g.city || 'an unknown city'}, ${when}`); + if (animate && on && !was) { + x.el.classList.remove('arrive'); + void x.el.offsetWidth; + x.el.classList.add('arrive'); + setTimeout(() => x.el.classList.remove('arrive'), 500); + } + } + + /** + * The replay of a device's moves (its window): `active` is the place (placeKey) the light is on, + * `when` the time under it; null goes back to how things are now. A change of place animates. + */ + replay(state: { active: string | null; when: string } | null, animate = true) { + const prev = this.replaying; + this.replaying = state; + // The same place a moment later: only its time changes. + if (prev && state && prev.active === state.active) { + const x = state.active ? this.places.get(state.active) : null; + if (x?.when) x.when.textContent = state.when; + return; + } + for (const key of this.places.keys()) if (key !== state?.active) this.paintPlace(key, animate); + if (state?.active) this.paintPlace(state.active, animate); + // Tiles grow and shrink: spread the crowded ones again, now and once they have their size. + this.declutter(); + setTimeout(() => this.declutter(), 320); + } + + /** A device's place lit while its row under the map is hovered; null for none. */ + hoverPlace(key: string | null) { + for (const [k, x] of this.places) x.el.classList.toggle('hl', k === key); + } + + /** + * The dots of the arc between two places (a move in the replay), as many as fit on screen at + * DOT_PX apart, all transparent until bandAt() brings the shimmer in; no arguments clear them. + */ + band(from?: [number, number], to?: [number, number]) { + this.bandDots = []; + if (this.map && from && to) { + const pts = arc(from, to); + const px = pts.map((c) => this.map.project(c)); + const len = [0]; + for (let i = 1; i < px.length; i++) len.push(len[i - 1] + Math.hypot(px[i].x - px[i - 1].x, px[i].y - px[i - 1].y)); + const total = len[len.length - 1]; + const n = Math.max(2, Math.round(total / DOT_PX)); + let j = 0; + for (let i = 0; i <= n; i++) { + const d = (total * i) / n; + while (j < len.length - 2 && len[j + 1] < d) j++; + const t = len[j + 1] > len[j] ? (d - len[j]) / (len[j + 1] - len[j]) : 0; + const at = [pts[j][0] + (pts[j + 1][0] - pts[j][0]) * t, pts[j][1] + (pts[j + 1][1] - pts[j][1]) * t]; + this.bandDots.push({ type: 'Feature', properties: { pos: i / n }, geometry: { type: 'Point', coordinates: at } }); + } + } + if (!this.map?.getLayer('dl-band')) return; + this.map.setPaintProperty('dl-band', 'circle-opacity', 0); + this.map.getSource('dl-band').setData({ type: 'FeatureCollection', features: this.bandDots }); + } + + /** The shimmer along the band's arc, its middle at `c` (a share of the arc: see places/model). */ + bandAt(c: number) { + if (this.map?.getLayer('dl-band')) this.map.setPaintProperty('dl-band', 'circle-opacity', shimmerOpacity(c)); + } + /** * One person in focus (hovering any of their markers): all their places and arcs stay, * everyone else fades, and a card lists their devices with where and when. @@ -894,9 +982,17 @@ export class ConnectionMap { const b = new this.gl.LngLatBounds(pts[0], pts[0]); pts.forEach((c) => b.extend(c)); const h = this.el.clientHeight || 380; + // A person's and a device's places have their name (and "now") under the tile; a device's + // window has the replay's controls in its top corner. + const below = !!this.data?.person; const opts = { // Just enough room for the labels: the server's chip above its plate, a place's name above its dot. - padding: { top: Math.min(60, h / 5), bottom: Math.min(40, h / 8), left: 48, right: 48 }, + padding: { + top: this.data?.device ? Math.min(56, h / 4) : Math.min(60, h / 5), + bottom: below ? Math.min(52, h / 4) : Math.min(40, h / 8), + left: 48, + right: 48, + }, // A person's page shows a little more around a single place. maxZoom: this.data?.person ? 11 : 12, }; diff --git a/web/src/admin/pages/overview.ts b/web/src/admin/pages/overview.ts index 5ad07a4..d0e749a 100644 --- a/web/src/admin/pages/overview.ts +++ b/web/src/admin/pages/overview.ts @@ -111,6 +111,8 @@ export class ServerOverview { st!: Status; el = E('div', { class: 'dl-srvov' }); map: ConnectionMap | null = null; + /** Whether the map card was made for locations on (a map) or off (a link to Settings); null before the first. */ + mapOn: boolean | null = null; range: Range = 'online'; parts: Record = {}; healthAt = 0; @@ -124,11 +126,11 @@ export class ServerOverview { /** Build once; later calls to update() keep the map instance. */ mount(st: Status): HTMLElement { this.st = scoped(st, this.srvId); - for (const k of ['health', 'bento', 'side', 'activity']) this.parts[k] = E('div', {}); + for (const k of ['health', 'bento', 'map', 'side', 'activity']) this.parts[k] = E('div', {}); dom.content(this.el, [ this.parts.health, this.parts.bento, - this.mapCard(), + this.parts.map, E('div', { class: 'dl-grid2' }, [this.parts.activity, this.parts.side]), ]); this.paint(); @@ -140,7 +142,6 @@ export class ServerOverview { update(st: Status, quiet = false) { this.st = scoped(st, this.srvId); this.paint(quiet); - this.map?.update(this.mapData()); // Health checks cost more than a status call: once a minute is plenty. if (Date.now() - this.healthAt > 60_000) void this.loadHealth(); } @@ -168,6 +169,21 @@ export class ServerOverview { return { geo: this.st.geo, people: this.st.people, now: this.st.now }; } + /** + * The map keeps its instance between updates. Its card is made again only + * when locations were turned on or off, or when the map was freed: leaving + * the page frees it, and Outline brings this same overview back on return. + */ + paintMap() { + const on = this.st.geo.enabled; + if (on === this.mapOn && (!on || this.map)) { + this.map?.update(this.mapData()); + return; + } + this.mapOn = on; + dom.content(this.parts.map, this.mapCard()); + } + mapCard(): HTMLElement { const st = this.st; const head = E('div', { class: 'dl-panel-head pad' }, [ @@ -181,6 +197,8 @@ export class ServerOverview { this.map?.setRange(r); }), ]); + this.map?.destroy(); + this.map = null; if (!st.geo.enabled) return E('div', { class: 'dl-panel flush' }, [ head, @@ -190,27 +208,27 @@ export class ServerOverview { '.', ]), ]); - this.map?.destroy(); - this.map = new ConnectionMap( + const map = (this.map = new ConnectionMap( { openPerson: (id) => (location.href = personUrl(id)), openDevice: (id, dev) => (location.href = personUrl(id, dev)), }, this.range, - ); + )); // A WebGL map outlives the page's DOM unless it is told: free it when - // Outline navigates away (the page object itself may be reused). + // Outline navigates away. The page object is reused on return, and its + // next update finds the map gone and makes the card again (paintMap). const offNav = onNavigate(() => { offNav(); - this.map?.destroy(); - this.map = null; + map.destroy(); + if (this.map === map) this.map = null; }); const legend = E('div', { class: 'dl-map-legend' }, [ E('span', {}, [E('i', { class: 'line live' }), 'Live tunnel']), E('span', {}, [E('i', { class: 'line' }), 'Seen recently']), ]); - const wrap = E('div', { class: 'dl-map-wrap' }, [this.map.el, legend]); - requestAnimationFrame(() => this.map!.mount(this.mapData())); + const wrap = E('div', { class: 'dl-map-wrap' }, [map.el, legend]); + requestAnimationFrame(() => map.mount(this.mapData())); return E('div', { class: 'dl-panel flush' }, [head, wrap]); } @@ -218,6 +236,7 @@ export class ServerOverview { const st = this.st; const srv = st.servers[0]; + this.paintMap(); repaint( this.parts.bento, E('div', { class: 'dl-bento' }, [this.onlineTile(), this.speedTile(), coreOf(srv).overviewTile(srv), this.monthTile()]), diff --git a/web/src/admin/pages/people.ts b/web/src/admin/pages/people.ts index 84678a2..44cba98 100644 --- a/web/src/admin/pages/people.ts +++ b/web/src/admin/pages/people.ts @@ -438,7 +438,7 @@ export class PeoplePage { icon(d.kind), E('span', { class: 'dl-chip-name' }, d.name), !d.handshake && !d.disabled ? E('span', { class: 'dl-chip-tag' }, 'not set up') : '', - // Online shows as the green dashed chip (.dl-chip.live); no dots. + // Online shows as the green chip (.dl-chip.live); no dots. ], ); }); @@ -448,30 +448,19 @@ export class PeoplePage { 'button', { type: 'button', - // Just a "+": the slots above say how many there are. class: 'dl-chip add', - 'aria-label': 'Add device', - title: free > 0 ? 'Add device' : 'Add device · over the limit, admins can still add', + title: free > 0 ? 'Add device' : 'Over the limit: admins can still add', click: (ev: Event) => { ev.preventDefault(); addDevice(p, this.deviceOpts(p)); }, }, - icon('plus'), + [icon('plus'), 'Add device'], ), ); - // Ending soon (the strip below handles an end that has passed); someone new - // without a device yet gets a nudge to send the link. + // Ending soon (the strip below handles an end that has passed). const fixes: Node[] = []; - if (!p.devices.length && portal && !stopped(p)) - fixes.push( - E( - 'button', - { type: 'button', class: 'dl-fix', click: () => inviteCard(p, this.st.servers.find((s) => s.id === p.server)?.name ?? 'Home') }, - 'Send invite', - ), - ); if (p.expires && endsSoon(p, left) && why !== 'expired') fixes.push( E( diff --git a/web/src/admin/places/model.ts b/web/src/admin/places/model.ts new file mode 100644 index 0000000..4578f3c --- /dev/null +++ b/web/src/admin/places/model.ts @@ -0,0 +1,245 @@ +// Where a device went: its stretches on each client address from the activity log +// (connect, roam, disconnect), as visits to the places the map shows, folded into +// stays for the replay, and the replay's timeline and shimmer. No DOM here (see ./render). + +import type { GeoPoint, LogEvent } from '../../shared/types'; + +/** On one client address: from a connect or a roam to the next one, a disconnect or now. */ +export interface Stretch { + ip: string; + from: number; + to: number; + live: boolean; +} + +/** + * A device's stretches in time order, from the activity log. A stretch the log leaves open + * goes on until now while the device is online, and ends at `seen` (its latest handshake) + * when it is not. Empty when the log has no connections (the category is off or cleared). + */ +export function stretches(events: LogEvent[], device: string, now: number, online: boolean, seen = 0): Stretch[] { + const out: Stretch[] = []; + let cur: Stretch | null = null; + const close = (t: number) => { + if (cur && t > cur.from) out.push({ ...cur, to: t }); + cur = null; + }; + const mine = events.filter((e) => e.device === device).sort((a, b) => a.ts - b.ts); + for (const e of mine) { + if (e.type === 'connect') { + close(e.ts); + if (e.detail) cur = { ip: e.detail, from: e.ts, to: e.ts, live: false }; + } else if (e.type === 'roam') { + // "old → new" + const ip = e.detail?.split('→')[1]?.trim(); + close(e.ts); + if (ip) cur = { ip, from: e.ts, to: e.ts, live: false }; + } else if (e.type === 'disconnect') close(e.ts); + } + const open = cur as Stretch | null; + if (open && online) out.push({ ...open, to: Math.max(now, open.from), live: true }); + else close(Math.min(now, seen)); + return out; +} + +/** A place as the map groups them: the city (or rounded coordinates where there is none) and the country. */ +export function placeKey(p: Pick): string { + return `${p.city || `${p.lat.toFixed(1)},${p.lon.toFixed(1)}`}|${p.cc}`; +} + +/** A stretch at a located address: the place it was at. */ +export interface Visit { + key: string; + point: GeoPoint; + from: number; + to: number; + live: boolean; +} + +/** + * The stretches since `from` whose address has a location (the device's own point first, then + * anyone's at that address), clipped to `from`. Addresses without one are left out, as on the map. + */ +export function visits(list: Stretch[], points: GeoPoint[], device: string, from: number): Visit[] { + const at = new Map(); + for (const p of points) if (p.device === device || !at.has(p.ip)) at.set(p.ip, p); + const out: Visit[] = []; + for (const s of list) { + const p = at.get(s.ip); + if (!p || s.to <= from) continue; + out.push({ key: placeKey(p), point: p, from: Math.max(s.from, from), to: s.to, live: s.live }); + } + return out; +} + +/** Each place's share of the time the visits cover (0–1), by place key. */ +export function shares(v: Visit[]): Map { + const time = new Map(); + let total = 0; + for (const x of v) { + time.set(x.key, (time.get(x.key) ?? 0) + (x.to - x.from)); + total += x.to - x.from; + } + return new Map([...time].map(([k, t]) => [k, total ? t / total : 0])); +} + +/** Visits in a row at one place, with `short` visits elsewhere folded in. */ +export interface Stay { + key: string; + point: GeoPoint; + from: number; + to: number; + live: boolean; + /** Visits elsewhere shorter than the fold (a phone flipping to mobile data and back), folded into this stay. */ + short: number; +} + +/** Visits as stays: a place's visits in a row are one, and a visit elsewhere shorter than `fold` seconds joins the stay around it. */ +export function stays(v: Visit[], fold = 45 * 60): Stay[] { + const out: Stay[] = []; + for (const x of v) { + const last = out[out.length - 1]; + if (last && x.key !== last.key && !x.live && x.to - x.from < fold) { + last.short++; + last.to = x.to; + continue; + } + if (last && last.key === x.key) { + last.to = x.to; + last.live = x.live; + continue; + } + out.push({ key: x.key, point: x.point, from: x.from, to: x.to, live: x.live, short: 0 }); + } + return out; +} + +/** + * Stays for a replay of at most `max` moves: every move while there are few, folding the + * shortest visits (minutes on mobile data, then longer) only as far as needed. + */ +export function replayStays(v: Visit[], max = 24): Stay[] { + for (const fold of [0, 5 * 60, 15 * 60, 45 * 60, 2 * 3600, 6 * 3600]) { + const st = stays(v, fold); + if (st.length - 1 <= max) return st; + } + return stays(v, 24 * 3600); +} + +/* ---------- the replay ---------- */ + +/** One move (ms): the place it leaves lets go, the shimmer runs along the arc, the next place lights up. */ +export const MOVE_MS = 1600; +/** The shimmer sets off once the place it leaves has started to go gray (a share of the move). */ +const LEAVE = 0.12; +/** The shimmer's length, a share of the arc: longer than the arc, so most of it is lit mid-move. */ +export const BAND = 1.3; +/** ± this around the shimmer's middle is fully lit; it fades out to ±BAND/2. */ +export const FLAT = 0.32; + +/** A move into stay `k` (from stay k − 1), or stay `k` itself, `ms` long from `start`. */ +export interface Step { + kind: 'move' | 'stay'; + k: number; + start: number; + ms: number; +} + +/** The replay's steps: each stay held in proportion to how long it lasted (within bounds), a move before each but the first. */ +export function timeline(st: Stay[], move = MOVE_MS): { steps: Step[]; total: number } { + const steps: Step[] = []; + let t = 0; + st.forEach((s, k) => { + if (k) { + steps.push({ kind: 'move', k, start: t, ms: move }); + t += move; + } + const ms = Math.min(1100, Math.max(350, ((s.to - s.from) / 3600) * 45)); + steps.push({ kind: 'stay', k, start: t, ms }); + t += ms; + }); + return { steps, total: t }; +} + +/** Where the replay is at `ms`: the step (its index), how far into it (0–1) and the moment shown. */ +export function moment(st: Stay[], steps: Step[], ms: number): { i: number; step: Step; q: number; t: number } { + let i = steps.findIndex((s) => ms >= s.start && ms < s.start + s.ms); + if (i < 0) i = steps.length - 1; + const step = steps[i]; + const q = Math.min(1, Math.max(0, (ms - step.start) / step.ms)); + const s = st[step.k]; + return { i, step, q, t: step.kind === 'move' ? s.from : s.from + (s.to - s.from) * q }; +} + +/** The replay's `ms` for moment `t` (a click on a strip): inside the stay it falls in. */ +export function msAt(st: Stay[], steps: Step[], t: number): number { + let k = st.findIndex((s) => t >= s.from && t < s.to); + if (k < 0) k = t < (st[0]?.from ?? 0) ? 0 : st.length - 1; + const step = steps.find((s) => s.kind === 'stay' && s.k === k)!; + const s = st[k]; + return step.start + step.ms * Math.min(0.999, Math.max(0, (t - s.from) / Math.max(1, s.to - s.from))); +} + +export const ease = (x: number) => (x <= 0 ? 0 : x >= 1 ? 1 : x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2); + +/** The shimmer's middle (a share of the arc) `q` into a move: it enters before the place it leaves and runs out past the next. */ +export function bandMiddle(q: number): number { + return -BAND / 2 + (1 + BAND) * ease((q - LEAVE) / (1 - LEAVE)); +} + +/** The next place lights up once the shimmer's bright part reaches it. */ +export const arrived = (middle: number) => middle + FLAT >= 1; + +/** + * The opacity of the arc's dots (each has its `pos` along the arc, 0–1) with the shimmer's middle + * at `c`: beui's text shimmer along a line, the arc itself transparent. A MapLibre expression. + */ +export function shimmerOpacity(c: number): unknown[] { + return ['interpolate', ['linear'], ['abs', ['-', ['get', 'pos'], c]], 0, 1, FLAT, 1, BAND / 2, 0]; +} + +/* ---------- labels ---------- */ + +/** Labels under the strips for a range ending `now`: [share of the range, label], in local time. */ +export function ticks(range: '24h' | '7d' | '30d', now: number): [number, string][] { + const span = range === '24h' ? 86400 : range === '7d' ? 7 * 86400 : 30 * 86400; + const from = now - span; + const out: [number, string][] = []; + const put = (ts: number, label: string) => { + const f = (ts - from) / span; + if (f > 0.02 && f < 0.98) out.push([f, label]); + }; + const d = new Date(from * 1000); + if (range === '24h') { + d.setMinutes(0, 0, 0); + while (d.getTime() / 1000 <= now) { + if (d.getHours() % 6 === 0) put(d.getTime() / 1000, `${String(d.getHours()).padStart(2, '0')}:00`); + d.setHours(d.getHours() + 1); + } + } else if (range === '7d') { + d.setHours(12, 0, 0, 0); + for (; d.getTime() / 1000 <= now; d.setDate(d.getDate() + 1)) + put(d.getTime() / 1000, d.toLocaleDateString('en-GB', { weekday: 'short' })); + } else { + const end = new Date(now * 1000); + end.setHours(0, 0, 0, 0); + for (let i = 0; i < 5; i++) { + const w = new Date(end); + w.setDate(end.getDate() - 7 * i); + put(w.getTime() / 1000, w.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })); + } + out.reverse(); + } + return out; +} + +/** "14:05", local. */ +export const clock = (ts: number) => new Date(ts * 1000).toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' }); + +/** "Today", "Yesterday" or "Wed 14 Oct" for a moment, against the router's `now`. */ +export function dayName(ts: number, now: number): string { + const day = (x: number) => new Date(x * 1000).toDateString(); + if (day(ts) === day(now)) return 'Today'; + if (day(ts) === day(now - 86400)) return 'Yesterday'; + return new Date(ts * 1000).toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short' }); +} diff --git a/web/src/admin/places/render.ts b/web/src/admin/places/render.ts new file mode 100644 index 0000000..cc72dee --- /dev/null +++ b/web/src/admin/places/render.ts @@ -0,0 +1,288 @@ +// Where a device went, under its map (the device window): a row per place with a strip of +// when it was there, and a replay of the period: the place it leaves goes gray, a blue +// shimmer runs along the dotted arc to the next place, which lights up. The model is +// ./model; the map draws (ConnectionMap.replay, band, bandAt). + +import type { Device, Geo, LogEvent, Person } from '../../shared/types'; +import { E } from '../e'; +import { icon } from '../../shared/icons'; +import { ago } from '../../shared/format'; +import { devicePlaces, type ConnectionMap, type MapData, type Range } from '../map'; +import { + MOVE_MS, + arrived, + bandMiddle, + clock, + dayName, + moment, + msAt, + placeKey, + shares, + replayStays, + stretches, + ticks, + timeline, + visits, + type Stay, + type Step, +} from './model'; + +export interface PlacesData { + geo: Geo; + /** The router's clock (seconds). */ + now: number; + person: Person; + device: Device; + /** The person's activity log (the device's connects and roams in it); null until loaded. */ + events: LogEvent[] | null; +} + +const SPAN: Record, number> = { '24h': 86400, '7d': 7 * 86400, '30d': 30 * 86400 }; +const pct = (part: number, whole: number) => `${((part / whole) * 100).toFixed(3)}%`; + +export class PlacesView { + /** The rows under the map. */ + readonly el = E('div', { class: 'dl-dplaces' }); + /** The replay's controls, for the map's top corner. */ + readonly controls = E('div', { class: 'dl-map-replay' }); + private data: PlacesData; + /** What came while the replay ran: shown once it ends (the replay plays what it started with). */ + private pending: PlacesData | null = null; + private rows = new Map(); + private st: Stay[] = []; + private steps: Step[] = []; + private total = 0; + /** Where the replay is (ms into it) and the step it showed last. */ + private ms = 0; + private stepI = -1; + /** In the replay (playing or paused), and playing. */ + private on = false; + private playing = false; + private raf = 0; + private last = 0; + private endTimer = 0; + private play = E('button', { type: 'button', class: 'dl-map-btn' }); + private chip = E('span', { class: 'dl-map-chip' }); + private stop = E('button', { type: 'button', class: 'dl-map-btn', title: 'Back to now', 'aria-label': 'Back to now' }, icon('x')); + private reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false; + + constructor( + private map: ConnectionMap, + private range: Range, + data: PlacesData, + ) { + this.data = data; + this.play.addEventListener('click', () => this.toggle()); + this.stop.addEventListener('click', () => this.end()); + this.paint(); + } + + mapData(): MapData { + const d = this.data; + return { geo: d.geo, people: [d.person], now: d.now, person: d.person.id, device: d.device.id }; + } + + /** New status or log: shown at once, or after the replay. */ + update(data: Partial) { + const next = { ...(this.pending ?? this.data), ...data }; + if (this.on) { + this.pending = next; + return; + } + this.data = next; + this.map.update(this.mapData()); + this.paint(); + } + + setRange(r: Range) { + this.end(); + this.range = r; + this.map.setRange(r); + this.paint(); + } + + destroy() { + cancelAnimationFrame(this.raf); + clearTimeout(this.endTimer); + } + + private paint() { + const d = this.data; + const span = SPAN[this.range as keyof typeof SPAN]; + const from = d.now - span; + const v = visits(stretches(d.events ?? [], d.device.id, d.now, d.device.online, d.device.handshake), d.geo.points, d.device.id, from); + const share = shares(v); + this.st = replayStays(v); + const list = devicePlaces(this.mapData(), this.range); + const strips = v.length > 0; + this.el.classList.toggle('strips', strips); + this.el.classList.toggle('can-replay', this.st.length > 1); + this.rows.clear(); + dom.content( + this.el, + list.length + ? [ + ...list.map((x) => { + const key = placeKey(x); + const sh = share.get(key); + const strip = strips + ? E( + 'div', + { class: `dl-dplace-strip${x.online ? ' live' : ''}` }, + v + .filter((y) => y.key === key) + .map((y) => E('i', { style: `left:${pct(y.from - from, span)};width:${pct(y.to - y.from, span)}` })), + ) + : ''; + const row = E('div', { class: 'dl-dplace-row' }, [ + E('span', { class: `dl-dplace-n${x.online ? ' live' : ''}` }, x.online ? icon(d.device.kind) : String(x.n)), + E('span', { class: 'dl-row-main dl-stack' }, [ + E('span', {}, [x.city || x.cc || 'Unknown city', x.org ? E('span', { class: 'dl-muted' }, ` · ${x.org}`) : '']), + E('span', { class: 'dl-faint' }, [ + E('span', { class: 'dl-mono' }, x.ip), + sh != null ? ` · ${sh > 0 && sh < 0.005 ? '<1' : Math.round(sh * 100)}% of the time` : '', + ]), + ]), + E('span', { class: x.online ? 'dl-dplace-now' : 'dl-faint dl-nowrap' }, x.online ? 'now' : ago(x.ts, d.now)), + strip, + ]); + row.addEventListener('mouseenter', () => this.map.hoverPlace(key)); + row.addEventListener('mouseleave', () => this.map.hoverPlace(null)); + // The strips are the replay's timeline: a click or a drag on one goes to that moment. + if (strip) { + const seek = (ev: PointerEvent) => { + const r = strip.getBoundingClientRect(); + this.seek(from + span * Math.min(1, Math.max(0, (ev.clientX - r.left) / r.width))); + }; + strip.addEventListener('pointerdown', (ev) => { + strip.setPointerCapture(ev.pointerId); + seek(ev); + }); + strip.addEventListener('pointermove', (ev) => ev.buttons && seek(ev)); + } + this.rows.set(key, row); + return row; + }), + strips + ? E( + 'div', + { class: 'dl-dplace-axis' }, + ticks(this.range as keyof typeof SPAN, d.now).map(([f, label]) => + E('span', { style: `left:${(f * 100).toFixed(2)}%` }, label), + ), + ) + : '', + ] + : E('div', { class: 'dl-sub' }, 'No locations in this period.'), + ); + this.paintControls(); + } + + private paintControls() { + dom.content(this.play, icon(this.playing ? 'pause' : 'play')); + this.play.title = this.playing ? 'Pause' : 'Replay this period'; + this.play.setAttribute('aria-label', this.play.title); + // LuCI's dom.content takes one level of children: no nested arrays. + dom.content(this.controls, this.on ? [this.play, this.chip, this.stop] : this.st.length > 1 ? [this.play] : []); + } + + /* ---------- the replay ---------- */ + + private begin() { + this.on = true; + ({ steps: this.steps, total: this.total } = timeline(this.st, this.reduced ? 400 : MOVE_MS)); + this.ms = 0; + this.stepI = -1; + // The live place lets go; the first stay lights up on the first frame. + this.map.replay({ active: null, when: '' }, true); + } + + private toggle() { + if (this.playing) { + this.playing = false; + cancelAnimationFrame(this.raf); + this.paintControls(); + return; + } + clearTimeout(this.endTimer); + if (!this.on || this.ms >= this.total) this.begin(); + this.playing = true; + this.last = performance.now(); + this.paintControls(); + this.raf = requestAnimationFrame((t) => this.frame(t)); + } + + private frame(now: number) { + if (!this.playing) return; + this.ms = Math.min(this.total, this.ms + (now - this.last)); + this.last = now; + this.show(true); + if (this.ms < this.total) { + this.raf = requestAnimationFrame((t) => this.frame(t)); + return; + } + // At the end: a moment on the last place, then back to now. + this.playing = false; + this.paintControls(); + this.endTimer = window.setTimeout(() => this.end(), 1500); + } + + /** Moment `t` (a click on a strip): its place at once, paused there. */ + private seek(t: number) { + if (this.st.length < 2) return; + clearTimeout(this.endTimer); + if (!this.on) this.begin(); + this.ms = msAt(this.st, this.steps, t); + this.stepI = -1; + this.show(false); + this.paintControls(); + } + + /** The replay at `this.ms`: the map's light and shimmer, the strips' tick, the chip. */ + private show(animate: boolean) { + const m = moment(this.st, this.steps, this.ms); + const s = this.st[m.step.k]; + if (m.step.kind === 'move') { + const prev = this.st[m.step.k - 1]; + if (m.i !== this.stepI) { + // The place it leaves goes gray; the shimmer sets off from it. + this.map.replay({ active: null, when: '' }, animate); + this.map.band([prev.point.lon, prev.point.lat], [s.point.lon, s.point.lat]); + } + const c = bandMiddle(m.q); + if (!this.reduced) this.map.bandAt(c); + if (this.reduced ? m.q >= 0.5 : arrived(c)) this.map.replay({ active: s.key, when: clock(m.t) }, animate); + } else { + if (m.i !== this.stepI) this.map.band(); + this.map.replay({ active: s.key, when: clock(m.t) }, animate); + } + this.stepI = m.i; + const d = this.data; + const from = d.now - SPAN[this.range as keyof typeof SPAN]; + this.el.classList.add('replay'); + this.el.style.setProperty('--at', pct(m.t - from, d.now - from)); + for (const [k, r] of this.rows) r.classList.toggle('cur', k === s.key); + this.chip.textContent = `${dayName(m.t, d.now)}, ${clock(m.t)} · ${s.point.city || s.point.cc || '?'}`; + } + + /** Back to now: the map as it is, and whatever came while the replay ran. */ + private end() { + cancelAnimationFrame(this.raf); + clearTimeout(this.endTimer); + if (!this.on) return; + this.on = false; + this.playing = false; + this.ms = 0; + this.stepI = -1; + this.map.band(); + this.map.replay(null, false); + this.el.classList.remove('replay'); + for (const r of this.rows.values()) r.classList.remove('cur'); + if (this.pending) { + this.data = this.pending; + this.pending = null; + this.map.update(this.mapData()); + this.paint(); + } else this.paintControls(); + } +} diff --git a/web/src/admin/styles/map.css b/web/src/admin/styles/map.css index bf1f3a3..0775907 100644 --- a/web/src/admin/styles/map.css +++ b/web/src/admin/styles/map.css @@ -51,6 +51,43 @@ .dl-dplace-n.live { background: #3b82f6; color: #fff; } .dl-dplace-n .dl-icon { width: 12px; height: 12px; } .dl-dplace-now { color: #3b82f6; } +/* With the log's connections, each place has a strip: when the device was there in the range (the + live place's blue). The highlight (hover, the replay's place) reaches past the content on both + sides, the separators stay with the content. */ +.dl-dplaces.strips .dl-dplace-row { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; column-gap: 10px; row-gap: 9px; + margin: 0 -10px; padding: 11px 10px; border-top: 0; border-radius: 10px; transition: background .15s; } +.dl-dplaces.strips .dl-dplace-row + .dl-dplace-row::before { content: ''; position: absolute; left: 10px; right: 10px; top: 0; height: 1px; background: var(--dl-line); } +.dl-dplaces.strips .dl-dplace-row:is(:hover, .cur) { background: var(--dl-soft); } +.dl-dplaces.strips .dl-dplace-row:is(:hover, .cur)::before, .dl-dplaces.strips .dl-dplace-row:is(:hover, .cur) + .dl-dplace-row::before { opacity: 0; } +.dl-dplace-strip { grid-column: 2 / 4; position: relative; height: 6px; border-radius: 3px; background: var(--dl-track); } +.dl-dplaces.can-replay .dl-dplace-strip { cursor: ew-resize; touch-action: none; } +.dl-dplace-strip i { position: absolute; top: 0; bottom: 0; min-width: 2px; border-radius: 2px; background: #8a8a8a; } +.dl-dplace-strip.live i { background: #3b82f6; } +/* The replay's moment: a tick on every strip. */ +.dl-dplaces.replay .dl-dplace-strip::after { content: ''; position: absolute; left: var(--at); top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; + background: var(--dl-fg); box-shadow: 0 0 0 2px var(--dialog-bg, var(--dl-elevated)); pointer-events: none; } +.dl-dplace-axis { position: relative; height: 16px; margin: 4px 0 0 30px; font-size: 11px; line-height: 16px; color: var(--dl-fg-faint); } +.dl-dplace-axis span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; } +/* The replay's controls in the map's top corner, and the place it lights. */ +.dl-dmap { position: relative; } +.dl-map-replay { position: absolute; left: 10px; top: 10px; z-index: 3; display: flex; align-items: center; gap: 6px; } +.dl-map-btn { all: unset; box-sizing: border-box; cursor: pointer; width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; + background: var(--dl-elevated); border: 1px solid var(--dl-line); color: var(--dl-fg); } +.dl-map-btn:hover { background: color-mix(in srgb, var(--dl-fg) 8%, var(--dl-elevated)); } +.dl-map-btn:focus-visible { outline: 2px solid var(--dl-ring); } +.dl-map-btn .dl-icon { width: 13px; height: 13px; } +.dl-map-chip { display: inline-flex; align-items: center; height: 28px; box-sizing: border-box; padding: 0 10px; border-radius: 8px; font-size: 11.5px; white-space: nowrap; + background: var(--dl-elevated); border: 1px solid var(--dl-line); color: var(--dl-fg); font-variant-numeric: tabular-nums; } +.dl-mk.step .dl-mk-tile { transition: width .3s cubic-bezier(.2, .8, .2, 1), height .3s cubic-bezier(.2, .8, .2, 1), border-radius .3s, background-color .3s, color .3s, + box-shadow .3s, transform .24s; } +.dl-mk.step .dl-mk-tile.sm .dl-mk-tile-ic { width: 11px; height: 11px; } +.dl-mk.step.faded > * { opacity: .5; } +/* The place in the light (or hovered in the list) over its neighbours, its name readable. */ +.dl-mk.step:is(.online, .hl) { z-index: 2; } +.dl-mk.step.hl .dl-mk-tile { box-shadow: 0 0 0 3px color-mix(in srgb, #3b82f6 55%, transparent); } +.dl-mk.step.arrive .dl-mk-tile { animation: dl-mk-arrive .45s cubic-bezier(.2, .8, .2, 1); } +@keyframes dl-mk-arrive { 0% { transform: scale(.8); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } } +.dl-mk-when.inline { display: inline; } /* 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. */ .dl-mk > * { transition: opacity .15s; opacity: var(--dl-mk-fade, 1); } @@ -116,14 +153,15 @@ .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; } +/* A device's few places keep their names at any distance. */ +.dl-lod-far .dl-mk:not(.step) .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; } } +@media (prefers-reduced-motion: reduce) { .dl-mk-dock, .dl-mk-pile-box, .dl-mk-face, .dl-mk-av, .dl-mk-tile, .dl-mk.step .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. */ .dl-mk-ptr { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: -1; pointer-events: none; } diff --git a/web/src/admin/styles/overview.css b/web/src/admin/styles/overview.css index 6a51000..35a0a8e 100644 --- a/web/src/admin/styles/overview.css +++ b/web/src/admin/styles/overview.css @@ -99,6 +99,8 @@ .dl-disg-ic { width: 36px; height: 36px; border-radius: 11px; background: color-mix(in srgb, var(--dl-accent) 14%, transparent); color: var(--dl-accent); display: inline-flex; align-items: center; justify-content: center; flex: none; } .dl-disg-ic .dl-icon-wrap { display: inline-flex; } .dl-disg-ic .dl-icon { width: 18px; height: 18px; } +/* No disguise: gray, as the picker's unselected methods. */ +.dl-disg-ic.off { background: var(--dl-soft); color: var(--dl-fg-muted); } .dl-disg-meters { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; font-size: 12px; color: var(--dl-fg-muted); } .dl-segs { display: inline-flex; gap: 3px; } .dl-segs i { width: 18px; height: 5px; border-radius: 3px; background: var(--dl-track); } .dl-segs.acc i.on { background: var(--dl-accent); } .dl-segs.ok i.on { background: var(--dl-ok); } diff --git a/web/src/admin/styles/people.css b/web/src/admin/styles/people.css index 4465ab6..caab35b 100644 --- a/web/src/admin/styles/people.css +++ b/web/src/admin/styles/people.css @@ -34,8 +34,9 @@ .dl-chip:hover { background: var(--dl-soft-hover); } .dl-chip:focus-visible { outline: 2px solid var(--dl-ring); outline-offset: 2px; } .dl-chip .dl-icon { width: 14px; height: 14px; color: var(--dl-fg-muted); } -.dl-chip.add { background: transparent; box-shadow: inset 0 0 0 1px var(--dl-line); color: var(--dl-fg-muted); aspect-ratio: 1; padding: 0; justify-content: center; } -.dl-chip.add:hover { background: var(--dl-soft); color: var(--dl-fg); } +.dl-chip.add { background: transparent; border: 1px dashed color-mix(in srgb, var(--dl-fg) 28%, transparent); color: var(--dl-fg-muted); } +.dl-chip.add:hover { background: var(--dl-soft); color: var(--dl-fg); border-color: color-mix(in srgb, var(--dl-fg) 45%, transparent); } +.dl-chip.add:hover .dl-icon { color: var(--dl-fg); } .dl-chip.disabled .dl-chip-name { text-decoration: line-through; color: var(--dl-fg-faint); } .dl-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .dl-dot { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: var(--dl-fg-faint); opacity: .6; } diff --git a/web/tests/places.test.ts b/web/tests/places.test.ts new file mode 100644 index 0000000..2739320 --- /dev/null +++ b/web/tests/places.test.ts @@ -0,0 +1,176 @@ +import { describe, expect, it } from 'vitest'; +import { + BAND, + FLAT, + arrived, + bandMiddle, + moment, + msAt, + placeKey, + replayStays, + shares, + shimmerOpacity, + stays, + stretches, + ticks, + timeline, + visits, +} from '../src/admin/places/model'; +import type { GeoPoint, LogEvent } from '../src/shared/types'; + +const D = 'd_1'; +const ev = (ts: number, type: string, detail?: string, device = D): LogEvent => ({ ts, type, detail, device, person: 'p' }); +const pt = (ip: string, city: string, lat: number, lon: number, device = D): GeoPoint => ({ + person: 'p', + device, + ip, + ts: 0, + online: false, + lat, + lon, + city, + country: 'Russia', + cc: 'RU', + asn: 1, + org: `${city} ISP`, +}); +const HOME = pt('37.78.36.76', 'Krasnodar', 45.04, 38.98); +const MOBILE = pt('85.249.175.96', 'Novocherkassk', 47.42, 40.09); + +describe('stretches', () => { + it('follows connects, roams and disconnects', () => { + const list = stretches( + [ + ev(100, 'connect', HOME.ip), + ev(200, 'roam', `${HOME.ip} → ${MOBILE.ip}`), + ev(300, 'disconnect'), + ev(400, 'connect', HOME.ip), + ev(150, 'connect', 'x', 'other'), + ], + D, + 1000, + true, + ); + expect(list).toEqual([ + { ip: HOME.ip, from: 100, to: 200, live: false }, + { ip: MOBILE.ip, from: 200, to: 300, live: false }, + { ip: HOME.ip, from: 400, to: 1000, live: true }, + ]); + }); + + it('ends an open stretch at the last handshake when the device is offline', () => { + expect(stretches([ev(100, 'connect', HOME.ip)], D, 1000, false, 600)).toEqual([{ ip: HOME.ip, from: 100, to: 600, live: false }]); + expect(stretches([ev(100, 'connect', HOME.ip)], D, 1000, false)).toEqual([]); + }); + + it('closes a stretch at a connect the log saw without a disconnect, and sorts by time', () => { + expect(stretches([ev(300, 'connect', MOBILE.ip), ev(100, 'connect', HOME.ip)], D, 400, false, 350)).toEqual([ + { ip: HOME.ip, from: 100, to: 300, live: false }, + { ip: MOBILE.ip, from: 300, to: 350, live: false }, + ]); + }); + + it('is empty without connections in the log', () => { + expect(stretches([ev(100, 'device_added', 'Phone')], D, 1000, true)).toEqual([]); + }); +}); + +describe('visits and stays', () => { + const s = stretches( + [ + ev(0, 'connect', HOME.ip), + ev(3600, 'roam', `${HOME.ip} → ${MOBILE.ip}`), + ev(3900, 'roam', `${MOBILE.ip} → ${HOME.ip}`), // 5 min on mobile data + ev(7200, 'roam', `${HOME.ip} → ${MOBILE.ip}`), + ev(18000, 'roam', `${MOBILE.ip} → 10.0.0.9`), // not located: left out + ev(19000, 'roam', `10.0.0.9 → ${HOME.ip}`), + ], + D, + 20000, + true, + ); + const v = visits(s, [HOME, MOBILE, pt(HOME.ip, 'Elsewhere', 1, 1, 'other')], D, 1800); + + it('keeps located addresses at their place, clipped to the range', () => { + expect(v.map((x) => [x.key, x.from, x.to])).toEqual([ + ['Krasnodar|RU', 1800, 3600], + ['Novocherkassk|RU', 3600, 3900], + ['Krasnodar|RU', 3900, 7200], + ['Novocherkassk|RU', 7200, 18000], + ['Krasnodar|RU', 19000, 20000], + ]); + expect(v[0].point.city).toBe('Krasnodar'); + }); + + it('shares the time by place', () => { + const sh = shares(v); + expect(sh.get('Krasnodar|RU')! + sh.get('Novocherkassk|RU')!).toBeCloseTo(1); + expect(sh.get('Novocherkassk|RU')).toBeCloseTo(11100 / 17200); + }); + + it('folds short visits into the stay around them', () => { + const st = stays(v); + expect(st.map((x) => [x.key, x.from, x.to, x.short, x.live])).toEqual([ + ['Krasnodar|RU', 1800, 7200, 1, false], + ['Novocherkassk|RU', 7200, 18000, 0, false], + ['Krasnodar|RU', 19000, 20000, 0, true], + ]); + }); + + it('folds for a replay only as far as needed', () => { + expect(replayStays(v).length).toBe(5); // few moves: every one + expect(replayStays(v, 2).map((x) => x.key)).toEqual(['Krasnodar|RU', 'Novocherkassk|RU', 'Krasnodar|RU']); + }); + + it('keys places like the map: the city, or rounded coordinates', () => { + expect(placeKey(HOME)).toBe('Krasnodar|RU'); + expect(placeKey({ city: '', lat: 45.0449, lon: 38.981, cc: 'RU' })).toBe('45.0,39.0|RU'); + }); +}); + +describe('replay', () => { + const st = stays( + visits(stretches([ev(0, 'connect', HOME.ip), ev(36000, 'roam', `${HOME.ip} → ${MOBILE.ip}`)], D, 40000, true), [HOME, MOBILE], D, 0), + ); + const { steps, total } = timeline(st, 1000); + + it('plays a move before each stay but the first, stays held within bounds', () => { + expect(steps.map((s) => s.kind)).toEqual(['stay', 'move', 'stay']); + expect(steps[0].ms).toBe(450); // 10 h + expect(steps[2].ms).toBe(350); // an hour: the shortest hold + expect(total).toBe(450 + 1000 + 350); + }); + + it('finds the moment for a time and back', () => { + expect(moment(st, steps, 0).t).toBe(0); + expect(moment(st, steps, 500)).toMatchObject({ i: 1, t: 36000 }); + expect(moment(st, steps, total).t).toBe(40000); + const ms = msAt(st, steps, 38000); + expect(moment(st, steps, ms).t).toBeCloseTo(38000, -1); + }); + + it('runs the shimmer from before the place it leaves to past the next', () => { + expect(bandMiddle(0)).toBeCloseTo(-BAND / 2); + expect(bandMiddle(1)).toBeCloseTo(1 + BAND / 2); + expect(arrived(bandMiddle(0.3))).toBe(false); + expect(arrived(1 - FLAT)).toBe(true); + const ex = shimmerOpacity(0.5); + expect(ex[0]).toBe('interpolate'); + expect(ex.slice(3)).toEqual([0, 1, FLAT, 1, BAND / 2, 0]); + }); +}); + +describe('ticks', () => { + const now = Date.UTC(2026, 9, 18, 21, 0) / 1000; + it('labels days for a week, inside the strip', () => { + const t = ticks('7d', now); + expect(t.length).toBeGreaterThanOrEqual(6); + expect(t.every(([f]) => f > 0 && f < 1)).toBe(true); + expect(t.map(([f]) => f)).toEqual([...t.map(([f]) => f)].sort((a, b) => a - b)); + }); + it('labels every six hours for a day', () => { + const t = ticks('24h', now); + expect(t.length).toBeGreaterThanOrEqual(3); + expect(t.every(([, l]) => /^\d\d:00$/.test(l))).toBe(true); + }); +});