var{defineProperty:H,getOwnPropertyNames:Q,getOwnPropertyDescriptor:W}=Object,X=Object.prototype.hasOwnProperty;function Y(b){return this[b]}var G=(b)=>{var h=(N??=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 Q(b))if(!X.call(h,z))H(h,z,{get:Y.bind(b,z),enumerable:!(j=W(b,z))||j.enumerable})}return N.set(b,h),h},N;var Z=(b)=>b;function _(b,h){this[b]=Z.bind(null,h)}var $=(b,h)=>{for(var j in h)H(b,j,{get:h[j],enumerable:!0,configurable:!0,set:_.bind(h,j)})};var O=(b,h)=>()=>(b&&(h=b(b=0)),h);var R={};$(R,{groupByToArray:()=>T,groupByMultiple:()=>U,groupBy:()=>E,getUniqueTags:()=>K,getUniqueOwners:()=>V,getUniqueDomains:()=>C,filterBy:()=>J,GroupingStrategies:()=>I});function J(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(I.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 T(b,h){let j=E(b,h);return Array.from(j.entries()).map(([z,A])=>({key:z,items:A}))}function U(b,h){let j=new Map;for(let z of b){let A=h(z);for(let D of A){let M=j.get(D);if(M)M.push(z);else j.set(D,[z])}}return j}function K(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 V(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 C(b){let h=new Set;for(let j of b)h.add(I.byDomain(j));return Array.from(h).sort()}var I;var P=O(()=>{I={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"}}});P();import{compareVersions as q}from"compare-versions";var B=(b)=>`${b.meta.key}.v${b.meta.version}`;class L{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 J(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 K(this.list())}}function u(b){return`${b.meta.key}.v${b.meta.version}`}class x extends L{constructor(b){super("data-view",b)}}export{u as dataViewKey,x as DataViewRegistry};
