import * as o from "react";
import u from "../../../classnames/index.mjs";
import _ from "../_util/hooks/useClosable.mjs";
import "../config-provider/index.mjs";
import { ConfigContext as S } from "../config-provider/context.mjs";
const I = (C) => {
  var i, c;
  const {
    prefixCls: l,
    title: d,
    footer: v,
    extra: n,
    closeIcon: g,
    closable: h,
    onClose: b,
    headerStyle: y,
    drawerStyle: p,
    bodyStyle: $,
    footerStyle: f,
    children: j,
    classNames: s,
    styles: t
  } = C, {
    drawer: e
  } = o.useContext(S), O = o.useCallback((a) => /* @__PURE__ */ o.createElement("button", {
    type: "button",
    onClick: b,
    "aria-label": "Close",
    className: `${l}-close`
  }, a), [b]), [m, N] = _(h, g, O, void 0, !0), w = o.useMemo(() => {
    var a, r;
    return !d && !m ? null : /* @__PURE__ */ o.createElement("div", {
      style: Object.assign(Object.assign(Object.assign({}, (a = e == null ? void 0 : e.styles) === null || a === void 0 ? void 0 : a.header), y), t == null ? void 0 : t.header),
      className: u(`${l}-header`, {
        [`${l}-header-close-only`]: m && !d && !n
      }, (r = e == null ? void 0 : e.classNames) === null || r === void 0 ? void 0 : r.header, s == null ? void 0 : s.header)
    }, /* @__PURE__ */ o.createElement("div", {
      className: `${l}-header-title`
    }, N, d && /* @__PURE__ */ o.createElement("div", {
      className: `${l}-title`
    }, d)), n && /* @__PURE__ */ o.createElement("div", {
      className: `${l}-extra`
    }, n));
  }, [m, N, n, y, l, d]), E = o.useMemo(() => {
    var a, r;
    if (!v)
      return null;
    const x = `${l}-footer`;
    return /* @__PURE__ */ o.createElement("div", {
      className: u(x, (a = e == null ? void 0 : e.classNames) === null || a === void 0 ? void 0 : a.footer, s == null ? void 0 : s.footer),
      style: Object.assign(Object.assign(Object.assign({}, (r = e == null ? void 0 : e.styles) === null || r === void 0 ? void 0 : r.footer), f), t == null ? void 0 : t.footer)
    }, v);
  }, [v, f, l]);
  return /* @__PURE__ */ o.createElement("div", {
    className: `${l}-wrapper-body`,
    style: p
  }, w, /* @__PURE__ */ o.createElement("div", {
    className: u(`${l}-body`, s == null ? void 0 : s.body, (i = e == null ? void 0 : e.classNames) === null || i === void 0 ? void 0 : i.body),
    style: Object.assign(Object.assign(Object.assign({}, (c = e == null ? void 0 : e.styles) === null || c === void 0 ? void 0 : c.body), $), t == null ? void 0 : t.body)
  }, j), E);
}, R = I;
export {
  R as default
};
