import { useMemo } from "react";
import Fuse from "fuse.js";
const useFuseFilteredOptions = (optionProps, options, input) => {
  const fuseOpts = optionProps.fuseOptions ?? true;
  const fuse = useMemo(() => {
    if (!options.some((it) => it.searchKeywords !== "")) {
      return void 0;
    }
    if (!fuseOpts) {
      return void 0;
    }
    return new Fuse(options, {
      ...fuseOpts === true ? {} : fuseOpts,
      keys: ["searchKeywords"]
    });
  }, [fuseOpts, options]);
  return useMemo(() => {
    return input && fuse ? fuse.search(input).map((it) => it.item) : options;
  }, [fuse, input, options]);
};
export { useFuseFilteredOptions };
//# sourceMappingURL=useFuseFilteredOptions.js.map
