import b from "../../@babel/runtime/helpers/esm/extends.mjs";
import w from "../../@babel/runtime/helpers/esm/defineProperty.mjs";
import D from "../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import L from "../../classnames/index.mjs";
import T from "../../rc-util/es/KeyCode.mjs";
import * as c from "react";
var q = /* @__PURE__ */ c.forwardRef(function(e, C) {
  var y = e.prefixCls, E = e.style, N = e.className, s = e.duration, l = s === void 0 ? 4.5 : s, _ = e.eventKey, M = e.content, u = e.closable, v = e.closeIcon, g = v === void 0 ? "x" : v, n = e.props, k = e.onClick, x = e.onNoticeClose, I = e.times, K = e.hovering, P = c.useState(!1), f = D(P, 2), $ = f[0], m = f[1], d = K || $, r = function() {
    x(_);
  }, R = function(o) {
    (o.key === "Enter" || o.code === "Enter" || o.keyCode === T.ENTER) && r();
  };
  c.useEffect(function() {
    if (!d && l > 0) {
      var a = setTimeout(function() {
        r();
      }, l * 1e3);
      return function() {
        clearTimeout(a);
      };
    }
  }, [l, d, I]);
  var i = "".concat(y, "-notice");
  return /* @__PURE__ */ c.createElement("div", b({}, n, {
    ref: C,
    className: L(i, N, w({}, "".concat(i, "-closable"), u)),
    style: E,
    onMouseEnter: function(o) {
      var t;
      m(!0), n == null || (t = n.onMouseEnter) === null || t === void 0 || t.call(n, o);
    },
    onMouseLeave: function(o) {
      var t;
      m(!1), n == null || (t = n.onMouseLeave) === null || t === void 0 || t.call(n, o);
    },
    onClick: k
  }), /* @__PURE__ */ c.createElement("div", {
    className: "".concat(i, "-content")
  }, M), u && /* @__PURE__ */ c.createElement("a", {
    tabIndex: 0,
    className: "".concat(i, "-close"),
    onKeyDown: R,
    onClick: function(o) {
      o.preventDefault(), o.stopPropagation(), r();
    }
  }, g));
});
export {
  q as default
};
