var M=Object.defineProperty;var D=(z)=>z;function N(z,G){this[z]=D.bind(null,G)}var h=(z,G)=>{for(var O in G)M(z,O,{get:G[O],enumerable:!0,configurable:!0,set:N.bind(G,O)})};var m=(z,G)=>()=>(z&&(G=z(z=0)),G);import{defaultDocRegistry as H}from"@contractspec/lib.contracts-spec/docs";import{useMemo as K}from"react";function Y(z,G){return K(()=>{try{return H.list().filter(({block:J})=>{let I=J.id.toLowerCase().includes(z.toLowerCase())||J.title.toLowerCase().includes(z.toLowerCase()),X=G?.some((L)=>J.tags?.some((Z)=>Z.toLowerCase().includes(L.toLowerCase())));return I||X}).map(({block:J,route:I})=>({id:J.id,title:J.title,summary:J.summary,route:I}))}catch(A){return console.error("Failed to fetch related docs:",A),[]}},[z,G])}import{Breadcrumbs as _,CodeBlock as U,EmptyState as V,PageHeaderResponsive as $,StatusChip as T}from"@contractspec/lib.design-system";import{Card as w}from"@contractspec/lib.ui-kit-web/ui/card";import{Box as E,HStack as W,VStack as Q}from"@contractspec/lib.ui-kit-web/ui/stack";import{cn as v}from"@contractspec/lib.ui-kit-web/ui/utils";import{Code as B,Database as g,Zap as P}from"lucide-react";import{jsx as q,jsxs as F}from"react/jsx-runtime";function k({feature:z,operationKey:G,operation:O,spec:A,className:J}){let I=O??z.operations?.find((L)=>L.key===G),X=Y(I?.key||"",A?.meta?.tags);if(!I)return F(Q,{gap:"lg",className:v("mx-auto w-full max-w-5xl p-6",J),children:[q($,{title:"Operation Not Found",subtitle:`Operation ${G} not found in feature ${z.meta.key}`,breadcrumb:q(_,{items:[{label:"Features",href:"/features"},{label:z.meta.title||z.meta.key,href:`/features/${z.meta.key}`},{label:"Operations"}]})}),q(V,{title:"Operation not found",description:`The operation '${G}' could not be found in this feature.`,icon:q(P,{className:"h-12 w-12 text-muted-foreground"})})]});return F(Q,{gap:"lg",className:v("mx-auto w-full max-w-5xl p-6",J),children:[q($,{title:I.key,subtitle:`Operation defined in ${z.meta.title??z.meta.key}`,breadcrumb:q(_,{items:[{label:"Features",href:"/features"},{label:z.meta.title||z.meta.key,href:`/features/${z.meta.key}`},{label:"Operations",href:`/features/${z.meta.key}/operations`},{label:I.key}]})}),F(W,{gap:"sm",children:[q(T,{tone:"neutral",label:I.key,size:"sm",icon:q(P,{className:"h-3 w-3"})}),q(T,{tone:"neutral",label:`v${I.version}`,size:"sm"}),A?.meta?.stability?q(T,{tone:A.meta.stability==="stable"?"success":"warning",label:A.meta.stability,size:"sm"}):null]}),F("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(w,{className:"p-6",children:F(Q,{gap:"md",children:[F(W,{className:"items-center gap-2 border-b pb-2",children:[q(B,{className:"h-5 w-5 text-muted-foreground"}),q("h3",{className:"font-semibold text-lg",children:"Schema Definition"})]}),A?F(Q,{gap:"lg",children:[A.meta.description&&q("p",{className:"text-muted-foreground",children:A.meta.description}),F(E,{className:"flex-col gap-2",children:[q("span",{className:"font-medium text-muted-foreground text-sm uppercase tracking-wider",children:"Input Schema"}),q(U,{className:"w-full",code:JSON.stringify(A.io.input,null,2),language:"json"})]}),F(E,{className:"flex-col gap-2",children:[q("span",{className:"font-medium text-muted-foreground text-sm uppercase tracking-wider",children:"Output Schema"}),q(U,{className:"w-full",code:JSON.stringify(A.io.output,null,2),language:"json"})]})]}):F(Q,{gap:"md",children:[q("p",{className:"text-muted-foreground",children:"Full schema details are not available for this operation reference."}),q(U,{code:JSON.stringify(I,null,2),language:"json"})]})]})})}),q("div",{className:"space-y-6",children:q(w,{className:"p-6",children:F(Q,{gap:"md",children:[F(W,{className:"items-center gap-2 border-b pb-2",children:[q(g,{className:"h-5 w-5 text-muted-foreground"}),q("h3",{className:"font-semibold text-lg",children:"Metadata"})]}),F("dl",{className:"grid grid-cols-1 gap-4 text-sm",children:[F("div",{children:[q("dt",{className:"text-muted-foreground",children:"Key"}),q("dd",{className:"truncate font-medium",children:I.key})]}),F("div",{children:[q("dt",{className:"text-muted-foreground",children:"Version"}),q("dd",{className:"font-medium",children:I.version})]}),A?.meta?.context&&F("div",{children:[q("dt",{className:"text-muted-foreground",children:"Context"}),q("dd",{className:"font-medium",children:A.meta.context})]}),A?.meta?.owners&&F("div",{children:[q("dt",{className:"text-muted-foreground",children:"Owners"}),q("dd",{className:"flex flex-wrap gap-1 font-medium",children:A.meta.owners.map((L)=>q(T,{label:L,size:"sm",tone:"neutral"},L))})]}),A?.meta?.tags&&F("div",{children:[q("dt",{className:"text-muted-foreground",children:"Tags"}),q("dd",{className:"flex flex-wrap gap-1 font-medium",children:A.meta.tags.map((L)=>q(T,{label:`#${L}`,size:"sm",tone:"neutral"},L))})]})]})]})})})]})]})}export{k as FeatureOperationDetailTemplate};
