"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-j0hi0afn33w9lxgi.js";
import { S as A } from "./skeleton-line-1j5exu6vv07mmhfb.js";
import { F as E } from "./field-csje72m7j9403fj5.js";
import { aV as P, aW as D, aX as T, aY as W, aZ as _, a_ as $, a$ as B, b0 as K, b1 as M, b2 as R } from "./vendor-base-ui-ccr5l0ynrievzzv3.js";
function y(t) {
  return Array.isArray(t) ? t : Object.entries(t).map(([s, a]) => ({
    value: s,
    label: a
  }));
}
function U(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: s,
  renderValue: a,
  label: n,
  hideLabel: c,
  placeholder: d,
  loading: m,
  labelTooltip: x,
  description: o,
  error: i,
  required: I,
  ...l
}) {
  const u = O(), b = l, 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 = l.items ? y(l.items) : void 0, j = t ?? (l.items ? U(l.items) : null), h = /* @__PURE__ */ r(
    P,
    {
      ...l,
      items: F,
      disabled: m || l.disabled,
      children: [
        /* @__PURE__ */ r(
          D,
          {
            className: v(
              V(),
              "justify-between font-normal",
              "focus:opacity-100 focus-visible:ring-1 focus-visible:ring-kumo-ring *:in-focus:opacity-100",
              l.disabled && "cursor-not-allowed opacity-50",
              s
            ),
            "aria-label": L,
            "aria-labelledby": g,
            children: [
              m ? /* @__PURE__ */ e(A, { className: "w-32" }) : /* @__PURE__ */ e(
                T,
                {
                  placeholder: d,
                  className: "min-w-0 truncate",
                  children: a
                }
              ),
              /* @__PURE__ */ e(W, { className: "flex shrink-0 items-center", children: /* @__PURE__ */ e(z, {}) })
            ]
          }
        ),
        /* @__PURE__ */ e(_, { children: /* @__PURE__ */ e($, { children: /* @__PURE__ */ e(
          B,
          {
            className: v(
              "overflow-hidden bg-kumo-base text-kumo-default",
              // background
              "rounded-lg shadow-lg ring ring-kumo-ring",
              // 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: o,
        error: i ? typeof i == "string" ? { message: i, match: !0 } : i : void 0,
        children: h
      }
    );
  const p = i ? typeof i == "string" ? { message: i } : i : 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 }) : o && /* @__PURE__ */ e("span", { className: "text-sm leading-snug text-kumo-subtle", children: o })
  ] });
}
function S({ children: t, value: s }) {
  return /* @__PURE__ */ r(
    K,
    {
      value: s,
      className: "group flex cursor-pointer items-center justify-between gap-2 rounded px-2 py-1.5 text-base data-highlighted:bg-kumo-tint",
      children: [
        /* @__PURE__ */ e(M, { children: t }),
        /* @__PURE__ */ e(R, { children: /* @__PURE__ */ e(C, {}) })
      ]
    }
  );
}
X.Option = S;
export {
  X as S
};
//# sourceMappingURL=select-hnt87e3cfos48qql.js.map
