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/file-import/Confirm.tsx
var Confirm_exports = {};
__export(Confirm_exports, {
  default: () => Confirm_default
});
module.exports = __toCommonJS(Confirm_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_ahooks = require("ahooks");
var import_service = require("./service");
var import_context = require("../config-provider/context");
var import_utils = require("../locale/utils");
var DEFAULT_PAGINATION_PARAMS = {
  currentPage: 1,
  pageSize: 20
};
var Confirm = ({ processKey, baseURL, tableProps, setTotal, renderNotice, renderContent }) => {
  var _a, _b, _c;
  const componentContext = (0, import_react.useContext)(import_context.ConfigContext);
  const { uiLocale } = componentContext;
  const { rowKey = "_ehr_id_", scroll = {}, columns, ...rest } = tableProps || {};
  const [pagination, setPagination] = (0, import_react.useState)(DEFAULT_PAGINATION_PARAMS);
  const { data, loading, run } = (0, import_ahooks.useRequest)((data2) => (0, import_service.getListFn)({ ...pagination, processKey, ...data2 }, { baseURL }), {
    onSuccess: (data2) => {
      setTotal((data2 == null ? void 0 : data2.total) || 0);
    }
  });
  const { data: sensitiveInfo } = (0, import_ahooks.useRequest)(() => (0, import_service.getSensitiveFn)({ processKey }, { baseURL }));
  const showTag = (_a = sensitiveInfo == null ? void 0 : sensitiveInfo.tagList) == null ? void 0 : _a.some((item) => item.tagNum > 0);
  const onChange = (pagination2) => {
    setPagination({ currentPage: pagination2.current, pageSize: pagination2.pageSize });
    run({ currentPage: pagination2.current, pageSize: pagination2.pageSize });
  };
  const paginationOptions = {
    hideOnSinglePage: !((_b = data == null ? void 0 : data.result) == null ? void 0 : _b.length),
    total: data == null ? void 0 : data.total,
    current: pagination.currentPage,
    pageSize: pagination.pageSize,
    size: "small"
  };
  const defaultDom = /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, showTag && /* @__PURE__ */ import_react.default.createElement("div", { className: "sensitive" }, (0, import_utils.replaceMessage)(uiLocale.FileImport.Confirm.sensitive, { content: (_c = sensitiveInfo.tagList) == null ? void 0 : _c.map((item) => `${item.tagName}：${item.tagNum}`).join(" | ") }), " ", sensitiveInfo.tagFileUrl && /* @__PURE__ */ import_react.default.createElement("a", { href: sensitiveInfo.tagFileUrl }, uiLocale.FileImport.Confirm.download)), /* @__PURE__ */ import_react.default.createElement("div", { className: "total" }, uiLocale.FileImport.Confirm.totalStart, /* @__PURE__ */ import_react.default.createElement("span", { className: "f-error" }, (data == null ? void 0 : data.total) || 0), " ", uiLocale.FileImport.Confirm.totalEnd, renderNotice == null ? void 0 : renderNotice()), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Table,
    {
      columns: columns ?? (data == null ? void 0 : data.head),
      dataSource: data == null ? void 0 : data.result,
      rowKey,
      loading,
      pagination: paginationOptions,
      onChange,
      scroll: { y: 420, ...scroll },
      ...rest
    }
  ));
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "container-confirm" }, renderContent ? renderContent(defaultDom, { data, tag: sensitiveInfo, processKey, refreshTable: run }) : defaultDom);
};
var Confirm_default = Confirm;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});
