import * as t from "react";
import * as Ee from "react-dom";
import { clamp as Te } from "../../../../../@radix-ui_number@1.1.0/node_modules/@radix-ui/number/dist/index.js";
import { composeEventHandlers as b } from "../../../../../@radix-ui_primitive@1.1.0/node_modules/@radix-ui/primitive/dist/index.js";
import { createCollection as tt } from "../../../../../@radix-ui_react-collection@1.1.0_@types_react-dom@18.3.6_@types_react@18.3.3__@types_re_068c4d9b06eb1baa6b6ecff66d582472/node_modules/@radix-ui/react-collection/dist/index.js";
import { useComposedRefs as L } from "../../../../../@radix-ui_react-compose-refs@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-compose-refs/dist/index.js";
import { createContextScope as ot } from "../../../../../@radix-ui_react-context@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-context/dist/index.js";
import { useDirection as nt } from "../../../../../@radix-ui_react-direction@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-direction/dist/index.js";
import { DismissableLayer as rt } from "../../../../../@radix-ui_react-dismissable-layer@1.1.0_@types_react-dom@18.3.6_@types_react@18.3.3__@t_540819d22b5f34e77f512765c1a78ce5/node_modules/@radix-ui/react-dismissable-layer/dist/index.js";
import { useFocusGuards as st } from "../../../../../@radix-ui_react-focus-guards@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-focus-guards/dist/index.js";
import { FocusScope as lt } from "../../../../../@radix-ui_react-focus-scope@1.1.0_@types_react-dom@18.3.6_@types_react@18.3.3__@types_r_c5413b53d4356de1cc2ff1163dee68dc/node_modules/@radix-ui/react-focus-scope/dist/index.js";
import { useId as ye } from "../../../../../@radix-ui_react-id@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-id/dist/index.js";
import { createPopperScope as Re, Root as ct, Anchor as it, Content as at, Arrow as dt } from "../../../../../@radix-ui_react-popper@1.2.0_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@_0c236d22233b5684ecf8a3d8d1b24562/node_modules/@radix-ui/react-popper/dist/index.js";
import { Portal as ut } from "../../../../../@radix-ui_react-portal@1.1.1_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@_d91fd04d10d265136bf0d35a7b9375b2/node_modules/@radix-ui/react-portal/dist/index.js";
import { Primitive as O } from "../../../../../@radix-ui_react-primitive@2.0.0_@types_react-dom@18.3.6_@types_react@18.3.3__@types_rea_bdcf182289a3a76356f07e550726e479/node_modules/@radix-ui/react-primitive/dist/index.js";
import { Slot as pt } from "../../../../../@radix-ui_react-slot@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-slot/dist/index.js";
import { useCallbackRef as ft } from "../../../../../@radix-ui_react-use-callback-ref@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-use-callback-ref/dist/index.js";
import { useControllableState as Pe } from "../../../../../@radix-ui_react-use-controllable-state@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-use-controllable-state/dist/index.js";
import { useLayoutEffect as K } from "../../../../../@radix-ui_react-use-layout-effect@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-use-layout-effect/dist/index.js";
import { usePrevious as mt } from "../../../../../@radix-ui_react-use-previous@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-use-previous/dist/index.js";
import { VisuallyHidden as ht } from "../../../../../@radix-ui_react-visually-hidden@1.1.0_@types_react-dom@18.3.6_@types_react@18.3.3__@typ_ed6b83029f4b3a260b4f0503b9e9f52c/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
import { hideOthers as vt } from "../../../../../aria-hidden@1.2.6/node_modules/aria-hidden/dist/es2015/index.js";
import gt from "../../../../../react-remove-scroll@2.5.7_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/react-remove-scroll/dist/es2015/Combination.js";
import { j as a } from "../../../../../../../_virtual/jsx-runtime.js";
var St = [" ", "Enter", "ArrowUp", "ArrowDown"], xt = [" ", "Enter"], re = "Select", [ie, ae, wt] = tt(re), [ee, lo] = ot(re, [
  wt,
  Re
]), de = Re(), [Ct, U] = ee(re), [yt, It] = ee(re), be = (o) => {
  const {
    __scopeSelect: i,
    children: e,
    open: c,
    defaultOpen: r,
    onOpenChange: d,
    value: n,
    defaultValue: s,
    onValueChange: l,
    dir: p,
    name: g,
    autoComplete: x,
    disabled: E,
    required: I
  } = o, f = de(i), [h, w] = t.useState(null), [m, v] = t.useState(null), [y, H] = t.useState(!1), A = nt(p), [te = !1, N] = Pe({
    prop: c,
    defaultProp: r,
    onChange: d
  }), [M, z] = Pe({
    prop: n,
    defaultProp: s,
    onChange: l
  }), $ = t.useRef(null), Y = h ? !!h.closest("form") : !0, [j, B] = t.useState(/* @__PURE__ */ new Set()), F = Array.from(j).map((R) => R.props.value).join(";");
  return /* @__PURE__ */ a.jsx(ct, { ...f, children: /* @__PURE__ */ a.jsxs(
    Ct,
    {
      required: I,
      scope: i,
      trigger: h,
      onTriggerChange: w,
      valueNode: m,
      onValueNodeChange: v,
      valueNodeHasChildren: y,
      onValueNodeHasChildrenChange: H,
      contentId: ye(),
      value: M,
      onValueChange: z,
      open: te,
      onOpenChange: N,
      dir: A,
      triggerPointerDownPosRef: $,
      disabled: E,
      children: [
        /* @__PURE__ */ a.jsx(ie.Provider, { scope: i, children: /* @__PURE__ */ a.jsx(
          yt,
          {
            scope: o.__scopeSelect,
            onNativeOptionAdd: t.useCallback((R) => {
              B((D) => new Set(D).add(R));
            }, []),
            onNativeOptionRemove: t.useCallback((R) => {
              B((D) => {
                const k = new Set(D);
                return k.delete(R), k;
              });
            }, []),
            children: e
          }
        ) }),
        Y ? /* @__PURE__ */ a.jsxs(
          Je,
          {
            "aria-hidden": !0,
            required: I,
            tabIndex: -1,
            name: g,
            autoComplete: x,
            value: M,
            onChange: (R) => z(R.target.value),
            disabled: E,
            children: [
              M === void 0 ? /* @__PURE__ */ a.jsx("option", { value: "" }) : null,
              Array.from(j)
            ]
          },
          F
        ) : null
      ]
    }
  ) });
};
be.displayName = re;
var Ne = "SelectTrigger", _e = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, disabled: c = !1, ...r } = o, d = de(e), n = U(Ne, e), s = n.disabled || c, l = L(i, n.onTriggerChange), p = ae(e), [g, x, E] = Qe((f) => {
      const h = p().filter((v) => !v.disabled), w = h.find((v) => v.value === n.value), m = et(h, f, w);
      m !== void 0 && n.onValueChange(m.value);
    }), I = () => {
      s || (n.onOpenChange(!0), E());
    };
    return /* @__PURE__ */ a.jsx(it, { asChild: !0, ...d, children: /* @__PURE__ */ a.jsx(
      O.button,
      {
        type: "button",
        role: "combobox",
        "aria-controls": n.contentId,
        "aria-expanded": n.open,
        "aria-required": n.required,
        "aria-autocomplete": "none",
        dir: n.dir,
        "data-state": n.open ? "open" : "closed",
        disabled: s,
        "data-disabled": s ? "" : void 0,
        "data-placeholder": $e(n.value) ? "" : void 0,
        ...r,
        ref: l,
        onClick: b(r.onClick, (f) => {
          f.currentTarget.focus();
        }),
        onPointerDown: b(r.onPointerDown, (f) => {
          const h = f.target;
          h.hasPointerCapture(f.pointerId) && h.releasePointerCapture(f.pointerId), f.button === 0 && f.ctrlKey === !1 && (I(), n.triggerPointerDownPosRef.current = {
            x: Math.round(f.pageX),
            y: Math.round(f.pageY)
          }, f.preventDefault());
        }),
        onKeyDown: b(r.onKeyDown, (f) => {
          const h = g.current !== "";
          !(f.ctrlKey || f.altKey || f.metaKey) && f.key.length === 1 && x(f.key), !(h && f.key === " ") && St.includes(f.key) && (I(), f.preventDefault());
        })
      }
    ) });
  }
);
_e.displayName = Ne;
var Me = "SelectValue", Oe = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, className: c, style: r, children: d, placeholder: n = "", ...s } = o, l = U(Me, e), { onValueNodeHasChildrenChange: p } = l, g = d !== void 0, x = L(i, l.onValueNodeChange);
    return K(() => {
      p(g);
    }, [p, g]), /* @__PURE__ */ a.jsx(
      O.span,
      {
        ...s,
        ref: x,
        style: { pointerEvents: "none" },
        children: $e(l.value) ? /* @__PURE__ */ a.jsx(a.Fragment, { children: n }) : d
      }
    );
  }
);
Oe.displayName = Me;
var Tt = "SelectIcon", Ae = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, children: c, ...r } = o;
    return /* @__PURE__ */ a.jsx(O.span, { "aria-hidden": !0, ...r, ref: i, children: c || "▼" });
  }
);
Ae.displayName = Tt;
var Pt = "SelectPortal", je = (o) => /* @__PURE__ */ a.jsx(ut, { asChild: !0, ...o });
je.displayName = Pt;
var Z = "SelectContent", De = t.forwardRef(
  (o, i) => {
    const e = U(Z, o.__scopeSelect), [c, r] = t.useState();
    if (K(() => {
      r(new DocumentFragment());
    }, []), !e.open) {
      const d = c;
      return d ? Ee.createPortal(
        /* @__PURE__ */ a.jsx(Le, { scope: o.__scopeSelect, children: /* @__PURE__ */ a.jsx(ie.Slot, { scope: o.__scopeSelect, children: /* @__PURE__ */ a.jsx("div", { children: o.children }) }) }),
        d
      ) : null;
    }
    return /* @__PURE__ */ a.jsx(ke, { ...o, ref: i });
  }
);
De.displayName = Z;
var V = 10, [Le, G] = ee(Z), Et = "SelectContentImpl", ke = t.forwardRef(
  (o, i) => {
    const {
      __scopeSelect: e,
      position: c = "item-aligned",
      onCloseAutoFocus: r,
      onEscapeKeyDown: d,
      onPointerDownOutside: n,
      //
      // PopperContent props
      side: s,
      sideOffset: l,
      align: p,
      alignOffset: g,
      arrowPadding: x,
      collisionBoundary: E,
      collisionPadding: I,
      sticky: f,
      hideWhenDetached: h,
      avoidCollisions: w,
      //
      ...m
    } = o, v = U(Z, e), [y, H] = t.useState(null), [A, te] = t.useState(null), N = L(i, (u) => H(u)), [M, z] = t.useState(null), [$, Y] = t.useState(
      null
    ), j = ae(e), [B, F] = t.useState(!1), R = t.useRef(!1);
    t.useEffect(() => {
      if (y) return vt(y);
    }, [y]), st();
    const D = t.useCallback(
      (u) => {
        const [T, ..._] = j().map((P) => P.ref.current), [S] = _.slice(-1), C = document.activeElement;
        for (const P of u)
          if (P === C || (P?.scrollIntoView({ block: "nearest" }), P === T && A && (A.scrollTop = 0), P === S && A && (A.scrollTop = A.scrollHeight), P?.focus(), document.activeElement !== C)) return;
      },
      [j, A]
    ), k = t.useCallback(
      () => D([M, y]),
      [D, M, y]
    );
    t.useEffect(() => {
      B && k();
    }, [B, k]);
    const { onOpenChange: J, triggerPointerDownPosRef: W } = v;
    t.useEffect(() => {
      if (y) {
        let u = { x: 0, y: 0 };
        const T = (S) => {
          u = {
            x: Math.abs(Math.round(S.pageX) - (W.current?.x ?? 0)),
            y: Math.abs(Math.round(S.pageY) - (W.current?.y ?? 0))
          };
        }, _ = (S) => {
          u.x <= 10 && u.y <= 10 ? S.preventDefault() : y.contains(S.target) || J(!1), document.removeEventListener("pointermove", T), W.current = null;
        };
        return W.current !== null && (document.addEventListener("pointermove", T), document.addEventListener("pointerup", _, { capture: !0, once: !0 })), () => {
          document.removeEventListener("pointermove", T), document.removeEventListener("pointerup", _, { capture: !0 });
        };
      }
    }, [y, J, W]), t.useEffect(() => {
      const u = () => J(!1);
      return window.addEventListener("blur", u), window.addEventListener("resize", u), () => {
        window.removeEventListener("blur", u), window.removeEventListener("resize", u);
      };
    }, [J]);
    const [ue, se] = Qe((u) => {
      const T = j().filter((C) => !C.disabled), _ = T.find((C) => C.ref.current === document.activeElement), S = et(T, u, _);
      S && setTimeout(() => S.ref.current.focus());
    }), pe = t.useCallback(
      (u, T, _) => {
        const S = !R.current && !_;
        (v.value !== void 0 && v.value === T || S) && (z(u), S && (R.current = !0));
      },
      [v.value]
    ), fe = t.useCallback(() => y?.focus(), [y]), Q = t.useCallback(
      (u, T, _) => {
        const S = !R.current && !_;
        (v.value !== void 0 && v.value === T || S) && Y(u);
      },
      [v.value]
    ), le = c === "popper" ? ge : Ve, oe = le === ge ? {
      side: s,
      sideOffset: l,
      align: p,
      alignOffset: g,
      arrowPadding: x,
      collisionBoundary: E,
      collisionPadding: I,
      sticky: f,
      hideWhenDetached: h,
      avoidCollisions: w
    } : {};
    return /* @__PURE__ */ a.jsx(
      Le,
      {
        scope: e,
        content: y,
        viewport: A,
        onViewportChange: te,
        itemRefCallback: pe,
        selectedItem: M,
        onItemLeave: fe,
        itemTextRefCallback: Q,
        focusSelectedItem: k,
        selectedItemText: $,
        position: c,
        isPositioned: B,
        searchRef: ue,
        children: /* @__PURE__ */ a.jsx(gt, { as: pt, allowPinchZoom: !0, children: /* @__PURE__ */ a.jsx(
          lt,
          {
            asChild: !0,
            trapped: v.open,
            onMountAutoFocus: (u) => {
              u.preventDefault();
            },
            onUnmountAutoFocus: b(r, (u) => {
              v.trigger?.focus({ preventScroll: !0 }), u.preventDefault();
            }),
            children: /* @__PURE__ */ a.jsx(
              rt,
              {
                asChild: !0,
                disableOutsidePointerEvents: !0,
                onEscapeKeyDown: d,
                onPointerDownOutside: n,
                onFocusOutside: (u) => u.preventDefault(),
                onDismiss: () => v.onOpenChange(!1),
                children: /* @__PURE__ */ a.jsx(
                  le,
                  {
                    role: "listbox",
                    id: v.contentId,
                    "data-state": v.open ? "open" : "closed",
                    dir: v.dir,
                    onContextMenu: (u) => u.preventDefault(),
                    ...m,
                    ...oe,
                    onPlaced: () => F(!0),
                    ref: N,
                    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",
                      ...m.style
                    },
                    onKeyDown: b(m.onKeyDown, (u) => {
                      const T = u.ctrlKey || u.altKey || u.metaKey;
                      if (u.key === "Tab" && u.preventDefault(), !T && u.key.length === 1 && se(u.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(u.key)) {
                        let S = j().filter((C) => !C.disabled).map((C) => C.ref.current);
                        if (["ArrowUp", "End"].includes(u.key) && (S = S.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(u.key)) {
                          const C = u.target, P = S.indexOf(C);
                          S = S.slice(P + 1);
                        }
                        setTimeout(() => D(S)), u.preventDefault();
                      }
                    })
                  }
                )
              }
            )
          }
        ) })
      }
    );
  }
);
ke.displayName = Et;
var Rt = "SelectItemAlignedPosition", Ve = t.forwardRef((o, i) => {
  const { __scopeSelect: e, onPlaced: c, ...r } = o, d = U(Z, e), n = G(Z, e), [s, l] = t.useState(null), [p, g] = t.useState(null), x = L(i, (N) => g(N)), E = ae(e), I = t.useRef(!1), f = t.useRef(!0), { viewport: h, selectedItem: w, selectedItemText: m, focusSelectedItem: v } = n, y = t.useCallback(() => {
    if (d.trigger && d.valueNode && s && p && h && w && m) {
      const N = d.trigger.getBoundingClientRect(), M = p.getBoundingClientRect(), z = d.valueNode.getBoundingClientRect(), $ = m.getBoundingClientRect();
      if (d.dir !== "rtl") {
        const C = $.left - M.left, P = z.left - C, q = N.left - P, X = N.width + q, me = Math.max(X, M.width), he = window.innerWidth - V, ve = Te(P, [V, he - me]);
        s.style.minWidth = X + "px", s.style.left = ve + "px";
      } else {
        const C = M.right - $.right, P = window.innerWidth - z.right - C, q = window.innerWidth - N.right - P, X = N.width + q, me = Math.max(X, M.width), he = window.innerWidth - V, ve = Te(P, [V, he - me]);
        s.style.minWidth = X + "px", s.style.right = ve + "px";
      }
      const Y = E(), j = window.innerHeight - V * 2, B = h.scrollHeight, F = window.getComputedStyle(p), R = parseInt(F.borderTopWidth, 10), D = parseInt(F.paddingTop, 10), k = parseInt(F.borderBottomWidth, 10), J = parseInt(F.paddingBottom, 10), W = R + D + B + J + k, ue = Math.min(w.offsetHeight * 5, W), se = window.getComputedStyle(h), pe = parseInt(se.paddingTop, 10), fe = parseInt(se.paddingBottom, 10), Q = N.top + N.height / 2 - V, le = j - Q, oe = w.offsetHeight / 2, u = w.offsetTop + oe, T = R + D + u, _ = W - T;
      if (T <= Q) {
        const C = w === Y[Y.length - 1].ref.current;
        s.style.bottom = "0px";
        const P = p.clientHeight - h.offsetTop - h.offsetHeight, q = Math.max(
          le,
          oe + // viewport might have padding bottom, include it to avoid a scrollable viewport
          (C ? fe : 0) + P + k
        ), X = T + q;
        s.style.height = X + "px";
      } else {
        const C = w === Y[0].ref.current;
        s.style.top = "0px";
        const q = Math.max(
          Q,
          R + h.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
          (C ? pe : 0) + oe
        ) + _;
        s.style.height = q + "px", h.scrollTop = T - Q + h.offsetTop;
      }
      s.style.margin = `${V}px 0`, s.style.minHeight = ue + "px", s.style.maxHeight = j + "px", c?.(), requestAnimationFrame(() => I.current = !0);
    }
  }, [
    E,
    d.trigger,
    d.valueNode,
    s,
    p,
    h,
    w,
    m,
    d.dir,
    c
  ]);
  K(() => y(), [y]);
  const [H, A] = t.useState();
  K(() => {
    p && A(window.getComputedStyle(p).zIndex);
  }, [p]);
  const te = t.useCallback(
    (N) => {
      N && f.current === !0 && (y(), v?.(), f.current = !1);
    },
    [y, v]
  );
  return /* @__PURE__ */ a.jsx(
    Nt,
    {
      scope: e,
      contentWrapper: s,
      shouldExpandOnScrollRef: I,
      onScrollButtonChange: te,
      children: /* @__PURE__ */ a.jsx(
        "div",
        {
          ref: l,
          style: {
            display: "flex",
            flexDirection: "column",
            position: "fixed",
            zIndex: H
          },
          children: /* @__PURE__ */ a.jsx(
            O.div,
            {
              ...r,
              ref: x,
              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%",
                ...r.style
              }
            }
          )
        }
      )
    }
  );
});
Ve.displayName = Rt;
var bt = "SelectPopperPosition", ge = t.forwardRef((o, i) => {
  const {
    __scopeSelect: e,
    align: c = "start",
    collisionPadding: r = V,
    ...d
  } = o, n = de(e);
  return /* @__PURE__ */ a.jsx(
    at,
    {
      ...n,
      ...d,
      ref: i,
      align: c,
      collisionPadding: r,
      style: {
        // Ensure border-box for floating-ui calculations
        boxSizing: "border-box",
        ...d.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)"
      }
    }
  );
});
ge.displayName = bt;
var [Nt, Ie] = ee(Z, {}), Se = "SelectViewport", He = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, nonce: c, ...r } = o, d = G(Se, e), n = Ie(Se, e), s = L(i, d.onViewportChange), l = t.useRef(0);
    return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
      /* @__PURE__ */ a.jsx(
        "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: c
        }
      ),
      /* @__PURE__ */ a.jsx(ie.Slot, { scope: e, children: /* @__PURE__ */ a.jsx(
        O.div,
        {
          "data-radix-select-viewport": "",
          role: "presentation",
          ...r,
          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,
            overflow: "auto",
            ...r.style
          },
          onScroll: b(r.onScroll, (p) => {
            const g = p.currentTarget, { contentWrapper: x, shouldExpandOnScrollRef: E } = n;
            if (E?.current && x) {
              const I = Math.abs(l.current - g.scrollTop);
              if (I > 0) {
                const f = window.innerHeight - V * 2, h = parseFloat(x.style.minHeight), w = parseFloat(x.style.height), m = Math.max(h, w);
                if (m < f) {
                  const v = m + I, y = Math.min(f, v), H = v - y;
                  x.style.height = y + "px", x.style.bottom === "0px" && (g.scrollTop = H > 0 ? H : 0, x.style.justifyContent = "flex-end");
                }
              }
            }
            l.current = g.scrollTop;
          })
        }
      ) })
    ] });
  }
);
He.displayName = Se;
var Be = "SelectGroup", [_t, Mt] = ee(Be), Fe = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, ...c } = o, r = ye();
    return /* @__PURE__ */ a.jsx(_t, { scope: e, id: r, children: /* @__PURE__ */ a.jsx(O.div, { role: "group", "aria-labelledby": r, ...c, ref: i }) });
  }
);
Fe.displayName = Be;
var We = "SelectLabel", Ke = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, ...c } = o, r = Mt(We, e);
    return /* @__PURE__ */ a.jsx(O.div, { id: r.id, ...c, ref: i });
  }
);
Ke.displayName = We;
var ce = "SelectItem", [Ot, Ue] = ee(ce), Ge = t.forwardRef(
  (o, i) => {
    const {
      __scopeSelect: e,
      value: c,
      disabled: r = !1,
      textValue: d,
      ...n
    } = o, s = U(ce, e), l = G(ce, e), p = s.value === c, [g, x] = t.useState(d ?? ""), [E, I] = t.useState(!1), f = L(
      i,
      (m) => l.itemRefCallback?.(m, c, r)
    ), h = ye(), w = () => {
      r || (s.onValueChange(c), s.onOpenChange(!1));
    };
    if (c === "")
      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__ */ a.jsx(
      Ot,
      {
        scope: e,
        value: c,
        disabled: r,
        textId: h,
        isSelected: p,
        onItemTextChange: t.useCallback((m) => {
          x((v) => v || (m?.textContent ?? "").trim());
        }, []),
        children: /* @__PURE__ */ a.jsx(
          ie.ItemSlot,
          {
            scope: e,
            value: c,
            disabled: r,
            textValue: g,
            children: /* @__PURE__ */ a.jsx(
              O.div,
              {
                role: "option",
                "aria-labelledby": h,
                "data-highlighted": E ? "" : void 0,
                "aria-selected": p && E,
                "data-state": p ? "checked" : "unchecked",
                "aria-disabled": r || void 0,
                "data-disabled": r ? "" : void 0,
                tabIndex: r ? void 0 : -1,
                ...n,
                ref: f,
                onFocus: b(n.onFocus, () => I(!0)),
                onBlur: b(n.onBlur, () => I(!1)),
                onPointerUp: b(n.onPointerUp, w),
                onPointerMove: b(n.onPointerMove, (m) => {
                  r ? l.onItemLeave?.() : m.currentTarget.focus({ preventScroll: !0 });
                }),
                onPointerLeave: b(n.onPointerLeave, (m) => {
                  m.currentTarget === document.activeElement && l.onItemLeave?.();
                }),
                onKeyDown: b(n.onKeyDown, (m) => {
                  l.searchRef?.current !== "" && m.key === " " || (xt.includes(m.key) && w(), m.key === " " && m.preventDefault());
                })
              }
            )
          }
        )
      }
    );
  }
);
Ge.displayName = ce;
var ne = "SelectItemText", ze = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, className: c, style: r, ...d } = o, n = U(ne, e), s = G(ne, e), l = Ue(ne, e), p = It(ne, e), [g, x] = t.useState(null), E = L(
      i,
      (m) => x(m),
      l.onItemTextChange,
      (m) => s.itemTextRefCallback?.(m, l.value, l.disabled)
    ), I = g?.textContent, f = t.useMemo(
      () => /* @__PURE__ */ a.jsx("option", { value: l.value, disabled: l.disabled, children: I }, l.value),
      [l.disabled, l.value, I]
    ), { onNativeOptionAdd: h, onNativeOptionRemove: w } = p;
    return K(() => (h(f), () => w(f)), [h, w, f]), /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
      /* @__PURE__ */ a.jsx(O.span, { id: l.textId, ...d, ref: E }),
      l.isSelected && n.valueNode && !n.valueNodeHasChildren ? Ee.createPortal(d.children, n.valueNode) : null
    ] });
  }
);
ze.displayName = ne;
var Ye = "SelectItemIndicator", qe = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, ...c } = o;
    return Ue(Ye, e).isSelected ? /* @__PURE__ */ a.jsx(O.span, { "aria-hidden": !0, ...c, ref: i }) : null;
  }
);
qe.displayName = Ye;
var xe = "SelectScrollUpButton", At = t.forwardRef((o, i) => {
  const e = G(xe, o.__scopeSelect), c = Ie(xe, o.__scopeSelect), [r, d] = t.useState(!1), n = L(i, c.onScrollButtonChange);
  return K(() => {
    if (e.viewport && e.isPositioned) {
      let s = function() {
        const p = l.scrollTop > 0;
        d(p);
      };
      const l = e.viewport;
      return s(), l.addEventListener("scroll", s), () => l.removeEventListener("scroll", s);
    }
  }, [e.viewport, e.isPositioned]), r ? /* @__PURE__ */ a.jsx(
    Xe,
    {
      ...o,
      ref: n,
      onAutoScroll: () => {
        const { viewport: s, selectedItem: l } = e;
        s && l && (s.scrollTop = s.scrollTop - l.offsetHeight);
      }
    }
  ) : null;
});
At.displayName = xe;
var we = "SelectScrollDownButton", jt = t.forwardRef((o, i) => {
  const e = G(we, o.__scopeSelect), c = Ie(we, o.__scopeSelect), [r, d] = t.useState(!1), n = L(i, c.onScrollButtonChange);
  return K(() => {
    if (e.viewport && e.isPositioned) {
      let s = function() {
        const p = l.scrollHeight - l.clientHeight, g = Math.ceil(l.scrollTop) < p;
        d(g);
      };
      const l = e.viewport;
      return s(), l.addEventListener("scroll", s), () => l.removeEventListener("scroll", s);
    }
  }, [e.viewport, e.isPositioned]), r ? /* @__PURE__ */ a.jsx(
    Xe,
    {
      ...o,
      ref: n,
      onAutoScroll: () => {
        const { viewport: s, selectedItem: l } = e;
        s && l && (s.scrollTop = s.scrollTop + l.offsetHeight);
      }
    }
  ) : null;
});
jt.displayName = we;
var Xe = t.forwardRef((o, i) => {
  const { __scopeSelect: e, onAutoScroll: c, ...r } = o, d = G("SelectScrollButton", e), n = t.useRef(null), s = ae(e), l = t.useCallback(() => {
    n.current !== null && (window.clearInterval(n.current), n.current = null);
  }, []);
  return t.useEffect(() => () => l(), [l]), K(() => {
    s().find((g) => g.ref.current === document.activeElement)?.ref.current?.scrollIntoView({ block: "nearest" });
  }, [s]), /* @__PURE__ */ a.jsx(
    O.div,
    {
      "aria-hidden": !0,
      ...r,
      ref: i,
      style: { flexShrink: 0, ...r.style },
      onPointerDown: b(r.onPointerDown, () => {
        n.current === null && (n.current = window.setInterval(c, 50));
      }),
      onPointerMove: b(r.onPointerMove, () => {
        d.onItemLeave?.(), n.current === null && (n.current = window.setInterval(c, 50));
      }),
      onPointerLeave: b(r.onPointerLeave, () => {
        l();
      })
    }
  );
}), Dt = "SelectSeparator", Ze = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, ...c } = o;
    return /* @__PURE__ */ a.jsx(O.div, { "aria-hidden": !0, ...c, ref: i });
  }
);
Ze.displayName = Dt;
var Ce = "SelectArrow", Lt = t.forwardRef(
  (o, i) => {
    const { __scopeSelect: e, ...c } = o, r = de(e), d = U(Ce, e), n = G(Ce, e);
    return d.open && n.position === "popper" ? /* @__PURE__ */ a.jsx(dt, { ...r, ...c, ref: i }) : null;
  }
);
Lt.displayName = Ce;
function $e(o) {
  return o === "" || o === void 0;
}
var Je = t.forwardRef(
  (o, i) => {
    const { value: e, ...c } = o, r = t.useRef(null), d = L(i, r), n = mt(e);
    return t.useEffect(() => {
      const s = r.current, l = window.HTMLSelectElement.prototype, g = Object.getOwnPropertyDescriptor(
        l,
        "value"
      ).set;
      if (n !== e && g) {
        const x = new Event("change", { bubbles: !0 });
        g.call(s, e), s.dispatchEvent(x);
      }
    }, [n, e]), /* @__PURE__ */ a.jsx(ht, { asChild: !0, children: /* @__PURE__ */ a.jsx("select", { ...c, ref: d, defaultValue: e }) });
  }
);
Je.displayName = "BubbleSelect";
function Qe(o) {
  const i = ft(o), e = t.useRef(""), c = t.useRef(0), r = t.useCallback(
    (n) => {
      const s = e.current + n;
      i(s), function l(p) {
        e.current = p, window.clearTimeout(c.current), p !== "" && (c.current = window.setTimeout(() => l(""), 1e3));
      }(s);
    },
    [i]
  ), d = t.useCallback(() => {
    e.current = "", window.clearTimeout(c.current);
  }, []);
  return t.useEffect(() => () => window.clearTimeout(c.current), []), [e, r, d];
}
function et(o, i, e) {
  const r = i.length > 1 && Array.from(i).every((p) => p === i[0]) ? i[0] : i, d = e ? o.indexOf(e) : -1;
  let n = kt(o, Math.max(d, 0));
  r.length === 1 && (n = n.filter((p) => p !== e));
  const l = n.find(
    (p) => p.textValue.toLowerCase().startsWith(r.toLowerCase())
  );
  return l !== e ? l : void 0;
}
function kt(o, i) {
  return o.map((e, c) => o[(i + c) % o.length]);
}
var co = be, io = _e, ao = Oe, uo = Ae, po = je, fo = De, mo = He, ho = Fe, vo = Ke, go = Ge, So = ze, xo = qe, wo = Ze;
export {
  fo as Content,
  ho as Group,
  uo as Icon,
  go as Item,
  xo as ItemIndicator,
  So as ItemText,
  vo as Label,
  po as Portal,
  co as Root,
  be as Select,
  Lt as SelectArrow,
  De as SelectContent,
  Fe as SelectGroup,
  Ae as SelectIcon,
  Ge as SelectItem,
  qe as SelectItemIndicator,
  ze as SelectItemText,
  Ke as SelectLabel,
  je as SelectPortal,
  jt as SelectScrollDownButton,
  At as SelectScrollUpButton,
  Ze as SelectSeparator,
  _e as SelectTrigger,
  Oe as SelectValue,
  He as SelectViewport,
  wo as Separator,
  io as Trigger,
  ao as Value,
  mo as Viewport,
  lo as createSelectScope
};
//# sourceMappingURL=index.js.map
