import f from "../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import R from "../../../classnames/index.mjs";
import E from "../../../rc-util/es/KeyCode.mjs";
import * as t from "react";
import { genDataNodeKey as T, getRemovable as h } from "../util.mjs";
var M = function(e) {
  var c, p = e.prefixCls, d = e.id, u = e.active, l = e.tab, i = l.key, r = l.label, s = l.disabled, y = l.closeIcon, m = l.icon, g = e.closable, k = e.renderWrapper, x = e.removeAriaLabel, b = e.editable, I = e.onClick, P = e.onFocus, D = e.style, n = "".concat(p, "-tab"), C = h(g, y, b, s);
  function v(o) {
    s || I(o);
  }
  function w(o) {
    o.preventDefault(), o.stopPropagation(), b.onEdit("remove", {
      key: i,
      event: o
    });
  }
  var K = t.useMemo(function() {
    return m && typeof r == "string" ? /* @__PURE__ */ t.createElement("span", null, r) : r;
  }, [r, m]), N = /* @__PURE__ */ t.createElement("div", {
    key: i,
    "data-node-key": T(i),
    className: R(n, (c = {}, f(c, "".concat(n, "-with-remove"), C), f(c, "".concat(n, "-active"), u), f(c, "".concat(n, "-disabled"), s), c)),
    style: D,
    onClick: v
  }, /* @__PURE__ */ t.createElement("div", {
    role: "tab",
    "aria-selected": u,
    id: d && "".concat(d, "-tab-").concat(i),
    className: "".concat(n, "-btn"),
    "aria-controls": d && "".concat(d, "-panel-").concat(i),
    "aria-disabled": s,
    tabIndex: s ? null : 0,
    onClick: function(a) {
      a.stopPropagation(), v(a);
    },
    onKeyDown: function(a) {
      [E.SPACE, E.ENTER].includes(a.which) && (a.preventDefault(), v(a));
    },
    onFocus: P
  }, m && /* @__PURE__ */ t.createElement("span", {
    className: "".concat(n, "-icon")
  }, m), r && K), C && /* @__PURE__ */ t.createElement("button", {
    type: "button",
    "aria-label": x || "remove",
    tabIndex: 0,
    className: "".concat(n, "-remove"),
    onClick: function(a) {
      a.stopPropagation(), w(a);
    }
  }, y || b.removeIcon || "×"));
  return k ? k(N) : N;
};
export {
  M as default
};
