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