import { _ as _slicedToArray } from '../_verture/slicedToArray-76060636.js';
import { _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import React__default from 'react';
import RcDrawer from 'rc-drawer';
import { Button } from '../Button/index.js';
import { u as useFormatMessage } from '../_verture/useFormatMessage-703f8b20.js';
import { $ as $prefixCls } from '../_verture/constant-66aa48a1.js';
import AutoTips from '../AutoTips/index.js';
import { isIE } from '@iam-com/lib';
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
import '../_verture/unsupportedIterableToArray-cb478f24.js';
import '../_verture/typeof-498dd2b1.js';
import 'clsx';
import '@iam-com/icons/LoadingF';
import '@iam-com/icons/Forbid';
import '../Tooltip/index.js';
import 'rc-tooltip';
import 'rc-tooltip/lib/placements';
import '@iam-com/icons/Down';
import '../_verture/index-fac03ce3.js';
import 'rc-dropdown';
import '../_verture/usePopupContainer-87febeb9.js';
import 'dayjs';
import '@para-ui/core/GlobalContext';

var en = {
  cancel: 'Cancel',
  ok: 'Ok'
};

var zh = {
  cancel: '取消',
  ok: '确定'
};

var localeJson = {
  zh: zh,
  en: en
};

var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/8 下午2:51\n* @description drawer样式\n*/\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-drawer {\n  position: fixed;\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n  z-index: 1000;\n  pointer-events: none;\n}\n\n.paraui-v3-drawer-inline {\n  position: absolute;\n}\n\n.paraui-v3-drawer-mask {\n  position: absolute;\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n  z-index: 1000;\n  background: rgba(0, 0, 0, 0.45);\n  pointer-events: auto;\n}\n\n.paraui-v3-drawer-content-wrapper {\n  position: absolute;\n  z-index: 1000;\n  transition: all 0.3s;\n}\n\n.paraui-v3-drawer-content-wrapper-hidden {\n  display: none;\n}\n\n.paraui-v3-drawer-left > .paraui-v3-drawer-content-wrapper {\n  top: 0;\n  bottom: 0;\n  left: 0;\n  box-shadow: 6px 0 16px -8px rgba(0, 0, 0, 0.08), 9px 0 28px 0 rgba(0, 0, 0, 0.05), 12px 0 48px 16px rgba(0, 0, 0, 0.03);\n}\n\n.paraui-v3-drawer-right > .paraui-v3-drawer-content-wrapper {\n  top: 0;\n  right: 0;\n  bottom: 0;\n  box-shadow: -6px 0 16px -8px rgba(0, 0, 0, 0.08), -9px 0 28px 0 rgba(0, 0, 0, 0.05), -12px 0 48px 16px rgba(0, 0, 0, 0.03);\n}\n\n.paraui-v3-drawer-top > .paraui-v3-drawer-content-wrapper {\n  top: 0;\n  right: 0;\n  left: 0;\n  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.08), 0 9px 28px 0 rgba(0, 0, 0, 0.05), 0 12px 48px 16px rgba(0, 0, 0, 0.03);\n}\n\n.paraui-v3-drawer-bottom > .paraui-v3-drawer-content-wrapper {\n  right: 0;\n  bottom: 0;\n  left: 0;\n  box-shadow: 0 -6px 16px -8px rgba(0, 0, 0, 0.08), 0 -9px 28px 0 rgba(0, 0, 0, 0.05), 0 -12px 48px 16px rgba(0, 0, 0, 0.03);\n}\n\n.paraui-v3-drawer-content {\n  width: 100%;\n  height: 100%;\n  overflow: auto;\n  background: rgb(255, 255, 255);\n  pointer-events: auto;\n  position: relative;\n}\n.paraui-v3-drawer-content .drawer-content-body {\n  display: flex;\n  flex-flow: column nowrap;\n  width: 100%;\n  height: 100%;\n}\n.paraui-v3-drawer-content .drawer-content-body .drawer-body-header {\n  position: relative;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  flex: none;\n  height: 60px;\n  padding: 0 24px;\n  font-size: 16px;\n  font-weight: 700;\n  color: rgb(46, 55, 67);\n  border-bottom: 1px solid rgba(171, 176, 185, 0.2);\n}\n.paraui-v3-drawer-content .drawer-content-body .drawer-body-header .drawer-header-title {\n  display: flex;\n  flex: 1;\n  align-items: center;\n  justify-content: space-between;\n}\n.paraui-v3-drawer-content .drawer-content-body .drawer-body-header .drawer-header-title-ellipsis {\n  overflow: hidden;\n}\n.paraui-v3-drawer-content .drawer-content-body .drawer-body-header .drawer-header-extra {\n  margin-left: 30px;\n  flex-shrink: 0;\n  white-space: nowrap;\n  text-align: right;\n}\n.paraui-v3-drawer-content .drawer-content-body .drawer-body-header .drawer-header-extra button + button {\n  margin-left: 16px;\n}\n.paraui-v3-drawer-content .drawer-content-body .drawer-body-content {\n  flex: 1;\n  padding: 24px;\n  overflow: auto;\n  word-wrap: break-word;\n  position: relative;\n}\n.paraui-v3-drawer-content .drawer-content-body .drawer-body-footer {\n  display: flex;\n  align-items: center;\n  flex: none;\n  padding: 16px 24px;\n  font-size: 16px;\n  color: rgb(46, 55, 67);\n  border-top: 1px solid rgba(171, 176, 185, 0.2);\n}\n\n.panel-motion-enter-start,\n.panel-motion-appear-start,\n.panel-motion-leave-start {\n  transition: none;\n}\n\n.panel-motion-enter-active,\n.panel-motion-appear-active,\n.panel-motion-leave-active {\n  transition: all 0.3s;\n}\n\n.paraui-v3-drawer-mask-motion-enter-active,\n.paraui-v3-drawer-mask-motion-appear-active,\n.paraui-v3-drawer-mask-motion-leave-active {\n  transition: all 0.3s;\n}\n\n.paraui-v3-drawer-mask-motion-enter,\n.paraui-v3-drawer-mask-motion-appear {\n  opacity: 0;\n}\n\n.paraui-v3-drawer-mask-motion-enter-active,\n.paraui-v3-drawer-mask-motion-appear-active {\n  opacity: 1;\n}\n\n.paraui-v3-drawer-mask-motion-leave {\n  opacity: 1;\n}\n\n.paraui-v3-drawer-mask-motion-leave-active {\n  opacity: 0;\n}\n\n.paraui-v3-drawer-panel-motion-left-enter-start,\n.paraui-v3-drawer-panel-motion-left-appear-start,\n.paraui-v3-drawer-panel-motion-left-leave-start {\n  transition: none;\n}\n\n.paraui-v3-drawer-panel-motion-left-enter-active,\n.paraui-v3-drawer-panel-motion-left-appear-active,\n.paraui-v3-drawer-panel-motion-left-leave-active {\n  transition: all 0.3s;\n}\n\n.paraui-v3-drawer-panel-motion-left-enter-start,\n.paraui-v3-drawer-panel-motion-left-appear-start {\n  transform: translateX(-100%) !important;\n}\n\n.paraui-v3-drawer-panel-motion-left-enter-active,\n.paraui-v3-drawer-panel-motion-left-appear-active {\n  transform: translateX(0);\n}\n\n.paraui-v3-drawer-panel-motion-left-leave {\n  transform: translateX(0);\n}\n\n.paraui-v3-drawer-panel-motion-left-leave-active {\n  transform: translateX(-100%);\n}\n\n.paraui-v3-drawer-panel-motion-right-enter-start,\n.paraui-v3-drawer-panel-motion-right-appear-start,\n.paraui-v3-drawer-panel-motion-right-leave-start {\n  transition: none;\n}\n\n.paraui-v3-drawer-panel-motion-right-enter-active,\n.paraui-v3-drawer-panel-motion-right-appear-active,\n.paraui-v3-drawer-panel-motion-right-leave-active {\n  transition: all 0.3s;\n}\n\n.paraui-v3-drawer-panel-motion-right-enter-start,\n.paraui-v3-drawer-panel-motion-right-appear-start {\n  transform: translateX(100%) !important;\n}\n\n.paraui-v3-drawer-panel-motion-right-enter-active,\n.paraui-v3-drawer-panel-motion-right-appear-active {\n  transform: translateX(0);\n}\n\n.paraui-v3-drawer-panel-motion-right-leave {\n  transform: translateX(0);\n}\n\n.paraui-v3-drawer-panel-motion-right-leave-active {\n  transform: translateX(100%);\n}\n\n.paraui-v3-drawer-panel-motion-top-enter-start,\n.paraui-v3-drawer-panel-motion-top-appear-start,\n.paraui-v3-drawer-panel-motion-top-leave-start {\n  transition: none;\n}\n\n.paraui-v3-drawer-panel-motion-top-enter-active,\n.paraui-v3-drawer-panel-motion-top-appear-active,\n.paraui-v3-drawer-panel-motion-top-leave-active {\n  transition: all 0.3s;\n}\n\n.paraui-v3-drawer-panel-motion-top-enter-start,\n.paraui-v3-drawer-panel-motion-top-appear-start {\n  transform: translateY(-100%) !important;\n}\n\n.paraui-v3-drawer-panel-motion-top-enter-active,\n.paraui-v3-drawer-panel-motion-top-appear-active {\n  transform: translateY(0);\n}\n\n.paraui-v3-drawer-panel-motion-top-leave {\n  transform: translateY(0);\n}\n\n.paraui-v3-drawer-panel-motion-top-leave-active {\n  transform: translateY(-100%);\n}\n\n.paraui-v3-drawer-panel-motion-bottom-enter-start,\n.paraui-v3-drawer-panel-motion-bottom-appear-start,\n.paraui-v3-drawer-panel-motion-bottom-leave-start {\n  transition: none;\n}\n\n.paraui-v3-drawer-panel-motion-bottom-enter-active,\n.paraui-v3-drawer-panel-motion-bottom-appear-active,\n.paraui-v3-drawer-panel-motion-bottom-leave-active {\n  transition: all 0.3s;\n}\n\n.paraui-v3-drawer-panel-motion-bottom-enter-start,\n.paraui-v3-drawer-panel-motion-bottom-appear-start {\n  transform: translateY(100%) !important;\n}\n\n.paraui-v3-drawer-panel-motion-bottom-enter-active,\n.paraui-v3-drawer-panel-motion-bottom-appear-active {\n  transform: translateY(0);\n}\n\n.paraui-v3-drawer-panel-motion-bottom-leave {\n  transform: translateY(0);\n}\n\n.paraui-v3-drawer-panel-motion-bottom-leave-active {\n  transform: translateY(100%);\n}";
styleInject(css_248z);

