var __assign = this && this.__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 __rest = this && this.__rest || function (s, e) {
  var t = {};

  for (var p in s) {
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  }

  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
    if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  }
  return t;
};

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import classNames from 'classnames';
import { IconButton } from "../button";
import "./style/progress.css";
var prefixCls = 'dmc-progress';

var Progress = function Progress(props) {
  var percent = props.percent,
      type = props.type,
      className = props.className,
      title = props.title,
      onCancel = props.onCancel,
      showPercent = props.showPercent,
      cancelable = props.cancelable,
      restProps = __rest(props, ["percent", "type", "className", "title", "onCancel", "showPercent", "cancelable"]);

  var trailCls = classNames(prefixCls + "-trail", prefixCls + "-trail-" + type);
  var width = percent + "%";
  var showInfo = !!title || showPercent && cancelable;
  var percentInline = !title && !cancelable && showPercent;
  return _jsxs("div", __assign({}, restProps, {
    className: prefixCls + " " + className
  }, {
    children: [showInfo && _jsxs("div", __assign({
      className: prefixCls + "-info"
    }, {
      children: [_jsx("div", __assign({
        className: prefixCls + "-title"
      }, {
        children: title
      }), void 0), showPercent && _jsx("div", __assign({
        className: prefixCls + "-percent"
      }, {
        children: width
      }), void 0)]
    }), void 0), _jsxs("div", __assign({
      className: prefixCls + "-wrapper"
    }, {
      children: [_jsx("div", __assign({
        className: prefixCls + "-bg"
      }, {
        children: _jsx("div", {
          className: trailCls,
          style: {
            width: width
          }
        }, void 0)
      }), void 0), cancelable && _jsx(IconButton, {
        className: prefixCls + "-cancel",
        icon: "close",
        type: "only-icon",
        onClick: onCancel
      }, void 0), percentInline && _jsx("div", __assign({
        className: prefixCls + "-percent"
      }, {
        children: width
      }), void 0)]
    }), void 0)]
  }), void 0);
};

Progress.defaultProps = {
  percent: 0,
  showPercent: false,
  cancelable: false
};
Progress.displayName = 'Progress';
export default Progress;
var ProgressMemo = /*#__PURE__*/React.memo(Progress);
ProgressMemo.displayName = 'ProgressMemo';
export { ProgressMemo };

