var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/productExtension/fields/Actor/CutOffTime/index.tsx
var CutOffTime_exports = {};
__export(CutOffTime_exports, {
  default: () => CutOffTime_default,
  maxNumber: () => maxNumber
});
module.exports = __toCommonJS(CutOffTime_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_index = require("./index.less");
var import_Container = __toESM(require("../Container"));
var import_utils = require("@pisell/utils");
var { Option } = import_antd.Select;
var maxNumber = {
  days: 365,
  hours: 8760,
  minutes: 525600
};
var CutOffTime = ({ value, onChange, name }) => {
  const [cutTimeMax, setCutTimeMax] = (0, import_react.useState)(365);
  const timeOptions = [
    {
      label: import_utils.locales.getText("pisell2.text.product-extension.days"),
      value: "days"
    },
    {
      label: import_utils.locales.getText("pisell2.text.product-extension.hours"),
      value: "hours"
    },
    {
      label: import_utils.locales.getText("pisell2.text.product-extension.minutes"),
      value: "minutes"
    }
  ];
  (0, import_react.useEffect)(() => {
    if (value) {
      setCutTimeMax(maxNumber[value == null ? void 0 : value.unit_type]);
    }
  }, [value]);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2_product-extension-cut-off-time-wrap" }, /* @__PURE__ */ import_react.default.createElement(
    import_Container.default,
    {
      title: import_utils.locales.getText("pisell2.text.product-extension.cut-off-time"),
      desc: import_utils.locales.getText(
        "pisell2.text.product-extension.cut-off-time.desc"
      ),
      isMargin: true
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2_product-extension-cut-off-time-input-wrap" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: [...name, "unit"], noStyle: true, initialValue: 1 }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.InputNumber,
      {
        min: 1,
        size: "large",
        max: cutTimeMax,
        className: "pisell2_product-extension-cut-off-time-input-small"
      }
    )), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        name: [...name, "unit_type"],
        noStyle: true,
        initialValue: "days"
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_antd.Select,
        {
          size: "large",
          className: "pisell2_product-extension-cut-off-time-select-wrap",
          onChange: (value2) => {
            setCutTimeMax(maxNumber[value2]);
          }
        },
        timeOptions.map((i) => /* @__PURE__ */ import_react.default.createElement(Option, { key: i.value }, i.label))
      )
    ))
  ), /* @__PURE__ */ import_react.default.createElement(
    import_Container.default,
    {
      title: import_utils.locales.getText("pisell2.text.product-extension.future-day"),
      desc: import_utils.locales.getText("pisell2.text.product-extension.future-day.hint")
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2_product-extension-cut-off-time-input-wrap" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: [...name, "future_day"], noStyle: true, initialValue: 365 }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.InputNumber,
      {
        size: "large",
        min: 0,
        max: 365,
        addonAfter: import_utils.locales.getText(
          "pisell2.text.product-extension.days"
        ),
        className: "pisell2_product-extension-cut-off-time-input-big"
      }
    )))
  ));
};
var CutOffTime_default = CutOffTime;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  maxNumber
});
