pacman-contribution-graph 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var t={d:(n,e)=>{for(var a in e)t.o(e,a)&&!t.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n)},n={};t.d(n,{C:()=>K});const e=52,a="yellow",o="#80808064",i=["blinky","clyde","inky","pinky"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=200,s={github:{textColor:"#586069",gridBackground:"#ffffff",contributionBoxColor:"#9be9a8",emptyContributionBoxColor:"#ebedf0",wallColor:"#000000"},"github-dark":{textColor:"#8b949e",gridBackground:"#0d1117",contributionBoxColor:"#26a641",emptyContributionBoxColor:"#161b22",wallColor:"#FFFFFF"},gitlab:{textColor:"#626167",gridBackground:"#ffffff",contributionBoxColor:"#7992f5",emptyContributionBoxColor:"#ececef",wallColor:"#000000"},"gitlab-dark":{textColor:"#999999",gridBackground:"#1f1f1f",contributionBoxColor:"#2e7db1",emptyContributionBoxColor:"#2d2d2d",wallColor:"#FFFFFF"}},l={blinky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfUlEQVQ4T+2TUQ7AIAhDy/0PzQIRAqxmLtnn/DJPWypBAVkKKOMCyOQN7IRElLrcnIrDLNK4wVtxNbkb6Hq+jOcSbim6QVzKEstkw92gxVeFrMpqokix4wA+NvCOnvfArvcEbHoe2G9QmmhDMUc65p3xYC6q3zQPxtdl3NgF5QpL/b/rs3IAAAAASUVORK5CYIIA"},clyde:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgUlEQVQ4T+2T0Q6AIAhFLx9sH1MfTIPCAeLKrcd8PHqP4JBQLN7BFacNlHkAs+AQcqIueBs2mVWjgtWwl4yCdrd/pHYLLlVEgR2yK0wy4SoI5TcGXU4wM+AEJQfwsUCuXngDOR4rqKbngf0C94gyFHmkbd4rbkxD/pv2jfR1Ky7sBNrzXbHpnBX+AAAAAElFTkSuQmCC"},inky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAg0lEQVQ4T+WTWxKAIAhFuQvK/a+jFoT5QAVxypn+6vMEx6sDIO/jk12OAMs1WDVOXV3UBW+bRVbTFMFu8yCZBExH/g26VHCXI0AJpKgdUCUrTlkwxE+FECdzS7HiJemXgvyeO29gE7jD8wDVFX4vSLNtR1q2z+OVlaZxTaXYrq7HbxYBS8VgMVrqzkEAAAAASUVORK5CYIIA"},pinky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAhklEQVQ4T+2T0Q2AIAwF281wC50Qt9DNagoptqVESfyUz4N3vJCCECxaD4o47gt6bsAo2IWUqAnehkUmbYpgNqwlvSCnur+dtnnAuYUVyCGJimTAi8DUzwmwOoGI7hYjDgAfC/jqiTfg47ZBND0P7BeoR+Sh8CMt8x5xYSWkv2nbcF834swuA/9u49Yy5bgAAAAASUVORK5CYIIA"},scared:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAeUlEQVQ4T82TUQ6AMAhD7UX0/sdyF0GREVmDmTN+bH9r6Bs0A0t2VpFULwDrrfBkZFcA3YC3ZodViAFGzQHyP0B2w2NrB0/1AoDbHwLoQ5/nrw1OBuD5e/crbM9Aiz35njHWzpSB/m3+0r40mV41M8U19WJe3Uw/tQOKt08pUUbBEQAAAABJRU5ErkJgggAA"}},u={horizontal:Array(53).fill(null).map((()=>Array(8).fill({active:!1,id:""}))),vertical:Array(53).fill(null).map((()=>Array(8).fill({active:!1,id:""})))},h=(t,n,e,a)=>{"horizontal"===e?t>=0&&t<u.horizontal.length&&n>=0&&n<u.horizontal[0].length&&(u.horizontal[t][n]={active:!0,id:a}):t>=0&&t<u.vertical.length&&n>=0&&n<u.vertical[0].length&&(u.vertical[t][n]={active:!0,id:a})};var d,m=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};!function(t){t.DEFAULT="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_chomp.wav",t.BEGINNING="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_beginning.wav",t.GAME_OVER="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_death.wav",t.EAT_GHOST="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_eatghost.wav"}(d||(d={}));class g{constructor(){this.sounds=new Map,this.currentSource=null,this.defaultSource=null,this.isMuted=!1,this.audioContext=new AudioContext}static getInstance(){return g.instance||(g.instance=new g),g.instance}preloadSounds(){return m(this,void 0,void 0,(function*(){for(const t of Object.values(d)){const n=yield fetch(t),e=yield n.arrayBuffer(),a=yield this.audioContext.decodeAudioData(e);this.sounds.set(t,a)}}))}play(t){return m(this,void 0,void 0,(function*(){if(this.isMuted)return;if(this.currentSource)try{this.currentSource.stop()}catch(t){}const n=this.sounds.get(t);if(n)return this.currentSource=this.audioContext.createBufferSource(),this.currentSource.buffer=n,this.currentSource.connect(this.audioContext.destination),this.isMuted||this.currentSource.start(),new Promise((t=>{this.currentSource.onended=()=>{this.currentSource=null,t()}}));console.error(`Sound ${t} not found`)}))}startDefaultSound(){if(this.defaultSource)try{this.defaultSource.stop()}catch(t){}const t=this.sounds.get(d.DEFAULT);t?(this.defaultSource=this.audioContext.createBufferSource(),this.defaultSource.buffer=t,this.defaultSource.loop=!0,this.defaultSource.connect(this.audioContext.destination),this.isMuted||this.defaultSource.start()):console.error("Default sound not found")}stopDefaultSound(){if(this.defaultSource){try{this.defaultSource.stop()}catch(t){}this.defaultSource=null}}mute(){this.isMuted=!0,this.currentSource&&this.currentSource.disconnect(),this.defaultSource&&this.defaultSource.disconnect()}unmute(){this.isMuted=!1,this.currentSource&&this.currentSource.connect(this.audioContext.destination),this.defaultSource&&this.defaultSource.connect(this.audioContext.destination)}}var f=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};const p=t=>{var n;return null!==(n=s[t.config.gameTheme])&&void 0!==n?n:s.github},y={},x=(t,n)=>{if(!y[t]){const e=new Image;e.src=n,y[t]=e}return y[t]},v=t=>{const n=t.config.canvas.getContext("2d");n.fillStyle=p(t).gridBackground,n.fillRect(0,0,t.config.canvas.width,t.config.canvas.height);for(let i=0;i<e;i++)for(let e=0;e<7;e++){const r=t.grid[i][e].intensity;if(r>0){const e=r<.2?.3:r,i=(a=p(t).contributionBoxColor,o=e,`rgba(${parseInt(a.slice(1,3),16)}, ${parseInt(a.slice(3,5),16)}, ${parseInt(a.slice(5,7),16)}, ${o})`);n.fillStyle=i}else n.fillStyle=p(t).emptyContributionBoxColor;n.beginPath(),t.config.canvas.getContext("2d").roundRect(22*i,22*e+15,20,20,5),n.fill()}var a,o;n.fillStyle=p(t).wallColor;for(let t=0;t<=e;t++)for(let e=0;e<=7;e++)u.horizontal[t][e].active&&n.fillRect(22*t-2,22*e-2+15,22,2),u.vertical[t][e].active&&n.fillRect(22*t-2,22*e-2+15,2,22);n.fillStyle=p(t).textColor,n.font="10px Arial",n.textAlign="center";let i="";for(let a=0;a<e;a++)if(t.monthLabels[a]!==i){const e=22*a+10;n.fillText(t.monthLabels[a],e,10),i=t.monthLabels[a]}},A=t=>{const n=t.config.canvas.getContext("2d"),e=22*t.pacman.x+10,i=22*t.pacman.y+10+15;t.pacman.deadRemainingDuration?n.fillStyle=o:t.pacman.powerupRemainingDuration?n.fillStyle="red":n.fillStyle=a;const r=t.pacmanMouthOpen?.35*Math.PI:.1*Math.PI;let c,s;switch(t.pacman.direction){case"up":c=1.5*Math.PI+r,s=1.5*Math.PI-r;break;case"down":c=.5*Math.PI+r,s=.5*Math.PI-r;break;case"left":c=Math.PI+r,s=Math.PI-r;break;default:c=0+r,s=2*Math.PI-r}n.beginPath(),n.arc(e,i,10,c,s),n.lineTo(e,i),n.fill()},b=t=>{t.ghosts.forEach((n=>{const e=22*n.x,a=22*n.y+15,o=t.config.canvas.getContext("2d");n.scared?o.drawImage(x("scared",l.scared.imgDate),e,a,20,20):o.drawImage(x(n.name,l[n.name].imgDate),e,a,20,20)}))},w=t=>{t.config.enableSounds&&t.config.canvas.addEventListener("click",(function(n){const e=t.config.canvas.getBoundingClientRect(),a=n.clientX-e.left,o=n.clientY-e.top,i=t.config.canvas.width-30-10;a>=i&&a<=i+this.width&&o>=10&&o<=10+this.height&&(g.getInstance().isMuted?g.getInstance().unmute():g.getInstance().mute())}))},C=(t,n)=>[[-1,0],[1,0],[0,-1],[0,1]].filter((([a,o])=>{const i=t+a,r=n+o;return!(i<0||i>=e||r<0||r>=7||(-1===a?u.vertical[t][n].active:1===a?u.vertical[t+1][n].active:-1===o?u.horizontal[t][n].active:1===o&&u.horizontal[t][n+1].active))})),L=(t,n,e,a)=>Math.sqrt(Math.pow(e-t,2)+Math.pow(a-n,2)),M=(t,n,e,a)=>{if(t===e&&n===a)return null;const o=[{x:t,y:n,path:[]}],i=new Set;for(i.add(`${t},${n}`);o.length>0;){const t=o.shift(),{x:n,y:r,path:c}=t,s=C(n,r);for(const[t,l]of s){const s=n+t,u=r+l,h=`${s},${u}`;if(i.has(h))continue;i.add(h);const d=[...c,{x:s,y:u}];if(s===e&&u===a)return d.length>0?d[0]:null;o.push({x:s,y:u,path:d})}}return null},S=(t,n)=>{const{pacman:e}=n;let a=[0,0];switch(t.name){case"blinky":default:return{x:e.x,y:e.y};case"pinky":a=$(n);const o=4;let i={x:e.x+a[0]*o,y:e.y+a[1]*o};return i.x=Math.min(Math.max(i.x,0),51),i.y=Math.min(Math.max(i.y,0),6),i;case"inky":const r=n.ghosts.find((t=>"blinky"===t.name));a=$(n);let c={x:e.x+2*a[0],y:e.y+2*a[1]};return r&&(c={x:c.x+(c.x-r.x),y:c.y+(c.y-r.y)}),c.x=Math.min(Math.max(c.x,0),51),c.y=Math.min(Math.max(c.y,0),6),c;case"clyde":return L(t.x,t.y,e.x,e.y)>8?{x:e.x,y:e.y}:{x:0,y:6}}},$=t=>{switch(t.pacman.direction){case"right":return[1,0];case"left":return[-1,0];case"up":return[0,-1];case"down":return[0,1];default:return[0,0]}},D=(t,n)=>{const e=t+Math.floor(17*Math.random())-8,a=n+Math.floor(17*Math.random())-8;return{x:Math.max(0,Math.min(e,51)),y:Math.max(0,Math.min(a,6))}},z=t=>{t.ghosts.forEach((n=>{n.scared||Math.random()<.15?((t,n)=>{(!t.target||t.x===t.target.x&&t.y===t.target.y)&&(t.target=D(t.x,t.y));const e=C(t.x,t.y);if(0===e.length)return;const a=t.target.x-t.x,o=t.target.y-t.y;let i=e.filter((t=>{if(Math.random()<.3)return!0;const n=t[0],e=t[1];return a>0&&n>0||a<0&&n<0||o>0&&e>0||o<0&&e<0}));0===i.length&&(i=e);const[r,c]=i[Math.floor(Math.random()*i.length)];n.pacman.powerupRemainingDuration&&Math.random()<.5||(t.x+=r,t.y+=c)})(n,t):((t,n)=>{const e=S(t,n);t.target=e;const a=M(t.x,t.y,e.x,e.y);a&&(t.x=a.x,t.y=a.y)})(n,t)}))},k=t=>{const n=new Map,a=!!t.pacman.powerupRemainingDuration;if(t.ghosts.forEach((t=>{if(!t.scared)for(let a=-5;a<=5;a++)for(let o=-5;o<=5;o++){const i=t.x+a,r=t.y+o;if(i>=0&&i<e&&r>=0&&r<7){const t=`${i},${r}`,e=15-(Math.abs(a)+Math.abs(o));if(e>0){const a=n.get(t)||0;n.set(t,Math.max(a,e))}}}})),a)for(const[t,e]of n.entries())n.set(t,e/5);return n},I=(t,n)=>{var e;(e=t.pacman).recentPositions||(e.recentPositions=[]),t.pacman.recentPositions.push(`${n.x},${n.y}`),t.pacman.recentPositions.length>5&&t.pacman.recentPositions.shift();const a=n.x-t.pacman.x,o=n.y-t.pacman.y;a>0?t.pacman.direction="right":a<0?t.pacman.direction="left":o>0?t.pacman.direction="down":o<0&&(t.pacman.direction="up"),t.pacman.x=n.x,t.pacman.y=n.y},B=t=>{t.pacman.powerupRemainingDuration=15,t.ghosts.forEach((t=>t.scared=!0))},T=t=>{if(t.pacman.deadRemainingDuration)return;const n=!!t.pacman.powerupRemainingDuration,a=t.ghosts.filter((t=>t.scared));let o=null;if(o=n&&a.length>0?(t=>{const n=t.ghosts.filter((t=>t.scared));return 0===n.length?null:n.reduce(((n,e)=>{const a=L(e.x,e.y,t.pacman.x,t.pacman.y);return a<n.distance?{x:e.x,y:e.y,distance:a}:n}),{x:t.pacman.x,y:t.pacman.y,distance:1/0})})(t):(t=>{let n=[];for(let a=0;a<e;a++)for(let e=0;e<7;e++)if(t.grid[a][e].intensity>0){const o=L(a,e,t.pacman.x,t.pacman.y),i=t.grid[a][e].intensity/(o+1);n.push({x:a,y:e,value:i})}return 0===n.length?null:(n.sort(((t,n)=>n.value-t.value)),n[0])})(t),!o)return;const i=((t,n)=>{var e;const a=[{x:t.pacman.x,y:t.pacman.y,path:[],score:0}],o=new Set;o.add(`${t.pacman.x},${t.pacman.y}`);const i=k(t);for(;a.length>0;){a.sort(((t,n)=>n.score-t.score));const r=a.shift(),{x:c,y:s,path:l}=r;if(c===n.x&&s===n.y)return l.length>0?l[0]:null;const u=C(c,s);for(const[r,h]of u){const u=c+r,d=s+h,m=`${u},${d}`;if(!o.has(m)){const r=[...l,{x:u,y:d}],c=i.get(m)||0,s=t.grid[u][d].intensity,h=L(u,d,n.x,n.y);let g=0;(null===(e=t.pacman.recentPositions)||void 0===e?void 0:e.includes(m))&&(g+=100),a.push({x:u,y:d,path:r,score:s-c-h/10-g}),o.add(m)}}}return null})(t,o);i?I(t,i):(t=>{const n=C(t.pacman.x,t.pacman.y);if(0===n.length)return;const e=n.reduce(((n,[e,a])=>{const o=t.pacman.x+e,i=t.pacman.y+a;let r=1/0;return t.ghosts.forEach((t=>{if(!t.scared){const n=L(t.x,t.y,o,i);r=Math.min(r,n)}})),r>n.distance?{dx:e,dy:a,distance:r}:n}),{dx:0,dy:0,distance:-1/0}),a=t.pacman.x+e.dx,o=t.pacman.y+e.dy;I(t,{x:a,y:o})})(t),(t=>{t.grid[t.pacman.x][t.pacman.y].intensity>0&&(t.pacman.totalPoints+=t.grid[t.pacman.x][t.pacman.y].commitsCount,t.pacman.points++,t.config.pointsIncreasedCallback(t.pacman.totalPoints),t.grid[t.pacman.x][t.pacman.y].intensity=0,t.pacman.points>=30&&B(t))})(t)},E=t=>{const n=10,e=t,a=2*Math.PI-t;return`M 10,10\n L ${n+n*Math.cos(e)},${n+n*Math.sin(e)}\n A 10,10 0 1,1 ${n+n*Math.cos(a)},${n+n*Math.sin(a)}\n Z`},F=(t,n,e)=>t.gameHistory.map((a=>{const o=a.grid[n][e];if(o>0){const n=o<.2?.3:o;return i=p(t).contributionBoxColor,r=n,3===(i=i.replace(/^#/,"")).length&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),`#${i}${Math.round(255*r).toString(16).padStart(2,"0")}`}var i,r;return p(t).emptyContributionBoxColor})),R=t=>{switch(t){case"blinky":return"gb";case"clyde":return"gc";case"inky":return"gi";case"pinky":return"gp";case"scared":return"gs";default:return t}},P=(t,n)=>{if(t.gameHistory.length!==n.length)throw new Error("The length of changingValues must match the length of gameHistory");const e=t.gameHistory.length;let a=[],o=[],i=null,r=null;return n.forEach(((t,n)=>{t!==i&&(null!==i&&null!==r&&n-1!==r&&(a.push(Number(((n-1e-6)/(e-1)).toFixed(6))),o.push(i)),a.push(Number((n/(e-1)).toFixed(6))),o.push(t),i=t,r=n)})),1!==a[a.length-1]&&(a.push(1),o.push(i)),{keyTimes:a.join(";"),values:o.join(";")}},O=t=>{let n='<svg width="1144" height="174" xmlns="http://www.w3.org/2000/svg">';n+=`<desc>Generated with https://github.com/abozanona/pacman-contribution-graph on ${new Date}</desc>`,n+=`<rect width="100%" height="100%" fill="${p(t).gridBackground}"/>`,n+=`<defs>\n\t\t<symbol id="${R("blinky")}" viewBox="0 0 100 100">\n <image href="${l.blinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("clyde")}" viewBox="0 0 100 100">\n <image href="${l.clyde.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("inky")}" viewBox="0 0 100 100">\n <image href="${l.inky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("pinky")}" viewBox="0 0 100 100">\n <image href="${l.pinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("scared")}" viewBox="0 0 100 100">\n <image href="${l.scared.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t</defs>`;let i="";for(let a=0;a<e;a++)t.monthLabels[a]!==i&&(n+=`<text x="${22*a+10}" y="10" text-anchor="middle" font-size="10" fill="${p(t).textColor}">${t.monthLabels[a]}</text>`,i=t.monthLabels[a]);for(let a=0;a<e;a++)for(let e=0;e<7;e++){const o=22*a,i=22*e+15,r=P(t,F(t,a,e));n+=`<rect id="c-${a}-${e}" x="${o}" y="${i}" width="20" height="20" rx="5" fill="${p(t).emptyContributionBoxColor}">\n <animate attributeName="fill" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite" \n values="${r.values}" \n keyTimes="${r.keyTimes}"/>\n </rect>`}for(let a=0;a<e;a++)for(let e=0;e<7;e++)u.horizontal[a][e].active&&(n+=`<rect id="wh-${a}-${e}" x="${22*a-2}" y="${22*e-2+15}" width="22" height="2" rx="5" fill="${p(t).wallColor}"></rect>`),u.vertical[a][e].active&&(n+=`<rect id="wv-${a}-${e}" x="${22*a-2}" y="${22*e-2+15}" width="2" height="22" rx="5" fill="${p(t).wallColor}"></rect>`);const r=P(t,(t=>t.gameHistory.map((t=>t.pacman.deadRemainingDuration?o:t.pacman.powerupRemainingDuration?"red":a)))(t)),s=P(t,(t=>t.gameHistory.map((t=>`${22*t.pacman.x},${22*t.pacman.y+15}`)))(t)),h=P(t,(t=>t.gameHistory.map((t=>{switch(t.pacman.direction){case"right":default:return"0 10 10";case"left":return"180 10 10";case"up":return"270 10 10";case"down":return"90 10 10"}})))(t));return n+=`<path id="pacman" d="${E(.55)}"\n >\n\t\t<animate attributeName="fill" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${r.keyTimes}"\n values="${r.values}"/>\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${s.keyTimes}"\n values="${s.values}"\n additive="sum"/>\n <animateTransform attributeName="transform" type="rotate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${h.keyTimes}"\n values="${h.values}"\n additive="sum"/>\n <animate attributeName="d" dur="0.5s" repeatCount="indefinite"\n values="${E(.55)};${E(.05)};${E(.55)}"/>\n </path>`,t.ghosts.forEach(((e,a)=>{const o=P(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return`${22*e.x},${22*e.y+15}`})))(t,a)),i=P(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return"#"+(e.scared?R("scared"):R(e.name))})))(t,a));n+=`<use id="ghost${a}" width="20" height="20" href="#ghost-${e.name}">\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${o.keyTimes}"\n values="${o.values}"/>\n <animate attributeName="href" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${i.keyTimes}"\n values="${i.values}"/>\n </use>`})),n+="</svg>",n};var N=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};const U=t=>{t.ghosts=[],t.ghosts.push({x:23,y:3,name:i[0],scared:!1,target:void 0}),t.ghosts.push({x:24,y:3,name:i[1],scared:!1,target:void 0}),t.ghosts.push({x:27,y:3,name:i[2],scared:!1,target:void 0}),t.ghosts.push({x:28,y:3,name:i[3],scared:!1,target:void 0}),"canvas"==t.config.outputFormat&&b(t)},V=t=>N(void 0,void 0,void 0,(function*(){if(t.frameCount++,t.frameCount%t.config.gameSpeed==0)if(t.pacman.deadRemainingDuration&&(t.pacman.deadRemainingDuration--,t.pacman.deadRemainingDuration||(U(t),"canvas"==t.config.outputFormat&&g.getInstance().play(d.GAME_OVER).then((()=>g.getInstance().startDefaultSound())))),t.pacman.powerupRemainingDuration&&(t.pacman.powerupRemainingDuration--,t.pacman.powerupRemainingDuration||(t.ghosts.forEach((t=>t.scared=!1)),t.pacman.points=0)),t.grid.some((t=>t.some((t=>t.intensity>0)))))T(t),H(t),t.pacman.deadRemainingDuration||(z(t),H(t)),t.pacmanMouthOpen=!t.pacmanMouthOpen,t.gameHistory.push({pacman:Object.assign({},t.pacman),ghosts:t.ghosts.map((t=>Object.assign({},t))),grid:t.grid.map((t=>[...t.map((t=>t.intensity))]))}),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&A(t),"canvas"==t.config.outputFormat&&b(t),"canvas"==t.config.outputFormat&&(t=>{if(!t.config.enableSounds)return;const n=t.config.canvas.getContext("2d"),e=t.config.canvas.width-30-10;n.fillStyle=`rgba(0, 0, 0, ${g.getInstance().isMuted?.3:.5})`,n.beginPath(),n.moveTo(e+10,20),n.lineTo(e+20,15),n.lineTo(e+20,35),n.lineTo(e+10,30),n.closePath(),n.fill(),g.getInstance().isMuted?(n.strokeStyle="rgba(255, 0, 0, 0.6)",n.lineWidth=3,n.beginPath(),n.moveTo(e+25,15),n.lineTo(e+5,35),n.stroke()):(n.strokeStyle="rgba(0, 0, 0, 0.4)",n.lineWidth=2,n.beginPath(),n.arc(e+25,25,5,0,2*Math.PI),n.stroke(),n.beginPath(),n.arc(e+25,25,8,0,2*Math.PI),n.stroke())})(t);else{if("canvas"==t.config.outputFormat&&(clearInterval(t.gameInterval),"canvas"==t.config.outputFormat&&((t=>{const n=t.config.canvas.getContext("2d");n.fillStyle=p(t).textColor,n.font="20px Arial",n.textAlign="center",n.fillText("Game Over",t.config.canvas.width/2,t.config.canvas.height/2)})(t),g.getInstance().play(d.BEGINNING).then((()=>g.getInstance().stopDefaultSound())))),"svg"==t.config.outputFormat){const n=O(t);t.config.svgCallback(n)}t.config.gameOverCallback()}else t.gameHistory.push({pacman:Object.assign({},t.pacman),ghosts:t.ghosts.map((t=>Object.assign({},t))),grid:t.grid.map((t=>[...t.map((t=>t.intensity))]))})})),H=t=>{t.pacman.deadRemainingDuration||t.ghosts.forEach(((n,e)=>{n.x===t.pacman.x&&n.y===t.pacman.y&&(t.pacman.powerupRemainingDuration&&n.scared?(Q(t,e),t.pacman.points+=10,"canvas"==t.config.outputFormat&&g.getInstance().play(d.EAT_GHOST)):(t.pacman.points=0,t.pacman.powerupRemainingDuration=0,t.pacman.deadRemainingDuration=10,"canvas"==t.config.outputFormat&&g.getInstance().play(d.GAME_OVER).then((()=>g.getInstance().stopDefaultSound()))))}))},Q=(t,n)=>{let a,o;do{a=Math.floor(Math.random()*e),o=Math.floor(7*Math.random())}while(Math.abs(a-t.pacman.x)<=2&&Math.abs(o-t.pacman.y)<=2||0===t.grid[a][o].intensity);t.ghosts[n]={x:a,y:o,name:i[n%i.length],scared:!1,target:void 0}},j=(t,n,a,o,i)=>{"horizontal"==a?(h(t,n,"horizontal",i),"x"==o?h(e-t-1,n,"horizontal",i):"y"==o?h(t,7-n,"horizontal",i):"xy"==o&&(h(e-t-1,n,"horizontal",i),h(t,7-n,"horizontal",i),h(e-t-1,7-n,"horizontal",i))):(h(t,n,"vertical",i),"x"==o?h(e-t,n,"vertical",i):"y"==o?h(t,7-n-1,"vertical",i):"xy"==o&&(h(e-t,n,"vertical",i),h(t,7-n-1,"vertical",i),h(e-t,7-n-1,"vertical",i)))},G={frameCount:0,contributions:[],pacman:{x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0,recentPositions:[]},ghosts:[],grid:[],monthLabels:[],pacmanMouthOpen:!0,gameInterval:0,gameHistory:[],config:void 0};class K{constructor(t){this.store=structuredClone(G),this.conf=Object.assign({},t),j(0,2,"horizontal","xy","L1"),j(1,2,"horizontal","xy","L1"),j(4,0,"vertical","x","L2"),j(4,1,"vertical","x","L2"),j(4,2,"vertical","x","L2"),j(4,3,"vertical","x","L2"),j(4,4,"vertical","x","L2"),j(3,3,"horizontal","x","L3"),j(2,3,"horizontal","x","L3"),j(4,5,"horizontal","x","L4"),j(6,4,"vertical","x","L5"),j(6,3,"vertical","x","L5"),j(6,2,"vertical","x","L5"),j(6,2,"horizontal","x","L6"),j(7,2,"horizontal","x","L6"),j(8,2,"horizontal","x","L6"),j(9,2,"horizontal","x","L6"),j(13,2,"horizontal","xy","L7"),j(14,2,"horizontal","xy","L7"),j(15,2,"horizontal","xy","L7"),j(16,2,"horizontal","xy","L7"),j(17,2,"horizontal","xy","L7"),j(18,2,"horizontal","xy","L7"),j(16,2,"vertical","xy","L8"),j(8,1,"horizontal","x","L9"),j(9,1,"horizontal","x","L9"),j(10,1,"horizontal","x","L9"),j(11,1,"horizontal","x","L9"),j(12,1,"vertical","x","L10"),j(12,3,"vertical","x","L10"),j(11,4,"horizontal","x","L11"),j(10,4,"horizontal","x","L11"),j(9,4,"horizontal","x","L11"),j(8,4,"horizontal","x","L11"),j(8,4,"vertical","x","L12"),j(8,5,"vertical","x","L12"),j(8,6,"vertical","x","L12"),j(23,2,"horizontal","x","L13"),j(24,2,"horizontal","x","L13"),j(23,4,"horizontal","x","L13"),j(24,4,"horizontal","x","L13"),j(25,4,"horizontal","x","L13"),j(23,2,"vertical","x","L14"),j(23,3,"vertical","x","L14"),j(26,4,"vertical","x","L15"),j(26,5,"vertical","x","L15"),j(23,6,"horizontal","x","L16"),j(24,6,"horizontal","x","L16"),j(25,6,"horizontal","x","L16"),j(26,0,"vertical","x","L17"),j(24,1,"vertical","x","L18"),j(23,1,"horizontal","x","L18"),j(22,1,"horizontal","x","L18"),j(21,1,"horizontal","x","L18"),j(21,1,"vertical","x","L18"),j(21,2,"vertical","x","L18"),j(21,3,"vertical","x","L18"),j(20,4,"horizontal","x","L18"),j(19,4,"horizontal","x","L18"),j(19,3,"vertical","x","L18"),j(18,3,"horizontal","x","L18"),j(22,5,"vertical","x","L19"),j(21,5,"horizontal","x","L19"),j(20,5,"horizontal","x","L19"),j(20,5,"vertical","x","L19"),j(1,6,"horizontal","x","L20"),j(2,6,"horizontal","x","L20"),j(3,5,"vertical","x","L20"),j(3,4,"vertical","x","L20"),j(5,6,"horizontal","x","L21"),j(6,6,"horizontal","x","L21")}start(){return t=this,n=void 0,o=function*(){switch(this.store.config=Object.assign(Object.assign({},{platform:"github",username:"",canvas:void 0,outputFormat:"svg",svgCallback:t=>{},gameOverCallback:()=>()=>{},gameTheme:"github",gameSpeed:1,enableSounds:!1,pointsIncreasedCallback:t=>{}}),this.conf),this.conf.platform){case"gitlab":this.store.contributions=yield(t=this.store,f(void 0,void 0,void 0,(function*(){const n=yield fetch(`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${t.config.username}`),e=yield n.json();return Object.entries(e).map((([t,n])=>({date:new Date(t),count:Number(n)})))})));break;case"github":this.store.contributions=yield(t=>f(void 0,void 0,void 0,(function*(){var n;const e=[];let a=!1,o=1;do{try{const i={};(null===(n=t.config.githubSettings)||void 0===n?void 0:n.accessToken)&&(i.Authorization="Bearer "+t.config.githubSettings.accessToken);const r=yield fetch(`https://api.github.com/search/commits?q=author:${t.config.username}&sort=author-date&order=desc&page=${o}&per_page=1000`,{headers:i}),c=yield r.json();a=0===c.items.length,e.push(...c.items),o++}catch(t){a=!0}}while(!a);return Array.from(e.reduce(((t,n)=>{const e=n.commit.committer.date.split("T")[0],a=new Date(e),o=(t.get(e)||{count:0}).count+1;return t.set(e,{date:a,count:o})}),new Map).values())})))(this.store)}var t;(t=>{N(void 0,void 0,void 0,(function*(){"canvas"==t.config.outputFormat&&(t.config.canvas=t.config.canvas,(t=>{t.config.canvas.width=1144,t.config.canvas.height=174})(t),w(t)),t.frameCount=0,t.ghosts.forEach((t=>t.scared=!1)),(t=>{t.pacman.points=0,t.pacman.totalPoints=0,t.grid=Array.from({length:e},(()=>Array.from({length:7},(()=>({commitsCount:0,intensity:0}))))),t.monthLabels=Array(e).fill("");let n=1;const a=new Date,o=new Date(a);o.setDate(a.getDate()-a.getDay()),t.contributions.forEach((a=>{const i=new Date(a.date),r=i.getDay(),c=Math.floor((+o-+i)/6048e5);c>=0&&c<e&&r>=0&&r<7&&(t.grid[51-c][r]={commitsCount:a.count,intensity:0},a.count>n&&(n=a.count))}));for(let a=0;a<e;a++)for(let e=0;e<7;e++)t.grid[a][e].commitsCount>0&&(t.grid[a][e].intensity=t.grid[a][e].commitsCount/n);for(let n=0;n<e;n++){const e=51-n,a=new Date(o);a.setDate(a.getDate()-7*e),t.monthLabels[n]=r[a.getMonth()]}})(t),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&(t.config.enableSounds||g.getInstance().mute(),yield g.getInstance().preloadSounds(),g.getInstance().startDefaultSound(),yield g.getInstance().play(d.BEGINNING));const n=()=>t.grid.some((t=>t.some((t=>t.intensity>0))));if(n()&&((t=>{t.pacman={x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0,recentPositions:[]},"canvas"==t.config.outputFormat&&A(t)})(t),U(t)),"svg"==t.config.outputFormat){for(;n();)yield V(t);yield V(t)}else clearInterval(t.gameInterval),t.gameInterval=setInterval((()=>N(void 0,void 0,void 0,(function*(){return yield V(t)}))),c)}))})(this.store)},new((a=void 0)||(a=Promise))((function(e,i){function r(t){try{s(o.next(t))}catch(t){i(t)}}function c(t){try{s(o.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(t){t(n)}))).then(r,c)}s((o=o.apply(t,n||[])).next())}));var t,n,a,o}stop(){var t;t=this.store,N(void 0,void 0,void 0,(function*(){clearInterval(t.gameInterval)}))}}var Y=n.C;export{Y as PacmanRenderer};
1
+ var t={d:(n,e)=>{for(var a in e)t.o(e,a)&&!t.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n)},n={};t.d(n,{C:()=>Y});const e=52,a="yellow",o="#80808064",i=["blinky","clyde","inky","pinky"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=200,s={github:{textColor:"#586069",gridBackground:"#ffffff",contributionBoxColor:"#9be9a8",emptyContributionBoxColor:"#ebedf0",wallColor:"#000000"},"github-dark":{textColor:"#8b949e",gridBackground:"#0d1117",contributionBoxColor:"#26a641",emptyContributionBoxColor:"#161b22",wallColor:"#FFFFFF"},gitlab:{textColor:"#626167",gridBackground:"#ffffff",contributionBoxColor:"#7992f5",emptyContributionBoxColor:"#ececef",wallColor:"#000000"},"gitlab-dark":{textColor:"#999999",gridBackground:"#1f1f1f",contributionBoxColor:"#2e7db1",emptyContributionBoxColor:"#2d2d2d",wallColor:"#FFFFFF"}},l={blinky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfUlEQVQ4T+2TUQ7AIAhDy/0PzQIRAqxmLtnn/DJPWypBAVkKKOMCyOQN7IRElLrcnIrDLNK4wVtxNbkb6Hq+jOcSbim6QVzKEstkw92gxVeFrMpqokix4wA+NvCOnvfArvcEbHoe2G9QmmhDMUc65p3xYC6q3zQPxtdl3NgF5QpL/b/rs3IAAAAASUVORK5CYIIA"},clyde:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgUlEQVQ4T+2T0Q6AIAhFLx9sH1MfTIPCAeLKrcd8PHqP4JBQLN7BFacNlHkAs+AQcqIueBs2mVWjgtWwl4yCdrd/pHYLLlVEgR2yK0wy4SoI5TcGXU4wM+AEJQfwsUCuXngDOR4rqKbngf0C94gyFHmkbd4rbkxD/pv2jfR1Ky7sBNrzXbHpnBX+AAAAAElFTkSuQmCC"},inky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAg0lEQVQ4T+WTWxKAIAhFuQvK/a+jFoT5QAVxypn+6vMEx6sDIO/jk12OAMs1WDVOXV3UBW+bRVbTFMFu8yCZBExH/g26VHCXI0AJpKgdUCUrTlkwxE+FECdzS7HiJemXgvyeO29gE7jD8wDVFX4vSLNtR1q2z+OVlaZxTaXYrq7HbxYBS8VgMVrqzkEAAAAASUVORK5CYIIA"},pinky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAhklEQVQ4T+2T0Q2AIAwF281wC50Qt9DNagoptqVESfyUz4N3vJCCECxaD4o47gt6bsAo2IWUqAnehkUmbYpgNqwlvSCnur+dtnnAuYUVyCGJimTAi8DUzwmwOoGI7hYjDgAfC/jqiTfg47ZBND0P7BeoR+Sh8CMt8x5xYSWkv2nbcF834swuA/9u49Yy5bgAAAAASUVORK5CYIIA"},scared:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAeUlEQVQ4T82TUQ6AMAhD7UX0/sdyF0GREVmDmTN+bH9r6Bs0A0t2VpFULwDrrfBkZFcA3YC3ZodViAFGzQHyP0B2w2NrB0/1AoDbHwLoQ5/nrw1OBuD5e/crbM9Aiz35njHWzpSB/m3+0r40mV41M8U19WJe3Uw/tQOKt08pUUbBEQAAAABJRU5ErkJgggAA"}},u={horizontal:Array(53).fill(null).map((()=>Array(8).fill({active:!1,id:""}))),vertical:Array(53).fill(null).map((()=>Array(8).fill({active:!1,id:""})))},h=(t,n,e,a)=>{"horizontal"===e?t>=0&&t<u.horizontal.length&&n>=0&&n<u.horizontal[0].length&&(u.horizontal[t][n]={active:!0,id:a}):t>=0&&t<u.vertical.length&&n>=0&&n<u.vertical[0].length&&(u.vertical[t][n]={active:!0,id:a})};var m,d=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};!function(t){t.DEFAULT="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_chomp.wav",t.BEGINNING="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_beginning.wav",t.GAME_OVER="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_death.wav",t.EAT_GHOST="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_eatghost.wav"}(m||(m={}));class g{constructor(){this.sounds=new Map,this.currentSource=null,this.defaultSource=null,this.isMuted=!1,this.audioContext=new AudioContext}static getInstance(){return g.instance||(g.instance=new g),g.instance}preloadSounds(){return d(this,void 0,void 0,(function*(){for(const t of Object.values(m)){const n=yield fetch(t),e=yield n.arrayBuffer(),a=yield this.audioContext.decodeAudioData(e);this.sounds.set(t,a)}}))}play(t){return d(this,void 0,void 0,(function*(){if(this.isMuted)return;if(this.currentSource)try{this.currentSource.stop()}catch(t){}const n=this.sounds.get(t);if(n)return this.currentSource=this.audioContext.createBufferSource(),this.currentSource.buffer=n,this.currentSource.connect(this.audioContext.destination),this.isMuted||this.currentSource.start(),new Promise((t=>{this.currentSource.onended=()=>{this.currentSource=null,t()}}));console.error(`Sound ${t} not found`)}))}startDefaultSound(){if(this.defaultSource)try{this.defaultSource.stop()}catch(t){}const t=this.sounds.get(m.DEFAULT);t?(this.defaultSource=this.audioContext.createBufferSource(),this.defaultSource.buffer=t,this.defaultSource.loop=!0,this.defaultSource.connect(this.audioContext.destination),this.isMuted||this.defaultSource.start()):console.error("Default sound not found")}stopDefaultSound(){if(this.defaultSource){try{this.defaultSource.stop()}catch(t){}this.defaultSource=null}}mute(){this.isMuted=!0,this.currentSource&&this.currentSource.disconnect(),this.defaultSource&&this.defaultSource.disconnect()}unmute(){this.isMuted=!1,this.currentSource&&this.currentSource.connect(this.audioContext.destination),this.defaultSource&&this.defaultSource.connect(this.audioContext.destination)}}var p=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};const f=t=>{var n;return null!==(n=s[t.config.gameTheme])&&void 0!==n?n:s.github},y={},x=(t,n)=>{if(!y[t]){const e=new Image;e.src=n,y[t]=e}return y[t]},v=t=>{const n=t.config.canvas.getContext("2d");n.fillStyle=f(t).gridBackground,n.fillRect(0,0,t.config.canvas.width,t.config.canvas.height);for(let i=0;i<e;i++)for(let e=0;e<7;e++){const r=t.grid[i][e].intensity;if(r>0){const e=r<.2?.3:r,i=(a=f(t).contributionBoxColor,o=e,`rgba(${parseInt(a.slice(1,3),16)}, ${parseInt(a.slice(3,5),16)}, ${parseInt(a.slice(5,7),16)}, ${o})`);n.fillStyle=i}else n.fillStyle=f(t).emptyContributionBoxColor;n.beginPath(),t.config.canvas.getContext("2d").roundRect(22*i,22*e+15,20,20,5),n.fill()}var a,o;n.fillStyle=f(t).wallColor;for(let t=0;t<=e;t++)for(let e=0;e<=7;e++)u.horizontal[t][e].active&&n.fillRect(22*t-2,22*e-2+15,22,2),u.vertical[t][e].active&&n.fillRect(22*t-2,22*e-2+15,2,22);n.fillStyle=f(t).textColor,n.font="10px Arial",n.textAlign="center";let i="";for(let a=0;a<e;a++)if(t.monthLabels[a]!==i){const e=22*a+10;n.fillText(t.monthLabels[a],e,10),i=t.monthLabels[a]}},A=t=>{const n=t.config.canvas.getContext("2d"),e=22*t.pacman.x+10,i=22*t.pacman.y+10+15;t.pacman.deadRemainingDuration?n.fillStyle=o:t.pacman.powerupRemainingDuration?n.fillStyle="red":n.fillStyle=a;const r=t.pacmanMouthOpen?.35*Math.PI:.1*Math.PI;let c,s;switch(t.pacman.direction){case"up":c=1.5*Math.PI+r,s=1.5*Math.PI-r;break;case"down":c=.5*Math.PI+r,s=.5*Math.PI-r;break;case"left":c=Math.PI+r,s=Math.PI-r;break;default:c=0+r,s=2*Math.PI-r}n.beginPath(),n.arc(e,i,10,c,s),n.lineTo(e,i),n.fill()},b=t=>{t.ghosts.forEach((n=>{const e=22*n.x,a=22*n.y+15,o=t.config.canvas.getContext("2d");n.scared?o.drawImage(x("scared",l.scared.imgDate),e,a,20,20):o.drawImage(x(n.name,l[n.name].imgDate),e,a,20,20)}))},w=t=>{t.config.enableSounds&&t.config.canvas.addEventListener("click",(function(n){const e=t.config.canvas.getBoundingClientRect(),a=n.clientX-e.left,o=n.clientY-e.top,i=t.config.canvas.width-30-10;a>=i&&a<=i+this.width&&o>=10&&o<=10+this.height&&(g.getInstance().isMuted?g.getInstance().unmute():g.getInstance().mute())}))},C=(t,n)=>[[-1,0],[1,0],[0,-1],[0,1]].filter((([a,o])=>{const i=t+a,r=n+o;return!(i<0||i>=e||r<0||r>=7||(-1===a?u.vertical[t][n].active:1===a?u.vertical[t+1][n].active:-1===o?u.horizontal[t][n].active:1===o&&u.horizontal[t][n+1].active))})),L=(t,n,e,a)=>Math.sqrt(Math.pow(e-t,2)+Math.pow(a-n,2)),M=(t,n,e,a)=>{if(t===e&&n===a)return null;const o=[{x:t,y:n,path:[]}],i=new Set;for(i.add(`${t},${n}`);o.length>0;){const t=o.shift(),{x:n,y:r,path:c}=t,s=C(n,r);for(const[t,l]of s){const s=n+t,u=r+l,h=`${s},${u}`;if(i.has(h))continue;i.add(h);const m=[...c,{x:s,y:u}];if(s===e&&u===a)return m.length>0?m[0]:null;o.push({x:s,y:u,path:m})}}return null},S=(t,n)=>{const{pacman:e}=n;let a=[0,0];switch(t.name){case"blinky":default:return{x:e.x,y:e.y};case"pinky":a=$(n);const o=4;let i={x:e.x+a[0]*o,y:e.y+a[1]*o};return i.x=Math.min(Math.max(i.x,0),51),i.y=Math.min(Math.max(i.y,0),6),i;case"inky":const r=n.ghosts.find((t=>"blinky"===t.name));a=$(n);let c={x:e.x+2*a[0],y:e.y+2*a[1]};return r&&(c={x:c.x+(c.x-r.x),y:c.y+(c.y-r.y)}),c.x=Math.min(Math.max(c.x,0),51),c.y=Math.min(Math.max(c.y,0),6),c;case"clyde":return L(t.x,t.y,e.x,e.y)>8?{x:e.x,y:e.y}:{x:0,y:6}}},$=t=>{switch(t.pacman.direction){case"right":return[1,0];case"left":return[-1,0];case"up":return[0,-1];case"down":return[0,1];default:return[0,0]}},D=(t,n)=>{const e=t+Math.floor(17*Math.random())-8,a=n+Math.floor(17*Math.random())-8;return{x:Math.max(0,Math.min(e,51)),y:Math.max(0,Math.min(a,6))}},z=t=>{t.ghosts.forEach((n=>{n.scared||Math.random()<.15?((t,n)=>{(!t.target||t.x===t.target.x&&t.y===t.target.y)&&(t.target=D(t.x,t.y));const e=C(t.x,t.y);if(0===e.length)return;const a=t.target.x-t.x,o=t.target.y-t.y;let i=e.filter((t=>{const n=t[0],e=t[1];return a>0&&n>0||a<0&&n<0||o>0&&e>0||o<0&&e<0}));0===i.length&&(i=e);const[r,c]=i[Math.floor(Math.random()*i.length)];n.pacman.powerupRemainingDuration&&Math.random()<.5||(t.x+=r,t.y+=c)})(n,t):((t,n)=>{const e=S(t,n);t.target=e;const a=M(t.x,t.y,e.x,e.y);a&&(t.x=a.x,t.y=a.y)})(n,t)}))},k=t=>{let n=[];for(let a=0;a<e;a++)for(let e=0;e<7;e++)if(t.grid[a][e].intensity>0){const o=L(a,e,t.pacman.x,t.pacman.y),i=t.grid[a][e].intensity/(o+1);n.push({x:a,y:e,value:i})}return n.sort(((t,n)=>n.value-t.value)),n[0]},I=t=>{const n=new Map,a=!!t.pacman.powerupRemainingDuration;if(t.ghosts.forEach((t=>{if(!t.scared)for(let a=-5;a<=5;a++)for(let o=-5;o<=5;o++){const i=t.x+a,r=t.y+o;if(i>=0&&i<e&&r>=0&&r<7){const t=`${i},${r}`,e=15-(Math.abs(a)+Math.abs(o));if(e>0){const a=n.get(t)||0;n.set(t,Math.max(a,e))}}}})),a)for(const[t,e]of n.entries())n.set(t,e/5);return n},B=(t,n)=>{var e;(e=t.pacman).recentPositions||(e.recentPositions=[]),t.pacman.recentPositions.push(`${n.x},${n.y}`),t.pacman.recentPositions.length>5&&t.pacman.recentPositions.shift();const a=n.x-t.pacman.x,o=n.y-t.pacman.y;a>0?t.pacman.direction="right":a<0?t.pacman.direction="left":o>0?t.pacman.direction="down":o<0&&(t.pacman.direction="up"),t.pacman.x=n.x,t.pacman.y=n.y},T=t=>{t.pacman.powerupRemainingDuration=15,t.ghosts.forEach((t=>t.scared=!0))},E=t=>{if(t.pacman.deadRemainingDuration)return;const n=!!t.pacman.powerupRemainingDuration,e=t.ghosts.filter((t=>t.scared));let a;if(n&&e.length>0){const n=(t=>{const n=t.ghosts.filter((t=>t.scared));return 0===n.length?null:n.reduce(((n,e)=>{const a=L(e.x,e.y,t.pacman.x,t.pacman.y);return a<n.distance?{x:e.x,y:e.y,distance:a}:n}),{x:t.pacman.x,y:t.pacman.y,distance:1/0})})(t);a=n||k(t)}else t.pacman.target?t.pacman.target.x==t.pacman.x&&t.pacman.target.y==t.pacman.y?(a=k(t),t.pacman.target={x:null==a?void 0:a.x,y:null==a?void 0:a.y}):a=t.pacman.target:(a=k(t),t.pacman.target={x:null==a?void 0:a.x,y:null==a?void 0:a.y});const o=((t,n)=>{var e;const a=[{x:t.pacman.x,y:t.pacman.y,path:[],score:0}],o=new Set;o.add(`${t.pacman.x},${t.pacman.y}`);const i=I(t);for(;a.length>0;){a.sort(((t,n)=>n.score-t.score));const r=a.shift(),{x:c,y:s,path:l}=r;if(c===n.x&&s===n.y)return l.length>0?l[0]:null;const u=C(c,s);for(const[r,h]of u){const u=c+r,m=s+h,d=`${u},${m}`;if(!o.has(d)){const r=[...l,{x:u,y:m}],c=i.get(d)||0,s=t.grid[u][m].intensity,h=L(u,m,n.x,n.y);let g=0;(null===(e=t.pacman.recentPositions)||void 0===e?void 0:e.includes(d))&&(g+=100),a.push({x:u,y:m,path:r,score:s-c-h/10-g}),o.add(d)}}}return null})(t,a);o?B(t,o):(t=>{const n=C(t.pacman.x,t.pacman.y);if(0===n.length)return;const e=n.reduce(((n,[e,a])=>{const o=t.pacman.x+e,i=t.pacman.y+a;let r=1/0;return t.ghosts.forEach((t=>{if(!t.scared){const n=L(t.x,t.y,o,i);r=Math.min(r,n)}})),r>n.distance?{dx:e,dy:a,distance:r}:n}),{dx:0,dy:0,distance:-1/0}),a=t.pacman.x+e.dx,o=t.pacman.y+e.dy;B(t,{x:a,y:o})})(t),(t=>{t.grid[t.pacman.x][t.pacman.y].intensity>0&&(t.pacman.totalPoints+=t.grid[t.pacman.x][t.pacman.y].commitsCount,t.pacman.points++,t.config.pointsIncreasedCallback(t.pacman.totalPoints),t.grid[t.pacman.x][t.pacman.y].intensity=0,t.pacman.points>=10&&T(t))})(t)},F=t=>{const n=10,e=t,a=2*Math.PI-t;return`M 10,10\n L ${n+n*Math.cos(e)},${n+n*Math.sin(e)}\n A 10,10 0 1,1 ${n+n*Math.cos(a)},${n+n*Math.sin(a)}\n Z`},R=(t,n,e)=>t.gameHistory.map((a=>{const o=a.grid[n][e];if(o>0){const n=o<.2?.3:o;return i=f(t).contributionBoxColor,r=n,3===(i=i.replace(/^#/,"")).length&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),`#${i}${Math.round(255*r).toString(16).padStart(2,"0")}`}var i,r;return f(t).emptyContributionBoxColor})),P=t=>{switch(t){case"blinky":return"gb";case"clyde":return"gc";case"inky":return"gi";case"pinky":return"gp";case"scared":return"gs";default:return t}},O=(t,n)=>{if(t.gameHistory.length!==n.length)throw new Error("The length of changingValues must match the length of gameHistory");const e=t.gameHistory.length;let a=[],o=[],i=null,r=null;return n.forEach(((t,n)=>{t!==i&&(null!==i&&null!==r&&n-1!==r&&(a.push(Number(((n-1e-6)/(e-1)).toFixed(6))),o.push(i)),a.push(Number((n/(e-1)).toFixed(6))),o.push(t),i=t,r=n)})),1!==a[a.length-1]&&(a.push(1),o.push(i)),{keyTimes:a.join(";"),values:o.join(";")}},N=t=>{let n='<svg width="1144" height="174" xmlns="http://www.w3.org/2000/svg">';n+=`<desc>Generated with https://github.com/abozanona/pacman-contribution-graph on ${new Date}</desc>`,n+=`<rect width="100%" height="100%" fill="${f(t).gridBackground}"/>`,n+=`<defs>\n\t\t<symbol id="${P("blinky")}" viewBox="0 0 100 100">\n <image href="${l.blinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${P("clyde")}" viewBox="0 0 100 100">\n <image href="${l.clyde.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${P("inky")}" viewBox="0 0 100 100">\n <image href="${l.inky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${P("pinky")}" viewBox="0 0 100 100">\n <image href="${l.pinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${P("scared")}" viewBox="0 0 100 100">\n <image href="${l.scared.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t</defs>`;let i="";for(let a=0;a<e;a++)t.monthLabels[a]!==i&&(n+=`<text x="${22*a+10}" y="10" text-anchor="middle" font-size="10" fill="${f(t).textColor}">${t.monthLabels[a]}</text>`,i=t.monthLabels[a]);for(let a=0;a<e;a++)for(let e=0;e<7;e++){const o=22*a,i=22*e+15,r=O(t,R(t,a,e));n+=`<rect id="c-${a}-${e}" x="${o}" y="${i}" width="20" height="20" rx="5" fill="${f(t).emptyContributionBoxColor}">\n <animate attributeName="fill" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite" \n values="${r.values}" \n keyTimes="${r.keyTimes}"/>\n </rect>`}for(let a=0;a<e;a++)for(let e=0;e<7;e++)u.horizontal[a][e].active&&(n+=`<rect id="wh-${a}-${e}" x="${22*a-2}" y="${22*e-2+15}" width="22" height="2" rx="5" fill="${f(t).wallColor}"></rect>`),u.vertical[a][e].active&&(n+=`<rect id="wv-${a}-${e}" x="${22*a-2}" y="${22*e-2+15}" width="2" height="22" rx="5" fill="${f(t).wallColor}"></rect>`);const r=O(t,(t=>t.gameHistory.map((t=>t.pacman.deadRemainingDuration?o:t.pacman.powerupRemainingDuration?"red":a)))(t)),s=O(t,(t=>t.gameHistory.map((t=>`${22*t.pacman.x},${22*t.pacman.y+15}`)))(t)),h=O(t,(t=>t.gameHistory.map((t=>{switch(t.pacman.direction){case"right":default:return"0 10 10";case"left":return"180 10 10";case"up":return"270 10 10";case"down":return"90 10 10"}})))(t));return n+=`<path id="pacman" d="${F(.55)}"\n >\n\t\t<animate attributeName="fill" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${r.keyTimes}"\n values="${r.values}"/>\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${s.keyTimes}"\n values="${s.values}"\n additive="sum"/>\n <animateTransform attributeName="transform" type="rotate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${h.keyTimes}"\n values="${h.values}"\n additive="sum"/>\n <animate attributeName="d" dur="0.5s" repeatCount="indefinite"\n values="${F(.55)};${F(.05)};${F(.55)}"/>\n </path>`,t.ghosts.forEach(((e,a)=>{const o=O(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return`${22*e.x},${22*e.y+15}`})))(t,a)),i=O(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return"#"+(e.scared?P("scared"):P(e.name))})))(t,a));n+=`<use id="ghost${a}" width="20" height="20" href="#ghost-${e.name}">\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${o.keyTimes}"\n values="${o.values}"/>\n <animate attributeName="href" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${i.keyTimes}"\n values="${i.values}"/>\n </use>`})),n+="</svg>",n};var U=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};const V=t=>{t.ghosts=[],t.ghosts.push({x:23,y:3,name:i[0],scared:!1,target:void 0}),t.ghosts.push({x:24,y:3,name:i[1],scared:!1,target:void 0}),t.ghosts.push({x:27,y:3,name:i[2],scared:!1,target:void 0}),t.ghosts.push({x:28,y:3,name:i[3],scared:!1,target:void 0}),"canvas"==t.config.outputFormat&&b(t)},H=t=>U(void 0,void 0,void 0,(function*(){if(t.frameCount++,t.frameCount%t.config.gameSpeed==0)if(t.pacman.deadRemainingDuration&&(t.pacman.deadRemainingDuration--,t.pacman.deadRemainingDuration||(V(t),"canvas"==t.config.outputFormat&&g.getInstance().play(m.GAME_OVER).then((()=>g.getInstance().startDefaultSound())))),t.pacman.powerupRemainingDuration&&(t.pacman.powerupRemainingDuration--,t.pacman.powerupRemainingDuration||(t.ghosts.forEach((t=>t.scared=!1)),t.pacman.points=0)),t.grid.some((t=>t.some((t=>t.intensity>0)))))E(t),Q(t),t.pacman.deadRemainingDuration||(z(t),Q(t)),t.pacmanMouthOpen=!t.pacmanMouthOpen,t.gameHistory.push({pacman:Object.assign({},t.pacman),ghosts:t.ghosts.map((t=>Object.assign({},t))),grid:t.grid.map((t=>[...t.map((t=>t.intensity))]))}),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&A(t),"canvas"==t.config.outputFormat&&b(t),"canvas"==t.config.outputFormat&&(t=>{if(!t.config.enableSounds)return;const n=t.config.canvas.getContext("2d"),e=t.config.canvas.width-30-10;n.fillStyle=`rgba(0, 0, 0, ${g.getInstance().isMuted?.3:.5})`,n.beginPath(),n.moveTo(e+10,20),n.lineTo(e+20,15),n.lineTo(e+20,35),n.lineTo(e+10,30),n.closePath(),n.fill(),g.getInstance().isMuted?(n.strokeStyle="rgba(255, 0, 0, 0.6)",n.lineWidth=3,n.beginPath(),n.moveTo(e+25,15),n.lineTo(e+5,35),n.stroke()):(n.strokeStyle="rgba(0, 0, 0, 0.4)",n.lineWidth=2,n.beginPath(),n.arc(e+25,25,5,0,2*Math.PI),n.stroke(),n.beginPath(),n.arc(e+25,25,8,0,2*Math.PI),n.stroke())})(t);else{if("canvas"==t.config.outputFormat&&(clearInterval(t.gameInterval),"canvas"==t.config.outputFormat&&((t=>{const n=t.config.canvas.getContext("2d");n.fillStyle=f(t).textColor,n.font="20px Arial",n.textAlign="center",n.fillText("Game Over",t.config.canvas.width/2,t.config.canvas.height/2)})(t),g.getInstance().play(m.BEGINNING).then((()=>g.getInstance().stopDefaultSound())))),"svg"==t.config.outputFormat){const n=N(t);t.config.svgCallback(n)}t.config.gameOverCallback()}else t.gameHistory.push({pacman:Object.assign({},t.pacman),ghosts:t.ghosts.map((t=>Object.assign({},t))),grid:t.grid.map((t=>[...t.map((t=>t.intensity))]))})})),Q=t=>{t.pacman.deadRemainingDuration||t.ghosts.forEach(((n,e)=>{n.x===t.pacman.x&&n.y===t.pacman.y&&(t.pacman.powerupRemainingDuration&&n.scared?(j(t,e),t.pacman.points+=10,"canvas"==t.config.outputFormat&&g.getInstance().play(m.EAT_GHOST)):(t.pacman.points=0,t.pacman.powerupRemainingDuration=0,t.pacman.deadRemainingDuration=10,"canvas"==t.config.outputFormat&&g.getInstance().play(m.GAME_OVER).then((()=>g.getInstance().stopDefaultSound()))))}))},j=(t,n)=>{let a,o;do{a=Math.floor(Math.random()*e),o=Math.floor(7*Math.random())}while(Math.abs(a-t.pacman.x)<=2&&Math.abs(o-t.pacman.y)<=2||0===t.grid[a][o].intensity);t.ghosts[n]={x:a,y:o,name:i[n%i.length],scared:!1,target:void 0}},G=(t,n,a,o,i)=>{"horizontal"==a?(h(t,n,"horizontal",i),"x"==o?h(e-t-1,n,"horizontal",i):"y"==o?h(t,7-n,"horizontal",i):"xy"==o&&(h(e-t-1,n,"horizontal",i),h(t,7-n,"horizontal",i),h(e-t-1,7-n,"horizontal",i))):(h(t,n,"vertical",i),"x"==o?h(e-t,n,"vertical",i):"y"==o?h(t,7-n-1,"vertical",i):"xy"==o&&(h(e-t,n,"vertical",i),h(t,7-n-1,"vertical",i),h(e-t,7-n-1,"vertical",i)))},K={frameCount:0,contributions:[],pacman:{x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0,recentPositions:[]},ghosts:[],grid:[],monthLabels:[],pacmanMouthOpen:!0,gameInterval:0,gameHistory:[],config:void 0};class Y{constructor(t){this.store=structuredClone(K),this.conf=Object.assign({},t),G(0,2,"horizontal","xy","L1"),G(1,2,"horizontal","xy","L1"),G(4,0,"vertical","x","L2"),G(4,1,"vertical","x","L2"),G(4,2,"vertical","x","L2"),G(4,3,"vertical","x","L2"),G(4,4,"vertical","x","L2"),G(3,3,"horizontal","x","L3"),G(2,3,"horizontal","x","L3"),G(4,5,"horizontal","x","L4"),G(6,4,"vertical","x","L5"),G(6,3,"vertical","x","L5"),G(6,2,"vertical","x","L5"),G(6,2,"horizontal","x","L6"),G(7,2,"horizontal","x","L6"),G(8,2,"horizontal","x","L6"),G(9,2,"horizontal","x","L6"),G(13,2,"horizontal","xy","L7"),G(14,2,"horizontal","xy","L7"),G(15,2,"horizontal","xy","L7"),G(16,2,"horizontal","xy","L7"),G(17,2,"horizontal","xy","L7"),G(18,2,"horizontal","xy","L7"),G(16,2,"vertical","xy","L8"),G(8,1,"horizontal","x","L9"),G(9,1,"horizontal","x","L9"),G(10,1,"horizontal","x","L9"),G(11,1,"horizontal","x","L9"),G(12,1,"vertical","x","L10"),G(12,3,"vertical","x","L10"),G(11,4,"horizontal","x","L11"),G(10,4,"horizontal","x","L11"),G(9,4,"horizontal","x","L11"),G(8,4,"horizontal","x","L11"),G(8,4,"vertical","x","L12"),G(8,5,"vertical","x","L12"),G(8,6,"vertical","x","L12"),G(23,2,"horizontal","x","L13"),G(24,2,"horizontal","x","L13"),G(23,4,"horizontal","x","L13"),G(24,4,"horizontal","x","L13"),G(25,4,"horizontal","x","L13"),G(23,2,"vertical","x","L14"),G(23,3,"vertical","x","L14"),G(26,4,"vertical","x","L15"),G(26,5,"vertical","x","L15"),G(23,6,"horizontal","x","L16"),G(24,6,"horizontal","x","L16"),G(25,6,"horizontal","x","L16"),G(26,0,"vertical","x","L17"),G(24,1,"vertical","x","L18"),G(23,1,"horizontal","x","L18"),G(22,1,"horizontal","x","L18"),G(21,1,"horizontal","x","L18"),G(21,1,"vertical","x","L18"),G(21,2,"vertical","x","L18"),G(21,3,"vertical","x","L18"),G(20,4,"horizontal","x","L18"),G(19,4,"horizontal","x","L18"),G(19,3,"vertical","x","L18"),G(18,3,"horizontal","x","L18"),G(22,5,"vertical","x","L19"),G(21,5,"horizontal","x","L19"),G(20,5,"horizontal","x","L19"),G(20,5,"vertical","x","L19"),G(1,6,"horizontal","x","L20"),G(2,6,"horizontal","x","L20"),G(3,5,"vertical","x","L20"),G(3,4,"vertical","x","L20"),G(5,6,"horizontal","x","L21"),G(6,6,"horizontal","x","L21")}start(){return t=this,n=void 0,o=function*(){switch(this.store.config=Object.assign(Object.assign({},{platform:"github",username:"",canvas:void 0,outputFormat:"svg",svgCallback:t=>{},gameOverCallback:()=>()=>{},gameTheme:"github",gameSpeed:1,enableSounds:!1,pointsIncreasedCallback:t=>{}}),this.conf),this.conf.platform){case"gitlab":this.store.contributions=yield(t=this.store,p(void 0,void 0,void 0,(function*(){const n=yield fetch(`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${t.config.username}`),e=yield n.json();return Object.entries(e).map((([t,n])=>({date:new Date(t),count:Number(n)})))})));break;case"github":this.store.contributions=yield(t=>p(void 0,void 0,void 0,(function*(){var n;const e=[];let a=!1,o=1;do{try{const i={};(null===(n=t.config.githubSettings)||void 0===n?void 0:n.accessToken)&&(i.Authorization="Bearer "+t.config.githubSettings.accessToken);const r=yield fetch(`https://api.github.com/search/commits?q=author:${t.config.username}&sort=author-date&order=desc&page=${o}&per_page=1000`,{headers:i}),c=yield r.json();a=0===c.items.length,e.push(...c.items),o++}catch(t){a=!0}}while(!a);return Array.from(e.reduce(((t,n)=>{const e=n.commit.committer.date.split("T")[0],a=new Date(e),o=(t.get(e)||{count:0}).count+1;return t.set(e,{date:a,count:o})}),new Map).values())})))(this.store)}var t;(t=>{U(void 0,void 0,void 0,(function*(){"canvas"==t.config.outputFormat&&(t.config.canvas=t.config.canvas,(t=>{t.config.canvas.width=1144,t.config.canvas.height=174})(t),w(t)),t.frameCount=0,t.ghosts.forEach((t=>t.scared=!1)),(t=>{t.pacman.points=0,t.pacman.totalPoints=0,t.grid=Array.from({length:e},(()=>Array.from({length:7},(()=>({commitsCount:0,intensity:0}))))),t.monthLabels=Array(e).fill("");let n=1;const a=new Date,o=new Date(a);o.setDate(a.getDate()-a.getDay()),t.contributions.forEach((a=>{const i=new Date(a.date),r=i.getDay(),c=Math.floor((+o-+i)/6048e5);c>=0&&c<e&&r>=0&&r<7&&(t.grid[51-c][r]={commitsCount:a.count,intensity:0},a.count>n&&(n=a.count))}));for(let a=0;a<e;a++)for(let e=0;e<7;e++)t.grid[a][e].commitsCount>0&&(t.grid[a][e].intensity=t.grid[a][e].commitsCount/n);for(let n=0;n<e;n++){const e=51-n,a=new Date(o);a.setDate(a.getDate()-7*e),t.monthLabels[n]=r[a.getMonth()]}})(t),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&(t.config.enableSounds||g.getInstance().mute(),yield g.getInstance().preloadSounds(),g.getInstance().startDefaultSound(),yield g.getInstance().play(m.BEGINNING));const n=()=>t.grid.some((t=>t.some((t=>t.intensity>0))));if(n()&&((t=>{t.pacman={x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0,recentPositions:[]},"canvas"==t.config.outputFormat&&A(t)})(t),V(t)),"svg"==t.config.outputFormat){for(;n();)yield H(t);yield H(t)}else clearInterval(t.gameInterval),t.gameInterval=setInterval((()=>U(void 0,void 0,void 0,(function*(){return yield H(t)}))),c)}))})(this.store)},new((a=void 0)||(a=Promise))((function(e,i){function r(t){try{s(o.next(t))}catch(t){i(t)}}function c(t){try{s(o.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(t){t(n)}))).then(r,c)}s((o=o.apply(t,n||[])).next())}));var t,n,a,o}stop(){var t;t=this.store,U(void 0,void 0,void 0,(function*(){clearInterval(t.gameInterval)}))}}var q=n.C;export{q as PacmanRenderer};
@@ -26841,8 +26841,8 @@ var __webpack_exports__ = {};
26841
26841
  var core = __nccwpck_require__(136);
