import { c } from "react-compiler-runtime";
import React from "react";
import PropTypes from "prop-types";
import { Vega } from "react-vega";
//#region src/UI/widgets/library/GaugeWidget/GaugeWidget.jsx
const GaugeWidget = (props) => {
	const $ = c(86);
	const { title: t0, unitLabel: t1, legend: t2, showTicks: t3, ticksNumber: t4, backgroundColor: t5, fillColor: t6, value: t7, minValue: t8, maxValue: t9, handleHover: t10 } = props;
	const title = t0 === void 0 ? "" : t0;
	const unitLabel = t1 === void 0 ? "" : t1;
	const legend = t2 === void 0 ? "" : t2;
	const showTicks = t3 === void 0 ? false : t3;
	const ticksNumber = t4 === void 0 ? 6 : t4;
	const backgroundColor = t5 === void 0 ? "#cbd1d6" : t5;
	const fillColor = t6 === void 0 ? "#FF9800" : t6;
	const value = t7 === void 0 ? 0 : t7;
	const minValue = t8 === void 0 ? 0 : t8;
	const maxValue = t9 === void 0 ? 100 : t9;
	const handleHover = t10 === void 0 ? _temp : t10;
	let t11;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t11 = {
			left: 0,
			right: 0,
			top: 0,
			bottom: 0
		};
		$[0] = t11;
	} else t11 = $[0];
	let t12;
	let t13;
	let t14;
	let t15;
	let t16;
	let t17;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t12 = [{
			name: "ticks",
			transform: [
				{
					type: "sequence",
					as: "data",
					start: { signal: "0" },
					stop: { signal: "(maxValue - minValue) + 0.1" },
					step: { signal: "(maxValue - minValue)/(ticksNumber-1)" }
				},
				{
					type: "formula",
					expr: "datum.data + minValue",
					as: "data_2"
				},
				{
					type: "formula",
					as: "radianRef",
					expr: "PI * (datum.data/(maxValue - minValue))"
				},
				{
					type: "formula",
					as: "x",
					expr: "centerX - ((outerRadius - (outerRadius - innerRadius) * 0.6) * cos(datum.radianRef))"
				},
				{
					type: "formula",
					as: "y",
					expr: "centerY - ((outerRadius - (outerRadius - innerRadius) * 0.7) * sin(datum.radianRef))"
				}
			]
		}];
		t13 = {
			name: "centerX",
			update: "width/2"
		};
		t14 = {
			name: "centerY",
			update: "height/2 + outerRadius/2"
		};
		t15 = {
			name: "outerRadius",
			update: "targetValue ? radiusRef * 0.9 : radiusRef * 0.95"
		};
		t16 = {
			name: "radiusRef",
			update: "max(width/2, height/2)"
		};
		t17 = {
			name: "innerRadius",
			update: "outerRadius - outerRadius * 0.25"
		};
		$[1] = t12;
		$[2] = t13;
		$[3] = t14;
		$[4] = t15;
		$[5] = t16;
		$[6] = t17;
	} else {
		t12 = $[1];
		t13 = $[2];
		t14 = $[3];
		t15 = $[4];
		t16 = $[5];
		t17 = $[6];
	}
	let t18;
	if ($[7] !== value) {
		t18 = {
			name: "targetValue",
			value
		};
		$[7] = value;
		$[8] = t18;
	} else t18 = $[8];
	let t19;
	if ($[9] !== backgroundColor) {
		t19 = {
			name: "backgroundColor",
			value: backgroundColor
		};
		$[9] = backgroundColor;
		$[10] = t19;
	} else t19 = $[10];
	let t20;
	if ($[11] !== ticksNumber) {
		t20 = {
			name: "ticksNumber",
			value: ticksNumber
		};
		$[11] = ticksNumber;
		$[12] = t20;
	} else t20 = $[12];
	let t21;
	if ($[13] !== value) {
		t21 = {
			name: "mainValue",
			value
		};
		$[13] = value;
		$[14] = t21;
	} else t21 = $[14];
	let t22;
	if ($[15] !== title) {
		t22 = {
			name: "title",
			value: title
		};
		$[15] = title;
		$[16] = t22;
	} else t22 = $[16];
	let t23;
	if ($[17] !== unitLabel) {
		t23 = {
			name: "unit",
			value: unitLabel
		};
		$[17] = unitLabel;
		$[18] = t23;
	} else t23 = $[18];
	let t24;
	if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = {
			name: "usedValue",
			update: "min(max(minValue, mainValue), maxValue)"
		};
		$[19] = t24;
	} else t24 = $[19];
	let t25;
	if ($[20] !== minValue) {
		t25 = {
			name: "minValue",
			value: minValue
		};
		$[20] = minValue;
		$[21] = t25;
	} else t25 = $[21];
	let t26;
	if ($[22] !== maxValue) {
		t26 = {
			name: "maxValue",
			value: maxValue
		};
		$[22] = maxValue;
		$[23] = t26;
	} else t26 = $[23];
	let t27;
	if ($[24] !== fillColor) {
		t27 = {
			name: "fillColor",
			value: fillColor
		};
		$[24] = fillColor;
		$[25] = t27;
	} else t27 = $[25];
	let t28;
	if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
		t28 = {
			name: "ticksColor",
			value: "#000000"
		};
		$[26] = t28;
	} else t28 = $[26];
	let t29;
	if ($[27] !== showTicks) {
		t29 = {
			name: "showTicks",
			value: showTicks
		};
		$[27] = showTicks;
		$[28] = t29;
	} else t29 = $[28];
	let t30;
	let t31;
	let t32;
	let t33;
	let t34;
	let t35;
	if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
		t30 = {
			name: "fontFactor",
			update: "(radiusRef/5)/25"
		};
		t31 = {
			name: "hasTarget",
			update: "isNumber(targetValue) === true"
		};
		t32 = {
			name: "targetRule",
			update: "(showTarget && hasTarget && (minValue <= targetValue) && (targetValue <= maxValue)) ? 1 : 0"
		};
		t33 = {
			name: "showTarget",
			value: true
		};
		t34 = {
			name: "targetStatus",
			update: "mainValue === targetValue ? 0 : mainValue > targetValue ? lowIsGood ? -1 : 1 : lowIsGood ? 1 : -1"
		};
		t35 = {
			name: "lowIsGood",
			value: false
		};
		$[29] = t30;
		$[30] = t31;
		$[31] = t32;
		$[32] = t33;
		$[33] = t34;
		$[34] = t35;
	} else {
		t30 = $[29];
		t31 = $[30];
		t32 = $[31];
		t33 = $[32];
		t34 = $[33];
		t35 = $[34];
	}
	let t36;
	if ($[35] !== legend) {
		t36 = {
			name: "legend",
			value: legend
		};
		$[35] = legend;
		$[36] = t36;
	} else t36 = $[36];
	let t37;
	if ($[37] !== t18 || $[38] !== t19 || $[39] !== t20 || $[40] !== t21 || $[41] !== t22 || $[42] !== t23 || $[43] !== t25 || $[44] !== t26 || $[45] !== t27 || $[46] !== t29 || $[47] !== t36) {
		t37 = [
			t13,
			t14,
			t15,
			t16,
			t17,
			t18,
			t19,
			t20,
			t21,
			t22,
			t23,
			t24,
			t25,
			t26,
			t27,
			t28,
			t29,
			t30,
			t31,
			t32,
			t33,
			t34,
			t35,
			t36
		];
		$[37] = t18;
		$[38] = t19;
		$[39] = t20;
		$[40] = t21;
		$[41] = t22;
		$[42] = t23;
		$[43] = t25;
		$[44] = t26;
		$[45] = t27;
		$[46] = t29;
		$[47] = t36;
		$[48] = t37;
	} else t37 = $[48];
	let t38;
	if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
		t38 = {
			data: "ticks",
			field: "data_2"
		};
		$[49] = t38;
	} else t38 = $[49];
	let t39;
	if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
		t39 = {
			name: "gaugeScale",
			type: "linear",
			domain: t38,
			zero: false,
			range: { signal: "[-PI/2, PI/2]" }
		};
		$[50] = t39;
	} else t39 = $[50];
	let t40;
	if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
		t40 = {
			name: "tickScale",
			type: "linear",
			domain: {
				data: "ticks",
				field: "data"
			},
			range: { signal: "[PI/2, -PI/2]" }
		};
		$[51] = t40;
	} else t40 = $[51];
	let t41;
	let t42;
	let t43;
	if ($[52] === Symbol.for("react.memo_cache_sentinel")) {
		t41 = [
			t39,
			t40,
			{
				name: "targetStatusColorScale",
				domain: [
					-1,
					0,
					1
				],
				range: [
					"red",
					"orange",
					"green"
				]
			}
		];
		t42 = [];
		t43 = [];
		$[52] = t41;
		$[53] = t42;
		$[54] = t43;
	} else {
		t41 = $[52];
		t42 = $[53];
		t43 = $[54];
	}
	let t44;
	if ($[55] === Symbol.for("react.memo_cache_sentinel")) {
		t44 = {
			type: "arc",
			name: "gauge",
			encode: { enter: {
				x: { signal: "centerX" },
				y: { signal: "centerY" },
				startAngle: { signal: "-PI/2" },
				endAngle: { signal: "PI/2" },
				outerRadius: { signal: "outerRadius" },
				innerRadius: { signal: "innerRadius" },
				fill: { signal: "backgroundColor" }
			} }
		};
		$[55] = t44;
	} else t44 = $[55];
	let t45;
	if ($[56] === Symbol.for("react.memo_cache_sentinel")) {
		t45 = {
			type: "arc",
			encode: {
				enter: { startAngle: { signal: "-PI/2" } },
				update: {
					x: { signal: "centerX" },
					y: { signal: "centerY" },
					innerRadius: { signal: "innerRadius" },
					outerRadius: { signal: "outerRadius" },
					endAngle: {
						scale: "gaugeScale",
						signal: "usedValue"
					},
					fill: { signal: "fillColor" }
				}
			}
		};
		$[56] = t45;
	} else t45 = $[56];
	let t46;
	if ($[57] === Symbol.for("react.memo_cache_sentinel")) {
		t46 = {
			type: "arc",
			description: "ticks on the arc",
			from: { data: "ticks" },
			encode: { enter: {
				x: { signal: "centerX" },
				y: { signal: "centerY" },
				outerRadius: { signal: "outerRadius" },
				innerRadius: { signal: "outerRadius - (radiusRef*0.05)" },
				startAngle: {
					scale: "tickScale",
					field: "data"
				},
				endAngle: {
					scale: "tickScale",
					field: "data"
				},
				stroke: { signal: "ticksColor" },
				opacity: { signal: "showTicks ? 1 : 0" }
			} }
		};
		$[57] = t46;
	} else t46 = $[57];
	let t47;
	if ($[58] === Symbol.for("react.memo_cache_sentinel")) {
		t47 = {
			type: "text",
			from: { data: "ticks" },
			encode: {
				enter: {
					align: { value: "center" },
					baseline: { value: "alphabetic" }
				},
				update: {
					text: { signal: "format(datum.data_2, '.0f')" },
					x: { field: "x" },
					y: { field: "y" },
					fontSize: { signal: "fontFactor* 11" },
					fill: { signal: "ticksColor" },
					opacity: { signal: "showTicks ? 1 : 0" }
				}
			}
		};
		$[58] = t47;
	} else t47 = $[58];
	let t48;
	let t49;
	let t50;
	let t51;
	if ($[59] === Symbol.for("react.memo_cache_sentinel")) {
		t48 = { data: "gauge" };
		t49 = {
			align: { value: "center" },
			baseline: { value: "top" }
		};
		t50 = { signal: "minValue" };
		t51 = { signal: "centerX - outerRadius + (outerRadius - innerRadius)/2" };
		$[59] = t48;
		$[60] = t49;
		$[61] = t50;
		$[62] = t51;
	} else {
		t48 = $[59];
		t49 = $[60];
		t50 = $[61];
		t51 = $[62];
	}
	let t52;
	if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
		t52 = {
			type: "text",
			description: "displayed min value at the bottom left of gauge when showTicks is false",
			from: t48,
			encode: {
				enter: t49,
				update: {
					text: t50,
					x: t51,
					y: {
						signal: "centerY",
						offset: { signal: "fontFactor*5" }
					},
					fontSize: { signal: "fontFactor * 11" },
					opacity: { signal: "showTicks ? 0 : 1" }
				}
			}
		};
		$[63] = t52;
	} else t52 = $[63];
	let t53;
	let t54;
	let t55;
	let t56;
	if ($[64] === Symbol.for("react.memo_cache_sentinel")) {
		t53 = { data: "gauge" };
		t54 = {
			align: { value: "center" },
			baseline: { value: "top" }
		};
		t55 = { signal: "maxValue" };
		t56 = { signal: "centerX + innerRadius + (outerRadius - innerRadius)/2" };
		$[64] = t53;
		$[65] = t54;
		$[66] = t55;
		$[67] = t56;
	} else {
		t53 = $[64];
		t54 = $[65];
		t55 = $[66];
		t56 = $[67];
	}
	let t57;
	if ($[68] === Symbol.for("react.memo_cache_sentinel")) {
		t57 = {
			type: "text",
			description: "displayed max value at the bottom right of gauge when showTicks is false",
			from: t53,
			encode: {
				enter: t54,
				update: {
					text: t55,
					x: t56,
					y: {
						signal: "centerY",
						offset: { signal: "fontFactor*5" }
					},
					fontSize: { signal: "fontFactor * 11" },
					opacity: { signal: "showTicks ? 0 : 1" }
				}
			}
		};
		$[68] = t57;
	} else t57 = $[68];
	let t58;
	let t59;
	if ($[69] === Symbol.for("react.memo_cache_sentinel")) {
		t58 = {
			x: { signal: "centerX" },
			baseline: { value: "top" },
			align: { value: "center" }
		};
		t59 = { signal: "title" };
		$[69] = t58;
		$[70] = t59;
	} else {
		t58 = $[69];
		t59 = $[70];
	}
	let t60;
	if ($[71] === Symbol.for("react.memo_cache_sentinel")) {
		t60 = {
			type: "text",
			description: "displayed a title for the chart ",
			name: "titleLabel",
			encode: {
				enter: t58,
				update: {
					text: t59,
					y: {
						signal: "centerY",
						offset: { signal: "fontFactor * -50" }
					},
					fontSize: { signal: "fontFactor * 14" },
					fill: { signal: "fillColor" }
				}
			}
		};
		$[71] = t60;
	} else t60 = $[71];
	let t61;
	let t62;
	if ($[72] === Symbol.for("react.memo_cache_sentinel")) {
		t61 = {
			x: { signal: "centerX" },
			baseline: { value: "top" },
			align: { value: "center" }
		};
		t62 = { signal: "format(mainValue, '.1f') + unit " };
		$[72] = t61;
		$[73] = t62;
	} else {
		t61 = $[72];
		t62 = $[73];
	}
	let t63;
	if ($[74] === Symbol.for("react.memo_cache_sentinel")) {
		t63 = {
			type: "text",
			description: "displayed main value at the bottom center of the gauge ",
			name: "gaugeValue",
			encode: {
				enter: t61,
				update: {
					text: t62,
					y: {
						signal: "centerY",
						offset: { signal: "fontFactor * -25" }
					},
					fontSize: { signal: "fontFactor * 20" }
				}
			}
		};
		$[74] = t63;
	} else t63 = $[74];
	let t64;
	let t65;
	let t66;
	if ($[75] === Symbol.for("react.memo_cache_sentinel")) {
		t64 = { data: "gaugeValue" };
		t65 = {
			x: { signal: "centerX" },
			align: { value: "center" },
			baseline: { value: "top" }
		};
		t66 = { signal: "legend" };
		$[75] = t64;
		$[76] = t65;
		$[77] = t66;
	} else {
		t64 = $[75];
		t65 = $[76];
		t66 = $[77];
	}
	let t67;
	if ($[78] === Symbol.for("react.memo_cache_sentinel")) {
		t67 = [
			t44,
			t45,
			t46,
			t47,
			t52,
			t57,
			t60,
			t63,
			{
				type: "text",
				name: "targetDiff",
				description: "add status with symbol and difference and percentage",
				from: t64,
				encode: {
					enter: t65,
					update: {
						text: t66,
						y: {
							signal: "centerY",
							offset: { signal: "fontFactor * -4" }
						},
						fontSize: { signal: "fontFactor * 10" },
						opacity: { signal: " targetRule ? 1 : 0" }
					}
				}
			}
		];
		$[78] = t67;
	} else t67 = $[78];
	let t68;
	if ($[79] !== t37) {
		t68 = {
			$schema: "https://vega.github.io/schema/vega/v5.json",
			width: 350,
			height: 180,
			padding: t11,
			data: t12,
			signals: t37,
			scales: t41,
			axes: t42,
			legends: t43,
			marks: t67
		};
		$[79] = t37;
		$[80] = t68;
	} else t68 = $[80];
	const specs = t68;
	let t69;
	if ($[81] !== handleHover) {
		t69 = { hover: handleHover };
		$[81] = handleHover;
		$[82] = t69;
	} else t69 = $[82];
	const signalListeners = t69;
	let t70;
	if ($[83] !== signalListeners || $[84] !== specs) {
		t70 = /* @__PURE__ */ React.createElement(Vega, {
			spec: specs,
			actions: false,
			signalListeners
		});
		$[83] = signalListeners;
		$[84] = specs;
		$[85] = t70;
	} else t70 = $[85];
	return t70;
};
GaugeWidget.propTypes = {
	title: PropTypes.string.isRequired,
	legend: PropTypes.string,
	showTicks: PropTypes.bool,
	unitLabel: PropTypes.string,
	ticksNumber: PropTypes.number,
	backgroundColor: PropTypes.string,
	value: PropTypes.number.isRequired,
	minValue: PropTypes.number,
	maxValue: PropTypes.number
};
function _temp() {}
//#endregion
export { GaugeWidget };

//# sourceMappingURL=GaugeWidget.mjs.map