"use strict";

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

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

var _antd = require("antd");

var _FontStyles = _interopRequireDefault(require("../../../../../common/FontStyles"));

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

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

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

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

function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

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 __assign = void 0 && (void 0).__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

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

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

    _this.state = {};

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

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

    return _this;
  }

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

    var data = this.props.data;
    var textData = data.content;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "m-text-config",
      style: {
        paddingTop: 20
      }
    }, /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: "Placeholder"
    }, /*#__PURE__*/_react["default"].createElement(_antd.Input, {
      onChange: function onChange(v) {
        data.placeholder = v;
      }
    })), /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: "Font Style"
    }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
      onChange: function onChange(v) {
        if (v == 'Customize font styles') {
          textData.sizeType = v;
        } else {
          var findOne = _TextConfig.sizeTypeList.find(function (t) {
            return t.key == v;
          });

          _extends(textData, __assign(__assign({}, findOne), {
            sizeType: findOne === null || findOne === void 0 ? void 0 : findOne.key
          }));
        }

        _this.selfRender();
      },
      value: textData.sizeType
    }, _TextConfig.sizeTypeList.map(function (sizeType) {
      return /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
        key: sizeType.key,
        value: sizeType.key
      }, sizeType.key);
    }))), textData.sizeType == 'Customize font styles' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: "font Family"
    }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
      onChange: function onChange(v) {
        textData.fontFamily = v;

        _this.selfRender();
      },
      value: textData.fontFamily
    }, /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: "Montserrat"
    }, "Montserrat"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: "Open Sans"
    }, "Open Sans"))), /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: "font Weight"
    }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
      onChange: function onChange(v) {
        textData.fontWeight = v;

        _this.selfRender();
      },
      value: textData.fontWeight
    }, /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: 400
    }, "Regular"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: 600
    }, "Medium"))), /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: "Font Size"
    }, /*#__PURE__*/_react["default"].createElement(_common.Slider, {
      onChange: function onChange(_a) {
        var count = _a.count;
        textData.fontSize = count;

        _this.selfRender();
      },
      unit: "px",
      value: {
        count: textData.fontSize
      }
    }))), /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: ""
    }, /*#__PURE__*/_react["default"].createElement(_FontStyles["default"], {
      onChange: function onChange(value) {
        _extends(textData, value);

        _this.selfRender();
      },
      showTextAlign: true,
      value: textData
    })));
  };

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

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