"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ProgressBarDecorator = exports.ProgressBarBase = exports.ProgressBar = void 0;
Object.defineProperty(exports, "ProgressBarTooltip", {
  enumerable: true,
  get: function get() {
    return _ProgressBarTooltip.ProgressBarTooltip;
  }
});
exports["default"] = void 0;
var _kind = _interopRequireDefault(require("@enact/core/kind"));
var _ComponentOverride = _interopRequireDefault(require("@enact/ui/ComponentOverride"));
var _Pure = _interopRequireDefault(require("@enact/ui/internal/Pure"));
var _ProgressBar = _interopRequireDefault(require("@enact/ui/ProgressBar"));
var _Slottable = _interopRequireDefault(require("@enact/ui/Slottable"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _compose = _interopRequireDefault(require("ramda/src/compose"));
var _Skinnable = _interopRequireDefault(require("../Skinnable"));
var _ProgressBarTooltip = require("./ProgressBarTooltip");
var _ProgressBarModule = _interopRequireDefault(require("./ProgressBar.module.css"));
var _jsxRuntime = require("react/jsx-runtime");
var _excluded = ["css", "orientation", "progress", "tooltip"];
/**
 * Provides an Agate-themed progress bar component.
 *
 * @example
 * <ProgressBar progress={0.5} backgroundProgress={0.75} />
 *
 * @module agate/ProgressBar
 * @exports ProgressBar
 * @exports ProgressBarBase
 * @exports ProgressBarDecorator
 * @exports ProgressBarTooltip
 */
/**
 * Renders an Agate-styled progress bar.
 *
 * @class ProgressBarBase
 * @memberof agate/ProgressBar
 * @extends ui/ProgressBar.ProgressBar
 * @ui
 * @public
 */
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
var ProgressBarBase = exports.ProgressBarBase = (0, _kind["default"])({
  name: 'ProgressBar',
  propTypes: /** @lends agate/ProgressBar.ProgressBarBase.prototype */{
    /**
     * The proportion of the loaded portion of the progress bar.
     *
     * * Valid values are between `0` and `1`.
     *
     * @type {Number}
     * @default 0
     * @public
     */
    backgroundProgress: _propTypes["default"].number,
    /**
     * Customizes the component by mapping the supplied collection of CSS class names to the
     * corresponding internal elements and states of this component.
     *
     * The following classes are supported:
     *
     * * `progressBar` - The root component class
     *
     * @type {Object}
     * @public
     */
    css: _propTypes["default"].object,
    /**
     * Highlights the filled portion.
     *
     * @type {Boolean}
     * @public
     */
    highlighted: _propTypes["default"].bool,
    /**
     * Sets the orientation of the progress bar.
     *
     * @type {('horizontal'|'vertical')}
     * @default 'horizontal'
     * @public
     */
    orientation: _propTypes["default"].oneOf(['horizontal', 'vertical']),
    /**
     * A number between `0` and `1` indicating the proportion of the filled portion of the bar.
     *
     * @type {Number}
     * @default 0
     * @public
     */
    progress: _propTypes["default"].number,
    /**
     * The size of the progress bar.
     *
     * @type {('small'|'large')}
     * @default 'large'
     * @public
     */
    size: _propTypes["default"].oneOf(['small', 'large']),
    /**
     * Enables the built-in tooltip.
     *
     * To customize the tooltip, pass either a custom tooltip component or an instance of
     * {@link agate/ProgressBar.ProgressBarTooltip|ProgressBarTooltip} with additional
     * props configured.
     *
     * The provided component will receive the following props from `ProgressBar`:
     *
     * * `orientation`  - The value of `orientation`
     * * `percent`      - Always `true` indicating the value should be presented as a percentage
     *                    rather than an absolute value
     * * `progress`     - The `value` as a proportion between `min` and `max`
     * * `visible`      - Always `true` indicating that the tooltip should be visible
     *
     * Usage:
     * ```
     * <ProgressBar
     *   tooltip={
     *     <ProgressBarTooltip position="after" />
     *   }
     * />
     * ```
     *
     * The tooltip may also be passed as a child via the `"tooltip"` slot. See
     * {@link ui/Slottable|Slottable} for more information on how slots can be used.
     *
     * Usage:
     * ```
     * <ProgressBar>
     *   <ProgressBarTooltip position="after" />
     * </ProgressBar>
     * ```
     *
     * @type {Boolean|Component|Element}
     * @public
     */
    tooltip: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].element, _propTypes["default"].func])
  },
  defaultProps: {
    backgroundProgress: 0,
    orientation: 'horizontal',
    progress: 0,
    size: 'large'
  },
  styles: {
    css: _ProgressBarModule["default"],
    publicClassNames: true
  },
  computed: {
    className: function className(_ref) {
      var highlighted = _ref.highlighted,
        size = _ref.size,
        styler = _ref.styler;
      return styler.append({
        highlighted: highlighted
      }, size);
    },
    tooltip: function tooltip(_ref2) {
      var _tooltip = _ref2.tooltip;
      return _tooltip === true ? _ProgressBarTooltip.ProgressBarTooltip : _tooltip;
    }
  },
  render: function render(_ref3) {
    var css = _ref3.css,
      orientation = _ref3.orientation,
      progress = _ref3.progress,
      tooltip = _ref3.tooltip,
      rest = _objectWithoutProperties(_ref3, _excluded);
    delete rest.highlighted;
    delete rest.tooltip;
    delete rest.size;
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProgressBar["default"], _objectSpread(_objectSpread({}, rest), {}, {
      orientation: orientation,
      progress: progress,
      css: css,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ComponentOverride["default"], {
        component: tooltip,
        orientation: orientation,
        percent: true,
        proportion: progress,
        visible: true
      })
    }));
  }
});

/**
 * Agate-specific behaviors to apply to {@link agate/ProgressBar.ProgressBarBase|ProgressBar}.
 *
 * @hoc
 * @memberof agate/ProgressBar
 * @mixes agate/Skinnable.Skinnable
 * @public
 */
var ProgressBarDecorator = exports.ProgressBarDecorator = (0, _compose["default"])(_Pure["default"], (0, _Slottable["default"])({
  slots: ['tooltip']
}), _Skinnable["default"]);

/**
 * The ready-to-use Agate-styled ProgressBar.
 *
 * @class ProgressBar
 * @memberof agate/ProgressBar
 * @extends agate/ProgressBar.ProgressBarBase
 * @mixes agate/ProgressBar.ProgressBarDecorator
 * @ui
 * @public
 */
var ProgressBar = exports.ProgressBar = ProgressBarDecorator(ProgressBarBase);
var _default = exports["default"] = ProgressBar;