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 { Grid, Typography, makeStyles } from "@material-ui/core";
import { Sparklines, SparklinesLine } from "react-sparklines";
//#region src/UI/widgets/library/SparklineWidget/SparklineWidget.jsx
const layout = {
	w: {
		default: 2,
		min: 0,
		max: 4
	},
	h: {
		default: 2,
		min: 0,
		max: 4
	}
};
const useStyles = makeStyles((theme) => ({ statList: {
	display: "flex",
	flexDirection: "row",
	justifyContent: "space-between"
} }));
const SparklineWidget = (props, ref) => {
	const $ = c(16);
	const classes = useStyles();
	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] !== classes.statList || $[6] !== dateRange || $[7] !== 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)), /* @__PURE__ */ React.createElement("div", { className: classes.statList }, mockData?.stats?.map(_temp)), /* @__PURE__ */ React.createElement(Sparklines, {
			data: mockData?.data,
			strokeWidth: .5
		}, /* @__PURE__ */ React.createElement(SparklinesLine, { color: "#067e7e" })), children) : /* @__PURE__ */ React.createElement(Typography, { variant: "subtitle2" }, "Could not retrieve widget data. Please contact support.");
		$[4] = children;
		$[5] = classes.statList;
		$[6] = dateRange;
		$[7] = mockData;
		$[8] = t1;
	} else t1 = $[8];
	let t2;
	if ($[9] !== classes.root || $[10] !== other || $[11] !== ref || $[12] !== t0 || $[13] !== t1 || $[14] !== theme) {
		t2 = /* @__PURE__ */ React.createElement(WidgetCard, {
			className: classes.root,
			theme,
			ref,
			...other,
			title: t0
		}, t1);
		$[9] = classes.root;
		$[10] = other;
		$[11] = ref;
		$[12] = t0;
		$[13] = t1;
		$[14] = theme;
		$[15] = t2;
	} else t2 = $[15];
	return t2;
};
var SparklineWidget_default = forwardRef(SparklineWidget);
function _temp(stat) {
	return /* @__PURE__ */ React.createElement(Grid, {
		item: true,
		key: stat.label
	}, /* @__PURE__ */ React.createElement(FluentStatsSnippet, {
		label: stat.label,
		amount: stat.amount,
		percent: stat.percent && stat.percent,
		trend: stat.trend
	}));
}
//#endregion
export { SparklineWidget_default as default, layout };

//# sourceMappingURL=SparklineWidget.mjs.map