"use client";
import { jsxs as l, jsx as r } from "react/jsx-runtime";
import { Children as k, cloneElement as d, isValidElement as x, useState as C, useEffect as g } from "react";
import { CheckIcon as w, CopyIcon as N } from "@phosphor-icons/react";
import { B as y } from "./button-ebfdg9mkhojue36n.js";
import { S as v } from "./skeleton-line-omxgxia23vpav94x.js";
import { u as B } from "./link-provider-mn2voeohon7cj9o4.js";
import { r as I } from "./resolve-variant-gw6eh7fa4st8ej7m.js";
import { c as f } from "./vendor-styling-ofvnbcuht98q88oo.js";
const L = {
  size: {
    sm: {
      classes: "text-sm h-10 gap-0.5",
      description: "Compact breadcrumbs for dense UIs"
    },
    base: {
      classes: "text-base h-12 gap-1",
      description: "Default breadcrumbs size"
    }
  }
}, b = {
  size: "base"
};
function A({
  size: t = b.size
} = {}) {
  return f(
    "group mr-4 flex min-w-0 grow items-center overflow-hidden whitespace-nowrap",
    I(L.size, t, b.size).classes
  );
}
const u = ({
  href: t,
  icon: e,
  children: n
}) => {
  const s = B();
  return /* @__PURE__ */ l(
    s,
    {
      "data-kumo-component": "Breadcrumbs",
      "data-kumo-part": "link",
      to: t,
      className: "flex min-w-0 max-w-full items-center gap-1 text-kumo-subtle no-underline",
      children: [
        !!e && /* @__PURE__ */ r("span", { className: "flex shrink-0 items-center", children: e }),
        /* @__PURE__ */ r("span", { className: "truncate", children: n })
      ]
    }
  );
};
function p({
  children: t,
  icon: e,
  loading: n
}) {
  return n ? /* @__PURE__ */ l("div", { className: "flex w-[125px] min-w-0 items-center gap-1", children: [
    e && /* @__PURE__ */ r("span", { className: "flex shrink-0 items-center", children: e }),
    /* @__PURE__ */ r(v, {})
  ] }) : /* @__PURE__ */ l(
    "div",
    {
      className: "flex min-w-0 max-w-full items-center gap-1 font-medium",
      "aria-current": "page",
      children: [
        e && /* @__PURE__ */ r("span", { className: "flex shrink-0 items-center", children: e }),
        /* @__PURE__ */ r("span", { className: "truncate", children: t })
      ]
    }
  );
}
function c() {
  return /* @__PURE__ */ r(
    "span",
    {
      className: "flex shrink-0 items-center text-kumo-inactive",
      "aria-hidden": "true",
      children: /* @__PURE__ */ r("svg", { width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", children: /* @__PURE__ */ r(
        "path",
        {
          stroke: "currentColor",
          strokeLinecap: "round",
          strokeLinejoin: "round",
          strokeWidth: "1.5",
          d: "M10.75 8.75L14.25 12L10.75 15.25"
        }
      ) })
    }
  );
}
function S() {
  return /* @__PURE__ */ r("span", { className: "flex shrink-0 items-center text-kumo-subtle", "aria-hidden": !0, children: "..." });
}
function E({ text: t }) {
  const [e, n] = C(!1);
  return g(() => {
    if (!e) return;
    const a = setTimeout(() => n(!1), 2e3);
    return () => clearTimeout(a);
  }, [e]), /* @__PURE__ */ r(
    y,
    {
      variant: "ghost",
      shape: "square",
      size: "sm",
      className: "opacity-0 transition-[opacity] group-hover:opacity-100",
      onClick: async () => {
        if (t)
          try {
            await navigator.clipboard.writeText(t), n(!0);
          } catch (a) {
            console.error("Failed to copy deeplink:", a);
          }
      },
      title: "Click to copy",
      "aria-label": "Copy",
      children: e ? /* @__PURE__ */ r(w, { weight: "bold", className: "text-kumo-success" }) : /* @__PURE__ */ r(N, { weight: "regular" })
    }
  );
}
function m({
  children: t,
  size: e = "base",
  className: n
}) {
  const s = k.toArray(t), a = z(s);
  return /* @__PURE__ */ l(
    "nav",
    {
      className: f(A({ size: e }), n),
      "aria-label": "breadcrumb",
      children: [
        /* @__PURE__ */ r("div", { className: "contents sm:hidden", children: a }),
        /* @__PURE__ */ r("div", { className: "hidden sm:contents", children: s })
      ]
    }
  );
}
function o(t, e) {
  return x(t) && t.type === e;
}
function z(t) {
  const e = t.filter(
    (i) => o(i, u) || o(i, p)
  );
  if (e.length <= 2)
    return t;
  const [n, s] = e.slice(-2), a = [
    /* @__PURE__ */ r(S, {}, "kumo-breadcrumb-mobile-ellipsis"),
    /* @__PURE__ */ r(c, {}, "kumo-breadcrumb-mobile-separator-leading"),
    d(n, { key: "kumo-breadcrumb-mobile-parent" }),
    /* @__PURE__ */ r(c, {}, "kumo-breadcrumb-mobile-separator-trailing"),
    d(s, { key: "kumo-breadcrumb-mobile-current" })
  ], h = t.filter(
    (i) => !o(i, u) && !o(i, p) && !o(i, c)
  );
  return [...a, ...h];
}
m.Link = u;
m.Current = p;
m.Separator = c;
m.Clipboard = E;
export {
  m as B,
  L as K,
  b as a,
  A as b
};
//# sourceMappingURL=breadcrumbs-js59m7m57bdsveew.js.map
