import { t as e } from "../component-x2UxdKEC.js";
//#region src/sidebar/index.ts
var t = {
	storageKey: "sidebar-collapsed",
	mobileBreakpoint: 900,
	collapsedClass: "sidebar--collapsed"
}, n = { ...t };
function r(e) {
	n = {
		...t,
		...e
	};
}
function i() {
	return window.innerWidth <= n.mobileBreakpoint;
}
function a(e) {
	return localStorage.getItem(`${n.storageKey}-${e}`) === "true";
}
function o(e, t) {
	localStorage.setItem(`${n.storageKey}-${e}`, String(t));
}
function s(e, t) {
	e.setAttribute("data-open", "false"), t && t.setAttribute("data-visible", "false");
}
function c(e, t) {
	let n = e.getAttribute("data-open") === "true";
	e.setAttribute("data-open", String(!n)), t && t.setAttribute("data-visible", String(!n));
}
function l({ sidebar: e, toggle: t, mobileToggles: n, backdrop: r, collapsedClass: l, key: u }) {
	!i() && a(u) && e.classList.add(l), t && t.addEventListener("click", () => {
		o(u, e.classList.toggle(l));
	}), n.forEach((t) => {
		t.addEventListener("click", () => {
			c(e, r);
		});
	}), r && r.addEventListener("click", () => {
		s(e, r);
	}), window.addEventListener("resize", () => {
		i() && s(e, r);
	}), document.addEventListener("keydown", (t) => {
		t.key === "Escape" && e.getAttribute("data-open") === "true" && s(e, r);
	});
}
function u(e) {
	let t = e.getAttribute("data-sidebar");
	t === null || t === "" || l({
		sidebar: e,
		toggle: e.querySelector("[data-sidebar-toggle]"),
		mobileToggles: Array.from(document.querySelectorAll("[data-sidebar-mobile-toggle]")),
		backdrop: document.querySelector(`[data-sidebar-backdrop="${t}"]`),
		collapsedClass: n.collapsedClass,
		key: t
	});
}
function d(e) {
	let t = document.querySelector(e.sidebar);
	t && (t.hasAttribute("data-sidebar") || l({
		sidebar: t,
		toggle: document.querySelector(e.toggle),
		mobileToggles: Array.from(document.querySelectorAll(e.mobileToggle)),
		backdrop: document.querySelector(e.backdrop),
		collapsedClass: e.collapsedClass,
		key: e.sidebar.replace(/[^a-z]/g, "")
	}));
}
var f = [
	{
		sidebar: ".page__sidebar",
		toggle: "[data-page-sidebar-toggle]",
		mobileToggle: "[data-page-mobile-toggle]",
		backdrop: ".sidebar-backdrop",
		collapsedClass: "page__sidebar--collapsed"
	},
	{
		sidebar: ".chat-sidebar",
		toggle: "[data-chat-sidebar-toggle]",
		mobileToggle: ".chat-header__menu-toggle",
		backdrop: ".chat-sidebar-backdrop",
		collapsedClass: "chat-sidebar--collapsed"
	},
	{
		sidebar: ".files-sidebar",
		toggle: "[data-files-sidebar-toggle]",
		mobileToggle: "[data-files-mobile-toggle]",
		backdrop: ".files-sidebar-backdrop",
		collapsedClass: "files-sidebar--collapsed"
	},
	{
		sidebar: ".storage-sidebar",
		toggle: "[data-storage-sidebar-toggle]",
		mobileToggle: "[data-storage-mobile-toggle]",
		backdrop: ".storage-sidebar-backdrop",
		collapsedClass: "storage-sidebar--collapsed"
	}
];
function p(e, t = f) {
	e && r(e), document.querySelectorAll("[data-sidebar]").forEach(u), t.forEach(d);
}
//#endregion
export { e as SidebarComponent, r as configureSidebar, f as defaultLegacyConfigs, a as getStoredState, p as initSidebar, i as isMobile, o as saveState };

//# sourceMappingURL=index.js.map