import{L as e,M as t,N as n,a as r,b as i,c as a,d as o,f as s,k as c,o as l,rt as u,s as d,u as f,v as p}from"./runtime-core.esm-bundler.-wy0QUpZ.js";import{v as m}from"./utils.CNePm0t_.js";import{f as h,h as g,l as _,m as v,n as y,r as b,t as x}from"./index.CzQRfW04.js";import{c as S,f as C,i as w,o as T,r as E,t as D}from"./chartjs-adapter-dayjs-4.esm.BNunhXdr.js";var O={class:`ui header tw-flex tw-items-center tw-justify-between`},k={class:`tw-flex ui segment main-graph`},A={key:0,class:`tw-m-auto`},j={key:0},M={key:1,class:`tw-text-red`},N=h(s({__name:`RepoRecentCommits`,props:{locale:{}},setup(s){let{pageData:h}=window.config;w.defaults.color=_.text,w.defaults.borderColor=_.border,w.register(S,T,E,C);let N=n(!1),P=n(``),F=h.repoLink,I=t([]);p(()=>{L()});async function L(){N.value=!0;try{let e;do e=await v(`${F}/activity/recent-commits/data`),e.status===202&&await m(1e3);while(e.status===202);if(e.ok){let t=await e.json(),n=Object.values(t)[0].week;I.value=x(b(n,y(new Date)),t).slice(-52),P.value=``}else P.value=e.statusText}catch(e){P.value=e.message}finally{N.value=!1}}function R(e){return{datasets:[{data:e.map(e=>({x:e.week,y:e.commits})),label:`Commits`,backgroundColor:_.commits,borderWidth:0,tension:.3}]}}let z={responsive:!0,maintainAspectRatio:!1,scales:{x:{type:`time`,grid:{display:!1},time:{minUnit:`week`},ticks:{maxRotation:0,maxTicksLimit:52}},y:{ticks:{maxTicksLimit:6}}}};return(t,n)=>(i(),a(`div`,null,[r(`div`,O,u(N.value?s.locale.loadingTitle:P.value?s.locale.loadingTitleFailed:`Number of commits in the past year`),1),r(`div`,k,[N.value||P.value!==``?(i(),a(`div`,A,[N.value?(i(),a(`div`,j,[o(e(g),{name:`gitea-running`,class:`tw-mr-2 rotate-clockwise`}),f(` `+u(s.locale.loadingInfo),1)])):(i(),a(`div`,M,[o(e(g),{name:`octicon-x-circle-fill`}),f(` `+u(P.value),1)]))])):d(``,!0),I.value.length===0?d(``,!0):c(I.value,()=>(i(),l(e(D),{key:1,data:R(I.value),options:z},null,8,[`data`])),n,0)])]))}}),[[`__scopeId`,`data-v-1b3ec9e4`]]);export{N as default};
//# sourceMappingURL=RepoRecentCommits.KhBfnsQv.js.map