"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _dialog = _interopRequireDefault(require("@alifd/next/lib/dialog"));
var _tab = _interopRequireDefault(require("@alifd/next/lib/tab"));
var _input = _interopRequireDefault(require("@alifd/next/lib/input"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _balloon = _interopRequireDefault(require("@alifd/next/lib/balloon"));
var React = _interopRequireWildcard(require("react"));
require("./index.scss");
var ICons = _interopRequireWildcard(require("@ant-design/icons"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
var IconMap = new Map();
for (var _i = 0, _Object$keys = Object.keys(ICons); _i < _Object$keys.length; _i++) {
  var key = _Object$keys[_i];
  // @ts-ignore
  var item = ICons[key];
  IconMap.set(key, item);
}
var Tooltip = _balloon["default"].Tooltip;
var items = [{
  key: "Outlined",
  title: "线框风格"
}, {
  key: "Filled",
  title: "实底风格"
}, {
  key: "TwoTone",
  title: "双色风格"
}];
var AntIconSetter = exports["default"] = /*#__PURE__*/function (_React$PureComponent) {
  function AntIconSetter(props) {
    var _this;
    _this = _React$PureComponent.call(this, props) || this;
    _this.onOpen = void 0;
    _this.onClose = void 0;
    _this.state = {
      visible: false
    };
    _this.state = {
      visible: false
    };
    _this.onOpen = function () {
      _this.setState({
        visible: true
      });
    };
    _this.onClose = function () {
      _this.setState({
        visible: false
      });
    };
    return _this;
  }
  (0, _inheritsLoose2["default"])(AntIconSetter, _React$PureComponent);
  var _proto = AntIconSetter.prototype;
  _proto.componentDidMount = function componentDidMount() {};
  _proto.render = function render() {
    var _this2 = this;
    var _this$props = this.props,
      value = _this$props.value,
      onChange = _this$props.onChange;
    var trigger = /*#__PURE__*/React.createElement(_input["default"], {
      style: {
        width: "100%"
      },
      value: value,
      readOnly: true,
      onClick: this.onOpen
    });
    var tab = /*#__PURE__*/React.createElement(_tab["default"], null, items.map(function (item) {
      return /*#__PURE__*/React.createElement(_tab["default"].Item, {
        title: item.title,
        key: item.key
      }, /*#__PURE__*/React.createElement("div", {
        style: {
          display: "flex",
          flexWrap: "wrap",
          fontSize: 24,
          lineHeight: 1,
          maxHeight: 600,
          overflowY: "auto"
        }
      }, [].concat(IconMap.keys()).filter(function (key) {
        return key.endsWith(item.key);
      }).map(function (key) {
        var Comp = IconMap.get(key);
        return /*#__PURE__*/React.createElement("div", {
          className: "icon-setter-select-item",
          onClick: function onClick() {
            onChange === null || onChange === void 0 ? void 0 : onChange(key);
            _this2.onClose();
          }
        }, /*#__PURE__*/React.createElement(Tooltip, {
          align: "t",
          trigger: /*#__PURE__*/React.createElement(Comp, null)
        }, key));
      })));
    }));
    return /*#__PURE__*/React.createElement("div", null, trigger, /*#__PURE__*/React.createElement(_dialog["default"], {
      v2: true,
      footer: false,
      wrapperStyle: {
        padding: 0
      },
      visible: this.state.visible,
      onOk: this.onClose,
      onClose: this.onClose
    }, tab));
  };
  return AntIconSetter;
}(React.PureComponent);
// 声明 Setter 的 title
AntIconSetter.displayName = 'AntIconSetter';