import { jsx } from "react/jsx-runtime";
import { AutoComplete } from "antd";
import { useState, useMemo } from "react";
import { useTheme } from "./Theme/UI.js";
import "./Theme/themeUtils.js";
import "./Theme/themes.js";
const InputSelect = ({
  allowClear,
  autoFocus,
  customFilter,
  defaultValue,
  disabled,
  options,
  placeholder,
  value,
  width,
  onBlur,
  onFocus,
  onChange,
  onKeyDown,
  onDropdownVisibleChange
}) => {
  const {
    themeSettings: { className: themeClass }
  } = useTheme();
  const [filterValue, setFilterValue] = useState("");
  const filteredOptions = useMemo(() => {
    let filteredOpts = [];
    if (customFilter) {
      filteredOpts = customFilter(options, filterValue);
    } else {
      filteredOpts = options == null ? void 0 : options.filter(
        (option) => option.toLowerCase().includes(filterValue.toLowerCase())
      );
    }
    return filteredOpts.map((val) => ({ value: val }));
  }, [options, filterValue, customFilter]);
  return /* @__PURE__ */ jsx(
    AutoComplete,
    {
      allowClear,
      autoFocus,
      className: themeClass,
      defaultValue,
      disabled,
      options: filteredOptions,
      placeholder,
      popupClassName: themeClass,
      style: { width },
      value,
      onBlur,
      onChange,
      onDropdownVisibleChange,
      onFocus,
      onKeyDown,
      onSearch: (text) => setFilterValue(text)
    }
  );
};
export {
  InputSelect as default
};
