import Fuse from "fuse.js";
function findSimilarSymbols(target, candidates, maxResults = 5, threshold = 0.4) {
  if (candidates.length === 0 || !target) return [];
  const fuse = new Fuse(candidates, {
    keys: ["name"],
    threshold,
    includeScore: true,
    shouldSort: true,
    minMatchCharLength: Math.max(2, Math.floor(target.length * 0.5))
  });
  const results = fuse.search(target, { limit: maxResults });
  return results.map((r) => ({
    name: r.item.name,
    score: r.score ?? 1,
    kind: r.item.kind,
    filePath: r.item.file_path
  }));
}
function globToLike(pattern) {
  return pattern.replace(/\*/g, "%").replace(/\?/g, "_");
}
function isGlobPattern(term) {
  return term.includes("*") || term.includes("?");
}
function isWildcard(term) {
  return !term || term === "*";
}
export {
  findSimilarSymbols,
  globToLike,
  isGlobPattern,
  isWildcard
};
