import {
  __objRest,
  __spreadProps,
  __spreadValues
} from "./chunk-2NMEKWO5.js";

// src/atoms/select.tsx
import { Select as RadixSelect } from "@radix-ui/themes";
import { createContext, forwardRef, useContext, useMemo } from "react";
import { jsx } from "react/jsx-runtime";
var SelectContext = createContext({
  error: false
});
var Content = forwardRef((props, ref) => {
  const _a = props, { className, isNavigation } = _a, rest = __objRest(_a, ["className", "isNavigation"]);
  const { error } = useContext(SelectContext);
  const cls = useMemo(() => {
    const etc = isNavigation ? "nav-select" : "";
    const errorCls = error ? "tipp-error" : "";
    return [etc, errorCls, className].join(" ");
  }, [className, error, isNavigation]);
  return /* @__PURE__ */ jsx(
    RadixSelect.Content,
    __spreadProps(__spreadValues({
      position: "popper"
    }, rest), {
      className: cls,
      ref
    })
  );
});
Content.displayName = "Select.Content";
var Trigger = forwardRef(
  (props, ref) => {
    const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
    const { error } = useContext(SelectContext);
    const cls = useMemo(() => {
      const errorCls = error ? "error" : "";
      return [errorCls, className].join(" ");
    }, [className, error]);
    return /* @__PURE__ */ jsx(RadixSelect.Trigger, __spreadProps(__spreadValues({}, rest), { className: cls, ref }));
  }
);
Trigger.displayName = "Select.Trigger";
function Root(props) {
  const _a = props, { error } = _a, rest = __objRest(_a, ["error"]);
  return /* @__PURE__ */ jsx(SelectContext.Provider, { value: { error }, children: /* @__PURE__ */ jsx(RadixSelect.Root, __spreadValues({}, rest)) });
}
Root.displayName = "Select.Root";
var Select = __spreadProps(__spreadValues({}, RadixSelect), {
  Root,
  Trigger,
  Content
});

export {
  Select
};
//# sourceMappingURL=chunk-AP52M2Z5.js.map