"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var query_utils_exports = {};
__export(query_utils_exports, {
  STOP_WORDS: () => STOP_WORDS,
  extractSearchTerms: () => extractSearchTerms,
  kindBonus: () => kindBonus,
  scorePathRelevance: () => scorePathRelevance
});
module.exports = __toCommonJS(query_utils_exports);
const STOP_WORDS = /* @__PURE__ */ new Set([
  "the",
  "and",
  "for",
  "with",
  "from",
  "this",
  "that",
  "have",
  "been",
  "will",
  "would",
  "could",
  "should",
  "does",
  "done",
  "make",
  "made",
  "use",
  "used",
  "using",
  "work",
  "works",
  "find",
  "found",
  "show",
  "call",
  "called",
  "get",
  "set",
  "add",
  "all",
  "any",
  "how",
  "what",
  "when",
  "where",
  "which",
  "who",
  "why",
  "fix",
  "bug",
  "code",
  "file",
  "files",
  "function",
  "method",
  "class",
  "type",
  "build",
  "run",
  "test",
  "a",
  "an",
  "in",
  "of",
  "to",
  "is",
  "it",
  "by",
  "on",
  "at",
  "as",
  "or",
  "be",
  "do",
  "if",
  "no",
  "so",
  "up",
  "not",
  "but",
  "are",
  "was",
  "has",
  "had",
  "its",
  "can",
  "may",
  "also",
  "into",
  "then",
  "than",
  "just",
  "more",
  "some",
  "such",
  "each",
  "over",
  "only",
  "new",
  "out",
  "two",
  "way",
  "see",
  "him",
  "his",
  "her",
  "she",
  "they",
  "them",
  "their",
  "our",
  "your",
  "you",
  "we",
  "me",
  "my",
  "him",
  "his"
]);
function extractSearchTerms(query) {
  const tokens = /* @__PURE__ */ new Set();
  const camelSplit = query.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2");
  const normalised = camelSplit.replace(/[_\.]+/g, " ");
  const words = normalised.split(/[^a-zA-Z0-9]+/).filter(Boolean);
  for (const word of words) {
    const lower = word.toLowerCase();
    if (lower.length < 3) continue;
    if (STOP_WORDS.has(lower)) continue;
    tokens.add(lower);
  }
  return [...tokens];
}
function scorePathRelevance(filePath, query) {
  const queryTerms = extractSearchTerms(query);
  if (queryTerms.length === 0) return 0;
  const normalised = filePath.replace(/\\/g, "/");
  const segments = normalised.split("/").filter(Boolean);
  if (segments.length === 0) return 0;
  const lastSegment = segments[segments.length - 1];
  const dotIdx = lastSegment.lastIndexOf(".");
  const filename = dotIdx > 0 ? lastSegment.slice(0, dotIdx) : lastSegment;
  const dirSegments = segments.slice(0, -1);
  let score = 0;
  for (const term of queryTerms) {
    const filenameLower = filename.toLowerCase();
    const termLower = term.toLowerCase();
    if (filenameLower === termLower) {
      score += 10;
    } else if (dirSegments.some((s) => s.toLowerCase() === termLower)) {
      score += 5;
    } else if (segments.some((s) => s.toLowerCase().includes(termLower))) {
      score += 3;
    }
  }
  return score;
}
function kindBonus(kind) {
  switch (kind) {
    case "function":
    case "method":
      return 10;
    case "route":
      return 9;
    case "class":
    case "component":
      return 8;
    case "interface":
      return 7;
    case "type_alias":
    case "struct":
    case "trait":
      return 6;
    case "enum":
      return 5;
    case "module":
    case "namespace":
      return 4;
    case "property":
    case "field":
    case "constant":
      return 3;
    case "variable":
      return 2;
    case "import":
    case "export":
      return 1;
    case "parameter":
    case "file":
      return 0;
    default:
      return 0;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  STOP_WORDS,
  extractSearchTerms,
  kindBonus,
  scorePathRelevance
});
//# sourceMappingURL=query-utils.js.map
