"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.BodyTextDecorator = exports.BodyTextBase = exports.BodyText = void 0;
var _kind = _interopRequireDefault(require("@enact/core/kind"));
var _BodyText = _interopRequireDefault(require("@enact/ui/BodyText"));
var _Pure = _interopRequireDefault(require("@enact/ui/internal/Pure"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _compose = _interopRequireDefault(require("ramda/src/compose"));
var _Marquee = require("../Marquee");
var _Skinnable = _interopRequireDefault(require("../Skinnable"));
var _BodyTextModule = _interopRequireDefault(require("./BodyText.module.css"));
var _jsxRuntime = require("react/jsx-runtime");
var _excluded = ["centered", "css", "noWrap"];
/**
 * Agate styled text block components and behaviors.
 *
 * @example
 * <BodyText centered>Hello Enact!</BodyText>
 *
 * @module agate/BodyText
 * @exports BodyText
 * @exports BodyTextBase
 * @exports BodyTextDecorator
 */
// Create a Marquee using BodyText as the base
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 MarqueeBodyText = (0, _Marquee.MarqueeDecorator)(_BodyText["default"]);

/**
 * A simple text block component.
 *
 * This component is most often not used directly but may be composed within another component as it
 * is within {@link agate/BodyText.BodyText|BodyText}.
 *
 * @class BodyTextBase
 * @memberof agate/BodyText
 * @extends ui/BodyText.BodyText
 * @ui
 * @public
 */
var BodyTextBase = exports.BodyTextBase = (0, _kind["default"])({
  name: 'BodyText',
  propTypes: /** @lends agate/BodyText.BodyTextBase.prototype */{
    /**
     * Centers the contents.
     *
     * Applies the `centered` CSS class which can be customized by
     * {@link /docs/developer-guide/theming/|theming}.
     *
     * @type {Boolean}
     * @default false
     * @public
     */
    centered: _propTypes["default"].bool,
    /**
     * 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:
     *
     * * `bodyText` - The root class name
     *
     * @type {Object}
     * @public
     */
    css: _propTypes["default"].object,
    /**
     * Toggles multi-line (`false`) vs single-line (`true`) behavior. `noWrap` mode
     * automatically enables {@link ui/Marquee} so long text isn't permanently occluded.
     *
     * @type {Boolean}
     * @default false
     * @public
     */
    noWrap: _propTypes["default"].bool,
    /**
     * Sets the text size to one of the preset sizes.
     * Available sizes: 'large' (default) and 'small'.
     *
     * @type {('small'|'large')}
     * @default 'large'
     * @public
     */
    size: _propTypes["default"].oneOf(['small', 'large'])
  },
  defaultProps: {
    centered: false,
    noWrap: false,
    size: 'large'
  },
  styles: {
    css: _BodyTextModule["default"],
    publicClassNames: 'bodyText'
  },
  computed: {
    className: function className(_ref) {
      var noWrap = _ref.noWrap,
        size = _ref.size,
        styler = _ref.styler;
      return styler.append(size, {
        noWrap: noWrap
      });
    }
  },
  render: function render(_ref2) {
    var centered = _ref2.centered,
      css = _ref2.css,
      noWrap = _ref2.noWrap,
      rest = _objectWithoutProperties(_ref2, _excluded);
    delete rest.size;
    if (noWrap) {
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(MarqueeBodyText, _objectSpread(_objectSpread({
        component: "div" // Assign a new component to BodyText, since DIV is not allowed inside a P tag (the default for BodyText)
        ,
        marqueeOn: "render"
      }, rest), {}, {
        alignment: centered ? 'center' : null // Centering Marquee
        ,
        centered: centered // Centering UiBodyText
        ,
        css: css
      }));
    }
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText["default"], _objectSpread(_objectSpread({}, rest), {}, {
      centered: centered,
      css: css
    }));
  }
});

/**
 * Applies Agate specific behaviors to {@link agate/BodyText.BodyTextBase|BodyTextBase}.
 *
 * @hoc
 * @memberof agate/BodyText
 * @mixes agate/Skinnable.Skinnable
 * @public
 */
var BodyTextDecorator = exports.BodyTextDecorator = (0, _compose["default"])(_Pure["default"], _Skinnable["default"]);

/**
 * A simple text block component, ready to use in Agate applications.
 *
 * `BodyText` may be used to display a block of text and is sized and spaced appropriately for a
 * Agate application.
 *
 * Usage:
 * ```
 * <BodyText>
 *   I have a Ham radio. There are many like it, but this one is mine.
 * </BodyText>
 * ```
 *
 * @class BodyText
 * @memberof agate/BodyText
 * @extends agate/BodyText.BodyTextBase
 * @mixes agate/BodyText.BodyTextDecorator
 * @ui
 * @public
 */
var BodyText = exports.BodyText = BodyTextDecorator(BodyTextBase);
var _default = exports["default"] = BodyText;