const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/pro/Selector/components/Indicator/index.tsx
const sizeMap = {
	small: 20,
	middle: 24,
	large: 28
};
const Indicator = (props) => {
	const { mode = "single", variant = "outlined", disabled = false, className, styles = {}, children, size = "middle", onChange, defaultChecked, checked: checkedProp } = props;
	const [internalChecked, setInternalChecked] = (0, react.useState)(defaultChecked || false);
	(0, react.useEffect)(() => {
		if (checkedProp !== void 0) setInternalChecked(checkedProp);
	}, [checkedProp]);
	const isControlled = checkedProp !== void 0;
	const checked = isControlled ? checkedProp : internalChecked;
	const prefixCls = "pisell-pro-indicator";
	const classes = (0, classnames.default)(prefixCls, `${prefixCls}-${mode}`, `${prefixCls}-${variant}`, {
		[`${prefixCls}-checked`]: checked,
		[`${prefixCls}-disabled`]: disabled
	}, className);
	const indicatorStyle = (0, react.useMemo)(() => {
		const sizeValue = sizeMap[size] || Number(size);
		return require_objectSpread2._objectSpread2({
			width: sizeValue,
			height: sizeValue
		}, styles.indicator);
	}, [size, styles.indicator]);
	const handleInputChange = (e) => {
		if (disabled) return;
		if (!isControlled) setInternalChecked(e.target.checked);
		onChange === null || onChange === void 0 || onChange(e);
	};
	const renderCheckIcon = () => {
		const iconSize = (sizeMap[size] || Number(size)) * .6;
		const strokeWidth = iconSize * .15;
		return /* @__PURE__ */ react.default.createElement("svg", {
			className: `${prefixCls}-check-icon`,
			width: iconSize,
			height: iconSize * .76,
			viewBox: "0 0 17 13",
			fill: "none",
			xmlns: "http://www.w3.org/2000/svg"
		}, /* @__PURE__ */ react.default.createElement("path", {
			d: "M14.8814 1.44043L5.64141 10.6804L1.44141 6.48043",
			stroke: "currentColor",
			strokeWidth,
			strokeLinecap: "round",
			strokeLinejoin: "round"
		}));
	};
	return /* @__PURE__ */ react.default.createElement("label", {
		className: classes,
		style: styles === null || styles === void 0 ? void 0 : styles.container
	}, /* @__PURE__ */ react.default.createElement("input", {
		type: mode === "single" ? "radio" : "checkbox",
		className: `${prefixCls}-input`,
		checked: !!checked,
		disabled,
		onChange: handleInputChange
	}), /* @__PURE__ */ react.default.createElement("div", {
		className: `${prefixCls}-inner`,
		style: indicatorStyle
	}, checked && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, mode === "single" && variant === "outlined" ? /* @__PURE__ */ react.default.createElement("div", { className: `${prefixCls}-dot` }) : renderCheckIcon())), children && /* @__PURE__ */ react.default.createElement("span", {
		className: `${prefixCls}-content`,
		style: styles === null || styles === void 0 ? void 0 : styles.content
	}, children));
};
//#endregion
exports.default = Indicator;
