"use client";
import { jsx as e, jsxs as g, Fragment as E } from "react/jsx-runtime";
import { forwardRef as K, useContext as N, createContext as v, useCallback as b, useRef as T } from "react";
import { CaretRightIcon as M, ArrowSquareOutIcon as H, ArrowRightIcon as _, MagnifyingGlassIcon as F } from "@phosphor-icons/react";
import { L as G } from "./layer-card-m6h85dpadvee39h2.js";
import { L as j } from "./loader-g8a6j76ue5nq0lr8.js";
import { u as U } from "./portal-provider-hwmkdmkpvct0cb76.js";
import { c as m } from "./vendor-styling-ofvnbcuht98q88oo.js";
import { aa as z, ac as B, af as O, bz as w, ae as V, ad as $, ag as q, bA as J, au as Q, aA as W, aB as X, aC as Y } from "./vendor-base-ui-elpbzr8xeffrz4h2.js";
const C = v({});
function I({
  open: t,
  onOpenChange: n,
  onBackdropClick: a,
  children: i,
  container: s
}) {
  const u = U(), d = s ?? u ?? void 0, r = (c) => {
    a ? a(c) : n(!1);
  }, o = b(() => {
    n(!1);
  }, [n]);
  return /* @__PURE__ */ e(Q, { open: t, onOpenChange: n, modal: !0, children: /* @__PURE__ */ g(W, { container: d, children: [
    /* @__PURE__ */ e(
      X,
      {
        className: "fixed inset-0 bg-kumo-overlay opacity-80 transition-all duration-150 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0",
        onClick: r
      }
    ),
    /* @__PURE__ */ e(
      G,
      {
        render: /* @__PURE__ */ e(Y, {}),
        className: m(
          "fixed top-[10vh] left-1/2 w-full max-w-2xl -translate-x-1/2",
          "overflow-hidden rounded-lg",
          "duration-150 data-[ending-style]:scale-90 data-[ending-style]:opacity-0 data-[starting-style]:scale-90 data-[starting-style]:opacity-0"
        ),
        style: {
          transitionProperty: "scale, opacity",
          transitionTimingFunction: "var(--default-transition-timing-function)"
        },
        children: /* @__PURE__ */ e(C.Provider, { value: { onClose: o }, children: i })
      }
    )
  ] }) });
}
function Z({
  open: t,
  onOpenChange: n,
  onBackdropClick: a,
  children: i,
  items: s,
  value: u,
  onValueChange: d,
  onItemHighlighted: r,
  itemToStringValue: o,
  filter: c,
  onSelect: l,
  getSelectableItems: f,
  container: h
}) {
  return /* @__PURE__ */ e(
    I,
    {
      open: t,
      onOpenChange: n,
      onBackdropClick: a,
      container: h,
      children: /* @__PURE__ */ e(
        L,
        {
          items: s,
          value: u,
          onValueChange: d,
          onItemHighlighted: r,
          itemToStringValue: o,
          filter: c,
          open: t,
          onSelect: l,
          getSelectableItems: f,
          children: i
        }
      )
    }
  );
}
function S({
  children: t,
  leading: n,
  trailing: a
}) {
  return /* @__PURE__ */ g("div", { className: "flex items-center gap-3 bg-kumo-base px-4 py-3 focus-within:ring-2 focus-within:ring-kumo-brand", children: [
    n ?? /* @__PURE__ */ e(
      F,
      {
        className: "h-4 w-4 text-kumo-subtle",
        weight: "bold"
      }
    ),
    t,
    a
  ] });
}
const D = K(function({ children: n, className: a }, i) {
  return /* @__PURE__ */ e(
    "div",
    {
      ref: i,
      className: m(
        "relative min-h-0 flex-1 overflow-y-auto rounded-b-lg bg-kumo-base px-2 py-2 scroll-py-2 ring-1 ring-kumo-hairline",
        a
      ),
      children: n
    }
  );
});
D.displayName = "CommandPalette.List";
function ee({
  children: t,
  className: n,
  ...a
}) {
  return /* @__PURE__ */ e($, { className: m("space-y-0.5", n), ...a, children: t });
}
function te({
  children: t,
  className: n
}) {
  return /* @__PURE__ */ e(
    V,
    {
      className: m(
        "mb-2 px-2 pt-1 text-xs font-semibold text-kumo-subtle",
        n
      ),
      children: t
    }
  );
}
function ne({
  value: t,
  disabled: n,
  children: a,
  className: i,
  onClick: s
}) {
  return /* @__PURE__ */ e(
    w,
    {
      value: t,
      disabled: n,
      onClick: s,
      className: m(
        "group flex w-full items-center gap-3 px-2 py-1.5 text-left text-base transition-colors",
        "cursor-pointer data-[highlighted]:bg-kumo-overlay",
        "rounded-lg",
        n && "cursor-default opacity-50",
        i
      ),
      children: a
    }
  );
}
function ae({ children: t }) {
  return /* @__PURE__ */ e(O, { children: /* @__PURE__ */ e("div", { className: "p-8 text-center", children: /* @__PURE__ */ e("p", { className: "text-kumo-subtle", children: t ?? "No results found" }) }) });
}
function oe({ children: t }) {
  return /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: t ?? /* @__PURE__ */ e(j, { size: 24 }) });
}
function se({ children: t }) {
  return /* @__PURE__ */ e("div", { className: "flex items-center justify-between rounded-b-lg bg-kumo-elevated px-4 py-3 text-xs text-kumo-subtle", children: t });
}
function y({
  text: t,
  highlights: n,
  className: a
}) {
  if (!n || n.length === 0)
    return /* @__PURE__ */ e("span", { className: a, children: t });
  const i = [...n].sort((r, o) => r[0] - o[0]), s = [];
  for (const r of i) {
    const o = s[s.length - 1];
    o && r[0] <= o[1] + 1 ? o[1] = Math.max(o[1], r[1]) : s.push([...r]);
  }
  const u = [];
  let d = 0;
  return s.forEach((r, o) => {
    const [c, l] = r;
    c > d && u.push(/* @__PURE__ */ e("span", { children: t.slice(d, c) }, `text-${o}`)), u.push(
      /* @__PURE__ */ e(
        "mark",
        {
          className: "rounded-sm bg-kumo-warning/50 text-kumo-default",
          children: t.slice(c, l + 1)
        },
        `highlight-${o}`
      )
    ), d = l + 1;
  }), d < t.length && u.push(/* @__PURE__ */ e("span", { children: t.slice(d) }, "text-end")), /* @__PURE__ */ e("span", { className: a, children: u });
}
function re({
  title: t,
  breadcrumbs: n,
  titleHighlights: a,
  breadcrumbHighlights: i,
  description: s,
  icon: u,
  value: d,
  onClick: r,
  showArrow: o = !0,
  external: c = !1,
  nonInteractive: l = !1
}) {
  return /* @__PURE__ */ g(
    w,
    {
      value: d,
      onClick: l ? void 0 : (f) => r(f),
      className: m(
        "group flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition-colors",
        l ? "cursor-default" : "cursor-pointer data-[highlighted]:bg-kumo-overlay"
      ),
      children: [
        u && /* @__PURE__ */ e("div", { className: "flex flex-shrink-0 items-center text-kumo-subtle", children: u }),
        /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ g("div", { className: "flex items-center gap-2 truncate", children: [
          n?.map((f, h) => /* @__PURE__ */ g("span", { className: "flex items-center gap-2", children: [
            /* @__PURE__ */ e(
              y,
              {
                text: f,
                highlights: i?.[h],
                className: "text-base text-kumo-default"
              }
            ),
            /* @__PURE__ */ e(
              M,
              {
                className: "h-3 w-3 flex-shrink-0 text-kumo-subtle",
                weight: "bold"
              }
            )
          ] }, h)),
          /* @__PURE__ */ e(
            y,
            {
              text: t,
              highlights: a,
              className: "text-base text-kumo-default"
            }
          ),
          c && /* @__PURE__ */ e(H, { className: "h-3.5 w-3.5 flex-shrink-0 text-kumo-subtle" }),
          s && /* @__PURE__ */ g(E, { children: [
            /* @__PURE__ */ e("span", { className: "text-kumo-subtle", children: "—" }),
            /* @__PURE__ */ e("span", { className: "truncate text-sm text-kumo-subtle", children: s })
          ] })
        ] }) }),
        o && !c && !l && /* @__PURE__ */ e(_, { className: "h-4 w-4 flex-shrink-0 text-kumo-subtle opacity-0 transition-opacity group-data-[highlighted]:opacity-100" })
      ]
    }
  );
}
function le({
  children: t,
  className: n
}) {
  return /* @__PURE__ */ e(
    "div",
    {
      className: m(
        "flex max-h-[60vh] flex-col overflow-hidden rounded-lg bg-kumo-elevated",
        n
      ),
      children: t
    }
  );
}
const A = v({}), ie = () => !0;
function L({
  children: t,
  items: n,
  value: a,
  onValueChange: i,
  onItemHighlighted: s,
  itemToStringValue: u,
  filter: d = ie,
  open: r = !0,
  className: o,
  onSelect: c,
  getSelectableItems: l
}) {
  const f = T(-1), h = b(
    (p, x) => {
      f.current = x.index, s?.(p, x);
    },
    [s]
  ), P = b(
    (p) => {
      const x = p.key === "Enter", R = p.metaKey || p.ctrlKey;
      if (x && R && c && l) {
        const k = l(n)[f.current];
        k !== void 0 && (p.preventDefault(), c(k, { newTab: !0 }));
      }
    },
    [n, c, l]
  );
  return /* @__PURE__ */ e(le, { className: o, children: /* @__PURE__ */ e(
    J,
    {
      items: n,
      value: a,
      onValueChange: i,
      onItemHighlighted: h,
      itemToStringValue: u,
      filter: d,
      autoHighlight: "always",
      keepHighlight: !0,
      open: r,
      children: /* @__PURE__ */ e(A.Provider, { value: { onInputKeyDown: P }, children: t })
    }
  ) });
}
function ce({
  autoFocus: t = !0,
  placeholder: n,
  className: a,
  onKeyDown: i,
  leading: s,
  trailing: u,
  ...d
}) {
  const { onInputKeyDown: r } = N(A), { onClose: o } = N(C), c = b(
    (l) => {
      if (i?.(l), !l.defaultPrevented) {
        if (l.key === "Escape" && o) {
          l.preventDefault(), o();
          return;
        }
        r?.(l);
      }
    },
    [r, i, o]
  );
  return /* @__PURE__ */ e(S, { leading: s, trailing: u, children: /* @__PURE__ */ e(
    q,
    {
      placeholder: n,
      className: m(
        "flex-1 border-none bg-transparent text-base kumo-input-placeholder",
        "outline-none",
        a
      ),
      onKeyDown: c,
      autoFocus: t,
      ...d
    }
  ) });
}
function ue({
  children: t,
  className: n
}) {
  return /* @__PURE__ */ e(B, { className: m("space-y-3", n), children: t });
}
const de = z, Ne = {}, ve = {}, we = {
  /** Modal dialog wrapper - use with Panel for content that can swap */
  Dialog: I,
  /** Dialog + Panel combined - for simple single-view command palettes */
  Root: Z,
  /** Autocomplete panel without dialog - use inside Dialog for swappable content */
  Panel: L,
  /** Input for use inside Panel */
  Input: ce,
  /** Scrollable results container */
  List: D,
  /** Category grouping */
  Group: ee,
  /** Section header text */
  GroupLabel: te,
  /** Basic item */
  Item: ne,
  /** Rich item with breadcrumbs, highlights, icons */
  ResultItem: re,
  /** Text with highlighted portions */
  HighlightedText: y,
  /** Empty state */
  Empty: ae,
  /** Loading state */
  Loading: oe,
  /** Footer for keyboard hints */
  Footer: se,
  /** Render prop iterator for groups */
  Results: ue,
  /** Render prop iterator for items within a group */
  Items: de
};
export {
  we as C,
  Ne as K,
  ve as a
};
//# sourceMappingURL=command-palette-c03zze4ayuytwxjg.js.map
