var{defineProperty:G,getOwnPropertyNames:L,getOwnPropertyDescriptor:N}=Object,O=Object.prototype.hasOwnProperty;function Q(j){return this[j]}var W=(j)=>{var z=(H??=new WeakMap).get(j),B;if(z)return z;if(z=G({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var D of L(j))if(!O.call(z,D))G(z,D,{get:Q.bind(j,D),enumerable:!(B=N(j,D))||B.enumerable})}return H.set(j,z),z},H;var R=(j)=>j;function T(j,z){this[j]=R.bind(null,z)}var X=(j,z)=>{for(var B in z)G(j,B,{get:z[B],enumerable:!0,configurable:!0,set:T.bind(z,B)})};var Y=(j,z)=>()=>(j&&(z=j(j=0)),z);class J extends Error{capabilityKey;requiredVersion;constructor(j,z){let B=z?`.v${z}`:"";super(`Missing required capability: ${j}${B}`);this.name="CapabilityMissingError",this.capabilityKey=j,this.requiredVersion=z}}class F{capabilities;capabilityVersions;constructor(j){let z=new Set,B=new Map;for(let D of j)z.add(D.key),B.set(D.key,D.version);this.capabilities=z,this.capabilityVersions=B}hasCapability(j,z){if(!this.capabilities.has(j))return!1;if(z!=null)return this.capabilityVersions.get(j)===z;return!0}requireCapability(j,z){if(!this.hasCapability(j,z))throw new J(j,z)}hasAllCapabilities(j){return j.every((z)=>this.capabilities.has(z))}hasAnyCapability(j){return j.some((z)=>this.capabilities.has(z))}getMatchingCapabilities(j){if(!j.includes("*"))return this.capabilities.has(j)?[j]:[];let z=j.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*"),B=new RegExp(`^${z}$`);return[...this.capabilities].filter((D)=>B.test(D))}}function _(j){return new F(j)}function $(){return new F([])}function h(j){return new F(j)}export{$ as createEmptyCapabilityContext,_ as createCapabilityContext,h as createBypassCapabilityContext,J as CapabilityMissingError};
