"use client";
import { jsxs as l, jsx as r } from "react/jsx-runtime";
import { Children as h, cloneElement as d, isValidElement as k, useState as x, useEffect as C } from "react";
import { CheckIcon as g, CopyIcon as w } from "@phosphor-icons/react";
import { B as N } from "./button-j0hi0afn33w9lxgi.js";
import { S as y } from "./skeleton-line-1j5exu6vv07mmhfb.js";
import { u as v } from "./link-provider-mn2voeohon7cj9o4.js";
import { c as b } from "./cn-ct4n7r74mh8y0f48.js";
const I = {
  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 L({
  size: t = B.size
} = {}) {
  return b(
    "group mr-4 flex min-w-0 grow items-center overflow-hidden whitespace-nowrap",
    I.size[t].classes
  );
}
const u = ({
  href: t,
  icon: e,
  children: n
}) => {
  const s = v();
  return /* @__PURE__ */ l(
    s,
    {
      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(y, {})
  ] }) : /* @__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 A() {
  return /* @__PURE__ */ r("span", { className: "flex shrink-0 items-center text-kumo-subtle", "aria-hidden": !0, children: "..." });
}
function S({ text: t }) {
  const [e, n] = x(!1);
  return C(() => {
    if (!e) return;
    const a = setTimeout(() => n(!1), 2e3);
    return () => clearTimeout(a);
  }, [e]), /* @__PURE__ */ r(
    N,
    {
      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(g, { weight: "bold", className: "text-kumo-success" }) : /* @__PURE__ */ r(w, { weight: "regular" })
    }
  );
}
function m({
  children: t,
  size: e = "base",
  className: n
}) {
  const s = h.toArray(t), a = E(s);
  return /* @__PURE__ */ l(
    "nav",
    {
      className: b(L({ 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 k(t) && t.type === e;
}
function E(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(A, {}, "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" })
  ], f = t.filter(
    (i) => !o(i, u) && !o(i, p) && !o(i, c)
  );
  return [...a, ...f];
}
m.Link = u;
m.Current = p;
m.Separator = c;
m.Clipboard = S;
export {
  m as B,
  I as K,
  B as a,
  L as b
};
//# sourceMappingURL=breadcrumbs-m79gm4gjwbfajpna.js.map
