import { jsx } from "react/jsx-runtime";
import {
  DSControlledDateTimePicker
} from "@elliemae/ds-controlled-form";
import {
  Controller
} from "react-hook-form";
const getConfig = (value, onChange) => ({
  "full-date-time": {
    dateTime: value,
    onDateTimeChange: onChange
  },
  "date-time-inputs": {
    dateTime: value,
    onDateTimeChange: onChange
  },
  "date-time-picker": {
    dateTime: value,
    onDateTimeChange: onChange
  },
  "date-time-picker-controller-only": {
    dateTime: value,
    onDateTimeChange: onChange
  },
  "date-inputs": {
    date: value,
    onDateChange: onChange
  },
  "date-picker": {
    date: value,
    onDateChange: onChange
  },
  "date-picker-controller-only": {
    date: value,
    onDateChange: onChange
  },
  "full-date": {
    date: value,
    onDateChange: onChange
  },
  "full-time": {
    time: value,
    onTimeChange: onChange
  },
  "time-inputs": {
    time: value,
    onTimeChange: onChange
  },
  "time-picker-controller-only": {
    time: value,
    onTimeChange: onChange
  },
  "time-picker": {
    time: value,
    onTimeChange: onChange
  }
});
const DateTimePicker = ({
  name,
  defaultValue = "",
  rules = {},
  type = "full-date-time",
  ...rest
}) => /* @__PURE__ */ jsx(
  Controller,
  {
    name,
    defaultValue,
    rules,
    render: ({
      field: { value, onChange, ...restProps },
      fieldState: { error }
    }) => (
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
      // @ts-ignore
      /* @__PURE__ */ jsx(
        DSControlledDateTimePicker,
        {
          hasError: !!error,
          ...restProps,
          type,
          ...getConfig(value, onChange)[type],
          ...rest
        }
      )
    )
  }
);
export {
  DateTimePicker
};
