// @bun
var{defineProperty:O,getOwnPropertyNames:z,getOwnPropertyDescriptor:J}=Object,Q=Object.prototype.hasOwnProperty;function X(S){return this[S]}var f=(S)=>{var A=(L??=new WeakMap).get(S),E;if(A)return A;if(A=O({},"__esModule",{value:!0}),S&&typeof S==="object"||typeof S==="function"){for(var N of z(S))if(!Q.call(A,N))O(A,N,{get:X.bind(S,N),enumerable:!(E=J(S,N))||E.enumerable})}return L.set(S,A),A},L;var Z=(S)=>S;function $(S,A){this[S]=Z.bind(null,A)}var V=(S,A)=>{for(var E in A)O(S,E,{get:A[E],enumerable:!0,configurable:!0,set:$.bind(A,E)})};var p=(S,A)=>()=>(S&&(A=S(S=0)),A);var q={};V(q,{groupByToArray:()=>B,groupByMultiple:()=>C,groupBy:()=>_,getUniqueTags:()=>D,getUniqueOwners:()=>G,getUniqueDomains:()=>U,filterBy:()=>h,GroupingStrategies:()=>T});function h(S,A){return S.filter((E)=>{if(A.tags?.length){if(!A.tags.some((H)=>E.meta.tags?.includes(H)))return!1}if(A.owners?.length){if(!A.owners.some((H)=>E.meta.owners?.includes(H)))return!1}if(A.stability?.length){if(!A.stability.includes(E.meta.stability??"stable"))return!1}if(A.domain){if(T.byDomain(E)!==A.domain)return!1}if(A.keyPattern){let N=E.meta.key??E.meta.key??"",H=A.keyPattern.replace(/\*/g,".*").replace(/\?/g,".");if(!new RegExp(`^${H}$`,"i").test(N))return!1}return!0})}function _(S,A){let E=new Map;for(let N of S){let H=A(N),I=E.get(H);if(I)I.push(N);else E.set(H,[N])}return E}function B(S,A){let E=_(S,A);return Array.from(E.entries()).map(([N,H])=>({key:N,items:H}))}function C(S,A){let E=new Map;for(let N of S){let H=A(N);for(let I of H){let M=E.get(I);if(M)M.push(N);else E.set(I,[N])}}return E}function D(S){let A=new Set;for(let E of S)for(let N of E.meta.tags??[])A.add(N);return Array.from(A).sort()}function G(S){let A=new Set;for(let E of S)for(let N of E.meta.owners??[])A.add(N);return Array.from(A).sort()}function U(S){let A=new Set;for(let E of S)A.add(T.byDomain(E));return Array.from(A).sort()}var T;var W=p(()=>{T={byTag:(S)=>S.meta.tags?.[0]??"untagged",byAllTags:(S)=>S.meta.tags?.length?S.meta.tags:["untagged"],byOwner:(S)=>S.meta.owners?.[0]??"unowned",byDomain:(S)=>{return(S.meta.key??S.meta.key??"").split(".")[0]??"default"},byStability:(S)=>S.meta.stability??"stable",byUrlPath:(S)=>(A)=>{if(!A.path)return"root";return A.path.split("/").filter(Boolean).slice(0,S).join("/")||"root"}}});var Y={Idea:"idea",InCreation:"in_creation",Experimental:"experimental",Beta:"beta",Stable:"stable",Deprecated:"deprecated"},w={PlatformCore:"platform.core",PlatformSigil:"platform.sigil",PlatformMarketplace:"platform.marketplace",PlatformMessaging:"platform.messaging",PlatformContent:"platform.content",PlatformFeatureFlags:"platform.featureflags",PlatformFinance:"platform.finance"},y=w,a={Spots:"spots",Collectivity:"collectivity",Marketplace:"marketplace",Sellers:"sellers",Auth:"auth",Login:"login",Signup:"signup",Guide:"guide",Docs:"docs",I18n:"i18n",Incident:"incident",Automation:"automation",Hygiene:"hygiene"},n=a;W();import{compareVersions as F}from"compare-versions";var v=(S)=>`${S.meta.key}.v${S.meta.version}`;class x{contractType;items=new Map;constructor(S,A){this.contractType=S;if(A)A.forEach((E)=>this.register(E))}register(S){let A=v(S);if(this.items.has(A))throw Error(`Duplicate contract \`${this.contractType}\` ${A}`);return this.items.set(A,S),this}count(){return this.items.size}list(){return[...this.items.values()]}get(S,A){if(A!=null)return this.items.get(`${S}.v${A}`);let E;for(let[N,H]of this.items.entries()){if(!N.startsWith(`${S}.v`))continue;if(!E||F(H.meta.version,E.meta.version)>0)E=H}return E}has(S,A){return!!this.get(S,A)}filter(S){return h(this.list(),S)}listByTag(S){return this.list().filter((A)=>A.meta.tags?.includes(S))}listByOwner(S){return this.list().filter((A)=>A.meta.owners?.includes(S))}groupBy(S){return _(this.list(),S)}getUniqueTags(){return D(this.list())}}function b(S){return S}var t=(S,A)=>`${S}.v${A}`;class u extends x{constructor(S){super("event",S)}}var d="harness",K=["platform.harness"],P=[a.Automation,"harness","evidence","evaluation"],j=Y.Experimental;import{ScalarTypeEnum as R,SchemaModel as l}from"@contractspec/lib.schema";var c=new l({name:"HarnessStepStartedPayload",fields:{runId:{type:R.ID(),isOptional:!1},stepId:{type:R.ID(),isOptional:!1},stepKey:{type:R.NonEmptyString(),isOptional:!1},mode:{type:R.String_unsecure(),isOptional:!1},startedAt:{type:R.DateTime(),isOptional:!1}}}),HS=b({meta:{key:"harness.step.started",version:"1.0.0",description:"Emitted when a harness step starts.",domain:d,owners:K,tags:[...P,"step","started"],stability:j},payload:c});export{c as HarnessStepStartedPayload,HS as HarnessStepStartedEvent};
