// src/features/docs/docs.contracts.ts
import {
  DocSummaryModel,
  DocsIndexInput,
  DocsIndexOutput,
  DocsIndexQuery,
  DocsIndexQuery as DocsIndexQuery2,
  ContractReferenceQuery
} from "@contractspec/lib.contracts-spec/docs";
// src/features/contracts-registry.ts
import {
  OperationSpecRegistry,
  EventRegistry
} from "@contractspec/lib.contracts-spec";
import {
  PresentationRegistry
} from "@contractspec/lib.contracts-spec/presentations";
import {
  DataViewRegistry
} from "@contractspec/lib.contracts-spec/data-views";
import { FormRegistry } from "@contractspec/lib.contracts-spec/forms";
import {
  serializeOperationSpec,
  serializeEventSpec,
  serializePresentationSpec,
  serializeDataViewSpec,
  serializeFormSpec
} from "@contractspec/lib.contracts-spec/serialization";
import {
  ContractReferenceDataView,
  ContractReferenceQuery as ContractReferenceQuery2,
  DocsGeneratedEvent,
  DocsGenerateCommand,
  DocsIndexDataView,
  DocsIndexQuery as DocsIndexQuery3,
  DocsLayoutPresentation,
  DocsPublishedEvent,
  DocsPublishCommand,
  DocsReferencePagePresentation,
  DocsSearchForm,
  ExampleCatalogDataView
} from "@contractspec/lib.contracts-spec/docs";
var operationRegistry = null;
function createContractSpecOperationRegistry() {
  const registry = new OperationSpecRegistry;
  registry.register(DocsIndexQuery3).register(ContractReferenceQuery2).register(DocsGenerateCommand).register(DocsPublishCommand);
  return registry;
}
function getContractSpecOperationRegistry() {
  if (!operationRegistry) {
    operationRegistry = createContractSpecOperationRegistry();
  }
  return operationRegistry;
}
function resolveOperationSpec(key, version) {
  return getContractSpecOperationRegistry().get(key, version);
}
var eventRegistry = null;
function createContractSpecEventRegistry() {
  const registry = new EventRegistry;
  registry.register(DocsGeneratedEvent).register(DocsPublishedEvent);
  return registry;
}
function getContractSpecEventRegistry() {
  if (!eventRegistry) {
    eventRegistry = createContractSpecEventRegistry();
  }
  return eventRegistry;
}
function resolveEventSpec(key, version) {
  return getContractSpecEventRegistry().get(key, version);
}
var presentationRegistry = null;
function createContractSpecPresentationRegistry() {
  const registry = new PresentationRegistry;
  registry.register(DocsLayoutPresentation).register(DocsReferencePagePresentation);
  return registry;
}
function getContractSpecPresentationRegistry() {
  if (!presentationRegistry) {
    presentationRegistry = createContractSpecPresentationRegistry();
  }
  return presentationRegistry;
}
function resolvePresentationSpec(key, version) {
  return getContractSpecPresentationRegistry().get(key, version);
}
var dataViewRegistry = null;
function createContractSpecDataViewRegistry() {
  const registry = new DataViewRegistry;
  registry.register(DocsIndexDataView).register(ContractReferenceDataView).register(ExampleCatalogDataView);
  return registry;
}
function getContractSpecDataViewRegistry() {
  if (!dataViewRegistry) {
    dataViewRegistry = createContractSpecDataViewRegistry();
  }
  return dataViewRegistry;
}
function resolveDataViewSpec(key, version) {
  return getContractSpecDataViewRegistry().get(key, version);
}
var formRegistry = null;
function createContractSpecFormRegistry() {
  const registry = new FormRegistry;
  registry.register(DocsSearchForm);
  return registry;
}
function getContractSpecFormRegistry() {
  if (!formRegistry) {
    formRegistry = createContractSpecFormRegistry();
  }
  return formRegistry;
}
function resolveFormSpec(key, _version) {
  return getContractSpecFormRegistry().get(key);
}
function resolveSerializedOperationSpec(key, version) {
  const spec = resolveOperationSpec(key, version);
  return serializeOperationSpec(spec) ?? undefined;
}
function resolveSerializedEventSpec(key, version) {
  const spec = resolveEventSpec(key, version);
  return serializeEventSpec(spec) ?? undefined;
}
function resolveSerializedPresentationSpec(key, version) {
  const spec = resolvePresentationSpec(key, version);
  return serializePresentationSpec(spec) ?? undefined;
}
function resolveSerializedDataViewSpec(key, version) {
  const spec = resolveDataViewSpec(key, version);
  return serializeDataViewSpec(spec) ?? undefined;
}
function resolveSerializedFormSpec(key, version) {
  const spec = resolveFormSpec(key, version);
  return serializeFormSpec(spec) ?? undefined;
}
function resetContractSpecOperationRegistry() {
  operationRegistry = null;
}
function resetContractSpecEventRegistry() {
  eventRegistry = null;
}
function resetContractSpecPresentationRegistry() {
  presentationRegistry = null;
}
function resetContractSpecDataViewRegistry() {
  dataViewRegistry = null;
}
function resetContractSpecFormRegistry() {
  formRegistry = null;
}
function resetAllContractSpecRegistries() {
  resetContractSpecOperationRegistry();
  resetContractSpecEventRegistry();
  resetContractSpecPresentationRegistry();
  resetContractSpecDataViewRegistry();
  resetContractSpecFormRegistry();
}

