// @bun
var Z=Object.defineProperty;var _=(b)=>b;function $(b,f){this[b]=_.bind(null,f)}var Kb=(b,f)=>{for(var j in f)Z(b,j,{get:f[j],enumerable:!0,configurable:!0,set:$.bind(f,j)})};var Lb=(b,f)=>()=>(b&&(f=b(b=0)),f);import{EventRegistry as z,OperationSpecRegistry as C}from"@contractspec/lib.contracts-spec";import{DataViewRegistry as E}from"@contractspec/lib.contracts-spec/data-views";import{ContractReferenceDataView as R,ContractReferenceQuery as P,DocsGenerateCommand as I,DocsGeneratedEvent as q,DocsIndexDataView as T,DocsIndexQuery as h,DocsLayoutPresentation as m,DocsPublishCommand as S,DocsPublishedEvent as u,DocsReferencePagePresentation as l,DocsSearchForm as k,ExampleCatalogDataView as v}from"@contractspec/lib.contracts-spec/docs";import{FormRegistry as d}from"@contractspec/lib.contracts-spec/forms";import{PresentationRegistry as n}from"@contractspec/lib.contracts-spec/presentations";import{serializeDataViewSpec as y,serializeEventSpec as t,serializeFormSpec as o,serializeOperationSpec as p,serializePresentationSpec as g}from"@contractspec/lib.contracts-spec/serialization";var B=null;function i(){let b=new C;return b.register(h).register(P).register(I).register(S),b}function c(){if(!B)B=i();return B}function K(b,f){return c().get(b,f)}var D=null;function a(){let b=new z;return b.register(q).register(u),b}function r(){if(!D)D=a();return D}function L(b,f){return r().get(b,f)}var F=null;function s(){let b=new n;return b.register(m).register(l),b}function e(){if(!F)F=s();return F}function M(b,f){return e().get(b,f)}var G=null;function bb(){let b=new E;return b.register(T).register(R).register(v),b}function fb(){if(!G)G=bb();return G}function N(b,f){return fb().get(b,f)}var H=null;function jb(){let b=new d;return b.register(k),b}function wb(){if(!H)H=jb();return H}function O(b,f){return wb().get(b)}function Q(b,f){let j=K(b,f);return p(j)??void 0}function U(b,f){let j=L(b,f);return t(j)??void 0}function V(b,f){let j=M(b,f);return g(j)??void 0}function W(b,f){let j=N(b,f);return y(j)??void 0}function X(b,f){let j=O(b,f);return o(j)??void 0}function xb(){B=null}function Ab(){D=null}function Bb(){F=null}function Db(){G=null}function Fb(){H=null}function Xb(){xb(),Ab(),Bb(),Db(),Fb()}import{defaultDocRegistry as Gb}from"@contractspec/lib.contracts-spec/docs";function Hb(b){return b?.trim().toLowerCase()??""}function Jb(b){for(let f of b??[]){let j=Gb.get(f);if(j)return j.route}return}function Y(b,f,j,x){let A=b.meta.title??b.meta.key,w=Jb(b.meta.docId),J=b.meta.description;return{key:b.meta.key,version:b.meta.version,type:f,title:A,description:J,markdown:[`# ${A}`,`- Key: ${b.meta.key}`,`- Type: ${f}`,`- Version: ${b.meta.version}`,w?`- Docs route: ${w}`:"",J?`
${J}`:""].filter(Boolean).join(`
`),...w?{route:w}:{},...j?{schema:j}:{},...x?{policy:x}:{},tags:b.meta.tags??[],owners:b.meta.owners??[],stability:b.meta.stability}}function $b(b){let f=b.includeSchema??!1,j=Hb(b.type),x=K(b.key,b.version);if(x&&(!j||j==="operation"||j===x.meta.kind))return{reference:Y(x,x.meta.kind,f?Q(b.key,b.version):void 0,x.policy)};let A=[{type:"data-view",spec:N(b.key,b.version),schema:f?W(b.key,b.version):void 0},{type:"form",spec:O(b.key,b.version),schema:f?X(b.key,b.version):void 0},{type:"presentation",spec:M(b.key,b.version),schema:f?V(b.key,b.version):void 0},{type:"event",spec:L(b.key,b.version),schema:f?U(b.key,b.version):void 0}];for(let w of A)if(w.spec&&(!j||j===w.type))return{reference:Y(w.spec,w.type,w.schema)};throw Error(`Contract reference not found: ${b.key}`)}export{$b as resolveContractReference};
