import { n as __exportAll } from "./chunk-B-1-B7_t.js";
import { n as cn } from "./utils-DXzSsU1e.js";
import { computed, createBlock, createElementBlock, defineAsyncComponent, defineComponent, normalizeClass, normalizeStyle, openBlock, resolveDynamicComponent, unref } from "vue";
//#region src/components/compositions/elements/display/ChartDisplay.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = ["data-chart-type"];
var _hoisted_2 = {
	key: 1,
	"aria-hidden": "true",
	"data-chart-placeholder": "true"
};
var ChartDisplay_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "ChartDisplay",
	props: {
		chartType: { default: "line" },
		data: {},
		options: {},
		width: { default: "100%" },
		height: { default: 300 },
		classList: {}
	},
	setup(__props) {
		/**
		* Props-driven chart display.
		*
		* Renders any of Chart.js's standard chart types via `vue-chartjs`.
		* `chart.js` and `vue-chartjs` are loaded via dynamic `import()` rather
		* than static imports so consumer apps that don't use `ChartDisplay`
		* never have to install them. Vite/Rollup emit a separate chunk for
		* the chart libraries and only fetch it when a chart actually renders.
		*
		* Chart.js is tree-shakable — controllers, scales, elements, and
		* plugins must be registered once before a chart can render. That
		* `Chart.register(...)` call happens lazily inside the async loader,
		* gated by a singleton promise so the registration only runs once
		* per page no matter how many ChartDisplay instances mount.
		*
		* If a 2D canvas context can't be acquired (jsdom, SSR, hardened
		* browsers without canvas), the component renders an inert placeholder
		* canvas instead of triggering the dynamic import — this keeps
		* consumer tests in jsdom-based environments quiet and crash-free.
		*/
		const props = __props;
		const canvasSupported = (() => {
			if (typeof document === "undefined") return false;
			if (typeof navigator !== "undefined" && /jsdom/i.test(navigator.userAgent)) return false;
			try {
				return !!document.createElement("canvas").getContext("2d");
			} catch {
				return false;
			}
		})();
		let chartLibPromise = null;
		function loadChartLib() {
			if (!chartLibPromise) chartLibPromise = (async () => {
				const [chartjs, vueChartjs] = await Promise.all([import("./chart-Cjdyl0OY.js"), import("./dist-C4bSm1Ea.js")]);
				chartjs.Chart.register(chartjs.CategoryScale, chartjs.LinearScale, chartjs.RadialLinearScale, chartjs.BarElement, chartjs.LineElement, chartjs.PointElement, chartjs.ArcElement, chartjs.BarController, chartjs.LineController, chartjs.PieController, chartjs.DoughnutController, chartjs.RadarController, chartjs.PolarAreaController, chartjs.BubbleController, chartjs.ScatterController, chartjs.Tooltip, chartjs.Legend, chartjs.Title, chartjs.Filler);
				return vueChartjs;
			})();
			return chartLibPromise;
		}
		const componentMap = {
			line: defineAsyncComponent(async () => (await loadChartLib()).Line),
			bar: defineAsyncComponent(async () => (await loadChartLib()).Bar),
			pie: defineAsyncComponent(async () => (await loadChartLib()).Pie),
			doughnut: defineAsyncComponent(async () => (await loadChartLib()).Doughnut),
			radar: defineAsyncComponent(async () => (await loadChartLib()).Radar),
			polarArea: defineAsyncComponent(async () => (await loadChartLib()).PolarArea),
			bubble: defineAsyncComponent(async () => (await loadChartLib()).Bubble),
			scatter: defineAsyncComponent(async () => (await loadChartLib()).Scatter)
		};
		const chartComponent = computed(() => componentMap[props.chartType] ?? componentMap.line);
		const wrapperClass = computed(() => {
			const cl = props.classList;
			const base = "relative";
			if (!cl) return base;
			return cn(base, Array.isArray(cl) ? cl.join(" ") : cl);
		});
		const dimensionStyle = computed(() => {
			const toCss = (v) => typeof v === "number" ? `${v}px` : v;
			return {
				width: toCss(props.width),
				height: toCss(props.height)
			};
		});
		const mergedOptions = computed(() => ({
			responsive: true,
			maintainAspectRatio: false,
			...props.options ?? {}
		}));
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", {
				class: normalizeClass(wrapperClass.value),
				style: normalizeStyle(dimensionStyle.value),
				"data-testid": "chart-display",
				"data-chart-type": __props.chartType
			}, [unref(canvasSupported) ? (openBlock(), createBlock(resolveDynamicComponent(chartComponent.value), {
				key: 0,
				data: __props.data,
				options: mergedOptions.value
			}, null, 8, ["data", "options"])) : (openBlock(), createElementBlock("canvas", _hoisted_2))], 14, _hoisted_1);
		};
	}
});
//#endregion
//#region src/components/compositions/elements/display/ChartDisplay.vue
var ChartDisplay_exports = /* @__PURE__ */ __exportAll({ default: () => ChartDisplay_default });
var ChartDisplay_default = ChartDisplay_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { ChartDisplay_exports as n, ChartDisplay_default as t };

//# sourceMappingURL=ChartDisplay-Bygrbntn.js.map