import * as n from "react";
import v from "../../../classnames/index.mjs";
import te from "../../../rc-drawer/es/Drawer.mjs";
import { useZIndex as oe } from "../_util/hooks/useZIndex.mjs";
import { getTransitionName as j } from "../_util/motion.mjs";
import { devUseWarning as se } from "../_util/warning.mjs";
import ne from "../_util/zindexContext.mjs";
import "../config-provider/index.mjs";
import { NoFormStyle as re } from "../form/context.mjs";
import { NoCompactStyle as ae } from "../space/Compact.mjs";
import { usePanelRef as le } from "../watermark/context.mjs";
import S from "./DrawerPanel.mjs";
import D from "./style/index.mjs";
import { ConfigContext as I } from "../config-provider/context.mjs";
var V = globalThis && globalThis.__rest || function(o, l) {
  var r = {};
  for (var t in o)
    Object.prototype.hasOwnProperty.call(o, t) && l.indexOf(t) < 0 && (r[t] = o[t]);
  if (o != null && typeof Object.getOwnPropertySymbols == "function")
    for (var s = 0, t = Object.getOwnPropertySymbols(o); s < t.length; s++)
      l.indexOf(t[s]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[s]) && (r[t[s]] = o[t[s]]);
  return r;
};
const ie = {
  distance: 180
}, x = (o) => {
  var l, r, t, s, d, u, a, p, f;
  const {
    rootClassName: h,
    width: m,
    height: C,
    size: g = "default",
    mask: O = !0,
    push: z = ie,
    open: b,
    afterOpenChange: N,
    onClose: w,
    prefixCls: $,
    getContainer: E,
    style: M,
    className: R,
    // Deprecated
    visible: T,
    afterVisibleChange: W
  } = o, i = V(o, ["rootClassName", "width", "height", "size", "mask", "push", "open", "afterOpenChange", "onClose", "prefixCls", "getContainer", "style", "className", "visible", "afterVisibleChange"]), {
    getPopupContainer: P,
    getPrefixCls: A,
    direction: F,
    drawer: e
  } = n.useContext(I), c = A("drawer", $), [L, U, Z] = D(c), _ = (
    // 有可能为 false，所以不能直接判断
    E === void 0 && P ? () => P(document.body) : E
  ), B = v({
    "no-mask": !O,
    [`${c}-rtl`]: F === "rtl"
  }, h, U, Z);
  if (process.env.NODE_ENV !== "production") {
    const y = se("Drawer");
    [["visible", "open"], ["afterVisibleChange", "afterOpenChange"], ["headerStyle", "styles.header"], ["bodyStyle", "styles.body"], ["footerStyle", "styles.footer"]].forEach((X) => {
      let [k, ee] = X;
      y.deprecated(!(k in o), k, ee);
    }), _ !== void 0 && ((l = o.style) === null || l === void 0 ? void 0 : l.position) === "absolute" && process.env.NODE_ENV !== "production" && y(!1, "breaking", "`style` is replaced by `rootStyle` in v5. Please check that `position: absolute` is necessary.");
  }
  const G = n.useMemo(() => m ?? (g === "large" ? 736 : 378), [m, g]), H = n.useMemo(() => C ?? (g === "large" ? 736 : 378), [C, g]), Y = {
    motionName: j(c, "mask-motion"),
    motionAppear: !0,
    motionEnter: !0,
    motionLeave: !0,
    motionDeadline: 500
  }, q = (y) => ({
    motionName: j(c, `panel-motion-${y}`),
    motionAppear: !0,
    motionEnter: !0,
    motionLeave: !0,
    motionDeadline: 500
  }), J = le(), [K, Q] = oe("Drawer", i.zIndex);
  return L(/* @__PURE__ */ n.createElement(ae, null, /* @__PURE__ */ n.createElement(re, {
    status: !0,
    override: !0
  }, /* @__PURE__ */ n.createElement(ne.Provider, {
    value: Q
  }, /* @__PURE__ */ n.createElement(te, Object.assign({
    prefixCls: c,
    onClose: w,
    maskMotion: Y,
    motion: q
  }, i, {
    classNames: {
      mask: v((r = i.classNames) === null || r === void 0 ? void 0 : r.mask, (t = e == null ? void 0 : e.classNames) === null || t === void 0 ? void 0 : t.mask),
      content: v((s = i.classNames) === null || s === void 0 ? void 0 : s.content, (d = e == null ? void 0 : e.classNames) === null || d === void 0 ? void 0 : d.content)
    },
    styles: {
      mask: Object.assign(Object.assign({}, (u = i.styles) === null || u === void 0 ? void 0 : u.mask), (a = e == null ? void 0 : e.styles) === null || a === void 0 ? void 0 : a.mask),
      content: Object.assign(Object.assign({}, (p = i.styles) === null || p === void 0 ? void 0 : p.content), (f = e == null ? void 0 : e.styles) === null || f === void 0 ? void 0 : f.content)
    },
    open: b ?? T,
    mask: O,
    push: z,
    width: G,
    height: H,
    style: Object.assign(Object.assign({}, e == null ? void 0 : e.style), M),
    className: v(e == null ? void 0 : e.className, R),
    rootClassName: B,
    getContainer: _,
    afterOpenChange: N ?? W,
    panelRef: J,
    zIndex: K
  }), /* @__PURE__ */ n.createElement(S, Object.assign({
    prefixCls: c
  }, i, {
    onClose: w
  })))))));
}, me = (o) => {
  const {
    prefixCls: l,
    style: r,
    className: t,
    placement: s = "right"
  } = o, d = V(o, ["prefixCls", "style", "className", "placement"]), {
    getPrefixCls: u
  } = n.useContext(I), a = u("drawer", l), [p, f, h] = D(a), m = v(a, `${a}-pure`, `${a}-${s}`, f, h, t);
  return p(/* @__PURE__ */ n.createElement("div", {
    className: m,
    style: r
  }, /* @__PURE__ */ n.createElement(S, Object.assign({
    prefixCls: a
  }, d))));
};
x._InternalPanelDoNotUseOrYouWillBeFired = me;
process.env.NODE_ENV !== "production" && (x.displayName = "Drawer");
const Oe = x;
export {
  Oe as default
};
