🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

github-contrib-graph

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-contrib-graph - npm Package Compare versions

Comparing version
3.1.0
to
3.1.1
+248
dist/themes-CKoQTTmA.d.cts
/**
* Contribution level indicating activity intensity
*/
type ContributionLevel = 'NONE' | 'FIRST_QUARTILE' | 'SECOND_QUARTILE' | 'THIRD_QUARTILE' | 'FOURTH_QUARTILE';
/**
* A single day's contribution data
*/
interface ContributionDay {
date: string;
contributionCount: number;
contributionLevel: ContributionLevel;
weekday: number;
}
/**
* A week of contribution data
*/
interface ContributionWeek {
contributionDays: ContributionDay[];
}
/**
* A month label in the calendar
*/
interface ContributionMonth {
name: string;
totalWeeks: number;
}
/**
* The full contribution calendar data
*/
interface ContributionCalendar {
totalContributions: number;
months: ContributionMonth[];
weeks: ContributionWeek[];
}
/**
* GitHub user data from API response
*/
interface GitHubUser {
avatarUrl: string;
contributionsCollection: {
contributionCalendar: ContributionCalendar;
};
}
/**
* API response structure
*/
interface APIResponse {
user: GitHubUser | null;
error?: string;
}
/**
* CSS custom property value. Numbers are converted to px when applied as a theme.
*/
type CSSValue = string | number;
/**
* Available theme presets
*/
type ThemePreset = 'default' | 'void' | 'slate' | 'midnight' | 'glacier' | 'cyber';
/**
* Custom theme configuration
*/
interface ThemeConfig {
bgColor?: CSSValue;
textColor?: CSSValue;
inactiveTextColor?: CSSValue;
linkHoverColor?: CSSValue;
cellLevel0?: CSSValue;
cellLevel1?: CSSValue;
cellLevel2?: CSSValue;
cellLevel3?: CSSValue;
cellLevel4?: CSSValue;
cellSize?: CSSValue;
cellGap?: CSSValue;
cellRadius?: CSSValue;
cellBorderColor?: CSSValue;
cellOutlineColor?: CSSValue;
tooltipBgColor?: CSSValue;
tooltipTextColor?: CSSValue;
tooltipPadding?: CSSValue;
tooltipRadius?: CSSValue;
tooltipFontSize?: CSSValue;
borderColor?: CSSValue;
borderWidth?: CSSValue;
cardPadding?: CSSValue;
cardPaddingBlock?: CSSValue;
cardRadius?: CSSValue;
canvasPaddingTop?: CSSValue;
canvasMarginInline?: CSSValue;
headerHeight?: CSSValue;
headerMarginBottom?: CSSValue;
headerFontSize?: CSSValue;
avatarSize?: CSSValue;
footerPadding?: CSSValue;
footerFontSize?: CSSValue;
fontFamily?: CSSValue;
}
/**
* Class hooks for styling or targeting rendered widget elements.
*/
interface CalendarClassNames {
root?: string;
header?: string;
total?: string;
profile?: string;
profileLink?: string;
avatar?: string;
card?: string;
canvas?: string;
table?: string;
monthLabel?: string;
dayLabel?: string;
dayCell?: string;
tooltip?: string;
footer?: string;
footerLegend?: string;
thumbnail?: string;
thumbnailLink?: string;
}
interface DayRenderContext {
day: ContributionDay;
week: ContributionWeek;
weekIndex: number;
dayIndex: number;
date: Date;
username: string;
}
interface HeaderRenderContext {
user: GitHubUser;
username: string;
totalContributions: number;
}
interface FooterRenderContext {
levels: ContributionLevel[];
labels: Required<FooterLabels>;
}
interface ThumbnailRenderContext {
repoUrl: string;
}
interface FooterLabels {
less?: string;
more?: string;
}
/**
* Inline style map for contribution day cells. Numeric values are converted to px.
*/
type DayStyle = Record<string, CSSValue | null | undefined>;
/**
* Widget render options
*/
interface RenderOptions {
showHeader?: boolean;
showFooter?: boolean;
showThumbnail?: boolean;
showMonthLabels?: boolean;
showWeekdayLabels?: boolean;
showTooltips?: boolean;
dayLabels?: string[];
footerLabels?: FooterLabels;
classNames?: CalendarClassNames;
dayClassName?: string | ((context: DayRenderContext) => string | null | undefined | false);
dayStyle?: DayStyle | ((context: DayRenderContext) => DayStyle | null | undefined);
dayAttributes?: (context: DayRenderContext) => Record<string, string | number | boolean | null | undefined> | null | undefined;
tooltipFormatter?: (context: DayRenderContext) => string;
monthLabelFormatter?: (month: ContributionMonth, index: number, months: ContributionMonth[]) => string;
renderDayContents?: (context: DayRenderContext) => Node | string | null | undefined;
renderHeader?: (context: HeaderRenderContext) => HTMLElement | null | undefined;
renderFooter?: (context: FooterRenderContext) => HTMLElement | null | undefined;
renderThumbnail?: (context: ThumbnailRenderContext) => HTMLElement | null | undefined;
}
/**
* Configuration for the widget
*/
interface GitHubContributionGraphConfig extends RenderOptions {
username: string;
apiEndpoint?: string;
container?: string | HTMLElement;
theme?: ThemePreset | ThemeConfig;
onDataLoaded?: (data: GitHubUser) => void;
onError?: (error: Error) => void;
}
/**
* Default API endpoint for fetching contribution data
*/
declare const DEFAULT_API_ENDPOINT = "https://githubgraph.jigyansurout.com/api/ghcg/fetch-data";
/**
* Root class applied to every rendered widget container.
*/
declare const ROOT_CLASS = "ghContributionGraph";
/**
* Repository URL for the widget
*/
declare const REPO_URL = "https://github.com/iamjr15/github-contribution-graph";
/**
* Contribution level values in order
*/
declare const CONTRIBUTION_LEVELS: ContributionLevel[];
/**
* Day labels for the calendar rows
*/
declare const DAY_LABELS: string[];
/**
* Theme presets with CSS variable values
*/
declare const THEME_PRESETS: Record<ThemePreset, ThemeConfig>;
/**
* Fetch contribution data for a GitHub user
*
* @param username - GitHub username
* @param apiEndpoint - Optional custom API endpoint
* @returns Promise resolving to user data
* @throws Error if user not found or network error
*
* @example
* ```ts
* const userData = await fetchContributionData('octocat');
* console.log(userData.contributionsCollection.contributionCalendar.totalContributions);
* ```
*/
declare function fetchContributionData(username: string, apiEndpoint?: string): Promise<GitHubUser>;
/**
* Apply a theme to an element by setting CSS custom properties
*
* @param element - The element to apply theme to
* @param theme - Theme preset name or custom config
*
* @example
* ```ts
* applyTheme(container, 'void');
* applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });
* ```
*/
declare function applyTheme(element: HTMLElement, theme: ThemePreset | ThemeConfig): void;
/**
* Generate CSS string from a theme configuration
*
* @param theme - Theme preset name or custom config
* @returns CSS custom properties string
*/
declare function getThemeCSS(theme: ThemePreset | ThemeConfig): string;
/**
* Get all available theme preset names
*/
declare function getThemePresets(): ThemePreset[];
export { type APIResponse as A, type ContributionCalendar as C, DEFAULT_API_ENDPOINT as D, type FooterLabels as F, type GitHubUser as G, type HeaderRenderContext as H, type RenderOptions as R, type ThemePreset as T, type ThemeConfig as a, applyTheme as b, getThemeCSS as c, THEME_PRESETS as d, type ContributionDay as e, fetchContributionData as f, getThemePresets as g, type ContributionWeek as h, type ContributionMonth as i, type CalendarClassNames as j, type DayStyle as k, type DayRenderContext as l, type FooterRenderContext as m, type ThumbnailRenderContext as n, type GitHubContributionGraphConfig as o, type ContributionLevel as p, type CSSValue as q, ROOT_CLASS as r, REPO_URL as s, CONTRIBUTION_LEVELS as t, DAY_LABELS as u };
/**
* Contribution level indicating activity intensity
*/
type ContributionLevel = 'NONE' | 'FIRST_QUARTILE' | 'SECOND_QUARTILE' | 'THIRD_QUARTILE' | 'FOURTH_QUARTILE';
/**
* A single day's contribution data
*/
interface ContributionDay {
date: string;
contributionCount: number;
contributionLevel: ContributionLevel;
weekday: number;
}
/**
* A week of contribution data
*/
interface ContributionWeek {
contributionDays: ContributionDay[];
}
/**
* A month label in the calendar
*/
interface ContributionMonth {
name: string;
totalWeeks: number;
}
/**
* The full contribution calendar data
*/
interface ContributionCalendar {
totalContributions: number;
months: ContributionMonth[];
weeks: ContributionWeek[];
}
/**
* GitHub user data from API response
*/
interface GitHubUser {
avatarUrl: string;
contributionsCollection: {
contributionCalendar: ContributionCalendar;
};
}
/**
* API response structure
*/
interface APIResponse {
user: GitHubUser | null;
error?: string;
}
/**
* CSS custom property value. Numbers are converted to px when applied as a theme.
*/
type CSSValue = string | number;
/**
* Available theme presets
*/
type ThemePreset = 'default' | 'void' | 'slate' | 'midnight' | 'glacier' | 'cyber';
/**
* Custom theme configuration
*/
interface ThemeConfig {
bgColor?: CSSValue;
textColor?: CSSValue;
inactiveTextColor?: CSSValue;
linkHoverColor?: CSSValue;
cellLevel0?: CSSValue;
cellLevel1?: CSSValue;
cellLevel2?: CSSValue;
cellLevel3?: CSSValue;
cellLevel4?: CSSValue;
cellSize?: CSSValue;
cellGap?: CSSValue;
cellRadius?: CSSValue;
cellBorderColor?: CSSValue;
cellOutlineColor?: CSSValue;
tooltipBgColor?: CSSValue;
tooltipTextColor?: CSSValue;
tooltipPadding?: CSSValue;
tooltipRadius?: CSSValue;
tooltipFontSize?: CSSValue;
borderColor?: CSSValue;
borderWidth?: CSSValue;
cardPadding?: CSSValue;
cardPaddingBlock?: CSSValue;
cardRadius?: CSSValue;
canvasPaddingTop?: CSSValue;
canvasMarginInline?: CSSValue;
headerHeight?: CSSValue;
headerMarginBottom?: CSSValue;
headerFontSize?: CSSValue;
avatarSize?: CSSValue;
footerPadding?: CSSValue;
footerFontSize?: CSSValue;
fontFamily?: CSSValue;
}
/**
* Class hooks for styling or targeting rendered widget elements.
*/
interface CalendarClassNames {
root?: string;
header?: string;
total?: string;
profile?: string;
profileLink?: string;
avatar?: string;
card?: string;
canvas?: string;
table?: string;
monthLabel?: string;
dayLabel?: string;
dayCell?: string;
tooltip?: string;
footer?: string;
footerLegend?: string;
thumbnail?: string;
thumbnailLink?: string;
}
interface DayRenderContext {
day: ContributionDay;
week: ContributionWeek;
weekIndex: number;
dayIndex: number;
date: Date;
username: string;
}
interface HeaderRenderContext {
user: GitHubUser;
username: string;
totalContributions: number;
}
interface FooterRenderContext {
levels: ContributionLevel[];
labels: Required<FooterLabels>;
}
interface ThumbnailRenderContext {
repoUrl: string;
}
interface FooterLabels {
less?: string;
more?: string;
}
/**
* Inline style map for contribution day cells. Numeric values are converted to px.
*/
type DayStyle = Record<string, CSSValue | null | undefined>;
/**
* Widget render options
*/
interface RenderOptions {
showHeader?: boolean;
showFooter?: boolean;
showThumbnail?: boolean;
showMonthLabels?: boolean;
showWeekdayLabels?: boolean;
showTooltips?: boolean;
dayLabels?: string[];
footerLabels?: FooterLabels;
classNames?: CalendarClassNames;
dayClassName?: string | ((context: DayRenderContext) => string | null | undefined | false);
dayStyle?: DayStyle | ((context: DayRenderContext) => DayStyle | null | undefined);
dayAttributes?: (context: DayRenderContext) => Record<string, string | number | boolean | null | undefined> | null | undefined;
tooltipFormatter?: (context: DayRenderContext) => string;
monthLabelFormatter?: (month: ContributionMonth, index: number, months: ContributionMonth[]) => string;
renderDayContents?: (context: DayRenderContext) => Node | string | null | undefined;
renderHeader?: (context: HeaderRenderContext) => HTMLElement | null | undefined;
renderFooter?: (context: FooterRenderContext) => HTMLElement | null | undefined;
renderThumbnail?: (context: ThumbnailRenderContext) => HTMLElement | null | undefined;
}
/**
* Configuration for the widget
*/
interface GitHubContributionGraphConfig extends RenderOptions {
username: string;
apiEndpoint?: string;
container?: string | HTMLElement;
theme?: ThemePreset | ThemeConfig;
onDataLoaded?: (data: GitHubUser) => void;
onError?: (error: Error) => void;
}
/**
* Default API endpoint for fetching contribution data
*/
declare const DEFAULT_API_ENDPOINT = "https://githubgraph.jigyansurout.com/api/ghcg/fetch-data";
/**
* Root class applied to every rendered widget container.
*/
declare const ROOT_CLASS = "ghContributionGraph";
/**
* Repository URL for the widget
*/
declare const REPO_URL = "https://github.com/iamjr15/github-contribution-graph";
/**
* Contribution level values in order
*/
declare const CONTRIBUTION_LEVELS: ContributionLevel[];
/**
* Day labels for the calendar rows
*/
declare const DAY_LABELS: string[];
/**
* Theme presets with CSS variable values
*/
declare const THEME_PRESETS: Record<ThemePreset, ThemeConfig>;
/**
* Fetch contribution data for a GitHub user
*
* @param username - GitHub username
* @param apiEndpoint - Optional custom API endpoint
* @returns Promise resolving to user data
* @throws Error if user not found or network error
*
* @example
* ```ts
* const userData = await fetchContributionData('octocat');
* console.log(userData.contributionsCollection.contributionCalendar.totalContributions);
* ```
*/
declare function fetchContributionData(username: string, apiEndpoint?: string): Promise<GitHubUser>;
/**
* Apply a theme to an element by setting CSS custom properties
*
* @param element - The element to apply theme to
* @param theme - Theme preset name or custom config
*
* @example
* ```ts
* applyTheme(container, 'void');
* applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });
* ```
*/
declare function applyTheme(element: HTMLElement, theme: ThemePreset | ThemeConfig): void;
/**
* Generate CSS string from a theme configuration
*
* @param theme - Theme preset name or custom config
* @returns CSS custom properties string
*/
declare function getThemeCSS(theme: ThemePreset | ThemeConfig): string;
/**
* Get all available theme preset names
*/
declare function getThemePresets(): ThemePreset[];
export { type APIResponse as A, type ContributionCalendar as C, DEFAULT_API_ENDPOINT as D, type FooterLabels as F, type GitHubUser as G, type HeaderRenderContext as H, type RenderOptions as R, type ThemePreset as T, type ThemeConfig as a, applyTheme as b, getThemeCSS as c, THEME_PRESETS as d, type ContributionDay as e, fetchContributionData as f, getThemePresets as g, type ContributionWeek as h, type ContributionMonth as i, type CalendarClassNames as j, type DayStyle as k, type DayRenderContext as l, type FooterRenderContext as m, type ThumbnailRenderContext as n, type GitHubContributionGraphConfig as o, type ContributionLevel as p, type CSSValue as q, ROOT_CLASS as r, REPO_URL as s, CONTRIBUTION_LEVELS as t, DAY_LABELS as u };
+19
-0

@@ -5,2 +5,21 @@ # Changelog

## [3.1.1] - 2026-05-04
### Added
- Expanded theme configuration to cover sizing, spacing, radius, borders, text colors, tooltips, header, footer, canvas, and avatar styles.
- Added class hooks for major widget elements through `classNames`.
- Added label, tooltip, per-day class, per-day style, per-day attribute, and day-content render hooks for the default renderer.
- Added DOM render hooks for the header, footer, and thumbnail.
- Added a React `render` prop for fully custom JSX rendering with the package-managed loading, error, refresh, and fetched data state.
- Added custom loading and error fallback support for the React component.
### Fixed
- Corrected package documentation to use the published `github-contrib-graph` npm name.
- Added a stable `ghContributionGraph` root class so styles work outside `#gh`.
- Fixed generated theme CSS variable names from `getThemeCSS`.
- Preserved existing query parameters when building custom API endpoint URLs.
- Synced Cloudflare demo assets from the package build output.
## [3.0.1] - 2024-12-09

@@ -7,0 +26,0 @@

+1
-1

@@ -1,2 +0,2 @@

