import { useFuse } from "@vueuse/integrations/useFuse";
import { computed, toValue } from "vue";
export function useFuzzy(searchTerm, items, fieldName, options) {
  const useFuzeOptions = computed(() => {
    const optionsValue = toValue(options);
    const fieldNameValue = toValue(fieldName);
    return {
      fuseOptions: {
        keys: fieldNameValue,
        isCaseSensitive: optionsValue?.isCaseSensitive ?? false,
        threshold: optionsValue?.threshold ?? 0.5
      },
      resultLimit: optionsValue?.resultLimit ?? 20,
      matchAllWhenSearchEmpty: optionsValue?.matchAllWhenSearchEmpty ?? false
    };
  });
  const { results } = useFuse(searchTerm, items, useFuzeOptions);
  return results;
}
