"use client";
import * as t from "react";
import * as be from "react-dom";
import { clamp as Re } from "../../../../../@radix-ui_number@1.1.1/node_modules/@radix-ui/number/dist/index.js";
import { composeEventHandlers as E } from "../../../../../@radix-ui_primitive@1.1.2/node_modules/@radix-ui/primitive/dist/index.js";
import { createCollection as nt } from "../../../../../@radix-ui_react-collection@1.1.6_@types_react-dom@19.0.4_@types_react@19.0.10__@types_react@1_ka7w4fakrytsput6lgs2oljks4/node_modules/@radix-ui/react-collection/dist/index.js";
import { useComposedRefs as V } from "../../../../../@radix-ui_react-compose-refs@1.1.2_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-compose-refs/dist/index.js";
import { createContextScope as rt } from "../../../../../@radix-ui_react-context@1.1.2_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-context/dist/index.js";
import { useDirection as st } from "../../../../../@radix-ui_react-direction@1.1.1_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-direction/dist/index.js";
import { DismissableLayer as lt } from "../../../../../@radix-ui_react-dismissable-layer@1.1.9_@types_react-dom@19.0.4_@types_react@19.0.10__@types__hzb3kf6qon52zivfi7gnebhcma/node_modules/@radix-ui/react-dismissable-layer/dist/index.js";
import { useFocusGuards as ct } from "../../../../../@radix-ui_react-focus-guards@1.1.2_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-focus-guards/dist/index.js";
import { FocusScope as it } from "../../../../../@radix-ui_react-focus-scope@1.1.6_@types_react-dom@19.0.4_@types_react@19.0.10__@types_react@_id43ncrttlmchyyb3c5ji6orxi/node_modules/@radix-ui/react-focus-scope/dist/index.js";
import { useId as Ie } from "../../../../../@radix-ui_react-id@1.1.1_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-id/dist/index.js";
import { createPopperScope as _e, Anchor as at, Content as dt, Root as ut, Arrow as pt } from "../../../../../@radix-ui_react-popper@1.2.6_@types_react-dom@19.0.4_@types_react@19.0.10__@types_react@19.0._kans3v2he7a2eejbluk2x3gauq/node_modules/@radix-ui/react-popper/dist/index.js";
import { Portal as ft } from "../../../../../@radix-ui_react-portal@1.1.8_@types_react-dom@19.0.4_@types_react@19.0.10__@types_react@19.0._rrthtkbmp73kytgng3eehoqbgq/node_modules/@radix-ui/react-portal/dist/index.js";
import { Primitive as M } from "../../../../../@radix-ui_react-primitive@2.1.2_@types_react-dom@19.0.4_@types_react@19.0.10__@types_react@19_yaprehzj3zhubujdvl7w24j6pq/node_modules/@radix-ui/react-primitive/dist/index.js";
import { createSlot as mt } from "../../../../../@radix-ui_react-slot@1.2.2_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-slot/dist/index.js";
import { useCallbackRef as ht } from "../../../../../@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-use-callback-ref/dist/index.js";
import { useControllableState as Ee } from "../../../../../@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-use-controllable-state/dist/index.js";
import { useLayoutEffect as Y } from "../../../../../@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-use-layout-effect/dist/index.js";
import { usePrevious as vt } from "../../../../../@radix-ui_react-use-previous@1.1.1_@types_react@19.0.10_react@19.0.0/node_modules/@radix-ui/react-use-previous/dist/index.js";
import { VISUALLY_HIDDEN_STYLES as gt } from "../../../../../@radix-ui_react-visually-hidden@1.2.2_@types_react-dom@19.0.4_@types_react@19.0.10__@types_re_c5qtc6nlv7wptmuhs7u6ddtksa/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
import { hideOthers as St } from "../../../../../aria-hidden@1.2.4/node_modules/aria-hidden/dist/es2015/index.js";
import wt from "../../../../../react-remove-scroll@2.6.3_@types_react@19.0.10_react@19.0.0/node_modules/react-remove-scroll/dist/es2015/Combination.js";
import { jsx as m, Fragment as Te, jsxs as ce } from "react/jsx-runtime";
var Ct = [" ", "Enter", "ArrowUp", "ArrowDown"], yt = [" ", "Enter"], J = "Select", [ae, de, xt] = nt(J), [te, uo] = rt(J, [
  xt,
  _e
]), ue = _e(), [It, j] = te(J), [Tt, Pt] = te(J), Ne = (n) => {
  const {
    __scopeSelect: c,
    children: e,
    open: i,
    defaultOpen: l,
    onOpenChange: u,
    value: r,
    defaultValue: s,
    onValueChange: o,
    dir: p,
    name: g,
    autoComplete: C,
    disabled: P,
    required: R,
    form: T
  } = n, a = ue(c), [v, y] = t.useState(null), [d, h] = t.useState(null), [A, O] = t.useState(!1), oe = st(p), [b, L] = Ee({
    prop: i,
    defaultProp: l ?? !1,
    onChange: u,
    caller: J
  }), [K, X] = Ee({
    prop: r,
    defaultProp: s,
    onChange: o,
    caller: J
  }), B = t.useRef(null), H = v ? T || !!v.closest("form") : !0, [G, W] = t.useState(/* @__PURE__ */ new Set()), F = Array.from(G).map((_) => _.props.value).join(";");
  return /* @__PURE__ */ m(ut, { ...a, children: /* @__PURE__ */ ce(
    It,
    {
      required: R,
      scope: c,
      trigger: v,
      onTriggerChange: y,
      valueNode: d,
      onValueNodeChange: h,
      valueNodeHasChildren: A,
      onValueNodeHasChildrenChange: O,
      contentId: Ie(),
      value: K,
      onValueChange: X,
      open: b,
      onOpenChange: L,
      dir: oe,
      triggerPointerDownPosRef: B,
      disabled: P,
      children: [
        /* @__PURE__ */ m(ae.Provider, { scope: c, children: /* @__PURE__ */ m(
          Tt,
          {
            scope: n.__scopeSelect,
            onNativeOptionAdd: t.useCallback((_) => {
              W((k) => new Set(k).add(_));
            }, []),
            onNativeOptionRemove: t.useCallback((_) => {
              W((k) => {
                const U = new Set(k);
                return U.delete(_), U;
              });
            }, []),
            children: e
          }
        ) }),
        H ? /* @__PURE__ */ ce(
          Qe,
          {
            "aria-hidden": !0,
            required: R,
            tabIndex: -1,
            name: g,
            autoComplete: C,
            value: K,
            onChange: (_) => X(_.target.value),
            disabled: P,
            form: T,
            children: [
              K === void 0 ? /* @__PURE__ */ m("option", { value: "" }) : null,
              Array.from(G)
            ]
          },
          F
        ) : null
      ]
    }
  ) });
};
Ne.displayName = J;
var Me = "SelectTrigger", Ae = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, disabled: i = !1, ...l } = n, u = ue(e), r = j(Me, e), s = r.disabled || i, o = V(c, r.onTriggerChange), p = de(e), g = t.useRef("touch"), [C, P, R] = tt((a) => {
      const v = p().filter((h) => !h.disabled), y = v.find((h) => h.value === r.value), d = ot(v, a, y);
      d !== void 0 && r.onValueChange(d.value);
    }), T = (a) => {
      s || (r.onOpenChange(!0), R()), a && (r.triggerPointerDownPosRef.current = {
        x: Math.round(a.pageX),
        y: Math.round(a.pageY)
      });
    };
    return /* @__PURE__ */ m(at, { asChild: !0, ...u, children: /* @__PURE__ */ m(
      M.button,
      {
        type: "button",
        role: "combobox",
        "aria-controls": r.contentId,
        "aria-expanded": r.open,
        "aria-required": r.required,
        "aria-autocomplete": "none",
        dir: r.dir,
        "data-state": r.open ? "open" : "closed",
        disabled: s,
        "data-disabled": s ? "" : void 0,
        "data-placeholder": et(r.value) ? "" : void 0,
        ...l,
        ref: o,
        onClick: E(l.onClick, (a) => {
          a.currentTarget.focus(), g.current !== "mouse" && T(a);
        }),
        onPointerDown: E(l.onPointerDown, (a) => {
          g.current = a.pointerType;
          const v = a.target;
          v.hasPointerCapture(a.pointerId) && v.releasePointerCapture(a.pointerId), a.button === 0 && a.ctrlKey === !1 && a.pointerType === "mouse" && (T(a), a.preventDefault());
        }),
        onKeyDown: E(l.onKeyDown, (a) => {
          const v = C.current !== "";
          !(a.ctrlKey || a.altKey || a.metaKey) && a.key.length === 1 && P(a.key), !(v && a.key === " ") && Ct.includes(a.key) && (T(), a.preventDefault());
        })
      }
    ) });
  }
);
Ae.displayName = Me;
var Oe = "SelectValue", De = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, className: i, style: l, children: u, placeholder: r = "", ...s } = n, o = j(Oe, e), { onValueNodeHasChildrenChange: p } = o, g = u !== void 0, C = V(c, o.onValueNodeChange);
    return Y(() => {
      p(g);
    }, [p, g]), /* @__PURE__ */ m(
      M.span,
      {
        ...s,
        ref: C,
        style: { pointerEvents: "none" },
        children: et(o.value) ? /* @__PURE__ */ m(Te, { children: r }) : u
      }
    );
  }
);
De.displayName = Oe;
var Rt = "SelectIcon", Le = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, children: i, ...l } = n;
    return /* @__PURE__ */ m(M.span, { "aria-hidden": !0, ...l, ref: c, children: i || "▼" });
  }
);
Le.displayName = Rt;
var Et = "SelectPortal", ke = (n) => /* @__PURE__ */ m(ft, { asChild: !0, ...n });
ke.displayName = Et;
var Q = "SelectContent", Ve = t.forwardRef(
  (n, c) => {
    const e = j(Q, n.__scopeSelect), [i, l] = t.useState();
    if (Y(() => {
      l(new DocumentFragment());
    }, []), !e.open) {
      const u = i;
      return u ? be.createPortal(
        /* @__PURE__ */ m(Be, { scope: n.__scopeSelect, children: /* @__PURE__ */ m(ae.Slot, { scope: n.__scopeSelect, children: /* @__PURE__ */ m("div", { children: n.children }) }) }),
        u
      ) : null;
    }
    return /* @__PURE__ */ m(He, { ...n, ref: c });
  }
);
Ve.displayName = Q;
var D = 10, [Be, q] = te(Q), bt = "SelectContentImpl", _t = mt("SelectContent.RemoveScroll"), He = t.forwardRef(
  (n, c) => {
    const {
      __scopeSelect: e,
      position: i = "item-aligned",
      onCloseAutoFocus: l,
      onEscapeKeyDown: u,
      onPointerDownOutside: r,
      //
      // PopperContent props
      side: s,
      sideOffset: o,
      align: p,
      alignOffset: g,
      arrowPadding: C,
      collisionBoundary: P,
      collisionPadding: R,
      sticky: T,
      hideWhenDetached: a,
      avoidCollisions: v,
      //
      ...y
    } = n, d = j(Q, e), [h, A] = t.useState(null), [O, oe] = t.useState(null), b = V(c, (f) => A(f)), [L, K] = t.useState(null), [X, B] = t.useState(
      null
    ), H = de(e), [G, W] = t.useState(!1), F = t.useRef(!1);
    t.useEffect(() => {
      if (h) return St(h);
    }, [h]), ct();
    const _ = t.useCallback(
      (f) => {
        const [I, ...N] = H().map((w) => w.ref.current), [x] = N.slice(-1), S = document.activeElement;
        for (const w of f)
          if (w === S || (w == null || w.scrollIntoView({ block: "nearest" }), w === I && O && (O.scrollTop = 0), w === x && O && (O.scrollTop = O.scrollHeight), w == null || w.focus(), document.activeElement !== S)) return;
      },
      [H, O]
    ), k = t.useCallback(
      () => _([L, h]),
      [_, L, h]
    );
    t.useEffect(() => {
      G && k();
    }, [G, k]);
    const { onOpenChange: U, triggerPointerDownPosRef: z } = d;
    t.useEffect(() => {
      if (h) {
        let f = { x: 0, y: 0 };
        const I = (x) => {
          var S, w;
          f = {
            x: Math.abs(Math.round(x.pageX) - (((S = z.current) == null ? void 0 : S.x) ?? 0)),
            y: Math.abs(Math.round(x.pageY) - (((w = z.current) == null ? void 0 : w.y) ?? 0))
          };
        }, N = (x) => {
          f.x <= 10 && f.y <= 10 ? x.preventDefault() : h.contains(x.target) || U(!1), document.removeEventListener("pointermove", I), z.current = null;
        };
        return z.current !== null && (document.addEventListener("pointermove", I), document.addEventListener("pointerup", N, { capture: !0, once: !0 })), () => {
          document.removeEventListener("pointermove", I), document.removeEventListener("pointerup", N, { capture: !0 });
        };
      }
    }, [h, U, z]), t.useEffect(() => {
      const f = () => U(!1);
      return window.addEventListener("blur", f), window.addEventListener("resize", f), () => {
        window.removeEventListener("blur", f), window.removeEventListener("resize", f);
      };
    }, [U]);
    const [pe, se] = tt((f) => {
      const I = H().filter((S) => !S.disabled), N = I.find((S) => S.ref.current === document.activeElement), x = ot(I, f, N);
      x && setTimeout(() => x.ref.current.focus());
    }), fe = t.useCallback(
      (f, I, N) => {
        const x = !F.current && !N;
        (d.value !== void 0 && d.value === I || x) && (K(f), x && (F.current = !0));
      },
      [d.value]
    ), me = t.useCallback(() => h == null ? void 0 : h.focus(), [h]), ee = t.useCallback(
      (f, I, N) => {
        const x = !F.current && !N;
        (d.value !== void 0 && d.value === I || x) && B(f);
      },
      [d.value]
    ), le = i === "popper" ? Se : We, ne = le === Se ? {
      side: s,
      sideOffset: o,
      align: p,
      alignOffset: g,
      arrowPadding: C,
      collisionBoundary: P,
      collisionPadding: R,
      sticky: T,
      hideWhenDetached: a,
      avoidCollisions: v
    } : {};
    return /* @__PURE__ */ m(
      Be,
      {
        scope: e,
        content: h,
        viewport: O,
        onViewportChange: oe,
        itemRefCallback: fe,
        selectedItem: L,
        onItemLeave: me,
        itemTextRefCallback: ee,
        focusSelectedItem: k,
        selectedItemText: X,
        position: i,
        isPositioned: G,
        searchRef: pe,
        children: /* @__PURE__ */ m(wt, { as: _t, allowPinchZoom: !0, children: /* @__PURE__ */ m(
          it,
          {
            asChild: !0,
            trapped: d.open,
            onMountAutoFocus: (f) => {
              f.preventDefault();
            },
            onUnmountAutoFocus: E(l, (f) => {
              var I;
              (I = d.trigger) == null || I.focus({ preventScroll: !0 }), f.preventDefault();
            }),
            children: /* @__PURE__ */ m(
              lt,
              {
                asChild: !0,
                disableOutsidePointerEvents: !0,
                onEscapeKeyDown: u,
                onPointerDownOutside: r,
                onFocusOutside: (f) => f.preventDefault(),
                onDismiss: () => d.onOpenChange(!1),
                children: /* @__PURE__ */ m(
                  le,
                  {
                    role: "listbox",
                    id: d.contentId,
                    "data-state": d.open ? "open" : "closed",
                    dir: d.dir,
                    onContextMenu: (f) => f.preventDefault(),
                    ...y,
                    ...ne,
                    onPlaced: () => W(!0),
                    ref: b,
                    style: {
                      // flex layout so we can place the scroll buttons properly
                      display: "flex",
                      flexDirection: "column",
                      // reset the outline by default as the content MAY get focused
                      outline: "none",
                      ...y.style
                    },
                    onKeyDown: E(y.onKeyDown, (f) => {
                      const I = f.ctrlKey || f.altKey || f.metaKey;
                      if (f.key === "Tab" && f.preventDefault(), !I && f.key.length === 1 && se(f.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(f.key)) {
                        let x = H().filter((S) => !S.disabled).map((S) => S.ref.current);
                        if (["ArrowUp", "End"].includes(f.key) && (x = x.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(f.key)) {
                          const S = f.target, w = x.indexOf(S);
                          x = x.slice(w + 1);
                        }
                        setTimeout(() => _(x)), f.preventDefault();
                      }
                    })
                  }
                )
              }
            )
          }
        ) })
      }
    );
  }
);
He.displayName = bt;
var Nt = "SelectItemAlignedPosition", We = t.forwardRef((n, c) => {
  const { __scopeSelect: e, onPlaced: i, ...l } = n, u = j(Q, e), r = q(Q, e), [s, o] = t.useState(null), [p, g] = t.useState(null), C = V(c, (b) => g(b)), P = de(e), R = t.useRef(!1), T = t.useRef(!0), { viewport: a, selectedItem: v, selectedItemText: y, focusSelectedItem: d } = r, h = t.useCallback(() => {
    if (u.trigger && u.valueNode && s && p && a && v && y) {
      const b = u.trigger.getBoundingClientRect(), L = p.getBoundingClientRect(), K = u.valueNode.getBoundingClientRect(), X = y.getBoundingClientRect();
      if (u.dir !== "rtl") {
        const S = X.left - L.left, w = K.left - S, Z = b.left - w, $ = b.width + Z, he = Math.max($, L.width), ve = window.innerWidth - D, ge = Re(w, [
          D,
          // Prevents the content from going off the starting edge of the
          // viewport. It may still go off the ending edge, but this can be
          // controlled by the user since they may want to manage overflow in a
          // specific way.
          // https://github.com/radix-ui/primitives/issues/2049
          Math.max(D, ve - he)
        ]);
        s.style.minWidth = $ + "px", s.style.left = ge + "px";
      } else {
        const S = L.right - X.right, w = window.innerWidth - K.right - S, Z = window.innerWidth - b.right - w, $ = b.width + Z, he = Math.max($, L.width), ve = window.innerWidth - D, ge = Re(w, [
          D,
          Math.max(D, ve - he)
        ]);
        s.style.minWidth = $ + "px", s.style.right = ge + "px";
      }
      const B = P(), H = window.innerHeight - D * 2, G = a.scrollHeight, W = window.getComputedStyle(p), F = parseInt(W.borderTopWidth, 10), _ = parseInt(W.paddingTop, 10), k = parseInt(W.borderBottomWidth, 10), U = parseInt(W.paddingBottom, 10), z = F + _ + G + U + k, pe = Math.min(v.offsetHeight * 5, z), se = window.getComputedStyle(a), fe = parseInt(se.paddingTop, 10), me = parseInt(se.paddingBottom, 10), ee = b.top + b.height / 2 - D, le = H - ee, ne = v.offsetHeight / 2, f = v.offsetTop + ne, I = F + _ + f, N = z - I;
      if (I <= ee) {
        const S = B.length > 0 && v === B[B.length - 1].ref.current;
        s.style.bottom = "0px";
        const w = p.clientHeight - a.offsetTop - a.offsetHeight, Z = Math.max(
          le,
          ne + // viewport might have padding bottom, include it to avoid a scrollable viewport
          (S ? me : 0) + w + k
        ), $ = I + Z;
        s.style.height = $ + "px";
      } else {
        const S = B.length > 0 && v === B[0].ref.current;
        s.style.top = "0px";
        const Z = Math.max(
          ee,
          F + a.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
          (S ? fe : 0) + ne
        ) + N;
        s.style.height = Z + "px", a.scrollTop = I - ee + a.offsetTop;
      }
      s.style.margin = `${D}px 0`, s.style.minHeight = pe + "px", s.style.maxHeight = H + "px", i == null || i(), requestAnimationFrame(() => R.current = !0);
    }
  }, [
    P,
    u.trigger,
    u.valueNode,
    s,
    p,
    a,
    v,
    y,
    u.dir,
    i
  ]);
  Y(() => h(), [h]);
  const [A, O] = t.useState();
  Y(() => {
    p && O(window.getComputedStyle(p).zIndex);
  }, [p]);
  const oe = t.useCallback(
    (b) => {
      b && T.current === !0 && (h(), d == null || d(), T.current = !1);
    },
    [h, d]
  );
  return /* @__PURE__ */ m(
    At,
    {
      scope: e,
      contentWrapper: s,
      shouldExpandOnScrollRef: R,
      onScrollButtonChange: oe,
      children: /* @__PURE__ */ m(
        "div",
        {
          ref: o,
          style: {
            display: "flex",
            flexDirection: "column",
            position: "fixed",
            zIndex: A
          },
          children: /* @__PURE__ */ m(
            M.div,
            {
              ...l,
              ref: C,
              style: {
                // When we get the height of the content, it includes borders. If we were to set
                // the height without having `boxSizing: 'border-box'` it would be too big.
                boxSizing: "border-box",
                // We need to ensure the content doesn't get taller than the wrapper
                maxHeight: "100%",
                ...l.style
              }
            }
          )
        }
      )
    }
  );
});
We.displayName = Nt;
var Mt = "SelectPopperPosition", Se = t.forwardRef((n, c) => {
  const {
    __scopeSelect: e,
    align: i = "start",
    collisionPadding: l = D,
    ...u
  } = n, r = ue(e);
  return /* @__PURE__ */ m(
    dt,
    {
      ...r,
      ...u,
      ref: c,
      align: i,
      collisionPadding: l,
      style: {
        // Ensure border-box for floating-ui calculations
        boxSizing: "border-box",
        ...u.style,
        "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-select-content-available-width": "var(--radix-popper-available-width)",
        "--radix-select-content-available-height": "var(--radix-popper-available-height)",
        "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
      }
    }
  );
});
Se.displayName = Mt;
var [At, Pe] = te(Q, {}), we = "SelectViewport", Fe = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, nonce: i, ...l } = n, u = q(we, e), r = Pe(we, e), s = V(c, u.onViewportChange), o = t.useRef(0);
    return /* @__PURE__ */ ce(Te, { children: [
      /* @__PURE__ */ m(
        "style",
        {
          dangerouslySetInnerHTML: {
            __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
          },
          nonce: i
        }
      ),
      /* @__PURE__ */ m(ae.Slot, { scope: e, children: /* @__PURE__ */ m(
        M.div,
        {
          "data-radix-select-viewport": "",
          role: "presentation",
          ...l,
          ref: s,
          style: {
            // we use position: 'relative' here on the `viewport` so that when we call
            // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
            // (independent of the scrollUpButton).
            position: "relative",
            flex: 1,
            // Viewport should only be scrollable in the vertical direction.
            // This won't work in vertical writing modes, so we'll need to
            // revisit this if/when that is supported
            // https://developer.chrome.com/blog/vertical-form-controls
            overflow: "hidden auto",
            ...l.style
          },
          onScroll: E(l.onScroll, (p) => {
            const g = p.currentTarget, { contentWrapper: C, shouldExpandOnScrollRef: P } = r;
            if (P != null && P.current && C) {
              const R = Math.abs(o.current - g.scrollTop);
              if (R > 0) {
                const T = window.innerHeight - D * 2, a = parseFloat(C.style.minHeight), v = parseFloat(C.style.height), y = Math.max(a, v);
                if (y < T) {
                  const d = y + R, h = Math.min(T, d), A = d - h;
                  C.style.height = h + "px", C.style.bottom === "0px" && (g.scrollTop = A > 0 ? A : 0, C.style.justifyContent = "flex-end");
                }
              }
            }
            o.current = g.scrollTop;
          })
        }
      ) })
    ] });
  }
);
Fe.displayName = we;
var Ue = "SelectGroup", [Ot, Dt] = te(Ue), Ke = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, ...i } = n, l = Ie();
    return /* @__PURE__ */ m(Ot, { scope: e, id: l, children: /* @__PURE__ */ m(M.div, { role: "group", "aria-labelledby": l, ...i, ref: c }) });
  }
);
Ke.displayName = Ue;
var Ge = "SelectLabel", ze = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, ...i } = n, l = Dt(Ge, e);
    return /* @__PURE__ */ m(M.div, { id: l.id, ...i, ref: c });
  }
);
ze.displayName = Ge;
var ie = "SelectItem", [Lt, Ye] = te(ie), je = t.forwardRef(
  (n, c) => {
    const {
      __scopeSelect: e,
      value: i,
      disabled: l = !1,
      textValue: u,
      ...r
    } = n, s = j(ie, e), o = q(ie, e), p = s.value === i, [g, C] = t.useState(u ?? ""), [P, R] = t.useState(!1), T = V(
      c,
      (d) => {
        var h;
        return (h = o.itemRefCallback) == null ? void 0 : h.call(o, d, i, l);
      }
    ), a = Ie(), v = t.useRef("touch"), y = () => {
      l || (s.onValueChange(i), s.onOpenChange(!1));
    };
    if (i === "")
      throw new Error(
        "A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
      );
    return /* @__PURE__ */ m(
      Lt,
      {
        scope: e,
        value: i,
        disabled: l,
        textId: a,
        isSelected: p,
        onItemTextChange: t.useCallback((d) => {
          C((h) => h || ((d == null ? void 0 : d.textContent) ?? "").trim());
        }, []),
        children: /* @__PURE__ */ m(
          ae.ItemSlot,
          {
            scope: e,
            value: i,
            disabled: l,
            textValue: g,
            children: /* @__PURE__ */ m(
              M.div,
              {
                role: "option",
                "aria-labelledby": a,
                "data-highlighted": P ? "" : void 0,
                "aria-selected": p && P,
                "data-state": p ? "checked" : "unchecked",
                "aria-disabled": l || void 0,
                "data-disabled": l ? "" : void 0,
                tabIndex: l ? void 0 : -1,
                ...r,
                ref: T,
                onFocus: E(r.onFocus, () => R(!0)),
                onBlur: E(r.onBlur, () => R(!1)),
                onClick: E(r.onClick, () => {
                  v.current !== "mouse" && y();
                }),
                onPointerUp: E(r.onPointerUp, () => {
                  v.current === "mouse" && y();
                }),
                onPointerDown: E(r.onPointerDown, (d) => {
                  v.current = d.pointerType;
                }),
                onPointerMove: E(r.onPointerMove, (d) => {
                  var h;
                  v.current = d.pointerType, l ? (h = o.onItemLeave) == null || h.call(o) : v.current === "mouse" && d.currentTarget.focus({ preventScroll: !0 });
                }),
                onPointerLeave: E(r.onPointerLeave, (d) => {
                  var h;
                  d.currentTarget === document.activeElement && ((h = o.onItemLeave) == null || h.call(o));
                }),
                onKeyDown: E(r.onKeyDown, (d) => {
                  var A;
                  ((A = o.searchRef) == null ? void 0 : A.current) !== "" && d.key === " " || (yt.includes(d.key) && y(), d.key === " " && d.preventDefault());
                })
              }
            )
          }
        )
      }
    );
  }
);
je.displayName = ie;
var re = "SelectItemText", qe = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, className: i, style: l, ...u } = n, r = j(re, e), s = q(re, e), o = Ye(re, e), p = Pt(re, e), [g, C] = t.useState(null), P = V(
      c,
      (y) => C(y),
      o.onItemTextChange,
      (y) => {
        var d;
        return (d = s.itemTextRefCallback) == null ? void 0 : d.call(s, y, o.value, o.disabled);
      }
    ), R = g == null ? void 0 : g.textContent, T = t.useMemo(
      () => /* @__PURE__ */ m("option", { value: o.value, disabled: o.disabled, children: R }, o.value),
      [o.disabled, o.value, R]
    ), { onNativeOptionAdd: a, onNativeOptionRemove: v } = p;
    return Y(() => (a(T), () => v(T)), [a, v, T]), /* @__PURE__ */ ce(Te, { children: [
      /* @__PURE__ */ m(M.span, { id: o.textId, ...u, ref: P }),
      o.isSelected && r.valueNode && !r.valueNodeHasChildren ? be.createPortal(u.children, r.valueNode) : null
    ] });
  }
);
qe.displayName = re;
var Xe = "SelectItemIndicator", Ze = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, ...i } = n;
    return Ye(Xe, e).isSelected ? /* @__PURE__ */ m(M.span, { "aria-hidden": !0, ...i, ref: c }) : null;
  }
);
Ze.displayName = Xe;
var Ce = "SelectScrollUpButton", kt = t.forwardRef((n, c) => {
  const e = q(Ce, n.__scopeSelect), i = Pe(Ce, n.__scopeSelect), [l, u] = t.useState(!1), r = V(c, i.onScrollButtonChange);
  return Y(() => {
    if (e.viewport && e.isPositioned) {
      let s = function() {
        const p = o.scrollTop > 0;
        u(p);
      };
      const o = e.viewport;
      return s(), o.addEventListener("scroll", s), () => o.removeEventListener("scroll", s);
    }
  }, [e.viewport, e.isPositioned]), l ? /* @__PURE__ */ m(
    $e,
    {
      ...n,
      ref: r,
      onAutoScroll: () => {
        const { viewport: s, selectedItem: o } = e;
        s && o && (s.scrollTop = s.scrollTop - o.offsetHeight);
      }
    }
  ) : null;
});
kt.displayName = Ce;
var ye = "SelectScrollDownButton", Vt = t.forwardRef((n, c) => {
  const e = q(ye, n.__scopeSelect), i = Pe(ye, n.__scopeSelect), [l, u] = t.useState(!1), r = V(c, i.onScrollButtonChange);
  return Y(() => {
    if (e.viewport && e.isPositioned) {
      let s = function() {
        const p = o.scrollHeight - o.clientHeight, g = Math.ceil(o.scrollTop) < p;
        u(g);
      };
      const o = e.viewport;
      return s(), o.addEventListener("scroll", s), () => o.removeEventListener("scroll", s);
    }
  }, [e.viewport, e.isPositioned]), l ? /* @__PURE__ */ m(
    $e,
    {
      ...n,
      ref: r,
      onAutoScroll: () => {
        const { viewport: s, selectedItem: o } = e;
        s && o && (s.scrollTop = s.scrollTop + o.offsetHeight);
      }
    }
  ) : null;
});
Vt.displayName = ye;
var $e = t.forwardRef((n, c) => {
  const { __scopeSelect: e, onAutoScroll: i, ...l } = n, u = q("SelectScrollButton", e), r = t.useRef(null), s = de(e), o = t.useCallback(() => {
    r.current !== null && (window.clearInterval(r.current), r.current = null);
  }, []);
  return t.useEffect(() => () => o(), [o]), Y(() => {
    var g;
    const p = s().find((C) => C.ref.current === document.activeElement);
    (g = p == null ? void 0 : p.ref.current) == null || g.scrollIntoView({ block: "nearest" });
  }, [s]), /* @__PURE__ */ m(
    M.div,
    {
      "aria-hidden": !0,
      ...l,
      ref: c,
      style: { flexShrink: 0, ...l.style },
      onPointerDown: E(l.onPointerDown, () => {
        r.current === null && (r.current = window.setInterval(i, 50));
      }),
      onPointerMove: E(l.onPointerMove, () => {
        var p;
        (p = u.onItemLeave) == null || p.call(u), r.current === null && (r.current = window.setInterval(i, 50));
      }),
      onPointerLeave: E(l.onPointerLeave, () => {
        o();
      })
    }
  );
}), Bt = "SelectSeparator", Je = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, ...i } = n;
    return /* @__PURE__ */ m(M.div, { "aria-hidden": !0, ...i, ref: c });
  }
);
Je.displayName = Bt;
var xe = "SelectArrow", Ht = t.forwardRef(
  (n, c) => {
    const { __scopeSelect: e, ...i } = n, l = ue(e), u = j(xe, e), r = q(xe, e);
    return u.open && r.position === "popper" ? /* @__PURE__ */ m(pt, { ...l, ...i, ref: c }) : null;
  }
);
Ht.displayName = xe;
var Wt = "SelectBubbleInput", Qe = t.forwardRef(
  ({ __scopeSelect: n, value: c, ...e }, i) => {
    const l = t.useRef(null), u = V(i, l), r = vt(c);
    return t.useEffect(() => {
      const s = l.current;
      if (!s) return;
      const o = window.HTMLSelectElement.prototype, g = Object.getOwnPropertyDescriptor(
        o,
        "value"
      ).set;
      if (r !== c && g) {
        const C = new Event("change", { bubbles: !0 });
        g.call(s, c), s.dispatchEvent(C);
      }
    }, [r, c]), /* @__PURE__ */ m(
      M.select,
      {
        ...e,
        style: { ...gt, ...e.style },
        ref: u,
        defaultValue: c
      }
    );
  }
);
Qe.displayName = Wt;
function et(n) {
  return n === "" || n === void 0;
}
function tt(n) {
  const c = ht(n), e = t.useRef(""), i = t.useRef(0), l = t.useCallback(
    (r) => {
      const s = e.current + r;
      c(s), function o(p) {
        e.current = p, window.clearTimeout(i.current), p !== "" && (i.current = window.setTimeout(() => o(""), 1e3));
      }(s);
    },
    [c]
  ), u = t.useCallback(() => {
    e.current = "", window.clearTimeout(i.current);
  }, []);
  return t.useEffect(() => () => window.clearTimeout(i.current), []), [e, l, u];
}
function ot(n, c, e) {
  const l = c.length > 1 && Array.from(c).every((p) => p === c[0]) ? c[0] : c, u = e ? n.indexOf(e) : -1;
  let r = Ft(n, Math.max(u, 0));
  l.length === 1 && (r = r.filter((p) => p !== e));
  const o = r.find(
    (p) => p.textValue.toLowerCase().startsWith(l.toLowerCase())
  );
  return o !== e ? o : void 0;
}
function Ft(n, c) {
  return n.map((e, i) => n[(c + i) % n.length]);
}
var po = Ne, fo = Ae, mo = De, ho = Le, vo = ke, go = Ve, So = Fe, wo = Ke, Co = ze, yo = je, xo = qe, Io = Ze, To = Je;
export {
  go as Content,
  wo as Group,
  ho as Icon,
  yo as Item,
  Io as ItemIndicator,
  xo as ItemText,
  Co as Label,
  vo as Portal,
  po as Root,
  Ne as Select,
  Ht as SelectArrow,
  Ve as SelectContent,
  Ke as SelectGroup,
  Le as SelectIcon,
  je as SelectItem,
  Ze as SelectItemIndicator,
  qe as SelectItemText,
  ze as SelectLabel,
  ke as SelectPortal,
  Vt as SelectScrollDownButton,
  kt as SelectScrollUpButton,
  Je as SelectSeparator,
  Ae as SelectTrigger,
  De as SelectValue,
  Fe as SelectViewport,
  To as Separator,
  fo as Trigger,
  mo as Value,
  So as Viewport,
  uo as createSelectScope
};
//# sourceMappingURL=index.js.map
