import { jsxs as t, jsx as e } from "react/jsx-runtime";
import { useState as m, useEffect as $ } from "react";
import { useParams as M, Link as u } from "react-router-dom";
import { useTranslation as x } from "react-i18next";
import { Target as N, Users as S, CheckCircle as E, ArrowRight as O, AlertTriangle as F, FileText as R, BookOpen as L, Shield as f, Database as w, ChevronDown as P, ChevronRight as B, Rocket as A, FolderTree as D, Globe as I, GitBranch as H, Loader2 as j, ArrowLeft as k } from "lucide-react";
import { b as C } from "./businessAnalysisApi-hLIodI9W.js";
function y({ title: r, items: s, color: a }) {
  return s?.length ? /* @__PURE__ */ t("div", { className: `rounded-lg border-l-4 ${a} p-4 bg-[var(--bg-secondary)]`, children: [
    /* @__PURE__ */ e("h4", { className: "text-sm font-semibold mb-2", children: r }),
    /* @__PURE__ */ e("ul", { className: "space-y-1", children: s.map((i) => /* @__PURE__ */ t("li", { className: "text-sm text-[var(--text-secondary)] flex items-start gap-2", children: [
      /* @__PURE__ */ e("span", { className: "mt-1.5 w-1.5 h-1.5 rounded-full bg-current flex-shrink-0" }),
      i
    ] }, i)) })
  ] }) : null;
}
function U({ stakeholder: r }) {
  const { t: s } = x("ba");
  return /* @__PURE__ */ t("div", { className: "card p-4", children: [
    /* @__PURE__ */ t("div", { className: "flex items-center gap-2 mb-2", children: [
      /* @__PURE__ */ e(S, { className: "w-4 h-4 text-[var(--color-primary-600)]" }),
      /* @__PURE__ */ e("h4", { className: "font-medium text-[var(--text-primary)]", children: r.role })
    ] }),
    r.function && /* @__PURE__ */ e("p", { className: "text-sm text-[var(--text-secondary)] mb-2", children: r.function }),
    (r.tasks?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { className: "mb-2", children: [
      /* @__PURE__ */ e("p", { className: "text-xs font-medium text-[var(--text-tertiary)] mb-1", children: s("stakeholder.tasks") }),
      /* @__PURE__ */ e("ul", { className: "space-y-0.5", children: r.tasks?.map((a) => /* @__PURE__ */ t("li", { className: "text-sm text-[var(--text-secondary)] flex items-center gap-1.5", children: [
        /* @__PURE__ */ e(O, { className: "w-3 h-3 text-[var(--text-tertiary)]" }),
        a
      ] }, a)) })
    ] }),
    (r.painPoints?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { children: [
      /* @__PURE__ */ e("p", { className: "text-xs font-medium text-[var(--text-tertiary)] mb-1", children: s("stakeholder.painPoints") }),
      /* @__PURE__ */ e("ul", { className: "space-y-0.5", children: r.painPoints?.map((a) => /* @__PURE__ */ t("li", { className: "text-sm text-red-600 dark:text-red-400 flex items-center gap-1.5", children: [
        /* @__PURE__ */ e(F, { className: "w-3 h-3" }),
        a
      ] }, a)) })
    ] })
  ] });
}
function q({ discovery: r }) {
  const { t: s } = x("ba");
  return r ? /* @__PURE__ */ t("div", { className: "space-y-8", children: [
    (r.problem || r.asIs || r.toBe) && /* @__PURE__ */ t("div", { className: "space-y-4", children: [
      r.problem && /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ t("h3", { className: "text-lg font-semibold mb-2 flex items-center gap-2", children: [
          /* @__PURE__ */ e(N, { className: "w-5 h-5 text-red-500" }),
          s("discovery.problem")
        ] }),
        /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)] bg-[var(--bg-secondary)] rounded-lg p-4 whitespace-pre-wrap", children: r.problem })
      ] }),
      /* @__PURE__ */ t("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
        r.asIs && /* @__PURE__ */ t("div", { children: [
          /* @__PURE__ */ e("h3", { className: "text-sm font-semibold mb-2 text-orange-600 dark:text-orange-400", children: s("discovery.asIs") }),
          /* @__PURE__ */ e("p", { className: "text-sm text-[var(--text-secondary)] bg-orange-50 dark:bg-orange-950/30 rounded-lg p-4 whitespace-pre-wrap", children: r.asIs })
        ] }),
        r.toBe && /* @__PURE__ */ t("div", { children: [
          /* @__PURE__ */ e("h3", { className: "text-sm font-semibold mb-2 text-green-600 dark:text-green-400", children: s("discovery.toBe") }),
          /* @__PURE__ */ e("p", { className: "text-sm text-[var(--text-secondary)] bg-green-50 dark:bg-green-950/30 rounded-lg p-4 whitespace-pre-wrap", children: r.toBe })
        ] })
      ] })
    ] }),
    (r.stakeholders?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { children: [
      /* @__PURE__ */ t("h3", { className: "text-lg font-semibold mb-3 flex items-center gap-2", children: [
        /* @__PURE__ */ e(S, { className: "w-5 h-5 text-[var(--color-primary-600)]" }),
        s("discovery.stakeholders")
      ] }),
      /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: r.stakeholders?.map((a) => /* @__PURE__ */ e(U, { stakeholder: a }, a.role)) })
    ] }),
    r.scope && /* @__PURE__ */ t("div", { children: [
      /* @__PURE__ */ t("h3", { className: "text-lg font-semibold mb-3 flex items-center gap-2", children: [
        /* @__PURE__ */ e(E, { className: "w-5 h-5 text-[var(--color-primary-600)]" }),
        s("discovery.scope")
      ] }),
      /* @__PURE__ */ t("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4", children: [
        /* @__PURE__ */ e(y, { title: s("scope.mustHave"), items: r.scope.mustHave, color: "border-red-500" }),
        /* @__PURE__ */ e(y, { title: s("scope.shouldHave"), items: r.scope.shouldHave, color: "border-yellow-500" }),
        /* @__PURE__ */ e(y, { title: s("scope.couldHave"), items: r.scope.couldHave, color: "border-blue-500" }),
        /* @__PURE__ */ e(y, { title: s("scope.outOfScope"), items: r.scope.outOfScope, color: "border-gray-400" })
      ] })
    ] })
  ] }) : /* @__PURE__ */ t("div", { className: "text-center py-12", children: [
    /* @__PURE__ */ e(N, { className: "w-10 h-10 text-[var(--text-tertiary)] mx-auto mb-3" }),
    /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)]", children: s("discovery.noData") })
  ] });
}
const G = {
  VAL: "bg-indigo-100 text-indigo-700 dark:bg-indigo-900 dark:text-indigo-300",
  CALC: "bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300",
  WF: "bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-300",
  SEC: "bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300",
  DATA: "bg-cyan-100 text-cyan-700 dark:bg-cyan-900 dark:text-cyan-300"
}, K = {
  must: "bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300",
  should: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300",
  could: "bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"
};
function _({ uc: r }) {
  const { t: s } = x("ba"), [a, i] = m(!1);
  return /* @__PURE__ */ t("div", { className: "card p-4", children: [
    /* @__PURE__ */ t(
      "button",
      {
        onClick: () => i(!a),
        className: "w-full flex items-start gap-2 text-left",
        children: [
          a ? /* @__PURE__ */ e(P, { className: "w-4 h-4 mt-0.5 flex-shrink-0" }) : /* @__PURE__ */ e(B, { className: "w-4 h-4 mt-0.5 flex-shrink-0" }),
          /* @__PURE__ */ t("div", { className: "flex-1 min-w-0", children: [
            /* @__PURE__ */ t("div", { className: "flex items-center gap-2 flex-wrap", children: [
              /* @__PURE__ */ e("span", { className: "text-xs font-mono text-[var(--color-primary-600)]", children: r.id }),
              /* @__PURE__ */ e("span", { className: "font-medium text-[var(--text-primary)]", children: r.name })
            ] }),
            r.description && !a && /* @__PURE__ */ e("p", { className: "text-sm text-[var(--text-tertiary)] truncate mt-0.5", children: r.description })
          ] })
        ]
      }
    ),
    a && /* @__PURE__ */ t("div", { className: "mt-3 ml-6 space-y-3 text-sm", children: [
      r.description && /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)]", children: r.description }),
      /* @__PURE__ */ t("div", { className: "flex gap-4 text-xs", children: [
        /* @__PURE__ */ t("span", { className: "text-[var(--text-tertiary)]", children: [
          s("useCase.actor"),
          ": ",
          /* @__PURE__ */ e("strong", { children: r.primaryActor })
        ] }),
        /* @__PURE__ */ t("span", { className: "text-[var(--text-tertiary)]", children: [
          s("useCase.permission"),
          ": ",
          /* @__PURE__ */ e("code", { className: "bg-[var(--bg-tertiary)] px-1 rounded", children: r.permission })
        ] })
      ] }),
      (r.preconditions?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ e("p", { className: "text-xs font-medium text-[var(--text-tertiary)] mb-1", children: s("useCase.preconditions") }),
        /* @__PURE__ */ e("ul", { className: "list-disc list-inside text-[var(--text-secondary)]", children: r.preconditions?.map((c) => /* @__PURE__ */ e("li", { children: c }, c)) })
      ] }),
      /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ e("p", { className: "text-xs font-medium text-[var(--text-tertiary)] mb-1", children: s("useCase.mainScenario") }),
        /* @__PURE__ */ e("ol", { className: "list-decimal list-inside text-[var(--text-secondary)] space-y-0.5", children: r.mainScenario.map((c) => /* @__PURE__ */ e("li", { children: c }, c)) })
      ] }),
      (r.alternativeScenarios?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ e("p", { className: "text-xs font-medium text-[var(--text-tertiary)] mb-1", children: s("useCase.alternatives") }),
        r.alternativeScenarios?.map((c) => /* @__PURE__ */ t("div", { className: "mb-2", children: [
          /* @__PURE__ */ e("p", { className: "text-xs font-medium text-[var(--text-secondary)]", children: c.name }),
          /* @__PURE__ */ e("ol", { className: "list-decimal list-inside text-[var(--text-secondary)] text-xs", children: c.steps.map((d) => /* @__PURE__ */ e("li", { children: d }, d)) })
        ] }, c.name))
      ] }),
      (r.linkedRules?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { className: "flex items-center gap-2 flex-wrap", children: [
        /* @__PURE__ */ t("span", { className: "text-xs text-[var(--text-tertiary)]", children: [
          s("useCase.linkedRules"),
          ":"
        ] }),
        r.linkedRules?.map((c) => /* @__PURE__ */ e("span", { className: "text-xs font-mono bg-[var(--bg-tertiary)] px-1.5 py-0.5 rounded", children: c }, c))
      ] })
    ] })
  ] });
}
function V({ specification: r, analysis: s }) {
  const { t: a } = x("ba"), [i, c] = m("uc"), d = r?.useCases && r.useCases.length > 0, p = s?.businessRules && s.businessRules.length > 0, b = s?.entities && s.entities.length > 0, h = r?.permissionMatrix?.permissions && r.permissionMatrix.permissions.length > 0;
  if (!d && !p && !b && !h)
    return /* @__PURE__ */ t("div", { className: "text-center py-12", children: [
      /* @__PURE__ */ e(R, { className: "w-10 h-10 text-[var(--text-tertiary)] mx-auto mb-3" }),
      /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)]", children: a("specification.noData") })
    ] });
  const o = [
    { id: "uc", label: a("specification.useCases"), count: r?.useCases?.length || 0, icon: L, show: d },
    { id: "br", label: a("specification.businessRules"), count: s?.businessRules?.length || 0, icon: f, show: p },
    { id: "entities", label: a("specification.entities"), count: s?.entities?.length || 0, icon: w, show: b },
    { id: "permissions", label: a("specification.permissions"), count: r?.permissionMatrix?.permissions?.length || 0, icon: f, show: h }
  ].filter((l) => l.show);
  return /* @__PURE__ */ t("div", { className: "space-y-6", children: [
    /* @__PURE__ */ e("div", { className: "flex gap-1 border-b border-[var(--border-color)]", children: o.map((l) => /* @__PURE__ */ t(
      "button",
      {
        onClick: () => c(l.id),
        className: `px-4 py-2 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 ${i === l.id ? "border-[var(--color-primary-600)] text-[var(--color-primary-600)]" : "border-transparent text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,
        children: [
          /* @__PURE__ */ e(l.icon, { className: "w-4 h-4" }),
          l.label,
          /* @__PURE__ */ e("span", { className: "text-xs bg-[var(--bg-tertiary)] px-1.5 py-0.5 rounded-full", children: l.count })
        ]
      },
      l.id
    )) }),
    i === "uc" && r?.useCases && /* @__PURE__ */ e("div", { className: "space-y-3", children: r.useCases.map((l) => /* @__PURE__ */ e(_, { uc: l }, l.id)) }),
    i === "br" && s?.businessRules && /* @__PURE__ */ e("div", { className: "space-y-2", children: s.businessRules.map((l) => /* @__PURE__ */ t("div", { className: "card p-4 flex items-start gap-3", children: [
      /* @__PURE__ */ t("div", { className: "flex-shrink-0 flex flex-col items-center gap-1", children: [
        /* @__PURE__ */ e("span", { className: `text-xs font-medium px-2 py-0.5 rounded ${G[l.category]}`, children: a(`brCategory.${l.category}`) }),
        /* @__PURE__ */ e("span", { className: `text-xs px-2 py-0.5 rounded ${K[l.priority]}`, children: a(`priority.${l.priority}`) })
      ] }),
      /* @__PURE__ */ t("div", { className: "flex-1 min-w-0", children: [
        /* @__PURE__ */ t("div", { className: "flex items-center gap-2 mb-1", children: [
          /* @__PURE__ */ e("span", { className: "text-xs font-mono text-[var(--color-primary-600)]", children: l.id }),
          /* @__PURE__ */ e("span", { className: "font-medium text-sm text-[var(--text-primary)]", children: l.name })
        ] }),
        /* @__PURE__ */ e("p", { className: "text-sm text-[var(--text-secondary)]", children: l.statement }),
        l.entity && /* @__PURE__ */ t("span", { className: "text-xs text-[var(--text-tertiary)] mt-1 inline-block", children: [
          a("businessRule.entity"),
          ": ",
          l.entity
        ] })
      ] })
    ] }, l.id)) }),
    i === "entities" && s?.entities && /* @__PURE__ */ e("div", { className: "space-y-4", children: s.entities.map((l) => /* @__PURE__ */ t("div", { className: "card p-4", children: [
      /* @__PURE__ */ t("div", { className: "flex items-center gap-2 mb-2", children: [
        /* @__PURE__ */ e(w, { className: "w-4 h-4 text-[var(--color-primary-600)]" }),
        /* @__PURE__ */ e("h4", { className: "font-medium text-[var(--text-primary)]", children: l.name }),
        l.type && /* @__PURE__ */ e("span", { className: "text-xs bg-[var(--bg-tertiary)] px-2 py-0.5 rounded", children: l.type })
      ] }),
      l.description && /* @__PURE__ */ e("p", { className: "text-sm text-[var(--text-secondary)] mb-3", children: l.description }),
      (l.attributes?.length ?? 0) > 0 && /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ t("table", { className: "w-full text-sm", children: [
        /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)]", children: [
          /* @__PURE__ */ e("th", { className: "text-left py-1 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: a("entity.name") }),
          /* @__PURE__ */ e("th", { className: "text-left py-1 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: a("entity.type") }),
          /* @__PURE__ */ e("th", { className: "text-center py-1 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: a("entity.required") }),
          /* @__PURE__ */ e("th", { className: "text-center py-1 text-xs font-medium text-[var(--text-tertiary)]", children: a("entity.unique") })
        ] }) }),
        /* @__PURE__ */ e("tbody", { children: l.attributes?.map((n) => /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)] last:border-0", children: [
          /* @__PURE__ */ e("td", { className: "py-1.5 pr-4 font-mono text-xs", children: n.name }),
          /* @__PURE__ */ e("td", { className: "py-1.5 pr-4 text-[var(--text-secondary)]", children: n.type }),
          /* @__PURE__ */ e("td", { className: "py-1.5 pr-4 text-center", children: n.required ? "✓" : "" }),
          /* @__PURE__ */ e("td", { className: "py-1.5 text-center", children: n.unique ? "✓" : "" })
        ] }, n.name)) })
      ] }) }),
      (l.relationships?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { className: "mt-3 pt-3 border-t border-[var(--border-color)]", children: [
        /* @__PURE__ */ e("p", { className: "text-xs font-medium text-[var(--text-tertiary)] mb-1", children: a("entity.relationships") }),
        /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: l.relationships?.map((n) => /* @__PURE__ */ t("span", { className: "text-xs bg-[var(--bg-tertiary)] px-2 py-1 rounded", children: [
          "→ ",
          n.target,
          " ",
          /* @__PURE__ */ t("span", { className: "text-[var(--text-tertiary)]", children: [
            "(",
            n.type,
            ")"
          ] })
        ] }, `${n.target}-${n.type}`)) })
      ] })
    ] }, l.name)) }),
    i === "permissions" && r?.permissionMatrix && /* @__PURE__ */ t("div", { className: "space-y-4", children: [
      r.permissionMatrix.permissions && /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ t("table", { className: "w-full text-sm", children: [
        /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)]", children: [
          /* @__PURE__ */ e("th", { className: "text-left py-2 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: "Permission" }),
          /* @__PURE__ */ e("th", { className: "text-left py-2 text-xs font-medium text-[var(--text-tertiary)]", children: "Description" })
        ] }) }),
        /* @__PURE__ */ e("tbody", { children: r.permissionMatrix.permissions.map((l) => /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)] last:border-0", children: [
          /* @__PURE__ */ e("td", { className: "py-2 pr-4 font-mono text-xs text-[var(--color-primary-600)]", children: l.path }),
          /* @__PURE__ */ e("td", { className: "py-2 text-[var(--text-secondary)]", children: l.description })
        ] }, l.path)) })
      ] }) }),
      r.permissionMatrix.roleAssignments && r.permissionMatrix.roleAssignments.length > 0 && /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ e("h4", { className: "text-sm font-medium mb-2", children: "Role Assignments" }),
        /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ t("table", { className: "w-full text-sm", children: [
          /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)]", children: [
            /* @__PURE__ */ e("th", { className: "text-left py-2 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: "Role" }),
            /* @__PURE__ */ e("th", { className: "text-left py-2 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: "Level" }),
            /* @__PURE__ */ e("th", { className: "text-left py-2 text-xs font-medium text-[var(--text-tertiary)]", children: "Permissions" })
          ] }) }),
          /* @__PURE__ */ e("tbody", { children: r.permissionMatrix.roleAssignments.map((l) => /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)] last:border-0", children: [
            /* @__PURE__ */ e("td", { className: "py-2 pr-4 font-medium", children: l.role }),
            /* @__PURE__ */ e("td", { className: "py-2 pr-4", children: /* @__PURE__ */ e("span", { className: "text-xs bg-[var(--bg-tertiary)] px-2 py-0.5 rounded", children: l.level }) }),
            /* @__PURE__ */ e("td", { className: "py-2", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1", children: l.permissions.map((n) => /* @__PURE__ */ e("span", { className: "text-xs font-mono bg-[var(--bg-tertiary)] px-1.5 py-0.5 rounded", children: n }, n)) }) })
          ] }, l.role)) })
        ] }) })
      ] })
    ] })
  ] });
}
const Y = {
  domain: "🏗️",
  application: "⚙️",
  infrastructure: "🔧",
  api: "🌐",
  frontend: "🖥️",
  seedData: "🌱",
  tests: "🧪"
};
function W({ category: r, files: s, t: a }) {
  return s.length ? /* @__PURE__ */ t("div", { className: "card p-4", children: [
    /* @__PURE__ */ t("h4", { className: "text-sm font-semibold mb-2 flex items-center gap-2", children: [
      /* @__PURE__ */ e("span", { children: Y[r] || "📁" }),
      a(`fileCategory.${r}`),
      /* @__PURE__ */ e("span", { className: "text-xs bg-[var(--bg-tertiary)] px-1.5 py-0.5 rounded-full", children: s.length })
    ] }),
    /* @__PURE__ */ e("div", { className: "space-y-1", children: s.map((i) => /* @__PURE__ */ t("div", { className: "flex items-start gap-2 text-sm", children: [
      /* @__PURE__ */ e("code", { className: "text-xs font-mono text-[var(--color-primary-600)] bg-[var(--bg-secondary)] px-1.5 py-0.5 rounded break-all", children: i.path }),
      i.description && /* @__PURE__ */ e("span", { className: "text-[var(--text-tertiary)] text-xs flex-shrink-0", children: i.description })
    ] }, i.path)) })
  ] }) : null;
}
function z({ handoff: r }) {
  const { t: s } = x("ba");
  return r ? /* @__PURE__ */ t("div", { className: "space-y-8", children: [
    /* @__PURE__ */ t("div", { className: "grid grid-cols-2 md:grid-cols-4 gap-4", children: [
      r.complexity && /* @__PURE__ */ t("div", { className: "card p-4 text-center", children: [
        /* @__PURE__ */ e("p", { className: "text-xs text-[var(--text-tertiary)] mb-1", children: s("handoff.complexity") }),
        /* @__PURE__ */ e("p", { className: "text-lg font-bold text-[var(--text-primary)]", children: r.complexity })
      ] }),
      r.implementationStrategy && /* @__PURE__ */ t("div", { className: "card p-4 text-center", children: [
        /* @__PURE__ */ e("p", { className: "text-xs text-[var(--text-tertiary)] mb-1", children: s("handoff.strategy") }),
        /* @__PURE__ */ e("p", { className: "text-lg font-bold text-[var(--text-primary)]", children: r.implementationStrategy })
      ] }),
      r.totalFiles != null && /* @__PURE__ */ t("div", { className: "card p-4 text-center", children: [
        /* @__PURE__ */ e("p", { className: "text-xs text-[var(--text-tertiary)] mb-1", children: s("handoff.totalFiles") }),
        /* @__PURE__ */ e("p", { className: "text-lg font-bold text-[var(--color-primary-600)]", children: r.totalFiles })
      ] }),
      r.totalTasks != null && /* @__PURE__ */ t("div", { className: "card p-4 text-center", children: [
        /* @__PURE__ */ e("p", { className: "text-xs text-[var(--text-tertiary)] mb-1", children: s("handoff.totalTasks") }),
        /* @__PURE__ */ e("p", { className: "text-lg font-bold text-[var(--color-primary-600)]", children: r.totalTasks })
      ] })
    ] }),
    r.filesToCreate && /* @__PURE__ */ t("div", { children: [
      /* @__PURE__ */ t("h3", { className: "text-lg font-semibold mb-3 flex items-center gap-2", children: [
        /* @__PURE__ */ e(D, { className: "w-5 h-5 text-[var(--color-primary-600)]" }),
        s("handoff.filesToCreate")
      ] }),
      /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: Object.entries(r.filesToCreate).map(
        ([a, i]) => (i?.length ?? 0) > 0 && /* @__PURE__ */ e(W, { category: a, files: i ?? [], t: s }, a)
      ) })
    ] }),
    (r.apiEndpointSummary?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { children: [
      /* @__PURE__ */ t("h3", { className: "text-lg font-semibold mb-3 flex items-center gap-2", children: [
        /* @__PURE__ */ e(I, { className: "w-5 h-5 text-[var(--color-primary-600)]" }),
        s("handoff.apiEndpoints")
      ] }),
      /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ t("table", { className: "w-full text-sm", children: [
        /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)]", children: [
          /* @__PURE__ */ e("th", { className: "text-left py-2 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: "Method" }),
          /* @__PURE__ */ e("th", { className: "text-left py-2 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: "Route" }),
          /* @__PURE__ */ e("th", { className: "text-left py-2 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: "Operation" }),
          /* @__PURE__ */ e("th", { className: "text-left py-2 text-xs font-medium text-[var(--text-tertiary)]", children: "Permission" })
        ] }) }),
        /* @__PURE__ */ e("tbody", { children: r.apiEndpointSummary?.map((a) => /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)] last:border-0", children: [
          /* @__PURE__ */ e("td", { className: `py-2 pr-4 font-mono text-xs font-bold ${{
            GET: "text-green-600",
            POST: "text-blue-600",
            PUT: "text-orange-600",
            PATCH: "text-yellow-600",
            DELETE: "text-red-600"
          }[a.method] || ""}`, children: a.method }),
          /* @__PURE__ */ e("td", { className: "py-2 pr-4 font-mono text-xs", children: a.route }),
          /* @__PURE__ */ e("td", { className: "py-2 pr-4 text-[var(--text-secondary)]", children: a.operation }),
          /* @__PURE__ */ e("td", { className: "py-2 font-mono text-xs text-[var(--text-tertiary)]", children: a.permission })
        ] }, `${a.method}-${a.route}`)) })
      ] }) })
    ] }),
    (r.brToCodeMapping?.length ?? 0) > 0 && /* @__PURE__ */ t("div", { children: [
      /* @__PURE__ */ t("h3", { className: "text-lg font-semibold mb-3 flex items-center gap-2", children: [
        /* @__PURE__ */ e(H, { className: "w-5 h-5 text-[var(--color-primary-600)]" }),
        s("handoff.brMapping")
      ] }),
      /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ t("table", { className: "w-full text-sm", children: [
        /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)]", children: [
          /* @__PURE__ */ e("th", { className: "text-left py-2 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: "Rule" }),
          /* @__PURE__ */ e("th", { className: "text-left py-2 pr-4 text-xs font-medium text-[var(--text-tertiary)]", children: "File" }),
          /* @__PURE__ */ e("th", { className: "text-left py-2 text-xs font-medium text-[var(--text-tertiary)]", children: "Method" })
        ] }) }),
        /* @__PURE__ */ e("tbody", { children: r.brToCodeMapping?.map((a) => /* @__PURE__ */ t("tr", { className: "border-b border-[var(--border-color)] last:border-0", children: [
          /* @__PURE__ */ t("td", { className: "py-2 pr-4", children: [
            /* @__PURE__ */ e("span", { className: "font-mono text-xs text-[var(--color-primary-600)]", children: a.ruleId }),
            a.ruleName && /* @__PURE__ */ e("span", { className: "text-xs text-[var(--text-tertiary)] ml-2", children: a.ruleName })
          ] }),
          /* @__PURE__ */ e("td", { className: "py-2 pr-4 font-mono text-xs break-all", children: a.targetFile }),
          /* @__PURE__ */ e("td", { className: "py-2 font-mono text-xs text-[var(--text-secondary)]", children: a.targetMethod })
        ] }, `${a.ruleId}-${a.targetFile}`)) })
      ] }) })
    ] })
  ] }) : /* @__PURE__ */ t("div", { className: "text-center py-12", children: [
    /* @__PURE__ */ e(A, { className: "w-10 h-10 text-[var(--text-tertiary)] mx-auto mb-3" }),
    /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)]", children: s("handoff.noData") })
  ] });
}
const J = [
  { id: "cadrage", icon: N, labelKey: "tabs.cadrage" },
  { id: "specification", icon: R, labelKey: "tabs.specification" },
  { id: "synthese", icon: A, labelKey: "tabs.synthese" }
], T = {
  draft: "bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300",
  analysed: "bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300",
  specified: "bg-indigo-100 text-indigo-700 dark:bg-indigo-900 dark:text-indigo-300",
  consolidated: "bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-300",
  "handed-off": "bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300"
};
function ae() {
  const { appCode: r, moduleCode: s } = M(), { t: a } = x("ba"), [i, c] = m(null), [d, p] = m(!0), [b, h] = m(null), [o, l] = m("cadrage");
  return $(() => {
    p(!0), h(null), C.getManifest().then((n) => {
      const g = n.analyses.find(
        (v) => v.appCode === r && (s ? v.moduleCode === s : !v.moduleCode)
      );
      if (g)
        return C.getFeature(g.path);
      throw new Error("Entry not found in manifest");
    }).then(c).catch((n) => h(n.message)).finally(() => p(!1)).catch(() => {
    });
  }, [r, s]), d ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-20", children: /* @__PURE__ */ e(j, { className: "w-8 h-8 animate-spin text-[var(--color-primary-600)]" }) }) : b || !i ? /* @__PURE__ */ t("div", { className: "space-y-4", children: [
    /* @__PURE__ */ t(u, { to: "/system/docs/ba", className: "text-sm text-[var(--color-primary-600)] hover:underline flex items-center gap-1", children: [
      /* @__PURE__ */ e(k, { className: "w-4 h-4" }),
      a("viewer.backToList")
    ] }),
    /* @__PURE__ */ e("div", { className: "text-center py-12", children: /* @__PURE__ */ t("p", { className: "text-[var(--text-secondary)]", children: [
      "Feature not found: ",
      r,
      s ? `/${s}` : ""
    ] }) })
  ] }) : /* @__PURE__ */ t("div", { className: "space-y-6", children: [
    /* @__PURE__ */ t(u, { to: "/system/docs/ba", className: "text-sm text-[var(--color-primary-600)] hover:underline flex items-center gap-1", children: [
      /* @__PURE__ */ e(k, { className: "w-4 h-4" }),
      a("viewer.backToList")
    ] }),
    /* @__PURE__ */ t("div", { className: "flex items-start justify-between", children: [
      /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ t("h1", { className: "text-2xl font-bold text-[var(--text-primary)]", children: [
          i.metadata.application,
          i.metadata.module && i.metadata.module !== i.metadata.application && /* @__PURE__ */ t("span", { className: "text-[var(--text-tertiary)]", children: [
            " / ",
            i.metadata.module
          ] })
        ] }),
        /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)] mt-1", children: i.metadata.featureDescription })
      ] }),
      /* @__PURE__ */ t("div", { className: "flex items-center gap-3 flex-shrink-0", children: [
        /* @__PURE__ */ t("span", { className: "text-sm text-[var(--text-tertiary)]", children: [
          "v",
          i.version
        ] }),
        /* @__PURE__ */ e("span", { className: `px-2.5 py-1 rounded-full text-xs font-medium ${T[i.status] || T.draft}`, children: a(`status.${i.status}`, i.status) })
      ] })
    ] }),
    /* @__PURE__ */ e("div", { className: "flex gap-1 border-b border-[var(--border-color)]", children: J.map((n) => /* @__PURE__ */ t(
      "button",
      {
        onClick: () => l(n.id),
        className: `px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 ${o === n.id ? "border-[var(--color-primary-600)] text-[var(--color-primary-600)]" : "border-transparent text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,
        children: [
          /* @__PURE__ */ e(n.icon, { className: "w-4 h-4" }),
          a(n.labelKey)
        ]
      },
      n.id
    )) }),
    /* @__PURE__ */ t("div", { children: [
      o === "cadrage" && /* @__PURE__ */ e(q, { discovery: i.discovery }),
      o === "specification" && /* @__PURE__ */ e(V, { specification: i.specification, analysis: i.analysis }),
      o === "synthese" && /* @__PURE__ */ e(z, { handoff: i.handoff })
    ] })
  ] });
}
export {
  ae as BaViewerPage
};
//# sourceMappingURL=BaViewerPage-TL6IHeQx.js.map
