import { useContext } from "react";
import { STATUS } from "../interface.js";
import Progress from "../../Progress/index.js";
import { ConfigContext } from "../../ConfigProvider/index.js";
import IconCheck from "../../../icon/react-icon/IconCheck/index.js";
import IconUpload from "../../../icon/react-icon/IconUpload/index.js";
import IconPlayArrowFill from "../../../icon/react-icon/IconPlayArrowFill/index.js";
import IconPause from "../../../icon/react-icon/IconPause/index.js";
import Tooltip from "../../Tooltip/index.js";
import { isFunction } from "../../_util/is.js";
import { jsxs, jsx, Fragment } from "../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var UploadProgress = function(props) {
  var file = props.file, prefixCls = props.prefixCls, progressProps = props.progressProps, progressRender = props.progressRender;
  var locale = useContext(ConfigContext).locale;
  var status = file.status, _a = file.percent, percent = _a === void 0 ? 0 : _a;
  var cls = prefixCls + "-list";
  var widthStyle = progressProps && progressProps.width ? {
    width: progressProps.width
  } : {};
  var dom = /* @__PURE__ */ jsxs(Fragment, {
    children: [status === STATUS.fail && props.reuploadIcon !== null && /* @__PURE__ */ jsx("span", {
      className: prefixCls + "-list-reupload-icon",
      onClick: function() {
        props.onReupload && props.onReupload(file);
      },
      children: props.reuploadIcon || (props.listType === "picture-card" ? /* @__PURE__ */ jsx(IconUpload, {}) : locale.Upload.reupload)
    }), status === STATUS.success && props.successIcon !== null && /* @__PURE__ */ jsx("span", {
      className: prefixCls + "-list-success-icon",
      children: props.successIcon || /* @__PURE__ */ jsx(IconCheck, {})
    }), status !== STATUS.success && /* @__PURE__ */ jsxs("div", {
      className: cls + "-status",
      style: widthStyle,
      children: [/* @__PURE__ */ jsx(Progress, {
        ...__assign({
          showText: false,
          className: cls + "-progress",
          type: "circle",
          status: status === STATUS.fail ? "error" : status === STATUS.success ? "success" : "normal",
          percent,
          size: "mini"
        }, progressProps)
      }), status === STATUS.init && props.startIcon !== null && /* @__PURE__ */ jsx("span", {
        className: prefixCls + "-list-start-icon",
        onClick: function() {
          props.onUpload && props.onUpload(file);
        },
        children: props.startIcon || /* @__PURE__ */ jsx(Tooltip, {
          content: locale.Upload.start,
          children: /* @__PURE__ */ jsx(IconPlayArrowFill, {})
        })
      }), status === STATUS.uploading && props.cancelIcon !== null && /* @__PURE__ */ jsx("span", {
        className: props.prefixCls + "-list-cancel-icon",
        onClick: function() {
          props.onAbort && props.onAbort(file);
        },
        children: props.cancelIcon || /* @__PURE__ */ jsx(Tooltip, {
          content: locale.Upload.cancel,
          children: /* @__PURE__ */ jsx(IconPause, {})
        })
      })]
    })]
  });
  return isFunction(progressRender) ? progressRender(file, dom) : dom;
};
const UploadProgress$1 = UploadProgress;
export {
  UploadProgress$1 as default
};
//# sourceMappingURL=uploadProgress.js.map
