"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _upload = _interopRequireDefault(require("antd/lib/upload"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _index = require("@ant-design/icons/es/index");
require("./index.less");
var _excluded = ["fileList", "matter", "action", "accept", "authorization", "tenantId", "preview", "flag", "style"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var antUploadWall = function antUploadWall(_ref) {
  var fileList = _ref.fileList,
    matter = _ref.matter,
    action = _ref.action,
    accept = _ref.accept,
    authorization = _ref.authorization,
    tenantId = _ref.tenantId,
    preview = _ref.preview,
    flag = _ref.flag,
    style = _ref.style,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _style = style || {};
  var _otherProps = otherProps || {};
  _otherProps.style = _style;

  // const getBase64 = (file) =>
  //   new Promise((resolve, reject) => {
  //     const reader = new FileReader();
  //     reader.readAsDataURL(file);
  //     reader.onload = () => resolve(reader.result);
  //     reader.onerror = (error) => reject(error);
  //   });
  // const [previewOpen, setPreviewOpen] = useState(false);
  // const [previewImage, setPreviewImage] = useState('');
  // const [previewTitle, setPreviewTitle] = useState('');
  // const [fileList, setFileList] = useState([...dataSource]);
  // const handleCancel = () => {
  //   console.log(111111111111)
  //   return setPreviewOpen(false);
  // }
  // const handlePreview = async (file) => {
  //   console.log(222222222222)

  //   if (!file.url && !file.preview) {
  //     file.preview = await getBase64(file.originFileObj);
  //   }
  //   setPreviewImage(file.url || file.preview);
  //   setPreviewOpen(true);
  //   setPreviewTitle(file.name || file.url.substring(file.url.lastIndexOf('/') + 1));
  // };
  // const handleChange = ({ fileList: newFileList }) => {
  //   console.log(newFileList, 33333333333333)

  //   // return setFileList(newFileList);
  // }

  var props = {
    label: "文件上传",
    name: "file",
    title: "上传文件",
    action: action,
    accept: accept,
    headers: {
      Authorization: "Bearer " + authorization,
      'TENANT-ID': tenantId
    }
  };
  var uploadButton = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_index.PlusOutlined, null), /*#__PURE__*/React.createElement("div", {
    style: {
      marginTop: 8
    }
  }, "Upload"));
  return /*#__PURE__*/React.createElement("div", {
    style: {
      width: '100%',
      display: flag ? 'none' : ''
    }
  }, /*#__PURE__*/React.createElement(_upload["default"], (0, _extends2["default"])({
    listType: "picture-card",
    fileList: fileList
  }, props, {
    showUploadList: {
      showPreviewIcon: false
    }
  }, _otherProps), fileList.length >= 8 ? null : uploadButton));
};
antUploadWall.displayName = 'antUploadWall';
var _default = antUploadWall;
exports["default"] = _default;