// @bun
var $=Object.defineProperty;var C=(n)=>n;function q(n,o){this[n]=C.bind(null,o)}var v=(n,o)=>{for(var s in o)$(n,s,{get:o[s],enumerable:!0,configurable:!0,set:q.bind(o,s)})};var Q=(n,o)=>()=>(n&&(o=n(n=0)),o);var B="docs-index.manifest.json";var D={};v(D,{listGeneratedDocs:()=>b,getGeneratedDocById:()=>y,getDocsIndexManifest:()=>j});import{readFile as M}from"fs/promises";import*as f from"path";import{fileURLToPath as S}from"url";function k(n){if(!n)return"_common";if(n.includes("/")){let[o]=n.split("/");return o||"_common"}return"_common"}async function T(){if(!m)m=M(f.join(u,B),"utf8").then((n)=>JSON.parse(n));return m}function V(n){let o=n.contentRoot??".";if(o==="../../../../../../../generated/docs")return H;return f.join(u,o)}async function A(n){let o=G.get(n);if(o)return o;let s=M(f.join(u,n),"utf8").then((t)=>JSON.parse(t));return G.set(n,s),s}async function b(){if(!E)E=(async()=>{let n=await T();return(await Promise.all(n.chunks.map((s)=>A(s.file)))).flat()})();return E}async function j(){return T()}async function y(n){let o=await T(),s=k(n),t=o.chunks.find((e)=>e.key===s);if(!t)return null;let i=(await A(t.file)).find((e)=>e.id===n);if(!i||!i.contentPath)return null;let r=f.join(V(o),i.contentPath);try{let e=await M(r,"utf8");return{entry:i,content:e}}catch{return null}}var u,H,m=null,E=null,G;var I=Q(()=>{u=f.dirname(S(import.meta.url)),H=f.join(u,"../../../../../../../generated/docs"),G=new Map});async function Fn(){let{getDocsIndexManifest:n}=await Promise.resolve().then(() => (I(),D));return n()}async function N(){let{listGeneratedDocs:n}=await Promise.resolve().then(() => (I(),D));return n()}async function Kn(n){let{getGeneratedDocById:o}=await Promise.resolve().then(() => (I(),D));return o(n)}import{DocsIndexDataView as nn,DocsSearchForm as on}from"@contractspec/lib.contracts-spec/docs";import{DataViewList as tn,formRenderer as sn,StatusChip as R}from"@contractspec/lib.design-system";import{HStack as en,VStack as _}from"@contractspec/lib.ui-kit-web/ui/stack";import{H1 as rn,Muted as O}from"@contractspec/lib.ui-kit-web/ui/typography";import{useMemo as L,useState as cn}from"react";import{jsx as g,jsxs as x}from"react/jsx-runtime";function pn(n){if(!n)return;return n.replace(/<!--.*?-->/g,"").replace(/[ \t]+/g," ").replace(/\n{3,}/g,`

`).trim()}function dn(n){let o=pn(n.summary),s=n.kind??(n.source==="generated"?"reference":void 0),t=n.visibility??(n.source==="generated"?"public":void 0);return{...n,summary:o,kind:s,visibility:t}}function fn(n,o){if(!o)return!0;return[n.title,n.summary,n.id,...n.tags??[]].filter(Boolean).join(" ").toLowerCase().includes(o.toLowerCase())}function W({entries:n}){let[o,s]=cn({}),t=L(()=>n.map(dn),[n]),p=L(()=>{let r=o.query?.trim()??"";return t.filter((e)=>{if(o.kind&&e.kind!==o.kind)return!1;if(o.visibility&&e.visibility!==o.visibility)return!1;return fn(e,r)})},[o,t]),i=sn.render(on,{defaultValues:{query:o.query??"",visibility:o.visibility??"",kind:o.kind??""},overrides:{onSubmitOverride:(r)=>{let e=r;s({query:e.query??"",visibility:e.visibility??"",kind:e.kind??""})}}});return x(_,{gap:"xl",children:[x(_,{gap:"sm",children:[g(rn,{children:"Reference"}),g(O,{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:i}),g(tn,{spec:nn,items:p,emptyState:g(O,{children:"No reference docs match your filters."}),onSelect:(r)=>{if(r.route)window.location.assign(r.route)},renderActions:(r)=>{return x(en,{gap:"xs",justify:"end",children:[r.kind?g(R,{size:"sm",label:r.kind}):null,r.visibility?g(R,{size:"sm",label:r.visibility}):null,r.version?g(R,{size:"sm",label:`v${r.version}`}):null]})}})]})}import{jsx as an}from"react/jsx-runtime";async function gn(){let n=await N();return an(W,{entries:n})}var hn=/^##\s+Metadata[\s\S]*?(?=^##\s|^#\s|Z)/m;function un(n){return n.replace(/^#\s+.*\n+/m,"").replace(hn,"")}function J(n){return/^#{1,4}\s+/.test(n)||/^```/.test(n)||/^\s*[-*]\s+/.test(n)||/^\s*\d+\.\s+/.test(n)||/^>\s+/.test(n)}function X(n){let o=un(n).split(/\r?\n/),s=[],t=0;while(t<o.length){let p=o[t]??"";if(p.startsWith("<!-- @generated")){t+=1;continue}let i=p.trim();if(!i){t+=1;continue}if(i.startsWith("```")){let e=i.slice(3).trim(),d=[];t+=1;while(t<o.length&&!(o[t]??"").trim().startsWith("```"))d.push(o[t]??""),t+=1;t+=1,s.push({type:"code",language:e||"text",code:d.join(`
`)});continue}if(/^#{1,4}\s+/.test(i)){let e=i.match(/^#{1,4}/)?.[0].length??2;s.push({type:"heading",level:e,text:i.replace(/^#{1,4}\s+/,"")}),t+=1;continue}if(/^>\s+/.test(i)){let e=[];while(t<o.length&&/^>\s+/.test((o[t]??"").trim()))e.push((o[t]??"").trim().replace(/^>\s+/,"")),t+=1;s.push({type:"quote",text:e.join(" ")});continue}if(/^[-*]\s+/.test(i)||/^\d+\.\s+/.test(i)){let e=/^\d+\.\s+/.test(i),d=[];while(t<o.length&&J((o[t]??"").trim())){let a=(o[t]??"").trim();if(e&&/^\d+\.\s+/.test(a))d.push(a.replace(/^\d+\.\s+/,""));else if(!e&&/^[-*]\s+/.test(a))d.push(a.replace(/^[-*]\s+/,""));else break;t+=1}s.push({type:"list",ordered:e,items:d});continue}let r=[];while(t<o.length&&!J((o[t]??"").trim())){let e=(o[t]??"").trim();if(!e)break;r.push(e),t+=1}s.push({type:"paragraph",text:r.join(" ")})}return s}import{CodeBlock as Dn}from"@contractspec/lib.design-system";import{HStack as In,VStack as w}from"@contractspec/lib.ui-kit-web/ui/stack";import{BlockQuote as ln,H2 as Pn,H3 as mn,H4 as En,Muted as F,P as K}from"@contractspec/lib.ui-kit-web/ui/typography";import{jsx as c,jsxs as _n}from"react/jsx-runtime";var Mn=new Set(["typescript","tsx","javascript","jsx","bash","shell","json","yaml","graphql","sql","python","go","rust","css","scss","html","markdown","text"]);function Tn(n){if(!n)return"text";let o=n.toLowerCase();return Mn.has(o)?o:"text"}function Rn(n,o){if(n<=2)return c(Pn,{children:o});if(n===3)return c(mn,{children:o});return c(En,{children:o})}function Z({content:n}){let o=X(n);if(!o.length)return c(F,{children:"No reference content available."});return c(w,{gap:"md",children:o.map((s,t)=>{switch(s.type){case"heading":return c(w,{children:Rn(s.level,s.text)},t);case"paragraph":return c(K,{children:s.text},t);case"quote":return c(ln,{children:s.text},t);case"code":return c(Dn,{language:Tn(s.language),code:s.code},t);case"list":return c(w,{gap:"xs",children:s.items.map((p,i)=>_n(In,{gap:"sm",align:"start",children:[c(F,{children:s.ordered?`${i+1}.`:"\u2022"}),c(K,{className:"leading-relaxed",children:p})]},i))},t);default:return null}})})}import{ContractReferenceDataView as l}from"@contractspec/lib.contracts-spec/docs";import{DataViewRenderer as xn}from"@contractspec/lib.design-system";import{VStack as wn}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as U,jsxs as Gn}from"react/jsx-runtime";function h(n,o){return n.match(new RegExp(`- \\*\\*${o}\\*\\*: (.+)`,"i"))?.[1]?.trim()}function Bn(n){if(!n)return;return n.replace(/<!--.*?-->/g,"").replace(/[ \t]+/g," ").replace(/\n{3,}/g,`

`).trim()}function Y({entry:n,content:o}){let s=Bn(n.summary),t=h(o,"Type"),p=h(o,"Version")??n.version,i=h(o,"Tags")?.split(",").map((P)=>P.trim()).filter(Boolean),r=h(o,"Owners")?.split(",").map((P)=>P.trim()).filter(Boolean),e=h(o,"Stability")??n.visibility,d={reference:{key:n.title??n.id,version:p,type:t,title:n.title??n.id,description:s,tags:i??n.tags,owners:r??n.owners,stability:e}},a={...l,meta:{...l.meta,title:n.title??l.meta.title,description:s??l.meta.description}};return Gn(wn,{gap:"xl",children:[U(xn,{spec:a,item:d}),U(Z,{content:o})]})}import{jsx as Nn}from"react/jsx-runtime";function An({entry:n,content:o}){return Nn(Y,{entry:n,content:o})}export{An as DocsReferencePage,gn as DocsReferenceIndexPage};
