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

`).trim()}function F(n){let o=B(n.summary),s=n.kind??(n.source==="generated"?"reference":void 0),i=n.visibility??(n.source==="generated"?"public":void 0);return{...n,summary:o,kind:s,visibility:i}}function K(n,o){if(!o)return!0;return[n.title,n.summary,n.id,...n.tags??[]].filter(Boolean).join(" ").toLowerCase().includes(o.toLowerCase())}function _({entries:n}){let[o,s]=v({}),i=M(()=>n.map(F),[n]),x=M(()=>{let t=o.query?.trim()??"";return i.filter((c)=>{if(o.kind&&c.kind!==o.kind)return!1;if(o.visibility&&c.visibility!==o.visibility)return!1;return K(c,t)})},[o,i]),r=T.render(A,{defaultValues:{query:o.query??"",visibility:o.visibility??"",kind:o.kind??""},overrides:{onSubmitOverride:(t)=>{let c=t;s({query:c.query??"",visibility:c.visibility??"",kind:c.kind??""})}}});return p(l,{gap:"xl",children:[p(l,{gap:"sm",children:[e(X,{children:"Reference"}),e(E,{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."})]}),e(l,{gap:"sm",className:"max-w-2xl",children:r}),e(G,{spec:O,items:x,emptyState:e(E,{children:"No reference docs match your filters."}),onSelect:(t)=>{if(t.route)window.location.assign(t.route)},renderActions:(t)=>{return p(J,{gap:"xs",justify:"end",children:[t.kind?e(D,{size:"sm",label:t.kind}):null,t.visibility?e(D,{size:"sm",label:t.visibility}):null,t.version?e(D,{size:"sm",label:`v${t.version}`}):null]})}})]})}import{jsx as U}from"react/jsx-runtime";async function cn(){let n=await k();return U(_,{entries:n})}export{cn as DocsReferenceIndexPage};
