// @bun
var X=/^##\s+Metadata[\s\S]*?(?=^##\s|^#\s|Z)/m;function Y(i){return i.replace(/^#\s+.*\n+/m,"").replace(X,"")}function E(i){return/^#{1,4}\s+/.test(i)||/^```/.test(i)||/^\s*[-*]\s+/.test(i)||/^\s*\d+\.\s+/.test(i)||/^>\s+/.test(i)}function F(i){let s=Y(i).split(/\r?\n/),h=[],p=0;while(p<s.length){let T=s[p]??"";if(T.startsWith("<!-- @generated")){p+=1;continue}let g=T.trim();if(!g){p+=1;continue}if(g.startsWith("```")){let t=g.slice(3).trim(),f=[];p+=1;while(p<s.length&&!(s[p]??"").trim().startsWith("```"))f.push(s[p]??""),p+=1;p+=1,h.push({type:"code",language:t||"text",code:f.join(`
`)});continue}if(/^#{1,4}\s+/.test(g)){let t=g.match(/^#{1,4}/)?.[0].length??2;h.push({type:"heading",level:t,text:g.replace(/^#{1,4}\s+/,"")}),p+=1;continue}if(/^>\s+/.test(g)){let t=[];while(p<s.length&&/^>\s+/.test((s[p]??"").trim()))t.push((s[p]??"").trim().replace(/^>\s+/,"")),p+=1;h.push({type:"quote",text:t.join(" ")});continue}if(/^[-*]\s+/.test(g)||/^\d+\.\s+/.test(g)){let t=/^\d+\.\s+/.test(g),f=[];while(p<s.length&&E((s[p]??"").trim())){let q=(s[p]??"").trim();if(t&&/^\d+\.\s+/.test(q))f.push(q.replace(/^\d+\.\s+/,""));else if(!t&&/^[-*]\s+/.test(q))f.push(q.replace(/^[-*]\s+/,""));else break;p+=1}h.push({type:"list",ordered:t,items:f});continue}let W=[];while(p<s.length&&!E((s[p]??"").trim())){let t=(s[p]??"").trim();if(!t)break;W.push(t),p+=1}h.push({type:"paragraph",text:W.join(" ")})}return h}import{CodeBlock as _}from"@contractspec/lib.design-system";import{HStack as $,VStack as Z}from"@contractspec/lib.ui-kit-web/ui/stack";import{BlockQuote as Q,H2 as U,H3 as r,H4 as z,Muted as J,P as K}from"@contractspec/lib.ui-kit-web/ui/typography";import{jsx as u,jsxs as P}from"react/jsx-runtime";var G=new Set(["typescript","tsx","javascript","jsx","bash","shell","json","yaml","graphql","sql","python","go","rust","css","scss","html","markdown","text"]);function v(i){if(!i)return"text";let s=i.toLowerCase();return G.has(s)?s:"text"}function w(i,s){if(i<=2)return u(U,{children:s});if(i===3)return u(r,{children:s});return u(z,{children:s})}function N({content:i}){let s=F(i);if(!s.length)return u(J,{children:"No reference content available."});return u(Z,{gap:"md",children:s.map((h,p)=>{switch(h.type){case"heading":return u(Z,{children:w(h.level,h.text)},p);case"paragraph":return u(K,{children:h.text},p);case"quote":return u(Q,{children:h.text},p);case"code":return u(_,{language:v(h.language),code:h.code},p);case"list":return u(Z,{gap:"xs",children:h.items.map((T,g)=>P($,{gap:"sm",align:"start",children:[u(J,{children:h.ordered?`${g+1}.`:"\u2022"}),u(K,{className:"leading-relaxed",children:T})]},g))},p);default:return null}})})}import{ContractReferenceDataView as B}from"@contractspec/lib.contracts-spec/docs";import{DataViewRenderer as D}from"@contractspec/lib.design-system";import{VStack as I}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as O,jsxs as d}from"react/jsx-runtime";function L(i,s){return i.match(new RegExp(`- \\*\\*${s}\\*\\*: (.+)`,"i"))?.[1]?.trim()}function M(i){if(!i)return;return i.replace(/<!--.*?-->/g,"").replace(/[ \t]+/g," ").replace(/\n{3,}/g,`

`).trim()}function a({entry:i,content:s}){let h=M(i.summary),p=L(s,"Type"),T=L(s,"Version")??i.version,g=L(s,"Tags")?.split(",").map((A)=>A.trim()).filter(Boolean),W=L(s,"Owners")?.split(",").map((A)=>A.trim()).filter(Boolean),t=L(s,"Stability")??i.visibility,f={reference:{key:i.title??i.id,version:T,type:p,title:i.title??i.id,description:h,tags:g??i.tags,owners:W??i.owners,stability:t}},q={...B,meta:{...B.meta,title:i.title??B.meta.title,description:h??B.meta.description}};return d(I,{gap:"xl",children:[O(D,{spec:q,item:f}),O(N,{content:s})]})}export{a as DocsReferenceContent};