"use strict";var GitHubContributionGraph=(()=>{var m=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var R=(t,e)=>{for(var o in e)m(t,o,{get:e[o],enumerable:!0})},N=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of P(e))!M.call(t,i)&&i!==o&&m(t,i,{get:()=>e[i],enumerable:!(r=x(e,i))||r.enumerable});return t};var U=t=>N(m({},"__esModule",{value:!0}),t);var k={};R(k,{GitHubContributionWidget:()=>d,applyTheme:()=>u,autoInit:()=>b,fetchContributionData:()=>h,getThemePresets:()=>L,renderWidget:()=>p});var T="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",E="https://github.com/iamjr15/github-contribution-graph",y=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],g=["","Mon","","Wed","","Fri",""],C={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function h(t,e=T){if(!t||typeof t!="string")throw new Error("Username is required");let o=`${e}?login=${encodeURIComponent(t.trim())}`,r=new AbortController,i=setTimeout(()=>r.abort(),1e4),n;try{n=await fetch(o,{signal:r.signal})}catch(l){throw clearTimeout(i),l instanceof DOMException&&l.name==="AbortError"?new Error("Request timed out. Please try again."):l}if(clearTimeout(i),!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let a=await n.json();if(!a.user)throw new Error(a.error||"User not found");return a.user}function D(){let t=document.createElement("table");t.className="ghCalendarTable";let e=t.createTHead(),o=t.createTBody(),i=e.insertRow().insertCell();i.style.width="28px";for(let n=0;n<7;n++){let l=o.insertRow().insertCell();if(g[n]){let s=document.createElement("span");s.className="ghCalendarLabel",s.textContent=g[n],l.appendChild(s)}}return{table:t,thead:e,tbody:o}}function S(t,e){for(let o=0;o<e.length-1;o++){let r=e[o].totalWeeks;if(r>=2){let i=t.rows[0].insertCell(),n=document.createElement("span");n.textContent=e[o].name,n.className="ghCalendarLabel",i.appendChild(n),i.colSpan=r}}}function A(t,e){for(let o of e)for(let r of o.contributionDays){let i=document.createElement("span"),n=new Date(r.date);i.textContent=`${r.contributionCount} contributions on ${n.toDateString()}`;let a=t.rows[r.weekday].insertCell();a.appendChild(i),a.className="ghCalendarDayCell",a.dataset.date=r.date,a.dataset.count=String(r.contributionCount),a.dataset.level=r.contributionLevel}}function I(){let t=document.createElement("div");return t.className="ghCalendarCard",t}function G(){let t=document.createElement("div");return t.className="ghCalendarCanvas",t}function O(t,e,o){let r=document.createElement("div");r.className="ghCalendarHeader";let i=document.createElement("span");i.textContent=`${t} contributions in the last year`;let n=document.createElement("div"),a=document.createElement("a");a.href=`https://github.com/${encodeURIComponent(e)}`,a.textContent=e;let l=document.createElement("img");return l.src=o,l.alt=`${e}'s avatar`,n.appendChild(a),n.appendChild(l),r.appendChild(i),r.appendChild(n),r}function _(){let t=document.createElement("div");t.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let o=document.createElement("span");o.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(o);for(let i of y){let n=document.createElement("div");n.className="ghCalendarDayCell",n.dataset.level=i,e.appendChild(n)}return e.appendChild(r),t.appendChild(e),t}function F(){let t=document.createElement("div");t.className="ghThumbNail";let e=document.createElement("a");e.href=E,e.target="_blank",e.rel="noopener noreferrer";let o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 98 96"),o.setAttribute("width","18"),o.setAttribute("height","18"),o.style.marginTop="10px",o.style.opacity="0.5",o.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),o.appendChild(r),e.appendChild(o),t.appendChild(e),t}function p(t,e,o,r={}){let{showHeader:i=!0,showFooter:n=!0,showThumbnail:a=!0}=r;t.innerHTML="";let l=e.contributionsCollection.contributionCalendar,{table:s,thead:w,tbody:H}=D();A(H,l.weeks),S(w,l.months);let v=I(),f=G();if(f.appendChild(s),n){let c=_();f.appendChild(c)}if(v.appendChild(f),i){let c=O(l.totalContributions,o,e.avatarUrl);t.appendChild(c)}if(t.appendChild(v),a){let c=F();t.appendChild(c)}}function u(t,e){let o=typeof e=="string"?C[e]:e;o&&(o.bgColor&&t.style.setProperty("--gh-bg-color",o.bgColor),o.textColor&&t.style.setProperty("--gh-text-default-color",o.textColor),o.cellLevel0&&t.style.setProperty("--gh-cell-level0-color",o.cellLevel0),o.cellLevel1&&t.style.setProperty("--gh-cell-level1-color",o.cellLevel1),o.cellLevel2&&t.style.setProperty("--gh-cell-level2-color",o.cellLevel2),o.cellLevel3&&t.style.setProperty("--gh-cell-level3-color",o.cellLevel3),o.cellLevel4&&t.style.setProperty("--gh-cell-level4-color",o.cellLevel4),o.borderColor&&t.style.setProperty("--gh-border-card-color",o.borderColor),o.fontFamily&&t.style.setProperty("--gh-font-default-family",o.fontFamily))}function L(){return Object.keys(C)}var d=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container)}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let o=document.getElementById("gh");if(!o)throw new Error('No container found. Specify container in config or add element with id="gh"');return o}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e)}async render(){this.config.theme&&u(this.container,this.config.theme),this.showLoading();try{this.data=await h(this.config.username,this.config.apiEndpoint),p(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.onDataLoaded?.(this.data)}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"))}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};function b(){let t=document.getElementById("gh");if(!t)return;let e=t.dataset.login;if(!e)return;let o=t.dataset.showThumbnail!=="false",r=t.dataset.showHeader!=="false",i=t.dataset.showFooter!=="false",n=new d({username:e,container:t,showThumbnail:o,showHeader:r,showFooter:i});n.render(),typeof window<"u"&&(window.renderGitHubWidget=()=>{let a=t.dataset.login;return a&&a!==n.getUsername()?n.update({username:a}):n.render()})}typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",b):b());return U(k);})();
"use strict";var GitHubContributionGraph=(()=>{var L=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var D=(t,e)=>{for(var r in e)L(t,r,{get:e[r],enumerable:!0})},P=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of O(e))!M.call(t,o)&&o!==r&&L(t,o,{get:()=>e[o],enumerable:!(n=N(e,o))||n.enumerable});return t};var A=t=>P(L({},"__esModule",{value:!0}),t);var ee={};D(ee,{GitHubContributionWidget:()=>p,applyTheme:()=>y,autoInit:()=>x,fetchContributionData:()=>C,getThemePresets:()=>S,renderWidget:()=>b});var R="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",g="ghContributionGraph",v="https://github.com/iamjr15/github-contribution-graph",E=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],H=["","Mon","","Wed","","Fri",""],w={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};function U(t,e){let r=encodeURIComponent(e);try{let n=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",o=new URL(t,n);return o.searchParams.set("login",e),/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t)?o.toString():`${o.pathname}${o.search}${o.hash}`}catch{let n=t.includes("?")?"&":"?";return`${t}${n}login=${r}`}}async function C(t,e=R){if(!t||typeof t!="string"||!t.trim())throw new Error("Username is required");let r=t.trim(),n=U(e,r),o=new AbortController,a=setTimeout(()=>o.abort(),1e4),i;try{i=await fetch(n,{signal:o.signal})}catch(s){throw clearTimeout(a),s instanceof DOMException&&s.name==="AbortError"?new Error("Request timed out. Please try again."):s}if(clearTimeout(a),!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let l=await i.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function c(t,e){return[t,e].filter(Boolean).join(" ")}function m(t,e){e&&t.classList.add(...e.split(/\s+/).filter(Boolean))}function k(t){return t.dayLabels??H}function I(t,e){return e.tooltipFormatter?e.tooltipFormatter(t):`${t.day.contributionCount} contributions on ${t.date.toDateString()}`}function F(t){return typeof t=="number"?`${t}px`:t}function G(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function _(t,e){return typeof e.dayClassName=="function"?e.dayClassName(t)||void 0:e.dayClassName}function $(t,e,r){let n=typeof r.dayStyle=="function"?r.dayStyle(e):r.dayStyle;if(n)for(let[o,a]of Object.entries(n))a==null||a===""||t.style.setProperty(G(o),F(a))}function z(t,e,r){let n=r.dayAttributes?.(e);if(n)for(let[o,a]of Object.entries(n))a==null||a===!1||t.setAttribute(o,a===!0?"":String(a))}function W(t,e,r){let n=typeof r.renderDayContents=="function",o=n?r.renderDayContents?.(e):void 0;if(typeof o=="string"){t.appendChild(document.createTextNode(o));return}if(o instanceof Node){t.appendChild(o);return}if(!n&&r.showTooltips!==!1){let a=document.createElement("span");a.className=c("ghCalendarTooltip",r.classNames?.tooltip),a.textContent=I(e,r),t.appendChild(a)}}function B(t={}){let e=document.createElement("table");e.className=c("ghCalendarTable",t.classNames?.table);let r=e.createTHead(),n=e.createTBody(),a=r.insertRow().insertCell();a.style.width="28px";let i=k(t),l=t.showWeekdayLabels!==!1;for(let s=0;s<7;s++){let d=n.insertRow().insertCell();if(l&&i[s]){let f=document.createElement("span");f.className=c("ghCalendarLabel",t.classNames?.dayLabel),f.textContent=i[s],d.appendChild(f)}}return{table:e,thead:r,tbody:n}}function j(t,e,r={}){if(r.showMonthLabels!==!1)for(let n=0;n<e.length-1;n++){let o=e[n].totalWeeks;if(o>=2){let a=t.rows[0].insertCell(),i=document.createElement("span");i.textContent=r.monthLabelFormatter?r.monthLabelFormatter(e[n],n,e):e[n].name,i.className=c("ghCalendarLabel",r.classNames?.monthLabel),a.appendChild(i),a.colSpan=o}}}function V(t,e,r={},n=""){for(let[o,a]of e.entries())for(let[i,l]of a.contributionDays.entries()){let s=new Date(l.date),u={day:l,week:a,weekIndex:o,dayIndex:i,date:s,username:n},d=t.rows[l.weekday].insertCell();d.className=c(c("ghCalendarDayCell",r.classNames?.dayCell),_(u,r)),d.dataset.date=l.date,d.dataset.count=String(l.contributionCount),d.dataset.level=l.contributionLevel,d.dataset.week=String(o),d.dataset.weekday=String(l.weekday),$(d,u,r),z(d,u,r),W(d,u,r)}}function Q(t={}){let e=document.createElement("div");return e.className=c("ghCalendarCard",t.classNames?.card),e}function q(t={}){let e=document.createElement("div");return e.className=c("ghCalendarCanvas",t.classNames?.canvas),e}function Z(t,e,r,n={},o){if(n.renderHeader&&o){let d=n.renderHeader({user:o,username:e,totalContributions:t});if(d)return d}let a=document.createElement("div");a.className=c("ghCalendarHeader",n.classNames?.header);let i=document.createElement("span");m(i,n.classNames?.total),i.textContent=`${t} contributions in the last year`;let l=document.createElement("div");m(l,n.classNames?.profile);let s=document.createElement("a");s.href=`https://github.com/${encodeURIComponent(e)}`,s.textContent=e,m(s,n.classNames?.profileLink);let u=document.createElement("img");return u.src=r,u.alt=`${e}'s avatar`,m(u,n.classNames?.avatar),l.appendChild(s),l.appendChild(u),a.appendChild(i),a.appendChild(l),a}function K(t={}){let e={less:t.footerLabels?.less??"Less",more:t.footerLabels?.more??"More"};if(t.renderFooter){let i=t.renderFooter({levels:E,labels:e});if(i)return i}let r=document.createElement("div");r.className=c("ghCalendarCardFooter",t.classNames?.footer);let n=document.createElement("div");n.className=c("ghCalendarCardFooterColors",t.classNames?.footerLegend);let o=document.createElement("span");o.textContent=e.less;let a=document.createElement("span");a.textContent=e.more,n.appendChild(o);for(let i of E){let l=document.createElement("div");l.className=c("ghCalendarDayCell",t.classNames?.dayCell),l.dataset.level=i,n.appendChild(l)}return n.appendChild(a),r.appendChild(n),r}function Y(t={}){if(t.renderThumbnail){let a=t.renderThumbnail({repoUrl:v});if(a)return a}let e=document.createElement("div");e.className=c("ghThumbNail",t.classNames?.thumbnail);let r=document.createElement("a");r.href=v,r.target="_blank",r.rel="noopener noreferrer",m(r,t.classNames?.thumbnailLink);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 98 96"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.style.marginTop="10px",n.style.opacity="0.5",n.style.fill="var(--gh-text-default-color, #333)";let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),n.appendChild(o),r.appendChild(n),e.appendChild(r),e}function b(t,e,r,n={}){let{showHeader:o=!0,showFooter:a=!0,showThumbnail:i=!0}=n;t.classList.add(g),m(t,n.classNames?.root),t.innerHTML="";let l=e.contributionsCollection.contributionCalendar,{table:s,thead:u,tbody:d}=B(n);V(d,l.weeks,n,r),j(u,l.months,n);let f=Q(n),T=q(n);if(T.appendChild(s),a){let h=K(n);T.appendChild(h)}if(f.appendChild(T),o){let h=Z(l.totalContributions,r,e.avatarUrl,n,e);t.appendChild(h)}if(t.appendChild(f),i){let h=Y(n);t.appendChild(h)}}var J={bgColor:"--gh-bg-color",textColor:"--gh-text-default-color",inactiveTextColor:"--gh-text-inactive-color",linkHoverColor:"--gh-link-hover-color",cellLevel0:"--gh-cell-level0-color",cellLevel1:"--gh-cell-level1-color",cellLevel2:"--gh-cell-level2-color",cellLevel3:"--gh-cell-level3-color",cellLevel4:"--gh-cell-level4-color",cellSize:"--gh-cell-size",cellGap:"--gh-cell-gap",cellRadius:"--gh-cell-radius",cellBorderColor:"--gh-cell-border-color",cellOutlineColor:"--gh-cell-outline-color",tooltipBgColor:"--gh-cell-info-bg-color",tooltipTextColor:"--gh-tooltip-text-color",tooltipPadding:"--gh-tooltip-padding",tooltipRadius:"--gh-tooltip-radius",tooltipFontSize:"--gh-tooltip-font-size",borderColor:"--gh-border-card-color",borderWidth:"--gh-border-card-width",cardPadding:"--gh-card-padding",cardPaddingBlock:"--gh-card-padding-block",cardRadius:"--gh-card-radius",canvasPaddingTop:"--gh-canvas-padding-top",canvasMarginInline:"--gh-canvas-margin-inline",headerHeight:"--gh-header-height",headerMarginBottom:"--gh-header-margin-bottom",headerFontSize:"--gh-header-font-size",avatarSize:"--gh-avatar-size",footerPadding:"--gh-footer-padding",footerFontSize:"--gh-footer-font-size",fontFamily:"--gh-font-default-family"};function X(t){return typeof t=="number"?`${t}px`:t}function y(t,e){let r=typeof e=="string"?w[e]:e;if(r)for(let[n,o]of Object.entries(r)){let a=J[n];a&&o!==void 0&&o!==null&&o!==""&&t.style.setProperty(a,X(o))}}function S(){return Object.keys(w)}var p=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container),this.container.classList.add(g)}resolveContainer(e){if(typeof e=="string"){let n=document.querySelector(e);if(!n)throw new Error(`Container not found: ${e}`);return n}if(e instanceof HTMLElement)return e;let r=document.getElementById("gh");if(!r)throw new Error('No container found. Specify container in config or add element with id="gh"');return r}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e)}async render(){this.config.theme&&y(this.container,this.config.theme),this.showLoading();try{this.data=await C(this.config.username,this.config.apiEndpoint),b(this.container,this.data,this.config.username,this.config),this.config.onDataLoaded?.(this.data)}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"))}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container),this.container.classList.add(g)),this.render()}};function x(){let t=document.getElementById("gh");if(!t)return;let e=t.dataset.login;if(!e)return;let r=t.dataset.showThumbnail!=="false",n=t.dataset.showHeader!=="false",o=t.dataset.showFooter!=="false",a=new p({username:e,container:t,showThumbnail:r,showHeader:n,showFooter:o});a.render(),typeof window<"u"&&(window.renderGitHubWidget=()=>{let i=t.dataset.login;return i&&i!==a.getUsername()?a.update({username:i}):a.render()})}typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",x):x());return A(ee);})();
//# sourceMappingURL=browser.global.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/vanilla/browser.ts","../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"sourcesContent":["/**\n * Browser entry point for script tag usage\n * This file is bundled as IIFE/UMD for direct browser usage\n */\n\nimport { GitHubContributionWidget } from './widget';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme, getThemePresets } from '../styles/themes';\nimport type { GitHubContributionGraphConfig } from '../core/types';\n\n// Export everything for global access\nexport { GitHubContributionWidget };\nexport { fetchContributionData };\nexport { renderWidget };\nexport { applyTheme, getThemePresets };\nexport type { GitHubContributionGraphConfig };\n\n// Re-export types\nexport * from '../core/types';\n\n/**\n * Auto-initialize widget for backward compatibility\n * Looks for element with id=\"gh\" and data-login attribute\n */\nexport function autoInit(): void {\n const container = document.getElementById('gh');\n if (!container) return;\n\n const username = container.dataset.login;\n if (!username) return;\n\n // Parse data attributes for options\n const showThumbnail = container.dataset.showThumbnail !== 'false';\n const showHeader = container.dataset.showHeader !== 'false';\n const showFooter = container.dataset.showFooter !== 'false';\n\n const widget = new GitHubContributionWidget({\n username,\n container,\n showThumbnail,\n showHeader,\n showFooter,\n });\n\n widget.render();\n\n // Expose for manual re-render (backward compatibility)\n if (typeof window !== 'undefined') {\n (window as Window & { renderGitHubWidget?: () => Promise<void> }).renderGitHubWidget = () => {\n const currentUsername = container.dataset.login;\n if (currentUsername && currentUsername !== widget.getUsername()) {\n return widget.update({ username: currentUsername });\n }\n return widget.render();\n };\n }\n}\n\n// Auto-init when DOM is ready (only in browser context)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', autoInit);\n } else {\n // DOM is already ready\n autoInit();\n }\n}\n","import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n const label = document.createElement('span');\n label.className = 'ghCalendarLabel';\n label.textContent = DAY_LABELS[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"],"mappings":"2cAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,eAAAC,EAAA,aAAAC,EAAA,0BAAAC,EAAA,oBAAAC,EAAA,iBAAAC,ICKO,IAA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L/GO,SAASQ,GAAiB,CAC/B,IAAMC,EAAY,SAAS,eAAe,IAAI,EAC9C,GAAI,CAACA,EAAW,OAEhB,IAAMC,EAAWD,EAAU,QAAQ,MACnC,GAAI,CAACC,EAAU,OAGf,IAAMC,EAAgBF,EAAU,QAAQ,gBAAkB,QACpDG,EAAaH,EAAU,QAAQ,aAAe,QAC9CI,EAAaJ,EAAU,QAAQ,aAAe,QAE9CK,EAAS,IAAIC,EAAyB,CAC1C,SAAAL,EACA,UAAAD,EACA,cAAAE,EACA,WAAAC,EACA,WAAAC,CACF,CAAC,EAEDC,EAAO,OAAO,EAGV,OAAO,OAAW,MACnB,OAAiE,mBAAqB,IAAM,CAC3F,IAAME,EAAkBP,EAAU,QAAQ,MAC1C,OAAIO,GAAmBA,IAAoBF,EAAO,YAAY,EACrDA,EAAO,OAAO,CAAE,SAAUE,CAAgB,CAAC,EAE7CF,EAAO,OAAO,CACvB,EAEJ,CAGI,OAAO,OAAW,KAAe,OAAO,SAAa,MACnD,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoBN,CAAQ,EAGtDA,EAAS","names":["browser_exports","__export","GitHubContributionWidget","applyTheme","autoInit","fetchContributionData","getThemePresets","renderWidget","DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","DEFAULT_API_ENDPOINT","url","controller","timeoutId","response","error","data","createTable","table","thead","tbody","firstCell","i","cell","DAY_LABELS","label","addMonths","months","totalWeeks","addWeeks","weeks","week","day","data","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","username","avatarUrl","header","total","profile","link","img","createFooter","footer","colors","less","more","level","CONTRIBUTION_LEVELS","createThumbnail","thumbnail","REPO_URL","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","applyTheme","element","theme","config","THEME_PRESETS","getThemePresets","THEME_PRESETS","GitHubContributionWidget","config","container","el","loader","applyTheme","fetchContributionData","renderWidget","error","autoInit","container","username","showThumbnail","showHeader","showFooter","widget","GitHubContributionWidget","currentUsername"]}
{"version":3,"sources":["../src/vanilla/browser.ts","../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"sourcesContent":["/**\n * Browser entry point for script tag usage\n * This file is bundled as IIFE/UMD for direct browser usage\n */\n\nimport { GitHubContributionWidget } from './widget';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme, getThemePresets } from '../styles/themes';\nimport type { GitHubContributionGraphConfig } from '../core/types';\n\n// Export everything for global access\nexport { GitHubContributionWidget };\nexport { fetchContributionData };\nexport { renderWidget };\nexport { applyTheme, getThemePresets };\nexport type { GitHubContributionGraphConfig };\n\n// Re-export types\nexport * from '../core/types';\n\n/**\n * Auto-initialize widget for backward compatibility\n * Looks for element with id=\"gh\" and data-login attribute\n */\nexport function autoInit(): void {\n const container = document.getElementById('gh');\n if (!container) return;\n\n const username = container.dataset.login;\n if (!username) return;\n\n // Parse data attributes for options\n const showThumbnail = container.dataset.showThumbnail !== 'false';\n const showHeader = container.dataset.showHeader !== 'false';\n const showFooter = container.dataset.showFooter !== 'false';\n\n const widget = new GitHubContributionWidget({\n username,\n container,\n showThumbnail,\n showHeader,\n showFooter,\n });\n\n widget.render();\n\n // Expose for manual re-render (backward compatibility)\n if (typeof window !== 'undefined') {\n (window as Window & { renderGitHubWidget?: () => Promise<void> }).renderGitHubWidget = () => {\n const currentUsername = container.dataset.login;\n if (currentUsername && currentUsername !== widget.getUsername()) {\n return widget.update({ username: currentUsername });\n }\n return widget.render();\n };\n }\n}\n\n// Auto-init when DOM is ready (only in browser context)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', autoInit);\n } else {\n // DOM is already ready\n autoInit();\n }\n}\n","import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Root class applied to every rendered widget container.\n */\nexport const ROOT_CLASS = 'ghContributionGraph';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Build an API URL while preserving existing query parameters.\n */\nfunction buildContributionUrl(apiEndpoint: string, username: string): string {\n const encodedUsername = encodeURIComponent(username);\n\n try {\n const base =\n typeof window !== 'undefined' && window.location?.origin\n ? window.location.origin\n : 'http://localhost';\n const url = new URL(apiEndpoint, base);\n url.searchParams.set('login', username);\n\n if (!/^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(apiEndpoint)) {\n return `${url.pathname}${url.search}${url.hash}`;\n }\n\n return url.toString();\n } catch {\n const separator = apiEndpoint.includes('?') ? '&' : '?';\n return `${apiEndpoint}${separator}login=${encodedUsername}`;\n }\n}\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string' || !username.trim()) {\n throw new Error('Username is required');\n }\n\n const trimmedUsername = username.trim();\n const url = buildContributionUrl(apiEndpoint, trimmedUsername);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL, ROOT_CLASS } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n DayStyle,\n DayRenderContext,\n FooterRenderContext,\n GitHubUser,\n HeaderRenderContext,\n RenderOptions,\n ThumbnailRenderContext,\n} from './types';\n\nfunction mergeClasses(baseClass: string, customClass?: string): string {\n return [baseClass, customClass].filter(Boolean).join(' ');\n}\n\nfunction applyCustomClass(element: HTMLElement | SVGElement, customClass?: string): void {\n if (customClass) {\n element.classList.add(...customClass.split(/\\s+/).filter(Boolean));\n }\n}\n\nfunction getDayLabels(options: RenderOptions): string[] {\n return options.dayLabels ?? DAY_LABELS;\n}\n\nfunction formatTooltip(context: DayRenderContext, options: RenderOptions): string {\n if (options.tooltipFormatter) {\n return options.tooltipFormatter(context);\n }\n\n return `${context.day.contributionCount} contributions on ${context.date.toDateString()}`;\n}\n\nfunction normalizeInlineStyleValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\nfunction normalizeStyleProperty(property: string): string {\n return property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction resolveDayClassName(context: DayRenderContext, options: RenderOptions): string | undefined {\n if (typeof options.dayClassName === 'function') {\n return options.dayClassName(context) || undefined;\n }\n\n return options.dayClassName;\n}\n\nfunction applyDayStyle(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const style =\n typeof options.dayStyle === 'function' ? options.dayStyle(context) : options.dayStyle;\n\n if (!style) return;\n\n for (const [property, value] of Object.entries(style satisfies DayStyle)) {\n if (value === undefined || value === null || value === '') continue;\n\n cell.style.setProperty(normalizeStyleProperty(property), normalizeInlineStyleValue(value));\n }\n}\n\nfunction applyDayAttributes(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const attributes = options.dayAttributes?.(context);\n if (!attributes) return;\n\n for (const [attribute, value] of Object.entries(attributes)) {\n if (value === undefined || value === null || value === false) continue;\n cell.setAttribute(attribute, value === true ? '' : String(value));\n }\n}\n\nfunction appendDayContents(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const hasCustomRenderer = typeof options.renderDayContents === 'function';\n const rendered = hasCustomRenderer ? options.renderDayContents?.(context) : undefined;\n\n if (typeof rendered === 'string') {\n cell.appendChild(document.createTextNode(rendered));\n return;\n }\n\n if (rendered instanceof Node) {\n cell.appendChild(rendered);\n return;\n }\n\n if (!hasCustomRenderer && options.showTooltips !== false) {\n const tooltip = document.createElement('span');\n tooltip.className = mergeClasses('ghCalendarTooltip', options.classNames?.tooltip);\n tooltip.textContent = formatTooltip(context, options);\n cell.appendChild(tooltip);\n }\n}\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(options: RenderOptions = {}): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = mergeClasses('ghCalendarTable', options.classNames?.table);\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n const dayLabels = getDayLabels(options);\n const showWeekdayLabels = options.showWeekdayLabels !== false;\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (showWeekdayLabels && dayLabels[i]) {\n const label = document.createElement('span');\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.dayLabel);\n label.textContent = dayLabels[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[],\n options: RenderOptions = {}\n): void {\n if (options.showMonthLabels === false) return;\n\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = options.monthLabelFormatter\n ? options.monthLabelFormatter(months[i], i, months)\n : months[i].name;\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.monthLabel);\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[],\n options: RenderOptions = {},\n username = ''\n): void {\n for (const [weekIndex, week] of weeks.entries()) {\n for (const [dayIndex, day] of week.contributionDays.entries()) {\n const date = new Date(day.date);\n const context: DayRenderContext = {\n day,\n week,\n weekIndex,\n dayIndex,\n date,\n username,\n };\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.className = mergeClasses(\n mergeClasses('ghCalendarDayCell', options.classNames?.dayCell),\n resolveDayClassName(context, options)\n );\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n cell.dataset.week = String(weekIndex);\n cell.dataset.weekday = String(day.weekday);\n applyDayStyle(cell, context, options);\n applyDayAttributes(cell, context, options);\n appendDayContents(cell, context, options);\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(options: RenderOptions = {}): HTMLDivElement {\n const card = document.createElement('div');\n card.className = mergeClasses('ghCalendarCard', options.classNames?.card);\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(options: RenderOptions = {}): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = mergeClasses('ghCalendarCanvas', options.classNames?.canvas);\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string,\n options: RenderOptions = {},\n user?: GitHubUser\n): HTMLElement {\n if (options.renderHeader && user) {\n const customHeader = options.renderHeader({\n user,\n username,\n totalContributions,\n } satisfies HeaderRenderContext);\n\n if (customHeader) return customHeader;\n }\n\n const header = document.createElement('div');\n header.className = mergeClasses('ghCalendarHeader', options.classNames?.header);\n\n const total = document.createElement('span');\n applyCustomClass(total, options.classNames?.total);\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n applyCustomClass(profile, options.classNames?.profile);\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n applyCustomClass(link, options.classNames?.profileLink);\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n applyCustomClass(img, options.classNames?.avatar);\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(options: RenderOptions = {}): HTMLElement {\n const labels = {\n less: options.footerLabels?.less ?? 'Less',\n more: options.footerLabels?.more ?? 'More',\n };\n\n if (options.renderFooter) {\n const customFooter = options.renderFooter({\n levels: CONTRIBUTION_LEVELS,\n labels,\n } satisfies FooterRenderContext);\n\n if (customFooter) return customFooter;\n }\n\n const footer = document.createElement('div');\n footer.className = mergeClasses('ghCalendarCardFooter', options.classNames?.footer);\n\n const colors = document.createElement('div');\n colors.className = mergeClasses(\n 'ghCalendarCardFooterColors',\n options.classNames?.footerLegend\n );\n\n const less = document.createElement('span');\n less.textContent = labels.less;\n\n const more = document.createElement('span');\n more.textContent = labels.more;\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = mergeClasses('ghCalendarDayCell', options.classNames?.dayCell);\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(options: RenderOptions = {}): HTMLElement {\n if (options.renderThumbnail) {\n const customThumbnail = options.renderThumbnail({\n repoUrl: REPO_URL,\n } satisfies ThumbnailRenderContext);\n\n if (customThumbnail) return customThumbnail;\n }\n\n const thumbnail = document.createElement('div');\n thumbnail.className = mergeClasses('ghThumbNail', options.classNames?.thumbnail);\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n applyCustomClass(link, options.classNames?.thumbnailLink);\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n container.classList.add(ROOT_CLASS);\n applyCustomClass(container, options.classNames?.root);\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable(options);\n\n addWeeks(tbody, calendar.weeks, options, username);\n addMonths(thead, calendar.months, options);\n\n const card = createCard(options);\n const canvas = createCanvas(options);\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter(options);\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(\n calendar.totalContributions,\n username,\n user.avatarUrl,\n options,\n user\n );\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail(options);\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\nconst THEME_CSS_VARIABLES: Record<keyof ThemeConfig, string> = {\n bgColor: '--gh-bg-color',\n textColor: '--gh-text-default-color',\n inactiveTextColor: '--gh-text-inactive-color',\n linkHoverColor: '--gh-link-hover-color',\n cellLevel0: '--gh-cell-level0-color',\n cellLevel1: '--gh-cell-level1-color',\n cellLevel2: '--gh-cell-level2-color',\n cellLevel3: '--gh-cell-level3-color',\n cellLevel4: '--gh-cell-level4-color',\n cellSize: '--gh-cell-size',\n cellGap: '--gh-cell-gap',\n cellRadius: '--gh-cell-radius',\n cellBorderColor: '--gh-cell-border-color',\n cellOutlineColor: '--gh-cell-outline-color',\n tooltipBgColor: '--gh-cell-info-bg-color',\n tooltipTextColor: '--gh-tooltip-text-color',\n tooltipPadding: '--gh-tooltip-padding',\n tooltipRadius: '--gh-tooltip-radius',\n tooltipFontSize: '--gh-tooltip-font-size',\n borderColor: '--gh-border-card-color',\n borderWidth: '--gh-border-card-width',\n cardPadding: '--gh-card-padding',\n cardPaddingBlock: '--gh-card-padding-block',\n cardRadius: '--gh-card-radius',\n canvasPaddingTop: '--gh-canvas-padding-top',\n canvasMarginInline: '--gh-canvas-margin-inline',\n headerHeight: '--gh-header-height',\n headerMarginBottom: '--gh-header-margin-bottom',\n headerFontSize: '--gh-header-font-size',\n avatarSize: '--gh-avatar-size',\n footerPadding: '--gh-footer-padding',\n footerFontSize: '--gh-footer-font-size',\n fontFamily: '--gh-font-default-family',\n};\n\nfunction normalizeCSSValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n element.style.setProperty(cssKey, normalizeCSSValue(value));\n }\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n cssVars.push(`${cssKey}: ${normalizeCSSValue(value)};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { ROOT_CLASS } from '../core/constants';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, this.config);\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n return this.render();\n }\n}\n"],"mappings":"2cAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,8BAAAE,EAAA,eAAAC,EAAA,aAAAC,EAAA,0BAAAC,EAAA,oBAAAC,EAAA,iBAAAC,ICKO,IAAMC,EAAuB,2DAKvBC,EAAa,sBAKbC,EAAW,uDAKXC,EAA2C,CACtD,OACA,iBACA,kBACA,iBACA,iBACF,EAKaC,EAAa,CAAC,GAAI,MAAO,GAAI,MAAO,GAAI,MAAO,EAAE,EAKjDC,EAAkD,CAC7D,QAAS,CACP,QAAS,UACT,UAAW,UACX,WAAY,UACZ,WAAY,UACZ,WAAY,UACZ,WAAY,UACZ,WAAY,UACZ,YAAa,SACf,EACA,KAAM,CACJ,QAAS,UACT,UAAW,UACX,WAAY,UACZ,YAAa,SACf,EACA,MAAO,CACL,QAAS,UACT,UAAW,UACX,WAAY,UACZ,YAAa,SACf,EACA,SAAU,CACR,QAAS,UACT,UAAW,UACX,WAAY,UACZ,YAAa,SACf,EACA,QAAS,CACP,QAAS,UACT,UAAW,UACX,WAAY,UACZ,YAAa,SACf,EACA,MAAO,CACL,QAAS,UACT,UAAW,UACX,WAAY,UACZ,YAAa,SACf,CACF,ECvEA,SAASC,EAAqBC,EAAqBC,EAA0B,CAC3E,IAAMC,EAAkB,mBAAmBD,CAAQ,EAEnD,GAAI,CACF,IAAME,EACJ,OAAO,OAAW,KAAe,OAAO,UAAU,OAC9C,OAAO,SAAS,OAChB,mBACAC,EAAM,IAAI,IAAIJ,EAAaG,CAAI,EAGrC,OAFAC,EAAI,aAAa,IAAI,QAASH,CAAQ,EAEjC,4BAA4B,KAAKD,CAAW,EAI1CI,EAAI,SAAS,EAHX,GAAGA,EAAI,QAAQ,GAAGA,EAAI,MAAM,GAAGA,EAAI,IAAI,EAIlD,MAAQ,CACN,IAAMC,EAAYL,EA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,EAC9C,GAAI,CAACA,EAAW,OAEhB,IAAMC,EAAWD,EAAU,QAAQ,MACnC,GAAI,CAACC,EAAU,OAGf,IAAMC,EAAgBF,EAAU,QAAQ,gBAAkB,QACpDG,EAAaH,EAAU,QAAQ,aAAe,QAC9CI,EAAaJ,EAAU,QAAQ,aAAe,QAE9CK,EAAS,IAAIC,EAAyB,CAC1C,SAAAL,EACA,UAAAD,EACA,cAAAE,EACA,WAAAC,EACA,WAAAC,CACF,CAAC,EAEDC,EAAO,OAAO,EAGV,OAAO,OAAW,MACnB,OAAiE,mBAAqB,IAAM,CAC3F,IAAME,EAAkBP,EAAU,QAAQ,MAC1C,OAAIO,GAAmBA,IAAoBF,EAAO,YAAY,EACrDA,EAAO,OAAO,CAAE,SAAUE,CAAgB,CAAC,EAE7CF,EAAO,OAAO,CACvB,EAEJ,CAGI,OAAO,OAAW,KAAe,OAAO,SAAa,MACnD,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoBN,CAAQ,EAGtDA,EAAS","names":["browser_exports","__export","GitHubContributionWidget","applyTheme","autoInit","fetchContributionData","getThemePresets","renderWidget","DEFAULT_API_ENDPOINT","ROOT_CLASS","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","buildContributionUrl","apiEndpoint","username","encodedUsername","base","url","separator","fetchContributionData","DEFAULT_API_ENDPOINT","trimmedUsername","controller","timeoutId","response","error","data","mergeClasses","baseClass","customClass","applyCustomClass","element","getDayLabels","options","DAY_LABELS","formatTooltip","context","normalizeInlineStyleValue","value","normalizeStyleProperty","property","letter","resolveDayClassName","applyDayStyle","cell","style","applyDayAttributes","attributes","attribute","appendDayContents","hasCustomRenderer","rendered","tooltip","createTable","table","thead","tbody","firstCell","dayLabels","showWeekdayLabels","i","label","addMonths","months","totalWeeks","addWeeks","weeks","username","weekIndex","week","dayIndex","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","user","customHeader","header","total","profile","link","img","createFooter","labels","customFooter","CONTRIBUTION_LEVELS","footer","colors","less","more","level","createThumbnail","customThumbnail","REPO_URL","thumbnail","svg","path","renderWidget","container","showHeader","showFooter","showThumbnail","ROOT_CLASS","calendar","THEME_CSS_VARIABLES","normalizeCSSValue","value","applyTheme","element","theme","config","THEME_PRESETS","key","cssKey","getThemePresets","THEME_PRESETS","GitHubContributionWidget","config","ROOT_CLASS","container","el","loader","applyTheme","fetchContributionData","renderWidget","error","autoInit","container","username","showThumbnail","showHeader","showFooter","widget","GitHubContributionWidget","currentUsername"]}

@@ -8,2 +8,5 @@ :root {

--gh-base-size-32: 2rem;
--gh-cell-size: 10px;
--gh-cell-gap: 3px;
--gh-cell-radius: 2px;
--gh-cell-level0-color: #21262d;

@@ -15,2 +18,6 @@ --gh-cell-level1-color: #0e4429;

--gh-cell-info-bg-color: #6e7681;
--gh-tooltip-text-color: var(--gh-text-default-color);
--gh-tooltip-padding: 10px;
--gh-tooltip-radius: 6px;
--gh-tooltip-font-size: 12px;
--gh-cell-outline-color: #ffffff0d;

@@ -20,2 +27,13 @@ --gh-cell-border-color: rgba(255, 255, 255, 0.03);

--gh-border-card-width: max(1px, 0.0625rem);
--gh-card-padding: var(--gh-base-size-16);
--gh-card-padding-block: 0.5rem;
--gh-card-radius: 6px;
--gh-canvas-padding-top: var(--gh-base-size-8);
--gh-canvas-margin-inline: var(--gh-base-size-8);
--gh-header-height: 20px;
--gh-header-margin-bottom: var(--gh-base-size-4);
--gh-header-font-size: inherit;
--gh-avatar-size: 20px;
--gh-footer-padding: var(--gh-base-size-4) var(--gh-base-size-32);
--gh-footer-font-size: var(--gh-base-size-12);
--gh-text-default-color: #e6edf3;

@@ -28,3 +46,3 @@ --gh-text-inactive-color: #848D97;

/* Main block */
#gh {
:where(#gh, .ghContributionGraph) {
color: var(--gh-text-default-color);

@@ -34,7 +52,7 @@ width: fit-content;

}
#gh a {
:where(#gh, .ghContributionGraph) a {
text-decoration: none;
color: var(--gh-text-inactive-color)
}
#gh a:hover {
:where(#gh, .ghContributionGraph) a:hover {
color: var(--gh-link-hover-color);

@@ -46,7 +64,7 @@ }

color: var(--gh-text-default-color);
border-spacing: 3px;
border-spacing: var(--gh-cell-gap);
border-collapse: separate;
}
.ghCalendarTable tr {
height: 10px;
height: var(--gh-cell-size);
}

@@ -61,4 +79,5 @@ .ghCalendarTable td {

.ghCalendarDayCell {
width: 10px;
border-radius: 2px;
width: var(--gh-cell-size);
height: var(--gh-cell-size);
border-radius: var(--gh-cell-radius);
border: 1px solid var(--gh-cell-border-color);

@@ -85,3 +104,3 @@ outline: 1px solid var(--gh-cell-outline-color);

}
.ghCalendarDayCell span {
.ghCalendarDayCell .ghCalendarTooltip {
visibility: hidden;

@@ -94,8 +113,9 @@ position: absolute;

background-color: var(--gh-cell-info-bg-color);
padding: 10px;
font-size: 12px;
border-radius: 6px;
color: var(--gh-tooltip-text-color);
padding: var(--gh-tooltip-padding);
font-size: var(--gh-tooltip-font-size);
border-radius: var(--gh-tooltip-radius);
font-family: var(--gh-font-default-family);
}
.ghCalendarDayCell span::after {
.ghCalendarDayCell .ghCalendarTooltip::after {
content: "";

@@ -109,3 +129,3 @@ position: absolute;

}
.ghCalendarDayCell:hover span {
.ghCalendarDayCell:hover .ghCalendarTooltip {
visibility: visible;

@@ -124,7 +144,6 @@ }

background-color: var(--gh-bg-color);
padding: var(--gh-base-size-16);
padding-top: 0.5rem;
padding-bottom: 0.5rem;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: var(--gh-card-padding);
padding-top: var(--gh-card-padding-block);
padding-bottom: var(--gh-card-padding-block);
border-radius: var(--gh-card-radius);
border: var(--gh-border-card-width, 1px) solid var(--gh-border-card-color);

@@ -135,6 +154,6 @@ }

flex-direction: column;
padding-top: var(--gh-base-size-8, 4px) !important;
padding-top: var(--gh-canvas-padding-top, 4px) !important;
text-align: center !important;
margin-right: var(--gh-base-size-8, 8px) !important;
margin-left: var(--gh-base-size-8, 8px) !important;
margin-right: var(--gh-canvas-margin-inline, 8px) !important;
margin-left: var(--gh-canvas-margin-inline, 8px) !important;
overflow: visible;

@@ -145,4 +164,5 @@ }

.ghCalendarHeader {
margin-bottom: var(--gh-base-size-4);
height: 20px;
margin-bottom: var(--gh-header-margin-bottom);
height: var(--gh-header-height);
font-size: var(--gh-header-font-size);
}

@@ -158,5 +178,5 @@ .ghCalendarHeader span {

.ghCalendarHeader div img {
width: 20px;
height: 20px;
border-radius: 10px;
width: var(--gh-avatar-size);
height: var(--gh-avatar-size);
border-radius: calc(var(--gh-avatar-size) / 2);
margin-left: var(--gh-base-size-4);

@@ -168,5 +188,5 @@ }

display: block;
padding: var(--gh-base-size-4, 4px) var(--gh-base-size-32, 32px) !important;
padding: var(--gh-footer-padding) !important;
text-align: center !important;
font-size: var(--gh-base-size-12);
font-size: var(--gh-footer-font-size);
font-family: var(--gh-font-default-family);

@@ -189,4 +209,4 @@ color: var(--gh-text-inactive-color);

.ghCalendarCardFooterColors div {
width: 10px;
height: 10px;
width: var(--gh-cell-size);
height: var(--gh-cell-size);
}

@@ -244,2 +264,2 @@

100% { opacity: 1; }
}
}

@@ -1,3 +0,3 @@

'use strict';var u="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",C="https://github.com/iamjr15/github-contribution-graph",g=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],p=["","Mon","","Wed","","Fri",""],d={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function b(o,e=u){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=new AbortController,i=setTimeout(()=>r.abort(),1e4),n;try{n=await fetch(t,{signal:r.signal});}catch(a){throw clearTimeout(i),a instanceof DOMException&&a.name==="AbortError"?new Error("Request timed out. Please try again."):a}if(clearTimeout(i),!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let l=await n.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),i=e.insertRow().insertCell();i.style.width="28px";for(let n=0;n<7;n++){let a=t.insertRow().insertCell();if(p[n]){let s=document.createElement("span");s.className="ghCalendarLabel",s.textContent=p[n],a.appendChild(s);}}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let i=o.rows[0].insertCell(),n=document.createElement("span");n.textContent=e[t].name,n.className="ghCalendarLabel",i.appendChild(n),i.colSpan=r;}}}function x(o,e){for(let t of e)for(let r of t.contributionDays){let i=document.createElement("span"),n=new Date(r.date);i.textContent=`${r.contributionCount} contributions on ${n.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(i),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function H(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let i=document.createElement("span");i.textContent=`${o} contributions in the last year`;let n=document.createElement("div"),l=document.createElement("a");l.href=`https://github.com/${encodeURIComponent(e)}`,l.textContent=e;let a=document.createElement("img");return a.src=t,a.alt=`${e}'s avatar`,n.appendChild(l),n.appendChild(a),r.appendChild(i),r.appendChild(n),r}function R(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let i of g){let n=document.createElement("div");n.className="ghCalendarDayCell",n.dataset.level=i,e.appendChild(n);}return e.appendChild(r),o.appendChild(e),o}function N(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=C,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.style.marginTop="10px",t.style.opacity="0.5",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function v(o,e,t,r={}){let{showHeader:i=true,showFooter:n=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:s,thead:T,tbody:y}=L();x(y,a.weeks),w(T,a.months);let m=H(),h=P();if(h.appendChild(s),n){let c=R();h.appendChild(c);}if(m.appendChild(h),i){let c=M(a.totalContributions,t,e.avatarUrl);o.appendChild(c);}if(o.appendChild(m),l){let c=N();o.appendChild(c);}}function U(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function E(o,e){let t=typeof e=="string"?d[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function k(o){let e=typeof o=="string"?d[o]:o;if(!e)return "";let t=[];for(let[r,i]of Object.entries(e))if(i){let n=`--gh-${U(r).replace("color","-color")}`;t.push(`${n}: ${i};`);}return t.join(`
`)}function G(){return Object.keys(d)}var f=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container);}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e);}async render(){this.config.theme&&E(this.container,this.config.theme),this.showLoading();try{this.data=await b(this.config.username,this.config.apiEndpoint),v(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};exports.CONTRIBUTION_LEVELS=g;exports.DAY_LABELS=p;exports.DEFAULT_API_ENDPOINT=u;exports.GitHubContributionWidget=f;exports.REPO_URL=C;exports.THEME_PRESETS=d;exports.addMonths=w;exports.addWeeks=x;exports.applyTheme=E;exports.createCanvas=P;exports.createCard=H;exports.createFooter=R;exports.createHeader=M;exports.createTable=L;exports.createThumbnail=N;exports.fetchContributionData=b;exports.getThemeCSS=k;exports.getThemePresets=G;exports.renderWidget=v;//# sourceMappingURL=index.cjs.map
'use strict';var L="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",g="ghContributionGraph",b="https://github.com/iamjr15/github-contribution-graph",y=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],v=["","Mon","","Wed","","Fri",""],p={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};function N(t,e){let r=encodeURIComponent(e);try{let n=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",o=new URL(t,n);return o.searchParams.set("login",e),/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t)?o.toString():`${o.pathname}${o.search}${o.hash}`}catch{let n=t.includes("?")?"&":"?";return `${t}${n}login=${r}`}}async function E(t,e=L){if(!t||typeof t!="string"||!t.trim())throw new Error("Username is required");let r=t.trim(),n=N(e,r),o=new AbortController,a=setTimeout(()=>o.abort(),1e4),i;try{i=await fetch(n,{signal:o.signal});}catch(s){throw clearTimeout(a),s instanceof DOMException&&s.name==="AbortError"?new Error("Request timed out. Please try again."):s}if(clearTimeout(a),!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let l=await i.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function d(t,e){return [t,e].filter(Boolean).join(" ")}function u(t,e){e&&t.classList.add(...e.split(/\s+/).filter(Boolean));}function S(t){return t.dayLabels??v}function O(t,e){return e.tooltipFormatter?e.tooltipFormatter(t):`${t.day.contributionCount} contributions on ${t.date.toDateString()}`}function M(t){return typeof t=="number"?`${t}px`:t}function D(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function P(t,e){return typeof e.dayClassName=="function"?e.dayClassName(t)||void 0:e.dayClassName}function A(t,e,r){let n=typeof r.dayStyle=="function"?r.dayStyle(e):r.dayStyle;if(n)for(let[o,a]of Object.entries(n))a==null||a===""||t.style.setProperty(D(o),M(a));}function k(t,e,r){let n=r.dayAttributes?.(e);if(n)for(let[o,a]of Object.entries(n))a==null||a===false||t.setAttribute(o,a===true?"":String(a));}function U(t,e,r){let n=typeof r.renderDayContents=="function",o=n?r.renderDayContents?.(e):void 0;if(typeof o=="string"){t.appendChild(document.createTextNode(o));return}if(o instanceof Node){t.appendChild(o);return}if(!n&&r.showTooltips!==false){let a=document.createElement("span");a.className=d("ghCalendarTooltip",r.classNames?.tooltip),a.textContent=O(e,r),t.appendChild(a);}}function I(t={}){let e=document.createElement("table");e.className=d("ghCalendarTable",t.classNames?.table);let r=e.createTHead(),n=e.createTBody(),a=r.insertRow().insertCell();a.style.width="28px";let i=S(t),l=t.showWeekdayLabels!==false;for(let s=0;s<7;s++){let c=n.insertRow().insertCell();if(l&&i[s]){let h=document.createElement("span");h.className=d("ghCalendarLabel",t.classNames?.dayLabel),h.textContent=i[s],c.appendChild(h);}}return {table:e,thead:r,tbody:n}}function F(t,e,r={}){if(r.showMonthLabels!==false)for(let n=0;n<e.length-1;n++){let o=e[n].totalWeeks;if(o>=2){let a=t.rows[0].insertCell(),i=document.createElement("span");i.textContent=r.monthLabelFormatter?r.monthLabelFormatter(e[n],n,e):e[n].name,i.className=d("ghCalendarLabel",r.classNames?.monthLabel),a.appendChild(i),a.colSpan=o;}}}function _(t,e,r={},n=""){for(let[o,a]of e.entries())for(let[i,l]of a.contributionDays.entries()){let s=new Date(l.date),f={day:l,week:a,weekIndex:o,dayIndex:i,date:s,username:n},c=t.rows[l.weekday].insertCell();c.className=d(d("ghCalendarDayCell",r.classNames?.dayCell),P(f,r)),c.dataset.date=l.date,c.dataset.count=String(l.contributionCount),c.dataset.level=l.contributionLevel,c.dataset.week=String(o),c.dataset.weekday=String(l.weekday),A(c,f,r),k(c,f,r),U(c,f,r);}}function G(t={}){let e=document.createElement("div");return e.className=d("ghCalendarCard",t.classNames?.card),e}function $(t={}){let e=document.createElement("div");return e.className=d("ghCalendarCanvas",t.classNames?.canvas),e}function z(t,e,r,n={},o){if(n.renderHeader&&o){let c=n.renderHeader({user:o,username:e,totalContributions:t});if(c)return c}let a=document.createElement("div");a.className=d("ghCalendarHeader",n.classNames?.header);let i=document.createElement("span");u(i,n.classNames?.total),i.textContent=`${t} contributions in the last year`;let l=document.createElement("div");u(l,n.classNames?.profile);let s=document.createElement("a");s.href=`https://github.com/${encodeURIComponent(e)}`,s.textContent=e,u(s,n.classNames?.profileLink);let f=document.createElement("img");return f.src=r,f.alt=`${e}'s avatar`,u(f,n.classNames?.avatar),l.appendChild(s),l.appendChild(f),a.appendChild(i),a.appendChild(l),a}function B(t={}){let e={less:t.footerLabels?.less??"Less",more:t.footerLabels?.more??"More"};if(t.renderFooter){let i=t.renderFooter({levels:y,labels:e});if(i)return i}let r=document.createElement("div");r.className=d("ghCalendarCardFooter",t.classNames?.footer);let n=document.createElement("div");n.className=d("ghCalendarCardFooterColors",t.classNames?.footerLegend);let o=document.createElement("span");o.textContent=e.less;let a=document.createElement("span");a.textContent=e.more,n.appendChild(o);for(let i of y){let l=document.createElement("div");l.className=d("ghCalendarDayCell",t.classNames?.dayCell),l.dataset.level=i,n.appendChild(l);}return n.appendChild(a),r.appendChild(n),r}function W(t={}){if(t.renderThumbnail){let a=t.renderThumbnail({repoUrl:b});if(a)return a}let e=document.createElement("div");e.className=d("ghThumbNail",t.classNames?.thumbnail);let r=document.createElement("a");r.href=b,r.target="_blank",r.rel="noopener noreferrer",u(r,t.classNames?.thumbnailLink);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 98 96"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.style.marginTop="10px",n.style.opacity="0.5",n.style.fill="var(--gh-text-default-color, #333)";let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),n.appendChild(o),r.appendChild(n),e.appendChild(r),e}function x(t,e,r,n={}){let{showHeader:o=true,showFooter:a=true,showThumbnail:i=true}=n;t.classList.add(g),u(t,n.classNames?.root),t.innerHTML="";let l=e.contributionsCollection.contributionCalendar,{table:s,thead:f,tbody:c}=I(n);_(c,l.weeks,n,r),F(f,l.months,n);let h=G(n),C=$(n);if(C.appendChild(s),a){let m=B(n);C.appendChild(m);}if(h.appendChild(C),o){let m=z(l.totalContributions,r,e.avatarUrl,n,e);t.appendChild(m);}if(t.appendChild(h),i){let m=W(n);t.appendChild(m);}}var w={bgColor:"--gh-bg-color",textColor:"--gh-text-default-color",inactiveTextColor:"--gh-text-inactive-color",linkHoverColor:"--gh-link-hover-color",cellLevel0:"--gh-cell-level0-color",cellLevel1:"--gh-cell-level1-color",cellLevel2:"--gh-cell-level2-color",cellLevel3:"--gh-cell-level3-color",cellLevel4:"--gh-cell-level4-color",cellSize:"--gh-cell-size",cellGap:"--gh-cell-gap",cellRadius:"--gh-cell-radius",cellBorderColor:"--gh-cell-border-color",cellOutlineColor:"--gh-cell-outline-color",tooltipBgColor:"--gh-cell-info-bg-color",tooltipTextColor:"--gh-tooltip-text-color",tooltipPadding:"--gh-tooltip-padding",tooltipRadius:"--gh-tooltip-radius",tooltipFontSize:"--gh-tooltip-font-size",borderColor:"--gh-border-card-color",borderWidth:"--gh-border-card-width",cardPadding:"--gh-card-padding",cardPaddingBlock:"--gh-card-padding-block",cardRadius:"--gh-card-radius",canvasPaddingTop:"--gh-canvas-padding-top",canvasMarginInline:"--gh-canvas-margin-inline",headerHeight:"--gh-header-height",headerMarginBottom:"--gh-header-margin-bottom",headerFontSize:"--gh-header-font-size",avatarSize:"--gh-avatar-size",footerPadding:"--gh-footer-padding",footerFontSize:"--gh-footer-font-size",fontFamily:"--gh-font-default-family"};function R(t){return typeof t=="number"?`${t}px`:t}function H(t,e){let r=typeof e=="string"?p[e]:e;if(r)for(let[n,o]of Object.entries(r)){let a=w[n];a&&o!==void 0&&o!==null&&o!==""&&t.style.setProperty(a,R(o));}}function Y(t){let e=typeof t=="string"?p[t]:t;if(!e)return "";let r=[];for(let[n,o]of Object.entries(e)){let a=w[n];a&&o!==void 0&&o!==null&&o!==""&&r.push(`${a}: ${R(o)};`);}return r.join(`
`)}function J(){return Object.keys(p)}var T=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container),this.container.classList.add(g);}resolveContainer(e){if(typeof e=="string"){let n=document.querySelector(e);if(!n)throw new Error(`Container not found: ${e}`);return n}if(e instanceof HTMLElement)return e;let r=document.getElementById("gh");if(!r)throw new Error('No container found. Specify container in config or add element with id="gh"');return r}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e);}async render(){this.config.theme&&H(this.container,this.config.theme),this.showLoading();try{this.data=await E(this.config.username,this.config.apiEndpoint),x(this.container,this.data,this.config.username,this.config),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container),this.container.classList.add(g)),this.render()}};exports.CONTRIBUTION_LEVELS=y;exports.DAY_LABELS=v;exports.DEFAULT_API_ENDPOINT=L;exports.GitHubContributionWidget=T;exports.REPO_URL=b;exports.ROOT_CLASS=g;exports.THEME_PRESETS=p;exports.addMonths=F;exports.addWeeks=_;exports.applyTheme=H;exports.createCanvas=$;exports.createCard=G;exports.createFooter=B;exports.createHeader=z;exports.createTable=I;exports.createThumbnail=W;exports.fetchContributionData=E;exports.getThemeCSS=Y;exports.getThemePresets=J;exports.renderWidget=x;//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","controller","timeoutId","response","error","data","createTable","table","thead","tbody","firstCell","i","cell","label","addMonths","months","totalWeeks","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","link","img","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","loader"],"mappings":"aAKO,IAAMA,CAAAA,CAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SA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d,IAAA,CAAK,SAAA,CAAU,SAAA,CAAY,EAAA,CAC3B,KAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOsD,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,CAAAA,CAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"index.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n const label = document.createElement('span');\n label.className = 'ghCalendarLabel';\n label.textContent = DAY_LABELS[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]}
{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","ROOT_CLASS","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","buildContributionUrl","apiEndpoint","username","encodedUsername","base","url","separator","fetchContributionData","trimmedUsername","controller","timeoutId","response","error","data","mergeClasses","baseClass","customClass","applyCustomClass","element","getDayLabels","options","formatTooltip","context","normalizeInlineStyleValue","value","normalizeStyleProperty","property","letter","resolveDayClassName","applyDayStyle","cell","style","applyDayAttributes","attributes","attribute","appendDayContents","hasCustomRenderer","rendered","tooltip","createTable","table","thead","tbody","firstCell","dayLabels","showWeekdayLabels","i","label","addMonths","months","totalWeeks","addWeeks","weeks","weekIndex","week","dayIndex","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","user","customHeader","header","total","profile","link","img","createFooter","labels","customFooter","footer","colors","less","more","level","createThumbnail","customThumbnail","thumbnail","svg","path","renderWidget","container","showHeader","showFooter","showThumbnail","calendar","THEME_CSS_VARIABLES","normalizeCSSValue","applyTheme","theme","config","key","cssKey","getThemeCSS","cssVars","getThemePresets","GitHubContributionWidget","el","loader"],"mappings":"aAKO,IAAMA,CAAAA,CAAuB,2DAKvBC,CAAAA,CAAa,qBAAA,CAKbC,EAA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AE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,CAAAA,CAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CACvD,IAAA,CAAK,SAAA,CAAU,SAAA,CAAU,GAAA,CAAIpG,CAAU,CAAA,CAAA,CAGlC,IAAA,CAAK,MAAA,EACd,CACF","file":"index.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Root class applied to every rendered widget container.\n */\nexport const ROOT_CLASS = 'ghContributionGraph';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Build an API URL while preserving existing query parameters.\n */\nfunction buildContributionUrl(apiEndpoint: string, username: string): string {\n const encodedUsername = encodeURIComponent(username);\n\n try {\n const base =\n typeof window !== 'undefined' && window.location?.origin\n ? window.location.origin\n : 'http://localhost';\n const url = new URL(apiEndpoint, base);\n url.searchParams.set('login', username);\n\n if (!/^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(apiEndpoint)) {\n return `${url.pathname}${url.search}${url.hash}`;\n }\n\n return url.toString();\n } catch {\n const separator = apiEndpoint.includes('?') ? '&' : '?';\n return `${apiEndpoint}${separator}login=${encodedUsername}`;\n }\n}\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string' || !username.trim()) {\n throw new Error('Username is required');\n }\n\n const trimmedUsername = username.trim();\n const url = buildContributionUrl(apiEndpoint, trimmedUsername);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL, ROOT_CLASS } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n DayStyle,\n DayRenderContext,\n FooterRenderContext,\n GitHubUser,\n HeaderRenderContext,\n RenderOptions,\n ThumbnailRenderContext,\n} from './types';\n\nfunction mergeClasses(baseClass: string, customClass?: string): string {\n return [baseClass, customClass].filter(Boolean).join(' ');\n}\n\nfunction applyCustomClass(element: HTMLElement | SVGElement, customClass?: string): void {\n if (customClass) {\n element.classList.add(...customClass.split(/\\s+/).filter(Boolean));\n }\n}\n\nfunction getDayLabels(options: RenderOptions): string[] {\n return options.dayLabels ?? DAY_LABELS;\n}\n\nfunction formatTooltip(context: DayRenderContext, options: RenderOptions): string {\n if (options.tooltipFormatter) {\n return options.tooltipFormatter(context);\n }\n\n return `${context.day.contributionCount} contributions on ${context.date.toDateString()}`;\n}\n\nfunction normalizeInlineStyleValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\nfunction normalizeStyleProperty(property: string): string {\n return property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction resolveDayClassName(context: DayRenderContext, options: RenderOptions): string | undefined {\n if (typeof options.dayClassName === 'function') {\n return options.dayClassName(context) || undefined;\n }\n\n return options.dayClassName;\n}\n\nfunction applyDayStyle(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const style =\n typeof options.dayStyle === 'function' ? options.dayStyle(context) : options.dayStyle;\n\n if (!style) return;\n\n for (const [property, value] of Object.entries(style satisfies DayStyle)) {\n if (value === undefined || value === null || value === '') continue;\n\n cell.style.setProperty(normalizeStyleProperty(property), normalizeInlineStyleValue(value));\n }\n}\n\nfunction applyDayAttributes(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const attributes = options.dayAttributes?.(context);\n if (!attributes) return;\n\n for (const [attribute, value] of Object.entries(attributes)) {\n if (value === undefined || value === null || value === false) continue;\n cell.setAttribute(attribute, value === true ? '' : String(value));\n }\n}\n\nfunction appendDayContents(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const hasCustomRenderer = typeof options.renderDayContents === 'function';\n const rendered = hasCustomRenderer ? options.renderDayContents?.(context) : undefined;\n\n if (typeof rendered === 'string') {\n cell.appendChild(document.createTextNode(rendered));\n return;\n }\n\n if (rendered instanceof Node) {\n cell.appendChild(rendered);\n return;\n }\n\n if (!hasCustomRenderer && options.showTooltips !== false) {\n const tooltip = document.createElement('span');\n tooltip.className = mergeClasses('ghCalendarTooltip', options.classNames?.tooltip);\n tooltip.textContent = formatTooltip(context, options);\n cell.appendChild(tooltip);\n }\n}\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(options: RenderOptions = {}): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = mergeClasses('ghCalendarTable', options.classNames?.table);\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n const dayLabels = getDayLabels(options);\n const showWeekdayLabels = options.showWeekdayLabels !== false;\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (showWeekdayLabels && dayLabels[i]) {\n const label = document.createElement('span');\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.dayLabel);\n label.textContent = dayLabels[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[],\n options: RenderOptions = {}\n): void {\n if (options.showMonthLabels === false) return;\n\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = options.monthLabelFormatter\n ? options.monthLabelFormatter(months[i], i, months)\n : months[i].name;\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.monthLabel);\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[],\n options: RenderOptions = {},\n username = ''\n): void {\n for (const [weekIndex, week] of weeks.entries()) {\n for (const [dayIndex, day] of week.contributionDays.entries()) {\n const date = new Date(day.date);\n const context: DayRenderContext = {\n day,\n week,\n weekIndex,\n dayIndex,\n date,\n username,\n };\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.className = mergeClasses(\n mergeClasses('ghCalendarDayCell', options.classNames?.dayCell),\n resolveDayClassName(context, options)\n );\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n cell.dataset.week = String(weekIndex);\n cell.dataset.weekday = String(day.weekday);\n applyDayStyle(cell, context, options);\n applyDayAttributes(cell, context, options);\n appendDayContents(cell, context, options);\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(options: RenderOptions = {}): HTMLDivElement {\n const card = document.createElement('div');\n card.className = mergeClasses('ghCalendarCard', options.classNames?.card);\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(options: RenderOptions = {}): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = mergeClasses('ghCalendarCanvas', options.classNames?.canvas);\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string,\n options: RenderOptions = {},\n user?: GitHubUser\n): HTMLElement {\n if (options.renderHeader && user) {\n const customHeader = options.renderHeader({\n user,\n username,\n totalContributions,\n } satisfies HeaderRenderContext);\n\n if (customHeader) return customHeader;\n }\n\n const header = document.createElement('div');\n header.className = mergeClasses('ghCalendarHeader', options.classNames?.header);\n\n const total = document.createElement('span');\n applyCustomClass(total, options.classNames?.total);\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n applyCustomClass(profile, options.classNames?.profile);\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n applyCustomClass(link, options.classNames?.profileLink);\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n applyCustomClass(img, options.classNames?.avatar);\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(options: RenderOptions = {}): HTMLElement {\n const labels = {\n less: options.footerLabels?.less ?? 'Less',\n more: options.footerLabels?.more ?? 'More',\n };\n\n if (options.renderFooter) {\n const customFooter = options.renderFooter({\n levels: CONTRIBUTION_LEVELS,\n labels,\n } satisfies FooterRenderContext);\n\n if (customFooter) return customFooter;\n }\n\n const footer = document.createElement('div');\n footer.className = mergeClasses('ghCalendarCardFooter', options.classNames?.footer);\n\n const colors = document.createElement('div');\n colors.className = mergeClasses(\n 'ghCalendarCardFooterColors',\n options.classNames?.footerLegend\n );\n\n const less = document.createElement('span');\n less.textContent = labels.less;\n\n const more = document.createElement('span');\n more.textContent = labels.more;\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = mergeClasses('ghCalendarDayCell', options.classNames?.dayCell);\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(options: RenderOptions = {}): HTMLElement {\n if (options.renderThumbnail) {\n const customThumbnail = options.renderThumbnail({\n repoUrl: REPO_URL,\n } satisfies ThumbnailRenderContext);\n\n if (customThumbnail) return customThumbnail;\n }\n\n const thumbnail = document.createElement('div');\n thumbnail.className = mergeClasses('ghThumbNail', options.classNames?.thumbnail);\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n applyCustomClass(link, options.classNames?.thumbnailLink);\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n container.classList.add(ROOT_CLASS);\n applyCustomClass(container, options.classNames?.root);\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable(options);\n\n addWeeks(tbody, calendar.weeks, options, username);\n addMonths(thead, calendar.months, options);\n\n const card = createCard(options);\n const canvas = createCanvas(options);\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter(options);\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(\n calendar.totalContributions,\n username,\n user.avatarUrl,\n options,\n user\n );\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail(options);\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\nconst THEME_CSS_VARIABLES: Record<keyof ThemeConfig, string> = {\n bgColor: '--gh-bg-color',\n textColor: '--gh-text-default-color',\n inactiveTextColor: '--gh-text-inactive-color',\n linkHoverColor: '--gh-link-hover-color',\n cellLevel0: '--gh-cell-level0-color',\n cellLevel1: '--gh-cell-level1-color',\n cellLevel2: '--gh-cell-level2-color',\n cellLevel3: '--gh-cell-level3-color',\n cellLevel4: '--gh-cell-level4-color',\n cellSize: '--gh-cell-size',\n cellGap: '--gh-cell-gap',\n cellRadius: '--gh-cell-radius',\n cellBorderColor: '--gh-cell-border-color',\n cellOutlineColor: '--gh-cell-outline-color',\n tooltipBgColor: '--gh-cell-info-bg-color',\n tooltipTextColor: '--gh-tooltip-text-color',\n tooltipPadding: '--gh-tooltip-padding',\n tooltipRadius: '--gh-tooltip-radius',\n tooltipFontSize: '--gh-tooltip-font-size',\n borderColor: '--gh-border-card-color',\n borderWidth: '--gh-border-card-width',\n cardPadding: '--gh-card-padding',\n cardPaddingBlock: '--gh-card-padding-block',\n cardRadius: '--gh-card-radius',\n canvasPaddingTop: '--gh-canvas-padding-top',\n canvasMarginInline: '--gh-canvas-margin-inline',\n headerHeight: '--gh-header-height',\n headerMarginBottom: '--gh-header-margin-bottom',\n headerFontSize: '--gh-header-font-size',\n avatarSize: '--gh-avatar-size',\n footerPadding: '--gh-footer-padding',\n footerFontSize: '--gh-footer-font-size',\n fontFamily: '--gh-font-default-family',\n};\n\nfunction normalizeCSSValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n element.style.setProperty(cssKey, normalizeCSSValue(value));\n }\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n cssVars.push(`${cssKey}: ${normalizeCSSValue(value)};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { ROOT_CLASS } from '../core/constants';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, this.config);\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n return this.render();\n }\n}\n"]}

