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