"use strict";

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

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _defaultJSON = require("./defaultJSON");

var _components = require("../../../../meta-comp/components");

var _compositeDecorator = _interopRequireDefault(require("../../../../decorator/compositeDecorator"));

require("./index.less");

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

var __extends = void 0 && (void 0).__extends || function () {
  var _extendStatics = function extendStatics(d, b) {
    _extendStatics = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function (d, b) {
      d.__proto__ = b;
    } || function (d, b) {
      for (var p in b) {
        if (b.hasOwnProperty(p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    _extendStatics(d, b);

    function __() {
      this.constructor = d;
    }

    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();

var __decorate = void 0 && (void 0).__decorate || function (decorators, target, key, desc) {
  var c = arguments.length,
      r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
      d;
  if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
    if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  }
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};

var Tag =
/** @class */
function (_super) {
  __extends(Tag, _super);

  function Tag() {
    return _super !== null && _super.apply(this, arguments) || this;
  }

  Tag.prototype.render = function () {
    var _a;

    var nodeData = this.props.nodeData;
    var wrapStyle = {};

    if (nodeData.background.bgType === 'color') {
      wrapStyle.backgroundColor = nodeData.background.color;
      wrapStyle.opacity = nodeData.background.opacity ? nodeData.background.opacity : 1;
    } else {
      wrapStyle.backgroundImage = "url(" + nodeData.background.image + ")";
      wrapStyle.backgroundPosition = 'center';
    }

    return /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])('tag-comp-wrap', (_a = {}, _a[nodeData.customize.layout] = true, _a[nodeData.customize.align] = true, _a)),
      onClick: this.onComponentClick,
      style: wrapStyle
    }, nodeData.content.image.open && /*#__PURE__*/_react["default"].createElement("div", {
      className: "tag-image"
    }, /*#__PURE__*/_react["default"].createElement(_components.MetaImage, {
      data: nodeData.content.image
    })), nodeData.content.button.open && /*#__PURE__*/_react["default"].createElement("div", {
      className: "first-button"
    }, /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
      data: nodeData.content.button
    })), nodeData.content.secondaryButton.open && /*#__PURE__*/_react["default"].createElement("div", {
      className: "secondary-button"
    }, /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
      data: nodeData.content.secondaryButton
    })));
  };

  Tag.defaultProps = {};
  Tag.type = 'TAG';
  Tag.getDefaultJSON = _defaultJSON.getDefaultJSON;
  Tag = __decorate([_compositeDecorator["default"]], Tag);
  return Tag;
}(_react.Component);

var _default = Tag;
exports["default"] = _default;