{"size": 934, "ext": "js", "max_stars_repo_path": "theme.js", "max_stars_repo_name": "pulpbitcoin/pulpbitcoin", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "theme.js", "max_issues_repo_name": "pulpbitcoin/pulpbitcoin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "theme.js", "max_forks_repo_name": "pulpbitcoin/pulpbitcoin", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.5789473684, "max_line_length": 104, "alphanum_fraction": 0.6391862955}
// --------------- Customization Points ---------------

// Declare these methods before loading this script to override them.

loadTheme = typeof loadTheme === 'function' ? loadTheme : () => localStorage.getItem('theme');
saveTheme = typeof saveTheme === 'function' ? saveTheme : theme => localStorage.setItem('theme', theme);

const themeChangeHandlers = [];

// =============== Initialization ===============

initTheme();

// =============== Methods ===============

// adapted from https://github.com/coliff/dark-mode-switch

function initTheme() {
	displayTheme(getTheme());
}

function getTheme() {
	return loadTheme() || (window.matchMedia(
		'(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
}

function setTheme(theme) {
	saveTheme(theme);
	displayTheme(theme);
}

function displayTheme(theme) {
	document.body.setAttribute('data-theme', theme);
	for (let handler of themeChangeHandlers) {
		handler(theme);
	}
}
