import{A as e,L as t,P as n,a as r,b as i,c as a,d as o,f as s,o as c,rt as l,s as u,u as d,v as f}from"./runtime-core.esm-bundler.BCIfMFaf.js";import{x as p}from"./colord.BTI3XySM.js";import{g as m,h,l as g,n as _,p as v,r as y,t as b,u as x}from"./index.ChkmaRqp.js";import{a as S,c as C,i as w,l as T,n as E,o as D,s as O,u as k}from"./chartjs-adapter-dayjs-4.esm.DoBzL3Ex.js";var A={class:`ui header`},j={class:`tw-flex ui segment main-graph`},M={key:0,class:`tw-m-auto`},N={key:0},P={key:1,class:`tw-text-red`},F=v(s({__name:`RepoCodeFrequency`,props:{locale:{}},setup(s){let{pageData:v}=window.config;w.defaults.color=g.text,w.defaults.borderColor=g.border,w.register(C,D,k,O,S,T);let F=n(!1),I=n(``),L=v.repoLink,R=n([]);f(()=>{z()});async function z(){F.value=!0;try{let e;do e=await h(`${L}/activity/code-frequency/data`),e.status===202&&await p(1e3);while(e.status===202);if(e.ok){let t=await e.json(),n=Object.values(t)[0].week;R.value=b(y(n,_(new Date)),t),I.value=``}else I.value=e.statusText}catch(e){I.value=x(e)}finally{F.value=!1}}function B(e){return{datasets:[{data:e.map(e=>({x:e.week,y:e.additions})),pointRadius:0,pointHitRadius:0,fill:!0,label:`Additions`,backgroundColor:g.additions,borderWidth:0,tension:.3},{data:e.map(e=>({x:e.week,y:-e.deletions})),pointRadius:0,pointHitRadius:0,fill:!0,label:`Deletions`,backgroundColor:g.deletions,borderWidth:0,tension:.3}]}}let V={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!0}},scales:{x:{type:`time`,grid:{display:!1},time:{minUnit:`month`},ticks:{maxRotation:0,maxTicksLimit:12}},y:{ticks:{maxTicksLimit:6}}}};return(n,f)=>(i(),a(`div`,null,[r(`div`,A,l(F.value?s.locale.loadingTitle:I.value?s.locale.loadingTitleFailed:`Code frequency over the history of ${t(L).slice(1)}`),1),r(`div`,j,[F.value||I.value!==``?(i(),a(`div`,M,[F.value?(i(),a(`div`,N,[o(t(m),{name:`gitea-running`,class:`tw-mr-2 rotate-clockwise`}),d(` `+l(s.locale.loadingInfo),1)])):(i(),a(`div`,P,[o(t(m),{name:`octicon-x-circle-fill`}),d(` `+l(I.value),1)]))])):u(``,!0),R.value.length===0?u(``,!0):e(R.value,()=>(i(),c(t(E),{key:1,data:B(R.value),options:V},null,8,[`data`])),f,0)])]))}}),[[`__scopeId`,`data-v-48d806e5`]]);export{F as default};
//# sourceMappingURL=RepoCodeFrequency.DlP0umGK.js.map