import { jsx as t, jsxs as B } from "react/jsx-runtime";
import w, { useMemo as c } from "react";
import { BreadcrumbWrapper as E, BreadcrumbList as g, BreadcrumbItem as v, BreadcrumbSeparator as F } from "./BreadcrumbPrimitives.js";
import M from "./utils/createSubmenu.js";
import $ from "./utils/createMenuItem.js";
import j from "./components/breadcrumb-item/BreadcrumbItem.js";
import D from "./components/breadcrumb-ellipsis-dropdown/BreadcrumbEllipsisDropdown.js";
const L = ({
  items: e,
  maxItems: i = 3,
  className: a,
  ref: d,
  as: u,
  urlField: p,
  ...h
}) => {
  const { visibleItems: n, showEllipsis: b, hiddenItems: l } = c(() => {
    if (!i || e.length <= i)
      return { visibleItems: e, showEllipsis: !1, hiddenItems: [] };
    const r = e[0], s = i - 1, o = e.slice(-s), m = e.slice(1, -s);
    return {
      visibleItems: [r, ...o],
      showEllipsis: !0,
      hiddenItems: m
    };
  }, [e, i]), f = c(() => l.map((r) => r.children && r.children.length > 0 ? M(r) : $(r)), [l]);
  return /* @__PURE__ */ t(E, { ref: d, className: a, ...h, children: /* @__PURE__ */ t(g, { children: n.map((r, s) => {
    const o = s === n.length - 1, I = s === 0 && b;
    return /* @__PURE__ */ B(w.Fragment, { children: [
      /* @__PURE__ */ t(v, { children: /* @__PURE__ */ t(j, { ...r, isLastItem: o, as: u, urlField: p }) }),
      I && /* @__PURE__ */ t(D, { ellipsisDropdownMenuItems: f }),
      !o && /* @__PURE__ */ t(F, {})
    ] }, `breadcrumb-${r.label}-${s}`);
  }) }) });
};
L.displayName = "Breadcrumb";
export {
  L as default
};
//# sourceMappingURL=Breadcrumb.js.map