26842
26842
  // EXTERNAL MODULE: external "fs"
26843
26843
  var external_fs_ = __nccwpck_require__(9896);
26844
- ;// CONCATENATED MODULE: ./node_modules/.pnpm/pacman-contribution-graph@1.0.10/node_modules/pacman-contribution-graph/dist/pacman-contribution-graph.min.js
26845
- var t={d:(n,e)=>{for(var a in e)t.o(e,a)&&!t.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n)},n={};t.d(n,{C:()=>K});const e=52,a="yellow",o="#80808064",i=["blinky","clyde","inky","pinky"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=200,s={github:{textColor:"#586069",gridBackground:"#ffffff",contributionBoxColor:"#9be9a8",emptyContributionBoxColor:"#ebedf0",wallColor:"#000000"},"github-dark":{textColor:"#8b949e",gridBackground:"#0d1117",contributionBoxColor:"#26a641",emptyContributionBoxColor:"#161b22",wallColor:"#FFFFFF"},gitlab:{textColor:"#626167",gridBackground:"#ffffff",contributionBoxColor:"#7992f5",emptyContributionBoxColor:"#ececef",wallColor:"#000000"},"gitlab-dark":{textColor:"#999999",gridBackground:"#1f1f1f",contributionBoxColor:"#2e7db1",emptyContributionBoxColor:"#2d2d2d",wallColor:"#FFFFFF"}},l={blinky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfUlEQVQ4T+2TUQ7AIAhDy/0PzQIRAqxmLtnn/DJPWypBAVkKKOMCyOQN7IRElLrcnIrDLNK4wVtxNbkb6Hq+jOcSbim6QVzKEstkw92gxVeFrMpqokix4wA+NvCOnvfArvcEbHoe2G9QmmhDMUc65p3xYC6q3zQPxtdl3NgF5QpL/b/rs3IAAAAASUVORK5CYIIA"},clyde:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgUlEQVQ4T+2T0Q6AIAhFLx9sH1MfTIPCAeLKrcd8PHqP4JBQLN7BFacNlHkAs+AQcqIueBs2mVWjgtWwl4yCdrd/pHYLLlVEgR2yK0wy4SoI5TcGXU4wM+AEJQfwsUCuXngDOR4rqKbngf0C94gyFHmkbd4rbkxD/pv2jfR1Ky7sBNrzXbHpnBX+AAAAAElFTkSuQmCC"},inky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAg0lEQVQ4T+WTWxKAIAhFuQvK/a+jFoT5QAVxypn+6vMEx6sDIO/jk12OAMs1WDVOXV3UBW+bRVbTFMFu8yCZBExH/g26VHCXI0AJpKgdUCUrTlkwxE+FECdzS7HiJemXgvyeO29gE7jD8wDVFX4vSLNtR1q2z+OVlaZxTaXYrq7HbxYBS8VgMVrqzkEAAAAASUVORK5CYIIA"},pinky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAhklEQVQ4T+2T0Q2AIAwF281wC50Qt9DNagoptqVESfyUz4N3vJCCECxaD4o47gt6bsAo2IWUqAnehkUmbYpgNqwlvSCnur+dtnnAuYUVyCGJimTAi8DUzwmwOoGI7hYjDgAfC/jqiTfg47ZBND0P7BeoR+Sh8CMt8x5xYSWkv2nbcF834swuA/9u49Yy5bgAAAAASUVORK5CYIIA"},scared:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAeUlEQVQ4T82TUQ6AMAhD7UX0/sdyF0GREVmDmTN+bH9r6Bs0A0t2VpFULwDrrfBkZFcA3YC3ZodViAFGzQHyP0B2w2NrB0/1AoDbHwLoQ5/nrw1OBuD5e/crbM9Aiz35njHWzpSB/m3+0r40mV41M8U19WJe3Uw/tQOKt08pUUbBEQAAAABJRU5ErkJgggAA"}},u={horizontal:Array(53).fill(null).map((()=>Array(8).fill({active:!1,id:""}))),vertical:Array(53).fill(null).map((()=>Array(8).fill({active:!1,id:""})))},h=(t,n,e,a)=>{"horizontal"===e?t>=0&&t<u.horizontal.length&&n>=0&&n<u.horizontal[0].length&&(u.horizontal[t][n]={active:!0,id:a}):t>=0&&t<u.vertical.length&&n>=0&&n<u.vertical[0].length&&(u.vertical[t][n]={active:!0,id:a})};var d,g=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};!function(t){t.DEFAULT="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_chomp.wav",t.BEGINNING="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_beginning.wav",t.GAME_OVER="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_death.wav",t.EAT_GHOST="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_eatghost.wav"}(d||(d={}));class m{constructor(){this.sounds=new Map,this.currentSource=null,this.defaultSource=null,this.isMuted=!1,this.audioContext=new AudioContext}static getInstance(){return m.instance||(m.instance=new m),m.instance}preloadSounds(){return g(this,void 0,void 0,(function*(){for(const t of Object.values(d)){const n=yield fetch(t),e=yield n.arrayBuffer(),a=yield this.audioContext.decodeAudioData(e);this.sounds.set(t,a)}}))}play(t){return g(this,void 0,void 0,(function*(){if(this.isMuted)return;if(this.currentSource)try{this.currentSource.stop()}catch(t){}const n=this.sounds.get(t);if(n)return this.currentSource=this.audioContext.createBufferSource(),this.currentSource.buffer=n,this.currentSource.connect(this.audioContext.destination),this.isMuted||this.currentSource.start(),new Promise((t=>{this.currentSource.onended=()=>{this.currentSource=null,t()}}));console.error(`Sound ${t} not found`)}))}startDefaultSound(){if(this.defaultSource)try{this.defaultSource.stop()}catch(t){}const t=this.sounds.get(d.DEFAULT);t?(this.defaultSource=this.audioContext.createBufferSource(),this.defaultSource.buffer=t,this.defaultSource.loop=!0,this.defaultSource.connect(this.audioContext.destination),this.isMuted||this.defaultSource.start()):console.error("Default sound not found")}stopDefaultSound(){if(this.defaultSource){try{this.defaultSource.stop()}catch(t){}this.defaultSource=null}}mute(){this.isMuted=!0,this.currentSource&&this.currentSource.disconnect(),this.defaultSource&&this.defaultSource.disconnect()}unmute(){this.isMuted=!1,this.currentSource&&this.currentSource.connect(this.audioContext.destination),this.defaultSource&&this.defaultSource.connect(this.audioContext.destination)}}var f=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};const p=t=>{var n;return null!==(n=s[t.config.gameTheme])&&void 0!==n?n:s.github},y={},x=(t,n)=>{if(!y[t]){const e=new Image;e.src=n,y[t]=e}return y[t]},v=t=>{const n=t.config.canvas.getContext("2d");n.fillStyle=p(t).gridBackground,n.fillRect(0,0,t.config.canvas.width,t.config.canvas.height);for(let i=0;i<e;i++)for(let e=0;e<7;e++){const r=t.grid[i][e].intensity;if(r>0){const e=r<.2?.3:r,i=(a=p(t).contributionBoxColor,o=e,`rgba(${parseInt(a.slice(1,3),16)}, ${parseInt(a.slice(3,5),16)}, ${parseInt(a.slice(5,7),16)}, ${o})`);n.fillStyle=i}else n.fillStyle=p(t).emptyContributionBoxColor;n.beginPath(),t.config.canvas.getContext("2d").roundRect(22*i,22*e+15,20,20,5),n.fill()}var a,o;n.fillStyle=p(t).wallColor;for(let t=0;t<=e;t++)for(let e=0;e<=7;e++)u.horizontal[t][e].active&&n.fillRect(22*t-2,22*e-2+15,22,2),u.vertical[t][e].active&&n.fillRect(22*t-2,22*e-2+15,2,22);n.fillStyle=p(t).textColor,n.font="10px Arial",n.textAlign="center";let i="";for(let a=0;a<e;a++)if(t.monthLabels[a]!==i){const e=22*a+10;n.fillText(t.monthLabels[a],e,10),i=t.monthLabels[a]}},A=t=>{const n=t.config.canvas.getContext("2d"),e=22*t.pacman.x+10,i=22*t.pacman.y+10+15;t.pacman.deadRemainingDuration?n.fillStyle=o:t.pacman.powerupRemainingDuration?n.fillStyle="red":n.fillStyle=a;const r=t.pacmanMouthOpen?.35*Math.PI:.1*Math.PI;let c,s;switch(t.pacman.direction){case"up":c=1.5*Math.PI+r,s=1.5*Math.PI-r;break;case"down":c=.5*Math.PI+r,s=.5*Math.PI-r;break;case"left":c=Math.PI+r,s=Math.PI-r;break;default:c=0+r,s=2*Math.PI-r}n.beginPath(),n.arc(e,i,10,c,s),n.lineTo(e,i),n.fill()},b=t=>{t.ghosts.forEach((n=>{const e=22*n.x,a=22*n.y+15,o=t.config.canvas.getContext("2d");n.scared?o.drawImage(x("scared",l.scared.imgDate),e,a,20,20):o.drawImage(x(n.name,l[n.name].imgDate),e,a,20,20)}))},w=t=>{t.config.enableSounds&&t.config.canvas.addEventListener("click",(function(n){const e=t.config.canvas.getBoundingClientRect(),a=n.clientX-e.left,o=n.clientY-e.top,i=t.config.canvas.width-30-10;a>=i&&a<=i+this.width&&o>=10&&o<=10+this.height&&(m.getInstance().isMuted?m.getInstance().unmute():m.getInstance().mute())}))},C=(t,n)=>[[-1,0],[1,0],[0,-1],[0,1]].filter((([a,o])=>{const i=t+a,r=n+o;return!(i<0||i>=e||r<0||r>=7||(-1===a?u.vertical[t][n].active:1===a?u.vertical[t+1][n].active:-1===o?u.horizontal[t][n].active:1===o&&u.horizontal[t][n+1].active))})),L=(t,n,e,a)=>Math.sqrt(Math.pow(e-t,2)+Math.pow(a-n,2)),M=(t,n,e,a)=>{if(t===e&&n===a)return null;const o=[{x:t,y:n,path:[]}],i=new Set;for(i.add(`${t},${n}`);o.length>0;){const t=o.shift(),{x:n,y:r,path:c}=t,s=C(n,r);for(const[t,l]of s){const s=n+t,u=r+l,h=`${s},${u}`;if(i.has(h))continue;i.add(h);const d=[...c,{x:s,y:u}];if(s===e&&u===a)return d.length>0?d[0]:null;o.push({x:s,y:u,path:d})}}return null},S=(t,n)=>{const{pacman:e}=n;let a=[0,0];switch(t.name){case"blinky":default:return{x:e.x,y:e.y};case"pinky":a=$(n);const o=4;let i={x:e.x+a[0]*o,y:e.y+a[1]*o};return i.x=Math.min(Math.max(i.x,0),51),i.y=Math.min(Math.max(i.y,0),6),i;case"inky":const r=n.ghosts.find((t=>"blinky"===t.name));a=$(n);let c={x:e.x+2*a[0],y:e.y+2*a[1]};return r&&(c={x:c.x+(c.x-r.x),y:c.y+(c.y-r.y)}),c.x=Math.min(Math.max(c.x,0),51),c.y=Math.min(Math.max(c.y,0),6),c;case"clyde":return L(t.x,t.y,e.x,e.y)>8?{x:e.x,y:e.y}:{x:0,y:6}}},$=t=>{switch(t.pacman.direction){case"right":return[1,0];case"left":return[-1,0];case"up":return[0,-1];case"down":return[0,1];default:return[0,0]}},D=(t,n)=>{const e=t+Math.floor(17*Math.random())-8,a=n+Math.floor(17*Math.random())-8;return{x:Math.max(0,Math.min(e,51)),y:Math.max(0,Math.min(a,6))}},z=t=>{t.ghosts.forEach((n=>{n.scared||Math.random()<.15?((t,n)=>{(!t.target||t.x===t.target.x&&t.y===t.target.y)&&(t.target=D(t.x,t.y));const e=C(t.x,t.y);if(0===e.length)return;const a=t.target.x-t.x,o=t.target.y-t.y;let i=e.filter((t=>{if(Math.random()<.3)return!0;const n=t[0],e=t[1];return a>0&&n>0||a<0&&n<0||o>0&&e>0||o<0&&e<0}));0===i.length&&(i=e);const[r,c]=i[Math.floor(Math.random()*i.length)];n.pacman.powerupRemainingDuration&&Math.random()<.5||(t.x+=r,t.y+=c)})(n,t):((t,n)=>{const e=S(t,n);t.target=e;const a=M(t.x,t.y,e.x,e.y);a&&(t.x=a.x,t.y=a.y)})(n,t)}))},k=t=>{const n=new Map,a=!!t.pacman.powerupRemainingDuration;if(t.ghosts.forEach((t=>{if(!t.scared)for(let a=-5;a<=5;a++)for(let o=-5;o<=5;o++){const i=t.x+a,r=t.y+o;if(i>=0&&i<e&&r>=0&&r<7){const t=`${i},${r}`,e=15-(Math.abs(a)+Math.abs(o));if(e>0){const a=n.get(t)||0;n.set(t,Math.max(a,e))}}}})),a)for(const[t,e]of n.entries())n.set(t,e/5);return n},I=(t,n)=>{var e;(e=t.pacman).recentPositions||(e.recentPositions=[]),t.pacman.recentPositions.push(`${n.x},${n.y}`),t.pacman.recentPositions.length>5&&t.pacman.recentPositions.shift();const a=n.x-t.pacman.x,o=n.y-t.pacman.y;a>0?t.pacman.direction="right":a<0?t.pacman.direction="left":o>0?t.pacman.direction="down":o<0&&(t.pacman.direction="up"),t.pacman.x=n.x,t.pacman.y=n.y},B=t=>{t.pacman.powerupRemainingDuration=15,t.ghosts.forEach((t=>t.scared=!0))},T=t=>{if(t.pacman.deadRemainingDuration)return;const n=!!t.pacman.powerupRemainingDuration,a=t.ghosts.filter((t=>t.scared));let o=null;if(o=n&&a.length>0?(t=>{const n=t.ghosts.filter((t=>t.scared));return 0===n.length?null:n.reduce(((n,e)=>{const a=L(e.x,e.y,t.pacman.x,t.pacman.y);return a<n.distance?{x:e.x,y:e.y,distance:a}:n}),{x:t.pacman.x,y:t.pacman.y,distance:1/0})})(t):(t=>{let n=[];for(let a=0;a<e;a++)for(let e=0;e<7;e++)if(t.grid[a][e].intensity>0){const o=L(a,e,t.pacman.x,t.pacman.y),i=t.grid[a][e].intensity/(o+1);n.push({x:a,y:e,value:i})}return 0===n.length?null:(n.sort(((t,n)=>n.value-t.value)),n[0])})(t),!o)return;const i=((t,n)=>{var e;const a=[{x:t.pacman.x,y:t.pacman.y,path:[],score:0}],o=new Set;o.add(`${t.pacman.x},${t.pacman.y}`);const i=k(t);for(;a.length>0;){a.sort(((t,n)=>n.score-t.score));const r=a.shift(),{x:c,y:s,path:l}=r;if(c===n.x&&s===n.y)return l.length>0?l[0]:null;const u=C(c,s);for(const[r,h]of u){const u=c+r,d=s+h,g=`${u},${d}`;if(!o.has(g)){const r=[...l,{x:u,y:d}],c=i.get(g)||0,s=t.grid[u][d].intensity,h=L(u,d,n.x,n.y);let m=0;(null===(e=t.pacman.recentPositions)||void 0===e?void 0:e.includes(g))&&(m+=100),a.push({x:u,y:d,path:r,score:s-c-h/10-m}),o.add(g)}}}return null})(t,o);i?I(t,i):(t=>{const n=C(t.pacman.x,t.pacman.y);if(0===n.length)return;const e=n.reduce(((n,[e,a])=>{const o=t.pacman.x+e,i=t.pacman.y+a;let r=1/0;return t.ghosts.forEach((t=>{if(!t.scared){const n=L(t.x,t.y,o,i);r=Math.min(r,n)}})),r>n.distance?{dx:e,dy:a,distance:r}:n}),{dx:0,dy:0,distance:-1/0}),a=t.pacman.x+e.dx,o=t.pacman.y+e.dy;I(t,{x:a,y:o})})(t),(t=>{t.grid[t.pacman.x][t.pacman.y].intensity>0&&(t.pacman.totalPoints+=t.grid[t.pacman.x][t.pacman.y].commitsCount,t.pacman.points++,t.config.pointsIncreasedCallback(t.pacman.totalPoints),t.grid[t.pacman.x][t.pacman.y].intensity=0,t.pacman.points>=30&&B(t))})(t)},E=t=>{const n=10,e=t,a=2*Math.PI-t;return`M 10,10\n L ${n+n*Math.cos(e)},${n+n*Math.sin(e)}\n A 10,10 0 1,1 ${n+n*Math.cos(a)},${n+n*Math.sin(a)}\n Z`},F=(t,n,e)=>t.gameHistory.map((a=>{const o=a.grid[n][e];if(o>0){const n=o<.2?.3:o;return i=p(t).contributionBoxColor,r=n,3===(i=i.replace(/^#/,"")).length&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),`#${i}${Math.round(255*r).toString(16).padStart(2,"0")}`}var i,r;return p(t).emptyContributionBoxColor})),R=t=>{switch(t){case"blinky":return"gb";case"clyde":return"gc";case"inky":return"gi";case"pinky":return"gp";case"scared":return"gs";default:return t}},P=(t,n)=>{if(t.gameHistory.length!==n.length)throw new Error("The length of changingValues must match the length of gameHistory");const e=t.gameHistory.length;let a=[],o=[],i=null,r=null;return n.forEach(((t,n)=>{t!==i&&(null!==i&&null!==r&&n-1!==r&&(a.push(Number(((n-1e-6)/(e-1)).toFixed(6))),o.push(i)),a.push(Number((n/(e-1)).toFixed(6))),o.push(t),i=t,r=n)})),1!==a[a.length-1]&&(a.push(1),o.push(i)),{keyTimes:a.join(";"),values:o.join(";")}},O=t=>{let n='<svg width="1144" height="174" xmlns="http://www.w3.org/2000/svg">';n+=`<desc>Generated with https://github.com/abozanona/pacman-contribution-graph on ${new Date}</desc>`,n+=`<rect width="100%" height="100%" fill="${p(t).gridBackground}"/>`,n+=`<defs>\n\t\t<symbol id="${R("blinky")}" viewBox="0 0 100 100">\n <image href="${l.blinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("clyde")}" viewBox="0 0 100 100">\n <image href="${l.clyde.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("inky")}" viewBox="0 0 100 100">\n <image href="${l.inky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("pinky")}" viewBox="0 0 100 100">\n <image href="${l.pinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("scared")}" viewBox="0 0 100 100">\n <image href="${l.scared.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t</defs>`;let i="";for(let a=0;a<e;a++)t.monthLabels[a]!==i&&(n+=`<text x="${22*a+10}" y="10" text-anchor="middle" font-size="10" fill="${p(t).textColor}">${t.monthLabels[a]}</text>`,i=t.monthLabels[a]);for(let a=0;a<e;a++)for(let e=0;e<7;e++){const o=22*a,i=22*e+15,r=P(t,F(t,a,e));n+=`<rect id="c-${a}-${e}" x="${o}" y="${i}" width="20" height="20" rx="5" fill="${p(t).emptyContributionBoxColor}">\n <animate attributeName="fill" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite" \n values="${r.values}" \n keyTimes="${r.keyTimes}"/>\n </rect>`}for(let a=0;a<e;a++)for(let e=0;e<7;e++)u.horizontal[a][e].active&&(n+=`<rect id="wh-${a}-${e}" x="${22*a-2}" y="${22*e-2+15}" width="22" height="2" rx="5" fill="${p(t).wallColor}"></rect>`),u.vertical[a][e].active&&(n+=`<rect id="wv-${a}-${e}" x="${22*a-2}" y="${22*e-2+15}" width="2" height="22" rx="5" fill="${p(t).wallColor}"></rect>`);const r=P(t,(t=>t.gameHistory.map((t=>t.pacman.deadRemainingDuration?o:t.pacman.powerupRemainingDuration?"red":a)))(t)),s=P(t,(t=>t.gameHistory.map((t=>`${22*t.pacman.x},${22*t.pacman.y+15}`)))(t)),h=P(t,(t=>t.gameHistory.map((t=>{switch(t.pacman.direction){case"right":default:return"0 10 10";case"left":return"180 10 10";case"up":return"270 10 10";case"down":return"90 10 10"}})))(t));return n+=`<path id="pacman" d="${E(.55)}"\n >\n\t\t<animate attributeName="fill" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${r.keyTimes}"\n values="${r.values}"/>\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${s.keyTimes}"\n values="${s.values}"\n additive="sum"/>\n <animateTransform attributeName="transform" type="rotate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${h.keyTimes}"\n values="${h.values}"\n additive="sum"/>\n <animate attributeName="d" dur="0.5s" repeatCount="indefinite"\n values="${E(.55)};${E(.05)};${E(.55)}"/>\n </path>`,t.ghosts.forEach(((e,a)=>{const o=P(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return`${22*e.x},${22*e.y+15}`})))(t,a)),i=P(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return"#"+(e.scared?R("scared"):R(e.name))})))(t,a));n+=`<use id="ghost${a}" width="20" height="20" href="#ghost-${e.name}">\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${o.keyTimes}"\n values="${o.values}"/>\n <animate attributeName="href" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${i.keyTimes}"\n values="${i.values}"/>\n </use>`})),n+="</svg>",n};var N=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};const U=t=>{t.ghosts=[],t.ghosts.push({x:23,y:3,name:i[0],scared:!1,target:void 0}),t.ghosts.push({x:24,y:3,name:i[1],scared:!1,target:void 0}),t.ghosts.push({x:27,y:3,name:i[2],scared:!1,target:void 0}),t.ghosts.push({x:28,y:3,name:i[3],scared:!1,target:void 0}),"canvas"==t.config.outputFormat&&b(t)},V=t=>N(void 0,void 0,void 0,(function*(){if(t.frameCount++,t.frameCount%t.config.gameSpeed==0)if(t.pacman.deadRemainingDuration&&(t.pacman.deadRemainingDuration--,t.pacman.deadRemainingDuration||(U(t),"canvas"==t.config.outputFormat&&m.getInstance().play(d.GAME_OVER).then((()=>m.getInstance().startDefaultSound())))),t.pacman.powerupRemainingDuration&&(t.pacman.powerupRemainingDuration--,t.pacman.powerupRemainingDuration||(t.ghosts.forEach((t=>t.scared=!1)),t.pacman.points=0)),t.grid.some((t=>t.some((t=>t.intensity>0)))))T(t),H(t),t.pacman.deadRemainingDuration||(z(t),H(t)),t.pacmanMouthOpen=!t.pacmanMouthOpen,t.gameHistory.push({pacman:Object.assign({},t.pacman),ghosts:t.ghosts.map((t=>Object.assign({},t))),grid:t.grid.map((t=>[...t.map((t=>t.intensity))]))}),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&A(t),"canvas"==t.config.outputFormat&&b(t),"canvas"==t.config.outputFormat&&(t=>{if(!t.config.enableSounds)return;const n=t.config.canvas.getContext("2d"),e=t.config.canvas.width-30-10;n.fillStyle=`rgba(0, 0, 0, ${m.getInstance().isMuted?.3:.5})`,n.beginPath(),n.moveTo(e+10,20),n.lineTo(e+20,15),n.lineTo(e+20,35),n.lineTo(e+10,30),n.closePath(),n.fill(),m.getInstance().isMuted?(n.strokeStyle="rgba(255, 0, 0, 0.6)",n.lineWidth=3,n.beginPath(),n.moveTo(e+25,15),n.lineTo(e+5,35),n.stroke()):(n.strokeStyle="rgba(0, 0, 0, 0.4)",n.lineWidth=2,n.beginPath(),n.arc(e+25,25,5,0,2*Math.PI),n.stroke(),n.beginPath(),n.arc(e+25,25,8,0,2*Math.PI),n.stroke())})(t);else{if("canvas"==t.config.outputFormat&&(clearInterval(t.gameInterval),"canvas"==t.config.outputFormat&&((t=>{const n=t.config.canvas.getContext("2d");n.fillStyle=p(t).textColor,n.font="20px Arial",n.textAlign="center",n.fillText("Game Over",t.config.canvas.width/2,t.config.canvas.height/2)})(t),m.getInstance().play(d.BEGINNING).then((()=>m.getInstance().stopDefaultSound())))),"svg"==t.config.outputFormat){const n=O(t);t.config.svgCallback(n)}t.config.gameOverCallback()}else t.gameHistory.push({pacman:Object.assign({},t.pacman),ghosts:t.ghosts.map((t=>Object.assign({},t))),grid:t.grid.map((t=>[...t.map((t=>t.intensity))]))})})),H=t=>{t.pacman.deadRemainingDuration||t.ghosts.forEach(((n,e)=>{n.x===t.pacman.x&&n.y===t.pacman.y&&(t.pacman.powerupRemainingDuration&&n.scared?(Q(t,e),t.pacman.points+=10,"canvas"==t.config.outputFormat&&m.getInstance().play(d.EAT_GHOST)):(t.pacman.points=0,t.pacman.powerupRemainingDuration=0,t.pacman.deadRemainingDuration=10,"canvas"==t.config.outputFormat&&m.getInstance().play(d.GAME_OVER).then((()=>m.getInstance().stopDefaultSound()))))}))},Q=(t,n)=>{let a,o;do{a=Math.floor(Math.random()*e),o=Math.floor(7*Math.random())}while(Math.abs(a-t.pacman.x)<=2&&Math.abs(o-t.pacman.y)<=2||0===t.grid[a][o].intensity);t.ghosts[n]={x:a,y:o,name:i[n%i.length],scared:!1,target:void 0}},j=(t,n,a,o,i)=>{"horizontal"==a?(h(t,n,"horizontal",i),"x"==o?h(e-t-1,n,"horizontal",i):"y"==o?h(t,7-n,"horizontal",i):"xy"==o&&(h(e-t-1,n,"horizontal",i),h(t,7-n,"horizontal",i),h(e-t-1,7-n,"horizontal",i))):(h(t,n,"vertical",i),"x"==o?h(e-t,n,"vertical",i):"y"==o?h(t,7-n-1,"vertical",i):"xy"==o&&(h(e-t,n,"vertical",i),h(t,7-n-1,"vertical",i),h(e-t,7-n-1,"vertical",i)))},G={frameCount:0,contributions:[],pacman:{x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0,recentPositions:[]},ghosts:[],grid:[],monthLabels:[],pacmanMouthOpen:!0,gameInterval:0,gameHistory:[],config:void 0};class K{constructor(t){this.store=Object.assign({},G),this.conf=Object.assign({},t),j(0,2,"horizontal","xy","L1"),j(1,2,"horizontal","xy","L1"),j(4,0,"vertical","x","L2"),j(4,1,"vertical","x","L2"),j(4,2,"vertical","x","L2"),j(4,3,"vertical","x","L2"),j(4,4,"vertical","x","L2"),j(3,3,"horizontal","x","L3"),j(2,3,"horizontal","x","L3"),j(4,5,"horizontal","x","L4"),j(6,4,"vertical","x","L5"),j(6,3,"vertical","x","L5"),j(6,2,"vertical","x","L5"),j(6,2,"horizontal","x","L6"),j(7,2,"horizontal","x","L6"),j(8,2,"horizontal","x","L6"),j(9,2,"horizontal","x","L6"),j(13,2,"horizontal","xy","L7"),j(14,2,"horizontal","xy","L7"),j(15,2,"horizontal","xy","L7"),j(16,2,"horizontal","xy","L7"),j(17,2,"horizontal","xy","L7"),j(18,2,"horizontal","xy","L7"),j(16,2,"vertical","xy","L8"),j(8,1,"horizontal","x","L9"),j(9,1,"horizontal","x","L9"),j(10,1,"horizontal","x","L9"),j(11,1,"horizontal","x","L9"),j(12,1,"vertical","x","L10"),j(12,3,"vertical","x","L10"),j(11,4,"horizontal","x","L11"),j(10,4,"horizontal","x","L11"),j(9,4,"horizontal","x","L11"),j(8,4,"horizontal","x","L11"),j(8,4,"vertical","x","L12"),j(8,5,"vertical","x","L12"),j(8,6,"vertical","x","L12"),j(23,2,"horizontal","x","L13"),j(24,2,"horizontal","x","L13"),j(23,4,"horizontal","x","L13"),j(24,4,"horizontal","x","L13"),j(25,4,"horizontal","x","L13"),j(23,2,"vertical","x","L14"),j(23,3,"vertical","x","L14"),j(26,4,"vertical","x","L15"),j(26,5,"vertical","x","L15"),j(23,6,"horizontal","x","L16"),j(24,6,"horizontal","x","L16"),j(25,6,"horizontal","x","L16"),j(26,0,"vertical","x","L17"),j(24,1,"vertical","x","L18"),j(23,1,"horizontal","x","L18"),j(22,1,"horizontal","x","L18"),j(21,1,"horizontal","x","L18"),j(21,1,"vertical","x","L18"),j(21,2,"vertical","x","L18"),j(21,3,"vertical","x","L18"),j(20,4,"horizontal","x","L18"),j(19,4,"horizontal","x","L18"),j(19,3,"vertical","x","L18"),j(18,3,"horizontal","x","L18"),j(22,5,"vertical","x","L19"),j(21,5,"horizontal","x","L19"),j(20,5,"horizontal","x","L19"),j(20,5,"vertical","x","L19"),j(1,6,"horizontal","x","L20"),j(2,6,"horizontal","x","L20"),j(3,5,"vertical","x","L20"),j(3,4,"vertical","x","L20"),j(5,6,"horizontal","x","L21"),j(6,6,"horizontal","x","L21")}start(){return t=this,n=void 0,o=function*(){switch(this.store.config=Object.assign(Object.assign({},{platform:"github",username:"",canvas:void 0,outputFormat:"svg",svgCallback:t=>{},gameOverCallback:()=>()=>{},gameTheme:"github",gameSpeed:1,enableSounds:!1,pointsIncreasedCallback:t=>{}}),this.conf),this.conf.platform){case"gitlab":this.store.contributions=yield(t=this.store,f(void 0,void 0,void 0,(function*(){const n=yield fetch(`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${t.config.username}`),e=yield n.json();return Object.entries(e).map((([t,n])=>({date:new Date(t),count:Number(n)})))})));break;case"github":this.store.contributions=yield(t=>f(void 0,void 0,void 0,(function*(){var n;const e=[];let a=!1,o=1;do{try{const i={};(null===(n=t.config.githubSettings)||void 0===n?void 0:n.accessToken)&&(i.Authorization="Bearer "+t.config.githubSettings.accessToken);const r=yield fetch(`https://api.github.com/search/commits?q=author:${t.config.username}&sort=author-date&order=desc&page=${o}&per_page=1000`,{headers:i}),c=yield r.json();a=0===c.items.length,e.push(...c.items),o++}catch(t){a=!0}}while(!a);return Array.from(e.reduce(((t,n)=>{const e=n.commit.committer.date.split("T")[0],a=new Date(e),o=(t.get(e)||{count:0}).count+1;return t.set(e,{date:a,count:o})}),new Map).values())})))(this.store)}var t;(t=>{N(void 0,void 0,void 0,(function*(){"canvas"==t.config.outputFormat&&(t.config.canvas=t.config.canvas,(t=>{t.config.canvas.width=1144,t.config.canvas.height=174})(t),w(t)),t.frameCount=0,t.ghosts.forEach((t=>t.scared=!1)),(t=>{t.pacman.points=0,t.pacman.totalPoints=0,t.grid=Array.from({length:e},(()=>Array.from({length:7},(()=>({commitsCount:0,intensity:0}))))),t.monthLabels=Array(e).fill("");let n=1;const a=new Date,o=new Date(a);o.setDate(a.getDate()-a.getDay()),t.contributions.forEach((a=>{const i=new Date(a.date),r=i.getDay(),c=Math.floor((+o-+i)/6048e5);c>=0&&c<e&&r>=0&&r<7&&(t.grid[51-c][r]={commitsCount:a.count,intensity:0},a.count>n&&(n=a.count))}));for(let a=0;a<e;a++)for(let e=0;e<7;e++)t.grid[a][e].commitsCount>0&&(t.grid[a][e].intensity=t.grid[a][e].commitsCount/n);for(let n=0;n<e;n++){const e=51-n,a=new Date(o);a.setDate(a.getDate()-7*e),t.monthLabels[n]=r[a.getMonth()]}})(t),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&(t.config.enableSounds||m.getInstance().mute(),yield m.getInstance().preloadSounds(),m.getInstance().startDefaultSound(),yield m.getInstance().play(d.BEGINNING));const n=()=>t.grid.some((t=>t.some((t=>t.intensity>0))));if(n()&&((t=>{t.pacman={x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0,recentPositions:[]},"canvas"==t.config.outputFormat&&A(t)})(t),U(t)),"svg"==t.config.outputFormat){for(;n();)yield V(t);yield V(t)}else clearInterval(t.gameInterval),t.gameInterval=setInterval((()=>N(void 0,void 0,void 0,(function*(){return yield V(t)}))),c)}))})(this.store)},new((a=void 0)||(a=Promise))((function(e,i){function r(t){try{s(o.next(t))}catch(t){i(t)}}function c(t){try{s(o.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(t){t(n)}))).then(r,c)}s((o=o.apply(t,n||[])).next())}));var t,n,a,o}stop(){var t;t=this.store,N(void 0,void 0,void 0,(function*(){clearInterval(t.gameInterval)}))}}var Y=n.C;
26844
+ ;// CONCATENATED MODULE: ./node_modules/.pnpm/pacman-contribution-graph@1.0.13/node_modules/pacman-contribution-graph/dist/pacman-contribution-graph.min.js
26845
+ var t={d:(n,e)=>{for(var a in e)t.o(e,a)&&!t.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n)},n={};t.d(n,{C:()=>K});const e=52,a="yellow",o="#80808064",i=["blinky","clyde","inky","pinky"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=200,s={github:{textColor:"#586069",gridBackground:"#ffffff",contributionBoxColor:"#9be9a8",emptyContributionBoxColor:"#ebedf0",wallColor:"#000000"},"github-dark":{textColor:"#8b949e",gridBackground:"#0d1117",contributionBoxColor:"#26a641",emptyContributionBoxColor:"#161b22",wallColor:"#FFFFFF"},gitlab:{textColor:"#626167",gridBackground:"#ffffff",contributionBoxColor:"#7992f5",emptyContributionBoxColor:"#ececef",wallColor:"#000000"},"gitlab-dark":{textColor:"#999999",gridBackground:"#1f1f1f",contributionBoxColor:"#2e7db1",emptyContributionBoxColor:"#2d2d2d",wallColor:"#FFFFFF"}},l={blinky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfUlEQVQ4T+2TUQ7AIAhDy/0PzQIRAqxmLtnn/DJPWypBAVkKKOMCyOQN7IRElLrcnIrDLNK4wVtxNbkb6Hq+jOcSbim6QVzKEstkw92gxVeFrMpqokix4wA+NvCOnvfArvcEbHoe2G9QmmhDMUc65p3xYC6q3zQPxtdl3NgF5QpL/b/rs3IAAAAASUVORK5CYIIA"},clyde:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgUlEQVQ4T+2T0Q6AIAhFLx9sH1MfTIPCAeLKrcd8PHqP4JBQLN7BFacNlHkAs+AQcqIueBs2mVWjgtWwl4yCdrd/pHYLLlVEgR2yK0wy4SoI5TcGXU4wM+AEJQfwsUCuXngDOR4rqKbngf0C94gyFHmkbd4rbkxD/pv2jfR1Ky7sBNrzXbHpnBX+AAAAAElFTkSuQmCC"},inky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAg0lEQVQ4T+WTWxKAIAhFuQvK/a+jFoT5QAVxypn+6vMEx6sDIO/jk12OAMs1WDVOXV3UBW+bRVbTFMFu8yCZBExH/g26VHCXI0AJpKgdUCUrTlkwxE+FECdzS7HiJemXgvyeO29gE7jD8wDVFX4vSLNtR1q2z+OVlaZxTaXYrq7HbxYBS8VgMVrqzkEAAAAASUVORK5CYIIA"},pinky:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAhklEQVQ4T+2T0Q2AIAwF281wC50Qt9DNagoptqVESfyUz4N3vJCCECxaD4o47gt6bsAo2IWUqAnehkUmbYpgNqwlvSCnur+dtnnAuYUVyCGJimTAi8DUzwmwOoGI7hYjDgAfC/jqiTfg47ZBND0P7BeoR+Sh8CMt8x5xYSWkv2nbcF834swuA/9u49Yy5bgAAAAASUVORK5CYIIA"},scared:{imgDate:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAeUlEQVQ4T82TUQ6AMAhD7UX0/sdyF0GREVmDmTN+bH9r6Bs0A0t2VpFULwDrrfBkZFcA3YC3ZodViAFGzQHyP0B2w2NrB0/1AoDbHwLoQ5/nrw1OBuD5e/crbM9Aiz35njHWzpSB/m3+0r40mV41M8U19WJe3Uw/tQOKt08pUUbBEQAAAABJRU5ErkJgggAA"}},u={horizontal:Array(53).fill(null).map((()=>Array(8).fill({active:!1,id:""}))),vertical:Array(53).fill(null).map((()=>Array(8).fill({active:!1,id:""})))},h=(t,n,e,a)=>{"horizontal"===e?t>=0&&t<u.horizontal.length&&n>=0&&n<u.horizontal[0].length&&(u.horizontal[t][n]={active:!0,id:a}):t>=0&&t<u.vertical.length&&n>=0&&n<u.vertical[0].length&&(u.vertical[t][n]={active:!0,id:a})};var d,m=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};!function(t){t.DEFAULT="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_chomp.wav",t.BEGINNING="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_beginning.wav",t.GAME_OVER="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_death.wav",t.EAT_GHOST="https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_eatghost.wav"}(d||(d={}));class g{constructor(){this.sounds=new Map,this.currentSource=null,this.defaultSource=null,this.isMuted=!1,this.audioContext=new AudioContext}static getInstance(){return g.instance||(g.instance=new g),g.instance}preloadSounds(){return m(this,void 0,void 0,(function*(){for(const t of Object.values(d)){const n=yield fetch(t),e=yield n.arrayBuffer(),a=yield this.audioContext.decodeAudioData(e);this.sounds.set(t,a)}}))}play(t){return m(this,void 0,void 0,(function*(){if(this.isMuted)return;if(this.currentSource)try{this.currentSource.stop()}catch(t){}const n=this.sounds.get(t);if(n)return this.currentSource=this.audioContext.createBufferSource(),this.currentSource.buffer=n,this.currentSource.connect(this.audioContext.destination),this.isMuted||this.currentSource.start(),new Promise((t=>{this.currentSource.onended=()=>{this.currentSource=null,t()}}));console.error(`Sound ${t} not found`)}))}startDefaultSound(){if(this.defaultSource)try{this.defaultSource.stop()}catch(t){}const t=this.sounds.get(d.DEFAULT);t?(this.defaultSource=this.audioContext.createBufferSource(),this.defaultSource.buffer=t,this.defaultSource.loop=!0,this.defaultSource.connect(this.audioContext.destination),this.isMuted||this.defaultSource.start()):console.error("Default sound not found")}stopDefaultSound(){if(this.defaultSource){try{this.defaultSource.stop()}catch(t){}this.defaultSource=null}}mute(){this.isMuted=!0,this.currentSource&&this.currentSource.disconnect(),this.defaultSource&&this.defaultSource.disconnect()}unmute(){this.isMuted=!1,this.currentSource&&this.currentSource.connect(this.audioContext.destination),this.defaultSource&&this.defaultSource.connect(this.audioContext.destination)}}var f=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};const p=t=>{var n;return null!==(n=s[t.config.gameTheme])&&void 0!==n?n:s.github},y={},x=(t,n)=>{if(!y[t]){const e=new Image;e.src=n,y[t]=e}return y[t]},v=t=>{const n=t.config.canvas.getContext("2d");n.fillStyle=p(t).gridBackground,n.fillRect(0,0,t.config.canvas.width,t.config.canvas.height);for(let i=0;i<e;i++)for(let e=0;e<7;e++){const r=t.grid[i][e].intensity;if(r>0){const e=r<.2?.3:r,i=(a=p(t).contributionBoxColor,o=e,`rgba(${parseInt(a.slice(1,3),16)}, ${parseInt(a.slice(3,5),16)}, ${parseInt(a.slice(5,7),16)}, ${o})`);n.fillStyle=i}else n.fillStyle=p(t).emptyContributionBoxColor;n.beginPath(),t.config.canvas.getContext("2d").roundRect(22*i,22*e+15,20,20,5),n.fill()}var a,o;n.fillStyle=p(t).wallColor;for(let t=0;t<=e;t++)for(let e=0;e<=7;e++)u.horizontal[t][e].active&&n.fillRect(22*t-2,22*e-2+15,22,2),u.vertical[t][e].active&&n.fillRect(22*t-2,22*e-2+15,2,22);n.fillStyle=p(t).textColor,n.font="10px Arial",n.textAlign="center";let i="";for(let a=0;a<e;a++)if(t.monthLabels[a]!==i){const e=22*a+10;n.fillText(t.monthLabels[a],e,10),i=t.monthLabels[a]}},A=t=>{const n=t.config.canvas.getContext("2d"),e=22*t.pacman.x+10,i=22*t.pacman.y+10+15;t.pacman.deadRemainingDuration?n.fillStyle=o:t.pacman.powerupRemainingDuration?n.fillStyle="red":n.fillStyle=a;const r=t.pacmanMouthOpen?.35*Math.PI:.1*Math.PI;let c,s;switch(t.pacman.direction){case"up":c=1.5*Math.PI+r,s=1.5*Math.PI-r;break;case"down":c=.5*Math.PI+r,s=.5*Math.PI-r;break;case"left":c=Math.PI+r,s=Math.PI-r;break;default:c=0+r,s=2*Math.PI-r}n.beginPath(),n.arc(e,i,10,c,s),n.lineTo(e,i),n.fill()},b=t=>{t.ghosts.forEach((n=>{const e=22*n.x,a=22*n.y+15,o=t.config.canvas.getContext("2d");n.scared?o.drawImage(x("scared",l.scared.imgDate),e,a,20,20):o.drawImage(x(n.name,l[n.name].imgDate),e,a,20,20)}))},w=t=>{t.config.enableSounds&&t.config.canvas.addEventListener("click",(function(n){const e=t.config.canvas.getBoundingClientRect(),a=n.clientX-e.left,o=n.clientY-e.top,i=t.config.canvas.width-30-10;a>=i&&a<=i+this.width&&o>=10&&o<=10+this.height&&(g.getInstance().isMuted?g.getInstance().unmute():g.getInstance().mute())}))},C=(t,n)=>[[-1,0],[1,0],[0,-1],[0,1]].filter((([a,o])=>{const i=t+a,r=n+o;return!(i<0||i>=e||r<0||r>=7||(-1===a?u.vertical[t][n].active:1===a?u.vertical[t+1][n].active:-1===o?u.horizontal[t][n].active:1===o&&u.horizontal[t][n+1].active))})),L=(t,n,e,a)=>Math.sqrt(Math.pow(e-t,2)+Math.pow(a-n,2)),M=(t,n,e,a)=>{if(t===e&&n===a)return null;const o=[{x:t,y:n,path:[]}],i=new Set;for(i.add(`${t},${n}`);o.length>0;){const t=o.shift(),{x:n,y:r,path:c}=t,s=C(n,r);for(const[t,l]of s){const s=n+t,u=r+l,h=`${s},${u}`;if(i.has(h))continue;i.add(h);const d=[...c,{x:s,y:u}];if(s===e&&u===a)return d.length>0?d[0]:null;o.push({x:s,y:u,path:d})}}return null},S=(t,n)=>{const{pacman:e}=n;let a=[0,0];switch(t.name){case"blinky":default:return{x:e.x,y:e.y};case"pinky":a=$(n);const o=4;let i={x:e.x+a[0]*o,y:e.y+a[1]*o};return i.x=Math.min(Math.max(i.x,0),51),i.y=Math.min(Math.max(i.y,0),6),i;case"inky":const r=n.ghosts.find((t=>"blinky"===t.name));a=$(n);let c={x:e.x+2*a[0],y:e.y+2*a[1]};return r&&(c={x:c.x+(c.x-r.x),y:c.y+(c.y-r.y)}),c.x=Math.min(Math.max(c.x,0),51),c.y=Math.min(Math.max(c.y,0),6),c;case"clyde":return L(t.x,t.y,e.x,e.y)>8?{x:e.x,y:e.y}:{x:0,y:6}}},$=t=>{switch(t.pacman.direction){case"right":return[1,0];case"left":return[-1,0];case"up":return[0,-1];case"down":return[0,1];default:return[0,0]}},D=(t,n)=>{const e=t+Math.floor(17*Math.random())-8,a=n+Math.floor(17*Math.random())-8;return{x:Math.max(0,Math.min(e,51)),y:Math.max(0,Math.min(a,6))}},z=t=>{t.ghosts.forEach((n=>{n.scared||Math.random()<.15?((t,n)=>{(!t.target||t.x===t.target.x&&t.y===t.target.y)&&(t.target=D(t.x,t.y));const e=C(t.x,t.y);if(0===e.length)return;const a=t.target.x-t.x,o=t.target.y-t.y;let i=e.filter((t=>{if(Math.random()<.3)return!0;const n=t[0],e=t[1];return a>0&&n>0||a<0&&n<0||o>0&&e>0||o<0&&e<0}));0===i.length&&(i=e);const[r,c]=i[Math.floor(Math.random()*i.length)];n.pacman.powerupRemainingDuration&&Math.random()<.5||(t.x+=r,t.y+=c)})(n,t):((t,n)=>{const e=S(t,n);t.target=e;const a=M(t.x,t.y,e.x,e.y);a&&(t.x=a.x,t.y=a.y)})(n,t)}))},k=t=>{const n=new Map,a=!!t.pacman.powerupRemainingDuration;if(t.ghosts.forEach((t=>{if(!t.scared)for(let a=-5;a<=5;a++)for(let o=-5;o<=5;o++){const i=t.x+a,r=t.y+o;if(i>=0&&i<e&&r>=0&&r<7){const t=`${i},${r}`,e=15-(Math.abs(a)+Math.abs(o));if(e>0){const a=n.get(t)||0;n.set(t,Math.max(a,e))}}}})),a)for(const[t,e]of n.entries())n.set(t,e/5);return n},I=(t,n)=>{var e;(e=t.pacman).recentPositions||(e.recentPositions=[]),t.pacman.recentPositions.push(`${n.x},${n.y}`),t.pacman.recentPositions.length>5&&t.pacman.recentPositions.shift();const a=n.x-t.pacman.x,o=n.y-t.pacman.y;a>0?t.pacman.direction="right":a<0?t.pacman.direction="left":o>0?t.pacman.direction="down":o<0&&(t.pacman.direction="up"),t.pacman.x=n.x,t.pacman.y=n.y},B=t=>{t.pacman.powerupRemainingDuration=15,t.ghosts.forEach((t=>t.scared=!0))},T=t=>{if(t.pacman.deadRemainingDuration)return;const n=!!t.pacman.powerupRemainingDuration,a=t.ghosts.filter((t=>t.scared));let o=null;if(o=n&&a.length>0?(t=>{const n=t.ghosts.filter((t=>t.scared));return 0===n.length?null:n.reduce(((n,e)=>{const a=L(e.x,e.y,t.pacman.x,t.pacman.y);return a<n.distance?{x:e.x,y:e.y,distance:a}:n}),{x:t.pacman.x,y:t.pacman.y,distance:1/0})})(t):(t=>{let n=[];for(let a=0;a<e;a++)for(let e=0;e<7;e++)if(t.grid[a][e].intensity>0){const o=L(a,e,t.pacman.x,t.pacman.y),i=t.grid[a][e].intensity/(o+1);n.push({x:a,y:e,value:i})}return 0===n.length?null:(n.sort(((t,n)=>n.value-t.value)),n[0])})(t),!o)return;const i=((t,n)=>{var e;const a=[{x:t.pacman.x,y:t.pacman.y,path:[],score:0}],o=new Set;o.add(`${t.pacman.x},${t.pacman.y}`);const i=k(t);for(;a.length>0;){a.sort(((t,n)=>n.score-t.score));const r=a.shift(),{x:c,y:s,path:l}=r;if(c===n.x&&s===n.y)return l.length>0?l[0]:null;const u=C(c,s);for(const[r,h]of u){const u=c+r,d=s+h,m=`${u},${d}`;if(!o.has(m)){const r=[...l,{x:u,y:d}],c=i.get(m)||0,s=t.grid[u][d].intensity,h=L(u,d,n.x,n.y);let g=0;(null===(e=t.pacman.recentPositions)||void 0===e?void 0:e.includes(m))&&(g+=100),a.push({x:u,y:d,path:r,score:s-c-h/10-g}),o.add(m)}}}return null})(t,o);i?I(t,i):(t=>{const n=C(t.pacman.x,t.pacman.y);if(0===n.length)return;const e=n.reduce(((n,[e,a])=>{const o=t.pacman.x+e,i=t.pacman.y+a;let r=1/0;return t.ghosts.forEach((t=>{if(!t.scared){const n=L(t.x,t.y,o,i);r=Math.min(r,n)}})),r>n.distance?{dx:e,dy:a,distance:r}:n}),{dx:0,dy:0,distance:-1/0}),a=t.pacman.x+e.dx,o=t.pacman.y+e.dy;I(t,{x:a,y:o})})(t),(t=>{t.grid[t.pacman.x][t.pacman.y].intensity>0&&(t.pacman.totalPoints+=t.grid[t.pacman.x][t.pacman.y].commitsCount,t.pacman.points++,t.config.pointsIncreasedCallback(t.pacman.totalPoints),t.grid[t.pacman.x][t.pacman.y].intensity=0,t.pacman.points>=30&&B(t))})(t)},E=t=>{const n=10,e=t,a=2*Math.PI-t;return`M 10,10\n L ${n+n*Math.cos(e)},${n+n*Math.sin(e)}\n A 10,10 0 1,1 ${n+n*Math.cos(a)},${n+n*Math.sin(a)}\n Z`},F=(t,n,e)=>t.gameHistory.map((a=>{const o=a.grid[n][e];if(o>0){const n=o<.2?.3:o;return i=p(t).contributionBoxColor,r=n,3===(i=i.replace(/^#/,"")).length&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),`#${i}${Math.round(255*r).toString(16).padStart(2,"0")}`}var i,r;return p(t).emptyContributionBoxColor})),R=t=>{switch(t){case"blinky":return"gb";case"clyde":return"gc";case"inky":return"gi";case"pinky":return"gp";case"scared":return"gs";default:return t}},P=(t,n)=>{if(t.gameHistory.length!==n.length)throw new Error("The length of changingValues must match the length of gameHistory");const e=t.gameHistory.length;let a=[],o=[],i=null,r=null;return n.forEach(((t,n)=>{t!==i&&(null!==i&&null!==r&&n-1!==r&&(a.push(Number(((n-1e-6)/(e-1)).toFixed(6))),o.push(i)),a.push(Number((n/(e-1)).toFixed(6))),o.push(t),i=t,r=n)})),1!==a[a.length-1]&&(a.push(1),o.push(i)),{keyTimes:a.join(";"),values:o.join(";")}},O=t=>{let n='<svg width="1144" height="174" xmlns="http://www.w3.org/2000/svg">';n+=`<desc>Generated with https://github.com/abozanona/pacman-contribution-graph on ${new Date}</desc>`,n+=`<rect width="100%" height="100%" fill="${p(t).gridBackground}"/>`,n+=`<defs>\n\t\t<symbol id="${R("blinky")}" viewBox="0 0 100 100">\n <image href="${l.blinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("clyde")}" viewBox="0 0 100 100">\n <image href="${l.clyde.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("inky")}" viewBox="0 0 100 100">\n <image href="${l.inky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("pinky")}" viewBox="0 0 100 100">\n <image href="${l.pinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${R("scared")}" viewBox="0 0 100 100">\n <image href="${l.scared.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t</defs>`;let i="";for(let a=0;a<e;a++)t.monthLabels[a]!==i&&(n+=`<text x="${22*a+10}" y="10" text-anchor="middle" font-size="10" fill="${p(t).textColor}">${t.monthLabels[a]}</text>`,i=t.monthLabels[a]);for(let a=0;a<e;a++)for(let e=0;e<7;e++){const o=22*a,i=22*e+15,r=P(t,F(t,a,e));n+=`<rect id="c-${a}-${e}" x="${o}" y="${i}" width="20" height="20" rx="5" fill="${p(t).emptyContributionBoxColor}">\n <animate attributeName="fill" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite" \n values="${r.values}" \n keyTimes="${r.keyTimes}"/>\n </rect>`}for(let a=0;a<e;a++)for(let e=0;e<7;e++)u.horizontal[a][e].active&&(n+=`<rect id="wh-${a}-${e}" x="${22*a-2}" y="${22*e-2+15}" width="22" height="2" rx="5" fill="${p(t).wallColor}"></rect>`),u.vertical[a][e].active&&(n+=`<rect id="wv-${a}-${e}" x="${22*a-2}" y="${22*e-2+15}" width="2" height="22" rx="5" fill="${p(t).wallColor}"></rect>`);const r=P(t,(t=>t.gameHistory.map((t=>t.pacman.deadRemainingDuration?o:t.pacman.powerupRemainingDuration?"red":a)))(t)),s=P(t,(t=>t.gameHistory.map((t=>`${22*t.pacman.x},${22*t.pacman.y+15}`)))(t)),h=P(t,(t=>t.gameHistory.map((t=>{switch(t.pacman.direction){case"right":default:return"0 10 10";case"left":return"180 10 10";case"up":return"270 10 10";case"down":return"90 10 10"}})))(t));return n+=`<path id="pacman" d="${E(.55)}"\n >\n\t\t<animate attributeName="fill" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${r.keyTimes}"\n values="${r.values}"/>\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${s.keyTimes}"\n values="${s.values}"\n additive="sum"/>\n <animateTransform attributeName="transform" type="rotate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${h.keyTimes}"\n values="${h.values}"\n additive="sum"/>\n <animate attributeName="d" dur="0.5s" repeatCount="indefinite"\n values="${E(.55)};${E(.05)};${E(.55)}"/>\n </path>`,t.ghosts.forEach(((e,a)=>{const o=P(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return`${22*e.x},${22*e.y+15}`})))(t,a)),i=P(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return"#"+(e.scared?R("scared"):R(e.name))})))(t,a));n+=`<use id="ghost${a}" width="20" height="20" href="#ghost-${e.name}">\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${o.keyTimes}"\n values="${o.values}"/>\n <animate attributeName="href" dur="${t.gameHistory.length*c}ms" repeatCount="indefinite"\n keyTimes="${i.keyTimes}"\n values="${i.values}"/>\n </use>`})),n+="</svg>",n};var N=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function r(t){try{s(a.next(t))}catch(t){i(t)}}function c(t){try{s(a.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(r,c)}s((a=a.apply(t,n||[])).next())}))};const U=t=>{t.ghosts=[],t.ghosts.push({x:23,y:3,name:i[0],scared:!1,target:void 0}),t.ghosts.push({x:24,y:3,name:i[1],scared:!1,target:void 0}),t.ghosts.push({x:27,y:3,name:i[2],scared:!1,target:void 0}),t.ghosts.push({x:28,y:3,name:i[3],scared:!1,target:void 0}),"canvas"==t.config.outputFormat&&b(t)},V=t=>N(void 0,void 0,void 0,(function*(){if(t.frameCount++,t.frameCount%t.config.gameSpeed==0)if(t.pacman.deadRemainingDuration&&(t.pacman.deadRemainingDuration--,t.pacman.deadRemainingDuration||(U(t),"canvas"==t.config.outputFormat&&g.getInstance().play(d.GAME_OVER).then((()=>g.getInstance().startDefaultSound())))),t.pacman.powerupRemainingDuration&&(t.pacman.powerupRemainingDuration--,t.pacman.powerupRemainingDuration||(t.ghosts.forEach((t=>t.scared=!1)),t.pacman.points=0)),t.grid.some((t=>t.some((t=>t.intensity>0)))))T(t),H(t),t.pacman.deadRemainingDuration||(z(t),H(t)),t.pacmanMouthOpen=!t.pacmanMouthOpen,t.gameHistory.push({pacman:Object.assign({},t.pacman),ghosts:t.ghosts.map((t=>Object.assign({},t))),grid:t.grid.map((t=>[...t.map((t=>t.intensity))]))}),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&A(t),"canvas"==t.config.outputFormat&&b(t),"canvas"==t.config.outputFormat&&(t=>{if(!t.config.enableSounds)return;const n=t.config.canvas.getContext("2d"),e=t.config.canvas.width-30-10;n.fillStyle=`rgba(0, 0, 0, ${g.getInstance().isMuted?.3:.5})`,n.beginPath(),n.moveTo(e+10,20),n.lineTo(e+20,15),n.lineTo(e+20,35),n.lineTo(e+10,30),n.closePath(),n.fill(),g.getInstance().isMuted?(n.strokeStyle="rgba(255, 0, 0, 0.6)",n.lineWidth=3,n.beginPath(),n.moveTo(e+25,15),n.lineTo(e+5,35),n.stroke()):(n.strokeStyle="rgba(0, 0, 0, 0.4)",n.lineWidth=2,n.beginPath(),n.arc(e+25,25,5,0,2*Math.PI),n.stroke(),n.beginPath(),n.arc(e+25,25,8,0,2*Math.PI),n.stroke())})(t);else{if("canvas"==t.config.outputFormat&&(clearInterval(t.gameInterval),"canvas"==t.config.outputFormat&&((t=>{const n=t.config.canvas.getContext("2d");n.fillStyle=p(t).textColor,n.font="20px Arial",n.textAlign="center",n.fillText("Game Over",t.config.canvas.width/2,t.config.canvas.height/2)})(t),g.getInstance().play(d.BEGINNING).then((()=>g.getInstance().stopDefaultSound())))),"svg"==t.config.outputFormat){const n=O(t);t.config.svgCallback(n)}t.config.gameOverCallback()}else t.gameHistory.push({pacman:Object.assign({},t.pacman),ghosts:t.ghosts.map((t=>Object.assign({},t))),grid:t.grid.map((t=>[...t.map((t=>t.intensity))]))})})),H=t=>{t.pacman.deadRemainingDuration||t.ghosts.forEach(((n,e)=>{n.x===t.pacman.x&&n.y===t.pacman.y&&(t.pacman.powerupRemainingDuration&&n.scared?(Q(t,e),t.pacman.points+=10,"canvas"==t.config.outputFormat&&g.getInstance().play(d.EAT_GHOST)):(t.pacman.points=0,t.pacman.powerupRemainingDuration=0,t.pacman.deadRemainingDuration=10,"canvas"==t.config.outputFormat&&g.getInstance().play(d.GAME_OVER).then((()=>g.getInstance().stopDefaultSound()))))}))},Q=(t,n)=>{let a,o;do{a=Math.floor(Math.random()*e),o=Math.floor(7*Math.random())}while(Math.abs(a-t.pacman.x)<=2&&Math.abs(o-t.pacman.y)<=2||0===t.grid[a][o].intensity);t.ghosts[n]={x:a,y:o,name:i[n%i.length],scared:!1,target:void 0}},j=(t,n,a,o,i)=>{"horizontal"==a?(h(t,n,"horizontal",i),"x"==o?h(e-t-1,n,"horizontal",i):"y"==o?h(t,7-n,"horizontal",i):"xy"==o&&(h(e-t-1,n,"horizontal",i),h(t,7-n,"horizontal",i),h(e-t-1,7-n,"horizontal",i))):(h(t,n,"vertical",i),"x"==o?h(e-t,n,"vertical",i):"y"==o?h(t,7-n-1,"vertical",i):"xy"==o&&(h(e-t,n,"vertical",i),h(t,7-n-1,"vertical",i),h(e-t,7-n-1,"vertical",i)))},G={frameCount:0,contributions:[],pacman:{x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0,recentPositions:[]},ghosts:[],grid:[],monthLabels:[],pacmanMouthOpen:!0,gameInterval:0,gameHistory:[],config:void 0};class K{constructor(t){this.store=structuredClone(G),this.conf=Object.assign({},t),j(0,2,"horizontal","xy","L1"),j(1,2,"horizontal","xy","L1"),j(4,0,"vertical","x","L2"),j(4,1,"vertical","x","L2"),j(4,2,"vertical","x","L2"),j(4,3,"vertical","x","L2"),j(4,4,"vertical","x","L2"),j(3,3,"horizontal","x","L3"),j(2,3,"horizontal","x","L3"),j(4,5,"horizontal","x","L4"),j(6,4,"vertical","x","L5"),j(6,3,"vertical","x","L5"),j(6,2,"vertical","x","L5"),j(6,2,"horizontal","x","L6"),j(7,2,"horizontal","x","L6"),j(8,2,"horizontal","x","L6"),j(9,2,"horizontal","x","L6"),j(13,2,"horizontal","xy","L7"),j(14,2,"horizontal","xy","L7"),j(15,2,"horizontal","xy","L7"),j(16,2,"horizontal","xy","L7"),j(17,2,"horizontal","xy","L7"),j(18,2,"horizontal","xy","L7"),j(16,2,"vertical","xy","L8"),j(8,1,"horizontal","x","L9"),j(9,1,"horizontal","x","L9"),j(10,1,"horizontal","x","L9"),j(11,1,"horizontal","x","L9"),j(12,1,"vertical","x","L10"),j(12,3,"vertical","x","L10"),j(11,4,"horizontal","x","L11"),j(10,4,"horizontal","x","L11"),j(9,4,"horizontal","x","L11"),j(8,4,"horizontal","x","L11"),j(8,4,"vertical","x","L12"),j(8,5,"vertical","x","L12"),j(8,6,"vertical","x","L12"),j(23,2,"horizontal","x","L13"),j(24,2,"horizontal","x","L13"),j(23,4,"horizontal","x","L13"),j(24,4,"horizontal","x","L13"),j(25,4,"horizontal","x","L13"),j(23,2,"vertical","x","L14"),j(23,3,"vertical","x","L14"),j(26,4,"vertical","x","L15"),j(26,5,"vertical","x","L15"),j(23,6,"horizontal","x","L16"),j(24,6,"horizontal","x","L16"),j(25,6,"horizontal","x","L16"),j(26,0,"vertical","x","L17"),j(24,1,"vertical","x","L18"),j(23,1,"horizontal","x","L18"),j(22,1,"horizontal","x","L18"),j(21,1,"horizontal","x","L18"),j(21,1,"vertical","x","L18"),j(21,2,"vertical","x","L18"),j(21,3,"vertical","x","L18"),j(20,4,"horizontal","x","L18"),j(19,4,"horizontal","x","L18"),j(19,3,"vertical","x","L18"),j(18,3,"horizontal","x","L18"),j(22,5,"vertical","x","L19"),j(21,5,"horizontal","x","L19"),j(20,5,"horizontal","x","L19"),j(20,5,"vertical","x","L19"),j(1,6,"horizontal","x","L20"),j(2,6,"horizontal","x","L20"),j(3,5,"vertical","x","L20"),j(3,4,"vertical","x","L20"),j(5,6,"horizontal","x","L21"),j(6,6,"horizontal","x","L21")}start(){return t=this,n=void 0,o=function*(){switch(this.store.config=Object.assign(Object.assign({},{platform:"github",username:"",canvas:void 0,outputFormat:"svg",svgCallback:t=>{},gameOverCallback:()=>()=>{},gameTheme:"github",gameSpeed:1,enableSounds:!1,pointsIncreasedCallback:t=>{}}),this.conf),this.conf.platform){case"gitlab":this.store.contributions=yield(t=this.store,f(void 0,void 0,void 0,(function*(){const n=yield fetch(`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${t.config.username}`),e=yield n.json();return Object.entries(e).map((([t,n])=>({date:new Date(t),count:Number(n)})))})));break;case"github":this.store.contributions=yield(t=>f(void 0,void 0,void 0,(function*(){var n;const e=[];let a=!1,o=1;do{try{const i={};(null===(n=t.config.githubSettings)||void 0===n?void 0:n.accessToken)&&(i.Authorization="Bearer "+t.config.githubSettings.accessToken);const r=yield fetch(`https://api.github.com/search/commits?q=author:${t.config.username}&sort=author-date&order=desc&page=${o}&per_page=1000`,{headers:i}),c=yield r.json();a=0===c.items.length,e.push(...c.items),o++}catch(t){a=!0}}while(!a);return Array.from(e.reduce(((t,n)=>{const e=n.commit.committer.date.split("T")[0],a=new Date(e),o=(t.get(e)||{count:0}).count+1;return t.set(e,{date:a,count:o})}),new Map).values())})))(this.store)}var t;(t=>{N(void 0,void 0,void 0,(function*(){"canvas"==t.config.outputFormat&&(t.config.canvas=t.config.canvas,(t=>{t.config.canvas.width=1144,t.config.canvas.height=174})(t),w(t)),t.frameCount=0,t.ghosts.forEach((t=>t.scared=!1)),(t=>{t.pacman.points=0,t.pacman.totalPoints=0,t.grid=Array.from({length:e},(()=>Array.from({length:7},(()=>({commitsCount:0,intensity:0}))))),t.monthLabels=Array(e).fill("");let n=1;const a=new Date,o=new Date(a);o.setDate(a.getDate()-a.getDay()),t.contributions.forEach((a=>{const i=new Date(a.date),r=i.getDay(),c=Math.floor((+o-+i)/6048e5);c>=0&&c<e&&r>=0&&r<7&&(t.grid[51-c][r]={commitsCount:a.count,intensity:0},a.count>n&&(n=a.count))}));for(let a=0;a<e;a++)for(let e=0;e<7;e++)t.grid[a][e].commitsCount>0&&(t.grid[a][e].intensity=t.grid[a][e].commitsCount/n);for(let n=0;n<e;n++){const e=51-n,a=new Date(o);a.setDate(a.getDate()-7*e),t.monthLabels[n]=r[a.getMonth()]}})(t),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&(t.config.enableSounds||g.getInstance().mute(),yield g.getInstance().preloadSounds(),g.getInstance().startDefaultSound(),yield g.getInstance().play(d.BEGINNING));const n=()=>t.grid.some((t=>t.some((t=>t.intensity>0))));if(n()&&((t=>{t.pacman={x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0,recentPositions:[]},"canvas"==t.config.outputFormat&&A(t)})(t),U(t)),"svg"==t.config.outputFormat){for(;n();)yield V(t);yield V(t)}else clearInterval(t.gameInterval),t.gameInterval=setInterval((()=>N(void 0,void 0,void 0,(function*(){return yield V(t)}))),c)}))})(this.store)},new((a=void 0)||(a=Promise))((function(e,i){function r(t){try{s(o.next(t))}catch(t){i(t)}}function c(t){try{s(o.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(t){t(n)}))).then(r,c)}s((o=o.apply(t,n||[])).next())}));var t,n,a,o}stop(){var t;t=this.store,N(void 0,void 0,void 0,(function*(){clearInterval(t.gameInterval)}))}}var Y=n.C;
26846
26846
  // EXTERNAL MODULE: external "path"
26847
26847
  var external_path_ = __nccwpck_require__(6928);
26848
26848
  ;// CONCATENATED MODULE: ./src/index.js
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "dependencies": {
8
8
  "@actions/core": "1.10.1",
9
- "pacman-contribution-graph": "^1.0.10"
9
+ "pacman-contribution-graph": "^1.0.13"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@vercel/ncc": "^0.38.3"
@@ -12,8 +12,8 @@ importers:
12
12
  specifier: 1.10.1
13
13
  version: 1.10.1
14
14
  pacman-contribution-graph:
15
- specifier: ^1.0.10
16
- version: 1.0.10
15
+ specifier: ^1.0.13
16
+ version: 1.0.13
17
17
  devDependencies:
18
18
  '@vercel/ncc':
19
19
  specifier: ^0.38.3
@@ -35,8 +35,8 @@ packages:
35
35
  resolution: {integrity: sha512-rnK6hJBS6mwc+Bkab+PGPs9OiS0i/3kdTO+CkI8V0/VrW3vmz7O2Pxjw/owOlmo6PKEIxRSeZKv/kuL9itnpYA==}
36
36
  hasBin: true
37
37
 
38
- pacman-contribution-graph@1.0.10:
39
- resolution: {integrity: sha512-fvIDZ2Uo5DpVjwPxgManp62LOSefVpJnT6TuXpMJsnN3/2t89Q5ysjzyn51yvxT9sxbIX9vwhGxV8QTZ6GYMcw==}
38
+ pacman-contribution-graph@1.0.13:
39
+ resolution: {integrity: sha512-SuUau0TvS6yYtfqySWkTh73n9c3sD1+OGW49wlZBy7+y8L36NcvF1E9/02OR5eg5OUZ1k7PA+McbjjjK4u2APA==}
40
40
 
41
41
  tunnel@0.0.6:
42
42
  resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==}
@@ -66,7 +66,7 @@ snapshots:
66
66
 
67
67
  '@vercel/ncc@0.38.3': {}
68
68
 
69
- pacman-contribution-graph@1.0.10: {}
69
+ pacman-contribution-graph@1.0.13: {}
70
70
 
71
71
  tunnel@0.0.6: {}
72
72
 
package/index.html CHANGED
@@ -293,7 +293,7 @@ pr.start();
293
293
  <code>&lt;iframe src="https://abozanona.github.io/pacman-contribution-graph/embeded/canvas.html?username=yourusername&platform=github"
294
294
  width="800" height="600" frameborder="0"&gt;&lt;/iframe&gt;</code>
295
295
  &lt;!-- For SVG --&gt;
296
- <code>&lt;img src="https://abozanona.github.io/pacman-contribution-graph/embeded/svg.html?username=yourusername&platform=github" /&gt;</code>
296
+ <code>&lt;img src="https://pacman.abozanona.me?username=yourusername" /&gt;</code>
297
297
  </code></pre>
298
298
  </div>
299
299
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacman-contribution-graph",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Generates a pacman game from a github or gitlab user contributions grid",
5
5
  "repository": "github:abozanona/pacman-contribution-graph",
6
6
  "homepage": "https://abozanona.github.io/pacman-contribution-graph/",
@@ -0,0 +1,47 @@
1
+ import http from 'http';
2
+ import { PacmanRenderer } from 'pacman-contribution-graph';
3
+ import querystring from 'querystring';
4
+ import url from 'url';
5
+
6
+ const githubToken = process.env.GITHUB_ACCESS_TOKEN;
7
+
8
+ const generateSvg = async (userName) => {
9
+ return new Promise((resolve) => {
10
+ const conf = {
11
+ platform: "github",
12
+ username: userName,
13
+ outputFormat: "svg",
14
+ gameSpeed: 1,
15
+ gameTheme: "github-dark",
16
+ githubSettings: {
17
+ accessToken: githubToken
18
+ },
19
+ svgCallback: (animatedSVG) => resolve(animatedSVG)
20
+ };
21
+
22
+ const pr = new PacmanRenderer(conf);
23
+ pr.start();
24
+ });
25
+ };
26
+
27
+ const server = http.createServer(async (req, res) => {
28
+ const parsedUrl = url.parse(req.url);
29
+ const queryParams = querystring.parse(parsedUrl.query);
30
+ const username = queryParams.username || 'abozanona';
31
+
32
+ try {
33
+ const svg = await generateSvg(username);
34
+ res.writeHead(200, {
35
+ 'Content-Type': 'image/svg+xml',
36
+ 'Cache-Control': 'no-store, no-cache, must-revalidate',
37
+ 'Pragma': 'no-cache',
38
+ 'Expires': '0'
39
+ });
40
+ res.end(svg.replace("Generated with ", "Generated with " + username + " "));
41
+ } catch (error) {
42
+ res.end('Error generating SVG');
43
+ throw error;
44
+ }
45
+ });
46
+
47
+ server.listen();
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "pacman-abozanona-node",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "dependencies": {
6
+ "pacman-contribution-graph": "^1.0.13"
7
+ }
8
+ }
@@ -1,5 +1,5 @@
1
1
  import { GRID_HEIGHT, GRID_WIDTH } from '../constants';
