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/productCard/components/Time/index.tsx
var Time_exports = {};
__export(Time_exports, {
  default: () => Time_default
});
module.exports = __toCommonJS(Time_exports);
var import_react = __toESM(require("react"));
var import_utils = require("../../utils");
var import_Divider = __toESM(require("../Divider"));
var import_Like = __toESM(require("./components/Like"));
var import_SelectResource = __toESM(require("./components/SelectResource"));
var import_SelectHolder = __toESM(require("./components/SelectHolder"));
var import_index = require("./index.less");
var import_SelectHolderMultiple = __toESM(require("./components/SelectHolderMultiple"));
var prefix = "pisell-lowcode-";
var Time = ({
  item,
  isShowHolder,
  onLike,
  isShowChangeResource,
  changeResource,
  changeHolder,
  isShowChangeHolder,
  holderMode,
  onAddHolder,
  isShowAddHolderButton,
  onClearHolder,
  onClearResource
}) => {
  const {
    start_date,
    end_date,
    holder_title,
    resource_id,
    relation_form_name,
    like_status,
    resources,
    is_hide_like,
    holder_id,
    holders,
    // 多个资源数据
    multiResources,
    addHolderButtonText,
    isErrorHolder,
    allowClearHolder,
    allowClearResource,
    isErrorResource,
    resourceErrorText,
    isMultipleResource,
    isShowChangeHolder: itemIsShowChangeHolder = true,
    holderMode: itemHolderMode,
    holderMaxCount
  } = item;
  const holderCom = (0, import_react.useMemo)(() => {
    if (!isShowHolder) return null;
    if (isShowChangeHolder && itemIsShowChangeHolder) {
      const Cpt = (itemHolderMode || holderMode) === "multiple" ? import_SelectHolderMultiple.default : import_SelectHolder.default;
      return /* @__PURE__ */ import_react.default.createElement(
        Cpt,
        {
          holderMaxCount,
          lists: holders,
          value: holder_id,
          onChange: changeHolder,
          holderMode: itemHolderMode || holderMode,
          isShowAddHolderButton,
          onAddHolder,
          addHolderButtonText,
          onClearHolder,
          isErrorHolder,
          allowClear: allowClearHolder
        }
      );
    }
    if (holder_title) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}product-holder-wrap` }, holder_title);
    }
  }, [
    isShowHolder,
    holder_id,
    holder_title,
    holderMode,
    holders,
    isShowAddHolderButton,
    isShowChangeHolder,
    isErrorHolder,
    addHolderButtonText,
    allowClearHolder,
    itemIsShowChangeHolder,
    itemHolderMode,
    holderMaxCount
  ]);
  const likeCom = (0, import_react.useCallback)(
    (status, item2) => {
      return /* @__PURE__ */ import_react.default.createElement(
        import_Like.default,
        {
          isShowChangeResource,
          style: { marginRight: 4 },
          status,
          onLike: (e) => {
            onLike({
              ...item2,
              like_status: e
            });
          }
        }
      );
    },
    [isShowChangeResource]
  );
  const resourceCom = (0, import_react.useCallback)(
    (item2) => {
      if ((item2 == null ? void 0 : item2.hasOwnProperty("isShowChangeResource")) && !item2.isShowChangeResource || !isShowChangeResource) {
        return item2 == null ? void 0 : item2.name;
      }
      return /* @__PURE__ */ import_react.default.createElement(
        import_SelectResource.default,
        {
          ...item2,
          lists: item2 == null ? void 0 : item2.lists,
          value: item2 == null ? void 0 : item2.id,
          onChange: changeResource,
          onClearResource,
          allowClear: item2 == null ? void 0 : item2.allowClearResource,
          isErrorResource: item2 == null ? void 0 : item2.isErrorResource,
          resourceErrorText: item2 == null ? void 0 : item2.resourceErrorText,
          resourceMode: item2.resourceMode,
          maxLength: item2.maxLength
        }
      );
    },
    [isShowChangeResource]
  );
  const likeAndResourceCom = (0, import_react.useMemo)(() => {
    if (isMultipleResource) {
      if ((multiResources == null ? void 0 : multiResources.length) > 0) {
        return multiResources.map((resourceItem) => {
          return /* @__PURE__ */ import_react.default.createElement("div", { key: (resourceItem == null ? void 0 : resourceItem.id) + (resourceItem == null ? void 0 : resourceItem._id) }, (resourceItem == null ? void 0 : resourceItem.id) && !is_hide_like && !resourceItem.is_hide_like ? likeCom(resourceItem == null ? void 0 : resourceItem.status, resourceItem) : null, resourceCom(resourceItem));
        });
      }
      return null;
    }
    const _resourceCom = resourceCom({
      name: relation_form_name,
      id: resource_id,
      lists: resources,
      allowClearResource,
      isErrorResource,
      resourceErrorText
    });
    return resource_id && !is_hide_like || _resourceCom ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, resource_id && !is_hide_like ? likeCom(like_status, item) : null, _resourceCom) : null;
  }, [
    multiResources,
    resource_id,
    resources,
    relation_form_name,
    is_hide_like,
    resourceErrorText,
    allowClearResource,
    isErrorResource,
    isShowChangeResource
  ]);
  const isShow = (0, import_react.useMemo)(() => {
    return start_date && end_date || holderCom || likeAndResourceCom;
  }, [start_date, holderCom, likeAndResourceCom]);
  return isShow ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_Divider.default, null), /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}product-time-wrap` }, start_date && end_date ? /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}product-date` }, (0, import_utils.getServiceTime)(item, start_date)) : null, holderCom, likeAndResourceCom ? /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `${prefix}product-technician ${isShowChangeResource ? "pisell-lowcode-change-resource" : ""} ${(multiResources == null ? void 0 : multiResources.length) > 0 ? "pisell-lowcode-multi-resources" : ""}`
    },
    likeAndResourceCom
  ) : null)) : null;
};
var Time_default = Time;
