"use strict";

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

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

var _GroupList = _interopRequireDefault(require("../../../../../common/GroupList"));

var _businessUtil = require("../../../../../utils/businessUtil");

var _Button = _interopRequireDefault(require("../../../../../common/Button"));

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

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": 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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");

    _extendStatics(d, b);

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

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

var notice = 'For best results, use an image at least 1920px wide'; // @inject('store')
// @observer

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

  function ImageTextConfigGroup() {
    var _this = _super !== null && _super.apply(this, arguments) || this;

    _this.state = {};

    _this.onClickItem = function (node) {
      console.log('---group', node);

      _this.props.store.setState({
        clickedGroup: node.id
      });
    };

    _this.onAddClick = function () {
      var json = (0, _defaultJSON.ImageTextGroupSourceJSON)();

      _this.props.source.push(json);

      _this.setState({});

      (0, _businessUtil.renderPreview)();
    };

    _this.reRender = function () {
      _this.setState({});
    };

    return _this;
  }

  ImageTextConfigGroup.prototype.render = function () {
    var source = this.props.source;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "banner_group"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "node_list"
    }, source.length === 0 ? /*#__PURE__*/_react["default"].createElement("span", {
      className: "notice"
    }, notice) : /*#__PURE__*/_react["default"].createElement(_GroupList["default"], {
      onClickItem: this.onClickItem,
      reRender: this.reRender,
      source: source
    })), /*#__PURE__*/_react["default"].createElement("div", {
      className: "btn_wrap"
    }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
      icon: "icon-add",
      onClick: this.onAddClick,
      type: "primary"
    }, "Add Banner")));
  };

  ImageTextConfigGroup.defaultProps = {
    source: []
  };
  return ImageTextConfigGroup;
}(_react["default"].Component);

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