import * as i from "react";
import V from "../../../@ant-design/icons/es/icons/ExclamationCircleFilled.mjs";
import k from "../../../classnames/index.mjs";
import D from "../../../rc-util/es/hooks/useMergedState.mjs";
import K from "../../../rc-util/es/KeyCode.mjs";
import I from "../../../rc-util/es/omit.mjs";
import { cloneElement as F } from "../_util/reactNode.mjs";
import "../config-provider/index.mjs";
import R from "../popover/index.mjs";
import z, { Overlay as B } from "./PurePanel.mjs";
import M from "./style/index.mjs";
import { ConfigContext as U } from "../config-provider/context.mjs";
var W = globalThis && globalThis.__rest || function(e, c) {
  var r = {};
  for (var n in e)
    Object.prototype.hasOwnProperty.call(e, n) && c.indexOf(n) < 0 && (r[n] = e[n]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var t = 0, n = Object.getOwnPropertySymbols(e); t < n.length; t++)
      c.indexOf(n[t]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[t]) && (r[n[t]] = e[n[t]]);
  return r;
};
const u = /* @__PURE__ */ i.forwardRef((e, c) => {
  var r, n;
  const {
    prefixCls: t,
    placement: C = "top",
    trigger: g = "click",
    okType: y = "primary",
    icon: O = /* @__PURE__ */ i.createElement(V, null),
    children: a,
    overlayClassName: b,
    onOpenChange: f,
    onVisibleChange: m
  } = e, h = W(e, ["prefixCls", "placement", "trigger", "okType", "icon", "children", "overlayClassName", "onOpenChange", "onVisibleChange"]), {
    getPrefixCls: P
  } = i.useContext(U), [v, x] = D(!1, {
    value: (r = e.open) !== null && r !== void 0 ? r : e.visible,
    defaultValue: (n = e.defaultOpen) !== null && n !== void 0 ? n : e.defaultVisible
  }), s = (o, l) => {
    x(o, !0), m == null || m(o), f == null || f(o, l);
  }, _ = (o) => {
    s(!1, o);
  }, E = (o) => {
    var l;
    return (l = e.onConfirm) === null || l === void 0 ? void 0 : l.call(globalThis, o);
  }, N = (o) => {
    var l;
    s(!1, o), (l = e.onCancel) === null || l === void 0 || l.call(globalThis, o);
  }, w = (o) => {
    o.keyCode === K.ESC && v && s(!1, o);
  }, j = (o) => {
    const {
      disabled: l = !1
    } = e;
    l || s(o);
  }, p = P("popconfirm", t), S = k(p, b), [T] = M(p);
  return T(/* @__PURE__ */ i.createElement(R, Object.assign({}, I(h, ["title"]), {
    trigger: g,
    placement: C,
    onOpenChange: j,
    open: v,
    ref: c,
    overlayClassName: S,
    content: /* @__PURE__ */ i.createElement(B, Object.assign({
      okType: y,
      icon: O
    }, e, {
      prefixCls: p,
      close: _,
      onConfirm: E,
      onCancel: N
    })),
    "data-popover-inject": !0
  }), F(a, {
    onKeyDown: (o) => {
      var l, d;
      /* @__PURE__ */ i.isValidElement(a) && ((d = a == null ? void 0 : (l = a.props).onKeyDown) === null || d === void 0 || d.call(l, o)), w(o);
    }
  })));
});
u._InternalPanelDoNotUseOrYouWillBeFired = z;
process.env.NODE_ENV !== "production" && (u.displayName = "Popconfirm");
const ee = u;
export {
  ee as default
};
