import { t as e } from "../utils-CSEWuKHo.js";
import { TopMenuBar as t } from "./app-shell.js";
import { t as n } from "../component-D5sRm1fq.js";
//#region src/layout/core-app-chrome.ts
var r = "[data-core-app-sidebar]", i = "[data-core-app-topbar]", a = "[data-core-app-topbar-action]", o = [
	{
		id: "dashboards",
		label: "Dashboards",
		items: [
			{
				id: "library",
				label: "Library",
				href: "/",
				icon: "library",
				end: !0
			},
			{
				id: "capacity",
				label: "Capacity",
				href: "/capacity",
				icon: "capacity"
			},
			{
				id: "operational-alerts",
				label: "Operational Alerts",
				href: "/alerts",
				icon: "alerts"
			}
		]
	},
	{
		id: "threat-library",
		label: "Threat Library",
		items: [
			{
				id: "detections",
				label: "Detections",
				href: "/detections",
				icon: "detections"
			},
			{
				id: "actors",
				label: "Actors",
				href: "/actors",
				icon: "actors"
			},
			{
				id: "library-reports",
				label: "Library Reports",
				href: "/intel",
				icon: "intel-reports"
			},
			{
				id: "mitre",
				label: "MITRE ATT&CK",
				href: "/mitre",
				icon: "mitre"
			}
		]
	},
	{
		id: "library-operations",
		label: "Library Operations",
		items: [{
			id: "pipeline",
			label: "Pipeline",
			href: "/pipeline",
			icon: "pipeline"
		}]
	},
	{
		id: "integrations",
		label: "Integrations",
		items: [{
			id: "connectors",
			label: "Connectors",
			href: "/connectors",
			icon: "connectors"
		}, {
			id: "jobs",
			label: "Jobs",
			href: "/jobs",
			icon: "jobs"
		}]
	},
	{
		id: "platform",
		label: "Platform",
		items: [
			{
				id: "tenants",
				label: "Tenants",
				href: "/tenants",
				icon: "tenants"
			},
			{
				id: "runners",
				label: "Runners",
				href: "/runners",
				icon: "runners"
			},
			{
				id: "topology",
				label: "Topology",
				href: "/topology",
				icon: "topology"
			},
			{
				id: "api-access",
				label: "API Access",
				href: "/api-access",
				icon: "api-access"
			}
		]
	}
], s = [
	{
		pattern: /^\/(?:dashboards\/)?capacity(?:\/|$)/,
		label: "Capacity"
	},
	{
		pattern: /^\/(?:dashboards\/)?alerts(?:\/|$)/,
		label: "Operational Alerts"
	},
	{
		pattern: /^\/dashboards\/library(?:\/|$)/,
		label: "Library Dashboard"
	},
	{
		pattern: /^\/detections(?:\/|$)/,
		label: "Detections"
	},
	{
		pattern: /^\/actors(?:\/|$)/,
		label: "Actors"
	},
	{
		pattern: /^\/intel(?:\/|$)/,
		label: "Library Reports"
	},
	{
		pattern: /^\/mitre(?:\/|$)/,
		label: "MITRE ATT&CK"
	},
	{
		pattern: /^\/pipeline(?:\/|$)/,
		label: "Pipeline"
	},
	{
		pattern: /^\/connectors(?:\/|$)/,
		label: "Connectors"
	},
	{
		pattern: /^\/jobs(?:\/|$)/,
		label: "Jobs"
	},
	{
		pattern: /^\/topology(?:\/|$)/,
		label: "Topology"
	},
	{
		pattern: /^\/tenants(?:\/|$)/,
		label: "Tenants"
	},
	{
		pattern: /^\/runners(?:\/|$)/,
		label: "Runners"
	},
	{
		pattern: /^\/api-access(?:\/|$)/,
		label: "API Access"
	},
	{
		pattern: /^\/settings(?:\/|$)/,
		label: "Settings"
	}
];
function c(e) {
	let t = e.trim();
	return t === "" || t === "/" ? "" : `/${t.replace(/^\/+|\/+$/g, "")}`;
}
function l(e, t) {
	let n = c(e);
	return t === "/" || t === "" ? n || "/" : `${n}/${t.replace(/^\/+/, "")}`;
}
function u(e, t) {
	let n = c(t);
	return n === "" ? e || "/" : e === n ? "/" : e.startsWith(`${n}/`) ? e.slice(n.length) || "/" : e || "/";
}
function d(e) {
	return e.map((e) => ({
		...e,
		items: e.items.map((e) => ({ ...e }))
	}));
}
function f(e = "/app") {
	return o.map((t) => ({
		id: t.id,
		label: t.label,
		items: t.items.map((t) => {
			let n = {
				id: t.id,
				label: t.label,
				href: l(e, t.href),
				icon: t.icon,
				tooltip: t.label,
				activeMatch: t.end === !0 ? "exact" : "prefix"
			};
			return t.end !== void 0 && (n.end = t.end), n;
		})
	}));
}
function p(e, t = "/app") {
	let n = u(e, t);
	return n === "/" || n === "" ? "Platform Overview" : s.find((e) => e.pattern.test(n))?.label ?? "Threat Library";
}
function m(e = {}) {
	let { basePath: t = "/app", sections: n, variant: r = "cm", brand: i, scope: a, beforeNav: o, afterNav: s, collapsible: c = !0, collapseButtonVisible: u = !0, user: p, footerActions: m, iconSet: h, collapsed: g, activeItemId: _, pathname: v, storageKey: y = "cm-sidebar-collapsed", persistCollapsed: b, mobileBreakpoint: x, mobileBackdrop: S = !0, closeOnNavigate: C = !0, open: w, onNavigate: T, onCollapse: E, onOpenChange: D } = e, O = i ?? {
		label: "CounterMeasure",
		href: l(t, "/")
	}, k = {
		variant: r,
		sections: n === void 0 ? f(t) : d(n),
		brand: O,
		collapsible: c,
		collapseButtonVisible: u,
		storageKey: y,
		mobileBackdrop: S,
		closeOnNavigate: C
	};
	return a !== void 0 && (k.scope = a), o !== void 0 && (k.beforeNav = o), s !== void 0 && (k.afterNav = s), p !== void 0 && (k.user = p), m !== void 0 && (k.footerActions = m), h !== void 0 && (k.iconSet = h), g !== void 0 && (k.collapsed = g), _ !== void 0 && (k.activeItemId = _), v !== void 0 && (k.pathname = v), b !== void 0 && (k.persistCollapsed = b), x !== void 0 && (k.mobileBreakpoint = x), w !== void 0 && (k.open = w), T !== void 0 && (k.onNavigate = T), E !== void 0 && (k.onCollapse = E), D !== void 0 && (k.onOpenChange = D), k;
}
function h(e = {}) {
	let { includeSearchAction: t = !0, includeFeedbackAction: n = !0, includeHelpAction: r = !0 } = e, i = [];
	return t && i.push({
		id: "search",
		label: "Find...",
		icon: "search",
		showLabel: !0,
		className: "cmm-topbar__action--search",
		attributes: { "data-app-search-trigger": !0 }
	}), n && i.push({
		id: "feedback",
		label: "Feedback",
		showLabel: !0,
		attributes: { "data-feedback-toggle": !0 }
	}), r && i.push({
		id: "help",
		label: "Help",
		icon: "help",
		attributes: { "data-help-toggle": !0 }
	}), i;
}
function g(e = {}) {
	let { basePath: t = "/app", pathname: n = typeof window > "u" ? "/" : window.location.pathname, product: r = "CounterMeasure Core", current: i = p(n, t), actions: a, beforeActions: o, afterActions: s, user: c, iconSet: l, className: u, breadcrumbs: d, container: f, includeSearchAction: m, includeFeedbackAction: g, includeHelpAction: _ } = e, v = {};
	m !== void 0 && (v.includeSearchAction = m), g !== void 0 && (v.includeFeedbackAction = g), _ !== void 0 && (v.includeHelpAction = _);
	let y = {
		product: r,
		current: i,
		actions: a ?? h(v)
	};
	return f !== void 0 && (y.container = f), d !== void 0 && (y.breadcrumbs = d), o !== void 0 && (y.beforeActions = o), s !== void 0 && (y.afterActions = s), c !== void 0 && (y.user = c), l !== void 0 && (y.iconSet = l), u !== void 0 && (y.className = u), y;
}
function _(e = {}) {
	let { basePath: t = "/app", pathname: n, scope: r, sidebarUser: i, sidebarFooterActions: a, topbarUser: o, topbarActions: s } = e, c = { basePath: t };
	r !== void 0 && (c.scope = r), i !== void 0 && (c.user = i), a !== void 0 && (c.footerActions = a), n !== void 0 && (c.pathname = n);
	let l = { basePath: t };
	return n !== void 0 && (l.pathname = n), o !== void 0 && (l.user = o), s !== void 0 && (l.actions = s), {
		sidebar: m(c),
		topbar: g(l)
	};
}
function v(e, t) {
	t !== !1 && e.replaceChildren();
}
function y(e) {
	return e.preserveTopbarActions === !1 ? [] : Array.from(e.container.querySelectorAll(e.selector ?? a));
}
function b(e, t) {
	return t.length === 0 ? e : e === void 0 ? t : Array.isArray(e) ? [...e, ...t] : [e, ...t];
}
function x(e, t) {
	return e.some((e) => e.hasAttribute(t));
}
function S(e, t) {
	e.actions !== void 0 || t.length === 0 || (e.includeSearchAction === void 0 && x(t, "data-app-search-trigger") && (e.includeSearchAction = !1), e.includeFeedbackAction === void 0 && x(t, "data-feedback-toggle") && (e.includeFeedbackAction = !1), e.includeHelpAction === void 0 && x(t, "data-help-toggle") && (e.includeHelpAction = !1));
}
function C(e) {
	let t = e.sidebar?.basePath ?? e.basePath ?? "/app", n = {
		...e.sidebar,
		basePath: t
	};
	return e.scope !== void 0 && (n.scope = e.scope), e.sidebarUser !== void 0 && (n.user = e.sidebarUser), e.sidebarFooterActions !== void 0 && (n.footerActions = e.sidebarFooterActions), e.pathname !== void 0 && n.pathname === void 0 && (n.pathname = e.pathname), n;
}
function w(e, t, n) {
	let r = e.topbar?.basePath ?? e.basePath ?? "/app", i = {
		...e.topbar,
		basePath: r,
		container: t
	}, a = b(e.topbar?.afterActions, n);
	return e.pathname !== void 0 && (i.pathname = e.pathname), e.topbarUser !== void 0 && (i.user = e.topbarUser), e.topbarActions !== void 0 && (i.actions = e.topbarActions), a !== void 0 && (i.afterActions = a), S(i, n), i;
}
function T(r) {
	let i = e(r.sidebarContainer);
	v(i, r.clearContainers);
	let a = new n({
		container: i,
		...m(C(r))
	}), o = r.topbarContainer ?? r.topbar?.container, s = o === void 0 ? void 0 : e(o), c;
	if (s !== void 0) {
		let e = y({
			container: s,
			preserveTopbarActions: r.preserveTopbarActions,
			selector: r.topbarActionSelector
		});
		v(s, r.clearContainers), c = new t(g(w(r, s, e)));
	}
	let l = {
		sidebar: a,
		destroy: () => {
			c?.destroy(), a.destroy();
		}
	};
	return c !== void 0 && (l.topbar = c), l;
}
function E(e, t) {
	let n = e?.dataset[t];
	return n === void 0 || n.length === 0 ? void 0 : n;
}
function D(e, t, n) {
	let r = e.topbar?.product ?? E(n ?? void 0, "product") ?? E(t, "product"), i = e.topbar?.current ?? E(n ?? void 0, "current") ?? E(t, "current");
	if (e.topbar === void 0 && r === void 0 && i === void 0) return;
	let a = { ...e.topbar ?? {} };
	return r !== void 0 && (a.product = r), i !== void 0 && (a.current = i), a;
}
function O(e = {}) {
	let t = e.root ?? document, n = t.querySelector(e.sidebarSelector ?? r);
	if (n === null) return null;
	let a = t.querySelector(e.topbarSelector ?? i), o = e.basePath ?? e.sidebar?.basePath ?? e.topbar?.basePath ?? E(n, "basePath") ?? E(a ?? void 0, "basePath") ?? "/app", s = e.pathname ?? E(n, "pathname") ?? E(a ?? void 0, "pathname"), c = {
		...e,
		sidebarContainer: n,
		basePath: o
	}, l = D(e, n, a);
	return l !== void 0 && (c.topbar = l), a !== null && (c.topbarContainer = a), s !== void 0 && (c.pathname = s), T(c);
}
//#endregion
export { s as CORE_APP_ROUTE_LABELS, _ as createCoreAppChromePreset, m as createCoreAppSidebarConfig, f as createCoreAppSidebarSections, h as createCoreAppTopbarActions, g as createCoreAppTopbarConfig, p as getCoreAppRouteLabel, T as mountCoreAppChrome, O as mountCoreAppChromeFromDom };

//# sourceMappingURL=core-app-chrome.js.map