"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.CloseComponent = void 0;
var _select = _interopRequireDefault(require("@alifd/next/lib/select"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _boxSlotComponent = _interopRequireDefault(require("../../_components/boxSlotComponent"));
var _groupComponent = require("./groupComponent");
var _config = require("../config");
var _type = require("../type");
var _rotateWheelComponent = require("./rotateWheelComponent");
var _locale = require("../../../../src/locale");
var _dialogComponent = require("./dialogComponent");
var _type2 = require("../../../../src/utils/CLowCodeService/type");
var _type3 = require("../../cGroupManage-setter/type");
var _animationComponent = require("./animationComponent");
var _carouselComponent = require("./carouselComponent");
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 CloseComponent = exports.CloseComponent = function CloseComponent(props) {
  var value = props.value,
    onChange = props.onChange;
  var _useState = (0, _react.useState)(value || {
      operateType: _config.OperateEnumType.Dialog
    }),
    openPageObj = _useState[0],
    setOpenPageObj = _useState[1];
  (0, _react.useEffect)(function () {
    onChange(openPageObj);
  }, [openPageObj]);
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("setter.controls")
  }, /*#__PURE__*/_react["default"].createElement(_select["default"], {
    placeholder: (0, _locale.t)("setter.selectPlaceHolder"),
    notFoundContent: (0, _locale.t)("setter.notFoundContent"),
    showSearch: true,
    value: openPageObj.operateType,
    dataSource: (0, _config.getComCloseActiveList)(),
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        operateType: e
      }));
    }
  })), openPageObj.operateType === _config.OperateEnumType.Dialog && /*#__PURE__*/_react["default"].createElement(_dialogComponent.DialogComponent, {
    title: (0, _locale.t)("setter.closeBehavior"),
    value: openPageObj.closeParams,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        closeParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.RotateWheel && /*#__PURE__*/_react["default"].createElement(_rotateWheelComponent.RotateWheelComponent, {
    type: _type.OperationType.stop,
    value: openPageObj.rotateWheelParams,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        rotateWheelParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Animation && /*#__PURE__*/_react["default"].createElement(_animationComponent.AnimationComponent, {
    type: _type.OperationType.stop,
    value: openPageObj.animationParams,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        animationParams: e
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Carousel && /*#__PURE__*/_react["default"].createElement(_carouselComponent.CarouselComponent, {
    type: _type.OperationType.stop,
    value: openPageObj.carouselParams,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        carouselParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Group && /*#__PURE__*/_react["default"].createElement(_groupComponent.GroupComponent, {
    originNode: _type2.BehaviorType.closeBehavior,
    value: openPageObj.groupParams || {
      groupId: '',
      groupIndex: '',
      groupIndexSelectType: _type3.GroupDataSourceType["default"],
      groupStateSelectType: _type3.GroupDataSourceType["default"],
      groupFollowStateSelectType: _type3.GroupDataSourceType["default"]
    },
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        groupParams: Object.assign({}, e)
      }));
    }
  }));
};