"use client";
import { jsxs as r, jsx as e } from "react/jsx-runtime";
import { CaretUpDownIcon as z, CheckIcon as C } from "@phosphor-icons/react";
import { useId as O } from "react";
import { c as v } from "./cn-ct4n7r74mh8y0f48.js";
import { b as V } from "./button-b1yp3lbrhjr9eg07.js";
import { S as A } from "./skeleton-line-1j5exu6vv07mmhfb.js";
import { F as E } from "./field-ftrgblg9mbmz9eo3.js";
import { aU as P, aV as D, aW as T, aX as U, aY as W, aZ as _, a_ as $, a$ as B, b0 as K, b1 as M } from "./vendor-base-ui-kxxocm122zr4pipe.js";
function y(t) {
  return Array.isArray(t) ? t : Object.entries(t).map(([o, a]) => ({
    value: o,
    label: a
  }));
}
function R(t) {
  return y(t).filter((a) => a.value !== null).map((a, n) => /* @__PURE__ */ e(
    S,
    {
      value: a.value,
      children: a.label
    },
    typeof a.value == "string" ? a.value : `option-${n}`
  ));
}
function X({
  children: t,
  className: o,
  renderValue: a,
  label: n,
  hideLabel: c,
  placeholder: d,
  loading: m,
  labelTooltip: x,
  description: s,
  error: l,
  required: I,
  ...i
}) {
  const u = O(), b = i, k = b["aria-label"], N = b["aria-labelledby"], w = typeof n == "string" ? n : d;
  process.env.NODE_ENV !== "production" && c !== void 0 && console.warn(
    '[Kumo Select]: `hideLabel` is deprecated. For hidden labels, use `aria-label` instead of `label` + `hideLabel={true}`.\n  Migration:\n  - For visible labels: <Select label="Country" /> (hideLabel no longer needed)\n  - For hidden labels: <Select aria-label="Select a country" /> (remove label and hideLabel)'
  );
  const f = n && c !== !0, g = f ? void 0 : N ?? (n ? u : void 0), L = k ?? (g ? void 0 : w), F = i.items ? y(i.items) : void 0, j = t ?? (i.items ? R(i.items) : null), h = /* @__PURE__ */ r(
    P,
    {
      ...i,
      items: F,
      disabled: m || i.disabled,
      children: [
        /* @__PURE__ */ r(
          D,
          {
            className: v(
              V(),
              "justify-between font-normal",
              "outline-none focus:opacity-100 focus-visible:ring-1 focus-visible:ring-kumo-ring *:in-focus:opacity-100",
              i.disabled && "cursor-not-allowed opacity-50",
              o
            ),
            "aria-label": L,
            "aria-labelledby": g,
            children: [
              m ? /* @__PURE__ */ e(A, { className: "w-32" }) : /* @__PURE__ */ e(T, { placeholder: d, children: a }),
              /* @__PURE__ */ e(U, { className: "flex items-center", children: /* @__PURE__ */ e(z, {}) })
            ]
          }
        ),
        /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(_, { children: /* @__PURE__ */ e(
          $,
          {
            className: v(
              "overflow-hidden bg-kumo-control text-kumo-default",
              // background
              "rounded-lg shadow-lg ring ring-kumo-line",
              // border part
              // 3px adjustment to account for padding + border differences
              "min-w-[calc(var(--anchor-width)+3px)] p-1.5"
              // spacing
            ),
            children: j
          }
        ) }) })
      ]
    }
  );
  if (f)
    return /* @__PURE__ */ e(
      E,
      {
        label: n,
        required: I,
        labelTooltip: x,
        description: s,
        error: l ? typeof l == "string" ? { message: l, match: !0 } : l : void 0,
        children: h
      }
    );
  const p = l ? typeof l == "string" ? { message: l } : l : void 0;
  return /* @__PURE__ */ r("div", { className: "grid gap-2", children: [
    n && /* @__PURE__ */ e("span", { id: u, className: "sr-only", children: n }),
    h,
    p ? /* @__PURE__ */ e("span", { className: "text-sm text-kumo-danger", children: p.message }) : s && /* @__PURE__ */ e("span", { className: "text-sm leading-snug text-kumo-subtle", children: s })
  ] });
}
function S({ children: t, value: o }) {
  return /* @__PURE__ */ r(
    B,
    {
      value: o,
      className: "group flex cursor-pointer items-center justify-between gap-2 rounded px-2 py-1.5 text-base data-highlighted:bg-kumo-overlay",
      children: [
        /* @__PURE__ */ e(K, { children: t }),
        /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(C, {}) })
      ]
    }
  );
}
X.Option = S;
export {
  X as S
};
//# sourceMappingURL=select-jxxef2rf76pgdrf8.js.map
