const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/peerJobsLogsModal.js","assets/dayjs.min.js","assets/index.js","assets/index.css","assets/localeText.js","assets/peerJobsAllModal.js","assets/browser.js","assets/peerCreate.js","assets/wireguard.js","assets/peerCreate.css","assets/vue-datepicker.js"])))=>i.map(i=>d[i]); import{_ as ut,D as Pt,W as us,G as Mt,m as nt,f as At,o as w,c as $,a as h,b as y,w as G,k as K,p as Z,F as lt,r as Zt,t as B,j as I,h as rt,e as z,I as qo,J as Qo,B as ns,E as fs,d as et,n as Q,g as H,q as j,K as Bn,L as zn,M as As,N as Zo,A as Xs,O as tr,P as Ls,Q as er,R as Nn,U as sr,l as ir,T as Gs,C as Ts,V as Is,v as Hn,s as jn,X as gs,u as nr,H as or,Y as gi,Z as pi}from"./index.js";import{L as D}from"./localeText.js";import{d as qt}from"./dayjs.min.js";import{b as rr}from"./browser.js";import ar from"./peerCreate.js";import{V as Vn}from"./vue-datepicker.js";const lr={name:"peerSearch",components:{LocaleText:D},setup(){const s=Pt(),t=us();return{store:s,wireguardConfigurationStore:t}},props:{configuration:Object},data(){return{sort:{status:Mt("Status"),name:Mt("Name"),allowed_ip:Mt("Allowed IPs"),restricted:Mt("Restricted")},interval:{5e3:Mt("5 Seconds"),1e4:Mt("10 Seconds"),3e4:Mt("30 Seconds"),6e4:Mt("1 Minutes")},searchString:"",searchStringTimeout:void 0,showDisplaySettings:!1,showMoreSettings:!1}},methods:{debounce(){this.searchStringTimeout?(clearTimeout(this.searchStringTimeout),this.searchStringTimeout=setTimeout(()=>{this.wireguardConfigurationStore.searchString=this.searchString},300)):this.searchStringTimeout=setTimeout(()=>{this.wireguardConfigurationStore.searchString=this.searchString},300)},updateSort(s){nt("/api/updateDashboardConfigurationItem",{section:"Server",key:"dashboard_sort",value:s},t=>{t.status&&this.store.getConfiguration()})},updateRefreshInterval(s){nt("/api/updateDashboardConfigurationItem",{section:"Server",key:"dashboard_refresh_interval",value:s},t=>{t.status&&this.store.getConfiguration()})},downloadAllPeer(){At(`/api/downloadAllPeers/${this.configuration.Name}`,{},s=>{console.log(s),window.wireguard.generateZipFiles(s,this.configuration.Name)})}},computed:{searchBarPlaceholder(){return Mt("Search Peers...")}}},cr={class:"mb-3"},dr={class:"d-flex gap-2 z-3 peerSearchContainer"},hr={class:"mt-3 mt-md-0 flex-grow-1"},ur=["placeholder"],fr={key:0,class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll displayModal"},gr={class:"container-md d-flex h-100 w-100"},pr={class:"m-auto modal-dialog-centered dashboardModal"},mr={class:"card rounded-3 shadow w-100"},br={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},_r={class:"mb-0 fw-normal"},xr={class:"card-body px-4 pb-4 d-flex gap-3 flex-column"},yr={class:"text-muted fw-bold mb-2"},vr={class:"list-group"},wr=["onClick"],Sr={class:"me-auto"},kr={key:0,class:"bi bi-check text-primary"},Pr={class:"text-muted fw-bold mb-2"},Mr={class:"list-group"},Cr=["onClick"],$r={class:"me-auto"},Dr={key:0,class:"bi bi-check text-primary"},Or={key:0,class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll displayModal"},Ar={class:"container-md d-flex h-100 w-100"},Lr={class:"m-auto modal-dialog-centered dashboardModal"},Tr={class:"card rounded-3 shadow w-100"},Ir={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},Rr={class:"mb-0"},Er={class:"card-body px-4 pb-4 d-flex gap-3 flex-column pt-0"},Fr={class:"text-muted fw-bold mb-2"},Br={class:"list-group"},zr={class:"text-muted fw-bold mb-2"},Nr={class:"list-group"};function Hr(s,t,e,i,n,o){const r=z("LocaleText"),a=z("RouterLink");return w(),$("div",cr,[h("div",dr,[y(a,{to:"create",class:"text-decoration-none btn text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle shadow-sm"},{default:G(()=>[t[13]||(t[13]=h("i",{class:"bi bi-plus-lg me-2"},null,-1)),y(r,{t:"Peer"})]),_:1}),h("button",{class:"btn text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle shadow-sm",onClick:t[0]||(t[0]=l=>this.downloadAllPeer())},[t[14]||(t[14]=h("i",{class:"bi bi-download me-2"},null,-1)),y(r,{t:"Download All"})]),h("div",hr,[K(h("input",{class:"form-control rounded-3 bg-secondary-subtle border-1 border-secondary-subtle shadow-sm w-100",placeholder:o.searchBarPlaceholder,id:"searchPeers",onKeyup:t[1]||(t[1]=l=>this.debounce()),"onUpdate:modelValue":t[2]||(t[2]=l=>this.searchString=l)},null,40,ur),[[Z,this.searchString]])]),h("button",{onClick:t[3]||(t[3]=l=>this.showDisplaySettings=!0),class:"btn text-secondary-emphasis bg-secondary-subtle rounded-3 border-1 border-secondary-subtle shadow-sm",type:"button","aria-expanded":"false"},[t[15]||(t[15]=h("i",{class:"bi bi-filter-circle me-2"},null,-1)),y(r,{t:"Display"})]),h("button",{class:"btn text-secondary-emphasis bg-secondary-subtle rounded-3 border-1 border-secondary-subtle shadow-sm",onClick:t[4]||(t[4]=l=>this.$emit("editConfiguration")),type:"button","aria-expanded":"false"},t[16]||(t[16]=[h("i",{class:"bi bi-gear-fill"},null,-1)])),h("button",{class:"btn text-secondary-emphasis bg-secondary-subtle rounded-3 border-1 border-secondary-subtle shadow-sm",onClick:t[5]||(t[5]=l=>this.showMoreSettings=!0),type:"button","aria-expanded":"false"},t[17]||(t[17]=[h("i",{class:"bi bi-three-dots"},null,-1)])),y(rt,{name:"zoom"},{default:G(()=>[this.showDisplaySettings?(w(),$("div",fr,[h("div",gr,[h("div",pr,[h("div",mr,[h("div",br,[h("h4",_r,[y(r,{t:"Display"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:t[6]||(t[6]=l=>this.showDisplaySettings=!1)})]),h("div",xr,[h("div",null,[h("p",yr,[h("small",null,[y(r,{t:"Sort by"})])]),h("div",vr,[(w(!0),$(lt,null,Zt(this.sort,(l,c)=>(w(),$("a",{class:"list-group-item list-group-item-action d-flex",role:"button",onClick:d=>this.updateSort(c)},[h("span",Sr,B(l),1),i.store.Configuration.Server.dashboard_sort===c?(w(),$("i",kr)):I("",!0)],8,wr))),256))])]),h("div",null,[h("p",Pr,[h("small",null,[y(r,{t:"Refresh Interval"})])]),h("div",Mr,[(w(!0),$(lt,null,Zt(this.interval,(l,c)=>(w(),$("a",{class:"list-group-item list-group-item-action d-flex",role:"button",onClick:d=>this.updateRefreshInterval(c)},[h("span",$r,B(l),1),i.store.Configuration.Server.dashboard_refresh_interval===c?(w(),$("i",Dr)):I("",!0)],8,Cr))),256))])])])])])])])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[this.showMoreSettings?(w(),$("div",Or,[h("div",Ar,[h("div",Lr,[h("div",Tr,[h("div",Ir,[h("h4",Rr,[y(r,{t:"Other Settings"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:t[7]||(t[7]=l=>this.showMoreSettings=!1)})]),h("div",Er,[h("div",null,[h("p",Fr,[h("small",null,[y(r,{t:"Peers"})])]),h("div",Br,[h("a",{class:"list-group-item list-group-item-action d-flex",role:"button",onClick:t[8]||(t[8]=l=>this.$emit("selectPeers"))},[y(r,{t:"Select Peers"})]),h("a",{class:"list-group-item list-group-item-action d-flex",role:"button",onClick:t[9]||(t[9]=l=>this.$emit("jobsAll"))},[y(r,{t:"Active Jobs"})]),h("a",{class:"list-group-item list-group-item-action d-flex",role:"button",onClick:t[10]||(t[10]=l=>this.$emit("jobLogs"))},[y(r,{t:"Logs"})])])]),h("div",null,[h("p",zr,[h("small",null,[y(r,{t:"Configuration"})])]),h("div",Nr,[h("a",{class:"list-group-item list-group-item-action d-flex",role:"button",onClick:t[11]||(t[11]=l=>this.$emit("backupRestore"))},[y(r,{t:"Backup & Restore"})]),h("a",{class:"list-group-item list-group-item-action d-flex text-danger fw-bold",role:"button",onClick:t[12]||(t[12]=l=>this.$emit("deleteConfiguration"))},[y(r,{t:"Delete Configuration"})])])])])])])])])):I("",!0)]),_:1})])])}const jr=ut(lr,[["render",Hr],["__scopeId","data-v-162e14b9"]]);function Vr(s){return qo()?(Qo(s),!0):!1}function Wn(s){return typeof s=="function"?s():ns(s)}const Un=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Wr=Object.prototype.toString,Ur=s=>Wr.call(s)==="[object Object]",es=()=>{},Yr=Kr();function Kr(){var s,t;return Un&&((s=window?.navigator)==null?void 0:s.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window?.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function ye(s){var t;const e=Wn(s);return(t=e?.$el)!=null?t:e}const Yn=Un?window:void 0;function _s(...s){let t,e,i,n;if(typeof s[0]=="string"||Array.isArray(s[0])?([e,i,n]=s,t=Yn):[t,e,i,n]=s,!t)return es;Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]);const o=[],r=()=>{o.forEach(d=>d()),o.length=0},a=(d,u,f,g)=>(d.addEventListener(u,f,g),()=>d.removeEventListener(u,f,g)),l=fs(()=>[ye(t),Wn(n)],([d,u])=>{if(r(),!d)return;const f=Ur(u)?{...u}:u;o.push(...e.flatMap(g=>i.map(p=>a(d,g,p,f))))},{immediate:!0,flush:"post"}),c=()=>{l(),r()};return Vr(c),c}let mi=!1;function Jr(s,t,e={}){const{window:i=Yn,ignore:n=[],capture:o=!0,detectIframe:r=!1}=e;if(!i)return es;Yr&&!mi&&(mi=!0,Array.from(i.document.body.children).forEach(f=>f.addEventListener("click",es)),i.document.documentElement.addEventListener("click",es));let a=!0;const l=f=>n.some(g=>{if(typeof g=="string")return Array.from(i.document.querySelectorAll(g)).some(p=>p===f.target||f.composedPath().includes(p));{const p=ye(g);return p&&(f.target===p||f.composedPath().includes(p))}}),d=[_s(i,"click",f=>{const g=ye(s);if(!(!g||g===f.target||f.composedPath().includes(g))){if(f.detail===0&&(a=!l(f)),!a){a=!0;return}t(f)}},{passive:!0,capture:o}),_s(i,"pointerdown",f=>{const g=ye(s);a=!l(f)&&!!(g&&!f.composedPath().includes(g))},{passive:!0}),r&&_s(i,"blur",f=>{setTimeout(()=>{var g;const p=ye(s);((g=i.document.activeElement)==null?void 0:g.tagName)==="IFRAME"&&!p?.contains(i.document.activeElement)&&t(f)},0)})].filter(Boolean);return()=>d.forEach(f=>f())}const Xr={name:"peerSettingsDropdown",components:{LocaleText:D},setup(){return{dashboardStore:Pt()}},props:{Peer:Object},data(){return{deleteBtnDisabled:!1,restrictBtnDisabled:!1,allowAccessBtnDisabled:!1,confirmDelete:!1}},methods:{downloadPeer(){At("/api/downloadPeer/"+this.$route.params.id,{id:this.Peer.id},s=>{if(s.status){const t=new Blob([s.data.file],{type:"text/plain"}),e=URL.createObjectURL(t),i=`${s.data.fileName}.conf`,n=document.createElement("a");n.href=e,n.download=i,n.click(),this.dashboardStore.newMessage("WGDashboard","Peer download started","success")}else this.dashboardStore.newMessage("Server",s.message,"danger")})},downloadQRCode(){At("/api/downloadPeer/"+this.$route.params.id,{id:this.Peer.id},s=>{s.status?this.$emit("qrcode",s.data.file):this.dashboardStore.newMessage("Server",s.message,"danger")})},deletePeer(){this.deleteBtnDisabled=!0,nt(`/api/deletePeers/${this.$route.params.id}`,{peers:[this.Peer.id]},s=>{this.dashboardStore.newMessage("Server",s.message,s.status?"success":"danger"),this.$emit("refresh"),this.deleteBtnDisabled=!1})},restrictPeer(){this.restrictBtnDisabled=!0,nt(`/api/restrictPeers/${this.$route.params.id}`,{peers:[this.Peer.id]},s=>{this.dashboardStore.newMessage("Server",s.message,s.status?"success":"danger"),this.$emit("refresh"),this.restrictBtnDisabled=!1})},allowAccessPeer(){this.allowAccessBtnDisabled=!0,nt(`/api/allowAccessPeers/${this.$route.params.id}`,{peers:[this.Peer.id]},s=>{this.dashboardStore.newMessage("Server",s.message,s.status?"success":"danger"),this.$emit("refresh"),this.allowAccessBtnDisabled=!1})}}},Gr={class:"dropdown-menu mt-2 shadow-lg d-block rounded-3",style:{"max-width":"200px"}},qr={style:{"font-size":"0.8rem","padding-left":"var(--bs-dropdown-item-padding-x)","padding-right":"var(--bs-dropdown-item-padding-x)"}},Qr={class:"text-body d-flex"},Zr={class:"ms-auto"},ta={key:1},ea={class:"w-100 dropdown-item text-muted",style:{"white-space":"break-spaces","font-size":"0.7rem"}},sa={key:2,class:"d-flex",style:{"padding-left":"var(--bs-dropdown-item-padding-x)","padding-right":"var(--bs-dropdown-item-padding-x)"}},ia={key:1,class:"confirmDelete"},na={style:{"white-space":"break-spaces"},class:"mb-2 d-block fw-bold"},oa={class:"d-flex w-100 gap-2"},ra=["disabled"],aa=["disabled"],la={key:1};function ca(s,t,e,i,n,o){const r=z("LocaleText");return w(),$("ul",Gr,[this.Peer.restricted?(w(),$("li",la,[h("a",{class:Q(["dropdown-item d-flex text-warning",{disabled:this.allowAccessBtnDisabled}]),onClick:t[9]||(t[9]=a=>this.allowAccessPeer()),role:"button"},[t[23]||(t[23]=h("i",{class:"me-auto bi bi-unlock"},null,-1)),this.allowAccessBtnDisabled?(w(),H(r,{key:1,t:"Allowing Access..."})):(w(),H(r,{key:0,t:"Allow Access"}))],2)])):(w(),$(lt,{key:0},[this.confirmDelete?(w(),$("li",ia,[h("p",na,[y(r,{t:"Are you sure to delete this peer?"})]),h("div",oa,[h("button",{onClick:t[7]||(t[7]=a=>this.deletePeer()),disabled:this.deleteBtnDisabled,class:"flex-grow-1 ms-auto btn btn-sm bg-danger"},[y(r,{t:"Yes"})],8,ra),h("button",{disabled:this.deleteBtnDisabled,onClick:t[8]||(t[8]=a=>this.confirmDelete=!1),class:"flex-grow-1 btn btn-sm bg-secondary-subtle text-secondary-emphasis border border-secondary-subtle"},[y(r,{t:"No"})],8,aa)])])):(w(),$(lt,{key:0},[this.Peer.status==="running"?(w(),$(lt,{key:0},[h("li",qr,[h("span",Qr,[t[10]||(t[10]=h("i",{class:"bi bi-box-arrow-in-right"},null,-1)),h("span",Zr,B(this.Peer.endpoint),1)])]),t[11]||(t[11]=h("li",null,[h("hr",{class:"dropdown-divider"})],-1))],64)):I("",!0),this.Peer.private_key?(w(),$("li",sa,[h("a",{class:"dropdown-item text-center px-0 rounded-3",role:"button",onClick:t[0]||(t[0]=a=>this.downloadPeer())},t[12]||(t[12]=[h("i",{class:"me-auto bi bi-download"},null,-1)])),h("a",{class:"dropdown-item text-center px-0 rounded-3",role:"button",onClick:t[1]||(t[1]=a=>this.downloadQRCode())},t[13]||(t[13]=[h("i",{class:"me-auto bi bi-qr-code"},null,-1)])),h("a",{class:"dropdown-item text-center px-0 rounded-3",role:"button",onClick:t[2]||(t[2]=a=>this.$emit("share"))},t[14]||(t[14]=[h("i",{class:"me-auto bi bi-share"},null,-1)]))])):(w(),$("li",ta,[h("small",ea,[y(r,{t:"Download & QR Code is not available due to no private key set for this peer"})])])),t[21]||(t[21]=h("li",null,[h("hr",{class:"dropdown-divider"})],-1)),h("li",null,[h("a",{class:"dropdown-item d-flex",role:"button",onClick:t[3]||(t[3]=a=>this.$emit("setting"))},[t[15]||(t[15]=h("i",{class:"me-auto bi bi-pen"},null,-1)),t[16]||(t[16]=et()),y(r,{t:"Peer Settings"})])]),h("li",null,[h("a",{class:"dropdown-item d-flex",role:"button",onClick:t[4]||(t[4]=a=>this.$emit("jobs"))},[t[17]||(t[17]=h("i",{class:"me-auto bi bi-app-indicator"},null,-1)),t[18]||(t[18]=et()),y(r,{t:"Schedule Jobs"})])]),t[22]||(t[22]=h("li",null,[h("hr",{class:"dropdown-divider"})],-1)),h("li",null,[h("a",{class:Q(["dropdown-item d-flex text-warning",{disabled:this.restrictBtnDisabled}]),onClick:t[5]||(t[5]=a=>this.restrictPeer()),role:"button"},[t[19]||(t[19]=h("i",{class:"me-auto bi bi-lock"},null,-1)),this.restrictBtnDisabled?(w(),H(r,{key:1,t:"Restricting..."})):(w(),H(r,{key:0,t:"Restrict Access"}))],2)]),h("li",null,[h("a",{class:Q(["dropdown-item d-flex fw-bold text-danger",{disabled:this.deleteBtnDisabled}]),onClick:t[6]||(t[6]=a=>this.confirmDelete=!0),role:"button"},[t[20]||(t[20]=h("i",{class:"me-auto bi bi-trash"},null,-1)),this.deleteBtnDisabled?(w(),H(r,{key:1,t:"Deleting..."})):(w(),H(r,{key:0,t:"Delete"}))],2)])],64))],64))])}const da=ut(Xr,[["render",ca],["__scopeId","data-v-f8d25e4d"]]),ha={name:"peer",components:{LocaleText:D,PeerSettingsDropdown:da},props:{Peer:Object},data(){return{}},setup(){const s=j(null),t=j(!1);return Jr(s,e=>{t.value=!1}),{target:s,subMenuOpened:t}},computed:{getLatestHandshake(){return this.Peer.latest_handshake.includes(",")?this.Peer.latest_handshake.split(",")[0]:this.Peer.latest_handshake}}},ua={key:0,class:"card-header bg-transparent d-flex align-items-center gap-2 border-0"},fa={style:{"font-size":"0.8rem"},class:"ms-auto d-flex gap-2"},ga={class:"text-primary"},pa={class:"text-success"},ma={key:0,class:"text-secondary"},ba={key:1,class:"border-0 card-header bg-transparent text-warning fw-bold",style:{"font-size":"0.8rem"}},_a={class:"card-body pt-1",style:{"font-size":"0.9rem"}},xa={class:"mb-1"},ya={class:"text-muted"},va={class:"d-block"},wa={class:"text-muted"},Sa={class:"d-block"},ka={class:"d-flex align-items-end"};function Pa(s,t,e,i,n,o){const r=z("LocaleText"),a=z("PeerSettingsDropdown");return w(),$("div",{class:Q(["card shadow-sm rounded-3 peerCard bg-transparent",{"border-warning":e.Peer.restricted}])},[h("div",null,[e.Peer.restricted?(w(),$("div",ba,[t[11]||(t[11]=h("i",{class:"bi-lock-fill me-2"},null,-1)),y(r,{t:"Access Restricted"})])):(w(),$("div",ua,[h("div",{class:Q(["dot ms-0",{active:e.Peer.status==="running"}])},null,2),h("div",fa,[h("span",ga,[t[6]||(t[6]=h("i",{class:"bi bi-arrow-down"},null,-1)),h("strong",null,B((e.Peer.cumu_receive+e.Peer.total_receive).toFixed(4)),1),t[7]||(t[7]=et(" GB "))]),h("span",pa,[t[8]||(t[8]=h("i",{class:"bi bi-arrow-up"},null,-1)),h("strong",null,B((e.Peer.cumu_sent+e.Peer.total_sent).toFixed(4)),1),t[9]||(t[9]=et(" GB "))]),e.Peer.latest_handshake!=="No Handshake"?(w(),$("span",ma,[t[10]||(t[10]=h("i",{class:"bi bi-arrows-angle-contract"},null,-1)),et(" "+B(o.getLatestHandshake)+" ago ",1)])):I("",!0)])]))]),h("div",_a,[h("h6",null,B(e.Peer.name?e.Peer.name:"Untitled Peer"),1),h("div",xa,[h("small",ya,[y(r,{t:"Public Key"})]),h("small",va,[h("samp",null,B(e.Peer.id),1)])]),h("div",null,[h("small",wa,[y(r,{t:"Allowed IPs"})]),h("small",Sa,[h("samp",null,B(e.Peer.allowed_ip),1)])]),h("div",ka,[h("div",{class:Q(["ms-auto px-2 rounded-3 subMenuBtn",{active:this.subMenuOpened}])},[h("a",{role:"button",class:"text-body",onClick:t[0]||(t[0]=l=>this.subMenuOpened=!0)},t[12]||(t[12]=[h("h5",{class:"mb-0"},[h("i",{class:"bi bi-three-dots"})],-1)])),y(rt,{name:"slide-fade"},{default:G(()=>[this.subMenuOpened?(w(),H(a,{key:0,onQrcode:t[1]||(t[1]=l=>this.$emit("qrcode",l)),onSetting:t[2]||(t[2]=l=>this.$emit("setting")),onJobs:t[3]||(t[3]=l=>this.$emit("jobs")),onRefresh:t[4]||(t[4]=l=>this.$emit("refresh")),onShare:t[5]||(t[5]=l=>this.$emit("share")),Peer:e.Peer,ref:"target"},null,8,["Peer"])):I("",!0)]),_:1})],2)])])],2)}const Ma=ut(ha,[["render",Pa],["__scopeId","data-v-4b600874"]]);/*! * @kurkle/color v0.3.2 * https://github.com/kurkle/color#readme * (c) 2023 Jukka Kurkela * Released under the MIT License */function Re(s){return s+.5|0}const It=(s,t,e)=>Math.max(Math.min(s,e),t);function ve(s){return It(Re(s*2.55),0,255)}function Et(s){return It(Re(s*255),0,255)}function Ot(s){return It(Re(s/2.55)/100,0,1)}function bi(s){return It(Re(s*100),0,100)}const gt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Rs=[..."0123456789ABCDEF"],Ca=s=>Rs[s&15],$a=s=>Rs[(s&240)>>4]+Rs[s&15],Ne=s=>(s&240)>>4===(s&15),Da=s=>Ne(s.r)&&Ne(s.g)&&Ne(s.b)&&Ne(s.a);function Oa(s){var t=s.length,e;return s[0]==="#"&&(t===4||t===5?e={r:255>[s[1]]*17,g:255>[s[2]]*17,b:255>[s[3]]*17,a:t===5?gt[s[4]]*17:255}:(t===7||t===9)&&(e={r:gt[s[1]]<<4|gt[s[2]],g:gt[s[3]]<<4|gt[s[4]],b:gt[s[5]]<<4|gt[s[6]],a:t===9?gt[s[7]]<<4|gt[s[8]]:255})),e}const Aa=(s,t)=>s<255?t(s):"";function La(s){var t=Da(s)?Ca:$a;return s?"#"+t(s.r)+t(s.g)+t(s.b)+Aa(s.a,t):void 0}const Ta=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Kn(s,t,e){const i=t*Math.min(e,1-e),n=(o,r=(o+s/30)%12)=>e-i*Math.max(Math.min(r-3,9-r,1),-1);return[n(0),n(8),n(4)]}function Ia(s,t,e){const i=(n,o=(n+s/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[i(5),i(3),i(1)]}function Ra(s,t,e){const i=Kn(s,1,.5);let n;for(t+e>1&&(n=1/(t+e),t*=n,e*=n),n=0;n<3;n++)i[n]*=1-t-e,i[n]+=t;return i}function Ea(s,t,e,i,n){return s===n?(t-e)/i+(t.5?d/(2-o-r):d/(o+r),l=Ea(e,i,n,d,o),l=l*60+.5),[l|0,c||0,a]}function Qs(s,t,e,i){return(Array.isArray(t)?s(t[0],t[1],t[2]):s(t,e,i)).map(Et)}function Zs(s,t,e){return Qs(Kn,s,t,e)}function Fa(s,t,e){return Qs(Ra,s,t,e)}function Ba(s,t,e){return Qs(Ia,s,t,e)}function Jn(s){return(s%360+360)%360}function za(s){const t=Ta.exec(s);let e=255,i;if(!t)return;t[5]!==i&&(e=t[6]?ve(+t[5]):Et(+t[5]));const n=Jn(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?i=Fa(n,o,r):t[1]==="hsv"?i=Ba(n,o,r):i=Zs(n,o,r),{r:i[0],g:i[1],b:i[2],a:e}}function Na(s,t){var e=qs(s);e[0]=Jn(e[0]+t),e=Zs(e),s.r=e[0],s.g=e[1],s.b=e[2]}function Ha(s){if(!s)return;const t=qs(s),e=t[0],i=bi(t[1]),n=bi(t[2]);return s.a<255?`hsla(${e}, ${i}%, ${n}%, ${Ot(s.a)})`:`hsl(${e}, ${i}%, ${n}%)`}const _i={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},xi={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function ja(){const s={},t=Object.keys(xi),e=Object.keys(_i);let i,n,o,r,a;for(i=0;i>16&255,o>>8&255,o&255]}return s}let He;function Va(s){He||(He=ja(),He.transparent=[0,0,0,0]);const t=He[s.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const Wa=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Ua(s){const t=Wa.exec(s);let e=255,i,n,o;if(t){if(t[7]!==i){const r=+t[7];e=t[8]?ve(r):It(r*255,0,255)}return i=+t[1],n=+t[3],o=+t[5],i=255&(t[2]?ve(i):It(i,0,255)),n=255&(t[4]?ve(n):It(n,0,255)),o=255&(t[6]?ve(o):It(o,0,255)),{r:i,g:n,b:o,a:e}}}function Ya(s){return s&&(s.a<255?`rgba(${s.r}, ${s.g}, ${s.b}, ${Ot(s.a)})`:`rgb(${s.r}, ${s.g}, ${s.b})`)}const xs=s=>s<=.0031308?s*12.92:Math.pow(s,1/2.4)*1.055-.055,ne=s=>s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4);function Ka(s,t,e){const i=ne(Ot(s.r)),n=ne(Ot(s.g)),o=ne(Ot(s.b));return{r:Et(xs(i+e*(ne(Ot(t.r))-i))),g:Et(xs(n+e*(ne(Ot(t.g))-n))),b:Et(xs(o+e*(ne(Ot(t.b))-o))),a:s.a+e*(t.a-s.a)}}function je(s,t,e){if(s){let i=qs(s);i[t]=Math.max(0,Math.min(i[t]+i[t]*e,t===0?360:1)),i=Zs(i),s.r=i[0],s.g=i[1],s.b=i[2]}}function Xn(s,t){return s&&Object.assign(t||{},s)}function yi(s){var t={r:0,g:0,b:0,a:255};return Array.isArray(s)?s.length>=3&&(t={r:s[0],g:s[1],b:s[2],a:255},s.length>3&&(t.a=Et(s[3]))):(t=Xn(s,{r:0,g:0,b:0,a:1}),t.a=Et(t.a)),t}function Ja(s){return s.charAt(0)==="r"?Ua(s):za(s)}class $e{constructor(t){if(t instanceof $e)return t;const e=typeof t;let i;e==="object"?i=yi(t):e==="string"&&(i=Oa(t)||Va(t)||Ja(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=Xn(this._rgb);return t&&(t.a=Ot(t.a)),t}set rgb(t){this._rgb=yi(t)}rgbString(){return this._valid?Ya(this._rgb):void 0}hexString(){return this._valid?La(this._rgb):void 0}hslString(){return this._valid?Ha(this._rgb):void 0}mix(t,e){if(t){const i=this.rgb,n=t.rgb;let o;const r=e===o?.5:e,a=2*r-1,l=i.a-n.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,i.r=255&c*i.r+o*n.r+.5,i.g=255&c*i.g+o*n.g+.5,i.b=255&c*i.b+o*n.b+.5,i.a=r*i.a+(1-r)*n.a,this.rgb=i}return this}interpolate(t,e){return t&&(this._rgb=Ka(this._rgb,t._rgb,e)),this}clone(){return new $e(this.rgb)}alpha(t){return this._rgb.a=Et(t),this}clearer(t){const e=this._rgb;return e.a*=1-t,this}greyscale(){const t=this._rgb,e=Re(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=e,this}opaquer(t){const e=this._rgb;return e.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return je(this._rgb,2,t),this}darken(t){return je(this._rgb,2,-t),this}saturate(t){return je(this._rgb,1,t),this}desaturate(t){return je(this._rgb,1,-t),this}rotate(t){return Na(this._rgb,t),this}}/*! * Chart.js v4.4.4 * https://www.chartjs.org * (c) 2024 Chart.js Contributors * Released under the MIT License */function Ct(){}const Xa=(()=>{let s=0;return()=>s++})();function W(s){return s===null||typeof s>"u"}function q(s){if(Array.isArray&&Array.isArray(s))return!0;const t=Object.prototype.toString.call(s);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function F(s){return s!==null&&Object.prototype.toString.call(s)==="[object Object]"}function mt(s){return(typeof s=="number"||s instanceof Number)&&isFinite(+s)}function xt(s,t){return mt(s)?s:t}function R(s,t){return typeof s>"u"?t:s}const Ga=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100*t:+s;function U(s,t,e){if(s&&typeof s.call=="function")return s.apply(e,t)}function N(s,t,e,i){let n,o,r;if(q(s))for(o=s.length,n=0;ns,x:s=>s.x,y:s=>s.y};function Za(s){const t=s.split("."),e=[];let i="";for(const n of t)i+=n,i.endsWith("\\")?i=i.slice(0,-1)+".":(e.push(i),i="");return e}function tl(s){const t=Za(s);return e=>{for(const i of t){if(i==="")break;e=e&&e[i]}return e}}function le(s,t){return(vi[t]||(vi[t]=tl(t)))(s)}function ti(s){return s.charAt(0).toUpperCase()+s.slice(1)}const Oe=s=>typeof s<"u",Ft=s=>typeof s=="function",wi=(s,t)=>{if(s.size!==t.size)return!1;for(const e of s)if(!t.has(e))return!1;return!0};function el(s){return s.type==="mouseup"||s.type==="click"||s.type==="contextmenu"}const tt=Math.PI,St=2*tt,sl=St+tt,as=Number.POSITIVE_INFINITY,il=tt/180,_t=tt/2,jt=tt/4,Si=tt*2/3,Es=Math.log10,kt=Math.sign;function Pe(s,t,e){return Math.abs(s-t)n-o).pop(),t}function Ae(s){return!isNaN(parseFloat(s))&&isFinite(s)}function ol(s,t){const e=Math.round(s);return e-t<=s&&e+t>=s}function rl(s,t,e){let i,n,o;for(i=0,n=s.length;il&&c=Math.min(t,e)-i&&s<=Math.max(t,e)+i}function ei(s,t,e){e=e||(r=>s[r]1;)o=n+i>>1,e(o)?n=o:i=o;return{lo:n,hi:i}}const Gt=(s,t,e,i)=>ei(s,e,i?n=>{const o=s[n][t];return os[n][t]ei(s,e,i=>s[i][t]>=e);function ul(s,t,e){let i=0,n=s.length;for(;ii&&s[n-1]>e;)n--;return i>0||n{const i="_onData"+ti(e),n=s[e];Object.defineProperty(s,e,{configurable:!0,enumerable:!1,value(...o){const r=n.apply(this,o);return s._chartjs.listeners.forEach(a=>{typeof a[i]=="function"&&a[i](...o)}),r}})})}function Mi(s,t){const e=s._chartjs;if(!e)return;const i=e.listeners,n=i.indexOf(t);n!==-1&&i.splice(n,1),!(i.length>0)&&(Qn.forEach(o=>{delete s[o]}),delete s._chartjs)}function Zn(s){const t=new Set(s);return t.size===s.length?s:Array.from(t)}const to=function(){return typeof window>"u"?function(s){return s()}:window.requestAnimationFrame}();function eo(s,t){let e=[],i=!1;return function(...n){e=n,i||(i=!0,to.call(window,()=>{i=!1,s.apply(t,e)}))}}function gl(s,t){let e;return function(...i){return t?(clearTimeout(e),e=setTimeout(s,t,i)):s.apply(this,i),t}}const si=s=>s==="start"?"left":s==="end"?"right":"center",st=(s,t,e)=>s==="start"?t:s==="end"?e:(t+e)/2,pl=(s,t,e,i)=>s===(i?"left":"right")?e:s==="center"?(t+e)/2:t;function ml(s,t,e){const i=t.length;let n=0,o=i;if(s._sorted){const{iScale:r,_parsed:a}=s,l=r.axis,{min:c,max:d,minDefined:u,maxDefined:f}=r.getUserBounds();u&&(n=ht(Math.min(Gt(a,l,c).lo,e?i:Gt(t,l,r.getPixelForValue(c)).lo),0,i-1)),f?o=ht(Math.max(Gt(a,r.axis,d,!0).hi+1,e?0:Gt(t,l,r.getPixelForValue(d),!0).hi+1),n,i)-n:o=i-n}return{start:n,count:o}}function bl(s){const{xScale:t,yScale:e,_scaleRanges:i}=s,n={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!i)return s._scaleRanges=n,!0;const o=i.xmin!==t.min||i.xmax!==t.max||i.ymin!==e.min||i.ymax!==e.max;return Object.assign(i,n),o}const Ve=s=>s===0||s===1,Ci=(s,t,e)=>-(Math.pow(2,10*(s-=1))*Math.sin((s-t)*St/e)),$i=(s,t,e)=>Math.pow(2,-10*s)*Math.sin((s-t)*St/e)+1,Me={linear:s=>s,easeInQuad:s=>s*s,easeOutQuad:s=>-s*(s-2),easeInOutQuad:s=>(s/=.5)<1?.5*s*s:-.5*(--s*(s-2)-1),easeInCubic:s=>s*s*s,easeOutCubic:s=>(s-=1)*s*s+1,easeInOutCubic:s=>(s/=.5)<1?.5*s*s*s:.5*((s-=2)*s*s+2),easeInQuart:s=>s*s*s*s,easeOutQuart:s=>-((s-=1)*s*s*s-1),easeInOutQuart:s=>(s/=.5)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2),easeInQuint:s=>s*s*s*s*s,easeOutQuint:s=>(s-=1)*s*s*s*s+1,easeInOutQuint:s=>(s/=.5)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2),easeInSine:s=>-Math.cos(s*_t)+1,easeOutSine:s=>Math.sin(s*_t),easeInOutSine:s=>-.5*(Math.cos(tt*s)-1),easeInExpo:s=>s===0?0:Math.pow(2,10*(s-1)),easeOutExpo:s=>s===1?1:-Math.pow(2,-10*s)+1,easeInOutExpo:s=>Ve(s)?s:s<.5?.5*Math.pow(2,10*(s*2-1)):.5*(-Math.pow(2,-10*(s*2-1))+2),easeInCirc:s=>s>=1?s:-(Math.sqrt(1-s*s)-1),easeOutCirc:s=>Math.sqrt(1-(s-=1)*s),easeInOutCirc:s=>(s/=.5)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1),easeInElastic:s=>Ve(s)?s:Ci(s,.075,.3),easeOutElastic:s=>Ve(s)?s:$i(s,.075,.3),easeInOutElastic(s){return Ve(s)?s:s<.5?.5*Ci(s*2,.1125,.45):.5+.5*$i(s*2-1,.1125,.45)},easeInBack(s){return s*s*((1.70158+1)*s-1.70158)},easeOutBack(s){return(s-=1)*s*((1.70158+1)*s+1.70158)+1},easeInOutBack(s){let t=1.70158;return(s/=.5)<1?.5*(s*s*(((t*=1.525)+1)*s-t)):.5*((s-=2)*s*(((t*=1.525)+1)*s+t)+2)},easeInBounce:s=>1-Me.easeOutBounce(1-s),easeOutBounce(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},easeInOutBounce:s=>s<.5?Me.easeInBounce(s*2)*.5:Me.easeOutBounce(s*2-1)*.5+.5};function ii(s){if(s&&typeof s=="object"){const t=s.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Di(s){return ii(s)?s:new $e(s)}function ys(s){return ii(s)?s:new $e(s).saturate(.5).darken(.1).hexString()}const _l=["x","y","borderWidth","radius","tension"],xl=["color","borderColor","backgroundColor"];function yl(s){s.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),s.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),s.set("animations",{colors:{type:"color",properties:xl},numbers:{type:"number",properties:_l}}),s.describe("animations",{_fallback:"animation"}),s.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function vl(s){s.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const Oi=new Map;function wl(s,t){t=t||{};const e=s+JSON.stringify(t);let i=Oi.get(e);return i||(i=new Intl.NumberFormat(s,t),Oi.set(e,i)),i}function so(s,t,e){return wl(t,e).format(s)}const io={values(s){return q(s)?s:""+s},numeric(s,t,e){if(s===0)return"0";const i=this.chart.options.locale;let n,o=s;if(e.length>1){const c=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(c<1e-4||c>1e15)&&(n="scientific"),o=Sl(s,e)}const r=Es(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:n,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),so(s,i,l)},logarithmic(s,t,e){if(s===0)return"0";const i=e[t].significand||s/Math.pow(10,Math.floor(Es(s)));return[1,2,3,5,10,15].includes(i)||t>.8*e.length?io.numeric.call(this,s,t,e):""}};function Sl(s,t){let e=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(e)>=1&&s!==Math.floor(s)&&(e=s-Math.floor(s)),e}var no={formatters:io};function kl(s){s.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:no.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),s.route("scale.ticks","color","","color"),s.route("scale.grid","color","","borderColor"),s.route("scale.border","color","","borderColor"),s.route("scale.title","color","","color"),s.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),s.describe("scales",{_fallback:"scale"}),s.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const te=Object.create(null),Bs=Object.create(null);function Ce(s,t){if(!t)return s;const e=t.split(".");for(let i=0,n=e.length;ii.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(i,n)=>ys(n.backgroundColor),this.hoverBorderColor=(i,n)=>ys(n.borderColor),this.hoverColor=(i,n)=>ys(n.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return vs(this,t,e)}get(t){return Ce(this,t)}describe(t,e){return vs(Bs,t,e)}override(t,e){return vs(te,t,e)}route(t,e,i,n){const o=Ce(this,t),r=Ce(this,i),a="_"+e;Object.defineProperties(o,{[a]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){const l=this[a],c=r[n];return F(l)?Object.assign({},c,l):R(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(e=>e(this))}}var J=new Pl({_scriptable:s=>!s.startsWith("on"),_indexable:s=>s!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[yl,vl,kl]);function Ml(s){return!s||W(s.size)||W(s.family)?null:(s.style?s.style+" ":"")+(s.weight?s.weight+" ":"")+s.size+"px "+s.family}function Ai(s,t,e,i,n){let o=t[n];return o||(o=t[n]=s.measureText(n).width,e.push(n)),o>i&&(i=o),i}function Vt(s,t,e){const i=s.currentDevicePixelRatio,n=e!==0?Math.max(e/2,.5):0;return Math.round((t-n)*i)/i+n}function Li(s,t){!t&&!s||(t=t||s.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,s.width,s.height),t.restore())}function zs(s,t,e,i){oo(s,t,e,i,null)}function oo(s,t,e,i,n){let o,r,a,l,c,d,u,f;const g=t.pointStyle,p=t.rotation,m=t.radius;let b=(p||0)*il;if(g&&typeof g=="object"&&(o=g.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){s.save(),s.translate(e,i),s.rotate(b),s.drawImage(g,-g.width/2,-g.height/2,g.width,g.height),s.restore();return}if(!(isNaN(m)||m<=0)){switch(s.beginPath(),g){default:n?s.ellipse(e,i,n/2,m,0,0,St):s.arc(e,i,m,0,St),s.closePath();break;case"triangle":d=n?n/2:m,s.moveTo(e+Math.sin(b)*d,i-Math.cos(b)*m),b+=Si,s.lineTo(e+Math.sin(b)*d,i-Math.cos(b)*m),b+=Si,s.lineTo(e+Math.sin(b)*d,i-Math.cos(b)*m),s.closePath();break;case"rectRounded":c=m*.516,l=m-c,r=Math.cos(b+jt)*l,u=Math.cos(b+jt)*(n?n/2-c:l),a=Math.sin(b+jt)*l,f=Math.sin(b+jt)*(n?n/2-c:l),s.arc(e-u,i-a,c,b-tt,b-_t),s.arc(e+f,i-r,c,b-_t,b),s.arc(e+u,i+a,c,b,b+_t),s.arc(e-f,i+r,c,b+_t,b+tt),s.closePath();break;case"rect":if(!p){l=Math.SQRT1_2*m,d=n?n/2:l,s.rect(e-d,i-l,2*d,2*l);break}b+=jt;case"rectRot":u=Math.cos(b)*(n?n/2:m),r=Math.cos(b)*m,a=Math.sin(b)*m,f=Math.sin(b)*(n?n/2:m),s.moveTo(e-u,i-a),s.lineTo(e+f,i-r),s.lineTo(e+u,i+a),s.lineTo(e-f,i+r),s.closePath();break;case"crossRot":b+=jt;case"cross":u=Math.cos(b)*(n?n/2:m),r=Math.cos(b)*m,a=Math.sin(b)*m,f=Math.sin(b)*(n?n/2:m),s.moveTo(e-u,i-a),s.lineTo(e+u,i+a),s.moveTo(e+f,i-r),s.lineTo(e-f,i+r);break;case"star":u=Math.cos(b)*(n?n/2:m),r=Math.cos(b)*m,a=Math.sin(b)*m,f=Math.sin(b)*(n?n/2:m),s.moveTo(e-u,i-a),s.lineTo(e+u,i+a),s.moveTo(e+f,i-r),s.lineTo(e-f,i+r),b+=jt,u=Math.cos(b)*(n?n/2:m),r=Math.cos(b)*m,a=Math.sin(b)*m,f=Math.sin(b)*(n?n/2:m),s.moveTo(e-u,i-a),s.lineTo(e+u,i+a),s.moveTo(e+f,i-r),s.lineTo(e-f,i+r);break;case"line":r=n?n/2:Math.cos(b)*m,a=Math.sin(b)*m,s.moveTo(e-r,i-a),s.lineTo(e+r,i+a);break;case"dash":s.moveTo(e,i),s.lineTo(e+Math.cos(b)*(n?n/2:m),i+Math.sin(b)*m);break;case!1:s.closePath();break}s.fill(),t.borderWidth>0&&s.stroke()}}function Le(s,t,e){return e=e||.5,!t||s&&s.x>t.left-e&&s.xt.top-e&&s.y0&&o.strokeColor!=="";let l,c;for(s.save(),s.font=n.string,Dl(s,o),l=0;l+s||0;function ro(s,t){const e={},i=F(t),n=i?Object.keys(t):t,o=F(s)?i?r=>R(s[r],s[t[r]]):r=>s[r]:()=>s;for(const r of n)e[r]=Rl(o(r));return e}function ao(s){return ro(s,{top:"y",right:"x",bottom:"y",left:"x"})}function re(s){return ro(s,["topLeft","topRight","bottomLeft","bottomRight"])}function bt(s){const t=ao(s);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function it(s,t){s=s||{},t=t||J.font;let e=R(s.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let i=R(s.style,t.style);i&&!(""+i).match(Tl)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const n={family:R(s.family,t.family),lineHeight:Il(R(s.lineHeight,t.lineHeight),e),size:e,style:i,weight:R(s.weight,t.weight),string:""};return n.string=Ml(n),n}function We(s,t,e,i){let n,o,r;for(n=0,o=s.length;ne&&a===0?0:a+l;return{min:r(i,-Math.abs(o)),max:r(n,o)}}function ee(s,t){return Object.assign(Object.create(s),t)}function ri(s,t=[""],e,i,n=()=>s[0]){const o=e||s;typeof i>"u"&&(i=uo("_fallback",s));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:s,_rootScopes:o,_fallback:i,_getTarget:n,override:a=>ri([a,...s],t,o,i)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete s[0][l],!0},get(a,l){return co(a,l,()=>Wl(l,t,s,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(s[0])},has(a,l){return Ii(a).includes(l)},ownKeys(a){return Ii(a)},set(a,l,c){const d=a._storage||(a._storage=n());return a[l]=d[l]=c,delete a._keys,!0}})}function ce(s,t,e,i){const n={_cacheable:!1,_proxy:s,_context:t,_subProxy:e,_stack:new Set,_descriptors:lo(s,i),setContext:o=>ce(s,o,e,i),override:o=>ce(s.override(o),t,e,i)};return new Proxy(n,{deleteProperty(o,r){return delete o[r],delete s[r],!0},get(o,r,a){return co(o,r,()=>Bl(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(s,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(s,r)},getPrototypeOf(){return Reflect.getPrototypeOf(s)},has(o,r){return Reflect.has(s,r)},ownKeys(){return Reflect.ownKeys(s)},set(o,r,a){return s[r]=a,delete o[r],!0}})}function lo(s,t={scriptable:!0,indexable:!0}){const{_scriptable:e=t.scriptable,_indexable:i=t.indexable,_allKeys:n=t.allKeys}=s;return{allKeys:n,scriptable:e,indexable:i,isScriptable:Ft(e)?e:()=>e,isIndexable:Ft(i)?i:()=>i}}const Fl=(s,t)=>s?s+ti(t):t,ai=(s,t)=>F(t)&&s!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function co(s,t,e){if(Object.prototype.hasOwnProperty.call(s,t)||t==="constructor")return s[t];const i=e();return s[t]=i,i}function Bl(s,t,e){const{_proxy:i,_context:n,_subProxy:o,_descriptors:r}=s;let a=i[t];return Ft(a)&&r.isScriptable(t)&&(a=zl(t,a,s,e)),q(a)&&a.length&&(a=Nl(t,a,s,r.isIndexable)),ai(t,a)&&(a=ce(a,n,o&&o[t],r)),a}function zl(s,t,e,i){const{_proxy:n,_context:o,_subProxy:r,_stack:a}=e;if(a.has(s))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+s);a.add(s);let l=t(o,r||i);return a.delete(s),ai(s,l)&&(l=li(n._scopes,n,s,l)),l}function Nl(s,t,e,i){const{_proxy:n,_context:o,_subProxy:r,_descriptors:a}=e;if(typeof o.index<"u"&&i(s))return t[o.index%t.length];if(F(t[0])){const l=t,c=n._scopes.filter(d=>d!==l);t=[];for(const d of l){const u=li(c,n,s,d);t.push(ce(u,o,r&&r[s],a))}}return t}function ho(s,t,e){return Ft(s)?s(t,e):s}const Hl=(s,t)=>s===!0?t:typeof s=="string"?le(t,s):void 0;function jl(s,t,e,i,n){for(const o of t){const r=Hl(e,o);if(r){s.add(r);const a=ho(r._fallback,e,n);if(typeof a<"u"&&a!==e&&a!==i)return a}else if(r===!1&&typeof i<"u"&&e!==i)return null}return!1}function li(s,t,e,i){const n=t._rootScopes,o=ho(t._fallback,e,i),r=[...s,...n],a=new Set;a.add(i);let l=Ti(a,r,e,o||e,i);return l===null||typeof o<"u"&&o!==e&&(l=Ti(a,r,o,l,i),l===null)?!1:ri(Array.from(a),[""],n,o,()=>Vl(t,e,i))}function Ti(s,t,e,i,n){for(;e;)e=jl(s,t,e,i,n);return e}function Vl(s,t,e){const i=s._getTarget();t in i||(i[t]={});const n=i[t];return q(n)&&F(e)?e:n||{}}function Wl(s,t,e,i){let n;for(const o of t)if(n=uo(Fl(o,s),e),typeof n<"u")return ai(s,n)?li(e,i,s,n):n}function uo(s,t){for(const e of t){if(!e)continue;const i=e[s];if(typeof i<"u")return i}}function Ii(s){let t=s._keys;return t||(t=s._keys=Ul(s._scopes)),t}function Ul(s){const t=new Set;for(const e of s)for(const i of Object.keys(e).filter(n=>!n.startsWith("_")))t.add(i);return Array.from(t)}const Yl=Number.EPSILON||1e-14,de=(s,t)=>ts==="x"?"y":"x";function Kl(s,t,e,i){const n=s.skip?t:s,o=t,r=e.skip?t:e,a=Fs(o,n),l=Fs(r,o);let c=a/(a+l),d=l/(a+l);c=isNaN(c)?0:c,d=isNaN(d)?0:d;const u=i*c,f=i*d;return{previous:{x:o.x-u*(r.x-n.x),y:o.y-u*(r.y-n.y)},next:{x:o.x+f*(r.x-n.x),y:o.y+f*(r.y-n.y)}}}function Jl(s,t,e){const i=s.length;let n,o,r,a,l,c=de(s,0);for(let d=0;d!c.skip)),t.cubicInterpolationMode==="monotone")Gl(s,n);else{let c=i?s[s.length-1]:s[0];for(o=0,r=s.length;os.ownerDocument.defaultView.getComputedStyle(s,null);function Zl(s,t){return ps(s).getPropertyValue(t)}const tc=["top","right","bottom","left"];function Qt(s,t,e){const i={};e=e?"-"+e:"";for(let n=0;n<4;n++){const o=tc[n];i[o]=parseFloat(s[t+"-"+o+e])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}const ec=(s,t,e)=>(s>0||t>0)&&(!e||!e.shadowRoot);function sc(s,t){const e=s.touches,i=e&&e.length?e[0]:s,{offsetX:n,offsetY:o}=i;let r=!1,a,l;if(ec(n,o,s.target))a=n,l=o;else{const c=t.getBoundingClientRect();a=i.clientX-c.left,l=i.clientY-c.top,r=!0}return{x:a,y:l,box:r}}function Ut(s,t){if("native"in s)return s;const{canvas:e,currentDevicePixelRatio:i}=t,n=ps(e),o=n.boxSizing==="border-box",r=Qt(n,"padding"),a=Qt(n,"border","width"),{x:l,y:c,box:d}=sc(s,e),u=r.left+(d&&a.left),f=r.top+(d&&a.top);let{width:g,height:p}=t;return o&&(g-=r.width+a.width,p-=r.height+a.height),{x:Math.round((l-u)/g*e.width/i),y:Math.round((c-f)/p*e.height/i)}}function ic(s,t,e){let i,n;if(t===void 0||e===void 0){const o=s&&di(s);if(!o)t=s.clientWidth,e=s.clientHeight;else{const r=o.getBoundingClientRect(),a=ps(o),l=Qt(a,"border","width"),c=Qt(a,"padding");t=r.width-c.width-l.width,e=r.height-c.height-l.height,i=cs(a.maxWidth,o,"clientWidth"),n=cs(a.maxHeight,o,"clientHeight")}}return{width:t,height:e,maxWidth:i||as,maxHeight:n||as}}const Ye=s=>Math.round(s*10)/10;function nc(s,t,e,i){const n=ps(s),o=Qt(n,"margin"),r=cs(n.maxWidth,s,"clientWidth")||as,a=cs(n.maxHeight,s,"clientHeight")||as,l=ic(s,t,e);let{width:c,height:d}=l;if(n.boxSizing==="content-box"){const f=Qt(n,"border","width"),g=Qt(n,"padding");c-=g.width+f.width,d-=g.height+f.height}return c=Math.max(0,c-o.width),d=Math.max(0,i?c/i:d-o.height),c=Ye(Math.min(c,r,l.maxWidth)),d=Ye(Math.min(d,a,l.maxHeight)),c&&!d&&(d=Ye(c/2)),(t!==void 0||e!==void 0)&&i&&l.height&&d>l.height&&(d=l.height,c=Ye(Math.floor(d*i))),{width:c,height:d}}function Ri(s,t,e){const i=t||1,n=Math.floor(s.height*i),o=Math.floor(s.width*i);s.height=Math.floor(s.height),s.width=Math.floor(s.width);const r=s.canvas;return r.style&&(e||!r.style.height&&!r.style.width)&&(r.style.height=`${s.height}px`,r.style.width=`${s.width}px`),s.currentDevicePixelRatio!==i||r.height!==n||r.width!==o?(s.currentDevicePixelRatio=i,r.height=n,r.width=o,s.ctx.setTransform(i,0,0,i,0,0),!0):!1}const oc=function(){let s=!1;try{const t={get passive(){return s=!0,!1}};ci()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return s}();function Ei(s,t){const e=Zl(s,t),i=e&&e.match(/^(\d+)(\.\d+)?px$/);return i?+i[1]:void 0}function Yt(s,t,e,i){return{x:s.x+e*(t.x-s.x),y:s.y+e*(t.y-s.y)}}function rc(s,t,e,i){return{x:s.x+e*(t.x-s.x),y:i==="middle"?e<.5?s.y:t.y:i==="after"?e<1?s.y:t.y:e>0?t.y:s.y}}function ac(s,t,e,i){const n={x:s.cp2x,y:s.cp2y},o={x:t.cp1x,y:t.cp1y},r=Yt(s,n,e),a=Yt(n,o,e),l=Yt(o,t,e),c=Yt(r,a,e),d=Yt(a,l,e);return Yt(c,d,e)}const lc=function(s,t){return{x(e){return s+s+t-e},setWidth(e){t=e},textAlign(e){return e==="center"?e:e==="right"?"left":"right"},xPlus(e,i){return e-i},leftForLtr(e,i){return e-i}}},cc=function(){return{x(s){return s},setWidth(s){},textAlign(s){return s},xPlus(s,t){return s+t},leftForLtr(s,t){return s}}};function ae(s,t,e){return s?lc(t,e):cc()}function go(s,t){let e,i;(t==="ltr"||t==="rtl")&&(e=s.canvas.style,i=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),s.prevTextDirection=i)}function po(s,t){t!==void 0&&(delete s.prevTextDirection,s.canvas.style.setProperty("direction",t[0],t[1]))}function mo(s){return s==="angle"?{between:qn,compare:cl,normalize:Tt}:{between:Xt,compare:(t,e)=>t-e,normalize:t=>t}}function Fi({start:s,end:t,count:e,loop:i,style:n}){return{start:s%e,end:t%e,loop:i&&(t-s+1)%e===0,style:n}}function dc(s,t,e){const{property:i,start:n,end:o}=e,{between:r,normalize:a}=mo(i),l=t.length;let{start:c,end:d,loop:u}=s,f,g;if(u){for(c+=l,d+=l,f=0,g=l;fl(n,S,_)&&a(n,S)!==0,x=()=>a(o,_)===0||l(o,S,_),P=()=>m||v(),M=()=>!m||x();for(let C=d,O=d;C<=u;++C)k=t[C%r],!k.skip&&(_=c(k[i]),_!==S&&(m=l(_,n,o),b===null&&P()&&(b=a(_,n)===0?C:O),b!==null&&M()&&(p.push(Fi({start:b,end:C,loop:f,count:r,style:g})),b=null),O=C,S=_));return b!==null&&p.push(Fi({start:b,end:u,loop:f,count:r,style:g})),p}function uc(s,t){const e=[],i=s.segments;for(let n=0;nn&&s[o%t].skip;)o--;return o%=t,{start:n,end:o}}function gc(s,t,e,i){const n=s.length,o=[];let r=t,a=s[t],l;for(l=t+1;l<=e;++l){const c=s[l%n];c.skip||c.stop?a.skip||(i=!1,o.push({start:t%n,end:(l-1)%n,loop:i}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%n,end:r%n,loop:i}),o}function pc(s,t){const e=s.points,i=s.options.spanGaps,n=e.length;if(!n)return[];const o=!!s._loop,{start:r,end:a}=fc(e,n,o,i);if(i===!0)return Bi(s,[{start:r,end:a,loop:o}],e,t);const l=aa({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(i-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=to.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,n)=>{if(!i.running||!i.items.length)return;const o=i.items;let r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(n.draw(),this._notify(n,i,t,"progress")),o.length||(i.running=!1,this._notify(n,i,t,"complete"),i.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){!e||!e.length||this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((i,n)=>Math.max(i,n._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!(!e||!e.running||!e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let n=i.length-1;for(;n>=0;--n)i[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var $t=new _c;const Ni="transparent",xc={boolean(s,t,e){return e>.5?t:s},color(s,t,e){const i=Di(s||Ni),n=i.valid&&Di(t||Ni);return n&&n.valid?n.mix(i,e).hexString():t},number(s,t,e){return s+(t-s)*e}};class yc{constructor(t,e,i,n){const o=e[i];n=We([t.to,n,o,t.from]);const r=We([t.from,o,n]);this._active=!0,this._fn=t.fn||xc[t.type||typeof r],this._easing=Me[t.easing]||Me.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=r,this._to=n,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const n=this._target[this._prop],o=i-this._start,r=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=We([t.to,e,n,t.from]),this._from=We([t.from,n,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,n=this._prop,o=this._from,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[n]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let n=0;n{const o=t[n];if(!F(o))return;const r={};for(const a of e)r[a]=o[a];(q(o.properties)&&o.properties||[n]).forEach(a=>{(a===n||!i.has(a))&&i.set(a,r)})})}_animateOptions(t,e){const i=e.options,n=wc(t,i);if(!n)return[];const o=this._createAnimations(n,i);return i.$shared&&vc(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,e){const i=this._properties,n=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){n.push(...this._animateOptions(t,e));continue}const d=e[c];let u=o[c];const f=i.get(c);if(u)if(f&&u.active()){u.update(f,d,a);continue}else u.cancel();if(!f||!f.duration){t[c]=d;continue}o[c]=u=new yc(f,t,c,d),n.push(u)}return n}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}const i=this._createAnimations(t,e);if(i.length)return $t.add(this._chart,i),!0}}function vc(s,t){const e=[],i=Object.keys(t);for(let n=0;n0||!e&&o<0)return n.index}return null}function Ui(s,t){const{chart:e,_cachedMeta:i}=s,n=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=i,l=o.axis,c=r.axis,d=Mc(o,r,i),u=t.length;let f;for(let g=0;ge[i].axis===t).shift()}function Dc(s,t){return ee(s,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function Oc(s,t,e){return ee(s,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function pe(s,t){const e=s.controller.index,i=s.vScale&&s.vScale.axis;if(i){t=t||s._parsed;for(const n of t){const o=n._stacks;if(!o||o[i]===void 0||o[i][e]===void 0)return;delete o[i][e],o[i]._visualValues!==void 0&&o[i]._visualValues[e]!==void 0&&delete o[i]._visualValues[e]}}}const Ss=s=>s==="reset"||s==="none",Yi=(s,t)=>t?s:Object.assign({},s),Ac=(s,t,e)=>s&&!t.hidden&&t._stacked&&{keys:_o(e,!0),values:null};class hi{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Vi(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&pe(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),n=(u,f,g,p)=>u==="x"?f:u==="r"?p:g,o=e.xAxisID=R(i.xAxisID,ws(t,"x")),r=e.yAxisID=R(i.yAxisID,ws(t,"y")),a=e.rAxisID=R(i.rAxisID,ws(t,"r")),l=e.indexAxis,c=e.iAxisID=n(l,o,r,a),d=e.vAxisID=n(l,r,o,a);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(c),e.vScale=this.getScaleForId(d)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&Mi(this._data,this),t._stacked&&pe(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(F(e)){const n=this._cachedMeta;this._data=Pc(e,n)}else if(i!==e){if(i){Mi(i,this);const n=this._cachedMeta;pe(n),n._parsed=[]}e&&Object.isExtensible(e)&&fl(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,i=this.getDataset();let n=!1;this._dataCheck();const o=e._stacked;e._stacked=Vi(e.vScale,e),e.stack!==i.stack&&(n=!0,pe(e),e.stack=i.stack),this._resyncElements(t),(n||o!==e._stacked)&&Ui(this,e._parsed)}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:i,_data:n}=this,{iScale:o,_stacked:r}=i,a=o.axis;let l=t===0&&e===n.length?!0:i._sorted,c=t>0&&i._parsed[t-1],d,u,f;if(this._parsing===!1)i._parsed=n,i._sorted=!0,f=n;else{q(n[t])?f=this.parseArrayData(i,n,t,e):F(n[t])?f=this.parseObjectData(i,n,t,e):f=this.parsePrimitiveData(i,n,t,e);const g=()=>u[a]===null||c&&u[a]m||u=0;--f)if(!p()){this.updateRangeFromParsed(c,t,g,l);break}}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let n,o,r;for(n=0,o=e.length;n=0&&tthis.getContext(i,n,e),m=c.resolveNamedOptions(f,g,p,u);return m.$shared&&(m.$shared=l,o[r]=Object.freeze(Yi(m,l))),m}_resolveAnimations(t,e,i){const n=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(n.options.animation!==!1){const d=this.chart.config,u=d.datasetAnimationScopeKeys(this._type,e),f=d.getOptionScopes(this.getDataset(),u);l=d.createResolver(f,this.getContext(t,i,e))}const c=new bo(n,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Ss(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),n=this._sharedOptions,o=this.getSharedOptions(i),r=this.includeOptions(e,o)||o!==n;return this.updateSharedOptions(o,e,i),{sharedOptions:o,includeOptions:r}}updateElement(t,e,i,n){Ss(n)?Object.assign(t,i):this._resolveAnimations(e,n).update(t,i)}updateSharedOptions(t,e,i){t&&!Ss(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,n){t.active=n;const o=this.getStyle(e,n);this._resolveAnimations(e,i,n).update(t,{options:!n&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const n=i.length,o=e.length,r=Math.min(o,n);r&&this.parse(0,r),o>n?this._insertElements(n,o-n,t):o{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;an-o))}return s._cache.$bar}function Tc(s){const t=s.iScale,e=Lc(t,s.type);let i=t._length,n,o,r,a;const l=()=>{r===32767||r===-32768||(Oe(a)&&(i=Math.min(i,Math.abs(r-a)||i)),a=r)};for(n=0,o=e.length;n0?n[s-1]:null,a=sMath.abs(a)&&(l=a,c=r),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:n,end:o,min:r,max:a}}function xo(s,t,e,i){return q(s)?Ec(s,t,e,i):t[e.axis]=e.parse(s,i),t}function Ki(s,t,e,i){const n=s.iScale,o=s.vScale,r=n.getLabels(),a=n===o,l=[];let c,d,u,f;for(c=e,d=e+i;c=e?1:-1)}function Bc(s){let t,e,i,n,o;return s.horizontal?(t=s.base>s.x,e="left",i="right"):(t=s.based.controller.options.grouped),o=i.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(e),l=a&&a[i.axis],c=d=>{const u=d._parsed.find(g=>g[i.axis]===l),f=u&&u[d.vScale.axis];if(W(f)||isNaN(f))return!0};for(const d of n)if(!(e!==void 0&&c(d))&&((o===!1||r.indexOf(d.stack)===-1||o===void 0&&d.stack===void 0)&&r.push(d.stack),d.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const n=this._getStacks(t,i),o=e!==void 0?n.indexOf(e):-1;return o===-1?n.length-1:o}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,n=[];let o,r;for(o=0,r=e.data.length;o0&&this.getParsed(e-1);for(let x=0;x=k){M.skip=!0;continue}const C=this.getParsed(x),O=W(C[g]),E=M[f]=r.getPixelForValue(C[f],x),L=M[g]=o||O?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,C,l):C[g],x);M.skip=isNaN(E)||isNaN(L)||O,M.stop=x>0&&Math.abs(C[f]-v[f])>b,m&&(M.parsed=C,M.raw=c.data[x]),u&&(M.options=d||this.resolveDataElementOptions(x,P.active?"active":n)),_||this.updateElement(P,x,M,n),v=C}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,n=t.data||[];if(!n.length)return i;const o=n[0].size(this.resolveDataElementOptions(0)),r=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(i,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}function Wt(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class ui{static override(t){Object.assign(ui.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Wt()}parse(){return Wt()}format(){return Wt()}add(){return Wt()}diff(){return Wt()}startOf(){return Wt()}endOf(){return Wt()}}var jc={_date:ui};function Vc(s,t,e,i){const{controller:n,data:o,_sorted:r}=s,a=n._cachedMeta.iScale;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const l=a._reversePixels?hl:Gt;if(i){if(n._sharedOptions){const c=o[0],d=typeof c.getRange=="function"&&c.getRange(t);if(d){const u=l(o,t,e-d),f=l(o,t,e+d);return{lo:u.lo,hi:f.hi}}}}else return l(o,t,e)}return{lo:0,hi:o.length-1}}function Ee(s,t,e,i,n){const o=s.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a{l[r]&&l[r](t[e],n)&&(o.push({element:l,datasetIndex:c,index:d}),a=a||l.inRange(t.x,t.y,n))}),i&&!a?[]:o}var Kc={evaluateInteractionItems:Ee,modes:{index(s,t,e,i){const n=Ut(t,s),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?Ps(s,n,o,i,r):Ms(s,n,o,!1,i,r),l=[];return a.length?(s.getSortedVisibleDatasetMetas().forEach(c=>{const d=a[0].index,u=c.data[d];u&&!u.skip&&l.push({element:u,datasetIndex:c.index,index:d})}),l):[]},dataset(s,t,e,i){const n=Ut(t,s),o=e.axis||"xy",r=e.includeInvisible||!1;let a=e.intersect?Ps(s,n,o,i,r):Ms(s,n,o,!1,i,r);if(a.length>0){const l=a[0].datasetIndex,c=s.getDatasetMeta(l).data;a=[];for(let d=0;de.pos===t)}function qi(s,t){return s.filter(e=>wo.indexOf(e.pos)===-1&&e.box.axis===t)}function be(s,t){return s.sort((e,i)=>{const n=t?i:e,o=t?e:i;return n.weight===o.weight?n.index-o.index:n.weight-o.weight})}function Jc(s){const t=[];let e,i,n,o,r,a;for(e=0,i=(s||[]).length;ec.box.fullSize),!0),i=be(me(t,"left"),!0),n=be(me(t,"right")),o=be(me(t,"top"),!0),r=be(me(t,"bottom")),a=qi(t,"x"),l=qi(t,"y");return{fullSize:e,leftAndTop:i.concat(o),rightAndBottom:n.concat(l).concat(r).concat(a),chartArea:me(t,"chartArea"),vertical:i.concat(n).concat(l),horizontal:o.concat(r).concat(a)}}function Qi(s,t,e,i){return Math.max(s[e],t[e])+Math.max(s[i],t[i])}function So(s,t){s.top=Math.max(s.top,t.top),s.left=Math.max(s.left,t.left),s.bottom=Math.max(s.bottom,t.bottom),s.right=Math.max(s.right,t.right)}function Qc(s,t,e,i){const{pos:n,box:o}=e,r=s.maxPadding;if(!F(n)){e.size&&(s[n]-=e.size);const u=i[e.stack]||{size:0,count:1};u.size=Math.max(u.size,e.horizontal?o.height:o.width),e.size=u.size/u.count,s[n]+=e.size}o.getPadding&&So(r,o.getPadding());const a=Math.max(0,t.outerWidth-Qi(r,s,"left","right")),l=Math.max(0,t.outerHeight-Qi(r,s,"top","bottom")),c=a!==s.w,d=l!==s.h;return s.w=a,s.h=l,e.horizontal?{same:c,other:d}:{same:d,other:c}}function Zc(s){const t=s.maxPadding;function e(i){const n=Math.max(t[i]-s[i],0);return s[i]+=n,n}s.y+=e("top"),s.x+=e("left"),e("right"),e("bottom")}function td(s,t){const e=t.maxPadding;function i(n){const o={left:0,top:0,right:0,bottom:0};return n.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return i(s?["left","right"]:["top","bottom"])}function we(s,t,e,i){const n=[];let o,r,a,l,c,d;for(o=0,r=s.length,c=0;o{typeof m.beforeLayout=="function"&&m.beforeLayout()});const d=l.reduce((m,b)=>b.box.options&&b.box.options.display===!1?m:m+1,0)||1,u=Object.freeze({outerWidth:t,outerHeight:e,padding:n,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/d,hBoxMaxHeight:r/2}),f=Object.assign({},n);So(f,bt(i));const g=Object.assign({maxPadding:f,w:o,h:r,x:n.left,y:n.top},n),p=Gc(l.concat(c),u);we(a.fullSize,g,u,p),we(l,g,u,p),we(c,g,u,p)&&we(l,g,u,p),Zc(g),Zi(a.leftAndTop,g,u,p),g.x+=g.w,g.y+=g.h,Zi(a.rightAndBottom,g,u,p),s.chartArea={left:g.left,top:g.top,right:g.left+g.w,bottom:g.top+g.h,height:g.h,width:g.w},N(a.chartArea,m=>{const b=m.box;Object.assign(b,s.chartArea),b.update(g.w,g.h,{left:0,top:0,right:0,bottom:0})})}};class ko{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,n){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,n?Math.floor(e/n):i)}}isAttached(t){return!0}updateConfig(t){}}class ed extends ko{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const ss="$chartjs",sd={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},tn=s=>s===null||s==="";function id(s,t){const e=s.style,i=s.getAttribute("height"),n=s.getAttribute("width");if(s[ss]={initial:{height:i,width:n,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",tn(n)){const o=Ei(s,"width");o!==void 0&&(s.width=o)}if(tn(i))if(s.style.height==="")s.height=s.width/(t||2);else{const o=Ei(s,"height");o!==void 0&&(s.height=o)}return s}const Po=oc?{passive:!0}:!1;function nd(s,t,e){s&&s.addEventListener(t,e,Po)}function od(s,t,e){s&&s.canvas&&s.canvas.removeEventListener(t,e,Po)}function rd(s,t){const e=sd[s.type]||s.type,{x:i,y:n}=Ut(s,t);return{type:e,chart:t,native:s,x:i!==void 0?i:null,y:n!==void 0?n:null}}function ds(s,t){for(const e of s)if(e===t||e.contains(t))return!0}function ad(s,t,e){const i=s.canvas,n=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||ds(a.addedNodes,i),r=r&&!ds(a.removedNodes,i);r&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}function ld(s,t,e){const i=s.canvas,n=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||ds(a.removedNodes,i),r=r&&!ds(a.addedNodes,i);r&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}const Ie=new Map;let en=0;function Mo(){const s=window.devicePixelRatio;s!==en&&(en=s,Ie.forEach((t,e)=>{e.currentDevicePixelRatio!==s&&t()}))}function cd(s,t){Ie.size||window.addEventListener("resize",Mo),Ie.set(s,t)}function dd(s){Ie.delete(s),Ie.size||window.removeEventListener("resize",Mo)}function hd(s,t,e){const i=s.canvas,n=i&&di(i);if(!n)return;const o=eo((a,l)=>{const c=n.clientWidth;e(a,l),c{const l=a[0],c=l.contentRect.width,d=l.contentRect.height;c===0&&d===0||o(c,d)});return r.observe(n),cd(s,o),r}function Cs(s,t,e){e&&e.disconnect(),t==="resize"&&dd(s)}function ud(s,t,e){const i=s.canvas,n=eo(o=>{s.ctx!==null&&e(rd(o,s))},s);return nd(i,t,n),n}class fd extends ko{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(id(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[ss])return!1;const i=e[ss].initial;["height","width"].forEach(o=>{const r=i[o];W(r)?e.removeAttribute(o):e.setAttribute(o,r)});const n=i.style||{};return Object.keys(n).forEach(o=>{e.style[o]=n[o]}),e.width=e.width,delete e[ss],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const n=t.$proxies||(t.$proxies={}),r={attach:ad,detach:ld,resize:hd}[e]||ud;n[e]=r(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),n=i[e];if(!n)return;({attach:Cs,detach:Cs,resize:Cs}[e]||od)(t,e,n),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,n){return nc(t,e,i,n)}isAttached(t){const e=t&&di(t);return!!(e&&e.isConnected)}}function gd(s){return!ci()||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas?ed:fd}class Bt{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return Ae(this.x)&&Ae(this.y)}getProps(t,e){const i=this.$animations;if(!e||!i)return this;const n={};return t.forEach(o=>{n[o]=i[o]&&i[o].active()?i[o]._to:this[o]}),n}}function pd(s,t){const e=s.options.ticks,i=md(s),n=Math.min(e.maxTicksLimit||i,i),o=e.major.enabled?_d(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>n)return xd(t,c,o,r/n),c;const d=bd(o,t,n);if(r>0){let u,f;const g=r>1?Math.round((l-a)/(r-1)):null;for(Je(t,c,d,W(g)?0:a-g,a),u=0,f=r-1;un)return l}return Math.max(n,1)}function _d(s){const t=[];let e,i;for(e=0,i=s.length;es==="left"?"right":s==="right"?"left":s,sn=(s,t,e)=>t==="top"||t==="left"?s[t]+e:s[t]-e,nn=(s,t)=>Math.min(t||s,s);function on(s,t){const e=[],i=s.length/t,n=s.length;let o=0;for(;or+a)))return l}function Sd(s,t){N(s,e=>{const i=e.gc,n=i.length/2;let o;if(n>t){for(o=0;oi?i:e,i=n&&e>i?e:i,{min:xt(e,xt(i,e)),max:xt(i,xt(e,i))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){U(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:n,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=El(this,o,n),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a=o||i<=1||!this.isHorizontal()){this.labelRotation=n;return}const d=this._getLabelSizes(),u=d.widest.width,f=d.highest.height,g=ht(this.chart.width-u,0,this.maxWidth);a=t.offset?this.maxWidth/i:g/(i-1),u+6>a&&(a=g/(i-(t.offset?.5:1)),l=this.maxHeight-_e(t.grid)-e.padding-rn(t.title,this.chart.options.font),c=Math.sqrt(u*u+f*f),r=al(Math.min(Math.asin(ht((d.highest.height+6)/a,-1,1)),Math.asin(ht(l/c,-1,1))-Math.asin(ht(f/c,-1,1)))),r=Math.max(n,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){U(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){U(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:n,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=rn(n,e.options.font);if(a?(t.width=this.maxWidth,t.height=_e(o)+l):(t.height=this.maxHeight,t.width=_e(o)+l),i.display&&this.ticks.length){const{first:c,last:d,widest:u,highest:f}=this._getLabelSizes(),g=i.padding*2,p=Jt(this.labelRotation),m=Math.cos(p),b=Math.sin(p);if(a){const _=i.mirror?0:b*u.width+m*f.height;t.height=Math.min(this.maxHeight,t.height+_+g)}else{const _=i.mirror?0:m*u.width+b*f.height;t.width=Math.min(this.maxWidth,t.width+_+g)}this._calculatePadding(c,d,b,m)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,n){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const d=this.getPixelForTick(0)-this.left,u=this.right-this.getPixelForTick(this.ticks.length-1);let f=0,g=0;l?c?(f=n*t.width,g=i*e.height):(f=i*t.height,g=n*e.width):o==="start"?g=e.width:o==="end"?f=t.width:o!=="inner"&&(f=t.width/2,g=e.width/2),this.paddingLeft=Math.max((f-d+r)*this.width/(this.width-d),0),this.paddingRight=Math.max((g-u+r)*this.width/(this.width-u),0)}else{let d=e.height/2,u=t.height/2;o==="start"?(d=0,u=t.height):o==="end"&&(d=e.height,u=0),this.paddingTop=d+r,this.paddingBottom=u+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){U(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,i;for(e=0,i=t.length;e({width:r[O]||0,height:a[O]||0});return{first:C(0),last:C(e-1),widest:C(P),highest:C(M),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return dl(this._alignToPixels?Vt(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*n?a/i:l/n:l*n0}_computeGridLineItems(t){const e=this.axis,i=this.chart,n=this.options,{grid:o,position:r,border:a}=n,l=o.offset,c=this.isHorizontal(),u=this.ticks.length+(l?1:0),f=_e(o),g=[],p=a.setContext(this.getContext()),m=p.display?p.width:0,b=m/2,_=function(X){return Vt(i,X,m)};let k,S,v,x,P,M,C,O,E,L,T,ot;if(r==="top")k=_(this.bottom),M=this.bottom-f,O=k-b,L=_(t.top)+b,ot=t.bottom;else if(r==="bottom")k=_(this.top),L=t.top,ot=_(t.bottom)-b,M=k+b,O=this.top+f;else if(r==="left")k=_(this.right),P=this.right-f,C=k-b,E=_(t.left)+b,T=t.right;else if(r==="right")k=_(this.left),E=t.left,T=_(t.right)-b,P=k+b,C=this.left+f;else if(e==="x"){if(r==="center")k=_((t.top+t.bottom)/2+.5);else if(F(r)){const X=Object.keys(r)[0],ft=r[X];k=_(this.chart.scales[X].getPixelForValue(ft))}L=t.top,ot=t.bottom,M=k+b,O=M+f}else if(e==="y"){if(r==="center")k=_((t.left+t.right)/2);else if(F(r)){const X=Object.keys(r)[0],ft=r[X];k=_(this.chart.scales[X].getPixelForValue(ft))}P=k-b,C=P-f,E=t.left,T=t.right}const Y=R(n.ticks.maxTicksLimit,u),V=Math.max(1,Math.ceil(u/Y));for(S=0;S0&&(Ht-=Nt/2);break}ze={left:Ht,top:ge,width:Nt+ie.width,height:fe+ie.height,color:V.backdropColor}}b.push({label:v,font:O,textOffset:T,options:{rotation:m,color:ft,strokeColor:Fe,strokeWidth:Be,textAlign:se,textBaseline:ot,translation:[x,P],backdrop:ze}})}return b}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-Jt(this.labelRotation))return t==="top"?"left":"right";let n="center";return e.align==="start"?n="left":e.align==="end"?n="right":e.align==="inner"&&(n="inner"),n}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:i,mirror:n,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width;let c,d;return e==="left"?n?(d=this.right+o,i==="near"?c="left":i==="center"?(c="center",d+=l/2):(c="right",d+=l)):(d=this.right-a,i==="near"?c="right":i==="center"?(c="center",d-=l/2):(c="left",d=this.left)):e==="right"?n?(d=this.left+o,i==="near"?c="right":i==="center"?(c="center",d-=l/2):(c="left",d-=l)):(d=this.left+a,i==="near"?c="left":i==="center"?(c="center",d+=l/2):(c="right",d=this.right)):c="right",{textAlign:c,x:d}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;if(e==="left"||e==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(e==="top"||e==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:i,top:n,width:o,height:r}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(i,n,o,r),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const n=this.ticks.findIndex(o=>o.value===t);return n>=0?e.setContext(this.getContext(n)).lineWidth:0}drawGrid(t){const e=this.options.grid,i=this.ctx,n=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(l,c,d)=>{!d.width||!d.color||(i.save(),i.lineWidth=d.width,i.strokeStyle=d.color,i.setLineDash(d.borderDash||[]),i.lineDashOffset=d.borderDashOffset,i.beginPath(),i.moveTo(l.x,l.y),i.lineTo(c.x,c.y),i.stroke(),i.restore())};if(e.display)for(o=0,r=n.length;o{this.draw(o)}}]:[{z:i,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:n,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",n=[];let o,r;for(o=0,r=e.length;o{const i=e.split("."),n=i.pop(),o=[s].concat(i).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");J.route(o,n,l,a)})}function Od(s){return"id"in s&&"defaults"in s}class Ad{constructor(){this.controllers=new Xe(hi,"datasets",!0),this.elements=new Xe(Bt,"elements"),this.plugins=new Xe(Object,"plugins"),this.scales=new Xe(he,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach(n=>{const o=i||this._getRegistryForType(n);i||o.isForType(n)||o===this.plugins&&n.id?this._exec(t,o,n):N(n,r=>{const a=i||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,i){const n=ti(t);U(i["before"+n],[],i),e[t](i),U(i["after"+n],[],i)}_getRegistryForType(t){for(let e=0;eo.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(n(e,i),t,"stop"),this._notify(n(i,e),t,"start")}}function Td(s){const t={},e=[],i=Object.keys(vt.plugins.items);for(let o=0;o1&&an(s[0].toLowerCase());if(i)return i}throw new Error(`Cannot determine type of '${s}' axis. Please provide 'axis' or 'position' option.`)}function ln(s,t,e){if(e[t+"AxisID"]===s)return{axis:t}}function Nd(s,t){if(t.data&&t.data.datasets){const e=t.data.datasets.filter(i=>i.xAxisID===s||i.yAxisID===s);if(e.length)return ln(s,"x",e[0])||ln(s,"y",e[0])}return{}}function Hd(s,t){const e=te[s.type]||{scales:{}},i=t.scales||{},n=Ns(s.type,t),o=Object.create(null);return Object.keys(i).forEach(r=>{const a=i[r];if(!F(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);const l=Hs(r,a,Nd(r,s),J.scales[a.type]),c=Bd(l,n),d=e.scales||{};o[r]=ke(Object.create(null),[{axis:l},a,d[l],d[c]])}),s.data.datasets.forEach(r=>{const a=r.type||s.type,l=r.indexAxis||Ns(a,t),d=(te[a]||{}).scales||{};Object.keys(d).forEach(u=>{const f=Fd(u,l),g=r[f+"AxisID"]||f;o[g]=o[g]||Object.create(null),ke(o[g],[{axis:f},i[g],d[u]])})}),Object.keys(o).forEach(r=>{const a=o[r];ke(a,[J.scales[a.type],J.scale])}),o}function Co(s){const t=s.options||(s.options={});t.plugins=R(t.plugins,{}),t.scales=Hd(s,t)}function $o(s){return s=s||{},s.datasets=s.datasets||[],s.labels=s.labels||[],s}function jd(s){return s=s||{},s.data=$o(s.data),Co(s),s}const cn=new Map,Do=new Set;function Ge(s,t){let e=cn.get(s);return e||(e=t(),cn.set(s,e),Do.add(e)),e}const xe=(s,t,e)=>{const i=le(t,e);i!==void 0&&s.add(i)};let Vd=class{constructor(t){this._config=jd(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=$o(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Co(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Ge(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Ge(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Ge(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id,i=this.type;return Ge(`${i}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let n=i.get(t);return(!n||e)&&(n=new Map,i.set(t,n)),n}getOptionScopes(t,e,i){const{options:n,type:o}=this,r=this._cachedScopes(t,i),a=r.get(e);if(a)return a;const l=new Set;e.forEach(d=>{t&&(l.add(t),d.forEach(u=>xe(l,t,u))),d.forEach(u=>xe(l,n,u)),d.forEach(u=>xe(l,te[o]||{},u)),d.forEach(u=>xe(l,J,u)),d.forEach(u=>xe(l,Bs,u))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),Do.has(e)&&r.set(e,c),c}chartOptionScopes(){const{options:t,type:e}=this;return[t,te[e]||{},J.datasets[e]||{},{type:e},J,Bs]}resolveNamedOptions(t,e,i,n=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=dn(this._resolverCache,t,n);let l=r;if(Ud(r,e)){o.$shared=!1,i=Ft(i)?i():i;const c=this.createResolver(t,i,a);l=ce(r,i,c)}for(const c of e)o[c]=l[c];return o}createResolver(t,e,i=[""],n){const{resolver:o}=dn(this._resolverCache,t,i);return F(e)?ce(o,e,void 0,n):o}};function dn(s,t,e){let i=s.get(t);i||(i=new Map,s.set(t,i));const n=e.join();let o=i.get(n);return o||(o={resolver:ri(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},i.set(n,o)),o}const Wd=s=>F(s)&&Object.getOwnPropertyNames(s).some(t=>Ft(s[t]));function Ud(s,t){const{isScriptable:e,isIndexable:i}=lo(s);for(const n of t){const o=e(n),r=i(n),a=(r||o)&&s[n];if(o&&(Ft(a)||Wd(a))||r&&q(a))return!0}return!1}var Yd="4.4.4";const Kd=["top","bottom","left","right","chartArea"];function hn(s,t){return s==="top"||s==="bottom"||Kd.indexOf(s)===-1&&t==="x"}function un(s,t){return function(e,i){return e[s]===i[s]?e[t]-i[t]:e[s]-i[s]}}function fn(s){const t=s.chart,e=t.options.animation;t.notifyPlugins("afterRender"),U(e&&e.onComplete,[s],t)}function Jd(s){const t=s.chart,e=t.options.animation;U(e&&e.onProgress,[s],t)}function Oo(s){return ci()&&typeof s=="string"?s=document.getElementById(s):s&&s.length&&(s=s[0]),s&&s.canvas&&(s=s.canvas),s}const is={},gn=s=>{const t=Oo(s);return Object.values(is).filter(e=>e.canvas===t).pop()};function Xd(s,t,e){const i=Object.keys(s);for(const n of i){const o=+n;if(o>=t){const r=s[n];delete s[n],(e>0||o>t)&&(s[o+e]=r)}}}function Gd(s,t,e,i){return!e||s.type==="mouseout"?null:i?t:s}function qe(s,t,e){return s.options.clip?s[e]:t[e]}function qd(s,t){const{xScale:e,yScale:i}=s;return e&&i?{left:qe(e,t,"left"),right:qe(e,t,"right"),top:qe(i,t,"top"),bottom:qe(i,t,"bottom")}:t}let ms=class{static defaults=J;static instances=is;static overrides=te;static registry=vt;static version=Yd;static getChart=gn;static register(...t){vt.add(...t),pn()}static unregister(...t){vt.remove(...t),pn()}constructor(t,e){const i=this.config=new Vd(e),n=Oo(t),o=gn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||gd(n)),this.platform.updateConfig(i);const a=this.platform.acquireContext(n,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,d=l&&l.width;if(this.id=Xa(),this.ctx=a,this.canvas=l,this.width=d,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Ld,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=gl(u=>this.update(u),r.resizeDelay||0),this._dataChanges=[],is[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}$t.listen(this,"complete",fn),$t.listen(this,"progress",Jd),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:n,_aspectRatio:o}=this;return W(t)?e&&o?o:n?i/n:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return vt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Ri(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Li(this.canvas,this.ctx),this}stop(){return $t.stop(this),this}resize(t,e){$t.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,n=this.canvas,o=i.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(n,t,e,o),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,Ri(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),U(i.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const e=this.options.scales||{};N(e,(i,n)=>{i.id=n})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,n=Object.keys(i).reduce((r,a)=>(r[a]=!1,r),{});let o=[];e&&(o=o.concat(Object.keys(e).map(r=>{const a=e[r],l=Hs(r,a),c=l==="r",d=l==="x";return{options:a,dposition:c?"chartArea":d?"bottom":"left",dtype:c?"radialLinear":d?"category":"linear"}}))),N(o,r=>{const a=r.options,l=a.id,c=Hs(l,a),d=R(a.type,r.dtype);(a.position===void 0||hn(a.position,c)!==hn(r.dposition))&&(a.position=r.dposition),n[l]=!0;let u=null;if(l in i&&i[l].type===d)u=i[l];else{const f=vt.getScale(d);u=new f({id:l,type:d,ctx:this.ctx,chart:this}),i[u.id]=u}u.init(a,t)}),N(n,(r,a)=>{r||delete i[a]}),N(i,r=>{pt.configure(this,r,r.options),pt.addBox(this,r)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort((n,o)=>n.index-o.index),i>e){for(let n=e;ne.length&&delete this._stacks,t.forEach((i,n)=>{e.filter(o=>o===i._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,n;for(this._removeUnreferencedMetasets(),i=0,n=e.length;i{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),n=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,d=this.data.datasets.length;c{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(un("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){N(this.scales,t=>{pt.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!wi(e,i)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:n,count:o}of e){const r=i==="_removeElements"?-o:o;Xd(t,n,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),n=i(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;pt.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],N(this.boxes,n=>{i&&n.position==="chartArea"||(n.configure&&n.configure(),this._layers.push(...n._layers()))},this),this._layers.forEach((n,o)=>{n._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,i=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,n=!i.disabled,o=qd(t,this.chartArea),r={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",r)!==!1&&(n&&ni(e,{left:i.left===!1?0:o.left-i.left,right:i.right===!1?this.width:o.right+i.right,top:i.top===!1?0:o.top-i.top,bottom:i.bottom===!1?this.height:o.bottom+i.bottom}),t.controller.draw(),n&&oi(e),r.cancelable=!1,this.notifyPlugins("afterDatasetDraw",r))}isPointInArea(t){return Le(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,n){const o=Kc.modes[e];return typeof o=="function"?o(this,t,i,n):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let n=i.filter(o=>o&&o._dataset===e).pop();return n||(n={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(n)),n}getContext(){return this.$context||(this.$context=ee(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return typeof i.hidden=="boolean"?!i.hidden:!e.hidden}setDatasetVisibility(t,e){const i=this.getDatasetMeta(t);i.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const n=i?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,n);Oe(e)?(o.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),r.update(o,{visible:i}),this.update(a=>a.datasetIndex===t?n:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),$t.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,r),t[o]=r},n=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};N(this.options.events,o=>i(o,n))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(l,c)=>{e.addEventListener(this,l,c),t[l]=c},n=(l,c)=>{t[l]&&(e.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let r;const a=()=>{n("attach",a),this.attached=!0,this.resize(),i("resize",o),i("detach",r)};r=()=>{this.attached=!1,n("resize",o),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){N(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},N(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const n=i?"set":"remove";let o,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+n+"DatasetHoverStyle"]()),a=0,l=t.length;a{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!os(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,i){const n=this.options.hover,o=(l,c)=>l.filter(d=>!c.some(u=>d.datasetIndex===u.datasetIndex&&d.index===u.index)),r=o(e,t),a=i?t:o(t,e);r.length&&this.updateHoverStyle(r,n.mode,!1),a.length&&n.mode&&this.updateHoverStyle(a,n.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},n=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",i,n)===!1)return;const o=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,n),(o||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:n=[],options:o}=this,r=e,a=this._getActiveElements(t,n,i,r),l=el(t),c=Gd(t,this._lastEvent,i,l);i&&(this._lastEvent=null,U(o.onHover,[t,a,this],this),l&&U(o.onClick,[t,a,this],this));const d=!os(a,n);return(d||e)&&(this._active=a,this._updateHoverStyles(a,n,e)),this._lastEvent=c,d}_getActiveElements(t,e,i,n){if(t.type==="mouseout")return[];if(!i)return e;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,n)}};function pn(){return N(ms.instances,s=>s._plugins.invalidate())}function Ao(s,t,e=t){s.lineCap=R(e.borderCapStyle,t.borderCapStyle),s.setLineDash(R(e.borderDash,t.borderDash)),s.lineDashOffset=R(e.borderDashOffset,t.borderDashOffset),s.lineJoin=R(e.borderJoinStyle,t.borderJoinStyle),s.lineWidth=R(e.borderWidth,t.borderWidth),s.strokeStyle=R(e.borderColor,t.borderColor)}function Qd(s,t,e){s.lineTo(e.x,e.y)}function Zd(s){return s.stepped?Cl:s.tension||s.cubicInterpolationMode==="monotone"?$l:Qd}function Lo(s,t,e={}){const i=s.length,{start:n=0,end:o=i-1}=e,{start:r,end:a}=t,l=Math.max(n,r),c=Math.min(o,a),d=na&&o>a;return{count:i,start:l,loop:t.loop,ilen:c(r+(c?a-v:v))%o,S=()=>{m!==b&&(s.lineTo(d,b),s.lineTo(d,m),s.lineTo(d,_))};for(l&&(g=n[k(0)],s.moveTo(g.x,g.y)),f=0;f<=a;++f){if(g=n[k(f)],g.skip)continue;const v=g.x,x=g.y,P=v|0;P===p?(xb&&(b=x),d=(u*d+v)/++u):(S(),s.lineTo(v,x),p=P,u=0,m=b=x),_=x}S()}function js(s){const t=s.options,e=t.borderDash&&t.borderDash.length;return!s._decimated&&!s._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?eh:th}function sh(s){return s.stepped?rc:s.tension||s.cubicInterpolationMode==="monotone"?ac:Yt}function ih(s,t,e,i){let n=t._path;n||(n=t._path=new Path2D,t.path(n,e,i)&&n.closePath()),Ao(s,t.options),s.stroke(n)}function nh(s,t,e,i){const{segments:n,options:o}=t,r=js(t);for(const a of n)Ao(s,o,a.style),s.beginPath(),r(s,t,a,{start:e,end:e+i-1})&&s.closePath(),s.stroke()}const oh=typeof Path2D=="function";function rh(s,t,e,i){oh&&!t.options.segment?ih(s,t,e,i):nh(s,t,e,i)}class ah extends Bt{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||i.cubicInterpolationMode==="monotone")&&!i.stepped&&!this._pointsUpdated){const n=i.spanGaps?this._loop:this._fullLoop;Ql(this._points,i,t,n,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=pc(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,n=t[e],o=this.points,r=uc(this,{property:e,start:n,end:n});if(!r.length)return;const a=[],l=sh(i);let c,d;for(c=0,d=r.length;c{let{boxHeight:e=t,boxWidth:i=t}=s;return s.usePointStyle&&(e=Math.min(e,t),i=s.pointStyleWidth||Math.min(i,t)),{boxWidth:i,boxHeight:e,itemHeight:Math.max(t,e)}},ph=(s,t)=>s!==null&&t!==null&&s.datasetIndex===t.datasetIndex&&s.index===t.index;class _n extends Bt{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=U(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(i=>t.filter(i,this.chart.data))),t.sort&&(e=e.sort((i,n)=>t.sort(i,n,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}const i=t.labels,n=it(i.font),o=n.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=bn(i,o);let c,d;e.font=n.string,this.isHorizontal()?(c=this.maxWidth,d=this._fitRows(r,o,a,l)+10):(d=this.maxHeight,c=this._fitCols(r,n,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(d,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,n){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],d=n+a;let u=t;o.textAlign="left",o.textBaseline="middle";let f=-1,g=-d;return this.legendItems.forEach((p,m)=>{const b=i+e/2+o.measureText(p.text).width;(m===0||c[c.length-1]+b+2*a>r)&&(u+=d,c[c.length-(m>0?0:1)]=0,g+=d,f++),l[m]={left:0,top:g,row:f,width:b,height:n},c[c.length-1]+=b+a}),u}_fitCols(t,e,i,n){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],d=r-t;let u=a,f=0,g=0,p=0,m=0;return this.legendItems.forEach((b,_)=>{const{itemWidth:k,itemHeight:S}=mh(i,e,o,b,n);_>0&&g+S+2*a>d&&(u+=f+a,c.push({width:f,height:g}),p+=f+a,m++,f=g=0),l[_]={left:p,top:g,col:m,width:k,height:S},f=Math.max(f,k),g+=S+a}),u+=f,c.push({width:f,height:g}),u}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:n},rtl:o}}=this,r=ae(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=st(i,this.left+n,this.right-this.lineWidths[a]);for(const c of e)a!==c.row&&(a=c.row,l=st(i,this.left+n,this.right-this.lineWidths[a])),c.top+=this.top+t+n,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+n}else{let a=0,l=st(i,this.top+t+n,this.bottom-this.columnSizes[a].height);for(const c of e)c.col!==a&&(a=c.col,l=st(i,this.top+t+n,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+n,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+n}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;ni(t,this),this._draw(),oi(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:n}=this,{align:o,labels:r}=t,a=J.color,l=ae(t.rtl,this.left,this.width),c=it(r.font),{padding:d}=r,u=c.size,f=u/2;let g;this.drawTitle(),n.textAlign=l.textAlign("left"),n.textBaseline="middle",n.lineWidth=.5,n.font=c.string;const{boxWidth:p,boxHeight:m,itemHeight:b}=bn(r,u),_=function(P,M,C){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;n.save();const O=R(C.lineWidth,1);if(n.fillStyle=R(C.fillStyle,a),n.lineCap=R(C.lineCap,"butt"),n.lineDashOffset=R(C.lineDashOffset,0),n.lineJoin=R(C.lineJoin,"miter"),n.lineWidth=O,n.strokeStyle=R(C.strokeStyle,a),n.setLineDash(R(C.lineDash,[])),r.usePointStyle){const E={radius:m*Math.SQRT2/2,pointStyle:C.pointStyle,rotation:C.rotation,borderWidth:O},L=l.xPlus(P,p/2),T=M+f;oo(n,E,L,T,r.pointStyleWidth&&p)}else{const E=M+Math.max((u-m)/2,0),L=l.leftForLtr(P,p),T=re(C.borderRadius);n.beginPath(),Object.values(T).some(ot=>ot!==0)?ls(n,{x:L,y:E,w:p,h:m,radius:T}):n.rect(L,E,p,m),n.fill(),O!==0&&n.stroke()}n.restore()},k=function(P,M,C){Te(n,C.text,P,M+b/2,c,{strikethrough:C.hidden,textAlign:l.textAlign(C.textAlign)})},S=this.isHorizontal(),v=this._computeTitleHeight();S?g={x:st(o,this.left+d,this.right-i[0]),y:this.top+d+v,line:0}:g={x:this.left+d,y:st(o,this.top+v+d,this.bottom-e[0].height),line:0},go(this.ctx,t.textDirection);const x=b+d;this.legendItems.forEach((P,M)=>{n.strokeStyle=P.fontColor,n.fillStyle=P.fontColor;const C=n.measureText(P.text).width,O=l.textAlign(P.textAlign||(P.textAlign=r.textAlign)),E=p+f+C;let L=g.x,T=g.y;l.setWidth(this.width),S?M>0&&L+E+d>this.right&&(T=g.y+=x,g.line++,L=g.x=st(o,this.left+d,this.right-i[g.line])):M>0&&T+x>this.bottom&&(L=g.x=L+e[g.line].width+d,g.line++,T=g.y=st(o,this.top+v+d,this.bottom-e[g.line].height));const ot=l.x(L);if(_(ot,T,P),L=pl(O,L+p+f,S?L+E:this.right,t.rtl),k(l.x(L),T,P),S)g.x+=E+d;else if(typeof P.text!="string"){const Y=c.lineHeight;g.y+=Io(P,Y)+d}else g.y+=x}),po(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=it(e.font),n=bt(e.padding);if(!e.display)return;const o=ae(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=i.size/2,c=n.top+l;let d,u=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),d=this.top+c,u=st(t.align,u,this.right-f);else{const p=this.columnSizes.reduce((m,b)=>Math.max(m,b.height),0);d=c+st(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}const g=st(a,u,u+f);r.textAlign=o.textAlign(si(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,Te(r,e.text,g,d,i)}_computeTitleHeight(){const t=this.options.title,e=it(t.font),i=bt(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,n,o;if(Xt(t,this.left,this.right)&&Xt(e,this.top,this.bottom)){for(o=this.legendHitBoxes,i=0;io.length>r.length?o:r)),t+e.size/2+i.measureText(n).width}function _h(s,t,e){let i=s;return typeof t.text!="string"&&(i=Io(t,e)),i}function Io(s,t){const e=s.text?s.text.length:0;return t*e}function xh(s,t){return!!((s==="mousemove"||s==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(s==="click"||s==="mouseup"))}var yh={id:"legend",_element:_n,start(s,t,e){const i=s.legend=new _n({ctx:s.ctx,options:e,chart:s});pt.configure(s,i,e),pt.addBox(s,i)},stop(s){pt.removeBox(s,s.legend),delete s.legend},beforeUpdate(s,t,e){const i=s.legend;pt.configure(s,i,e),i.options=e},afterUpdate(s){const t=s.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(s,t){t.replay||s.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(s,t,e){const i=t.datasetIndex,n=e.chart;n.isDatasetVisible(i)?(n.hide(i),t.hidden=!0):(n.show(i),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:s=>s.chart.options.color,boxWidth:40,padding:10,generateLabels(s){const t=s.data.datasets,{labels:{usePointStyle:e,pointStyle:i,textAlign:n,color:o,useBorderRadius:r,borderRadius:a}}=s.legend.options;return s._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(e?0:void 0),d=bt(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(d.width+d.height)/4,strokeStyle:c.borderColor,pointStyle:i||c.pointStyle,rotation:c.rotation,textAlign:n||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:s=>s.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:s=>!s.startsWith("on"),labels:{_scriptable:s=>!["generateLabels","filter","sort"].includes(s)}}};class Ro extends Bt{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=e;const n=q(i.text)?i.text.length:1;this._padding=bt(i.padding);const o=n*it(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:e,left:i,bottom:n,right:o,options:r}=this,a=r.align;let l=0,c,d,u;return this.isHorizontal()?(d=st(a,i,o),u=e+t,c=o-i):(r.position==="left"?(d=i+t,u=st(a,n,e),l=tt*-.5):(d=o-t,u=st(a,e,n),l=tt*.5),c=n-e),{titleX:d,titleY:u,maxWidth:c,rotation:l}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=it(e.font),o=i.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(o);Te(t,e.text,0,0,i,{color:e.color,maxWidth:l,rotation:c,textAlign:si(e.align),textBaseline:"middle",translation:[r,a]})}}function vh(s,t){const e=new Ro({ctx:s.ctx,options:t,chart:s});pt.configure(s,e,t),pt.addBox(s,e),s.titleBlock=e}var wh={id:"title",_element:Ro,start(s,t,e){vh(s,e)},stop(s){const t=s.titleBlock;pt.removeBox(s,t),delete s.titleBlock},beforeUpdate(s,t,e){const i=s.titleBlock;pt.configure(s,i,e),i.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Se={average(s){if(!s.length)return!1;let t,e,i=new Set,n=0,o=0;for(t=0,e=s.length;ta+l)/i.size,y:n/o}},nearest(s,t){if(!s.length)return!1;let e=t.x,i=t.y,n=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=s.length;o-1?s.split(` `):s}function Sh(s,t){const{element:e,datasetIndex:i,index:n}=t,o=s.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(n);return{chart:s,label:r,parsed:o.getParsed(n),raw:s.data.datasets[i].data[n],formattedValue:a,dataset:o.getDataset(),dataIndex:n,datasetIndex:i,element:e}}function xn(s,t){const e=s.chart.ctx,{body:i,footer:n,title:o}=s,{boxWidth:r,boxHeight:a}=t,l=it(t.bodyFont),c=it(t.titleFont),d=it(t.footerFont),u=o.length,f=n.length,g=i.length,p=bt(t.padding);let m=p.height,b=0,_=i.reduce((v,x)=>v+x.before.length+x.lines.length+x.after.length,0);if(_+=s.beforeBody.length+s.afterBody.length,u&&(m+=u*c.lineHeight+(u-1)*t.titleSpacing+t.titleMarginBottom),_){const v=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=g*v+(_-g)*l.lineHeight+(_-1)*t.bodySpacing}f&&(m+=t.footerMarginTop+f*d.lineHeight+(f-1)*t.footerSpacing);let k=0;const S=function(v){b=Math.max(b,e.measureText(v).width+k)};return e.save(),e.font=c.string,N(s.title,S),e.font=l.string,N(s.beforeBody.concat(s.afterBody),S),k=t.displayColors?r+2+t.boxPadding:0,N(i,v=>{N(v.before,S),N(v.lines,S),N(v.after,S)}),k=0,e.font=d.string,N(s.footer,S),e.restore(),b+=p.width,{width:b,height:m}}function kh(s,t){const{y:e,height:i}=t;return es.height-i/2?"bottom":"center"}function Ph(s,t,e,i){const{x:n,width:o}=i,r=e.caretSize+e.caretPadding;if(s==="left"&&n+o+r>t.width||s==="right"&&n-o-r<0)return!0}function Mh(s,t,e,i){const{x:n,width:o}=e,{width:r,chartArea:{left:a,right:l}}=s;let c="center";return i==="center"?c=n<=(a+l)/2?"left":"right":n<=o/2?c="left":n>=r-o/2&&(c="right"),Ph(c,s,t,e)&&(c="center"),c}function yn(s,t,e){const i=e.yAlign||t.yAlign||kh(s,e);return{xAlign:e.xAlign||t.xAlign||Mh(s,t,e,i),yAlign:i}}function Ch(s,t){let{x:e,width:i}=s;return t==="right"?e-=i:t==="center"&&(e-=i/2),e}function $h(s,t,e){let{y:i,height:n}=s;return t==="top"?i+=e:t==="bottom"?i-=n+e:i-=n/2,i}function vn(s,t,e,i){const{caretSize:n,caretPadding:o,cornerRadius:r}=s,{xAlign:a,yAlign:l}=e,c=n+o,{topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=re(r);let p=Ch(t,a);const m=$h(t,l,c);return l==="center"?a==="left"?p+=c:a==="right"&&(p-=c):a==="left"?p-=Math.max(d,f)+n:a==="right"&&(p+=Math.max(u,g)+n),{x:ht(p,0,i.width-t.width),y:ht(m,0,i.height-t.height)}}function Qe(s,t,e){const i=bt(e.padding);return t==="center"?s.x+s.width/2:t==="right"?s.x+s.width-i.right:s.x+i.left}function wn(s){return yt([],Dt(s))}function Dh(s,t,e){return ee(s,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Sn(s,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?s.override(e):s}const Eo={beforeTitle:Ct,title(s){if(s.length>0){const t=s[0],e=t.chart.data.labels,i=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex"u"?Eo[t].call(e,i):n}class kn extends Bt{static positioners=Se;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,i=this.options.setContext(this.getContext()),n=i.enabled&&e.options.animation&&i.animations,o=new bo(this.chart,n);return n._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Dh(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,n=at(i,"beforeTitle",this,t),o=at(i,"title",this,t),r=at(i,"afterTitle",this,t);let a=[];return a=yt(a,Dt(n)),a=yt(a,Dt(o)),a=yt(a,Dt(r)),a}getBeforeBody(t,e){return wn(at(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,n=[];return N(t,o=>{const r={before:[],lines:[],after:[]},a=Sn(i,o);yt(r.before,Dt(at(a,"beforeLabel",this,o))),yt(r.lines,at(a,"label",this,o)),yt(r.after,Dt(at(a,"afterLabel",this,o))),n.push(r)}),n}getAfterBody(t,e){return wn(at(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,n=at(i,"beforeFooter",this,t),o=at(i,"footer",this,t),r=at(i,"afterFooter",this,t);let a=[];return a=yt(a,Dt(n)),a=yt(a,Dt(o)),a=yt(a,Dt(r)),a}_createItems(t){const e=this._active,i=this.chart.data,n=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;lt.filter(d,u,f,i))),t.itemSort&&(a=a.sort((d,u)=>t.itemSort(d,u,i))),N(a,d=>{const u=Sn(t.callbacks,d);n.push(at(u,"labelColor",this,d)),o.push(at(u,"labelPointStyle",this,d)),r.push(at(u,"labelTextColor",this,d))}),this.labelColors=n,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const i=this.options.setContext(this.getContext()),n=this._active;let o,r=[];if(!n.length)this.opacity!==0&&(o={opacity:0});else{const a=Se[i.position].call(this,n,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=xn(this,i),c=Object.assign({},a,l),d=yn(this.chart,i,c),u=vn(i,c,d,this.chart);this.xAlign=d.xAlign,this.yAlign=d.yAlign,o={opacity:1,x:u.x,y:u.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,n){const o=this.getCaretPosition(t,i,n);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,i){const{xAlign:n,yAlign:o}=this,{caretSize:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:d,bottomRight:u}=re(a),{x:f,y:g}=t,{width:p,height:m}=e;let b,_,k,S,v,x;return o==="center"?(v=g+m/2,n==="left"?(b=f,_=b-r,S=v+r,x=v-r):(b=f+p,_=b+r,S=v-r,x=v+r),k=b):(n==="left"?_=f+Math.max(l,d)+r:n==="right"?_=f+p-Math.max(c,u)-r:_=this.caretX,o==="top"?(S=g,v=S-r,b=_-r,k=_+r):(S=g+m,v=S+r,b=_+r,k=_-r),x=S),{x1:b,x2:_,x3:k,y1:S,y2:v,y3:x}}drawTitle(t,e,i){const n=this.title,o=n.length;let r,a,l;if(o){const c=ae(i.rtl,this.x,this.width);for(t.x=Qe(this,i.titleAlign,i),e.textAlign=c.textAlign(i.titleAlign),e.textBaseline="middle",r=it(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=r.string,l=0;lk!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,ls(t,{x:m,y:p,w:c,h:l,radius:_}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),ls(t,{x:b,y:p+1,w:c-2,h:l-2,radius:_}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(m,p,c,l),t.strokeRect(m,p,c,l),t.fillStyle=r.backgroundColor,t.fillRect(b,p+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:n}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:d}=i,u=it(i.bodyFont);let f=u.lineHeight,g=0;const p=ae(i.rtl,this.x,this.width),m=function(C){e.fillText(C,p.x(t.x+g),t.y+f/2),t.y+=f+o},b=p.textAlign(r);let _,k,S,v,x,P,M;for(e.textAlign=r,e.textBaseline="middle",e.font=u.string,t.x=Qe(this,b,i),e.fillStyle=i.bodyColor,N(this.beforeBody,m),g=a&&b!=="right"?r==="center"?c/2+d:c+2+d:0,v=0,P=n.length;v0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,n=i&&i.x,o=i&&i.y;if(n||o){const r=Se[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=xn(this,t),l=Object.assign({},r,this._size),c=yn(e,t,l),d=vn(t,l,c,e);(n._to!==d.x||o._to!==d.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,d))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const n={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const r=bt(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,n,e),go(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),po(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,n=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!os(i,n),r=this._positionChanged(n,e);(o||r)&&(this._active=n,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const n=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,i),a=this._positionChanged(r,t),l=e||!os(r,o)||a;return l&&(this._active=r,(n.enabled||n.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,i,n){const o=this.options;if(t.type==="mouseout")return[];if(!n)return e.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:i,caretY:n,options:o}=this,r=Se[o.position].call(this,t,e);return r!==!1&&(i!==r.x||n!==r.y)}}var Oh={id:"tooltip",_element:kn,positioners:Se,afterInit(s,t,e){e&&(s.tooltip=new kn({chart:s,options:e}))},beforeUpdate(s,t,e){s.tooltip&&s.tooltip.initialize(e)},reset(s,t,e){s.tooltip&&s.tooltip.initialize(e)},afterDraw(s){const t=s.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(s.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(s.ctx),s.notifyPlugins("afterTooltipDraw",e)}},afterEvent(s,t){if(s.tooltip){const e=t.replay;s.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(s,t)=>t.bodyFont.size,boxWidth:(s,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Eo},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:s=>s!=="filter"&&s!=="itemSort"&&s!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const Ah=(s,t,e,i)=>(typeof t=="string"?(e=s.push(t)-1,i.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function Lh(s,t,e,i){const n=s.indexOf(t);if(n===-1)return Ah(s,t,e,i);const o=s.lastIndexOf(t);return n!==o?e:n}const Th=(s,t)=>s===null?null:ht(Math.round(s),0,t);function Pn(s){const t=this.getLabels();return s>=0&&se.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Rh(s,t){const e=[],{bounds:n,step:o,min:r,max:a,precision:l,count:c,maxTicks:d,maxDigits:u,includeBounds:f}=s,g=o||1,p=d-1,{min:m,max:b}=t,_=!W(r),k=!W(a),S=!W(c),v=(b-m)/(u+1);let x=ki((b-m)/p/g)*g,P,M,C,O;if(x<1e-14&&!_&&!k)return[{value:m},{value:b}];O=Math.ceil(b/x)-Math.floor(m/x),O>p&&(x=ki(O*x/p/g)*g),W(l)||(P=Math.pow(10,l),x=Math.ceil(x*P)/P),n==="ticks"?(M=Math.floor(m/x)*x,C=Math.ceil(b/x)*x):(M=m,C=b),_&&k&&o&&ol((a-r)/o,x/1e3)?(O=Math.round(Math.min((a-r)/x,d)),x=(a-r)/O,M=r,C=a):S?(M=_?r:M,C=k?a:C,O=c-1,x=(C-M)/O):(O=(C-M)/x,Pe(O,Math.round(O),x/1e3)?O=Math.round(O):O=Math.ceil(O));const E=Math.max(Pi(x),Pi(M));P=Math.pow(10,W(l)?E:l),M=Math.round(M*P)/P,C=Math.round(C*P)/P;let L=0;for(_&&(f&&M!==r?(e.push({value:r}),Ma)break;e.push({value:T})}return k&&f&&C!==a?e.length&&Pe(e[e.length-1].value,a,Mn(a,v,s))?e[e.length-1].value=a:e.push({value:a}):(!k||C===a)&&e.push({value:C}),e}function Mn(s,t,{horizontal:e,minRotation:i}){const n=Jt(i),o=(e?Math.sin(n):Math.cos(n))||.001,r=.75*t*(""+s).length;return Math.min(t/o,r)}class Eh extends he{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return W(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:n,max:o}=this;const r=l=>n=e?n:l,a=l=>o=i?o:l;if(t){const l=kt(n),c=kt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(n===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(n-l)}this.min=n,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:i}=t,n;return i?(n=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e=e||11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const n={maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},o=this._range||this,r=Rh(n,o);return t.bounds==="ticks"&&rl(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let e=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const n=(i-e)/Math.max(t.length-1,1)/2;e-=n,i+=n}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return so(t,this.chart.options.locale,this.options.ticks.format)}}class Fh extends Eh{static id="linear";static defaults={ticks:{callback:no.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=mt(t)?t:0,this.max=mt(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=Jt(this.options.ticks.minRotation),n=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/n))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const bs={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ct=Object.keys(bs);function Cn(s,t){return s-t}function $n(s,t){if(W(t))return null;const e=s._adapter,{parser:i,round:n,isoWeekday:o}=s._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),mt(r)||(r=typeof i=="string"?e.parse(r,i):e.parse(r)),r===null?null:(n&&(r=n==="week"&&(Ae(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,n)),+r)}function Dn(s,t,e,i){const n=ct.length;for(let o=ct.indexOf(s);o=ct.indexOf(e);o--){const r=ct[o];if(bs[r].common&&s._adapter.diff(n,i,r)>=t-1)return r}return ct[e?ct.indexOf(e):0]}function zh(s){for(let t=ct.indexOf(s)+1,e=ct.length;t=t?e[i]:e[n];s[o]=!0}}function Nh(s,t,e,i){const n=s._adapter,o=+n.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+n.add(a,1,i))l=e[a],l>=0&&(t[l].major=!0);return t}function An(s,t,e){const i=[],n={},o=t.length;let r,a;for(r=0;r+t.value))}initOffsets(t=[]){let e=0,i=0,n,o;this.options.offset&&t.length&&(n=this.getDecimalForValue(t[0]),t.length===1?e=1-n:e=(this.getDecimalForValue(t[1])-n)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=ht(e,0,r),i=ht(i,0,r),this._offsets={start:e,end:i,factor:1/(e+1+i)}}_generate(){const t=this._adapter,e=this.min,i=this.max,n=this.options,o=n.time,r=o.unit||Dn(o.minUnit,e,i,this._getLabelCapacity(e)),a=R(n.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Ae(l)||l===!0,d={};let u=e,f,g;if(c&&(u=+t.startOf(u,"isoWeek",l)),u=+t.startOf(u,c?"day":r),t.diff(i,e,r)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+r);const p=n.ticks.source==="data"&&this.getDataTimestamps();for(f=u,g=0;f+m)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const n=this.options.time.displayFormats,o=this._unit,r=e||n[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,i,n){const o=this.options,r=o.ticks.callback;if(r)return U(r,[t,e,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,d=l&&a[l],u=c&&a[c],f=i[e],g=c&&u&&f&&f.major;return this._adapter.format(t,n||(g?u:d))}generateTickLabels(t){let e,i,n;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,i;if(t.length)return t;const n=this.getMatchingVisibleMetas();if(this._normalized&&n.length)return this._cache.data=n[0].controller.getAllParsedValues(this);for(e=0,i=n.length;e=s[i].pos&&t<=s[n].pos&&({lo:i,hi:n}=Gt(s,"pos",t)),{pos:o,time:a}=s[i],{pos:r,time:l}=s[n]):(t>=s[i].time&&t<=s[n].time&&({lo:i,hi:n}=Gt(s,"time",t)),{time:o,pos:a}=s[i],{time:r,pos:l}=s[n]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class __ extends Ln{static id="timeseries";static defaults=Ln.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=Ze(e,this.min),this._tableRange=Ze(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,n=[],o=[];let r,a,l,c,d;for(r=0,a=t.length;r=e&&c<=i&&n.push(c);if(n.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(r=0,a=n.length;rn-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return e.length&&i.length?t=this.normalize(e.concat(i)):t=e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(Ze(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return Ze(this._table,i*this._tableRange+this._minPos,!0)}}const Fo={data:{type:Object,required:!0},options:{type:Object,default:()=>({})},plugins:{type:Array,default:()=>[]},datasetIdKey:{type:String,default:"label"},updateMode:{type:String,default:void 0}},Hh={ariaLabel:{type:String},ariaDescribedby:{type:String}},jh={type:{type:String,required:!0},destroyDelay:{type:Number,default:0},...Fo,...Hh},Vh=Zo[0]==="2"?(s,t)=>Object.assign(s,{attrs:t}):(s,t)=>Object.assign(s,t);function oe(s){return Nn(s)?Ls(s):s}function Wh(s){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:s;return Nn(t)?new Proxy(s,{}):s}function Uh(s,t){const e=s.options;e&&t&&Object.assign(e,t)}function Bo(s,t){s.labels=t}function zo(s,t,e){const i=[];s.datasets=t.map(n=>{const o=s.datasets.find(r=>r[e]===n[e]);return!o||!n.data||i.includes(o)?{...n}:(i.push(o),Object.assign(o,n),o)})}function Yh(s,t){const e={labels:[],datasets:[]};return Bo(e,s.labels),zo(e,s.datasets,t),e}const Kh=Bn({props:jh,setup(s,t){let{expose:e,slots:i}=t;const n=j(null),o=zn(null);e({chart:o});const r=()=>{if(!n.value)return;const{type:c,data:d,options:u,plugins:f,datasetIdKey:g}=s,p=Yh(d,g),m=Wh(p,d);o.value=new ms(n.value,{type:c,data:m,options:{...u},plugins:f})},a=()=>{const c=Ls(o.value);c&&(s.destroyDelay>0?setTimeout(()=>{c.destroy(),o.value=null},s.destroyDelay):(c.destroy(),o.value=null))},l=c=>{c.update(s.updateMode)};return Xs(r),tr(a),fs([()=>s.options,()=>s.data],(c,d)=>{let[u,f]=c,[g,p]=d;const m=Ls(o.value);if(!m)return;let b=!1;if(u){const _=oe(u),k=oe(g);_&&_!==k&&(Uh(m,_),b=!0)}if(f){const _=oe(f.labels),k=oe(p.labels),S=oe(f.datasets),v=oe(p.datasets);_!==k&&(Bo(m.config.data,_),b=!0),S&&S!==v&&(zo(m.config.data,S,s.datasetIdKey),b=!0)}b&&er(()=>{l(m)})},{deep:!0}),()=>As("canvas",{role:"img",ariaLabel:s.ariaLabel,ariaDescribedby:s.ariaDescribedby,ref:n},[As("p",{},[i.default?i.default():""])])}});function No(s,t){return ms.register(t),Bn({props:Fo,setup(e,i){let{expose:n}=i;const o=zn(null),r=a=>{o.value=a?.chart};return n({chart:o}),()=>As(Kh,Vh({ref:r},{type:s,...e}))}})}const Jh=No("bar",yo),Xh=No("line",vo);function Lt(s){return Array.isArray?Array.isArray(s):Vo(s)==="[object Array]"}const Gh=1/0;function qh(s){if(typeof s=="string")return s;let t=s+"";return t=="0"&&1/s==-Gh?"-0":t}function Qh(s){return s==null?"":qh(s)}function wt(s){return typeof s=="string"}function Ho(s){return typeof s=="number"}function Zh(s){return s===!0||s===!1||tu(s)&&Vo(s)=="[object Boolean]"}function jo(s){return typeof s=="object"}function tu(s){return jo(s)&&s!==null}function dt(s){return s!=null}function Os(s){return!s.trim().length}function Vo(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const eu="Incorrect 'index' type",su=s=>`Invalid value for key ${s}`,iu=s=>`Pattern length exceeds max of ${s}.`,nu=s=>`Missing ${s} property in key`,ou=s=>`Property 'weight' in key '${s}' must be a positive integer`,Tn=Object.prototype.hasOwnProperty;class ru{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let n=Wo(i);this._keys.push(n),this._keyMap[n.id]=n,e+=n.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Wo(s){let t=null,e=null,i=null,n=1,o=null;if(wt(s)||Lt(s))i=s,t=In(s),e=Vs(s);else{if(!Tn.call(s,"name"))throw new Error(nu("name"));const r=s.name;if(i=r,Tn.call(s,"weight")&&(n=s.weight,n<=0))throw new Error(ou(r));t=In(r),e=Vs(r),o=s.getFn}return{path:t,id:e,weight:n,src:i,getFn:o}}function In(s){return Lt(s)?s:s.split(".")}function Vs(s){return Lt(s)?s.join("."):s}function au(s,t){let e=[],i=!1;const n=(o,r,a)=>{if(dt(o))if(!r[a])e.push(o);else{let l=r[a];const c=o[l];if(!dt(c))return;if(a===r.length-1&&(wt(c)||Ho(c)||Zh(c)))e.push(Qh(c));else if(Lt(c)){i=!0;for(let d=0,u=c.length;ds.score===t.score?s.idx{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,wt(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();wt(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e{let r=n.getFn?n.getFn(t):this.getFn(t,n.path);if(dt(r)){if(Lt(r)){let a=[];const l=[{nestedArrIndex:-1,value:r}];for(;l.length;){const{nestedArrIndex:c,value:d}=l.pop();if(dt(d))if(wt(d)&&!Os(d)){let u={v:d,i:c,n:this.norm.get(d)};a.push(u)}else Lt(d)&&d.forEach((u,f)=>{l.push({nestedArrIndex:f,value:u})})}i.$[o]=a}else if(wt(r)&&!Os(r)){let a={v:r,n:this.norm.get(r)};i.$[o]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function Uo(s,t,{getFn:e=A.getFn,fieldNormWeight:i=A.fieldNormWeight}={}){const n=new fi({getFn:e,fieldNormWeight:i});return n.setKeys(s.map(Wo)),n.setSources(t),n.create(),n}function gu(s,{getFn:t=A.getFn,fieldNormWeight:e=A.fieldNormWeight}={}){const{keys:i,records:n}=s,o=new fi({getFn:t,fieldNormWeight:e});return o.setKeys(i),o.setIndexRecords(n),o}function ts(s,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:n=A.distance,ignoreLocation:o=A.ignoreLocation}={}){const r=t/s.length;if(o)return r;const a=Math.abs(i-e);return n?r+a/n:a?1:r}function pu(s=[],t=A.minMatchCharLength){let e=[],i=-1,n=-1,o=0;for(let r=s.length;o=t&&e.push([i,n]),i=-1)}return s[o-1]&&o-i>=t&&e.push([i,o-1]),e}const Kt=32;function mu(s,t,e,{location:i=A.location,distance:n=A.distance,threshold:o=A.threshold,findAllMatches:r=A.findAllMatches,minMatchCharLength:a=A.minMatchCharLength,includeMatches:l=A.includeMatches,ignoreLocation:c=A.ignoreLocation}={}){if(t.length>Kt)throw new Error(iu(Kt));const d=t.length,u=s.length,f=Math.max(0,Math.min(i,u));let g=o,p=f;const m=a>1||l,b=m?Array(u):[];let _;for(;(_=s.indexOf(t,p))>-1;){let M=ts(t,{currentLocation:_,expectedLocation:f,distance:n,ignoreLocation:c});if(g=Math.min(M,g),p=_+d,m){let C=0;for(;C=E;Y-=1){let V=Y-1,X=e[s.charAt(V)];if(m&&(b[V]=+!!X),T[Y]=(T[Y+1]<<1|1)&X,M&&(T[Y]|=(k[Y+1]|k[Y])<<1|1|k[Y+1]),T[Y]&x&&(S=ts(t,{errors:M,currentLocation:V,expectedLocation:f,distance:n,ignoreLocation:c}),S<=g)){if(g=S,p=V,p<=f)break;E=Math.max(1,2*f-p)}}if(ts(t,{errors:M+1,currentLocation:f,expectedLocation:f,distance:n,ignoreLocation:c})>g)break;k=T}const P={isMatch:p>=0,score:Math.max(.001,S)};if(m){const M=pu(b,a);M.length?l&&(P.indices=M):P.isMatch=!1}return P}function bu(s){let t={};for(let e=0,i=s.length;e{this.chunks.push({pattern:f,alphabet:bu(f),startIndex:g})},u=this.pattern.length;if(u>Kt){let f=0;const g=u%Kt,p=u-g;for(;f{const{isMatch:_,score:k,indices:S}=mu(t,p,m,{location:n+b,distance:o,threshold:r,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});_&&(f=!0),u+=k,_&&S&&(d=[...d,...S])});let g={isMatch:f,score:f?u/this.chunks.length:1};return f&&i&&(g.indices=d),g}}class zt{constructor(t){this.pattern=t}static isMultiMatch(t){return Rn(t,this.multiRegex)}static isSingleMatch(t){return Rn(t,this.singleRegex)}search(){}}function Rn(s,t){const e=s.match(t);return e?e[1]:null}class _u extends zt{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class xu extends zt{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class yu extends zt{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class vu extends zt{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class wu extends zt{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Su extends zt{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class Ko extends zt{constructor(t,{location:e=A.location,threshold:i=A.threshold,distance:n=A.distance,includeMatches:o=A.includeMatches,findAllMatches:r=A.findAllMatches,minMatchCharLength:a=A.minMatchCharLength,isCaseSensitive:l=A.isCaseSensitive,ignoreLocation:c=A.ignoreLocation}={}){super(t),this._bitapSearch=new Yo(t,{location:e,threshold:i,distance:n,includeMatches:o,findAllMatches:r,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Jo extends zt{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const n=[],o=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+o,n.push([i,e-1]);const r=!!n.length;return{isMatch:r,score:r?0:1,indices:n}}}const Ws=[_u,Jo,yu,vu,Su,wu,xu,Ko],En=Ws.length,ku=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Pu="|";function Mu(s,t={}){return s.split(Pu).map(e=>{let i=e.trim().split(ku).filter(o=>o&&!!o.trim()),n=[];for(let o=0,r=i.length;o!!(s[hs.AND]||s[hs.OR]),Ou=s=>!!s[Ks.PATH],Au=s=>!Lt(s)&&jo(s)&&!Js(s),Fn=s=>({[hs.AND]:Object.keys(s).map(t=>({[t]:s[t]}))});function Xo(s,t,{auto:e=!0}={}){const i=n=>{let o=Object.keys(n);const r=Ou(n);if(!r&&o.length>1&&!Js(n))return i(Fn(n));if(Au(n)){const l=r?n[Ks.PATH]:o[0],c=r?n[Ks.PATTERN]:n[l];if(!wt(c))throw new Error(su(l));const d={keyId:Vs(l),pattern:c};return e&&(d.searcher=Ys(c,t)),d}let a={children:[],operator:o[0]};return o.forEach(l=>{const c=n[l];Lt(c)&&c.forEach(d=>{a.children.push(i(d))})}),a};return Js(s)||(s=Fn(s)),i(s)}function Lu(s,{ignoreFieldNorm:t=A.ignoreFieldNorm}){s.forEach(e=>{let i=1;e.matches.forEach(({key:n,norm:o,score:r})=>{const a=n?n.weight:null;i*=Math.pow(r===0&&a?Number.EPSILON:r,(a||1)*(t?1:o))}),e.score=i})}function Tu(s,t){const e=s.matches;t.matches=[],dt(e)&&e.forEach(i=>{if(!dt(i.indices)||!i.indices.length)return;const{indices:n,value:o}=i;let r={indices:n,value:o};i.key&&(r.key=i.key.src),i.idx>-1&&(r.refIndex=i.idx),t.matches.push(r)})}function Iu(s,t){t.score=s.score}function Ru(s,t,{includeMatches:e=A.includeMatches,includeScore:i=A.includeScore}={}){const n=[];return e&&n.push(Tu),i&&n.push(Iu),s.map(o=>{const{idx:r}=o,a={item:t[r],refIndex:r};return n.length&&n.forEach(l=>{l(o,a)}),a})}class ue{constructor(t,e={},i){this.options={...A,...e},this.options.useExtendedSearch,this._keyStore=new ru(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof fi))throw new Error(eu);this._myIndex=e||Uo(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){dt(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,n=this._docs.length;i-1&&(l=l.slice(0,e)),Ru(l,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(t){const e=Ys(t,this.options),{records:i}=this._myIndex,n=[];return i.forEach(({v:o,i:r,n:a})=>{if(!dt(o))return;const{isMatch:l,score:c,indices:d}=e.searchIn(o);l&&n.push({item:o,idx:r,matches:[{score:c,value:o,norm:a,indices:d}]})}),n}_searchLogical(t){const e=Xo(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:u,searcher:f}=a,g=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:f});return g&&g.length?[{idx:c,item:l,matches:g}]:[]}const d=[];for(let u=0,f=a.children.length;u{if(dt(a)){let c=i(e,a,l);c.length&&(o[l]||(o[l]={idx:l,item:a,matches:[]},r.push(o[l])),c.forEach(({matches:d})=>{o[l].matches.push(...d)}))}}),r}_searchObjectList(t){const e=Ys(t,this.options),{keys:i,records:n}=this._myIndex,o=[];return n.forEach(({$:r,i:a})=>{if(!dt(r))return;let l=[];i.forEach((c,d)=>{l.push(...this._findMatches({key:c,value:r[d],searcher:e}))}),l.length&&o.push({idx:a,item:r,matches:l})}),o}_findMatches({key:t,value:e,searcher:i}){if(!dt(e))return[];let n=[];if(Lt(e))e.forEach(({v:o,i:r,n:a})=>{if(!dt(o))return;const{isMatch:l,score:c,indices:d}=i.searchIn(o);l&&n.push({score:c,key:t,value:o,idx:r,norm:a,indices:d})});else{const{v:o,n:r}=e,{isMatch:a,score:l,indices:c}=i.searchIn(o);a&&n.push({score:l,key:t,value:o,norm:r,indices:c})}return n}}ue.version="7.0.0";ue.createIndex=Uo;ue.parseIndex=gu;ue.config=A;ue.parseQuery=Xo;Du($u);const Eu={name:"peerSettings",components:{LocaleText:D},props:{selectedPeer:Object},data(){return{data:void 0,dataChanged:!1,showKey:!1,saving:!1}},setup(){return{dashboardConfigurationStore:Pt()}},methods:{reset(){this.selectedPeer&&(this.data=JSON.parse(JSON.stringify(this.selectedPeer)),this.dataChanged=!1)},savePeer(){this.saving=!0,nt(`/api/updatePeerSettings/${this.$route.params.id}`,this.data,s=>{this.saving=!1,s.status?this.dashboardConfigurationStore.newMessage("Server","Peer saved","success"):this.dashboardConfigurationStore.newMessage("Server",s.message,"danger"),this.$emit("refresh")})},resetPeerData(s){this.saving=!0,nt(`/api/resetPeerData/${this.$route.params.id}`,{id:this.data.id,type:s},t=>{this.saving=!1,t.status?this.dashboardConfigurationStore.newMessage("Server","Peer data usage reset successfully","success"):this.dashboardConfigurationStore.newMessage("Server",t.message,"danger"),this.$emit("refresh")})}},beforeMount(){this.reset()},mounted(){this.$el.querySelectorAll("input").forEach(s=>{s.addEventListener("keyup",()=>{this.dataChanged=!0})})}},Fu={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},Bu={class:"container d-flex h-100 w-100"},zu={class:"m-auto modal-dialog-centered dashboardModal"},Nu={class:"card rounded-3 shadow flex-grow-1"},Hu={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},ju={class:"mb-0"},Vu={key:0,class:"card-body px-4 pb-4"},Wu={class:"d-flex flex-column gap-2 mb-4"},Uu={class:"d-flex align-items-center"},Yu={class:"text-muted"},Ku={class:"ms-auto"},Ju={for:"peer_name_textbox",class:"form-label"},Xu={class:"text-muted"},Gu=["disabled"],qu={class:"d-flex position-relative"},Qu={for:"peer_private_key_textbox",class:"form-label"},Zu={class:"text-muted"},tf=["type","disabled"],ef={for:"peer_allowed_ip_textbox",class:"form-label"},sf={class:"text-muted"},nf=["disabled"],of={for:"peer_endpoint_allowed_ips",class:"form-label"},rf={class:"text-muted"},af=["disabled"],lf={for:"peer_DNS_textbox",class:"form-label"},cf={class:"text-muted"},df=["disabled"],hf={class:"accordion mt-3",id:"peerSettingsAccordion"},uf={class:"accordion-item"},ff={class:"accordion-header"},gf={class:"accordion-button rounded-3 collapsed",type:"button","data-bs-toggle":"collapse","data-bs-target":"#peerSettingsAccordionOptional"},pf={id:"peerSettingsAccordionOptional",class:"accordion-collapse collapse","data-bs-parent":"#peerSettingsAccordion"},mf={class:"accordion-body d-flex flex-column gap-2 mb-2"},bf={for:"peer_preshared_key_textbox",class:"form-label"},_f={class:"text-muted"},xf=["disabled"],yf={for:"peer_mtu",class:"form-label"},vf={class:"text-muted"},wf=["disabled"],Sf={for:"peer_keep_alive",class:"form-label"},kf={class:"text-muted"},Pf=["disabled"],Mf={class:"d-flex gap-2 align-items-center"},Cf={class:"d-flex gap-2 ms-auto"},$f={class:"d-flex align-items-center gap-2"},Df=["disabled"],Of=["disabled"];function Af(s,t,e,i,n,o){const r=z("LocaleText");return w(),$("div",Fu,[h("div",Bu,[h("div",zu,[h("div",Nu,[h("div",Hu,[h("h4",ju,[y(r,{t:"Peer Settings"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),this.data?(w(),$("div",Vu,[h("div",Wu,[h("div",Uu,[h("small",Yu,[y(r,{t:"Public Key"})]),h("small",Ku,[h("samp",null,B(this.data.id),1)])]),h("div",null,[h("label",Ju,[h("small",Xu,[y(r,{t:"Name"})])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[1]||(t[1]=a=>this.data.name=a),id:"peer_name_textbox",placeholder:""},null,8,Gu),[[Z,this.data.name]])]),h("div",null,[h("div",qu,[h("label",Qu,[h("small",Zu,[y(r,{t:"Private Key"}),h("code",null,[y(r,{t:"(Required for QR Code and Download)"})])])]),h("a",{role:"button",class:"ms-auto text-decoration-none toggleShowKey",onClick:t[2]||(t[2]=a=>this.showKey=!this.showKey)},[h("i",{class:Q(["bi",[this.showKey?"bi-eye-slash-fill":"bi-eye-fill"]])},null,2)])]),K(h("input",{type:[this.showKey?"text":"password"],class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[3]||(t[3]=a=>this.data.private_key=a),id:"peer_private_key_textbox",style:{"padding-right":"40px"}},null,8,tf),[[sr,this.data.private_key]])]),h("div",null,[h("label",ef,[h("small",sf,[y(r,{t:"Allowed IPs"}),h("code",null,[y(r,{t:"(Required)"})])])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[4]||(t[4]=a=>this.data.allowed_ip=a),id:"peer_allowed_ip_textbox"},null,8,nf),[[Z,this.data.allowed_ip]])]),h("div",null,[h("label",of,[h("small",rf,[y(r,{t:"Endpoint Allowed IPs"}),h("code",null,[y(r,{t:"(Required)"})])])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[5]||(t[5]=a=>this.data.endpoint_allowed_ip=a),id:"peer_endpoint_allowed_ips"},null,8,af),[[Z,this.data.endpoint_allowed_ip]])]),h("div",null,[h("label",lf,[h("small",cf,[y(r,{t:"DNS"})])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[6]||(t[6]=a=>this.data.DNS=a),id:"peer_DNS_textbox"},null,8,df),[[Z,this.data.DNS]])]),h("div",hf,[h("div",uf,[h("h2",ff,[h("button",gf,[y(r,{t:"Optional Settings"})])]),h("div",pf,[h("div",mf,[h("div",null,[h("label",bf,[h("small",_f,[y(r,{t:"Pre-Shared Key"})])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[7]||(t[7]=a=>this.data.preshared_key=a),id:"peer_preshared_key_textbox"},null,8,xf),[[Z,this.data.preshared_key]])]),h("div",null,[h("label",yf,[h("small",vf,[y(r,{t:"MTU"})])]),K(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[8]||(t[8]=a=>this.data.mtu=a),id:"peer_mtu"},null,8,wf),[[Z,this.data.mtu]])]),h("div",null,[h("label",Sf,[h("small",kf,[y(r,{t:"Persistent Keepalive"})])]),K(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:this.saving,"onUpdate:modelValue":t[9]||(t[9]=a=>this.data.keepalive=a),id:"peer_keep_alive"},null,8,Pf),[[Z,this.data.keepalive]])])])])])]),t[18]||(t[18]=h("hr",null,null,-1)),h("div",Mf,[h("strong",null,[y(r,{t:"Reset Data Usage"})]),h("div",Cf,[h("button",{class:"btn bg-primary-subtle text-primary-emphasis rounded-3 flex-grow-1 shadow-sm",onClick:t[10]||(t[10]=a=>this.resetPeerData("total"))},[t[15]||(t[15]=h("i",{class:"bi bi-arrow-down-up me-2"},null,-1)),y(r,{t:"Total"})]),h("button",{class:"btn bg-primary-subtle text-primary-emphasis rounded-3 flex-grow-1 shadow-sm",onClick:t[11]||(t[11]=a=>this.resetPeerData("receive"))},[t[16]||(t[16]=h("i",{class:"bi bi-arrow-down me-2"},null,-1)),y(r,{t:"Received"})]),h("button",{class:"btn bg-primary-subtle text-primary-emphasis rounded-3 flex-grow-1 shadow-sm",onClick:t[12]||(t[12]=a=>this.resetPeerData("sent"))},[t[17]||(t[17]=h("i",{class:"bi bi-arrow-up me-2"},null,-1)),y(r,{t:"Sent"})])])])]),h("div",$f,[h("button",{class:"btn bg-secondary-subtle border-secondary-subtle text-secondary-emphasis rounded-3 shadow ms-auto px-3 py-2",onClick:t[13]||(t[13]=a=>this.reset()),disabled:!this.dataChanged||this.saving},t[19]||(t[19]=[h("i",{class:"bi bi-arrow-clockwise"},null,-1)]),8,Df),h("button",{class:"btn bg-primary-subtle border-primary-subtle text-primary-emphasis rounded-3 px-3 py-2 shadow",disabled:!this.dataChanged||this.saving,onClick:t[14]||(t[14]=a=>this.savePeer())},t[20]||(t[20]=[h("i",{class:"bi bi-save-fill"},null,-1)]),8,Of)])])):I("",!0)])])])])}const Lf=ut(Eu,[["render",Af],["__scopeId","data-v-a63ae8cb"]]),Tf={name:"peerQRCode",components:{LocaleText:D},props:{peerConfigData:String},mounted(){rr.toCanvas(document.querySelector("#qrcode"),this.peerConfigData,s=>{s&&console.error(s)})}},If={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0"},Rf={class:"container d-flex h-100 w-100"},Ef={class:"m-auto modal-dialog-centered dashboardModal justify-content-center"},Ff={class:"card rounded-3 shadow"},Bf={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},zf={class:"mb-0"},Nf={class:"card-body"},Hf={id:"qrcode",class:"rounded-3 shadow",ref:"qrcode"};function jf(s,t,e,i,n,o){const r=z("LocaleText");return w(),$("div",If,[h("div",Rf,[h("div",Ef,[h("div",Ff,[h("div",Bf,[h("h4",zf,[y(r,{t:"QR Code"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=a=>this.$emit("close"))})]),h("div",Nf,[h("canvas",Hf,null,512)])])])])])}const Vf=ut(Tf,[["render",jf]]),Wf={name:"scheduleDropdown",props:{options:Array,data:String,edit:!1},setup(s){s.data===void 0&&this.$emit("update",this.options[0].value)},computed:{currentSelection(){return this.options.find(s=>s.value===this.data)}}},Uf={class:"dropdown scheduleDropdown"},Yf={class:"dropdown-menu rounded-3 shadow",style:{"font-size":"0.875rem",width:"200px"}},Kf=["onClick"],Jf={key:0,class:"bi bi-check ms-auto"};function Xf(s,t,e,i,n,o){return w(),$("div",Uf,[h("button",{class:Q(["btn btn-sm btn-outline-primary rounded-3",{"disabled border-transparent":!e.edit}]),type:"button","data-bs-toggle":"dropdown","aria-expanded":"false"},[h("samp",null,B(this.currentSelection.display),1)],2),h("ul",Yf,[e.edit?(w(!0),$(lt,{key:0},Zt(this.options,r=>(w(),$("li",null,[h("a",{class:"dropdown-item d-flex align-items-center",role:"button",onClick:a=>s.$emit("update",r.value)},[h("samp",null,B(r.display),1),r.value===this.currentSelection.value?(w(),$("i",Jf)):I("",!0)],8,Kf)]))),256)):I("",!0)])])}const Go=ut(Wf,[["render",Xf],["__scopeId","data-v-6a5aba2a"]]),Gf={name:"schedulePeerJob",components:{LocaleText:D,VueDatePicker:Vn,ScheduleDropdown:Go},props:{dropdowns:Array[Object],pjob:Object,viewOnly:!1},setup(s){const t=j({}),e=j(!1),i=j(!1);t.value=JSON.parse(JSON.stringify(s.pjob)),t.value.CreationDate||(e.value=!0,i.value=!0);const n=Pt();return{job:t,edit:e,newJob:i,store:n}},data(){return{inputType:void 0}},watch:{pjob:{deep:!0,immediate:!0,handler(s){this.edit||(this.job=JSON.parse(JSON.stringify(s)))}}},methods:{save(){this.job.Field&&this.job.Operator&&this.job.Action&&this.job.Value?nt("/api/savePeerScheduleJob/",{Job:this.job},s=>{s.status?(this.edit=!1,this.store.newMessage("Server","Peer job saved","success"),console.log(s.data),this.$emit("refresh",s.data[0]),this.newJob=!1):this.store.newMessage("Server",s.message,"danger")}):this.alert()},alert(){let s="animate__flash",t=this.$el.querySelectorAll(".scheduleDropdown"),e=this.$el.querySelectorAll("input");t.forEach(i=>i.classList.add("animate__animated",s)),e.forEach(i=>i.classList.add("animate__animated",s)),setTimeout(()=>{t.forEach(i=>i.classList.remove("animate__animated",s)),e.forEach(i=>i.classList.remove("animate__animated",s))},2e3)},reset(){this.job.CreationDate?(this.job=JSON.parse(JSON.stringify(this.pjob)),this.edit=!1):this.$emit("delete")},delete(){this.job.CreationDate&&nt("/api/deletePeerScheduleJob/",{Job:this.job},s=>{s.status?this.store.newMessage("Server","Peer job deleted","success"):(this.store.newMessage("Server",s.message,"danger"),this.$emit("delete"))}),this.$emit("delete")},parseTime(s){s&&(this.job.Value=qt(s).format("YYYY-MM-DD HH:mm:ss"))}}},qf={class:"card-header bg-transparent text-muted border-0"},Qf={key:0,class:"d-flex"},Zf={class:"me-auto"},tg={key:1},eg={class:"badge text-bg-warning"},sg={class:"card-body pt-1",style:{"font-family":"var(--bs-font-monospace)"}},ig={class:"d-flex gap-2 align-items-center mb-2"},ng=["disabled"],og={class:"px-5 d-flex gap-2 align-items-center"},rg={class:"d-flex gap-3"},ag={key:0,class:"ms-auto d-flex gap-3"},lg={key:1,class:"ms-auto d-flex gap-3"};function cg(s,t,e,i,n,o){const r=z("LocaleText"),a=z("ScheduleDropdown"),l=z("VueDatePicker");return w(),$("div",{class:Q(["card shadow-sm rounded-3 mb-2",{"border-warning-subtle":this.newJob}])},[h("div",qf,[this.newJob?(w(),$("small",tg,[h("span",eg,[y(r,{t:"Unsaved Job"})])])):(w(),$("small",Qf,[h("strong",Zf,[y(r,{t:"Job ID"})]),h("samp",null,B(this.job.JobID),1)]))]),h("div",sg,[h("div",ig,[h("samp",null,[y(r,{t:"if"})]),y(a,{edit:i.edit,options:this.dropdowns.Field,data:this.job.Field,onUpdate:t[0]||(t[0]=c=>{this.job.Field=c})},null,8,["edit","options","data"]),h("samp",null,[y(r,{t:"is"})]),y(a,{edit:i.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"?(w(),H(l,{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:!i.edit,dark:this.store.Configuration.Server.dashboard_theme==="dark"},null,8,["min-date","model-value","onUpdate:modelValue","disabled","dark"])):K((w(),$("input",{key:1,class:"form-control form-control-sm form-control-dark rounded-3 flex-grow-1",disabled:!i.edit,"onUpdate:modelValue":t[2]||(t[2]=c=>this.job.Value=c),style:{width:"auto"}},null,8,ng)),[[Z,this.job.Value]]),h("samp",null,B(this.dropdowns.Field.find(c=>c.value===this.job.Field)?.unit)+" { ",1)]),h("div",og,[h("samp",null,[y(r,{t:"then"})]),y(a,{edit:i.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",rg,[t[12]||(t[12]=h("samp",null,"}",-1)),this.edit?(w(),$("div",lg,[h("a",{role:"button",class:"text-secondary text-decoration-none",onClick:t[6]||(t[6]=c=>this.reset())},[t[10]||(t[10]=et("[C] ")),y(r,{t:"Cancel"})]),h("a",{role:"button",class:"text-primary ms-auto text-decoration-none",onClick:t[7]||(t[7]=c=>this.save())},[t[11]||(t[11]=et("[S] ")),y(r,{t:"Save"})])])):(w(),$("div",ag,[h("a",{role:"button",class:"ms-auto text-decoration-none",onClick:t[4]||(t[4]=c=>this.edit=!0)},[t[8]||(t[8]=et("[E] ")),y(r,{t:"Edit"})]),h("a",{role:"button",onClick:t[5]||(t[5]=c=>this.delete()),class:"text-danger text-decoration-none"},[t[9]||(t[9]=et("[D] ")),y(r,{t:"Delete"})])]))])])],2)}const dg=ut(Gf,[["render",cg],["__scopeId","data-v-8f3f1b93"]]),hg={name:"peerJobs",setup(){return{store:us()}},props:{selectedPeer:Object},components:{LocaleText:D,SchedulePeerJob:dg,ScheduleDropdown:Go},data(){return{}},methods:{deleteJob(s){this.selectedPeer.jobs=this.selectedPeer.jobs.filter(t=>t.JobID!==s.JobID)},addJob(){this.selectedPeer.jobs.unshift(JSON.parse(JSON.stringify({JobID:ir().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})))}}},ug={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},fg={class:"container d-flex h-100 w-100"},gg={class:"m-auto modal-dialog-centered dashboardModal"},pg={class:"card rounded-3 shadow",style:{width:"700px"}},mg={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-2"},bg={class:"mb-0 fw-normal"},_g={class:"card-body px-4 pb-4 pt-2 position-relative"},xg={class:"d-flex align-items-center mb-3"},yg={class:"card shadow-sm",key:"none",style:{height:"153px"}},vg={class:"card-body text-muted text-center d-flex"},wg={class:"m-auto"};function Sg(s,t,e,i,n,o){const r=z("LocaleText"),a=z("SchedulePeerJob");return w(),$("div",ug,[h("div",fg,[h("div",gg,[h("div",pg,[h("div",mg,[h("h4",bg,[y(r,{t:"Schedule Jobs"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=l=>this.$emit("close"))})]),h("div",_g,[h("div",xg,[h("button",{class:"btn bg-primary-subtle border-1 border-primary-subtle text-primary-emphasis rounded-3 shadow",onClick:t[1]||(t[1]=l=>this.addJob())},[t[3]||(t[3]=h("i",{class:"bi bi-plus-lg me-2"},null,-1)),y(r,{t:"Job"})])]),y(Gs,{name:"schedulePeerJobTransition",tag:"div",class:"position-relative"},{default:G(()=>[(w(!0),$(lt,null,Zt(this.selectedPeer.jobs,(l,c)=>(w(),H(a,{onRefresh:t[2]||(t[2]=d=>this.$emit("refresh")),onDelete:d=>this.deleteJob(l),dropdowns:this.store.PeerScheduleJobs.dropdowns,key:l.JobID,pjob:l},null,8,["onDelete","dropdowns","pjob"]))),128)),this.selectedPeer.jobs.length===0?(w(),$("div",yg,[h("div",vg,[h("h6",wg,[y(r,{t:"This peer does not have any job yet."})])])])):I("",!0)]),_:1})])])])])])}const kg=ut(hg,[["render",Sg],["__scopeId","data-v-5bbdd42b"]]),Pg={name:"peerShareLinkModal",props:{peer:Object},components:{LocaleText:D,VueDatePicker:Vn},data(){return{dataCopy:void 0,loading:!1}},setup(){return{store:Pt()}},mounted(){this.dataCopy=JSON.parse(JSON.stringify(this.peer.ShareLink)).at(0)},watch:{"peer.ShareLink":{deep:!0,handler(s,t){t.length!==s.length&&(this.dataCopy=JSON.parse(JSON.stringify(this.peer.ShareLink)).at(0))}}},methods:{startSharing(){this.loading=!0,nt("/api/sharePeer/create",{Configuration:this.peer.configuration.Name,Peer:this.peer.id,ExpireDate:qt().add(7,"d").format("YYYY-MM-DD HH:mm:ss")},s=>{s.status?(this.peer.ShareLink=s.data,this.dataCopy=s.data.at(0)):this.store.newMessage("Server","Share link failed to create. Reason: "+s.message,"danger"),this.loading=!1})},updateLinkExpireDate(){nt("/api/sharePeer/update",this.dataCopy,s=>{s.status?(this.dataCopy=s.data.at(0),this.peer.ShareLink=s.data,this.store.newMessage("Server","Link expire date updated","success")):this.store.newMessage("Server","Link expire date failed to update. Reason: "+s.message,"danger"),this.loading=!1})},stopSharing(){this.loading=!0,this.dataCopy.ExpireDate=qt().format("YYYY-MM-DD HH:mm:ss"),this.updateLinkExpireDate()},parseTime(s){s?this.dataCopy.ExpireDate=qt(s).format("YYYY-MM-DD HH:mm:ss"):this.dataCopy.ExpireDate=void 0,this.updateLinkExpireDate()}},computed:{getUrl(){const s=this.store.getActiveCrossServer();return s?`${s.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}}},Mg={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},Cg={class:"container d-flex h-100 w-100"},$g={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"500px"}},Dg={class:"card rounded-3 shadow flex-grow-1"},Og={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},Ag={class:"mb-0"},Lg={key:0,class:"card-body px-4 pb-4"},Tg={key:0},Ig={class:"mb-3 text-muted"},Rg=["disabled"],Eg={key:1},Fg={class:"d-flex gap-2 mb-4"},Bg=["href"],zg={class:"d-flex flex-column gap-2 mb-3"},Ng=["disabled"];function Hg(s,t,e,i,n,o){const r=z("LocaleText"),a=z("VueDatePicker");return w(),$("div",Mg,[h("div",Cg,[h("div",$g,[h("div",Dg,[h("div",Og,[h("h4",Ag,[y(r,{t:"Share Peer"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:t[0]||(t[0]=l=>this.$emit("close"))})]),this.peer.ShareLink?(w(),$("div",Lg,[this.dataCopy?(w(),$("div",Eg,[h("div",Fg,[t[4]||(t[4]=h("i",{class:"bi bi-link-45deg"},null,-1)),h("a",{href:this.getUrl,class:"text-decoration-none",target:"_blank"},B(o.getUrl),9,Bg)]),h("div",zg,[h("small",null,[t[5]||(t[5]=h("i",{class:"bi bi-calendar me-2"},null,-1)),y(r,{t:"Expire At"})]),y(a,{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]=l=>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:Q({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},t[6]||(t[6]=[h("i",{class:"bi bi-send-slash-fill me-2"},null,-1)]),2),this.loading?(w(),H(r,{key:0,t:"Stop Sharing..."})):(w(),H(r,{key:1,t:"Stop Sharing"}))],8,Ng)])):(w(),$("div",Tg,[h("h6",Ig,[y(r,{t:"Currently the peer is not sharing"})]),h("button",{onClick:t[1]||(t[1]=l=>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:Q({"animate__animated animate__flash animate__infinite animate__slower":this.loading})},t[3]||(t[3]=[h("i",{class:"bi bi-send-fill me-2"},null,-1)]),2),this.loading?(w(),H(r,{key:0,t:"Sharing..."})):(w(),H(r,{key:1,t:"Start Sharing"}))],8,Rg)]))])):I("",!0)])])])])}const jg=ut(Pg,[["render",Hg]]),Vg={class:"container d-flex h-100 w-100"},Wg={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"700px"}},Ug={class:"card rounded-3 shadow flex-grow-1"},Yg={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4"},Kg={class:"mb-0"},Jg={class:"card-body px-4 pb-4"},Xg={class:"d-flex gap-2 flex-column"},Gg={class:"d-flex align-items-center"},qg={class:"text-muted"},Qg={class:"ms-auto"},Zg={class:"d-flex align-items-center"},tp={class:"text-muted"},ep={class:"ms-auto"},sp={for:"configuration_private_key",class:"form-label d-flex"},ip={class:"text-muted d-block"},np={class:"form-check form-switch ms-auto"},op=["disabled"],rp={for:"configuration_ipaddress_cidr",class:"form-label"},ap={class:"text-muted"},lp=["disabled"],cp={for:"configuration_listen_port",class:"form-label"},dp={class:"text-muted"},hp=["disabled"],up={for:"configuration_preup",class:"form-label"},fp={class:"text-muted"},gp=["disabled"],pp={for:"configuration_predown",class:"form-label"},mp={class:"text-muted"},bp=["disabled"],_p={for:"configuration_postup",class:"form-label"},xp={class:"text-muted"},yp=["disabled"],vp={for:"configuration_postdown",class:"form-label"},wp={class:"text-muted"},Sp=["disabled"],kp={class:"d-flex align-items-center gap-2 mt-4"},Pp=["disabled"],Mp=["disabled"],Cp={__name:"editConfiguration",props:{configurationInfo:Object},emits:["changed","close"],setup(s,{emit:t}){const e=s,i=us(),n=Pt(),o=j(!1),r=Ts(JSON.parse(JSON.stringify(e.configurationInfo))),a=j(!1),l=j(!1);j(!1);const c=Ts({PrivateKey:!0,IPAddress:!0,ListenPort:!0}),d=Is("editConfigurationContainer"),u=()=>{i.checkWGKeyLength(r.PrivateKey)?(c.PrivateKey=!0,r.PublicKey=window.wireguard.generatePublicKey(r.PrivateKey)):c.PrivateKey=!1},f=()=>{l.value=!1,Object.assign(r,JSON.parse(JSON.stringify(e.configurationInfo)))},g=t,p=()=>{o.value=!0,nt("/api/updateWireguardConfiguration",r,m=>{o.value=!1,m.status?(n.newMessage("Server","Configuration saved","success"),l.value=!1,g("dataChanged",m.data)):n.newMessage("Server",m.message,"danger")})};return fs(r,()=>{l.value=JSON.stringify(r)!==JSON.stringify(e.configurationInfo)},{deep:!0}),j(!1),(m,b)=>(w(),$("div",{class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll",ref_key:"editConfigurationContainer",ref:d},[h("div",Vg,[h("div",Wg,[h("div",Ug,[h("div",Yg,[h("h4",Kg,[y(D,{t:"Configuration Settings"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:b[0]||(b[0]=_=>m.$emit("close"))})]),h("div",Jg,[h("div",Xg,[h("div",Gg,[h("small",qg,[y(D,{t:"Name"})]),h("small",Qg,[h("samp",null,B(r.Name),1)])]),h("div",Zg,[h("small",tp,[y(D,{t:"Public Key"})]),h("small",ep,[h("samp",null,B(r.PublicKey),1)])]),b[15]||(b[15]=h("hr",null,null,-1)),h("div",null,[h("label",sp,[h("small",ip,[y(D,{t:"Private Key"})]),h("div",np,[K(h("input",{class:"form-check-input",type:"checkbox",role:"switch",id:"editPrivateKeySwitch","onUpdate:modelValue":b[1]||(b[1]=_=>a.value=_)},null,512),[[Hn,a.value]]),b[12]||(b[12]=h("label",{class:"form-check-label",for:"editPrivateKeySwitch"},[h("small",null,"Edit")],-1))])]),K(h("input",{type:"text",class:Q(["form-control form-control-sm rounded-3",{"is-invalid":!c.PrivateKey}]),disabled:o.value||!a.value,onKeyup:b[2]||(b[2]=_=>u()),"onUpdate:modelValue":b[3]||(b[3]=_=>r.PrivateKey=_),id:"configuration_private_key"},null,42,op),[[Z,r.PrivateKey]])]),h("div",null,[h("label",rp,[h("small",ap,[y(D,{t:"IP Address/CIDR"})])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:o.value,"onUpdate:modelValue":b[4]||(b[4]=_=>r.Address=_),id:"configuration_ipaddress_cidr"},null,8,lp),[[Z,r.Address]])]),h("div",null,[h("label",cp,[h("small",dp,[y(D,{t:"Listen Port"})])]),K(h("input",{type:"number",class:"form-control form-control-sm rounded-3",disabled:o.value,"onUpdate:modelValue":b[5]||(b[5]=_=>r.ListenPort=_),id:"configuration_listen_port"},null,8,hp),[[Z,r.ListenPort]])]),h("div",null,[h("label",up,[h("small",fp,[y(D,{t:"PreUp"})])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:o.value,"onUpdate:modelValue":b[6]||(b[6]=_=>r.PreUp=_),id:"configuration_preup"},null,8,gp),[[Z,r.PreUp]])]),h("div",null,[h("label",pp,[h("small",mp,[y(D,{t:"PreDown"})])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:o.value,"onUpdate:modelValue":b[7]||(b[7]=_=>r.PreDown=_),id:"configuration_predown"},null,8,bp),[[Z,r.PreDown]])]),h("div",null,[h("label",_p,[h("small",xp,[y(D,{t:"PostUp"})])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:o.value,"onUpdate:modelValue":b[8]||(b[8]=_=>r.PostUp=_),id:"configuration_postup"},null,8,yp),[[Z,r.PostUp]])]),h("div",null,[h("label",vp,[h("small",wp,[y(D,{t:"PostDown"})])]),K(h("input",{type:"text",class:"form-control form-control-sm rounded-3",disabled:o.value,"onUpdate:modelValue":b[9]||(b[9]=_=>r.PostDown=_),id:"configuration_postdown"},null,8,Sp),[[Z,r.PostDown]])]),h("div",kp,[h("button",{class:"btn bg-secondary-subtle border-secondary-subtle text-secondary-emphasis rounded-3 shadow ms-auto",onClick:b[10]||(b[10]=_=>f()),disabled:!l.value||o.value},b[13]||(b[13]=[h("i",{class:"bi bi-arrow-clockwise"},null,-1)]),8,Pp),h("button",{class:"btn bg-primary-subtle border-primary-subtle text-primary-emphasis rounded-3 shadow",disabled:!l.value||o.value,onClick:b[11]||(b[11]=_=>p())},b[14]||(b[14]=[h("i",{class:"bi bi-save-fill"},null,-1)]),8,Mp)])])])])])])],512))}},$p={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll",ref:"selectPeersContainer"},Dp={class:"container d-flex h-100 w-100"},Op={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"700px"}},Ap={class:"card rounded-3 shadow flex-grow-1"},Lp={class:"card-header bg-transparent d-flex align-items-center gap-2 p-4 flex-column pb-3"},Tp={class:"mb-2 w-100 d-flex"},Ip={class:"mb-0"},Rp={class:"d-flex w-100 align-items-center gap-2"},Ep={class:"d-flex gap-3"},Fp={class:"card-body px-4 flex-grow-1 d-flex gap-2 flex-column position-relative",ref:"card-body",style:{"overflow-y":"scroll"}},Bp=["onClick","disabled","data-id"],zp={key:0},Np={class:"d-flex flex-column"},Hp={class:"fw-bold"},jp={class:"text-muted"},Vp={key:1,class:"ms-auto"},Wp={key:0,class:"spinner-border spinner-border-sm",role:"status"},Up={class:"card-footer px-4 py-3 gap-2 d-flex align-items-center"},Yp=["disabled"],Kp={key:0,class:"flex-grow-1 text-center"},Jp=["disabled"],Xp={key:0,class:"flex-grow-1 text-center"},Gp=["disabled"],qp={key:0,class:"flex-grow-1 text-center"},Qp=["disabled"],Zp={__name:"selectPeers",props:{configurationPeers:Array},emits:["refresh","close"],setup(s,{emit:t}){const e=s,i=j(!1),n=j(!1),o=j([]),r=j(""),a=S=>{o.value.find(v=>v===S)?o.value=o.value.filter(v=>v!==S):o.value.push(S)},l=jn(()=>i.value||n.value?e.configurationPeers.filter(S=>o.value.find(v=>v===S.id)):r.value.length>0?e.configurationPeers.filter(S=>S.id.includes(r.value)||S.name.includes(r.value)):e.configurationPeers);fs(o,()=>{o.value.length===0&&(i.value=!1,n.value=!1)});const c=gs(),d=Pt(),u=t,f=j(!1),g=()=>{f.value=!0,nt(`/api/deletePeers/${c.params.id}`,{peers:o.value},S=>{d.newMessage("Server",S.message,S.status?"success":"danger"),S.status&&(o.value=[],i.value=!1),u("refresh"),f.value=!1})},p=Ts({success:[],failed:[]}),m=Is("card-body"),b=Is("sp"),_=async()=>{n.value=!0;for(const S of o.value)m.value.scrollTo({top:b.value.find(v=>v.dataset.id===S).offsetTop-20,behavior:"smooth"}),await At("/api/downloadPeer/"+c.params.id,{id:S},v=>{if(v.status){const x=new Blob([v.data.file],{type:"text/plain"}),P=URL.createObjectURL(x),M=`${v.data.fileName}.conf`,C=document.createElement("a");C.href=P,C.download=M,C.click(),p.success.push(S)}else p.failed.push(S)})},k=()=>{p.success=[],p.failed=[],n.value=!1};return(S,v)=>(w(),$("div",$p,[h("div",Dp,[h("div",Op,[h("div",Ap,[h("div",Lp,[h("div",Tp,[h("h4",Ip,[y(D,{t:"Select Peers"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:v[0]||(v[0]=x=>u("close"))})]),h("div",Rp,[h("div",Ep,[!n.value&&o.value.length!==s.configurationPeers.map(x=>x.id).length?(w(),$("a",{key:0,role:"button",onClick:v[1]||(v[1]=x=>o.value=s.configurationPeers.map(P=>P.id)),class:"text-decoration-none text-body"},[h("small",null,[v[9]||(v[9]=h("i",{class:"bi bi-check-all me-2"},null,-1)),y(D,{t:"Select All"})])])):I("",!0),o.value.length>0&&!n.value?(w(),$("a",{key:1,role:"button",class:"text-decoration-none text-body",onClick:v[2]||(v[2]=x=>o.value=[])},[h("small",null,[v[10]||(v[10]=h("i",{class:"bi bi-x-circle-fill me-2"},null,-1)),y(D,{t:"Clear Selection"})])])):I("",!0)]),v[11]||(v[11]=h("label",{class:"ms-auto",for:"selectPeersSearchInput"},[h("i",{class:"bi bi-search"})],-1)),K(h("input",{class:"form-control form-control-sm rounded-3","onUpdate:modelValue":v[3]||(v[3]=x=>r.value=x),id:"selectPeersSearchInput",style:{width:"200px !important"},type:"text"},null,512),[[Z,r.value]])])]),h("div",Fp,[(w(!0),$(lt,null,Zt(l.value,x=>(w(),$("button",{type:"button",class:Q(["btn w-100 peerBtn text-start rounded-3 d-flex align-items-center gap-3",{active:o.value.find(P=>P===x.id)}]),onClick:P=>a(x.id),key:x.id,disabled:i.value||n.value,ref_for:!0,ref:"sp","data-id":x.id},[n.value?I("",!0):(w(),$("span",zp,[h("i",{class:Q(["bi",[o.value.find(P=>P===x.id)?"bi-check-circle-fill":"bi-circle"]])},null,2)])),h("span",Np,[h("small",Hp,B(x.name?x.name:"Untitled Peer"),1),h("small",jp,[h("samp",null,B(x.id),1)])]),n.value?(w(),$("span",Vp,[!p.success.find(P=>P===x.id)&&!p.failed.find(P=>P===x.id)?(w(),$("span",Wp)):(w(),$("i",{key:1,class:Q(["bi",[p.failed.find(P=>P===x.id)?"bi-x-circle-fill":"bi-check-circle-fill"]])},null,2))])):I("",!0)],10,Bp))),128))],512),h("div",Up,[!i.value&&!n.value?(w(),$(lt,{key:0},[h("button",{class:"btn bg-primary-subtle text-primary-emphasis border-primary-subtle rounded-3",disabled:o.value.length===0||f.value,onClick:v[4]||(v[4]=x=>_())},v[12]||(v[12]=[h("i",{class:"bi bi-download"},null,-1)]),8,Yp),o.value.length>0?(w(),$("span",Kp,[v[13]||(v[13]=h("i",{class:"bi bi-check-circle-fill me-2"},null,-1)),y(D,{t:o.value.length+" Peer"+(o.value.length>1?"s":"")},null,8,["t"])])):I("",!0),h("button",{class:"btn bg-danger-subtle text-danger-emphasis border-danger-subtle ms-auto rounded-3",onClick:v[5]||(v[5]=x=>i.value=!0),disabled:o.value.length===0||f.value},v[14]||(v[14]=[h("i",{class:"bi bi-trash"},null,-1)]),8,Jp)],64)):n.value?(w(),$(lt,{key:1},[p.failed.length+p.success.length1?"s":"")},null,8,["t"]),v[16]||(v[16]=et("... "))])):(w(),$(lt,{key:1},[h("strong",null,[y(D,{t:"Download Finished"})]),h("button",{onClick:v[6]||(v[6]=x=>k()),class:"btn bg-secondary-subtle text-secondary-emphasis border border-secondary-subtle rounded-3 ms-auto"},[y(D,{t:"Done"})])],64))],64)):i.value?(w(),$(lt,{key:2},[h("button",{class:"btn btn-danger rounded-3",disabled:o.value.length===0||f.value,onClick:v[7]||(v[7]=x=>g())},[y(D,{t:"Yes"})],8,Gp),o.value.length>0?(w(),$("strong",qp,[y(D,{t:"Are you sure to delete"}),v[17]||(v[17]=et()),y(D,{t:o.value.length+" Peer"+(o.value.length>1?"s":"")},null,8,["t"]),v[18]||(v[18]=et("? "))])):I("",!0),h("button",{class:"btn bg-secondary-subtle text-secondary-emphasis border border-secondary-subtle ms-auto rounded-3",disabled:o.value.length===0||f.value,onClick:v[8]||(v[8]=x=>i.value=!1)},[y(D,{t:"No"})],8,Qp)],64)):I("",!0)])])])])],512))}},tm=ut(Zp,[["__scopeId","data-v-177407c1"]]),em={class:"card my-0 rounded-3"},sm={class:"card-body position-relative"},im={key:0,class:"position-absolute w-100 h-100 confirmationContainer start-0 top-0 rounded-3 d-flex p-2"},nm={class:"m-auto"},om={class:"d-flex gap-2 align-items-center justify-content-center"},rm=["disabled"],am=["disabled"],lm={key:0,class:"position-absolute w-100 h-100 confirmationContainer start-0 top-0 rounded-3 d-flex p-2"},cm={class:"m-auto"},dm={class:"d-flex gap-2 align-items-center justify-content-center"},hm=["disabled"],um=["disabled"],fm={class:"d-flex gap-3"},gm={class:"d-flex flex-column"},pm={class:"text-muted"},mm={class:"d-flex flex-column"},bm={class:"text-muted"},_m={class:"d-flex gap-2 align-items-center ms-auto"},xm={class:"card rounded-3"},ym={key:0,class:"card-body"},vm=["value"],wm={class:"d-flex"},Sm={__name:"backup",props:["b","delay"],emits:["refresh","refreshPeersList"],setup(s,{emit:t}){nr(g=>({"6919ade8":u.value}));const e=s,i=j(!1),n=j(!1),o=gs(),r=t,a=Pt(),l=j(!1),c=()=>{l.value=!0,nt("/api/deleteWireguardConfigurationBackup",{configurationName:o.params.id,backupFileName:e.b.filename},g=>{l.value=!1,g.status?(r("refresh"),a.newMessage("Server","Backup deleted","success")):a.newMessage("Server","Backup failed to delete","danger")})},d=()=>{l.value=!0,nt("/api/restoreWireguardConfigurationBackup",{configurationName:o.params.id,backupFileName:e.b.filename},g=>{l.value=!1,n.value=!1,g.status?(r("refresh"),a.newMessage("Server","Backup restored with "+e.b.filename,"success")):a.newMessage("Server","Backup failed to restore","danger")})},u=jn(()=>e.delay+"s"),f=j(!1);return(g,p)=>(w(),$("div",em,[h("div",sm,[y(rt,{name:"zoomReversed"},{default:G(()=>[i.value?(w(),$("div",im,[h("div",nm,[h("h5",null,[y(D,{t:"Are you sure to delete this backup?"})]),h("div",om,[h("button",{class:"btn btn-danger rounded-3",disabled:l.value,onClick:p[0]||(p[0]=m=>c())},[y(D,{t:"Yes"})],8,rm),h("button",{onClick:p[1]||(p[1]=m=>i.value=!1),disabled:l.value,class:"btn bg-secondary-subtle text-secondary-emphasis border-secondary-subtle rounded-3"},[y(D,{t:"No"})],8,am)])])])):I("",!0)]),_:1}),y(rt,{name:"zoomReversed"},{default:G(()=>[n.value?(w(),$("div",lm,[h("div",cm,[h("h5",null,[y(D,{t:"Are you sure to restore this backup?"})]),h("div",dm,[h("button",{disabled:l.value,onClick:p[2]||(p[2]=m=>d()),class:"btn btn-success rounded-3"},[y(D,{t:"Yes"})],8,hm),h("button",{onClick:p[3]||(p[3]=m=>n.value=!1),disabled:l.value,class:"btn bg-secondary-subtle text-secondary-emphasis border-secondary-subtle rounded-3"},[y(D,{t:"No"})],8,um)])])])):I("",!0)]),_:1}),h("div",fm,[h("div",gm,[h("small",pm,[y(D,{t:"Backup"})]),h("samp",null,B(s.b.filename),1)]),h("div",mm,[h("small",bm,[y(D,{t:"Backup Date"})]),et(" "+B(ns(qt)(s.b.backupDate,"YYYYMMDDHHmmss").format("YYYY-MM-DD HH:mm:ss")),1)]),h("div",_m,[h("button",{onClick:p[4]||(p[4]=m=>n.value=!0),class:"btn bg-warning-subtle text-warning-emphasis border-warning-subtle rounded-3 btn-sm"},p[7]||(p[7]=[h("i",{class:"bi bi-clock-history"},null,-1)])),h("button",{onClick:p[5]||(p[5]=m=>i.value=!0),class:"btn bg-danger-subtle text-danger-emphasis border-danger-subtle rounded-3 btn-sm"},p[8]||(p[8]=[h("i",{class:"bi bi-trash-fill"},null,-1)]))])]),p[12]||(p[12]=h("hr",null,null,-1)),h("div",xm,[h("a",{role:"button",class:Q(["card-header d-flex text-decoration-none align-items-center",{"border-bottom-0":!f.value}]),style:{cursor:"pointer"},onClick:p[6]||(p[6]=m=>f.value=!f.value)},[h("small",null,[p[9]||(p[9]=et(".conf ")),y(D,{t:"File"})]),p[10]||(p[10]=h("i",{class:"bi bi-chevron-down ms-auto"},null,-1))],2),f.value?(w(),$("div",ym,[h("textarea",{class:"form-control rounded-3",value:s.b.content,disabled:"",style:{height:"300px","font-family":"var(--bs-font-monospace),sans-serif !important"}},null,8,vm)])):I("",!0)]),p[13]||(p[13]=h("hr",null,null,-1)),h("div",wm,[h("span",null,[p[11]||(p[11]=h("i",{class:"bi bi-database me-1"},null,-1)),y(D,{t:"Database File"})]),h("i",{class:Q(["bi ms-auto",[s.b.database?"text-success bi-check-circle-fill":"text-danger bi-x-circle-fill"]])},null,2)])])]))}},km=ut(Sm,[["__scopeId","data-v-a575be12"]]),Pm={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll",ref:"editConfigurationContainer"},Mm={class:"d-flex h-100 w-100"},Cm={class:"modal-dialog-centered dashboardModal w-100 h-100 overflow-x-scroll flex-column gap-3 mx-3"},$m={class:"my-5 d-flex gap-3 flex-column position-relative"},Dm={class:"title"},Om={class:"d-flex mb-3"},Am={class:"mb-0"},Lm={class:"position-relative d-flex flex-column gap-3"},Tm={class:"text-center title",key:"spinner"},Im={class:"card my-0 rounded-3",key:"noBackups"},Rm={class:"card-body text-center text-muted"},Em={__name:"configurationBackupRestore",emits:["close","refreshPeersList"],setup(s,{emit:t}){const e=gs(),i=j([]),n=j(!0),o=t;Xs(()=>{r()});const r=()=>{n.value=!0,At("/api/getWireguardConfigurationBackup",{configurationName:e.params.id},l=>{i.value=l.data,n.value=!1})},a=()=>{At("/api/createWireguardConfigurationBackup",{configurationName:e.params.id},l=>{i.value=l.data,n.value=!1})};return(l,c)=>(w(),$("div",Pm,[h("div",Mm,[h("div",Cm,[h("div",$m,[h("div",Dm,[h("div",Om,[h("h4",Am,[y(D,{t:"Backup & Restore"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:c[0]||(c[0]=d=>l.$emit("close"))})]),h("button",{onClick:c[1]||(c[1]=d=>a()),class:"btn bg-primary-subtle text-primary-emphasis border-primary-subtle rounded-3 w-100"},[c[4]||(c[4]=h("i",{class:"bi bi-plus-circle-fill me-2"},null,-1)),y(D,{t:"Create Backup"})])]),h("div",Lm,[y(Gs,{name:"list1"},{default:G(()=>[n.value&&i.value.length===0?(w(),$("div",Tm,c[5]||(c[5]=[h("div",{class:"spinner-border"},null,-1)]))):!n.value&&i.value.length===0?(w(),$("div",Im,[h("div",Rm,[c[6]||(c[6]=h("i",{class:"bi bi-x-circle-fill me-2"},null,-1)),y(D,{t:"No backup yet, click the button above to create backup."})])])):I("",!0),(w(!0),$(lt,null,Zt(i.value,(d,u)=>(w(),H(km,{onRefresh:c[2]||(c[2]=f=>r()),onRefreshPeersList:c[3]||(c[3]=f=>o("refreshPeersList")),b:d,delay:u*.05,key:d.filename},null,8,["b","delay"]))),128))]),_:1})])])])])],512))}},Fm=ut(Em,[["__scopeId","data-v-0b159317"]]),Bm={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},zm={class:"container d-flex h-100 w-100"},Nm={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"700px"}},Hm={class:"card rounded-3 shadow flex-grow-1 bg-danger-subtle border-danger-subtle",id:"deleteConfigurationContainer"},jm={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},Vm={class:"mb-0"},Wm={class:"card-body px-4 text-muted"},Um={class:"mb-0"},Ym={key:0},Km={key:1},Jm={key:2,class:"d-flex align-items-center gap-2"},Xm=["placeholder"],Gm=["disabled"],qm={__name:"deleteConfiguration",emits:["backup"],setup(s,{emit:t}){const i=gs().params.id,n=j(""),o=or(),r=Pt(),a=j(!1),l=()=>{clearInterval(r.Peers.RefreshInterval),a.value=!0,nt("/api/deleteWireguardConfiguration",{Name:i},g=>{g.status?(o.push("/"),r.newMessage("Server","Configuration deleted","success")):a.value=!1})},c=j(!0),d=j([]),u=()=>{c.value=!0,At("/api/getWireguardConfigurationBackup",{configurationName:i},g=>{d.value=g.data,c.value=!1})};Xs(()=>{u()});const f=t;return(g,p)=>(w(),$("div",Bm,[h("div",zm,[h("div",Nm,[h("div",Hm,[h("div",jm,[h("h5",Vm,[y(D,{t:"Are you sure to delete this configuration?"})]),h("button",{type:"button",class:"btn-close ms-auto",onClick:p[0]||(p[0]=m=>g.$emit("close"))})]),h("div",Wm,[h("p",Um,[y(D,{t:"Once you deleted this configuration:"})]),h("ul",null,[h("li",null,[y(D,{t:"All connected peers will get disconnected"})]),h("li",null,[y(D,{t:"Both configuration file (.conf) and database table related to this configuration will get deleted"})])]),h("div",{class:Q(["alert",[c.value?"alert-secondary":d.value.length>0?"alert-success":"alert-danger"]])},[c.value?(w(),$("div",Ym,[p[5]||(p[5]=h("i",{class:"bi bi-search me-2"},null,-1)),y(D,{t:"Checking backups..."})])):d.value.length>0?(w(),$("div",Km,[p[6]||(p[6]=h("i",{class:"bi bi-check-circle-fill me-2"},null,-1)),y(D,{t:"This configuration have "+d.value.length+" backups"},null,8,["t"])])):(w(),$("div",Jm,[p[9]||(p[9]=h("i",{class:"bi bi-x-circle-fill me-2"},null,-1)),y(D,{t:"This configuration have no backup"}),h("a",{role:"button",onClick:p[1]||(p[1]=m=>f("backup")),class:"ms-auto btn btn-sm btn-primary rounded-3"},[p[7]||(p[7]=h("i",{class:"bi bi-clock-history me-2"},null,-1)),y(D,{t:"Backup"})]),h("a",{role:"button",onClick:p[2]||(p[2]=m=>u()),class:"btn btn-sm btn-primary rounded-3"},p[8]||(p[8]=[h("i",{class:"bi bi-arrow-clockwise"},null,-1)]))]))],2),p[11]||(p[11]=h("hr",null,null,-1)),h("p",null,[y(D,{t:"If you're sure, please type in the configuration name below and click Delete"})]),K(h("input",{class:"form-control rounded-3 mb-3",placeholder:ns(i),"onUpdate:modelValue":p[3]||(p[3]=m=>n.value=m),type:"text"},null,8,Xm),[[Z,n.value]]),h("button",{class:"btn btn-danger w-100",onClick:p[4]||(p[4]=m=>l()),disabled:n.value!==ns(i)||a.value},[p[10]||(p[10]=h("i",{class:"bi bi-trash-fill me-2 rounded-3"},null,-1)),y(D,{t:"Delete"})],8,Gm)])])])])]))}};ms.register(ah,gh,yo,vo,Fh,yh,wh,Oh,Ih,lh);const Qm={name:"peerList",components:{DeleteConfiguration:qm,ConfigurationBackupRestore:Fm,SelectPeers:tm,EditConfiguration:Cp,LocaleText:D,PeerShareLinkModal:jg,PeerJobsLogsModal:gi(()=>pi(()=>import("./peerJobsLogsModal.js"),__vite__mapDeps([0,1,2,3,4]))),PeerJobsAllModal:gi(()=>pi(()=>import("./peerJobsAllModal.js"),__vite__mapDeps([5,2,3,4,1,6,7,8,9,10]))),PeerJobs:kg,PeerCreate:ar,PeerQRCode:Vf,PeerSettings:Lf,PeerSearch:jr,Peer:Ma,Line:Xh,Bar:Jh},setup(){const s=Pt(),t=us(),e=j(void 0);return{dashboardConfigurationStore:s,wireguardConfigurationStore:t,interval:e}},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},editConfiguration:{modalOpen:!1},selectPeers:{modalOpen:!1},backupRestore:{modalOpen:!1},deleteConfiguration:{modalOpen:!1}}},mounted(){},watch:{$route:{immediate:!0,handler(){clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval),this.loading=!0;let s=this.$route.params.id;this.configurationInfo=[],this.configurationPeers=[],s&&(this.getPeers(s),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,At("/api/toggleWireguardConfiguration/",{configurationName:this.configurationInfo.Name},s=>{s.status?this.dashboardConfigurationStore.newMessage("Server",`${this.configurationInfo.Name} ${s.data?"is on":"is off"}`,"success"):this.dashboardConfigurationStore.newMessage("Server",s.message,"danger"),this.configurationInfo.Status=s.data,this.configurationToggling=!1})},getPeers(s=this.$route.params.id){At("/api/getWireguardConfigurationInfo",{configurationName:s},t=>{if(this.configurationInfo=t.data.configurationInfo,this.configurationPeers=t.data.configurationPeers,this.configurationPeers.forEach(e=>{e.restricted=!1}),t.data.configurationRestrictedPeers.forEach(e=>{e.restricted=!0,this.configurationPeers.push(e)}),this.loading=!1,this.configurationPeers.length>0){const e=this.configurationPeers.map(n=>n.total_sent+n.cumu_sent).reduce((n,o)=>n+o).toFixed(4),i=this.configurationPeers.map(n=>n.total_receive+n.cumu_receive).reduce((n,o)=>n+o).toFixed(4);this.historyDataSentDifference[this.historyDataSentDifference.length-1]!==e&&(this.historyDataSentDifference.length>0&&(this.historySentData={labels:[...this.historySentData.labels,qt().format("HH:mm:ss A")],datasets:[{label:"Data Sent",data:[...this.historySentData.datasets[0].data,((e-this.historyDataSentDifference[this.historyDataSentDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#198754",tension:0}]}),this.historyDataSentDifference.push(e)),this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1]!==i&&(this.historyDataReceivedDifference.length>0&&(this.historyReceiveData={labels:[...this.historyReceiveData.labels,qt().format("HH:mm:ss A")],datasets:[{label:"Data Received",data:[...this.historyReceiveData.datasets[0].data,((i-this.historyDataReceivedDifference[this.historyDataReceivedDifference.length-1])*1e3).toFixed(4)],fill:!1,borderColor:"#0d6efd",tension:0}]}),this.historyDataReceivedDifference.push(i))}})},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,e)=>t+e,0).toFixed(4):0,totalReceive:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_receive+t.cumu_receive).reduce((t,e)=>t+e,0).toFixed(4):0,totalSent:this.configurationPeers.length>0?this.configurationPeers.filter(t=>!t.restricted).map(t=>t.total_sent+t.cumu_sent).reduce((t,e)=>t+e,0).toFixed(4):0}},receiveData(){return this.historyReceiveData},sentData(){return this.historySentData},individualDataUsage(){return{labels:this.configurationPeers.map(s=>s.name?s.name:`Untitled Peer - ${s.id}`),datasets:[{label:"Total Data Usage",data:this.configurationPeers.map(s=>s.cumu_data+s.total_data),backgroundColor:this.configurationPeers.map(s=>"#0dcaf0"),tooltip:{callbacks:{label:s=>`${s.formattedValue} GB`}}}]}},individualDataUsageChartOption(){return{responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(s,t)=>`${s} GB`},grid:{display:!1}}}}},chartOptions(){return{responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:s=>`${s.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(s,t)=>`${s} MB/s`},grid:{display:!1}}}}},searchPeers(){new ue(this.configurationPeers,{keys:["name","id","allowed_ip"]});const s=this.wireguardConfigurationStore.searchString?this.configurationPeers.filter(t=>t.name.includes(this.wireguardConfigurationStore.searchString)||t.id.includes(this.wireguardConfigurationStore.searchString)||t.allowed_ip.includes(this.wireguardConfigurationStore.searchString)):this.configurationPeers;return this.dashboardConfigurationStore.Configuration.Server.dashboard_sort==="restricted"?s.slice().sort((t,e)=>t[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]e[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?-1:0):s.slice().sort((t,e)=>t[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]e[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]?1:0)}}},Zm={key:0,class:"container-md"},tb={class:"d-flex align-items-center"},eb={CLASS:"text-muted"},sb={class:"d-flex align-items-center gap-3"},ib={class:"mb-0 display-4"},nb={class:"card rounded-3 bg-transparent shadow-sm ms-auto"},ob={class:"card-body py-2 d-flex align-items-center"},rb={class:"mb-0 text-muted"},ab={class:"form-check form-switch ms-auto"},lb=["for"],cb={key:4,class:"spinner-border spinner-border-sm ms-2","aria-hidden":"true"},db=["disabled","id"],hb={class:"row mt-3 gy-2 gx-2 mb-2"},ub={class:"col-12 col-lg-3"},fb={class:"card rounded-3 bg-transparent shadow-sm"},gb={class:"card-body py-2"},pb={class:"mb-0 text-muted"},mb={class:"col-12 col-lg-3"},bb={class:"card rounded-3 bg-transparent shadow-sm"},_b={class:"card-body py-2"},xb={class:"mb-0 text-muted"},yb={style:{"word-break":"break-all"},class:"col-12 col-lg-6"},vb={class:"card rounded-3 bg-transparent shadow-sm"},wb={class:"card-body py-2"},Sb={class:"mb-0 text-muted"},kb={class:"row gx-2 gy-2 mb-2"},Pb={class:"col-12 col-lg-3"},Mb={class:"card rounded-3 bg-transparent shadow-sm"},Cb={class:"card-body d-flex"},$b={class:"mb-0 text-muted"},Db={class:"h4"},Ob={class:"col-12 col-lg-3"},Ab={class:"card rounded-3 bg-transparent shadow-sm"},Lb={class:"card-body d-flex"},Tb={class:"mb-0 text-muted"},Ib={class:"h4"},Rb={class:"col-12 col-lg-3"},Eb={class:"card rounded-3 bg-transparent shadow-sm"},Fb={class:"card-body d-flex"},Bb={class:"mb-0 text-muted"},zb={class:"h4 text-primary"},Nb={class:"col-12 col-lg-3"},Hb={class:"card rounded-3 bg-transparent shadow-sm"},jb={class:"card-body d-flex"},Vb={class:"mb-0 text-muted"},Wb={class:"h4 text-success"},Ub={class:"row gx-2 gy-2 mb-3"},Yb={class:"col-12 col-lg-6"},Kb={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},Jb={class:"card-header bg-transparent border-0"},Xb={class:"text-muted"},Gb={class:"card-body pt-1"},qb={class:"col-sm col-lg-3"},Qb={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},Zb={class:"card-header bg-transparent border-0"},t_={class:"text-muted"},e_={class:"card-body pt-1"},s_={class:"col-sm col-lg-3"},i_={class:"card rounded-3 bg-transparent shadow-sm",style:{height:"270px"}},n_={class:"card-header bg-transparent border-0"},o_={class:"text-muted"},r_={class:"card-body pt-1"},a_={class:"mb-3"};function l_(s,t,e,i,n,o){const r=z("LocaleText"),a=z("Bar"),l=z("Line"),c=z("PeerSearch"),d=z("Peer"),u=z("PeerSettings"),f=z("PeerQRCode"),g=z("PeerJobs"),p=z("PeerJobsAllModal"),m=z("PeerJobsLogsModal"),b=z("PeerShareLinkModal"),_=z("EditConfiguration"),k=z("SelectPeers"),S=z("DeleteConfiguration"),v=z("ConfigurationBackupRestore");return this.loading?I("",!0):(w(),$("div",Zm,[h("div",tb,[h("div",null,[h("small",eb,[y(r,{t:"CONFIGURATION"})]),h("div",sb,[h("h1",ib,[h("samp",null,B(this.configurationInfo.Name),1)])])]),h("div",nb,[h("div",ob,[h("div",null,[h("p",rb,[h("small",null,[y(r,{t:"Status"})])]),h("div",ab,[h("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+this.configurationInfo.id},[!this.configurationInfo.Status&&this.configurationToggling?(w(),H(r,{key:0,t:"Turning Off..."})):this.configurationInfo.Status&&this.configurationToggling?(w(),H(r,{key:1,t:"Turning On..."})):this.configurationInfo.Status&&!this.configurationToggling?(w(),H(r,{key:2,t:"On"})):!this.configurationInfo.Status&&!this.configurationToggling?(w(),H(r,{key:3,t:"Off"})):I("",!0),this.configurationToggling?(w(),$("span",cb)):I("",!0)],8,lb),K(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]=x=>this.toggle()),"onUpdate:modelValue":t[1]||(t[1]=x=>this.configurationInfo.Status=x)},null,40,db),[[Hn,this.configurationInfo.Status]])])]),h("div",{class:Q(["dot ms-5",{active:this.configurationInfo.Status}])},null,2)])])]),t[31]||(t[31]=h("hr",null,null,-1)),h("div",hb,[h("div",ub,[h("div",fb,[h("div",gb,[h("p",pb,[h("small",null,[y(r,{t:"Address"})])]),et(" "+B(this.configurationInfo.Address),1)])])]),h("div",mb,[h("div",bb,[h("div",_b,[h("p",xb,[h("small",null,[y(r,{t:"Listen Port"})])]),et(" "+B(this.configurationInfo.ListenPort),1)])])]),h("div",yb,[h("div",vb,[h("div",wb,[h("p",Sb,[h("small",null,[y(r,{t:"Public Key"})])]),h("samp",null,B(this.configurationInfo.PublicKey),1)])])])]),h("div",kb,[h("div",Pb,[h("div",Mb,[h("div",Cb,[h("div",null,[h("p",$b,[h("small",null,[y(r,{t:"Connected Peers"})])]),h("strong",Db,B(o.configurationSummary.connectedPeers)+" / "+B(n.configurationPeers.length),1)]),t[27]||(t[27]=h("i",{class:"bi bi-ethernet ms-auto h2 text-muted"},null,-1))])])]),h("div",Ob,[h("div",Ab,[h("div",Lb,[h("div",null,[h("p",Tb,[h("small",null,[y(r,{t:"Total Usage"})])]),h("strong",Ib,B(o.configurationSummary.totalUsage)+" GB",1)]),t[28]||(t[28]=h("i",{class:"bi bi-arrow-down-up ms-auto h2 text-muted"},null,-1))])])]),h("div",Rb,[h("div",Eb,[h("div",Fb,[h("div",null,[h("p",Bb,[h("small",null,[y(r,{t:"Total Received"})])]),h("strong",zb,B(o.configurationSummary.totalReceive)+" GB",1)]),t[29]||(t[29]=h("i",{class:"bi bi-arrow-down ms-auto h2 text-muted"},null,-1))])])]),h("div",Nb,[h("div",Hb,[h("div",jb,[h("div",null,[h("p",Vb,[h("small",null,[y(r,{t:"Total Sent"})])]),h("strong",Wb,B(o.configurationSummary.totalSent)+" GB",1)]),t[30]||(t[30]=h("i",{class:"bi bi-arrow-up ms-auto h2 text-muted"},null,-1))])])])]),h("div",Ub,[h("div",Yb,[h("div",Kb,[h("div",Jb,[h("small",Xb,[y(r,{t:"Peers Data Usage"})])]),h("div",Gb,[y(a,{data:o.individualDataUsage,options:o.individualDataUsageChartOption,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),h("div",qb,[h("div",Qb,[h("div",Zb,[h("small",t_,[y(r,{t:"Real Time Received Data Usage"})])]),h("div",e_,[y(l,{options:o.chartOptions,data:o.receiveData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),h("div",s_,[h("div",i_,[h("div",n_,[h("small",o_,[y(r,{t:"Real Time Sent Data Usage"})])]),h("div",r_,[y(l,{options:o.chartOptions,data:o.sentData,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])])]),h("div",a_,[y(c,{onJobsAll:t[2]||(t[2]=x=>this.peerScheduleJobsAll.modalOpen=!0),onJobLogs:t[3]||(t[3]=x=>this.peerScheduleJobsLogs.modalOpen=!0),onEditConfiguration:t[4]||(t[4]=x=>this.editConfiguration.modalOpen=!0),onSelectPeers:t[5]||(t[5]=x=>this.selectPeers.modalOpen=!0),onBackupRestore:t[6]||(t[6]=x=>this.backupRestore.modalOpen=!0),onDeleteConfiguration:t[7]||(t[7]=x=>this.deleteConfiguration.modalOpen=!0),configuration:this.configurationInfo},null,8,["configuration"]),y(Gs,{name:"list",tag:"div",class:"row gx-2 gy-2 z-0"},{default:G(()=>[(w(!0),$(lt,null,Zt(this.searchPeers,x=>(w(),$("div",{class:"col-12 col-lg-6 col-xl-4",key:x.id},[y(d,{Peer:x,onShare:P=>{this.peerShare.selectedPeer=x.id,this.peerShare.modalOpen=!0},onRefresh:t[8]||(t[8]=P=>this.getPeers()),onJobs:P=>{n.peerScheduleJobs.modalOpen=!0,n.peerScheduleJobs.selectedPeer=this.configurationPeers.find(M=>M.id===x.id)},onSetting:P=>{n.peerSetting.modalOpen=!0,n.peerSetting.selectedPeer=this.configurationPeers.find(M=>M.id===x.id)},onQrcode:t[9]||(t[9]=P=>{this.peerQRCode.peerConfigData=P,this.peerQRCode.modalOpen=!0})},null,8,["Peer","onShare","onJobs","onSetting"])]))),128))]),_:1})]),y(rt,{name:"zoom"},{default:G(()=>[this.peerSetting.modalOpen?(w(),H(u,{key:"settings",selectedPeer:this.peerSetting.selectedPeer,onRefresh:t[10]||(t[10]=x=>this.getPeers()),onClose:t[11]||(t[11]=x=>this.peerSetting.modalOpen=!1)},null,8,["selectedPeer"])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[n.peerQRCode.modalOpen?(w(),H(f,{peerConfigData:this.peerQRCode.peerConfigData,key:"qrcode",onClose:t[12]||(t[12]=x=>this.peerQRCode.modalOpen=!1)},null,8,["peerConfigData"])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[this.peerScheduleJobs.modalOpen?(w(),H(g,{key:0,onRefresh:t[13]||(t[13]=x=>this.getPeers()),selectedPeer:this.peerScheduleJobs.selectedPeer,onClose:t[14]||(t[14]=x=>this.peerScheduleJobs.modalOpen=!1)},null,8,["selectedPeer"])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[this.peerScheduleJobsAll.modalOpen?(w(),H(p,{key:0,onRefresh:t[15]||(t[15]=x=>this.getPeers()),onClose:t[16]||(t[16]=x=>this.peerScheduleJobsAll.modalOpen=!1),configurationPeers:this.configurationPeers},null,8,["configurationPeers"])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[this.peerScheduleJobsLogs.modalOpen?(w(),H(m,{key:0,onClose:t[17]||(t[17]=x=>this.peerScheduleJobsLogs.modalOpen=!1),configurationInfo:this.configurationInfo},null,8,["configurationInfo"])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[this.peerShare.modalOpen?(w(),H(b,{key:0,onClose:t[18]||(t[18]=x=>{this.peerShare.modalOpen=!1,this.peerShare.selectedPeer=void 0}),peer:this.configurationPeers.find(x=>x.id===this.peerShare.selectedPeer)},null,8,["peer"])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[this.editConfiguration.modalOpen?(w(),H(_,{key:0,onClose:t[19]||(t[19]=x=>this.editConfiguration.modalOpen=!1),onDataChanged:t[20]||(t[20]=x=>this.configurationInfo=x),configurationInfo:this.configurationInfo},null,8,["configurationInfo"])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[this.selectPeers.modalOpen?(w(),H(k,{key:0,onRefresh:t[21]||(t[21]=x=>this.getPeers()),configurationPeers:this.configurationPeers,onClose:t[22]||(t[22]=x=>this.selectPeers.modalOpen=!1)},null,8,["configurationPeers"])):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[n.deleteConfiguration.modalOpen?(w(),H(S,{key:0,onBackup:t[23]||(t[23]=x=>n.backupRestore.modalOpen=!0),onClose:t[24]||(t[24]=x=>n.deleteConfiguration.modalOpen=!1)})):I("",!0)]),_:1}),y(rt,{name:"zoom"},{default:G(()=>[n.backupRestore.modalOpen?(w(),H(v,{key:0,onClose:t[25]||(t[25]=x=>n.backupRestore.modalOpen=!1),onRefreshPeersList:t[26]||(t[26]=x=>this.getPeers())})):I("",!0)]),_:1})]))}const c_=ut(Qm,[["render",l_],["__scopeId","data-v-18c89b95"]]),x_=Object.freeze(Object.defineProperty({__proto__:null,default:c_},Symbol.toStringTag,{value:"Module"}));export{dg as S,x_ as p};