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