pacman-contribution-graph 1.0.10 → 1.0.11
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.
- package/README.md +145 -18
- package/action.yml +16 -0
- package/dist/pacman-contribution-graph.min.js +1 -1
- package/github-action/dist/index.js +5 -3
- package/github-action/package.json +1 -1
- package/github-action/pnpm-lock.yaml +5 -5
- package/github-action/src/index.js +2 -0
- package/index.html +1 -1
- package/package.json +1 -1
- package/src/utils.ts +5 -2
package/README.md
CHANGED
|
@@ -1,24 +1,151 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Pac-Man Contribution Graph Game
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Transform your GitHub or GitLab contribution graph into an interactive Pac-Man game! This JavaScript library offers a unique and engaging way to visualize your coding activity over the past year.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<picture>
|
|
6
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/abozanona/abozanona/output/pacman-contribution-graph-dark.svg">
|
|
7
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/abozanona/abozanona/output/pacman-contribution-graph.svg">
|
|
8
|
+
<img alt="pacman contribution graph" src="https://raw.githubusercontent.com/abozanona/abozanona/output/pacman-contribution-graph.svg">
|
|
9
|
+
</picture>
|
|
6
10
|
|
|
7
11
|
## Features
|
|
8
12
|
|
|
13
|
+
Elevate your GitHub profile with the Pac-Man Contribution Graph Game and add a playful touch to your coding journey!
|
|
14
|
+
|
|
9
15
|
- **Contribution Visualization**: Converts your GitHub or GitLab contribution data into a colorful grid.
|
|
10
|
-
- **Interactive Gameplay**: Navigate Pac-Man through your
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
- **Interactive Gameplay**: Navigate Pac-Man through your contributions, evading ghosts and collecting pellets.
|
|
17
|
+
- **Multiple Themes**: Choose between different themes, such as GitHub Dark and GitLab Dark.
|
|
18
|
+
- **Customizable Settings**: Adjust game speed, sound preferences, and output format (Canvas or SVG).
|
|
19
|
+
|
|
20
|
+
## Demo
|
|
21
|
+
|
|
22
|
+
Experience the game firsthand:
|
|
23
|
+
|
|
24
|
+
**Live Demo**: [Pac-Man Contribution Game](https://abozanona.github.io/pacman-contribution-graph/)
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
To integrate the Pac-Man Contribution Graph into your project, you can install it via npm:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install pacman-contribution-graph
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Alternatively, include it directly in your HTML using jsDelivr:
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<script src="https://cdn.jsdelivr.net/npm/pacman-contribution-graph@1.0.10/dist/index.min.js"></script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
Here's how to set up and run the Pac-Man Contribution Graph:
|
|
43
|
+
|
|
44
|
+
1. **Include the Library**: Ensure the library is included in your project, either via npm or a script tag.
|
|
45
|
+
2. **Initialize the Game**: Use the following code to generate the game:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
import { generatePacManGame } from 'pacman-contribution-graph';
|
|
49
|
+
|
|
50
|
+
generatePacManGame({
|
|
51
|
+
username: 'your_username',
|
|
52
|
+
platform: 'github', // or 'gitlab'
|
|
53
|
+
theme: 'github-dark', // or 'gitlab-dark'
|
|
54
|
+
speed: 2,
|
|
55
|
+
sound: true,
|
|
56
|
+
output: 'canvas' // or 'svg'
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
3. **Customize Settings**: Adjust the parameters as needed:
|
|
61
|
+
- `username`: Your GitHub or GitLab username.
|
|
62
|
+
- `platform`: Specify `'github'` or `'gitlab'`.
|
|
63
|
+
- `theme`: Choose between available themes.
|
|
64
|
+
- `speed`: Set the game speed (e.g., `1` for normal, `2` for fast).
|
|
65
|
+
- `sound`: Enable or disable sound (`true` or `false`).
|
|
66
|
+
- `output`: Select `'canvas'` for browser play or `'svg'` for a downloadable animated SVG.
|
|
67
|
+
|
|
68
|
+
## Integrate into Your GitHub Profile
|
|
69
|
+
|
|
70
|
+
To showcase the Pac-Man game on your GitHub profile, follow these steps:
|
|
71
|
+
|
|
72
|
+
1. **Create a Special Repository**:
|
|
73
|
+
|
|
74
|
+
- Name a new repository exactly as your GitHub username (e.g., `username/username`).
|
|
75
|
+
- This repository powers your GitHub profile page.
|
|
76
|
+
|
|
77
|
+
2. **Set Up GitHub Actions**:
|
|
78
|
+
|
|
79
|
+
- In the repository, create a `.github/workflows/` directory.
|
|
80
|
+
- Add a `main.yml` file with the following content:
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
name: generate pacman game
|
|
84
|
+
|
|
85
|
+
on:
|
|
86
|
+
schedule: # Run automatically every 24 hours
|
|
87
|
+
- cron: "0 */24 * * *"
|
|
88
|
+
workflow_dispatch: # Allows manual triggering
|
|
89
|
+
push: # Runs on every push to the main branch
|
|
90
|
+
branches:
|
|
91
|
+
- main
|
|
92
|
+
|
|
93
|
+
jobs:
|
|
94
|
+
generate:
|
|
95
|
+
permissions:
|
|
96
|
+
contents: write
|
|
97
|
+
runs-on: ubuntu-latest
|
|
98
|
+
timeout-minutes: 5
|
|
99
|
+
|
|
100
|
+
steps:
|
|
101
|
+
- name: generate pacman-contribution-graph.svg
|
|
102
|
+
uses: abozanona/pacman-contribution-graph@main
|
|
103
|
+
with:
|
|
104
|
+
github_user_name: ${{ github.repository_owner }}
|
|
105
|
+
|
|
106
|
+
# Push the generated SVG to the output branch
|
|
107
|
+
- name: push pacman-contribution-graph.svg to the output branch
|
|
108
|
+
uses: crazy-max/ghaction-github-pages@v3.1.0
|
|
109
|
+
with:
|
|
110
|
+
target_branch: output
|
|
111
|
+
build_dir: dist
|
|
112
|
+
env:
|
|
113
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
3. **Add to Profile README**:
|
|
117
|
+
|
|
118
|
+
- In your repository, create or edit the `README.md` file to include:
|
|
119
|
+
|
|
120
|
+
```markdown
|
|
121
|
+
## My Contribution Graph
|
|
122
|
+
|
|
123
|
+
<picture>
|
|
124
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/[USERNAME]/[USERNAME]/output/pacman-contribution-graph-dark.svg">
|
|
125
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/[USERNAME]/[USERNAME]/output/pacman-contribution-graph.svg">
|
|
126
|
+
<img alt="pacman contribution graph" src="https://raw.githubusercontent.com/[USERNAME]/[USERNAME]/output/pacman-contribution-graph.svg">
|
|
127
|
+
</picture>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
4. **Commit and Push**:
|
|
131
|
+
- Push the changes to GitHub. The GitHub Actions workflow will run daily, updating the Pac-Man game on your profile.
|
|
132
|
+
|
|
133
|
+
For a detailed guide, refer to the blog post: [Integrate Pac-Man Contribution Graph into Your GitHub Profile](https://abozanona.me/integrate-pacman-contribution-graph-into-github/)
|
|
134
|
+
|
|
135
|
+
## Contributing
|
|
136
|
+
|
|
137
|
+
Contributions are welcome! To contribute:
|
|
138
|
+
|
|
139
|
+
1. Fork the repository.
|
|
140
|
+
2. Create a new branch: `git checkout -b feature-name`.
|
|
141
|
+
3. Make your changes and commit them: `git commit -m 'Add feature'`.
|
|
142
|
+
4. Push to the branch: `git push origin feature-name`.
|
|
143
|
+
5. Submit a pull request.
|
|
144
|
+
|
|
145
|
+
## Acknowledgements
|
|
146
|
+
|
|
147
|
+
Inspired by the [snk](https://github.com/Platane/snk) project, which turns your GitHub contribution graph into a snake game. Special thanks to all contributors and the open-source community for their support.
|
|
148
|
+
|
|
149
|
+
## Online tools that use Pac-Man Contribution Graph Game
|
|
150
|
+
|
|
151
|
+
- Profile Readme Generator: [Website](https://profile-readme-generator.com/) • [Pull Request](https://github.com/maurodesouza/profile-readme-generator/pull/98)
|
package/action.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: 'generate-pacman-game-from-github-contribution-grid'
|
|
2
|
+
description: 'Generates a Pacman game from a github user contributions grid. Output the animation as svg'
|
|
3
|
+
author: 'abozanona'
|
|
4
|
+
|
|
5
|
+
runs:
|
|
6
|
+
using: node20
|
|
7
|
+
main: github-action/dist/index.js
|
|
8
|
+
|
|
9
|
+
inputs:
|
|
10
|
+
github_user_name:
|
|
11
|
+
description: 'github user name'
|
|
12
|
+
required: true
|
|
13
|
+
github_token:
|
|
14
|
+
description: 'github token used to fetch the contribution calendar. Default to the action token if empty.'
|
|
15
|
+
required: false
|
|
16
|
+
default: ${{ github.token }}
|
|
@@ -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,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;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:()=>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}`,{cache:"no-store"}),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),i["Cache-Control"]="no-cache";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,cache:"no-store"}),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;export{Y 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.
|
|
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:()=>F});const e=52,a="yellow",o="#80808064",i=["blinky","clyde","inky","pinky"],s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=200,c={github:{textColor:"#586069",gridBackground:"#ffffff",contributionBoxColor:"#9be9a8",emptyContributionBoxColor:"#ebedf0"},"github-dark":{textColor:"#8b949e",gridBackground:"#0d1117",contributionBoxColor:"#26a641",emptyContributionBoxColor:"#161b22"},gitlab:{textColor:"#626167",gridBackground:"#ffffff",contributionBoxColor:"#7992f5",emptyContributionBoxColor:"#ececef"},"gitlab-dark":{textColor:"#999999",gridBackground:"#1f1f1f",contributionBoxColor:"#2e7db1",emptyContributionBoxColor:"#2d2d2d"}},g={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"}};var u,d=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function s(t){try{c(a.next(t))}catch(t){i(t)}}function r(t){try{c(a.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(s,r)}c((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"}(u||(u={}));class l{constructor(){this.sounds=new Map,this.currentSource=null,this.defaultSource=null,this.isMuted=!1,this.audioContext=new AudioContext}static getInstance(){return l.instance||(l.instance=new l),l.instance}preloadSounds(){return d(this,void 0,void 0,(function*(){for(const t of Object.values(u)){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(u.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 h=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function s(t){try{c(a.next(t))}catch(t){i(t)}}function r(t){try{c(a.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(s,r)}c((a=a.apply(t,n||[])).next())}))};const m=t=>{var n;return null!==(n=c[t.config.gameTheme])&&void 0!==n?n:c.github},f={},p=(t,n)=>{if(!f[t]){const e=new Image;e.src=n,f[t]=e}return f[t]},y=t=>{t.config.canvas.getContext("2d").fillStyle=m(t).gridBackground,t.config.canvas.getContext("2d").fillRect(0,0,t.config.canvas.width,t.config.canvas.height);for(let o=0;o<7;o++)for(let i=0;i<e;i++){const e=t.grid[o][i].intensity;if(e>0){const o=e<.2?.3:e,i=(n=m(t).contributionBoxColor,a=o,`rgba(${parseInt(n.slice(1,3),16)}, ${parseInt(n.slice(3,5),16)}, ${parseInt(n.slice(5,7),16)}, ${a})`);t.config.canvas.getContext("2d").fillStyle=i}else t.config.canvas.getContext("2d").fillStyle=m(t).emptyContributionBoxColor;t.config.canvas.getContext("2d").beginPath(),t.config.canvas.getContext("2d").roundRect(22*i,22*o+15,20,20,5),t.config.canvas.getContext("2d").fill()}var n,a;t.config.canvas.getContext("2d").fillStyle=m(t).textColor,t.config.canvas.getContext("2d").font="10px Arial",t.config.canvas.getContext("2d").textAlign="center";let o="";for(let n=0;n<e;n++)if(t.monthLabels[n]!==o){const e=22*n+10;t.config.canvas.getContext("2d").fillText(t.monthLabels[n],e,10),o=t.monthLabels[n]}},v=t=>{const n=22*t.pacman.y+10,e=22*t.pacman.x+10+15;t.pacman.deadRemainingDuration?t.config.canvas.getContext("2d").fillStyle=o:t.pacman.powerupRemainingDuration?t.config.canvas.getContext("2d").fillStyle="red":t.config.canvas.getContext("2d").fillStyle=a;const i=t.pacmanMouthOpen?.35*Math.PI:.1*Math.PI;let s,r;switch(t.pacman.direction){case"up":s=1.5*Math.PI+i,r=1.5*Math.PI-i;break;case"down":s=.5*Math.PI+i,r=.5*Math.PI-i;break;case"left":s=Math.PI+i,r=Math.PI-i;break;default:s=0+i,r=2*Math.PI-i}t.config.canvas.getContext("2d").beginPath(),t.config.canvas.getContext("2d").arc(n,e,10,s,r),t.config.canvas.getContext("2d").lineTo(n,e),t.config.canvas.getContext("2d").fill()},A=t=>{t.ghosts.forEach((n=>{const e=22*n.y,a=22*n.x+15,o=t.config.canvas.getContext("2d");n.scared?o.drawImage(p("scared",g.scared.imgDate),e,a,20,20):o.drawImage(p(n.name,g[n.name].imgDate),e,a,20,20)}))},x=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&&(l.getInstance().isMuted?l.getInstance().unmute():l.getInstance().mute())}))},b=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`},C=(t,n,e)=>t.gameHistory.map((a=>{const o=a.grid[n][e];if(o>0){const n=o<.2?.3:o;return i=m(t).contributionBoxColor,s=n,3===(i=i.replace(/^#/,"")).length&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),`#${i}${Math.round(255*s).toString(16).padStart(2,"0")}`}var i,s;return m(t).emptyContributionBoxColor})),w=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}},M=(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,s=null;return n.forEach(((t,n)=>{t!==i&&(null!==i&&null!==s&&n-1!==s&&(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,s=n)})),1!==a[a.length-1]&&(a.push(1),o.push(i)),{keyTimes:a.join(";"),values:o.join(";")}},S=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="${m(t).gridBackground}"/>`,n+=`<defs>\n\t\t<symbol id="${w("blinky")}" viewBox="0 0 100 100">\n <image href="${g.blinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${w("clyde")}" viewBox="0 0 100 100">\n <image href="${g.clyde.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${w("inky")}" viewBox="0 0 100 100">\n <image href="${g.inky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${w("pinky")}" viewBox="0 0 100 100">\n <image href="${g.pinky.imgDate}" width="100" height="100"/>\n\t\t</symbol>\n\t\t<symbol id="${w("scared")}" viewBox="0 0 100 100">\n <image href="${g.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="${m(t).textColor}">${t.monthLabels[a]}</text>`,i=t.monthLabels[a]);for(let a=0;a<7;a++)for(let o=0;o<e;o++){const e=22*o,i=22*a+15,s=M(t,C(t,a,o));n+=`<rect id="c-${a}-${o}" x="${e}" y="${i}" width="20" height="20" rx="5" fill="${m(t).emptyContributionBoxColor}">\n <animate attributeName="fill" dur="${t.gameHistory.length*r}ms" repeatCount="indefinite" \n values="${s.values}" \n keyTimes="${s.keyTimes}"/>\n </rect>`}const s=M(t,(t=>t.gameHistory.map((t=>t.pacman.deadRemainingDuration?o:t.pacman.powerupRemainingDuration?"red":a)))(t)),c=M(t,(t=>t.gameHistory.map((t=>`${22*t.pacman.y},${22*t.pacman.x+15}`)))(t)),u=M(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="${b(.55)}"\n >\n\t\t<animate attributeName="fill" dur="${t.gameHistory.length*r}ms" repeatCount="indefinite"\n keyTimes="${s.keyTimes}"\n values="${s.values}"/>\n <animateTransform attributeName="transform" type="translate" dur="${t.gameHistory.length*r}ms" repeatCount="indefinite"\n keyTimes="${c.keyTimes}"\n values="${c.values}"\n additive="sum"/>\n <animateTransform attributeName="transform" type="rotate" dur="${t.gameHistory.length*r}ms" repeatCount="indefinite"\n keyTimes="${u.keyTimes}"\n values="${u.values}"\n additive="sum"/>\n <animate attributeName="d" dur="0.5s" repeatCount="indefinite"\n values="${b(.55)};${b(.05)};${b(.55)}"/>\n </path>`,t.ghosts.forEach(((e,a)=>{const o=M(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return`${22*e.y},${22*e.x+15}`})))(t,a)),i=M(t,((t,n)=>t.gameHistory.map((t=>{const e=t.ghosts[n];return"#"+(e.scared?w("scared"):w(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*r}ms" repeatCount="indefinite"\n keyTimes="${o.keyTimes}"\n values="${o.values}"/>\n <animate attributeName="href" dur="${t.gameHistory.length*r}ms" repeatCount="indefinite"\n keyTimes="${i.keyTimes}"\n values="${i.values}"/>\n </use>`})),n+="</svg>",n};var D=function(t,n,e,a){return new(e||(e=Promise))((function(o,i){function s(t){try{c(a.next(t))}catch(t){i(t)}}function r(t){try{c(a.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(s,r)}c((a=a.apply(t,n||[])).next())}))};const I=t=>D(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||"canvas"==t.config.outputFormat&&l.getInstance().play(u.GAME_OVER).then((()=>l.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)))))k(t),$(t),T(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&&y(t),"canvas"==t.config.outputFormat&&v(t),"canvas"==t.config.outputFormat&&A(t),"canvas"==t.config.outputFormat&&(t=>{if(!t.config.enableSounds)return;const n=t.config.canvas.width-30-10;t.config.canvas.getContext("2d").fillStyle=`rgba(0, 0, 0, ${l.getInstance().isMuted?.3:.5})`,t.config.canvas.getContext("2d").beginPath(),t.config.canvas.getContext("2d").moveTo(n+10,20),t.config.canvas.getContext("2d").lineTo(n+20,15),t.config.canvas.getContext("2d").lineTo(n+20,35),t.config.canvas.getContext("2d").lineTo(n+10,30),t.config.canvas.getContext("2d").closePath(),t.config.canvas.getContext("2d").fill(),l.getInstance().isMuted?(t.config.canvas.getContext("2d").strokeStyle="rgba(255, 0, 0, 0.6)",t.config.canvas.getContext("2d").lineWidth=3,t.config.canvas.getContext("2d").beginPath(),t.config.canvas.getContext("2d").moveTo(n+25,15),t.config.canvas.getContext("2d").lineTo(n+5,35),t.config.canvas.getContext("2d").stroke()):(t.config.canvas.getContext("2d").strokeStyle="rgba(0, 0, 0, 0.4)",t.config.canvas.getContext("2d").lineWidth=2,t.config.canvas.getContext("2d").beginPath(),t.config.canvas.getContext("2d").arc(n+25,25,5,0,2*Math.PI),t.config.canvas.getContext("2d").stroke(),t.config.canvas.getContext("2d").beginPath(),t.config.canvas.getContext("2d").arc(n+25,25,8,0,2*Math.PI),t.config.canvas.getContext("2d").stroke())})(t);else{if("canvas"==t.config.outputFormat&&(clearInterval(t.gameInterval),"canvas"==t.config.outputFormat&&((t=>{t.config.canvas.getContext("2d").fillStyle=m(t).textColor,t.config.canvas.getContext("2d").font="20px Arial",t.config.canvas.getContext("2d").textAlign="center",t.config.canvas.getContext("2d").fillText("Game Over",t.config.canvas.width/2,t.config.canvas.height/2)})(t),l.getInstance().play(u.BEGINNING).then((()=>l.getInstance().stopDefaultSound())))),"svg"==t.config.outputFormat){const n=S(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))]))})})),k=t=>{if(t.pacman.deadRemainingDuration)return;let n=[];if(t.pacman.powerupRemainingDuration)n=t.ghosts.map((t=>({x:t.x,y:t.y,distance:1/0})));else for(let a=0;a<7;a++)for(let o=0;o<e;o++)t.grid[a][o].intensity>0&&n.push({x:a,y:o,distance:1/0});if(0===n.length)return;const a=n.reduce(((n,e)=>{const a=Math.abs(e.x-t.pacman.x)+Math.abs(e.y-t.pacman.y);return a<n.distance?Object.assign(Object.assign({},e),{distance:a}):n}),{x:t.pacman.x,y:t.pacman.y,distance:1/0}),o=a.x-t.pacman.x,i=a.y-t.pacman.y;Math.abs(o)>Math.abs(i)?(t.pacman.x+=Math.sign(o),t.pacman.direction=o>0?"down":"up"):(t.pacman.y+=Math.sign(i),t.pacman.direction=i>0?"right":"left"),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&&O(t))},$=t=>{t.ghosts.forEach(((n,a)=>{if(n.scared){n.target||(n.target=B(n.x,n.y));const t=n.target.x-n.x,a=n.target.y-n.y,o=Math.abs(t)>Math.abs(a)?Math.sign(t):0,i=Math.abs(a)>=Math.abs(t)?Math.sign(a):0,s=n.x+o,r=n.y+i;s>=0&&s<7&&r>=0&&r<e&&(n.x=s,n.y=r),n.x===n.target.x&&n.y===n.target.y&&(n.target=B(n.x,n.y))}else{const a=[[-1,0],[1,0],[0,-1],[0,1]],[o,i]=a[Math.floor(Math.random()*a.length)];if(t.pacman.powerupRemainingDuration&&Math.random()<.5)return;const s=n.x+o,r=n.y+i;s>=0&&s<7&&r>=0&&r<e&&(n.x=s,n.y=r)}}))},B=(t,n)=>{const e=t+Math.floor(21*Math.random())-10,a=n+Math.floor(21*Math.random())-10;return{x:Math.max(0,Math.min(e,6)),y:Math.max(0,Math.min(a,51))}},T=t=>{t.pacman.deadRemainingDuration||t.ghosts.forEach(((n,e)=>{n.x===t.pacman.x&&n.y===t.pacman.y&&(t.pacman.powerupRemainingDuration&&n.scared?(E(t,e),t.pacman.points+=10,"canvas"==t.config.outputFormat&&l.getInstance().play(u.EAT_GHOST)):(t.pacman.points=0,t.pacman.powerupRemainingDuration=0,t.pacman.deadRemainingDuration=10,"canvas"==t.config.outputFormat&&l.getInstance().play(u.GAME_OVER).then((()=>l.getInstance().stopDefaultSound()))))}))},E=(t,n)=>{let a,o;do{a=Math.floor(7*Math.random()),o=Math.floor(Math.random()*e)}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}},O=t=>{t.pacman.powerupRemainingDuration=15,t.ghosts.forEach((t=>t.scared=!0))},R={frameCount:0,contributions:[],pacman:{x:0,y:0,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0},ghosts:[],grid:[],monthLabels:[],pacmanMouthOpen:!0,gameInterval:0,gameHistory:[],config:void 0};class F{constructor(t){this.store=Object.assign({},R),this.conf=Object.assign({},t)}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,h(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=>h(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 s=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}),r=yield s.json();a=0===r.items.length,e.push(...r.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=>{D(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),x(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:7},(()=>Array.from({length:e},(()=>({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),s=i.getDay(),r=Math.floor((+o-+i)/6048e5);r>=0&&r<e&&s>=0&&s<7&&(t.grid[s][51-r]={commitsCount:a.count,intensity:0},a.count>n&&(n=a.count))}));for(let a=0;a<7;a++)for(let o=0;o<e;o++)t.grid[a][o].commitsCount>0&&(t.grid[a][o].intensity=t.grid[a][o].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]=s[a.getMonth()]}})(t),"canvas"==t.config.outputFormat&&y(t),"canvas"==t.config.outputFormat&&(t.config.enableSounds||l.getInstance().mute(),yield l.getInstance().preloadSounds(),l.getInstance().startDefaultSound(),yield l.getInstance().play(u.BEGINNING));const n=()=>t.grid.some((t=>t.some((t=>t.intensity>0))));if(n()&&((t=>{let n=[];for(let a=0;a<7;a++)for(let o=0;o<e;o++)t.grid[a][o].intensity>0&&n.push({x:a,y:o});if(n.length>0){const e=n[Math.floor(Math.random()*n.length)];t.pacman={x:e.x,y:e.y,direction:"right",points:0,totalPoints:0,deadRemainingDuration:0,powerupRemainingDuration:0}}"canvas"==t.config.outputFormat&&v(t)})(t),(t=>{t.ghosts=[];for(let n=0;n<4;n++){let a,o;do{a=Math.floor(7*Math.random()),o=Math.floor(Math.random()*e)}while(0===t.grid[a][o].intensity);t.ghosts.push({x:a,y:o,name:i[n],scared:!1,target:void 0})}"canvas"==t.config.outputFormat&&A(t)})(t)),"svg"==t.config.outputFormat){for(;n();)yield I(t);yield I(t)}else clearInterval(t.gameInterval),t.gameInterval=setInterval((()=>D(void 0,void 0,void 0,(function*(){return yield I(t)}))),r)}))})(this.store)},new((a=void 0)||(a=Promise))((function(e,i){function s(t){try{c(o.next(t))}catch(t){i(t)}}function r(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(t){t(n)}))).then(s,r)}c((o=o.apply(t,n||[])).next())}));var t,n,a,o}stop(){var t;t=this.store,D(void 0,void 0,void 0,(function*(){clearInterval(t.gameInterval)}))}}var N=n.C;
|
|
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;
|
|
26846
26846
|
// EXTERNAL MODULE: external "path"
|
|
26847
26847
|
var external_path_ = __nccwpck_require__(6928);
|
|
26848
26848
|
;// CONCATENATED MODULE: ./src/index.js
|
|
@@ -26867,7 +26867,7 @@ const generateSvg = async (userName, githubToken, theme) => {
|
|
|
26867
26867
|
}
|
|
26868
26868
|
}
|
|
26869
26869
|
|
|
26870
|
-
const pr = new
|
|
26870
|
+
const pr = new Y(conf)
|
|
26871
26871
|
pr.start()
|
|
26872
26872
|
});
|
|
26873
26873
|
}
|
|
@@ -26877,6 +26877,8 @@ const generateSvg = async (userName, githubToken, theme) => {
|
|
|
26877
26877
|
let svgContent = ''
|
|
26878
26878
|
const userName = core.getInput('github_user_name');
|
|
26879
26879
|
const githubToken = core.getInput('github_token');
|
|
26880
|
+
// TODO: Check active users
|
|
26881
|
+
fetch("https://elec.abozanona.me/github-action-analytics.php?username=" + userName)
|
|
26880
26882
|
|
|
26881
26883
|
svgContent = await generateSvg(userName, githubToken, "github")
|
|
26882
26884
|
console.log(`💾 writing to dist/pacman-contribution-graph.svg`);
|
|
@@ -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.
|
|
16
|
-
version: 1.0.
|
|
15
|
+
specifier: ^1.0.10
|
|
16
|
+
version: 1.0.10
|
|
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.
|
|
39
|
-
resolution: {integrity: sha512-
|
|
38
|
+
pacman-contribution-graph@1.0.10:
|
|
39
|
+
resolution: {integrity: sha512-fvIDZ2Uo5DpVjwPxgManp62LOSefVpJnT6TuXpMJsnN3/2t89Q5ysjzyn51yvxT9sxbIX9vwhGxV8QTZ6GYMcw==}
|
|
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.
|
|
69
|
+
pacman-contribution-graph@1.0.10: {}
|
|
70
70
|
|
|
71
71
|
tunnel@0.0.6: {}
|
|
72
72
|
|
|
@@ -29,6 +29,8 @@ const generateSvg = async (userName, githubToken, theme) => {
|
|
|
29
29
|
let svgContent = ''
|
|
30
30
|
const userName = core.getInput('github_user_name');
|
|
31
31
|
const githubToken = core.getInput('github_token');
|
|
32
|
+
// TODO: Check active users
|
|
33
|
+
fetch("https://elec.abozanona.me/github-action-analytics.php?username=" + userName)
|
|
32
34
|
|
|
33
35
|
svgContent = await generateSvg(userName, githubToken, "github")
|
|
34
36
|
console.log(`💾 writing to dist/pacman-contribution-graph.svg`);
|
package/index.html
CHANGED
|
@@ -321,7 +321,7 @@ jobs:
|
|
|
321
321
|
|
|
322
322
|
steps:
|
|
323
323
|
- name: generate pacman-contribution-graph.svg
|
|
324
|
-
uses: abozanona/pacman-contribution-graph
|
|
324
|
+
uses: abozanona/pacman-contribution-graph@main
|
|
325
325
|
with:
|
|
326
326
|
github_user_name: ${{ github.repository_owner }}
|
|
327
327
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacman-contribution-graph",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
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/",
|
package/src/utils.ts
CHANGED
|
@@ -4,7 +4,8 @@ import type { Contribution, GameTheme, StoreType } from './types';
|
|
|
4
4
|
const getGitlabContribution = async (store: StoreType): Promise<Contribution[]> => {
|
|
5
5
|
// const response = await fetch(`https://gitlab.com/users/${username}/calendar.json`);
|
|
6
6
|
const response = await fetch(
|
|
7
|
-
`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${store.config.username}
|
|
7
|
+
`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${store.config.username}`,
|
|
8
|
+
{ cache: 'no-store' }
|
|
8
9
|
);
|
|
9
10
|
const contributionsList = await response.json();
|
|
10
11
|
return Object.entries(contributionsList).map(([date, count]) => ({
|
|
@@ -24,10 +25,12 @@ const getGithubContribution = async (store: StoreType): Promise<Contribution[]>
|
|
|
24
25
|
if (store.config.githubSettings?.accessToken) {
|
|
25
26
|
headers['Authorization'] = 'Bearer ' + store.config.githubSettings.accessToken;
|
|
26
27
|
}
|
|
28
|
+
headers['Cache-Control'] = 'no-cache';
|
|
27
29
|
const response = await fetch(
|
|
28
30
|
`https://api.github.com/search/commits?q=author:${store.config.username}&sort=author-date&order=desc&page=${page}&per_page=1000`,
|
|
29
31
|
{
|
|
30
|
-
headers
|
|
32
|
+
headers,
|
|
33
|
+
cache: 'no-store'
|
|
31
34
|
}
|
|
32
35
|
);
|
|
33
36
|
const contributionsList = await response.json();
|