import { getText } from "../../locales/index.js";
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import PisellRow from "../pisellRow/index.js";
import PisellTags from "../pisellTags/index.js";
import CustomSelect from "../customSelect/index.js";
import React from "react";
import "./index.less";
//#region src/components/versionSelect/index.tsx
const _excluded = [
	"versions",
	"value",
	"onChange"
];
const getStatusColor = (status) => {
	if (status === "live") return "success";
	if (status === "draft") return "gray";
	if (status === "deprecated") return "error";
	return "gray";
};
const getStatusText = (status) => {
	if (status === "live") return getText("pisell-lowcode-app-version-control-live");
	if (status === "draft") return getText("pisell-lowcode-app-version-control-draft");
	if (status === "deprecated") return getText("pisell-lowcode-app-version-control-deprecated");
};
const VersionSelect = (props) => {
	const { versions, value, onChange } = props, rest = _objectWithoutProperties(props, _excluded);
	const handleVersionChange = (value) => {
		const version = versions.find((v) => v.value === value);
		onChange === null || onChange === void 0 || onChange(value, version);
	};
	return /* @__PURE__ */ React.createElement(CustomSelect, _objectSpread2(_objectSpread2({}, rest), {}, {
		options: versions,
		value,
		size: "large",
		onChange: handleVersionChange,
		style: { width: "100%" },
		renderItem: (option) => /* @__PURE__ */ React.createElement(PisellRow, {
			leftContent: option.label,
			rightContent: /* @__PURE__ */ React.createElement(PisellTags, {
				type: "pill_color",
				color: getStatusColor(option.status),
				className: "pisell-lowcode-version-select-tag"
			}, getStatusText(option.status))
		})
	}));
};
//#endregion
export { VersionSelect as default };
