"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.HeadingDecorator = exports.HeadingBase = exports.Heading = void 0;
var _kind = _interopRequireDefault(require("@enact/core/kind"));
var _Heading = require("@enact/ui/Heading");
var _Pure = _interopRequireDefault(require("@enact/ui/internal/Pure"));
var _Layout = require("@enact/ui/Layout");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _compose = _interopRequireDefault(require("ramda/src/compose"));
var _Button = _interopRequireDefault(require("../Button"));
var _Marquee = require("../Marquee");
var _Skinnable = _interopRequireDefault(require("../Skinnable"));
var _HeadingModule = _interopRequireDefault(require("./Heading.module.css"));
var _jsxRuntime = require("react/jsx-runtime");
var _excluded = ["children", "css"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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; }
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); } /**
 * Agate styled labeled Heading components and behaviors
 *
 * @example
 * <Heading
 * 	size="large"
 * 	spacing="small"
 * >
 * 	A Content Section Heading
 * </Heading>
 *
 * @module agate/Heading
 * @exports Heading
 * @exports HeadingBase
 * @exports HeadingDecorator
 */ /**
 * A labeled Heading component.
 *
 * This component is most often not used directly but may be composed within another component as it
 * is within {@link agate/Heading.Heading|Heading}.
 *
 * @class HeadingBase
 * @memberof agate/Heading
 * @extends ui/Heading.Heading
 * @ui
 * @public
 */
var HeadingBase = exports.HeadingBase = (0, _kind["default"])({
  name: 'Heading',
  propTypes: /** @lends agate/Heading.HeadingBase.prototype */{
    /**
     * Set a custom color to be used by the Heading when `size` is "title".
     * Defaults to the current accent color if none is specified.
     *
     * @type {String}
     * @public
     */
    color: _propTypes["default"].string,
    /**
     * Customizes the component by mapping the supplied collection of CSS class names to the
     * corresponding internal elements and states of this component.
     *
     * @type {Object}
     * @public
     */
    css: _propTypes["default"].object,
    /**
     * Shows the back button.
     *
     * @type {Boolean}
     * @public
     */
    showBackButton: _propTypes["default"].bool,
    /**
     * Adds a horizontal-rule (line) under the component
     *
     * @type {Boolean}
     * @public
     */
    showLine: _propTypes["default"].bool,
    /**
     * The current skin.
     *
     * @type {String}
     * @private
     */
    skin: _propTypes["default"].string,
    /**
     * The size of the spacing around the Heading.
     *
     * Allowed values include:
     * * `'auto'` - Value is based on the `size` prop for automatic usage.
     * * `'title'` - Specifically assign the `'title'` spacing.
     * * `'large'` - Specifically assign the `'large'` spacing.
     * * `'medium'` - Specifically assign the `'medium'` spacing.
     * * `'small'` - Specifically assign the `'small'` spacing.
     * * `'none'` - No spacing at all. Neighboring elements will directly touch the Heading.
     *
     * @type {('auto'|'title'|'large'|'medium'|'small'|'none')}
     * @default 'auto'
     * @public
     */
    spacing: _propTypes["default"].oneOf(['auto', 'title', 'large', 'medium', 'small', 'none'])
  },
  defaultProps: {
    spacing: 'auto'
  },
  styles: {
    css: _HeadingModule["default"],
    className: 'heading',
    publicClassNames: true
  },
  computed: {
    children: function children(_ref) {
      var _children = _ref.children,
        showBackButton = _ref.showBackButton,
        skin = _ref.skin;
      var icon = skin === 'silicon' ? 'arrowleft' : 'arrowlargeleft';
      return showBackButton ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Layout.Row, {
        align: "center",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Cell, {
          shrink: true,
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button["default"], {
            backgroundOpacity: "transparent",
            icon: icon,
            size: "small"
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Cell, {
          shrink: true,
          children: _children
        })]
      }) : _children;
    },
    className: function className(_ref2) {
      var showLine = _ref2.showLine,
        styler = _ref2.styler;
      return styler.append({
        showLine: showLine
      });
    },
    style: function style(_ref3) {
      var color = _ref3.color,
        _style = _ref3.style;
      return _objectSpread(_objectSpread({}, _style), {}, {
        '--agate-heading-accent': color
      });
    }
  },
  render: function render(_ref4) {
    var children = _ref4.children,
      css = _ref4.css,
      rest = _objectWithoutProperties(_ref4, _excluded);
    delete rest.color;
    delete rest.showBackButton;
    delete rest.showLine;
    delete rest.skin;
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Heading.HeadingBase, _objectSpread(_objectSpread({
      css: css
    }, rest), {}, {
      children: children
    }));
  }
});

/**
 * Applies Agate specific behaviors to {@link agate/Heading.HeadingBase|HeadingBase}.
 *
 * @hoc
 * @memberof agate/Heading
 * @mixes agate/Marquee.MarqueeDecorator
 * @mixes agate/Skinnable.Skinnable
 * @public
 */
var HeadingDecorator = exports.HeadingDecorator = (0, _compose["default"])(_Pure["default"], _Marquee.MarqueeDecorator, (0, _Skinnable["default"])({
  prop: 'skin'
}));

/**
 * A labeled Heading component, ready to use in Agate applications.
 *
 * `Heading` may be used as a header to group related components.
 *
 * Usage:
 * ```
 * <Heading
 *   spacing="medium"
 * >
 *   Related Settings
 * </Heading>
 * <CheckboxItem>A Setting</CheckboxItem>
 * <CheckboxItem>A Second Setting</CheckboxItem>
 * ```
 *
 * @class Heading
 * @memberof agate/Heading
 * @extends agate/Heading.HeadingBase
 * @mixes agate/Heading.HeadingDecorator
 * @ui
 * @public
 */
var Heading = exports.Heading = HeadingDecorator(HeadingBase);

/**
 * Marquee animation trigger.
 *
 * Allowed values include:
 * * `'hover'` - Marquee begins when the pointer enters the component
 * * `'render'` - Marquee begins when the component is rendered
 *
 * @name marqueeOn
 * @type {('hover'|'render')}
 * @default 'render'
 * @memberof agate/Heading.Heading.prototype
 * @see {@link agate/Marquee.Marquee}
 * @public
 */

Heading.defaultProps = {
  marqueeOn: 'render'
};
var _default = exports["default"] = Heading;