//drawer 抽屉
var Drawer = function Drawer(props) {
  props.className;
    var onClose = props.onClose,
    _props$destroyOnClose = props.destroyOnClose,
    destroyOnClose = _props$destroyOnClose === void 0 ? false : _props$destroyOnClose,
    style = props.style,
    title = props.title,
    extra = props.extra,
    _props$showExtra = props.showExtra,
    showExtra = _props$showExtra === void 0 ? true : _props$showExtra,
    footer = props.footer,
    children = props.children,
    _props$size = props.size,
    size = _props$size === void 0 ? 'large' : _props$size,
    onOk = props.onOk,
    onCancel = props.onCancel,
    afterVisibleChange = props.afterVisibleChange,
    okButtonProps = props.okButtonProps,
    cancelButtonProps = props.cancelButtonProps,
    _props$push = props.push,
    push = _props$push === void 0 ? {
      distance: 180
    } : _props$push,
    restProps = __rest(props, ["className", "onClose", "destroyOnClose", "style", "title", "extra", "showExtra", "footer", "children", "size", "onOk", "onCancel", "afterVisibleChange", "okButtonProps", "cancelButtonProps", "push"]);
  var intl = useFormatMessage('Drawer', localeJson);
  var _React$useState = React__default.useState(0),
    _React$useState2 = _slicedToArray(_React$useState, 2),
    setRefresh = _React$useState2[1];
  var destroyCloseRef = React__default.useRef(false); //销毁标识
  var timerRef = React__default.useRef();
  React__default.useEffect(function () {
    return function () {
      // 销毁时销毁timer
      if (!timerRef.current) return;
      clearTimeout(timerRef.current);
      timerRef.current = null;
    };
  }, []);
  //设置drawer width、height
  var getOffsetStyle = function getOffsetStyle() {
    if (!props.open) {
      return {};
    }
    var sizeMap = {
      large: '1008px',
      medium: '608px',
      small: '400px'
    };
    var offsetStyle = {};
    if (props.placement === 'left' || props.placement === 'right') {
      var defaultWidth = sizeMap[size];
      if (size !== 'auto') {
        offsetStyle.width = props.width === undefined ? defaultWidth : props.width;
      }
    } else {
      var defaultHeight = size === 'large' ? 736 : 378;
      if (size !== 'auto') {
        offsetStyle.height = props.height === undefined ? defaultHeight : props.height;
      }
    }
    return offsetStyle;
  };
  //关闭回调
  var handleClose = function handleClose(e) {
    onClose === null || onClose === void 0 ? void 0 : onClose(e);
  };
  //确定回调
  var handleOk = function handleOk() {
    onOk === null || onOk === void 0 ? void 0 : onOk();
  };
  //取消回调
  var handleCancel = function handleCancel() {
    onCancel === null || onCancel === void 0 ? void 0 : onCancel();
  };
  var handleTitle = function handleTitle(title) {
    if (typeof title === 'string') {
      return jsx("div", Object.assign({
        className: 'drawer-header-title drawer-header-title-ellipsis'
      }, {
        children: jsx(AutoTips, {
          children: title
        })
      }));
    }
    return jsx("div", Object.assign({
      className: 'drawer-header-title'
    }, {
      children: title
    }));
  };
  //标题节点
  var titleNode = jsxs("div", Object.assign({
    className: 'drawer-body-header'
  }, {
    children: [jsx(Fragment, {
      children: handleTitle(title)
    }), showExtra && jsx(Fragment, {
      children: jsx("div", Object.assign({
        className: 'drawer-header-extra'
      }, {
        children: extra || jsxs(Fragment, {
          children: [jsx(Button, Object.assign({
            variant: "outlined",
            size: "medium",
            onClick: handleCancel
          }, cancelButtonProps, {
            children: (cancelButtonProps === null || cancelButtonProps === void 0 ? void 0 : cancelButtonProps.children) || intl({
              id: 'cancel'
            })
          })), jsx(Button, Object.assign({
            variant: "contained",
            size: "medium",
            onClick: handleOk
          }, okButtonProps, {
            children: (okButtonProps === null || okButtonProps === void 0 ? void 0 : okButtonProps.children) || intl({
              id: 'ok'
            })
          }))]
        })
      }))
    })]
  }));
  //渲染内容
  var renderContent = function renderContent() {
    if (!title && !footer) return children;
    return jsxs("div", Object.assign({
      className: 'drawer-content-body'
    }, {
      children: [title && titleNode, jsx("div", Object.assign({
        className: 'drawer-body-content'
      }, {
        children: children
      })), footer && jsx("div", Object.assign({
        className: 'drawer-body-footer'
      }, {
        children: footer
      }))]
    }));
  };
  if (destroyCloseRef.current) {
    destroyCloseRef.current = false;
    return null;
  }
  var maskMotion = {
    motionName: $prefixCls + '-drawer-mask-motion',
    motionAppear: true,
    motionEnter: true,
    motionLeave: true,
    motionDeadline: isIE() ? 0 : 100
  };
  var panelMotion = function panelMotion(motionPlacement) {
    return {
      motionName: $prefixCls + "-drawer-panel-motion-".concat(motionPlacement),
      motionAppear: true,
      motionEnter: true,
      motionLeave: true,
      motionDeadline: isIE() ? 0 : 100
    };
  };
  return jsx(RcDrawer, Object.assign({}, restProps, getOffsetStyle(), {
    style: style,
    maskMotion: maskMotion,
    motion: panelMotion,
    push: push,
    prefixCls: "".concat($prefixCls, "-drawer"),
    rootClassName: props.className,
    onClose: handleClose,
    afterOpenChange: function afterOpenChange(open) {
      if (open) {
        destroyCloseRef.current = false;
      } else if (destroyOnClose) {
        destroyCloseRef.current = true;
        timerRef.current = setTimeout(function () {
          setRefresh(Math.random());
        }, 300);
      }
      afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(open);
    }
  }, {
    children: renderContent()
  }));
};
Drawer.defaultProps = {
  level: null,
  handler: false,
  showMask: true,
  placement: 'right'
};

export { Drawer, Drawer as default };
