import { jsxs as j, jsx as n } from "react/jsx-runtime";
import r, { useState as m } from "react";
import { AnimatePresence as E } from "motion/react";
import H from "../../utils/classNames.js";
import I from "./DataTabHeader.js";
const W = (i) => {
  const [a] = i;
  return a?.props.tabKey;
}, G = (i) => {
  const {
    activeKey: a = "",
    bordered: d = !0,
    className: p,
    commonTabContent: c,
    disableTransition: l = !1,
    arrowClassName: h = "bg-highlight-dark border-color-transparent",
    onSelectTab: C = () => {
    },
    tabActiveClassName: u = "bg-highlight-dark text-color-white",
    tabClassName: v = "",
    tabContentClassName: N = "",
    tabFirstChildClassName: T = "",
    tabHoverClassName: f = "bg-highlight-decent text-color-darkest",
    tabLastChildClassName: g = "",
    tabsWrapperClassName: y = "",
    vertical: A = !1,
    children: s,
    ...K
  } = i, [o, D] = m(
    a || W(r.Children.toArray(s))
  ), [w, x] = m(a);
  a !== w && (a && D(a), x(a));
  const k = (t) => {
    C(t.currentTarget?.getAttribute("data-tabkey"));
  }, S = H(
    "DataTabsContainer",
    d && "DataTab-bordered",
    p,
    A ? "DataTabs-vertical" : "DataTabs-horizontal"
  ), F = () => {
    if (l)
      return r.Children.map(s, (e) => e ? r.cloneElement(e, {
        active: e.props.tabKey === o,
        disableTransition: l
      }) : null);
    const t = r.Children.toArray(s).filter((e) => e.props.tabKey === o).map((e) => r.cloneElement(e, { active: !0, disableTransition: l }));
    return /* @__PURE__ */ n(E, { initial: !1, mode: "wait", children: t });
  };
  return /* @__PURE__ */ j("div", { ...K, className: S, children: [
    /* @__PURE__ */ n("div", { className: `DataTabsWrapper ${y}`, children: /* @__PURE__ */ n("ul", { className: "DataTabs", role: "tabList", children: r.Children.map(s, (t, e) => {
      if (!t)
        return null;
      const { tabKey: b, title: L, className: P } = t.props;
      return /* @__PURE__ */ n(
        I,
        {
          isActive: b === o,
          tabKey: b,
          title: L,
          onSelectTab: k,
          isFirstTab: e === 0,
          isLastTab: !!(s?.length - 1),
          tabFirstChildClassName: T,
          tabLastChildClassName: g,
          tabActiveClassName: u,
          tabClassName: v,
          tabHoverClassName: f,
          arrowClassName: h,
          className: P
        }
      );
    }) }) }),
    /* @__PURE__ */ n("div", { className: `tab-content ${N}`, role: "tabpanel", children: c || F() })
  ] });
};
export {
  G as default
};
//# sourceMappingURL=DataTabs.js.map
