"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TooltipLabel = exports["default"] = void 0;

var _jsxRuntime = require("react/jsx-runtime");

var _kind = _interopRequireDefault(require("@enact/core/kind"));

var _util = require("@enact/i18n/util");

var _propTypes = _interopRequireDefault(require("prop-types"));

var _TooltipModule = _interopRequireDefault(require("./Tooltip.module.css"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/**
 * {@link agate/TooltipDecorator.TooltipLabel} is a stateless tooltip component with
 * Agate styling applied.
 *
 * @class TooltipLabel
 * @memberof agate/TooltipDecorator
 * @ui
 * @private
 */
var TooltipLabel = (0, _kind["default"])({
  name: 'TooltipLabel',
  propTypes:
  /** @lends agate/TooltipDecorator.TooltipLabel.prototype */
  {
    /**
     * The node to be displayed as the main content of the tooltip.
     *
     * @type {Node}
     * @required
     */
    children: _propTypes["default"].node.isRequired,

    /**
     * The width of tooltip content in pixels (px). If the content goes over the given width,
     * then it will automatically wrap. When `null`, content does not wrap.
     *
     * @type {Number}
     * @public
     */
    width: _propTypes["default"].number
  },
  styles: {
    css: _TooltipModule["default"],
    className: 'tooltipLabel'
  },
  computed: {
    className: function className(_ref) {
      var width = _ref.width,
          styler = _ref.styler;
      return styler.append({
        multi: !!width
      });
    },
    style: function style(_ref2) {
      var children = _ref2.children,
          width = _ref2.width,
          _style = _ref2.style;
      return _objectSpread(_objectSpread({}, _style), {}, {
        direction: (0, _util.isRtlText)(children) ? 'rtl' : 'ltr',
        width: width
      });
    }
  },
  render: function render(_ref3) {
    var children = _ref3.children,
        rest = _objectWithoutProperties(_ref3, ["children"]);

    delete rest.width;
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
      children: children
    }));
  }
});
exports.TooltipLabel = TooltipLabel;
var _default = TooltipLabel;
exports["default"] = _default;