"use client";
import { jsx as t, jsxs as g, Fragment as E } from "react/jsx-runtime";
import { forwardRef as K, useContext as N, createContext as w, 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-hvivdirwwnyq88wa.js";
import { L as j } from "./loader-hr2w7cpqeev3p3vl.js";
import { c as m } from "./cn-ct4n7r74mh8y0f48.js";
import { u as U } from "./portal-provider-hwmkdmkpvct0cb76.js";
import { a6 as q, a8 as O, ab as V, bt as v, aa as $, a9 as z, ac as B, bu as J, aq as Q, av as W, aw as X, ax as Y } from "./vendor-base-ui-ie71jahf0czyf58j.js";
const C = w({});
function I({
  open: e,
  onOpenChange: n,
  onBackdropClick: o,
  children: l,
  container: s
}) {
  const u = U(), d = s ?? u ?? void 0, r = (c) => {
    o ? o(c) : n(!1);
  }, a = b(() => {
    n(!1);
  }, [n]);
  return /* @__PURE__ */ t(Q, { open: e, onOpenChange: n, modal: !0, children: /* @__PURE__ */ g(W, { container: d, children: [
    /* @__PURE__ */ t(
      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__ */ t(
      G,
      {
        render: /* @__PURE__ */ t(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__ */ t(C.Provider, { value: { onClose: a }, children: l })
      }
    )
  ] }) });
}
function Z({
  open: e,
  onOpenChange: n,
  onBackdropClick: o,
  children: l,
  items: s,
  value: u,
  onValueChange: d,
  onItemHighlighted: r,
  itemToStringValue: a,
  filter: c,
  onSelect: i,
  getSelectableItems: f,
  container: h
}) {
  return /* @__PURE__ */ t(
    I,
    {
      open: e,
      onOpenChange: n,
      onBackdropClick: o,
      container: h,
      children: /* @__PURE__ */ t(
        A,
        {
          items: s,
          value: u,
          onValueChange: d,
          onItemHighlighted: r,
          itemToStringValue: a,
          filter: c,
          open: e,
          onSelect: i,
          getSelectableItems: f,
          children: l
        }
      )
    }
  );
}
function S({
  children: e,
  leading: n,
  trailing: o
}) {
  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__ */ t(
      F,
      {
        className: "h-4 w-4 text-kumo-subtle",
        weight: "bold"
      }
    ),
    e,
    o
  ] });
}
const D = K(function({ children: n, className: o }, l) {
  return /* @__PURE__ */ t(
    "div",
    {
      ref: l,
      className: m(
        "min-h-0 flex-1 overflow-y-auto rounded-b-lg bg-kumo-base px-2 py-2 ring-1 ring-kumo-hairline",
        o
      ),
      children: n
    }
  );
});
D.displayName = "CommandPalette.List";
function tt({
  children: e,
  className: n,
  ...o
}) {
  return /* @__PURE__ */ t(z, { className: m("space-y-0.5", n), ...o, children: e });
}
function et({
  children: e,
  className: n
}) {
  return /* @__PURE__ */ t(
    $,
    {
      className: m(
        "mb-2 px-2 pt-1 text-xs font-semibold text-kumo-strong",
        n
      ),
      children: e
    }
  );
}
function nt({
  value: e,
  disabled: n,
  children: o,
  className: l,
  onClick: s
}) {
  return /* @__PURE__ */ t(
    v,
    {
      value: e,
      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",
        l
      ),
      children: o
    }
  );
}
function ot({ children: e }) {
  return /* @__PURE__ */ t(V, { children: /* @__PURE__ */ t("div", { className: "p-8 text-center", children: /* @__PURE__ */ t("p", { className: "text-kumo-strong", children: e ?? "No results found" }) }) });
}
function at({ children: e }) {
  return /* @__PURE__ */ t("div", { className: "flex items-center justify-center p-8", children: e ?? /* @__PURE__ */ t(j, { size: 24 }) });
}
function st({ children: e }) {
  return /* @__PURE__ */ t("div", { className: "flex items-center justify-between rounded-b-lg bg-kumo-elevated px-4 py-3 text-xs text-kumo-strong", children: e });
}
function y({
  text: e,
  highlights: n,
  className: o
}) {
  if (!n || n.length === 0)
    return /* @__PURE__ */ t("span", { className: o, children: e });
  const l = [...n].sort((r, a) => r[0] - a[0]), s = [];
  for (const r of l) {
    const a = s[s.length - 1];
    a && r[0] <= a[1] + 1 ? a[1] = Math.max(a[1], r[1]) : s.push([...r]);
  }
  const u = [];
  let d = 0;
  return s.forEach((r, a) => {
    const [c, i] = r;
    c > d && u.push(/* @__PURE__ */ t("span", { children: e.slice(d, c) }, `text-${a}`)), u.push(
      /* @__PURE__ */ t(
        "mark",
        {
          className: "rounded-sm bg-kumo-warning/50 text-kumo-default",
          children: e.slice(c, i + 1)
        },
        `highlight-${a}`
      )
    ), d = i + 1;
  }), d < e.length && u.push(/* @__PURE__ */ t("span", { children: e.slice(d) }, "text-end")), /* @__PURE__ */ t("span", { className: o, children: u });
}
function rt({
  title: e,
  breadcrumbs: n,
  titleHighlights: o,
  breadcrumbHighlights: l,
  description: s,
  icon: u,
  value: d,
  onClick: r,
  showArrow: a = !0,
  external: c = !1,
  nonInteractive: i = !1
}) {
  return /* @__PURE__ */ g(
    v,
    {
      value: d,
      onClick: i ? 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",
        i ? "cursor-default" : "cursor-pointer data-[highlighted]:bg-kumo-overlay"
      ),
      children: [
        u && /* @__PURE__ */ t("div", { className: "flex flex-shrink-0 items-center text-kumo-subtle", children: u }),
        /* @__PURE__ */ t("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__ */ t(
              y,
              {
                text: f,
                highlights: l?.[h],
                className: "text-base text-kumo-default"
              }
            ),
            /* @__PURE__ */ t(
              M,
              {
                className: "h-3 w-3 flex-shrink-0 text-kumo-subtle",
                weight: "bold"
              }
            )
          ] }, h)),
          /* @__PURE__ */ t(
            y,
            {
              text: e,
              highlights: o,
              className: "text-base text-kumo-default"
            }
          ),
          c && /* @__PURE__ */ t(H, { className: "h-3.5 w-3.5 flex-shrink-0 text-kumo-subtle" }),
          s && /* @__PURE__ */ g(E, { children: [
            /* @__PURE__ */ t("span", { className: "text-kumo-strong", children: "—" }),
            /* @__PURE__ */ t("span", { className: "truncate text-sm text-kumo-strong", children: s })
          ] })
        ] }) }),
        a && !c && !i && /* @__PURE__ */ t(_, { className: "h-4 w-4 flex-shrink-0 text-kumo-subtle opacity-0 transition-opacity group-data-[highlighted]:opacity-100" })
      ]
    }
  );
}
function it({
  children: e,
  className: n
}) {
  return /* @__PURE__ */ t(
    "div",
    {
      className: m(
        "flex max-h-[60vh] flex-col overflow-hidden rounded-lg bg-kumo-elevated",
        n
      ),
      children: e
    }
  );
}
const L = w({}), lt = () => !0;
function A({
  children: e,
  items: n,
  value: o,
  onValueChange: l,
  onItemHighlighted: s,
  itemToStringValue: u,
  filter: d = lt,
  open: r = !0,
  className: a,
  onSelect: c,
  getSelectableItems: i
}) {
  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 && i) {
        const k = i(n)[f.current];
        k !== void 0 && (p.preventDefault(), c(k, { newTab: !0 }));
      }
    },
    [n, c, i]
  );
  return /* @__PURE__ */ t(it, { className: a, children: /* @__PURE__ */ t(
    J,
    {
      items: n,
      value: o,
      onValueChange: l,
      onItemHighlighted: h,
      itemToStringValue: u,
      filter: d,
      autoHighlight: "always",
      keepHighlight: !0,
      open: r,
      children: /* @__PURE__ */ t(L.Provider, { value: { onInputKeyDown: P }, children: e })
    }
  ) });
}
function ct({
  autoFocus: e = !0,
  placeholder: n,
  className: o,
  onKeyDown: l,
  leading: s,
  trailing: u,
  ...d
}) {
  const { onInputKeyDown: r } = N(L), { onClose: a } = N(C), c = b(
    (i) => {
      if (l?.(i), !i.defaultPrevented) {
        if (i.key === "Escape" && a) {
          i.preventDefault(), a();
          return;
        }
        r?.(i);
      }
    },
    [r, l, a]
  );
  return /* @__PURE__ */ t(S, { leading: s, trailing: u, children: /* @__PURE__ */ t(
    B,
    {
      placeholder: n,
      className: m(
        "flex-1 border-none bg-transparent text-base kumo-input-placeholder",
        "outline-none",
        o
      ),
      onKeyDown: c,
      autoFocus: e,
      ...d
    }
  ) });
}
function ut({
  children: e,
  className: n
}) {
  return /* @__PURE__ */ t(O, { className: m("space-y-3", n), children: e });
}
const dt = q, Nt = {}, wt = {}, vt = {
  /** 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: A,
  /** Input for use inside Panel */
  Input: ct,
  /** Scrollable results container */
  List: D,
  /** Category grouping */
  Group: tt,
  /** Section header text */
  GroupLabel: et,
  /** Basic item */
  Item: nt,
  /** Rich item with breadcrumbs, highlights, icons */
  ResultItem: rt,
  /** Text with highlighted portions */
  HighlightedText: y,
  /** Empty state */
  Empty: ot,
  /** Loading state */
  Loading: at,
  /** Footer for keyboard hints */
  Footer: st,
  /** Render prop iterator for groups */
  Results: ut,
  /** Render prop iterator for items within a group */
  Items: dt
};
export {
  vt as C,
  Nt as K,
  wt as a
};
//# sourceMappingURL=command-palette-gk9m34ymp2b3hfc5.js.map
