// @bun
var{defineProperty:I,getOwnPropertyNames:$,getOwnPropertyDescriptor:h}=Object,D=Object.prototype.hasOwnProperty;function S(L){return this[L]}var g=(L)=>{var N=(C??=new WeakMap).get(L),O;if(N)return N;if(N=I({},"__esModule",{value:!0}),L&&typeof L==="object"||typeof L==="function"){for(var _ of $(L))if(!D.call(N,_))I(N,_,{get:S.bind(L,_),enumerable:!(O=h(L,_))||O.enumerable})}return C.set(L,N),N},C;var V=(L)=>L;function U(L,N){this[L]=V.bind(null,N)}var q=(L,N)=>{for(var O in N)I(L,O,{get:N[O],enumerable:!0,configurable:!0,set:U.bind(N,O)})};var B=(L,N)=>()=>(L&&(N=L(L=0)),N);var v={};q(v,{groupByToArray:()=>G,groupByMultiple:()=>w,groupBy:()=>E,getUniqueTags:()=>Y,getUniqueOwners:()=>F,getUniqueDomains:()=>u,filterBy:()=>W,GroupingStrategies:()=>P});function W(L,N){return L.filter((O)=>{if(N.tags?.length){if(!N.tags.some((A)=>O.meta.tags?.includes(A)))return!1}if(N.owners?.length){if(!N.owners.some((A)=>O.meta.owners?.includes(A)))return!1}if(N.stability?.length){if(!N.stability.includes(O.meta.stability??"stable"))return!1}if(N.domain){if(P.byDomain(O)!==N.domain)return!1}if(N.keyPattern){let _=O.meta.key??O.meta.key??"",A=N.keyPattern.replace(/\*/g,".*").replace(/\?/g,".");if(!new RegExp(`^${A}$`,"i").test(_))return!1}return!0})}function E(L,N){let O=new Map;for(let _ of L){let A=N(_),T=O.get(A);if(T)T.push(_);else O.set(A,[_])}return O}function G(L,N){let O=E(L,N);return Array.from(O.entries()).map(([_,A])=>({key:_,items:A}))}function w(L,N){let O=new Map;for(let _ of L){let A=N(_);for(let T of A){let z=O.get(T);if(z)z.push(_);else O.set(T,[_])}}return O}function Y(L){let N=new Set;for(let O of L)for(let _ of O.meta.tags??[])N.add(_);return Array.from(N).sort()}function F(L){let N=new Set;for(let O of L)for(let _ of O.meta.owners??[])N.add(_);return Array.from(N).sort()}function u(L){let N=new Set;for(let O of L)N.add(P.byDomain(O));return Array.from(N).sort()}var P;var H=B(()=>{P={byTag:(L)=>L.meta.tags?.[0]??"untagged",byAllTags:(L)=>L.meta.tags?.length?L.meta.tags:["untagged"],byOwner:(L)=>L.meta.owners?.[0]??"unowned",byDomain:(L)=>{return(L.meta.key??L.meta.key??"").split(".")[0]??"default"},byStability:(L)=>L.meta.stability??"stable",byUrlPath:(L)=>(N)=>{if(!N.path)return"root";return N.path.split("/").filter(Boolean).slice(0,L).join("/")||"root"}}});var J={Idea:"idea",InCreation:"in_creation",Experimental:"experimental",Beta:"beta",Stable:"stable",Deprecated:"deprecated"},b={PlatformCore:"platform.core",PlatformSigil:"platform.sigil",PlatformMarketplace:"platform.marketplace",PlatformMessaging:"platform.messaging",PlatformContent:"platform.content",PlatformFeatureFlags:"platform.featureflags",PlatformFinance:"platform.finance"},y=b,j={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"},a=j;H();import{compareVersions as d}from"compare-versions";var c=(L)=>`${L.meta.key}.v${L.meta.version}`;class x{contractType;items=new Map;constructor(L,N){this.contractType=L;if(N)N.forEach((O)=>this.register(O))}register(L){let N=c(L);if(this.items.has(N))throw Error(`Duplicate contract \`${this.contractType}\` ${N}`);return this.items.set(N,L),this}count(){return this.items.size}list(){return[...this.items.values()]}get(L,N){if(N!=null)return this.items.get(`${L}.v${N}`);let O;for(let[_,A]of this.items.entries()){if(!_.startsWith(`${L}.v`))continue;if(!O||d(A.meta.version,O.meta.version)>0)O=A}return O}has(L,N){return!!this.get(L,N)}filter(L){return W(this.list(),L)}listByTag(L){return this.list().filter((N)=>N.meta.tags?.includes(L))}listByOwner(L){return this.list().filter((N)=>N.meta.owners?.includes(L))}groupBy(L){return E(this.list(),L)}getUniqueTags(){return Y(this.list())}}function K(L){return L}var t=(L,N)=>`${L}.v${N}`;class f extends x{constructor(L){super("event",L)}}var M="control-plane",Q=[b.PlatformCore],X=[j.Automation,"control-plane","agent-runtime"],Z=J.Experimental;import{ScalarTypeEnum as R,SchemaModel as p}from"@contractspec/lib.schema";var k=new p({name:"ControlPlaneExecutionCompletedPayload",fields:{executionId:{type:R.ID(),isOptional:!1},runId:{type:R.ID(),isOptional:!1},completedAt:{type:R.DateTime(),isOptional:!1},outcome:{type:R.String_unsecure(),isOptional:!0}}}),AL=K({meta:{key:"controlPlane.execution.completed",version:"1.0.0",description:"Emitted when an execution run finishes successfully.",domain:M,owners:Q,tags:[...X,"execution"],stability:Z},payload:k});export{k as ControlPlaneExecutionCompletedPayload,AL as ControlPlaneExecutionCompletedEvent};
