"use strict";

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

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

var _antd = require("antd");

var _BaseConfig = _interopRequireDefault(require("../../../../meta-comp/config-panels/BaseConfig"));

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

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

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 CustomizeConfig =
/** @class */
function (_super) {
  __extends(CustomizeConfig, _super);

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

    _this.layoutChange = function (v) {
      var selectedLayoutFun = _this.props.selectedLayoutFun;

      if (selectedLayoutFun) {
        selectedLayoutFun(v);
      } else {
        data.layout = value;
      }

      _this.selfRender();
    };

    return _this;
  }

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

    var _a = this.props,
        data = _a.data,
        isHideAlign = _a.isHideAlign,
        layoutSource = _a.layoutSource,
        selectedLayoutFun = _a.selectedLayoutFun;
    var value = data.layout;

    if (selectedLayoutFun) {
      value = (0, _coreUtil.isPc)() ? data === null || data === void 0 ? void 0 : data.layout.pcLayout : data === null || data === void 0 ? void 0 : data.layout.h5Layout;
    }

    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "container"
    }, /*#__PURE__*/_react["default"].createElement(_common.Field, {
      split: !isHideAlign,
      title: "Layout"
    }, /*#__PURE__*/_react["default"].createElement(_common.LayoutSelector, {
      onChange: function onChange(value) {
        _this.layoutChange(value);
      },
      source: layoutSource,
      value: value
    })), !isHideAlign && /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: "Alignment"
    }, /*#__PURE__*/_react["default"].createElement(_common.AlignSelector, {
      onChange: function onChange(value) {
        data.align = value;

        _this.selfRender();
      },
      value: data.align
    })), (data === null || data === void 0 ? void 0 : data.rowNum) && /*#__PURE__*/_react["default"].createElement(_antd.Select, {
      onChange: function onChange(rowNum) {
        data.rowNum = rowNum;

        _this.selfRender();
      },
      style: {
        marginBottom: '15px'
      },
      value: data.rowNum
    }, /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: "2"
    }, "2"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: "3"
    }, "3"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: "4"
    }, "4"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: "5"
    }, "5")));
  };

  CustomizeConfig.defaultProps = {
    data: {
      layout: 'left',
      align: 'left'
    },
    isHideAlign: false,
    layoutObj: null
  };
  return CustomizeConfig;
}(_BaseConfig["default"]);

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