"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireDefault(require("react"));
var _SocialPreviewSt = require("./SocialPreview.st.css.js");
var _Text = _interopRequireDefault(require("../Text"));
var _Box = _interopRequireDefault(require("../Box"));
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _constants = require("./constants");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/SocialPreview/SocialPreview.jsx";
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
/**
 * A displayer for a social post
 */
var SocialPreview = /*#__PURE__*/function (_React$Component) {
  function SocialPreview() {
    (0, _classCallCheck2["default"])(this, SocialPreview);
    return _callSuper(this, SocialPreview, arguments);
  }
  (0, _inherits2["default"])(SocialPreview, _React$Component);
  return (0, _createClass2["default"])(SocialPreview, [{
    key: "_isTwitter",
    value: function _isTwitter() {
      var skin = this.props.skin;
      return skin === 'twitter';
    }
  }, {
    key: "_isTwitterSmall",
    value: function _isTwitterSmall() {
      var size = this.props.size;
      return this._isTwitter() && size === 'small';
    }
  }, {
    key: "_renderTitle",
    value: function _renderTitle() {
      var _this$props = this.props,
        skin = _this$props.skin,
        title = _this$props.title;
      return /*#__PURE__*/_react["default"].createElement(_Text["default"], {
        weight: "bold",
        size: this._isTwitter() ? 'tiny' : 'small',
        dataHook: _constants.dataHooks.socialPreviewTitle,
        className: (0, _SocialPreviewSt.st)(_SocialPreviewSt.classes.socialPreviewTitle, {
          skin: skin
        }),
        ellipsis: true,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 32,
          columnNumber: 7
        }
      }, title);
    }
  }, {
    key: "_renderDescription",
    value: function _renderDescription() {
      var _this$props2 = this.props,
        skin = _this$props2.skin,
        description = _this$props2.description;
      return /*#__PURE__*/_react["default"].createElement(_Text["default"], {
        weight: this._isTwitter() ? 'normal' : 'thin',
        size: "tiny",
        dataHook: _constants.dataHooks.socialPreviewDescription,
        className: (0, _SocialPreviewSt.st)(_SocialPreviewSt.classes.socialPreviewDescription, {
          skin: skin
        }),
        ellipsis: true,
        maxLines: this._isTwitter() ? 2 : 1,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 47,
          columnNumber: 7
        }
      }, description);
    }
  }, {
    key: "_renderUrlText",
    value: function _renderUrlText() {
      var _this$props3 = this.props,
        skin = _this$props3.skin,
        previewUrl = _this$props3.previewUrl;
      return /*#__PURE__*/_react["default"].createElement(_Text["default"], {
        weight: "normal",
        size: "tiny",
        dataHook: _constants.dataHooks.socialPreviewUrl,
        className: (0, _SocialPreviewSt.st)(_SocialPreviewSt.classes.socialPreviewUrl, {
          skin: skin
        }),
        ellipsis: true,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 63,
          columnNumber: 7
        }
      }, this._isTwitter() ? previewUrl : previewUrl && previewUrl.toUpperCase());
    }
  }, {
    key: "_renderUrl",
    value: function _renderUrl() {
      var _this$props4 = this.props,
        skin = _this$props4.skin,
        previewUrl = _this$props4.previewUrl;
      if (this._isTwitter()) {
        return previewUrl && /*#__PURE__*/_react["default"].createElement("div", {
          className: (0, _SocialPreviewSt.st)(_SocialPreviewSt.classes.socialPreviewUrlContainer, {
            skin: skin
          }),
          __self: this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 82,
            columnNumber: 11
          }
        }, /*#__PURE__*/_react["default"].createElement(_wixUiIconsCommon.Link, {
          size: "14px",
          __self: this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 83,
            columnNumber: 13
          }
        }), this._renderUrlText());
      } else {
        return this._renderUrlText();
      }
    }
  }, {
    key: "_renderMedia",
    value: function _renderMedia() {
      var _this$props5 = this.props,
        skin = _this$props5.skin,
        size = _this$props5.size,
        media = _this$props5.media;
      if (this._isTwitterSmall()) {
        return /*#__PURE__*/_react["default"].createElement("div", {
          className: (0, _SocialPreviewSt.st)(_SocialPreviewSt.classes.mediaContainer, {
            skin: skin,
            size: size
          }),
          __self: this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 97,
            columnNumber: 9
          }
        }, media);
      }
      return media;
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props6 = this.props,
        skin = _this$props6.skin,
        size = _this$props6.size;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _SocialPreviewSt.st)(_SocialPreviewSt.classes.root, {
          skin: skin,
          size: size
        }),
        "data-hook": this.props.dataHook,
        "data-skin": skin,
        "data-size": size,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 110,
          columnNumber: 7
        }
      }, this._renderMedia(), /*#__PURE__*/_react["default"].createElement(_Box["default"], {
        className: (0, _SocialPreviewSt.st)(_SocialPreviewSt.classes.container, {
          skin: skin,
          size: size
        }),
        direction: "vertical",
        verticalAlign: this._isTwitterSmall() ? 'middle' : undefined,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 117,
          columnNumber: 9
        }
      }, !this._isTwitter() && this._renderUrl(), this._renderTitle(), this._renderDescription(), this._isTwitter() && this._renderUrl()));
    }
  }]);
}(_react["default"].Component);
SocialPreview.displayName = 'SocialPreview';
SocialPreview.defaultProps = {
  skin: 'social',
  size: 'large'
};
var _default = exports["default"] = SocialPreview;