"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = exports.DateYearSetter = exports.DateRangeSetter = exports.DateMonthSetter = void 0;
var _timePicker = _interopRequireDefault(require("@alifd/next/lib/time-picker"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _datePicker = _interopRequireDefault(require("@alifd/next/lib/date-picker"));
var _react = _interopRequireWildcard(require("react"));
var _lowcodeUtils = require("@alilc/lowcode-utils");
var _utils = require("./utils");
var _moment = _interopRequireDefault(require("moment"));
var _expressionSetter = _interopRequireDefault(require("./setter/expression-setter"));
exports.ExpressionSetter = _expressionSetter["default"];
var _colorSetter = _interopRequireDefault(require("./setter/color-setter"));
var _jsonSetter = _interopRequireDefault(require("./setter/json-setter"));
exports.JsonSetter = _jsonSetter["default"];
var _eventsSetter = _interopRequireDefault(require("./setter/events-setter"));
exports.EventsSetter = _eventsSetter["default"];
var _styleSetter = _interopRequireDefault(require("./setter/style-setter"));
var _iconSetter = _interopRequireDefault(require("./setter/icon-setter"));
exports.IconSetter = _iconSetter["default"];
var _functionSetter = _interopRequireDefault(require("./setter/function-setter"));
var _classnameSetter = _interopRequireDefault(require("./setter/classname-setter"));
var _stringSetter = _interopRequireDefault(require("./setter/string-setter"));
var _selectSetter = _interopRequireDefault(require("./setter/select-setter"));
var _radiogroupSetter = _interopRequireDefault(require("./setter/radiogroup-setter"));
var _boolSetter = _interopRequireDefault(require("./setter/bool-setter"));
var _numberSetter = _interopRequireDefault(require("./setter/number-setter"));
var _i18nSetter = _interopRequireDefault(require("./setter/i18n-setter"));
var _mixedSetter = _interopRequireDefault(require("./setter/mixed-setter"));
var _slotSetter = _interopRequireDefault(require("./setter/slot-setter"));
var _textareaSetter = _interopRequireDefault(require("./setter/textarea-setter"));
var _arraySetter = _interopRequireDefault(require("./setter/array-setter"));
var _objectSetter = _interopRequireDefault(require("./setter/object-setter"));
var _variableSetter = _interopRequireDefault(require("./setter/variable-setter"));
var _pluginEventBindDialog = _interopRequireDefault(require("./plugin/plugin-event-bind-dialog"));
var _pluginVariableBindDialog = _interopRequireDefault(require("./plugin/plugin-variable-bind-dialog"));
require("./index.less");
var _package = _interopRequireDefault(require("../package.json"));
var _autoCompleteSetter = _interopRequireDefault(require("./setter/autoComplete-setter"));
var _antIconSetter = _interopRequireDefault(require("./setter/ant-icon-setter"));
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 DateYearSetter = exports.DateYearSetter = _datePicker["default"].YearPicker;
var DateMonthSetter = exports.DateMonthSetter = _datePicker["default"].MonthPicker;
var DateRangeSetter = exports.DateRangeSetter = _datePicker["default"].RangePicker;
// eslint-disable-next-line react/no-multi-comp
var StringDateSetter = /*#__PURE__*/function (_Component) {
  function StringDateSetter() {
    return _Component.apply(this, arguments) || this;
  }
  (0, _inheritsLoose2["default"])(StringDateSetter, _Component);
  var _proto = StringDateSetter.prototype;
  _proto.render = function render() {
    var _this$props = this.props,
      _onChange = _this$props.onChange,
      value = _this$props.value,
      showTime = _this$props.showTime;
    return /*#__PURE__*/_react["default"].createElement(_datePicker["default"], {
      value: (0, _moment["default"])(value),
      showTime: showTime,
      onChange: function onChange(val) {
        _onChange(val ? val.format() : val);
      }
    });
  };
  return StringDateSetter;
}(_react.Component); // eslint-disable-next-line react/no-multi-comp
var StringTimePicker = /*#__PURE__*/function (_Component2) {
  function StringTimePicker() {
    return _Component2.apply(this, arguments) || this;
  }
  (0, _inheritsLoose2["default"])(StringTimePicker, _Component2);
  var _proto2 = StringTimePicker.prototype;
  _proto2.render = function render() {
    var _this$props2 = this.props,
      _onChange2 = _this$props2.onChange,
      value = _this$props2.value;
    return /*#__PURE__*/_react["default"].createElement(_timePicker["default"], {
      value: (0, _moment["default"])(value),
      onChange: function onChange(val) {
        _onChange2(val ? val.format('HH:mm:ss') : val);
      }
    });
  };
  return StringTimePicker;
}(_react.Component);
var DataExpressionSetter = {
  component: _expressionSetter["default"],
  condition: function condition(field) {
    var v = field.getValue();
    return (0, _lowcodeUtils.isJSExpression)(v);
  },
  valueType: ['JSExpression'],
  defaultProps: {
    placeholder: '请输入表达式'
  },
  title: '表达式输入',
  recommend: true
};
var DataVariableSetter = {
  component: _variableSetter["default"],
  condition: function condition(field) {
    var v = field.getValue();
    return (0, _lowcodeUtils.isJSExpression)(v);
  },
  valueType: ['JSExpression'],
  title: '变量输入',
  recommend: true
};
var FunctionBindSetter = {
  component: _functionSetter["default"],
  title: '函数绑定',
  condition: function condition(field) {
    var v = field.getValue();
    return (0, _lowcodeUtils.isJSFunction)(v);
  },
  valueType: ['JSFunction']
};
var DataJsonSetter = {
  component: _jsonSetter["default"],
  valueType: ['object', 'array']
};
var DataArraySetter = {
  component: _arraySetter["default"],
  defaultProps: {},
  title: 'ArraySetter',
  condition: function condition(field) {
    var v = field.getValue();
    return v == null || Array.isArray(v);
  },
  initialValue: [],
  recommend: true,
  valueType: ['array']
};
var DataObjectSetter = {
  component: _objectSetter["default"],
  // todo: defaultProps
  defaultProps: {},
  title: 'ObjectSetter',
  // TODO
  condition: function condition(field) {
    var v = field.getValue();
    return v == null || (0, _utils.isPlainObject)(v);
  },
  initialValue: {},
  recommend: true
};
var DataSlotSetter = {
  component: _slotSetter["default"],
  title: {
    type: 'i18n',
    'zh-CN': '插槽输入',
    'en-US': 'Slot Setter'
  },
  condition: function condition(field) {
    return (0, _lowcodeUtils.isJSSlot)(field.getValue());
  },
  initialValue: function initialValue(field, value) {
    if ((0, _lowcodeUtils.isJSSlot)(value)) {
      return value;
    }
    return {
      type: 'JSSlot',
      value: value
    };
  },
  recommend: true,
  valueType: ['JSSlot']
};
var EngineExt = {
  setters: {
    StringSetter: _stringSetter["default"],
    NumberSetter: _numberSetter["default"],
    BoolSetter: _boolSetter["default"],
    SelectSetter: _selectSetter["default"],
    VariableSetter: DataVariableSetter,
    ExpressionSetter: DataExpressionSetter,
    RadioGroupSetter: _radiogroupSetter["default"],
    TextAreaSetter: _textareaSetter["default"],
    DateSetter: StringDateSetter,
    TimePicker: StringTimePicker,
    DateYearSetter: DateYearSetter,
    DateMonthSetter: DateMonthSetter,
    DateRangeSetter: DateRangeSetter,
    EventsSetter: _eventsSetter["default"],
    ColorSetter: _colorSetter["default"],
    JsonSetter: DataJsonSetter,
    StyleSetter: _styleSetter["default"],
    IconSetter: _iconSetter["default"],
    ClassNameSetter: _classnameSetter["default"],
    I18nSetter: _i18nSetter["default"],
    FunctionSetter: FunctionBindSetter,
    MixedSetter: _mixedSetter["default"],
    SlotSetter: DataSlotSetter,
    ArraySetter: DataArraySetter,
    ObjectSetter: DataObjectSetter
  },
  setterMap: {
    StringSetter: _stringSetter["default"],
    NumberSetter: _numberSetter["default"],
    BoolSetter: _boolSetter["default"],
    SelectSetter: _selectSetter["default"],
    VariableSetter: DataVariableSetter,
    ExpressionSetter: DataExpressionSetter,
    RadioGroupSetter: _radiogroupSetter["default"],
    TextAreaSetter: _textareaSetter["default"],
    DateSetter: StringDateSetter,
    TimePicker: StringTimePicker,
    DateYearSetter: DateYearSetter,
    DateMonthSetter: DateMonthSetter,
    DateRangeSetter: DateRangeSetter,
    EventsSetter: _eventsSetter["default"],
    ColorSetter: _colorSetter["default"],
    JsonSetter: DataJsonSetter,
    StyleSetter: _styleSetter["default"],
    IconSetter: _iconSetter["default"],
    ClassNameSetter: _classnameSetter["default"],
    I18nSetter: _i18nSetter["default"],
    FunctionSetter: FunctionBindSetter,
    MixedSetter: _mixedSetter["default"],
    SlotSetter: DataSlotSetter,
    ArraySetter: DataArraySetter,
    ObjectSetter: DataObjectSetter
  },
  pluginMap: {
    EventBindDialog: _pluginEventBindDialog["default"],
    VariableBindDialog: _pluginVariableBindDialog["default"]
  },
  registerSetter: function registerSetter(key, value) {
    // @ts-ignore
    this.setters[key] = value;
    // @ts-ignore
    this.setterMap[key] = value;
  }
};
EngineExt.registerSetter(_autoCompleteSetter["default"].displayName, _autoCompleteSetter["default"]);
EngineExt.registerSetter(_antIconSetter["default"].displayName, _antIconSetter["default"]);
// @ts-ignore
EngineExt.version = _package["default"].version;
// @ts-ignore
window.AliLowCodeEngineExt = EngineExt;
console.log(
// @ts-ignore
'%c AliLowCodeExt %c v'.concat(EngineExt.version, ' '), 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #5584ff; font-weight: bold;', 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;');
var _default = exports["default"] = EngineExt; // registerSetter(builtinSetters);