diff --git a/src/static/app/dist/assets/index.js b/src/static/app/dist/assets/index.js index 9a6a36f..3a5d430 100644 --- a/src/static/app/dist/assets/index.js +++ b/src/static/app/dist/assets/index.js @@ -65,4 +65,4 @@ The chosen QR Code version cannot contain this amount of data. Minimum version required to store current data is: `+o+`. `);const r=nW(t,n,i),a=Cu.getSymbolSize(t),l=new Yj(a);return Xj(l,t),Qj(l),Zj(l,t),Dd(l,n,0),t>=7&&eW(l,t),tW(l,r),isNaN(s)&&(s=Th.getBestMask(l,Dd.bind(null,l,n))),Th.applyMask(s,l),Dd(l,n,s),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:s,segments:i}}M1.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let s=Td.M,i,o;return typeof n<"u"&&(s=Td.from(n.errorCorrectionLevel,Td.M),i=Yc.from(n.version),o=Th.from(n.maskPattern),n.toSJISFunc&&Cu.setToSJISFunction(n.toSJISFunc)),iW(t,i,s,o)};var z1={},cp={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(o){return[o,o]}))),s.length===6&&s.push("F","F");const i=parseInt(s.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const i=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,o=s.width&&s.width>=21?s.width:void 0,r=s.scale||4;return{width:o,scale:o?4:r,margin:i,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,i){return i.width&&i.width>=s+i.margin*2?i.width/(s+i.margin*2):i.scale},e.getImageWidth=function(s,i){const o=e.getScale(s,i);return Math.floor((s+i.margin*2)*o)},e.qrToImageData=function(s,i,o){const r=i.modules.size,a=i.modules.data,l=e.getScale(r,o),c=Math.floor((r+o.margin*2)*l),u=o.margin*l,d=[o.color.light,o.color.dark];for(let f=0;f=u&&p>=u&&f"u"&&(!r||!r.getContext)&&(l=r,r=void 0),r||(c=s()),l=t.getOptions(l);const u=t.getImageWidth(o.modules.size,l),d=c.getContext("2d"),f=d.createImageData(u,u);return t.qrToImageData(f.data,o,l),n(d,c,u),d.putImageData(f,0,0),c},e.renderToDataURL=function(o,r,a){let l=a;typeof l>"u"&&(!r||!r.getContext)&&(l=r,r=void 0),l||(l={});const c=e.render(o,r,l),u=l.type||"image/png",d=l.rendererOpts||{};return c.toDataURL(u,d.quality)}})(z1);var Y1={};const oW=cp;function mv(e,t){const n=e.a/255,s=t+'="'+e.hex+'"';return n<1?s+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':s}function Od(e,t,n){let s=e+t;return typeof n<"u"&&(s+=" "+n),s}function rW(e,t,n){let s="",i=0,o=!1,r=0;for(let a=0;a0&&l>0&&e[a-1]||(s+=o?Od("M",l+n,.5+c+n):Od("m",i,0),i=0,o=!1),l+1':"",c="',u='viewBox="0 0 '+a+" "+a+'"',f=''+l+c+` `;return typeof s=="function"&&s(null,f),f};const aW=yj,Dh=M1,U1=z1,lW=Y1;function up(e,t,n,s,i){const o=[].slice.call(arguments,1),r=o.length,a=typeof o[r-1]=="function";if(!a&&!aW())throw new Error("Callback required as last argument");if(a){if(r<2)throw new Error("Too few arguments provided");r===2?(i=n,n=t,t=s=void 0):r===3&&(t.getContext&&typeof i>"u"?(i=s,s=void 0):(i=s,s=n,n=t,t=void 0))}else{if(r<1)throw new Error("Too few arguments provided");return r===1?(n=t,t=s=void 0):r===2&&!t.getContext&&(s=n,n=t,t=void 0),new Promise(function(l,c){try{const u=Dh.create(n,s);l(e(u,t,s))}catch(u){c(u)}})}try{const l=Dh.create(n,s);i(null,e(l,t,s))}catch(l){i(l)}}Bo.create=Dh.create;Bo.toCanvas=up.bind(null,U1.render);Bo.toDataURL=up.bind(null,U1.renderToDataURL);Bo.toString=up.bind(null,function(e,t,n){return lW.render(e,n)});const cW={name:"peerQRCode",props:{peerConfigData:String},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfigData,e=>{e&&console.error(e)})}},uW={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0"},dW={class:"container d-flex h-100 w-100"},hW={class:"m-auto modal-dialog-centered dashboardModal justify-content-center"},fW={class:"card rounded-3 shadow"},pW={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},gW=h("h4",{class:"mb-0"},"QR Code",-1),mW={class:"card-body"},_W={id:"qrcode",class:"rounded-3 shadow",ref:"qrcode"};function vW(e,t,n,s,i,o){return O(),F("div",uW,[h("div",dW,[h("div",hW,[h("div",fW,[h("div",pW,[gW,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=r=>this.$emit("close"))})]),h("div",mW,[h("canvas",_W,null,512)])])])])])}const bW=ze(cW,[["render",vW]]),yW={name:"nameInput",props:{bulk:Boolean,data:Object,saving:Boolean}},wW=h("label",{for:"peer_name_textbox",class:"form-label"},[h("small",{class:"text-muted"},"Name")],-1),xW=["disabled"];function kW(e,t,n,s,i,o){return O(),F("div",{class:Ee({inactiveField:this.bulk})},[wW,Re(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving||this.bulk,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.name=r),id:"peer_name_textbox",placeholder:""},null,8,xW),[[We,this.data.name]])],2)}const SW=ze(yW,[["render",kW]]),AW={name:"privatePublicKeyInput",props:{data:Object,saving:Boolean,bulk:Boolean},setup(){return{dashboardStore:et()}},data(){return{keypair:{publicKey:"",privateKey:"",presharedKey:""},editKey:!1,error:!1}},methods:{genKeyPair(){this.editKey=!1,this.keypair=window.wireguard.generateKeypair(),this.data.private_key=this.keypair.privateKey,this.data.public_key=this.keypair.publicKey},checkMatching(){try{window.wireguard.generatePublicKey(this.keypair.privateKey)!==this.keypair.publicKey&&(this.error=!0,this.dashboardStore.newMessage("WGDashboard","Private Key and Public Key does not match.","danger"))}catch{this.error=!0,this.data.private_key="",this.data.public_key=""}}},mounted(){this.genKeyPair()},watch:{keypair:{deep:!0,handler(){this.error=!1,this.checkMatching()}}}},$W=h("label",{for:"peer_private_key_textbox",class:"form-label"},[h("small",{class:"text-muted"},[ye("Private Key "),h("code",null,"(Required for QR Code and Download)")])],-1),CW={class:"input-group"},EW=["disabled"],PW=["disabled"],TW=h("i",{class:"bi bi-arrow-repeat"},null,-1),MW=[TW],DW={class:"d-flex"},OW=h("label",{for:"public_key",class:"form-label"},[h("small",{class:"text-muted"},[ye("Public Key "),h("code",null,"(Required)")])],-1),IW={class:"form-check form-switch ms-auto"},RW=["disabled"],LW=h("label",{class:"form-check-label",for:"enablePublicKeyEdit"},[h("small",null,"Edit")],-1),NW=["disabled"];function FW(e,t,n,s,i,o){return O(),F("div",{class:Ee(["d-flex gap-2 flex-column",{inactiveField:this.bulk}])},[h("div",null,[$W,h("div",CW,[Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-start-3",{"is-invalid":this.error}]),"onUpdate:modelValue":t[0]||(t[0]=r=>this.keypair.privateKey=r),disabled:!this.editKey||this.bulk,onBlur:t[1]||(t[1]=r=>this.checkMatching()),id:"peer_private_key_textbox"},null,42,EW),[[We,this.keypair.privateKey]]),h("button",{class:"btn btn-outline-info btn-sm rounded-end-3",onClick:t[2]||(t[2]=r=>this.genKeyPair()),disabled:this.bulk,type:"button",id:"button-addon2"},MW,8,PW)])]),h("div",null,[h("div",DW,[OW,h("div",IW,[Re(h("input",{class:"form-check-input",type:"checkbox",role:"switch",disabled:this.bulk,id:"enablePublicKeyEdit","onUpdate:modelValue":t[3]||(t[3]=r=>this.editKey=r)},null,8,RW),[[In,this.editKey]]),LW])]),Re(h("input",{class:Ee(["form-control-sm form-control rounded-3",{"is-invalid":this.error}]),"onUpdate:modelValue":t[4]||(t[4]=r=>this.keypair.publicKey=r),onBlur:t[5]||(t[5]=r=>this.checkMatching()),disabled:!this.editKey||this.bulk,type:"text",id:"public_key"},null,42,NW),[[We,this.keypair.publicKey]])])],2)}const BW=ze(AW,[["render",FW]]),VW={name:"allowedIPsInput",props:{data:Object,saving:Boolean,bulk:Boolean,availableIp:void 0},data(){return{allowedIp:[],availableIpSearchString:"",customAvailableIp:"",allowedIpFormatError:!1}},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},computed:{searchAvailableIps(){return this.availableIpSearchString?this.availableIp.filter(e=>e.includes(this.availableIpSearchString)&&!this.data.allowed_ips.includes(e)):this.availableIp.filter(e=>!this.data.allowed_ips.includes(e))}},methods:{addAllowedIp(e){return this.store.checkCIDR(e)?(this.data.allowed_ips.push(e),!0):!1}},watch:{customAvailableIp(){this.allowedIpFormatError=!1},availableIp(){this.availableIp!==void 0&&this.availableIp.length>0&&this.addAllowedIp(this.availableIp[0])}},mounted(){}},pl=e=>(Kt("data-v-2af3b91a"),e=e(),qt(),e),HW=pl(()=>h("label",{for:"peer_allowed_ip_textbox",class:"form-label"},[h("small",{class:"text-muted"},[ye("Allowed IPs "),h("code",null,"(Required)")])],-1)),jW=["onClick"],WW=pl(()=>h("i",{class:"bi bi-x-circle-fill ms-1"},null,-1)),zW=[WW],YW={class:"d-flex gap-2 align-items-center"},UW={class:"input-group"},KW=["disabled"],qW=["disabled"],GW=pl(()=>h("i",{class:"bi bi-plus-lg"},null,-1)),JW=[GW],XW=pl(()=>h("small",{class:"text-muted"},"or",-1)),QW={class:"dropdown flex-grow-1"},ZW=["disabled"],ez=pl(()=>h("i",{class:"bi bi-filter-circle me-2"},null,-1)),tz={key:0,class:"dropdown-menu mt-2 shadow w-100 dropdown-menu-end rounded-3",style:{"overflow-y":"scroll","max-height":"270px",width:"300px !important"}},nz={class:"px-3 pb-2 pt-1"},sz=["onClick"],iz={class:"me-auto"},oz={key:0},rz={class:"px-3 text-muted"};function az(e,t,n,s,i,o){return O(),F("div",{class:Ee({inactiveField:this.bulk})},[HW,h("div",{class:Ee(["d-flex gap-2 flex-wrap",{"mb-2":this.data.allowed_ips.length>0}])},[$e(Wi,{name:"list"},{default:Te(()=>[(O(!0),F(Me,null,Ke(this.data.allowed_ips,(r,a)=>(O(),F("span",{class:"badge rounded-pill text-bg-success",key:r},[ye(ve(r)+" ",1),h("a",{role:"button",onClick:l=>this.data.allowed_ips.splice(a,1)},zW,8,jW)]))),128))]),_:1})],2),h("div",YW,[h("div",UW,[Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-start-3",{"is-invalid":this.allowedIpFormatError}]),placeholder:"Enter IP Address/CIDR","onUpdate:modelValue":t[0]||(t[0]=r=>i.customAvailableIp=r),disabled:n.bulk},null,10,KW),[[We,i.customAvailableIp]]),h("button",{class:"btn btn-outline-success btn-sm rounded-end-3",disabled:n.bulk||!this.customAvailableIp,onClick:t[1]||(t[1]=r=>{this.addAllowedIp(this.customAvailableIp)?this.customAvailableIp="":this.allowedIpFormatError=!0,this.dashboardStore.newMessage("WGDashboard","Allowed IP is invalid","danger")}),type:"button",id:"button-addon2"},JW,8,qW)]),XW,h("div",QW,[h("button",{class:"btn btn-outline-secondary btn-sm dropdown-toggle rounded-3 w-100",disabled:!n.availableIp||n.bulk,"data-bs-auto-close":"outside",type:"button","data-bs-toggle":"dropdown","aria-expanded":"false"},[ez,ye(" Pick Available IP ")],8,ZW),this.availableIp?(O(),F("ul",tz,[h("li",null,[h("div",nz,[Re(h("input",{class:"form-control form-control-sm rounded-3","onUpdate:modelValue":t[2]||(t[2]=r=>this.availableIpSearchString=r),placeholder:"Search..."},null,512),[[We,this.availableIpSearchString]])])]),(O(!0),F(Me,null,Ke(this.searchAvailableIps,r=>(O(),F("li",null,[h("a",{class:"dropdown-item d-flex",role:"button",onClick:a=>this.addAllowedIp(r)},[h("span",iz,[h("small",null,ve(r),1)])],8,sz)]))),256)),this.searchAvailableIps.length===0?(O(),F("li",oz,[h("small",rz,'No available IP containing "'+ve(this.availableIpSearchString)+'"',1)])):ae("",!0)])):ae("",!0)])])],2)}const lz=ze(VW,[["render",az],["__scopeId","data-v-2af3b91a"]]),cz={name:"dnsInput",props:{data:Object,saving:Boolean},data(){return{error:!1,dns:JSON.parse(JSON.stringify(this.data.DNS))}},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},methods:{checkDNS(){if(this.dns){let e=this.dns.split(",").map(t=>t.replaceAll(" ",""));for(let t in e)if(!this.store.regexCheckIP(e[t])){this.error||this.dashboardStore.newMessage("WGDashboard","DNS is invalid","danger"),this.error=!0,this.data.DNS="";return}this.error=!1,this.data.DNS=this.dns}}},watch:{dns(){this.checkDNS()}}},uz=h("label",{for:"peer_DNS_textbox",class:"form-label"},[h("small",{class:"text-muted"},"DNS")],-1),dz=["disabled"];function hz(e,t,n,s,i,o){return O(),F("div",null,[uz,Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-3",{"is-invalid":this.error}]),disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.dns=r),id:"peer_DNS_textbox"},null,10,dz),[[We,this.dns]])])}const fz=ze(cz,[["render",hz]]),pz={name:"endpointAllowedIps",props:{data:Object,saving:Boolean},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},data(){return{endpointAllowedIps:JSON.parse(JSON.stringify(this.data.endpoint_allowed_ip)),error:!1}},methods:{checkAllowedIP(){let e=this.endpointAllowedIps.split(",").map(t=>t.replaceAll(" ",""));for(let t in e)if(!this.store.checkCIDR(e[t])){this.error||this.dashboardStore.newMessage("WGDashboard","Endpoint Allowed IP is invalid.","danger"),this.data.endpoint_allowed_ip="",this.error=!0;return}this.error=!1,this.data.endpoint_allowed_ip=this.endpointAllowedIps}},watch:{endpointAllowedIps(){this.checkAllowedIP()}}},gz=h("label",{for:"peer_endpoint_allowed_ips",class:"form-label"},[h("small",{class:"text-muted"},[ye("Endpoint Allowed IPs "),h("code",null,"(Required)")])],-1),mz=["disabled"];function _z(e,t,n,s,i,o){return O(),F("div",null,[gz,Re(h("input",{type:"text",class:Ee(["form-control form-control-sm rounded-3",{"is-invalid":i.error}]),disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.endpointAllowedIps=r),onBlur:t[1]||(t[1]=r=>this.checkAllowedIP()),id:"peer_endpoint_allowed_ips"},null,42,mz),[[We,this.endpointAllowedIps]])])}const vz=ze(pz,[["render",_z]]),bz={name:"presharedKeyInput",props:{data:Object,saving:Boolean}},yz=h("label",{for:"peer_preshared_key_textbox",class:"form-label"},[h("small",{class:"text-muted"},"Pre-Shared Key")],-1),wz=["disabled"];function xz(e,t,n,s,i,o){return O(),F("div",null,[yz,Re(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.preshared_key=r),id:"peer_preshared_key_textbox"},null,8,wz),[[We,this.data.preshared_key]])])}const kz=ze(bz,[["render",xz]]),Sz={name:"mtuInput",props:{data:Object,saving:Boolean}},Az=h("label",{for:"peer_mtu",class:"form-label"},[h("small",{class:"text-muted"},"MTU")],-1),$z=["disabled"];function Cz(e,t,n,s,i,o){return O(),F("div",null,[Az,Re(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.mtu=r),id:"peer_mtu"},null,8,$z),[[We,this.data.mtu]])])}const Ez=ze(Sz,[["render",Cz]]),Pz={name:"persistentKeepAliveInput",props:{data:Object,saving:Boolean}},Tz=h("label",{for:"peer_keep_alive",class:"form-label"},[h("small",{class:"text-muted"},"Persistent Keepalive")],-1),Mz=["disabled"];function Dz(e,t,n,s,i,o){return O(),F("div",null,[Tz,Re(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=r=>this.data.keepalive=r),id:"peer_keep_alive"},null,8,Mz),[[We,this.data.keepalive]])])}const Oz=ze(Pz,[["render",Dz]]),Iz={name:"bulkAdd",props:{saving:Boolean,data:Object,availableIp:void 0}},Rz={class:"form-check form-switch"},Lz=["disabled"],Nz=h("label",{class:"form-check-label me-2",for:"bulk_add"},[h("small",null,[h("strong",null,"Bulk Add")])],-1),Fz=h("small",{class:"text-muted d-block"}," By adding peers by bulk, each peer's name will be auto generated, and Allowed IP will be assign to the next available IP. ",-1),Bz=[Fz],Vz={key:0,class:"form-group"},Hz=["max"],jz={class:"text-muted"};function Wz(e,t,n,s,i,o){return O(),F("div",null,[h("div",Rz,[Re(h("input",{class:"form-check-input",type:"checkbox",role:"switch",disabled:!this.availableIp,id:"bulk_add","onUpdate:modelValue":t[0]||(t[0]=r=>this.data.bulkAdd=r)},null,8,Lz),[[In,this.data.bulkAdd]]),Nz]),h("p",{class:Ee({"mb-0":!this.data.bulkAdd})},Bz,2),this.data.bulkAdd?(O(),F("div",Vz,[Re(h("input",{class:"form-control form-control-sm rounded-3 mb-1",type:"number",min:"1",max:this.availableIp.length,"onUpdate:modelValue":t[1]||(t[1]=r=>this.data.bulkAddAmount=r),placeholder:"How many peers you want to add?"},null,8,Hz),[[We,this.data.bulkAddAmount]]),h("small",jz,[ye(" You can add up to "),h("strong",null,ve(this.availableIp.length),1),ye(" peers ")])])):ae("",!0)])}const zz=ze(Iz,[["render",Wz]]),Yz={name:"peerCreate",components:{BulkAdd:zz,PersistentKeepAliveInput:Oz,MtuInput:Ez,PresharedKeyInput:kz,EndpointAllowedIps:vz,DnsInput:fz,AllowedIPsInput:lz,PrivatePublicKeyInput:BW,NameInput:SW},data(){return{data:{bulkAdd:!1,bulkAddAmount:"",name:"",allowed_ips:[],private_key:"",public_key:"",DNS:this.dashboardStore.Configuration.Peers.peer_global_dns,endpoint_allowed_ip:this.dashboardStore.Configuration.Peers.peer_endpoint_allowed_ip,keepalive:parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive),mtu:parseInt(this.dashboardStore.Configuration.Peers.peer_mtu),preshared_key:""},availableIp:void 0,availableIpSearchString:"",saving:!1,allowedIpDropdown:void 0}},mounted(){Tt("/api/getAvailableIPs/"+this.$route.params.id,{},e=>{e.status&&(this.availableIp=e.data)})},setup(){const e=Bn(),t=et();return{store:e,dashboardStore:t}},methods:{peerCreate(){this.saving=!0,dt("/api/addPeers/"+this.$route.params.id,this.data,e=>{e.status?(this.$router.push(`/configuration/${this.$route.params.id}/peers`),this.dashboardStore.newMessage("Server","Peer create successfully","success")):this.dashboardStore.newMessage("Server",e.message,"danger"),this.saving=!1})}},computed:{allRequireFieldsFilled(){let e=!0;return this.data.bulkAdd?(this.data.bulkAddAmount.length===0||this.data.bulkAddAmount>this.availableIp.length)&&(e=!1):["allowed_ips","private_key","public_key","endpoint_allowed_ip","keepalive","mtu"].forEach(n=>{this.data[n].length===0&&(e=!1)}),e}},watch:{bulkAdd(e){e||(this.data.bulkAddAmount="")},"data.bulkAddAmount"(){this.data.bulkAddAmount>this.availableIp.length&&(this.data.bulkAddAmount=this.availableIp.length)}}},Eu=e=>(Kt("data-v-c3292318"),e=e(),qt(),e),Uz={class:"container"},Kz={class:"mb-4"},qz=Eu(()=>h("h3",{class:"mb-0 text-body"},[h("i",{class:"bi bi-chevron-left"})],-1)),Gz=Eu(()=>h("h3",{class:"text-body mb-0"},"Add Peers",-1)),Jz={class:"d-flex flex-column gap-2"},Xz=Eu(()=>h("hr",{class:"mb-0 mt-2"},null,-1)),Qz=Eu(()=>h("hr",{class:"mb-0 mt-2"},null,-1)),Zz={class:"row"},eY={key:0,class:"col-sm"},tY={class:"col-sm"},nY={class:"col-sm"},sY={class:"d-flex mt-2"},iY=["disabled"],oY={key:0,class:"bi bi-plus-circle-fill me-2"};function rY(e,t,n,s,i,o){const r=je("RouterLink"),a=je("BulkAdd"),l=je("NameInput"),c=je("PrivatePublicKeyInput"),u=je("AllowedIPsInput"),d=je("EndpointAllowedIps"),f=je("DnsInput"),p=je("PresharedKeyInput"),m=je("MtuInput"),_=je("PersistentKeepAliveInput");return O(),F("div",Uz,[h("div",Kz,[$e(r,{to:"peers",is:"div",class:"d-flex align-items-center gap-4 text-decoration-none"},{default:Te(()=>[qz,Gz]),_:1})]),h("div",Jz,[$e(a,{saving:i.saving,data:this.data,availableIp:this.availableIp},null,8,["saving","data","availableIp"]),Xz,this.data.bulkAdd?ae("",!0):(O(),Ne(l,{key:0,saving:i.saving,data:this.data},null,8,["saving","data"])),this.data.bulkAdd?ae("",!0):(O(),Ne(c,{key:1,saving:i.saving,data:i.data},null,8,["saving","data"])),this.data.bulkAdd?ae("",!0):(O(),Ne(u,{key:2,availableIp:this.availableIp,saving:i.saving,data:i.data},null,8,["availableIp","saving","data"])),$e(d,{saving:i.saving,data:i.data},null,8,["saving","data"]),$e(f,{saving:i.saving,data:i.data},null,8,["saving","data"]),Qz,h("div",Zz,[this.data.bulkAdd?ae("",!0):(O(),F("div",eY,[$e(p,{saving:i.saving,data:i.data,bulk:this.data.bulkAdd},null,8,["saving","data","bulk"])])),h("div",tY,[$e(m,{saving:i.saving,data:i.data},null,8,["saving","data"])]),h("div",nY,[$e(_,{saving:i.saving,data:i.data},null,8,["saving","data"])])]),h("div",sY,[h("button",{class:"ms-auto btn btn-dark btn-brand rounded-3 px-3 py-2 shadow",disabled:!this.allRequireFieldsFilled||this.saving,onClick:t[0]||(t[0]=b=>this.peerCreate())},[this.saving?ae("",!0):(O(),F("i",oY)),ye(" "+ve(this.saving?"Saving...":"Add"),1)],8,iY)])])])}const K1=ze(Yz,[["render",rY],["__scopeId","data-v-c3292318"]]),aY={name:"scheduleDropdown",props:{options:Array,data:String,edit:!1},setup(e){e.data===void 0&&this.$emit("update",this.options[0].value)},computed:{currentSelection(){return this.options.find(e=>e.value===this.data)}}},lY={class:"dropdown scheduleDropdown"},cY={class:"dropdown-menu rounded-3 shadow",style:{"font-size":"0.875rem",width:"200px"}},uY=["onClick"],dY={key:0,class:"bi bi-check ms-auto"};function hY(e,t,n,s,i,o){return O(),F("div",lY,[h("button",{class:Ee(["btn btn-sm btn-outline-primary rounded-3",{"disabled border-transparent":!n.edit}]),type:"button","data-bs-toggle":"dropdown","aria-expanded":"false"},[h("samp",null,ve(this.currentSelection.display),1)],2),h("ul",cY,[n.edit?(O(!0),F(Me,{key:0},Ke(this.options,r=>(O(),F("li",null,[h("a",{class:"dropdown-item d-flex align-items-center",role:"button",onClick:a=>e.$emit("update",r.value)},[h("samp",null,ve(r.display),1),r.value===this.currentSelection.value?(O(),F("i",dY)):ae("",!0)],8,uY)]))),256)):ae("",!0)])])}const q1=ze(aY,[["render",hY],["__scopeId","data-v-6a5aba2a"]]),fY={name:"schedulePeerJob",components:{VueDatePicker:ll,ScheduleDropdown:q1},props:{dropdowns:Array[Object],pjob:Object,viewOnly:!1},setup(e){const t=be({}),n=be(!1),s=be(!1);t.value=JSON.parse(JSON.stringify(e.pjob)),t.value.CreationDate||(n.value=!0,s.value=!0);const i=et();return{job:t,edit:n,newJob:s,store:i}},data(){return{inputType:void 0}},watch:{pjob:{deep:!0,immediate:!0,handler(e){this.edit||(this.job=JSON.parse(JSON.stringify(e)))}}},methods:{save(){this.job.Field&&this.job.Operator&&this.job.Action&&this.job.Value?dt("/api/savePeerScheduleJob/",{Job:this.job},e=>{e.status?(this.edit=!1,this.store.newMessage("Server","Job Saved!","success"),console.log(e.data),this.$emit("refresh",e.data[0]),this.newJob=!1):this.store.newMessage("Server",e.message,"danger")}):this.alert()},alert(){let e="animate__flash",t=this.$el.querySelectorAll(".scheduleDropdown"),n=this.$el.querySelectorAll("input");t.forEach(s=>s.classList.add("animate__animated",e)),n.forEach(s=>s.classList.add("animate__animated",e)),setTimeout(()=>{t.forEach(s=>s.classList.remove("animate__animated",e)),n.forEach(s=>s.classList.remove("animate__animated",e))},2e3)},reset(){this.job.CreationDate?(this.job=JSON.parse(JSON.stringify(this.pjob)),this.edit=!1):this.$emit("delete")},delete(){this.job.CreationDate&&dt("/api/deletePeerScheduleJob/",{Job:this.job},e=>{e.status?this.store.newMessage("Server","Job Deleted!","success"):(this.store.newMessage("Server",e.message,"danger"),this.$emit("delete"))}),this.$emit("delete")},parseTime(e){e&&(this.job.Value=Cn(e).format("YYYY-MM-DD HH:mm:ss"))}}},jr=e=>(Kt("data-v-811b149e"),e=e(),qt(),e),pY={class:"card-header bg-transparent text-muted border-0"},gY={key:0,class:"d-flex"},mY=jr(()=>h("strong",{class:"me-auto"},"Job ID",-1)),_Y={key:1},vY=jr(()=>h("span",{class:"badge text-bg-warning"},"Unsaved Job",-1)),bY=[vY],yY={class:"card-body pt-1",style:{"font-family":"var(--bs-font-monospace)"}},wY={class:"d-flex gap-2 align-items-center mb-2"},xY=jr(()=>h("samp",null," if ",-1)),kY=jr(()=>h("samp",null," is ",-1)),SY=["disabled"],AY={class:"px-5 d-flex gap-2 align-items-center"},$Y=jr(()=>h("samp",null,"then",-1)),CY={class:"d-flex gap-3"},EY=jr(()=>h("samp",null,"}",-1)),PY={key:0,class:"ms-auto d-flex gap-3"},TY={key:1,class:"ms-auto d-flex gap-3"};function MY(e,t,n,s,i,o){var l;const r=je("ScheduleDropdown"),a=je("VueDatePicker");return O(),F("div",{class:Ee(["card shadow-sm rounded-3 mb-2",{"border-warning-subtle":this.newJob}])},[h("div",pY,[this.newJob?(O(),F("small",_Y,bY)):(O(),F("small",gY,[mY,h("samp",null,ve(this.job.JobID),1)]))]),h("div",yY,[h("div",wY,[xY,$e(r,{edit:s.edit,options:this.dropdowns.Field,data:this.job.Field,onUpdate:t[0]||(t[0]=c=>{this.job.Field=c})},null,8,["edit","options","data"]),kY,$e(r,{edit:s.edit,options:this.dropdowns.Operator,data:this.job.Operator,onUpdate:t[1]||(t[1]=c=>this.job.Operator=c)},null,8,["edit","options","data"]),this.job.Field==="date"?(O(),Ne(a,{key:0,is24:!0,"min-date":new Date,"model-value":this.job.Value,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",clearable:!1,disabled:!s.edit,dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","disabled","dark"])):Re((O(),F("input",{key:1,class:"form-control form-control-sm form-control-dark rounded-3 flex-grow-1",disabled:!s.edit,"onUpdate:modelValue":t[2]||(t[2]=c=>this.job.Value=c),style:{width:"auto"}},null,8,SY)),[[We,this.job.Value]]),h("samp",null,ve((l=this.dropdowns.Field.find(c=>c.value===this.job.Field))==null?void 0:l.unit)+" { ",1)]),h("div",AY,[$Y,$e(r,{edit:s.edit,options:this.dropdowns.Action,data:this.job.Action,onUpdate:t[3]||(t[3]=c=>this.job.Action=c)},null,8,["edit","options","data"])]),h("div",CY,[EY,this.edit?(O(),F("div",TY,[h("a",{role:"button",class:"text-secondary text-decoration-none",onClick:t[6]||(t[6]=c=>this.reset())},"[C] Cancel"),h("a",{role:"button",class:"text-primary ms-auto text-decoration-none",onClick:t[7]||(t[7]=c=>this.save())},"[S] Save")])):(O(),F("div",PY,[h("a",{role:"button",class:"ms-auto text-decoration-none",onClick:t[4]||(t[4]=c=>this.edit=!0)},"[E] Edit"),h("a",{role:"button",onClick:t[5]||(t[5]=c=>this.delete()),class:"text-danger text-decoration-none"},"[D] Delete")]))])])],2)}const G1=ze(fY,[["render",MY],["__scopeId","data-v-811b149e"]]),DY={name:"peerJobs",setup(){return{store:Bn()}},props:{selectedPeer:Object},components:{SchedulePeerJob:G1,ScheduleDropdown:q1},data(){return{}},methods:{deleteJob(e){this.selectedPeer.jobs=this.selectedPeer.jobs.filter(t=>t.JobID!==e.JobID)},addJob(){this.selectedPeer.jobs.unshift(JSON.parse(JSON.stringify({JobID:Ms().toString(),Configuration:this.selectedPeer.configuration.Name,Peer:this.selectedPeer.id,Field:this.store.PeerScheduleJobs.dropdowns.Field[0].value,Operator:this.store.PeerScheduleJobs.dropdowns.Operator[0].value,Value:"",CreationDate:"",ExpireDate:"",Action:this.store.PeerScheduleJobs.dropdowns.Action[0].value})))}}},dp=e=>(Kt("data-v-31a1606a"),e=e(),qt(),e),OY={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},IY={class:"container d-flex h-100 w-100"},RY={class:"m-auto modal-dialog-centered dashboardModal"},LY={class:"card rounded-3 shadow",style:{width:"700px"}},NY={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},FY=dp(()=>h("h4",{class:"mb-0 fw-normal"},[ye("Schedule Jobs "),h("strong")],-1)),BY={class:"card-body px-4 pb-4 pt-2 position-relative"},VY={class:"d-flex align-items-center mb-3"},HY=dp(()=>h("i",{class:"bi bi-plus-lg me-2"},null,-1)),jY={class:"card shadow-sm",key:"none",style:{height:"153px"}},WY=dp(()=>h("div",{class:"card-body text-muted text-center d-flex"},[h("h6",{class:"m-auto"},"This peer does not have any job yet.")],-1)),zY=[WY];function YY(e,t,n,s,i,o){const r=je("SchedulePeerJob");return O(),F("div",OY,[h("div",IY,[h("div",RY,[h("div",LY,[h("div",NY,[FY,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),h("div",BY,[h("div",VY,[h("button",{class:"btn bg-primary-subtle border-1 border-primary-subtle text-primary-emphasis rounded-3 shadow",onClick:t[1]||(t[1]=a=>this.addJob())},[HY,ye(" Job ")])]),$e(Wi,{name:"schedulePeerJobTransition",tag:"div",class:"position-relative"},{default:Te(()=>[(O(!0),F(Me,null,Ke(this.selectedPeer.jobs,(a,l)=>(O(),Ne(r,{onRefresh:t[2]||(t[2]=c=>this.$emit("refresh")),onDelete:c=>this.deleteJob(a),dropdowns:this.store.PeerScheduleJobs.dropdowns,key:a.JobID,pjob:a},null,8,["onDelete","dropdowns","pjob"]))),128)),this.selectedPeer.jobs.length===0?(O(),F("div",jY,zY)):ae("",!0)]),_:1})])])])])])}const UY=ze(DY,[["render",YY],["__scopeId","data-v-31a1606a"]]),KY={name:"peerJobsAllModal",setup(){return{store:Bn()}},components:{SchedulePeerJob:G1},props:{configurationPeers:Array[Object]},methods:{getuuid(){return Ms()}},computed:{getAllJobs(){return this.configurationPeers.filter(e=>e.jobs.length>0)}}},qY={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},GY={class:"container d-flex h-100 w-100"},JY={class:"m-auto modal-dialog-centered dashboardModal"},XY={class:"card rounded-3 shadow",style:{width:"700px"}},QY={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},ZY=h("h4",{class:"mb-0 fw-normal"},"All Active Jobs ",-1),eU={class:"card-body px-4 pb-4 pt-2"},tU={key:0,class:"accordion",id:"peerJobsLogsModalAccordion"},nU={class:"accordion-header"},sU=["data-bs-target"],iU={key:0},oU={class:"text-muted"},rU=["id"],aU={class:"accordion-body"},lU={key:1,class:"card shadow-sm",style:{height:"153px"}},cU=h("div",{class:"card-body text-muted text-center d-flex"},[h("h6",{class:"m-auto"},"No active job at the moment.")],-1),uU=[cU];function dU(e,t,n,s,i,o){const r=je("SchedulePeerJob");return O(),F("div",qY,[h("div",GY,[h("div",JY,[h("div",XY,[h("div",QY,[ZY,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),h("div",eU,[this.getAllJobs.length>0?(O(),F("div",tU,[(O(!0),F(Me,null,Ke(this.getAllJobs,(a,l)=>(O(),F("div",{class:"accordion-item",key:a.id},[h("h2",nU,[h("button",{class:"accordion-button collapsed",type:"button","data-bs-toggle":"collapse","data-bs-target":"#collapse_"+l},[h("small",null,[h("strong",null,[a.name?(O(),F("span",iU,ve(a.name)+" • ",1)):ae("",!0),h("samp",oU,ve(a.id),1)])])],8,sU)]),h("div",{id:"collapse_"+l,class:"accordion-collapse collapse","data-bs-parent":"#peerJobsLogsModalAccordion"},[h("div",aU,[(O(!0),F(Me,null,Ke(a.jobs,c=>(O(),Ne(r,{onDelete:t[1]||(t[1]=u=>this.$emit("refresh")),onRefresh:t[2]||(t[2]=u=>this.$emit("refresh")),dropdowns:this.store.PeerScheduleJobs.dropdowns,viewOnly:!0,key:c.JobID,pjob:c},null,8,["dropdowns","pjob"]))),128))])],8,rU)]))),128))])):(O(),F("div",lU,uU))])])])])])}const hU=ze(KY,[["render",dU]]),fU={name:"peerJobsLogsModal",props:{configurationInfo:Object},data(){return{dataLoading:!0,data:[],logFetchTime:void 0,showLogID:!1,showJobID:!0,showSuccessJob:!0,showFailedJob:!0,showLogAmount:10}},async mounted(){await this.fetchLog()},methods:{async fetchLog(){this.dataLoading=!0,await Tt(`/api/getPeerScheduleJobLogs/${this.configurationInfo.Name}`,{},e=>{this.data=e.data,this.logFetchTime=Cn().format("YYYY-MM-DD HH:mm:ss"),this.dataLoading=!1})}},computed:{getLogs(){return this.data.filter(e=>this.showSuccessJob&&e.Status==="1"||this.showFailedJob&&e.Status==="0")},showLogs(){return this.getLogs.slice(0,this.showLogAmount)}}},pU={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},gU={class:"container-fluid d-flex h-100 w-100"},mU={class:"m-auto mt-0 modal-dialog-centered dashboardModal",style:{width:"100%"}},_U={class:"card rounded-3 shadow w-100"},vU={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},bU=h("h4",{class:"mb-0"},"Jobs Logs",-1),yU={class:"card-body px-4 pb-4 pt-2"},wU={key:0},xU={class:"mb-2 d-flex gap-3"},kU=h("i",{class:"bi bi-arrow-clockwise me-2"},null,-1),SU={class:"d-flex gap-3 align-items-center"},AU=h("span",{class:"text-muted"},"Filter",-1),$U={class:"form-check"},CU=h("label",{class:"form-check-label",for:"jobLogsShowSuccessCheck"},[h("span",{class:"badge text-success-emphasis bg-success-subtle"},"Success")],-1),EU={class:"form-check"},PU=h("label",{class:"form-check-label",for:"jobLogsShowFailedCheck"},[h("span",{class:"badge text-danger-emphasis bg-danger-subtle"},"Failed")],-1),TU={class:"d-flex gap-3 align-items-center ms-auto"},MU=h("span",{class:"text-muted"},"Display",-1),DU={class:"form-check"},OU=h("label",{class:"form-check-label",for:"jobLogsShowJobIDCheck"}," Job ID ",-1),IU={class:"form-check"},RU=h("label",{class:"form-check-label",for:"jobLogsShowLogIDCheck"}," Log ID ",-1),LU={class:"table"},NU=h("th",{scope:"col"},"Date",-1),FU={key:0,scope:"col"},BU={key:1,scope:"col"},VU=h("th",{scope:"col"},"Status",-1),HU=h("th",{scope:"col"},"Message",-1),jU={style:{"font-size":"0.875rem"}},WU={scope:"row"},zU={key:0},YU={class:"text-muted"},UU={key:1},KU={class:"text-muted"},qU={class:"d-flex gap-2"},GU=h("i",{class:"bi bi-chevron-down me-2"},null,-1),JU=h("i",{class:"bi bi-chevron-up me-2"},null,-1),XU={key:1,class:"d-flex align-items-center flex-column"},QU=h("div",{class:"spinner-border text-body",role:"status"},[h("span",{class:"visually-hidden"},"Loading...")],-1),ZU=[QU];function eK(e,t,n,s,i,o){return O(),F("div",pU,[h("div",gU,[h("div",mU,[h("div",_U,[h("div",vU,[bU,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=r=>this.$emit("close"))})]),h("div",yU,[this.dataLoading?(O(),F("div",XU,ZU)):(O(),F("div",wU,[h("p",null,"Updated at: "+ve(this.logFetchTime),1),h("div",xU,[h("button",{onClick:t[1]||(t[1]=r=>this.fetchLog()),class:"btn btn-sm rounded-3 shadow-sm text-info-emphasis bg-info-subtle border-1 border-info-subtle me-1"},[kU,ye(" Refresh ")]),h("div",SU,[AU,h("div",$U,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[2]||(t[2]=r=>this.showSuccessJob=r),id:"jobLogsShowSuccessCheck"},null,512),[[In,this.showSuccessJob]]),CU]),h("div",EU,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[3]||(t[3]=r=>this.showFailedJob=r),id:"jobLogsShowFailedCheck"},null,512),[[In,this.showFailedJob]]),PU])]),h("div",TU,[MU,h("div",DU,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[4]||(t[4]=r=>i.showJobID=r),id:"jobLogsShowJobIDCheck"},null,512),[[In,i.showJobID]]),OU]),h("div",IU,[Re(h("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":t[5]||(t[5]=r=>i.showLogID=r),id:"jobLogsShowLogIDCheck"},null,512),[[In,i.showLogID]]),RU])])]),h("table",LU,[h("thead",null,[h("tr",null,[NU,i.showLogID?(O(),F("th",FU,"Log ID")):ae("",!0),i.showJobID?(O(),F("th",BU,"Job ID")):ae("",!0),VU,HU])]),h("tbody",null,[(O(!0),F(Me,null,Ke(this.showLogs,r=>(O(),F("tr",jU,[h("th",WU,ve(r.LogDate),1),i.showLogID?(O(),F("td",zU,[h("samp",YU,ve(r.LogID),1)])):ae("",!0),i.showJobID?(O(),F("td",UU,[h("samp",KU,ve(r.JobID),1)])):ae("",!0),h("td",null,[h("span",{class:Ee(["badge",[r.Status==="1"?"text-success-emphasis bg-success-subtle":"text-danger-emphasis bg-danger-subtle"]])},ve(r.Status==="1"?"Success":"Failed"),3)]),h("td",null,ve(r.Message),1)]))),256))])]),h("div",qU,[this.getLogs.length>this.showLogAmount?(O(),F("button",{key:0,onClick:t[6]||(t[6]=r=>this.showLogAmount+=20),class:"btn btn-sm rounded-3 shadow-sm text-primary-emphasis bg-primary-subtle border-1 border-primary-subtle"},[GU,ye(" Show More ")])):ae("",!0),this.showLogAmount>20?(O(),F("button",{key:1,onClick:t[7]||(t[7]=r=>this.showLogAmount=20),class:"btn btn-sm rounded-3 shadow-sm text-primary-emphasis bg-primary-subtle border-1 border-primary-subtle"},[JU,ye(" Collapse ")])):ae("",!0)])]))])])])])])}const tK=ze(fU,[["render",eK]]),nK={name:"peerShareLinkModal",props:{peer:Object},components:{VueDatePicker:ll},data(){return{dataCopy:void 0,loading:!1}},setup(){return{store:et()}},mounted(){this.dataCopy=JSON.parse(JSON.stringify(this.peer.ShareLink)).at(0)},watch:{"peer.ShareLink":{deep:!0,handler(e,t){t.length!==e.length&&(this.dataCopy=JSON.parse(JSON.stringify(this.peer.ShareLink)).at(0))}}},methods:{startSharing(){this.loading=!0,dt("/api/sharePeer/create",{Configuration:this.peer.configuration.Name,Peer:this.peer.id,ExpireDate:Cn().add(7,"d").format("YYYY-MM-DD HH:mm:ss")},e=>{e.status?(this.peer.ShareLink=e.data,this.dataCopy=e.data.at(0),this.store.newMessage("Server","Share link created successfully","success")):this.store.newMessage("Server","Share link failed to create. Reason: "+e.message,"danger"),this.loading=!1})},updateLinkExpireDate(){dt("/api/sharePeer/update",this.dataCopy,e=>{e.status?(this.dataCopy=e.data.at(0),this.peer.ShareLink=e.data,this.store.newMessage("Server","Link expire date updated","success")):this.store.newMessage("Server","Link expire date failed to update. Reason: "+e.message,"danger"),this.loading=!1})},stopSharing(){this.loading=!0,this.dataCopy.ExpireDate=Cn().format("YYYY-MM-DD HH:mm:ss"),this.updateLinkExpireDate()},parseTime(e){e?this.dataCopy.ExpireDate=Cn(e).format("YYYY-MM-DD HH:mm:ss"):this.dataCopy.ExpireDate=void 0,this.updateLinkExpireDate()}},computed:{getUrl(){const e=this.store.getActiveCrossServer();return e?`${e.host}/${this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}`:window.location.origin+window.location.pathname+this.$router.resolve({path:"/share",query:{ShareID:this.dataCopy.ShareID}}).href}}},sK={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},iK={class:"container d-flex h-100 w-100"},oK={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"500px"}},rK={class:"card rounded-3 shadow flex-grow-1"},aK={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},lK=h("h4",{class:"mb-0"},"Share Peer",-1),cK={key:0,class:"card-body px-4 pb-4"},uK={key:0},dK=h("h6",{class:"mb-3 text-muted"}," Currently the peer is not sharing ",-1),hK=["disabled"],fK=h("i",{class:"bi bi-send-fill me-2"},null,-1),pK=[fK],gK={key:1},mK={class:"d-flex gap-2 mb-4"},_K=h("i",{class:"bi bi-link-45deg"},null,-1),vK=["href"],bK={class:"d-flex flex-column gap-2 mb-3"},yK=h("small",null,[h("i",{class:"bi bi-calendar me-2"}),ye(" Expire Date ")],-1),wK=["disabled"],xK=h("i",{class:"bi bi-send-slash-fill me-2"},null,-1),kK=[xK];function SK(e,t,n,s,i,o){const r=je("VueDatePicker");return O(),F("div",sK,[h("div",iK,[h("div",oK,[h("div",rK,[h("div",aK,[lK,h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),this.peer.ShareLink?(O(),F("div",cK,[this.dataCopy?(O(),F("div",gK,[h("div",mK,[_K,h("a",{href:this.getUrl,class:"text-decoration-none",target:"_blank"},ve(o.getUrl),9,vK)]),h("div",bK,[yK,$e(r,{is24:!0,"min-date":new Date,"model-value":this.dataCopy.ExpireDate,"onUpdate:modelValue":this.parseTime,"time-picker-inline":"",format:"yyyy-MM-dd HH:mm:ss","preview-format":"yyyy-MM-dd HH:mm:ss",dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","dark"])]),h("button",{onClick:t[2]||(t[2]=a=>this.stopSharing()),disabled:this.loading,class:"w-100 btn bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle rounded-3 shadow-sm"},[h("span",{class:Ee({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},kK,2),ye(" "+ve(this.loading?"Stop Sharing...":"Stop Sharing"),1)],8,wK)])):(O(),F("div",uK,[dK,h("button",{onClick:t[1]||(t[1]=a=>this.startSharing()),disabled:this.loading,class:"w-100 btn bg-success-subtle text-success-emphasis border-1 border-success-subtle rounded-3 shadow-sm"},[h("span",{class:Ee({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},pK,2),ye(" "+ve(this.loading?"Sharing...":"Start Sharing"),1)],8,hK)]))])):ae("",!0)])])])])}const AK=ze(nK,[["render",SK]]);xu.register(da,$i,wc,yc,Ta,pc,or,Ma,hh,gc,mc,_c,vh,bh,yh,fa,Za,xh,$6,U6,Q6,eH,lH);const $K={name:"peerList",components:{PeerShareLinkModal:AK,PeerJobsLogsModal:tK,PeerJobsAllModal:hU,PeerJobs:UY,PeerCreate:K1,PeerQRCode:bW,PeerSettings:bj,PeerSearch:H5,Peer:NF,Line:BH,Bar:FH},setup(){const e=et(),t=Bn(),n=be(void 0);return{dashboardConfigurationStore:e,wireguardConfigurationStore:t,interval:n}},data(){return{configurationToggling:!1,loading:!1,error:null,configurationInfo:[],configurationPeers:[],historyDataSentDifference:[],historyDataReceivedDifference:[],historySentData:{labels:[],datasets:[{label:"Data Sent",data:[],fill:!1,borderColor:"#198754",tension:0}]},historyReceiveData:{labels:[],datasets:[{label:"Data Received",data:[],fill:!1,borderColor:"#0d6efd",tension:0}]},peerSetting:{modalOpen:!1,selectedPeer:void 0},peerScheduleJobs:{modalOpen:!1,selectedPeer:void 0},peerQRCode:{modalOpen:!1,peerConfigData:void 0},peerCreate:{modalOpen:!1},peerScheduleJobsAll:{modalOpen:!1},peerScheduleJobsLogs:{modalOpen:!1},peerShare:{modalOpen:!1,selectedPeer:void 0}}},mounted(){},watch:{$route:{immediate:!0,handler(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval),this.loading=!0;let e=this.$route.params.id;this.configurationInfo=[],this.configurationPeers=[],e&&(this.getPeers(e),this.setPeerInterval())}},"dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval"(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval),this.setPeerInterval()}},beforeRouteLeave(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval)},methods:{toggle(){this.configurationToggling=!0,Tt("/api/toggleWireguardConfiguration/",{configurationName:this.configurationInfo.Name},e=>{e.status?this.dashboardConfigurationStore.newMessage("Server",`${this.configurationInfo.Name} is - ${e.data?"is on":"is off"}`,"Success"):this.dashboardConfigurationStore.newMessage("Server",e.message,"danger"),this.configurationInfo.Status=e.data,this.configurationToggling=!1})},getPeers(e=this.$route.params.id){Tt("/api/getWireguardConfigurationInfo",{configurationName:e},t=>{if(this.configurationInfo=t.data.configurationInfo,this.configurationPeers=t.data.configurationPeers,this.configurationPeers.forEach(n=>{n.restricted=!1}),t.data.configurationRestrictedPeers.forEach(n=>{n.restricted=!0,this.configurationPeers.push(n)}),this.loading=!1,this.configurationPeers.length>0){const n=this.configurationPeers.map(i=>i.total_sent+i.cumu_sent).reduce((i,o)=>i+o).toFixed(4),s=this.configurationPeers.map(i=>i.total_receive+i.cumu_receive).reduce((i,o)=>i+o).toFixed(4);this.historyDataSentDifference[this.historyDataSentDifference.length-1]!==n&&(this.historyDataSentDifference.length>0&&(this.historySentData={labels:[...this.historySentData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Sent",data:[...this.historySentData.datasets[0].data,((n-this.historyDataSentDifference[this.historyDataSentDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#198754",tension:0}]}),this.historyDataSentDifference.push(n)),this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1]!==s&&(this.historyDataReceivedDifference.length>0&&(this.historyReceiveData={labels:[...this.historyReceiveData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Received",data:[...this.historyReceiveData.datasets[0].data,((s-this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#0d6efd",tension:0}]}),this.historyDataReceivedDifference.push(s))}})},setPeerInterval(){this.dashboardConfigurationStore.Peers.RefreshInterval=setInterval(()=>{this.getPeers()},parseInt(this.dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval))}},computed:{configurationSummary(){return{connectedPeers:this.configurationPeers.filter(t=>t.status==="running").length,totalUsage:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_data+t.cumu_data).reduce((t,n)=>t+n).toFixed(4):0,totalReceive:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_receive+t.cumu_receive).reduce((t,n)=>t+n).toFixed(4):0,totalSent:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_sent+t.cumu_sent).reduce((t,n)=>t+n).toFixed(4):0}},receiveData(){return this.historyReceiveData},sentData(){return this.historySentData},individualDataUsage(){return{labels:this.configurationPeers.map(e=>e.name?e.name:`Untitled Peer - ${e.id}`),datasets:[{label:"Total Data Usage",data:this.configurationPeers.map(e=>e.cumu_data+e.total_data),backgroundColor:this.configurationPeers.map(e=>"#0dcaf0"),tooltip:{callbacks:{label:e=>`${e.formattedValue} GB`}}}]}},individualDataUsageChartOption(){return{responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} GB`},grid:{display:!1}}}}},chartOptions(){return{responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:e=>`${e.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} MB/s`},grid:{display:!1}}}}},searchPeers(){const e=new Hr(this.configurationPeers,{keys:["name","id","allowed_ip"]}),t=this.wireguardConfigurationStore.searchString?e.search(this.wireguardConfigurationStore.searchString).map(n=>n.item):this.configurationPeers;return this.dashboardConfigurationStore.Configuration.Server.dashboard_sort==="restricted"?t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?-1:0):t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?1:0)}}},pn=e=>(Kt("data-v-2a3b3231"),e=e(),qt(),e),CK={key:0},EK={class:"d-flex align-items-center"},PK=pn(()=>h("small",{CLASS:"text-muted"},"CONFIGURATION",-1)),TK={class:"d-flex align-items-center gap-3"},MK={class:"mb-0"},DK={class:"card rounded-3 bg-transparent shadow-sm ms-auto"},OK={class:"card-body py-2 d-flex align-items-center"},IK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Status")],-1)),RK={class:"form-check form-switch ms-auto"},LK=["for"],NK={key:0,class:"spinner-border spinner-border-sm","aria-hidden":"true"},FK=["disabled","id"],BK={class:"row mt-3 gy-2 gx-2 mb-2"},VK={class:"col-6 col-lg-3"},HK={class:"card rounded-3 bg-transparent shadow-sm"},jK={class:"card-body py-2"},WK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),zK={class:"col-6 col-lg-3"},YK={class:"card rounded-3 bg-transparent shadow-sm"},UK={class:"card-body py-2"},KK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Listen Port")],-1)),qK={style:{"word-break":"break-all"},class:"col-12 col-lg-6"},GK={class:"card rounded-3 bg-transparent shadow-sm"},JK={class:"card-body py-2"},XK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Public Key")],-1)),QK={class:"row gx-2 gy-2 mb-2"},ZK={class:"col-6 col-lg-3"},e7={class:"card rounded-3 bg-transparent shadow-sm"},t7={class:"card-body d-flex"},n7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Connected Peers")],-1)),s7={class:"h4"},i7=pn(()=>h("i",{class:"bi bi-ethernet ms-auto h2 text-muted"},null,-1)),o7={class:"col-6 col-lg-3"},r7={class:"card rounded-3 bg-transparent shadow-sm"},a7={class:"card-body d-flex"},l7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Usage")],-1)),c7={class:"h4"},u7=pn(()=>h("i",{class:"bi bi-arrow-down-up ms-auto h2 text-muted"},null,-1)),d7={class:"col-6 col-lg-3"},h7={class:"card rounded-3 bg-transparent shadow-sm"},f7={class:"card-body d-flex"},p7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Received")],-1)),g7={class:"h4 text-primary"},m7=pn(()=>h("i",{class:"bi bi-arrow-down ms-auto h2 text-muted"},null,-1)),_7={class:"col-6 col-lg-3"},v7={class:"card rounded-3 bg-transparent shadow-sm"},b7={class:"card-body d-flex"},y7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Sent")],-1)),w7={class:"h4 text-success"},x7=pn(()=>h("i",{class:"bi bi-arrow-up ms-auto h2 text-muted"},null,-1)),k7={class:"row gx-2 gy-2 mb-3"},S7={class:"col-12 col-lg-6"},A7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},$7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Peers Total Data Usage")],-1)),C7={class:"card-body pt-1"},E7={class:"col-sm col-lg-3"},P7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},T7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Received Data Usage")],-1)),M7={class:"card-body pt-1"},D7={class:"col-sm col-lg-3"},O7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},I7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Sent Data Usage")],-1)),R7={class:"card-body pt-1"},L7={class:"mb-4"};function N7(e,t,n,s,i,o){const r=je("Bar"),a=je("Line"),l=je("PeerSearch"),c=je("Peer"),u=je("PeerSettings"),d=je("PeerQRCode"),f=je("PeerJobs"),p=je("PeerJobsAllModal"),m=je("PeerJobsLogsModal"),_=je("PeerShareLinkModal");return this.loading?ae("",!0):(O(),F("div",CK,[h("div",EK,[h("div",null,[PK,h("div",TK,[h("h1",MK,[h("samp",null,ve(this.configurationInfo.Name),1)])])]),h("div",DK,[h("div",OK,[h("div",null,[IK,h("div",RK,[h("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+this.configurationInfo.id},[ye(ve(this.configurationToggling?"Turning ":"")+" "+ve(this.configurationInfo.Status?"On":"Off")+" ",1),this.configurationToggling?(O(),F("span",NK)):ae("",!0)],8,LK),Re(h("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:this.configurationToggling,type:"checkbox",role:"switch",id:"switch"+this.configurationInfo.id,onChange:t[0]||(t[0]=b=>this.toggle()),"onUpdate:modelValue":t[1]||(t[1]=b=>this.configurationInfo.Status=b)},null,40,FK),[[In,this.configurationInfo.Status]])])]),h("div",{class:Ee(["dot ms-5",{active:this.configurationInfo.Status}])},null,2)])])]),h("div",BK,[h("div",VK,[h("div",HK,[h("div",jK,[WK,ye(" "+ve(this.configurationInfo.Address),1)])])]),h("div",zK,[h("div",YK,[h("div",UK,[KK,ye(" "+ve(this.configurationInfo.ListenPort),1)])])]),h("div",qK,[h("div",GK,[h("div",JK,[XK,h("samp",null,ve(this.configurationInfo.PublicKey),1)])])])]),h("div",QK,[h("div",ZK,[h("div",e7,[h("div",t7,[h("div",null,[n7,h("strong",s7,ve(o.configurationSummary.connectedPeers),1)]),i7])])]),h("div",o7,[h("div",r7,[h("div",a7,[h("div",null,[l7,h("strong",c7,ve(o.configurationSummary.totalUsage)+" GB",1)]),u7])])]),h("div",d7,[h("div",h7,[h("div",f7,[h("div",null,[p7,h("strong",g7,ve(o.configurationSummary.totalReceive)+" GB",1)]),m7])])]),h("div",_7,[h("div",v7,[h("div",b7,[h("div",null,[y7,h("strong",w7,ve(o.configurationSummary.totalSent)+" GB",1)]),x7])])])]),h("div",k7,[h("div",S7,[h("div",A7,[$7,h("div",C7,[$e(r,{data:o.individualDataUsage,options:o.individualDataUsageChartOption,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),h("div",E7,[h("div",P7,[T7,h("div",M7,[$e(a,{options:o.chartOptions,data:o.receiveData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),h("div",D7,[h("div",O7,[I7,h("div",R7,[$e(a,{options:o.chartOptions,data:o.sentData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])])]),h("div",L7,[$e(l,{onJobsAll:t[2]||(t[2]=b=>this.peerScheduleJobsAll.modalOpen=!0),onJobLogs:t[3]||(t[3]=b=>this.peerScheduleJobsLogs.modalOpen=!0),configuration:this.configurationInfo},null,8,["configuration"]),$e(Wi,{name:"list",tag:"div",class:"row gx-2 gy-2 z-0"},{default:Te(()=>[(O(!0),F(Me,null,Ke(this.searchPeers,b=>(O(),F("div",{class:"col-12 col-lg-6 col-xl-4",key:b.id},[$e(c,{Peer:b,onShare:w=>{this.peerShare.selectedPeer=b.id,this.peerShare.modalOpen=!0},onRefresh:t[4]||(t[4]=w=>this.getPeers()),onJobs:w=>{i.peerScheduleJobs.modalOpen=!0,i.peerScheduleJobs.selectedPeer=this.configurationPeers.find(A=>A.id===b.id)},onSetting:w=>{i.peerSetting.modalOpen=!0,i.peerSetting.selectedPeer=this.configurationPeers.find(A=>A.id===b.id)},onQrcode:t[5]||(t[5]=w=>{this.peerQRCode.peerConfigData=w,this.peerQRCode.modalOpen=!0})},null,8,["Peer","onShare","onJobs","onSetting"])]))),128))]),_:1})]),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerSetting.modalOpen?(O(),Ne(u,{key:"settings",selectedPeer:this.peerSetting.selectedPeer,onRefresh:t[6]||(t[6]=b=>this.getPeers()),onClose:t[7]||(t[7]=b=>this.peerSetting.modalOpen=!1)},null,8,["selectedPeer"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[i.peerQRCode.modalOpen?(O(),Ne(d,{peerConfigData:this.peerQRCode.peerConfigData,key:"qrcode",onClose:t[8]||(t[8]=b=>this.peerQRCode.modalOpen=!1)},null,8,["peerConfigData"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobs.modalOpen?(O(),Ne(f,{key:0,onRefresh:t[9]||(t[9]=b=>this.getPeers()),selectedPeer:this.peerScheduleJobs.selectedPeer,onClose:t[10]||(t[10]=b=>this.peerScheduleJobs.modalOpen=!1)},null,8,["selectedPeer"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobsAll.modalOpen?(O(),Ne(p,{key:0,onRefresh:t[11]||(t[11]=b=>this.getPeers()),onClose:t[12]||(t[12]=b=>this.peerScheduleJobsAll.modalOpen=!1),configurationPeers:this.configurationPeers},null,8,["configurationPeers"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobsLogs.modalOpen?(O(),Ne(m,{key:0,onClose:t[13]||(t[13]=b=>this.peerScheduleJobsLogs.modalOpen=!1),configurationInfo:this.configurationInfo},null,8,["configurationInfo"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerShare.modalOpen?(O(),Ne(_,{key:0,onClose:t[14]||(t[14]=b=>{this.peerShare.modalOpen=!1,this.peerShare.selectedPeer=void 0}),peer:this.configurationPeers.find(b=>b.id===this.peerShare.selectedPeer)},null,8,["peer"])):ae("",!0)]),_:1})]))}const F7=ze($K,[["render",N7],["__scopeId","data-v-2a3b3231"]]),B7={name:"ping",data(){return{loading:!1,cips:{},selectedConfiguration:void 0,selectedPeer:void 0,selectedIp:void 0,count:4,pingResult:void 0,pinging:!1}},setup(){return{store:et()}},mounted(){Tt("/api/ping/getAllPeersIpAddress",{},e=>{e.status&&(this.loading=!0,this.cips=e.data,console.log(this.cips))})},methods:{execute(){this.selectedIp&&(this.pinging=!0,this.pingResult=void 0,Tt("/api/ping/execute",{ipAddress:this.selectedIp,count:this.count},e=>{e.status?this.pingResult=e.data:this.store.newMessage("Server",e.message,"danger")}))}},watch:{selectedConfiguration(){this.selectedPeer=void 0,this.selectedIp=void 0},selectedPeer(){this.selectedIp=void 0}}},Hn=e=>(Kt("data-v-875f5a3c"),e=e(),qt(),e),V7={class:"mt-5 text-body"},H7={class:"container"},j7=Hn(()=>h("h3",{class:"mb-3 text-body"},"Ping",-1)),W7={class:"row"},z7={class:"col-sm-4 d-flex gap-2 flex-column"},Y7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"configuration"},[h("small",null,"Configuration")],-1)),U7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Configuration...",-1)),K7=["value"],q7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"peer"},[h("small",null,"Peer")],-1)),G7=["disabled"],J7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Peer...",-1)),X7=["value"],Q7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"ip"},[h("small",null,"IP Address")],-1)),Z7=["disabled"],e9=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a IP...",-1)),t9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"count"},[h("small",null,"Ping Count")],-1)),n9=["disabled"],s9=Hn(()=>h("i",{class:"bi bi-person-walking me-2"},null,-1)),i9={class:"col-sm-8"},o9={key:"pingPlaceholder"},r9={key:"pingResult",class:"d-flex flex-column gap-2 w-100"},a9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.15s"}},l9={class:"card-body"},c9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),u9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.3s"}},d9={class:"card-body"},h9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Is Alive")],-1)),f9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.45s"}},p9={class:"card-body"},g9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Average / Min / Max Round Trip Time")],-1)),m9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.6s"}},_9={class:"card-body"},v9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Sent / Received / Lost Package")],-1));function b9(e,t,n,s,i,o){return O(),F("div",V7,[h("div",H7,[j7,h("div",W7,[h("div",z7,[h("div",null,[Y7,Re(h("select",{class:"form-select","onUpdate:modelValue":t[0]||(t[0]=r=>this.selectedConfiguration=r)},[U7,(O(!0),F(Me,null,Ke(this.cips,(r,a)=>(O(),F("option",{value:a},ve(a),9,K7))),256))],512),[[hc,this.selectedConfiguration]])]),h("div",null,[q7,Re(h("select",{id:"peer",class:"form-select","onUpdate:modelValue":t[1]||(t[1]=r=>this.selectedPeer=r),disabled:this.selectedConfiguration===void 0},[J7,this.selectedConfiguration!==void 0?(O(!0),F(Me,{key:0},Ke(this.cips[this.selectedConfiguration],(r,a)=>(O(),F("option",{value:a},ve(a),9,X7))),256)):ae("",!0)],8,G7),[[hc,this.selectedPeer]])]),h("div",null,[Q7,Re(h("select",{id:"ip",class:"form-select","onUpdate:modelValue":t[2]||(t[2]=r=>this.selectedIp=r),disabled:this.selectedPeer===void 0},[e9,this.selectedPeer!==void 0?(O(!0),F(Me,{key:0},Ke(this.cips[this.selectedConfiguration][this.selectedPeer].allowed_ips,r=>(O(),F("option",null,ve(r),1))),256)):ae("",!0)],8,Z7),[[hc,this.selectedIp]])]),h("div",null,[t9,Re(h("input",{class:"form-control",type:"number","onUpdate:modelValue":t[3]||(t[3]=r=>this.count=r),min:"1",id:"count",placeholder:"How many times you want to ping?"},null,512),[[We,this.count]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.selectedIp,onClick:t[4]||(t[4]=r=>this.execute())},[s9,ye("Go! ")],8,n9)]),h("div",i9,[$e(Wi,{name:"ping"},{default:Te(()=>[this.pingResult?(O(),F("div",r9,[h("div",a9,[h("div",l9,[c9,ye(" "+ve(this.pingResult.address),1)])]),h("div",u9,[h("div",d9,[h9,h("span",{class:Ee([this.pingResult.is_alive?"text-success":"text-danger"])},[h("i",{class:Ee(["bi me-1",[this.pingResult.is_alive?"bi-check-circle-fill":"bi-x-circle-fill"]])},null,2),ye(" "+ve(this.pingResult.is_alive?"Yes":"No"),1)],2)])]),h("div",f9,[h("div",p9,[g9,h("samp",null,ve(this.pingResult.avg_rtt)+"ms / "+ve(this.pingResult.min_rtt)+"ms / "+ve(this.pingResult.max_rtt)+"ms ",1)])]),h("div",m9,[h("div",_9,[v9,h("samp",null,ve(this.pingResult.package_sent)+" / "+ve(this.pingResult.package_received)+" / "+ve(this.pingResult.package_loss),1)])])])):(O(),F("div",o9,[(O(),F(Me,null,Ke(4,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.pinging}]),style:Wt({"animation-delay":`${r*.15}s`})},null,6)),64))]))]),_:1})])])])])}const y9=ze(B7,[["render",b9],["__scopeId","data-v-875f5a3c"]]),w9={name:"traceroute",data(){return{tracing:!1,ipAddress:void 0,tracerouteResult:void 0}},setup(){return{store:Bn()}},methods:{execute(){this.ipAddress&&(this.tracing=!0,this.tracerouteResult=void 0,Tt("/api/traceroute/execute",{ipAddress:this.ipAddress},e=>{e.status?this.tracerouteResult=e.data:this.store.newMessage("Server",e.message,"danger"),this.tracing=!1}))}}},Pu=e=>(Kt("data-v-dda37ccf"),e=e(),qt(),e),x9={class:"mt-5 text-body"},k9={class:"container"},S9=Pu(()=>h("h3",{class:"mb-3 text-body"},"Traceroute",-1)),A9={class:"row"},$9={class:"col-sm-4 d-flex gap-2 flex-column"},C9=Pu(()=>h("label",{class:"mb-1 text-muted",for:"ipAddress"},[h("small",null,"IP Address")],-1)),E9=["disabled"],P9=Pu(()=>h("i",{class:"bi bi-bullseye me-2"},null,-1)),T9={class:"col-sm-8 position-relative"},M9={key:"pingPlaceholder"},D9={key:"table",class:"w-100"},O9={class:"table table-borderless rounded-3 w-100"},I9=Pu(()=>h("thead",null,[h("tr",null,[h("th",{scope:"col"},"Hop"),h("th",{scope:"col"},"IP Address"),h("th",{scope:"col"},"Average / Min / Max Round Trip Time")])],-1));function R9(e,t,n,s,i,o){return O(),F("div",x9,[h("div",k9,[S9,h("div",A9,[h("div",$9,[h("div",null,[C9,Re(h("input",{id:"ipAddress",class:"form-control","onUpdate:modelValue":t[0]||(t[0]=r=>this.ipAddress=r),type:"text",placeholder:"Enter an IP Address you want to trace :)"},null,512),[[We,this.ipAddress]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.store.regexCheckIP(this.ipAddress)||this.tracing,onClick:t[1]||(t[1]=r=>this.execute())},[P9,ye(" "+ve(this.tracing?"Tracing...":"Trace It!"),1)],8,E9)]),h("div",T9,[$e(Wi,{name:"ping"},{default:Te(()=>[this.tracerouteResult?(O(),F("div",D9,[h("table",O9,[I9,h("tbody",null,[(O(!0),F(Me,null,Ke(this.tracerouteResult,(r,a)=>(O(),F("tr",{class:"animate__fadeInUp animate__animated",style:Wt({"animation-delay":`${a*.05}s`})},[h("td",null,ve(r.hop),1),h("td",null,ve(r.ip),1),h("td",null,ve(r.avg_rtt)+" / "+ve(r.min_rtt)+" / "+ve(r.max_rtt),1)],4))),256))])])])):(O(),F("div",M9,[(O(),F(Me,null,Ke(10,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.tracing}]),style:Wt({"animation-delay":`${r*.05}s`})},null,6)),64))]))]),_:1})])])])])}const L9=ze(w9,[["render",R9],["__scopeId","data-v-dda37ccf"]]),N9={name:"totp",async setup(){const e=et();let t="";return await Tt("/api/Welcome_GetTotpLink",{},n=>{n.status&&(t=n.data)}),{l:t,store:e}},mounted(){this.l&&Bo.toCanvas(document.getElementById("qrcode"),this.l,function(e){})},data(){return{totp:"",totpInvalidMessage:"",verified:!1}},methods:{validateTotp(){}},watch:{totp(e){const t=document.querySelector("#totp");t.classList.remove("is-invalid","is-valid"),e.length===6&&(console.log(e),/[0-9]{6}/.test(e)?dt("/api/Welcome_VerifyTotpLink",{totp:e},n=>{n.status?(this.verified=!0,t.classList.add("is-valid"),this.$emit("verified")):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP does not match.")}):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP can only contain numbers"))}}},F9=["data-bs-theme"],B9={class:"m-auto text-body",style:{width:"500px"}},V9={class:"d-flex flex-column"},H9=h("h1",{class:"dashboardLogo display-4"},"Multi-Factor Authentication",-1),j9=h("p",{class:"mb-2"},[h("small",{class:"text-muted"},"1. Please scan the following QR Code to generate TOTP")],-1),W9=h("canvas",{id:"qrcode",class:"rounded-3 mb-2"},null,-1),z9={class:"p-3 bg-body-secondary rounded-3 border mb-3"},Y9=h("p",{class:"text-muted mb-0"},[h("small",null,"Or you can click the link below:")],-1),U9=["href"],K9={style:{"line-break":"anywhere"}},q9=h("label",{for:"totp",class:"mb-2"},[h("small",{class:"text-muted"},"2. Enter the TOTP generated by your authenticator to verify")],-1),G9={class:"form-group mb-2"},J9=["disabled"],X9={class:"invalid-feedback"},Q9=h("div",{class:"valid-feedback"}," TOTP verified! ",-1),Z9=h("div",{class:"alert alert-warning rounded-3"},[h("i",{class:"bi bi-exclamation-triangle-fill me-2"}),ye(" If you ever lost your TOTP and can't login, please follow instruction on "),h("a",{href:"https://github.com/donaldzou/WGDashboard",target:"_blank"},"readme.md"),ye(" to reset. ")],-1),eq=h("hr",null,null,-1),tq={class:"d-flex gap-3 mt-5 flex-column"},nq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1),sq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1);function iq(e,t,n,s,i,o){const r=je("RouterLink");return O(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.store.Configuration.Server.dashboard_theme},[h("div",B9,[h("div",V9,[h("div",null,[H9,j9,W9,h("div",z9,[Y9,h("a",{href:this.l},[h("code",K9,ve(this.l),1)],8,U9)]),q9,h("div",G9,[Re(h("input",{class:"form-control text-center totp",id:"totp",maxlength:"6",type:"text",inputmode:"numeric",autocomplete:"one-time-code","onUpdate:modelValue":t[0]||(t[0]=a=>this.totp=a),disabled:this.verified},null,8,J9),[[We,this.totp]]),h("div",X9,ve(this.totpInvalidMessage),1),Q9]),Z9]),eq,h("div",tq,[this.verified?(O(),Ne(r,{key:1,to:"/",class:"btn btn-dark btn-lg d-flex btn-brand shadow align-items-center flex-grow-1 rounded-3"},{default:Te(()=>[ye(" Complete "),sq]),_:1})):(O(),Ne(r,{key:0,to:"/",class:"btn bg-secondary-subtle text-secondary-emphasis rounded-3 flex-grow-1 btn-lg border-1 border-secondary-subtle shadow d-flex"},{default:Te(()=>[ye(" I don't need MFA "),nq]),_:1}))])])])],8,F9)}const oq=ze(N9,[["render",iq]]),rq={name:"share",async setup(){const e=tP(),t=be(!1),n=et(),s=be(""),i=be(""),o=be(new Blob);await Tt("/api/getDashboardTheme",{},a=>{s.value=a.data});const r=e.query.ShareID;return r===void 0||r.length===0?(i.value=void 0,t.value=!0):await Tt("/api/sharePeer/get",{ShareID:r},a=>{a.status?(i.value=a.data,o.value=new Blob([i.value.file],{type:"text/plain"})):i.value=void 0,t.value=!0}),{store:n,theme:s,peerConfiguration:i,blob:o}},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfiguration.file,e=>{e&&console.error(e)})},methods:{download(){const e=new Blob([this.peerConfiguration.file],{type:"text/plain"}),t=URL.createObjectURL(e),n=`${this.peerConfiguration.fileName}.conf`,s=document.createElement("a");s.href=t,s.download=n,s.click()}},computed:{getBlob(){return URL.createObjectURL(this.blob)}}},hp=e=>(Kt("data-v-99d4b06a"),e=e(),qt(),e),aq=["data-bs-theme"],lq={class:"m-auto text-body",style:{width:"500px"}},cq={key:0,class:"text-center position-relative",style:{}},uq=Q$('

Oh no... This link is either expired or invalid.

',2),dq=[uq],hq={key:1,class:"d-flex align-items-center flex-column gap-3"},fq=hp(()=>h("div",{class:"h1 dashboardLogo text-center animate__animated animate__fadeInUp"},[h("h6",null,"WGDashboard"),ye(" Scan QR Code from the WireGuard App ")],-1)),pq={id:"qrcode",class:"rounded-3 shadow animate__animated animate__fadeInUp mb-3",ref:"qrcode"},gq=hp(()=>h("p",{class:"text-muted animate__animated animate__fadeInUp mb-1",style:{"animation-delay":"0.2s"}},[ye("or click the button below to download the "),h("samp",null,".conf"),ye(" file")],-1)),mq=["download","href"],_q=hp(()=>h("i",{class:"bi bi-download"},null,-1)),vq=[_q];function bq(e,t,n,s,i,o){return O(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.theme},[h("div",lq,[this.peerConfiguration?(O(),F("div",hq,[fq,h("canvas",pq,null,512),gq,h("a",{download:this.peerConfiguration.fileName+".conf",href:o.getBlob,class:"btn btn-lg bg-primary-subtle text-primary-emphasis border-1 border-primary-subtle animate__animated animate__fadeInUp shadow-sm",style:{"animation-delay":"0.25s"}},vq,8,mq)])):(O(),F("div",cq,dq))])],8,aq)}const yq=ze(rq,[["render",bq],["__scopeId","data-v-99d4b06a"]]),wq=async()=>{let e=!1;return await Tt("/api/validateAuthentication",{},t=>{e=t.status}),e},gl=ZE({history:mE(),routes:[{name:"Index",path:"/",component:UP,meta:{requiresAuth:!0},children:[{name:"Configuration List",path:"",component:PM,meta:{title:"WireGuard Configurations"}},{name:"Settings",path:"/settings",component:MN,meta:{title:"Settings"}},{path:"/ping",name:"Ping",component:y9},{path:"/traceroute",name:"Traceroute",component:L9},{name:"New Configuration",path:"/new_configuration",component:f5,meta:{title:"New Configuration"}},{name:"Configuration",path:"/configuration/:id",component:_5,meta:{title:"Configuration"},children:[{name:"Peers List",path:"peers",component:F7},{name:"Peers Create",path:"create",component:K1}]}]},{path:"/signin",component:GT,meta:{title:"Sign In"}},{path:"/welcome",component:ZN,meta:{requiresAuth:!0,title:"Welcome to WGDashboard"}},{path:"/2FASetup",component:oq,meta:{requiresAuth:!0,title:"Multi-Factor Authentication Setup"}},{path:"/share",component:yq,meta:{title:"Share"}}]});gl.beforeEach(async(e,t,n)=>{const s=Bn(),i=et();e.meta.title?e.params.id?document.title=e.params.id+" | WGDashboard":document.title=e.meta.title+" | WGDashboard":document.title="WGDashboard",i.ShowNavBar=!1,e.meta.requiresAuth?i.getActiveCrossServer()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),n()):nP.getCookie("authToken")&&await wq()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),i.Redirect=void 0,n()):(i.Redirect=e,n("/signin"),i.newMessage("WGDashboard","Session Ended","warning")):n()});const J1=()=>{let e={"content-type":"application/json"};const n=et().getActiveCrossServer();return n&&(e["wg-dashboard-apikey"]=n.apiKey),e},X1=e=>{const n=et().getActiveCrossServer();return n?`${n.host}${e}`:`${window.location.protocol}//${window.location.host}${window.location.pathname}${e}`},Tt=async(e,t=void 0,n=void 0)=>{const s=new URLSearchParams(t);await fetch(`${X1(e)}?${s.toString()}`,{headers:J1()}).then(i=>{const o=et();if(i.ok)return i.json();if(i.status!==200)throw i.status===401&&o.newMessage("WGDashboard","Session Ended","warning"),new Error(i.statusText)}).then(i=>n?n(i):void 0).catch(i=>{console.log(i),gl.push({path:"/signin"})})},dt=async(e,t,n)=>{await fetch(`${X1(e)}`,{headers:J1(),method:"POST",body:JSON.stringify(t)}).then(s=>{const i=et();if(s.ok)return s.json();if(s.status!==200)throw s.status===401&&i.newMessage("WGDashboard","Session Ended","warning"),new Error(s.statusText)}).then(s=>n?n(s):void 0).catch(s=>{console.log(s),gl.push({path:"/signin"})})},et=bf("DashboardConfigurationStore",{state:()=>({Redirect:void 0,Configuration:void 0,Messages:[],Peers:{Selecting:!1,RefreshInterval:void 0},CrossServerConfiguration:{Enable:!1,ServerList:{}},ActiveServerConfiguration:void 0,IsElectronApp:!1,ShowNavBar:!1}),actions:{initCrossServerConfiguration(){const e=localStorage.getItem("CrossServerConfiguration");localStorage.getItem("ActiveCrossServerConfiguration")!==null&&(this.ActiveServerConfiguration=localStorage.getItem("ActiveCrossServerConfiguration")),e===null?localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration)):this.CrossServerConfiguration=JSON.parse(e)},syncCrossServerConfiguration(){localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration))},addCrossServerConfiguration(){this.CrossServerConfiguration.ServerList[Ms().toString()]={host:"",apiKey:"",active:!1}},deleteCrossServerConfiguration(e){delete this.CrossServerConfiguration.ServerList[e]},getActiveCrossServer(){const e=localStorage.getItem("ActiveCrossServerConfiguration");if(e!==null)return this.CrossServerConfiguration.ServerList[e]},setActiveCrossServer(e){this.ActiveServerConfiguration=e,localStorage.setItem("ActiveCrossServerConfiguration",e)},removeActiveCrossServer(){this.ActiveServerConfiguration=void 0,localStorage.removeItem("ActiveCrossServerConfiguration")},async getConfiguration(){await Tt("/api/getDashboardConfiguration",{},e=>{e.status&&(this.Configuration=e.data)})},async updateConfiguration(){await dt("/api/updateDashboardConfiguration",{DashboardConfiguration:this.Configuration},e=>{console.log(e)})},async signOut(){await Tt("/api/signout",{},e=>{this.removeActiveCrossServer(),this.$router.go("/signin")})},newMessage(e,t,n){this.Messages.push({id:Ms(),from:e,content:t,type:n,show:!0})}}}),fp=e=>(Kt("data-v-b845c904"),e=e(),qt(),e),xq={class:"navbar bg-dark sticky-top border-bottom border-secondary-subtle","data-bs-theme":"dark"},kq={class:"container-fluid d-flex text-body align-items-center"},Sq=fp(()=>h("span",{class:"navbar-brand mb-0 h1"},"WGDashboard",-1)),Aq={key:0,class:"ms-auto text-muted"},$q=fp(()=>h("i",{class:"bi bi-server me-2"},null,-1)),Cq=fp(()=>h("i",{class:"bi bi-list"},null,-1)),Eq=[Cq],Pq={__name:"App",setup(e){const t=et();t.initCrossServerConfiguration(),window.IS_WGDASHBOARD_DESKTOP&&(t.IsElectronApp=!0,t.CrossServerConfiguration.Enable=!0),Vt(t.CrossServerConfiguration,()=>{t.syncCrossServerConfiguration()},{deep:!0});const n=_e(()=>{if(t.ActiveServerConfiguration)return t.CrossServerConfiguration.ServerList[t.ActiveServerConfiguration]});return(s,i)=>(O(),F(Me,null,[h("nav",xq,[h("div",kq,[Sq,n.value!==void 0?(O(),F("small",Aq,[$q,ye(ve(n.value.host),1)])):ae("",!0),h("a",{role:"button",class:"navbarBtn text-body",onClick:i[0]||(i[0]=o=>q(t).ShowNavBar=!q(t).ShowNavBar),style:{"line-height":"0","font-size":"2rem"}},Eq)])]),(O(),Ne(uf,null,{default:Te(()=>[$e(q(ky),null,{default:Te(({Component:o})=>[$e(Bt,{name:"app",mode:"out-in"},{default:Te(()=>[(O(),Ne(Io(o)))]),_:2},1024)]),_:1})]),_:1}))],64))}},Tq=ze(Pq,[["__scopeId","data-v-b845c904"]]),pp=jC(Tq);pp.use(gl);const Q1=UC();Q1.use(({store:e})=>{e.$router=tu(gl)});pp.use(Q1);pp.mount("#app"); + ${e.data?"is on":"is off"}`,"Success"):this.dashboardConfigurationStore.newMessage("Server",e.message,"danger"),this.configurationInfo.Status=e.data,this.configurationToggling=!1})},getPeers(e=this.$route.params.id){Tt("/api/getWireguardConfigurationInfo",{configurationName:e},t=>{if(this.configurationInfo=t.data.configurationInfo,this.configurationPeers=t.data.configurationPeers,this.configurationPeers.forEach(n=>{n.restricted=!1}),t.data.configurationRestrictedPeers.forEach(n=>{n.restricted=!0,this.configurationPeers.push(n)}),this.loading=!1,this.configurationPeers.length>0){const n=this.configurationPeers.map(i=>i.total_sent+i.cumu_sent).reduce((i,o)=>i+o).toFixed(4),s=this.configurationPeers.map(i=>i.total_receive+i.cumu_receive).reduce((i,o)=>i+o).toFixed(4);this.historyDataSentDifference[this.historyDataSentDifference.length-1]!==n&&(this.historyDataSentDifference.length>0&&(this.historySentData={labels:[...this.historySentData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Sent",data:[...this.historySentData.datasets[0].data,((n-this.historyDataSentDifference[this.historyDataSentDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#198754",tension:0}]}),this.historyDataSentDifference.push(n)),this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1]!==s&&(this.historyDataReceivedDifference.length>0&&(this.historyReceiveData={labels:[...this.historyReceiveData.labels,Cn().format("HH:mm:ss A")],datasets:[{label:"Data Received",data:[...this.historyReceiveData.datasets[0].data,((s-this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#0d6efd",tension:0}]}),this.historyDataReceivedDifference.push(s))}})},setPeerInterval(){this.dashboardConfigurationStore.Peers.RefreshInterval=setInterval(()=>{this.getPeers()},parseInt(this.dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval))}},computed:{configurationSummary(){return{connectedPeers:this.configurationPeers.filter(t=>t.status==="running").length,totalUsage:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_data+t.cumu_data).reduce((t,n)=>t+n).toFixed(4):0,totalReceive:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_receive+t.cumu_receive).reduce((t,n)=>t+n).toFixed(4):0,totalSent:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_sent+t.cumu_sent).reduce((t,n)=>t+n).toFixed(4):0}},receiveData(){return this.historyReceiveData},sentData(){return this.historySentData},individualDataUsage(){return{labels:this.configurationPeers.map(e=>e.name?e.name:`Untitled Peer - ${e.id}`),datasets:[{label:"Total Data Usage",data:this.configurationPeers.map(e=>e.cumu_data+e.total_data),backgroundColor:this.configurationPeers.map(e=>"#0dcaf0"),tooltip:{callbacks:{label:e=>`${e.formattedValue} GB`}}}]}},individualDataUsageChartOption(){return{responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} GB`},grid:{display:!1}}}}},chartOptions(){return{responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:e=>`${e.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(e,t)=>`${e} MB/s`},grid:{display:!1}}}}},searchPeers(){const e=new Hr(this.configurationPeers,{keys:["name","id","allowed_ip"]}),t=this.wireguardConfigurationStore.searchString?e.search(this.wireguardConfigurationStore.searchString).map(n=>n.item):this.configurationPeers;return this.dashboardConfigurationStore.Configuration.Server.dashboard_sort==="restricted"?t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?-1:0):t.slice().sort((n,s)=>n[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]s[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?1:0)}}},pn=e=>(Kt("data-v-2a3b3231"),e=e(),qt(),e),CK={key:0},EK={class:"d-flex align-items-center"},PK=pn(()=>h("small",{CLASS:"text-muted"},"CONFIGURATION",-1)),TK={class:"d-flex align-items-center gap-3"},MK={class:"mb-0"},DK={class:"card rounded-3 bg-transparent shadow-sm ms-auto"},OK={class:"card-body py-2 d-flex align-items-center"},IK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Status")],-1)),RK={class:"form-check form-switch ms-auto"},LK=["for"],NK={key:0,class:"spinner-border spinner-border-sm","aria-hidden":"true"},FK=["disabled","id"],BK={class:"row mt-3 gy-2 gx-2 mb-2"},VK={class:"col-6 col-lg-3"},HK={class:"card rounded-3 bg-transparent shadow-sm"},jK={class:"card-body py-2"},WK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),zK={class:"col-6 col-lg-3"},YK={class:"card rounded-3 bg-transparent shadow-sm"},UK={class:"card-body py-2"},KK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Listen Port")],-1)),qK={style:{"word-break":"break-all"},class:"col-12 col-lg-6"},GK={class:"card rounded-3 bg-transparent shadow-sm"},JK={class:"card-body py-2"},XK=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Public Key")],-1)),QK={class:"row gx-2 gy-2 mb-2"},ZK={class:"col-6 col-lg-3"},e7={class:"card rounded-3 bg-transparent shadow-sm"},t7={class:"card-body d-flex"},n7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Connected Peers")],-1)),s7={class:"h4"},i7=pn(()=>h("i",{class:"bi bi-ethernet ms-auto h2 text-muted"},null,-1)),o7={class:"col-6 col-lg-3"},r7={class:"card rounded-3 bg-transparent shadow-sm"},a7={class:"card-body d-flex"},l7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Usage")],-1)),c7={class:"h4"},u7=pn(()=>h("i",{class:"bi bi-arrow-down-up ms-auto h2 text-muted"},null,-1)),d7={class:"col-6 col-lg-3"},h7={class:"card rounded-3 bg-transparent shadow-sm"},f7={class:"card-body d-flex"},p7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Received")],-1)),g7={class:"h4 text-primary"},m7=pn(()=>h("i",{class:"bi bi-arrow-down ms-auto h2 text-muted"},null,-1)),_7={class:"col-6 col-lg-3"},v7={class:"card rounded-3 bg-transparent shadow-sm"},b7={class:"card-body d-flex"},y7=pn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Total Sent")],-1)),w7={class:"h4 text-success"},x7=pn(()=>h("i",{class:"bi bi-arrow-up ms-auto h2 text-muted"},null,-1)),k7={class:"row gx-2 gy-2 mb-3"},S7={class:"col-12 col-lg-6"},A7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},$7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Peers Total Data Usage")],-1)),C7={class:"card-body pt-1"},E7={class:"col-sm col-lg-3"},P7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},T7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Received Data Usage")],-1)),M7={class:"card-body pt-1"},D7={class:"col-sm col-lg-3"},O7={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},I7=pn(()=>h("div",{class:"card-header bg-transparent border-0"},[h("small",{class:"text-muted"},"Real Time Sent Data Usage")],-1)),R7={class:"card-body pt-1"},L7={class:"mb-4"};function N7(e,t,n,s,i,o){const r=je("Bar"),a=je("Line"),l=je("PeerSearch"),c=je("Peer"),u=je("PeerSettings"),d=je("PeerQRCode"),f=je("PeerJobs"),p=je("PeerJobsAllModal"),m=je("PeerJobsLogsModal"),_=je("PeerShareLinkModal");return this.loading?ae("",!0):(O(),F("div",CK,[h("div",EK,[h("div",null,[PK,h("div",TK,[h("h1",MK,[h("samp",null,ve(this.configurationInfo.Name),1)])])]),h("div",DK,[h("div",OK,[h("div",null,[IK,h("div",RK,[h("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+this.configurationInfo.id},[ye(ve(this.configurationToggling?"Turning ":"")+" "+ve(this.configurationInfo.Status?"On":"Off")+" ",1),this.configurationToggling?(O(),F("span",NK)):ae("",!0)],8,LK),Re(h("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:this.configurationToggling,type:"checkbox",role:"switch",id:"switch"+this.configurationInfo.id,onChange:t[0]||(t[0]=b=>this.toggle()),"onUpdate:modelValue":t[1]||(t[1]=b=>this.configurationInfo.Status=b)},null,40,FK),[[In,this.configurationInfo.Status]])])]),h("div",{class:Ee(["dot ms-5",{active:this.configurationInfo.Status}])},null,2)])])]),h("div",BK,[h("div",VK,[h("div",HK,[h("div",jK,[WK,ye(" "+ve(this.configurationInfo.Address),1)])])]),h("div",zK,[h("div",YK,[h("div",UK,[KK,ye(" "+ve(this.configurationInfo.ListenPort),1)])])]),h("div",qK,[h("div",GK,[h("div",JK,[XK,h("samp",null,ve(this.configurationInfo.PublicKey),1)])])])]),h("div",QK,[h("div",ZK,[h("div",e7,[h("div",t7,[h("div",null,[n7,h("strong",s7,ve(o.configurationSummary.connectedPeers),1)]),i7])])]),h("div",o7,[h("div",r7,[h("div",a7,[h("div",null,[l7,h("strong",c7,ve(o.configurationSummary.totalUsage)+" GB",1)]),u7])])]),h("div",d7,[h("div",h7,[h("div",f7,[h("div",null,[p7,h("strong",g7,ve(o.configurationSummary.totalReceive)+" GB",1)]),m7])])]),h("div",_7,[h("div",v7,[h("div",b7,[h("div",null,[y7,h("strong",w7,ve(o.configurationSummary.totalSent)+" GB",1)]),x7])])])]),h("div",k7,[h("div",S7,[h("div",A7,[$7,h("div",C7,[$e(r,{data:o.individualDataUsage,options:o.individualDataUsageChartOption,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),h("div",E7,[h("div",P7,[T7,h("div",M7,[$e(a,{options:o.chartOptions,data:o.receiveData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),h("div",D7,[h("div",O7,[I7,h("div",R7,[$e(a,{options:o.chartOptions,data:o.sentData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])])]),h("div",L7,[$e(l,{onJobsAll:t[2]||(t[2]=b=>this.peerScheduleJobsAll.modalOpen=!0),onJobLogs:t[3]||(t[3]=b=>this.peerScheduleJobsLogs.modalOpen=!0),configuration:this.configurationInfo},null,8,["configuration"]),$e(Wi,{name:"list",tag:"div",class:"row gx-2 gy-2 z-0"},{default:Te(()=>[(O(!0),F(Me,null,Ke(this.searchPeers,b=>(O(),F("div",{class:"col-12 col-lg-6 col-xl-4",key:b.id},[$e(c,{Peer:b,onShare:w=>{this.peerShare.selectedPeer=b.id,this.peerShare.modalOpen=!0},onRefresh:t[4]||(t[4]=w=>this.getPeers()),onJobs:w=>{i.peerScheduleJobs.modalOpen=!0,i.peerScheduleJobs.selectedPeer=this.configurationPeers.find(A=>A.id===b.id)},onSetting:w=>{i.peerSetting.modalOpen=!0,i.peerSetting.selectedPeer=this.configurationPeers.find(A=>A.id===b.id)},onQrcode:t[5]||(t[5]=w=>{this.peerQRCode.peerConfigData=w,this.peerQRCode.modalOpen=!0})},null,8,["Peer","onShare","onJobs","onSetting"])]))),128))]),_:1})]),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerSetting.modalOpen?(O(),Ne(u,{key:"settings",selectedPeer:this.peerSetting.selectedPeer,onRefresh:t[6]||(t[6]=b=>this.getPeers()),onClose:t[7]||(t[7]=b=>this.peerSetting.modalOpen=!1)},null,8,["selectedPeer"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[i.peerQRCode.modalOpen?(O(),Ne(d,{peerConfigData:this.peerQRCode.peerConfigData,key:"qrcode",onClose:t[8]||(t[8]=b=>this.peerQRCode.modalOpen=!1)},null,8,["peerConfigData"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobs.modalOpen?(O(),Ne(f,{key:0,onRefresh:t[9]||(t[9]=b=>this.getPeers()),selectedPeer:this.peerScheduleJobs.selectedPeer,onClose:t[10]||(t[10]=b=>this.peerScheduleJobs.modalOpen=!1)},null,8,["selectedPeer"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobsAll.modalOpen?(O(),Ne(p,{key:0,onRefresh:t[11]||(t[11]=b=>this.getPeers()),onClose:t[12]||(t[12]=b=>this.peerScheduleJobsAll.modalOpen=!1),configurationPeers:this.configurationPeers},null,8,["configurationPeers"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerScheduleJobsLogs.modalOpen?(O(),Ne(m,{key:0,onClose:t[13]||(t[13]=b=>this.peerScheduleJobsLogs.modalOpen=!1),configurationInfo:this.configurationInfo},null,8,["configurationInfo"])):ae("",!0)]),_:1}),$e(Bt,{name:"zoom"},{default:Te(()=>[this.peerShare.modalOpen?(O(),Ne(_,{key:0,onClose:t[14]||(t[14]=b=>{this.peerShare.modalOpen=!1,this.peerShare.selectedPeer=void 0}),peer:this.configurationPeers.find(b=>b.id===this.peerShare.selectedPeer)},null,8,["peer"])):ae("",!0)]),_:1})]))}const F7=ze($K,[["render",N7],["__scopeId","data-v-2a3b3231"]]),B7={name:"ping",data(){return{loading:!1,cips:{},selectedConfiguration:void 0,selectedPeer:void 0,selectedIp:void 0,count:4,pingResult:void 0,pinging:!1}},setup(){return{store:et()}},mounted(){Tt("/api/ping/getAllPeersIpAddress",{},e=>{e.status&&(this.loading=!0,this.cips=e.data,console.log(this.cips))})},methods:{execute(){this.selectedIp&&(this.pinging=!0,this.pingResult=void 0,Tt("/api/ping/execute",{ipAddress:this.selectedIp,count:this.count},e=>{e.status?this.pingResult=e.data:this.store.newMessage("Server",e.message,"danger")}))}},watch:{selectedConfiguration(){this.selectedPeer=void 0,this.selectedIp=void 0},selectedPeer(){this.selectedIp=void 0}}},Hn=e=>(Kt("data-v-875f5a3c"),e=e(),qt(),e),V7={class:"mt-5 text-body"},H7={class:"container"},j7=Hn(()=>h("h3",{class:"mb-3 text-body"},"Ping",-1)),W7={class:"row"},z7={class:"col-sm-4 d-flex gap-2 flex-column"},Y7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"configuration"},[h("small",null,"Configuration")],-1)),U7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Configuration...",-1)),K7=["value"],q7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"peer"},[h("small",null,"Peer")],-1)),G7=["disabled"],J7=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a Peer...",-1)),X7=["value"],Q7=Hn(()=>h("label",{class:"mb-1 text-muted",for:"ip"},[h("small",null,"IP Address")],-1)),Z7=["disabled"],e9=Hn(()=>h("option",{disabled:"",selected:"",value:void 0},"Select a IP...",-1)),t9=Hn(()=>h("label",{class:"mb-1 text-muted",for:"count"},[h("small",null,"Ping Count")],-1)),n9=["disabled"],s9=Hn(()=>h("i",{class:"bi bi-person-walking me-2"},null,-1)),i9={class:"col-sm-8"},o9={key:"pingPlaceholder"},r9={key:"pingResult",class:"d-flex flex-column gap-2 w-100"},a9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.15s"}},l9={class:"card-body"},c9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Address")],-1)),u9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.3s"}},d9={class:"card-body"},h9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Is Alive")],-1)),f9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.45s"}},p9={class:"card-body"},g9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Average / Min / Max Round Trip Time")],-1)),m9={class:"card rounded-3 bg-transparent shadow-sm animate__animated animate__fadeIn",style:{"animation-delay":"0.6s"}},_9={class:"card-body"},v9=Hn(()=>h("p",{class:"mb-0 text-muted"},[h("small",null,"Sent / Received / Lost Package")],-1));function b9(e,t,n,s,i,o){return O(),F("div",V7,[h("div",H7,[j7,h("div",W7,[h("div",z7,[h("div",null,[Y7,Re(h("select",{class:"form-select","onUpdate:modelValue":t[0]||(t[0]=r=>this.selectedConfiguration=r)},[U7,(O(!0),F(Me,null,Ke(this.cips,(r,a)=>(O(),F("option",{value:a},ve(a),9,K7))),256))],512),[[hc,this.selectedConfiguration]])]),h("div",null,[q7,Re(h("select",{id:"peer",class:"form-select","onUpdate:modelValue":t[1]||(t[1]=r=>this.selectedPeer=r),disabled:this.selectedConfiguration===void 0},[J7,this.selectedConfiguration!==void 0?(O(!0),F(Me,{key:0},Ke(this.cips[this.selectedConfiguration],(r,a)=>(O(),F("option",{value:a},ve(a),9,X7))),256)):ae("",!0)],8,G7),[[hc,this.selectedPeer]])]),h("div",null,[Q7,Re(h("select",{id:"ip",class:"form-select","onUpdate:modelValue":t[2]||(t[2]=r=>this.selectedIp=r),disabled:this.selectedPeer===void 0},[e9,this.selectedPeer!==void 0?(O(!0),F(Me,{key:0},Ke(this.cips[this.selectedConfiguration][this.selectedPeer].allowed_ips,r=>(O(),F("option",null,ve(r),1))),256)):ae("",!0)],8,Z7),[[hc,this.selectedIp]])]),h("div",null,[t9,Re(h("input",{class:"form-control",type:"number","onUpdate:modelValue":t[3]||(t[3]=r=>this.count=r),min:"1",id:"count",placeholder:"How many times you want to ping?"},null,512),[[We,this.count]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.selectedIp,onClick:t[4]||(t[4]=r=>this.execute())},[s9,ye("Go! ")],8,n9)]),h("div",i9,[$e(Wi,{name:"ping"},{default:Te(()=>[this.pingResult?(O(),F("div",r9,[h("div",a9,[h("div",l9,[c9,ye(" "+ve(this.pingResult.address),1)])]),h("div",u9,[h("div",d9,[h9,h("span",{class:Ee([this.pingResult.is_alive?"text-success":"text-danger"])},[h("i",{class:Ee(["bi me-1",[this.pingResult.is_alive?"bi-check-circle-fill":"bi-x-circle-fill"]])},null,2),ye(" "+ve(this.pingResult.is_alive?"Yes":"No"),1)],2)])]),h("div",f9,[h("div",p9,[g9,h("samp",null,ve(this.pingResult.avg_rtt)+"ms / "+ve(this.pingResult.min_rtt)+"ms / "+ve(this.pingResult.max_rtt)+"ms ",1)])]),h("div",m9,[h("div",_9,[v9,h("samp",null,ve(this.pingResult.package_sent)+" / "+ve(this.pingResult.package_received)+" / "+ve(this.pingResult.package_loss),1)])])])):(O(),F("div",o9,[(O(),F(Me,null,Ke(4,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.pinging}]),style:Wt({"animation-delay":`${r*.15}s`})},null,6)),64))]))]),_:1})])])])])}const y9=ze(B7,[["render",b9],["__scopeId","data-v-875f5a3c"]]),w9={name:"traceroute",data(){return{tracing:!1,ipAddress:void 0,tracerouteResult:void 0}},setup(){return{store:Bn()}},methods:{execute(){this.ipAddress&&(this.tracing=!0,this.tracerouteResult=void 0,Tt("/api/traceroute/execute",{ipAddress:this.ipAddress},e=>{e.status?this.tracerouteResult=e.data:this.store.newMessage("Server",e.message,"danger"),this.tracing=!1}))}}},Pu=e=>(Kt("data-v-dda37ccf"),e=e(),qt(),e),x9={class:"mt-5 text-body"},k9={class:"container"},S9=Pu(()=>h("h3",{class:"mb-3 text-body"},"Traceroute",-1)),A9={class:"row"},$9={class:"col-sm-4 d-flex gap-2 flex-column"},C9=Pu(()=>h("label",{class:"mb-1 text-muted",for:"ipAddress"},[h("small",null,"IP Address")],-1)),E9=["disabled"],P9=Pu(()=>h("i",{class:"bi bi-bullseye me-2"},null,-1)),T9={class:"col-sm-8 position-relative"},M9={key:"pingPlaceholder"},D9={key:"table",class:"w-100"},O9={class:"table table-borderless rounded-3 w-100"},I9=Pu(()=>h("thead",null,[h("tr",null,[h("th",{scope:"col"},"Hop"),h("th",{scope:"col"},"IP Address"),h("th",{scope:"col"},"Average / Min / Max Round Trip Time")])],-1));function R9(e,t,n,s,i,o){return O(),F("div",x9,[h("div",k9,[S9,h("div",A9,[h("div",$9,[h("div",null,[C9,Re(h("input",{id:"ipAddress",class:"form-control","onUpdate:modelValue":t[0]||(t[0]=r=>this.ipAddress=r),type:"text",placeholder:"Enter an IP Address you want to trace :)"},null,512),[[We,this.ipAddress]])]),h("button",{class:"btn btn-primary rounded-3 mt-3",disabled:!this.store.regexCheckIP(this.ipAddress)||this.tracing,onClick:t[1]||(t[1]=r=>this.execute())},[P9,ye(" "+ve(this.tracing?"Tracing...":"Trace It!"),1)],8,E9)]),h("div",T9,[$e(Wi,{name:"ping"},{default:Te(()=>[this.tracerouteResult?(O(),F("div",D9,[h("table",O9,[I9,h("tbody",null,[(O(!0),F(Me,null,Ke(this.tracerouteResult,(r,a)=>(O(),F("tr",{class:"animate__fadeInUp animate__animated",style:Wt({"animation-delay":`${a*.05}s`})},[h("td",null,ve(r.hop),1),h("td",null,ve(r.ip),1),h("td",null,ve(r.avg_rtt)+" / "+ve(r.min_rtt)+" / "+ve(r.max_rtt),1)],4))),256))])])])):(O(),F("div",M9,[(O(),F(Me,null,Ke(10,r=>h("div",{class:Ee(["pingPlaceholder bg-body-secondary rounded-3 mb-3",{"animate__animated animate__flash animate__slower animate__infinite":this.tracing}]),style:Wt({"animation-delay":`${r*.05}s`})},null,6)),64))]))]),_:1})])])])])}const L9=ze(w9,[["render",R9],["__scopeId","data-v-dda37ccf"]]),N9={name:"totp",async setup(){const e=et();let t="";return await Tt("/api/Welcome_GetTotpLink",{},n=>{n.status&&(t=n.data)}),{l:t,store:e}},mounted(){this.l&&Bo.toCanvas(document.getElementById("qrcode"),this.l,function(e){})},data(){return{totp:"",totpInvalidMessage:"",verified:!1}},methods:{validateTotp(){}},watch:{totp(e){const t=document.querySelector("#totp");t.classList.remove("is-invalid","is-valid"),e.length===6&&(console.log(e),/[0-9]{6}/.test(e)?dt("/api/Welcome_VerifyTotpLink",{totp:e},n=>{n.status?(this.verified=!0,t.classList.add("is-valid"),this.$emit("verified")):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP does not match.")}):(t.classList.add("is-invalid"),this.totpInvalidMessage="TOTP can only contain numbers"))}}},F9=["data-bs-theme"],B9={class:"m-auto text-body",style:{width:"500px"}},V9={class:"d-flex flex-column"},H9=h("h1",{class:"dashboardLogo display-4"},"Multi-Factor Authentication",-1),j9=h("p",{class:"mb-2"},[h("small",{class:"text-muted"},"1. Please scan the following QR Code to generate TOTP")],-1),W9=h("canvas",{id:"qrcode",class:"rounded-3 mb-2"},null,-1),z9={class:"p-3 bg-body-secondary rounded-3 border mb-3"},Y9=h("p",{class:"text-muted mb-0"},[h("small",null,"Or you can click the link below:")],-1),U9=["href"],K9={style:{"line-break":"anywhere"}},q9=h("label",{for:"totp",class:"mb-2"},[h("small",{class:"text-muted"},"2. Enter the TOTP generated by your authenticator to verify")],-1),G9={class:"form-group mb-2"},J9=["disabled"],X9={class:"invalid-feedback"},Q9=h("div",{class:"valid-feedback"}," TOTP verified! ",-1),Z9=h("div",{class:"alert alert-warning rounded-3"},[h("i",{class:"bi bi-exclamation-triangle-fill me-2"}),ye(" If you ever lost your TOTP and can't login, please follow instruction on "),h("a",{href:"https://github.com/donaldzou/WGDashboard",target:"_blank"},"readme.md"),ye(" to reset. ")],-1),eq=h("hr",null,null,-1),tq={class:"d-flex gap-3 mt-5 flex-column"},nq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1),sq=h("i",{class:"bi bi-chevron-right ms-auto"},null,-1);function iq(e,t,n,s,i,o){const r=je("RouterLink");return O(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.store.Configuration.Server.dashboard_theme},[h("div",B9,[h("div",V9,[h("div",null,[H9,j9,W9,h("div",z9,[Y9,h("a",{href:this.l},[h("code",K9,ve(this.l),1)],8,U9)]),q9,h("div",G9,[Re(h("input",{class:"form-control text-center totp",id:"totp",maxlength:"6",type:"text",inputmode:"numeric",autocomplete:"one-time-code","onUpdate:modelValue":t[0]||(t[0]=a=>this.totp=a),disabled:this.verified},null,8,J9),[[We,this.totp]]),h("div",X9,ve(this.totpInvalidMessage),1),Q9]),Z9]),eq,h("div",tq,[this.verified?(O(),Ne(r,{key:1,to:"/",class:"btn btn-dark btn-lg d-flex btn-brand shadow align-items-center flex-grow-1 rounded-3"},{default:Te(()=>[ye(" Complete "),sq]),_:1})):(O(),Ne(r,{key:0,to:"/",class:"btn bg-secondary-subtle text-secondary-emphasis rounded-3 flex-grow-1 btn-lg border-1 border-secondary-subtle shadow d-flex"},{default:Te(()=>[ye(" I don't need MFA "),nq]),_:1}))])])])],8,F9)}const oq=ze(N9,[["render",iq]]),rq={name:"share",async setup(){const e=tP(),t=be(!1),n=et(),s=be(""),i=be(""),o=be(new Blob);await Tt("/api/getDashboardTheme",{},a=>{s.value=a.data});const r=e.query.ShareID;return r===void 0||r.length===0?(i.value=void 0,t.value=!0):await Tt("/api/sharePeer/get",{ShareID:r},a=>{a.status?(i.value=a.data,o.value=new Blob([i.value.file],{type:"text/plain"})):i.value=void 0,t.value=!0}),{store:n,theme:s,peerConfiguration:i,blob:o}},mounted(){Bo.toCanvas(document.querySelector("#qrcode"),this.peerConfiguration.file,e=>{e&&console.error(e)})},methods:{download(){const e=new Blob([this.peerConfiguration.file],{type:"text/plain"}),t=URL.createObjectURL(e),n=`${this.peerConfiguration.fileName}.conf`,s=document.createElement("a");s.href=t,s.download=n,s.click()}},computed:{getBlob(){return URL.createObjectURL(this.blob)}}},hp=e=>(Kt("data-v-99d4b06a"),e=e(),qt(),e),aq=["data-bs-theme"],lq={class:"m-auto text-body",style:{width:"500px"}},cq={key:0,class:"text-center position-relative",style:{}},uq=Q$('

Oh no... This link is either expired or invalid.

',2),dq=[uq],hq={key:1,class:"d-flex align-items-center flex-column gap-3"},fq=hp(()=>h("div",{class:"h1 dashboardLogo text-center animate__animated animate__fadeInUp"},[h("h6",null,"WGDashboard"),ye(" Scan QR Code from the WireGuard App ")],-1)),pq={id:"qrcode",class:"rounded-3 shadow animate__animated animate__fadeInUp mb-3",ref:"qrcode"},gq=hp(()=>h("p",{class:"text-muted animate__animated animate__fadeInUp mb-1",style:{"animation-delay":"0.2s"}},[ye("or click the button below to download the "),h("samp",null,".conf"),ye(" file")],-1)),mq=["download","href"],_q=hp(()=>h("i",{class:"bi bi-download"},null,-1)),vq=[_q];function bq(e,t,n,s,i,o){return O(),F("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.theme},[h("div",lq,[this.peerConfiguration?(O(),F("div",hq,[fq,h("canvas",pq,null,512),gq,h("a",{download:this.peerConfiguration.fileName+".conf",href:o.getBlob,class:"btn btn-lg bg-primary-subtle text-primary-emphasis border-1 border-primary-subtle animate__animated animate__fadeInUp shadow-sm",style:{"animation-delay":"0.25s"}},vq,8,mq)])):(O(),F("div",cq,dq))])],8,aq)}const yq=ze(rq,[["render",bq],["__scopeId","data-v-99d4b06a"]]),wq=async()=>{let e=!1;return await Tt("/api/validateAuthentication",{},t=>{e=t.status}),e},gl=ZE({history:mE(),routes:[{name:"Index",path:"/",component:UP,meta:{requiresAuth:!0},children:[{name:"Configuration List",path:"",component:PM,meta:{title:"WireGuard Configurations"}},{name:"Settings",path:"/settings",component:MN,meta:{title:"Settings"}},{path:"/ping",name:"Ping",component:y9},{path:"/traceroute",name:"Traceroute",component:L9},{name:"New Configuration",path:"/new_configuration",component:f5,meta:{title:"New Configuration"}},{name:"Configuration",path:"/configuration/:id",component:_5,meta:{title:"Configuration"},children:[{name:"Peers List",path:"peers",component:F7},{name:"Peers Create",path:"create",component:K1}]}]},{path:"/signin",component:GT,meta:{title:"Sign In"}},{path:"/welcome",component:ZN,meta:{requiresAuth:!0,title:"Welcome to WGDashboard"}},{path:"/2FASetup",component:oq,meta:{requiresAuth:!0,title:"Multi-Factor Authentication Setup"}},{path:"/share",component:yq,meta:{title:"Share"}}]});gl.beforeEach(async(e,t,n)=>{const s=Bn(),i=et();e.meta.title?e.params.id?document.title=e.params.id+" | WGDashboard":document.title=e.meta.title+" | WGDashboard":document.title="WGDashboard",i.ShowNavBar=!1,e.meta.requiresAuth?i.getActiveCrossServer()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),n()):nP.getCookie("authToken")&&await wq()?(await i.getConfiguration(),!s.Configurations&&e.name!=="Configuration List"&&await s.getConfigurations(),i.Redirect=void 0,n()):(i.Redirect=e,n("/signin"),i.newMessage("WGDashboard","Session Ended","warning")):n()});const J1=()=>{let e={"content-type":"application/json"};const n=et().getActiveCrossServer();return n&&(e["wg-dashboard-apikey"]=n.apiKey),e},X1=e=>{const n=et().getActiveCrossServer();return n?`${n.host}${e}`:(console.log("URL fetching: ",`${window.location.protocol}//${window.location.host}${window.location.pathname}${e}`),`${window.location.protocol}//${window.location.host}${window.location.pathname}${e}`)},Tt=async(e,t=void 0,n=void 0)=>{const s=new URLSearchParams(t);await fetch(`${X1(e)}?${s.toString()}`,{headers:J1()}).then(i=>{const o=et();if(i.ok)return i.json();if(i.status!==200)throw i.status===401&&o.newMessage("WGDashboard","Session Ended","warning"),new Error(i.statusText)}).then(i=>n?n(i):void 0).catch(i=>{console.log(i),gl.push({path:"/signin"})})},dt=async(e,t,n)=>{await fetch(`${X1(e)}`,{headers:J1(),method:"POST",body:JSON.stringify(t)}).then(s=>{const i=et();if(s.ok)return s.json();if(s.status!==200)throw s.status===401&&i.newMessage("WGDashboard","Session Ended","warning"),new Error(s.statusText)}).then(s=>n?n(s):void 0).catch(s=>{console.log(s),gl.push({path:"/signin"})})},et=bf("DashboardConfigurationStore",{state:()=>({Redirect:void 0,Configuration:void 0,Messages:[],Peers:{Selecting:!1,RefreshInterval:void 0},CrossServerConfiguration:{Enable:!1,ServerList:{}},ActiveServerConfiguration:void 0,IsElectronApp:!1,ShowNavBar:!1}),actions:{initCrossServerConfiguration(){const e=localStorage.getItem("CrossServerConfiguration");localStorage.getItem("ActiveCrossServerConfiguration")!==null&&(this.ActiveServerConfiguration=localStorage.getItem("ActiveCrossServerConfiguration")),e===null?localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration)):this.CrossServerConfiguration=JSON.parse(e)},syncCrossServerConfiguration(){localStorage.setItem("CrossServerConfiguration",JSON.stringify(this.CrossServerConfiguration))},addCrossServerConfiguration(){this.CrossServerConfiguration.ServerList[Ms().toString()]={host:"",apiKey:"",active:!1}},deleteCrossServerConfiguration(e){delete this.CrossServerConfiguration.ServerList[e]},getActiveCrossServer(){const e=localStorage.getItem("ActiveCrossServerConfiguration");if(e!==null)return this.CrossServerConfiguration.ServerList[e]},setActiveCrossServer(e){this.ActiveServerConfiguration=e,localStorage.setItem("ActiveCrossServerConfiguration",e)},removeActiveCrossServer(){this.ActiveServerConfiguration=void 0,localStorage.removeItem("ActiveCrossServerConfiguration")},async getConfiguration(){await Tt("/api/getDashboardConfiguration",{},e=>{e.status&&(this.Configuration=e.data)})},async updateConfiguration(){await dt("/api/updateDashboardConfiguration",{DashboardConfiguration:this.Configuration},e=>{console.log(e)})},async signOut(){await Tt("/api/signout",{},e=>{this.removeActiveCrossServer(),this.$router.go("/signin")})},newMessage(e,t,n){this.Messages.push({id:Ms(),from:e,content:t,type:n,show:!0})}}}),fp=e=>(Kt("data-v-b845c904"),e=e(),qt(),e),xq={class:"navbar bg-dark sticky-top border-bottom border-secondary-subtle","data-bs-theme":"dark"},kq={class:"container-fluid d-flex text-body align-items-center"},Sq=fp(()=>h("span",{class:"navbar-brand mb-0 h1"},"WGDashboard",-1)),Aq={key:0,class:"ms-auto text-muted"},$q=fp(()=>h("i",{class:"bi bi-server me-2"},null,-1)),Cq=fp(()=>h("i",{class:"bi bi-list"},null,-1)),Eq=[Cq],Pq={__name:"App",setup(e){const t=et();t.initCrossServerConfiguration(),window.IS_WGDASHBOARD_DESKTOP&&(t.IsElectronApp=!0,t.CrossServerConfiguration.Enable=!0),Vt(t.CrossServerConfiguration,()=>{t.syncCrossServerConfiguration()},{deep:!0});const n=_e(()=>{if(t.ActiveServerConfiguration)return t.CrossServerConfiguration.ServerList[t.ActiveServerConfiguration]});return(s,i)=>(O(),F(Me,null,[h("nav",xq,[h("div",kq,[Sq,n.value!==void 0?(O(),F("small",Aq,[$q,ye(ve(n.value.host),1)])):ae("",!0),h("a",{role:"button",class:"navbarBtn text-body",onClick:i[0]||(i[0]=o=>q(t).ShowNavBar=!q(t).ShowNavBar),style:{"line-height":"0","font-size":"2rem"}},Eq)])]),(O(),Ne(uf,null,{default:Te(()=>[$e(q(ky),null,{default:Te(({Component:o})=>[$e(Bt,{name:"app",mode:"out-in"},{default:Te(()=>[(O(),Ne(Io(o)))]),_:2},1024)]),_:1})]),_:1}))],64))}},Tq=ze(Pq,[["__scopeId","data-v-b845c904"]]),pp=jC(Tq);pp.use(gl);const Q1=UC();Q1.use(({store:e})=>{e.$router=tu(gl)});pp.use(Q1);pp.mount("#app"); diff --git a/src/static/app/src/utilities/fetch.js b/src/static/app/src/utilities/fetch.js index 2e7db5d..57f0086 100644 --- a/src/static/app/src/utilities/fetch.js +++ b/src/static/app/src/utilities/fetch.js @@ -19,6 +19,10 @@ const getUrl = (url) => { if (apiKey){ return `${apiKey.host}${url}` } + + console.log("URL fetching: ", import.meta.env.MODE === 'development' ? url + : `${window.location.protocol}//${window.location.host}${window.location.pathname}${url}`) + return import.meta.env.MODE === 'development' ? url : `${window.location.protocol}//${window.location.host}${window.location.pathname}${url}` }