2
- import { Ghost, StoreType } from '../types';
2
+ import { Ghost, Point2d, StoreType } from '../types';
3
3
  import { MovementUtils } from './movement-utils';
4
4
 
5
5
  const moveGhosts = (store: StoreType) => {
@@ -27,10 +27,6 @@ const moveScaredGhost = (ghost: Ghost, store: StoreType) => {
27
27
 
28
28
  // Filter moves that generally go toward the target
29
29
  let possibleMoves = validMoves.filter((move) => {
30
- // If random < 0.3, allow any valid move for more erratic movement
31
- if (Math.random() < 0.3) return true;
32
-
33
- // Otherwise prefer moves that go toward target
34
30
  const moveX = move[0];
35
31
  const moveY = move[1];
36
32
  return (dx > 0 && moveX > 0) || (dx < 0 && moveX < 0) || (dy > 0 && moveY > 0) || (dy < 0 && moveY < 0);
@@ -64,11 +60,11 @@ const moveGhostWithPersonality = (ghost: Ghost, store: StoreType) => {
64
60
  };
65
61
 
66
62
  // Find the next position to move to using BFS
67
- const BFSTargetLocation = (startX: number, startY: number, targetX: number, targetY: number): { x: number; y: number } | null => {
63
+ const BFSTargetLocation = (startX: number, startY: number, targetX: number, targetY: number): Point2d | null => {
68
64
  // If we're already at the target, no need to move
69
65
  if (startX === targetX && startY === targetY) return null;
70
66
 
71
- const queue: { x: number; y: number; path: { x: number; y: number }[] }[] = [{ x: startX, y: startY, path: [] }];
67
+ const queue: { x: number; y: number; path: Point2d[] }[] = [{ x: startX, y: startY, path: [] }];
72
68
  const visited = new Set<string>();
73
69
  visited.add(`${startX},${startY}`);
74
70
 
@@ -101,7 +97,7 @@ const BFSTargetLocation = (startX: number, startY: number, targetX: number, targ
101
97
  };
102
98
 
103
99
  // Calculate ghost target based on personality
104
- const calculateGhostTarget = (ghost: Ghost, store: StoreType): { x: number; y: number } => {
100
+ const calculateGhostTarget = (ghost: Ghost, store: StoreType): Point2d => {
105
101
  const { pacman } = store;
106
102
  let pacDirection = [0, 0];
107
103
  switch (ghost.name) {
@@ -1,5 +1,5 @@
1
1
  import { GRID_HEIGHT, GRID_WIDTH, PACMAN_POWERUP_DURATION } from '../constants';
2
- import { StoreType } from '../types';
2
+ import { Point2d, StoreType } from '../types';
3
3
  import { MovementUtils } from './movement-utils';
4
4
 
5
5
  const RECENT_POSITIONS_LIMIT = 5;
@@ -12,16 +12,25 @@ const movePacman = (store: StoreType) => {
12
12
  const hasPowerup = !!store.pacman.powerupRemainingDuration;
13
13
  const scaredGhosts = store.ghosts.filter((ghost) => ghost.scared);
14
14
 
15
- let targetPosition = null;
15
+ let targetPosition: Point2d;
16
16
 
17
17
  if (hasPowerup && scaredGhosts.length > 0) {
18
- targetPosition = findClosestScaredGhost(store);
18
+ const ghostPosition = findClosestScaredGhost(store);
19
+ if (ghostPosition) {
20
+ targetPosition = ghostPosition;
21
+ } else {
22
+ targetPosition = findOptimalTarget(store);
23
+ }
24
+ } else if (store.pacman.target) {
25
+ if (store.pacman.target.x == store.pacman.x && store.pacman.target.y == store.pacman.y) {
26
+ targetPosition = findOptimalTarget(store);
27
+ store.pacman.target = { x: targetPosition?.x, y: targetPosition?.y };
28
+ } else {
29
+ targetPosition = store.pacman.target;
30
+ }
19
31
  } else {
20
32
  targetPosition = findOptimalTarget(store);
21
- }
22
-
23
- if (!targetPosition) {
24
- return;
33
+ store.pacman.target = { x: targetPosition?.x, y: targetPosition?.y };
25
34
  }
26
35
 
27
36
  const nextPosition = calculateOptimalPath(store, targetPosition);
@@ -62,14 +71,12 @@ const findOptimalTarget = (store: StoreType) => {
62
71
  }
63
72
  }
64
73
 
65
- if (pointCells.length === 0) return null;
66
-
67
74
  pointCells.sort((a, b) => b.value - a.value);
68
75
  return pointCells[0];
69
76
  };
70
77
 
71
- const calculateOptimalPath = (store: StoreType, target: { x: number; y: number }) => {
72
- const queue: { x: number; y: number; path: { x: number; y: number }[]; score: number }[] = [
78
+ const calculateOptimalPath = (store: StoreType, target: Point2d) => {
79
+ const queue: { x: number; y: number; path: Point2d[]; score: number }[] = [
73
80
  { x: store.pacman.x, y: store.pacman.y, path: [], score: 0 }
74
81
  ];
75
82
  const visited = new Set<string>();
@@ -183,7 +190,7 @@ const makeDesperationMove = (store: StoreType) => {
183
190
  updatePacmanPosition(store, { x: newX, y: newY });
184
191
  };
185
192
 
186
- const updatePacmanPosition = (store: StoreType, position: { x: number; y: number }) => {
193
+ const updatePacmanPosition = (store: StoreType, position: Point2d) => {
187
194
  store.pacman.recentPositions ||= [];
188
195
  store.pacman.recentPositions.push(`${position.x},${position.y}`);
189
196
  if (store.pacman.recentPositions.length > RECENT_POSITIONS_LIMIT) {
@@ -209,7 +216,7 @@ const checkAndEatPoint = (store: StoreType) => {
209
216
  store.config.pointsIncreasedCallback(store.pacman.totalPoints);
210
217
  store.grid[store.pacman.x][store.pacman.y].intensity = 0;
211
218
 
212
- if (store.pacman.points >= 30) activatePowerUp(store);
219
+ if (store.pacman.points >= 10) activatePowerUp(store);
213
220
  }
214
221
  };
215
222
 
package/src/types.ts CHANGED
@@ -1,3 +1,8 @@
1
+ export type Point2d = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+
1
6
  export interface Pacman {
2
7
  x: number;
3
8
  y: number;
@@ -7,6 +12,7 @@ export interface Pacman {
7
12
  deadRemainingDuration: number;
8
13
  powerupRemainingDuration: number;
9
14
  recentPositions: string[];
15
+ target?: Point2d;
10
16
  }
11
17
 
12
18
  export type GhostName = 'blinky' | 'clyde' | 'inky' | 'pinky';
@@ -15,7 +21,7 @@ export interface Ghost {
15
21
  y: number;
16
22
  name: GhostName;
17
23
  scared: boolean;
18
- target?: { x: number; y: number };
24
+ target?: Point2d;
19
25
  }
20
26
 
21
27
  export interface Contribution {
package/embeded/svg.html DELETED
@@ -1,18 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Pac-Man Contributions Game</title>
7
- <style>
8
- body {
9
- margin: 0;
10
- padding: 0;
11
- }
12
- </style>
13
- </head>
14
- <body>
15
- <!-- TODO: render it from server side -->
16
- COMING SOON
17
- </body>
18
- </html>