// @bun
import{defaultDocRegistry as L}from"@contractspec/lib.contracts-spec/docs";import{useMemo as M}from"react";function _(A,T){return M(()=>{try{return L.list().filter(({block:J})=>{let G=J.id.toLowerCase().includes(A.toLowerCase())||J.title.toLowerCase().includes(A.toLowerCase()),U=T?.some((I)=>J.tags?.some((P)=>P.toLowerCase().includes(I.toLowerCase())));return G||U}).map(({block:J,route:G})=>({id:J.id,title:J.title,summary:J.summary,route:G}))}catch(F){return console.error("Failed to fetch related docs:",F),[]}},[A,T])}import{Breadcrumbs as $,CodeBlock as w,EmptyState as N,PageHeaderResponsive as E,StatusChip as W}from"@contractspec/lib.design-system";import{Card as Y}from"@contractspec/lib.ui-kit-web/ui/card";import{Box as B,HStack as X,VStack as Q}from"@contractspec/lib.ui-kit-web/ui/stack";import{cn as O}from"@contractspec/lib.ui-kit-web/ui/utils";import{BookOpen as D,Code as H,Database as K,Layout as v}from"lucide-react";import h from"next/link";import{jsx as q,jsxs as z}from"react/jsx-runtime";function n({feature:A,presentationKey:T,presentation:Z,spec:F,className:J}){let G=Z??A.presentations?.find((I)=>I.key===T),U=_(G?.key||"",F?.meta?.tags);if(!G)return z(Q,{gap:"lg",className:O("mx-auto w-full max-w-5xl p-6",J),children:[q(E,{title:"Presentation Not Found",subtitle:`Presentation ${T} not found in feature ${A.meta.key}`,breadcrumb:q($,{items:[{label:"Features",href:"/features"},{label:A.meta.title||A.meta.key,href:`/features/${A.meta.key}`},{label:"Presentations",href:`/features/${A.meta.key}/presentation`}]})}),q(N,{title:"Presentation not found",description:`The presentation '${T}' could not be found in this feature.`,icon:q(v,{className:"h-12 w-12 text-muted-foreground"})})]});return z(Q,{gap:"lg",className:O("mx-auto w-full max-w-5xl p-6",J),children:[q(E,{title:G.key,subtitle:`Presentation defined in ${A.meta.title??A.meta.key}`,breadcrumb:q($,{items:[{label:"Features",href:"/features"},{label:A.meta.title||A.meta.key,href:`/features/${A.meta.key}`},{label:"Presentations",href:`/features/${A.meta.key}#presentations`},{label:G.key}]})}),z(X,{gap:"sm",children:[q(W,{tone:"neutral",label:G.key,size:"sm",icon:q(v,{className:"h-3 w-3"})}),q(W,{tone:"neutral",label:`v${G.version}`,size:"sm"}),F?.meta?.stability?q(W,{tone:F.meta.stability==="stable"?"success":"warning",label:F.meta.stability,size:"sm"}):null]}),z("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:[q("div",{className:"space-y-6 lg:col-span-2",children:q(Y,{className:"p-6",children:z(Q,{gap:"md",children:[z(X,{className:"items-center gap-2 border-b pb-2",children:[q(H,{className:"h-5 w-5 text-muted-foreground"}),q("h3",{className:"font-semibold text-lg",children:"Component Definition"})]}),F?z(Q,{gap:"lg",children:[F.meta.description&&q("p",{className:"text-muted-foreground",children:F.meta.description}),z(B,{className:"flex-col gap-2",children:[q("span",{className:"font-medium text-muted-foreground text-sm uppercase tracking-wider",children:"Spec Details"}),q(w,{code:JSON.stringify(F,null,2),language:"json"})]})]}):z(Q,{gap:"md",children:[q("p",{className:"text-muted-foreground",children:"Full component details are not available for this presentation reference."}),q(w,{code:JSON.stringify(G,null,2),language:"json"})]})]})})}),q("div",{className:"space-y-6",children:q(Y,{className:"p-6",children:z(Q,{gap:"md",children:[z(X,{className:"items-center gap-2 border-b pb-2",children:[q(K,{className:"h-5 w-5 text-muted-foreground"}),q("h3",{className:"font-semibold text-lg",children:"Metadata"})]}),z("dl",{className:"grid grid-cols-1 gap-4 text-sm",children:[z("div",{children:[q("dt",{className:"text-muted-foreground",children:"Key"}),q("dd",{className:"truncate font-medium",children:G.key})]}),z("div",{children:[q("dt",{className:"text-muted-foreground",children:"Version"}),q("dd",{className:"font-medium",children:G.version})]}),F?.meta?.owners&&z("div",{children:[q("dt",{className:"text-muted-foreground",children:"Owners"}),q("dd",{className:"flex flex-wrap gap-1 font-medium",children:F.meta.owners.map((I)=>q(W,{label:I,size:"sm",tone:"neutral"},I))})]})]})]})})}),U?.length?q("div",{className:"lg:col-span-3",children:q(Y,{className:"p-6",children:z(Q,{gap:"md",children:[z(X,{className:"items-center gap-2 border-b pb-2",children:[q(D,{className:"h-5 w-5 text-muted-foreground"}),q("h3",{className:"font-semibold text-lg",children:"Related Documentation"})]}),q("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",children:U.map((I)=>q(h,{href:I.route||`/docs/${I.id}`,className:"group block",children:z("div",{className:"h-full rounded-lg border p-4 transition-colors hover:border-primary",children:[q("h4",{className:"mb-1 font-semibold group-hover:text-primary",children:I.title}),I.summary&&q("p",{className:"line-clamp-2 text-muted-foreground text-sm",children:I.summary})]})},I.id))})]})})}):null]})]})}export{n as FeaturePresentationDetailTemplate};