// src/features/docs.feature.ts
var DocsFeature = {
  meta: {
    key: "contractspec.docs",
    version: "1.0.0",
    title: "Documentation",
    description: "Comprehensive documentation system for ContractSpec",
    domain: "platform",
    owners: ["@platform.docs"],
    tags: ["documentation", "guides", "api-reference"],
    stability: "stable"
  },
  operations: [
    { key: "docs.search", version: "1.0.0" },
    { key: "docs.navigate", version: "1.0.0" }
  ],
  events: [
    { key: "docs.page_viewed", version: "1.0.0" },
    { key: "docs.search_performed", version: "1.0.0" }
  ],
  presentations: [
    { key: "docs.landing", version: "1.0.0" },
    { key: "docs.getting-started", version: "1.0.0" },
    { key: "docs.architecture", version: "1.0.0" }
  ],
  capabilities: {
    provides: [{ key: "contracts.docs", version: "1.0.0" }],
    requires: []
  }
};

// src/features/mcp.feature.ts
var MCPFeature = {
  meta: {
    key: "contractspec.mcp",
    version: "1.0.0",
    title: "MCP Integration",
    description: "Model Context Protocol server for AI agent integration",
    domain: "platform",
    owners: ["@platform.mcp"],
    tags: ["mcp", "ai-agents", "tooling"],
    stability: "beta"
  },
  operations: [
    { key: "mcp.tool.register", version: "1.0.0" },
    { key: "mcp.resource.register", version: "1.0.0" },
    { key: "mcp.prompt.register", version: "1.0.0" }
  ],
  events: [
    { key: "mcp.tool_invoked", version: "1.0.0" },
    { key: "mcp.resource_accessed", version: "1.0.0" }
  ],
  presentations: [],
  capabilities: {
    provides: [{ key: "contracts.mcp", version: "1.0.0" }],
    requires: [{ key: "contracts.operations", version: "1.0.0" }]
  }
};

// src/features/presentations.feature.ts
var PresentationsFeature = {
  meta: {
    key: "contractspec.presentations",
    version: "1.0.0",
    title: "Presentation Runtime",
    description: "Cross-platform rendering of contract-driven UI",
    domain: "platform",
    owners: ["@platform.presentations"],
    tags: ["presentations", "ui", "rendering", "cross-platform"],
    stability: "beta"
  },
  operations: [
    { key: "presentation.render", version: "1.0.0" },
    { key: "presentation.transform", version: "1.0.0" }
  ],
  events: [
    { key: "presentation.rendered", version: "1.0.0" },
    { key: "presentation.transformed", version: "1.0.0" }
  ],
  presentations: [
    { key: "form.standard", version: "1.0.0" },
    { key: "list.standard", version: "1.0.0" },
    { key: "detail.standard", version: "1.0.0" }
  ],
  capabilities: {
    provides: [{ key: "contracts.presentations", version: "1.0.0" }],
    requires: []
  }
};

// src/features/registry.ts
import { FeatureRegistry } from "@contractspec/lib.contracts-spec/features";
import { AppConfigFeature } from "@contractspec/lib.contracts-spec/app-config";
function createContractSpecFeatureRegistry() {
  const features = new FeatureRegistry;
  features.register(DocsFeature);
  features.register(MCPFeature);
  features.register(PresentationsFeature);
  features.register(AppConfigFeature);
  return features;
}
var registryInstance = null;
function getContractSpecFeatureRegistry() {
  if (!registryInstance) {
    registryInstance = createContractSpecFeatureRegistry();
  }
  return registryInstance;
}
function resetContractSpecFeatureRegistry() {
  registryInstance = null;
}

// src/features/index.ts
import { FeatureRegistry as FeatureRegistry2 } from "@contractspec/lib.contracts-spec/features";

// src/presentation/features/organisms/FeatureFormsList.tsx
import { EntityCard } from "@contractspec/lib.design-system";
import { FormInput } from "lucide-react";
import { jsx } from "react/jsx-runtime";
"use client";
function FeatureFormsList({ feature }) {
  if (!feature.forms?.length)
    return null;
  return /* @__PURE__ */ jsx("div", {
    className: "grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",
    children: feature.forms.map((form) => {
      const spec = resolveSerializedFormSpec(form.key, form.version);
      return /* @__PURE__ */ jsx(EntityCard, {
        cardTitle: form.key,
        cardSubtitle: form.version ? `v${form.version}` : undefined,
        footer: spec?.meta.description,
        icon: /* @__PURE__ */ jsx(FormInput, {
          className: "h-4 w-4"
        }),
        href: `/features/${feature.meta.key}/forms/${form.key}`
      }, form.key);
    })
  });
}

// src/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.tsx
import {
  PageHeaderResponsive,
  Breadcrumbs
} from "@contractspec/lib.design-system";
import { VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
"use client";
function FeatureFormsTemplate({
  feature,
  className
}) {
  return /* @__PURE__ */ jsxs(VStack, {
    gap: "lg",
    className: cn("mx-auto w-full max-w-5xl p-6", className),
    children: [
      /* @__PURE__ */ jsx2(PageHeaderResponsive, {
        title: "Forms",
        subtitle: `Forms defined in ${feature.meta.title ?? feature.meta.key}`,
        breadcrumb: /* @__PURE__ */ jsx2(Breadcrumbs, {
          items: [
            { label: "Features", href: "/features" },
            {
              label: feature.meta.title || feature.meta.key,
              href: `/features/${feature.meta.key}`
            },
            { label: "Forms" }
          ]
        })
      }),
      /* @__PURE__ */ jsx2(FeatureFormsList, {
        feature
      })
    ]
  });
}
export {
  FeatureFormsTemplate
};
