"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 vue_exports = {};
__export(vue_exports, {
  nuxtResolver: () => nuxtResolver,
  vueResolver: () => vueResolver
});
module.exports = __toCommonJS(vue_exports);
const nuxtResolver = {
  name: "nuxt",
  detect(context) {
    if (context.fileExists("nuxt.config.ts") || context.fileExists("nuxt.config.js")) return true;
    const pkg = context.readFile("package.json");
    if (pkg) {
      try {
        const parsed = JSON.parse(pkg);
        const deps = { ...parsed.dependencies, ...parsed.devDependencies };
        if ("nuxt" in deps || "nuxt3" in deps) return true;
      } catch {
      }
    }
    return false;
  },
  resolve(ref, context) {
    if (ref.referenceName.startsWith("use")) {
      const id = resolveComposable(ref.referenceName, context);
      if (id) return { original: ref, targetNodeId: id, confidence: 0.9, resolvedBy: "framework" };
    }
    if (/^[A-Z][a-zA-Z]+$/.test(ref.referenceName)) {
      const id = resolveComponent(ref.referenceName, context);
      if (id) return { original: ref, targetNodeId: id, confidence: 0.85, resolvedBy: "framework" };
    }
    if (ref.referenceName.startsWith("use") && ref.referenceName.endsWith("Store")) {
      const id = resolveStore(ref.referenceName, context);
      if (id) return { original: ref, targetNodeId: id, confidence: 0.9, resolvedBy: "framework" };
    }
    return null;
  },
  extractNodes(filePath, content) {
    const nodes = [];
    const now = Date.now();
    if (filePath.includes("server/api/") || filePath.includes("server/routes/")) {
      const routePath = filePath.replace(/.*server\/(api|routes)/, "/$1").replace(/\.(ts|js|mjs)$/, "").replace(/\/index$/, "").replace(/\[([^\]]+)\]/g, ":$1");
      const methodMatch = routePath.match(/\.(get|post|put|patch|delete)$/i);
      const method = methodMatch ? methodMatch[1].toUpperCase() : "ANY";
      const cleanPath = methodMatch ? routePath.replace(/\.(get|post|put|patch|delete)$/i, "") : routePath;
      const name = `${method} ${cleanPath}`;
      nodes.push({
        id: `route:${filePath}:${method}:${cleanPath}:1`,
        kind: "route",
        name,
        qualifiedName: `${filePath}::${name}`,
        filePath,
        startLine: 1,
        endLine: 1,
        startColumn: 0,
        endColumn: 0,
        language: "typescript",
        updatedAt: now
      });
    }
    if (filePath.includes("pages/") && filePath.endsWith(".vue")) {
      const routePath = filePath.replace(/.*pages/, "").replace(/\.vue$/, "").replace(/\/index$/, "").replace(/\[([^\]]+)\]/g, ":$1");
      const name = `PAGE ${routePath || "/"}`;
      nodes.push({
        id: `route:${filePath}:PAGE:${routePath || "/"}:1`,
        kind: "route",
        name,
        qualifiedName: `${filePath}::${name}`,
        filePath,
        startLine: 1,
        endLine: 1,
        startColumn: 0,
        endColumn: 0,
        language: "vue",
        updatedAt: now
      });
    }
    return nodes;
  }
};
const vueResolver = {
  name: "vue",
  detect(context) {
    const pkg = context.readFile("package.json");
    if (pkg) {
      try {
        const parsed = JSON.parse(pkg);
        const deps = { ...parsed.dependencies, ...parsed.devDependencies };
        if ("vue" in deps) return true;
      } catch {
      }
    }
    return context.getAllFiles().some((f) => f.endsWith(".vue"));
  },
  resolve(ref, context) {
    if (/^[A-Z][a-zA-Z]+$/.test(ref.referenceName)) {
      const id = resolveComponent(ref.referenceName, context);
      if (id) return { original: ref, targetNodeId: id, confidence: 0.8, resolvedBy: "framework" };
    }
    if (ref.referenceName.startsWith("use")) {
      const id = resolveComposable(ref.referenceName, context);
      if (id) return { original: ref, targetNodeId: id, confidence: 0.85, resolvedBy: "framework" };
    }
    return null;
  }
};
function resolveComposable(name, context) {
  const dirs = ["composables", "src/composables", "hooks", "src/hooks"];
  for (const file of context.getAllFiles()) {
    if ((file.endsWith(".ts") || file.endsWith(".js")) && dirs.some((d) => file.includes(`/${d}/`))) {
      const node = context.getNodesInFile(file).find((n) => n.name === name);
      if (node) return node.id;
    }
  }
  return null;
}
function resolveComponent(name, context) {
  const kebab = name.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  const dirs = ["components", "src/components"];
  for (const file of context.getAllFiles()) {
    if (!file.endsWith(".vue") && !file.endsWith(".tsx") && !file.endsWith(".ts")) continue;
    if (!dirs.some((d) => file.includes(`/${d}/`))) continue;
    const basename = file.split("/").pop()?.replace(/\.(vue|tsx|ts)$/, "") ?? "";
    if (basename === name || basename === kebab || basename.toLowerCase() === name.toLowerCase()) {
      const nodes = context.getNodesInFile(file);
      if (nodes.length > 0) return nodes[0].id;
    }
  }
  return null;
}
function resolveStore(name, context) {
  const dirs = ["stores", "store", "src/stores", "src/store"];
  for (const file of context.getAllFiles()) {
    if ((file.endsWith(".ts") || file.endsWith(".js")) && dirs.some((d) => file.includes(`/${d}/`))) {
      const node = context.getNodesInFile(file).find((n) => n.name === name);
      if (node) return node.id;
    }
  }
  return null;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  nuxtResolver,
  vueResolver
});
//# sourceMappingURL=vue.js.map
