"use strict";

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

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

var _mobxReact = require("mobx-react");

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

var _coreUtil = require("../../../../../utils/coreUtil");

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

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

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

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 (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 __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 notice = 'For best results, use an image at least 1920px wide';

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, _coreUtil.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: []
  };
  ImageTextConfigGroup = __decorate([(0, _mobxReact.inject)('store'), _mobxReact.observer], ImageTextConfigGroup);
  return ImageTextConfigGroup;
}(_react["default"].Component);

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