import { mapIterable as e, toList as t } from "../helpers/iterators.js";
import { useLocalStorage as n } from "./useLocalStorage.js";
import { computed as r, onMounted as i, onUnmounted as a, ref as o, unref as s, watch as c } from "vue";
var l = /* @__PURE__ */ new Set();
window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (n) => {
	t(e(l.values(), (e) => e(n.matches ? "dark" : "light")));
});
var u = o(window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"), d = n("theme");
function f(e) {
	let t = r(() => d.value ? d.value : u.value), n = (t) => {
		u.value = t, e?.(t);
	};
	function o() {
		d.value = t.value === "light" ? "dark" : (t.value, "light");
	}
	return c(t, (t) => {
		e?.(s(t));
	}), i(() => {
		l.add(n);
	}), a(() => {
		l.delete(n);
	}), [t, o];
}
export { f as useTheme };

//# sourceMappingURL=useTheme.js.map