// 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/atoms/FeatureIcon/FeatureIcon.tsx
import * as React from "react";
import {
  FileText,
  Boxes,
  Settings,
  Globe,
  Shield,
  Database,
  MessageSquare,
  Layout,
  Workflow
} from "lucide-react";
import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
import { jsx } from "react/jsx-runtime";
"use client";
var domainIconMap = {
  platform: Settings,
  documentation: FileText,
  docs: FileText,
  integration: Workflow,
  api: Globe,
  security: Shield,
  data: Database,
  messaging: MessageSquare,
  ui: Layout,
  presentation: Layout
};
var tagIconMap = {
  documentation: FileText,
  guides: FileText,
  "api-reference": Globe,
  presentations: Layout,
  ui: Layout,
  rendering: Layout,
  mcp: Workflow,
  integration: Workflow,
  security: Shield,
  auth: Shield,
  data: Database,
  storage: Database
};
var stabilityToneMap = {
  stable: "success",
  beta: "warning",
  experimental: "info",
  deprecated: "danger"
};
var sizeClasses = {
  sm: "h-4 w-4",
  md: "h-5 w-5",
  lg: "h-6 w-6"
};
function FeatureIcon({
  domain,
  tags = [],
  stability,
  icon: IconOverride,
  size = "md",
  className
}) {
  const Icon = React.useMemo(() => {
    if (IconOverride)
      return IconOverride;
    if (domain) {
      const domainIcon = domainIconMap[domain.toLowerCase()];
      if (domainIcon)
        return domainIcon;
    }
    for (const tag of tags) {
      const tagIcon = tagIconMap[tag.toLowerCase()];
      if (tagIcon)
        return tagIcon;
    }
    return Boxes;
  }, [domain, tags, IconOverride]);
  const tone = stability ? stabilityToneMap[stability] || "primary" : "primary";
  const toneClasses = {
    success: "text-emerald-600 dark:text-emerald-400",
    warning: "text-amber-600 dark:text-amber-400",
    info: "text-blue-600 dark:text-blue-400",
    danger: "text-red-600 dark:text-red-400",
    primary: "text-primary"
  };
  return /* @__PURE__ */ jsx(Icon, {
    className: cn(sizeClasses[size], toneClasses[tone], className)
  });
}
function getFeatureIconTone(stability) {
  if (!stability)
    return "primary";
  return stabilityToneMap[stability] || "primary";
}
// src/presentation/features/hooks/useFeatureRegistry.ts
import { useMemo as useMemo2 } from "react";
"use client";
function useFeatureRegistry() {
  const registry = useMemo2(() => getContractSpecFeatureRegistry(), []);
  return useMemo2(() => {
    const features = registry.list();
    return {
      features,
      getFeature: (key) => registry.get(key),
      getByTag: (tag) => registry.listByTag(tag),
      getByOwner: (owner) => registry.listByOwner(owner),
      getUniqueTags: () => registry.getUniqueTags(),
      getUniqueDomains: () => {
        const domains = new Set;
        for (const f of features) {
          if (f.meta.domain)
            domains.add(f.meta.domain);
        }
        return [...domains].sort();
      },
      getUniqueStabilities: () => {
        const stabilities = new Set;
        for (const f of features) {
          if (f.meta.stability)
            stabilities.add(f.meta.stability);
        }
        return [...stabilities].sort();
      }
    };
  }, [registry]);
}

