"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["code-frequency-graph"],{"./web_src/js/components/RepoCodeFrequency.vue":function(I,m,s){s.d(m,{default:function(){return R}});var t=s("./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js"),d=s("./node_modules/@vue/shared/dist/shared.esm-bundler.js");const F=e=>(_pushScopeId("data-v-8f699cd6"),e=e(),_popScopeId(),e),p={class:"ui header tw-flex tw-items-center tw-justify-between"},v={class:"tw-flex ui segment main-graph"},f={key:0,class:"gt-tc tw-m-auto"},g={key:0},j={key:1,class:"text red"};function y(e,o,i,l,c,u){const h=(0,t.g2)("SvgIcon"),D=(0,t.g2)("ChartLine");return(0,t.uX)(),(0,t.CE)("div",null,[(0,t.Lk)("div",p,(0,d.v_)(e.isLoading?i.locale.loadingTitle:e.errorText?i.locale.loadingTitleFailed:`Code frequency over the history of ${e.repoLink.slice(1)}`),1),(0,t.Lk)("div",v,[e.isLoading||e.errorText!==""?((0,t.uX)(),(0,t.CE)("div",f,[e.isLoading?((0,t.uX)(),(0,t.CE)("div",g,[(0,t.bF)(h,{name:"octicon-sync",class:"tw-mr-2 job-status-rotate"}),(0,t.eW)(" "+(0,d.v_)(i.locale.loadingInfo),1)])):((0,t.uX)(),(0,t.CE)("div",j,[(0,t.bF)(h,{name:"octicon-x-circle-fill"}),(0,t.eW)(" "+(0,d.v_)(e.errorText),1)]))])):(0,t.Q3)("v-if",!0),e.data.length!==0?(0,t.bU)(e.data,()=>((0,t.uX)(),(0,t.Wv)(D,{key:1,data:u.toGraphData(e.data),options:u.getOptions()},null,8,["data","options"])),o,0):(0,t.Q3)("v-if",!0)])])}var w=s("./web_src/js/svg.js"),a=s("./node_modules/chart.js/dist/chart.js"),b=s("./web_src/js/modules/fetch.js"),k=s("./node_modules/vue-chartjs/dist/index.js"),r=s("./web_src/js/utils/time.js"),n=s("./web_src/js/utils/color.js"),L=s("./web_src/js/utils.js"),S=s("./node_modules/chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm.js");const{pageData:x}=window.config;a.t1.defaults.color=n.K.text,a.t1.defaults.borderColor=n.K.border,a.t1.register(a.UA,a.kc,a.s$,a.FN,a.No,a.dN);var C={components:{ChartLine:k.N1,SvgIcon:w.Ah},props:{locale:{type:Object,required:!0}},data:()=>({isLoading:!1,errorText:"",repoLink:x.repoLink||[],data:[]}),mounted(){this.fetchGraphData()},methods:{async fetchGraphData(){this.isLoading=!0;try{let e;do e=await(0,b.fG)(`${this.repoLink}/activity/code-frequency/data`),e.status===202&&await(0,L.yy)(1e3);while(e.status===202);if(e.ok){this.data=await e.json();const i=Object.values(this.data)[0].week,l=(0,r.Z1)(new Date),c=(0,r.Ex)(i,l);this.data=(0,r.a$)(c,this.data),this.errorText=""}else this.errorText=e.statusText}catch(e){this.errorText=e.message}finally{this.isLoading=!1}},toGraphData(e){return{datasets:[{data:e.map(o=>({x:o.week,y:o.additions})),pointRadius:0,pointHitRadius:0,fill:!0,label:"Additions",backgroundColor:n.K.additions,borderWidth:0,tension:.3},{data:e.map(o=>({x:o.week,y:-o.deletions})),pointRadius:0,pointHitRadius:0,fill:!0,label:"Deletions",backgroundColor:n.K.deletions,borderWidth:0,tension:.3}]}},getOptions(){return{responsive:!0,maintainAspectRatio:!1,animation:!0,plugins:{legend:{display:!0}},scales:{x:{type:"time",grid:{display:!1},time:{minUnit:"month"},ticks:{maxRotation:0,maxTicksLimit:12}},y:{ticks:{maxTicksLimit:6}}}}}}},T=s("./node_modules/vue-loader/dist/exportHelper.js"),R=(0,T.A)(C,[["render",y],["__scopeId","data-v-8f699cd6"]])}}]);
