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

`).trim()}function H(n){let o=S(n.summary),t=n.kind??(n.source==="generated"?"reference":void 0),s=n.visibility??(n.source==="generated"?"public":void 0);return{...n,summary:o,kind:t,visibility:s}}function z(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,t]=Q({}),s=G(()=>n.map(H),[n]),h=G(()=>{let e=o.query?.trim()??"";return s.filter((c)=>{if(o.kind&&c.kind!==o.kind)return!1;if(o.visibility&&c.visibility!==o.visibility)return!1;return z(c,e)})},[o,s]),a=Z.render(W,{defaultValues:{query:o.query??"",visibility:o.visibility??"",kind:o.kind??""},overrides:{onSubmitOverride:(e)=>{let c=e;t({query:c.query??"",visibility:c.visibility??"",kind:c.kind??""})}}});return m(l,{gap:"xl",children:[m(l,{gap:"sm",children:[r(b,{children:"Reference"}),r(w,{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."})]}),r(l,{gap:"sm",className:"max-w-2xl",children:a}),r(Y,{spec:L,items:h,emptyState:r(w,{children:"No reference docs match your filters."}),onSelect:(e)=>{if(e.route)window.location.assign(e.route)},renderActions:(e)=>{return m($,{gap:"xs",justify:"end",children:[e.kind?r(x,{size:"sm",label:e.kind}):null,e.visibility?r(x,{size:"sm",label:e.visibility}):null,e.version?r(x,{size:"sm",label:`v${e.version}`}):null]})}})]})}import{jsx as q}from"react/jsx-runtime";async function un(){let n=await k();return q(_,{entries:n})}export{un as DocsReferenceIndexPage};