// src/presentation/features/hooks/useFeatureFilters.ts
import { useState, useMemo as useMemo3, useCallback } from "react";
"use client";
var defaultFilters = {
  search: "",
  tags: [],
  stability: [],
  domain: []
};
function useFeatureFilters(features) {
  const [filters, setFilters] = useState(defaultFilters);
  const setSearch = useCallback((search) => {
    setFilters((prev) => ({ ...prev, search }));
  }, []);
  const toggleTag = useCallback((tag) => {
    setFilters((prev) => ({
      ...prev,
      tags: prev.tags.includes(tag) ? prev.tags.filter((t) => t !== tag) : [...prev.tags, tag]
    }));
  }, []);
  const toggleStability = useCallback((stability) => {
    setFilters((prev) => ({
      ...prev,
      stability: prev.stability.includes(stability) ? prev.stability.filter((s) => s !== stability) : [...prev.stability, stability]
    }));
  }, []);
  const toggleDomain = useCallback((domain) => {
    setFilters((prev) => ({
      ...prev,
      domain: prev.domain.includes(domain) ? prev.domain.filter((d) => d !== domain) : [...prev.domain, domain]
    }));
  }, []);
  const clearFilters = useCallback(() => setFilters(defaultFilters), []);
  const hasActiveFilters = useMemo3(() => {
    return filters.search.length > 0 || filters.tags.length > 0 || filters.stability.length > 0 || filters.domain.length > 0;
  }, [filters]);
  const filteredFeatures = useMemo3(() => {
    return features.filter((feature) => {
      if (filters.search) {
        const searchLower = filters.search.toLowerCase();
        const title = feature.meta.title ?? "";
        const matches = title.toLowerCase().includes(searchLower) || feature.meta.description?.toLowerCase().includes(searchLower) || feature.meta.key.toLowerCase().includes(searchLower);
        if (!matches)
          return false;
      }
      if (filters.tags.length > 0) {
        const hasTag = filters.tags.some((tag) => feature.meta.tags?.includes(tag));
        if (!hasTag)
          return false;
      }
      if (filters.stability.length > 0) {
        if (!filters.stability.includes(feature.meta.stability ?? "unknown"))
          return false;
      }
      if (filters.domain.length > 0) {
        if (!filters.domain.includes(feature.meta.domain ?? "unknown"))
          return false;
      }
      return true;
    });
  }, [features, filters]);
  return {
    filters,
    setSearch,
    toggleTag,
    toggleStability,
    toggleDomain,
    clearFilters,
    filteredFeatures,
    hasActiveFilters
  };
}

