// @bun
var{defineProperty:H,getOwnPropertyNames:X,getOwnPropertyDescriptor:Y}=Object,Z=Object.prototype.hasOwnProperty;function _(b){return this[b]}var G=(b)=>{var h=(Q??=new WeakMap).get(b),j;if(h)return h;if(h=H({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var z of X(b))if(!Z.call(h,z))H(h,z,{get:_.bind(b,z),enumerable:!(j=Y(b,z))||j.enumerable})}return Q.set(b,h),h},Q;var $=(b)=>b;function I(b,h){this[b]=$.bind(null,h)}var O=(b,h)=>{for(var j in h)H(b,j,{get:h[j],enumerable:!0,configurable:!0,set:I.bind(h,j)})};var P=(b,h)=>()=>(b&&(h=b(b=0)),h);var C={};O(C,{groupByToArray:()=>R,groupByMultiple:()=>T,groupBy:()=>E,getUniqueTags:()=>L,getUniqueOwners:()=>U,getUniqueDomains:()=>V,filterBy:()=>K,GroupingStrategies:()=>J});function K(b,h){return b.filter((j)=>{if(h.tags?.length){if(!h.tags.some((A)=>j.meta.tags?.includes(A)))return!1}if(h.owners?.length){if(!h.owners.some((A)=>j.meta.owners?.includes(A)))return!1}if(h.stability?.length){if(!h.stability.includes(j.meta.stability??"stable"))return!1}if(h.domain){if(J.byDomain(j)!==h.domain)return!1}if(h.keyPattern){let z=j.meta.key??j.meta.key??"",A=h.keyPattern.replace(/\*/g,".*").replace(/\?/g,".");if(!new RegExp(`^${A}$`,"i").test(z))return!1}return!0})}function E(b,h){let j=new Map;for(let z of b){let A=h(z),D=j.get(A);if(D)D.push(z);else j.set(A,[z])}return j}function R(b,h){let j=E(b,h);return Array.from(j.entries()).map(([z,A])=>({key:z,items:A}))}function T(b,h){let j=new Map;for(let z of b){let A=h(z);for(let D of A){let N=j.get(D);if(N)N.push(z);else j.set(D,[z])}}return j}function L(b){let h=new Set;for(let j of b)for(let z of j.meta.tags??[])h.add(z);return Array.from(h).sort()}function U(b){let h=new Set;for(let j of b)for(let z of j.meta.owners??[])h.add(z);return Array.from(h).sort()}function V(b){let h=new Set;for(let j of b)h.add(J.byDomain(j));return Array.from(h).sort()}var J;var W=P(()=>{J={byTag:(b)=>b.meta.tags?.[0]??"untagged",byAllTags:(b)=>b.meta.tags?.length?b.meta.tags:["untagged"],byOwner:(b)=>b.meta.owners?.[0]??"unowned",byDomain:(b)=>{return(b.meta.key??b.meta.key??"").split(".")[0]??"default"},byStability:(b)=>b.meta.stability??"stable",byUrlPath:(b)=>(h)=>{if(!h.path)return"root";return h.path.split("/").filter(Boolean).slice(0,b).join("/")||"root"}}});W();import{compareVersions as q}from"compare-versions";var B=(b)=>`${b.meta.key}.v${b.meta.version}`;class M{contractType;items=new Map;constructor(b,h){this.contractType=b;if(h)h.forEach((j)=>this.register(j))}register(b){let h=B(b);if(this.items.has(h))throw Error(`Duplicate contract \`${this.contractType}\` ${h}`);return this.items.set(h,b),this}count(){return this.items.size}list(){return[...this.items.values()]}get(b,h){if(h!=null)return this.items.get(`${b}.v${h}`);let j;for(let[z,A]of this.items.entries()){if(!z.startsWith(`${b}.v`))continue;if(!j||q(A.meta.version,j.meta.version)>0)j=A}return j}has(b,h){return!!this.get(b,h)}filter(b){return K(this.list(),b)}listByTag(b){return this.list().filter((h)=>h.meta.tags?.includes(b))}listByOwner(b){return this.list().filter((h)=>h.meta.owners?.includes(b))}groupBy(b){return E(this.list(),b)}getUniqueTags(){return L(this.list())}}class x extends M{constructor(b){super("presentation",b)}}export{x as PresentationRegistry};
