import WidgetCard from "../../WidgetCard.mjs";
import FluentStatsSnippet from "../../FluentComponents/atoms/FluentStatsSnippet.mjs";
import { convertISODate } from "../../utils/ConvertISODate.mjs";
import { c } from "react-compiler-runtime";
import React, { Fragment, forwardRef } from "react";
import { Box, Grid, Typography } from "@material-ui/core";
import { MuiVegaLite } from "@material-vega/material-ui";
//#region src/UI/widgets/library/LineGraphWidget/LineGraphWidget.jsx
const layout = {
	w: {
		default: 2,
		min: 0,
		max: 4
	},
	h: {
		default: 2,
		min: 0,
		max: 4
	}
};
const params = { mode: { defaultValue: "chart" } };
const LineGraphWidget = (props, ref) => {
	const $ = c(14);
	let children;
	let other;
	let params;
	if ($[0] !== props) {
		const { children: t0, params: t1, setParam, ...t2 } = props;
		children = t0;
		params = t1;
		other = t2;
		$[0] = props;
		$[1] = children;
		$[2] = other;
		$[3] = params;
	} else {
		children = $[1];
		other = $[2];
		params = $[3];
	}
	const { mockData, theme, dateRange } = params;
	const t0 = mockData?.title;
	let t1;
	if ($[4] !== children || $[5] !== dateRange || $[6] !== mockData) {
		t1 = mockData ? /* @__PURE__ */ React.createElement(Fragment, null, dateRange && /* @__PURE__ */ React.createElement(Typography, {
			gutterBottom: true,
			variant: "caption",
			component: "h3"
		}, "From: ", convertISODate(dateRange.from), " to:", " ", convertISODate(dateRange.to), " "), mockData?.stats && /* @__PURE__ */ React.createElement(Grid, { container: true }, mockData?.stats.map(_temp)), /* @__PURE__ */ React.createElement(Box, {
			clone: true,
			flex: 1,
			mt: 1,
			overflow: "hidden"
		}, /* @__PURE__ */ React.createElement(MuiVegaLite, {
			variant: "lineChart",
			color: "secondary",
			spec: {
				$schema: "https://vega.github.io/schema/vega-lite/v4.json",
				description: mockData?.description,
				data: { values: mockData?.data },
				mark: "line",
				encoding: {
					x: {
						field: "xAxis",
						type: mockData?.xAxisType
					},
					y: {
						field: "yAxis",
						type: mockData?.yAxisType
					},
					color: {
						field: "label",
						type: "nominal",
						legend: {
							direction: "vertical",
							orient: "right"
						}
					}
				}
			},
			width: "container",
			height: "container",
			autoResize: "true"
		})), children) : /* @__PURE__ */ React.createElement(Typography, { variant: "subtitle2" }, "Could not retrieve widget data. Please contact support.");
		$[4] = children;
		$[5] = dateRange;
		$[6] = mockData;
		$[7] = t1;
	} else t1 = $[7];
	let t2;
	if ($[8] !== other || $[9] !== ref || $[10] !== t0 || $[11] !== t1 || $[12] !== theme) {
		t2 = /* @__PURE__ */ React.createElement(WidgetCard, {
			ref,
			...other,
			title: t0,
			theme
		}, t1);
		$[8] = other;
		$[9] = ref;
		$[10] = t0;
		$[11] = t1;
		$[12] = theme;
		$[13] = t2;
	} else t2 = $[13];
	return t2;
};
var LineGraphWidget_default = forwardRef(LineGraphWidget);
function _temp(stat) {
	return /* @__PURE__ */ React.createElement(Grid, {
		item: true,
		xs: 3,
		key: stat.label
	}, /* @__PURE__ */ React.createElement(FluentStatsSnippet, {
		label: stat.label,
		amount: stat.currentValue,
		prevAmount: stat.previousValue
	}));
}
//#endregion
export { LineGraphWidget_default as default, layout, params };

//# sourceMappingURL=LineGraphWidget.mjs.map