"use strict";

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); }

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

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

var _antd = require("antd");

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

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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 Option = _antd.Select.Option;

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

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

    _this.getLineStyleDom = function (type) {
      return /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          height: '100%',
          display: 'flex',
          alignItems: 'center'
        }
      }, /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          width: '100%',
          borderBottom: "2px " + type + " #232F46"
        }
      }));
    };

    _this.reRender = function () {
      (0, _coreUtil.renderPreview)();

      _this.setState({});
    };

    _this.getDividerConfig = function () {
      var content = _this.props.content;
      return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_common.Field, {
        split: true,
        title: "Line Color"
      }, /*#__PURE__*/_react["default"].createElement(_common.Slider, {
        maxVal: 100,
        minVal: 0,
        needColor: true,
        onChange: function onChange(_a) {
          var count = _a.count,
              color = _a.color;
          content.color = color;
          content.opacity = count;

          _this.reRender();
        },
        unit: "%",
        value: {
          count: content.opacity,
          color: content.color
        }
      })), /*#__PURE__*/_react["default"].createElement(_common.Field, {
        split: true,
        title: "Line Weight"
      }, /*#__PURE__*/_react["default"].createElement(_common.Slider, {
        maxVal: 10,
        minVal: 1,
        onChange: function onChange(_a) {
          var count = _a.count;
          content.height = count;

          _this.reRender();
        },
        unit: "px",
        value: {
          count: content.height
        }
      })), /*#__PURE__*/_react["default"].createElement(_common.Field, {
        split: true,
        title: "Line Style"
      }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
        onChange: function onChange(data) {
          content.style = data;

          _this.reRender();
        },
        value: content.style
      }, /*#__PURE__*/_react["default"].createElement(Option, {
        value: "solid"
      }, _this.getLineStyleDom('solid')), /*#__PURE__*/_react["default"].createElement(Option, {
        value: "dashed"
      }, _this.getLineStyleDom('dashed')), /*#__PURE__*/_react["default"].createElement(Option, {
        value: "dotted"
      }, _this.getLineStyleDom('dotted')), /*#__PURE__*/_react["default"].createElement(Option, {
        value: "double"
      }, _this.getLineStyleDom('double')))), /*#__PURE__*/_react["default"].createElement(_common.Field, {
        split: true,
        title: "Line Width"
      }, /*#__PURE__*/_react["default"].createElement(_common.Slider, {
        maxVal: 100,
        minVal: 0,
        onChange: function onChange(_a) {
          var count = _a.count;
          content.width = count;

          _this.reRender();
        },
        unit: "%",
        value: {
          count: content.width
        }
      })));
    };

    return _this;
  }

  DividerContentSetting.prototype.render = function () {
    var source = [{
      key: '1',
      name: 'Show Divider',
      value: this.getDividerConfig(),
      metaOption: this.props.content
    }];
    return /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
      headerSize: "middle",
      onRefresh: this.reRender,
      showActiveColor: true,
      source: source,
      type: "switch"
    });
  };

  return DividerContentSetting;
}(_react.Component);

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