@@ -1,3 +0,3 @@

import { i as ContributionMonth, h as ContributionWeek, G as GitHubUser, R as RenderOptions, j as GitHubContributionGraphConfig } from './themes-DbIjuNDH.cjs';
export { A as APIResponse, m as CONTRIBUTION_LEVELS, C as ContributionCalendar, e as ContributionDay, k as ContributionLevel, n as DAY_LABELS, D as DEFAULT_API_ENDPOINT, l as REPO_URL, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.cjs';
import { R as RenderOptions, i as ContributionMonth, h as ContributionWeek, G as GitHubUser, o as GitHubContributionGraphConfig } from './themes-CKoQTTmA.cjs';
export { A as APIResponse, t as CONTRIBUTION_LEVELS, q as CSSValue, j as CalendarClassNames, C as ContributionCalendar, e as ContributionDay, p as ContributionLevel, u as DAY_LABELS, D as DEFAULT_API_ENDPOINT, l as DayRenderContext, k as DayStyle, F as FooterLabels, m as FooterRenderContext, H as HeaderRenderContext, s as REPO_URL, r as ROOT_CLASS, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, n as ThumbnailRenderContext, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-CKoQTTmA.cjs';

@@ -7,3 +7,3 @@ /**

*/
declare function createTable(): {
declare function createTable(options?: RenderOptions): {
table: HTMLTableElement;

@@ -16,27 +16,27 @@ thead: HTMLTableSectionElement;

*/
declare function addMonths(thead: HTMLTableSectionElement, months: ContributionMonth[]): void;
declare function addMonths(thead: HTMLTableSectionElement, months: ContributionMonth[], options?: RenderOptions): void;
/**
* Add contribution days to the table body
*/
declare function addWeeks(tbody: HTMLTableSectionElement, weeks: ContributionWeek[]): void;
declare function addWeeks(tbody: HTMLTableSectionElement, weeks: ContributionWeek[], options?: RenderOptions, username?: string): void;
/**
* Create the card container
*/
declare function createCard(): HTMLDivElement;
declare function createCard(options?: RenderOptions): HTMLDivElement;
/**
* Create the canvas wrapper for table and footer
*/
declare function createCanvas(): HTMLDivElement;
declare function createCanvas(options?: RenderOptions): HTMLDivElement;
/**
* Create the header with total contributions and user profile
*/
declare function createHeader(totalContributions: number, username: string, avatarUrl: string): HTMLDivElement;
declare function createHeader(totalContributions: number, username: string, avatarUrl: string, options?: RenderOptions, user?: GitHubUser): HTMLElement;
/**
* Create the footer with contribution level legend
*/
declare function createFooter(): HTMLDivElement;
declare function createFooter(options?: RenderOptions): HTMLElement;
/**
* Create the thumbnail/attribution link
*/
declare function createThumbnail(): HTMLDivElement;
declare function createThumbnail(options?: RenderOptions): HTMLElement;
/**

@@ -43,0 +43,0 @@ * Render the complete widget into a container

@@ -1,3 +0,3 @@

import { i as ContributionMonth, h as ContributionWeek, G as GitHubUser, R as RenderOptions, j as GitHubContributionGraphConfig } from './themes-DbIjuNDH.js';
export { A as APIResponse, m as CONTRIBUTION_LEVELS, C as ContributionCalendar, e as ContributionDay, k as ContributionLevel, n as DAY_LABELS, D as DEFAULT_API_ENDPOINT, l as REPO_URL, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.js';
import { R as RenderOptions, i as ContributionMonth, h as ContributionWeek, G as GitHubUser, o as GitHubContributionGraphConfig } from './themes-CKoQTTmA.js';
export { A as APIResponse, t as CONTRIBUTION_LEVELS, q as CSSValue, j as CalendarClassNames, C as ContributionCalendar, e as ContributionDay, p as ContributionLevel, u as DAY_LABELS, D as DEFAULT_API_ENDPOINT, l as DayRenderContext, k as DayStyle, F as FooterLabels, m as FooterRenderContext, H as HeaderRenderContext, s as REPO_URL, r as ROOT_CLASS, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, n as ThumbnailRenderContext, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-CKoQTTmA.js';

@@ -7,3 +7,3 @@ /**

*/
declare function createTable(): {
declare function createTable(options?: RenderOptions): {
table: HTMLTableElement;

@@ -16,27 +16,27 @@ thead: HTMLTableSectionElement;

*/
declare function addMonths(thead: HTMLTableSectionElement, months: ContributionMonth[]): void;
declare function addMonths(thead: HTMLTableSectionElement, months: ContributionMonth[], options?: RenderOptions): void;
/**
* Add contribution days to the table body
*/
declare function addWeeks(tbody: HTMLTableSectionElement, weeks: ContributionWeek[]): void;
declare function addWeeks(tbody: HTMLTableSectionElement, weeks: ContributionWeek[], options?: RenderOptions, username?: string): void;
/**
* Create the card container
*/
declare function createCard(): HTMLDivElement;
declare function createCard(options?: RenderOptions): HTMLDivElement;
/**
* Create the canvas wrapper for table and footer
*/
declare function createCanvas(): HTMLDivElement;
declare function createCanvas(options?: RenderOptions): HTMLDivElement;
/**
* Create the header with total contributions and user profile
*/
declare function createHeader(totalContributions: number, username: string, avatarUrl: string): HTMLDivElement;
declare function createHeader(totalContributions: number, username: string, avatarUrl: string, options?: RenderOptions, user?: GitHubUser): HTMLElement;
/**
* Create the footer with contribution level legend
*/
declare function createFooter(): HTMLDivElement;
declare function createFooter(options?: RenderOptions): HTMLElement;
/**
* Create the thumbnail/attribution link
*/
declare function createThumbnail(): HTMLDivElement;
declare function createThumbnail(options?: RenderOptions): HTMLElement;
/**

@@ -43,0 +43,0 @@ * Render the complete widget into a container

@@ -1,3 +0,3 @@

var u="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",C="https://github.com/iamjr15/github-contribution-graph",g=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],p=["","Mon","","Wed","","Fri",""],d={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function b(o,e=u){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=new AbortController,i=setTimeout(()=>r.abort(),1e4),n;try{n=await fetch(t,{signal:r.signal});}catch(a){throw clearTimeout(i),a instanceof DOMException&&a.name==="AbortError"?new Error("Request timed out. Please try again."):a}if(clearTimeout(i),!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let l=await n.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),i=e.insertRow().insertCell();i.style.width="28px";for(let n=0;n<7;n++){let a=t.insertRow().insertCell();if(p[n]){let s=document.createElement("span");s.className="ghCalendarLabel",s.textContent=p[n],a.appendChild(s);}}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let i=o.rows[0].insertCell(),n=document.createElement("span");n.textContent=e[t].name,n.className="ghCalendarLabel",i.appendChild(n),i.colSpan=r;}}}function x(o,e){for(let t of e)for(let r of t.contributionDays){let i=document.createElement("span"),n=new Date(r.date);i.textContent=`${r.contributionCount} contributions on ${n.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(i),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function H(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let i=document.createElement("span");i.textContent=`${o} contributions in the last year`;let n=document.createElement("div"),l=document.createElement("a");l.href=`https://github.com/${encodeURIComponent(e)}`,l.textContent=e;let a=document.createElement("img");return a.src=t,a.alt=`${e}'s avatar`,n.appendChild(l),n.appendChild(a),r.appendChild(i),r.appendChild(n),r}function R(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let i of g){let n=document.createElement("div");n.className="ghCalendarDayCell",n.dataset.level=i,e.appendChild(n);}return e.appendChild(r),o.appendChild(e),o}function N(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=C,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.style.marginTop="10px",t.style.opacity="0.5",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function v(o,e,t,r={}){let{showHeader:i=true,showFooter:n=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:s,thead:T,tbody:y}=L();x(y,a.weeks),w(T,a.months);let m=H(),h=P();if(h.appendChild(s),n){let c=R();h.appendChild(c);}if(m.appendChild(h),i){let c=M(a.totalContributions,t,e.avatarUrl);o.appendChild(c);}if(o.appendChild(m),l){let c=N();o.appendChild(c);}}function U(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function E(o,e){let t=typeof e=="string"?d[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function k(o){let e=typeof o=="string"?d[o]:o;if(!e)return "";let t=[];for(let[r,i]of Object.entries(e))if(i){let n=`--gh-${U(r).replace("color","-color")}`;t.push(`${n}: ${i};`);}return t.join(`
`)}function G(){return Object.keys(d)}var f=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container);}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e);}async render(){this.config.theme&&E(this.container,this.config.theme),this.showLoading();try{this.data=await b(this.config.username,this.config.apiEndpoint),v(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};export{g as CONTRIBUTION_LEVELS,p as DAY_LABELS,u as DEFAULT_API_ENDPOINT,f as GitHubContributionWidget,C as REPO_URL,d as THEME_PRESETS,w as addMonths,x as addWeeks,E as applyTheme,P as createCanvas,H as createCard,R as createFooter,M as createHeader,L as createTable,N as createThumbnail,b as fetchContributionData,k as getThemeCSS,G as getThemePresets,v as renderWidget};//# sourceMappingURL=index.js.map
var L="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",g="ghContributionGraph",b="https://github.com/iamjr15/github-contribution-graph",y=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],v=["","Mon","","Wed","","Fri",""],p={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};function N(t,e){let r=encodeURIComponent(e);try{let n=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",o=new URL(t,n);return o.searchParams.set("login",e),/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t)?o.toString():`${o.pathname}${o.search}${o.hash}`}catch{let n=t.includes("?")?"&":"?";return `${t}${n}login=${r}`}}async function E(t,e=L){if(!t||typeof t!="string"||!t.trim())throw new Error("Username is required");let r=t.trim(),n=N(e,r),o=new AbortController,a=setTimeout(()=>o.abort(),1e4),i;try{i=await fetch(n,{signal:o.signal});}catch(s){throw clearTimeout(a),s instanceof DOMException&&s.name==="AbortError"?new Error("Request timed out. Please try again."):s}if(clearTimeout(a),!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let l=await i.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function d(t,e){return [t,e].filter(Boolean).join(" ")}function u(t,e){e&&t.classList.add(...e.split(/\s+/).filter(Boolean));}function S(t){return t.dayLabels??v}function O(t,e){return e.tooltipFormatter?e.tooltipFormatter(t):`${t.day.contributionCount} contributions on ${t.date.toDateString()}`}function M(t){return typeof t=="number"?`${t}px`:t}function D(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function P(t,e){return typeof e.dayClassName=="function"?e.dayClassName(t)||void 0:e.dayClassName}function A(t,e,r){let n=typeof r.dayStyle=="function"?r.dayStyle(e):r.dayStyle;if(n)for(let[o,a]of Object.entries(n))a==null||a===""||t.style.setProperty(D(o),M(a));}function k(t,e,r){let n=r.dayAttributes?.(e);if(n)for(let[o,a]of Object.entries(n))a==null||a===false||t.setAttribute(o,a===true?"":String(a));}function U(t,e,r){let n=typeof r.renderDayContents=="function",o=n?r.renderDayContents?.(e):void 0;if(typeof o=="string"){t.appendChild(document.createTextNode(o));return}if(o instanceof Node){t.appendChild(o);return}if(!n&&r.showTooltips!==false){let a=document.createElement("span");a.className=d("ghCalendarTooltip",r.classNames?.tooltip),a.textContent=O(e,r),t.appendChild(a);}}function I(t={}){let e=document.createElement("table");e.className=d("ghCalendarTable",t.classNames?.table);let r=e.createTHead(),n=e.createTBody(),a=r.insertRow().insertCell();a.style.width="28px";let i=S(t),l=t.showWeekdayLabels!==false;for(let s=0;s<7;s++){let c=n.insertRow().insertCell();if(l&&i[s]){let h=document.createElement("span");h.className=d("ghCalendarLabel",t.classNames?.dayLabel),h.textContent=i[s],c.appendChild(h);}}return {table:e,thead:r,tbody:n}}function F(t,e,r={}){if(r.showMonthLabels!==false)for(let n=0;n<e.length-1;n++){let o=e[n].totalWeeks;if(o>=2){let a=t.rows[0].insertCell(),i=document.createElement("span");i.textContent=r.monthLabelFormatter?r.monthLabelFormatter(e[n],n,e):e[n].name,i.className=d("ghCalendarLabel",r.classNames?.monthLabel),a.appendChild(i),a.colSpan=o;}}}function _(t,e,r={},n=""){for(let[o,a]of e.entries())for(let[i,l]of a.contributionDays.entries()){let s=new Date(l.date),f={day:l,week:a,weekIndex:o,dayIndex:i,date:s,username:n},c=t.rows[l.weekday].insertCell();c.className=d(d("ghCalendarDayCell",r.classNames?.dayCell),P(f,r)),c.dataset.date=l.date,c.dataset.count=String(l.contributionCount),c.dataset.level=l.contributionLevel,c.dataset.week=String(o),c.dataset.weekday=String(l.weekday),A(c,f,r),k(c,f,r),U(c,f,r);}}function G(t={}){let e=document.createElement("div");return e.className=d("ghCalendarCard",t.classNames?.card),e}function $(t={}){let e=document.createElement("div");return e.className=d("ghCalendarCanvas",t.classNames?.canvas),e}function z(t,e,r,n={},o){if(n.renderHeader&&o){let c=n.renderHeader({user:o,username:e,totalContributions:t});if(c)return c}let a=document.createElement("div");a.className=d("ghCalendarHeader",n.classNames?.header);let i=document.createElement("span");u(i,n.classNames?.total),i.textContent=`${t} contributions in the last year`;let l=document.createElement("div");u(l,n.classNames?.profile);let s=document.createElement("a");s.href=`https://github.com/${encodeURIComponent(e)}`,s.textContent=e,u(s,n.classNames?.profileLink);let f=document.createElement("img");return f.src=r,f.alt=`${e}'s avatar`,u(f,n.classNames?.avatar),l.appendChild(s),l.appendChild(f),a.appendChild(i),a.appendChild(l),a}function B(t={}){let e={less:t.footerLabels?.less??"Less",more:t.footerLabels?.more??"More"};if(t.renderFooter){let i=t.renderFooter({levels:y,labels:e});if(i)return i}let r=document.createElement("div");r.className=d("ghCalendarCardFooter",t.classNames?.footer);let n=document.createElement("div");n.className=d("ghCalendarCardFooterColors",t.classNames?.footerLegend);let o=document.createElement("span");o.textContent=e.less;let a=document.createElement("span");a.textContent=e.more,n.appendChild(o);for(let i of y){let l=document.createElement("div");l.className=d("ghCalendarDayCell",t.classNames?.dayCell),l.dataset.level=i,n.appendChild(l);}return n.appendChild(a),r.appendChild(n),r}function W(t={}){if(t.renderThumbnail){let a=t.renderThumbnail({repoUrl:b});if(a)return a}let e=document.createElement("div");e.className=d("ghThumbNail",t.classNames?.thumbnail);let r=document.createElement("a");r.href=b,r.target="_blank",r.rel="noopener noreferrer",u(r,t.classNames?.thumbnailLink);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 98 96"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.style.marginTop="10px",n.style.opacity="0.5",n.style.fill="var(--gh-text-default-color, #333)";let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),n.appendChild(o),r.appendChild(n),e.appendChild(r),e}function x(t,e,r,n={}){let{showHeader:o=true,showFooter:a=true,showThumbnail:i=true}=n;t.classList.add(g),u(t,n.classNames?.root),t.innerHTML="";let l=e.contributionsCollection.contributionCalendar,{table:s,thead:f,tbody:c}=I(n);_(c,l.weeks,n,r),F(f,l.months,n);let h=G(n),C=$(n);if(C.appendChild(s),a){let m=B(n);C.appendChild(m);}if(h.appendChild(C),o){let m=z(l.totalContributions,r,e.avatarUrl,n,e);t.appendChild(m);}if(t.appendChild(h),i){let m=W(n);t.appendChild(m);}}var w={bgColor:"--gh-bg-color",textColor:"--gh-text-default-color",inactiveTextColor:"--gh-text-inactive-color",linkHoverColor:"--gh-link-hover-color",cellLevel0:"--gh-cell-level0-color",cellLevel1:"--gh-cell-level1-color",cellLevel2:"--gh-cell-level2-color",cellLevel3:"--gh-cell-level3-color",cellLevel4:"--gh-cell-level4-color",cellSize:"--gh-cell-size",cellGap:"--gh-cell-gap",cellRadius:"--gh-cell-radius",cellBorderColor:"--gh-cell-border-color",cellOutlineColor:"--gh-cell-outline-color",tooltipBgColor:"--gh-cell-info-bg-color",tooltipTextColor:"--gh-tooltip-text-color",tooltipPadding:"--gh-tooltip-padding",tooltipRadius:"--gh-tooltip-radius",tooltipFontSize:"--gh-tooltip-font-size",borderColor:"--gh-border-card-color",borderWidth:"--gh-border-card-width",cardPadding:"--gh-card-padding",cardPaddingBlock:"--gh-card-padding-block",cardRadius:"--gh-card-radius",canvasPaddingTop:"--gh-canvas-padding-top",canvasMarginInline:"--gh-canvas-margin-inline",headerHeight:"--gh-header-height",headerMarginBottom:"--gh-header-margin-bottom",headerFontSize:"--gh-header-font-size",avatarSize:"--gh-avatar-size",footerPadding:"--gh-footer-padding",footerFontSize:"--gh-footer-font-size",fontFamily:"--gh-font-default-family"};function R(t){return typeof t=="number"?`${t}px`:t}function H(t,e){let r=typeof e=="string"?p[e]:e;if(r)for(let[n,o]of Object.entries(r)){let a=w[n];a&&o!==void 0&&o!==null&&o!==""&&t.style.setProperty(a,R(o));}}function Y(t){let e=typeof t=="string"?p[t]:t;if(!e)return "";let r=[];for(let[n,o]of Object.entries(e)){let a=w[n];a&&o!==void 0&&o!==null&&o!==""&&r.push(`${a}: ${R(o)};`);}return r.join(`
`)}function J(){return Object.keys(p)}var T=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container),this.container.classList.add(g);}resolveContainer(e){if(typeof e=="string"){let n=document.querySelector(e);if(!n)throw new Error(`Container not found: ${e}`);return n}if(e instanceof HTMLElement)return e;let r=document.getElementById("gh");if(!r)throw new Error('No container found. Specify container in config or add element with id="gh"');return r}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e);}async render(){this.config.theme&&H(this.container,this.config.theme),this.showLoading();try{this.data=await E(this.config.username,this.config.apiEndpoint),x(this.container,this.data,this.config.username,this.config),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container),this.container.classList.add(g)),this.render()}};export{y as CONTRIBUTION_LEVELS,v as DAY_LABELS,L as DEFAULT_API_ENDPOINT,T as GitHubContributionWidget,b as REPO_URL,g as ROOT_CLASS,p as THEME_PRESETS,F as addMonths,_ as addWeeks,H as applyTheme,$ as createCanvas,G as createCard,B as createFooter,z as createHeader,I as createTable,W as createThumbnail,E as fetchContributionData,Y as getThemeCSS,J as getThemePresets,x as renderWidget};//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","controller","timeoutId","response","error","data","createTable","table","thead","tbody","firstCell","i","cell","label","addMonths","months","totalWeeks","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","link","img","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","loader"],"mappings":"AAKO,IAAMA,CAAAA,CAAuB,0DAAA,CAK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B,CAAC,CAAA,CAED,IAAA,CAAK,MAAA,CAAO,YAAA,GAAe,IAAA,CAAK,IAAI,EACtC,CAAA,MAASxC,CAAAA,CAAO,CACd,IAAA,CAAK,SAAA,CAAU,SAAA,CACb,kEAAA,CACF,IAAA,CAAK,MAAA,CAAO,OAAA,GACVA,aAAiB,KAAA,CAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,OAAA,EAAyB,CAC7B,OAAO,IAAA,CAAK,QACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,IAAA,CAAK,IACd,CAKA,OAAA,EAAgB,CACd,IAAA,CAAK,SAAA,CAAU,SAAA,CAAY,EAAA,CAC3B,KAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOsD,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,CAAAA,CAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"index.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n const label = document.createElement('span');\n label.className = 'ghCalendarLabel';\n label.textContent = DAY_LABELS[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]}
{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","ROOT_CLASS","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","buildContributionUrl","apiEndpoint","username","encodedUsername","base","url","separator","fetchContributionData","trimmedUsername","controller","timeoutId","response","error","data","mergeClasses","baseClass","customClass","applyCustomClass","element","getDayLabels","options","formatTooltip","context","normalizeInlineStyleValue","value","normalizeStyleProperty","property","letter","resolveDayClassName","applyDayStyle","cell","style","applyDayAttributes","attributes","attribute","appendDayContents","hasCustomRenderer","rendered","tooltip","createTable","table","thead","tbody","firstCell","dayLabels","showWeekdayLabels","i","label","addMonths","months","totalWeeks","addWeeks","weeks","weekIndex","week","dayIndex","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","user","customHeader","header","total","profile","link","img","createFooter","labels","customFooter","footer","colors","less","more","level","createThumbnail","customThumbnail","thumbnail","svg","path","renderWidget","container","showHeader","showFooter","showThumbnail","calendar","THEME_CSS_VARIABLES","normalizeCSSValue","applyTheme","theme","config","key","cssKey","getThemeCSS","cssVars","getThemePresets","GitHubContributionWidget","el","loader"],"mappings":"AAKO,IAAMA,CAAAA,CAAuB,2DAKvBC,CAAAA,CAAa,qBAAA,CAKbC,EAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,kBACA,gBAAA,CACA,iBACF,EAKaC,CAAAA,CAAa,CAAC,GAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,EAKjDC,CAAAA,CAAkD,CAC7D,QAAS,CACP,OAAA,CAAS,UACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,WAAY,SAAA,CACZ,UAAA,CAAY,UACZ,WAAA,CAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,UACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,UACZ,WAAA,CAAa,SACf,EACA,QAAA,CAAU,CACR,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,YAAa,SACf,CAAA,CACA,MAAO,CACL,OAAA,CAAS,UACT,SAAA,C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CAAK,MAAA,CAAO,OAAA,GACVA,CAAAA,YAAiB,KAAA,CAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,OAAA,EAAyB,CAC7B,OAAO,IAAA,CAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,OAAA,EAAgB,CACd,IAAA,CAAK,SAAA,CAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOmF,EAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,CAAAA,CAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CACvD,IAAA,CAAK,SAAA,CAAU,SAAA,CAAU,GAAA,CAAIpG,CAAU,CAAA,CAAA,CAGlC,IAAA,CAAK,MAAA,EACd,CACF","file":"index.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Root class applied to every rendered widget container.\n */\nexport const ROOT_CLASS = 'ghContributionGraph';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Build an API URL while preserving existing query parameters.\n */\nfunction buildContributionUrl(apiEndpoint: string, username: string): string {\n const encodedUsername = encodeURIComponent(username);\n\n try {\n const base =\n typeof window !== 'undefined' && window.location?.origin\n ? window.location.origin\n : 'http://localhost';\n const url = new URL(apiEndpoint, base);\n url.searchParams.set('login', username);\n\n if (!/^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(apiEndpoint)) {\n return `${url.pathname}${url.search}${url.hash}`;\n }\n\n return url.toString();\n } catch {\n const separator = apiEndpoint.includes('?') ? '&' : '?';\n return `${apiEndpoint}${separator}login=${encodedUsername}`;\n }\n}\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string' || !username.trim()) {\n throw new Error('Username is required');\n }\n\n const trimmedUsername = username.trim();\n const url = buildContributionUrl(apiEndpoint, trimmedUsername);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL, ROOT_CLASS } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n DayStyle,\n DayRenderContext,\n FooterRenderContext,\n GitHubUser,\n HeaderRenderContext,\n RenderOptions,\n ThumbnailRenderContext,\n} from './types';\n\nfunction mergeClasses(baseClass: string, customClass?: string): string {\n return [baseClass, customClass].filter(Boolean).join(' ');\n}\n\nfunction applyCustomClass(element: HTMLElement | SVGElement, customClass?: string): void {\n if (customClass) {\n element.classList.add(...customClass.split(/\\s+/).filter(Boolean));\n }\n}\n\nfunction getDayLabels(options: RenderOptions): string[] {\n return options.dayLabels ?? DAY_LABELS;\n}\n\nfunction formatTooltip(context: DayRenderContext, options: RenderOptions): string {\n if (options.tooltipFormatter) {\n return options.tooltipFormatter(context);\n }\n\n return `${context.day.contributionCount} contributions on ${context.date.toDateString()}`;\n}\n\nfunction normalizeInlineStyleValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\nfunction normalizeStyleProperty(property: string): string {\n return property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction resolveDayClassName(context: DayRenderContext, options: RenderOptions): string | undefined {\n if (typeof options.dayClassName === 'function') {\n return options.dayClassName(context) || undefined;\n }\n\n return options.dayClassName;\n}\n\nfunction applyDayStyle(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const style =\n typeof options.dayStyle === 'function' ? options.dayStyle(context) : options.dayStyle;\n\n if (!style) return;\n\n for (const [property, value] of Object.entries(style satisfies DayStyle)) {\n if (value === undefined || value === null || value === '') continue;\n\n cell.style.setProperty(normalizeStyleProperty(property), normalizeInlineStyleValue(value));\n }\n}\n\nfunction applyDayAttributes(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const attributes = options.dayAttributes?.(context);\n if (!attributes) return;\n\n for (const [attribute, value] of Object.entries(attributes)) {\n if (value === undefined || value === null || value === false) continue;\n cell.setAttribute(attribute, value === true ? '' : String(value));\n }\n}\n\nfunction appendDayContents(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const hasCustomRenderer = typeof options.renderDayContents === 'function';\n const rendered = hasCustomRenderer ? options.renderDayContents?.(context) : undefined;\n\n if (typeof rendered === 'string') {\n cell.appendChild(document.createTextNode(rendered));\n return;\n }\n\n if (rendered instanceof Node) {\n cell.appendChild(rendered);\n return;\n }\n\n if (!hasCustomRenderer && options.showTooltips !== false) {\n const tooltip = document.createElement('span');\n tooltip.className = mergeClasses('ghCalendarTooltip', options.classNames?.tooltip);\n tooltip.textContent = formatTooltip(context, options);\n cell.appendChild(tooltip);\n }\n}\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(options: RenderOptions = {}): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = mergeClasses('ghCalendarTable', options.classNames?.table);\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n const dayLabels = getDayLabels(options);\n const showWeekdayLabels = options.showWeekdayLabels !== false;\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (showWeekdayLabels && dayLabels[i]) {\n const label = document.createElement('span');\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.dayLabel);\n label.textContent = dayLabels[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[],\n options: RenderOptions = {}\n): void {\n if (options.showMonthLabels === false) return;\n\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = options.monthLabelFormatter\n ? options.monthLabelFormatter(months[i], i, months)\n : months[i].name;\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.monthLabel);\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[],\n options: RenderOptions = {},\n username = ''\n): void {\n for (const [weekIndex, week] of weeks.entries()) {\n for (const [dayIndex, day] of week.contributionDays.entries()) {\n const date = new Date(day.date);\n const context: DayRenderContext = {\n day,\n week,\n weekIndex,\n dayIndex,\n date,\n username,\n };\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.className = mergeClasses(\n mergeClasses('ghCalendarDayCell', options.classNames?.dayCell),\n resolveDayClassName(context, options)\n );\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n cell.dataset.week = String(weekIndex);\n cell.dataset.weekday = String(day.weekday);\n applyDayStyle(cell, context, options);\n applyDayAttributes(cell, context, options);\n appendDayContents(cell, context, options);\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(options: RenderOptions = {}): HTMLDivElement {\n const card = document.createElement('div');\n card.className = mergeClasses('ghCalendarCard', options.classNames?.card);\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(options: RenderOptions = {}): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = mergeClasses('ghCalendarCanvas', options.classNames?.canvas);\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string,\n options: RenderOptions = {},\n user?: GitHubUser\n): HTMLElement {\n if (options.renderHeader && user) {\n const customHeader = options.renderHeader({\n user,\n username,\n totalContributions,\n } satisfies HeaderRenderContext);\n\n if (customHeader) return customHeader;\n }\n\n const header = document.createElement('div');\n header.className = mergeClasses('ghCalendarHeader', options.classNames?.header);\n\n const total = document.createElement('span');\n applyCustomClass(total, options.classNames?.total);\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n applyCustomClass(profile, options.classNames?.profile);\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n applyCustomClass(link, options.classNames?.profileLink);\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n applyCustomClass(img, options.classNames?.avatar);\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(options: RenderOptions = {}): HTMLElement {\n const labels = {\n less: options.footerLabels?.less ?? 'Less',\n more: options.footerLabels?.more ?? 'More',\n };\n\n if (options.renderFooter) {\n const customFooter = options.renderFooter({\n levels: CONTRIBUTION_LEVELS,\n labels,\n } satisfies FooterRenderContext);\n\n if (customFooter) return customFooter;\n }\n\n const footer = document.createElement('div');\n footer.className = mergeClasses('ghCalendarCardFooter', options.classNames?.footer);\n\n const colors = document.createElement('div');\n colors.className = mergeClasses(\n 'ghCalendarCardFooterColors',\n options.classNames?.footerLegend\n );\n\n const less = document.createElement('span');\n less.textContent = labels.less;\n\n const more = document.createElement('span');\n more.textContent = labels.more;\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = mergeClasses('ghCalendarDayCell', options.classNames?.dayCell);\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(options: RenderOptions = {}): HTMLElement {\n if (options.renderThumbnail) {\n const customThumbnail = options.renderThumbnail({\n repoUrl: REPO_URL,\n } satisfies ThumbnailRenderContext);\n\n if (customThumbnail) return customThumbnail;\n }\n\n const thumbnail = document.createElement('div');\n thumbnail.className = mergeClasses('ghThumbNail', options.classNames?.thumbnail);\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n applyCustomClass(link, options.classNames?.thumbnailLink);\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n container.classList.add(ROOT_CLASS);\n applyCustomClass(container, options.classNames?.root);\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable(options);\n\n addWeeks(tbody, calendar.weeks, options, username);\n addMonths(thead, calendar.months, options);\n\n const card = createCard(options);\n const canvas = createCanvas(options);\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter(options);\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(\n calendar.totalContributions,\n username,\n user.avatarUrl,\n options,\n user\n );\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail(options);\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\nconst THEME_CSS_VARIABLES: Record<keyof ThemeConfig, string> = {\n bgColor: '--gh-bg-color',\n textColor: '--gh-text-default-color',\n inactiveTextColor: '--gh-text-inactive-color',\n linkHoverColor: '--gh-link-hover-color',\n cellLevel0: '--gh-cell-level0-color',\n cellLevel1: '--gh-cell-level1-color',\n cellLevel2: '--gh-cell-level2-color',\n cellLevel3: '--gh-cell-level3-color',\n cellLevel4: '--gh-cell-level4-color',\n cellSize: '--gh-cell-size',\n cellGap: '--gh-cell-gap',\n cellRadius: '--gh-cell-radius',\n cellBorderColor: '--gh-cell-border-color',\n cellOutlineColor: '--gh-cell-outline-color',\n tooltipBgColor: '--gh-cell-info-bg-color',\n tooltipTextColor: '--gh-tooltip-text-color',\n tooltipPadding: '--gh-tooltip-padding',\n tooltipRadius: '--gh-tooltip-radius',\n tooltipFontSize: '--gh-tooltip-font-size',\n borderColor: '--gh-border-card-color',\n borderWidth: '--gh-border-card-width',\n cardPadding: '--gh-card-padding',\n cardPaddingBlock: '--gh-card-padding-block',\n cardRadius: '--gh-card-radius',\n canvasPaddingTop: '--gh-canvas-padding-top',\n canvasMarginInline: '--gh-canvas-margin-inline',\n headerHeight: '--gh-header-height',\n headerMarginBottom: '--gh-header-margin-bottom',\n headerFontSize: '--gh-header-font-size',\n avatarSize: '--gh-avatar-size',\n footerPadding: '--gh-footer-padding',\n footerFontSize: '--gh-footer-font-size',\n fontFamily: '--gh-font-default-family',\n};\n\nfunction normalizeCSSValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n element.style.setProperty(cssKey, normalizeCSSValue(value));\n }\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n cssVars.push(`${cssKey}: ${normalizeCSSValue(value)};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { ROOT_CLASS } from '../core/constants';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, this.config);\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n return this.render();\n }\n}\n"]}

@@ -1,3 +0,3 @@

'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var T="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",R="https://github.com/iamjr15/github-contribution-graph",U=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],y=["","Mon","","Wed","","Fri",""],h={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function b(t,o=T){if(!t||typeof t!="string")throw new Error("Username is required");let e=`${o}?login=${encodeURIComponent(t.trim())}`,r=new AbortController,l=setTimeout(()=>r.abort(),1e4),n;try{n=await fetch(e,{signal:r.signal});}catch(i){throw clearTimeout(l),i instanceof DOMException&&i.name==="AbortError"?new Error("Request timed out. Please try again."):i}if(clearTimeout(l),!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let a=await n.json();if(!a.user)throw new Error(a.error||"User not found");return a.user}function I(){let t=document.createElement("table");t.className="ghCalendarTable";let o=t.createTHead(),e=t.createTBody(),l=o.insertRow().insertCell();l.style.width="28px";for(let n=0;n<7;n++){let i=e.insertRow().insertCell();if(y[n]){let c=document.createElement("span");c.className="ghCalendarLabel",c.textContent=y[n],i.appendChild(c);}}return {table:t,thead:o,tbody:e}}function O(t,o){for(let e=0;e<o.length-1;e++){let r=o[e].totalWeeks;if(r>=2){let l=t.rows[0].insertCell(),n=document.createElement("span");n.textContent=o[e].name,n.className="ghCalendarLabel",l.appendChild(n),l.colSpan=r;}}}function _(t,o){for(let e of o)for(let r of e.contributionDays){let l=document.createElement("span"),n=new Date(r.date);l.textContent=`${r.contributionCount} contributions on ${n.toDateString()}`;let a=t.rows[r.weekday].insertCell();a.appendChild(l),a.className="ghCalendarDayCell",a.dataset.date=r.date,a.dataset.count=String(r.contributionCount),a.dataset.level=r.contributionLevel;}}function k(){let t=document.createElement("div");return t.className="ghCalendarCard",t}function F(){let t=document.createElement("div");return t.className="ghCalendarCanvas",t}function $(t,o,e){let r=document.createElement("div");r.className="ghCalendarHeader";let l=document.createElement("span");l.textContent=`${t} contributions in the last year`;let n=document.createElement("div"),a=document.createElement("a");a.href=`https://github.com/${encodeURIComponent(o)}`,a.textContent=o;let i=document.createElement("img");return i.src=e,i.alt=`${o}'s avatar`,n.appendChild(a),n.appendChild(i),r.appendChild(l),r.appendChild(n),r}function W(){let t=document.createElement("div");t.className="ghCalendarCardFooter";let o=document.createElement("div");o.className="ghCalendarCardFooterColors";let e=document.createElement("span");e.textContent="Less";let r=document.createElement("span");r.textContent="More",o.appendChild(e);for(let l of U){let n=document.createElement("div");n.className="ghCalendarDayCell",n.dataset.level=l,o.appendChild(n);}return o.appendChild(r),t.appendChild(o),t}function B(){let t=document.createElement("div");t.className="ghThumbNail";let o=document.createElement("a");o.href=R,o.target="_blank",o.rel="noopener noreferrer";let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 98 96"),e.setAttribute("width","18"),e.setAttribute("height","18"),e.style.marginTop="10px",e.style.opacity="0.5",e.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),e.appendChild(r),o.appendChild(e),t.appendChild(o),t}function N(t,o,e,r={}){let{showHeader:l=true,showFooter:n=true,showThumbnail:a=true}=r;t.innerHTML="";let i=o.contributionsCollection.contributionCalendar,{table:c,thead:u,tbody:p}=I();_(p,i.weeks),O(u,i.months);let d=k(),f=F();if(f.appendChild(c),n){let s=W();f.appendChild(s);}if(d.appendChild(f),l){let s=$(i.totalContributions,e,o.avatarUrl);t.appendChild(s);}if(t.appendChild(d),a){let s=B();t.appendChild(s);}}function j(t){return t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}function v(t,o){let e=typeof o=="string"?h[o]:o;e&&(e.bgColor&&t.style.setProperty("--gh-bg-color",e.bgColor),e.textColor&&t.style.setProperty("--gh-text-default-color",e.textColor),e.cellLevel0&&t.style.setProperty("--gh-cell-level0-color",e.cellLevel0),e.cellLevel1&&t.style.setProperty("--gh-cell-level1-color",e.cellLevel1),e.cellLevel2&&t.style.setProperty("--gh-cell-level2-color",e.cellLevel2),e.cellLevel3&&t.style.setProperty("--gh-cell-level3-color",e.cellLevel3),e.cellLevel4&&t.style.setProperty("--gh-cell-level4-color",e.cellLevel4),e.borderColor&&t.style.setProperty("--gh-border-card-color",e.borderColor),e.fontFamily&&t.style.setProperty("--gh-font-default-family",e.fontFamily));}function q(t){let o=typeof t=="string"?h[t]:t;if(!o)return "";let e=[];for(let[r,l]of Object.entries(o))if(l){let n=`--gh-${j(r).replace("color","-color")}`;e.push(`${n}: ${l};`);}return e.join(`
`)}function Q(){return Object.keys(h)}var G=react.forwardRef((t,o)=>{let{username:e,apiEndpoint:r,theme:l="default",showHeader:n=true,showFooter:a=true,showThumbnail:i=true,className:c,style:u,onDataLoaded:p,onError:d,onLoading:f}=t,s=react.useRef(null),[C,S]=react.useState(null),[A,g]=react.useState(true),[M,E]=react.useState(null),D=async()=>{if(!e){E(new Error("Username is required")),g(false);return}g(true),f?.(true),E(null);try{let m=await b(e,r);S(m),p?.(m);}catch(m){let P=m instanceof Error?m:new Error("Unknown error");E(P),d?.(P);}finally{g(false),f?.(false);}};return react.useEffect(()=>{D();},[e,r]),react.useEffect(()=>{s.current&&v(s.current,l);},[l]),react.useEffect(()=>{C&&s.current&&N(s.current,C,e,{showHeader:n,showFooter:a,showThumbnail:i});},[C,n,a,i,e]),react.useImperativeHandle(o,()=>({refresh:D,getData:()=>C})),M?jsxRuntime.jsx("div",{className:c,style:u,children:jsxRuntime.jsx("p",{style:{color:"#f85149"},children:"Failed to load contribution data."})}):jsxRuntime.jsx("div",{ref:s,className:c,style:u,"data-loading":A})});G.displayName="GitHubContributionGraph";function J(t,o={}){let{apiEndpoint:e,autoFetch:r=true}=o,[l,n]=react.useState(null),[a,i]=react.useState(r),[c,u]=react.useState(null),p=react.useCallback(async()=>{if(!t){u(new Error("Username is required"));return}i(true),u(null);try{let d=await b(t,e);n(d);}catch(d){u(d instanceof Error?d:new Error("Unknown error"));}finally{i(false);}},[t,e]);return react.useEffect(()=>{r&&t&&p();},[r,t,p]),{data:l,loading:a,error:c,refetch:p}}exports.DEFAULT_API_ENDPOINT=T;exports.GitHubContributionGraph=G;exports.THEME_PRESETS=h;exports.applyTheme=v;exports.fetchContributionData=b;exports.getThemeCSS=q;exports.getThemePresets=Q;exports.useContributionData=J;//# sourceMappingURL=react.cjs.map
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var U="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",w="ghContributionGraph",P="https://github.com/iamjr15/github-contribution-graph",G=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],Y=["","Mon","","Wed","","Fri",""],y={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};function le(e,t){let o=encodeURIComponent(t);try{let r=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(e,r);return n.searchParams.set("login",t),/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)?n.toString():`${n.pathname}${n.search}${n.hash}`}catch{let r=e.includes("?")?"&":"?";return `${e}${r}login=${o}`}}async function T(e,t=U){if(!e||typeof e!="string"||!e.trim())throw new Error("Username is required");let o=e.trim(),r=le(t,o),n=new AbortController,a=setTimeout(()=>n.abort(),1e4),i;try{i=await fetch(r,{signal:n.signal});}catch(d){throw clearTimeout(a),d instanceof DOMException&&d.name==="AbortError"?new Error("Request timed out. Please try again."):d}if(clearTimeout(a),!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let l=await i.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function f(e,t){return [e,t].filter(Boolean).join(" ")}function C(e,t){t&&e.classList.add(...t.split(/\s+/).filter(Boolean));}function ie(e){return e.dayLabels??Y}function se(e,t){return t.tooltipFormatter?t.tooltipFormatter(e):`${e.day.contributionCount} contributions on ${e.date.toDateString()}`}function de(e){return typeof e=="number"?`${e}px`:e}function ce(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function ue(e,t){return typeof t.dayClassName=="function"?t.dayClassName(e)||void 0:t.dayClassName}function fe(e,t,o){let r=typeof o.dayStyle=="function"?o.dayStyle(t):o.dayStyle;if(r)for(let[n,a]of Object.entries(r))a==null||a===""||e.style.setProperty(ce(n),de(a));}function me(e,t,o){let r=o.dayAttributes?.(t);if(r)for(let[n,a]of Object.entries(r))a==null||a===false||e.setAttribute(n,a===true?"":String(a));}function he(e,t,o){let r=typeof o.renderDayContents=="function",n=r?o.renderDayContents?.(t):void 0;if(typeof n=="string"){e.appendChild(document.createTextNode(n));return}if(n instanceof Node){e.appendChild(n);return}if(!r&&o.showTooltips!==false){let a=document.createElement("span");a.className=f("ghCalendarTooltip",o.classNames?.tooltip),a.textContent=se(t,o),e.appendChild(a);}}function pe(e={}){let t=document.createElement("table");t.className=f("ghCalendarTable",e.classNames?.table);let o=t.createTHead(),r=t.createTBody(),a=o.insertRow().insertCell();a.style.width="28px";let i=ie(e),l=e.showWeekdayLabels!==false;for(let d=0;d<7;d++){let s=r.insertRow().insertCell();if(l&&i[d]){let u=document.createElement("span");u.className=f("ghCalendarLabel",e.classNames?.dayLabel),u.textContent=i[d],s.appendChild(u);}}return {table:t,thead:o,tbody:r}}function be(e,t,o={}){if(o.showMonthLabels!==false)for(let r=0;r<t.length-1;r++){let n=t[r].totalWeeks;if(n>=2){let a=e.rows[0].insertCell(),i=document.createElement("span");i.textContent=o.monthLabelFormatter?o.monthLabelFormatter(t[r],r,t):t[r].name,i.className=f("ghCalendarLabel",o.classNames?.monthLabel),a.appendChild(i),a.colSpan=n;}}}function Ce(e,t,o={},r=""){for(let[n,a]of t.entries())for(let[i,l]of a.contributionDays.entries()){let d=new Date(l.date),c={day:l,week:a,weekIndex:n,dayIndex:i,date:d,username:r},s=e.rows[l.weekday].insertCell();s.className=f(f("ghCalendarDayCell",o.classNames?.dayCell),ue(c,o)),s.dataset.date=l.date,s.dataset.count=String(l.contributionCount),s.dataset.level=l.contributionLevel,s.dataset.week=String(n),s.dataset.weekday=String(l.weekday),fe(s,c,o),me(s,c,o),he(s,c,o);}}function ge(e={}){let t=document.createElement("div");return t.className=f("ghCalendarCard",e.classNames?.card),t}function ye(e={}){let t=document.createElement("div");return t.className=f("ghCalendarCanvas",e.classNames?.canvas),t}function Te(e,t,o,r={},n){if(r.renderHeader&&n){let s=r.renderHeader({user:n,username:t,totalContributions:e});if(s)return s}let a=document.createElement("div");a.className=f("ghCalendarHeader",r.classNames?.header);let i=document.createElement("span");C(i,r.classNames?.total),i.textContent=`${e} contributions in the last year`;let l=document.createElement("div");C(l,r.classNames?.profile);let d=document.createElement("a");d.href=`https://github.com/${encodeURIComponent(t)}`,d.textContent=t,C(d,r.classNames?.profileLink);let c=document.createElement("img");return c.src=o,c.alt=`${t}'s avatar`,C(c,r.classNames?.avatar),l.appendChild(d),l.appendChild(c),a.appendChild(i),a.appendChild(l),a}function Ee(e={}){let t={less:e.footerLabels?.less??"Less",more:e.footerLabels?.more??"More"};if(e.renderFooter){let i=e.renderFooter({levels:G,labels:t});if(i)return i}let o=document.createElement("div");o.className=f("ghCalendarCardFooter",e.classNames?.footer);let r=document.createElement("div");r.className=f("ghCalendarCardFooterColors",e.classNames?.footerLegend);let n=document.createElement("span");n.textContent=t.less;let a=document.createElement("span");a.textContent=t.more,r.appendChild(n);for(let i of G){let l=document.createElement("div");l.className=f("ghCalendarDayCell",e.classNames?.dayCell),l.dataset.level=i,r.appendChild(l);}return r.appendChild(a),o.appendChild(r),o}function Re(e={}){if(e.renderThumbnail){let a=e.renderThumbnail({repoUrl:P});if(a)return a}let t=document.createElement("div");t.className=f("ghThumbNail",e.classNames?.thumbnail);let o=document.createElement("a");o.href=P,o.target="_blank",o.rel="noopener noreferrer",C(o,e.classNames?.thumbnailLink);let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("viewBox","0 0 98 96"),r.setAttribute("width","18"),r.setAttribute("height","18"),r.style.marginTop="10px",r.style.opacity="0.5",r.style.fill="var(--gh-text-default-color, #333)";let n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("fill-rule","evenodd"),n.setAttribute("clip-rule","evenodd"),n.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),r.appendChild(n),o.appendChild(r),t.appendChild(o),t}function J(e,t,o,r={}){let{showHeader:n=true,showFooter:a=true,showThumbnail:i=true}=r;e.classList.add(w),C(e,r.classNames?.root),e.innerHTML="";let l=t.contributionsCollection.contributionCalendar,{table:d,thead:c,tbody:s}=pe(r);Ce(s,l.weeks,r,o),be(c,l.months,r);let u=ge(r),b=ye(r);if(b.appendChild(d),a){let m=Ee(r);b.appendChild(m);}if(u.appendChild(b),n){let m=Te(l.totalContributions,o,t.avatarUrl,r,t);e.appendChild(m);}if(e.appendChild(u),i){let m=Re(r);e.appendChild(m);}}var X={bgColor:"--gh-bg-color",textColor:"--gh-text-default-color",inactiveTextColor:"--gh-text-inactive-color",linkHoverColor:"--gh-link-hover-color",cellLevel0:"--gh-cell-level0-color",cellLevel1:"--gh-cell-level1-color",cellLevel2:"--gh-cell-level2-color",cellLevel3:"--gh-cell-level3-color",cellLevel4:"--gh-cell-level4-color",cellSize:"--gh-cell-size",cellGap:"--gh-cell-gap",cellRadius:"--gh-cell-radius",cellBorderColor:"--gh-cell-border-color",cellOutlineColor:"--gh-cell-outline-color",tooltipBgColor:"--gh-cell-info-bg-color",tooltipTextColor:"--gh-tooltip-text-color",tooltipPadding:"--gh-tooltip-padding",tooltipRadius:"--gh-tooltip-radius",tooltipFontSize:"--gh-tooltip-font-size",borderColor:"--gh-border-card-color",borderWidth:"--gh-border-card-width",cardPadding:"--gh-card-padding",cardPaddingBlock:"--gh-card-padding-block",cardRadius:"--gh-card-radius",canvasPaddingTop:"--gh-canvas-padding-top",canvasMarginInline:"--gh-canvas-margin-inline",headerHeight:"--gh-header-height",headerMarginBottom:"--gh-header-margin-bottom",headerFontSize:"--gh-header-font-size",avatarSize:"--gh-avatar-size",footerPadding:"--gh-footer-padding",footerFontSize:"--gh-footer-font-size",fontFamily:"--gh-font-default-family"};function ee(e){return typeof e=="number"?`${e}px`:e}function k(e,t){let o=typeof t=="string"?y[t]:t;if(o)for(let[r,n]of Object.entries(o)){let a=X[r];a&&n!==void 0&&n!==null&&n!==""&&e.style.setProperty(a,ee(n));}}function Le(e){let t=typeof e=="string"?y[e]:e;if(!t)return "";let o=[];for(let[r,n]of Object.entries(t)){let a=X[r];a&&n!==void 0&&n!==null&&n!==""&&o.push(`${a}: ${ee(n)};`);}return o.join(`
`)}function ve(){return Object.keys(y)}var te=react.forwardRef((e,t)=>{let{username:o,apiEndpoint:r,theme:n="default",showHeader:a=true,showFooter:i=true,showThumbnail:l=true,showMonthLabels:d,showWeekdayLabels:c,showTooltips:s,dayLabels:u,footerLabels:b,classNames:m,dayClassName:I,dayStyle:_,dayAttributes:$,tooltipFormatter:z,monthLabelFormatter:B,renderDayContents:W,renderHeader:j,renderFooter:V,renderThumbnail:q,className:re,style:R,onDataLoaded:oe,onError:ne,onLoading:Q,render:L,loadingFallback:Z,errorFallback:H}=e,h=react.useRef(null),v=[w,m?.root,re].filter(Boolean).join(" "),[g,ae]=react.useState(null),[N,S]=react.useState(true),[x,D]=react.useState(null),O=async()=>{if(!o){D(new Error("Username is required")),S(false);return}S(true),Q?.(true),D(null);try{let p=await T(o,r);ae(p),oe?.(p);}catch(p){let K=p instanceof Error?p:new Error("Unknown error");D(K),ne?.(K);}finally{S(false),Q?.(false);}};if(react.useEffect(()=>{O();},[o,r]),react.useEffect(()=>{h.current&&k(h.current,n);},[n]),react.useEffect(()=>{g&&h.current&&!L&&J(h.current,g,o,{showHeader:a,showFooter:i,showThumbnail:l,showMonthLabels:d,showWeekdayLabels:c,showTooltips:s,dayLabels:u,footerLabels:b,classNames:m,dayClassName:I,dayStyle:_,dayAttributes:$,tooltipFormatter:z,monthLabelFormatter:B,renderDayContents:W,renderHeader:j,renderFooter:V,renderThumbnail:q});},[g,a,i,l,d,c,s,u,b,m,I,_,$,z,B,W,j,V,q,o,L]),react.useImperativeHandle(t,()=>({refresh:O,getData:()=>g})),L)return jsxRuntime.jsx("div",{ref:h,className:v,style:R,"data-error":x?"true":void 0,children:L({username:o,data:g,loading:N,error:x,refresh:O})});if(N&&Z)return jsxRuntime.jsx("div",{ref:h,className:v,style:R,children:Z});if(x){let p=typeof H=="function"?H(x):H;return jsxRuntime.jsx("div",{className:v,style:R,children:p??jsxRuntime.jsx("p",{style:{color:"#f85149"},children:"Failed to load contribution data."})})}return jsxRuntime.jsx("div",{ref:h,className:v,style:R,"data-loading":N})});te.displayName="GitHubContributionGraph";function De(e,t={}){let{apiEndpoint:o,autoFetch:r=true}=t,[n,a]=react.useState(null),[i,l]=react.useState(r),[d,c]=react.useState(null),s=react.useCallback(async()=>{if(!e){c(new Error("Username is required"));return}l(true),c(null);try{let u=await T(e,o);a(u);}catch(u){c(u instanceof Error?u:new Error("Unknown error"));}finally{l(false);}},[e,o]);return react.useEffect(()=>{r&&e&&s();},[r,e,s]),{data:n,loading:i,error:d,refetch:s}}exports.DEFAULT_API_ENDPOINT=U;exports.GitHubContributionGraph=te;exports.THEME_PRESETS=y;exports.applyTheme=k;exports.fetchContributionData=T;exports.getThemeCSS=Le;exports.getThemePresets=ve;exports.useContributionData=De;//# sourceMappingURL=react.cjs.map
//# sourceMappingURL=react.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/react/GitHubContributionGraph.tsx","../src/react/useContributionData.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","controller","timeoutId","response","error","data","createTable","table","thead","tbody","firstCell","i","cell","label","addMonths","months","totalWeeks","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","link","img","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionGraph","forwardRef","props","ref","className","style","onDataLoaded","onError","onLoading","containerRef","useRef","setData","useState","loading","setLoading","setError","fetchData","userData","err","fetchError","useEffect","useImperativeHandle","jsx","useContributionData","autoFetch","refetch","useCallback"],"mappings":"gFAKO,IAAMA,CAAAA,CAAuB,2DAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,EAAA,CAAI,KAAA,CAAO,GAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAA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A,CAAW3F,EAAU4F,CAAO,CAAC,EAE1B,CAAE,IAAA,CAAArF,EAAM,OAAA,CAAAyE,CAAAA,CAAS,MAAA1E,CAAAA,CAAO,OAAA,CAAAsF,CAAQ,CACzC","file":"react.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n const label = document.createElement('span');\n label.className = 'ghCalendarLabel';\n label.textContent = DAY_LABELS[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import React, {\n useRef,\n useEffect,\n useState,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme } from '../styles/themes';\nimport type { GitHubUser, ThemePreset, ThemeConfig } from '../core/types';\n\nexport interface GitHubContributionGraphProps {\n /**\n * GitHub username to display contributions for\n */\n username: string;\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Theme preset name or custom theme configuration\n */\n theme?: ThemePreset | ThemeConfig;\n /**\n * Whether to show the header with total contributions\n * @default true\n */\n showHeader?: boolean;\n /**\n * Whether to show the footer legend\n * @default true\n */\n showFooter?: boolean;\n /**\n * Whether to show the GitHub thumbnail/attribution\n * @default true\n */\n showThumbnail?: boolean;\n /**\n * Additional CSS class name\n */\n className?: string;\n /**\n * Inline styles\n */\n style?: React.CSSProperties;\n /**\n * Callback when data is successfully loaded\n */\n onDataLoaded?: (data: GitHubUser) => void;\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n /**\n * Callback when loading state changes\n */\n onLoading?: (isLoading: boolean) => void;\n}\n\nexport interface GitHubContributionGraphRef {\n /**\n * Manually refresh the contribution data\n */\n refresh: () => Promise<void>;\n /**\n * Get the currently loaded data\n */\n getData: () => GitHubUser | null;\n}\n\n/**\n * React component for displaying GitHub contribution graphs\n *\n * @example\n * ```tsx\n * import { GitHubContributionGraph } from 'github-contribution-graph/react';\n * import 'github-contribution-graph/styles.css';\n *\n * function App() {\n * return (\n * <GitHubContributionGraph\n * username=\"octocat\"\n * theme=\"midnight\"\n * onDataLoaded={(data) => console.log('Loaded!', data)}\n * />\n * );\n * }\n * ```\n */\nexport const GitHubContributionGraph = forwardRef<\n GitHubContributionGraphRef,\n GitHubContributionGraphProps\n>((props, ref) => {\n const {\n username,\n apiEndpoint,\n theme = 'default',\n showHeader = true,\n showFooter = true,\n showThumbnail = true,\n className,\n style,\n onDataLoaded,\n onError,\n onLoading,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = async () => {\n if (!username) {\n setError(new Error('Username is required'));\n setLoading(false);\n return;\n }\n\n setLoading(true);\n onLoading?.(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n onDataLoaded?.(userData);\n } catch (err) {\n const fetchError = err instanceof Error ? err : new Error('Unknown error');\n setError(fetchError);\n onError?.(fetchError);\n } finally {\n setLoading(false);\n onLoading?.(false);\n }\n };\n\n // Fetch data when username or apiEndpoint changes\n useEffect(() => {\n fetchData();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [username, apiEndpoint]);\n\n // Apply theme whenever it changes\n useEffect(() => {\n if (containerRef.current) {\n applyTheme(containerRef.current, theme);\n }\n }, [theme]);\n\n // Render widget when data or options change\n useEffect(() => {\n if (data && containerRef.current) {\n renderWidget(containerRef.current, data, username, {\n showHeader,\n showFooter,\n showThumbnail,\n });\n }\n }, [data, showHeader, showFooter, showThumbnail, username]);\n\n // Expose ref methods\n useImperativeHandle(ref, () => ({\n refresh: fetchData,\n getData: () => data,\n }));\n\n if (error) {\n return (\n <div className={className} style={style}>\n <p style={{ color: '#f85149' }}>Failed to load contribution data.</p>\n </div>\n );\n }\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={style}\n data-loading={loading}\n />\n );\n});\n\nGitHubContributionGraph.displayName = 'GitHubContributionGraph';\n","import { useState, useEffect, useCallback } from 'react';\nimport { fetchContributionData } from '../core/api';\nimport type { GitHubUser } from '../core/types';\n\nexport interface UseContributionDataOptions {\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Whether to fetch data automatically on mount\n * @default true\n */\n autoFetch?: boolean;\n}\n\nexport interface UseContributionDataResult {\n /**\n * The fetched user data, null if not loaded\n */\n data: GitHubUser | null;\n /**\n * Whether data is currently being fetched\n */\n loading: boolean;\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n /**\n * Function to manually refetch data\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * React hook for fetching GitHub contribution data\n *\n * @param username - GitHub username\n * @param options - Hook options\n * @returns Object containing data, loading state, error, and refetch function\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { data, loading, error, refetch } = useContributionData('octocat');\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>\n * <button onClick={refetch}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useContributionData(\n username: string,\n options: UseContributionDataOptions = {}\n): UseContributionDataResult {\n const { apiEndpoint, autoFetch = true } = options;\n\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(autoFetch);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!username) {\n setError(new Error('Username is required'));\n return;\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n } finally {\n setLoading(false);\n }\n }, [username, apiEndpoint]);\n\n useEffect(() => {\n if (autoFetch && username) {\n refetch();\n }\n }, [autoFetch, username, refetch]);\n\n return { data, loading, error, refetch };\n}\n"]}
{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/react/GitHubContributionGraph.tsx","../src/react/useContributionData.ts"],"names":["DEFAULT_API_ENDPOINT","ROOT_CLASS","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","buildContributionUrl","apiEndpoint","username","encodedUsername","base","url","separator","fetchContributionData","trimmedUsername","controller","timeoutId","response","error","data","mergeClasses","baseClass","customClass","applyCustomClass","element","getDayLabels","options","formatTooltip","context","normalizeInlineStyleValue","value","normalizeStyleProperty","property","letter","resolveDayClassName","applyDayStyle","cell","style","applyDayAttributes","attributes","attribute","appendDayContents","hasCustomRenderer","rendered","tooltip","createTable","table","thead","tbody","firstCell","dayLabels","showWeekdayLabels","i","label","addMonths","months","totalWeeks","addWeeks","weeks","weekIndex","week","dayIndex","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","user","customHeader","header","total","profile","link","img","createFooter","labels","customFooter","footer","colors","less","more","level","createThumbnail","customThumbnail","thumbnail","svg","path","renderWidget","container","showHeader","showFooter","showThumbnail","calendar","THEME_CSS_VARIABLES","normalizeCSSValue","applyTheme","theme","config","key","cssKey","getThemeCSS","cssVars","getThemePresets","GitHubContributionGraph","forwardRef","props","ref","showMonthLabels","showTooltips","footerLabels","classNames","dayClassName","dayStyle","dayAttributes","tooltipFormatter","monthLabelFormatter","renderDayContents","renderHeader","renderFooter","renderThumbnail","className","onDataLoaded","onError","onLoading","customRender","loadingFallback","errorFallback","containerRef","useRef","rootClassName","setData","useState","loading","setLoading","setError","fetchData","userData","err","fetchError","useEffect","useImperativeHandle","jsx","renderedError","useContributionData","autoFetch","refetch","useCallback"],"mappings":"gFAKO,IAAMA,CAAAA,CAAuB,2DAKvBC,CAAAA,CAAa,qBAAA,CAKbC,EAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,iBACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,CAAI,MAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,CAAA,CAKjDC,EAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,UACZ,WAAA,CAAa,SACf,EACA,KAAA,CAAO,CACL,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CAC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W,CAAA,CAClE+H,CAAAA,CAAQM,CAAQ,EAClB,CAAA,MAASC,CAAAA,CAAK,CACZH,CAAAA,CAASG,CAAAA,YAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,KAAA,CAAM,eAAe,CAAC,EAClE,CAAA,OAAE,CACAJ,CAAAA,CAAW,KAAK,EAClB,CACF,CAAA,CAAG,CAACjI,CAAAA,CAAUD,CAAW,CAAC,CAAA,CAE1B,OAAAwI,eAAAA,CAAU,IAAM,CACVK,CAAAA,EAAa5I,CAAAA,EACf6I,IAEJ,CAAA,CAAG,CAACD,CAAAA,CAAW5I,CAAAA,CAAU6I,CAAO,CAAC,CAAA,CAE1B,CAAE,IAAA,CAAAlI,CAAAA,CAAM,OAAA,CAAAqH,CAAAA,CAAS,KAAA,CAAAtH,CAAAA,CAAO,OAAA,CAAAmI,CAAQ,CACzC","file":"react.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Root class applied to every rendered widget container.\n */\nexport const ROOT_CLASS = 'ghContributionGraph';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Build an API URL while preserving existing query parameters.\n */\nfunction buildContributionUrl(apiEndpoint: string, username: string): string {\n const encodedUsername = encodeURIComponent(username);\n\n try {\n const base =\n typeof window !== 'undefined' && window.location?.origin\n ? window.location.origin\n : 'http://localhost';\n const url = new URL(apiEndpoint, base);\n url.searchParams.set('login', username);\n\n if (!/^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(apiEndpoint)) {\n return `${url.pathname}${url.search}${url.hash}`;\n }\n\n return url.toString();\n } catch {\n const separator = apiEndpoint.includes('?') ? '&' : '?';\n return `${apiEndpoint}${separator}login=${encodedUsername}`;\n }\n}\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string' || !username.trim()) {\n throw new Error('Username is required');\n }\n\n const trimmedUsername = username.trim();\n const url = buildContributionUrl(apiEndpoint, trimmedUsername);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL, ROOT_CLASS } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n DayStyle,\n DayRenderContext,\n FooterRenderContext,\n GitHubUser,\n HeaderRenderContext,\n RenderOptions,\n ThumbnailRenderContext,\n} from './types';\n\nfunction mergeClasses(baseClass: string, customClass?: string): string {\n return [baseClass, customClass].filter(Boolean).join(' ');\n}\n\nfunction applyCustomClass(element: HTMLElement | SVGElement, customClass?: string): void {\n if (customClass) {\n element.classList.add(...customClass.split(/\\s+/).filter(Boolean));\n }\n}\n\nfunction getDayLabels(options: RenderOptions): string[] {\n return options.dayLabels ?? DAY_LABELS;\n}\n\nfunction formatTooltip(context: DayRenderContext, options: RenderOptions): string {\n if (options.tooltipFormatter) {\n return options.tooltipFormatter(context);\n }\n\n return `${context.day.contributionCount} contributions on ${context.date.toDateString()}`;\n}\n\nfunction normalizeInlineStyleValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\nfunction normalizeStyleProperty(property: string): string {\n return property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction resolveDayClassName(context: DayRenderContext, options: RenderOptions): string | undefined {\n if (typeof options.dayClassName === 'function') {\n return options.dayClassName(context) || undefined;\n }\n\n return options.dayClassName;\n}\n\nfunction applyDayStyle(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const style =\n typeof options.dayStyle === 'function' ? options.dayStyle(context) : options.dayStyle;\n\n if (!style) return;\n\n for (const [property, value] of Object.entries(style satisfies DayStyle)) {\n if (value === undefined || value === null || value === '') continue;\n\n cell.style.setProperty(normalizeStyleProperty(property), normalizeInlineStyleValue(value));\n }\n}\n\nfunction applyDayAttributes(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const attributes = options.dayAttributes?.(context);\n if (!attributes) return;\n\n for (const [attribute, value] of Object.entries(attributes)) {\n if (value === undefined || value === null || value === false) continue;\n cell.setAttribute(attribute, value === true ? '' : String(value));\n }\n}\n\nfunction appendDayContents(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const hasCustomRenderer = typeof options.renderDayContents === 'function';\n const rendered = hasCustomRenderer ? options.renderDayContents?.(context) : undefined;\n\n if (typeof rendered === 'string') {\n cell.appendChild(document.createTextNode(rendered));\n return;\n }\n\n if (rendered instanceof Node) {\n cell.appendChild(rendered);\n return;\n }\n\n if (!hasCustomRenderer && options.showTooltips !== false) {\n const tooltip = document.createElement('span');\n tooltip.className = mergeClasses('ghCalendarTooltip', options.classNames?.tooltip);\n tooltip.textContent = formatTooltip(context, options);\n cell.appendChild(tooltip);\n }\n}\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(options: RenderOptions = {}): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = mergeClasses('ghCalendarTable', options.classNames?.table);\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n const dayLabels = getDayLabels(options);\n const showWeekdayLabels = options.showWeekdayLabels !== false;\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (showWeekdayLabels && dayLabels[i]) {\n const label = document.createElement('span');\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.dayLabel);\n label.textContent = dayLabels[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[],\n options: RenderOptions = {}\n): void {\n if (options.showMonthLabels === false) return;\n\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = options.monthLabelFormatter\n ? options.monthLabelFormatter(months[i], i, months)\n : months[i].name;\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.monthLabel);\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[],\n options: RenderOptions = {},\n username = ''\n): void {\n for (const [weekIndex, week] of weeks.entries()) {\n for (const [dayIndex, day] of week.contributionDays.entries()) {\n const date = new Date(day.date);\n const context: DayRenderContext = {\n day,\n week,\n weekIndex,\n dayIndex,\n date,\n username,\n };\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.className = mergeClasses(\n mergeClasses('ghCalendarDayCell', options.classNames?.dayCell),\n resolveDayClassName(context, options)\n );\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n cell.dataset.week = String(weekIndex);\n cell.dataset.weekday = String(day.weekday);\n applyDayStyle(cell, context, options);\n applyDayAttributes(cell, context, options);\n appendDayContents(cell, context, options);\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(options: RenderOptions = {}): HTMLDivElement {\n const card = document.createElement('div');\n card.className = mergeClasses('ghCalendarCard', options.classNames?.card);\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(options: RenderOptions = {}): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = mergeClasses('ghCalendarCanvas', options.classNames?.canvas);\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string,\n options: RenderOptions = {},\n user?: GitHubUser\n): HTMLElement {\n if (options.renderHeader && user) {\n const customHeader = options.renderHeader({\n user,\n username,\n totalContributions,\n } satisfies HeaderRenderContext);\n\n if (customHeader) return customHeader;\n }\n\n const header = document.createElement('div');\n header.className = mergeClasses('ghCalendarHeader', options.classNames?.header);\n\n const total = document.createElement('span');\n applyCustomClass(total, options.classNames?.total);\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n applyCustomClass(profile, options.classNames?.profile);\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n applyCustomClass(link, options.classNames?.profileLink);\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n applyCustomClass(img, options.classNames?.avatar);\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(options: RenderOptions = {}): HTMLElement {\n const labels = {\n less: options.footerLabels?.less ?? 'Less',\n more: options.footerLabels?.more ?? 'More',\n };\n\n if (options.renderFooter) {\n const customFooter = options.renderFooter({\n levels: CONTRIBUTION_LEVELS,\n labels,\n } satisfies FooterRenderContext);\n\n if (customFooter) return customFooter;\n }\n\n const footer = document.createElement('div');\n footer.className = mergeClasses('ghCalendarCardFooter', options.classNames?.footer);\n\n const colors = document.createElement('div');\n colors.className = mergeClasses(\n 'ghCalendarCardFooterColors',\n options.classNames?.footerLegend\n );\n\n const less = document.createElement('span');\n less.textContent = labels.less;\n\n const more = document.createElement('span');\n more.textContent = labels.more;\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = mergeClasses('ghCalendarDayCell', options.classNames?.dayCell);\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(options: RenderOptions = {}): HTMLElement {\n if (options.renderThumbnail) {\n const customThumbnail = options.renderThumbnail({\n repoUrl: REPO_URL,\n } satisfies ThumbnailRenderContext);\n\n if (customThumbnail) return customThumbnail;\n }\n\n const thumbnail = document.createElement('div');\n thumbnail.className = mergeClasses('ghThumbNail', options.classNames?.thumbnail);\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n applyCustomClass(link, options.classNames?.thumbnailLink);\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n container.classList.add(ROOT_CLASS);\n applyCustomClass(container, options.classNames?.root);\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable(options);\n\n addWeeks(tbody, calendar.weeks, options, username);\n addMonths(thead, calendar.months, options);\n\n const card = createCard(options);\n const canvas = createCanvas(options);\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter(options);\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(\n calendar.totalContributions,\n username,\n user.avatarUrl,\n options,\n user\n );\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail(options);\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\nconst THEME_CSS_VARIABLES: Record<keyof ThemeConfig, string> = {\n bgColor: '--gh-bg-color',\n textColor: '--gh-text-default-color',\n inactiveTextColor: '--gh-text-inactive-color',\n linkHoverColor: '--gh-link-hover-color',\n cellLevel0: '--gh-cell-level0-color',\n cellLevel1: '--gh-cell-level1-color',\n cellLevel2: '--gh-cell-level2-color',\n cellLevel3: '--gh-cell-level3-color',\n cellLevel4: '--gh-cell-level4-color',\n cellSize: '--gh-cell-size',\n cellGap: '--gh-cell-gap',\n cellRadius: '--gh-cell-radius',\n cellBorderColor: '--gh-cell-border-color',\n cellOutlineColor: '--gh-cell-outline-color',\n tooltipBgColor: '--gh-cell-info-bg-color',\n tooltipTextColor: '--gh-tooltip-text-color',\n tooltipPadding: '--gh-tooltip-padding',\n tooltipRadius: '--gh-tooltip-radius',\n tooltipFontSize: '--gh-tooltip-font-size',\n borderColor: '--gh-border-card-color',\n borderWidth: '--gh-border-card-width',\n cardPadding: '--gh-card-padding',\n cardPaddingBlock: '--gh-card-padding-block',\n cardRadius: '--gh-card-radius',\n canvasPaddingTop: '--gh-canvas-padding-top',\n canvasMarginInline: '--gh-canvas-margin-inline',\n headerHeight: '--gh-header-height',\n headerMarginBottom: '--gh-header-margin-bottom',\n headerFontSize: '--gh-header-font-size',\n avatarSize: '--gh-avatar-size',\n footerPadding: '--gh-footer-padding',\n footerFontSize: '--gh-footer-font-size',\n fontFamily: '--gh-font-default-family',\n};\n\nfunction normalizeCSSValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n element.style.setProperty(cssKey, normalizeCSSValue(value));\n }\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n cssVars.push(`${cssKey}: ${normalizeCSSValue(value)};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import React, {\n useRef,\n useEffect,\n useState,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { fetchContributionData } from '../core/api';\nimport { ROOT_CLASS } from '../core/constants';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme } from '../styles/themes';\nimport type { GitHubUser, ThemePreset, ThemeConfig, RenderOptions } from '../core/types';\n\nexport interface GitHubContributionGraphRenderState {\n username: string;\n data: GitHubUser | null;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n}\n\nexport interface GitHubContributionGraphProps extends RenderOptions {\n /**\n * GitHub username to display contributions for\n */\n username: string;\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Theme preset name or custom theme configuration\n */\n theme?: ThemePreset | ThemeConfig;\n /**\n * Whether to show the header with total contributions\n * @default true\n */\n showHeader?: boolean;\n /**\n * Whether to show the footer legend\n * @default true\n */\n showFooter?: boolean;\n /**\n * Whether to show the GitHub thumbnail/attribution\n * @default true\n */\n showThumbnail?: boolean;\n /**\n * Additional CSS class name\n */\n className?: string;\n /**\n * Inline styles\n */\n style?: React.CSSProperties;\n /**\n * Callback when data is successfully loaded\n */\n onDataLoaded?: (data: GitHubUser) => void;\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n /**\n * Callback when loading state changes\n */\n onLoading?: (isLoading: boolean) => void;\n /**\n * Fully custom React renderer. When provided, the package only fetches data\n * and lets you render every pixel yourself.\n */\n render?: (state: GitHubContributionGraphRenderState) => React.ReactNode;\n /**\n * Optional custom loading UI for the default renderer path\n */\n loadingFallback?: React.ReactNode;\n /**\n * Optional custom error UI for the default renderer path\n */\n errorFallback?: React.ReactNode | ((error: Error) => React.ReactNode);\n}\n\nexport interface GitHubContributionGraphRef {\n /**\n * Manually refresh the contribution data\n */\n refresh: () => Promise<void>;\n /**\n * Get the currently loaded data\n */\n getData: () => GitHubUser | null;\n}\n\n/**\n * React component for displaying GitHub contribution graphs\n *\n * @example\n * ```tsx\n * import { GitHubContributionGraph } from 'github-contrib-graph/react';\n * import 'github-contrib-graph/styles.css';\n *\n * function App() {\n * return (\n * <GitHubContributionGraph\n * username=\"octocat\"\n * theme=\"midnight\"\n * onDataLoaded={(data) => console.log('Loaded!', data)}\n * />\n * );\n * }\n * ```\n */\nexport const GitHubContributionGraph = forwardRef<\n GitHubContributionGraphRef,\n GitHubContributionGraphProps\n>((props, ref) => {\n const {\n username,\n apiEndpoint,\n theme = 'default',\n showHeader = true,\n showFooter = true,\n showThumbnail = true,\n showMonthLabels,\n showWeekdayLabels,\n showTooltips,\n dayLabels,\n footerLabels,\n classNames,\n dayClassName,\n dayStyle,\n dayAttributes,\n tooltipFormatter,\n monthLabelFormatter,\n renderDayContents,\n renderHeader,\n renderFooter,\n renderThumbnail,\n className,\n style,\n onDataLoaded,\n onError,\n onLoading,\n render: customRender,\n loadingFallback,\n errorFallback,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const rootClassName = [ROOT_CLASS, classNames?.root, className].filter(Boolean).join(' ');\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = async () => {\n if (!username) {\n setError(new Error('Username is required'));\n setLoading(false);\n return;\n }\n\n setLoading(true);\n onLoading?.(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n onDataLoaded?.(userData);\n } catch (err) {\n const fetchError = err instanceof Error ? err : new Error('Unknown error');\n setError(fetchError);\n onError?.(fetchError);\n } finally {\n setLoading(false);\n onLoading?.(false);\n }\n };\n\n // Fetch data when username or apiEndpoint changes\n useEffect(() => {\n fetchData();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [username, apiEndpoint]);\n\n // Apply theme whenever it changes\n useEffect(() => {\n if (containerRef.current) {\n applyTheme(containerRef.current, theme);\n }\n }, [theme]);\n\n // Render widget when data or options change\n useEffect(() => {\n if (data && containerRef.current && !customRender) {\n renderWidget(containerRef.current, data, username, {\n showHeader,\n showFooter,\n showThumbnail,\n showMonthLabels,\n showWeekdayLabels,\n showTooltips,\n dayLabels,\n footerLabels,\n classNames,\n dayClassName,\n dayStyle,\n dayAttributes,\n tooltipFormatter,\n monthLabelFormatter,\n renderDayContents,\n renderHeader,\n renderFooter,\n renderThumbnail,\n });\n }\n }, [\n data,\n showHeader,\n showFooter,\n showThumbnail,\n showMonthLabels,\n showWeekdayLabels,\n showTooltips,\n dayLabels,\n footerLabels,\n classNames,\n dayClassName,\n dayStyle,\n dayAttributes,\n tooltipFormatter,\n monthLabelFormatter,\n renderDayContents,\n renderHeader,\n renderFooter,\n renderThumbnail,\n username,\n customRender,\n ]);\n\n // Expose ref methods\n useImperativeHandle(ref, () => ({\n refresh: fetchData,\n getData: () => data,\n }));\n\n if (customRender) {\n return (\n <div\n ref={containerRef}\n className={rootClassName}\n style={style}\n data-error={error ? 'true' : undefined}\n >\n {customRender({ username, data, loading, error, refresh: fetchData })}\n </div>\n );\n }\n\n if (loading && loadingFallback) {\n return (\n <div\n ref={containerRef}\n className={rootClassName}\n style={style}\n >\n {loadingFallback}\n </div>\n );\n }\n\n if (error) {\n const renderedError =\n typeof errorFallback === 'function' ? errorFallback(error) : errorFallback;\n\n return (\n <div className={rootClassName} style={style}>\n {renderedError ?? (\n <p style={{ color: '#f85149' }}>Failed to load contribution data.</p>\n )}\n </div>\n );\n }\n\n return (\n <div\n ref={containerRef}\n className={rootClassName}\n style={style}\n data-loading={loading}\n />\n );\n});\n\nGitHubContributionGraph.displayName = 'GitHubContributionGraph';\n","import { useState, useEffect, useCallback } from 'react';\nimport { fetchContributionData } from '../core/api';\nimport type { GitHubUser } from '../core/types';\n\nexport interface UseContributionDataOptions {\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Whether to fetch data automatically on mount\n * @default true\n */\n autoFetch?: boolean;\n}\n\nexport interface UseContributionDataResult {\n /**\n * The fetched user data, null if not loaded\n */\n data: GitHubUser | null;\n /**\n * Whether data is currently being fetched\n */\n loading: boolean;\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n /**\n * Function to manually refetch data\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * React hook for fetching GitHub contribution data\n *\n * @param username - GitHub username\n * @param options - Hook options\n * @returns Object containing data, loading state, error, and refetch function\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { data, loading, error, refetch } = useContributionData('octocat');\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>\n * <button onClick={refetch}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useContributionData(\n username: string,\n options: UseContributionDataOptions = {}\n): UseContributionDataResult {\n const { apiEndpoint, autoFetch = true } = options;\n\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(autoFetch);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!username) {\n setError(new Error('Username is required'));\n return;\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n } finally {\n setLoading(false);\n }\n }, [username, apiEndpoint]);\n\n useEffect(() => {\n if (autoFetch && username) {\n refetch();\n }\n }, [autoFetch, username, refetch]);\n\n return { data, loading, error, refetch };\n}\n"]}
import React from 'react';
import { T as ThemePreset, a as ThemeConfig, G as GitHubUser } from './themes-DbIjuNDH.cjs';
export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, d as THEME_PRESETS, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.cjs';
import { R as RenderOptions, T as ThemePreset, a as ThemeConfig, G as GitHubUser } from './themes-CKoQTTmA.cjs';
export { j as CalendarClassNames, C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, l as DayRenderContext, k as DayStyle, F as FooterLabels, m as FooterRenderContext, H as HeaderRenderContext, d as THEME_PRESETS, n as ThumbnailRenderContext, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-CKoQTTmA.cjs';
interface GitHubContributionGraphProps {
interface GitHubContributionGraphRenderState {
username: string;
data: GitHubUser | null;
loading: boolean;
error: Error | null;
refresh: () => Promise<void>;
}
interface GitHubContributionGraphProps extends RenderOptions {
/**

@@ -53,2 +60,15 @@ * GitHub username to display contributions for

onLoading?: (isLoading: boolean) => void;
/**
* Fully custom React renderer. When provided, the package only fetches data
* and lets you render every pixel yourself.
*/
render?: (state: GitHubContributionGraphRenderState) => React.ReactNode;
/**
* Optional custom loading UI for the default renderer path
*/
loadingFallback?: React.ReactNode;
/**
* Optional custom error UI for the default renderer path
*/
errorFallback?: React.ReactNode | ((error: Error) => React.ReactNode);
}

@@ -70,4 +90,4 @@ interface GitHubContributionGraphRef {

* ```tsx
* import { GitHubContributionGraph } from 'github-contribution-graph/react';
* import 'github-contribution-graph/styles.css';
* import { GitHubContributionGraph } from 'github-contrib-graph/react';
* import 'github-contrib-graph/styles.css';
*

@@ -142,2 +162,2 @@ * function App() {

export { GitHubContributionGraph, type GitHubContributionGraphProps, type GitHubContributionGraphRef, GitHubUser, ThemeConfig, ThemePreset, type UseContributionDataOptions, type UseContributionDataResult, useContributionData };
export { GitHubContributionGraph, type GitHubContributionGraphProps, type GitHubContributionGraphRef, type GitHubContributionGraphRenderState, GitHubUser, RenderOptions, ThemeConfig, ThemePreset, type UseContributionDataOptions, type UseContributionDataResult, useContributionData };
import React from 'react';
import { T as ThemePreset, a as ThemeConfig, G as GitHubUser } from './themes-DbIjuNDH.js';
export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, d as THEME_PRESETS, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.js';
import { R as RenderOptions, T as ThemePreset, a as ThemeConfig, G as GitHubUser } from './themes-CKoQTTmA.js';
export { j as CalendarClassNames, C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, l as DayRenderContext, k as DayStyle, F as FooterLabels, m as FooterRenderContext, H as HeaderRenderContext, d as THEME_PRESETS, n as ThumbnailRenderContext, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-CKoQTTmA.js';
interface GitHubContributionGraphProps {
interface GitHubContributionGraphRenderState {
username: string;
data: GitHubUser | null;
loading: boolean;
error: Error | null;
refresh: () => Promise<void>;
}
interface GitHubContributionGraphProps extends RenderOptions {
/**

@@ -53,2 +60,15 @@ * GitHub username to display contributions for

onLoading?: (isLoading: boolean) => void;
/**
* Fully custom React renderer. When provided, the package only fetches data
* and lets you render every pixel yourself.
*/
render?: (state: GitHubContributionGraphRenderState) => React.ReactNode;
/**
* Optional custom loading UI for the default renderer path
*/
loadingFallback?: React.ReactNode;
/**
* Optional custom error UI for the default renderer path
*/
errorFallback?: React.ReactNode | ((error: Error) => React.ReactNode);
}

@@ -70,4 +90,4 @@ interface GitHubContributionGraphRef {

* ```tsx
* import { GitHubContributionGraph } from 'github-contribution-graph/react';
* import 'github-contribution-graph/styles.css';
* import { GitHubContributionGraph } from 'github-contrib-graph/react';
* import 'github-contrib-graph/styles.css';
*

@@ -142,2 +162,2 @@ * function App() {

export { GitHubContributionGraph, type GitHubContributionGraphProps, type GitHubContributionGraphRef, GitHubUser, ThemeConfig, ThemePreset, type UseContributionDataOptions, type UseContributionDataResult, useContributionData };
export { GitHubContributionGraph, type GitHubContributionGraphProps, type GitHubContributionGraphRef, type GitHubContributionGraphRenderState, GitHubUser, RenderOptions, ThemeConfig, ThemePreset, type UseContributionDataOptions, type UseContributionDataResult, useContributionData };

@@ -1,3 +0,3 @@

import {forwardRef,useRef,useState,useEffect,useImperativeHandle,useCallback}from'react';import {jsx}from'react/jsx-runtime';var T="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",R="https://github.com/iamjr15/github-contribution-graph",U=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],y=["","Mon","","Wed","","Fri",""],h={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function b(t,o=T){if(!t||typeof t!="string")throw new Error("Username is required");let e=`${o}?login=${encodeURIComponent(t.trim())}`,r=new AbortController,l=setTimeout(()=>r.abort(),1e4),n;try{n=await fetch(e,{signal:r.signal});}catch(i){throw clearTimeout(l),i instanceof DOMException&&i.name==="AbortError"?new Error("Request timed out. Please try again."):i}if(clearTimeout(l),!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let a=await n.json();if(!a.user)throw new Error(a.error||"User not found");return a.user}function I(){let t=document.createElement("table");t.className="ghCalendarTable";let o=t.createTHead(),e=t.createTBody(),l=o.insertRow().insertCell();l.style.width="28px";for(let n=0;n<7;n++){let i=e.insertRow().insertCell();if(y[n]){let c=document.createElement("span");c.className="ghCalendarLabel",c.textContent=y[n],i.appendChild(c);}}return {table:t,thead:o,tbody:e}}function O(t,o){for(let e=0;e<o.length-1;e++){let r=o[e].totalWeeks;if(r>=2){let l=t.rows[0].insertCell(),n=document.createElement("span");n.textContent=o[e].name,n.className="ghCalendarLabel",l.appendChild(n),l.colSpan=r;}}}function _(t,o){for(let e of o)for(let r of e.contributionDays){let l=document.createElement("span"),n=new Date(r.date);l.textContent=`${r.contributionCount} contributions on ${n.toDateString()}`;let a=t.rows[r.weekday].insertCell();a.appendChild(l),a.className="ghCalendarDayCell",a.dataset.date=r.date,a.dataset.count=String(r.contributionCount),a.dataset.level=r.contributionLevel;}}function k(){let t=document.createElement("div");return t.className="ghCalendarCard",t}function F(){let t=document.createElement("div");return t.className="ghCalendarCanvas",t}function $(t,o,e){let r=document.createElement("div");r.className="ghCalendarHeader";let l=document.createElement("span");l.textContent=`${t} contributions in the last year`;let n=document.createElement("div"),a=document.createElement("a");a.href=`https://github.com/${encodeURIComponent(o)}`,a.textContent=o;let i=document.createElement("img");return i.src=e,i.alt=`${o}'s avatar`,n.appendChild(a),n.appendChild(i),r.appendChild(l),r.appendChild(n),r}function W(){let t=document.createElement("div");t.className="ghCalendarCardFooter";let o=document.createElement("div");o.className="ghCalendarCardFooterColors";let e=document.createElement("span");e.textContent="Less";let r=document.createElement("span");r.textContent="More",o.appendChild(e);for(let l of U){let n=document.createElement("div");n.className="ghCalendarDayCell",n.dataset.level=l,o.appendChild(n);}return o.appendChild(r),t.appendChild(o),t}function B(){let t=document.createElement("div");t.className="ghThumbNail";let o=document.createElement("a");o.href=R,o.target="_blank",o.rel="noopener noreferrer";let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 98 96"),e.setAttribute("width","18"),e.setAttribute("height","18"),e.style.marginTop="10px",e.style.opacity="0.5",e.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),e.appendChild(r),o.appendChild(e),t.appendChild(o),t}function N(t,o,e,r={}){let{showHeader:l=true,showFooter:n=true,showThumbnail:a=true}=r;t.innerHTML="";let i=o.contributionsCollection.contributionCalendar,{table:c,thead:u,tbody:p}=I();_(p,i.weeks),O(u,i.months);let d=k(),f=F();if(f.appendChild(c),n){let s=W();f.appendChild(s);}if(d.appendChild(f),l){let s=$(i.totalContributions,e,o.avatarUrl);t.appendChild(s);}if(t.appendChild(d),a){let s=B();t.appendChild(s);}}function j(t){return t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}function v(t,o){let e=typeof o=="string"?h[o]:o;e&&(e.bgColor&&t.style.setProperty("--gh-bg-color",e.bgColor),e.textColor&&t.style.setProperty("--gh-text-default-color",e.textColor),e.cellLevel0&&t.style.setProperty("--gh-cell-level0-color",e.cellLevel0),e.cellLevel1&&t.style.setProperty("--gh-cell-level1-color",e.cellLevel1),e.cellLevel2&&t.style.setProperty("--gh-cell-level2-color",e.cellLevel2),e.cellLevel3&&t.style.setProperty("--gh-cell-level3-color",e.cellLevel3),e.cellLevel4&&t.style.setProperty("--gh-cell-level4-color",e.cellLevel4),e.borderColor&&t.style.setProperty("--gh-border-card-color",e.borderColor),e.fontFamily&&t.style.setProperty("--gh-font-default-family",e.fontFamily));}function q(t){let o=typeof t=="string"?h[t]:t;if(!o)return "";let e=[];for(let[r,l]of Object.entries(o))if(l){let n=`--gh-${j(r).replace("color","-color")}`;e.push(`${n}: ${l};`);}return e.join(`
`)}function Q(){return Object.keys(h)}var G=forwardRef((t,o)=>{let{username:e,apiEndpoint:r,theme:l="default",showHeader:n=true,showFooter:a=true,showThumbnail:i=true,className:c,style:u,onDataLoaded:p,onError:d,onLoading:f}=t,s=useRef(null),[C,S]=useState(null),[A,g]=useState(true),[M,E]=useState(null),D=async()=>{if(!e){E(new Error("Username is required")),g(false);return}g(true),f?.(true),E(null);try{let m=await b(e,r);S(m),p?.(m);}catch(m){let P=m instanceof Error?m:new Error("Unknown error");E(P),d?.(P);}finally{g(false),f?.(false);}};return useEffect(()=>{D();},[e,r]),useEffect(()=>{s.current&&v(s.current,l);},[l]),useEffect(()=>{C&&s.current&&N(s.current,C,e,{showHeader:n,showFooter:a,showThumbnail:i});},[C,n,a,i,e]),useImperativeHandle(o,()=>({refresh:D,getData:()=>C})),M?jsx("div",{className:c,style:u,children:jsx("p",{style:{color:"#f85149"},children:"Failed to load contribution data."})}):jsx("div",{ref:s,className:c,style:u,"data-loading":A})});G.displayName="GitHubContributionGraph";function J(t,o={}){let{apiEndpoint:e,autoFetch:r=true}=o,[l,n]=useState(null),[a,i]=useState(r),[c,u]=useState(null),p=useCallback(async()=>{if(!t){u(new Error("Username is required"));return}i(true),u(null);try{let d=await b(t,e);n(d);}catch(d){u(d instanceof Error?d:new Error("Unknown error"));}finally{i(false);}},[t,e]);return useEffect(()=>{r&&t&&p();},[r,t,p]),{data:l,loading:a,error:c,refetch:p}}export{T as DEFAULT_API_ENDPOINT,G as GitHubContributionGraph,h as THEME_PRESETS,v as applyTheme,b as fetchContributionData,q as getThemeCSS,Q as getThemePresets,J as useContributionData};//# sourceMappingURL=react.js.map
import {forwardRef,useRef,useState,useEffect,useImperativeHandle,useCallback}from'react';import {jsx}from'react/jsx-runtime';var U="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",w="ghContributionGraph",P="https://github.com/iamjr15/github-contribution-graph",G=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],Y=["","Mon","","Wed","","Fri",""],y={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};function le(e,t){let o=encodeURIComponent(t);try{let r=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(e,r);return n.searchParams.set("login",t),/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)?n.toString():`${n.pathname}${n.search}${n.hash}`}catch{let r=e.includes("?")?"&":"?";return `${e}${r}login=${o}`}}async function T(e,t=U){if(!e||typeof e!="string"||!e.trim())throw new Error("Username is required");let o=e.trim(),r=le(t,o),n=new AbortController,a=setTimeout(()=>n.abort(),1e4),i;try{i=await fetch(r,{signal:n.signal});}catch(d){throw clearTimeout(a),d instanceof DOMException&&d.name==="AbortError"?new Error("Request timed out. Please try again."):d}if(clearTimeout(a),!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let l=await i.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function f(e,t){return [e,t].filter(Boolean).join(" ")}function C(e,t){t&&e.classList.add(...t.split(/\s+/).filter(Boolean));}function ie(e){return e.dayLabels??Y}function se(e,t){return t.tooltipFormatter?t.tooltipFormatter(e):`${e.day.contributionCount} contributions on ${e.date.toDateString()}`}function de(e){return typeof e=="number"?`${e}px`:e}function ce(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function ue(e,t){return typeof t.dayClassName=="function"?t.dayClassName(e)||void 0:t.dayClassName}function fe(e,t,o){let r=typeof o.dayStyle=="function"?o.dayStyle(t):o.dayStyle;if(r)for(let[n,a]of Object.entries(r))a==null||a===""||e.style.setProperty(ce(n),de(a));}function me(e,t,o){let r=o.dayAttributes?.(t);if(r)for(let[n,a]of Object.entries(r))a==null||a===false||e.setAttribute(n,a===true?"":String(a));}function he(e,t,o){let r=typeof o.renderDayContents=="function",n=r?o.renderDayContents?.(t):void 0;if(typeof n=="string"){e.appendChild(document.createTextNode(n));return}if(n instanceof Node){e.appendChild(n);return}if(!r&&o.showTooltips!==false){let a=document.createElement("span");a.className=f("ghCalendarTooltip",o.classNames?.tooltip),a.textContent=se(t,o),e.appendChild(a);}}function pe(e={}){let t=document.createElement("table");t.className=f("ghCalendarTable",e.classNames?.table);let o=t.createTHead(),r=t.createTBody(),a=o.insertRow().insertCell();a.style.width="28px";let i=ie(e),l=e.showWeekdayLabels!==false;for(let d=0;d<7;d++){let s=r.insertRow().insertCell();if(l&&i[d]){let u=document.createElement("span");u.className=f("ghCalendarLabel",e.classNames?.dayLabel),u.textContent=i[d],s.appendChild(u);}}return {table:t,thead:o,tbody:r}}function be(e,t,o={}){if(o.showMonthLabels!==false)for(let r=0;r<t.length-1;r++){let n=t[r].totalWeeks;if(n>=2){let a=e.rows[0].insertCell(),i=document.createElement("span");i.textContent=o.monthLabelFormatter?o.monthLabelFormatter(t[r],r,t):t[r].name,i.className=f("ghCalendarLabel",o.classNames?.monthLabel),a.appendChild(i),a.colSpan=n;}}}function Ce(e,t,o={},r=""){for(let[n,a]of t.entries())for(let[i,l]of a.contributionDays.entries()){let d=new Date(l.date),c={day:l,week:a,weekIndex:n,dayIndex:i,date:d,username:r},s=e.rows[l.weekday].insertCell();s.className=f(f("ghCalendarDayCell",o.classNames?.dayCell),ue(c,o)),s.dataset.date=l.date,s.dataset.count=String(l.contributionCount),s.dataset.level=l.contributionLevel,s.dataset.week=String(n),s.dataset.weekday=String(l.weekday),fe(s,c,o),me(s,c,o),he(s,c,o);}}function ge(e={}){let t=document.createElement("div");return t.className=f("ghCalendarCard",e.classNames?.card),t}function ye(e={}){let t=document.createElement("div");return t.className=f("ghCalendarCanvas",e.classNames?.canvas),t}function Te(e,t,o,r={},n){if(r.renderHeader&&n){let s=r.renderHeader({user:n,username:t,totalContributions:e});if(s)return s}let a=document.createElement("div");a.className=f("ghCalendarHeader",r.classNames?.header);let i=document.createElement("span");C(i,r.classNames?.total),i.textContent=`${e} contributions in the last year`;let l=document.createElement("div");C(l,r.classNames?.profile);let d=document.createElement("a");d.href=`https://github.com/${encodeURIComponent(t)}`,d.textContent=t,C(d,r.classNames?.profileLink);let c=document.createElement("img");return c.src=o,c.alt=`${t}'s avatar`,C(c,r.classNames?.avatar),l.appendChild(d),l.appendChild(c),a.appendChild(i),a.appendChild(l),a}function Ee(e={}){let t={less:e.footerLabels?.less??"Less",more:e.footerLabels?.more??"More"};if(e.renderFooter){let i=e.renderFooter({levels:G,labels:t});if(i)return i}let o=document.createElement("div");o.className=f("ghCalendarCardFooter",e.classNames?.footer);let r=document.createElement("div");r.className=f("ghCalendarCardFooterColors",e.classNames?.footerLegend);let n=document.createElement("span");n.textContent=t.less;let a=document.createElement("span");a.textContent=t.more,r.appendChild(n);for(let i of G){let l=document.createElement("div");l.className=f("ghCalendarDayCell",e.classNames?.dayCell),l.dataset.level=i,r.appendChild(l);}return r.appendChild(a),o.appendChild(r),o}function Re(e={}){if(e.renderThumbnail){let a=e.renderThumbnail({repoUrl:P});if(a)return a}let t=document.createElement("div");t.className=f("ghThumbNail",e.classNames?.thumbnail);let o=document.createElement("a");o.href=P,o.target="_blank",o.rel="noopener noreferrer",C(o,e.classNames?.thumbnailLink);let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("viewBox","0 0 98 96"),r.setAttribute("width","18"),r.setAttribute("height","18"),r.style.marginTop="10px",r.style.opacity="0.5",r.style.fill="var(--gh-text-default-color, #333)";let n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("fill-rule","evenodd"),n.setAttribute("clip-rule","evenodd"),n.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),r.appendChild(n),o.appendChild(r),t.appendChild(o),t}function J(e,t,o,r={}){let{showHeader:n=true,showFooter:a=true,showThumbnail:i=true}=r;e.classList.add(w),C(e,r.classNames?.root),e.innerHTML="";let l=t.contributionsCollection.contributionCalendar,{table:d,thead:c,tbody:s}=pe(r);Ce(s,l.weeks,r,o),be(c,l.months,r);let u=ge(r),b=ye(r);if(b.appendChild(d),a){let m=Ee(r);b.appendChild(m);}if(u.appendChild(b),n){let m=Te(l.totalContributions,o,t.avatarUrl,r,t);e.appendChild(m);}if(e.appendChild(u),i){let m=Re(r);e.appendChild(m);}}var X={bgColor:"--gh-bg-color",textColor:"--gh-text-default-color",inactiveTextColor:"--gh-text-inactive-color",linkHoverColor:"--gh-link-hover-color",cellLevel0:"--gh-cell-level0-color",cellLevel1:"--gh-cell-level1-color",cellLevel2:"--gh-cell-level2-color",cellLevel3:"--gh-cell-level3-color",cellLevel4:"--gh-cell-level4-color",cellSize:"--gh-cell-size",cellGap:"--gh-cell-gap",cellRadius:"--gh-cell-radius",cellBorderColor:"--gh-cell-border-color",cellOutlineColor:"--gh-cell-outline-color",tooltipBgColor:"--gh-cell-info-bg-color",tooltipTextColor:"--gh-tooltip-text-color",tooltipPadding:"--gh-tooltip-padding",tooltipRadius:"--gh-tooltip-radius",tooltipFontSize:"--gh-tooltip-font-size",borderColor:"--gh-border-card-color",borderWidth:"--gh-border-card-width",cardPadding:"--gh-card-padding",cardPaddingBlock:"--gh-card-padding-block",cardRadius:"--gh-card-radius",canvasPaddingTop:"--gh-canvas-padding-top",canvasMarginInline:"--gh-canvas-margin-inline",headerHeight:"--gh-header-height",headerMarginBottom:"--gh-header-margin-bottom",headerFontSize:"--gh-header-font-size",avatarSize:"--gh-avatar-size",footerPadding:"--gh-footer-padding",footerFontSize:"--gh-footer-font-size",fontFamily:"--gh-font-default-family"};function ee(e){return typeof e=="number"?`${e}px`:e}function k(e,t){let o=typeof t=="string"?y[t]:t;if(o)for(let[r,n]of Object.entries(o)){let a=X[r];a&&n!==void 0&&n!==null&&n!==""&&e.style.setProperty(a,ee(n));}}function Le(e){let t=typeof e=="string"?y[e]:e;if(!t)return "";let o=[];for(let[r,n]of Object.entries(t)){let a=X[r];a&&n!==void 0&&n!==null&&n!==""&&o.push(`${a}: ${ee(n)};`);}return o.join(`
`)}function ve(){return Object.keys(y)}var te=forwardRef((e,t)=>{let{username:o,apiEndpoint:r,theme:n="default",showHeader:a=true,showFooter:i=true,showThumbnail:l=true,showMonthLabels:d,showWeekdayLabels:c,showTooltips:s,dayLabels:u,footerLabels:b,classNames:m,dayClassName:I,dayStyle:_,dayAttributes:$,tooltipFormatter:z,monthLabelFormatter:B,renderDayContents:W,renderHeader:j,renderFooter:V,renderThumbnail:q,className:re,style:R,onDataLoaded:oe,onError:ne,onLoading:Q,render:L,loadingFallback:Z,errorFallback:H}=e,h=useRef(null),v=[w,m?.root,re].filter(Boolean).join(" "),[g,ae]=useState(null),[N,S]=useState(true),[x,D]=useState(null),O=async()=>{if(!o){D(new Error("Username is required")),S(false);return}S(true),Q?.(true),D(null);try{let p=await T(o,r);ae(p),oe?.(p);}catch(p){let K=p instanceof Error?p:new Error("Unknown error");D(K),ne?.(K);}finally{S(false),Q?.(false);}};if(useEffect(()=>{O();},[o,r]),useEffect(()=>{h.current&&k(h.current,n);},[n]),useEffect(()=>{g&&h.current&&!L&&J(h.current,g,o,{showHeader:a,showFooter:i,showThumbnail:l,showMonthLabels:d,showWeekdayLabels:c,showTooltips:s,dayLabels:u,footerLabels:b,classNames:m,dayClassName:I,dayStyle:_,dayAttributes:$,tooltipFormatter:z,monthLabelFormatter:B,renderDayContents:W,renderHeader:j,renderFooter:V,renderThumbnail:q});},[g,a,i,l,d,c,s,u,b,m,I,_,$,z,B,W,j,V,q,o,L]),useImperativeHandle(t,()=>({refresh:O,getData:()=>g})),L)return jsx("div",{ref:h,className:v,style:R,"data-error":x?"true":void 0,children:L({username:o,data:g,loading:N,error:x,refresh:O})});if(N&&Z)return jsx("div",{ref:h,className:v,style:R,children:Z});if(x){let p=typeof H=="function"?H(x):H;return jsx("div",{className:v,style:R,children:p??jsx("p",{style:{color:"#f85149"},children:"Failed to load contribution data."})})}return jsx("div",{ref:h,className:v,style:R,"data-loading":N})});te.displayName="GitHubContributionGraph";function De(e,t={}){let{apiEndpoint:o,autoFetch:r=true}=t,[n,a]=useState(null),[i,l]=useState(r),[d,c]=useState(null),s=useCallback(async()=>{if(!e){c(new Error("Username is required"));return}l(true),c(null);try{let u=await T(e,o);a(u);}catch(u){c(u instanceof Error?u:new Error("Unknown error"));}finally{l(false);}},[e,o]);return useEffect(()=>{r&&e&&s();},[r,e,s]),{data:n,loading:i,error:d,refetch:s}}export{U as DEFAULT_API_ENDPOINT,te as GitHubContributionGraph,y as THEME_PRESETS,k as applyTheme,T as fetchContributionData,Le as getThemeCSS,ve as getThemePresets,De as useContributionData};//# sourceMappingURL=react.js.map
//# sourceMappingURL=react.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/react/GitHubContributionGraph.tsx","../src/react/useContributionData.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","controller","timeoutId","response","error","data","createTable","table","thead","tbody","firstCell","i","cell","label","addMonths","months","totalWeeks","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","link","img","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionGraph","forwardRef","props","ref","className","style","onDataLoaded","onError","onLoading","containerRef","useRef","setData","useState","loading","setLoading","setError","fetchData","userData","err","fetchError","useEffect","useImperativeHandle","jsx","useContributionData","autoFetch","refetch","useCallback"],"mappings":"6HAKO,IAAMA,CAAAA,CAAuB,2DAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,EAAA,CAAI,KAAA,CAAO,GAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,OAAA,CAAS,CACP,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CACF,ECvDA,eAAsBC,CAAA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AY,CACtC,GAAI,CAAC7F,EAAU,CACbkF,CAAAA,CAAS,IAAI,KAAA,CAAM,sBAAsB,CAAC,CAAA,CAC1C,MACF,CAEAD,CAAAA,CAAW,IAAI,EACfC,CAAAA,CAAS,IAAI,EAEb,GAAI,CACF,IAAME,CAAAA,CAAW,MAAMrF,EAAsBC,CAAAA,CAAUC,CAAW,EAClE6E,CAAAA,CAAQM,CAAQ,EAClB,CAAA,MAASC,CAAAA,CAAK,CACZH,CAAAA,CAASG,CAAAA,YAAe,MAAQA,CAAAA,CAAM,IAAI,MAAM,eAAe,CAAC,EAClE,CAAA,OAAE,CACAJ,EAAW,KAAK,EAClB,CACF,CAAA,CAAG,CAACjF,EAAUC,CAAW,CAAC,EAE1B,OAAAsF,SAAAA,CAAU,IAAM,CACVI,CAAAA,EAAa3F,GACf4F,CAAAA,GAEJ,EAAG,CAACD,CAAAA,CAAW3F,EAAU4F,CAAO,CAAC,EAE1B,CAAE,IAAA,CAAArF,EAAM,OAAA,CAAAyE,CAAAA,CAAS,MAAA1E,CAAAA,CAAO,OAAA,CAAAsF,CAAQ,CACzC","file":"react.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n const label = document.createElement('span');\n label.className = 'ghCalendarLabel';\n label.textContent = DAY_LABELS[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import React, {\n useRef,\n useEffect,\n useState,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme } from '../styles/themes';\nimport type { GitHubUser, ThemePreset, ThemeConfig } from '../core/types';\n\nexport interface GitHubContributionGraphProps {\n /**\n * GitHub username to display contributions for\n */\n username: string;\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Theme preset name or custom theme configuration\n */\n theme?: ThemePreset | ThemeConfig;\n /**\n * Whether to show the header with total contributions\n * @default true\n */\n showHeader?: boolean;\n /**\n * Whether to show the footer legend\n * @default true\n */\n showFooter?: boolean;\n /**\n * Whether to show the GitHub thumbnail/attribution\n * @default true\n */\n showThumbnail?: boolean;\n /**\n * Additional CSS class name\n */\n className?: string;\n /**\n * Inline styles\n */\n style?: React.CSSProperties;\n /**\n * Callback when data is successfully loaded\n */\n onDataLoaded?: (data: GitHubUser) => void;\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n /**\n * Callback when loading state changes\n */\n onLoading?: (isLoading: boolean) => void;\n}\n\nexport interface GitHubContributionGraphRef {\n /**\n * Manually refresh the contribution data\n */\n refresh: () => Promise<void>;\n /**\n * Get the currently loaded data\n */\n getData: () => GitHubUser | null;\n}\n\n/**\n * React component for displaying GitHub contribution graphs\n *\n * @example\n * ```tsx\n * import { GitHubContributionGraph } from 'github-contribution-graph/react';\n * import 'github-contribution-graph/styles.css';\n *\n * function App() {\n * return (\n * <GitHubContributionGraph\n * username=\"octocat\"\n * theme=\"midnight\"\n * onDataLoaded={(data) => console.log('Loaded!', data)}\n * />\n * );\n * }\n * ```\n */\nexport const GitHubContributionGraph = forwardRef<\n GitHubContributionGraphRef,\n GitHubContributionGraphProps\n>((props, ref) => {\n const {\n username,\n apiEndpoint,\n theme = 'default',\n showHeader = true,\n showFooter = true,\n showThumbnail = true,\n className,\n style,\n onDataLoaded,\n onError,\n onLoading,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = async () => {\n if (!username) {\n setError(new Error('Username is required'));\n setLoading(false);\n return;\n }\n\n setLoading(true);\n onLoading?.(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n onDataLoaded?.(userData);\n } catch (err) {\n const fetchError = err instanceof Error ? err : new Error('Unknown error');\n setError(fetchError);\n onError?.(fetchError);\n } finally {\n setLoading(false);\n onLoading?.(false);\n }\n };\n\n // Fetch data when username or apiEndpoint changes\n useEffect(() => {\n fetchData();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [username, apiEndpoint]);\n\n // Apply theme whenever it changes\n useEffect(() => {\n if (containerRef.current) {\n applyTheme(containerRef.current, theme);\n }\n }, [theme]);\n\n // Render widget when data or options change\n useEffect(() => {\n if (data && containerRef.current) {\n renderWidget(containerRef.current, data, username, {\n showHeader,\n showFooter,\n showThumbnail,\n });\n }\n }, [data, showHeader, showFooter, showThumbnail, username]);\n\n // Expose ref methods\n useImperativeHandle(ref, () => ({\n refresh: fetchData,\n getData: () => data,\n }));\n\n if (error) {\n return (\n <div className={className} style={style}>\n <p style={{ color: '#f85149' }}>Failed to load contribution data.</p>\n </div>\n );\n }\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={style}\n data-loading={loading}\n />\n );\n});\n\nGitHubContributionGraph.displayName = 'GitHubContributionGraph';\n","import { useState, useEffect, useCallback } from 'react';\nimport { fetchContributionData } from '../core/api';\nimport type { GitHubUser } from '../core/types';\n\nexport interface UseContributionDataOptions {\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Whether to fetch data automatically on mount\n * @default true\n */\n autoFetch?: boolean;\n}\n\nexport interface UseContributionDataResult {\n /**\n * The fetched user data, null if not loaded\n */\n data: GitHubUser | null;\n /**\n * Whether data is currently being fetched\n */\n loading: boolean;\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n /**\n * Function to manually refetch data\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * React hook for fetching GitHub contribution data\n *\n * @param username - GitHub username\n * @param options - Hook options\n * @returns Object containing data, loading state, error, and refetch function\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { data, loading, error, refetch } = useContributionData('octocat');\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>\n * <button onClick={refetch}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useContributionData(\n username: string,\n options: UseContributionDataOptions = {}\n): UseContributionDataResult {\n const { apiEndpoint, autoFetch = true } = options;\n\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(autoFetch);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!username) {\n setError(new Error('Username is required'));\n return;\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n } finally {\n setLoading(false);\n }\n }, [username, apiEndpoint]);\n\n useEffect(() => {\n if (autoFetch && username) {\n refetch();\n }\n }, [autoFetch, username, refetch]);\n\n return { data, loading, error, refetch };\n}\n"]}
{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/react/GitHubContributionGraph.tsx","../src/react/useContributionData.ts"],"names":["DEFAULT_API_ENDPOINT","ROOT_CLASS","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","buildContributionUrl","apiEndpoint","username","encodedUsername","base","url","separator","fetchContributionData","trimmedUsername","controller","timeoutId","response","error","data","mergeClasses","baseClass","customClass","applyCustomClass","element","getDayLabels","options","formatTooltip","context","normalizeInlineStyleValue","value","normalizeStyleProperty","property","letter","resolveDayClassName","applyDayStyle","cell","style","applyDayAttributes","attributes","attribute","appendDayContents","hasCustomRenderer","rendered","tooltip","createTable","table","thead","tbody","firstCell","dayLabels","showWeekdayLabels","i","label","addMonths","months","totalWeeks","addWeeks","weeks","weekIndex","week","dayIndex","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","user","customHeader","header","total","profile","link","img","createFooter","labels","customFooter","footer","colors","less","more","level","createThumbnail","customThumbnail","thumbnail","svg","path","renderWidget","container","showHeader","showFooter","showThumbnail","calendar","THEME_CSS_VARIABLES","normalizeCSSValue","applyTheme","theme","config","key","cssKey","getThemeCSS","cssVars","getThemePresets","GitHubContributionGraph","forwardRef","props","ref","showMonthLabels","showTooltips","footerLabels","classNames","dayClassName","dayStyle","dayAttributes","tooltipFormatter","monthLabelFormatter","renderDayContents","renderHeader","renderFooter","renderThumbnail","className","onDataLoaded","onError","onLoading","customRender","loadingFallback","errorFallback","containerRef","useRef","rootClassName","setData","useState","loading","setLoading","setError","fetchData","userData","err","fetchError","useEffect","useImperativeHandle","jsx","renderedError","useContributionData","autoFetch","refetch","useCallback"],"mappings":"6HAKO,IAAMA,CAAAA,CAAuB,2DAKvBC,CAAAA,CAAa,qBAAA,CAKbC,EAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,iBACA,i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6I,CAAAA,CAAY,IAAK,CAAA,CAAI1H,CAAAA,CAEpC,CAACP,EAAMmH,CAAO,CAAA,CAAIC,QAAAA,CAA4B,IAAI,CAAA,CAClD,CAACC,CAAAA,CAASC,CAAU,CAAA,CAAIF,QAAAA,CAASa,CAAS,CAAA,CAC1C,CAAClI,CAAAA,CAAOwH,CAAQ,CAAA,CAAIH,SAAuB,IAAI,CAAA,CAE/Cc,CAAAA,CAAUC,WAAAA,CAAY,SAAY,CACtC,GAAI,CAAC9I,CAAAA,CAAU,CACbkI,CAAAA,CAAS,IAAI,KAAA,CAAM,sBAAsB,CAAC,CAAA,CAC1C,MACF,CAEAD,CAAAA,CAAW,IAAI,CAAA,CACfC,CAAAA,CAAS,IAAI,CAAA,CAEb,GAAI,CACF,IAAME,CAAAA,CAAW,MAAM/H,CAAAA,CAAsBL,CAAAA,CAAUD,CAAW,CAAA,CAClE+H,CAAAA,CAAQM,CAAQ,EAClB,CAAA,MAASC,CAAAA,CAAK,CACZH,CAAAA,CAASG,CAAAA,YAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,KAAA,CAAM,eAAe,CAAC,EAClE,CAAA,OAAE,CACAJ,CAAAA,CAAW,KAAK,EAClB,CACF,CAAA,CAAG,CAACjI,CAAAA,CAAUD,CAAW,CAAC,CAAA,CAE1B,OAAAwI,SAAAA,CAAU,IAAM,CACVK,CAAAA,EAAa5I,CAAAA,EACf6I,IAEJ,CAAA,CAAG,CAACD,CAAAA,CAAW5I,CAAAA,CAAU6I,CAAO,CAAC,CAAA,CAE1B,CAAE,IAAA,CAAAlI,CAAAA,CAAM,OAAA,CAAAqH,CAAAA,CAAS,KAAA,CAAAtH,CAAAA,CAAO,OAAA,CAAAmI,CAAQ,CACzC","file":"react.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Root class applied to every rendered widget container.\n */\nexport const ROOT_CLASS = 'ghContributionGraph';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Build an API URL while preserving existing query parameters.\n */\nfunction buildContributionUrl(apiEndpoint: string, username: string): string {\n const encodedUsername = encodeURIComponent(username);\n\n try {\n const base =\n typeof window !== 'undefined' && window.location?.origin\n ? window.location.origin\n : 'http://localhost';\n const url = new URL(apiEndpoint, base);\n url.searchParams.set('login', username);\n\n if (!/^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(apiEndpoint)) {\n return `${url.pathname}${url.search}${url.hash}`;\n }\n\n return url.toString();\n } catch {\n const separator = apiEndpoint.includes('?') ? '&' : '?';\n return `${apiEndpoint}${separator}login=${encodedUsername}`;\n }\n}\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string' || !username.trim()) {\n throw new Error('Username is required');\n }\n\n const trimmedUsername = username.trim();\n const url = buildContributionUrl(apiEndpoint, trimmedUsername);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL, ROOT_CLASS } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n DayStyle,\n DayRenderContext,\n FooterRenderContext,\n GitHubUser,\n HeaderRenderContext,\n RenderOptions,\n ThumbnailRenderContext,\n} from './types';\n\nfunction mergeClasses(baseClass: string, customClass?: string): string {\n return [baseClass, customClass].filter(Boolean).join(' ');\n}\n\nfunction applyCustomClass(element: HTMLElement | SVGElement, customClass?: string): void {\n if (customClass) {\n element.classList.add(...customClass.split(/\\s+/).filter(Boolean));\n }\n}\n\nfunction getDayLabels(options: RenderOptions): string[] {\n return options.dayLabels ?? DAY_LABELS;\n}\n\nfunction formatTooltip(context: DayRenderContext, options: RenderOptions): string {\n if (options.tooltipFormatter) {\n return options.tooltipFormatter(context);\n }\n\n return `${context.day.contributionCount} contributions on ${context.date.toDateString()}`;\n}\n\nfunction normalizeInlineStyleValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\nfunction normalizeStyleProperty(property: string): string {\n return property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction resolveDayClassName(context: DayRenderContext, options: RenderOptions): string | undefined {\n if (typeof options.dayClassName === 'function') {\n return options.dayClassName(context) || undefined;\n }\n\n return options.dayClassName;\n}\n\nfunction applyDayStyle(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const style =\n typeof options.dayStyle === 'function' ? options.dayStyle(context) : options.dayStyle;\n\n if (!style) return;\n\n for (const [property, value] of Object.entries(style satisfies DayStyle)) {\n if (value === undefined || value === null || value === '') continue;\n\n cell.style.setProperty(normalizeStyleProperty(property), normalizeInlineStyleValue(value));\n }\n}\n\nfunction applyDayAttributes(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const attributes = options.dayAttributes?.(context);\n if (!attributes) return;\n\n for (const [attribute, value] of Object.entries(attributes)) {\n if (value === undefined || value === null || value === false) continue;\n cell.setAttribute(attribute, value === true ? '' : String(value));\n }\n}\n\nfunction appendDayContents(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const hasCustomRenderer = typeof options.renderDayContents === 'function';\n const rendered = hasCustomRenderer ? options.renderDayContents?.(context) : undefined;\n\n if (typeof rendered === 'string') {\n cell.appendChild(document.createTextNode(rendered));\n return;\n }\n\n if (rendered instanceof Node) {\n cell.appendChild(rendered);\n return;\n }\n\n if (!hasCustomRenderer && options.showTooltips !== false) {\n const tooltip = document.createElement('span');\n tooltip.className = mergeClasses('ghCalendarTooltip', options.classNames?.tooltip);\n tooltip.textContent = formatTooltip(context, options);\n cell.appendChild(tooltip);\n }\n}\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(options: RenderOptions = {}): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = mergeClasses('ghCalendarTable', options.classNames?.table);\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n const dayLabels = getDayLabels(options);\n const showWeekdayLabels = options.showWeekdayLabels !== false;\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (showWeekdayLabels && dayLabels[i]) {\n const label = document.createElement('span');\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.dayLabel);\n label.textContent = dayLabels[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[],\n options: RenderOptions = {}\n): void {\n if (options.showMonthLabels === false) return;\n\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = options.monthLabelFormatter\n ? options.monthLabelFormatter(months[i], i, months)\n : months[i].name;\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.monthLabel);\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[],\n options: RenderOptions = {},\n username = ''\n): void {\n for (const [weekIndex, week] of weeks.entries()) {\n for (const [dayIndex, day] of week.contributionDays.entries()) {\n const date = new Date(day.date);\n const context: DayRenderContext = {\n day,\n week,\n weekIndex,\n dayIndex,\n date,\n username,\n };\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.className = mergeClasses(\n mergeClasses('ghCalendarDayCell', options.classNames?.dayCell),\n resolveDayClassName(context, options)\n );\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n cell.dataset.week = String(weekIndex);\n cell.dataset.weekday = String(day.weekday);\n applyDayStyle(cell, context, options);\n applyDayAttributes(cell, context, options);\n appendDayContents(cell, context, options);\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(options: RenderOptions = {}): HTMLDivElement {\n const card = document.createElement('div');\n card.className = mergeClasses('ghCalendarCard', options.classNames?.card);\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(options: RenderOptions = {}): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = mergeClasses('ghCalendarCanvas', options.classNames?.canvas);\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string,\n options: RenderOptions = {},\n user?: GitHubUser\n): HTMLElement {\n if (options.renderHeader && user) {\n const customHeader = options.renderHeader({\n user,\n username,\n totalContributions,\n } satisfies HeaderRenderContext);\n\n if (customHeader) return customHeader;\n }\n\n const header = document.createElement('div');\n header.className = mergeClasses('ghCalendarHeader', options.classNames?.header);\n\n const total = document.createElement('span');\n applyCustomClass(total, options.classNames?.total);\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n applyCustomClass(profile, options.classNames?.profile);\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n applyCustomClass(link, options.classNames?.profileLink);\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n applyCustomClass(img, options.classNames?.avatar);\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(options: RenderOptions = {}): HTMLElement {\n const labels = {\n less: options.footerLabels?.less ?? 'Less',\n more: options.footerLabels?.more ?? 'More',\n };\n\n if (options.renderFooter) {\n const customFooter = options.renderFooter({\n levels: CONTRIBUTION_LEVELS,\n labels,\n } satisfies FooterRenderContext);\n\n if (customFooter) return customFooter;\n }\n\n const footer = document.createElement('div');\n footer.className = mergeClasses('ghCalendarCardFooter', options.classNames?.footer);\n\n const colors = document.createElement('div');\n colors.className = mergeClasses(\n 'ghCalendarCardFooterColors',\n options.classNames?.footerLegend\n );\n\n const less = document.createElement('span');\n less.textContent = labels.less;\n\n const more = document.createElement('span');\n more.textContent = labels.more;\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = mergeClasses('ghCalendarDayCell', options.classNames?.dayCell);\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(options: RenderOptions = {}): HTMLElement {\n if (options.renderThumbnail) {\n const customThumbnail = options.renderThumbnail({\n repoUrl: REPO_URL,\n } satisfies ThumbnailRenderContext);\n\n if (customThumbnail) return customThumbnail;\n }\n\n const thumbnail = document.createElement('div');\n thumbnail.className = mergeClasses('ghThumbNail', options.classNames?.thumbnail);\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n applyCustomClass(link, options.classNames?.thumbnailLink);\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n container.classList.add(ROOT_CLASS);\n applyCustomClass(container, options.classNames?.root);\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable(options);\n\n addWeeks(tbody, calendar.weeks, options, username);\n addMonths(thead, calendar.months, options);\n\n const card = createCard(options);\n const canvas = createCanvas(options);\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter(options);\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(\n calendar.totalContributions,\n username,\n user.avatarUrl,\n options,\n user\n );\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail(options);\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\nconst THEME_CSS_VARIABLES: Record<keyof ThemeConfig, string> = {\n bgColor: '--gh-bg-color',\n textColor: '--gh-text-default-color',\n inactiveTextColor: '--gh-text-inactive-color',\n linkHoverColor: '--gh-link-hover-color',\n cellLevel0: '--gh-cell-level0-color',\n cellLevel1: '--gh-cell-level1-color',\n cellLevel2: '--gh-cell-level2-color',\n cellLevel3: '--gh-cell-level3-color',\n cellLevel4: '--gh-cell-level4-color',\n cellSize: '--gh-cell-size',\n cellGap: '--gh-cell-gap',\n cellRadius: '--gh-cell-radius',\n cellBorderColor: '--gh-cell-border-color',\n cellOutlineColor: '--gh-cell-outline-color',\n tooltipBgColor: '--gh-cell-info-bg-color',\n tooltipTextColor: '--gh-tooltip-text-color',\n tooltipPadding: '--gh-tooltip-padding',\n tooltipRadius: '--gh-tooltip-radius',\n tooltipFontSize: '--gh-tooltip-font-size',\n borderColor: '--gh-border-card-color',\n borderWidth: '--gh-border-card-width',\n cardPadding: '--gh-card-padding',\n cardPaddingBlock: '--gh-card-padding-block',\n cardRadius: '--gh-card-radius',\n canvasPaddingTop: '--gh-canvas-padding-top',\n canvasMarginInline: '--gh-canvas-margin-inline',\n headerHeight: '--gh-header-height',\n headerMarginBottom: '--gh-header-margin-bottom',\n headerFontSize: '--gh-header-font-size',\n avatarSize: '--gh-avatar-size',\n footerPadding: '--gh-footer-padding',\n footerFontSize: '--gh-footer-font-size',\n fontFamily: '--gh-font-default-family',\n};\n\nfunction normalizeCSSValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n element.style.setProperty(cssKey, normalizeCSSValue(value));\n }\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n cssVars.push(`${cssKey}: ${normalizeCSSValue(value)};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import React, {\n useRef,\n useEffect,\n useState,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { fetchContributionData } from '../core/api';\nimport { ROOT_CLASS } from '../core/constants';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme } from '../styles/themes';\nimport type { GitHubUser, ThemePreset, ThemeConfig, RenderOptions } from '../core/types';\n\nexport interface GitHubContributionGraphRenderState {\n username: string;\n data: GitHubUser | null;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n}\n\nexport interface GitHubContributionGraphProps extends RenderOptions {\n /**\n * GitHub username to display contributions for\n */\n username: string;\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Theme preset name or custom theme configuration\n */\n theme?: ThemePreset | ThemeConfig;\n /**\n * Whether to show the header with total contributions\n * @default true\n */\n showHeader?: boolean;\n /**\n * Whether to show the footer legend\n * @default true\n */\n showFooter?: boolean;\n /**\n * Whether to show the GitHub thumbnail/attribution\n * @default true\n */\n showThumbnail?: boolean;\n /**\n * Additional CSS class name\n */\n className?: string;\n /**\n * Inline styles\n */\n style?: React.CSSProperties;\n /**\n * Callback when data is successfully loaded\n */\n onDataLoaded?: (data: GitHubUser) => void;\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n /**\n * Callback when loading state changes\n */\n onLoading?: (isLoading: boolean) => void;\n /**\n * Fully custom React renderer. When provided, the package only fetches data\n * and lets you render every pixel yourself.\n */\n render?: (state: GitHubContributionGraphRenderState) => React.ReactNode;\n /**\n * Optional custom loading UI for the default renderer path\n */\n loadingFallback?: React.ReactNode;\n /**\n * Optional custom error UI for the default renderer path\n */\n errorFallback?: React.ReactNode | ((error: Error) => React.ReactNode);\n}\n\nexport interface GitHubContributionGraphRef {\n /**\n * Manually refresh the contribution data\n */\n refresh: () => Promise<void>;\n /**\n * Get the currently loaded data\n */\n getData: () => GitHubUser | null;\n}\n\n/**\n * React component for displaying GitHub contribution graphs\n *\n * @example\n * ```tsx\n * import { GitHubContributionGraph } from 'github-contrib-graph/react';\n * import 'github-contrib-graph/styles.css';\n *\n * function App() {\n * return (\n * <GitHubContributionGraph\n * username=\"octocat\"\n * theme=\"midnight\"\n * onDataLoaded={(data) => console.log('Loaded!', data)}\n * />\n * );\n * }\n * ```\n */\nexport const GitHubContributionGraph = forwardRef<\n GitHubContributionGraphRef,\n GitHubContributionGraphProps\n>((props, ref) => {\n const {\n username,\n apiEndpoint,\n theme = 'default',\n showHeader = true,\n showFooter = true,\n showThumbnail = true,\n showMonthLabels,\n showWeekdayLabels,\n showTooltips,\n dayLabels,\n footerLabels,\n classNames,\n dayClassName,\n dayStyle,\n dayAttributes,\n tooltipFormatter,\n monthLabelFormatter,\n renderDayContents,\n renderHeader,\n renderFooter,\n renderThumbnail,\n className,\n style,\n onDataLoaded,\n onError,\n onLoading,\n render: customRender,\n loadingFallback,\n errorFallback,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const rootClassName = [ROOT_CLASS, classNames?.root, className].filter(Boolean).join(' ');\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = async () => {\n if (!username) {\n setError(new Error('Username is required'));\n setLoading(false);\n return;\n }\n\n setLoading(true);\n onLoading?.(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n onDataLoaded?.(userData);\n } catch (err) {\n const fetchError = err instanceof Error ? err : new Error('Unknown error');\n setError(fetchError);\n onError?.(fetchError);\n } finally {\n setLoading(false);\n onLoading?.(false);\n }\n };\n\n // Fetch data when username or apiEndpoint changes\n useEffect(() => {\n fetchData();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [username, apiEndpoint]);\n\n // Apply theme whenever it changes\n useEffect(() => {\n if (containerRef.current) {\n applyTheme(containerRef.current, theme);\n }\n }, [theme]);\n\n // Render widget when data or options change\n useEffect(() => {\n if (data && containerRef.current && !customRender) {\n renderWidget(containerRef.current, data, username, {\n showHeader,\n showFooter,\n showThumbnail,\n showMonthLabels,\n showWeekdayLabels,\n showTooltips,\n dayLabels,\n footerLabels,\n classNames,\n dayClassName,\n dayStyle,\n dayAttributes,\n tooltipFormatter,\n monthLabelFormatter,\n renderDayContents,\n renderHeader,\n renderFooter,\n renderThumbnail,\n });\n }\n }, [\n data,\n showHeader,\n showFooter,\n showThumbnail,\n showMonthLabels,\n showWeekdayLabels,\n showTooltips,\n dayLabels,\n footerLabels,\n classNames,\n dayClassName,\n dayStyle,\n dayAttributes,\n tooltipFormatter,\n monthLabelFormatter,\n renderDayContents,\n renderHeader,\n renderFooter,\n renderThumbnail,\n username,\n customRender,\n ]);\n\n // Expose ref methods\n useImperativeHandle(ref, () => ({\n refresh: fetchData,\n getData: () => data,\n }));\n\n if (customRender) {\n return (\n <div\n ref={containerRef}\n className={rootClassName}\n style={style}\n data-error={error ? 'true' : undefined}\n >\n {customRender({ username, data, loading, error, refresh: fetchData })}\n </div>\n );\n }\n\n if (loading && loadingFallback) {\n return (\n <div\n ref={containerRef}\n className={rootClassName}\n style={style}\n >\n {loadingFallback}\n </div>\n );\n }\n\n if (error) {\n const renderedError =\n typeof errorFallback === 'function' ? errorFallback(error) : errorFallback;\n\n return (\n <div className={rootClassName} style={style}>\n {renderedError ?? (\n <p style={{ color: '#f85149' }}>Failed to load contribution data.</p>\n )}\n </div>\n );\n }\n\n return (\n <div\n ref={containerRef}\n className={rootClassName}\n style={style}\n data-loading={loading}\n />\n );\n});\n\nGitHubContributionGraph.displayName = 'GitHubContributionGraph';\n","import { useState, useEffect, useCallback } from 'react';\nimport { fetchContributionData } from '../core/api';\nimport type { GitHubUser } from '../core/types';\n\nexport interface UseContributionDataOptions {\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Whether to fetch data automatically on mount\n * @default true\n */\n autoFetch?: boolean;\n}\n\nexport interface UseContributionDataResult {\n /**\n * The fetched user data, null if not loaded\n */\n data: GitHubUser | null;\n /**\n * Whether data is currently being fetched\n */\n loading: boolean;\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n /**\n * Function to manually refetch data\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * React hook for fetching GitHub contribution data\n *\n * @param username - GitHub username\n * @param options - Hook options\n * @returns Object containing data, loading state, error, and refetch function\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { data, loading, error, refetch } = useContributionData('octocat');\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>\n * <button onClick={refetch}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useContributionData(\n username: string,\n options: UseContributionDataOptions = {}\n): UseContributionDataResult {\n const { apiEndpoint, autoFetch = true } = options;\n\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(autoFetch);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!username) {\n setError(new Error('Username is required'));\n return;\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n } finally {\n setLoading(false);\n }\n }, [username, apiEndpoint]);\n\n useEffect(() => {\n if (autoFetch && username) {\n refetch();\n }\n }, [autoFetch, username, refetch]);\n\n return { data, loading, error, refetch };\n}\n"]}

@@ -1,3 +0,3 @@

'use strict';var p="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",T="https://github.com/iamjr15/github-contribution-graph",E=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],f=["","Mon","","Wed","","Fri",""],d={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function u(o,e=p){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=new AbortController,i=setTimeout(()=>r.abort(),1e4),n;try{n=await fetch(t,{signal:r.signal});}catch(a){throw clearTimeout(i),a instanceof DOMException&&a.name==="AbortError"?new Error("Request timed out. Please try again."):a}if(clearTimeout(i),!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let l=await n.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),i=e.insertRow().insertCell();i.style.width="28px";for(let n=0;n<7;n++){let a=t.insertRow().insertCell();if(f[n]){let s=document.createElement("span");s.className="ghCalendarLabel",s.textContent=f[n],a.appendChild(s);}}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let i=o.rows[0].insertCell(),n=document.createElement("span");n.textContent=e[t].name,n.className="ghCalendarLabel",i.appendChild(n),i.colSpan=r;}}}function x(o,e){for(let t of e)for(let r of t.contributionDays){let i=document.createElement("span"),n=new Date(r.date);i.textContent=`${r.contributionCount} contributions on ${n.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(i),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function H(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let i=document.createElement("span");i.textContent=`${o} contributions in the last year`;let n=document.createElement("div"),l=document.createElement("a");l.href=`https://github.com/${encodeURIComponent(e)}`,l.textContent=e;let a=document.createElement("img");return a.src=t,a.alt=`${e}'s avatar`,n.appendChild(l),n.appendChild(a),r.appendChild(i),r.appendChild(n),r}function R(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let i of E){let n=document.createElement("div");n.className="ghCalendarDayCell",n.dataset.level=i,e.appendChild(n);}return e.appendChild(r),o.appendChild(e),o}function N(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=T,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.style.marginTop="10px",t.style.opacity="0.5",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function m(o,e,t,r={}){let{showHeader:i=true,showFooter:n=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:s,thead:v,tbody:y}=L();x(y,a.weeks),w(v,a.months);let b=H(),h=P();if(h.appendChild(s),n){let c=R();h.appendChild(c);}if(b.appendChild(h),i){let c=M(a.totalContributions,t,e.avatarUrl);o.appendChild(c);}if(o.appendChild(b),l){let c=N();o.appendChild(c);}}function D(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function C(o,e){let t=typeof e=="string"?d[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function S(o){let e=typeof o=="string"?d[o]:o;if(!e)return "";let t=[];for(let[r,i]of Object.entries(e))if(i){let n=`--gh-${D(r).replace("color","-color")}`;t.push(`${n}: ${i};`);}return t.join(`
`)}function U(){return Object.keys(d)}var g=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container);}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e);}async render(){this.config.theme&&C(this.container,this.config.theme),this.showLoading();try{this.data=await u(this.config.username,this.config.apiEndpoint),m(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};exports.DEFAULT_API_ENDPOINT=p;exports.GitHubContributionWidget=g;exports.THEME_PRESETS=d;exports.applyTheme=C;exports.fetchContributionData=u;exports.getThemeCSS=S;exports.getThemePresets=U;exports.renderWidget=m;//# sourceMappingURL=vanilla.cjs.map
'use strict';var b="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",g="ghContributionGraph",y="https://github.com/iamjr15/github-contribution-graph",T=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],R=["","Mon","","Wed","","Fri",""],C={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};function S(t,e){let r=encodeURIComponent(e);try{let n=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",o=new URL(t,n);return o.searchParams.set("login",e),/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t)?o.toString():`${o.pathname}${o.search}${o.hash}`}catch{let n=t.includes("?")?"&":"?";return `${t}${n}login=${r}`}}async function L(t,e=b){if(!t||typeof t!="string"||!t.trim())throw new Error("Username is required");let r=t.trim(),n=S(e,r),o=new AbortController,a=setTimeout(()=>o.abort(),1e4),l;try{l=await fetch(n,{signal:o.signal});}catch(s){throw clearTimeout(a),s instanceof DOMException&&s.name==="AbortError"?new Error("Request timed out. Please try again."):s}if(clearTimeout(a),!l.ok)throw new Error(`HTTP error! status: ${l.status}`);let i=await l.json();if(!i.user)throw new Error(i.error||"User not found");return i.user}function c(t,e){return [t,e].filter(Boolean).join(" ")}function f(t,e){e&&t.classList.add(...e.split(/\s+/).filter(Boolean));}function N(t){return t.dayLabels??R}function D(t,e){return e.tooltipFormatter?e.tooltipFormatter(t):`${t.day.contributionCount} contributions on ${t.date.toDateString()}`}function O(t){return typeof t=="number"?`${t}px`:t}function M(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function P(t,e){return typeof e.dayClassName=="function"?e.dayClassName(t)||void 0:e.dayClassName}function A(t,e,r){let n=typeof r.dayStyle=="function"?r.dayStyle(e):r.dayStyle;if(n)for(let[o,a]of Object.entries(n))a==null||a===""||t.style.setProperty(M(o),O(a));}function U(t,e,r){let n=r.dayAttributes?.(e);if(n)for(let[o,a]of Object.entries(n))a==null||a===false||t.setAttribute(o,a===true?"":String(a));}function k(t,e,r){let n=typeof r.renderDayContents=="function",o=n?r.renderDayContents?.(e):void 0;if(typeof o=="string"){t.appendChild(document.createTextNode(o));return}if(o instanceof Node){t.appendChild(o);return}if(!n&&r.showTooltips!==false){let a=document.createElement("span");a.className=c("ghCalendarTooltip",r.classNames?.tooltip),a.textContent=D(e,r),t.appendChild(a);}}function I(t={}){let e=document.createElement("table");e.className=c("ghCalendarTable",t.classNames?.table);let r=e.createTHead(),n=e.createTBody(),a=r.insertRow().insertCell();a.style.width="28px";let l=N(t),i=t.showWeekdayLabels!==false;for(let s=0;s<7;s++){let d=n.insertRow().insertCell();if(i&&l[s]){let u=document.createElement("span");u.className=c("ghCalendarLabel",t.classNames?.dayLabel),u.textContent=l[s],d.appendChild(u);}}return {table:e,thead:r,tbody:n}}function F(t,e,r={}){if(r.showMonthLabels!==false)for(let n=0;n<e.length-1;n++){let o=e[n].totalWeeks;if(o>=2){let a=t.rows[0].insertCell(),l=document.createElement("span");l.textContent=r.monthLabelFormatter?r.monthLabelFormatter(e[n],n,e):e[n].name,l.className=c("ghCalendarLabel",r.classNames?.monthLabel),a.appendChild(l),a.colSpan=o;}}}function _(t,e,r={},n=""){for(let[o,a]of e.entries())for(let[l,i]of a.contributionDays.entries()){let s=new Date(i.date),h={day:i,week:a,weekIndex:o,dayIndex:l,date:s,username:n},d=t.rows[i.weekday].insertCell();d.className=c(c("ghCalendarDayCell",r.classNames?.dayCell),P(h,r)),d.dataset.date=i.date,d.dataset.count=String(i.contributionCount),d.dataset.level=i.contributionLevel,d.dataset.week=String(o),d.dataset.weekday=String(i.weekday),A(d,h,r),U(d,h,r),k(d,h,r);}}function G(t={}){let e=document.createElement("div");return e.className=c("ghCalendarCard",t.classNames?.card),e}function $(t={}){let e=document.createElement("div");return e.className=c("ghCalendarCanvas",t.classNames?.canvas),e}function z(t,e,r,n={},o){if(n.renderHeader&&o){let d=n.renderHeader({user:o,username:e,totalContributions:t});if(d)return d}let a=document.createElement("div");a.className=c("ghCalendarHeader",n.classNames?.header);let l=document.createElement("span");f(l,n.classNames?.total),l.textContent=`${t} contributions in the last year`;let i=document.createElement("div");f(i,n.classNames?.profile);let s=document.createElement("a");s.href=`https://github.com/${encodeURIComponent(e)}`,s.textContent=e,f(s,n.classNames?.profileLink);let h=document.createElement("img");return h.src=r,h.alt=`${e}'s avatar`,f(h,n.classNames?.avatar),i.appendChild(s),i.appendChild(h),a.appendChild(l),a.appendChild(i),a}function B(t={}){let e={less:t.footerLabels?.less??"Less",more:t.footerLabels?.more??"More"};if(t.renderFooter){let l=t.renderFooter({levels:T,labels:e});if(l)return l}let r=document.createElement("div");r.className=c("ghCalendarCardFooter",t.classNames?.footer);let n=document.createElement("div");n.className=c("ghCalendarCardFooterColors",t.classNames?.footerLegend);let o=document.createElement("span");o.textContent=e.less;let a=document.createElement("span");a.textContent=e.more,n.appendChild(o);for(let l of T){let i=document.createElement("div");i.className=c("ghCalendarDayCell",t.classNames?.dayCell),i.dataset.level=l,n.appendChild(i);}return n.appendChild(a),r.appendChild(n),r}function W(t={}){if(t.renderThumbnail){let a=t.renderThumbnail({repoUrl:y});if(a)return a}let e=document.createElement("div");e.className=c("ghThumbNail",t.classNames?.thumbnail);let r=document.createElement("a");r.href=y,r.target="_blank",r.rel="noopener noreferrer",f(r,t.classNames?.thumbnailLink);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 98 96"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.style.marginTop="10px",n.style.opacity="0.5",n.style.fill="var(--gh-text-default-color, #333)";let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),n.appendChild(o),r.appendChild(n),e.appendChild(r),e}function E(t,e,r,n={}){let{showHeader:o=true,showFooter:a=true,showThumbnail:l=true}=n;t.classList.add(g),f(t,n.classNames?.root),t.innerHTML="";let i=e.contributionsCollection.contributionCalendar,{table:s,thead:h,tbody:d}=I(n);_(d,i.weeks,n,r),F(h,i.months,n);let u=G(n),p=$(n);if(p.appendChild(s),a){let m=B(n);p.appendChild(m);}if(u.appendChild(p),o){let m=z(i.totalContributions,r,e.avatarUrl,n,e);t.appendChild(m);}if(t.appendChild(u),l){let m=W(n);t.appendChild(m);}}var w={bgColor:"--gh-bg-color",textColor:"--gh-text-default-color",inactiveTextColor:"--gh-text-inactive-color",linkHoverColor:"--gh-link-hover-color",cellLevel0:"--gh-cell-level0-color",cellLevel1:"--gh-cell-level1-color",cellLevel2:"--gh-cell-level2-color",cellLevel3:"--gh-cell-level3-color",cellLevel4:"--gh-cell-level4-color",cellSize:"--gh-cell-size",cellGap:"--gh-cell-gap",cellRadius:"--gh-cell-radius",cellBorderColor:"--gh-cell-border-color",cellOutlineColor:"--gh-cell-outline-color",tooltipBgColor:"--gh-cell-info-bg-color",tooltipTextColor:"--gh-tooltip-text-color",tooltipPadding:"--gh-tooltip-padding",tooltipRadius:"--gh-tooltip-radius",tooltipFontSize:"--gh-tooltip-font-size",borderColor:"--gh-border-card-color",borderWidth:"--gh-border-card-width",cardPadding:"--gh-card-padding",cardPaddingBlock:"--gh-card-padding-block",cardRadius:"--gh-card-radius",canvasPaddingTop:"--gh-canvas-padding-top",canvasMarginInline:"--gh-canvas-margin-inline",headerHeight:"--gh-header-height",headerMarginBottom:"--gh-header-margin-bottom",headerFontSize:"--gh-header-font-size",avatarSize:"--gh-avatar-size",footerPadding:"--gh-footer-padding",footerFontSize:"--gh-footer-font-size",fontFamily:"--gh-font-default-family"};function H(t){return typeof t=="number"?`${t}px`:t}function v(t,e){let r=typeof e=="string"?C[e]:e;if(r)for(let[n,o]of Object.entries(r)){let a=w[n];a&&o!==void 0&&o!==null&&o!==""&&t.style.setProperty(a,H(o));}}function j(t){let e=typeof t=="string"?C[t]:t;if(!e)return "";let r=[];for(let[n,o]of Object.entries(e)){let a=w[n];a&&o!==void 0&&o!==null&&o!==""&&r.push(`${a}: ${H(o)};`);}return r.join(`
`)}function V(){return Object.keys(C)}var x=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container),this.container.classList.add(g);}resolveContainer(e){if(typeof e=="string"){let n=document.querySelector(e);if(!n)throw new Error(`Container not found: ${e}`);return n}if(e instanceof HTMLElement)return e;let r=document.getElementById("gh");if(!r)throw new Error('No container found. Specify container in config or add element with id="gh"');return r}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e);}async render(){this.config.theme&&v(this.container,this.config.theme),this.showLoading();try{this.data=await L(this.config.username,this.config.apiEndpoint),E(this.container,this.data,this.config.username,this.config),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container),this.container.classList.add(g)),this.render()}};exports.DEFAULT_API_ENDPOINT=b;exports.GitHubContributionWidget=x;exports.THEME_PRESETS=C;exports.applyTheme=v;exports.fetchContributionData=L;exports.getThemeCSS=j;exports.getThemePresets=V;exports.renderWidget=E;//# sourceMappingURL=vanilla.cjs.map
//# sourceMappingURL=vanilla.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","controller","timeoutId","response","error","data","createTable","table","thead","tbody","firstCell","i","cell","label","addMonths","months","totalWeeks","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","link","img","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","loader"],"mappings":"aAKO,IAAMA,CAAAA,CAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,UACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,OAAA,CAAS,CACP,O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types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n const label = document.createElement('span');\n label.className = 'ghCalendarLabel';\n label.textContent = DAY_LABELS[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]}
{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","ROOT_CLASS","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","buildContributionUrl","apiEndpoint","username","encodedUsername","base","url","separator","fetchContributionData","trimmedUsername","controller","timeoutId","response","error","data","mergeClasses","baseClass","customClass","applyCustomClass","element","getDayLabels","options","formatTooltip","context","normalizeInlineStyleValue","value","normalizeStyleProperty","property","letter","resolveDayClassName","applyDayStyle","cell","style","applyDayAttributes","attributes","attribute","appendDayContents","hasCustomRenderer","rendered","tooltip","createTable","table","thead","tbody","firstCell","dayLabels","showWeekdayLabels","i","label","addMonths","months","totalWeeks","addWeeks","weeks","weekIndex","week","dayIndex","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","user","customHeader","header","total","profile","link","img","createFooter","labels","customFooter","footer","colors","less","more","level","createThumbnail","customThumbnail","thumbnail","svg","path","renderWidget","container","showHeader","showFooter","showThumbnail","calendar","THEME_CSS_VARIABLES","normalizeCSSValue","applyTheme","theme","config","key","cssKey","getThemeCSS","cssVars","getThemePresets","GitHubContributionWidget","el","loader"],"mappings":"aAKO,IAAMA,CAAAA,CAAuB,2DAKvBC,CAAAA,CAAa,qBAAA,CAKbC,EAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,kBACA,gBAAA,CACA,iBACF,EAKaC,CAAAA,CAAa,CAAC,GAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,EAKjDC,CAAAA,CAAkD,CAC7D,QAAS,CACP,OAAA,CAAS,UACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,WAAY,SAAA,CACZ,UAAA,CAAY,UACZ,WAAA,CAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CA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AK,WAAA,EAAY,CACjB,GAAI,CACF,IAAA,CAAK,IAAA,CAAO,MAAMtF,CAAAA,CAChB,IAAA,CAAK,MAAA,CAAO,QAAA,CACZ,IAAA,CAAK,MAAA,CAAO,WACd,CAAA,CAEA8E,CAAAA,CAAa,IAAA,CAAK,UAAW,IAAA,CAAK,IAAA,CAAM,IAAA,CAAK,MAAA,CAAO,QAAA,CAAU,IAAA,CAAK,MAAM,CAAA,CAEzE,IAAA,CAAK,MAAA,CAAO,YAAA,GAAe,IAAA,CAAK,IAAI,EACtC,CAAA,MAASzE,CAAAA,CAAO,CACd,IAAA,CAAK,SAAA,CAAU,SAAA,CACb,kEAAA,CACF,IAAA,CAAK,MAAA,CAAO,OAAA,GACVA,CAAAA,YAAiB,KAAA,CAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,OAAA,EAAyB,CAC7B,OAAO,IAAA,CAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,OAAA,EAAgB,CACd,IAAA,CAAK,SAAA,CAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOmF,EAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,CAAAA,CAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CACvD,IAAA,CAAK,SAAA,CAAU,SAAA,CAAU,GAAA,CAAIpG,CAAU,CAAA,CAAA,CAGlC,IAAA,CAAK,MAAA,EACd,CACF","file":"vanilla.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Root class applied to every rendered widget container.\n */\nexport const ROOT_CLASS = 'ghContributionGraph';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Build an API URL while preserving existing query parameters.\n */\nfunction buildContributionUrl(apiEndpoint: string, username: string): string {\n const encodedUsername = encodeURIComponent(username);\n\n try {\n const base =\n typeof window !== 'undefined' && window.location?.origin\n ? window.location.origin\n : 'http://localhost';\n const url = new URL(apiEndpoint, base);\n url.searchParams.set('login', username);\n\n if (!/^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(apiEndpoint)) {\n return `${url.pathname}${url.search}${url.hash}`;\n }\n\n return url.toString();\n } catch {\n const separator = apiEndpoint.includes('?') ? '&' : '?';\n return `${apiEndpoint}${separator}login=${encodedUsername}`;\n }\n}\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string' || !username.trim()) {\n throw new Error('Username is required');\n }\n\n const trimmedUsername = username.trim();\n const url = buildContributionUrl(apiEndpoint, trimmedUsername);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL, ROOT_CLASS } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n DayStyle,\n DayRenderContext,\n FooterRenderContext,\n GitHubUser,\n HeaderRenderContext,\n RenderOptions,\n ThumbnailRenderContext,\n} from './types';\n\nfunction mergeClasses(baseClass: string, customClass?: string): string {\n return [baseClass, customClass].filter(Boolean).join(' ');\n}\n\nfunction applyCustomClass(element: HTMLElement | SVGElement, customClass?: string): void {\n if (customClass) {\n element.classList.add(...customClass.split(/\\s+/).filter(Boolean));\n }\n}\n\nfunction getDayLabels(options: RenderOptions): string[] {\n return options.dayLabels ?? DAY_LABELS;\n}\n\nfunction formatTooltip(context: DayRenderContext, options: RenderOptions): string {\n if (options.tooltipFormatter) {\n return options.tooltipFormatter(context);\n }\n\n return `${context.day.contributionCount} contributions on ${context.date.toDateString()}`;\n}\n\nfunction normalizeInlineStyleValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\nfunction normalizeStyleProperty(property: string): string {\n return property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction resolveDayClassName(context: DayRenderContext, options: RenderOptions): string | undefined {\n if (typeof options.dayClassName === 'function') {\n return options.dayClassName(context) || undefined;\n }\n\n return options.dayClassName;\n}\n\nfunction applyDayStyle(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const style =\n typeof options.dayStyle === 'function' ? options.dayStyle(context) : options.dayStyle;\n\n if (!style) return;\n\n for (const [property, value] of Object.entries(style satisfies DayStyle)) {\n if (value === undefined || value === null || value === '') continue;\n\n cell.style.setProperty(normalizeStyleProperty(property), normalizeInlineStyleValue(value));\n }\n}\n\nfunction applyDayAttributes(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const attributes = options.dayAttributes?.(context);\n if (!attributes) return;\n\n for (const [attribute, value] of Object.entries(attributes)) {\n if (value === undefined || value === null || value === false) continue;\n cell.setAttribute(attribute, value === true ? '' : String(value));\n }\n}\n\nfunction appendDayContents(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const hasCustomRenderer = typeof options.renderDayContents === 'function';\n const rendered = hasCustomRenderer ? options.renderDayContents?.(context) : undefined;\n\n if (typeof rendered === 'string') {\n cell.appendChild(document.createTextNode(rendered));\n return;\n }\n\n if (rendered instanceof Node) {\n cell.appendChild(rendered);\n return;\n }\n\n if (!hasCustomRenderer && options.showTooltips !== false) {\n const tooltip = document.createElement('span');\n tooltip.className = mergeClasses('ghCalendarTooltip', options.classNames?.tooltip);\n tooltip.textContent = formatTooltip(context, options);\n cell.appendChild(tooltip);\n }\n}\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(options: RenderOptions = {}): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = mergeClasses('ghCalendarTable', options.classNames?.table);\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n const dayLabels = getDayLabels(options);\n const showWeekdayLabels = options.showWeekdayLabels !== false;\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (showWeekdayLabels && dayLabels[i]) {\n const label = document.createElement('span');\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.dayLabel);\n label.textContent = dayLabels[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[],\n options: RenderOptions = {}\n): void {\n if (options.showMonthLabels === false) return;\n\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = options.monthLabelFormatter\n ? options.monthLabelFormatter(months[i], i, months)\n : months[i].name;\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.monthLabel);\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[],\n options: RenderOptions = {},\n username = ''\n): void {\n for (const [weekIndex, week] of weeks.entries()) {\n for (const [dayIndex, day] of week.contributionDays.entries()) {\n const date = new Date(day.date);\n const context: DayRenderContext = {\n day,\n week,\n weekIndex,\n dayIndex,\n date,\n username,\n };\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.className = mergeClasses(\n mergeClasses('ghCalendarDayCell', options.classNames?.dayCell),\n resolveDayClassName(context, options)\n );\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n cell.dataset.week = String(weekIndex);\n cell.dataset.weekday = String(day.weekday);\n applyDayStyle(cell, context, options);\n applyDayAttributes(cell, context, options);\n appendDayContents(cell, context, options);\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(options: RenderOptions = {}): HTMLDivElement {\n const card = document.createElement('div');\n card.className = mergeClasses('ghCalendarCard', options.classNames?.card);\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(options: RenderOptions = {}): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = mergeClasses('ghCalendarCanvas', options.classNames?.canvas);\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string,\n options: RenderOptions = {},\n user?: GitHubUser\n): HTMLElement {\n if (options.renderHeader && user) {\n const customHeader = options.renderHeader({\n user,\n username,\n totalContributions,\n } satisfies HeaderRenderContext);\n\n if (customHeader) return customHeader;\n }\n\n const header = document.createElement('div');\n header.className = mergeClasses('ghCalendarHeader', options.classNames?.header);\n\n const total = document.createElement('span');\n applyCustomClass(total, options.classNames?.total);\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n applyCustomClass(profile, options.classNames?.profile);\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n applyCustomClass(link, options.classNames?.profileLink);\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n applyCustomClass(img, options.classNames?.avatar);\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(options: RenderOptions = {}): HTMLElement {\n const labels = {\n less: options.footerLabels?.less ?? 'Less',\n more: options.footerLabels?.more ?? 'More',\n };\n\n if (options.renderFooter) {\n const customFooter = options.renderFooter({\n levels: CONTRIBUTION_LEVELS,\n labels,\n } satisfies FooterRenderContext);\n\n if (customFooter) return customFooter;\n }\n\n const footer = document.createElement('div');\n footer.className = mergeClasses('ghCalendarCardFooter', options.classNames?.footer);\n\n const colors = document.createElement('div');\n colors.className = mergeClasses(\n 'ghCalendarCardFooterColors',\n options.classNames?.footerLegend\n );\n\n const less = document.createElement('span');\n less.textContent = labels.less;\n\n const more = document.createElement('span');\n more.textContent = labels.more;\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = mergeClasses('ghCalendarDayCell', options.classNames?.dayCell);\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(options: RenderOptions = {}): HTMLElement {\n if (options.renderThumbnail) {\n const customThumbnail = options.renderThumbnail({\n repoUrl: REPO_URL,\n } satisfies ThumbnailRenderContext);\n\n if (customThumbnail) return customThumbnail;\n }\n\n const thumbnail = document.createElement('div');\n thumbnail.className = mergeClasses('ghThumbNail', options.classNames?.thumbnail);\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n applyCustomClass(link, options.classNames?.thumbnailLink);\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n container.classList.add(ROOT_CLASS);\n applyCustomClass(container, options.classNames?.root);\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable(options);\n\n addWeeks(tbody, calendar.weeks, options, username);\n addMonths(thead, calendar.months, options);\n\n const card = createCard(options);\n const canvas = createCanvas(options);\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter(options);\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(\n calendar.totalContributions,\n username,\n user.avatarUrl,\n options,\n user\n );\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail(options);\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\nconst THEME_CSS_VARIABLES: Record<keyof ThemeConfig, string> = {\n bgColor: '--gh-bg-color',\n textColor: '--gh-text-default-color',\n inactiveTextColor: '--gh-text-inactive-color',\n linkHoverColor: '--gh-link-hover-color',\n cellLevel0: '--gh-cell-level0-color',\n cellLevel1: '--gh-cell-level1-color',\n cellLevel2: '--gh-cell-level2-color',\n cellLevel3: '--gh-cell-level3-color',\n cellLevel4: '--gh-cell-level4-color',\n cellSize: '--gh-cell-size',\n cellGap: '--gh-cell-gap',\n cellRadius: '--gh-cell-radius',\n cellBorderColor: '--gh-cell-border-color',\n cellOutlineColor: '--gh-cell-outline-color',\n tooltipBgColor: '--gh-cell-info-bg-color',\n tooltipTextColor: '--gh-tooltip-text-color',\n tooltipPadding: '--gh-tooltip-padding',\n tooltipRadius: '--gh-tooltip-radius',\n tooltipFontSize: '--gh-tooltip-font-size',\n borderColor: '--gh-border-card-color',\n borderWidth: '--gh-border-card-width',\n cardPadding: '--gh-card-padding',\n cardPaddingBlock: '--gh-card-padding-block',\n cardRadius: '--gh-card-radius',\n canvasPaddingTop: '--gh-canvas-padding-top',\n canvasMarginInline: '--gh-canvas-margin-inline',\n headerHeight: '--gh-header-height',\n headerMarginBottom: '--gh-header-margin-bottom',\n headerFontSize: '--gh-header-font-size',\n avatarSize: '--gh-avatar-size',\n footerPadding: '--gh-footer-padding',\n footerFontSize: '--gh-footer-font-size',\n fontFamily: '--gh-font-default-family',\n};\n\nfunction normalizeCSSValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n element.style.setProperty(cssKey, normalizeCSSValue(value));\n }\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n cssVars.push(`${cssKey}: ${normalizeCSSValue(value)};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { ROOT_CLASS } from '../core/constants';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, this.config);\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n return this.render();\n }\n}\n"]}
export { GitHubContributionWidget, renderWidget } from './index.cjs';
export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, j as GitHubContributionGraphConfig, G as GitHubUser, R as RenderOptions, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.cjs';
export { j as CalendarClassNames, C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, l as DayRenderContext, k as DayStyle, F as FooterLabels, m as FooterRenderContext, o as GitHubContributionGraphConfig, G as GitHubUser, H as HeaderRenderContext, R as RenderOptions, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, n as ThumbnailRenderContext, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-CKoQTTmA.cjs';
export { GitHubContributionWidget, renderWidget } from './index.js';
export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, j as GitHubContributionGraphConfig, G as GitHubUser, R as RenderOptions, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.js';
export { j as CalendarClassNames, C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, l as DayRenderContext, k as DayStyle, F as FooterLabels, m as FooterRenderContext, o as GitHubContributionGraphConfig, G as GitHubUser, H as HeaderRenderContext, R as RenderOptions, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, n as ThumbnailRenderContext, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-CKoQTTmA.js';

@@ -1,3 +0,3 @@

var p="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",T="https://github.com/iamjr15/github-contribution-graph",E=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],f=["","Mon","","Wed","","Fri",""],d={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function u(o,e=p){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=new AbortController,i=setTimeout(()=>r.abort(),1e4),n;try{n=await fetch(t,{signal:r.signal});}catch(a){throw clearTimeout(i),a instanceof DOMException&&a.name==="AbortError"?new Error("Request timed out. Please try again."):a}if(clearTimeout(i),!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let l=await n.json();if(!l.user)throw new Error(l.error||"User not found");return l.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),i=e.insertRow().insertCell();i.style.width="28px";for(let n=0;n<7;n++){let a=t.insertRow().insertCell();if(f[n]){let s=document.createElement("span");s.className="ghCalendarLabel",s.textContent=f[n],a.appendChild(s);}}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let i=o.rows[0].insertCell(),n=document.createElement("span");n.textContent=e[t].name,n.className="ghCalendarLabel",i.appendChild(n),i.colSpan=r;}}}function x(o,e){for(let t of e)for(let r of t.contributionDays){let i=document.createElement("span"),n=new Date(r.date);i.textContent=`${r.contributionCount} contributions on ${n.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(i),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function H(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let i=document.createElement("span");i.textContent=`${o} contributions in the last year`;let n=document.createElement("div"),l=document.createElement("a");l.href=`https://github.com/${encodeURIComponent(e)}`,l.textContent=e;let a=document.createElement("img");return a.src=t,a.alt=`${e}'s avatar`,n.appendChild(l),n.appendChild(a),r.appendChild(i),r.appendChild(n),r}function R(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let i of E){let n=document.createElement("div");n.className="ghCalendarDayCell",n.dataset.level=i,e.appendChild(n);}return e.appendChild(r),o.appendChild(e),o}function N(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=T,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.style.marginTop="10px",t.style.opacity="0.5",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function m(o,e,t,r={}){let{showHeader:i=true,showFooter:n=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:s,thead:v,tbody:y}=L();x(y,a.weeks),w(v,a.months);let b=H(),h=P();if(h.appendChild(s),n){let c=R();h.appendChild(c);}if(b.appendChild(h),i){let c=M(a.totalContributions,t,e.avatarUrl);o.appendChild(c);}if(o.appendChild(b),l){let c=N();o.appendChild(c);}}function D(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function C(o,e){let t=typeof e=="string"?d[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function S(o){let e=typeof o=="string"?d[o]:o;if(!e)return "";let t=[];for(let[r,i]of Object.entries(e))if(i){let n=`--gh-${D(r).replace("color","-color")}`;t.push(`${n}: ${i};`);}return t.join(`
`)}function U(){return Object.keys(d)}var g=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container);}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e);}async render(){this.config.theme&&C(this.container,this.config.theme),this.showLoading();try{this.data=await u(this.config.username,this.config.apiEndpoint),m(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};export{p as DEFAULT_API_ENDPOINT,g as GitHubContributionWidget,d as THEME_PRESETS,C as applyTheme,u as fetchContributionData,S as getThemeCSS,U as getThemePresets,m as renderWidget};//# sourceMappingURL=vanilla.js.map
var b="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",g="ghContributionGraph",y="https://github.com/iamjr15/github-contribution-graph",T=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],R=["","Mon","","Wed","","Fri",""],C={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};function S(t,e){let r=encodeURIComponent(e);try{let n=typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost",o=new URL(t,n);return o.searchParams.set("login",e),/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t)?o.toString():`${o.pathname}${o.search}${o.hash}`}catch{let n=t.includes("?")?"&":"?";return `${t}${n}login=${r}`}}async function L(t,e=b){if(!t||typeof t!="string"||!t.trim())throw new Error("Username is required");let r=t.trim(),n=S(e,r),o=new AbortController,a=setTimeout(()=>o.abort(),1e4),l;try{l=await fetch(n,{signal:o.signal});}catch(s){throw clearTimeout(a),s instanceof DOMException&&s.name==="AbortError"?new Error("Request timed out. Please try again."):s}if(clearTimeout(a),!l.ok)throw new Error(`HTTP error! status: ${l.status}`);let i=await l.json();if(!i.user)throw new Error(i.error||"User not found");return i.user}function c(t,e){return [t,e].filter(Boolean).join(" ")}function f(t,e){e&&t.classList.add(...e.split(/\s+/).filter(Boolean));}function N(t){return t.dayLabels??R}function D(t,e){return e.tooltipFormatter?e.tooltipFormatter(t):`${t.day.contributionCount} contributions on ${t.date.toDateString()}`}function O(t){return typeof t=="number"?`${t}px`:t}function M(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function P(t,e){return typeof e.dayClassName=="function"?e.dayClassName(t)||void 0:e.dayClassName}function A(t,e,r){let n=typeof r.dayStyle=="function"?r.dayStyle(e):r.dayStyle;if(n)for(let[o,a]of Object.entries(n))a==null||a===""||t.style.setProperty(M(o),O(a));}function U(t,e,r){let n=r.dayAttributes?.(e);if(n)for(let[o,a]of Object.entries(n))a==null||a===false||t.setAttribute(o,a===true?"":String(a));}function k(t,e,r){let n=typeof r.renderDayContents=="function",o=n?r.renderDayContents?.(e):void 0;if(typeof o=="string"){t.appendChild(document.createTextNode(o));return}if(o instanceof Node){t.appendChild(o);return}if(!n&&r.showTooltips!==false){let a=document.createElement("span");a.className=c("ghCalendarTooltip",r.classNames?.tooltip),a.textContent=D(e,r),t.appendChild(a);}}function I(t={}){let e=document.createElement("table");e.className=c("ghCalendarTable",t.classNames?.table);let r=e.createTHead(),n=e.createTBody(),a=r.insertRow().insertCell();a.style.width="28px";let l=N(t),i=t.showWeekdayLabels!==false;for(let s=0;s<7;s++){let d=n.insertRow().insertCell();if(i&&l[s]){let u=document.createElement("span");u.className=c("ghCalendarLabel",t.classNames?.dayLabel),u.textContent=l[s],d.appendChild(u);}}return {table:e,thead:r,tbody:n}}function F(t,e,r={}){if(r.showMonthLabels!==false)for(let n=0;n<e.length-1;n++){let o=e[n].totalWeeks;if(o>=2){let a=t.rows[0].insertCell(),l=document.createElement("span");l.textContent=r.monthLabelFormatter?r.monthLabelFormatter(e[n],n,e):e[n].name,l.className=c("ghCalendarLabel",r.classNames?.monthLabel),a.appendChild(l),a.colSpan=o;}}}function _(t,e,r={},n=""){for(let[o,a]of e.entries())for(let[l,i]of a.contributionDays.entries()){let s=new Date(i.date),h={day:i,week:a,weekIndex:o,dayIndex:l,date:s,username:n},d=t.rows[i.weekday].insertCell();d.className=c(c("ghCalendarDayCell",r.classNames?.dayCell),P(h,r)),d.dataset.date=i.date,d.dataset.count=String(i.contributionCount),d.dataset.level=i.contributionLevel,d.dataset.week=String(o),d.dataset.weekday=String(i.weekday),A(d,h,r),U(d,h,r),k(d,h,r);}}function G(t={}){let e=document.createElement("div");return e.className=c("ghCalendarCard",t.classNames?.card),e}function $(t={}){let e=document.createElement("div");return e.className=c("ghCalendarCanvas",t.classNames?.canvas),e}function z(t,e,r,n={},o){if(n.renderHeader&&o){let d=n.renderHeader({user:o,username:e,totalContributions:t});if(d)return d}let a=document.createElement("div");a.className=c("ghCalendarHeader",n.classNames?.header);let l=document.createElement("span");f(l,n.classNames?.total),l.textContent=`${t} contributions in the last year`;let i=document.createElement("div");f(i,n.classNames?.profile);let s=document.createElement("a");s.href=`https://github.com/${encodeURIComponent(e)}`,s.textContent=e,f(s,n.classNames?.profileLink);let h=document.createElement("img");return h.src=r,h.alt=`${e}'s avatar`,f(h,n.classNames?.avatar),i.appendChild(s),i.appendChild(h),a.appendChild(l),a.appendChild(i),a}function B(t={}){let e={less:t.footerLabels?.less??"Less",more:t.footerLabels?.more??"More"};if(t.renderFooter){let l=t.renderFooter({levels:T,labels:e});if(l)return l}let r=document.createElement("div");r.className=c("ghCalendarCardFooter",t.classNames?.footer);let n=document.createElement("div");n.className=c("ghCalendarCardFooterColors",t.classNames?.footerLegend);let o=document.createElement("span");o.textContent=e.less;let a=document.createElement("span");a.textContent=e.more,n.appendChild(o);for(let l of T){let i=document.createElement("div");i.className=c("ghCalendarDayCell",t.classNames?.dayCell),i.dataset.level=l,n.appendChild(i);}return n.appendChild(a),r.appendChild(n),r}function W(t={}){if(t.renderThumbnail){let a=t.renderThumbnail({repoUrl:y});if(a)return a}let e=document.createElement("div");e.className=c("ghThumbNail",t.classNames?.thumbnail);let r=document.createElement("a");r.href=y,r.target="_blank",r.rel="noopener noreferrer",f(r,t.classNames?.thumbnailLink);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 98 96"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.style.marginTop="10px",n.style.opacity="0.5",n.style.fill="var(--gh-text-default-color, #333)";let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),n.appendChild(o),r.appendChild(n),e.appendChild(r),e}function E(t,e,r,n={}){let{showHeader:o=true,showFooter:a=true,showThumbnail:l=true}=n;t.classList.add(g),f(t,n.classNames?.root),t.innerHTML="";let i=e.contributionsCollection.contributionCalendar,{table:s,thead:h,tbody:d}=I(n);_(d,i.weeks,n,r),F(h,i.months,n);let u=G(n),p=$(n);if(p.appendChild(s),a){let m=B(n);p.appendChild(m);}if(u.appendChild(p),o){let m=z(i.totalContributions,r,e.avatarUrl,n,e);t.appendChild(m);}if(t.appendChild(u),l){let m=W(n);t.appendChild(m);}}var w={bgColor:"--gh-bg-color",textColor:"--gh-text-default-color",inactiveTextColor:"--gh-text-inactive-color",linkHoverColor:"--gh-link-hover-color",cellLevel0:"--gh-cell-level0-color",cellLevel1:"--gh-cell-level1-color",cellLevel2:"--gh-cell-level2-color",cellLevel3:"--gh-cell-level3-color",cellLevel4:"--gh-cell-level4-color",cellSize:"--gh-cell-size",cellGap:"--gh-cell-gap",cellRadius:"--gh-cell-radius",cellBorderColor:"--gh-cell-border-color",cellOutlineColor:"--gh-cell-outline-color",tooltipBgColor:"--gh-cell-info-bg-color",tooltipTextColor:"--gh-tooltip-text-color",tooltipPadding:"--gh-tooltip-padding",tooltipRadius:"--gh-tooltip-radius",tooltipFontSize:"--gh-tooltip-font-size",borderColor:"--gh-border-card-color",borderWidth:"--gh-border-card-width",cardPadding:"--gh-card-padding",cardPaddingBlock:"--gh-card-padding-block",cardRadius:"--gh-card-radius",canvasPaddingTop:"--gh-canvas-padding-top",canvasMarginInline:"--gh-canvas-margin-inline",headerHeight:"--gh-header-height",headerMarginBottom:"--gh-header-margin-bottom",headerFontSize:"--gh-header-font-size",avatarSize:"--gh-avatar-size",footerPadding:"--gh-footer-padding",footerFontSize:"--gh-footer-font-size",fontFamily:"--gh-font-default-family"};function H(t){return typeof t=="number"?`${t}px`:t}function v(t,e){let r=typeof e=="string"?C[e]:e;if(r)for(let[n,o]of Object.entries(r)){let a=w[n];a&&o!==void 0&&o!==null&&o!==""&&t.style.setProperty(a,H(o));}}function j(t){let e=typeof t=="string"?C[t]:t;if(!e)return "";let r=[];for(let[n,o]of Object.entries(e)){let a=w[n];a&&o!==void 0&&o!==null&&o!==""&&r.push(`${a}: ${H(o)};`);}return r.join(`
`)}function V(){return Object.keys(C)}var x=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container),this.container.classList.add(g);}resolveContainer(e){if(typeof e=="string"){let n=document.querySelector(e);if(!n)throw new Error(`Container not found: ${e}`);return n}if(e instanceof HTMLElement)return e;let r=document.getElementById("gh");if(!r)throw new Error('No container found. Specify container in config or add element with id="gh"');return r}getUsername(){return this.config.username}showLoading(){this.container.innerHTML="";let e=document.createElement("div");e.className="ghCalendarLoading",e.textContent="Loading...",this.container.appendChild(e);}async render(){this.config.theme&&v(this.container,this.config.theme),this.showLoading();try{this.data=await L(this.config.username,this.config.apiEndpoint),E(this.container,this.data,this.config.username,this.config),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container),this.container.classList.add(g)),this.render()}};export{b as DEFAULT_API_ENDPOINT,x as GitHubContributionWidget,C as THEME_PRESETS,v as applyTheme,L as fetchContributionData,j as getThemeCSS,V as getThemePresets,E as renderWidget};//# sourceMappingURL=vanilla.js.map
//# sourceMappingURL=vanilla.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","controller","timeoutId","response","error","data","createTable","table","thead","tbody","firstCell","i","cell","label","addMonths","months","totalWeeks","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","link","img","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","loader"],"mappings":"AAKO,IAAMA,CAAAA,CAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA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,EAAyB,CAC7B,OAAO,IAAA,CAAK,QACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,IAAA,CAAK,IACd,CAKA,OAAA,EAAgB,CACd,IAAA,CAAK,SAAA,CAAU,SAAA,CAAY,EAAA,CAC3B,KAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOsD,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,CAAAA,CAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"vanilla.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n const label = document.createElement('span');\n label.className = 'ghCalendarLabel';\n label.textContent = DAY_LABELS[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]}
{"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","ROOT_CLASS","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","buildContributionUrl","apiEndpoint","username","encodedUsername","base","url","separator","fetchContributionData","trimmedUsername","controller","timeoutId","response","error","data","mergeClasses","baseClass","customClass","applyCustomClass","element","getDayLabels","options","formatTooltip","context","normalizeInlineStyleValue","value","normalizeStyleProperty","property","letter","resolveDayClassName","applyDayStyle","cell","style","applyDayAttributes","attributes","attribute","appendDayContents","hasCustomRenderer","rendered","tooltip","createTable","table","thead","tbody","firstCell","dayLabels","showWeekdayLabels","i","label","addMonths","months","totalWeeks","addWeeks","weeks","weekIndex","week","dayIndex","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","user","customHeader","header","total","profile","link","img","createFooter","labels","customFooter","footer","colors","less","more","level","createThumbnail","customThumbnail","thumbnail","svg","path","renderWidget","container","showHeader","showFooter","showThumbnail","calendar","THEME_CSS_VARIABLES","normalizeCSSValue","applyTheme","theme","config","key","cssKey","getThemeCSS","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,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOmF,EAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,CAAAA,CAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CACvD,IAAA,CAAK,SAAA,CAAU,SAAA,CAAU,GAAA,CAAIpG,CAAU,CAAA,CAAA,CAGlC,IAAA,CAAK,MAAA,EACd,CACF","file":"vanilla.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Root class applied to every rendered widget container.\n */\nexport const ROOT_CLASS = 'ghContributionGraph';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Build an API URL while preserving existing query parameters.\n */\nfunction buildContributionUrl(apiEndpoint: string, username: string): string {\n const encodedUsername = encodeURIComponent(username);\n\n try {\n const base =\n typeof window !== 'undefined' && window.location?.origin\n ? window.location.origin\n : 'http://localhost';\n const url = new URL(apiEndpoint, base);\n url.searchParams.set('login', username);\n\n if (!/^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(apiEndpoint)) {\n return `${url.pathname}${url.search}${url.hash}`;\n }\n\n return url.toString();\n } catch {\n const separator = apiEndpoint.includes('?') ? '&' : '?';\n return `${apiEndpoint}${separator}login=${encodedUsername}`;\n }\n}\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string' || !username.trim()) {\n throw new Error('Username is required');\n }\n\n const trimmedUsername = username.trim();\n const url = buildContributionUrl(apiEndpoint, trimmedUsername);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n let response: Response;\n try {\n response = await fetch(url, { signal: controller.signal });\n } catch (error) {\n clearTimeout(timeoutId);\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new Error('Request timed out. Please try again.');\n }\n throw error;\n }\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL, ROOT_CLASS } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n DayStyle,\n DayRenderContext,\n FooterRenderContext,\n GitHubUser,\n HeaderRenderContext,\n RenderOptions,\n ThumbnailRenderContext,\n} from './types';\n\nfunction mergeClasses(baseClass: string, customClass?: string): string {\n return [baseClass, customClass].filter(Boolean).join(' ');\n}\n\nfunction applyCustomClass(element: HTMLElement | SVGElement, customClass?: string): void {\n if (customClass) {\n element.classList.add(...customClass.split(/\\s+/).filter(Boolean));\n }\n}\n\nfunction getDayLabels(options: RenderOptions): string[] {\n return options.dayLabels ?? DAY_LABELS;\n}\n\nfunction formatTooltip(context: DayRenderContext, options: RenderOptions): string {\n if (options.tooltipFormatter) {\n return options.tooltipFormatter(context);\n }\n\n return `${context.day.contributionCount} contributions on ${context.date.toDateString()}`;\n}\n\nfunction normalizeInlineStyleValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\nfunction normalizeStyleProperty(property: string): string {\n return property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\nfunction resolveDayClassName(context: DayRenderContext, options: RenderOptions): string | undefined {\n if (typeof options.dayClassName === 'function') {\n return options.dayClassName(context) || undefined;\n }\n\n return options.dayClassName;\n}\n\nfunction applyDayStyle(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const style =\n typeof options.dayStyle === 'function' ? options.dayStyle(context) : options.dayStyle;\n\n if (!style) return;\n\n for (const [property, value] of Object.entries(style satisfies DayStyle)) {\n if (value === undefined || value === null || value === '') continue;\n\n cell.style.setProperty(normalizeStyleProperty(property), normalizeInlineStyleValue(value));\n }\n}\n\nfunction applyDayAttributes(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const attributes = options.dayAttributes?.(context);\n if (!attributes) return;\n\n for (const [attribute, value] of Object.entries(attributes)) {\n if (value === undefined || value === null || value === false) continue;\n cell.setAttribute(attribute, value === true ? '' : String(value));\n }\n}\n\nfunction appendDayContents(\n cell: HTMLTableCellElement,\n context: DayRenderContext,\n options: RenderOptions\n): void {\n const hasCustomRenderer = typeof options.renderDayContents === 'function';\n const rendered = hasCustomRenderer ? options.renderDayContents?.(context) : undefined;\n\n if (typeof rendered === 'string') {\n cell.appendChild(document.createTextNode(rendered));\n return;\n }\n\n if (rendered instanceof Node) {\n cell.appendChild(rendered);\n return;\n }\n\n if (!hasCustomRenderer && options.showTooltips !== false) {\n const tooltip = document.createElement('span');\n tooltip.className = mergeClasses('ghCalendarTooltip', options.classNames?.tooltip);\n tooltip.textContent = formatTooltip(context, options);\n cell.appendChild(tooltip);\n }\n}\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(options: RenderOptions = {}): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = mergeClasses('ghCalendarTable', options.classNames?.table);\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n const dayLabels = getDayLabels(options);\n const showWeekdayLabels = options.showWeekdayLabels !== false;\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (showWeekdayLabels && dayLabels[i]) {\n const label = document.createElement('span');\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.dayLabel);\n label.textContent = dayLabels[i];\n cell.appendChild(label);\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[],\n options: RenderOptions = {}\n): void {\n if (options.showMonthLabels === false) return;\n\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = options.monthLabelFormatter\n ? options.monthLabelFormatter(months[i], i, months)\n : months[i].name;\n label.className = mergeClasses('ghCalendarLabel', options.classNames?.monthLabel);\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[],\n options: RenderOptions = {},\n username = ''\n): void {\n for (const [weekIndex, week] of weeks.entries()) {\n for (const [dayIndex, day] of week.contributionDays.entries()) {\n const date = new Date(day.date);\n const context: DayRenderContext = {\n day,\n week,\n weekIndex,\n dayIndex,\n date,\n username,\n };\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.className = mergeClasses(\n mergeClasses('ghCalendarDayCell', options.classNames?.dayCell),\n resolveDayClassName(context, options)\n );\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n cell.dataset.week = String(weekIndex);\n cell.dataset.weekday = String(day.weekday);\n applyDayStyle(cell, context, options);\n applyDayAttributes(cell, context, options);\n appendDayContents(cell, context, options);\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(options: RenderOptions = {}): HTMLDivElement {\n const card = document.createElement('div');\n card.className = mergeClasses('ghCalendarCard', options.classNames?.card);\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(options: RenderOptions = {}): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = mergeClasses('ghCalendarCanvas', options.classNames?.canvas);\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string,\n options: RenderOptions = {},\n user?: GitHubUser\n): HTMLElement {\n if (options.renderHeader && user) {\n const customHeader = options.renderHeader({\n user,\n username,\n totalContributions,\n } satisfies HeaderRenderContext);\n\n if (customHeader) return customHeader;\n }\n\n const header = document.createElement('div');\n header.className = mergeClasses('ghCalendarHeader', options.classNames?.header);\n\n const total = document.createElement('span');\n applyCustomClass(total, options.classNames?.total);\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n applyCustomClass(profile, options.classNames?.profile);\n const link = document.createElement('a');\n link.href = `https://github.com/${encodeURIComponent(username)}`;\n link.textContent = username;\n applyCustomClass(link, options.classNames?.profileLink);\n const img = document.createElement('img');\n img.src = avatarUrl;\n img.alt = `${username}'s avatar`;\n applyCustomClass(img, options.classNames?.avatar);\n profile.appendChild(link);\n profile.appendChild(img);\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(options: RenderOptions = {}): HTMLElement {\n const labels = {\n less: options.footerLabels?.less ?? 'Less',\n more: options.footerLabels?.more ?? 'More',\n };\n\n if (options.renderFooter) {\n const customFooter = options.renderFooter({\n levels: CONTRIBUTION_LEVELS,\n labels,\n } satisfies FooterRenderContext);\n\n if (customFooter) return customFooter;\n }\n\n const footer = document.createElement('div');\n footer.className = mergeClasses('ghCalendarCardFooter', options.classNames?.footer);\n\n const colors = document.createElement('div');\n colors.className = mergeClasses(\n 'ghCalendarCardFooterColors',\n options.classNames?.footerLegend\n );\n\n const less = document.createElement('span');\n less.textContent = labels.less;\n\n const more = document.createElement('span');\n more.textContent = labels.more;\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = mergeClasses('ghCalendarDayCell', options.classNames?.dayCell);\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(options: RenderOptions = {}): HTMLElement {\n if (options.renderThumbnail) {\n const customThumbnail = options.renderThumbnail({\n repoUrl: REPO_URL,\n } satisfies ThumbnailRenderContext);\n\n if (customThumbnail) return customThumbnail;\n }\n\n const thumbnail = document.createElement('div');\n thumbnail.className = mergeClasses('ghThumbNail', options.classNames?.thumbnail);\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n applyCustomClass(link, options.classNames?.thumbnailLink);\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n container.classList.add(ROOT_CLASS);\n applyCustomClass(container, options.classNames?.root);\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable(options);\n\n addWeeks(tbody, calendar.weeks, options, username);\n addMonths(thead, calendar.months, options);\n\n const card = createCard(options);\n const canvas = createCanvas(options);\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter(options);\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(\n calendar.totalContributions,\n username,\n user.avatarUrl,\n options,\n user\n );\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail(options);\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\nconst THEME_CSS_VARIABLES: Record<keyof ThemeConfig, string> = {\n bgColor: '--gh-bg-color',\n textColor: '--gh-text-default-color',\n inactiveTextColor: '--gh-text-inactive-color',\n linkHoverColor: '--gh-link-hover-color',\n cellLevel0: '--gh-cell-level0-color',\n cellLevel1: '--gh-cell-level1-color',\n cellLevel2: '--gh-cell-level2-color',\n cellLevel3: '--gh-cell-level3-color',\n cellLevel4: '--gh-cell-level4-color',\n cellSize: '--gh-cell-size',\n cellGap: '--gh-cell-gap',\n cellRadius: '--gh-cell-radius',\n cellBorderColor: '--gh-cell-border-color',\n cellOutlineColor: '--gh-cell-outline-color',\n tooltipBgColor: '--gh-cell-info-bg-color',\n tooltipTextColor: '--gh-tooltip-text-color',\n tooltipPadding: '--gh-tooltip-padding',\n tooltipRadius: '--gh-tooltip-radius',\n tooltipFontSize: '--gh-tooltip-font-size',\n borderColor: '--gh-border-card-color',\n borderWidth: '--gh-border-card-width',\n cardPadding: '--gh-card-padding',\n cardPaddingBlock: '--gh-card-padding-block',\n cardRadius: '--gh-card-radius',\n canvasPaddingTop: '--gh-canvas-padding-top',\n canvasMarginInline: '--gh-canvas-margin-inline',\n headerHeight: '--gh-header-height',\n headerMarginBottom: '--gh-header-margin-bottom',\n headerFontSize: '--gh-header-font-size',\n avatarSize: '--gh-avatar-size',\n footerPadding: '--gh-footer-padding',\n footerFontSize: '--gh-footer-font-size',\n fontFamily: '--gh-font-default-family',\n};\n\nfunction normalizeCSSValue(value: string | number): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n element.style.setProperty(cssKey, normalizeCSSValue(value));\n }\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n const cssKey = THEME_CSS_VARIABLES[key as keyof ThemeConfig];\n if (cssKey && value !== undefined && value !== null && value !== '') {\n cssVars.push(`${cssKey}: ${normalizeCSSValue(value)};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { ROOT_CLASS } from '../core/constants';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Get the configured username\n */\n getUsername(): string {\n return this.config.username;\n }\n\n /**\n * Show loading indicator\n */\n private showLoading(): void {\n this.container.innerHTML = '';\n const loader = document.createElement('div');\n loader.className = 'ghCalendarLoading';\n loader.textContent = 'Loading...';\n this.container.appendChild(loader);\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n this.showLoading();\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, this.config);\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n this.container.classList.add(ROOT_CLASS);\n }\n\n return this.render();\n }\n}\n"]}
{
"name": "github-contrib-graph",
"version": "3.1.0",
"version": "3.1.1",
"description": "Lightweight, customizable GitHub contribution graph widget for any website",

@@ -5,0 +5,0 @@ "keywords": [

+446
-94

@@ -1,13 +0,31 @@

# github-contribution-graph
# github-contrib-graph
A lightweight, customizable GitHub contribution graph widget for any website.
A lightweight, customizable GitHub contribution graph widget for React, vanilla JavaScript, and plain HTML pages.
[![npm version](https://img.shields.io/npm/v/github-contribution-graph.svg)](https://npmjs.com/package/github-contribution-graph)
[![npm downloads](https://img.shields.io/npm/dm/github-contribution-graph.svg)](https://npmjs.com/package/github-contribution-graph)
[![License](https://img.shields.io/npm/l/github-contribution-graph.svg)](https://github.com/iamjr15/github-contribution-graph/blob/main/LICENSE)
[![npm version](https://img.shields.io/npm/v/github-contrib-graph.svg)](https://npmjs.com/package/github-contrib-graph)
[![npm downloads](https://img.shields.io/npm/dm/github-contrib-graph.svg)](https://npmjs.com/package/github-contrib-graph)
[![License](https://img.shields.io/npm/l/github-contrib-graph.svg)](https://github.com/iamjr15/github-contribution-graph/blob/main/LICENSE)
> Package name: `github-contrib-graph`.
> Repository name: `github-contribution-graph`.
> The npm package named `github-contribution-graph` is a different package.
## Features
- React component and data-fetching hook
- Vanilla JavaScript widget class
- Script-tag browser bundle for static sites
- Built-in dark and light themes
- Custom theming through props or CSS variables
- Class hooks for every major rendered element
- Per-day class, style, attribute, tooltip, and content render hooks
- Replaceable header, footer legend, and GitHub attribution
- Fully custom React rendering when you only want the package to fetch data
- Hosted API by default, with support for your own API endpoint
- TypeScript definitions for all public APIs
## Installation
```bash
npm install github-contribution-graph
npm install github-contrib-graph
```

@@ -20,6 +38,6 @@

```tsx
import { GitHubContributionGraph } from 'github-contribution-graph/react';
import 'github-contribution-graph/styles.css';
import { GitHubContributionGraph } from 'github-contrib-graph/react';
import 'github-contrib-graph/styles.css';
function App() {
export function ProfileActivity() {
return (

@@ -29,3 +47,5 @@ <GitHubContributionGraph

theme="midnight"
onDataLoaded={(data) => console.log('Loaded!', data)}
onDataLoaded={(data) => {
console.log(data.contributionsCollection.contributionCalendar.totalContributions);
}}
/>

@@ -39,4 +59,4 @@ );

```js
import { GitHubContributionWidget } from 'github-contribution-graph/vanilla';
import 'github-contribution-graph/styles.css';
import { GitHubContributionWidget } from 'github-contrib-graph/vanilla';
import 'github-contrib-graph/styles.css';

@@ -49,67 +69,99 @@ const widget = new GitHubContributionWidget({

widget.render();
await widget.render();
```
### Script Tag (CDN)
```html
<div id="my-graph"></div>
```
### Script Tag
Use this when you do not have a bundler.
```html
<link rel="stylesheet" href="https://unpkg.com/github-contribution-graph/dist/gh.css">
<div id="gh"
data-login="octocat"
data-show-thumbnail="true"
data-show-header="true"
data-show-footer="true"></div>
<script src="https://unpkg.com/github-contribution-graph/dist/browser.global.js"></script>
<link rel="stylesheet" href="https://unpkg.com/github-contrib-graph@latest/dist/gh.css">
<div
id="gh"
data-login="octocat"
data-show-thumbnail="true"
data-show-header="true"
data-show-footer="true"
></div>
<script src="https://unpkg.com/github-contrib-graph@latest/dist/browser.global.js"></script>
```
#### Data Attributes
For production pages, pin a version instead of using `@latest`:
```html
<link rel="stylesheet" href="https://unpkg.com/github-contrib-graph@3.1.1/dist/gh.css">
<script src="https://unpkg.com/github-contrib-graph@3.1.1/dist/browser.global.js"></script>
```
The browser bundle auto-renders an element with `id="gh"` and `data-login`. It also exposes `window.renderGitHubWidget()` for manual re-rendering after you change `data-login`.
## Data Attributes
| Attribute | Default | Description |
|-----------|---------|-------------|
| `data-login` | required | GitHub username |
| `data-show-thumbnail` | `"true"` | Show/hide GitHub logo below graph |
| `data-show-header` | `"true"` | Show/hide contribution count header |
| `data-show-footer` | `"true"` | Show/hide legend footer |
| --- | --- | --- |
| `data-login` | required | GitHub username to render |
| `data-show-thumbnail` | `"true"` | Show or hide the GitHub attribution icon |
| `data-show-header` | `"true"` | Show or hide the contribution total and avatar |
| `data-show-footer` | `"true"` | Show or hide the Less/More legend |
## React API
### GitHubContributionGraph
```tsx
import { GitHubContributionGraph } from 'github-contribution-graph/react';
import { GitHubContributionGraph } from 'github-contrib-graph/react';
<GitHubContributionGraph
username="octocat" // Required: GitHub username
apiEndpoint="..." // Optional: Custom API endpoint
theme="default" // Optional: Theme preset or custom config
showHeader={true} // Optional: Show contribution count header
showFooter={true} // Optional: Show legend footer
showThumbnail={true} // Optional: Show GitHub attribution
className="my-class" // Optional: CSS class
style={{ margin: 20 }} // Optional: Inline styles
onDataLoaded={(data) => {}} // Optional: Callback when data loads
onError={(error) => {}} // Optional: Callback on error
onLoading={(loading) => {}} // Optional: Callback on loading state change
/>
username="octocat"
apiEndpoint="https://your-domain.com/api/ghcg/fetch-data"
theme="default"
showHeader={true}
showFooter={true}
showThumbnail={true}
showMonthLabels={true}
showWeekdayLabels={true}
showTooltips={true}
dayLabels={['', 'Mon', '', 'Wed', '', 'Fri', '']}
footerLabels={{ less: 'Less', more: 'More' }}
classNames={{ root: 'my-graph-root', dayCell: 'my-day-cell' }}
dayClassName={({ day }) => (day.contributionCount > 0 ? 'has-activity' : '')}
dayStyle={({ day }) => ({
opacity: day.contributionCount === 0 ? '0.45' : '1',
})}
dayAttributes={({ day }) => ({
'aria-label': `${day.contributionCount} contributions on ${day.date}`,
})}
tooltipFormatter={({ day, date }) =>
`${day.contributionCount} contributions on ${date.toLocaleDateString()}`
}
monthLabelFormatter={(month) => month.name.slice(0, 3)}
className="my-graph"
style={{ margin: 20 }}
onDataLoaded={(data) => {}}
onError={(error) => {}}
onLoading={(isLoading) => {}}
/>;
```
### useContributionData Hook
### `useContributionData`
```tsx
import { useContributionData } from 'github-contribution-graph/react';
import { useContributionData } from 'github-contrib-graph/react';
function CustomGraph() {
function TotalContributions() {
const { data, loading, error, refetch } = useContributionData('octocat', {
apiEndpoint: 'https://custom-api.com', // Optional
autoFetch: true, // Optional: default true
autoFetch: true,
});
if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
if (error) return <div>{error.message}</div>;
return (
<div>
<p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>
<button onClick={refetch}>Refresh</button>
</div>
<button onClick={refetch}>
{data?.contributionsCollection.contributionCalendar.totalContributions}
</button>
);

@@ -119,27 +171,34 @@ }

## Vanilla JS API
## Vanilla API
### GitHubContributionWidget
```js
import { GitHubContributionWidget } from 'github-contribution-graph/vanilla';
import { GitHubContributionWidget } from 'github-contrib-graph/vanilla';
const widget = new GitHubContributionWidget({
username: 'octocat', // Required: GitHub username
container: '#my-graph', // Optional: CSS selector or HTMLElement
apiEndpoint: '...', // Optional: Custom API endpoint
theme: 'void', // Optional: Theme preset or custom config
showHeader: true, // Optional: Show contribution count header
showFooter: true, // Optional: Show legend footer
showThumbnail: true, // Optional: Show GitHub attribution
onDataLoaded: (data) => {}, // Optional: Callback when data loads
onError: (error) => {}, // Optional: Callback on error
username: 'octocat',
container: '#my-graph',
apiEndpoint: 'https://your-domain.com/api/ghcg/fetch-data',
theme: 'void',
showHeader: true,
showFooter: true,
showThumbnail: true,
showMonthLabels: true,
showWeekdayLabels: true,
showTooltips: true,
classNames: {
root: 'profile-graph',
dayCell: 'profile-graph__day',
},
dayStyle: ({ day }) => ({
transform: day.contributionCount > 20 ? 'scale(1.15)' : 'scale(1)',
}),
onDataLoaded: (data) => {},
onError: (error) => {},
});
// Methods
await widget.render(); // Render the widget
await widget.refresh(); // Refresh data and re-render
const data = widget.getData(); // Get current data
widget.destroy(); // Clear content
await widget.update({ ... }); // Update config and re-render
await widget.render();
await widget.refresh();
const data = widget.getData();
widget.destroy();
await widget.update({ username: 'another-user' });
```

@@ -149,13 +208,19 @@

Built-in theme presets:
Built-in presets:
- `default` - GitHub's default dark theme
- `void` - Pure black minimalist
- `slate` - Textured dark grey
- `midnight` - Deep indigo/purple
- `glacier` - Clean light theme
- `cyber` - Neon green matrix style
- `default`
- `void`
- `slate`
- `midnight`
- `glacier`
- `cyber`
### Custom Theme
Pass a preset name:
```tsx
<GitHubContributionGraph username="octocat" theme="cyber" />
```
Or pass a custom theme object:
```js

@@ -165,10 +230,11 @@ const widget = new GitHubContributionWidget({

theme: {
bgColor: '#1a1a2e',
textColor: '#eaeaea',
cellLevel0: '#16213e',
cellLevel1: '#0f3460',
cellLevel2: '#533483',
cellLevel3: '#e94560',
cellLevel4: '#ff6b6b',
borderColor: '#0f3460',
bgColor: '#111111',
textColor: '#eeeeee',
cellLevel0: '#222222',
cellLevel1: '#0e4429',
cellLevel2: '#006d32',
cellLevel3: '#26a641',
cellLevel4: '#39d353',
borderColor: '#333333',
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',
},

@@ -178,14 +244,300 @@ });

## Self-Hosting the API
You can also override CSS variables directly on the widget root:
By default, the widget uses the hosted API at `githubgraph.jigyansurout.com`. To self-host:
```css
.my-graph {
--gh-bg-color: #000000;
--gh-text-default-color: #ffffff;
--gh-cell-level0-color: #111111;
--gh-border-card-color: #333333;
--gh-font-default-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
```
1. Clone the repository
2. Deploy to Netlify (or similar)
3. Set `GITHUB_TOKEN` environment variable (needs `read:user` scope)
4. Use the `apiEndpoint` option to point to your deployment
The rendered root receives the `ghContributionGraph` class, so styles work even when your container is not `#gh`.
## Customization
The package has layered customization. You can use only the built-in presets, override the default DOM with class and render hooks, or skip the default DOM entirely in React and render your own calendar from the fetched data.
### Theme Object
Every theme key can be passed through the `theme` prop or config option. String values are used as-is. Numeric values are converted to `px`.
```tsx
<GitHubContributionGraph
username="octocat"
theme={{
bgColor: '#080c10',
textColor: '#f4f7fb',
inactiveTextColor: '#7d8794',
linkHoverColor: '#8ab4ff',
cellLevel0: '#18202a',
cellLevel1: '#163b2a',
cellLevel2: '#196c3d',
cellLevel3: '#32a852',
cellLevel4: '#7ee787',
cellSize: 13,
cellGap: 4,
cellRadius: 4,
cellBorderColor: 'rgba(255,255,255,0.08)',
cellOutlineColor: 'transparent',
tooltipBgColor: '#f4f7fb',
tooltipTextColor: '#080c10',
tooltipPadding: '8px 10px',
tooltipRadius: 8,
tooltipFontSize: 12,
borderColor: '#27313d',
borderWidth: 1,
cardPadding: 18,
cardPaddingBlock: 10,
cardRadius: 10,
canvasPaddingTop: 8,
canvasMarginInline: 12,
headerHeight: 28,
headerMarginBottom: 8,
headerFontSize: 14,
avatarSize: 24,
footerPadding: '8px 32px',
footerFontSize: 12,
fontFamily: 'Inter, ui-sans-serif, system-ui, sans-serif',
}}
/>
```
The matching CSS variables are:
| Theme key | CSS variable |
| --- | --- |
| `bgColor` | `--gh-bg-color` |
| `textColor` | `--gh-text-default-color` |
| `inactiveTextColor` | `--gh-text-inactive-color` |
| `linkHoverColor` | `--gh-link-hover-color` |
| `cellLevel0` - `cellLevel4` | `--gh-cell-level0-color` - `--gh-cell-level4-color` |
| `cellSize` | `--gh-cell-size` |
| `cellGap` | `--gh-cell-gap` |
| `cellRadius` | `--gh-cell-radius` |
| `cellBorderColor` | `--gh-cell-border-color` |
| `cellOutlineColor` | `--gh-cell-outline-color` |
| `tooltipBgColor` | `--gh-cell-info-bg-color` |
| `tooltipTextColor` | `--gh-tooltip-text-color` |
| `tooltipPadding` | `--gh-tooltip-padding` |
| `tooltipRadius` | `--gh-tooltip-radius` |
| `tooltipFontSize` | `--gh-tooltip-font-size` |
| `borderColor` | `--gh-border-card-color` |
| `borderWidth` | `--gh-border-card-width` |
| `cardPadding` | `--gh-card-padding` |
| `cardPaddingBlock` | `--gh-card-padding-block` |
| `cardRadius` | `--gh-card-radius` |
| `canvasPaddingTop` | `--gh-canvas-padding-top` |
| `canvasMarginInline` | `--gh-canvas-margin-inline` |
| `headerHeight` | `--gh-header-height` |
| `headerMarginBottom` | `--gh-header-margin-bottom` |
| `headerFontSize` | `--gh-header-font-size` |
| `avatarSize` | `--gh-avatar-size` |
| `footerPadding` | `--gh-footer-padding` |
| `footerFontSize` | `--gh-footer-font-size` |
| `fontFamily` | `--gh-font-default-family` |
### Labels, Tooltips, Classes, And Cells
```tsx
<GitHubContributionGraph
username="octocat"
showMonthLabels
showWeekdayLabels
showTooltips
dayLabels={['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']}
footerLabels={{ less: 'Quiet', more: 'Busy' }}
classNames={{
root: 'activity',
header: 'activity__header',
total: 'activity__total',
profile: 'activity__profile',
profileLink: 'activity__profile-link',
avatar: 'activity__avatar',
card: 'activity__card',
canvas: 'activity__canvas',
table: 'activity__table',
monthLabel: 'activity__month',
dayLabel: 'activity__weekday',
dayCell: 'activity__day',
tooltip: 'activity__tooltip',
footer: 'activity__footer',
footerLegend: 'activity__legend',
thumbnail: 'activity__thumbnail',
thumbnailLink: 'activity__thumbnail-link',
}}
dayClassName={({ day }) =>
day.contributionCount >= 10 ? 'activity__day--hot' : undefined
}
dayStyle={({ day }) => ({
opacity: day.contributionCount === 0 ? '0.35' : '1',
borderRadius: day.contributionCount >= 10 ? 6 : 2,
})}
dayAttributes={({ day }) => ({
'aria-label': `${day.contributionCount} contributions on ${day.date}`,
'data-busy': day.contributionCount >= 10,
})}
tooltipFormatter={({ day, date, username }) =>
`${username} made ${day.contributionCount} contributions on ${date.toLocaleDateString()}`
}
monthLabelFormatter={(month) => month.name.toUpperCase()}
/>
```
Every day cell also receives these default attributes, which makes CSS-only custom designs straightforward:
```css
.activity__day[data-level='FOURTH_QUARTILE'] {
box-shadow: 0 0 0 2px color-mix(in srgb, var(--gh-cell-level4-color), white 20%);
}
.activity__day[data-count='0'] {
opacity: 0.4;
}
```
### Replace Individual Sections
The default renderer can replace the header, footer, thumbnail, or the contents inside each day cell. These hooks return DOM nodes or strings.
```ts
const widget = new GitHubContributionWidget({
username: 'octocat',
container: '#my-graph',
renderHeader: ({ username, totalContributions, user }) => {
const header = document.createElement('header');
header.className = 'activity-header';
const avatar = document.createElement('img');
avatar.src = user.avatarUrl;
avatar.alt = `${username}'s avatar`;
const name = document.createElement('strong');
name.textContent = username;
const total = document.createElement('span');
total.textContent = `${totalContributions.toLocaleString()} contributions`;
header.append(avatar, name, total);
return header;
},
renderDayContents: ({ day }) => {
const dot = document.createElement('span');
dot.className = 'activity-dot';
dot.textContent = day.contributionCount > 0 ? String(day.contributionCount) : '';
return dot;
},
renderFooter: ({ labels }) => {
const footer = document.createElement('footer');
footer.textContent = `${labels.less} / ${labels.more}`;
return footer;
},
renderThumbnail: () => null,
});
```
When using the React component, `renderHeader`, `renderFooter`, `renderThumbnail`, and `renderDayContents` still belong to the default DOM renderer, so they return DOM nodes. Use the React `render` prop if you want JSX-level control.
### Fully Custom React Render
The `render` prop lets React users use the package only for fetching and state management. You receive the raw GitHub contribution calendar and can render every pixel yourself.
```tsx
<GitHubContributionGraph
username="octocat"
render={({ data, loading, error, refresh }) => {
if (loading) return <p>Loading activity...</p>;
if (error) return <button onClick={refresh}>Retry</button>;
const calendar = data?.contributionsCollection.contributionCalendar;
return (
<section className="activity-board">
<strong>{calendar?.totalContributions.toLocaleString()} contributions</strong>
<div className="activity-grid">
{calendar?.weeks.flatMap((week) =>
week.contributionDays.map((day) => (
<span
key={day.date}
className="activity-cell"
data-level={day.contributionLevel}
title={`${day.contributionCount} on ${day.date}`}
/>
))
)}
</div>
</section>
);
}}
/>
```
## API Endpoint
By default, the package fetches contribution data from:
```text
https://githubgraph.jigyansurout.com/api/ghcg/fetch-data?login={username}
```
The response shape matches the GitHub GraphQL contribution calendar:
```json
{
"user": {
"avatarUrl": "https://avatars.githubusercontent.com/...",
"contributionsCollection": {
"contributionCalendar": {
"totalContributions": 1234,
"months": [],
"weeks": []
}
}
}
}
```
Use `apiEndpoint` if you want to run your own backend.
## Self-Hosting
This repository includes a Cloudflare Pages Functions backend at `functions/api/ghcg/fetch-data.js`.
1. Fork or clone the repository.
2. Create a GitHub personal access token with enough access to read the contribution calendar you want to show.
3. Add `GITHUB_TOKEN` to your Cloudflare Pages environment variables.
4. Use `npm run build` as the build command.
5. Use `cf-dist` as the Pages output directory.
6. Deploy with the repository root as the project root so Cloudflare can discover `functions/`.
7. Pass your endpoint to the widget:
```tsx
<GitHubContributionGraph
username="octocat"
apiEndpoint="https://your-domain.com/api/ghcg/fetch-data"
/>
```
Local development:
```bash
npm install
echo "GITHUB_TOKEN=your_token" > .env
npm run build
npm run dev
```
## Troubleshooting
- Use `github-contrib-graph`, not `github-contribution-graph`, when installing from npm.
- For script-tag usage, place the `<script>` after the graph container or call `window.renderGitHubWidget()` after adding the container.
- Make sure `data-login` or `username` is a valid GitHub username.
- If you self-host, confirm your API returns `{ "user": ... }` and includes CORS headers for browser usage.
- If private contributions are missing, check the permissions and visibility available to your GitHub token.
## Browser Support
- Modern browsers (ES2020+)
- Modern browsers with ES2020 support
- Node.js 18+

@@ -192,0 +544,0 @@

/**
* Contribution level indicating activity intensity
*/
type ContributionLevel = 'NONE' | 'FIRST_QUARTILE' | 'SECOND_QUARTILE' | 'THIRD_QUARTILE' | 'FOURTH_QUARTILE';
/**
* A single day's contribution data
*/
interface ContributionDay {
date: string;
contributionCount: number;
contributionLevel: ContributionLevel;
weekday: number;
}
/**
* A week of contribution data
*/
interface ContributionWeek {
contributionDays: ContributionDay[];
}
/**
* A month label in the calendar
*/
interface ContributionMonth {
name: string;
totalWeeks: number;
}
/**
* The full contribution calendar data
*/
interface ContributionCalendar {
totalContributions: number;
months: ContributionMonth[];
weeks: ContributionWeek[];
}
/**
* GitHub user data from API response
*/
interface GitHubUser {
avatarUrl: string;
contributionsCollection: {
contributionCalendar: ContributionCalendar;
};
}
/**
* API response structure
*/
interface APIResponse {
user: GitHubUser | null;
error?: string;
}
/**
* Available theme presets
*/
type ThemePreset = 'default' | 'void' | 'slate' | 'midnight' | 'glacier' | 'cyber';
/**
* Custom theme configuration
*/
interface ThemeConfig {
bgColor?: string;
textColor?: string;
cellLevel0?: string;
cellLevel1?: string;
cellLevel2?: string;
cellLevel3?: string;
cellLevel4?: string;
borderColor?: string;
fontFamily?: string;
}
/**
* Widget render options
*/
interface RenderOptions {
showHeader?: boolean;
showFooter?: boolean;
showThumbnail?: boolean;
}
/**
* Configuration for the widget
*/
interface GitHubContributionGraphConfig extends RenderOptions {
username: string;
apiEndpoint?: string;
container?: string | HTMLElement;
theme?: ThemePreset | ThemeConfig;
onDataLoaded?: (data: GitHubUser) => void;
onError?: (error: Error) => void;
}
/**
* Default API endpoint for fetching contribution data
*/
declare const DEFAULT_API_ENDPOINT = "https://githubgraph.jigyansurout.com/api/ghcg/fetch-data";
/**
* Repository URL for the widget
*/
declare const REPO_URL = "https://github.com/iamjr15/github-contribution-graph";
/**
* Contribution level values in order
*/
declare const CONTRIBUTION_LEVELS: ContributionLevel[];
/**
* Day labels for the calendar rows
*/
declare const DAY_LABELS: string[];
/**
* Theme presets with CSS variable values
*/
declare const THEME_PRESETS: Record<ThemePreset, ThemeConfig>;
/**
* Fetch contribution data for a GitHub user
*
* @param username - GitHub username
* @param apiEndpoint - Optional custom API endpoint
* @returns Promise resolving to user data
* @throws Error if user not found or network error
*
* @example
* ```ts
* const userData = await fetchContributionData('octocat');
* console.log(userData.contributionsCollection.contributionCalendar.totalContributions);
* ```
*/
declare function fetchContributionData(username: string, apiEndpoint?: string): Promise<GitHubUser>;
/**
* Apply a theme to an element by setting CSS custom properties
*
* @param element - The element to apply theme to
* @param theme - Theme preset name or custom config
*
* @example
* ```ts
* applyTheme(container, 'void');
* applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });
* ```
*/
declare function applyTheme(element: HTMLElement, theme: ThemePreset | ThemeConfig): void;
/**
* Generate CSS string from a theme configuration
*
* @param theme - Theme preset name or custom config
* @returns CSS custom properties string
*/
declare function getThemeCSS(theme: ThemePreset | ThemeConfig): string;
/**
* Get all available theme preset names
*/
declare function getThemePresets(): ThemePreset[];
export { type APIResponse as A, type ContributionCalendar as C, DEFAULT_API_ENDPOINT as D, type GitHubUser as G, type RenderOptions as R, type ThemePreset as T, type ThemeConfig as a, applyTheme as b, getThemeCSS as c, THEME_PRESETS as d, type ContributionDay as e, fetchContributionData as f, getThemePresets as g, type ContributionWeek as h, type ContributionMonth as i, type GitHubContributionGraphConfig as j, type ContributionLevel as k, REPO_URL as l, CONTRIBUTION_LEVELS as m, DAY_LABELS as n };
/**
* Contribution level indicating activity intensity
*/
type ContributionLevel = 'NONE' | 'FIRST_QUARTILE' | 'SECOND_QUARTILE' | 'THIRD_QUARTILE' | 'FOURTH_QUARTILE';
/**
* A single day's contribution data
*/
interface ContributionDay {
date: string;
contributionCount: number;
contributionLevel: ContributionLevel;
weekday: number;
}
/**
* A week of contribution data
*/
interface ContributionWeek {
contributionDays: ContributionDay[];
}
/**
* A month label in the calendar
*/
interface ContributionMonth {
name: string;
totalWeeks: number;
}
/**
* The full contribution calendar data
*/
interface ContributionCalendar {
totalContributions: number;
months: ContributionMonth[];
weeks: ContributionWeek[];
}
/**
* GitHub user data from API response
*/
interface GitHubUser {
avatarUrl: string;
contributionsCollection: {
contributionCalendar: ContributionCalendar;
};
}
/**
* API response structure
*/
interface APIResponse {
user: GitHubUser | null;
error?: string;
}
/**
* Available theme presets
*/
type ThemePreset = 'default' | 'void' | 'slate' | 'midnight' | 'glacier' | 'cyber';
/**
* Custom theme configuration
*/
interface ThemeConfig {
bgColor?: string;
textColor?: string;
cellLevel0?: string;
cellLevel1?: string;
cellLevel2?: string;
cellLevel3?: string;
cellLevel4?: string;
borderColor?: string;
fontFamily?: string;
}
/**
* Widget render options
*/
interface RenderOptions {
showHeader?: boolean;
showFooter?: boolean;
showThumbnail?: boolean;
}
/**
* Configuration for the widget
*/
interface GitHubContributionGraphConfig extends RenderOptions {
username: string;
apiEndpoint?: string;
container?: string | HTMLElement;
theme?: ThemePreset | ThemeConfig;
onDataLoaded?: (data: GitHubUser) => void;
onError?: (error: Error) => void;
}
/**
* Default API endpoint for fetching contribution data
*/
declare const DEFAULT_API_ENDPOINT = "https://githubgraph.jigyansurout.com/api/ghcg/fetch-data";
/**
* Repository URL for the widget
*/
declare const REPO_URL = "https://github.com/iamjr15/github-contribution-graph";
/**
* Contribution level values in order
*/
declare const CONTRIBUTION_LEVELS: ContributionLevel[];
/**
* Day labels for the calendar rows
*/
declare const DAY_LABELS: string[];
/**
* Theme presets with CSS variable values
*/
declare const THEME_PRESETS: Record<ThemePreset, ThemeConfig>;
/**
* Fetch contribution data for a GitHub user
*
* @param username - GitHub username
* @param apiEndpoint - Optional custom API endpoint
* @returns Promise resolving to user data
* @throws Error if user not found or network error
*
* @example
* ```ts
* const userData = await fetchContributionData('octocat');
* console.log(userData.contributionsCollection.contributionCalendar.totalContributions);
* ```
*/
declare function fetchContributionData(username: string, apiEndpoint?: string): Promise<GitHubUser>;
/**
* Apply a theme to an element by setting CSS custom properties
*
* @param element - The element to apply theme to
* @param theme - Theme preset name or custom config
*
* @example
* ```ts
* applyTheme(container, 'void');
* applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });
* ```
*/
declare function applyTheme(element: HTMLElement, theme: ThemePreset | ThemeConfig): void;
/**
* Generate CSS string from a theme configuration
*
* @param theme - Theme preset name or custom config
* @returns CSS custom properties string
*/
declare function getThemeCSS(theme: ThemePreset | ThemeConfig): string;
/**
* Get all available theme preset names
*/
declare function getThemePresets(): ThemePreset[];
export { type APIResponse as A, type ContributionCalendar as C, DEFAULT_API_ENDPOINT as D, type GitHubUser as G, type RenderOptions as R, type ThemePreset as T, type ThemeConfig as a, applyTheme as b, getThemeCSS as c, THEME_PRESETS as d, type ContributionDay as e, fetchContributionData as f, getThemePresets as g, type ContributionWeek as h, type ContributionMonth as i, type GitHubContributionGraphConfig as j, type ContributionLevel as k, REPO_URL as l, CONTRIBUTION_LEVELS as m, DAY_LABELS as n };