import { j as jsxRuntimeExports } from "../../../../../../../_virtual/jsx-runtime.js";
import { useState } from "react";
import "../../../../../../../node_modules/.pnpm/@formkit_auto-animate@0.8.2/node_modules/@formkit/auto-animate/index.js";
import "../../../../../../../node_modules/.pnpm/react-hot-toast@2.5.2_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/react-hot-toast/dist/index.js";
import { FieldTitle } from "../field-factory.js";
import { Slider as s } from "../../../../../../../node_modules/.pnpm/@radix-ui_themes@3.2.1_@types_react-dom@19.1.9_@types_react@19.1.13__@types_react@19.1._832fa1fef691e6e9510ada03948dc85c/node_modules/@radix-ui/themes/dist/esm/components/slider.js";
import { Root as u } from "../../../../../../../node_modules/.pnpm/@radix-ui_themes@3.2.1_@types_react-dom@19.1.9_@types_react@19.1.13__@types_react@19.1._832fa1fef691e6e9510ada03948dc85c/node_modules/@radix-ui/themes/dist/esm/components/text-field.js";
const SliderField = (props) => {
  const { schema, currentValue, onChange, title, description } = props;
  const unit = schema["ui:unit"] ?? "";
  const multiplier = schema["ui:multiplier"] ?? 1;
  const [val, setVal] = useState(currentValue);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "slider-field flex-1 flex justify-between gap-3 items-center", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(FieldTitle, { title, description }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ml-auto basis-1/3 flex items-center gap-2", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(
        s,
        {
          onValueChange: (value) => {
            console.log("slider value changed", value[0]);
            setVal(value[0]);
            onChange(value[0]);
          },
          size: "1",
          variant: "soft",
          min: schema.minimum,
          max: schema.maximum,
          step: schema.multipleOf ?? 1,
          defaultValue: [currentValue]
        }
      ),
      typeof currentValue === "number" && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-500 text-sm text-nowrap whitespace-nowrap", children: [
        val * multiplier,
        " ",
        unit
      ] })
    ] })
  ] });
};
const NumberField = (props) => {
  const { currentValue, onChange, schema, title, description, placeholder } = props;
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "number-field flex-1 flex justify-between gap-3 items-center", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(FieldTitle, { title, description }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(
      u,
      {
        defaultValue: currentValue,
        type: "number",
        onChange: (e) => onChange(e.target.value ? Number(e.target.value) : null),
        className: "!max-w-[50px] !text-right",
        inputMode: "numeric",
        min: schema.minimum,
        max: schema.maximum,
        step: schema.multipleOf ?? 1,
        placeholder: placeholder ?? schema["ui:placeholder"]
      }
    )
  ] });
};
export {
  NumberField,
  SliderField
};
//# sourceMappingURL=number.js.map
