"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { ChevronRight, MoreHorizontal } from "lucide-react";
import { cn } from "@open-mercato/shared/lib/utils";
const BreadcrumbContext = React.createContext({
  divider: "slash"
});
function Breadcrumb({
  divider = "slash",
  className,
  children,
  ...props
}) {
  const contextValue = React.useMemo(
    () => ({ divider }),
    [divider]
  );
  return /* @__PURE__ */ jsx(BreadcrumbContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
    "nav",
    {
      "aria-label": "Breadcrumb",
      "data-slot": "breadcrumb",
      "data-divider": divider,
      className: cn("min-w-0", className),
      ...props,
      children
    }
  ) });
}
function BreadcrumbList({ className, children, ...props }) {
  if (React.Children.count(children) === 0) return null;
  return /* @__PURE__ */ jsx(
    "ol",
    {
      "data-slot": "breadcrumb-list",
      className: cn(
        "flex items-center gap-1.5 text-sm font-medium leading-5 tracking-tight min-w-0",
        className
      ),
      ...props,
      children
    }
  );
}
function BreadcrumbItem({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    "li",
    {
      "data-slot": "breadcrumb-item",
      className: cn("inline-flex items-center gap-1.5 min-w-0", className),
      ...props
    }
  );
}
function BreadcrumbLink({
  asChild = false,
  className,
  children,
  ...props
}) {
  const Comp = asChild ? Slot : "a";
  return /* @__PURE__ */ jsx(
    Comp,
    {
      "data-slot": "breadcrumb-link",
      className: cn(
        "inline-flex items-center gap-1.5 max-w-[40vw] md:max-w-[28vw] truncate text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:text-foreground rounded-sm focus-visible:shadow-focus [&_svg:not([class*='size-'])]:size-5 [&_svg]:shrink-0",
        className
      ),
      ...props,
      children
    }
  );
}
function BreadcrumbPage({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    "span",
    {
      "aria-current": "page",
      "data-slot": "breadcrumb-page",
      className: cn(
        "inline-block text-foreground truncate min-w-0 max-w-[45vw] md:max-w-[60vw] [&_svg:not([class*='size-'])]:size-5 [&_svg]:shrink-0 [&_svg]:inline-block [&_svg]:align-middle",
        className
      ),
      ...props
    }
  );
}
function BreadcrumbStatic({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    "span",
    {
      "data-slot": "breadcrumb-static",
      className: cn(
        "inline-flex items-center gap-1.5 max-w-[40vw] md:max-w-[28vw] truncate text-muted-foreground select-none [&_svg:not([class*='size-'])]:size-5 [&_svg]:shrink-0",
        className
      ),
      ...props
    }
  );
}
function BreadcrumbSeparator({
  divider: dividerProp,
  className,
  children,
  ...props
}) {
  const { divider: contextDivider } = React.useContext(BreadcrumbContext);
  const divider = dividerProp ?? contextDivider;
  return /* @__PURE__ */ jsx(
    "li",
    {
      role: "presentation",
      "aria-hidden": "true",
      "data-slot": "breadcrumb-separator",
      "data-divider": divider,
      className: cn(
        "inline-flex items-center text-text-disabled select-none [&_svg:not([class*='size-'])]:size-5",
        className
      ),
      ...props,
      children: children ?? /* @__PURE__ */ jsx(DefaultSeparator, { divider })
    }
  );
}
function DefaultSeparator({ divider }) {
  if (divider === "arrow") return /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": "true" });
  if (divider === "dot") return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xB7" });
  return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "/" });
}
function BreadcrumbEllipsis({ className, children, ...props }) {
  return /* @__PURE__ */ jsxs(
    "span",
    {
      role: "presentation",
      "data-slot": "breadcrumb-ellipsis",
      className: cn(
        "inline-flex size-5 items-center justify-center text-muted-foreground",
        className
      ),
      ...props,
      children: [
        children ?? /* @__PURE__ */ jsx(MoreHorizontal, { "aria-hidden": "true", className: "size-4" }),
        /* @__PURE__ */ jsx("span", { className: "sr-only", children: "More" })
      ]
    }
  );
}
export {
  Breadcrumb,
  BreadcrumbEllipsis,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator,
  BreadcrumbStatic
};
//# sourceMappingURL=breadcrumb.js.map
