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