// src/components/docs/libraries/LibrariesEvolutionPage.tsx
import { CodeBlock, InstallCommand } from "@contractspec/lib.design-system";
import Link from "@contractspec/lib.ui-link";
import { ChevronRight } from "lucide-react";
import { jsx, jsxs } from "react/jsx-runtime";
function LibrariesEvolutionPage() {
  return /* @__PURE__ */ jsxs("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h1", {
            className: "text-4xl font-bold",
            children: "@contractspec/lib.evolution"
          }),
          /* @__PURE__ */ jsx("p", {
            className: "text-muted-foreground text-lg",
            children: "Analyze production telemetry, surface anomalies, and turn them into AI-reviewed spec proposals that can be approved, rolled out, or reverted."
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Installation"
          }),
          /* @__PURE__ */ jsx(InstallCommand, {
            package: "@contractspec/lib.evolution"
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-3",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "From telemetry to intent"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `import { SpecAnalyzer } from '@contractspec/lib.evolution/analyzer';
import { EvolutionPipeline } from '@contractspec/lib.observability';

const analyzer = new SpecAnalyzer();
const pipeline = new EvolutionPipeline({
  onIntent: (intent) => console.log('[intent]', intent),
});

// feed telemetry samples from tracing middleware
pipeline.ingest({
  operation: { name: 'billing.createInvoice', version: 4 },
  durationMs: 612,
  success: false,
  timestamp: new Date(),
  errorCode: 'VALIDATION_FAILED',
});`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-3",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Generate & approve suggestions"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `import {
  SpecGenerator,
  SpecSuggestionOrchestrator,
  InMemorySpecSuggestionRepository,
} from '@contractspec/lib.evolution';

const generator = new SpecGenerator();
const repository = new InMemorySpecSuggestionRepository();
const orchestrator = new SpecSuggestionOrchestrator({ repository });

const suggestion = generator.generateFromIntent(intentPattern, {
  summary: 'Add PO number requirement for acme.corp',
});

await orchestrator.submit(suggestion, sessionState);`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-3",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Write approved specs back to git"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `import { FileSystemSuggestionWriter } from '@contractspec/lib.evolution/approval';

const writer = new FileSystemSuggestionWriter({
  outputDir:
    'packages/libs/contracts-spec/src/generated',
});

await writer.write({
  ...suggestion,
  status: 'approved',
  approvals: { reviewer: 'ops@contractspec', decidedAt: new Date() },
});`
          })
        ]
      }),
      /* @__PURE__ */ jsx("div", {
        className: "grid gap-4 md:grid-cols-2",
        children: [
          {
            title: "Approvals by default",
            description: "Every suggestion flows through @contractspec/lib.ai-agent's ApprovalWorkflow. Tune auto-approval thresholds per environment."
          },
          {
            title: "Pluggable storage",
            description: "Use the Prisma repository in production, in-memory for tests, or stream serialized suggestions into your own queue."
          }
        ].map((card) => /* @__PURE__ */ jsxs("div", {
          className: "card-subtle space-y-2 p-4",
          children: [
            /* @__PURE__ */ jsx("h3", {
              className: "text-lg font-semibold",
              children: card.title
            }),
            /* @__PURE__ */ jsx("p", {
              className: "text-muted-foreground text-sm",
              children: card.description
            })
          ]
        }, card.title))
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsx(Link, {
            href: "/docs/libraries",
            className: "btn-ghost",
            children: "Back to Libraries"
          }),
          /* @__PURE__ */ jsxs(Link, {
            href: "/docs/libraries/observability",
            className: "btn-primary",
            children: [
              "Next: Observability ",
              /* @__PURE__ */ jsx(ChevronRight, {
                size: 16
              })
            ]
          })
        ]
      })
    ]
  });
}
export {
  LibrariesEvolutionPage
};
