// @bun
var M="docs-index.manifest.json";import{readFile as l}from"fs/promises";import{dirname as Y,join as d}from"path";import{fileURLToPath as $}from"url";var m=Y($(import.meta.url)),P=null,a=null,N=new Map;function q(s){if(!s)return"_common";if(s.includes("/")){let[n]=s.split("/");return n||"_common"}return"_common"}async function E(){if(!P)P=l(d(m,M),"utf8").then((s)=>JSON.parse(s));return P}function v(s){let n=s.contentRoot??".";return d(m,n)}async function O(s){let n=N.get(s);if(n)return n;let t=l(d(m,s),"utf8").then((o)=>JSON.parse(o));return N.set(s,t),t}async function B(){if(!a)a=(async()=>{let s=await E();return(await Promise.all(s.chunks.map((t)=>O(t.file)))).flat()})();return a}async function As(){return E()}async function Ms(s){let n=await E(),t=q(s),o=n.chunks.find((i)=>i.key===t);if(!o)return null;let e=(await O(o.file)).find((i)=>i.id===s);if(!e||!e.contentPath)return null;let c=d(v(n),e.contentPath);try{let i=await l(c,"utf8");return{entry:e,content:i}}catch{return null}}import{DocsIndexDataView as C,DocsSearchForm as Q}from"@contractspec/lib.contracts-spec/docs";import{DataViewList as z,formRenderer as H,StatusChip as T}from"@contractspec/lib.design-system";import{HStack as S,VStack as _}from"@contractspec/lib.ui-kit-web/ui/stack";import{H1 as x,Muted as L}from"@contractspec/lib.ui-kit-web/ui/typography";import{useMemo as W,useState as k}from"react";import{jsx as g,jsxs as R}from"react/jsx-runtime";function V(s){if(!s)return;return s.replace(/<!--.*?-->/g,"").replace(/[ \t]+/g," ").replace(/\n{3,}/g,`

`).trim()}function b(s){let n=V(s.summary),t=s.kind??(s.source==="generated"?"reference":void 0),o=s.visibility??(s.source==="generated"?"public":void 0);return{...s,summary:n,kind:t,visibility:o}}function j(s,n){if(!n)return!0;return[s.title,s.summary,s.id,...s.tags??[]].filter(Boolean).join(" ").toLowerCase().includes(n.toLowerCase())}function w({entries:s}){let[n,t]=k({}),o=W(()=>s.map(b),[s]),p=W(()=>{let c=n.query?.trim()??"";return o.filter((i)=>{if(n.kind&&i.kind!==n.kind)return!1;if(n.visibility&&i.visibility!==n.visibility)return!1;return j(i,c)})},[n,o]),e=H.render(Q,{defaultValues:{query:n.query??"",visibility:n.visibility??"",kind:n.kind??""},overrides:{onSubmitOverride:(c)=>{let i=c;t({query:i.query??"",visibility:i.visibility??"",kind:i.kind??""})}}});return R(_,{gap:"xl",children:[R(_,{gap:"sm",children:[g(x,{children:"Reference"}),g(L,{children:"Generated reference material for public contract surfaces, versions, owners, and example-backed implementations. Use this when you need the repo truth, not just the narrative docs layer."})]}),g(_,{gap:"sm",className:"max-w-2xl",children:e}),g(z,{spec:C,items:p,emptyState:g(L,{children:"No reference docs match your filters."}),onSelect:(c)=>{if(c.route)window.location.assign(c.route)},renderActions:(c)=>{return R(S,{gap:"xs",justify:"end",children:[c.kind?g(T,{size:"sm",label:c.kind}):null,c.visibility?g(T,{size:"sm",label:c.visibility}):null,c.version?g(T,{size:"sm",label:`v${c.version}`}):null]})}})]})}import{jsx as ss}from"react/jsx-runtime";async function y(){let s=await B();return ss(w,{entries:s})}var ns=/^##\s+Metadata[\s\S]*?(?=^##\s|^#\s|Z)/m;function os(s){return s.replace(/^#\s+.*\n+/m,"").replace(ns,"")}function J(s){return/^#{1,4}\s+/.test(s)||/^```/.test(s)||/^\s*[-*]\s+/.test(s)||/^\s*\d+\.\s+/.test(s)||/^>\s+/.test(s)}function X(s){let n=os(s).split(/\r?\n/),t=[],o=0;while(o<n.length){let p=n[o]??"";if(p.startsWith("<!-- @generated")){o+=1;continue}let e=p.trim();if(!e){o+=1;continue}if(e.startsWith("```")){let i=e.slice(3).trim(),f=[];o+=1;while(o<n.length&&!(n[o]??"").trim().startsWith("```"))f.push(n[o]??""),o+=1;o+=1,t.push({type:"code",language:i||"text",code:f.join(`
`)});continue}if(/^#{1,4}\s+/.test(e)){let i=e.match(/^#{1,4}/)?.[0].length??2;t.push({type:"heading",level:i,text:e.replace(/^#{1,4}\s+/,"")}),o+=1;continue}if(/^>\s+/.test(e)){let i=[];while(o<n.length&&/^>\s+/.test((n[o]??"").trim()))i.push((n[o]??"").trim().replace(/^>\s+/,"")),o+=1;t.push({type:"quote",text:i.join(" ")});continue}if(/^[-*]\s+/.test(e)||/^\d+\.\s+/.test(e)){let i=/^\d+\.\s+/.test(e),f=[];while(o<n.length&&J((n[o]??"").trim())){let h=(n[o]??"").trim();if(i&&/^\d+\.\s+/.test(h))f.push(h.replace(/^\d+\.\s+/,""));else if(!i&&/^[-*]\s+/.test(h))f.push(h.replace(/^[-*]\s+/,""));else break;o+=1}t.push({type:"list",ordered:i,items:f});continue}let c=[];while(o<n.length&&!J((n[o]??"").trim())){let i=(n[o]??"").trim();if(!i)break;c.push(i),o+=1}t.push({type:"paragraph",text:c.join(" ")})}return t}import{CodeBlock as ts}from"@contractspec/lib.design-system";import{HStack as is,VStack as A}from"@contractspec/lib.ui-kit-web/ui/stack";import{BlockQuote as es,H2 as cs,H3 as rs,H4 as ps,Muted as F,P as G}from"@contractspec/lib.ui-kit-web/ui/typography";import{jsx as r,jsxs as us}from"react/jsx-runtime";var fs=new Set(["typescript","tsx","javascript","jsx","bash","shell","json","yaml","graphql","sql","python","go","rust","css","scss","html","markdown","text"]);function gs(s){if(!s)return"text";let n=s.toLowerCase();return fs.has(n)?n:"text"}function hs(s,n){if(s<=2)return r(cs,{children:n});if(s===3)return r(rs,{children:n});return r(ps,{children:n})}function K({content:s}){let n=X(s);if(!n.length)return r(F,{children:"No reference content available."});return r(A,{gap:"md",children:n.map((t,o)=>{switch(t.type){case"heading":return r(A,{children:hs(t.level,t.text)},o);case"paragraph":return r(G,{children:t.text},o);case"quote":return r(es,{children:t.text},o);case"code":return r(ts,{language:gs(t.language),code:t.code},o);case"list":return r(A,{gap:"xs",children:t.items.map((p,e)=>us(is,{gap:"sm",align:"start",children:[r(F,{children:t.ordered?`${e+1}.`:"\u2022"}),r(G,{className:"leading-relaxed",children:p})]},e))},o);default:return null}})})}import{ContractReferenceDataView as D}from"@contractspec/lib.contracts-spec/docs";import{DataViewRenderer as ds}from"@contractspec/lib.design-system";import{VStack as Ds}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as Z,jsxs as Ps}from"react/jsx-runtime";function u(s,n){return s.match(new RegExp(`- \\*\\*${n}\\*\\*: (.+)`,"i"))?.[1]?.trim()}function Is(s){if(!s)return;return s.replace(/<!--.*?-->/g,"").replace(/[ \t]+/g," ").replace(/\n{3,}/g,`

`).trim()}function U({entry:s,content:n}){let t=Is(s.summary),o=u(n,"Type"),p=u(n,"Version")??s.version,e=u(n,"Tags")?.split(",").map((I)=>I.trim()).filter(Boolean),c=u(n,"Owners")?.split(",").map((I)=>I.trim()).filter(Boolean),i=u(n,"Stability")??s.visibility,f={reference:{key:s.title??s.id,version:p,type:o,title:s.title??s.id,description:t,tags:e??s.tags,owners:c??s.owners,stability:i}},h={...D,meta:{...D.meta,title:s.title??D.meta.title,description:t??D.meta.description}};return Ps(Ds,{gap:"xl",children:[Z(ds,{spec:h,item:f}),Z(K,{content:n})]})}import{jsx as ls}from"react/jsx-runtime";function as({entry:s,content:n}){return ls(U,{entry:s,content:n})}export{as as DocsReferencePage,y as DocsReferenceIndexPage};