// src/presentation/features/molecules/FeatureHoverPreview/FeatureHoverPreview.tsx
import { StatusChip } from "@contractspec/lib.design-system";
import { HStack } from "@contractspec/lib.ui-kit-web/ui/stack";
import {
  ArrowRight,
  Layout as Layout2,
  Radio,
  Shield as Shield2,
  Tag,
  Users,
  Zap
} from "lucide-react";
import { jsx as jsx2, jsxs, Fragment } from "react/jsx-runtime";
"use client";
function FeatureHoverPreview({ feature }) {
  const { meta, operations, events, presentations, capabilities } = feature;
  const hasCapabilities = capabilities?.provides?.length || capabilities?.requires?.length;
  return /* @__PURE__ */ jsxs(Fragment, {
    children: [
      meta.description && /* @__PURE__ */ jsx2("p", {
        className: "text-muted-foreground text-sm leading-relaxed",
        children: meta.description
      }),
      /* @__PURE__ */ jsxs(HStack, {
        gap: "md",
        className: "py-2",
        children: [
          operations?.length ? /* @__PURE__ */ jsxs("div", {
            className: "flex items-center gap-1.5 text-sm",
            children: [
              /* @__PURE__ */ jsx2(Zap, {
                className: "h-4 w-4 text-amber-500"
              }),
              /* @__PURE__ */ jsx2("span", {
                className: "font-medium",
                children: operations.length
              }),
              /* @__PURE__ */ jsx2("span", {
                className: "text-muted-foreground",
                children: "ops"
              })
            ]
          }) : null,
          events?.length ? /* @__PURE__ */ jsxs("div", {
            className: "flex items-center gap-1.5 text-sm",
            children: [
              /* @__PURE__ */ jsx2(Radio, {
                className: "h-4 w-4 text-blue-500"
              }),
              /* @__PURE__ */ jsx2("span", {
                className: "font-medium",
                children: events.length
              }),
              /* @__PURE__ */ jsx2("span", {
                className: "text-muted-foreground",
                children: "events"
              })
            ]
          }) : null,
          presentations?.length ? /* @__PURE__ */ jsxs("div", {
            className: "flex items-center gap-1.5 text-sm",
            children: [
              /* @__PURE__ */ jsx2(Layout2, {
                className: "h-4 w-4 text-purple-500"
              }),
              /* @__PURE__ */ jsx2("span", {
                className: "font-medium",
                children: presentations.length
              }),
              /* @__PURE__ */ jsx2("span", {
                className: "text-muted-foreground",
                children: "views"
              })
            ]
          }) : null
        ]
      }),
      hasCapabilities && /* @__PURE__ */ jsxs("div", {
        className: "border-border/50 space-y-1.5 border-t pt-1",
        children: [
          capabilities?.provides?.length ? /* @__PURE__ */ jsxs(HStack, {
            gap: "xs",
            wrap: "wrap",
            className: "items-start",
            children: [
              /* @__PURE__ */ jsx2(Shield2, {
                className: "mt-0.5 h-3.5 w-3.5 text-emerald-500"
              }),
              /* @__PURE__ */ jsx2("span", {
                className: "text-muted-foreground text-xs",
                children: "Provides:"
              }),
              capabilities.provides.slice(0, 2).map((cap) => /* @__PURE__ */ jsx2(StatusChip, {
                tone: "success",
                label: cap.key,
                size: "sm"
              }, cap.key)),
              capabilities.provides.length > 2 && /* @__PURE__ */ jsxs("span", {
                className: "text-muted-foreground text-xs",
                children: [
                  "+",
                  capabilities.provides.length - 2
                ]
              })
            ]
          }) : null,
          capabilities?.requires?.length ? /* @__PURE__ */ jsxs(HStack, {
            gap: "xs",
            wrap: "wrap",
            className: "items-start",
            children: [
              /* @__PURE__ */ jsx2(ArrowRight, {
                className: "mt-0.5 h-3.5 w-3.5 text-blue-500"
              }),
              /* @__PURE__ */ jsx2("span", {
                className: "text-muted-foreground text-xs",
                children: "Requires:"
              }),
              capabilities.requires.slice(0, 2).map((req) => /* @__PURE__ */ jsx2(StatusChip, {
                tone: "info",
                label: req.key,
                size: "sm"
              }, req.key)),
              capabilities.requires.length > 2 && /* @__PURE__ */ jsxs("span", {
                className: "text-muted-foreground text-xs",
                children: [
                  "+",
                  capabilities.requires.length - 2
                ]
              })
            ]
          }) : null
        ]
      }),
      meta.tags?.length ? /* @__PURE__ */ jsxs(HStack, {
        gap: "xs",
        wrap: "wrap",
        className: "border-border/50 items-center border-t pt-1",
        children: [
          /* @__PURE__ */ jsx2(Tag, {
            className: "text-muted-foreground h-3.5 w-3.5"
          }),
          meta.tags.slice(0, 4).map((tag) => /* @__PURE__ */ jsxs("span", {
            className: "bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-xs",
            children: [
              "#",
              tag
            ]
          }, tag)),
          meta.tags.length > 4 && /* @__PURE__ */ jsxs("span", {
            className: "text-muted-foreground text-xs",
            children: [
              "+",
              meta.tags.length - 4
            ]
          })
        ]
      }) : null,
      meta.owners?.length ? /* @__PURE__ */ jsxs(HStack, {
        gap: "xs",
        className: "text-muted-foreground items-center text-xs",
        children: [
          /* @__PURE__ */ jsx2(Users, {
            className: "h-3.5 w-3.5"
          }),
          /* @__PURE__ */ jsx2("span", {
            children: meta.owners.join(", ")
          })
        ]
      }) : null
    ]
  });
}
// src/presentation/features/molecules/FeatureCard/FeatureCard.tsx
import { EntityCard, StatusChip as StatusChip2 } from "@contractspec/lib.design-system";
import { HStack as HStack2 } from "@contractspec/lib.ui-kit-web/ui/stack";
import { Zap as Zap2, Radio as Radio2, Layout as Layout3, Shield as Shield3 } from "lucide-react";
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
"use client";
var stabilityTone = {
  stable: "success",
  beta: "warning",
  experimental: "info",
  deprecated: "danger"
};
function FeatureCard({
  feature,
  onSelect,
  className
}) {
  const { meta, operations, events, presentations, capabilities } = feature;
  const tone = stabilityTone[meta.stability] ?? "neutral";
  const iconTone = getFeatureIconTone(meta.stability);
  const emphasis = meta.stability === "stable" ? "strong" : "default";
  const handleClick = onSelect ? () => onSelect(feature) : undefined;
  const hasCapabilities = capabilities?.provides?.length || capabilities?.requires?.length;
  return /* @__PURE__ */ jsx3(EntityCard, {
    cardTitle: meta.title,
    cardSubtitle: meta.key,
    className,
    onClick: handleClick,
    emphasis,
    icon: /* @__PURE__ */ jsx3(FeatureIcon, {
      domain: meta.domain,
      tags: meta.tags,
      stability: meta.stability,
      size: "md"
    }),
    iconTone,
    chips: /* @__PURE__ */ jsx3(StatusChip2, {
      tone,
      label: meta.stability ?? "unknown",
      size: "sm"
    }),
    meta: meta.description ? /* @__PURE__ */ jsx3("span", {
      className: "text-muted-foreground line-clamp-2 text-sm",
      children: meta.description
    }) : undefined,
    preview: /* @__PURE__ */ jsx3(FeatureHoverPreview, {
      feature
    }),
    footer: /* @__PURE__ */ jsxs2(HStack2, {
      gap: "md",
      className: "text-muted-foreground w-full justify-between text-xs",
      children: [
        /* @__PURE__ */ jsxs2(HStack2, {
          gap: "sm",
          children: [
            operations?.length ? /* @__PURE__ */ jsxs2("span", {
              className: "flex items-center gap-1",
              children: [
                /* @__PURE__ */ jsx3(Zap2, {
                  className: "h-3 w-3 text-amber-500"
                }),
                operations.length
              ]
            }) : null,
            events?.length ? /* @__PURE__ */ jsxs2("span", {
              className: "flex items-center gap-1",
              children: [
                /* @__PURE__ */ jsx3(Radio2, {
                  className: "h-3 w-3 text-blue-500"
                }),
                events.length
              ]
            }) : null,
            presentations?.length ? /* @__PURE__ */ jsxs2("span", {
              className: "flex items-center gap-1",
              children: [
                /* @__PURE__ */ jsx3(Layout3, {
                  className: "h-3 w-3 text-purple-500"
                }),
                presentations.length
              ]
            }) : null
          ]
        }),
        hasCapabilities && /* @__PURE__ */ jsxs2("span", {
          className: "flex items-center gap-1",
          children: [
            /* @__PURE__ */ jsx3(Shield3, {
              className: "h-3 w-3 text-emerald-500"
            }),
            (capabilities?.provides?.length ?? 0) + (capabilities?.requires?.length ?? 0)
          ]
        })
      ]
    })
  });
}
// src/presentation/features/molecules/FeatureFilters/FeatureFilters.tsx
import { Button, Input } from "@contractspec/lib.design-system";
import { VStack, HStack as HStack3 } from "@contractspec/lib.ui-kit-web/ui/stack";
import { cn as cn2 } from "@contractspec/lib.ui-kit-web/ui/utils";
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
"use client";
function FeatureFiltersBar({
  uniqueTags,
  uniqueStabilities,
  filters,
  setSearch,
  toggleTag,
  toggleStability,
  clearFilters,
  hasActiveFilters,
  className
}) {
  return /* @__PURE__ */ jsxs3(VStack, {
    gap: "md",
    className: cn2("w-full", className),
    children: [
      /* @__PURE__ */ jsxs3(HStack3, {
        gap: "md",
        justify: "between",
        className: "w-full",
        children: [
          /* @__PURE__ */ jsx4(Input, {
            placeholder: "Search features...",
            value: filters.search,
            onChange: (e) => setSearch(e.target.value),
            className: "max-w-md",
            "aria-label": "Search features"
          }),
          hasActiveFilters && /* @__PURE__ */ jsx4(Button, {
            variant: "ghost",
            size: "sm",
            onClick: clearFilters,
            children: "Clear filters"
          })
        ]
      }),
      uniqueStabilities.length > 0 && /* @__PURE__ */ jsxs3(HStack3, {
        gap: "xs",
        wrap: "wrap",
        children: [
          /* @__PURE__ */ jsx4("span", {
            className: "text-muted-foreground text-sm",
            children: "Stability:"
          }),
          uniqueStabilities.map((stability) => /* @__PURE__ */ jsx4(Button, {
            variant: filters.stability.includes(stability) ? "default" : "outline",
            size: "sm",
            onClick: () => toggleStability(stability),
            "aria-pressed": filters.stability.includes(stability),
            children: stability
          }, stability))
        ]
      }),
      uniqueTags.length > 0 && /* @__PURE__ */ jsxs3(HStack3, {
        gap: "xs",
        wrap: "wrap",
        children: [
          /* @__PURE__ */ jsx4("span", {
            className: "text-muted-foreground text-sm",
            children: "Tags:"
          }),
          uniqueTags.slice(0, 10).map((tag) => /* @__PURE__ */ jsxs3(Button, {
            variant: filters.tags.includes(tag) ? "default" : "outline",
            size: "sm",
            onClick: () => toggleTag(tag),
            "aria-pressed": filters.tags.includes(tag),
            children: [
              "#",
              tag
            ]
          }, tag)),
          uniqueTags.length > 10 && /* @__PURE__ */ jsxs3("span", {
            className: "text-muted-foreground text-sm",
            children: [
              "+",
              uniqueTags.length - 10,
              " more"
            ]
          })
        ]
      })
    ]
  });
}
// src/presentation/features/molecules/FeatureCategoryHeader/FeatureCategoryHeader.tsx
import { cn as cn3 } from "@contractspec/lib.ui-kit-web/ui/utils";
import { ChevronDown, Boxes as Boxes2 } from "lucide-react";
import { HStack as HStack4 } from "@contractspec/lib.ui-kit-web/ui/stack";
import { StatusChip as StatusChip3 } from "@contractspec/lib.design-system";
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
"use client";
function FeatureCategoryHeader({
  title,
  count,
  icon,
  isCollapsed = false,
  onToggle,
  className
}) {
  return /* @__PURE__ */ jsxs4("button", {
    type: "button",
    onClick: onToggle,
    className: cn3("flex w-full items-center justify-between rounded-lg px-4 py-3", "bg-muted/30 hover:bg-muted/50 transition-colors", "group cursor-pointer", className),
    children: [
      /* @__PURE__ */ jsxs4(HStack4, {
        gap: "sm",
        className: "items-center",
        children: [
          /* @__PURE__ */ jsx5("div", {
            className: "text-muted-foreground group-hover:text-foreground transition-colors",
            children: icon || /* @__PURE__ */ jsx5(Boxes2, {
              className: "h-5 w-5"
            })
          }),
          /* @__PURE__ */ jsx5("span", {
            className: "group-hover:text-primary text-lg font-semibold capitalize transition-colors",
            children: title
          }),
          /* @__PURE__ */ jsx5(StatusChip3, {
            tone: "neutral",
            label: `${count} ${count === 1 ? "feature" : "features"}`,
            size: "sm"
          })
        ]
      }),
      /* @__PURE__ */ jsx5(ChevronDown, {
        className: cn3("text-muted-foreground h-5 w-5 transition-transform duration-200", isCollapsed && "-rotate-90")
      })
    ]
  });
}
// src/presentation/features/organisms/FeatureDiscovery/FeatureDiscovery.tsx
import * as React2 from "react";
import {
  PageHeaderResponsive,
  EmptyState,
  Button as Button2,
  StatusChip as StatusChip4
} from "@contractspec/lib.design-system";
import { VStack as VStack2, HStack as HStack5 } from "@contractspec/lib.ui-kit-web/ui/stack";
import { cn as cn4 } from "@contractspec/lib.ui-kit-web/ui/utils";
import { LayoutGrid, List, Star } from "lucide-react";
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
"use client";
function groupFeaturesByDomain(features) {
  const groups = {};
  for (const feature of features) {
    const domain = feature.meta.domain || "Other";
    if (!groups[domain])
      groups[domain] = [];
    groups[domain].push(feature);
  }
  return groups;
}
function groupFeaturesByStability(features) {
  const order = ["stable", "beta", "experimental", "deprecated", "unknown"];
  const groups = {};
  for (const feature of features) {
    const stability = feature.meta.stability || "unknown";
    if (!groups[stability])
      groups[stability] = [];
    groups[stability].push(feature);
  }
  const sorted = {};
  for (const key of order) {
    if (groups[key])
      sorted[key] = groups[key];
  }
  return sorted;
}
function FeatureDiscovery({
  onSelectFeature,
  className,
  defaultViewMode = "grid",
  groupBy = "domain",
  showFeatured = true
}) {
  const { features, getUniqueTags, getUniqueStabilities } = useFeatureRegistry();
  const {
    filters,
    setSearch,
    toggleTag,
    toggleStability,
    clearFilters,
    filteredFeatures,
    hasActiveFilters
  } = useFeatureFilters(features);
  const uniqueTags = getUniqueTags();
  const uniqueStabilities = getUniqueStabilities();
  const [viewMode, setViewMode] = React2.useState(defaultViewMode);
  const [collapsedGroups, setCollapsedGroups] = React2.useState(new Set);
  const featuredFeatures = React2.useMemo(() => filteredFeatures.filter((f) => f.meta.stability === "stable"), [filteredFeatures]);
  const nonFeaturedFeatures = React2.useMemo(() => showFeatured ? filteredFeatures.filter((f) => f.meta.stability !== "stable") : filteredFeatures, [filteredFeatures, showFeatured]);
  const groupedFeatures = React2.useMemo(() => {
    if (groupBy === "none")
      return null;
    if (groupBy === "domain")
      return groupFeaturesByDomain(nonFeaturedFeatures);
    return groupFeaturesByStability(nonFeaturedFeatures);
  }, [nonFeaturedFeatures, groupBy]);
  const toggleGroup = (group) => {
    setCollapsedGroups((prev) => {
      const next = new Set(prev);
      if (next.has(group)) {
        next.delete(group);
      } else {
        next.add(group);
      }
      return next;
    });
  };
  const gridClasses = viewMode === "grid" ? "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3" : "flex flex-col gap-3";
  const renderFeatureCards = (featureList) => /* @__PURE__ */ jsx6("div", {
    className: gridClasses,
    children: featureList.map((feature) => /* @__PURE__ */ jsx6(FeatureCard, {
      feature,
      onSelect: onSelectFeature
    }, feature.meta.key))
  });
  return /* @__PURE__ */ jsxs5(VStack2, {
    gap: "lg",
    className: cn4("w-full p-6", className),
    children: [
      /* @__PURE__ */ jsxs5("div", {
        className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
        children: [
          /* @__PURE__ */ jsx6(PageHeaderResponsive, {
            title: "Feature Discovery",
            subtitle: `Browse ${features.length} available ContractSpec features`
          }),
          /* @__PURE__ */ jsxs5(HStack5, {
            gap: "xs",
            children: [
              /* @__PURE__ */ jsx6("button", {
                type: "button",
                onClick: () => setViewMode("grid"),
                className: cn4("rounded-md p-2 transition-colors", viewMode === "grid" ? "bg-primary text-primary-foreground" : "bg-muted hover:bg-muted/80 text-muted-foreground"),
                "aria-label": "Grid view",
                children: /* @__PURE__ */ jsx6(LayoutGrid, {
                  className: "h-4 w-4"
                })
              }),
              /* @__PURE__ */ jsx6("button", {
                type: "button",
                onClick: () => setViewMode("list"),
                className: cn4("rounded-md p-2 transition-colors", viewMode === "list" ? "bg-primary text-primary-foreground" : "bg-muted hover:bg-muted/80 text-muted-foreground"),
                "aria-label": "List view",
                children: /* @__PURE__ */ jsx6(List, {
                  className: "h-4 w-4"
                })
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsx6(FeatureFiltersBar, {
        uniqueTags,
        uniqueStabilities,
        filters,
        setSearch,
        toggleTag,
        toggleStability,
        clearFilters,
        hasActiveFilters
      }),
      filteredFeatures.length === 0 ? /* @__PURE__ */ jsx6(EmptyState, {
        title: "No features found",
        description: hasActiveFilters ? "Try adjusting your search or filters" : "No features are registered yet",
        primaryAction: hasActiveFilters ? /* @__PURE__ */ jsx6(Button2, {
          variant: "outline",
          onClick: clearFilters,
          children: "Clear filters"
        }) : undefined
      }) : /* @__PURE__ */ jsxs5(VStack2, {
        gap: "lg",
        children: [
          showFeatured && featuredFeatures.length > 0 && /* @__PURE__ */ jsxs5(VStack2, {
            gap: "sm",
            children: [
              /* @__PURE__ */ jsxs5(HStack5, {
                gap: "sm",
                className: "items-center",
                children: [
                  /* @__PURE__ */ jsx6(Star, {
                    className: "h-5 w-5 fill-amber-500 text-amber-500"
                  }),
                  /* @__PURE__ */ jsx6("span", {
                    className: "text-lg font-semibold",
                    children: "Featured"
                  }),
                  /* @__PURE__ */ jsx6(StatusChip4, {
                    tone: "success",
                    label: `${featuredFeatures.length} stable`,
                    size: "sm"
                  })
                ]
              }),
              renderFeatureCards(featuredFeatures)
            ]
          }),
          groupedFeatures ? /* @__PURE__ */ jsx6(VStack2, {
            gap: "md",
            children: Object.entries(groupedFeatures).map(([group, groupFeatures]) => /* @__PURE__ */ jsxs5(VStack2, {
              gap: "sm",
              children: [
                /* @__PURE__ */ jsx6(FeatureCategoryHeader, {
                  title: group,
                  count: groupFeatures.length,
                  isCollapsed: collapsedGroups.has(group),
                  onToggle: () => toggleGroup(group)
                }),
                !collapsedGroups.has(group) && renderFeatureCards(groupFeatures)
              ]
            }, group))
          }) : renderFeatureCards(nonFeaturedFeatures)
        ]
      })
    ]
  });
}
// src/presentation/features/organisms/FeatureDetail/FeatureDetail.tsx
import {
  StatCard,
  StatCardGroup,
  StatusChip as StatusChip5
} from "@contractspec/lib.design-system";
import { Box, HStack as HStack6, VStack as VStack3 } from "@contractspec/lib.ui-kit-web/ui/stack";
import { cn as cn5 } from "@contractspec/lib.ui-kit-web/ui/utils";
import Link from "next/link";
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
"use client";
var stabilityTone2 = {
  stable: "success",
  beta: "warning",
  experimental: "info",
  deprecated: "danger"
};
function FeatureDetail({ feature, className }) {
  const { meta, operations, events, presentations, capabilities } = feature;
  const tone = stabilityTone2[meta.stability] ?? "neutral";
  return /* @__PURE__ */ jsxs6(VStack3, {
    gap: "lg",
    className: cn5("w-full", className),
    children: [
      /* @__PURE__ */ jsxs6(HStack6, {
        gap: "sm",
        children: [
          /* @__PURE__ */ jsx7(StatusChip5, {
            tone,
            label: meta.stability ?? "unknown"
          }),
          /* @__PURE__ */ jsx7(StatusChip5, {
            tone: "neutral",
            label: meta.key,
            size: "sm"
          }),
          /* @__PURE__ */ jsx7(StatusChip5, {
            tone: "neutral",
            label: `v${meta.version}`,
            size: "sm"
          })
        ]
      }),
      /* @__PURE__ */ jsxs6(StatCardGroup, {
        children: [
          /* @__PURE__ */ jsx7(Link, {
            href: `./${feature.meta.key}/operations`,
            children: /* @__PURE__ */ jsx7(StatCard, {
              label: "Operations",
              value: operations?.length ?? 0
            })
          }),
          /* @__PURE__ */ jsx7(Link, {
            href: `./${feature.meta.key}/events`,
            children: /* @__PURE__ */ jsx7(StatCard, {
              label: "Events",
              value: events?.length ?? 0
            })
          }),
          /* @__PURE__ */ jsx7(Link, {
            href: `./${feature.meta.key}/presentations`,
            children: /* @__PURE__ */ jsx7(StatCard, {
              label: "Presentations",
              value: presentations?.length ?? 0
            })
          })
        ]
      }),
      capabilities?.provides?.length ? /* @__PURE__ */ jsxs6(Box, {
        className: "flex-col rounded-lg border p-4",
        gap: "sm",
        align: "start",
        children: [
          /* @__PURE__ */ jsx7("span", {
            className: "font-semibold",
            children: "Provides Capabilities"
          }),
          /* @__PURE__ */ jsx7(HStack6, {
            gap: "xs",
            wrap: "wrap",
            children: capabilities.provides.map((cap) => /* @__PURE__ */ jsx7(StatusChip5, {
              tone: "success",
              label: `${cap.key} v${cap.version}`,
              size: "sm"
            }, `${cap.key}-${cap.version}`))
          })
        ]
      }) : null,
      capabilities?.requires?.length ? /* @__PURE__ */ jsxs6(Box, {
        className: "flex-col rounded-lg border p-4",
        gap: "sm",
        align: "start",
        children: [
          /* @__PURE__ */ jsx7("span", {
            className: "font-semibold",
            children: "Requires Capabilities"
          }),
          /* @__PURE__ */ jsx7(HStack6, {
            gap: "xs",
            wrap: "wrap",
            children: capabilities.requires.map((req) => /* @__PURE__ */ jsx7(StatusChip5, {
              tone: "info",
              label: `${req.key}${req.version ? ` v${req.version}` : ""}${req.optional ? " (optional)" : ""}`,
              size: "sm"
            }, req.key))
          })
        ]
      }) : null,
      meta.tags?.length ? /* @__PURE__ */ jsxs6(Box, {
        className: "flex-col rounded-lg border p-4",
        gap: "sm",
        align: "start",
        children: [
          /* @__PURE__ */ jsx7("span", {
            className: "font-semibold",
            children: "Tags"
          }),
          /* @__PURE__ */ jsx7(HStack6, {
            gap: "xs",
            wrap: "wrap",
            children: meta.tags.map((tag) => /* @__PURE__ */ jsx7(StatusChip5, {
              tone: "neutral",
              label: `#${tag}`,
              size: "sm"
            }, tag))
          })
        ]
      }) : null,
      meta.owners?.length ? /* @__PURE__ */ jsxs6(Box, {
        className: "flex-col rounded-lg border p-4",
        gap: "sm",
        align: "start",
        children: [
          /* @__PURE__ */ jsx7("span", {
            className: "font-semibold",
            children: "Owners"
          }),
          /* @__PURE__ */ jsx7(HStack6, {
            gap: "xs",
            wrap: "wrap",
            children: meta.owners.map((owner) => /* @__PURE__ */ jsx7(StatusChip5, {
              tone: "neutral",
              label: owner,
              size: "sm"
            }, owner))
          })
        ]
      }) : null
    ]
  });
}
// src/presentation/features/organisms/FeatureOperationsList.tsx
import { EntityCard as EntityCard2 } from "@contractspec/lib.design-system";
import { Zap as Zap3 } from "lucide-react";
import { jsx as jsx8 } from "react/jsx-runtime";
"use client";
function FeatureOperationsList({
  feature
}) {
  if (!feature.operations?.length)
    return null;
  return /* @__PURE__ */ jsx8("div", {
    className: "grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",
    children: feature.operations.map((op) => {
      const spec = resolveSerializedOperationSpec(op.key, op.version);
      return /* @__PURE__ */ jsx8(EntityCard2, {
        cardTitle: op.key,
        cardSubtitle: `v${op.version}`,
        footer: spec?.meta.description,
        icon: /* @__PURE__ */ jsx8(Zap3, {
          className: "h-4 w-4"
        }),
        href: `/features/${feature.meta.key}/operations/${op.key}`
      }, op.key);
    })
  });
}

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

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

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

// src/presentation/features/organisms/FeatureFormsList.tsx
import { EntityCard as EntityCard6 } from "@contractspec/lib.design-system";
import { FormInput } from "lucide-react";
import { jsx as jsx12 } from "react/jsx-runtime";
"use client";
function FeatureFormsList({ feature }) {
  if (!feature.forms?.length)
    return null;
  return /* @__PURE__ */ jsx12("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__ */ jsx12(EntityCard6, {
        cardTitle: form.key,
        cardSubtitle: form.version ? `v${form.version}` : undefined,
        footer: spec?.meta.description,
        icon: /* @__PURE__ */ jsx12(FormInput, {
          className: "h-4 w-4"
        }),
        href: `/features/${feature.meta.key}/forms/${form.key}`
      }, form.key);
    })
  });
}
export {
  FeaturePresentationsList,
  FeatureOperationsList,
  FeatureFormsList,
  FeatureEventsList,
  FeatureDiscovery,
  FeatureDetail,
  FeatureDataViewsList
};
