"use strict";

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

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

var _ImageTextConfigGroup = _interopRequireDefault(require("./ImageTextConfigGroup"));

var _common = require("../../../../common");

var _TextConfig = _interopRequireDefault(require("../../../../meta-comp/config-panels/TextConfig"));

var _ButtonConfig = _interopRequireDefault(require("../../../../meta-comp/config-panels/ButtonConfig"));

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

var _BackgroundConfig = _interopRequireDefault(require("../../../common/config-panels/BackgroundConfig"));

var _CustomizeConfig = _interopRequireDefault(require("../../../common/config-panels/CustomizeConfig"));

var _layoutImagetextM = _interopRequireDefault(require("../../../../assets/images/layout-icon/layout-imagetext-m3-1.svg"));

var _layoutImagetextM2 = _interopRequireDefault(require("../../../../assets/images/layout-icon/layout-imagetext-m3-2.svg"));

var _layoutImagetextP = _interopRequireDefault(require("../../../../assets/images/layout-icon/layout-imagetext-p3.svg"));

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

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 pclayoutSource = [// { id: 'layout1', name: 'layout1', image: leftIcon },
// { id: 'layout2', name: 'layout2', image: centerIcon },
{
  id: 'layout3',
  name: 'layout3',
  image: _layoutImagetextP["default"]
}];
var h5layoutSource = [// { id: 'layout1', name: 'layout1', image: leftIcon },
// { id: 'layout2', name: 'layout2', image: centerIcon },
{
  id: 'layout3',
  name: 'layout3',
  image: _layoutImagetextM["default"]
}, {
  id: 'layout3',
  name: 'layout3-2',
  image: _layoutImagetextM2["default"]
}];

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

  function ImageTextConfig() {
    var _this = _super !== null && _super.apply(this, arguments) || this; // state = {
    //   ready: false,
    // }


    _this.selfRender = function () {
      (0, _businessUtil.renderPreview)();

      _this.setState({});
    };

    _this.getTitlePanel = function () {
      var data = _this.props.data;
      var source = [{
        key: 'imageTextTitle1',
        name: 'Headline',
        value: /*#__PURE__*/_react["default"].createElement(_TextConfig["default"], {
          data: data.headline
        }),
        metaOption: data.headline,
        toggleType: 'switch'
      }, {
        key: 'imageTextTitle2',
        name: 'Subtitle',
        value: /*#__PURE__*/_react["default"].createElement(_TextConfig["default"], {
          data: data.subtitle
        }),
        metaOption: data.subtitle,
        toggleType: 'switch'
      }];
      return /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
        divider: "dashed",
        headerSize: "middle",
        onRefresh: function onRefresh() {
          return (0, _businessUtil.renderPreview)();
        },
        source: source,
        type: "switch"
      });
    };

    _this.getButtonPanel = function () {
      var data = _this.props.data;
      var source = [{
        key: 'imageTextButton1',
        name: 'Button',
        value: /*#__PURE__*/_react["default"].createElement(_ButtonConfig["default"], {
          data: data.button
        }),
        metaOption: data.button,
        toggleType: 'switch'
      }, {
        key: 'imageTextButton2',
        name: 'Secondary button',
        value: /*#__PURE__*/_react["default"].createElement(_ButtonConfig["default"], {
          data: data.secondButton
        }),
        metaOption: data.secondButton,
        toggleType: 'switch'
      }];
      return /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
        divider: "dashed",
        headerSize: "middle",
        onRefresh: function onRefresh() {
          return (0, _businessUtil.renderPreview)();
        },
        source: source,
        type: "switch"
      });
    };

    _this.getLayout = function (v) {
      var data = _this.props.data;

      if ((0, _coreUtil.isPc)()) {
        data.customize.layout.pcLayout = v;
      } else {
        data.customize.layout.h5Layout = v;
      }

      _this.selfRender();
    };

    return _this;
  }

  ImageTextConfig.prototype.render = function () {
    var _this = this;

    var data = this.props.data;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "container"
    }, /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
      divider: "bold",
      headerSize: "large",
      source: [{
        key: 'imageText1',
        name: 'Title',
        value: this.getTitlePanel()
      }, {
        key: 'imageText2',
        name: 'Group',
        value: /*#__PURE__*/_react["default"].createElement(_ImageTextConfigGroup["default"], {
          source: data.groupSource
        }),
        metaOption: data.groupSource
      }, {
        key: 'imageText3',
        name: 'Button',
        value: this.getButtonPanel()
      }, {
        key: 'imageText4',
        name: 'Customize',
        value: /*#__PURE__*/_react["default"].createElement(_CustomizeConfig["default"], {
          data: data.customize,
          layoutSource: (0, _coreUtil.isPc)() ? pclayoutSource : h5layoutSource,
          selectedLayoutFun: function selectedLayoutFun(v) {
            _this.getLayout(v);
          }
        })
      }, {
        key: 'imageText5',
        name: 'Background',
        value: /*#__PURE__*/_react["default"].createElement(_BackgroundConfig["default"], {
          data: data.background
        })
      }]
    }));
  };

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

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