"use strict";(self.webpackChunkforgejo=self.webpackChunkforgejo||[]).push([["repo-activity-top-authors"],{"./web_src/js/components/RepoActivityTopAuthors.vue":(function(T,v,c){c.d(v,{default:function(){return k}});var u=c("./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js");const y={class:"activity-bar-graph",ref:"style",style:{width:"0",height:"0"}};function x(r,t,s,o,a,i){const e=(0,u.g2)("Bar");return(0,u.uX)(),(0,u.CE)("div",null,[(0,u.Lk)("div",y,null,512),(0,u.bF)(e,{height:"150px",data:i.graphPoints(),options:i.getOptions()},null,8,["data","options"])])}var f=c("./node_modules/vue-chartjs/dist/index.js"),n=c("./node_modules/chart.js/dist/chart.js"),g=c("./web_src/js/utils/color.js");n.t1.defaults.color=g.K.text,n.t1.defaults.borderColor=g.K.border,n.t1.register(n.PP,n.kc,n.E8,n.m_);var b={components:{Bar:f.yP},props:{locale:{type:Object,required:!0}},data:()=>({colors:{barColor:"green"},activityTopAuthors:window.config.pageData.repoActivityTopAuthors||[],i18nCommitActivity:void 0}),mounted(){this.init()},methods:{graphPoints(){return{datasets:[{label:this.locale.commitActivity,data:this.activityTopAuthors.map(r=>r.commits),backgroundColor:this.colors.barColor,barThickness:40,borderWidth:0,tension:.3}],labels:this.activityTopAuthors.map(r=>r.name)}},getOptions(){return{responsive:!0,maintainAspectRatio:!1,animation:!0,scales:{x:{type:"category",grid:{display:!1},ticks:{color:"transparent",minRotation:90,maxRotation:90,autoSkip:!1}},y:{ticks:{stepSize:1}}},plugins:{tooltip:{intersect:!1}}}},init(){const r=window.getComputedStyle(this.$refs.style);this.colors.barColor=r.backgroundColor;for(const t of this.activityTopAuthors){const s=new Image;s.src=t.avatar_link,t.avatar_img=s}n.t1.register({id:"image_label",afterDraw:t=>{const s=t.boxes[0],o=t.boxes[1];for(const[a]of s.ticks.entries()){const i=s.getPixelForTick(a),e=this.activityTopAuthors[a].avatar_img;t.ctx.save();const[p,l,d,h]=this.calcImageSizeAndShift(e);t.ctx.drawImage(e,0,0,e.naturalWidth,e.naturalHeight,i-10+d,o.bottom+10+h,p,l),t.ctx.restore()}},beforeEvent:(t,s)=>{const o=s.event;if(o.type!=="mousemove"&&o.type!=="click")return;const a=t.boxes[1];if(o.y<a.bottom+10||o.y>a.bottom+30){t.canvas.style.cursor="";return}const i=t.boxes[0],e=i.ticks.findIndex((p,l)=>{const d=i.getPixelForTick(l);return o.x>=d-10&&o.x<=d+10});if(e===-1){t.canvas.style.cursor="";return}t.canvas.style.cursor="pointer",o.type==="click"&&this.activityTopAuthors[e].home_link&&(window.location.href=this.activityTopAuthors[e].home_link)}})},calcImageSizeAndShift(r){const[s,o]=[r.naturalWidth,r.naturalHeight],a=20/Math.max(s,o),i=m=>m*a,[e,p]=[i(s),i(o)],l=m=>(20-m)/2,[d,h]=[l(e),l(p)];return[e,p,d,h]}}},A=c("./node_modules/vue-loader/dist/exportHelper.js"),k=(0,A.A)(b,[["render",x]])})}]);
