const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../Container/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
require("./index.less");
//#region src/components/productExtension/fields/Actor/CutOffTime/index.tsx
const { Option } = antd.Select;
const maxNumber = {
	days: 365,
	hours: 8760,
	minutes: 525600
};
const CutOffTime = ({ value, onChange, name }) => {
	const [cutTimeMax, setCutTimeMax] = (0, react.useState)(365);
	const timeOptions = [
		{
			label: _pisell_utils.locales.getText("pisell2.text.product-extension.days"),
			value: "days"
		},
		{
			label: _pisell_utils.locales.getText("pisell2.text.product-extension.hours"),
			value: "hours"
		},
		{
			label: _pisell_utils.locales.getText("pisell2.text.product-extension.minutes"),
			value: "minutes"
		}
	];
	(0, react.useEffect)(() => {
		if (value) setCutTimeMax(maxNumber[value === null || value === void 0 ? void 0 : value.unit_type]);
	}, [value]);
	return /* @__PURE__ */ react.default.createElement("div", { className: "pisell2_product-extension-cut-off-time-wrap" }, /* @__PURE__ */ react.default.createElement(require_index.default, {
		title: _pisell_utils.locales.getText("pisell2.text.product-extension.cut-off-time"),
		desc: _pisell_utils.locales.getText("pisell2.text.product-extension.cut-off-time.desc"),
		isMargin: true
	}, /* @__PURE__ */ react.default.createElement("div", { className: "pisell2_product-extension-cut-off-time-input-wrap" }, /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: [...name, "unit"],
		noStyle: true,
		initialValue: 1
	}, /* @__PURE__ */ react.default.createElement(antd.InputNumber, {
		min: 1,
		size: "large",
		max: cutTimeMax,
		className: "pisell2_product-extension-cut-off-time-input-small"
	})), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: [...name, "unit_type"],
		noStyle: true,
		initialValue: "days"
	}, /* @__PURE__ */ react.default.createElement(antd.Select, {
		size: "large",
		className: "pisell2_product-extension-cut-off-time-select-wrap",
		onChange: (value) => {
			setCutTimeMax(maxNumber[value]);
		}
	}, timeOptions.map((i) => /* @__PURE__ */ react.default.createElement(Option, { key: i.value }, i.label)))))), /* @__PURE__ */ react.default.createElement(require_index.default, {
		title: _pisell_utils.locales.getText("pisell2.text.product-extension.future-day"),
		desc: _pisell_utils.locales.getText("pisell2.text.product-extension.future-day.hint")
	}, /* @__PURE__ */ react.default.createElement("div", { className: "pisell2_product-extension-cut-off-time-input-wrap" }, /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: [...name, "future_day"],
		noStyle: true,
		initialValue: 365
	}, /* @__PURE__ */ react.default.createElement(antd.InputNumber, {
		size: "large",
		min: 0,
		max: 365,
		addonAfter: _pisell_utils.locales.getText("pisell2.text.product-extension.days"),
		className: "pisell2_product-extension-cut-off-time-input-big"
	})))));
};
//#endregion
exports.default = CutOffTime;
