1import{i as A,u as w,C as R,c as T}from"./D3i8xCMy.js";import{H as q,W as F,al as N,$ as P,aC as U,d as B,bf as W,t as V,ag as D,i as o}from"./app-B8bCG1Di.js";import{M as Y}from"./E6X-yqzf.js";import{_ as j}from"./BOHH6ppL.js";import{M as C}from"./D4gKUyhw.js";import{_ as O}from"./GMnQeWc7.js";import{a as z}from"./BPp9MNgd.js";import{b as $,u as E,e as H,g as v,l as g,c as K,a as x,C as p,j as c,s as e,q as n,A as u,B as y,H as S,h as X}from"./cXplQNgf.js";import"./DIkCtOC9.js";import"./C6RkJzSU.js";import"./j8hoE-Bf.js";import"./Dn_OK9s2.js";const G=$({__name:"MkRetentionLineChart",setup(L){A();const d=E("chartEl"),{handler:M}=w(),_=i=>{const m=i.getFullYear().toString().padStart(2,"0"),k=(i.getMonth()+1).toString().padStart(2,"0"),f=i.getDate().toString().padStart(2,"0");return`${m}/${k}/${f}`},b=i=>{const[m,k,f]=i.split("-").map(l=>parseInt(l,10));return new Date(m,k+1,f,0,0,0,0)};return H(async()=>{let i=await q("retention",{});const m=F.s.darkMode?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.2)",f=N(getComputedStyle(window.document.documentElement).getPropertyValue("--MI_THEME-accent")).toHex();d.value!=null&&new R(d.value,{type:"line",data:{labels:[],datasets:i.map((s,l)=>({label:_(new Date(s.createdAt)),pointRadius:0,borderWidth:2,borderJoinStyle:"round",borderColor:z(f,Math.min(1,(i.length-(l-1))/i.length)),fill:!1,tension:.4,data:[{x:"0",y:100,d:_(new Date(s.createdAt))},...Object.entries(s.data).sort((t,a)=>b(t[0])>b(a[0])?1:-1).map(([t,a],r)=>({x:(r+1).toString(),y:a/s.users*100,d:_(new Date(s.createdAt))}))]}))},options:{aspectRatio:2.5,layout:{padding:{left:0,right:0,top:0,bottom:0}},scales:{x:{title:{display:!0,text:"Days later"}},y:{title:{display:!0,text:"Rate (%)"},ticks:{callback:(s,l,t)=>s+"%"},min:0}},interaction:{intersect:!1},plugins:{legend:{display:!1},tooltip:{enabled:!1,callbacks:{title(s){return`${s[0].dataset.data[s[0].dataIndex].x} days later`},label(s){const l=s.dataset.data[s.dataIndex],t=Math.round(l.y)+"%";return`${l.d} ${t}`}},mode:"index",animation:{duration:0},external:M}}},plugins:[T(m)]})}),(i,m)=>(v(),g("canvas",{ref_key:"chartEl",ref:d},null,512))}}),J={class:"selects"},Q=["label"],Z={value:"federation"},tt={value:"ap-request"},et=["label"],at={value:"users"},st={value:"users-total"},ot={value:"active-users"},nt=["label"],lt={value:"notes"},rt={value:"local-notes"},it={key:0,value:"remote-notes"},ut={value:"notes-total"},ct=["label"],dt={value:"drive-files"},pt={value:"drive"},mt={value:"hour"},ht={value:"day"},vt={class:"chart _panel"},_t={key:0,value:"ap-requests-inbox-received"},ft={key:1,value:"ap-requests-deliver-succeeded"},gt={key:2,value:"ap-requests-deliver-failed"},bt={class:"pies"},kt={class:"sub"},yt={class:"pub"},Mt=500,qt=$({__name:"MkInstanceStats",setup(L){A();const d=K(()=>(B.federation!=="none"||P?.isModerator)&&U.canViewFederation),M=x("hour"),_=x("active-users"),b=x("active-users"),i=E("subDoughnutEl"),m=E("pubDoughnutEl"),{handler:k}=w({position:"middle"}),{handler:f}=w({position:"middle"});function s(l,t,a){const r=new R(l,{type:"doughnut",data:{labels:a.map(h=>h.name),datasets:[{backgroundColor:a.map(h=>h.color),borderColor:getComputedStyle(window.document.documentElement).getPropertyValue("--MI_THEME-panel"),borderWidth:2,hoverOffset:0,data:a.map(h=>h.value)}]},options:{maintainAspectRatio:!1,layout:{padding:{left:16,right:16,top:16,bottom:16}},onClick:h=>{if(h.native==null)return;const I=r.getElementsAtEventForMode(h.native,"nearest",{intersect:!0},!1)[0];I&&a[I.index].onClick&&a[I.index].onClick()},plugins:{legend:{display:!1},tooltip:{enabled:!1,mode:"index",animation:{duration:0},external:t}}}});return r}return H(()=>{W("federation/stats",{limit:30}).then(l=>{const t=l.topSubInstances.map(r=>({name:r.host,color:r.themeColor,value:r.followersCount,onClick:()=>{V(`/instance-info/${r.host}`)}}));t.push({name:"(other)",color:"#80808080",value:l.otherFollowersCount}),s(i.value,k,t);const a=l.topPubInstances.map(r=>({name:r.host,color:r.themeColor,value:r.followingCount,onClick:()=>{V(`/instance-info/${r.host}`)}}));a.push({name:"(other)",color:"#80808080",value:l.otherFollowingCount}),s(m.value,f,a)})}),(l,t)=>(v(),g("div",{class:"MkInstanceStats-root-jUmo"},[p(C,{class:"item"},{header:c(()=>[...t[3]||(t[3]=[S("Chart",-1)])]),default:c(()=>[e("div",{class:"MkInstanceStats-chart-AsEh"},[e("div",J,[p(D,{modelValue:_.value,"onUpdate:modelValue":t[0]||(t[0]=a=>_.value=a),style:{margin:"0",flex:"1"}},{default:c(()=>[d.value?(v(),g("optgroup",{key:0,label:n(o).ts.federation},[e("option",Z,u(n(o).ts._charts.federation),1),e("option",tt,u(n(o).ts._charts.apRequest),1)],8,Q)):y("",!0),e("optgroup",{label:n(o).ts.users},[e("option",at,u(n(o).ts._charts.usersIncDec),1),e("option",st,u(n(o).ts._charts.usersTotal),1),e("option",ot,u(n(o).ts._charts.activeUsers),1)],8,et),e("optgroup",{label:n(o).ts.notes},[e("option",lt,u(n(o).ts._charts.notesIncDec),1),e("option",rt,u(n(o).ts._charts.localNotesIncDec),1),d.value?(v(),g("option",it,u(n(o).ts._charts.remoteNotesIncDec),1)):y("",!0),e("option",ut,u(n(o).ts._charts.notesTotal),1)],8,
1nt),e("optgroup",{label:n(o).ts.drive},[e("option",dt,u(n(o).ts._charts.filesIncDec),1),e("option",pt,u(n(o).ts._charts.storageUsageIncDec),1)],8,ct)]),_:1},8,["modelValue"]),p(D,{modelValue:M.value,"onUpdate:modelValue":t[1]||(t[1]=a=>M.value=a),style:{margin:"0 0 0 10px"}},{default:c(()=>[e("option",mt,u(n(o).ts.perHour),1),e("option",ht,u(n(o).ts.perDay),1)]),_:1},8,["modelValue"])]),e("div",vt,[p(Y,{src:_.value,span:M.value,limit:Mt,detailed:!0},null,8,["src","span"])])],2)]),_:1}),p(C,{class:"item"},{header:c(()=>[...t[4]||(t[4]=[S("Active users heatmap",-1)])]),default:c(()=>[p(D,{modelValue:b.value,"onUpdate:modelValue":t[2]||(t[2]=a=>b.value=a),style:{margin:"0 0 12px 0"}},{default:c(()=>[t[5]||(t[5]=e("option",{value:"active-users"},"Active users",-1)),t[6]||(t[6]=e("option",{value:"notes"},"Notes",-1)),d.value?(v(),g("option",_t,"AP Requests: inboxReceived")):y("",!0),d.value?(v(),g("option",ft,"AP Requests: deliverSucceeded")):y("",!0),d.value?(v(),g("option",gt,"AP Requests: deliverFailed")):y("",!0)]),_:1},8,["modelValue"]),e("div",{class:"_panel MkInstanceStats-heatmap-CLf6"},[p(j,{src:b.value,label:"Read & Write"},null,8,["src"])],2)]),_:1}),p(C,{class:"item"},{header:c(()=>[...t[7]||(t[7]=[S("Retention rate",-1)])]),default:c(()=>[e("div",{class:"_panel MkInstanceStats-retentionHeatmap-eXlR"},[p(O)],2),e("div",{class:"_panel MkInstanceStats-retentionLine-rOzK"},[p(G)],2)]),_:1}),d.value?(v(),X(C,{key:0,class:"item"},{header:c(()=>[...t[8]||(t[8]=[S("Federation",-1)])]),default:c(()=>[e("div",{class:"MkInstanceStats-federation-Di80"},[e("div",bt,[e("div",kt,[t[9]||(t[9]=e("div",{class:"title"},"Sub",-1)),e("canvas",{ref_key:"subDoughnutEl",ref:i},null,512)]),e("div",yt,[t[10]||(t[10]=e("div",{class:"title"},"Pub",-1)),e("canvas",{ref_key:"pubDoughnutEl",ref:m},null,512)])])],2)]),_:1})):y("",!0)],2))}});export{qt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.