import { I as __exportAll } from "./portal_tenant_content-DPLnrtOG.mjs";
import { i as getBorderColorField, l as getColorField, m as getPaddingField, n as borderWidthClasses, o as getBorderRadiusField, p as getHeightField, s as getBorderWidthField, t as borderColorClasses, u as getFontSizeField } from "./registries-kvRRUHcO.mjs";
import { Ct as ChartTooltipContent, St as ChartTooltip, bt as ChartLegend, wt as Card, xt as ChartLegendContent, yt as ChartContainer } from "./src-B3W228vu.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
import { Area, AreaChart, Bar, BarChart, CartesianGrid, Line, LineChart, Pie, PieChart, XAxis, YAxis } from "recharts";
//#region ../widgets/src/widgets/ChartWidget.tsx
var ChartWidget_exports = /* @__PURE__ */ __exportAll({
	ChartWidget: () => ChartWidget,
	chartWidgetPropertySchema: () => chartWidgetPropertySchema
});
const defaultData = [
	{
		name: "Jan",
		value: 186
	},
	{
		name: "Feb",
		value: 305
	},
	{
		name: "Mar",
		value: 237
	},
	{
		name: "Apr",
		value: 273
	},
	{
		name: "May",
		value: 209
	},
	{
		name: "Jun",
		value: 214
	}
];
const defaultPieData = [
	{
		name: "Jan",
		value: 186,
		fill: "var(--chart-1)"
	},
	{
		name: "Feb",
		value: 305,
		fill: "var(--chart-2)"
	},
	{
		name: "Mar",
		value: 237,
		fill: "var(--chart-3)"
	},
	{
		name: "Apr",
		value: 273,
		fill: "var(--chart-4)"
	},
	{
		name: "May",
		value: 209,
		fill: "var(--chart-5)"
	}
];
const defaultChartConfig = { value: {
	label: "Value",
	color: "var(--chart-1)"
} };
function ChartWidget({ titleEnabled = true, title = "Chart Widget", titleFontSize = "lg", titleColor = "foreground", description = "Displaying sample data", descriptionFontSize = "md", descriptionColor = "foreground", chartType = "bar", showLegend = false, showTooltip = true, showGrid = true, width = "100%", height = "300px", background = {
	type: "solid",
	color: "background"
}, padding = 4, borderRadius = "md", borderWidth = "none", borderColor = "muted", dataKey = "value", xAxisKey = "name", data, chartConfig, className, ...props }) {
	const backgroundColor = background.color || "background";
	const backgroundImage = (background.resource?.image_url || background.resource?.imageUrl) && background.type === "image" ? `url(${background.resource.image_url || background.resource.imageUrl})` : "none";
	const chartData = data ?? defaultData;
	const chartPieData = chartType === "pie" && data ? data.map((item, index) => ({
		...item,
		fill: `var(--chart-${index % 5 + 1})`
	})) : defaultPieData;
	const config = chartConfig ?? defaultChartConfig;
	const chartElement = (() => {
		switch (chartType) {
			case "bar": return /* @__PURE__ */ jsxs(BarChart, {
				data: chartData,
				children: [
					showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
					/* @__PURE__ */ jsx(XAxis, { dataKey: xAxisKey }),
					/* @__PURE__ */ jsx(YAxis, {}),
					showTooltip && /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
					showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
					/* @__PURE__ */ jsx(Bar, {
						dataKey,
						fill: "var(--color-value)",
						radius: 8
					})
				]
			});
			case "line": return /* @__PURE__ */ jsxs(LineChart, {
				data: chartData,
				children: [
					showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
					/* @__PURE__ */ jsx(XAxis, { dataKey: xAxisKey }),
					/* @__PURE__ */ jsx(YAxis, {}),
					showTooltip && /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
					showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
					/* @__PURE__ */ jsx(Line, {
						type: "monotone",
						dataKey,
						stroke: "var(--color-value)",
						strokeWidth: 2,
						dot: { r: 4 }
					})
				]
			});
			case "area": return /* @__PURE__ */ jsxs(AreaChart, {
				data: chartData,
				children: [
					showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
					/* @__PURE__ */ jsx(XAxis, { dataKey: xAxisKey }),
					/* @__PURE__ */ jsx(YAxis, {}),
					showTooltip && /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
					showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
					/* @__PURE__ */ jsx(Area, {
						type: "monotone",
						dataKey,
						stroke: "var(--color-value)",
						fill: "var(--color-value)",
						fillOpacity: .6
					})
				]
			});
			case "pie": return /* @__PURE__ */ jsxs(PieChart, { children: [
				showTooltip && /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, { hideLabel: true }) }),
				showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
				/* @__PURE__ */ jsx(Pie, {
					data: chartPieData,
					dataKey,
					nameKey: xAxisKey,
					cx: "50%",
					cy: "50%",
					outerRadius: 80,
					label: true
				})
			] });
			default: return /* @__PURE__ */ jsxs(BarChart, {
				data: chartData,
				children: [
					showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
					/* @__PURE__ */ jsx(XAxis, { dataKey: xAxisKey }),
					/* @__PURE__ */ jsx(YAxis, {}),
					showTooltip && /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
					showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
					/* @__PURE__ */ jsx(Bar, {
						dataKey,
						fill: "var(--color-value)",
						radius: 8
					})
				]
			});
		}
	})();
	return /* @__PURE__ */ jsx(Card, {
		className: `bg-${backgroundColor} p-${padding} rounded-${borderRadius} ${borderWidthClasses[borderWidth]} ${borderWidth !== "none" ? borderColorClasses[borderColor] : ""} ${className}`,
		style: {
			width,
			maxWidth: "100%",
			backgroundImage
		},
		...props,
		children: /* @__PURE__ */ jsxs("div", {
			className: "p-6",
			children: [/* @__PURE__ */ jsxs("div", {
				className: "mb-4",
				children: [titleEnabled && /* @__PURE__ */ jsx("h3", {
					className: `text-${titleFontSize} text-${titleColor} font-header font-bold`,
					children: title
				}), description && /* @__PURE__ */ jsx("p", {
					className: `text-${descriptionFontSize} text-${descriptionColor}`,
					children: description
				})]
			}), /* @__PURE__ */ jsx(ChartContainer, {
				config,
				style: { height },
				children: chartElement
			})]
		})
	});
}
const chartWidgetPropertySchema = {
	widgetType: "ChartWidget",
	displayName: "Chart",
	tabsConfig: [{
		id: "styling",
		label: "Styling"
	}, {
		id: "data",
		label: "Data"
	}],
	dataSourceTargetProps: ["data", "chartConfig"],
	fields: [
		{
			key: "titleEnabled",
			label: "Widget Title",
			type: "boolean",
			description: "Enable the title displayed above the chart",
			defaultValue: true,
			tab: "styling",
			group: "Title"
		},
		{
			key: "title",
			label: "Title",
			type: "text",
			description: "The chart title",
			defaultValue: "Chart Widget",
			tab: "styling",
			group: "Title",
			requiresKeyToBeTrue: "titleEnabled"
		},
		getFontSizeField({
			key: "titleFontSize",
			label: "Title Font Size",
			description: "Font size for the chart title",
			defaultValue: "lg",
			tab: "styling",
			group: "Title",
			requiresKeyToBeTrue: "titleEnabled"
		}),
		getColorField({
			key: "titleColor",
			label: "Title Color",
			description: "Color for the chart title",
			defaultValue: "foreground",
			tab: "styling",
			group: "Title",
			requiresKeyToBeTrue: "titleEnabled"
		}),
		{
			key: "description",
			label: "Description",
			type: "textarea",
			description: "The chart description",
			rows: 2,
			defaultValue: "Displaying sample data",
			tab: "styling",
			group: "Description"
		},
		getFontSizeField({
			key: "descriptionFontSize",
			label: "Description Font Size",
			description: "Font size for the chart description",
			defaultValue: "md",
			tab: "styling",
			group: "Description"
		}),
		getColorField({
			key: "descriptionColor",
			label: "Description Color",
			description: "Color for the chart description",
			defaultValue: "foreground",
			tab: "styling",
			group: "Description"
		}),
		{
			key: "chartType",
			label: "Chart Type",
			type: "select",
			description: "Type of chart to display",
			options: [
				{
					label: "Bar Chart",
					value: "bar"
				},
				{
					label: "Line Chart",
					value: "line"
				},
				{
					label: "Area Chart",
					value: "area"
				},
				{
					label: "Pie Chart",
					value: "pie"
				}
			],
			defaultValue: "bar",
			tab: "styling",
			group: "Design"
		},
		{
			key: "showLegend",
			label: "Show Legend",
			type: "boolean",
			description: "Display chart legend",
			defaultValue: false,
			tab: "styling",
			group: "Design"
		},
		{
			key: "showTooltip",
			label: "Show Tooltip",
			type: "boolean",
			description: "Display tooltip on hover",
			defaultValue: true,
			tab: "styling",
			group: "Design"
		},
		{
			key: "showGrid",
			label: "Show Grid",
			type: "boolean",
			description: "Display background grid lines",
			defaultValue: true,
			tab: "styling",
			group: "Design"
		},
		{
			key: "separator",
			type: "separator",
			label: "Separator",
			tab: "styling",
			group: "Design"
		},
		{
			key: "width",
			label: "Width",
			type: "text",
			description: "Width of the chart container (CSS value, e.g., 100%, 600px)",
			defaultValue: "100%",
			tab: "styling",
			group: "Design"
		},
		getHeightField({
			key: "height",
			label: "Height",
			description: "Height of the chart",
			defaultValue: "300px",
			tab: "styling",
			group: "Design"
		}),
		{
			key: "separator2",
			type: "separator",
			label: "Separator",
			tab: "styling",
			group: "Design"
		},
		{
			type: "background",
			key: "background",
			label: "Background",
			description: "Background for the chart container",
			defaultValue: "background",
			tab: "styling",
			group: "Design"
		},
		getPaddingField({
			key: "padding",
			label: "Padding",
			description: "Padding for the chart container",
			defaultValue: 4,
			tab: "styling",
			group: "Design"
		}),
		getBorderRadiusField({
			key: "borderRadius",
			label: "Border Radius",
			description: "Border radius for the chart container",
			defaultValue: "md",
			tab: "styling",
			group: "Design"
		}),
		getBorderWidthField({
			key: "borderWidth",
			label: "Border Width",
			description: "Border width for the widget",
			defaultValue: "none",
			tab: "styling",
			group: "Design"
		}),
		getBorderColorField({
			key: "borderColor",
			label: "Border Color",
			description: "Border color for the widget",
			defaultValue: "muted",
			tab: "styling",
			group: "Design"
		}),
		{
			key: "dataSource",
			label: "Data Source",
			type: "dataSource",
			description: "Configure dynamic data fetching from an API",
			tab: "data",
			group: "Data"
		},
		{
			key: "dataKey",
			label: "Data Key",
			type: "select",
			description: "Key in the data to use for chart values",
			options: [{
				label: "value",
				value: "value"
			}],
			defaultValue: "value",
			tab: "data",
			group: "Data"
		},
		{
			key: "xAxisKey",
			label: "X-Axis Key",
			type: "select",
			description: "Key in the data to use for X-axis labels",
			options: [{
				label: "name",
				value: "name"
			}],
			defaultValue: "name",
			tab: "data",
			group: "Data"
		}
	]
};
//#endregion
export { ChartWidget_exports as n, chartWidgetPropertySchema as r, ChartWidget as t };

//# sourceMappingURL=ChartWidget-CIscUHUD.mjs.map