// src/components/docs/shared/StudioPrompt.tsx
import Link from "@contractspec/lib.ui-link";
import { jsx, jsxs } from "react/jsx-runtime";
function StudioPrompt({
  title = "Want to turn product signals into spec-first deliverables?",
  body = "ContractSpec Studio ingests evidence from meetings, support, analytics, docs, and code, then compiles decisions into spec diffs and task packs.",
  ctaLabel = "Try Studio",
  href = "https://www.contractspec.studio"
}) {
  return /* @__PURE__ */ jsxs("div", {
    className: "card-subtle space-y-3 p-6",
    children: [
      /* @__PURE__ */ jsx("h3", {
        className: "text-lg font-semibold",
        children: title
      }),
      /* @__PURE__ */ jsx("p", {
        className: "text-muted-foreground text-sm",
        children: body
      }),
      /* @__PURE__ */ jsx(Link, {
        href,
        className: "btn-primary",
        children: ctaLabel
      })
    ]
  });
}

// src/components/docs/guides/GuideNextjsOneEndpointPage.tsx
import { CodeBlock } from "@contractspec/lib.design-system";
import Link2 from "@contractspec/lib.ui-link";
import { ChevronRight } from "lucide-react";
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
function GuideNextjsOneEndpointPage() {
  return /* @__PURE__ */ jsxs2("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs2("div", {
        className: "space-y-3",
        children: [
          /* @__PURE__ */ jsx2("h1", {
            className: "text-4xl font-bold",
            children: "Next.js: add one endpoint"
          }),
          /* @__PURE__ */ jsx2("p", {
            className: "text-muted-foreground text-lg",
            children: "Add ContractSpec to an existing Next.js App Router project by wiring a single operation end-to-end with validation and types."
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "card-subtle space-y-4 p-6",
        children: [
          /* @__PURE__ */ jsx2("h2", {
            className: "text-2xl font-bold",
            children: "What you'll build"
          }),
          /* @__PURE__ */ jsxs2("ul", {
            className: "text-muted-foreground space-y-2 text-sm",
            children: [
              /* @__PURE__ */ jsx2("li", {
                children: "One OperationSpec with SchemaModel validation."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "A registry wiring the operation to its handler."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "A Next.js route handler that exposes the operation."
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "space-y-6",
        children: [
          /* @__PURE__ */ jsxs2("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx2("h2", {
                className: "text-2xl font-bold",
                children: "1) Install core packages"
              }),
              /* @__PURE__ */ jsx2(CodeBlock, {
                language: "bash",
                filename: "nextjs-install",
                code: `bun add -D contractspec
bun add @contractspec/lib.contracts-spec @contractspec/lib.contracts-runtime-server-rest @contractspec/lib.schema`
              }),
              /* @__PURE__ */ jsxs2("p", {
                className: "text-muted-foreground text-sm",
                children: [
                  "Expected output: ",
                  /* @__PURE__ */ jsx2("code", {
                    children: "added 3 packages"
                  }),
                  " and a lockfile update."
                ]
              })
            ]
          }),
          /* @__PURE__ */ jsxs2("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx2("h2", {
                className: "text-2xl font-bold",
                children: "2) Define the operation spec"
              }),
              /* @__PURE__ */ jsxs2("p", {
                className: "text-muted-foreground text-sm",
                children: [
                  "Create ",
                  /* @__PURE__ */ jsx2("code", {
                    children: "src/contracts/healthcheck.operation.ts"
                  }),
                  ":"
                ]
              }),
              /* @__PURE__ */ jsx2(CodeBlock, {
                language: "typescript",
                filename: "src/contracts/healthcheck.operation.ts",
                code: `import { defineQuery } from "@contractspec/lib.contracts-spec/operations";
import { SchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";

const HealthcheckOutput = new SchemaModel({
  name: "HealthcheckOutput",
  fields: {
    status: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
    checkedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
  },
});

export const HealthcheckQuery = defineQuery({
  meta: {
    key: "healthcheck.get",
    version: "1.0.0",
    description: "Return service health status",
    owners: ["@platform.core"],
    tags: ["health", "observability"],
  },
  io: {
    input: null,
    output: HealthcheckOutput,
  },
  policy: {
    auth: "public",
  },
  transport: {
    rest: { method: "GET" },
    gql: { field: "healthcheck_get" },
    mcp: { toolName: "healthcheck_get-v1" },
  },
});`
              })
            ]
          }),
          /* @__PURE__ */ jsxs2("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx2("h2", {
                className: "text-2xl font-bold",
                children: "3) Register the operation"
              }),
              /* @__PURE__ */ jsxs2("p", {
                className: "text-muted-foreground text-sm",
                children: [
                  "Create ",
                  /* @__PURE__ */ jsx2("code", {
                    children: "src/contracts/registry.ts"
                  }),
                  ":"
                ]
              }),
              /* @__PURE__ */ jsx2(CodeBlock, {
                language: "typescript",
                filename: "src/contracts/registry.ts",
                code: `import {
  OperationSpecRegistry,
  installOp,
} from "@contractspec/lib.contracts-spec/operations";
import { HealthcheckQuery } from "./healthcheck.operation";

export const registry = new OperationSpecRegistry();

installOp(registry, HealthcheckQuery, async () => ({
  status: "ok",
  checkedAt: new Date().toISOString(),
}));`
              })
            ]
          }),
          /* @__PURE__ */ jsxs2("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx2("h2", {
                className: "text-2xl font-bold",
                children: "4) Add the Next.js handler"
              }),
              /* @__PURE__ */ jsxs2("p", {
                className: "text-muted-foreground text-sm",
                children: [
                  "Create ",
                  /* @__PURE__ */ jsx2("code", {
                    children: "app/api/ops/[...route]/route.ts"
                  }),
                  ":"
                ]
              }),
              /* @__PURE__ */ jsx2(CodeBlock, {
                language: "typescript",
                filename: "app/api/ops/[...route]/route.ts",
                code: `import { makeNextAppHandler } from "@contractspec/lib.contracts-runtime-server-rest/rest-next-app";
import { registry } from "@/contracts/registry";

const handler = makeNextAppHandler(registry, async () => ({
  actor: "public",
  tenantId: "public",
}));

export { handler as GET, handler as POST };`
              }),
              /* @__PURE__ */ jsxs2("p", {
                className: "text-muted-foreground text-sm",
                children: [
                  "Expected output: the route responds at",
                  /* @__PURE__ */ jsx2("code", {
                    children: " /api/ops/healthcheck.get"
                  }),
                  "."
                ]
              })
            ]
          }),
          /* @__PURE__ */ jsxs2("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx2("h2", {
                className: "text-2xl font-bold",
                children: "5) Validate the spec"
              }),
              /* @__PURE__ */ jsx2(CodeBlock, {
                language: "bash",
                filename: "nextjs-validate",
                code: `contractspec validate src/contracts/healthcheck.operation.ts`
              }),
              /* @__PURE__ */ jsxs2("p", {
                className: "text-muted-foreground text-sm",
                children: [
                  "Expected output: ",
                  /* @__PURE__ */ jsx2("code", {
                    children: "Validation passed"
                  }),
                  "."
                ]
              })
            ]
          }),
          /* @__PURE__ */ jsxs2("div", {
            className: "card-subtle space-y-3 p-6",
            children: [
              /* @__PURE__ */ jsx2("h3", {
                className: "text-lg font-semibold",
                children: "Example package"
              }),
              /* @__PURE__ */ jsxs2("p", {
                className: "text-muted-foreground text-sm",
                children: [
                  "Use ",
                  /* @__PURE__ */ jsx2("code", {
                    children: "@contractspec/example.lifecycle-dashboard"
                  }),
                  " as a lightweight Next.js snippet reference."
                ]
              }),
              /* @__PURE__ */ jsx2(CodeBlock, {
                language: "bash",
                filename: "nextjs-example",
                code: `# Inspect the example docs
contractspec examples show lifecycle-dashboard

# Validate all example manifests in this repo
contractspec examples validate --repo-root .`
              })
            ]
          }),
          /* @__PURE__ */ jsx2(StudioPrompt, {
            title: "Want real product evidence behind endpoint changes?",
            body: "Studio correlates meetings, support, analytics, and code signals before compiling endpoint decisions into spec diffs."
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsxs2(Link2, {
            href: "/docs/guides/spec-validation-and-typing",
            className: "btn-primary",
            children: [
              "Next: Spec validation + typing ",
              /* @__PURE__ */ jsx2(ChevronRight, {
                size: 16
              })
            ]
          }),
          /* @__PURE__ */ jsx2(Link2, {
            href: "/docs/guides",
            className: "btn-ghost",
            children: "Back to guides"
          })
        ]
      })
    ]
  });
}
export {
  GuideNextjsOneEndpointPage
};
