@cratis/screenplay-language 4.122.0 → 4.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ import{a as c}from"./chunk-AYDF3IFZ.js";var Ll="screenplay",Qy={id:Ll,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Gy=["domain","import","concept","type","policy","purpose","persona","authentication","identity","module","layout","theme","ui","feature","slice","event","public","system","eventsource","operation","command","query","projection","capture","reaction","runs","reducer","readmodel","trigger","screen","dialog","form","contribute","constraint","specification","case","parameter","example","seed","behavior","exposure","instance"];var Vo=["depends","direction","inbound","outbound","description","documentation","template","profile","require","authenticated","role","claim","subject","authorize","validate","produces","reads","as","handler","performer","observable","identifier","reason","from","when","given","then","arguments","result","clock","exactly","error","message","not","empty","rule","matches","all","max","min","length","today","true","false","and","or","by","filter","data","via","component","context","property","literal","icons","packages","outlet","display","scopes","reexposes","operations","items","toolbar","item","presentation","exposes","mode","oneWay","twoWay","null","propagate","clear","preserve","expected","action","navigate","to","label","section","table","summary","title","column","field","on","unique","file","concurrency","eventSource","sourceType","streamType","streamId","tag","for","readmodel","no","when","every","at","where","invokes","contains","starts","with","provider","uses","parameter","order","open","close","refresh","set","notify","confirm","raise","interval","success","failure","click","double","select","submit","change","load","unload","enter","leave","info","warning"],_y=["csharp","typescript","react","html","sql"],ar=["command","arguments","tenant","causedBy","causation","occurred","identity"],sr=["subject","name","userName"],At=["id","name","userName","isAuthenticated","roles","claims"],lr=["StateChange","StateView","Automation","Translate"],zn=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Zy=["pii","personal","secret"],jl=/^\s*(?:module|feature|slice\s+\w+|type|command|event|readmodel|reducer|projection|capture|reaction|screen|dialog|form|contribute|specification|case|constraint|persona|policy|behavior|layout|theme|ui\s+profile|trigger|authentication|identity|seed|system|eventsource|operation|screen\s+template|dialog\s+template|produces\s+event|validate|handler|on)\b[^=]*$/,Ky={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:jl,action:{indentAction:1}}],indentationRules:{increaseIndentPattern:/^\s*(module|feature|slice|policy|persona|authentication|identity|provider|event|command|query|type|screen|projection|capture|reaction|trigger|constraint|specification|layout|template|validate|produces|handler|implementation(?=\s*$)|performer|rule|section|action|otherwise(?=\s*$|\s+execute\b)|concurrency|seed|for|when|then|arguments|result|every|at|invokes|on)\b.*$/,decreaseIndentPattern:/(?!)/}};function dn(t){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(t);return{name:e?.[1]??t,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}c(dn,"typeReferenceSymbol");function Hy(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}c(Hy,"typeReferenceText");function Ae(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}c(Ae,"withoutComment");function ne(t){return t.length-t.trimStart().length}c(ne,"indentOf");function cr(t){return t.trim().split(/\s+/)[0]??""}c(cr,"firstWord");function De(t){let e=new Array(t.length).fill(!1),n=!1;for(let i=0;i<t.length;i++){if(/^\s*```(?:[a-z]+)?\s*$/.test(t[i])&&(!n||/^\s*```\s*$/.test(t[i]))){e[i]=!0,n=!n;continue}e[i]=n}return e}c(De,"fenceMap");function Qo(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Ae(t[s]);if(a.trim().length===0)continue;let d=ne(a);d<o&&(r.push(cr(a)),o=d)}return r}c(Qo,"enclosingChain");function th(t,e,n,i){for(let r=n-1;r>=0&&i>0;r--){if(e[r])continue;let o=Ae(t[r]);if(o.trim().length!==0&&ne(o)<i)return o.trim()}}c(th,"nearestEnclosingLine");function nh(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Ae(t[s]);if(a.trim().length===0)continue;let d=ne(a);d<o&&(r.push(a.trim()),o=d)}return r}c(nh,"enclosingHeaders");var Go="EventContext",pn={EventContext:[{name:"eventType",type:"EventType",kind:"composite",description:"The type of the event - its identifier, generation and whether it is a tombstone."},{name:"eventSourceType",type:"EventSourceType",kind:"value",description:"The type of the event source the event was appended to."},{name:"eventSourceId",type:"EventSourceId",kind:"value",description:"The identifier of the event source the event was appended to - the value $eventSourceId resolves."},{name:"eventStreamType",type:"EventStreamType",kind:"value",description:"The type of the event stream the event belongs to."},{name:"eventStreamId",type:"EventStreamId",kind:"value",description:"The identifier of the event stream the event belongs to."},{name:"sequenceNumber",type:"EventSequenceNumber",kind:"value",description:"The position of the event in its event sequence."},{name:"occurred",type:"DateTimeOffset",kind:"value",description:"When the event occurred - the time it was appended unless one was given."},{name:"eventStore",type:"EventStoreName",kind:"value",description:"The name of the event store the event belongs to."},{name:"namespace",type:"EventStoreNamespaceName",kind:"value",description:"The namespace within the event store the event belongs to."},{name:"correlationId",type:"CorrelationId",kind:"value",description:"The correlation identifier the event was appended with."},{name:"causation",type:"IEnumerable<Causation>",kind:"collection",description:"The chain of causes that led to the event - a collection, not addressable below."},{name:"causedBy",type:"Identity",kind:"composite",description:"The identity that caused the event."},{name:"tags",type:"IEnumerable<Tag>",kind:"collection",description:"The tags the event was appended with - a collection, not addressable below."},{name:"hash",type:"EventHash",kind:"value",description:"The hash of the event content."},{name:"observationState",type:"EventObservationState",kind:"value",description:"Whether the observer sees the event for the first time or again on replay - differs between live processing and replay."},{name:"subject",type:"Subject",kind:"value",description:"The compliance subject the event is about - the event source identifier unless one was given."},{name:"subjectIsEventSourceId",type:"bool",kind:"value",description:"Whether the subject is the event source identifier."}],EventType:[{name:"id",type:"EventTypeId",kind:"value",description:"The identifier of the event type."},{name:"generation",type:"EventTypeGeneration",kind:"value",description:"The generation of the event type."},{name:"tombstone",type:"bool",kind:"value",description:"Whether the event is a tombstone event."}],EventSourceType:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventSourceId:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventStreamType:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventStreamId:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventSequenceNumber:[{name:"value",type:"ulong",kind:"value",description:"The underlying ulong value."}],DateTimeOffset:[{name:"Week",type:"int",kind:"function",description:"The ISO 8601 week of the year the value falls in."}],EventStoreName:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventStoreNamespaceName:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],CorrelationId:[{name:"value",type:"Guid",kind:"value",description:"The underlying Guid value."}],Identity:[{name:"subject",type:"string",kind:"value",description:"The subject identifier of the identity."},{name:"name",type:"string",kind:"value",description:"The display name of the identity."},{name:"userName",type:"string",kind:"value",description:"The user name of the identity."},{name:"onBehalfOf",type:"Identity",kind:"composite",description:"The identity this identity acted on behalf of, if any - an identity with the same members."}],EventHash:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],Subject:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventTypeId:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventTypeGeneration:[{name:"value",type:"uint",kind:"value",description:"The underlying uint value."}]},dr=[{path:"eventType",name:"eventType",type:"EventType",kind:"composite",description:"The type of the event - its identifier, generation and whether it is a tombstone."},{path:"eventType.id",name:"id",type:"EventTypeId",kind:"value",description:"The identifier of the event type."},{path:"eventType.id.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"eventType.generation",name:"generation",type:"EventTypeGeneration",kind:"value",description:"The generation of the event type."},{path:"eventType.generation.value",name:"value",type:"uint",kind:"value",description:"The underlying uint value."},{path:"eventType.tombstone",name:"tombstone",type:"bool",kind:"value",description:"Whether the event is a tombstone event."},{path:"eventSourceType",name:"eventSourceType",type:"EventSourceType",kind:"value",description:"The type of the event source the event was appended to."},{path:"eventSourceType.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"eventSourceId",name:"eventSourceId",type:"EventSourceId",kind:"value",description:"The identifier of the event source the event was appended to - the value $eventSourceId resolves."},{path:"eventSourceId.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"eventStreamType",name:"eventStreamType",type:"EventStreamType",kind:"value",description:"The type of the event stream the event belongs to."},{path:"eventStreamType.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"eventStreamId",name:"eventStreamId",type:"EventStreamId",kind:"value",description:"The identifier of the event stream the event belongs to."},{path:"eventStreamId.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"sequenceNumber",name:"sequenceNumber",type:"EventSequenceNumber",kind:"value",description:"The position of the event in its event sequence."},{path:"sequenceNumber.value",name:"value",type:"ulong",kind:"value",description:"The underlying ulong value."},{path:"occurred",name:"occurred",type:"DateTimeOffset",kind:"value",description:"When the event occurred - the time it was appended unless one was given."},{path:"occurred.Week",name:"Week",type:"int",kind:"function",description:"The ISO 8601 week of the year the value falls in."},{path:"eventStore",name:"eventStore",type:"EventStoreName",kind:"value",description:"The name of the event store the event belongs to."},{path:"eventStore.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"namespace",name:"namespace",type:"EventStoreNamespaceName",kind:"value",description:"The namespace within the event store the event belongs to."},{path:"namespace.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"correlationId",name:"correlationId",type:"CorrelationId",kind:"value",description:"The correlation identifier the event was appended with."},{path:"correlationId.value",name:"value",type:"Guid",kind:"value",description:"The underlying Guid value."},{path:"causation",name:"causation",type:"IEnumerable<Causation>",kind:"collection",description:"The chain of causes that led to the event - a collection, not addressable below."},{path:"causedBy",name:"causedBy",type:"Identity",kind:"composite",description:"The identity that caused the event."},{path:"causedBy.subject",name:"subject",type:"string",kind:"value",description:"The subject identifier of the identity."},{path:"causedBy.name",name:"name",type:"string",kind:"value",description:"The display name of the identity."},{path:"causedBy.userName",name:"userName",type:"string",kind:"value",description:"The user name of the identity."},{path:"causedBy.onBehalfOf",name:"onBehalfOf",type:"Identity",kind:"composite",description:"The identity this identity acted on behalf of, if any - an identity with the same members."},{path:"tags",name:"tags",type:"IEnumerable<Tag>",kind:"collection",description:"The tags the event was appended with - a collection, not addressable below."},{path:"hash",name:"hash",type:"EventHash",kind:"value",description:"The hash of the event content."},{path:"hash.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"observationState",name:"observationState",type:"EventObservationState",kind:"value",description:"Whether the observer sees the event for the first time or again on replay - differs between live processing and replay."},{path:"subject",name:"subject",type:"Subject",kind:"value",description:"The compliance subject the event is about - the event source identifier unless one was given."},{path:"subject.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"subjectIsEventSourceId",name:"subjectIsEventSourceId",type:"bool",kind:"value",description:"Whether the subject is the event source identifier."}];function pr(t,e){if(t.kind==="function")return e===t.name||e===`${t.name}()`;let n=t.name[0].toUpperCase()+t.name.slice(1);return e===n||e.length>0&&e[0].toUpperCase()+e.slice(1)===n}c(pr,"namesEventContextMember");var ur=pn[Go];function Nl(t){let e=ur;for(let n of t){let i=e.find(r=>pr(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=pn[i.type]??[]}return e}c(Nl,"eventContextMembersAfter");function sh(t){return t.length===0?void 0:Nl(t.slice(0,-1))?.find(n=>pr(n,t[t.length-1]))}c(sh,"eventContextMemberAt");function fr(t){let e,n=ur;for(let i of t.split(".")){if(i.length===0)return{status:"missing",member:e,expected:n};if(e?.kind==="collection")return{status:"belowCollection",member:e,segment:i,expected:[]};let r=n.find(o=>pr(o,i));if(!r)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:n};e=r,n=r.kind==="function"?[]:pn[r.type]??[]}return{status:"known",member:e,expected:[]}}c(fr,"resolveEventContextPath");function lh(){return["**$eventContext**","","Metadata about the event being projected. Paths are checked against the event-context catalog; `causation` and `tags` are collections and cannot be addressed below.","","**Members:**",...ur.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
2
+ `)}c(lh,"describeEventContext");function ch(t,e){let n=e.kind==="collection"||e.kind==="function"?[]:pn[e.type]??[],i=[`**$eventContext.${t}**: \`${e.type}\``,"",e.description];return n.length>0&&i.push("",`**Members:** ${n.map(r=>`\`${r.name}\``).join(", ")}`),i.join(`
3
+ `)}c(ch,"describeEventContextMember");var ht={label:"documentation",insertText:"documentation\n ```markdown\n ${1:Reasoning, assumptions or rejected alternatives}\n ```",documentation:"One nonempty authoring-only Markdown block; report-only (PLAY0270), with no executable effect."};var un={label:"purpose",insertText:"purpose ${1:Name}",documentation:"Adds a declared processing purpose to the union covering this slice and its enclosing containers."},fh=[{label:"description",insertText:'description "${1:processing intent}"',documentation:"Describes the processing, not a legal verdict."},{label:"basis",insertText:"basis ${1|consent,contract,legalObligation,vitalInterests,publicTask,legitimateInterests|}",documentation:"One Art. 6(1) lawful basis, with an optional quoted reference."},{label:"interest",insertText:'interest "${1:legitimate interests pursued}"',documentation:"Statement accompanying basis legitimateInterests."},{label:"condition",insertText:"condition ${1|explicitConsent,employmentLaw,vitalInterests,notForProfit,madePublic,legalClaims,substantialPublicInterest,healthCare,publicHealth,research|}",documentation:"Art. 9(2) condition for special-category data."},{label:"authorization",insertText:'authorization "${1:authorization in law}"',documentation:"Art. 10 authorization for criminal-offence data."},{label:"subjects",insertText:"subjects ${1:customer}",documentation:"Comma-separated open identifiers for categories of data subjects."},{label:"retention",insertText:'retention "${1:period or criteria}"',documentation:"Declared retention, not enforced."},{label:"recipient",insertText:'recipient "${1:recipient category}"',documentation:"Repeatable recipient category."},{label:"transfer",insertText:'transfer "${1:destination}" safeguard "${2:safeguard}"',documentation:"Repeatable destination and safeguards."},{label:"erasure exception",insertText:"erasure exception ${1|expression,legalObligation,publicTask,publicHealth,archiving,legalClaims|}",documentation:"Declared Art. 17(3) exception; does not change Chronicle per-subject erasure."}];var It=[{label:"example",insertText:"example ${1:Name} : ${2:Type}\n ${3:property} = ${4:value}",documentation:"One possibly partial event, command or read-model fixture. Step assignments override its values; no implicit defaults."}];var mr=[{label:"on",insertText:"on ${1|click,select,submit,change,load,unload,enter,leave|}\n ${2:execute command}",documentation:"Wires what happens on an interaction - a click, a submit, entering or leaving the screen."},{label:"uses",insertText:"uses ${1:Behavior}",documentation:"Attaches a named behavior declared at the top level."}],ql=[un,ht,...It,{label:"description",insertText:'description "${1:what this module is for}"',documentation:"A human-readable description."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"Policies that must pass for everything in the module."},{label:"depends on",insertText:"depends on ${1:Name}",documentation:"Declares an allowed module or feature dependency. Opts this container into independent explicit-reference checks."},{label:'import "\u2026"',insertText:'import "${1:*/*.play}"',documentation:"Imports `.play` files into this module \u2014 their top level is the module's body."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Groups related slices into a vertical feature."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a module-level UI screen."},{label:"screen template",insertText:"screen template ${1:Name}\n fits slot ${2:content}\n\n ${3:slot}",documentation:"Declares a reusable screen shape that fits a slot of the shell."},{label:"dialog template",insertText:"dialog template ${1:Name}\n ${2:body}\n ${3:actions}",documentation:"Declares a reusable dialog shape that opens over the shell."},{label:"form",insertText:'form ${1:Name} for ${2:Command}\n field ${3:property} label "${4:Label}"',documentation:"Declares a form bound to a command."},{label:"contribute",insertText:'contribute to ${1:Navigation}\n navigate to ${2:Screen}\n label "${3:Label}"',documentation:"Contributes an entry to a slot of the shell, such as navigation."},...mr],Bl=[un,ht,...It,{label:"description",insertText:'description "${1:what this feature is for}"',documentation:"A human-readable description."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"Policies that must pass for everything in the feature."},{label:"depends on",insertText:"depends on ${1:Name}",documentation:"Declares an allowed module or feature dependency. Sibling feature names resolve before module names."},{label:'import "\u2026"',insertText:'import "${1:*.play}"',documentation:"Imports `.play` files into this feature \u2014 their top level is the feature's body."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Declares a nested sub-feature."},{label:"slice StateChange",insertText:"slice StateChange ${1:Name}\n ",documentation:"A command \u2192 events flow; something that changes the system."},{label:"slice StateView",insertText:"slice StateView ${1:Name}\n ",documentation:"A query + projection + screen; something that reads the system."},{label:"slice Automation",insertText:"slice Automation ${1:Name}\n ",documentation:"A reaction or reducer; something that runs when something happens."},{label:"slice Translate",insertText:"slice Translate ${1:Name}\n ",documentation:"A capture; converts external data into events."},{label:"contribute",insertText:'contribute to ${1:Navigation}\n navigate to ${2:Screen}\n label "${3:Label}"',documentation:"Contributes an entry to a slot of the shell, such as navigation."},...mr],xh=[ht,{label:"description",insertText:'description "${1:what one instance holds}"',documentation:"A human-readable description."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the file this read model is realized by."},{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the read model \u2014 a name and a type reference."}],vh=[{label:"description",insertText:'description "${1:what the reducer does}"',documentation:"A human-readable description."},{label:"on",insertText:"on ${1:EventType}\n ```csharp\n ${2}\n ```",documentation:"A rule applied when the event occurs, in code or from a file."}],$h=[{label:"description",insertText:'description "${1:input surface intent}"',documentation:"Report-only description of the form."},{label:"populate via query",insertText:"populate via query ${1:Query} by ${2:parameter}",documentation:"Fills the form from a query before it is shown."},{label:"populate from item",insertText:"populate from item",documentation:"Fills the form from the item the screen was opened for."},{label:"field",insertText:'field ${1:property} label "${2:Label}"',documentation:"A form field bound to a command property."},...mr],bh=[{label:"navigate to",insertText:"navigate to ${1:Screen}",documentation:"The screen the entry opens."},{label:"label",insertText:'label "${1:Label}"',documentation:"The text of the entry."},{label:"order",insertText:"order ${1:10}",documentation:"Where the entry sits among the others; lower comes first."}],kh=[{label:"description",insertText:'description "${1:what the behavior does}"',documentation:"A human-readable description."},{label:"parameter",insertText:"parameter ${1:name} ${2:Type}",documentation:"A value the behavior is given where it is attached."},{label:"order",insertText:"order ${1:10}",documentation:"The order behaviors attached to the same element run in."},{label:"on",insertText:"on ${1|click,select,submit,change,load,unload,enter,leave|}\n ${2:execute command}",documentation:"Wires what happens on an interaction."}],Ge=c((t,e,n)=>({label:t,insertText:e,documentation:n}),"step"),Yl=[Ge("execute","execute ${1:command}","Runs a command."),Ge("navigate to","navigate to ${1:Screen}","Opens a screen."),Ge("open","open ${1:Dialog}","Opens a dialog."),Ge("close","close","Closes the dialog."),Ge("refresh","refresh ${1:query}","Reloads a query."),Ge("set","set ${1:name} ${2:value}","Sets a value."),Ge("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),Ge("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),Ge("raise","raise ${1:Trigger}","Raises a trigger.")],Eh=[Ge("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),Ge("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...Yl],Ch=[{label:"description",insertText:'description "${1:who they are}"',documentation:"A human-readable description."},{label:"policy",insertText:"policy ${1:PolicyName}",documentation:"A policy this persona holds."}],Ph=[{label:"provider",insertText:"provider ${1:Name}",documentation:"An identity provider."},{label:"provider (named)",insertText:"provider ${1:Kind} name ${2:Name}",documentation:"An identity provider of a kind, under its own name."}],Ah=[{label:"for",insertText:'for ${1:"event-source-id"}\n ${2:EventType}\n ${3:property} = ${4:value}',documentation:"Events to seed for one event source id."}],Ih=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],wh=[{label:"target platform",insertText:"target platform ${1:web}",documentation:"The platforms the profile is for."},{label:"target size",insertText:"target size ${1|compact,regular|}",documentation:"The screen sizes the profile is for."},{label:"packages",insertText:"packages\n ${1:Package}",documentation:"The component packages the profile uses."},{label:"layout",insertText:"layout ${1:Layout}",documentation:"The layout of the profile."},{label:"theme",insertText:"theme ${1:Theme}",documentation:"The theme of the profile."}],Fl=[{label:"slot",insertText:"${1:slot}",documentation:"A named slot of the shell."},{label:"slot contributes",insertText:"${1:slot} contributes ${2:Name}",documentation:"A slot other declarations contribute to, such as `navigation contributes Navigation`."},{label:"arrangement",insertText:`arrangement flow
4
+ column
5
+ \${1:slot}`,documentation:"How the slots are placed."}],Oh=[{label:"fits slot",insertText:"fits slot ${1:content}",documentation:"The slot of the shell the template fits."},...Fl,{label:"on",insertText:"on ${1|enter,leave,load,unload|}\n ${2:refresh query}",documentation:"Wires what happens on an interaction."}];var qh=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],Me=c(t=>`\`\`\`${t}
6
+ \${1}
7
+ \`\`\``,"fenced"),Bh=[{label:"description",insertText:'description "${1:caller details}"',documentation:"Describes the caller metadata."},{label:"detail from claim",insertText:'${1:detail} ${2:Type} from claim "${3:claim}"',documentation:"One typed detail sourced from a token claim."},{label:"detail from query",insertText:"${1:detail} ${2:Type} from query ${3:Query} by \\$identity.id",documentation:"A keyed, single-result query authorized without additional caller details."},{label:"detail from code",insertText:"${1:detail} ${2:Type}\n ```csharp\n ${3:return value;}\n ```",documentation:"An opaque inline source; authoring metadata, not executable."},{label:"detail from file",insertText:"${1:detail} ${2:Type}\n file ${3:Path}",documentation:"One file source; no refresh or cache directives."}];function Yh(t){let e=[...new Map((t.identityDetails??[]).map(n=>[n.name,n])).values()];return[...Gl,...e.filter(n=>!At.includes(n.name)).map(n=>({label:`$identity.${n.name}`,insertText:`\\$identity.${n.name}`,detail:n.type,documentation:"Declared caller detail. Authoring metadata only; executable reads report PLAY0268 until admitted (#600)."}))]}c(Yh,"contextVariableEntries");var Fh=[{label:"identity",insertText:'identity\n ${1:detail} ${2:Type} from claim "${3:claim}"',documentation:"Typed additional caller details; authoring metadata only, at most one block per application."},{label:"purpose",insertText:'purpose ${1:Name}\n description "${2:processing intent}"\n basis ${3|consent,contract,legalObligation,vitalInterests,publicTask,legitimateInterests|}',documentation:"Report-only processing metadata. Not legal advice; referenced by module, feature and slice."},...It,{label:"eventsource",insertText:"eventsource ${1:Name}\n identifier ${2:Type}\n stream ${3:Name}",documentation:"Application-owned source with nested streams, admitted by ESM v8. Pin the stored name before renaming a source with stored events; Default is reserved."},{label:"system",insertText:'system ${1:Name}\n description "${2:external system}"',documentation:"Application-scoped external system; not admitted by any supported executable model (ESM) version yet."},{label:"import",insertText:"import ${1:Module}.${2:Type}",documentation:"Imports a type from another module by its qualified name."},{label:"import from",insertText:'import ${1:Module}.${2:Event} from "${3:origin}"',documentation:"Imports a public event contract with a nonblank opaque origin, not a file path. An import has no local shape, so executable binding still refuses it with PLAY0268."},{label:'import "\u2026"',insertText:'import "${1:**/*.play}"',documentation:"Imports other `.play` files by path or glob, relative to this file's folder, as whole documents of the application."},{label:"concept",insertText:"concept ${1:Name} : ${2|Uuid,String,Int,Decimal,Bool,Date,DateTime|}",documentation:"Declares a formalized value type wrapping a primitive."},{label:"concept (enum)",insertText:"concept ${1:Name} : Enum\n ${2:value}",documentation:"Declares an enumeration concept with a fixed set of values."},{label:"concept (pii with reason)",insertText:'concept ${1:Name} : ${2|String,Uuid,Int,Decimal,Bool,Date,DateTime|} pii\n pii reason "${3:why this value is personal data}"',documentation:"Declares a personal-data concept together with the reason it is personal data."},{label:"type",insertText:"type ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a composite value type \u2014 a named shape built from several properties."},{label:"policy",insertText:"policy ${1:Name}\n require ${2:authenticated}",documentation:"Declares a named authorization rule for commands and queries."},{label:"module",insertText:"module ${1:Name}\n ",documentation:"Declares the top-level namespace \u2014 maps to a bounded context."},{label:"domain",insertText:"domain ${1:Name}",documentation:"The domain the file belongs to \u2014 optional, at most one per file, before everything else."},{label:"persona",insertText:'persona ${1:Name}\n description "${2:who they are}"',documentation:"A named role interacting with the application, with the policies it holds."},{label:"authentication",insertText:"authentication\n provider ${1:Name}\n ${2:setting} ${3:value}",documentation:"Declares the identity providers of the application \u2014 at most one block per file."},{label:"seed",insertText:"seed\n for ${1:EventSourceId}\n ${2:EventType}",documentation:"Declares events to seed into the event store per event source id."},{label:"layout",insertText:"layout ${1:Name}\n ${2:slot}",documentation:"Declares the application shell with named slots."},{label:"theme",insertText:"theme ${1:Name}\n compatible with ${2:Package}",documentation:"Declares a theme and the component packages it is compatible with."},{label:"ui profile",insertText:"ui profile ${1:Name}\n target platform ${2:web}\n layout ${3:Layout}\n theme ${4:Theme}",documentation:"Binds a target platform and size to a layout, theme and component packages."},{label:"behavior",insertText:"behavior ${1:Name}\n on ${2:click}\n ${3:execute command}",documentation:"A named interaction wiring, attached to a screen, form or dialog with `uses`."},{label:"trigger",insertText:"trigger ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an integration signal a reaction can run on."}],Uh=[{label:"uses",insertText:"uses ${1:System}",documentation:"Exactly one application-scoped external system."},{label:"description",insertText:'description "${1:intent}"',documentation:"Describes operation intent, without requiring code."},{label:"input",insertText:"${1:input} ${2:Type}",documentation:"Typed operation input; no identifier or generated modifier."},{label:"execute",insertText:'execute\n description "${1:effect}"',documentation:"Optional execution intent; not admitted by any supported executable model (ESM) version yet."},{label:"compensate",insertText:'compensate\n description "${1:undo intent}"',documentation:"Optional compensation intent; not admitted by any supported executable model (ESM) version yet."}],Ul=[{label:"hint",insertText:'hint "${1:implementation guidance}"',documentation:"Ordered authoring guidance; not an executable implementation role."},{label:"file",insertText:"file ${1:Path}",documentation:"Selects the phase\u2019s sole source attachment."},...["csharp","typescript","react","html","sql"].map(t=>({label:t,insertText:Me(t),documentation:"Selects the phase\u2019s sole inline source; not admitted by any supported executable model (ESM) version yet."}))],Wh=[{label:"description",insertText:'description "${1:phase intent}"',documentation:"A description-only phase is valid, pending intent."},{label:"implementation",insertText:'implementation\n hint "${1:guidance}"',documentation:"Hints with optional source; phase owns File/Code, wrapper owns hints only."},...Ul.filter(t=>t.label!=="hint")],zh=[{label:"description",insertText:'description "${1:what this value represents}"',documentation:"Report-only authoring description; not a validation or compliance note."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"pii reason",insertText:'pii reason "${1:why this value is personal data}"',documentation:"A free-text concept note, not a lawful basis."},{label:"secret reason",insertText:'secret reason "${1:why this value is an operational secret}"',documentation:"Records why the secret marker applies."},{label:"secret scope",insertText:"secret scope ${1|subject,namespace,global|}",documentation:"Explicit encryption scope; omitted scope keeps Chronicle\u2019s Subject default."},{label:"pii special",insertText:"pii special ${1|racialOrEthnicOrigin,politicalOpinions,religiousOrPhilosophicalBeliefs,tradeUnionMembership,genetic,biometric,health,sexLifeOrSexualOrientation|}",documentation:"GDPR Art. 9(1) special category of personal data."},{label:"pii criminal",insertText:"pii criminal",documentation:"Personal data relating to criminal convictions and offenses (GDPR Art. 10)."},{label:"validate",insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:"Validation rules that travel with the value everywhere it appears."}],Vh=[{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"description",insertText:'description "${1:what this shape represents}"',documentation:"A human-readable description of the type."},{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the type \u2014 a name and a type reference."}],_o=[un,ht,...It,{label:"operation",insertText:"operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type}",documentation:"Reusable slice-owned operation intent; not admitted by any supported executable model (ESM) version yet."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"public event",insertText:"public event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a public event: a contract this application publishes. Admitted by ESM v9; an outbound Translate slice produces it through a projection that targets it."},{label:"event from",insertText:'event ${1:Name} from "${2:origin}"\n ${3:property} ${4:Type}',documentation:"An event with an opaque origin naming the application that owns it, not a path or declaration reference. It is a public event admitted by ESM v9; consume it with a capture over source events."},{label:"direction",insertText:"direction ${1|inbound,outbound|}",documentation:"Translate direction, inbound or outbound, admitted by ESM v9. No transport or delivery guarantee is implied."},{label:"event",insertText:"event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an event type \u2014 an immutable, past-tense fact."},{label:"event generation",insertText:"event ${1:Name} generation ${2:2}\n ${3:property} ${4:Type}",documentation:"Declares a complete numbered event generation; start at 1 and do not skip a number."},{label:"command",insertText:"command ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a command \u2014 an imperative intent that produces events."},{label:"query",insertText:"query ${1:Name} => ${2:ReadModel}",documentation:"Declares a read-side entry point mapping to a return type."},{label:"query observable",insertText:"query ${1:Name} => observable ${2:ReadModel}",documentation:"Declares a live read \u2014 the query keeps pushing as the read model changes, instead of answering once."},{label:"readmodel",insertText:"readmodel ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares the shape of a read model \u2014 its properties \u2014 that a projection, reducer or query fills and returns."},{label:"reducer",insertText:"reducer ${1:Name} => ${2:ReadModel}\n on ${3:EventType}\n ```csharp\n ${4}\n ```",documentation:"Declares a reducer building a read model from events with imperative code, for what a projection cannot express."},{label:"specification",insertText:"specification ${1:Name}\n given ${2:EventType}\n when ${3:Command}\n then ${4:EventType}",documentation:"Given/when/then acceptance criteria for the slice."},{label:"projection",insertText:"projection ${1:Name} => ${2:ReadModel}\n from ${3:EventType}",documentation:"Declares how events project into a read model (PDL)."},{label:"capture",insertText:"capture ${1:Name}\n source ${2:api}",documentation:"Declares a change data capture converting external data into events (CDL)."},{label:"reaction",insertText:"reaction ${1:Name}\n when ${2:Trigger}",documentation:"Declares behavior that runs when something happens."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a UI screen."},{label:"constraint",insertText:"constraint ${1:Name}\n unique ${2:property} on ${3:EventType}",documentation:"Declares a server-side rule enforced before events are committed."}],Qh=[ht,{label:"property",insertText:"${1:property} ${2:Type}",documentation:"An input of the command \u2014 a name and a type reference."},{label:"produces operation",insertText:"produces operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type} = ${5:source}",documentation:"Declares ordered operation intent; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"returns property",insertText:"returns @${1:property}",documentation:"Scalar response from a direct command property, only on acceptance. Executable as ESM v7."},{label:"returns block",insertText:"returns\n ${1:field} = ${2:property}",documentation:"Unnamed record response with inferred or explicit field types, only on acceptance. Executable as ESM v7."},{label:"produces event",insertText:"produces event ${1:Name}\n ${2:property} ${3:Type} = ${4:source}",documentation:"Declares a slice-owned generation-1 event and maps its properties. An omitted for uses the command identifier."},{label:"identifier property",insertText:"${1:property} ${2:Type} identifier",documentation:"Marks the property a runtime resolves the event source id from. At most one per command."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"References the policies that must pass for the command to execute."},{label:"reads",insertText:"reads ${1:View} by ${2:property}",documentation:"Declares a view the command consults. Executable binding is not yet supported."},{label:"reads as",insertText:"reads ${1:View} as ${2:alias} by ${3:property}",documentation:"Names one instance of a view; every instance needs a unique alias when reading the same view more than once."},{label:"validate",insertText:'validate\n ${1:property} not empty message "${2:message}"',documentation:"Declarative validation rules with messages."},{label:"validate csharp",insertText:`validate
8
+ ${Me("csharp")}`,documentation:"Imperative validation in C#, yielding the message of every rule the artifact breaks."},{label:"produces",insertText:"produces ${1:EventType}\n ${2:property} = ${3:source}",documentation:"Declares the event the command emits, with property mappings."},{label:"produces when",insertText:"produces when ${1:condition}\n ${2:EventType}\n ${3:property} = ${4:source}",documentation:"Conditionally emits an event when the condition holds."},{label:"description",insertText:'description "${1:what the command asks for}"',documentation:"A human-readable description."},{label:"concurrency",insertText:"concurrency\n ${1|eventSource,sourceType,streamType,streamId,events|}",documentation:"The scope of the concurrency check made when the command appends events."},{label:"handler",insertText:`handler
9
+ `,documentation:"Fully imperative command implementation \u2014 file reference or inline C#, instead of produces."}],Wl=[{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the event \u2014 a name and a type reference."},{label:"description",insertText:'description "${1:what happened}"',documentation:"Authoring metadata, as one line or a text/markdown fence."},{label:"documentation",insertText:"documentation\n ```markdown\n ${1:Details}\n ```",documentation:"Authoring-only Markdown documentation."},{label:"id",insertText:'id "${1:OldName}"',documentation:"Preserves a previous persisted event name after a rename. Leave absent for new events."},{label:"tag",insertText:"tag ${1:audit}",documentation:"An event-type tag stamped on every occurrence."}],Gh=[...Wl,{label:"for",insertText:"for ${1:identifier}",documentation:"Explicitly names the command identifier used as the event source."},{label:"property mapping",insertText:"${1:property} ${2:Type} = ${3:source}",documentation:"Declares and maps an event property on one line."}],_h=[{label:"when",insertText:"when ${1:condition}",documentation:"Guards the produced event with a condition."}],Zh=[{label:"hint",insertText:'hint "${1:implementation guidance}"',documentation:"Ordered nonblank guidance for a handler implementation. Not an execution guarantee."},{label:"file",insertText:"file ${1:Path}",documentation:"Selects one existing model-relative attachment."},...["csharp","typescript","react","html","sql"].map(t=>({label:t,insertText:Me(t),documentation:"Selects one inline payload. Handler execution remains unsupported."}))],Kh=[{label:"implementation",insertText:'implementation\n hint "${1:implementation guidance}"',documentation:"Handler-only implementation intent with optional file or tagged fence. With no payload it is pending."},{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the command implementation to an external C# file."},{label:"csharp",insertText:Me("csharp"),documentation:"Inline C# returning the events to append."}],Jh=[{label:"description",insertText:'description "${1:what this query is trying to accomplish}"',documentation:"What the query is for, in prose \u2014 what a generator or reviewer works from."},{label:"by",insertText:"by ${1:param} ${2:Type}",documentation:"Declares the identifying parameter of the query."},{label:"filter",insertText:"filter ${1:param} ${2:Type} optional",documentation:"Declares an optional filter parameter supplied by the caller."},{label:"filter from context",insertText:"filter ${1:param} ${2:Type} from $context.${3|tenant,causedBy.subject,occurred|}",documentation:"Declares a parameter filled from the query context instead of the caller."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"References the policies that must pass for the query to execute."},{label:"performer",insertText:`performer
10
+ `,documentation:"The code that performs the query \u2014 a file reference or an inline csharp/sql block."}],Hh=[{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the query implementation to an external file."},{label:"csharp",insertText:Me("csharp"),documentation:"Inline C# returning the query result, with the QueryContext in scope as context."},{label:"sql",insertText:Me("sql"),documentation:"Inline SQL returning the query result."}],Xh=[{label:"description",insertText:'description "${1:invariant intent}"',documentation:"Report-only description, distinct from the violation message."},{label:"unique",insertText:"unique ${1:property} on ${2:EventType}",documentation:"Enforces a unique property value across an event type."},{label:"unique event",insertText:"unique event ${1:EventType}",documentation:"Enforces that the event type occurs at most once per event source."},{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the constraint to a custom C# implementation."}],eS=[ht,{label:"runs as system",insertText:"runs as system",documentation:"Authenticated system identity with no roles for returned commands. Syntax-only (PLAY0268, #383)."},{label:"runs as system role",insertText:'runs as system role "${1:Role}"',documentation:"Exact system roles for every returned or invoked command, not imperative pipeline calls. Syntax-only (PLAY0268, #383)."},{label:"description",insertText:'description "${1:what this reaction does}"',documentation:"What the reaction does \u2014 a complete statement of intent before any code exists."},{label:"when",insertText:"when ${1:Trigger}",documentation:"An event, a declared trigger or a host signal that sets the reaction off. A trigger needs no body."},{label:"every",insertText:"every ${1:15} ${2|seconds,minutes,hours,days|}",documentation:"Runs the reaction on an interval."},{label:"at",insertText:"at ${1:08:00}",documentation:"Runs the reaction at a time of day \u2014 every day unless narrowed with `on <Weekday>` or `on day <n>`."},{label:"where",insertText:"where ${1:condition}",documentation:"Narrows which occurrences actually run the reaction."}],tS=[{label:"reads",insertText:"reads ${1:View}",documentation:"The view this trigger consults. Optionally use `as <alias> by <trigger value>`; clock triggers take no values and cannot use `by`."},{label:"description",insertText:'description "${1:what this reaction does}"',documentation:"What this particular reaction does \u2014 enough on its own, with no file to point at."},{label:"produces",insertText:"produces ${1:EventType}",documentation:"An event the reaction appends."},{label:"invokes",insertText:"invokes ${1:Command}",documentation:"A command the reaction hands on. A command is asked for, not produced \u2014 it may still be rejected."},{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the reaction to an external C# file."},{label:"csharp",insertText:Me("csharp"),documentation:"Inline C# returning event side effects."}],St="Syntax-only; reaction refusal handling and redelivery are not yet executable (PLAY0268).",nS=[{label:"on refused",insertText:`on refused
11
+ acknowledge`,documentation:`Handles validation and constraint refusals, not authorization. ${St}`},{label:"on refused by validation",insertText:`on refused by validation
12
+ acknowledge`,documentation:`Handles validation refusals. ${St}`},{label:"on refused by constraint",insertText:"on refused by constraint ${1:Name}\n acknowledge",documentation:`Handles a named constraint refusal; omit the name for any constraint. ${St}`},{label:"on refused by authorization",insertText:`on refused by authorization
13
+ acknowledge`,documentation:`Explicitly handles unauthorized results, never Unsupported. ${St}`}],iS=[{label:"acknowledge",insertText:"acknowledge",documentation:`Acknowledges alone, without productions. ${St}`},{label:"produces",insertText:"produces ${1:Event}\n ${2:reason} = \\$refusal.reason",documentation:`Records the refusal with ordinary event productions. ${St}`}],rS=[{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"description",insertText:'description "${1:when this occurs}"',documentation:"What makes an occurrence of this trigger happen."},{label:"value",insertText:"${1:name} ${2:Type}",documentation:"A value an occurrence hands the reaction. The type is optional."}],oS=[{label:"parameter",insertText:"parameter ${1:name} ${2:Type}",documentation:"One typed value, supplied exactly once by every case."},{label:"case",insertText:"case ${1:Name}\n ${2:parameter} = ${3:value}",documentation:"One named complete set of concrete parameter values."},{label:"given caller as",insertText:"given caller as ${1:Persona}",documentation:"An authenticated deterministic witness of a top-level persona; no body. Use explicit callers for negation, ownership claims and implementations."},{label:"description",insertText:'description "${1:rule or case witnessed}"',documentation:"Authoring-only description of what this scenario demonstrates."},{label:"when redelivered",insertText:"when redelivered ${1:Event} to ${2:Reaction}\n for ${3:value}",documentation:`Selects exactly one given event occurrence for one event-trigger reaction; does not append it again. ${St}`},{label:"given operation fails",insertText:"given operation ${1:Name} fails",documentation:"Failure fixture leaf; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"then operation",insertText:"then operation ${1:Name}\n ${2:input} = ${3:value}",documentation:"Partial requested-operation assertion; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"then compensated",insertText:"then compensated ${1:Name}",documentation:"Compensation assertion leaf; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"given",insertText:"given ${1:EventType}\n ${2:property} = ${3:value}",documentation:"Establishes prior state by replaying an event before the command runs."},{label:"given readmodel",insertText:"given readmodel ${1:ReadModelType}\n ${2:property} = ${3:value}",documentation:"Establishes prior read model state directly."},{label:"when",insertText:"when ${1:CommandType}\n ${2:property} = ${3:value}",documentation:"The command being exercised."},{label:"then",insertText:"then ${1:EventType}\n ${2:property} = ${3:value}",documentation:"An event expected to be produced by the command."},{label:"then readmodel",insertText:"then readmodel ${1:ReadModelType}\n ${2:property} = ${3:value}",documentation:"The read model state expected after the command."},{label:"then no readmodel",insertText:"then no readmodel ${1:ReadModelType} for ${2:key}",documentation:"Asserts that precisely one keyed read-model instance does not exist; another key may still be present."},{label:"then query",insertText:"then query ${1:QueryName}\n arguments\n ${2:argument} = ${3:value}\n result\n ${4:property} = ${5:value}",documentation:"The ordered query results expected for explicit arguments. Remove the result block to assert an empty result."},{label:"then error",insertText:"then error",documentation:"A rejection, for a reason this specification does not name."},{label:'then error "..."',insertText:'then error "${1:reason}"',documentation:"A rejection, for the named reason."},{label:"given clock",insertText:'given clock "${1:2026-10-05T08:00:00Z}"',documentation:"The instant the scenario happens at - the occurrence time of everything it does. At most once."},{label:"given capture",insertText:"given capture ${1:Capture}\n ${2:field} = ${3:value}",documentation:"A record the capture's source held before."},{label:"when clock",insertText:'when clock "${1:2026-10-05T09:00:00Z}"',documentation:"The clock reaches an instant, as the action."},{label:"when trigger",insertText:"when trigger ${1:Trigger}\n ${2:value} = ${3:value}",documentation:"An application trigger fires, as the action."},{label:"when capture",insertText:"when capture ${1:Capture}\n ${2:field} = ${3:value}",documentation:"The record a capture's source holds now, as the action."},{label:"when query",insertText:"when query ${1:Query}\n ${2:argument} = ${3:value}",documentation:"Performs a query, as the action."},{label:"then result",insertText:"then result\n ${1:property} = ${2:value}",documentation:"One result the query performed by `when query` returns, in order."},{label:"then no result",insertText:"then no result",documentation:"The query performed by `when query` returns nothing."},{label:"then no events",insertText:"then no events",documentation:"Syntax-only assertion of no new events after a non-append action (PLAY0268); cannot accompany event, error or denial expectations."}],Zo={given:[{label:"operation",insertText:"operation ${1:Name} fails",documentation:"Syntax-only failure fixture; no children."},{label:"clock",insertText:'clock "${1:2026-10-05T08:00:00Z}"',documentation:"The instant the scenario happens at - the occurrence time of everything it does."},{label:"capture",insertText:"capture ${1:Capture}\n ${2:field} = ${3:value}",documentation:"A record the capture's source held before. Repeat it for several records."},{label:"readmodel",insertText:"readmodel ${1:ReadModelType}\n ${2:property} = ${3:value}",documentation:"Establishes prior read model state directly."},{label:"caller",insertText:"caller\n ${1:authenticated}",documentation:"The identity the scenario runs as."}],when:[{label:"redelivered",insertText:"redelivered ${1:Event} to ${2:Reaction}\n for ${3:value}",documentation:`Selects exactly one given event occurrence for one reaction. ${St}`},{label:"clock",insertText:'clock "${1:2026-10-05T09:00:00Z}"',documentation:"The clock reaches an instant - what a scheduled reaction responds to."},{label:"trigger",insertText:"trigger ${1:Trigger}\n ${2:value} = ${3:value}",documentation:"An application trigger fires, with the values it carries."},{label:"capture",insertText:"capture ${1:Capture}\n ${2:field} = ${3:value}",documentation:"The record a capture's source holds now."},{label:"query",insertText:"query ${1:Query}\n ${2:argument} = ${3:value}",documentation:"Performs a query; assert what it returns with `then result` or `then no result`."},{label:"append",insertText:"append ${1:EventType}\n ${2:property} = ${3:value}",documentation:"An event occurs, instead of a command being executed."}],then:[{label:"operation",insertText:"operation ${1:Name}\n ${2:input} = ${3:value}",documentation:"Syntax-only partial operation assertion; not admitted by any supported executable model (ESM) version yet."},{label:"compensated",insertText:"compensated ${1:Name}",documentation:"Syntax-only compensation assertion; no children."},{label:"returns value",insertText:"returns ${1:value}",documentation:"Scalar response expectation, compared by semantic value equality. Executable as ESM v7."},{label:"returns block",insertText:"returns\n ${1:field} = ${2:value}",documentation:"Nonempty subset of response fields asserted by name. Executable as ESM v7."},{label:"result",insertText:"result\n ${1:property} = ${2:value}",documentation:"One result the query performed by `when query` returns, in order."},{label:"result exactly",insertText:"result exactly\n ${1:property} = ${2:value}",documentation:"One result, with every property asserted."},{label:"no result",insertText:"no result",documentation:"The query performed by `when query` returns nothing."},{label:"no events",insertText:"no events",documentation:"Syntax-only assertion of no new events after a non-append action; not yet executable (PLAY0268)."},{label:"readmodel",insertText:"readmodel ${1:ReadModelType}\n ${2:property} = ${3:value}",documentation:"The read model state expected afterwards."},{label:"error",insertText:'error "${1:reason}"',documentation:"A rejection, for the named reason."},{label:"denied",insertText:"denied",documentation:"The action is denied to the caller."}]},zl=[{label:"hint",insertText:'hint "${1:predicate guidance}"',documentation:"Ordered nonblank authoring guidance. Does not execute or confirm the predicate."},{label:"file",insertText:"file ${1:Path}",documentation:"The sole named-rule predicate attachment."},{label:"csharp",insertText:Me("csharp"),documentation:"Opaque named-rule predicate returning a bool. Requires an admitting target."}],aS=[{label:"implementation",insertText:'implementation\n hint "${1:predicate guidance}"',documentation:"Command named-rule intent with optional file or tagged fence. Pending intent cannot bind."},...zl.filter(t=>t.label!=="hint")],sS=[{label:"file",insertText:"file ${1:Path}",documentation:"Gives the named predicate its implementation in an external C# file."},{label:"csharp",insertText:Me("csharp"),documentation:"Gives the named predicate its implementation as inline C# returning a bool."}],lS=[{label:"description",insertText:'description "${1:authorization intent}"',documentation:"Report-only description; does not supply an implementation."},{label:"require authenticated",insertText:"require authenticated",documentation:"Requires an authenticated caller."},{label:"require role",insertText:'require role "${1:role}"',documentation:"Requires the caller to have a role."},{label:"require not role",insertText:'require not role "${1:role}"',documentation:"Excludes callers with a role. Add authenticated to require a signed-in caller."},{label:"require not claim",insertText:'require not claim "${1:claim}" matches ${2:subject}',documentation:"Requires that no claim value matches the subject or a value."},{label:"require claim",insertText:'require claim "${1:claim}" matches ${2:subject}',documentation:"Requires a claim to match the subject or a value."},{label:"csharp",insertText:Me("csharp"),documentation:"Fully custom policy logic in C#, returning a bool."}],cS=[{label:"not empty",insertText:'${1:property} not empty message "${2:message}"',documentation:"The property must have a value."},{label:"max",insertText:'${1:property} max ${2:500} message "${3:message}"',documentation:"Maximum length or value."},{label:"min",insertText:'${1:property} min ${2:1} message "${3:message}"',documentation:"Minimum length or value."},{label:"matches",insertText:'${1:property} matches "${2:pattern}" message "${3:message}"',documentation:"The property must match a regular expression."},{label:"rule",insertText:'${1:property} rule ${2:PredicateName} message "${3:message}"',documentation:"Names a predicate \u2014 optionally followed by an indented `file` reference or inline `csharp` block giving it a body; bare, it just states that a constraint exists."},{label:"==",insertText:'${1:property} == ${2:value} message "${3:message}"',documentation:"The property must equal the value."},{label:"!=",insertText:'${1:property} != ${2:value} message "${3:message}"',documentation:"The property must not equal the value."},{label:"length ==",insertText:'${1:property} length == ${2:3} message "${3:message}"',documentation:"The property must have an exact length."},{label:"all >",insertText:'${1:collection}.${2:property} all > ${3:0} message "${4:message}"',documentation:"Every element of a collection must satisfy the comparison."}],dS=[{label:"description",insertText:'description "${1:screen intent}"',documentation:"Report-only description, not a localizable screen title."},{label:"data",insertText:"data ${1:ReadModel} via query ${2:QueryName}",documentation:"Binds a read model to the screen through a query."},{label:"action",insertText:"action ${1:CommandName}",documentation:"Makes a command available as an action on the screen."},{label:'action "\u2026"',insertText:'action "${1:Label}"\n when item.${2:status} == "${3:open}" execute ${4:CommandName}\n otherwise hidden',documentation:"One labeled button selecting the first matching command; hidden without a subject or match."},{label:"layout",insertText:"layout ${1:LayoutName}",documentation:"Uses a layout template and fills its slots."},{label:"section",insertText:"section ${1:name}",documentation:"A named structural section of the screen."},{label:"table",insertText:'table ${1:name}\n column ${2:property} label "${3:text}"',documentation:"A table widget over a read model or collection."},{label:"summary",insertText:'summary ${1:ReadModel}\n field ${2:property} label "${3:text}"',documentation:"A summary widget showing labeled fields."},{label:"title",insertText:'title "${1:text}"',documentation:"The title of the screen or section."},{label:"file",insertText:"file ${1:Path}",documentation:"Full external implementation \u2014 Stage uses the referenced file."},{label:"react",insertText:Me("react"),documentation:"Inline React/TSX component receiving the data contract as Props."},{label:"typescript",insertText:Me("typescript"),documentation:"Inline plain TypeScript."},{label:"html",insertText:Me("html"),documentation:"Inline static HTML."}],Vl=[{label:"navigate to",insertText:"navigate to ${1:ScreenName}",documentation:"Navigates to a screen after the action completes."},{label:"label",insertText:'label "${1:text}"',documentation:"The display label of the action."}],pS=[{label:"when \u2026 execute",insertText:'when item.${1:status} == "${2:open}" execute ${3:CommandName}',documentation:"First matching alternative selects the command; authorization never falls through."},{label:"otherwise hidden",insertText:"otherwise hidden",documentation:"Hides the action when no alternative matches; also the default."},{label:"otherwise execute",insertText:"otherwise execute ${1:CommandName}",documentation:"Selects a fallback command when no alternative matches and a subject exists."},...Vl.filter(t=>t.label!=="label")],Ql=[{label:"execute",insertText:"execute ${1:CommandName}",documentation:"Executes a command; denial never selects another alternative."},{label:"navigate to",insertText:"navigate to ${1:ScreenName}",documentation:"Navigates to the named screen."},{label:"open dialog",insertText:"open dialog ${1:DialogTemplate}",documentation:"Opens a dialog."},{label:"notify",insertText:'notify info "${1:Message}"',documentation:"Displays a message."},{label:"confirm",insertText:'confirm "${1:Message}"\n on success\n execute ${2:CommandName}',documentation:"Asks before continuing."},{label:"refresh",insertText:"refresh ${1:QueryName}",documentation:"Refreshes a query-backed element."}],uS=[{label:"when \u2026",insertText:'when item.${1:status} == "${2:open}"\n execute ${3:CommandName}',documentation:"Selects a whole action list once against the rendered subject at gesture time."},{label:"otherwise",insertText:'otherwise\n notify info "${1:Message}"',documentation:"Final fallback list; without a subject nothing runs, including fallback."},...Ql],fS=[{label:"with \u2026 from",insertText:"with ${1:property} from item.${2:property}",documentation:"Explicit input binding for this command alternative, before same-name item fields or its form."}],mS=[{label:"column",insertText:'column ${1:property} label "${2:text}"',documentation:"A column bound to a property."},{label:"on row-click",insertText:"on row-click navigate to ${1:ScreenName} by ${2:param}",documentation:"Navigates when a row is clicked."}],Gl=[...At.map(t=>({label:`$identity.${t}${t==="claims"?".":""}`,insertText:`$identity.${t}${t==="claims"?".${1:name}":""}`,documentation:`The caller's ${t}, equivalent to $context.identity.${t}.`})),{label:"$context.occurred",insertText:"$context.occurred",documentation:"When the command or query was received."},{label:"$context.tenant",insertText:"$context.tenant",documentation:"The tenant the command or query is executing for."},{label:"$context.command.",insertText:"$context.command.${1:property}",documentation:"A property of the command being handled."},{label:"$context.arguments.",insertText:"$context.arguments.${1:name}",documentation:"An argument of the query being performed."},{label:"$context.causedBy.subject",insertText:"$context.causedBy.subject",documentation:"Subject of the identity that caused the command or query."},{label:"$context.causedBy.name",insertText:"$context.causedBy.name",documentation:"Display name of the identity that caused the command or query."},{label:"$context.causedBy.userName",insertText:"$context.causedBy.userName",documentation:"User name of the identity that caused the command or query."},{label:"$context.causation.type",insertText:"$context.causation.type",documentation:"What caused this \u2014 a command, a reactor, a schedule."},{label:"$context.identity.id",insertText:"$context.identity.id",documentation:"The identifier of the caller from the auth token."},{label:"$context.identity.name",insertText:"$context.identity.name",documentation:"The display name of the caller."},{label:"$context.identity.userName",insertText:"$context.identity.userName",documentation:"The user name of the caller."},{label:"$context.identity.isAuthenticated",insertText:"$context.identity.isAuthenticated",documentation:"Whether the caller is authenticated."},{label:"$context.identity.roles",insertText:"$context.identity.roles",documentation:"The roles the caller holds."},{label:"$context.identity.claims.",insertText:"$context.identity.claims.${1:name}",documentation:"The value of a claim the caller carries."},{label:"$env.",insertText:"$env.${1:VAR_NAME}",documentation:"An environment variable."},...dr.filter(t=>t.name!=="value").map(t=>({label:`$eventContext.${t.path}`,insertText:`$eventContext.${t.path}`,documentation:`${t.description} (PDL)`}))],_l={StateChange:["operation","file","description","event","event generation","command","constraint","screen","specification"],StateView:["file","description","readmodel","query","query observable","projection","reducer","screen","specification","event","event generation"],Automation:["operation","file","description","reaction","reducer","command","event","event generation","readmodel","specification"],Translate:["file","description","capture","event","event generation","specification"]};function yS(t){let e=t?_l[t]:void 0;return e?_o.filter(n=>n.label==="purpose"||n.label==="example"||n.label==="documentation"||n.label==="public event"||n.label==="event from"||n.label==="direction"&&t==="Translate"||e.includes(n.label)):_o}c(yS,"sliceItemsFor");var l={InvalidIdentityDeclaration:"PLAY0633",DuplicateIdentity:"PLAY0634",InvalidIdentityDetail:"PLAY0635",UnknownIdentitySource:"PLAY0636",IdentityDetailWithoutSource:"PLAY0637",IdentitySourceWithBody:"PLAY0638",DuplicateIdentityDetail:"PLAY0639",BuiltInIdentityDetail:"PLAY0640",UnknownIdentityQuery:"PLAY0641",InvalidIdentityQuery:"PLAY0642",IdentityQueryWithoutKey:"PLAY0643",InvalidIdentityQueryKey:"PLAY0644",IdentityQueryAuthorizationDependency:"PLAY0645",IdentityQueryTypeMismatch:"PLAY0646",InvalidReactionIdentity:"PLAY0647",GatedInvocationWithoutIdentity:"PLAY0648",UnusedReactionIdentity:"PLAY0649",UnusedReactionRole:"PLAY0650",UnsatisfiedReactionIdentity:"PLAY0651",ReactionPrivilegeEscalation:"PLAY0652",CommandProducesPublicEvent:"PLAY0607",PublicEventRequiresOutboundTranslation:"PLAY0608",OutboundPublicEventCount:"PLAY0609",ForeignPublicEventConsumer:"PLAY0610",OutboundTranslationInput:"PLAY0611",InboundTranslationOutput:"PLAY0612",ForeignPublicEventProduced:"PLAY0613",PublicTranslationRequiresDirection:"PLAY0614",TranslationConstructDirection:"PLAY0615",InboundTranslationInput:"PLAY0616",OutboundTranslationOutput:"PLAY0617",EventTargetOutsideOutboundTranslation:"PLAY0618",EventsSourceOutsideInboundTranslation:"PLAY0619",InvalidCaptureEventsSource:"PLAY0620",InvalidExposureDeclaration:"PLAY0621",UnknownExposureOwner:"PLAY0622",ReExposureCycle:"PLAY0623",ReExposureBroken:"PLAY0624",InvalidInstanceContribution:"PLAY0625",UnknownContributionInstance:"PLAY0626",ContributionNotExposed:"PLAY0627",ContributionTypeMismatch:"PLAY0628",UnknownTemplateContentSlot:"PLAY0629",UnknownNavigationOutlet:"PLAY0630",TemplateScopeMismatch:"PLAY0631",IncompatibleComponentPackage:"PLAY0632",LegacyComplianceMarker:"PLAY0565",UnknownComplianceMarker:"PLAY0566",InvalidSecretScope:"PLAY0567",DuplicateSecretScope:"PLAY0568",SecretScopeIgnoredForPii:"PLAY0569",InvalidPersonalDataQualifier:"PLAY0570",DuplicateSpecialCategory:"PLAY0571",InvalidPurposeDeclaration:"PLAY0596",InvalidPurposeVocabulary:"PLAY0597",DuplicatePurposeField:"PLAY0598",DuplicatePurposeDeclaration:"PLAY0599",UnknownPurpose:"PLAY0600",PurposeInterestMismatch:"PLAY0601",PersonalDataWithoutPurpose:"PLAY0602",SpecialDataWithoutCondition:"PLAY0603",CriminalDataWithoutAuthorization:"PLAY0604",PurposeWithoutBasis:"PLAY0605",UnusedPurpose:"PLAY0606",ConflictingScreenDataBinding:"PLAY0530",ScreenDataQueryMismatch:"PLAY0531",ActionWithoutInputSurface:"PLAY0532",CommandWithoutInputSurface:"PLAY0533",ReadModelFieldWithoutOrigin:"PLAY0534",QueryParameterNotHeldByView:"PLAY0535",UnconsumedEvent:"PLAY0536",UnreachableScreen:"PLAY0537",UnknownActionSubjectField:"PLAY0345",UnresolvedActionSubject:"PLAY0346",UnreachableActionAlternative:"PLAY0347",UnknownActionArgumentProperty:"PLAY0348",UnreachableRefusalBranch:"PLAY0540",InvalidRefusalValue:"PLAY0541",UnknownRefusalConstraint:"PLAY0542",UnknownRedeliveryReaction:"PLAY0544",IndeterminateNegatedClaimTarget:"PLAY0546",InvalidRefusalBranch:"PLAY0538",InvalidRefusalBranchBody:"PLAY0539",UnmatchedRedeliveredOccurrence:"PLAY0543",InvalidNoEventsExpectation:"PLAY0545",InvalidProducesDeclaration:"PLAY0042",ProducesWhenWithoutEvent:"PLAY0043",InvalidPropertyMapping:"PLAY0044",DuplicateProducesTarget:"PLAY0193",EventSourceIdInPayload:"PLAY0469",ExplicitProducesTargetsRequired:"PLAY0470",RedundantEventId:"PLAY0471",InvalidEventId:"PLAY0472",InlineEventCollision:"PLAY0473",InlineEventOutsideCommand:"PLAY0474",InlineEventGeneration:"PLAY0475",ReservedProductionMetadata:"PLAY0476",InvalidEventDocumentation:"PLAY0477",OmittedProductionDestination:"PLAY0478",UnknownConstraintProperty:"PLAY0391",UnknownTopLevelConstruct:"PLAY0001",InvalidDomainDeclaration:"PLAY0002",DuplicateDomain:"PLAY0003",DomainNotFirst:"PLAY0004",InvalidImportDeclaration:"PLAY0005",TabIndentation:"PLAY0006",InvalidConceptDeclaration:"PLAY0007",UnknownPrimitiveType:"PLAY0008",InvalidEnumerationValue:"PLAY0009",UnknownConceptDirective:"PLAY0010",ValidateReadAsEnumerationBlock:"PLAY0011",AttributeReasonWithoutAttribute:"PLAY0012",DuplicateAttributeReason:"PLAY0013",InvalidTypeDeclaration:"PLAY0014",TypeWithoutProperties:"PLAY0015",InvalidPropertyDeclaration:"PLAY0016",IdentifierOutsideCommand:"PLAY0017",InvalidEventDeclaration:"PLAY0018",IdentifierOnEventProperty:"PLAY0019",TagPropertyReadAsTag:"PLAY0020",InvalidModuleDeclaration:"PLAY0021",UnknownModuleDirective:"PLAY0022",InvalidFeatureDeclaration:"PLAY0023",UnknownFeatureDirective:"PLAY0024",InvalidSliceDeclaration:"PLAY0027",UnknownSliceType:"PLAY0028",UnknownSliceDirective:"PLAY0029",InvalidPersonaDeclaration:"PLAY0030",InvalidPersonaPolicyReference:"PLAY0031",UnknownPersonaDirective:"PLAY0032",InvalidCommandDeclaration:"PLAY0033",UnknownCommandDirective:"PLAY0034",DuplicateCommandIdentifier:"PLAY0036",InvalidQueryDeclaration:"PLAY0047",UnknownQueryDirective:"PLAY0048",InvalidQueryParameter:"PLAY0049",InvalidProjectionDeclaration:"PLAY0056",EmptyProjection:"PLAY0057",UnknownProjectionDirective:"PLAY0058",FromWithoutEvent:"PLAY0061",InvalidEventReference:"PLAY0062",InvalidJoinDeclaration:"PLAY0063",JoinWithoutEvent:"PLAY0064",InvalidChildrenDeclaration:"PLAY0065",InvalidNestedDeclaration:"PLAY0066",NestedBlockWithoutFrom:"PLAY0067",InvalidRemoveDeclaration:"PLAY0068",UnknownRemoveDirective:"PLAY0069",InvalidClearDeclaration:"PLAY0070",ClearWithOutsideNestedBlock:"PLAY0071",InvalidSpecificationDeclaration:"PLAY0094",UnknownSpecificationDirective:"PLAY0095",InvalidSpecificationWhen:"PLAY0096",DuplicateSpecificationWhen:"PLAY0097",InvalidThenError:"PLAY0098",InvalidReadModelStep:"PLAY0099",InvalidEventStep:"PLAY0100",InvalidSpecificationValue:"PLAY0101",InvalidScreenDeclaration:"PLAY0102",UnknownScreenDirective:"PLAY0103",InvalidDataDirective:"PLAY0104",InvalidActionDirective:"PLAY0105",UnknownActionDirective:"PLAY0106",InvalidNavigation:"PLAY0107",InvalidScreenLayoutSlot:"PLAY0108",InvalidTitleDirective:"PLAY0109",UnknownTableDirective:"PLAY0110",UnknownSummaryDirective:"PLAY0111",AuthorizeWithoutPolicy:"PLAY0122",InvalidPolicyReference:"PLAY0123",InvalidConstraintDeclaration:"PLAY0132",ConstraintWithoutRule:"PLAY0133",InvalidConstraintBody:"PLAY0134",DuplicateConstraintBody:"PLAY0135",InvalidReactionDeclaration:"PLAY0136",InvalidReactionTrigger:"PLAY0137",ReactionWithoutTrigger:"PLAY0138",InvalidValidateDeclaration:"PLAY0140",InvalidValidationRule:"PLAY0141",InvalidRuleName:"PLAY0143",UnknownRuleImplementationDirective:"PLAY0144",InvalidDescription:"PLAY0145",EmptyDescription:"PLAY0146",DuplicateDescription:"PLAY0147",TagWithoutValue:"PLAY0148",InvalidTagValue:"PLAY0149",UnknownContextPath:"PLAY0153",UnknownContextCausedByProperty:"PLAY0154",UnknownContextIdentityProperty:"PLAY0155",ExpectedCodeFence:"PLAY0163",UnclosedCodeBlock:"PLAY0164",DuplicateDeclaration:"PLAY0168",RepeatedSingularDeclarationAcrossFiles:"PLAY0172",RepeatedDeclarationAcrossFiles:"PLAY0173",ConflictingDescriptionAcrossFiles:"PLAY0174",UnexpectedTokenInAuthorize:"PLAY0184",UnclosedAuthorizeGroup:"PLAY0185",InvalidReadModelDeclaration:"PLAY0186",InvalidInvokesDeclaration:"PLAY0194",InvalidScopeDeclaration:"PLAY0199",DuplicateScope:"PLAY0200",InvalidIntervalTrigger:"PLAY0249",InvalidScheduleTrigger:"PLAY0250",DuplicateReactionTrigger:"PLAY0253",InvalidSpecificationEventSource:"PLAY0275",DuplicateSpecificationEventSource:"PLAY0276",InvalidProjectionVariantDeclaration:"PLAY0277",InvalidEntersOnDeclaration:"PLAY0279",NestedProjectionVariantNotAllowed:"PLAY0280",InvalidStructuredValue:"PLAY0291",DuplicateStructuredValueMember:"PLAY0294",ConflictingSpecificationActions:"PLAY0358",InvalidSpecificationEventOrder:"PLAY0359",InvalidValidationSeverity:"PLAY0368",VariantRequiresEnteringEvent:"PLAY0382",DuplicateProjectionVariant:"PLAY0384",DuplicateVariantEnteringEvent:"PLAY0385",InvalidSpecificationDenied:"PLAY0388",DuplicateAuthorizationAcrossFiles:"PLAY0394",FileConstraintOnlySupportsUniqueness:"PLAY0396",LegacyInlineCodeFence:"PLAY0397",InvalidEventGeneration:"PLAY0446",InvalidFileImport:"PLAY0454",FileImportMatchesNothing:"PLAY0455",ImportedFileNotFound:"PLAY0456",ConflictingImportPlacement:"PLAY0457",ImportCycle:"PLAY0458",ModuleInPlacedFile:"PLAY0459",UnexpectedInPlacedFile:"PLAY0460",InvalidSpecificationClock:"PLAY0461",InvalidSpecificationTrigger:"PLAY0462",InvalidSpecificationCapture:"PLAY0463",InvalidSpecificationQueryAction:"PLAY0464",InvalidSpecificationQuery:"PLAY0265",UnknownSpecificationQueryDirective:"PLAY0266",DuplicateSpecificationQueryArguments:"PLAY0267",InvalidAbsentReadModelStep:"PLAY0453",LegacyOptionalSuffix:"PLAY0479",InvalidOptionalModifierOrder:"PLAY0480",OptionalReadsNotSupported:"PLAY0481",InvalidSpecificationCaller:"PLAY0386",DuplicateSpecificationCallerOrDenied:"PLAY0387",GeneratedPropertyOutsideCommand:"PLAY0482",InvalidGeneratedType:"PLAY0483",InvalidGeneratedModifierOrder:"PLAY0484",DuplicateEventSubject:"PLAY0590",InvalidSubjectType:"PLAY0591",ProtectedSubjectType:"PLAY0592",InvalidSubjectOwner:"PLAY0593",ReadModelSubjectNotSupported:"PLAY0594",InvalidSubjectModifierOrder:"PLAY0595",GeneratedPropertySuppliedAsInput:"PLAY0485",InvalidCommandResponse:"PLAY0486",InvalidResponseSource:"PLAY0487",DuplicateResponseField:"PLAY0488",InvalidResponseShape:"PLAY0489",InvalidGeneratedFixture:"PLAY0490",InvalidReturnExpectation:"PLAY0491",InvalidImplementationBlock:"PLAY0492",InvalidImplementationHint:"PLAY0493",ConflictingImplementationSources:"PLAY0494",UnknownType:"PLAY0165",InvalidSystemDeclaration:"PLAY0495",InvalidOperationDeclaration:"PLAY0496",InvalidProductionReference:"PLAY0497",ProductionDeclarationCollision:"PLAY0498",OperationOutsideCommand:"PLAY0499",InvalidSystemReference:"PLAY0500",InvalidOperationMapping:"PLAY0501",InvalidOperationSpecification:"PLAY0502",InvalidCaptureDeclaration:"PLAY0078",UnknownCaptureDirective:"PLAY0079",InvalidMapEntry:"PLAY0080",InvalidTranslation:"PLAY0081",InvalidSplitDeclaration:"PLAY0082",InvalidSplitTarget:"PLAY0083",InvalidAppendDeclaration:"PLAY0084",UnknownAppendDirective:"PLAY0085",WhenWithoutTrigger:"PLAY0086",InvalidWhenClause:"PLAY0087",InvalidWhenTransitionClause:"PLAY0088",MixedWhenCombinators:"PLAY0089",WhenCombinatorWithoutProperty:"PLAY0090",UnknownCaptureBlockDirective:"PLAY0091",InvalidCompositeKeyPart:"PLAY0072",TemplateInCompositeKey:"PLAY0073",EmptyCompositeKey:"PLAY0074",InvalidProjectionMapping:"PLAY0075",ExpectedLiteralValue:"PLAY0150",InvalidExpression:"PLAY0152",UnterminatedInterpolation:"PLAY0157",UnterminatedTemplateExpression:"PLAY0156",ProjectionDocumentWithoutProjection:"PLAY0055",CaptureDocumentWithoutCapture:"PLAY0077",SpecificationDocumentWithoutSpecification:"PLAY0093",InvalidSeedDeclaration:"PLAY0128",InvalidSeedGroup:"PLAY0129",InvalidSeedEvent:"PLAY0130",InvalidSeedPropertyAssignment:"PLAY0131",InvalidPolicyDeclaration:"PLAY0112",UnknownPolicyDirective:"PLAY0113",PolicyWithoutRequirement:"PLAY0114",ExpectedRoleName:"PLAY0118",ExpectedClaimName:"PLAY0119",ExpectedClaimMatches:"PLAY0120",ExpectedClaimMatchTarget:"PLAY0121",MixedPolicyImplementation:"PLAY0440",RepeatedPolicyRequirement:"PLAY0441",UnexpectedTokenInPolicyCondition:"PLAY0115",ExpectedPolicyCondition:"PLAY0116",UnclosedPolicyConditionGroup:"PLAY0117",UnexpectedTokenInCondition:"PLAY0158",ExpectedCondition:"PLAY0159",ExpectedComparisonOperator:"PLAY0161",ExpectedComparisonValue:"PLAY0162",InvalidActionAlternative:"PLAY0341",GuardedActionWithoutAlternatives:"PLAY0342",MisplacedActionOtherwise:"PLAY0343",UnsupportedActionConditionOperand:"PLAY0344",InvalidInteractionArgument:"PLAY0319",UnclosedConditionGroup:"PLAY0160",InvalidNumericDirective:"PLAY0508",DuplicateNumericDirective:"PLAY0509",LateNumericDirective:"PLAY0510",InexactNumericLiteral:"PLAY0511",MixedNumericModes:"PLAY0512",IncompatibleNumericSource:"PLAY0513",EventFromLaterSlice:"PLAY0516",TimelineCycleGroup:"PLAY0517",InvalidSpecificationExample:"PLAY0518",DuplicateSpecificationAssignment:"PLAY0519",UnresolvedSpecificationExampleType:"PLAY0520",SpecificationExampleNameCollision:"PLAY0521",SpecificationExampleKindMismatch:"PLAY0522",InvalidSpecificationExampleValue:"PLAY0523",MissingSpecificationProperty:"PLAY0524",UnadmittedSpecificationExampleValue:"PLAY0525",InvalidSpecificationExampleBody:"PLAY0526",AmbiguousReference:"PLAY0198",InvalidSpecificationStream:"PLAY0547",SpecificationStreamOnCommand:"PLAY0548",InvalidSpecificationStreamRoute:"PLAY0549",InvalidSpecificationStreamEventSource:"PLAY0550",SpecificationStreamContradictsCommand:"PLAY0551",InvalidDependencyTarget:"PLAY0554",RepeatedDependencyDeclaration:"PLAY0555",UndeclaredDependency:"PLAY0552",UnusedDependencyDeclaration:"PLAY0553",MutualDependencyDeclarations:"PLAY0556",AuthorizationRefusalWithoutIdentity:"PLAY0557",InvalidDocumentation:"PLAY0558",ConflictingDocumentationAcrossFiles:"PLAY0559",InvalidSpecificationCallerPersona:"PLAY0572",UnsynthesizablePersonaCaller:"PLAY0573",PersonaWithoutGate:"PLAY0574",GateWithoutPersona:"PLAY0575",AmbiguousPersonaCaller:"PLAY0576",InvalidSpecificationParameter:"PLAY0577",InvalidSpecificationCase:"PLAY0578",DuplicateSpecificationParameter:"PLAY0579",DuplicateSpecificationCase:"PLAY0580",IncompleteSpecificationTable:"PLAY0581",InvalidSpecificationCaseAssignment:"PLAY0582",InvalidSpecificationCaseValue:"PLAY0583",InvalidSpecificationCaseReference:"PLAY0584",OptionalSpecificationParameterTarget:"PLAY0585",SpecificationCaseNameCollision:"PLAY0586",IncompatibleSpecificationParameterType:"PLAY0587",UnusedSpecificationParameter:"PLAY0588",SingularSpecificationTableExpansion:"PLAY0589",UnsupportedInteractionAlternatives:"PLAY0560",MixedInteractionAlternatives:"PLAY0561",InteractionAlternativeWithoutActions:"PLAY0562",InlineInteractionAlternative:"PLAY0563",LegacyInteractionWhere:"PLAY0564",InvalidEventSourceDeclaration:"PLAY0503",InvalidCommandStream:"PLAY0504",AmbiguousCommandStream:"PLAY0505",UnsupportedStreamIdType:"PLAY0506",RedundantSourceStreamId:"PLAY0507",UnknownEvent:"PLAY0166",UnknownReadModelProperty:"PLAY0514",PiiNotSupportedOnIdentifier:"PLAY0515",HandlerWithoutImplementation:"PLAY0045",UnknownHandlerDirective:"PLAY0046",CommandWithProducesAndHandler:"PLAY0035",AbsoluteFileReference:"PLAY0264",InvalidTriggerData:"PLAY0246"};var yr="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}",Y="[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";function Z(t){let e=`(?=[\\u0000-\\uFFFF])[${yr}]`,n=t.replace(/\[([^\]]*\\w[^\]]*)\]/g,(i,r)=>{let o=r.replaceAll("\\w","");return o===""?`(?:${e})`:`(?:${e}|[${o}])`});return new RegExp(n.replaceAll("\\w",`(?:${e})`),"u")}c(Z,"nativePattern");function w(t){let e="",n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&i+1<t.length){let o=t[i+1];i++,o==="w"?e+=n?yr:`[${yr}]`:o==="d"?e+="\\p{Nd}":e+=`\\${o}`;continue}r==="["&&!n?n=!0:r==="]"&&n&&(n=!1),e+=r}return new RegExp(e,"u")}c(w,"pattern");var Zl=new RegExp(`^depends${Y}+on(?:${Y}|$)`,"u"),Kl=new RegExp(`${Y}+$`,"u");function jt(t,e=!1,n){let i=[],r=0,o=0;for(let s of t.split(`
14
+ `)){r++;let a=s.endsWith("\r")?s.replace(/\r+$/,""):s,d=a.length-a.trimStart().length,u=Jl(a.substring(d),e),m=Zl.test(u)?u.replace(Kl,""):u.trimEnd();i.push(n===void 0?{number:r,raw:a,indent:d,content:m,startOffset:o}:{number:r,raw:a,indent:d,content:m,path:n,startOffset:o}),o+=s.length+1}return i}c(jt,"splitLines");function fn(t,e=!1){let n=!1,i=!1;for(let r=0;r<t.length;r++){let o=t[r];if(o==="\\"&&n&&r+1<t.length)r++;else if(o==='"'&&!i)n=!n;else if(o==="`"&&!n)i=!i;else if(!n&&!i&&(o==="/"&&r+1<t.length&&t[r+1]==="/"||e&&o==="#"))return r}return-1}c(fn,"commentStart");function Jl(t,e){let n=fn(t,e);return n<0?t:t.substring(0,n)}c(Jl,"stripComment");function le(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}c(le,"eventDeclarations");function Vn(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}c(Vn,"operationDeclarations");var H;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(H||(H={}));var ie=class{static{c(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e,n){let i=c((r,o)=>{for(let s of r){let a=[...o,s.name];for(let d of s.slices)this.slices.push({slice:d,scope:[...a,d.name]});i(s.features,a)}},"collect");e.modules.forEach(r=>i(r.features,[r.name]));for(let{slice:r,scope:o}of this.slices){this.scopes.set(r,o);let s=new Map;for(let d of le(r)){let u=s.get(d.name)??[];u.push(d),s.set(d.name,u)}let a=[...s.values()].flatMap(d=>new Set(d.map(u=>u.generation)).size!==d.length?d:[d.reduce((u,m)=>u.generation>=m.generation?u:m)]);this.declarations.push(...a.map(d=>({kind:H.Event,name:d.name,node:d,scope:o})),...Vn(r).map(d=>({kind:H.Operation,name:d.name,node:d,scope:o})))}n!==void 0&&this.declarations.splice(0,this.declarations.length,...n);for(let r of this.declarations){let o=this.byName.get(r.name)??[];o.push(r),this.byName.set(r.name,o)}}resolve(e,n){let i=this.scopes.get(n);if(i===void 0)return{kind:H.Unresolved,declaration:null,candidates:[]};let r=this.resolutions.get(n)??new Map,o=r.get(e);if(o!==void 0)return o;let s=this.resolveFromScope(e,i);return r.set(e,s),this.resolutions.set(n,r),s}resolveFromScope(e,n){let i=this.candidates(e,n);return i.length===1?{kind:i[0].kind,declaration:i[0],candidates:[]}:{kind:i.length===0?H.Unresolved:H.Ambiguous,declaration:null,candidates:i}}isOperation(e,n){return e.inlineOperation!=null||this.resolve(e.event,n).kind===H.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==H.Operation&&!(i.kind===H.Ambiguous&&i.candidates.some(r=>r.kind===H.Operation))}candidates(e,n){let i=e.split(".").filter(s=>s.length>0);if(i.length===0)return[];let r=this.byName.get(i.at(-1))??[],o=i.slice(0,-1);if(o.length>0)return r.filter(s=>o.length<=s.scope.length&&o.every((a,d)=>s.scope[s.scope.length-o.length+d]===a));for(let s=n.length;s>=0;s--){let a=r.filter(d=>s<=d.scope.length&&n.slice(0,s).every((u,m)=>d.scope[m]===u));if(a.length>0)return a}return[]}};var at=new WeakMap,fe=c(t=>at.get(t)??{},"dependencySourcesOf");var Ce=class{static{c(this,"ScreenplaySyntaxWalker")}visitNode(e){}visitApplication(e){this.visitNode(e),e.domain!==null&&this.visitDomain(e.domain),e.imports.forEach(n=>this.visitImport(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.systems?.forEach(n=>this.visitSystem(n)),e.eventSources?.forEach(n=>this.visitEventSource(n)),e.concepts.forEach(n=>this.visitConcept(n)),e.types.forEach(n=>this.visitType(n)),e.personas.forEach(n=>this.visitPersona(n)),e.policies?.forEach(n=>this.visitPolicy(n)),e.exposures?.forEach(n=>{this.visitNode(n),n.properties.forEach(i=>this.visitNode(i))}),e.instanceContributions?.forEach(n=>{this.visitNode(n),n.contributions.forEach(i=>{this.visitNode(i),i.value!==null&&this.visitExpression(i.value),i.items.forEach(r=>{this.visitNode(r),r.values.forEach(o=>{this.visitNode(o),this.visitExpression(o.value)})})})}),e.identity!=null&&this.visitIdentity(e.identity),e.purposes?.forEach(n=>this.visitPurpose(n)),e.seeds?.forEach(n=>this.visitSeed(n)),e.modules.forEach(n=>this.visitModule(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n))}visitIdentity(e){this.visitNode(e),e.details.forEach(n=>this.visitIdentityDetail(n))}visitIdentityDetail(e){this.visitNode(e),this.visitTypeRef(e.type),this.visitIdentitySource(e.source)}visitIdentitySource(e){switch(e.kind){case"ClaimIdentitySourceSyntax":this.visitClaimIdentitySource(e);break;case"QueryIdentitySourceSyntax":this.visitQueryIdentitySource(e);break;case"CodeIdentitySourceSyntax":this.visitCodeIdentitySource(e);break;case"FileIdentitySourceSyntax":this.visitFileIdentitySource(e);break;default:this.visitNode(e);break}}visitClaimIdentitySource(e){this.visitNode(e)}visitQueryIdentitySource(e){this.visitNode(e),this.visitExpression(e.by)}visitCodeIdentitySource(e){this.visitNode(e),this.visitCodeBlock(e.code)}visitFileIdentitySource(e){this.visitNode(e),this.visitFileReference(e.file)}visitPurpose(e){this.visitNode(e),e.transfers.forEach(n=>this.visitPurposeTransfer(n))}visitPurposeReference(e){this.visitNode(e)}visitPurposeTransfer(e){this.visitNode(e)}visitPolicy(e){this.visitNode(e),e.condition!==null&&this.visitPolicyCondition(e.condition),e.code!==null&&this.visitCodeBlock(e.code),e.file!==null&&this.visitFileReference(e.file)}visitPolicyCondition(e){this.visitNode(e),e.kind==="ClaimConditionSyntax"&&e.matches!==null&&this.visitExpression(e.matches),e.kind==="NotPolicyConditionSyntax"&&this.visitPolicyCondition(e.operand),e.kind==="LogicalPolicyConditionSyntax"&&(this.visitPolicyCondition(e.left),this.visitPolicyCondition(e.right))}visitSeed(e){this.visitNode(e),e.groups.forEach(n=>{this.visitNode(n),n.events.forEach(i=>{this.visitNode(i),i.properties.forEach(r=>this.visitPropertyMapping(r))})})}visitPersona(e){this.visitNode(e)}visitAuthorize(e){this.visitNode(e),this.visitPolicyRequirement(e.requirement)}visitPolicyRequirement(e){this.visitNode(e),e.kind==="LogicalPolicyRequirementSyntax"&&(this.visitPolicyRequirement(e.left),this.visitPolicyRequirement(e.right))}visitDomain(e){this.visitNode(e)}visitImport(e){this.visitNode(e)}visitFileImport(e){this.visitNode(e)}visitConcept(e){this.visitNode(e),e.attributes.forEach(n=>this.visitNode(n)),e.validations?.forEach(n=>this.visitValidate(n))}visitType(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n))}visitDependsOn(e){this.visitNode(e)}visitModule(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.dependsOn?.forEach(n=>this.visitDependsOn(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(n=>this.visitFeature(n))}visitFeature(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.dependsOn?.forEach(n=>this.visitDependsOn(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(n=>this.visitFeature(n)),e.slices.forEach(n=>this.visitSlice(n))}visitSlice(e){this.visitNode(e),e.purposes?.forEach(n=>this.visitPurposeReference(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.commands.forEach(n=>this.visitCommand(n)),e.operations?.forEach(n=>this.visitOperation(n)),e.events.forEach(n=>this.visitEvent(n)),e.constraints.forEach(n=>this.visitConstraint(n)),e.queries.forEach(n=>this.visitQuery(n)),e.projections.forEach(n=>this.visitProjection(n)),e.readModels.forEach(n=>this.visitReadModel(n)),e.captures.forEach(n=>this.visitCapture(n)),e.reactions.forEach(n=>this.visitReaction(n)),e.screens.forEach(n=>this.visitScreen(n)),e.specifications.forEach(n=>this.visitSpecification(n))}visitTriggerData(e){this.visitNode(e),e.type!==null&&this.visitTypeRef(e.type)}visitReads(e){this.visitNode(e)}visitConcurrency(e){this.visitNode(e)}visitReducer(e){this.visitNode(e),e.rules.forEach(n=>this.visitReducerRule(n))}visitReducerRule(e){this.visitNode(e),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitForm(e){this.visitNode(e),e.populate!==null&&this.visitNode(e.populate),e.fields.forEach(n=>this.visitNode(n)),e.columns?.forEach(n=>this.visitNode(n)),e.layout!==null&&e.layout!==void 0&&(this.visitNode(e.layout),e.layout.columns.forEach(n=>{this.visitNode(n),n.width!==null&&this.visitNode(n.width),n.minWidth!==null&&this.visitNode(n.minWidth),n.maxWidth!==null&&this.visitNode(n.maxWidth)}),e.layout.columnGap!==null&&this.visitNode(e.layout.columnGap),e.layout.rowGap!==null&&this.visitNode(e.layout.rowGap),e.layout.placements.forEach(n=>{this.visitNode(n),n.width!==null&&this.visitNode(n.width)})),e.onSubmit!==null&&this.visitScreenDirective(e.onSubmit)}visitCommand(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.stream!=null&&this.visitCommandStream(e.stream),e.streamCandidates?.forEach(n=>this.visitCommandStream(n)),e.validations.forEach(n=>this.visitValidate(n)),e.produces.forEach(n=>this.visitProduces(n)),e.handler!=null&&this.visitHandler(e.handler),e.response!=null&&this.visitCommandResponse(e.response)}visitEventSource(e){this.visitNode(e),e.identifier!==null&&this.visitTypeRef(e.identifier),e.streams.forEach(n=>this.visitEventStream(n))}visitEventStream(e){this.visitNode(e),e.streamId!==null&&this.visitTypeRef(e.streamId),e.streamIdParts.forEach(n=>this.visitEventStreamIdPart(n))}visitEventStreamIdPart(e){this.visitNode(e),this.visitTypeRef(e.type)}visitCommandStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n)),e.propertyCandidate!==null&&this.visitProperty(e.propertyCandidate)}visitSystem(e){this.visitNode(e)}visitOperation(e){this.visitNode(e),e.inputs.forEach(n=>this.visitProperty(n)),e.execute!==null&&this.visitOperationPhase(e.execute),e.compensate!==null&&this.visitOperationPhase(e.compensate)}visitOperationPhase(e){this.visitNode(e),e.implementation!==null&&this.visitImplementation(e.implementation),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitSpecificationOperationFailure(e){this.visitNode(e)}visitSpecificationCompensated(e){this.visitNode(e)}visitSpecificationOperation(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n))}visitHandler(e){this.visitNode(e),e.implementation!=null&&this.visitImplementation(e.implementation),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitImplementation(e){this.visitNode(e),e.hints.forEach(n=>this.visitImplementationHint(n))}visitImplementationHint(e){this.visitNode(e)}visitFileReference(e){this.visitNode(e)}visitCodeBlock(e){this.visitNode(e)}visitCommandResponse(e){e.kind==="ScalarCommandResponseSyntax"?this.visitScalarCommandResponse(e):this.visitRecordCommandResponse(e)}visitScalarCommandResponse(e){this.visitNode(e),this.visitPropertyResponseSource(e.source)}visitRecordCommandResponse(e){this.visitNode(e),e.fields.forEach(n=>this.visitResponseField(n))}visitResponseField(e){this.visitNode(e),e.type!==null&&this.visitTypeRef(e.type),this.visitPropertyResponseSource(e.source)}visitPropertyResponseSource(e){this.visitNode(e)}visitSpecificationReturn(e){e.kind==="ScalarSpecificationReturnSyntax"?this.visitScalarSpecificationReturn(e):this.visitRecordSpecificationReturn(e)}visitScalarSpecificationReturn(e){this.visitNode(e),this.visitExpression(e.value)}visitRecordSpecificationReturn(e){this.visitNode(e),e.fields.forEach(n=>this.visitPropertyMapping(n))}visitValidate(e){this.visitNode(e),e.kind==="DeclarativeValidateSyntax"?(e.rules.forEach(n=>this.visitValidationRule(n)),e.requirements?.forEach(n=>{this.visitNode(n),this.visitCondition(n.condition)})):e.code!=null&&this.visitCodeBlock(e.code)}visitValidationRule(e){this.visitNode(e),e.implementation!=null&&this.visitImplementation(e.implementation),e.value!==null&&this.visitExpression(e.value),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitEvent(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n)),e.tags.forEach(n=>this.visitTag(n))}visitTag(e){this.visitNode(e),this.visitExpression(e.value)}visitReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n))}visitConstraint(e){this.visitNode(e),e.kind==="FileConstraintSyntax"&&this.visitNode(e.file),e.additionalRules.forEach(n=>this.visitConstraint(n))}visitQuery(e){this.visitNode(e),this.visitTypeRef(e.returnType),e.by!==null&&this.visitQueryParameter(e.by),e.filters.forEach(n=>this.visitQueryParameter(n)),e.authorize!==null&&this.visitAuthorize(e.authorize)}visitQueryParameter(e){this.visitNode(e),this.visitTypeRef(e.type),e.source!=null&&this.visitExpression(e.source)}visitKey(e){this.visitNode(e),e.kind==="ExpressionKeySyntax"?this.visitExpression(e.expression):e.parts.forEach(n=>{this.visitNode(n),this.visitExpression(n.expression)})}visitProjection(e){this.visitNode(e),e.key!=null&&this.visitKey(e.key),e.blocks.forEach(n=>this.visitProjectionBlock(n))}visitProjectionBlock(e){switch(this.visitNode(e),e.kind){case"FromSyntax":e.events.forEach(n=>{this.visitNode(n),n.key!=null&&this.visitExpression(n.key)}),e.key!=null&&this.visitKey(e.key),e.parentKey!=null&&this.visitExpression(e.parentKey),e.mappings.forEach(n=>this.visitMapping(n));break;case"EverySyntax":case"AllSyntax":e.mappings.forEach(n=>this.visitMapping(n));break;case"JoinSyntax":e.events.forEach(n=>this.visitJoinEvent(n));break;case"ProjectionVariantSyntax":e.entersOn.forEach(n=>{this.visitNode(n),n.key!=null&&this.visitExpression(n.key)}),e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"ChildrenSyntax":e.identifiedBy!==void 0&&this.visitExpression(e.identifiedBy),e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"NestedSyntax":e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"RemoveWithSyntax":e.parentKey!=null&&this.visitExpression(e.parentKey),e.key!=null&&this.visitExpression(e.key);break;case"RemoveViaJoinSyntax":e.key!=null&&this.visitExpression(e.key);break}}visitJoinEvent(e){this.visitNode(e),e.mappings.forEach(n=>this.visitMapping(n))}visitMapping(e){this.visitNode(e),e.source!==void 0&&this.visitExpression(e.source),e.value!==void 0&&this.visitExpression(e.value)}visitCondition(e){this.visitNode(e),e.kind==="ComparisonConditionSyntax"?this.visitExpression(e.right):(this.visitCondition(e.left),this.visitCondition(e.right))}visitReaction(e){this.visitNode(e),e.runsAs!=null&&this.visitReactionIdentity(e.runsAs),e.where!=null&&this.visitCondition(e.where),e.triggers.forEach(n=>this.visitReactionTrigger(n))}visitReactionIdentity(e){this.visitNode(e)}visitReactionTrigger(e){this.visitNode(e),this.visitTriggerSource(e.source),e.produces.forEach(n=>this.visitProduces(n)),e.invokes.forEach(n=>this.visitInvokes(n))}visitProduces(e){this.visitNode(e),e.when!=null&&this.visitCondition(e.when),e.inlineEvent!==null&&this.visitEvent(e.inlineEvent),e.inlineOperation!=null&&this.visitOperation(e.inlineOperation),e.for!==null&&this.visitExpression(e.for),e.mappings.forEach(n=>this.visitPropertyMapping(n)),e.tags.forEach(n=>this.visitTag(n))}visitInvokes(e){this.visitNode(e),e.mappings?.forEach(n=>this.visitPropertyMapping(n)),e.onRefused?.forEach(n=>this.visitInvocationRefusal(n))}visitInvocationRefusal(e){this.visitNode(e),e.produces.forEach(n=>this.visitProduces(n))}visitCapture(e){this.visitNode(e),e.source!==null&&this.visitCaptureSource(e.source),e.map?.forEach(n=>this.visitCaptureMap(n)),e.appends.forEach(n=>this.visitCaptureAppend(n)),e.children.forEach(n=>this.visitCaptureChildren(n)),e.nested.forEach(n=>this.visitCaptureNested(n))}visitCaptureSource(e){this.visitNode(e),e.settings.forEach(n=>this.visitCaptureSourceSetting(n))}visitCaptureSourceSetting(e){this.visitNode(e)}visitCaptureMap(e){this.visitNode(e),this.visitExpression(e.source),e.kind==="CaptureMapEntrySyntax"&&e.translations.forEach(n=>this.visitNode(n))}visitCaptureAppend(e){this.visitNode(e),e.when!=null&&this.visitNode(e.when),e.mappings?.forEach(n=>this.visitPropertyMapping(n)),e.tags?.forEach(n=>this.visitTag(n))}visitCaptureChildren(e){this.visitNode(e),e.map?.forEach(n=>this.visitCaptureMap(n)),e.appends.forEach(n=>this.visitCaptureAppend(n))}visitCaptureNested(e){this.visitNode(e),e.map?.forEach(n=>this.visitCaptureMap(n)),e.appends.forEach(n=>this.visitCaptureAppend(n))}visitTriggerSource(e){this.visitNode(e)}visitScreen(e){this.visitNode(e),e.directives.forEach(n=>this.visitScreenDirective(n)),e.contributions?.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))})}visitScreenDirective(e){if(e.kind==="ScreenGuardedActionSyntax"){this.visitScreenGuardedAction(e);return}switch(this.visitNode(e),e.kind){case"ScreenDataSyntax":this.visitTypeRef(e.type);break;case"ScreenActionSyntax":e.navigate!==null&&this.visitScreenDirective(e.navigate);break;case"ScreenNavigateSyntax":e.parameters.forEach(n=>{this.visitNode(n),this.visitUiBinding(n.binding)});break;case"ScreenTemplateReferenceSyntax":e.slots.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenSectionSyntax":e.directives.forEach(n=>this.visitScreenDirective(n));break;case"ScreenTableSyntax":e.columns.forEach(n=>this.visitNode(n)),e.rowClick!==null&&this.visitScreenDirective(e.rowClick);break;case"ScreenSummarySyntax":e.fields.forEach(n=>this.visitNode(n));break;case"ScreenComponentSyntax":e.context!==null&&this.visitUiBinding(e.context),e.properties.forEach(n=>{this.visitNode(n),n.binding!==null&&this.visitUiBinding(n.binding),n.value!==null&&this.visitExpression(n.value)}),e.exposes.forEach(n=>{this.visitNode(n),this.visitUiBinding(n.binding)}),e.presentation.forEach(n=>this.visitNode(n)),e.outlets.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenToolbarSyntax":e.items.forEach(n=>{this.visitNode(n),n.parameters.forEach(i=>{this.visitNode(i),this.visitUiBinding(i.binding)}),n.presentation.forEach(i=>this.visitNode(i))});break;case"ScreenCodeSyntax":this.visitNode(e.code);break}}visitScreenGuardedAction(e){this.visitNode(e),e.alternatives.forEach(n=>this.visitScreenActionAlternative(n)),e.otherwise!==null&&this.visitScreenActionOtherwise(e.otherwise),e.navigate!==null&&this.visitScreenDirective(e.navigate)}visitScreenActionAlternative(e){this.visitNode(e),this.visitCondition(e.condition),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitScreenActionOtherwise(e){this.visitNode(e),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitInteractionArgument(e){this.visitNode(e)}visitSpecification(e){this.visitNode(e),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.parameters?.forEach(n=>{this.visitNode(n),this.visitTypeRef(n.type)}),e.cases?.forEach(n=>{this.visitNode(n),n.values.forEach(i=>this.visitPropertyMapping(i))}),e.givenClock!==null&&this.visitSpecificationClock(e.givenClock),e.givenOperationFailures?.forEach(n=>this.visitSpecificationOperationFailure(n)),e.thenOperations?.forEach(n=>this.visitSpecificationOperation(n)),e.thenCompensated?.forEach(n=>this.visitSpecificationCompensated(n)),e.givenCallerPersona!=null&&this.visitNode(e.givenCallerPersona),e.givenCaller!=null&&(this.visitNode(e.givenCaller),e.givenCaller.claims.forEach(n=>this.visitNode(n))),e.given.forEach(n=>this.visitSpecificationEvent(n)),e.givenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.when!==null&&this.visitSpecificationCommand(e.when),e.givenCaptures.forEach(n=>this.visitSpecificationCapture(n)),e.whenAppended!==null&&this.visitSpecificationEvent(e.whenAppended),e.whenRedelivered!=null&&this.visitSpecificationRedelivery(e.whenRedelivered),e.whenClock!==null&&this.visitSpecificationClock(e.whenClock),e.whenTrigger!==null&&this.visitSpecificationTrigger(e.whenTrigger),e.whenCapture!==null&&this.visitSpecificationCapture(e.whenCapture),e.whenQuery!==null&&this.visitSpecificationWhenQuery(e.whenQuery),e.thenEvents.forEach(n=>this.visitSpecificationEvent(n)),e.thenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.thenAbsentReadModels?.forEach(n=>{this.visitNode(n),this.visitExpression(n.key)}),e.thenQueries?.forEach(n=>{this.visitNode(n),n.arguments.forEach(i=>this.visitPropertyMapping(i)),n.results.forEach(i=>this.visitSpecificationQueryResult(i))}),e.thenResults.forEach(n=>this.visitSpecificationQueryResult(n)),e.thenNoResult!==null&&this.visitNode(e.thenNoResult),e.thenDenied!=null&&this.visitNode(e.thenDenied),e.thenReturns!=null&&this.visitSpecificationReturn(e.thenReturns),e.thenErrors.forEach(n=>{this.visitNode(n),n.caseValue!=null&&this.visitExpression(n.caseValue)})}visitSpecificationRedelivery(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationClock(e){this.visitNode(e)}visitSpecificationTrigger(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationCapture(e){this.visitNode(e),e.record.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationWhenQuery(e){this.visitNode(e),e.arguments.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationQueryResult(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationExample(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.generatedValues.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationEvent(e){this.visitNode(e),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationNoStream(e){this.visitNode(e)}visitSpecificationCommand(e){this.visitNode(e),(e.generatedValues??[]).forEach(n=>this.visitPropertyMapping(n)),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitPropertyMapping(e){this.visitNode(e),this.visitExpression(e.source)}visitProperty(e){this.visitNode(e),this.visitTypeRef(e.type)}visitTypeRef(e){this.visitNode(e)}visitUiBinding(e){this.visitNode(e),e.literal!==null&&this.visitExpression(e.literal)}visitIdentityExpression(e){this.visitNode(e)}visitExpression(e){if(e.kind==="IdentityExpressionSyntax"){this.visitIdentityExpression(e);return}this.visitNode(e),e.kind==="ListExpressionSyntax"?e.items.forEach(n=>this.visitExpression(n)):e.kind==="ObjectExpressionSyntax"?e.members.forEach(n=>this.visitObjectMember(n)):e.kind==="TemplateExpressionSyntax"&&e.parts.forEach(n=>{this.visitNode(n),n.kind==="TemplateInterpolationSyntax"&&this.visitExpression(n.expression)})}visitObjectMember(e){this.visitNode(e),this.visitExpression(e.value)}};var hr="79228162514264337593543950335";function st(t){let e=Ko(t);if(e===void 0)return;let n=e.integer+e.fraction,i=0;for(;i<n.length&&n[i]==="0";)i++;if(i===n.length)return Object.freeze({literalType:"ExactNumber",value:"0"});let r=n.length;for(;n[r-1]==="0";)r--;let o=e.fraction.length-e.exponent-(n.length-r),s=o<0?-o:0;if(o>28||r-i+s>hr.length)return;let a=n.substring(i,r)+"0".repeat(s);if(a.length===hr.length&&a>hr)return;let d=Math.max(0,o),u=d===0?a:a.length>d?`${a.substring(0,a.length-d)}.${a.substring(a.length-d)}`:`0.${"0".repeat(d-a.length)}${a}`;return Object.freeze({literalType:"ExactNumber",value:(e.negative?"-":"")+u})}c(st,"parseExactNumber");function mn(t){return Ko(t)!==void 0}c(mn,"isExactNumberToken");function Ko(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&Sr(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let a=++i;for(;i<t.length&&Sr(t[i]);)i++;if(i===a)return;o=t.substring(a,i)}let s=0;if(t[i]==="e"||t[i]==="E"){i++;let a=t[i]==="-";(t[i]==="+"||t[i]==="-")&&i++;let d=i,u=t.length+29;for(;i<t.length&&Sr(t[i]);)s=Math.min(u,s*10+t.charCodeAt(i++)-48);if(i===d)return;a&&(s=-s)}return i===t.length?{negative:e,integer:r,fraction:o,exponent:s}:void 0}c(Ko,"scan");function Sr(t){return t>="0"&&t<="9"}c(Sr,"isDigit");var z='(?:[^"\\\\]|\\\\.)*',Hl={"\\":"\\",'"':'"',n:`
15
+ `,r:"\r",t:" "};function V(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.length?Hl[t[n+1]]:void 0;t[n]==="\\"&&i!==void 0?(e+=i,n++):e+=t[n]}return e}c(V,"unescapeString");var Jo=64,Be=class extends Error{static{c(this,"InvalidStructuredValue")}},Qn=class{static{c(this,"StructuredValueParser")}text;start;context;#e=0;constructor(e,n,i){this.text=e,this.start=n,this.context=i}parse(){let e=this.#t(0);if(this.#n(),this.#e<this.text.length)throw new Be(`'${this.text[this.#e]}' is invalid after a single JSON value.`);return e}#t(e){this.#n();let n=this.#a(),i=this.text[this.#e];if(i==="["||i==="{"){if(e>=Jo)throw new Be(`The value nests deeper than ${Jo} levels.`);return i==="["?this.#s(e,n):this.#i(e,n)}if(i==='"')return{kind:"LiteralExpressionSyntax",value:this.#r(),location:n};for(let[r,o]of[["true",!0],["false",!1],["null",null]])if(this.text.startsWith(r,this.#e))return this.#e+=r.length,{kind:"LiteralExpressionSyntax",value:o,location:n};return this.#l(n)}#s(e,n){this.#e++;let i=[];if(this.#n(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};for(;;){if(i.push(this.#t(e+1)),this.#n(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};this.#d(",")}}#i(e,n){this.#e++;let i=[],r=new Set;if(this.#n(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};for(;;){this.#n();let o=this.#a();if(this.text[this.#e]!=='"')throw new Be("Expected a property name in double quotes.");let s=this.#r();this.#n(),this.#d(":");let a=this.#t(e+1);if(r.has(s)?this.context?.error(l.DuplicateStructuredValueMember,`Duplicate property '${s}' in structured value`,o):(r.add(s),i.push({kind:"ObjectMemberSyntax",name:s,value:a,location:o})),this.#n(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};this.#d(",")}}#r(){let e=this.#o(this.#e),n=this.text.substring(this.#e,e);this.#e=e;try{return JSON.parse(n)}catch{throw new Be(`${n} is not a valid JSON string.`)}}#o(e){for(let n=e+1;n<this.text.length;n++)if(this.text[n]==="\\")n++;else if(this.text[n]==='"')return n+1;throw new Be("A string is not closed.")}#l(e){let n=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(this.text.substring(this.#e));if(n===null)throw new Be(`'${this.text[this.#e]??""}' is an invalid start of a value.`);if(this.#e+=n[0].length,this.context?.sourceOptions.numericMode==="exact"){let r=st(n[0]);return r===void 0?(this.context.error(l.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:n[0],location:e}):{kind:"LiteralExpressionSyntax",value:r,location:e}}let i=Number(n[0]);if(!Number.isFinite(i))throw new Be("JSON number is outside the finite Double range.");return{kind:"LiteralExpressionSyntax",value:i,location:e}}#a(){return{...this.start,column:this.start.column+this.#e}}#n(){for(;this.#e<this.text.length&&`
16
+ \r`.includes(this.text[this.#e]);)this.#e++}#c(e){return this.text[this.#e]!==e?!1:(this.#e++,!0)}#d(e){if(!this.#c(e))throw new Be(`Expected '${e}' at position ${this.#e}.`)}};var Xl=w("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),ec=Z("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),tc=w("^-?\\d+(\\.\\d+)?$"),Ho=["command","arguments","tenant","causedBy","causation","occurred","identity"],Xo=["subject","name","userName"],Je=["id","name","userName","isAuthenticated","roles","claims"];function Ye(t,e,n){return ae(t,e,n,!0)}c(Ye,"parseModeledMappingSource");function ae(t,e,n,i=!1){if(t=t.trim(),t==="$refusal"||t.startsWith("$refusal."))return{kind:"RefusalExpressionSyntax",member:t==="$refusal"?"":t.substring(9),location:e};if(t==="$identity"||t==="$identity.")return n?.error(l.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e};if(t.startsWith("$identity.")){let o=t.substring(10);return n?.deferIdentityValidation!==!0&&ea(o.split(".")[0],"$identity",e,n),{kind:"IdentityExpressionSyntax",path:o,location:e}}if(t.startsWith("$context.")){let o=t.substring(9);return nc(o,e,n),{kind:"ContextExpressionSyntax",path:o,location:e}}if(t.startsWith("$env."))return{kind:"EnvironmentExpressionSyntax",name:t.substring(5),location:e};if(t.startsWith("$strings."))return{kind:"StringsExpressionSyntax",key:t.substring(9),location:e};if(t.startsWith("$."))return{kind:"SourceItemExpressionSyntax",path:t.substring(2),location:e};if(t.startsWith("{")||t.startsWith("["))try{return new Qn(t,e,n).parse()}catch(o){if(!(o instanceof Be))throw o;return n?.error(l.InvalidStructuredValue,`Invalid inline structured value: ${o.message}`,e),{kind:"RawExpressionSyntax",text:t,location:e}}let r=n===void 0?yn(t,e):yn(t,e,n);return r!==void 0?r:(i||n?.sourceOptions.numericMode==="exact"?ec:Xl).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}c(ae,"parseMappingSource");function nc(t,e,n){let[i,r]=t.split(".");Ho.includes(i)?r!==void 0&&i==="causedBy"&&!Xo.includes(r)?n?.warning(l.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${Xo.join(", ")}`,e):r!==void 0&&i==="identity"&&ea(r,"$context.identity",e,n):n?.warning(l.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${Ho.join(", ")}`,e)}c(nc,"warnOnUnknownContextPath");function ea(t,e,n,i){Je.includes(t)||i?.warning(l.UnknownContextIdentityProperty,`Unknown ${e} property '${t}' - expected ${Je.join(", ")}`,n)}c(ea,"warnOnUnknownIdentityProperty");function yn(t,e,n){let i=c(o=>({kind:"LiteralExpressionSyntax",value:o,location:e}),"literal");switch(t){case"true":return i(!0);case"false":return i(!1);case"null":return i(null)}if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")))return i(V(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!mn(t))return;let o=st(t);return o!==void 0?i(o):(n.error(l.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:t,location:e})}if(tc.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}c(yn,"parseLiteral");function Gn(t,e){let n=t.identity?.details??[],i=new Set(n.map(a=>a.name)),r=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(a=>a.name),...t.types.map(a=>a.name),...t.imports.map(a=>a.qualifiedName.split(".").at(-1))]),o=new ie(t);for(let{slice:a}of o.slices){for(let d of a.readModels)r.add(d.name);for(let d of a.projections){let u=d.blocks.filter(m=>m.kind==="ProjectionVariantSyntax");for(let m of u.length>0?u.map(p=>p.name):[d.readModel??d.name])r.add(m)}for(let d of fe(a).reducers??[])r.add(d.readModel)}new xr(i,e).visitApplication(t);let s=new Set;for(let a of n){if(s.has(a.name)&&e.error(l.DuplicateIdentityDetail,`Duplicate identity detail '${a.name}' - detail names must be unique`,a.location),s.add(a.name),Je.includes(a.name)&&e.error(l.BuiltInIdentityDetail,`Identity detail '${a.name}' redeclares a built-in caller property`,a.location),r.has(a.type.name)||e.warning(l.UnknownType,`Unknown type '${a.type.name}' on identity detail '${a.name}'`,a.type.location),a.source.kind!=="QueryIdentitySourceSyntax")continue;let d=a.source;ic(d.by)||e.error(l.InvalidIdentityQueryKey,`Identity detail '${a.name}' query key may reference only caller built-ins, claims or literals, never another detail`,d.by.location);let u=d.query.split("."),m=u.at(-1),p=u.slice(0,-1),y=o.slices.flatMap(({slice:x,scope:P})=>x.queries.map(I=>({query:I,scope:P}))).filter(x=>x.query.name===m&&p.length<=x.scope.length&&p.every((P,I)=>P===x.scope[x.scope.length-p.length+I]));if(y.length!==1){e.error(l.UnknownIdentityQuery,`Unknown or ambiguous identity query '${d.query}'`,d.location);continue}let{query:h,scope:g}=y[0];(h.by===null||h.returnType.isCollection)&&e.error(l.InvalidIdentityQuery,`Identity query '${d.query}' must be keyed and return a single, possibly optional result`,d.location),(h.returnType.name!==a.type.name||a.type.isCollection||h.returnType.isOptional&&!a.type.isOptional)&&e.error(l.IdentityQueryTypeMismatch,`Identity detail '${a.name}' must match query '${d.query}' result type, including optionality`,a.type.location);let b=h.authorize===null?[]:[h.authorize];for(let x of t.modules.filter(P=>P.name===g[0]))x.authorize!==null&&b.push(x.authorize),ta(x.features,g.slice(1,-1),b);let S=new Set(b.flatMap(x=>gr(x.requirement))),$=new vr(i);for(let x of(t.policies??[]).filter(P=>S.has(P.name)))$.visitPolicy(x);$.found.length>0&&e.error(l.IdentityQueryAuthorizationDependency,`Identity query '${d.query}' authorization depends on identity detail '${$.found[0].path.split(".")[0]}' - caller details cannot authorize their own resolution`,d.location)}}c(Gn,"validateIdentity");function ic(t){return t.kind==="LiteralExpressionSyntax"?!0:t.kind==="IdentityExpressionSyntax"?Je.includes(t.path.split(".")[0]):t.kind==="ContextExpressionSyntax"&&t.path.startsWith("identity.")&&Je.includes(t.path.split(".")[1])}c(ic,"isTokenKey");function gr(t){return t.kind==="PolicyReferenceSyntax"?[t.name]:[...gr(t.left),...gr(t.right)]}c(gr,"policyNames");function ta(t,e,n){for(let i of t.filter(r=>r.name===e[0]))i.authorize!==null&&n.push(i.authorize),ta(i.features,e.slice(1),n)}c(ta,"collectFeatureAuthorizations");var xr=class extends Ce{static{c(this,"IdentityPaths")}details;context;constructor(e,n){super(),this.details=e,this.context=n}visitExpression(e){if(e.kind==="ContextExpressionSyntax"&&e.path.startsWith("identity.")){let n=e.path.split(".")[1];!Je.includes(n)&&!this.context.diagnostics.some(i=>i.code===l.UnknownContextIdentityProperty&&i.location.line===e.location.line&&i.location.column===e.location.column)&&this.context.warning(l.UnknownContextIdentityProperty,`Unknown $context.identity property '${n}' - expected ${Je.join(", ")}`,e.location)}super.visitExpression(e)}visitIdentityExpression(e){let n=e.path.split(".")[0];!this.details.has(n)&&!Je.includes(n)&&this.context.warning(l.UnknownContextIdentityProperty,`Unknown $identity property '${n}' - expected ${[...Je,...this.details].join(", ")}`,e.location)}},vr=class extends Ce{static{c(this,"DetailReferences")}details;found=[];constructor(e){super(),this.details=e}visitIdentityExpression(e){this.details.has(e.path.split(".")[0])&&this.found.push(e)}};var pe;(function(t){t.Unique="unique",t.Ambiguous="ambiguous",t.NotFound="notFound",t.WrongKind="wrongKind"})(pe||(pe={}));var Fe=class{static{c(this,"EventSourceCatalog")}sources=new Map;otherNames;constructor(e){for(let n of e.eventSources??[])this.sources.set(n.name,[...this.sources.get(n.name)??[],n]);this.otherNames=new Set([...e.concepts,...e.types].map(n=>n.name))}resolve(e,n){let i=this.sources.get(e)??[],r=i.flatMap(s=>s.streams).filter(s=>s.name===n),o;return i.length===0?o=this.otherNames.has(e)?pe.WrongKind:pe.NotFound:i.length>1||r.length>1?o=pe.Ambiguous:o=r.length===1?pe.Unique:pe.NotFound,{kind:o,sources:i,streams:r}}};function na(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}c(na,"eventProductions");function $r(t,e){let n=na(t,e),i=t.properties.find(r=>r.isIdentifier)?.name;return n.some(r=>r.for!==null&&(r.for.kind!=="PathExpressionSyntax"||r.for.path!==i))||n.some(r=>r.inlineEvent!==null&&r.for===null)&&n.some(r=>r.inlineEvent===null&&r.for===null)}c($r,"requiresExplicitDestinations");function ia(t,e,n){let i=na(t,n);if(e.inlineOperation!=null||n!==void 0&&!n.resolver.isEventProduction(e,n.slice)||e.for!==null||$r(t,n))return;if(e.inlineEvent===null)return i.some(o=>o.for!==null||o.inlineEvent!==null)?void 0:"new event source";let r=t.properties.filter(o=>o.isIdentifier&&!o.type.isOptional&&!o.type.isCollection);return r.length===1?r[0].name:void 0}c(ia,"implicitDestination");var br=class extends Error{static{c(this,"InvalidExactNumber")}};function kr(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||st(t.value)?.value!==t.value)throw new br("Expected a canonical, bounded ExactNumber value.");return t.value}c(kr,"canonicalExactText");function ra(t){return!kr(t).includes(".")}c(ra,"exactIsIntegral");var rc=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,oc=/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.[0-9]{1,7})?(?:Z|[+-]([0-9]{2}):([0-9]{2}))$/;function Er(t,e){let n=(e?oc:rc).exec(t);if(n===null||n[0].length!==t.length)return!1;let i=Number(n[1]),r=Number(n[2]),o=Number(n[3]),a=[31,i%4===0&&(i%100!==0||i%400===0)?29:28,31,30,31,30,31,31,30,31,30,31];if(i<1||r<1||r>12||o<1||o>a[r-1])return!1;if(!e)return!0;if(Number(n[4])>23||Number(n[5])>59||Number(n[6])>59)return!1;if(n[7]===void 0)return!0;let d=Number(n[7]),u=Number(n[8]);return d<=14&&u<=59&&(d!==14||u===0)}c(Er,"responseDateValue");var ac="http://schemas.microsoft.com/ws/2008/06/identity/claims/role",Cr=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),gt=c(t=>Array.from(t,e=>{let n=e.toUpperCase();return n.length===e.length&&e!=="\u0131"&&e!=="\u017F"?n:e}).join(""),"claimTypeKey");function Sn(t,e){let n=[],i=[],r=c(a=>({caller:null,contributions:n,refusal:a}),"refused");if(t.policies.length===0)return r({policy:null,reason:"noPolicies",location:t.location});for(let a of t.policies){let d=(e.policies??[]).find(m=>m.name===a);if(!d)return r({policy:a,reason:"unresolvedPolicy",location:t.location});if(d.condition===null||d.code!==null||d.file!==null)return r({policy:a,reason:"opaqueImplementation",location:d.location});let u=Pr(d.condition);if(u)return r({policy:a,reason:"negation",location:u.location});i.push(d)}for(let a of i){let d=Ar(a.condition,a.name,n);if(d)return r(d)}for(let a of i){let d=hn(a.condition,a.name,n);if(d)return r(d)}let o=[...new Set(n.filter(a=>a.kind==="role").map(a=>a.value))].sort(Cr),s=[];for(let a of n.filter(d=>d.kind==="claim"))s.some(d=>gt(d.type)===gt(a.type)&&d.value===a.value)||s.push({kind:"SpecificationCallerClaimSyntax",type:a.type,value:a.value,location:a.location});return s.sort((a,d)=>Cr(gt(a.type),gt(d.type))||Cr(a.value,d.value)),{caller:{kind:"SpecificationCallerSyntax",authenticated:!0,roles:o,claims:s,location:t.location},contributions:n,refusal:null}}c(Sn,"synthesizePersonaCaller");function Pr(t){return t.kind==="NotPolicyConditionSyntax"?t:t.kind==="LogicalPolicyConditionSyntax"?Pr(t.left)??Pr(t.right):null}c(Pr,"negation");function oa(t,e,n){switch(t.kind){case"AuthenticatedConditionSyntax":return n.push({kind:"authenticated",value:"true",type:null,policy:e,location:t.location}),null;case"RoleConditionSyntax":return n.push({kind:"role",value:t.role,type:null,policy:e,location:t.location}),null;case"ClaimConditionSyntax":if(gt(t.claim)===gt(ac))return{policy:e,reason:"roleClaim",location:t.location};if(!t.matchesSubject&&t.matches?.kind==="LiteralExpressionSyntax"&&typeof t.matches.value=="string")return n.push({kind:"claim",value:t.matches.value,type:t.claim,policy:e,location:t.location}),null}return{policy:e,reason:"nonLiteralClaim",location:t.location}}c(oa,"atom");function Ar(t,e,n){return t.kind!=="LogicalPolicyConditionSyntax"?oa(t,e,n):t.operator==="Or"?null:Ar(t.left,e,n)??Ar(t.right,e,n)}c(Ar,"required");function Nt(t,e){switch(t.kind){case"AuthenticatedConditionSyntax":return!0;case"RoleConditionSyntax":return e.some(n=>n.kind==="role"&&n.value===t.role);case"ClaimConditionSyntax":{let n=t.matches;return!t.matchesSubject&&n?.kind==="LiteralExpressionSyntax"&&e.some(i=>i.kind==="claim"&&gt(i.type)===gt(t.claim)&&i.value===n.value)}case"LogicalPolicyConditionSyntax":return t.operator==="And"?Nt(t.left,e)&&Nt(t.right,e):Nt(t.left,e)||Nt(t.right,e);default:return!1}}c(Nt,"satisfied");function hn(t,e,n){if(t.kind!=="LogicalPolicyConditionSyntax")return Nt(t,n)?null:oa(t,e,n);if(t.operator==="And")return hn(t.left,e,n)??hn(t.right,e,n);if(Nt(t,n))return null;let i=[...n],r=hn(t.left,e,i);if(r===null)return n.push(...i.slice(n.length)),null;let o=[...n];return hn(t.right,e,o)!==null?r:(n.push(...o.slice(n.length)),null)}c(hn,"complete");var Ir=new WeakMap;var D=c(t=>{let e=t.indexOf(" ");return e===-1?t:t.substring(0,e)},"firstWord"),re=c(t=>t.replaceAll("@",""),"unescapeIdentifier");function aa(t,e){let n=[],i=0,r=!1,o=!1;for(let s=0;s<t.length;s++){let a=t[s];a==="\\"&&r&&s+1<t.length?s++:a==='"'&&!o?r=!r:a==="`"&&!r?o=!o:a===e&&!r&&!o&&(n.push(t.substring(i,s)),i=s+1)}return n.push(t.substring(i)),n}c(aa,"splitTopLevel");var qt=c((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var wr=c(t=>t.content.length===0,"isBlank"),f=c(t=>qt(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),sa=c(t=>qt(t.number,1,t.path),"startOf");var sc=w("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?$"),la=w("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject)(?:\\s+(?:optional|generated|identifier|subject))*)$"),lc=w("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function He(t){let e=sc.exec(t.content);if(e===null)return;let n=f(t);return{kind:"PropertySyntax",name:re(e[1]),type:Ie(e[2],{...n,column:n.column+t.content.indexOf(e[2],e[1].length)}),isGenerated:e[3]!==void 0,nameWasEscaped:e[1].startsWith("@"),isIdentifier:e[4]!==void 0,...e[5]!==void 0?{isSubject:!0}:{},location:n}}c(He,"tryParseProperty");function Ie(t,e){let n=t.endsWith("?"),i=/\soptional$/.test(t),r=n||i;r&&(t=t.substring(0,t.length-(n?1:8)).trimEnd());let o=t.endsWith("[]");return o&&(t=t.substring(0,t.length-2)),{kind:"TypeRefSyntax",name:t,isCollection:o,isOptional:r,location:e}}c(Ie,"parseTypeRef");function Ue(t,e){let n=He(e);return n!==void 0?Le(t,n.type,e):_n(t,e),n}c(Ue,"parseProperty");function Le(t,e,n){t.claimField(n);let i=e.name.length+(e.isCollection?2:0),r=e.location.column-n.indent-1+i;if(e.isOptional&&n.content[r]==="?"){let o=e.name+(e.isCollection?"[]":"");t.information(l.LegacyOptionalSuffix,`Write '${o} optional' instead of '${o}?'.`,e.location)}}c(Le,"reportLegacyOptionalSuffix");function _n(t,e){let n=la.exec(e.content);if(n!==null&&n[1].split(/\s+/).includes("subject"))return t.error(l.InvalidSubjectModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier subject'.",f(e)),!0;if(lc.test(e.content))return t.error(l.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",f(e)),!0;{let i=la.exec(e.content);if(i!==null&&i[1].split(/\s+/).some(r=>r==="generated"||r==="identifier"))return t.error(l.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",f(e)),!0}return!1}c(_n,"reportInvalidModifierOrder");var Or=w("^then\\s+returns\\b"),Zn=w("^generated\\s+(?=\\S)(?![=])"),Kn=w("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),cc=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),dc=w(`^(?:"${z}"|'(?:[^'\\\\]|\\\\.)*')$`);function Bt(t,e,n,i){if(e.startsWith("case."))return je(e,n,t);if(Ft(e)&&t.error(l.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",n),(e.startsWith('"')||e.startsWith("'"))&&!dc.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=ae(e,n,t);return!["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(r.kind)||r.kind==="LiteralExpressionSyntax"&&typeof r.value=="number"&&!Number.isFinite(r.value)?(t.error(i,"Expected exactly one concrete literal or structured value, not an expression.",n),null):r}c(Bt,"parseConcrete");function Yt(t,e,n,i){let r=n.exec(e.content);if(r===null)return t.error(i,"Expected a named fixture or assertion with exactly one concrete value.",f(e)),t.skipBlock(e.indent),null;let o=f(e),s=Bt(t,r[2],{...o,column:o.column+e.content.indexOf(r[2],e.content.indexOf("=")+1)},i),a=t.peekChild(e.indent);return a!==void 0&&(t.error(i,"A fixture or return field cannot have child directives.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"PropertyMappingSyntax",property:r[1],source:s,location:o}}c(Yt,"parseConcreteMapping");function ca(t,e){let n=Or.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=f(e);if(i.length>0){let s=Bt(t,i,{...r,column:r.column+e.content.indexOf(i,n)},l.InvalidReturnExpectation),a=t.peekChild(e.indent);return a!==void 0&&(t.error(l.InvalidReturnExpectation,"A scalar return expectation cannot have child assertions.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"ScalarSpecificationReturnSyntax",value:s,location:r}}let o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=Yt(t,s,cc,l.InvalidReturnExpectation);a!==null&&o.push(a)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}c(ca,"parseReturn");var pc=new RegExp(w("^case\\s+([A-Za-z_]\\w*)(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?$").source,"du"),uc=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),fc=w("^case\\.([a-z_]\\w*)$");function Ft(t){return/\bcase\.[a-z_]\w*/.test(t.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,""))}c(Ft,"containsCaseReference");function je(t,e,n,i=!1){if(!t.startsWith("case."))return Ft(t)&&n.error(l.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",e),ae(t,e,n,i);let r=fc.exec(t);return r===null&&n.error(l.InvalidSpecificationCaseReference,"A case reference fills a whole value position: 'case.<parameter>'.",e),{kind:"CaseValueExpressionSyntax",parameter:r?.[1]??t.substring(5),location:e}}c(je,"parseSpecificationValue");function da(t,e){let n=e.content.indexOf(" ")+1,i=n>0?Ue(t,{...e,content:e.content.substring(n),indent:e.indent+n}):void 0;if(i===void 0||i.isGenerated||i.isIdentifier)return t.error(l.InvalidSpecificationParameter,"Expected 'parameter <name> <Type>', with optional collection and optional modifiers.",f(e)),t.skipOpaqueBlock(e.indent),null;let r=t.peekChild(e.indent);return r!==void 0&&(t.error(l.InvalidSpecificationParameter,"A parameter has no body or default.",f(r)),t.skipOpaqueBlock(e.indent)),{kind:"SpecificationParameterSyntax",name:i.name,type:i.type,location:f(e)}}c(da,"parseParameter");function pa(t,e){let n=pc.exec(e.content);if(n===null)return t.error(l.InvalidSpecificationCase,"Expected 'case <Name>' with at most one inline parameter assignment.",f(e)),t.skipOpaqueBlock(e.indent),null;let i=[],r=c((o,s,a)=>{let d=f(a),u={...d,column:d.column+a.content.indexOf(s,a.content.indexOf("=")+1)};if(s.startsWith("case.")){t.error(l.InvalidSpecificationCaseValue,"A case assigns concrete values, not case references.",u);return}let m=Bt(t,s,u,l.InvalidSpecificationCaseValue);m!==null&&i.push({kind:"PropertyMappingSyntax",property:o,source:m,location:a===e?{...d,column:d.column+n.indices.groups.property[0]}:d})},"add");n.groups?.property!==void 0&&r(n.groups.property,n.groups.value,e);for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=uc.exec(o.content);if(s===null){t.error(l.InvalidSpecificationCaseAssignment,"Expected '<parameter> = <concrete value>' in a case.",f(o)),t.skipOpaqueBlock(o.indent);continue}r(s[1],s[2],o);let a=t.peekChild(o.indent);a!==void 0&&(t.error(l.InvalidSpecificationCaseValue,"A case value must fit on one line.",f(a)),t.skipOpaqueBlock(o.indent))}return{kind:"SpecificationCaseSyntax",name:n[1],values:i,location:f(e)}}c(pa,"parseCase");function Ut(t){return Array.isArray(t)?t.flatMap(Ut):t===null||typeof t!="object"?[]:"kind"in t&&t.kind==="CaseValueExpressionSyntax"?[t]:Object.values(t).flatMap(Ut)}c(Ut,"caseReferences");function ua(t,e){let n=t.parameters??[],i=t.cases??[];n.length===0!=(i.length===0)&&e.error(l.IncompleteSpecificationTable,"A specification table requires parameters and at least one case.",t.location),n.forEach((o,s)=>{n.slice(0,s).some(a=>a.name===o.name)&&e.error(l.DuplicateSpecificationParameter,`Parameter '${o.name}' is declared more than once.`,o.location)}),i.forEach((o,s)=>{i.slice(0,s).some(a=>a.name===o.name)&&e.error(l.DuplicateSpecificationCase,`Case '${o.name}' is declared more than once.`,o.location);for(let a of o.values.filter(d=>!n.some(u=>u.name===d.property)))e.error(l.InvalidSpecificationCaseAssignment,`Case '${o.name}' assigns undeclared parameter '${a.property}'.`,a.location);for(let a of n.filter(d=>o.values.filter(u=>u.property===d.name).length!==1))e.error(l.InvalidSpecificationCaseAssignment,`Case '${o.name}' must assign parameter '${a.name}' exactly once.`,o.location)});let r=Ut(t);for(let o of r)(i.length===0||!n.some(s=>s.name===o.parameter))&&e.error(l.InvalidSpecificationCaseReference,`Case reference '${o.parameter}' requires a declared parameter in a specification table.`,o.location);for(let o of n.filter(s=>!r.some(a=>a.parameter===s.name)))e.warning(l.UnusedSpecificationParameter,`Parameter '${o.name}' is never referenced.`,o.location);for(let o of Ut(t.whenRedelivered))e.error(l.InvalidSpecificationCaseReference,"Case references are not permitted in redelivery locators.",o.location)}c(ua,"validateTable");function wt(t,e,n=new WeakMap){if(t!==null&&typeof t=="object"&&n.has(t))return n.get(t);if(Array.isArray(t)){let r=t.map(o=>wt(o,e,n));return n.set(t,r),r}if(t===null||typeof t!="object"||!("kind"in t))return t;if(t.kind==="CaseValueExpressionSyntax"){let r=t.parameter;return e.values.find(o=>o.property===r)?.source??t}let i=Object.fromEntries(Object.entries(t).map(([r,o])=>[r,wt(o,e,n)]));if(t.kind==="SpecificationErrorSyntax"&&"caseValue"in t&&t.caseValue!==void 0){let r=i.caseValue;i.name=r.kind==="LiteralExpressionSyntax"?r.value:null,delete i.caseValue}return n.set(t,i),i}c(wt,"substituteCase");function Wt(t){let e=[],n=c((a,d)=>{for(let u of a??[])e.push({name:u.name,scope:d,example:u})},"examples"),i=c((a,d)=>{for(let u of a){let m=[...d,u.name];n(u.examples,m);for(let p of u.slices){let y=[...d,u.name,p.name];n(p.examples,y);for(let h of new Set(le(p).map(g=>g.name)))e.push({name:h,scope:y,kind:"event"});for(let h of p.commands)e.push({name:h.name,scope:y,kind:"command"});for(let h of p.readModels)e.push({name:h.name,scope:y,kind:"readmodel"})}i(u.features,m)}},"features");n(t.examples,[]);for(let a of[...t.concepts,...t.types])e.push({name:a.name,scope:[],kind:"type"});for(let a of t.modules)n(a.examples,[a.name]),i(a.features,[a.name]);let r=c((a,d)=>{let u=c(y=>{let h=y.split("."),g=e.filter(S=>S.name===h.at(-1)),b=h.slice(0,-1);if(b.length)return g.filter(S=>b.length<=S.scope.length&&b.every(($,x)=>S.scope[S.scope.length-b.length+x]===$));for(let S=d.length;S>=0;S--){let $=g.filter(x=>S<=x.scope.length&&d.slice(0,S).every((P,I)=>x.scope[I]===P));if($.length)return $}return[]},"candidates"),m=u(a),p=t.imports.filter(y=>y.qualifiedName.split(".").at(-1)===a);return!m.length&&p.length===1&&(m=u(p[0].qualifiedName)),m.length===1?m[0]:void 0},"resolve"),o=c((a,d,u)=>{let m=r(a,u),p=m?.example;if(!p)return null;let y=r(p.type,m.scope);return y?.kind===d?{example:p,name:[...y.scope,y.name].join(".")}:null},"fixture"),s=c((a,d)=>[...a.filter(u=>!d.some(m=>m.property===u.property)),...d],"merge");return{resolvedExamples:e.filter(a=>a.example!==void 0).flatMap(a=>{let d=r(a.example.type,a.scope);return d?.kind===void 0?[]:[{example:a.example,kind:d.kind,name:[...d.scope,d.name].join("."),scope:d.scope}]}),eventStep:c((a,d,u)=>{let m=o(a.eventType,"event",u),p=m?.example??null,y=p?.stream??p?.noStream??null,h=a.stream??a.noStream??null,g=h??y,b=m===null?a:{...a,eventType:m.name,values:s(p.values,a.values),for:a.for??p.for,stream:g?.kind==="SpecificationStreamSyntax"?g:null,noStream:g?.kind==="SpecificationNoStreamSyntax"?g:null},S=b.values.map($=>{let x=p?.values.find(I=>I.property===$.property),P=a.values.includes($);return{property:$.property,value:$.source,origin:P?x===void 0?"authored":"override":"example",overriddenValue:P?x?.source??null:null}});return b.for!==null&&S.push({property:"for",value:b.for,origin:a.for===null?"example":p?.for==null?"authored":"override",overriddenValue:a.for===null?null:p?.for??null}),{role:d,authored:a,effective:b,example:p,values:S,route:g===null?null:{value:g,origin:h===null?"example":y===null?"authored":"override",overriddenValue:h===null?null:y}}},"eventStep"),command:c((a,d)=>{if(!a)return a;let u=o(a.commandType,"command",d);if(!u)return a;let{example:m,name:p}=u;return{...a,commandType:p,values:s(m.values,a.values),generatedValues:s(m.generatedValues,a.generatedValues??[]),for:a.for??m.for}},"command"),readModel:c((a,d)=>{let u=o(a.name,"readmodel",d);return u?{...a,name:u.name,properties:s(u.example.values,a.properties)}:a},"readModel")}}c(Wt,"specificationExamples");function Jn(t){return Wt(t).command}c(Jn,"specificationCommandExamples");function _e(t){return Hn(t).application}c(_e,"expandSpecificationExamples");function Hn(t){let e=Wt(t),n=[],i=c((r,o)=>r.map(s=>{let a=[...o,s.name];return{...s,features:i(s.features,a),slices:s.slices.map(d=>{let u=[...o,s.name,d.name],m={...d,specifications:d.specifications.flatMap(p=>{let y=[],h=c((x,P)=>{let I=e.eventStep(x,P,u);return y.push(I),I.effective},"event"),g=t.personas.find(x=>x.name===p.givenCallerPersona?.name),b=g===void 0?null:Sn(g,t),S=b?.caller==null?null:{...b.caller,location:p.givenCallerPersona.location};S!==null&&y.push({role:"given caller",authored:p.givenCallerPersona,effective:S,example:null,route:null,values:b.contributions.map(x=>({property:x.type??x.kind,value:{kind:"LiteralExpressionSyntax",value:x.kind==="authenticated"?!0:x.value,location:x.location},origin:"persona",overriddenValue:null,persona:g.name,policy:x.policy}))});let $={...p,...S===null?{}:{givenCaller:S,givenCallerPersona:void 0},given:p.given.map(x=>h(x,"given")),givenReadModels:p.givenReadModels.map(x=>e.readModel(x,u)),when:e.command(p.when,u),whenAppended:p.whenAppended===null?null:h(p.whenAppended,"when append"),thenEvents:p.thenEvents.map(x=>h(x,"then")),thenReadModels:p.thenReadModels.map(x=>e.readModel(x,u))};return(p.cases?.length??0)===0?(n.push({authored:p,effective:$,steps:y}),[$]):p.cases.map(x=>{let P=new WeakMap,I={...wt($,x,P),name:`${p.name}_${x.name}`,parameters:[],cases:[]};return Ir.set(I,{table:p.name,case:x.name}),n.push({authored:p,effective:I,table:p.name,case:x.name,steps:y.map(v=>({...v,effective:wt(v.effective,x,P),values:v.values.map(E=>E.value.kind==="CaseValueExpressionSyntax"?{...E,value:wt(E.value,x,P),origin:"case",caseParameter:E.value.parameter}:E),route:v.route===null?null:{...v.route,value:wt(v.route.value,x,P)}}))}),I})})};return at.set(m,fe(d)),m})}}),"features");return{application:{...t,modules:t.modules.map(r=>({...r,features:i(r.features,[r.name])}))},specifications:n}}c(Hn,"expandEffectiveSpecificationExamples");var Xn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function ei(t,e,n=e.inputUses){let i=Jn(t),r=[],o=c((v,E)=>{let C=[...E,v.name];v.slices.forEach(k=>r.push({slice:k,scope:[...C,k.name]})),v.features.forEach(k=>o(k,C))},"collect");t.modules.forEach(v=>v.features.forEach(E=>o(E,[v.name])));let s=new Map,a=new Map,d=new Map;for(let{slice:v,scope:E}of r)for(let C of v.commands){let k=s.get(C.name)??[];k.push({command:C,scope:E}),s.set(C.name,k),a.set(C,oe(C.properties)),C.response?.kind==="RecordCommandResponseSyntax"&&d.set(C,oe(C.response.fields))}let u=new Map;for(let v of t.imports){let E=v.qualifiedName.split(".").at(-1);u.set(E,[...u.get(E)??[],v.qualifiedName])}let m=new Map,p=c((v,E)=>{let C=`${E.join(".")}|${v}`;if(m.has(C))return m.get(C);let k=u.get(v)??[],T=((s.get(v.split(".").at(-1))??[]).length===0&&k.length===1?k[0]:v).split("."),M=s.get(T.at(-1))??[];if(T.length>1){let j=T.slice(0,-1);M=M.filter(q=>j.length<=q.scope.length&&j.every((Q,K)=>q.scope[q.scope.length-j.length+K]===Q))}else for(let j=E.length;j>=0;j--){let q=M.filter(Q=>j<=Q.scope.length&&E.slice(0,j).every((K,J)=>Q.scope[J]===K));if(q.length>0){M=q;break}}let N=M.length===1?M[0].command:null;return m.set(C,N),N},"resolve"),y=oe(t.concepts),h=new Set(t.concepts.map(v=>v.name)),g=new Map([...oe(t.types)].map(([v,E])=>[v,oe(E.properties)])),b=new Set(r.flatMap(v=>v.slice.readModels.map(E=>E.name))),S=new Set([...a.keys()].flatMap(v=>[...v.properties])),$=c(v=>{for(let E of v)E.isGenerated&&!S.has(E)&&e.error(l.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",E.location)},"checkDeclarations"),x=c(v=>{v.features.forEach(x);for(let E of v.slices){for(let C of E.commands)for(let k of C.produces)k.inlineEvent!==null&&$(k.inlineEvent.properties);E.events.forEach(C=>$(C.properties)),E.readModels.forEach(C=>$(C.properties));for(let C of E.reactions)for(let k of C.triggers)for(let A of k.produces)A.inlineEvent!==null&&$(A.inlineEvent.properties)}},"checkFeature");t.types.forEach(v=>$(v.properties)),t.modules.forEach(v=>v.features.forEach(x));let P=c((v,E,C)=>{let k=a.get(C).get(v.property);if(k===void 0){e.error(l.InvalidResponseSource,`Response source '${v.property}' must reference one direct command property.`,v.location);return}let A=k.type;(A.isCollection||b.has(A.name))&&e.error(l.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",v.location),E!==null&&(E.name!==A.name||E.isCollection!==A.isCollection||E.isOptional!==A.isOptional)&&e.error(l.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",E.location)},"validateSource");for(let v of a.keys()){for(let C of v.properties){if(!C.isGenerated)continue;let k=y.get(C.type.name);(C.type.isOptional||C.type.isCollection||(k===void 0?Xn.has(C.type.name)||g.has(C.type.name)||h.has(C.type.name)||b.has(C.type.name):k.type!=="Uuid"))&&e.error(l.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",C.location)}let E=v.response;if(E?.kind==="ScalarCommandResponseSyntax")P(E.source,null,v);else if(E?.kind==="RecordCommandResponseSyntax"){E.fields.length===0&&e.error(l.InvalidCommandResponse,"A response block requires at least one field.",E.location);let C=new Set;for(let k of E.fields)C.has(k.name)&&e.error(l.DuplicateResponseField,`Duplicate response field '${k.name}'.`,k.location),C.add(k.name),P(k.source,k.type,v)}}let I=c((v,E)=>{let C=i(v.when,E),k=C===null?null:p(C.commandType,E);if(C!==null&&k!==null){let M=a.get(k);for(let q of C.values)M.get(q.property.split(".")[0])?.isGenerated&&e.error(l.GeneratedPropertySuppliedAsInput,`Generated property '${q.property}' cannot be supplied as request or form input.`,q.location);let N=[...M.values()].filter(q=>q.isIdentifier);if(C.for!==null&&N.length===1&&N[0].isGenerated){let q=N[0].type;(Xn.has(q.name)||y.has(q.name)||g.has(q.name))&&(q.isOptional||q.isCollection||y.get(q.name)?.type!=="Uuid"||C.for.kind!=="LiteralExpressionSyntax"||typeof C.for.value!="string"||!fa(C.for.value))&&e.error(l.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",C.for.location)}let j=new Set;for(let q of C.generatedValues??[]){let Q=M.get(q.property);(j.has(q.property)||Q===void 0||!Q.isGenerated||Q.isIdentifier||!Pe(q.source,Q.type,y,g))&&e.error(l.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",q.location),j.add(q.property)}}let A=v.thenReturns;if(A==null||((C===null||v.thenErrors.length>0||v.thenDenied!=null)&&e.error(l.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",A.location),k===null))return;let O=k.response,T=a.get(k);if(A.kind==="ScalarSpecificationReturnSyntax"&&O?.kind==="ScalarCommandResponseSyntax"&&T.has(O.source.property))Pe(A.value,T.get(O.source.property).type,y,g)||e.error(l.InvalidReturnExpectation,"The expected return value must match the response source's type.",A.location);else if(A.kind==="RecordSpecificationReturnSyntax"&&O?.kind==="RecordCommandResponseSyntax"){A.fields.length===0&&e.error(l.InvalidReturnExpectation,"A record return expectation requires at least one field.",A.location);let M=d.get(k),N=new Set;for(let j of A.fields){let q=M.get(j.property),Q=q===void 0?void 0:T.get(q.source.property);(N.has(j.property)||Q===void 0||!Pe(j.source,Q.type,y,g))&&e.error(l.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",j.location),N.add(j.property)}}else e.error(l.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",A.location)},"validateSpecification");for(let{slice:v,scope:E}of r)v.specifications.forEach(C=>I(C,E));for(let v of n){if(v.isParameter===!0)continue;let E=p(v.command,v.scope);E!==null&&a.get(E).get(v.property.split(".")[0])?.isGenerated&&e.error(l.GeneratedPropertySuppliedAsInput,`Generated property '${v.property}' cannot be supplied as request or form input.`,v.location)}}c(ei,"validateResponses");function oe(t){let e=new Map,n=new Set;for(let i of t)e.has(i.name)&&n.add(i.name),e.set(i.name,i);return n.forEach(i=>e.delete(i)),e}c(oe,"uniqueByName");function Pe(t,e,n,i){if(t.kind==="LiteralExpressionSyntax"&&t.value===null)return e.isOptional;if(e.isCollection)return t.kind==="ListExpressionSyntax"&&t.items.every(a=>Pe(a,{...e,isCollection:!1,isOptional:!1},n,i));let r=i.get(e.name);if(r!==void 0)return t.kind==="ObjectExpressionSyntax"&&t.members.every(a=>{let d=r.get(a.name);return d!==void 0&&Pe(a.value,d.type,n,i)});let o=n.get(e.name),s=o?.type??e.name;if(o?.type==="Enum")return t.kind==="LiteralExpressionSyntax"&&typeof t.value=="string"&&o.values.includes(t.value);if(t.kind==="LiteralExpressionSyntax")switch(s){case"Uuid":return typeof t.value=="string"&&fa(t.value);case"String":return typeof t.value=="string";case"Bool":return typeof t.value=="boolean";case"Int":return typeof t.value=="number"?Number.isFinite(t.value)&&Number.isInteger(t.value):typeof t.value=="object"&&t.value!==null&&ra(t.value);case"Decimal":return typeof t.value=="number"?Number.isFinite(t.value):typeof t.value=="object"&&t.value!==null&&t.value.literalType==="ExactNumber";case"Date":return typeof t.value=="string"&&Er(t.value,!1);case"DateTime":return typeof t.value=="string"&&Er(t.value,!0);default:return!Xn.has(s)}return!Xn.has(s)&&o===void 0}c(Pe,"compatibleValue");var mc=/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}|\{[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\}|\([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\))(?![\s\S])/i;function fa(t){return mc.test(t)}c(fa,"uuidValue");function yc(t,e,n){let i=oe(n.types),r=t.properties,o=null,s=!1,a=!1;for(let d of e.split(".")){let u=r.filter(p=>p.name===d);if(u.length!==1)return null;let m=u[0].type;s||=m.isOptional,a||=m.isCollection,o={...m,isOptional:s,isCollection:a},r=i.get(m.name)?.properties??[]}return o}c(yc,"commandPathType");function zt(t,e,n,i){let r=e.for?.kind==="PathExpressionSyntax"?e.for.path:ia(t,e,i);return r==="new event source"?t.properties.find(o=>o.isGenerated&&o.isIdentifier)?.type??{kind:"TypeRefSyntax",name:"Uuid",isOptional:!1,isCollection:!1,location:e.location}:r===void 0?null:yc(t,r,n)}c(zt,"commandDestinationType");var ma=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]),Xe=class{static{c(this,"RefusalDeclarations")}application;slices;types;concepts;events;knownTypes;constructor(e){this.application=e,this.slices=new ie(e).slices,this.types=oe(e.types),this.concepts=oe(e.concepts),this.knownTypes=new Set([...ma,...e.types.map(n=>n.name),...e.concepts.map(n=>n.name)]),this.events=new Map(this.slices.map(({slice:n})=>{let i=new Map;for(let r of le(n))(!i.has(r.name)||i.get(r.name).generation<r.generation)&&i.set(r.name,r);return[n,[...i.values()]]}))}resolve(e,n,i){let r=this.slices.flatMap(({slice:d,scope:u})=>i(d).map(m=>({node:m,slice:d,scope:u}))),o=this.slices.find(d=>d.slice===n)?.scope??[],s=c(d=>{let u=d.split("."),m=r.filter(y=>y.node.name===u.at(-1)),p=u.slice(0,-1);if(p.length>0)return m.filter(y=>p.length<=y.scope.length&&p.every((h,g)=>y.scope[y.scope.length-p.length+g]===h));for(let y=o.length;y>=0;y--){let h=m.filter(g=>y<=g.scope.length&&o.slice(0,y).every((b,S)=>g.scope[S]===b));if(h.length>0)return h}return[]},"candidates"),a=s(e);if(a.length===0){let d=this.application.imports.filter(u=>u.qualifiedName.split(".").at(-1)===e);d.length===1&&(a=s(d[0].qualifiedName))}return a.length===1?a[0]:null}event(e,n){return this.resolve(e,n,i=>this.events.get(i)??[])?.node??null}property(e,n){let i=n.split(".");for(let[r,o]of i.entries()){let s=e?.filter(d=>d.name===o)??[];if(s.length!==1)return null;let a=s[0];if(r===i.length-1)return a;if(ma.has(a.type.name)||this.concepts.has(a.type.name)&&!this.application.types.some(d=>d.name===a.type.name))return null;e=this.types.get(a.type.name)?.properties??null}return null}compatible(e,n){return this.knownTypes.has(e.name)&&this.knownTypes.has(n.name)?e.name===n.name&&e.isCollection===n.isCollection&&(!e.isOptional||n.isOptional):null}};var hc=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function ni(t,e,n){let i=new Xe(t),r=Wt(t),o=c(d=>hc.has(d)||i.concepts.has(d)||i.types.has(d),"knownType"),s=new Map([...i.types].map(([d,u])=>[d,new Map(u.properties.map(m=>[m.name,m]))])),a=n===void 0?i.slices:[{scope:[],slice:{kind:"SliceSyntax",type:"StateChange",name:"",description:null,location:t.location,events:[],commands:[],queries:[],projections:[],captures:[],reactions:[],constraints:[],readModels:[],screens:[],specifications:n}}];for(let{slice:d,scope:u}of a){let m=new Map;for(let p of d.specifications){let y=(p.cases?.length??0)===0?[p.name]:p.cases.map(h=>`${p.name}_${h.name}`);for(let h of y)m.set(h,(m.get(h)??0)+1);(p.cases?.length??0)>0&&m.set(p.name,(m.get(p.name)??0)+1)}for(let p of d.specifications){for(let b of p.cases??[])(m.get(`${p.name}_${b.name}`)??0)>1&&e.error(l.SpecificationCaseNameCollision,`Case '${b.name}' derives specification '${p.name}_${b.name}', which collides in this ${n===void 0?"slice":"document"}.`,b.location);for(let b of p.parameters??[]){n===void 0&&!o(b.type.name)&&e.error(l.IncompatibleSpecificationParameterType,`Parameter '${b.name}' has unknown type '${b.type.name}'.`,b.type.location);for(let S of p.cases??[])for(let $ of S.values.filter(x=>x.property===b.name))Pe($.source,b.type,i.concepts,s)||e.error(l.InvalidSpecificationCaseValue,`Case '${S.name}' parameter '${b.name}' requires a concrete value of type '${b.type.name}'.`,$.source.location)}let y=c((b,S,$)=>{if(b?.kind!=="CaseValueExpressionSyntax"||S===void 0)return;let x=p.parameters?.find(E=>E.name===b.parameter);if(x===void 0||(x.type.isOptional&&!S.isOptional&&e.error(l.OptionalSpecificationParameterTarget,`Optional parameter '${x.name}' cannot supply required target '${$}'.`,b.location),n!==void 0&&(!o(x.type.name)||!o(S.name))))return;let P=i.concepts.get(x.type.name),I=i.concepts.get(S.name);(!(x.type.name===S.name||P?.type!=="Enum"&&P?.type===S.name||I?.type!=="Enum"&&I?.type===x.type.name)||x.type.isCollection!==S.isCollection)&&e.error(l.IncompatibleSpecificationParameterType,`Parameter '${x.name}' type '${x.type.name}' is incompatible with target '${$}' type '${S.name}'.`,b.location)},"check"),h=c((b,S)=>{for(let $ of b)y($.source,i.property(S,$.property)?.type,$.property)},"assignments"),g=r.command(p.when,u);if(g!==null){let b=i.resolve(g.commandType,d,S=>S.commands)?.node.properties??null;h(g.values,b),h(g.generatedValues??[],b),y(g.for,b?.find(S=>S.isIdentifier)?.type,"for")}if(g!==null&&p.thenReturns!=null){let b=i.resolve(g.commandType,d,$=>$.commands)?.node,S=b?.response;if(p.thenReturns.kind==="ScalarSpecificationReturnSyntax"&&S?.kind==="ScalarCommandResponseSyntax"&&y(p.thenReturns.value,b?.properties.find($=>$.name===S.source.property)?.type,"value"),p.thenReturns.kind==="RecordSpecificationReturnSyntax"&&S?.kind==="RecordCommandResponseSyntax")for(let $ of p.thenReturns.fields){let x=S.fields.find(P=>P.name===$.property);y($.source,x?.type??b?.properties.find(P=>P.name===x?.source.property)?.type,$.property)}}for(let b of[...p.given,...p.thenEvents,...p.whenAppended===null?[]:[p.whenAppended]]){let S=r.eventStep(b,"given",u).effective;h(S.values,i.event(S.eventType,d)?.properties??null);let $=S.stream==null?null:new Fe(t).resolve(S.stream.eventSource,S.stream.stream),x=$?.kind===pe.Unique?$.sources[0]:void 0,P=$?.kind===pe.Unique?$.streams[0]:void 0;y(S.for,S.stream!=null&&x===void 0?void 0:x?.identifier??Sc(S.eventType,d,t,i),"for"),S.stream?.streamId!=null&&y(S.stream.streamId.source,P?.streamId??void 0,"streamId");for(let I of S.stream?.streamIdParts??[])y(I.source,P?.streamIdParts.find(v=>v.name===I.property)?.type,I.property)}for(let b of[...p.givenReadModels,...p.thenReadModels]){let S=r.readModel(b,u);h(S.properties,i.resolve(S.name,d,$=>$.readModels)?.node.properties??null)}if(p.whenTrigger!=null){let b=(t.declaredTriggers??[]).find(S=>S.name===p.whenTrigger.trigger);for(let S of p.whenTrigger.values)y(S.source,b?.data.find($=>$.name===S.property)?.type,S.property)}for(let b of p.thenErrors)y(b.caseValue??null,{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:b.location},"message");for(let b of p.thenAbsentReadModels??[]){let S=i.resolve(b.name,d,x=>x.readModels)?.node,$=i.slices.flatMap(({slice:x})=>x.queries.filter(P=>P.by!==null&&i.resolve(P.returnType.name,x,I=>I.readModels)?.node===S));y(b.key,S!==void 0&&$.length===1?$[0].by.type:void 0,"for")}for(let b of[...p.thenQueries??[],...p.whenQuery===null?[]:[p.whenQuery]]){let S=i.resolve(b.query,d,I=>I.queries),$=S===null?[]:[...S.node.by===null?[]:[S.node.by],...S.node.filters].map(I=>({...I,kind:"PropertySyntax",isIdentifier:!1}));h(b.arguments,$);let x=S===null?null:i.resolve(S.node.returnType.name,S.slice,I=>I.readModels)?.node.properties??null,P=b.kind==="SpecificationQuerySyntax"?b.results:p.thenResults;for(let I of P)h(I.properties,x)}}}}c(ni,"validateSpecificationCases");function ti(t){let e=new Map(t.map(n=>[JSON.stringify([n.name,n.isOptional,n.isCollection]),n]));return e.size===1?[...e.values()][0]:void 0}c(ti,"uniqueDestinationType");function Sc(t,e,n,i){let r=new ie(n),o=i.event(t,e);if(o===null)return;let s=c((d,u=i.slices)=>u.flatMap(({slice:m})=>m.commands.flatMap(p=>p.produces.filter(y=>r.isEventProduction(y,m)&&i.event(y.event,m)===d).map(y=>zt(p,y,n,{resolver:r,slice:m})).filter(y=>y!==null))),"commandTypes"),a=c((d,u)=>{if(u.has(d))return[];u.add(d);let m=s(d);for(let{slice:p}of i.slices){for(let y of p.reactions.flatMap(h=>h.triggers)){let h=y.source.kind==="NamedTriggerSourceSyntax"?y.source.name:void 0,g=h===void 0?null:i.event(h,p);for(let b of y.produces.filter(S=>i.event(S.event,p)===d))if(b.for?.kind==="PathExpressionSyntax"){let S=b.for.path,$=i.property(g?.properties??null,S)?.type??(h===void 0?void 0:(n.declaredTriggers??[]).find(x=>x.name===h)?.data.find(x=>x.name===S)?.type);$!==void 0&&m.push($)}else b.for?.kind==="LiteralExpressionSyntax"?m.push({kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:b.location}):b.for===null&&g!==null&&m.push(...a(g,u))}p.captures.flatMap(y=>[...y.appends,...y.children.flatMap(h=>h.appends),...y.nested.flatMap(h=>h.appends)]).some(y=>i.event(y.event,p)===d)&&m.push(ti(s(d))??{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:d.location})}return m},"producerTypes");return ti(s(o,i.slices.filter(d=>d.slice===e)))??ti(s(o))??ti(a(o,new Set))}c(Sc,"eventDestinationType");function ii(t){let e=new ie(t);return e.slices.flatMap(({slice:n})=>n.commands.flatMap(i=>{let r=i.properties.filter(o=>o.isIdentifier&&!o.type.isOptional&&!o.type.isCollection);return r.length!==1?[]:i.produces.filter(o=>e.isEventProduction(o,n)&&o.inlineEvent===null&&o.when===null&&o.for===null).map(o=>({severity:"information",code:l.OmittedProductionDestination,message:`Plain 'produces ${o.event}' omits its destination - use 'for ${r[0].name}' to explicitly select the command's identifier.`,location:o.location}))}))}c(ii,"productionDestinationDiagnostics");function ri(t,e){let n=new ie(t).slices.map(r=>r.slice),i=n.flatMap(le);for(let r of n)for(let o of r.constraints.flatMap(s=>[s,...s.additionalRules])){if(o.kind!=="UniquePropertyConstraintSyntax")continue;let s=i.filter(a=>a.name===o.event);if(s.length!==0)for(let a of[o.property,...o.additionalProperties])a.includes(".")||s.some(d=>d.properties.some(u=>u.name===a))||e.error(l.UnknownConstraintProperty,`Constraint '${o.name}' names property '${a}', which event '${o.event}' does not declare.`,o.location)}}c(ri,"validateConstraintProperties");var ya=c((t,e)=>t.length===e.length&&t.every((n,i)=>n===e[i]),"same"),oi=c(t=>[...t.scope,t.name].join("."),"addressOf"),Ne=class{static{c(this,"DeclaredDependencyTargets")}static containersOf(e){let n=[],i=c((r,o)=>{n.push({name:r.name,scope:o}),r.features.forEach(s=>i(s,[...o,r.name]))},"inventory");for(let r of e.modules)n.push({name:r.name,scope:[]}),r.features.forEach(o=>i(o,[r.name]));return[...new Map(n.map(r=>[oi(r),r])).values()]}static candidates(e,n){let i=e.join(".");return n.flatMap(r=>{let o=oi(r);if(o===i||o.startsWith(i+".")||i.startsWith(o+"."))return[];let s=[...r.scope,r.name];for(let a=1;a<=s.length;a++){let d=s.slice(-a).join(".");if(this.resolve(d,e,n).resolved!==r)continue;let u=a===1?e.length-1-r.scope.length:"qualified";return[{container:r,reference:d,tier:u}]}return[]}).sort((r,o)=>(r.tier==="qualified"?e.length:r.tier)-(o.tier==="qualified"?e.length:o.tier))}static resolve(e,n,i){let r=e.split(".");if(r.length>1){let o=i.filter(s=>ya([...s.scope,s.name].slice(-r.length),r));return o.length===1?{resolved:o[0],ambiguous:[]}:{ambiguous:o}}for(let o=n.length-1;o>=0;o--){let s=i.filter(a=>a.name===e&&ya(a.scope,n.slice(0,o)));if(s.length>0)return s.length===1?{resolved:s[0],ambiguous:[]}:{ambiguous:s}}return{ambiguous:[]}}};function ai(t,e){let n=c(a=>(a.dependsOn?.length??0)>0||a.features.some(n),"hasDependencies");if(!t.modules.some(n))return t;let i=Ne.containersOf(t),r=new Map,o=c((a,d)=>{let u=[],m=d.join(".");r.has(m)||r.set(m,new Set);let p=r.get(m);for(let y of a){let h=Ne.resolve(y.target,d,i),g=h.resolved===void 0?void 0:oi(h.resolved),b=g===void 0?`text:${y.target}`:`resolved:${g}`;if(p.has(b)){e.warning(l.RepeatedDependencyDeclaration,`Dependency '${y.target}' is already declared on this container - this repeated declaration is ignored`,y.location);continue}p.add(b),u.push(y),h.ambiguous.length>0?e.warning(l.AmbiguousReference,`Ambiguous dependency target '${y.target}' - candidates: ${h.ambiguous.map(oi).join(", ")}`,y.location):(g===void 0||g===m||g.startsWith(m+".")||m.startsWith(g+"."))&&e.warning(l.InvalidDependencyTarget,`Invalid dependency target '${y.target}' on '${m}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`,y.location)}return u},"keep"),s=c((a,d)=>{let u=[...d,a.name];return{...a,dependsOn:o(a.dependsOn??[],u),features:a.features.map(m=>s(m,u))}},"normalize");return{...t,modules:t.modules.map(a=>({...a,dependsOn:o(a.dependsOn??[],[a.name]),features:a.features.map(d=>s(d,[a.name]))}))}}c(ai,"validateDependencyDeclarations");var Ot=[],gn=c(t=>t.length===0,"isDocumentPlacement");function si(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}c(si,"describePlacement");var gc=w("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),xc=new RegExp(w("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),vc=w("^[A-Z]\\w*$");function xt(t,e){let n=e.content.substring(9);for(let a=t.peekChild(e.indent);a!==void 0&&gc.test(a.content);a=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${a.content}`;let i=$c(n),r=f(e);if(i.length===0)return t.error(l.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let s=new Tr(t,i,r).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:r}}c(xt,"parseAuthorize");function et(t,e){return t===null?e:e===null?t:{kind:"AuthorizeSyntax",requirement:{kind:"LogicalPolicyRequirementSyntax",left:t.requirement,operator:"And",right:e.requirement,location:t.location},location:t.location}}c(et,"combineAuthorize");function $c(t){let e=[];for(let n of t.match(xc)??[])e.length>0&&bc(e[e.length-1])&&kc(n)&&e.push("and"),e.push(n);return e}c($c,"tokenize");var ha=c(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),bc=c(t=>t===")"||ha(t),"isOperandEnd"),kc=c(t=>t==="("||ha(t),"isOperandStart"),Tr=class{static{c(this,"RequirementParser")}context;tokens;location;#e=0;constructor(e,n,i){this.context=e,this.tokens=n,this.location=i}parse(){let e=this.#t();return e!==null&&this.#e<this.tokens.length&&this.context.error(l.UnexpectedTokenInAuthorize,`Unexpected '${this.tokens[this.#e]}' in authorize`,this.location),e}#t(){return this.#i("or","Or",()=>this.#s())}#s(){return this.#i("and","And",()=>this.#r())}#i(e,n,i){let r=i();for(;r!==null&&this.tokens[this.#e]===e;){this.#e++;let o=i();if(o===null)return null;r={kind:"LogicalPolicyRequirementSyntax",left:r,operator:n,right:o,location:this.location}}return r}#r(){if(this.tokens[this.#e]!=="(")return this.#o();this.#e++;let e=this.#t();return this.tokens[this.#e]===")"?this.#e++:this.context.error(l.UnclosedAuthorizeGroup,"Expected ')' in authorize",this.location),e}#o(){if(this.#e>=this.tokens.length)return this.context.error(l.AuthorizeWithoutPolicy,"Expected a policy name",this.location),null;let e=this.tokens[this.#e++];return vc.test(e)?{kind:"PolicyReferenceSyntax",name:e,location:this.location}:(this.context.error(l.InvalidPolicyReference,`Invalid policy reference '${e}' - policy names are PascalCase identifiers`,this.location),null)}};function Vt(t,e,n,i=!1){let o=n.content.startsWith("```")?n:t.reader.peekSignificant(),s=e==="description"?"```text":`\`\`\`${e}`;if(o===void 0||o!==n&&o.indent<=n.indent||o.content!==s&&!(i&&e==="description"&&o.content==="```markdown")&&!(o.content==="```"&&o!==n))return t.error(l.ExpectedCodeFence,`Expected an opening \`\`\`${e==="description"?"text":e} fence after '${e}'`,f(n)),null;o!==n&&t.reader.takeSignificant(),e==="description"&&o.content==="```"&&t.warning(l.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",f(o));let a=[];for(;;){let d=t.reader.takeRaw();if(d===void 0){t.error(l.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(o));break}if(d.raw.trim()==="```")break;let u=0;for(;u<o.indent&&u<d.raw.length&&d.raw[u]===" ";)u++;a.push(d.raw.substring(u))}return a.join(`
17
+ `)}c(Vt,"parseFencedText");var Ec=w(`^description\\s+"(${z})"$`);function G(t,e,n,i,r=!1){if(e.content==="description"){let s=Vt(t,"description",e,r);return s===null?n:s.trim().length===0?(t.error(l.EmptyDescription,`${i} declares an empty description - the fenced block must contain text`,f(e)),n):Sa(t,e,n,i,s)}let o=Ec.exec(e.content);return o===null?(t.error(l.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,f(e)),n):Sa(t,e,n,i,V(o[1]))}c(G,"parseDescription");function Sa(t,e,n,i,r){return n!==null?(t.error(l.DuplicateDescription,`${i} already declares a description - at most one is allowed`,f(e)),n):r}c(Sa,"keep");var Cc=w("^purpose\\s+([A-Za-z_]\\w*)$"),Pc=w(`^(basis|condition)\\s+(\\w+)(?:\\s+"(${z})")?$`),Ac=w(`^(interest|authorization|retention|recipient)\\s+"(${z})"$`),Ic=w(`^transfer\\s+"(${z})"\\s+safeguard\\s+"(${z})"$`),wc=w("^[A-Za-z_]\\w*$"),Oc=w("^erasure\\s+exception\\s+(\\w+)$"),Tc=["consent","contract","legalObligation","vitalInterests","publicTask","legitimateInterests"],Rc=["explicitConsent","employmentLaw","vitalInterests","notForProfit","madePublic","legalClaims","substantialPublicInterest","healthCare","publicHealth","research"],ga=["expression","legalObligation","publicTask","publicHealth","archiving","legalClaims"];function xa(t,e){let n=va(t,e),i={kind:"PurposeSyntax",name:n,description:null,basis:null,basisReference:null,interest:null,condition:null,conditionReference:null,authorization:null,subjects:[],retention:null,recipients:[],transfers:[],erasureException:null,location:f(e)},r=new Set,o=[],s=[];for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){t.reader.takeSignificant();let d=D(a.content);if(d!=="recipient"&&d!=="transfer"&&r.has(d)){t.error(l.DuplicatePurposeField,`Purpose '${n}' already declares '${d}' - at most one is allowed`,f(a)),t.skipBlock(a.indent);continue}if(r.add(d),d==="description")i={...i,description:G(t,a,i.description,`Purpose '${n}'`)};else if(d==="basis"||d==="condition"){let u=Pc.exec(a.content),m=d==="basis"?Tc:Rc;if(u===null||!m.includes(u[2]))t.error(l.InvalidPurposeVocabulary,`Invalid ${d} in purpose '${n}' - expected ${m.join(", ")} with an optional quoted reference`,f(a));else{let p=u[3]===void 0?null:V(u[3]);i=d==="basis"?{...i,basis:u[2],basisReference:p}:{...i,condition:u[2],conditionReference:p}}}else if(d==="interest"||d==="authorization"||d==="retention"||d==="recipient"){let u=Ac.exec(a.content);u===null?t.error(l.InvalidPurposeDeclaration,`Invalid purpose field '${a.content}' - expected '${d} "<text>"'`,f(a)):d==="recipient"?o.push(V(u[2])):i={...i,[d]:V(u[2])}}else if(d==="subjects"){let u=a.content.slice(8).split(",").map(m=>m.trim());u.every(m=>wc.test(m))?i={...i,subjects:[...new Set(u)]}:t.error(l.InvalidPurposeDeclaration,`Invalid purpose subjects '${a.content}' - expected comma-separated identifiers`,f(a))}else if(d==="erasure"){let u=Oc.exec(a.content);u!==null&&ga.includes(u[1])?i={...i,erasureException:u[1]}:t.error(l.InvalidPurposeVocabulary,`Invalid erasure exception '${a.content}' - expected 'erasure exception ${ga.join("|")}'`,f(a))}else if(d==="transfer"){let u=Ic.exec(a.content);u===null?t.error(l.InvalidPurposeDeclaration,`Invalid transfer '${a.content}' - expected 'transfer "<destination>" safeguard "<text>"'`,f(a)):s.push({kind:"PurposeTransferSyntax",destination:V(u[1]),safeguard:V(u[2]),location:f(a)})}else t.error(l.InvalidPurposeDeclaration,`Unexpected '${a.content}' in purpose '${n}'`,f(a)),t.skipBlock(a.indent)}return{...i,recipients:o,transfers:s}}c(xa,"parsePurpose");function Qt(t,e,n){let i=va(t,e);i.length>0&&!n.some(r=>r.name===i)&&n.push({kind:"PurposeReferenceSyntax",name:i,location:f(e)})}c(Qt,"parsePurposeReference");function va(t,e){let n=Cc.exec(e.content);return n!==null?n[1]:(t.error(l.InvalidPurposeDeclaration,`Invalid purpose declaration '${e.content}' - expected 'purpose <Name>'`,f(e)),"")}c(va,"purposeName");function we(t,e,n,i,r=l.InvalidDocumentation){if(e.content!=="documentation"||t.peekChild(e.indent)?.content!=="```markdown")return t.error(r,`${i} documentation requires a fenced markdown block`,f(e)),t.skipOpaqueBlock(e.indent),n;let o=Vt(t,"markdown",e);return o===null||o.trim().length===0||n!==null?(t.error(r,`${i} accepts one nonempty documentation block`,f(e)),n):o}c(we,"parseDocumentation");var Dc=Z(`^depends${Y}+on${Y}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function li(t,e,n,i){let r=Dc.exec(e.content)?.[1];if(r===void 0){t.error(i,`Invalid dependency declaration '${e.content}' - expected 'depends on <Name>'`,f(e)),t.skipBlock(e.indent);return}if(n.some(o=>o.target===r)){t.warning(l.RepeatedDependencyDeclaration,`Dependency '${r}' is already declared on this container - this repeated declaration is ignored`,f(e));return}n.push({kind:"DependsOnSyntax",target:r,location:f(e)})}c(li,"parseDependsOn");var Mc=w('^import\\s+"([^"\\\\]+)"$'),Lc=w('^import\\s+"'),$a=c(t=>Lc.test(t),"isFileImport");function ba(t){let e=Mc.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:f(t)}}c(ba,"tryParseFileImport");function Gt(t,e,n){let i=ba(e);if(i!==void 0){n.push(i);return}t.error(l.InvalidFileImport,`Invalid import '${e.content}' - inside a module or feature, import names files: 'import "<path or glob>"'`,f(e)),t.skipBlock(e.indent)}c(Gt,"parseFileImport");var Rr={"==":"Equal","!=":"NotEqual",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual",contains:"Contains","starts with":"StartsWith"};function Ze(t,e,n,i=!1){i||(t=t.valueContext);let r=i?Y:"\\s",o=t.sourceOptions.numericMode==="exact"?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|${r}|[()])|`:"",s=t.sourceOptions.numericMode==="exact"&&!i?"[\\w.$-]+|[^\\s]":"[\\w.$-]+",a=new RegExp(Z(`"${z}"|==|!=|>=|<=|>|<|\\(|\\)|${o}${s}`).source,"gu");if(i){let g=e.replace(a,"").replace(new RegExp(Y,"gu"),"");if(g.length>0)return t.error(l.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${g[0]}'`,n),null}let d=e.match(a)??[],u=0,m=c(()=>{if(d[u]==="("){u++;let $=y();return d[u]===")"?u++:(i||t.sourceOptions.numericMode==="exact")&&t.error(l.UnclosedConditionGroup,"Expected ')' in condition",n),$}let g=d[u++];if(i&&g===void 0)return t.error(l.ExpectedCondition,"Expected a condition",n),null;let b=d[u++];if(b==="starts"&&d[u]==="with"&&(b+=" with",u++),i&&!Object.hasOwn(Rr,b))return t.error(l.ExpectedComparisonOperator,`Expected a comparison operator after '${g}'`,n),null;let S=d[u++];return i&&S===void 0?(t.error(l.ExpectedComparisonValue,"Expected a value to compare against",n),null):g===void 0||S===void 0||Rr[b]===void 0?null:{kind:"ComparisonConditionSyntax",left:g,operator:Rr[b],right:Ye(S,n,t),location:n}},"group"),p=c(()=>{let g=m();for(;g!==null&&d[u]==="and";){u++;let b=m();if(b===null)return null;g={kind:"LogicalConditionSyntax",left:g,operator:"And",right:b,location:n}}return g},"and"),y=c(()=>{let g=p();for(;g!==null&&d[u]==="or";){u++;let b=p();if(b===null)return null;g={kind:"LogicalConditionSyntax",left:g,operator:"Or",right:b,location:n}}return g},"or"),h=y();return(i||t.sourceOptions.numericMode==="exact")&&(h===null&&!i?t.error(l.ExpectedCondition,"Expected a condition",n):h!==null&&u<d.length&&t.error(l.UnexpectedTokenInCondition,`Unexpected '${d[u]}' in condition`,n)),h}c(Ze,"parseCondition");var jc=w(`^when${Y}+([^\\n]+)${Y}+execute${Y}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Nc=w(`^otherwise${Y}+execute${Y}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),qc=w(`^with${Y}+([A-Za-z_]\\w*)${Y}+from${Y}+([^\\n]+)$`),Bc=w("^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Yc=new RegExp(`^${Y}+|${Y}+$`,"gu");function Ea(t,e,n,i){let r=[],o=null,s=null,a=!1;for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent)){t.reader.takeSignificant();let u=jc.exec(d.content),m=Nc.exec(d.content);if(u!==null){a&&t.error(l.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(d));let p=Ze(t,u[1],f(d),!0),y=ka(t,d);p!==null&&(_t(t,p),r.push({kind:"ScreenActionAlternativeSyntax",condition:p,command:u[2],arguments:y,location:f(d)}))}else if(d.content==="otherwise hidden"||m!==null)if(a&&t.error(l.MisplacedActionOtherwise,"A guarded action permits only one 'otherwise'",f(d)),a=!0,m!==null)o={kind:"ScreenActionOtherwiseSyntax",outcome:"Execute",command:m[1],arguments:ka(t,d),location:f(d)};else{o={kind:"ScreenActionOtherwiseSyntax",outcome:"Hidden",command:null,arguments:[],location:f(d)};for(let p=t.peekChild(d.indent);p!==void 0;p=t.peekChild(d.indent))t.reader.takeSignificant(),t.error(l.InvalidActionAlternative,"'otherwise hidden' cannot declare command arguments",f(p)),t.skipBlock(p.indent)}else if(D(d.content)==="navigate")s!==null&&t.error(l.InvalidActionAlternative,"A guarded action permits only one 'navigate to'",f(d)),s=i(t,d.content,d)??null;else{let p=D(d.content)==="label";t.error(p?l.UnknownActionDirective:l.InvalidActionAlternative,p?"A guarded action's header already supplies its label":`Unexpected '${d.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,f(d)),t.skipBlock(d.indent)}}return r.length===0&&t.error(l.GuardedActionWithoutAlternatives,"A guarded action must declare at least one 'when' alternative",f(e)),{kind:"ScreenGuardedActionSyntax",label:n,alternatives:r,otherwise:o,navigate:s,location:f(e)}}c(Ea,"parseGuardedAction");function ka(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=qc.exec(i.content);r!==null?n.push({kind:"InteractionArgumentSyntax",name:r[1],binding:r[2].replace(Yc,""),location:f(i)}):(t.error(l.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,f(i)),t.skipBlock(i.indent))}return n}c(ka,"parseArguments");function _t(t,e){if(e.kind==="LogicalConditionSyntax"){_t(t,e.left),_t(t,e.right);return}let n=e.right.kind==="LiteralExpressionSyntax"?e.right.value:void 0,i=Bc.test(e.left)&&e.right.kind==="LiteralExpressionSyntax";["GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual"].includes(e.operator)?i&&=typeof n=="number"||typeof n=="object"&&n!==null:["Contains","StartsWith"].includes(e.operator)&&(i&&=typeof n=="string"),i||t.error(l.UnsupportedActionConditionOperand,"Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string",e.location)}c(_t,"validateCondition");var qe=class t{static{c(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every(wr)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&wr(this.lines[this.#e]);)this.#e++;return this.#e<this.lines.length?this.lines[this.#e]:void 0}takeSignificant(){let e=this.peekSignificant();if(e===void 0)throw new Error("There is no significant line left to take");return this.#e++,e}takeRaw(){return this.#e<this.lines.length?this.lines[this.#e++]:void 0}};var ue=class extends Error{static{c(this,"InvalidSyntaxJson")}};var We=Object.freeze({numericMode:"legacy"}),ci=Object.freeze({numericMode:"exact"}),Ca=Object.freeze({numericMode:"invalid"});function Zt(t){if(typeof t!="object"||t===null||Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null||Reflect.ownKeys(t).length!==1||!Object.hasOwn(t,"numericMode"))throw new ue("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new ue("Malformed source numeric options.");return e==="exact"?ci:We}c(Zt,"validatedSourceOptions");var Pa=new WeakSet;function Aa(t){Pa.add(t)}c(Aa,"recordAuthoredDocument");function Ia(t){return Pa.has(t)}c(Ia,"isAuthoredDocument");var ye=class t{static{c(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=We;authoredDeclarations=!1;deferIdentityValidation=!1;streamCandidates;get valueContext(){if(this.sourceOptions.numericMode==="exact")return this;let e=new t(this.reader,this.path,this.languages);return e.sourceOptions=this.sourceOptions,e}constructor(e,n,i=new Set(["csharp","typescript","react","html","sql"])){this.reader=e,this.path=n,this.languages=i}get start(){return qt(1,1,this.path)}get diagnostics(){return this.nestedNumericDirectives.size>0&&this.sourceOptions.numericMode!=="legacy"&&this.reader.atEnd&&(this.#e.push(...[...this.nestedNumericDirectives].sort((e,n)=>e[0]-n[0]).map(e=>e[1])),this.nestedNumericDirectives.clear()),this.#e}nestedNumericDirectives=new Map;claimField(e){this.nestedNumericDirectives.delete(e.number)}information(e,n,i){this.#e.push({severity:"information",code:e,message:n,location:i})}error(e,n,i){this.#e.push({severity:"error",code:e,message:n,location:i})}warning(e,n,i){this.#e.push({severity:"warning",code:e,message:n,location:i})}peekChild(e){let n=this.reader.peekSignificant();return n!==void 0&&n.indent>e?n:void 0}skipBlock(e){for(;this.peekChild(e)!==void 0;)this.reader.takeSignificant()}skipOpaqueBlock(e){let n=this.peekChild(e);for(;n!==void 0;)this.reader.takeSignificant(),n.content.startsWith("```")&&this.skipFencedBody(),n=this.peekChild(e)}skipFencedBody(){for(let e=this.reader.takeRaw();e!==void 0;e=this.reader.takeRaw())if(e.raw.trim()==="```")return}};var Fc=w(`^when${Y}+([^\\n]+)${Y}+execute${Y}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Uc=w(`^on${Y}+([^\\n]+)$`),Oa=w(`^where${Y}+([^\\n]+)$`),wa=new Set(["execute","navigate","open","close","refresh","set","notify","confirm","raise"]);function Ta(t,e){for(let n=0;n<e.length;n++){let i=e[n],r=Uc.exec(i.content);if(r===null||r[1].startsWith("row-click "))continue;let o=[];for(let p=n+1;p<e.length&&e[p].indent>i.indent;p++)o.push(e[p]);let s=o.filter(p=>p.indent===o[0]?.indent),a=s.filter(p=>["when","otherwise"].includes(D(p.content))),d=["click","double click","select"].includes(r[1].trim()),u=s.filter(p=>Oa.test(p.content)),m=!1;for(let p of a){let y=D(p.content)==="when",h=y?Fc.exec(p.content):null;if(y){m&&t.error(l.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(p));let S=Ze(t,h?.[1]??p.content.slice(4).trim(),f(p),!0);S!==null&&_t(t,S),h!==null&&t.error(l.InlineInteractionAlternative,"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'",f(p))}else(m||p.content!=="otherwise")&&t.error(l.MisplacedActionOtherwise,"An interaction permits one final block-form 'otherwise'",f(p)),m=!0;let g=o.indexOf(p),b=o[g+1];h===null&&(b===void 0||b.indent<=p.indent||!wa.has(D(b.content)))&&t.error(l.InteractionAlternativeWithoutActions,"An interaction alternative requires a non-empty action list",f(p))}if(a.length>0&&(d||t.error(l.UnsupportedInteractionAlternatives,"Interaction alternatives are only supported on click, double click and select",f(i)),(u.length>0||s.some(p=>wa.has(D(p.content))))&&t.error(l.MixedInteractionAlternatives,"Interaction alternatives cannot mix with plain actions or 'where'",f(i)),a.some(p=>D(p.content)==="when")||t.error(l.GuardedActionWithoutAlternatives,"A guarded interaction requires at least one 'when' alternative",f(i))),d)for(let p of u)Wc(t,p)}}c(Ta,"validateInteractionBodies");function Wc(t,e){let n=new ye(new qe([]));n.sourceOptions=t.sourceOptions;let i=Ze(n,Oa.exec(e.content)[1].trim(),f(e),!0);i!==null&&_t(n,i);let r="Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions";i!==null&&n.diagnostics.length===0?t.warning(l.LegacyInteractionWhere,r,f(e)):t.information(l.LegacyInteractionWhere,r,f(e))}c(Wc,"deprecateWhere");var Ra=w("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),zc=w("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Vc=w("^field\\s+([\\w.]+)(?:\\s|$)"),Qc=w("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),Gc=w("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),_c=w("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),Zc=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on","when","otherwise"]);function ze(t,e){let n=[],i=new Set,r=[],o=D(e.content)==="behavior",s=null,a=c(u=>{for(;n.length>0&&n[n.length-1].indent>=u.indent;)n.pop();let m=o&&n.length===0?_c.exec(u.content):null;m!==null&&i.add(m[1]);let p=Ra.exec(u.content),y=zc.exec(u.content);if(p!==null)n.push({command:p[1],kind:"form",indent:u.indent});else if(y!==null)n.push({command:y[2],kind:y[1],indent:u.indent});else if(Zc.has(D(u.content)))n.push({command:"",kind:"other",indent:u.indent});else{let h=n.at(-1);if(h===void 0||h.kind==="other")return;let g=(h.kind==="form"?Vc:h.kind==="execute"?Qc:Gc).exec(u.content);g!==null&&r.push({command:h.command,property:re(g[1]),scope:t.scope,location:f(u)})}},"recognize");a(e);let d=[e];for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){for(t.reader.takeSignificant();n.length>0&&n[n.length-1].indent>=u.indent;)n.pop();Ra.test(e.content)&&D(u.content)==="description"&&n.at(-1)?.kind==="form"?s=G(t,u,s,`Form '${e.content.split(w("\\s+"))[1]}'`):u.content.startsWith("```")?t.skipFencedBody():(d.push(u),a(u))}Ta(t,d);for(let u of r)t.inputUses.push(i.has(u.command)?{...u,isParameter:!0}:u)}c(ze,"collectInputUses");var Kc=new RegExp(`^runs${Y}+as${Y}+system(?:${Y}+role${Y}+"${z}"(?:${Y}+and${Y}+role${Y}+"${z}")*)?$`,"u"),Jc=new RegExp(`"(${z})"`,"gu"),Hc=new RegExp(`^runs${Y}+as\\b`,"u"),Kt=c(t=>Hc.test(t.content),"isReactionIdentityLine");function Da(t,e,n){if(n)return t.error(l.InvalidReactionIdentity,"A reaction may declare 'runs as' only once.",f(e)),t.skipBlock(e.indent),null;if(!Kc.test(e.content)||t.peekChild(e.indent)!==void 0)return t.error(l.InvalidReactionIdentity,`Expected one reaction-level line: 'runs as system [role "<Role>" and role "<Role>"]'.`,f(e)),t.skipBlock(e.indent),null;let i=[...e.content.matchAll(Jc)].map(r=>V(r[1]));return i.some(r=>r.length===0)||new Set(i).size!==i.length?(t.error(l.InvalidReactionIdentity,"Reaction identity roles must be nonempty and distinct quoted literals.",f(e)),null):{kind:"ReactionIdentitySyntax",syntaxKind:"system",roles:i,location:f(e)}}c(Da,"parseReactionIdentity");function Oe(t,e){t.error(l.InvalidReactionIdentity,"'runs as' belongs directly in a reaction body, not under a trigger or invocation.",f(e)),t.skipBlock(e.indent)}c(Oe,"misplacedReactionIdentity");function ke(t){return w(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}c(ke,"sourceStreamPattern");var Xc=ke("^[A-Za-z_]\\w*(?![\\s\\S])"),ed=ke("^[\\w.]+(?![\\s\\S])");function Dr(t){return typeof t=="string"&&Xc.test(t)}c(Dr,"isSourceStreamName");function di(t){return typeof t=="string"&&ed.test(t)}c(di,"isSourceStreamTypeName");var td=w(`^id\\s+"(${z})"$`),nd=ke("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),id=ke("^eventsource\\s+([A-Za-z_]\\w*)$"),rd=ke("^stream\\s+([A-Za-z_]\\w*)$");function Ma(t,e){let n=id.exec(e.content)?.[1]??"";n===""&&lt(t,e,"Expected 'eventsource <Name>'.");let i=[],r=null,o=null,s=null;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(a.content)){case"stream":i.push(od(t,a));break;case"identifier":r=La(t,a,"identifier",r);break;case"description":o=G(t,a,o,`Event source '${n}'`,!0);break;case"id":s=ja(t,a,n,s);break;default:lt(t,a,"An event source accepts description, id, identifier and stream declarations."),t.skipBlock(a.indent);break}return{kind:"EventSourceSyntax",name:n,streams:i,identifier:r,description:o,id:s,location:f(e)}}c(Ma,"parseEventSource");function od(t,e){let n=rd.exec(e.content)?.[1]??"";n===""&&lt(t,e,"Expected 'stream <Name>'.");let i=null,r=[],o=!1,s={},a=null,d=null;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(u.content)){case"streamId":o?(lt(t,u,"Declare either one 'streamId <Type>' or one streamId part block."),t.skipBlock(u.indent)):u.content==="streamId"?(o=!0,s.streamId=f(u),r=ad(t,u)):(i=La(t,u,"streamId",i),o=i!==null);break;case"description":a=G(t,u,a,`Stream '${n}'`,!0);break;case"id":d=ja(t,u,n,d);break;default:lt(t,u,"A stream accepts description, id and streamId declarations."),t.skipBlock(u.indent);break}return{kind:"EventStreamSyntax",name:n,streamId:i,streamIdParts:r,description:a,id:d,directiveLocations:s,location:f(e)}}c(od,"parseEventStream");function La(t,e,n,i){let r=nd.exec(e.content);return r===null||i!==null?lt(t,e,`Declare at most one '${n} <Type>'.`):(i=Ie(r[2],{...f(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),Le(t,i,e)),xn(t,e,l.InvalidEventSourceDeclaration),i}c(La,"parseType");function ja(t,e,n,i){let r=td.exec(e.content),o=r===null?null:V(r[1]);return o===null||o.trim()===""||i!==null?lt(t,e,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(i=o,o===n&&t.information(l.RedundantSourceStreamId,"The rename pin repeats the current name; omit it for a new declaration.",f(e))),xn(t,e,l.InvalidEventSourceDeclaration),i}c(ja,"parsePin");function Na(t,e,n,i){let[r,o]=n.type.name.split("."),s={kind:"CommandStreamSyntax",eventSource:r,stream:o,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:n.type.location,referenceLength:n.type.name.length,location:f(e)};if(i)return t.error(l.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,f(e)),{...s,propertyCandidate:n};let a=null,d=[],u=!1,m={};for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),p.content==="streamId"){a!==null||u?(t.error(l.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(p)),t.skipBlock(p.indent)):(u=!0,m.streamId=f(p),d=Mr(t,p,l.InvalidCommandStream));continue}let y=/^streamId\s*=\s*(.+)$/.exec(p.content);if(y===null||a!==null||u)t.error(l.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(p)),t.skipBlock(p.indent);else{let h={...f(p),column:p.indent+1+p.content.indexOf(y[1],p.content.indexOf("=")+1)};a={kind:"PropertyMappingSyntax",property:"streamId",source:ae(y[1],h,t),location:f(p)},xn(t,p,l.InvalidCommandStream)}}return{...s,streamId:a,streamIdParts:d,directiveLocations:m}}c(Na,"parseCommandStream");function ad(t,e){let n=[],i=ke("^([A-Za-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$");for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=i.exec(r.content);if(o===null){lt(t,r,"Expected '<part> <Type>' without modifiers in a streamId part block."),t.skipBlock(r.indent);continue}let s=Ie(o[2],{...f(r),column:r.indent+1+r.content.indexOf(o[2],o[1].length)});Le(t,s,r),n.push({kind:"EventStreamIdPartSyntax",name:o[1],type:s,location:f(r)}),xn(t,r,l.InvalidEventSourceDeclaration)}return n.length===0&&lt(t,e,"A streamId part block cannot be empty."),n}c(ad,"parseStreamIdParts");function Mr(t,e,n){let i=[],r=ke("^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$");for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=r.exec(o.content);if(s===null){t.error(n,"Expected '<part> = <source>' in a streamId part block.",f(o)),t.skipBlock(o.indent);continue}let a={...f(o),column:o.indent+1+o.content.indexOf(s[2],o.content.indexOf("=")+1)};i.push({kind:"PropertyMappingSyntax",property:s[1],source:ae(s[2],a,t),location:f(o)}),xn(t,o,n)}return i.length===0&&t.error(n,"A streamId part block cannot be empty.",f(e)),i}c(Mr,"parseRouteParts");function xn(t,e,n){let i=t.peekChild(e.indent);i!==void 0&&(t.error(n,"This directive cannot have children.",f(i)),t.skipBlock(e.indent))}c(xn,"rejectChildren");function lt(t,e,n){t.error(l.InvalidEventSourceDeclaration,n,f(e))}c(lt,"invalid");var sd=w("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),qa=c(t=>D(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),ge=c(t=>qa(t).length>0,"isFileDirective"),pi=c(t=>ge(t)&&!sd.test(qa(t)),"isFileDirectiveAmongProperties");var ld=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function ui(t){if(t===null)return!0;for(let e of t){let n=e.charCodeAt(0);if(!(n>=9&&n<=13||n>=8192&&n<=8202||ld.has(n)))return!1}return!0}c(ui,"isBlankImplementationHint");var Ba=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),vt=c(t=>D(t.content)==="file"&&t.content.substring(4).trim().length>0,"isFile"),Tt=c((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCode");function tt(t,e){let n=e.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(n)&&t.warning(l.AbsoluteFileReference,`'${n}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,f(e)),{kind:"FileReferenceSyntax",path:n,location:f(e)}}c(tt,"parseFile");var Lr=c(t=>t.raw.trim()==="```","isClosingCodeFence");function Te(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n))return t.error(l.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(l.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=e.indent||o.content!=="```"&&o.content!==`\`\`\`${n}`)return t.error(l.ExpectedCodeFence,`Expected an opening \`\`\`${n} fence after '${n}'`,f(e)),null;i=t.reader.takeSignificant()}let r=[];for(;;){let o=t.reader.takeRaw();if(o===void 0){t.error(l.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(i));break}if(Lr(o))break;let s=0;for(;s<i.indent&&o.raw[s]===" ";)s++;r.push(o.raw.substring(s))}return{kind:"CodeBlockSyntax",language:n,code:r.join(`
18
+ `),location:f(e)}}c(Te,"parseCode");function Ya(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(l.HandlerWithoutImplementation,"Expected a 'file' directive or an inline code block in the handler",f(e)),null;if(t.reader.takeSignificant(),D(n.content)==="implementation")return cd(t,e,n);let i=vt(n)?tt(t,n):null,r=i===null&&Tt(t,n)?Te(t,n):null;if(i!==null||r!==null){let o=t.peekChild(e.indent);return o!==void 0&&D(o.content)==="implementation"&&(t.error(l.ConflictingImplementationSources,"A handler cannot mix wrapped and direct sources.",f(o)),t.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:r,implementation:null,location:f(e)}}return t.error(l.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,f(n)),t.skipBlock(e.indent),null}c(Ya,"parseHandler");function cd(t,e,n){let i=vn(t,n);for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(D(r.content)==="implementation"?l.InvalidImplementationBlock:l.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",f(r)),Tt(t,r)?Te(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:f(e)}}c(cd,"parseImplementation");function vn(t,e){let n=[],i=null,r=null,o=!1;e.content!=="implementation"&&t.error(l.InvalidImplementationBlock,"Expected 'implementation' with no operand.",f(e));for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="hint"||Ba.test(s.content)){let a=Ba.exec(s.content),d=a===null?null:V(a[1]);ui(d)?t.error(l.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",f(s)):n.push({kind:"ImplementationHintSyntax",text:d,location:f(s)});let u=t.peekChild(s.indent);u!==void 0&&(t.error(l.InvalidImplementationHint,"A hint cannot have children.",f(u)),t.skipBlock(s.indent))}else if(vt(s)||s.content.startsWith("```")){o&&t.error(l.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",f(s));let a=vt(s)?tt(t,s):null,d=a===null?Te(t,s):null;o||(i=a,r=d),o=!0;let u=t.peekChild(s.indent);a!==null&&u!==void 0&&(t.error(l.InvalidImplementationBlock,"A file directive cannot have children.",f(u)),t.skipBlock(s.indent))}else t.error(l.InvalidImplementationBlock,`Unexpected '${s.content}' in implementation - expected hint, file or a tagged fence.`,f(s)),t.skipBlock(s.indent);return{file:i,code:r,implementation:{kind:"ImplementationSyntax",hints:n,location:f(e)}}}c(vn,"parseImplementationWrapper");var dd=w("^system\\s+([A-Za-z_]\\w*)$"),pd=w("^operation\\s+([A-Za-z_]\\w*)$"),ud=w("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),jr=w("^uses\\s+([A-Za-z_]\\w*)$"),fd=w("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),md=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function $n(t,e,n,i){let r=t.peekChild(e.indent);r!==void 0&&(t.error(n,i,f(r)),t.skipBlock(e.indent))}c($n,"rejectOperationChildren");function Fa(t,e){let n=dd.exec(e.content);n===null&&t.error(l.InvalidSystemDeclaration,"Expected 'system <Name>'.",f(e));let i=null;for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="description"?i=G(t,r,i,`System '${n?.[1]??""}'`):(t.error(l.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",f(r)),t.skipBlock(r.indent));return{kind:"SystemSyntax",name:n?.[1]??"",description:i,location:f(e)}}c(Fa,"parseSystem");function fi(t,e,n=!1){let i=(n?ud:pd).exec(e.content),r=i?.[1]??"";i===null&&t.error(l.InvalidOperationDeclaration,"Expected an operation declaration with one name.",f(e));let o=null,s=null,a=f(e),d=null,u=null,m=[],p=[],y=new Set;for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){t.reader.takeSignificant();let g=fd.exec(h.content),b=n&&g!==null?{...h,content:g[1].trimEnd()}:h;if(g===null&&md.has(D(h.content))){t.error(l.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",f(h)),t.skipBlock(h.indent);continue}if(!jr.test(h.content)&&He(b)!==void 0){let S=Ue(t,b);n&&g===null&&t.error(l.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",f(h)),S.isSubject&&t.error(l.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).",f(h)),(S.isIdentifier||S.isGenerated)&&t.error(l.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",f(h)),y.has(S.name)&&t.error(l.DuplicateDeclaration,`Operation '${r}' already declares input '${S.name}'.`,f(h)),y.add(S.name),m.push(S),n&&g!==null&&p.push({kind:"PropertyMappingSyntax",property:S.name,source:ae(g[2],{...f(h),column:h.indent+h.content.length-g[2].length+1},t),location:f(h)}),$n(t,h,l.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(D(h.content)==="description")o=G(t,h,o,`Operation '${r}'`);else if(jr.test(h.content))s!==null?t.error(l.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",f(h)):(s=jr.exec(h.content)[1],a={...f(h),column:f(h).column+h.content.indexOf(s,4)}),$n(t,h,l.InvalidSystemReference,"A system reference cannot have children.");else if(h.content==="execute"||h.content==="compensate"){let S=yd(t,h);h.content==="execute"?d!==null?t.error(l.InvalidOperationDeclaration,"An operation declares execute at most once.",f(h)):d=S:u!==null?t.error(l.InvalidOperationDeclaration,"An operation declares compensate at most once.",f(h)):u=S}else t.error(l.InvalidOperationDeclaration,`Unexpected '${h.content}' in operation - expected uses, an input, description, execute or compensate.`,f(h)),t.skipBlock(h.indent)}return s===null&&t.error(l.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",f(e)),{operation:{kind:"OperationSyntax",name:r,uses:s??"",usesLocation:a,inputs:m,description:o,execute:d,compensate:u,location:f(e)},mappings:p}}c(fi,"parseOperation");function yd(t,e){let n=null,i=null,r=null,o=null,s=!1;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(a.content)==="description"){n=G(t,a,n,`Operation phase '${e.content}'`);continue}if(D(a.content)==="implementation"){s&&t.error(l.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",f(a));let d=vn(t,a);s||(i=d.file,r=d.code,o=d.implementation),s=!0}else if(ge(a)||a.content.startsWith("```")){s&&t.error(l.ConflictingImplementationSources,"A phase has at most one file or inline payload.",f(a));let d=ge(a)?tt(t,a):null,u=d===null?Te(t,a):null;s||(i=d,r=u),s=!0,d!==null&&$n(t,a,l.InvalidImplementationBlock,"A file directive cannot have children.")}else t.error(l.InvalidOperationDeclaration,"A phase accepts description, file, a tagged fence or implementation.",f(a)),t.skipBlock(a.indent)}return{kind:"OperationPhaseSyntax",description:n,file:i,code:r,implementation:o,location:f(e)}}c(yd,"parseOperationPhase");var hd=w("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),Sd=w("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),gd=w("^specification\\s+([A-Za-z_]\\w*)$"),xd=w("^given caller as ([A-Za-z_]\\w*)$"),vd="([A-Z]\\w*(?:\\.\\w+)*)",$d="(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?",Jt=c((t,e="")=>Z(`^${t}\\s+${vd}${e}${$d}$`.replaceAll("\\s",Y)),"stepPattern"),bd=Jt("given"),kd=Jt("when\\s+append"),Ed=Jt("when"),Cd=Jt("then"),Pd=w("^then\\s+query\\b"),Ua=w("^(?:given|then)\\s+readmodel\\b"),Ad=Jt("given\\s+readmodel"),Id=Jt("then\\s+readmodel","(?<exactly>\\s+exactly)?"),Wa=w("^then\\s+no\\b"),wd=w(`^then\\s+error\\s+"(${z})"$`),Br=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Od=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Td=w("^given\\s+clock\\b"),Rd=w("^given\\s+capture\\b"),Dd=w("^when\\s+clock\\b"),Md=w("^when\\s+trigger\\b"),Ld=w("^when\\s+capture\\b"),jd=w("^when\\s+query\\b"),Nd=w("^then\\s+result\\b"),qd=w("^then\\s+no\\s+result\\b"),Bd=Z("^when\\s+redelivered\\b"),Yd=Z("^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Fd=w("^then\\s+no\\s+events\\b"),Ud=w('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),Wd=w("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),zd=w("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),Vd=w("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Qd=w("^then\\s+result(\\s+exactly)?$"),za=Z("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),Gd=Z(`^(?:"${z}"|'(?:[^'\\\\]|\\\\.)*')$`),_d=Z("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function Yr(t,e){let n=gd.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,f(e));let i=null,r=[],o=[],s={givenOperationFailures:[],thenOperations:[],thenCompensated:[],thenAbsentReadModels:[],thenQueries:[],given:[],givenReadModels:[],when:null,whenAppended:null,whenRedelivered:null,whenDeclared:!1,thenEvents:[],thenEventsInAnyOrder:!1,thenNoEvents:!1,thenReadModels:[],thenErrors:[],givenClock:null,givenCaptures:[],whenClock:null,whenTrigger:null,whenCapture:null,whenQuery:null,thenResults:[],thenNoResult:null,thenDenied:null,givenCaller:null,thenReturns:null};for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ge(p)||Zd(t,p,s))continue;let y=Wa.test(p.content)?"then":D(p.content);if(y==="parameter"){let h=da(t,p);h!==null&&r.push(h)}else if(y==="case"){let h=pa(t,p);h!==null&&o.push(h)}else y==="description"?i=G(t,p,i,`Specification '${n}'`):y==="given"?Kd(t,p,s):y==="when"?ep(t,p,s,n):y==="then"?tp(t,p,s):(t.error(l.UnknownSpecificationDirective,`Unexpected '${D(p.content)}' in specification body`,f(p)),t.skipBlock(p.indent))}s.noEventsLine!==void 0&&(s.whenAppended!==null||s.thenEvents.length>0||s.thenEventsInAnyOrder||s.thenErrors.length>0||s.thenDenied!==null)&&t.error(l.InvalidNoEventsExpectation,"'then no events' cannot follow 'when append' or accompany event, event-order, error or denial expectations.",f(s.noEventsLine));let{whenDeclared:a,noEventsLine:d,...u}=s,m={kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,description:i,...u,...r.length===0?{}:{parameters:r},...o.length===0?{}:{cases:o},location:f(e)};return ua(m,t),m}c(Yr,"parseSpecification");function Zd(t,e,n){if(!hd.test(e.content))return!1;let i=Sd.exec(e.content);if(i===null||i[1]==="given operation"!=(i[3]!==void 0))t.error(l.InvalidOperationSpecification,"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.",f(e)),xe(t,e.indent);else if(i[1]==="then operation"){let r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=Yt(t,o,Br,l.InvalidOperationSpecification);s!==null&&r.push(s)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:f(e)})}else $n(t,e,l.InvalidOperationSpecification,"Failure and compensation assertions cannot have children."),i[1]==="given operation"?n.givenOperationFailures.push({kind:"SpecificationOperationFailureSyntax",operation:i[2],location:f(e)}):n.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:f(e)});return!0}c(Zd,"parseOperationStep");function Kd(t,e,n){if(Td.test(e.content))n.givenClock!==null?(t.error(l.InvalidSpecificationClock,"A specification states its clock at most once.",f(e)),xe(t,e.indent)):n.givenClock=Va(t,e,"given");else if(Rd.test(e.content)){let i=Qa(t,e,"given");i!==null&&n.givenCaptures.push(i)}else if(e.content.startsWith("given caller"))if(n.givenCaller!==null||n.givenCallerPersona!==void 0)t.error(l.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'given caller' block.",f(e)),t.skipBlock(e.indent);else if(e.content.startsWith("given caller as")){let i=xd.exec(e.content);i===null&&t.error(l.InvalidSpecificationCallerPersona,"Expected 'given caller as <Persona>'.",f(e));let r=t.peekChild(e.indent);r!==void 0&&t.error(l.InvalidSpecificationCallerPersona,"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.",f(r)),xe(t,e.indent),i!==null&&(n.givenCallerPersona={kind:"SpecificationCallerPersonaSyntax",name:i[1],location:f(e)})}else n.givenCaller=Xd(t,e);else if(Ua.test(e.content)){let i=Ga(t,e,Ad,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=Fr(t,e,bd,"given");i!==void 0&&n.given.push(i)}}c(Kd,"parseGiven");var Jd=w(`^role${Y}+"(${z})"$`),Hd=w(`^claim${Y}+"(${z})"${Y}*=${Y}*"(${z})"$`);function Xd(t,e){if(e.content!=="given caller")return t.error(l.InvalidSpecificationCaller,"Expected exactly 'given caller'.",f(e)),t.skipBlock(e.indent),null;let n=!1,i=[],r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=Jd.exec(o.content),a=Hd.exec(o.content);o.content==="authenticated"&&!n?n=!0:s!==null?i.push(V(s[1])):a!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:V(a[1]),value:V(a[2]),location:f(o)}):t.error(Ft(o.content)?l.InvalidSpecificationCaseReference:l.InvalidSpecificationCaller,`Invalid caller fixture '${o.content}' - expected authenticated, role "...", or claim "..." = "...".`,f(o))}return{kind:"SpecificationCallerSyntax",authenticated:n,roles:i,claims:r,location:f(e)}}c(Xd,"parseCaller");function ep(t,e,n,i){let r=e.content.startsWith("when append");if(n.whenDeclared){let d=n.whenAppended!==null||r?l.ConflictingSpecificationActions:l.DuplicateSpecificationWhen;t.error(d,`Specification '${i}' already declares a 'when' - a specification can have at most one`,f(e)),xe(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=Fr(t,e,kd,"when append")??null;return}if(Bd.test(e.content)){let d=Yd.exec(e.content);d===null?(t.error(l.UnmatchedRedeliveredOccurrence,"Expected 'when redelivered <Event> to <Reaction>'.",f(e)),xe(t,e.indent)):n.whenRedelivered={kind:"SpecificationRedeliverySyntax",eventType:d[1],reaction:d[2],...qr(t,e,void 0,void 0,"when redelivered"),location:f(e)};return}if(Dd.test(e.content)){n.whenClock=Va(t,e,"when");return}if(Md.test(e.content)){n.whenTrigger=Nr(t,e,Wd,l.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(d,u)=>({kind:"SpecificationTriggerSyntax",trigger:d,values:u,location:f(e)}));return}if(Ld.test(e.content)){n.whenCapture=Qa(t,e,"when");return}if(jd.test(e.content)){n.whenQuery=Nr(t,e,Vd,l.InvalidSpecificationQueryAction,"when query","when query <Query>",(d,u)=>({kind:"SpecificationWhenQuerySyntax",query:d,arguments:u,location:f(e)}));return}let o=Ed.exec(e.content);if(o===null){t.error(l.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,f(e)),xe(t,e.indent);return}let s=[],a=qr(t,e,s,o);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...a,generatedValues:s,inlineProperty:o.groups?.property??null,location:f(e)}}c(ep,"parseWhen");function tp(t,e,n){if(Fd.test(e.content)){e.content!=="then no events"||n.thenNoEvents?t.error(l.InvalidNoEventsExpectation,"Expected one 'then no events' directive.",f(e)):(n.thenNoEvents=!0,n.noEventsLine=e);let o=t.peekChild(e.indent);o!==void 0&&t.error(l.InvalidNoEventsExpectation,"'then no events' cannot have child mappings.",f(o)),xe(t,e.indent);return}if(Or.test(e.content)){let o=ca(t,e);n.thenReturns!==null?t.error(l.InvalidReturnExpectation,"A specification declares at most one return expectation.",f(e)):n.thenReturns=o;return}if(e.content.startsWith("then events")){e.content!=="then events in any order"||n.thenEventsInAnyOrder?t.error(l.InvalidSpecificationEventOrder,"Expected one 'then events in any order' directive.",f(e)):n.thenEventsInAnyOrder=!0,xe(t,e.indent);return}if(Nd.test(e.content)){ip(t,e,n);return}if(qd.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(l.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",f(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:f(e)},xe(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(l.InvalidSpecificationDenied,"Expected exactly 'then denied'.",f(e)),xe(t,e.indent)):n.thenDenied!==null?t.error(l.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",f(e)):n.thenDenied={kind:"SpecificationDeniedSyntax",location:f(e)};return}if(e.content==="then error"){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:f(e)});return}if(e.content.startsWith("then error case.")){let o=je(e.content.substring(11),{...f(e),column:f(e).column+11},t);o.kind==="CaseValueExpressionSyntax"&&n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,caseValue:o,location:f(e)});return}let i=wd.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:V(i[1]),location:f(e)});return}if(D(e.content.substring(4).trim())==="error"){t.error(l.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,f(e)),xe(t,e.indent);return}if(Wa.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let s=np(t,e);s!==null&&n.thenAbsentReadModels.push(s);return}let o=za.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let s=je(o[2].trim(),f(e),t.valueContext);(s.kind==="LiteralExpressionSyntax"||s.kind==="ObjectExpressionSyntax"||s.kind==="CaseValueExpressionSyntax")&&n.thenAbsentReadModels.push({kind:"SpecificationAbsentReadModelSyntax",name:o[1],key:s,location:f(e)})}t.skipOpaqueBlock(e.indent);return}if(Pd.test(e.content)){let o=t.sourceOptions.numericMode==="exact",s=c((p,y,h)=>{if(!o)return t.skipOpaqueBlock(h.indent);t.error(p,y,f(h)),t.skipBlock(h.indent)},"reject"),a=_d.exec(e.content);if(a===null)return s(l.InvalidSpecificationQuery,`Invalid 'then query' declaration '${e.content}' - expected 'then query <Query> [exactly]'`,e);let d=[],u=[],m=!1;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))t.reader.takeSignificant(),p.content==="arguments"&&!m?d.push(...bn(t.valueContext,p,!0)):p.content==="arguments"?s(l.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,p):p.content==="result"?u.push({kind:"SpecificationQueryResultSyntax",properties:bn(t.valueContext,p,!0),exactly:!1,location:f(p)}):s(l.UnknownSpecificationQueryDirective,`Unexpected '${D(p.content)}' in 'then query' body - expected arguments or result`,p),m||=p.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:a[1],arguments:d,results:u,exactly:a[2]!==void 0,location:f(e)});return}if(Ua.test(e.content)){let o=Ga(t,e,Id,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=Fr(t,e,Cd,"then");r!==void 0&&n.thenEvents.push(r)}c(tp,"parseThen");function np(t,e){let n=za.exec(e.content);if(n===null||n[2].endsWith(" exactly"))return t.error(l.InvalidAbsentReadModelStep,`Invalid absence assertion '${e.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,f(e)),xe(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||Gd.test(i)?je(i,f(e),t.valueContext):null,s=o!==null&&(o.kind==="LiteralExpressionSyntax"||o.kind==="ObjectExpressionSyntax"||o.kind==="CaseValueExpressionSyntax");s||t.error(l.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,f(e));let a=!1;for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(l.InvalidAbsentReadModelStep,"An absent read model assertion cannot have child mappings.",f(d)),a=!0;return a||!s?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:f(e)}}c(np,"parseAbsentReadModel");function xe(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}c(xe,"skipBody");function Va(t,e,n){let i=Ud.exec(e.content);return xe(t,e.indent),i===null||i[1]!==n?(t.error(Ft(e.content)?l.InvalidSpecificationCaseReference:l.InvalidSpecificationClock,`Invalid '${n} clock' - expected '${n} clock "<ISO 8601 instant>"', such as '${n} clock "2026-10-05T08:00:00Z"'`,f(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:f(e)}}c(Va,"parseClock");function Qa(t,e,n){return Nr(t,e,zd,l.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:f(e)}))}c(Qa,"parseCapture");function Nr(t,e,n,i,r,o,s){let a=n.exec(e.content);return a===null?(t.error(i,`Invalid '${r}' declaration '${e.content}' - expected '${o}'`,f(e)),xe(t,e.indent),null):s(a[1],bn(t,e))}c(Nr,"parseNamedStep");function ip(t,e,n){let i=Qd.exec(e.content);if(i===null){t.error(l.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,f(e)),xe(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:bn(t,e),exactly:i[1]!==void 0,location:f(e)})}c(ip,"parseResult");function Ga(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(l.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${e.content}' - expected '${i} readmodel <ReadModelType>'`,f(e)),xe(t,e.indent);return}return{kind:"SpecificationReadModelSyntax",name:r[1],properties:bn(t,e,!1,r),exactly:i==="then"&&r.groups?.exactly!==void 0,inlineProperty:r.groups?.property??null,location:f(e)}}c(Ga,"parseReadModelStep");function Fr(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(l.InvalidEventStep,`Invalid '${i}' declaration '${e.content}' - expected '${i} <EventType>'`,f(e)),xe(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...qr(t,e,void 0,r,i),inlineProperty:r.groups?.property??null,location:f(e)}}c(Fr,"parseEventStep");var Ur=ke("^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$"),rp=w("^streamId\\s*=(?!=|>)\\s*(.+)$");function qr(t,e,n,i,r){let o=[];yi(t,e,i,o);let s=null,a,d,u=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&Zn.test(m.content)){let y=Yt(t,m,Kn,l.InvalidGeneratedFixture);y!==null&&n.push(y);continue}let p=Br.exec(m.content);if(p!==null)kn(t,o,_a(t,m,p));else if(D(m.content)==="stream"||m.content.startsWith("no stream")){if(r===void 0){t.error(l.SpecificationStreamOnCommand,"A command occurrence cannot declare a route; assert it on a then event.",f(m)),t.skipBlock(m.indent);continue}if(u){t.error(l.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(m)),t.skipBlock(m.indent);continue}let y=Ur.exec(m.content);m.content==="no stream"&&(r==="then"||r==="when redelivered")?(d={kind:"SpecificationNoStreamSyntax",location:f(m)},u=!0,mi(t,m)):y!==null?(a=Wr(t,m,y),u=!0):(t.error(l.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",f(m)),t.skipBlock(m.indent))}else if(D(m.content)==="for"){let y=m.content.substring(3).trim();y.length===0?t.error(l.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(m)):s!==null?t.error(l.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(m)):s=je(y,f(m),t)}else t.error(l.InvalidSpecificationValue,`Invalid property mapping '${m.content}' - expected '<property> = <value>'`,f(m))}return{values:o,for:s,...a===void 0?{}:{stream:a},...d===void 0?{}:{noStream:d}}}c(qr,"parseValuesWithEventSource");function Wr(t,e,n){let i=null,r=[],o=!1,s={};for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),a.content==="streamId"){i!==null||o?(t.error(l.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent)):(o=!0,s.streamId=f(a),r=Mr(t,a,l.InvalidSpecificationStream).map(m=>m.source.kind==="PathExpressionSyntax"&&m.source.path.startsWith("case.")?{...m,source:je(m.source.path,m.source.location,t)}:m));continue}let d=rp.exec(a.content);if(d===null||i!==null||o){t.error(l.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent);continue}let u={...f(a),column:a.indent+1+a.content.indexOf(d[1],a.content.indexOf("=")+1)};i={kind:"PropertyMappingSyntax",property:"streamId",source:je(d[1],u,t),location:f(a)},mi(t,a)}return{kind:"SpecificationStreamSyntax",eventSource:n[1],stream:n[2],streamId:i,streamIdParts:r,directiveLocations:s,referenceLocation:{...f(e),column:e.indent+1+e.content.indexOf(n[1],6)},referenceLength:n[1].length+1+n[2].length,location:f(e)}}c(Wr,"parseSpecificationStream");function mi(t,e){let n=t.peekChild(e.indent);n!==void 0&&(t.error(l.InvalidSpecificationStream,"This directive cannot have children.",f(n)),t.skipBlock(e.indent))}c(mi,"rejectSpecificationRouteChildren");function bn(t,e,n=!1,i){let r=[];yi(t,e,i,r);for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=(n||t.sourceOptions.numericMode==="exact"?Od:Br).exec(o.content);if(s===null){t.error(l.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,f(o));continue}kn(t,r,_a(t,o,s,n))}return r}c(bn,"parseValues");function _a(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:je(n[2],f(e),t,i),location:f(e)}}c(_a,"mappingOf");var op=Z("^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$".replaceAll("\\s",Y)),ap=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$".replaceAll("\\s",Y));function ct(t,e){let n=op.exec(e.content);if(n===null)return t.error(l.InvalidSpecificationExample,`Invalid example declaration '${e.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SpecificationExampleSyntax",name:"",type:"",values:[],generatedValues:[],for:null,description:null,location:f(e)};let i=sp(t,e,void 0,!0,n[1]);for(let r of Ut(i))t.error(l.InvalidSpecificationCaseReference,"Case references are not permitted in example bodies.",r.location);return{kind:"SpecificationExampleSyntax",name:n[1],type:n[2],...i,location:f(e)}}c(ct,"parseExample");function yi(t,e,n,i){if(n?.groups?.property===void 0)return;let r=n.groups.property,o=n.groups.value,s=e.content.length-o.length,a=f(e),d=Bt(t,o,{...a,column:a.column+s},l.InvalidSpecificationValue);d!==null&&i.push({kind:"PropertyMappingSyntax",property:r,source:d,location:{...a,column:a.column+e.content.lastIndexOf(r,e.content.indexOf("="))}})}c(yi,"addInlineValue");function kn(t,e,n,i=[]){if([...e,...i].some(r=>r.property===n.property)){t.error(l.DuplicateSpecificationAssignment,`Property '${n.property}' is assigned more than once in this fixture - assign it only once, inline or indented`,n.location);return}e.push(n)}c(kn,"addFixtureValue");function sp(t,e,n,i=!1,r){let o=[],s=[],a=null,d=null,u,m;yi(t,e,n,o);for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r!==void 0&&D(p.content)==="description"){d=G(t,p,d,`Example '${r}'`);continue}if(i&&Zn.test(p.content)){let h=Yt(t,p,Kn,l.InvalidGeneratedFixture);h!==null&&(r===void 0?s.push(h):kn(t,s,h,o));continue}let y=ap.exec(p.content);if(r!==void 0&&y===null&&(D(p.content)==="stream"||p.content.startsWith("no stream"))){let h=Ur.exec(p.content);u!==void 0||m!==void 0?(t.error(l.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(p)),t.skipOpaqueBlock(p.indent)):p.content==="no stream"?(m={kind:"SpecificationNoStreamSyntax",location:f(p)},mi(t,p)):h!==null?u=Wr(t,p,h):(t.error(l.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on an event example.",f(p)),t.skipOpaqueBlock(p.indent));continue}if(y!==null)kn(t,o,{kind:"PropertyMappingSyntax",property:y[1],source:je(y[2],f(p),t),location:f(p)},s);else if(D(p.content)==="for"){let h=p.content.substring(3).trim();h.length===0?t.error(l.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(p)):a!==null?t.error(l.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(p)):a=je(h,f(p),t)}else t.error(l.InvalidSpecificationValue,`Invalid property mapping '${p.content}' - expected '<property> = <value>'`,f(p))}return{values:o,for:a,generatedValues:s,description:d,...u===void 0?{}:{stream:u},...m===void 0?{}:{noStream:m}}}c(sp,"parseFixtureBody");var Za=["StateChange","StateView","Automation","Translate"];var de;(function(t){t.Inbound="Inbound",t.Outbound="Outbound"})(de||(de={}));var zr="events",Vr="from";function En(t){return t.syntaxKind===zr}c(En,"isEventsSource");function Ka(t){return En(t)?t.settings.filter(e=>e.name===Vr):[]}c(Ka,"consumedEvents");var se;(function(t){t.Private="Private",t.Public="Public"})(se||(se={}));var lp=new RegExp(`^${Y}*$`),Cn=c(t=>lp.test(t),"isBlankPublicEventOrigin");function hi(t){if(t.kind==="EventSyntax"||t.kind==="ImportSyntax"){let e=t,n=e.visibility===void 0?se.Private:e.visibility;if(n!==se.Private&&n!==se.Public)return"Event visibility must be Private or Public.";if(e.origin!=null&&(typeof e.origin!="string"||Cn(e.origin)))return"An event or import origin must be a nonblank quoted string.";if(e.origin!=null&&n!==se.Public)return"An event or import with an origin is a public contract.";if(t.kind==="ImportSyntax"&&n===se.Public&&e.origin==null)return"A public contract import requires an origin."}if(t.kind==="SliceSyntax"){let e=t;if(e.direction!=null&&e.type!=="Translate")return"Only a Translate slice may declare a direction.";if(e.direction!=null&&e.direction!==de.Inbound&&e.direction!==de.Outbound)return"A translation direction must be Inbound or Outbound."}}c(hi,"publicEventMetadataError");var Pn=["tag"];var cp=w(`^id\\s+"(${z})"$`),Ht=class{static{c(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=f(n);switch(D(n.content)){case"id":{let r=cp.exec(n.content),o=r===null?"":V(r[1]);return o.trim().length===0||this.value.id!==null?e.error(l.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,i):(this.value.id=o,o===this.name&&e.information(l.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,i)),!0}case"description":return this.value.description=G(e,n,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":return this.value.documentation=we(e,n,this.value.documentation,`Event '${this.name}'`,l.InvalidEventDocumentation),!0;default:return!1}}};var dp=w("^type\\s+([A-Za-z_]\\w*)$"),pp=w(`^(?:(?<public>public)\\s+)?event\\s+(?<name>[A-Za-z_]\\w*)(?:\\s+generation\\s+(?<generation>[0-9]+))?(?:\\s+from\\s+"(?<origin>${z})")?$`),up=w("^readmodel\\s+([A-Za-z_]\\w*)$"),Ja=4294967295,fp=w("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),mp=w("^[A-Za-z_]\\w*$"),Ha=c(t=>D(t.content)==="description"&&He(t)===void 0,"isDescription");function Qr(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,f(n)),{...e,isIdentifier:!1}):e}c(Qr,"withoutIdentifier");function Xa(t,e){let n=dp.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,f(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Ha(o)){r=G(t,o,r,`Type '${n}'`);continue}if(pi(o))continue;let s=Ue(t,o);if(s===void 0){t.error(l.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,f(o));continue}i.push(Qr(t,s,o,l.IdentifierOutsideCommand,`Property '${s.name}' of type '${n}' cannot be marked identifier - only a command property can be`))}return i.length===0&&t.error(l.TypeWithoutProperties,`Type '${n}' must declare at least one property`,f(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:f(e)}}c(Xa,"parseType");function es(t,e){let n=pp.exec(e.content),i=n?.groups?.name??"";n===null&&t.error(l.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected '[public] event <Name> [generation <N>] [from "<origin>"]'`,f(e));let r=n?.groups?.origin===void 0?null:V(n.groups.origin),o=n?.groups?.public!==void 0||r!==null?se.Public:se.Private;r!==null&&Cn(r)&&t.error(l.InvalidEventDeclaration,"An event origin must be a nonblank quoted string",f(e));let s=n?.groups?.generation!==void 0,a=1;if(s){let p=Number(n.groups.generation);!Number.isSafeInteger(p)||p===0||p>=Ja?t.error(l.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${Ja-1}`,f(e)):a=p}let d=[],u=[],m=new Ht(i);for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),pi(p))continue;if(Pn.includes(D(p.content))){let h=An(t,p);h!==void 0&&u.push(h);continue}let y=Ue(t,p);if(y===void 0){m.tryParse(t,p)||t.error(l.InvalidPropertyDeclaration,`Invalid property '${p.content}' - expected '<name> <Type>'`,f(p));continue}d.push(Qr(t,y,p,l.IdentifierOnEventProperty,`Property '${y.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:d,tags:u,visibility:o,origin:r,generation:a,hasGenerationMarker:s,...m.value,location:f(e)}}c(es,"parseEvent");function An(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&fp.test(i)&&t.warning(l.TagPropertyReadAsTag,`'${e.content}' declares a static tag with the value '${i}', not a property named 'tag' - write 'tag "${i}"' for the tag, or '@${e.content}' for the property`,f(e)),i.length===0){t.error(l.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",f(e));return}if(mp.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:f(e)},location:f(e)};let r=ae(i,f(e),t);if(r.kind==="RawExpressionSyntax"){t.error(l.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,f(e));return}return{kind:"TagSyntax",value:r,location:f(e)}}c(An,"parseTag");function ts(t,e){let n=up.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,f(e));let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),Ha(s))r=G(t,s,r,`Read model '${n}'`);else if(D(s.content)==="documentation"&&He(s)===void 0)o=we(t,s,o,`Read model '${n}'`);else{if(pi(s))continue;{let a=Ue(t,s);if(a===void 0){t.error(l.InvalidPropertyDeclaration,`Invalid property '${s.content}' - expected '<name> <Type>'`,f(s));continue}i.push(Qr(t,a,s,l.IdentifierOutsideCommand,`Property '${a.name}' of read model '${n}' cannot be marked identifier - only a command property can be`))}}return{kind:"ReadModelSyntax",name:n,properties:i,description:r,documentation:o,location:f(e)}}c(ts,"parseReadModel");var yp=Z("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function Ee(t,e,n){if(n=n.valueContext,t=t.trim(),t.startsWith("`")){let o=[];if(!t.endsWith("`")||t.length<2)return n.error(l.UnterminatedTemplateExpression,"Unterminated template expression - expected a closing backtick",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};let s=t.substring(1,t.length-1),a=0;for(let d=0;d<s.length;d++){if(s[d]!=="$"||s[d+1]!=="{")continue;d>a&&o.push({kind:"TemplateTextSyntax",text:s.substring(a,d),location:e});let u=s.indexOf("}",d);if(u<0)return n.error(l.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};o.push({kind:"TemplateInterpolationSyntax",expression:Ee(s.substring(d+2,u),e,n),location:e}),d=u,a=u+1}return a<s.length&&o.push({kind:"TemplateTextSyntax",text:s.substring(a),location:e}),{kind:"TemplateExpressionSyntax",parts:o,location:e}}let i=t.startsWith("literal ")?t.substring(8).trim():t;if(n.sourceOptions.numericMode==="exact"&&(i.startsWith("{")||i.startsWith("[")))return Ye(i,e,n);if(t.startsWith("literal ")){let o=yn(t.substring(8).trim(),e,n);return o!==void 0?o:(n.error(l.ExpectedLiteralValue,`Expected a literal value after 'literal', got '${t.substring(8).trim()}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}if(t==="$refusal"||t.startsWith("$refusal."))return{kind:"RefusalExpressionSyntax",member:t==="$refusal"?"":t.substring(9),location:e};if(t==="$eventSourceId")return{kind:"EventSourceIdExpressionSyntax",location:e};if(t.startsWith("$eventContext."))return{kind:"EventContextExpressionSyntax",path:t.substring(14),location:e};if(t==="$causedBy")return{kind:"CausedByExpressionSyntax",property:null,location:e};if(t.startsWith("$causedBy."))return{kind:"CausedByExpressionSyntax",property:t.substring(10),location:e};let r=yn(t,e,n);return r!==void 0?r:yp.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(l.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}c(Ee,"parseProjectionExpression");var gi=c(t=>({legacy:w(t),native:Z(t)}),"grammar"),hp=gi("^capture\\s+([A-Za-z_]\\w*)$"),Sp=/^[A-Za-z_][\w.]*$/,gp=gi("^append\\s+([A-Z]\\w*)$"),xp=gi("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),vp=gi("^nested\\s+([\\w.]+)$"),Si=c((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),$p=Z("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),bp=Z("^([a-z_]\\w*)\\s*=\\s*(.+)$"),kp=Z(`^"(${z})"\\s*=>\\s*(\\w+)$`),Ep=Z(`^split\\s+(\\S+)\\s+by\\s+"(${z})"$`),Cp=new RegExp(Z(`"${z}"|[\\w.]+`).source,"gu"),Pp=Z("^[\\w.]+$");function Gr(t,e){let n=t;t=t.valueContext;let i=Si(t,hp).exec(e.content)?.[1]??"";i===""&&t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,f(e));let r=null,o=null,s=[],a=[],d=[],u=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(m.content)){case"source":r=Ap(t,m,n);break;case"key":o=m.content.substring(3).trim();break;case"map":s.push(...is(t,m));break;case"append":rs(t,m,a);break;case"children":{let p=Si(t,xp).exec(m.content);if(p===null){t.error(l.InvalidChildrenDeclaration,`Invalid children declaration '${m.content}' - expected 'children <collection> identified by <key>'`,f(m)),t.skipOpaqueBlock(m.indent);break}let y=ns(t,m);p!==null&&d.push({kind:"CaptureChildrenSyntax",property:p[1],identifiedBy:p[2],...y,location:f(m)});break}case"nested":{let p=Si(t,vp).exec(m.content);if(p===null){t.error(l.InvalidNestedDeclaration,`Invalid nested declaration '${m.content}' - expected 'nested <Property>'`,f(m)),t.skipOpaqueBlock(m.indent);break}let y=ns(t,m);p!==null&&u.push({kind:"CaptureNestedSyntax",property:p[1],...y,location:f(m)});break}default:t.error(l.UnknownCaptureDirective,`Unexpected '${m.content}' in capture body`,f(m)),t.skipOpaqueBlock(m.indent)}return{kind:"CaptureSyntax",sourceOptions:t.sourceOptions,name:i,source:r,key:o,map:s,appends:a,children:d,nested:u,location:f(e)}}c(Gr,"parseCapture");function Ap(t,e,n){let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);i.push({kind:"CaptureSourceSettingSyntax",name:s,value:o.content.substring(s.length).trim(),location:f(o)})}let r=e.content.substring(6).trim();return r===zr&&Ip(n,e,i),{kind:"CaptureSourceSyntax",syntaxKind:r,settings:i,location:f(e)}}c(Ap,"parseSource");function Ip(t,e,n){n.length===0&&t.error(l.InvalidCaptureEventsSource,"'source events' needs at least one 'from <Event>' line naming a public event to consume",f(e));let i=new Set;for(let r of n)r.name!==Vr?t.error(l.InvalidCaptureEventsSource,`'source events' accepts only 'from <Event>' lines, got '${r.name}'`,r.location):Sp.test(r.value)?i.has(r.value)?t.error(l.InvalidCaptureEventsSource,`Event '${r.value}' is already consumed by this 'source events'`,r.location):i.add(r.value):t.error(l.InvalidCaptureEventsSource,`Invalid event '${r.value}' - expected 'from <Event>', optionally qualified with dots`,r.location)}c(Ip,"validateEventsSource");function is(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=f(i);if(D(i.content)==="split"){let p=Ep.exec(i.content);if(p===null){t.error(l.InvalidSplitDeclaration,`Invalid split operation '${i.content}' - expected 'split <property> by "<separator>"'`,r),t.skipOpaqueBlock(i.indent);continue}let y=[];for(let h=t.peekChild(i.indent);h!==void 0;h=t.peekChild(i.indent))t.reader.takeSignificant(),Pp.test(h.content)?y.push(h.content):t.error(l.InvalidSplitTarget,`Invalid split target '${h.content}' - expected a property path`,f(h));p!==null&&n.push({kind:"CaptureSplitSyntax",source:Ee(p[1],r,t),separator:V(p[2]),targets:y,location:r});continue}let o=bp.exec(i.content);if(o===null){t.error(l.InvalidMapEntry,`Invalid map entry '${i.content}' - expected '<property> = <source> [translate]'`,r),t.skipOpaqueBlock(i.indent);continue}let s=o[2].trim(),a=s.startsWith("`")?s.indexOf("`",1):-1,d=s.startsWith("`")?a>=0&&s.substring(a+1).trim()==="translate":s.endsWith(" translate"),u=s.startsWith("`")&&a>=0&&(t.sourceOptions.numericMode!=="exact"||d||s.substring(a+1).trim()==="")?s.substring(0,a+1):d?s.substring(0,s.length-10).trimEnd():s,m=[];if(d)for(let p=t.peekChild(i.indent);p!==void 0;p=t.peekChild(i.indent)){t.reader.takeSignificant();let y=kp.exec(p.content);y!==null?m.push({kind:"CaptureTranslationSyntax",from:V(y[1]),to:y[2],location:f(p)}):t.error(l.InvalidTranslation,`Invalid translation '${p.content}' - expected '"<source>" => <target>'`,f(p))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:Ee(u,r,t),translations:m,location:r})}return n}c(is,"parseMap");function ns(t,e){let n=[],i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="map"?n=is(t,r):D(r.content)==="append"?rs(t,r,i):(t.error(l.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${D(e.content)} block - expected 'map' or 'append <EventType>'`,f(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}c(ns,"mapAndAppends");function rs(t,e,n){let i=Si(t,gp).exec(e.content);if(i===null){t.error(l.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,f(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],s=null,a=c((d,u=!1)=>{let m=f(d);if(D(d.content)==="tag"){let y=An(t.valueContext,d,!1);y!==void 0&&o.push(y);return}let p=$p.exec(d.content);p!==null?r.push({kind:"PropertyMappingSyntax",property:re(p[1]),source:Ye(p[2],m,t.valueContext),location:m}):t.error(u?l.InvalidPropertyMapping:l.UnknownAppendDirective,`Unexpected '${d.content}' in append body`,m)},"mapping");for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(d.content)==="when"){s=wp(t,d);for(let u=t.peekChild(d.indent);u!==void 0;u=t.peekChild(d.indent))t.reader.takeSignificant(),a(u,!0)}else a(d);n.push({kind:"CaptureAppendSyntax",event:i[1],when:s,mappings:r,tags:o,location:f(e)})}c(rs,"pushAppend");function wp(t,e){let n=e.content.substring(4).trim(),i=f(e),r=c((d,u=[],m=null,p=null,y=null)=>({kind:"CaptureWhenSyntax",syntaxKind:d,properties:u,fromValue:m,toValue:p,expression:y,location:i}),"value");if(n==="added")return r("Added");if(n==="removed")return r("Removed");if(n.startsWith("`"))return(!n.endsWith("`")||n.length<2)&&t.error(l.UnterminatedTemplateExpression,"Unterminated template expression in 'when' - expected a closing backtick",i),r("Expression",[],null,null,n);if(n.length===0)return t.error(l.WhenWithoutTrigger,"Expected a trigger after 'when'",i),null;let o=[...n.match(t.sourceOptions.numericMode==="exact"?new RegExp(`"${z}"|[^\\s]+`,"gu"):Cp)??[]],s=c(d=>d.startsWith('"')&&d.endsWith('"')?V(d.substring(1,d.length-1)):d,"unquote");if(o.length===0)return t.error(l.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length===1)return r("PropertyChanged",[s(o[0])]);if(o[1]==="from")return o.length===5&&o[3]==="to"?r("ValueTransition",[s(o[0])],s(o[2]),s(o[4])):(t.error(l.InvalidWhenTransitionClause,`Invalid 'when ... from ... to ...' clause '${e.content}'`,i),null);if(o[1]!=="or"&&o[1]!=="and")return t.error(l.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length%2===0)return t.error(l.WhenCombinatorWithoutProperty,`Expected a property after '${o[1]}'`,i),null;let a=[s(o[0])];for(let d=1;d<o.length-1;d+=2){if(o[d]!==o[1])return t.error(l.MixedWhenCombinators,`Cannot mix 'and' and 'or' in a single 'when' clause '${e.content}'`,i),null;a.push(s(o[d+1]))}return r(o[1]==="or"?"LogicalOr":"LogicalAnd",a)}c(wp,"parseWhen");var _r=w("^returns\\s+(@?[A-Za-z_]\\w*)$"),Op=w("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function Zr(t,e){let n=f(e);if(e.content!=="returns"){let r=_r.exec(e.content);if(r===null)return t.error(l.InvalidCommandResponse,"Expected 'returns <property>' or an unconditional 'returns' block.",n),t.skipBlock(e.indent),null;let o=t.peekChild(e.indent);o!==void 0&&(t.error(l.InvalidCommandResponse,"A scalar response cannot have child directives.",f(o)),t.skipBlock(e.indent));let s=r.index+r[0].length-r[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:re(r[1]),location:{...n,column:n.column+s}},location:n}}let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Op.exec(r.content);if(o===null){He({...r,content:r.content.split("=",1)[0].trimEnd()})?.isSubject?t.error(l.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not response fields (decision 0008: one data subject per event).",f(r)):t.error(l.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",f(r)),t.skipBlock(r.indent);continue}let s=f(r),a=o[2]===void 0?null:Ie(o[2],{...s,column:s.column+r.content.indexOf(o[2],o[1].length)});a!==null&&Le(t,a,r),i.push({kind:"ResponseFieldSyntax",name:re(o[1]),type:a,source:{kind:"PropertyResponseSourceSyntax",property:re(o[3]),location:{...s,column:s.column+r.content.lastIndexOf(o[3])}},location:s});let d=t.peekChild(r.indent);d!==void 0&&(t.error(l.InvalidCommandResponse,"A response field cannot have child directives.",f(d)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}c(Zr,"parseCommandResponse");var xi=new WeakMap;function vi(t){let e=Z(`^reads${Y}+([A-Z]\\w*)(?:${Y}+as${Y}+([a-z_]\\w*))?(?:${Y}+by${Y}+([a-z_]\\w*))?$`).exec(t.content);if(!(e===null||["as","by","reads"].includes(e[2])))return{kind:"ReadsSyntax",readModel:e[1],alias:e[2]??null,by:e[3]??null,location:f(t)}}c(vi,"captureReads");function os(t){return new ye(t.reader.fork(),t.path,t.languages)}c(os,"fork");function as(t,e){if(e.content!=="concurrency")return;let n=os(t),i=!1,r={},o;for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent))switch(n.reader.takeSignificant(),D(s.content)){case"eventSource":s.content==="eventSource"&&(i=!0);break;case"sourceType":case"streamType":case"streamId":{let a=Z(`^(sourceType|streamType|streamId)${Y}+([A-Za-z_]\\w*)$`).exec(s.content);a!==null&&(r[a[1]]??=a[2]);break}case"events":{if(o!==void 0)break;let a=s.content.slice(6).split(",").map(d=>d.replace(new RegExp(`^${Y}+|${Y}+$`,"gu"),"")).filter(Boolean);a.length>0&&a.every(d=>Z("^[A-Z]\\w*$").test(d))&&(o=a);break}default:n.skipBlock(s.indent);break}return{kind:"ConcurrencySyntax",eventSource:i,eventSourceType:r.sourceType??null,eventStreamType:r.streamType??null,eventStreamId:r.streamId??null,eventTypes:o??[],location:f(e)}}c(as,"captureConcurrency");function ss(t,e){let n=Z(`^reducer${Y}+([A-Za-z_]\\w*)${Y}*=>${Y}*([A-Za-z_]\\w*)$`).exec(e.content),i=os(t),r=[];for(let o=i.peekChild(e.indent);o!==void 0;o=i.peekChild(e.indent)){if(i.reader.takeSignificant(),D(o.content)==="description"){G(i,o,null,"Reducer");continue}let s=Z(`^on${Y}+([A-Z]\\w*)$`).exec(o.content);s!==null&&r.push({kind:"ReducerRuleSyntax",event:s[1],file:null,code:null,description:null,location:f(o)}),i.skipOpaqueBlock(o.indent)}return{kind:"ReducerSyntax",name:n?.[1]??"",readModel:n?.[2]??"",rules:r,description:null,location:f(e)}}c(ss,"captureReducer");var Tp=w("^produces\\s+operation(?:\\s|$)"),Rp=w("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),Dp=w("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),ls=w("^produces\\s+when\\s+(.+)$"),Mp=w("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Lp=w("^for\\s+(\\S.*)$"),jp=w("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Np=w("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),qp=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function In(t,e,n=!1){if(Tp.test(e.content)){if(!n){t.error(l.OperationOutsideCommand,"Operations can only be produced by commands.",f(e)),t.skipOpaqueBlock(e.indent);return}let g=fi(t,e,!0);return{kind:"ProducesSyntax",when:null,event:g.operation.name,targetLocation:{...f(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:g.operation,mappings:g.mappings,for:null,tags:[],location:f(e)}}let i=Rp.exec(e.content),r=e,o=null,s,a;if(i!==null){if(!n){t.error(l.InlineEventOutsideCommand,"Inline events can only be declared inside commands",f(e)),t.skipOpaqueBlock(e.indent);return}i[2]!==void 0&&t.error(l.InlineEventGeneration,"Inline events are generation 1 - extract the event before declaring generations",f(e)),s=i[1],a=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(ls.test(e.content)){o=Ze(t,ls.exec(e.content)[1],f(e));let g=t.peekChild(e.indent);if(g===void 0||!Mp.test(g.content)){t.error(l.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",f(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=g,s=g.content,a=g.indent+1}else{let g=Dp.exec(e.content);if(g===null){t.error(l.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,f(e)),t.skipOpaqueBlock(e.indent);return}s=g[1],a=e.indent+e.content.match(/^produces\s+/)[0].length+1}let d=[],u=new Set,m=[],p=[],y=new Ht(s),h=null;for(let g=t.peekChild(r.indent);g!==void 0;g=t.peekChild(r.indent)){t.reader.takeSignificant();let b=D(g.content),S=f(g);if(qp.has(b)){t.error(l.ReservedProductionMetadata,`'${b}' is system-assigned production metadata and cannot be supplied here`,S),t.skipOpaqueBlock(g.indent);continue}if(i!==null&&(b==="generation"||b==="origin")){t.error(b==="generation"?l.InlineEventGeneration:l.ReservedProductionMetadata,b==="generation"?"Inline events are generation 1 - extract the event before declaring generations":"An inline event is local to its command and cannot declare origin",S),t.skipOpaqueBlock(g.indent);continue}if(b==="tag"){let I=An(t,g,!1);I!==void 0&&p.push(I);continue}let $=Lp.exec(g.content);if($!==null){h!==null?t.error(l.DuplicateProducesTarget,`'${r.content}' already declares where it lands - an event is appended to one event source`,S):h=ae($[1],S,t);continue}let x=(i===null?jp:Np).exec(g.content),P=x===null||i===null?void 0:Ue(t,{...g,content:x[1].trimEnd()});if(x!==null&&(i===null||P!==void 0)){if(P!==void 0){P.isIdentifier&&(t.error(l.IdentifierOnEventProperty,`Property '${P.name}' of event '${s}' cannot be marked identifier - an event never carries its event source id`,S),P={...P,isIdentifier:!1});let I=P.name;u.has(I)&&t.error(l.DuplicateDeclaration,`Event '${s}' already declares property '${P.name}'`,S),u.add(I),d.push(P)}m.push({kind:"PropertyMappingSyntax",property:P?.name??re(x[1]),source:ae(x[2],{...S,column:g.indent+g.content.length-x[2].length+1},t),location:S})}else(i===null||!y.tryParse(t,g))&&t.error(l.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${g.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,S)}return r!==e&&t.skipBlock(e.indent),{kind:"ProducesSyntax",when:o,event:s,targetLocation:{...f(r),column:a},inlineOperation:null,mappings:m,for:h,tags:i===null?p:[],location:f(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:s,properties:d,tags:p,generation:1,hasGenerationMarker:!1,...y.value,location:f(e)}}}c(In,"parseProduces");var Bp=w("^command\\s+([A-Za-z_]\\w*)$"),Yp=ke("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),Fp=w("\\bseverity\\s+(\\S+)$"),ds=w(`\\bmessage\\s+(?:"(${z})"|(\\$strings\\.\\S*))$`),Up=w("^([\\w.]+)\\s+(.+)$"),Wp=w("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),zp=ke("^[A-Za-z_]\\w*$"),Vp=w("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),Qp={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},ps={information:"Information",warning:"Warning",error:"Error"},Gp=new Set(["reads","concurrency"]),_p=new Set(["description","documentation","handler","concurrency"]);function us(t,e){let n=new Set,i=new ye(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,cs(i,e,void 0,n),cs(t,e,n)}c(us,"parseCommand");function cs(t,e,n,i){let r=Bp.exec(e.content)?.[1]??"";r===""&&t.error(l.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,f(e));let o=[],s=[],a,d=[],u=[],m=[],p=[],y,h=null,g=null,b=null,S=null,$=null,x=[];for(let k=t.peekChild(e.indent);k!==void 0;k=t.peekChild(e.indent)){t.reader.takeSignificant();let A=D(k.content),O=He(k);if(O!==void 0&&(_p.has(A)||A==="validate"&&k.content!=="validate csharp"))a=$i(t,o,O,r,k,a);else if(A==="returns"){let T=_r.exec(k.content);T!==null&&!T[1].startsWith("@")&&O!==void 0?n===void 0?(o.push(O),s.push({line:k,candidate:O,response:null})):n.has(O.type.name)?s.push({line:k,candidate:null,response:Zr(t,k)}):a=$i(t,o,O,r,k,a):O!==void 0?a=$i(t,o,O,r,k,a):_n(t,k)?t.skipBlock(k.indent):s.push({line:k,candidate:null,response:Zr(t,k)})}else if(A==="stream"&&Yp.test(k.content)&&O!==void 0&&t.streamCandidates?.hasSource(O.type.name.split(".")[0])===!0){let[T,M]=O.type.name.split("."),N=t.streamCandidates.hasPropertyType(O.type.name)&&t.streamCandidates.hasUniqueStream(T,M),j=Na(t,k,O,N);($!==null||x.length>0)&&t.error(l.InvalidCommandStream,"A command declares at most one stream route.",f(k)),N||$!==null?x.push(j):$=j}else if(A==="runs"&&Kt(k))Oe(t,k);else if(A==="description")h=G(t,k,h,`Command '${r}'`);else if(A==="documentation")g=we(t,k,g,`Command '${r}'`);else if(A==="authorize")b=et(b,xt(t,k));else if(A==="validate"){let T=Kr(t,k,"command");T!==void 0&&d.push(T)}else if(A==="produces"){let T=In(t,k,!0);T!==void 0&&u.push(T)}else if(A==="handler")S=Ya(t,k);else if(Gp.has(A)){let T=vi(k);T!==void 0&&p.push(T),A==="concurrency"&&y===void 0&&(y=as(t,k));let M=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(k.content);M!==null&&m.push({readModel:M[1],alias:M[2]??null}),Vp.test(k.content)&&t.error(l.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(k)),t.skipOpaqueBlock(k.indent)}else O!==void 0?a=$i(t,o,O,r,k,a):(_n(t,k),t.error(l.UnknownCommandDirective,`Unexpected '${k.content}' in command body`,f(k)),t.skipBlock(k.indent))}let P=new Set(s.flatMap(k=>k.candidate===null?[]:[k.candidate])),I=new Set(o.filter(k=>!P.has(k)).map(k=>k.name));s.some(k=>k.candidate!==null&&!I.has(k.candidate.type.name)&&k.candidate.type.name!=="returns")&&I.add("returns");for(let k of I)i?.add(k);let v=null,E=new Set;for(let k of s){let A=k.response;if(k.candidate!==null){if(!I.has(k.candidate.type.name))continue;E.add(k.candidate),A={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:k.candidate.type.name,location:k.candidate.type.location},location:f(k.line)}}A!==null&&(v!==null?t.error(l.InvalidCommandResponse,"A command declares at most one unconditional response.",f(k.line)):v=A)}S!==null&&u.length>0&&t.error(l.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,f(e));let C={kind:"CommandSyntax",name:r,description:h,documentation:g,authorize:b,properties:o.filter(k=>!E.has(k)),validations:d,produces:u,handler:S,response:v,stream:$,streamCandidates:x,location:f(e)};return xi.set(C,m),at.set(C,{reads:p,concurrency:y}),C}c(cs,"parseCommandBody");function $i(t,e,n,i,r,o){return Le(t,n.type,r),n.isIdentifier&&o!==void 0&&(t.error(l.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,n.location),n={...n,isIdentifier:!1}),e.push(n),o??(n.isIdentifier?n:void 0)}c($i,"addProperty");function Kr(t,e,n){if(e.content==="validate"){let i=t.peekChild(e.indent);if(i!==void 0&&i.content.startsWith("```")){t.reader.takeSignificant();let a=Te(t.valueContext,i);return a===null&&t.skipFencedBody(),{kind:"CodeValidateSyntax",code:a,location:f(e)}}let r=[],o=[],s;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n==="concept"){if(t.sourceOptions.numericMode==="legacy"&&a.content.startsWith("```")){t.skipFencedBody();continue}if(s!==void 0&&a.indent<=s&&(s=void 0),s!==void 0||D(a.content)==="implementation"){t.error(l.InvalidValidationRule,`Invalid validation rule '${a.content}'`,f(a)),s??=a.indent;continue}}if(D(a.content)==="require"){let u=Ze(n==="concept"?t.valueContext:t,a.content.substring(7).trim(),f(a)),m=null,p="Error",y=!1;for(let h=t.peekChild(a.indent);h!==void 0;h=t.peekChild(a.indent)){t.reader.takeSignificant();let g=ds.exec(h.content);g!==null&&g.index===0?m=g[1]!==void 0?V(g[1]):g[2]:D(h.content)==="severity"?(y||(p=ps[h.content.substring(8).trim()]??"Error"),y=!0):t.skipOpaqueBlock(h.indent)}u!==null&&o.push({kind:"RequirementSyntax",condition:u,message:m,severity:p,location:f(a)});continue}let d=Zp(t,n==="concept"?{...a,content:`value ${a.content}`}:a,n);d!==void 0&&r.push(d)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:f(e)}}if(e.content==="validate csharp"){let i=Te(t.valueContext,{...e,content:"csharp"});return i===null&&t.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",code:i,location:f(e)}}t.error(l.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,f(e)),t.skipBlock(e.indent)}c(Kr,"parseValidate");function Zp(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=Jp(e.content),s=Hp(i,e,r);if(s===void 0)return;let a=Up.exec(s.content);if(a===null){i.error(l.InvalidValidationRule,`Invalid validation rule '${e.content}'`,f(e));return}let d=Xp(i,a[2],e);if(d===void 0)return;let u=d.kind==="Rule"?Kp(t,e,n==="command"):{file:null,code:null,implementation:null};return{kind:"ValidationRuleSyntax",property:a[1],rule:d.kind,value:d.value,message:o,severity:s.severity,...u,location:f(e)}}c(Zp,"parseValidationRule");function Kp(t,e,n){let i=t.peekChild(e.indent);if(i===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let r=n&&D(i.content)==="implementation",o=r?vn(t,i):{file:vt(i)?tt(t,i):null,code:!vt(i)&&Tt(t,i)?Te(t,i):null,implementation:null};!r&&o.file===null&&o.code===null&&(t.error(l.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,f(i)),t.skipBlock(i.indent));for(let s=t.peekChild(e.indent);s!==void 0&&(r||n&&D(s.content)==="implementation");s=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(r&&D(s.content)==="implementation"?l.InvalidImplementationBlock:l.ConflictingImplementationSources,"A named rule has one implementation wrapper and cannot mix wrapped and direct sources.",f(s)),Tt(t,s)?Te(t,s):t.skipBlock(s.indent);return o}c(Kp,"parseRuleImplementation");function Jp(t){let e=ds.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?V(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}c(Jp,"splitMessage");function Hp(t,e,n){let i=Fp.exec(n);if(i===null)return{content:n,severity:"Error"};let r=ps[i[1]];if(r===void 0){t.error(l.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,f(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}c(Hp,"splitSeverity");function Xp(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=Wp.exec(e);if(i===null){t.error(l.InvalidValidationRule,`Invalid validation rule '${n.content}'`,f(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!zp.test(r)){t.error(l.InvalidRuleName,`Invalid rule name '${r}' in '${n.content}' - expected 'rule <Name>' with an identifier`,f(n));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:r,location:f(n)}}}return{kind:Qp[i[1]],value:ae(i[2],f(n),t)}}c(Xp,"parseRule");var eu=w("^constraint\\s+([A-Za-z_]\\w*)$"),tu=w("^unique\\s+event\\s+([A-Z]\\w*)$"),nu=w("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),iu=w("^released\\s+by\\s+([A-Z]\\w*)$"),ru=w(`^message\\s+"(${z})"$`),ou=c(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function fs(t,e){let n=eu.exec(e.content);n===null&&t.error(l.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,f(e));let i=n?.[1]??D(e.content),r=[],o=[],s=new Set,a=new Set,d=null,u=null,m=!1;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(p.content)==="description"){u=G(t,p,u,`Constraint '${i}'`);continue}let y=iu.exec(p.content),h=ru.exec(p.content);y!==null?s.has(y[1])?t.error(l.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${y[1]}'`,f(p)):(o.push(y[1]),s.add(y[1])):h!==null?d!==null?t.error(l.DuplicateConstraintBody,`Constraint '${i}' already has a message`,f(p)):d=V(h[1]):p.content==="ignore casing"?(m&&t.error(l.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,f(p)),m=!0):au(t,i,p,r,a)}for(let p of o.filter(y=>a.has(y)))t.error(l.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${p}'`,f(e));return r.length===0&&(t.error(l.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,f(e)),r.push(bi(i,f(e),{kind:"UniqueEventConstraintSyntax",event:""}))),r[0].kind==="FileConstraintSyntax"&&(o.length>0||d!==null||m)&&t.error(l.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,f(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:d,ignoreCasing:m,description:u}}c(fs,"parseConstraint");function au(t,e,n,i,r){let o=su(t,e,n);if(o===void 0)return;if(i.length>0&&(o.kind==="FileConstraintSyntax"||i[0].kind==="FileConstraintSyntax"||o.kind==="UniqueEventConstraintSyntax"!=(i[0].kind==="UniqueEventConstraintSyntax"))){t.error(l.DuplicateConstraintBody,`Constraint '${e}' cannot mix constraint kinds`,f(n));return}let s=ou(o);if(s!==void 0&&r.has(s)){t.error(l.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,f(n));return}s!==void 0&&r.add(s),i.push(o)}c(au,"addRule");function su(t,e,n){let i=f(n),r=tu.exec(n.content);if(r!==null)return bi(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=nu.exec(n.content);if(o!==null){let s=o[1].split(",").map(a=>a.trim());if(new Set(s).size!==s.length){t.error(l.DuplicateConstraintBody,`Constraint '${e}' repeats a property in its composite key`,i);return}return bi(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:o[2]})}if(ge(n)){t.warning(l.FileConstraintOnlySupportsUniqueness,"A file constraint can only declare unique constraints in Chronicle - declare them with 'unique ...' so they are portable; a rule that is not uniqueness belongs in command validation or a 'require' condition",i);let s=n.content.substring(4).trim();return bi(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}t.error(l.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}c(su,"parseRule");function bi(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}c(bi,"rule");var lu=w("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),cu=w("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),du=w("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),pu=w("^with\\s+(@?[\\w.]+)$"),uu=w("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),fu=w("^nested\\s+(@?[\\w.]+)$"),mu=w("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),yu=w("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),hu=w("^clear\\s+with\\s+(@?[\\w.]+)$"),Su=w("^variant\\s+(@?[\\w.]+)\\s*$"),gu=w("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),xu=w("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),vu=w("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),$u=w("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),ms=w("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),bu={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function Hr(t,e){let n=lu.exec(e.content);if(n===null)return t.error(l.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:D(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:f(e)};let i=n[1],r=null,o=null,s="Inherit",a=null,d=[];for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ge(u))continue;let m=D(u.content);if(m==="description")o=G(t,u,o,`Projection '${i}'`);else if(m==="sequence")r=u.content.substring(8).trim();else if(m==="automap")s="Enabled";else if(u.content==="no automap")s="Disabled";else if(m==="key")a=hs(t,u);else if(m==="variant")d.push(Ou(t,u));else{let p=Xr(t,u,!1);p!==void 0&&d.push(p)}}return ku(t,d,i),d.length===0&&t.error(l.EmptyProjection,`Projection '${i}' must contain at least one directive`,f(e)),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:i,readModel:n[2]??null,sequence:r,autoMap:s,key:a,blocks:d,description:o,location:f(e)}}c(Hr,"parseProjection");function ku(t,e,n){let i=e.filter(s=>s.kind==="ProjectionVariantSyntax"),r=new Map;i.forEach(s=>r.set(s.name,[...r.get(s.name)??[],s]));for(let s of[...r.values()].flatMap(a=>a.slice(1)))t.error(l.DuplicateProjectionVariant,`Duplicate variant '${s.name}' - a variant name is declared once`,s.location);let o=new Set;for(let s of e.flatMap(a=>a.kind==="ProjectionVariantSyntax"?a.entersOn:[]))s.event.length>0&&o.has(s.event)&&t.error(l.DuplicateVariantEnteringEvent,`Entering event '${s.event}' is claimed more than once in projection '${n}'`,s.location),o.add(s.event)}c(ku,"reportVariantConflicts");function Xr(t,e,n){let i=f(e);switch(D(e.content)){case"from":return Eu(t,e);case"every":{let r=!0,{autoMap:o,mappings:s}=Jr(t,e,a=>a.content!=="exclude children"?!1:(r=!1,!0));return{kind:"EverySyntax",includeChildren:r,autoMap:o,mappings:s,location:i}}case"all":{let{autoMap:r,mappings:o}=Jr(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return Cu(t,e);case"children":return Pu(t,e);case"nested":return Au(t,e);case"remove":return Iu(t,e);case"clear":return n||t.error(l.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),wu(t,e);default:t.error(l.UnknownProjectionDirective,`Unexpected '${D(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}c(Xr,"parseBlock");function Eu(t,e){let n=[];for(let s of aa(e.content.substring(4),",")){let a=s.trim();if(a.length===0){t.error(l.FromWithoutEvent,"Expected an event type after 'from'",f(e));continue}let d=cu.exec(a);if(d===null){t.error(l.InvalidEventReference,`Invalid event reference '${a}'`,f(e));continue}n.push({kind:"EventSpecSyntax",event:re(d[1]),key:d[2]===void 0?null:Ee(d[2],f(e),t),location:f(e)})}let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);a==="key"?r=hs(t,s):a==="parent"?o=Ee(s.content.substring(6),f(s),t):Ss(t,s,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:f(e)}}c(Eu,"parseFrom");function Cu(t,e){let n=du.exec(e.content);if(n===null)return t.error(l.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,f(e)),t.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:f(e)};let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=pu.exec(r.content);if(o===null){t.error(l.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:a}=Jr(t,r);i.push({kind:"JoinEventSyntax",event:re(o[1]),autoMap:s,mappings:a,location:f(r)})}return{kind:"JoinSyntax",property:re(n[1]),on:re(n[2]),events:i,location:f(e)}}c(Cu,"parseJoin");function Pu(t,e){let n=uu.exec(e.content);if(n===null)return t.error(l.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,f(e)),t.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let{autoMap:i,blocks:r}=ys(t,e);return{kind:"ChildrenSyntax",property:re(n[1]),identifiedBy:Ee(n[2],f(e),t),autoMap:i,blocks:r,location:f(e)}}c(Pu,"parseChildren");function Au(t,e){let n=fu.exec(e.content);if(n===null)return t.error(l.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,f(e)),t.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let i=re(n[1]),{autoMap:r,blocks:o}=ys(t,e);return o.some(s=>s.kind==="FromSyntax")||t.error(l.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,f(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:f(e)}}c(Au,"parseNested");function ys(t,e){let n=[],i="Inherit";for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r.content==="automap"){i="Enabled";continue}if(r.content==="no automap"){i="Disabled";continue}let o=Xr(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}c(ys,"parseChildBlocks");function Iu(t,e){let n=yu.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:re(n[1]),key:n[2]===void 0?null:Ee(n[2],f(e),t),location:f(e)};let i=mu.exec(e.content);if(i===null){t.error(l.InvalidRemoveDeclaration,`Invalid remove declaration '${e.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,f(e)),t.skipBlock(e.indent);return}let r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),D(o.content)==="parent"?r=Ee(o.content.substring(6),f(o),t):t.error(l.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,f(o));return{kind:"RemoveWithSyntax",event:re(i[1]),key:i[2]===void 0?null:Ee(i[2],f(e),t),parentKey:r,location:f(e)}}c(Iu,"parseRemove");function wu(t,e){let n=hu.exec(e.content);return n===null?(t.error(l.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,f(e)),{kind:"ClearWithSyntax",event:"",location:f(e)}):{kind:"ClearWithSyntax",event:re(n[1]),location:f(e)}}c(wu,"parseClearWith");function Ou(t,e){let n=Su.exec(e.content);if(n===null)return t.error(l.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:D(e.content),entersOn:[],blocks:[],location:f(e)};let i=re(n[1]),r=[],o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);if(a==="enters")r.push(Tu(t,s));else if(a==="variant")t.error(l.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",f(s)),t.skipBlock(s.indent);else{let d=Xr(t,s,!1);d!==void 0&&o.push(d)}}return r.length===0&&t.error(l.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,f(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:f(e)}}c(Ou,"parseVariant");function Tu(t,e){let n=gu.exec(e.content);return n===null?(t.error(l.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",key:null,location:f(e)}):{kind:"ProjectionEntersOnSyntax",event:re(n[1]),key:n[2]===void 0?null:Ee(n[2],f(e),t),location:f(e)}}c(Tu,"parseEntersOn");function hs(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:Ee(n,f(e),t),location:f(e)};let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),o.content==="}")continue;let s=ms.exec(o.content);if(s===null){t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,f(o));continue}let a=Ee(s[2],f(o),t);t.sourceOptions.numericMode==="exact"&&a.kind==="TemplateExpressionSyntax"&&t.error(l.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",f(o)),i.push({kind:"KeyPartSyntax",property:re(s[1]),expression:a,location:f(o)})}let r=t.reader.peekSignificant();return r!==void 0&&r.indent===e.indent&&r.content==="}"&&t.reader.takeSignificant(),t.sourceOptions.numericMode==="exact"&&i.length===0&&t.error(l.EmptyCompositeKey,"Composite keys must contain at least one part",f(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:f(e)}}c(hs,"parseKey");function Jr(t,e,n=()=>!1){let i="Inherit",r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),o.content==="automap"?i="Enabled":o.content==="no automap"?i="Disabled":n(o)||Ss(t,o,r);return{autoMap:i,mappings:r}}c(Jr,"parseMappingBlock");function Ss(t,e,n){let i=f(e),r=xu.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:bu[r[1]],property:re(r[2]),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidProjectionMapping,`Invalid mapping '${e.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`,i);return}let o=vu.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:re(o[2]),value:Ee(o[3],i,t),location:i});return}let s=$u.exec(e.content)??ms.exec(e.content);s!==null?n.push({kind:"SetMappingSyntax",property:re(s[1]),source:Ee(s[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}c(Ss,"pushMapping");var Ru=w("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Du=w("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),Mu=w("^scoped\\s+to\\s+([a-z_]\\w*)$"),Lu=new Set(["performer"]);function xs(t,e){let n=Ru.exec(e.content);if(n===null)return t.error(l.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,f(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:D(e.content),returnType:Ie("",f(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:f(e)};let i=n[1],r=Ie(n[3],{...f(e),column:e.indent+1+n[0].length-n[3].length});n[2]===void 0&&r.name==="observable"&&r.isOptional&&!r.isCollection||Le(t,r,e);let o=null,s=[],a=null,d=null,u=null;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let p=D(m.content);if(p==="description")a=G(t,m,a,`Query '${i}'`);else if(p==="by"){let y=gs(t,m,"by");y!==void 0&&(o!==null&&t.error(l.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,f(m)),o=y)}else if(p==="filter"){let y=gs(t,m,"filter");y!==void 0&&s.push(y)}else p==="authorize"?u=et(u,xt(t,m)):p==="scoped"?d=ju(t,m,d,i)??d:Lu.has(p)?t.skipOpaqueBlock(m.indent):(t.error(l.UnknownQueryDirective,`Unexpected '${m.content}' in query body - expected description, by, filter, authorize, scoped or performer`,f(m)),t.skipBlock(m.indent))}return{kind:"QuerySyntax",name:i,returnType:r,by:o,filters:s,description:a,isObservable:n[2]!==void 0,scope:d,authorize:u,location:f(e)}}c(xs,"parseQuery");function gs(t,e,n){let i=Du.exec(e.content.substring(n.length).trim());if(i===null){t.error(l.InvalidQueryParameter,`Invalid '${n}' parameter '${e.content}' - expected '${n} <name> <Type> [from <source>]'`,f(e));return}let r=e.content.indexOf(i[1],n.length),o=Ie(i[2],{...f(e),column:e.indent+1+e.content.indexOf(i[2],r+i[1].length)});return Le(t,o,e),{kind:"QueryParameterSyntax",name:i[1],type:o,source:i[3]===void 0?null:ae(i[3],f(e),t.valueContext),location:f(e)}}c(gs,"parseParameter");function ju(t,e,n,i){let r=Mu.exec(e.content);if(r===null){t.error(l.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,f(e));return}if(n!==null){t.error(l.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,f(e));return}return r[1]}c(ju,"parseScope");var Nu=w("^@?[a-z_]\\w*\\s+[\\w.]+");function eo(t,e){let n=Ue(t,e);if(n!==void 0){n.isGenerated&&t.error(l.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),n.isSubject&&t.error(l.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not trigger or reaction data properties (decision 0008: one data subject per event).",n.location),t.triggerData.push(n);return}Nu.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(l.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,f(e)),t.skipOpaqueBlock(e.indent)}c(eo,"parseTriggerData");function vs(t,e){let n=t.triggerData.length;for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),D(i.content)==="description"?G(t,i,null,`Trigger '${e.content}'`):ge(i)||eo(t,i);return t.triggerData.slice(n)}c(vs,"parseTriggerDeclaration");var qu=w("^reaction\\s+([A-Za-z_]\\w*)$"),Bu=w("^when\\s+([A-Za-z_]\\w*)$"),Yu=w("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),Fu=w("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),Uu=new Set(["when","every","at"]),Wu=w("^invokes\\s+([A-Z]\\w*)$"),zu=Z("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),to=Z("^on\\s+refused\\b(?=$|\\s+by\\b)"),Vu=Z("^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$"),Qu=w("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function $s(t,e){let n=qu.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,f(e));let i=null,r=null,o=null,s=null,a=!1,d=[],u=new Set,m=!1;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let y=D(p.content);if(y==="description"){i=G(t,p,i,`Reaction '${n}'`);continue}if(y==="documentation"){r=we(t,p,r,`Reaction '${n}'`);continue}if(y==="runs"){s=Da(t,p,a)??s,a=!0;continue}if(y==="where"){o=Ze(t,p.content.substring(5).trim(),f(p));continue}if(to.test(p.content)){t.error(l.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent),m=!0;continue}if(!Uu.has(y)){t.error(l.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${p.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,f(p)),t.skipBlock(p.indent),m=!0;continue}let h=Ku(t,p);if(h===void 0){m=!0;continue}let g=Zu(h);if(u.has(g)){t.error(l.DuplicateReactionTrigger,`Reaction '${n}' already declares '${p.content}' - a second says nothing the first did not`,f(p)),t.skipBlock(p.indent);continue}u.add(g),d.push(Gu(t,p,h))}return d.length===0&&!m&&t.error(l.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,f(e)),{kind:"ReactionSyntax",name:n,description:i,documentation:r,runsAs:s,where:o,triggers:d,location:f(e)}}c($s,"parseReaction");function Gu(t,e,n){let i=null,r=[],o=[],s=[],a=[],d=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let p=D(m.content);if(p==="runs"&&Kt(m))Oe(t,m);else if(p==="description")i=G(t,m,i,`Trigger '${m.content}'`);else if(p==="produces"){let y=In(t,m);y!==void 0&&r.push(y)}else if(p==="invokes"){let y=Wu.exec(m.content);if(y===null)t.error(l.InvalidInvokesDeclaration,`Invalid invokes declaration '${m.content}' - expected 'invokes <Command>'`,f(m)),t.skipBlock(m.indent);else{let h=new ye(t.reader.fork(),t.path,t.languages);h.scope=t.scope,h.sourceOptions=t.sourceOptions,ze(h,m),t.inputUses.push(...h.inputUses);let g=[],b=[];for(let S=t.peekChild(m.indent);S!==void 0;S=t.peekChild(m.indent)){if(t.reader.takeSignificant(),Kt(S)){Oe(t,S);continue}if(to.test(S.content)){let x=_u(t,S);x!==void 0&&b.push(x);continue}let $=zu.exec(S.content);$!==null?g.push({kind:"PropertyMappingSyntax",property:$[1].replaceAll("@",""),source:Ye($[2],f(S),t.valueContext),location:f(S)}):t.error(l.InvalidPropertyMapping,`Invalid property mapping '${S.content}' - expected '<property> = <source>'`,f(S))}o.push({kind:"InvokesSyntax",command:y[1],mappings:g,onRefused:b,location:f(m)})}}else if(to.test(m.content))t.error(l.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(m)),t.skipBlock(m.indent);else if(p==="reads"||p==="file"||m.content==="csharp"||m.content.startsWith("```")){d||=p==="file"||m.content==="csharp"||m.content.startsWith("```");let y=vi(m);y!==void 0&&s.push(y),Qu.test(m.content)&&t.error(l.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(m)),m.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(m.indent)}else{let y=t.triggerData.length;eo(t,m);for(let h of t.triggerData.slice(y))a.push({kind:"TriggerDataSyntax",name:h.name,type:h.type,location:h.location})}}let u={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:f(e)};return at.set(u,{reads:s,data:a,implementation:d}),u}c(Gu,"parseTrigger");function _u(t,e){let n=Vu.exec(e.content);if(n===null||n[2]!==void 0&&n[1]!=="constraint"){t.error(l.InvalidRefusalBranch,"Expected 'on refused [by validation | by constraint [<Name>] | by authorization]'.",f(e)),t.skipBlock(e.indent);return}let i=[],r=!1,o=!1;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),Kt(s))Oe(t,s),o=!0;else if(s.content==="acknowledge")(r||i.length>0||t.peekChild(s.indent)!==void 0)&&(t.error(l.InvalidRefusalBranchBody,"A refusal branch contains 'acknowledge' alone or one or more 'produces' blocks.",f(s)),o=!0),r=!0,t.skipBlock(s.indent);else if(D(s.content)==="produces"){r&&(t.error(l.InvalidRefusalBranchBody,"A refusal branch cannot combine 'acknowledge' and 'produces'.",f(s)),o=!0);let a=In(t,s);a!==void 0?i.push(a):o=!0}else t.error(l.InvalidRefusalBranchBody,"Expected 'acknowledge' or 'produces <Event>' in a refusal branch.",f(s)),t.skipBlock(s.indent),o=!0;return!r&&i.length===0&&!o&&t.error(l.InvalidRefusalBranchBody,"A refusal branch must acknowledge or produce an event.",f(e)),{kind:"InvocationRefusalSyntax",selector:n[1]??"any",constraint:n[2]??null,acknowledge:r,produces:i,location:f(e)}}c(_u,"parseRefusal");function Zu(t){switch(t.kind){case"NamedTriggerSourceSyntax":return JSON.stringify([t.kind,t.name]);case"IntervalTriggerSourceSyntax":return JSON.stringify([t.kind,t.amount,t.unit]);case"ScheduleTriggerSourceSyntax":return JSON.stringify([t.kind,t.time,t.dayOfWeek,t.dayOfMonth])}}c(Zu,"sourceKey");function Ku(t,e){let n=f(e);switch(D(e.content)){case"when":{let i=Bu.exec(e.content);if(i===null){t.error(l.InvalidReactionTrigger,`Invalid trigger '${e.content}' - expected 'when <Name>'`,n),t.skipBlock(e.indent);return}return{kind:"NamedTriggerSourceSyntax",name:i[1],location:n}}case"every":{let i=Yu.exec(e.content),r=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(r)||r<1||r>2147483647){t.error(l.InvalidIntervalTrigger,`Invalid interval '${e.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,n),t.skipBlock(e.indent);return}return{kind:"IntervalTriggerSourceSyntax",amount:r,unit:Xu(i[2]),location:n}}default:return Ju(t,e)}}c(Ku,"parseTriggerSource");function Ju(t,e){let n=f(e),i=Fu.exec(e.content),r=i===null?void 0:Hu(i[1]);if(i===null||r===void 0){t.error(l.InvalidScheduleTrigger,`Invalid schedule '${e.content}' - expected 'at <HH:mm>', optionally followed by 'on <Weekday>' or 'on day <n>'`,n),t.skipBlock(e.indent);return}if(i[3]!==void 0){let o=Number(i[3]);if(o<1||o>31){t.error(l.InvalidScheduleTrigger,`Invalid day of month '${o}' in '${e.content}' - a day of the month is between 1 and 31`,n),t.skipBlock(e.indent);return}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:null,dayOfMonth:o,location:n}}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:i[2]??null,dayOfMonth:null,location:n}}c(Ju,"parseSchedule");function Hu(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}c(Hu,"timeOf");function Xu(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}c(Xu,"unitOf");var ef=w("^(data|query|component)\\s+(\\S+)(.*)$"),tf=w("^literal\\s+(.+?)(?:\\s+(mode\\s+.+|null\\s+.+|expected\\s+.+))?$"),nf=w("^([A-Za-z_]\\w*)(?:\\.(.+))?$"),rf=w('^(?:([A-Za-z_]\\w*)|"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)")\\.(.+)$'),of=w("^mode\\s+(oneWay|twoWay)\\b(.*)$"),af=w("^null\\s+(propagate|clear|preserve)\\b(.*)$"),sf=w("^expected\\s+(\\w+(?:\\.\\w+)*)(.*)$");function Xt(t,e,n){let i=e.trim(),r=i.split(/\s+/,1)[0];return r==="data"||r==="query"||r==="component"||r==="literal"?bs(t,`from ${i}`,n):bs(t,i,n)}c(Xt,"parseFromClause");function bs(t,e,n){let i=e.trim();if(!i.startsWith("from "))return no(t,dt("DataContext",i,n),"",n);let r=i.substring(5).trim();if(r.startsWith("literal ")){let a=tf.exec(r);return a===null?(t.error(l.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from literal <value>'`,n),{...dt("Invalid",r,n),rawText:i}):no(t,{...dt("Literal","",n),literal:ae(a[1],n,t)},a[2]??"",n)}let o=ef.exec(r);if(o===null)return t.error(l.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from data <path>', 'from query <Query>[.<path>]', 'from component <id>.<path>' or 'from literal <value>'`,n),{...dt("Invalid",r,n),rawText:i};let s=lf(t,o[1],o[2],i,n);return no(t,s,o[3],n)}c(bs,"parseUiBinding");function lf(t,e,n,i,r){return e==="data"?dt("DataContext",n,r):e==="query"?cf(t,n,i,r):df(t,n,i,r)}c(lf,"parseBindingSource");function cf(t,e,n,i){let r=nf.exec(e);return r===null?(t.error(l.UnknownScreenDirective,`Invalid query binding '${n}' - expected 'from query <Query>[.<path>]'.`,i),{...dt("Invalid",e,i),rawText:n}):{...dt("QueryResult",r[2]??"",i),query:r[1]}}c(cf,"queryBinding");function df(t,e,n,i){let r=rf.exec(e);if(r===null)return t.error(l.UnknownScreenDirective,`Invalid component binding '${n}' - expected 'from component <stableInstanceId>.<outputPath>' or 'from component "<stableInstanceId>".<outputPath>'.`,i),{...dt("Invalid",e,i),rawText:n};let o=r[1]??r[2],s=r[3];return{...dt("ComponentProperty",s,i),componentId:o,componentPropertyPath:s}}c(df,"componentBinding");function no(t,e,n,i){let r=e,o=n.trim();for(;o.length>0;){let s=of.exec(o);if(s!==null){r={...r,mode:s[1]==="twoWay"?"TwoWay":"OneWay"},o=s[2].trim();continue}let a=af.exec(o);if(a!==null){r={...r,nullBehavior:a[1]==="clear"?"Clear":a[1]==="preserve"?"Preserve":"Propagate"},o=a[2].trim();continue}let d=sf.exec(o);if(d!==null){r={...r,expectedValueType:d[1]},o=d[2].trim();continue}return t.error(l.UnknownScreenDirective,`Unsupported UI binding modifier '${o}' - supported modifiers are 'mode oneWay|twoWay', 'null propagate|clear|preserve' and 'expected <Type>'.`,i),{...r,rawText:r.rawText??o}}return r}c(no,"withModifiers");function dt(t,e,n){return{kind:"UiBindingSyntax",bindingKind:t,path:e,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,literal:null,rawText:null,location:n}}c(dt,"create");var Rt=`(?:"(${z})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,pf=w("^screen\\s+([A-Za-z_]\\w*)$"),uf=w("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),ff=w("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),ks=w(`^label\\s+${Rt}$`),mf=w(`^action\\s+${Rt}$`),yf=w("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),hf=w(`^route\\s+${Rt}$`),Sf=w("^outlet\\s+([A-Za-z_]\\w*)$"),gf=w("^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$"),Es=w("^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),xf=w("^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$"),vf=w(`^id\\s+(?:"(${z})"|(\\S+))$`),$f=w("^property\\s+([\\w.]+)\\s+from\\s+(.+)$"),bf=w("^property\\s+([\\w.]+)\\s*=\\s+(.+)$"),kf=w("^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),Ef=w(`^presentation\\s+([A-Za-z_]\\w*)\\s+${Rt}$`),Cf=w("^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Pf=w("^[a-z_]\\w*$"),Af=w(`^title\\s+${Rt}$`),If=w(`^column\\s+([\\w.]+)(?:\\s+label\\s+${Rt})?$`),wf=w("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),Of=w(`^field\\s+([\\w.]+)\\s+label\\s+${Rt}$`),pt=c((t,e)=>t[e]!==void 0?V(t[e]):t[e+1],"operandText"),Tf=c(t=>["on","uses"].includes(D(t.content)),"isInteraction"),Rf=c((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function Cs(t,e){let n=pf.exec(e.content);n===null&&t.error(l.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,f(e));let i=[],r=[],o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="contribute"){let a=Df(t,s);a!==void 0&&r.push(a)}else D(s.content)==="description"?o=G(t,s,o,`Screen '${n?.[1]??""}'`):ge(s)||Ps(t,s,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,description:o,...r.length>0?{contributions:r}:{},location:f(e)}}c(Cs,"parseScreen");function Df(t,e){let n=gf.exec(e.content);if(n===null){t.error(l.UnknownScreenDirective,`Invalid screen contribution '${e.content}' - expected 'contribute to <Point> [order <n>]'`,f(e)),t.skipBlock(e.indent);return}return{kind:"ScreenContributionSyntax",contributionPoint:n[1],order:n[2]===void 0?null:Number(n[2]),directives:Ei(t,e),location:f(e)}}c(Df,"parseScreenContribution");function Ps(t,e,n){let i=Mf(t,e);i!==void 0&&n.push(i)}c(Ps,"pushDirective");function Ei(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),Ps(t,i,n);return n}c(Ei,"parseDirectives");function Mf(t,e){switch(D(e.content)){case"data":return Lf(t,e);case"action":return jf(t,e);case"template":return Nf(t,e);case"section":return qf(t,e);case"title":return Bf(t,e);case"table":return Yf(t,e);case"summary":return Ff(t,e);case"component":return Uf(t,e);case"toolbar":return Gf(t,e);case"navigate":return ki(t,e.content,e);case"on":return ze(t,e),{kind:"ScreenBehaviorSyntax",location:f(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:f(e)};default:if(Rf(t,e))return Kf(t,e);t.error(l.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,f(e)),t.skipBlock(e.indent);return}}c(Mf,"parseDirective");function Lf(t,e){let n=uf.exec(e.content);if(n===null){t.error(l.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,f(e));return}return{kind:"ScreenDataSyntax",type:Ie(n[1],f(e)),query:n[2],by:n[3]??null,location:f(e)}}c(Lf,"parseData");function jf(t,e){let n=mf.exec(e.content);if(n!==null)return Ea(t,e,pt(n,1),ki);let i=ff.exec(e.content);if(i===null){t.error(l.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,f(e)),t.skipBlock(e.indent);return}let r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=ks.exec(s.content);a!==null?r=pt(a,1):D(s.content)==="navigate"?o=ki(t,s.content,s)??null:t.error(l.UnknownActionDirective,`Unexpected '${s.content}' in action - expected 'label "..."' or 'navigate to ...'`,f(s))}return{kind:"ScreenActionSyntax",command:i[1],label:r,navigate:o,location:f(e)}}c(jf,"parseAction");function ki(t,e,n){let i=yf.exec(e);if(i===null){t.error(l.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,f(n));return}let r=[],o=null,s=null;for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let d=Es.exec(a.content);if(d!==null){r.push({kind:"ScreenNavigationParameterSyntax",name:d[1],binding:Xt(t,d[2],f(a)),location:f(a)});continue}let u=hf.exec(a.content);if(u!==null){o=pt(u,1);continue}let m=Sf.exec(a.content);if(m!==null){s=m[1];continue}t.error(l.InvalidNavigation,`Unexpected '${a.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,f(a))}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,route:o,...s===null?{}:{outlet:s},parameters:r,location:f(n)}}c(ki,"parseNavigate");function Nf(t,e){let n=e.content.substring(8).trim(),i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){if(t.reader.takeSignificant(),!Pf.test(r.content)){t.error(l.InvalidScreenLayoutSlot,`Expected a slot name in template '${n}', got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ScreenSlotSyntax",name:r.content,directives:Ei(t,r),location:f(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:f(e)}}c(Nf,"parseTemplateReference");function qf(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:Ei(t,e),location:f(e)}}c(qf,"parseSection");function Bf(t,e){let n=Af.exec(e.content);return n===null?(t.error(l.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,f(e)),{kind:"ScreenTitleSyntax",text:"",location:f(e)}):{kind:"ScreenTitleSyntax",text:pt(n,1),location:f(e)}}c(Bf,"parseTitle");function Yf(t,e){let n=e.content.substring(5).trim(),i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=If.exec(o.content),a=wf.exec(o.content);if(s!==null){let d=s[2]!==void 0||s[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:s[1],label:d?pt(s,2):null,location:f(o)})}else a!==null?r=ki(t,a[1],o)??null:D(o.content)==="on"?ze(t,o):Tf(o)?t.skipOpaqueBlock(o.indent):t.error(l.UnknownTableDirective,`Unexpected '${o.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,f(o))}return{kind:"ScreenTableSyntax",target:n,columns:i,rowClick:r,location:f(e)}}c(Yf,"parseTable");function Ff(t,e){let n=e.content.substring(7).trim(),i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Of.exec(r.content);if(o===null){t.error(l.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,f(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:pt(o,2),location:f(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:f(e)}}c(Ff,"parseSummary");function Uf(t,e){let n=xf.exec(e.content);if(n===null){t.error(l.UnknownScreenDirective,`Invalid component directive '${e.content}' - expected 'component <Package.Component> <name>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=null,s=[],a=[],d=[],u=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(m.content)){case"context":i=Wf(t,m);break;case"id":r=Vf(t,m);break;case"property":zf(t,m,s);break;case"icon":o=m.content.substring(4).trim();break;case"presentation":As(t,m,d);break;case"exposes":Qf(t,m,a);break;case"outlet":u.push({kind:"ComponentOutletSyntax",name:m.content.substring(6).trim(),directives:Ei(t,m),location:f(m)});break;case"on":ze(t,m);break;case"uses":t.skipOpaqueBlock(m.indent);break;default:t.error(l.UnknownScreenDirective,`Unexpected '${m.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,f(m)),t.skipBlock(m.indent);break}return{kind:"ScreenComponentSyntax",component:n[1],name:n[2],stableId:r,context:i,properties:s,exposes:a,presentation:d,icon:o,outlets:u,location:f(e)}}c(Uf,"parseComponent");function Wf(t,e){return Zf(t,e.content.substring(7).trim(),e)}c(Wf,"parseUiContext");function zf(t,e,n){let i=$f.exec(e.content);if(i!==null){n.push({kind:"ComponentPropertySyntax",property:i[1],binding:Xt(t,i[2],f(e)),value:null,location:f(e)});return}let r=bf.exec(e.content);if(r!==null){n.push({kind:"ComponentPropertySyntax",property:r[1],binding:null,value:ae(r[2],f(e),t),location:f(e)});return}t.error(l.UnknownScreenDirective,`Invalid component property '${e.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,f(e))}c(zf,"parseComponentProperty");function Vf(t,e){let n=vf.exec(e.content);return n===null?(t.error(l.UnknownScreenDirective,`Invalid component id '${e.content}' - expected 'id "stable-id"'`,f(e)),null):pt(n,1)}c(Vf,"parseStableId");function Qf(t,e,n){let i=kf.exec(e.content);if(i===null){t.error(l.UnknownScreenDirective,`Invalid exposed value '${e.content}' - expected 'exposes <name> from <binding>'`,f(e));return}n.push({kind:"ComponentExposedValueSyntax",name:i[1],binding:Xt(t,i[2],f(e)),location:f(e)})}c(Qf,"parseExposedValue");function As(t,e,n){let i=Ef.exec(e.content);if(i===null){t.error(l.UnknownScreenDirective,`Invalid presentation value '${e.content}' - expected 'presentation <key> "value"'`,f(e));return}n.push({kind:"PresentationValueSyntax",name:i[1],value:pt(i,2),location:f(e)})}c(As,"parsePresentationValue");function Gf(t,e){let n=e.content.substring(7).trim(),i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=_f(t,r);o!==void 0&&i.push(o)}return{kind:"ScreenToolbarSyntax",name:n,items:i,location:f(e)}}c(Gf,"parseToolbar");function _f(t,e){let n=Cf.exec(e.content);if(n===null){t.error(l.UnknownScreenDirective,`Invalid toolbar item '${e.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>' or 'item <name> dialog <DialogTemplate>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=[],s=[];for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent)){t.reader.takeSignificant();let u=ks.exec(d.content);if(u!==null){i=pt(u,1);continue}let m=Es.exec(d.content);if(m!==null){o.push({kind:"ScreenNavigationParameterSyntax",name:m[1],binding:Xt(t,m[2],f(d)),location:f(d)});continue}if(D(d.content)==="icon"){r=d.content.substring(4).trim();continue}As(t,d,s)}let a=n[2]==="navigate"?"Navigate":n[2]==="dialog"?"Dialog":"Action";return{kind:"ToolbarItemSyntax",name:n[1],syntaxKind:a,target:n[3],label:i,icon:r,parameters:o,presentation:s,location:f(e)}}c(_f,"parseToolbarItem");function Zf(t,e,n){return Xt(t,e,f(n))}c(Zf,"parseUiBindingValue");function Kf(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n)){t.error(l.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e));return}e.content.startsWith("```")||t.warning(l.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let i=Vt(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:f(e)},location:f(e)}}c(Kf,"parseCode");var Jf=w("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),Hf=new Set(["reducer"]);function Is(t,e){let n=Jf.exec(e.content),i="StateChange",r="";n===null?t.error(l.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,f(e)):(r=n[2],Za.includes(n[1])?i=n[1]:t.error(l.UnknownSliceType,`Unknown slice type '${n[1]}' - expected StateChange, StateView, Automation or Translate`,f(e)));let o=t.scope;t.scope=[...o,r];let s=null,a=!1,d=null,u=null,m=[],p=[],y=[],h=[],g=[],b=[],S=[],$=[],x=[],P=[],I=[],v=[],E=[],C=[];for(let A=t.peekChild(e.indent);A!==void 0;A=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ge(A))continue;let O=A.content.split(/[ \t]/,1)[0],T=O==="public"||O==="direction"?O:D(A.content);if(T==="description")d=G(t,A,d,`Slice '${r}'`);else if(T==="documentation")u=we(t,A,u,`Slice '${r}'`);else if(T==="purpose")Qt(t,A,I);else if(T==="operation")p.push(fi(t,A).operation);else if(T==="direction"){let M=/^direction\s+(inbound|outbound)$/.exec(A.content);a||i!=="Translate"||M===null?t.error(l.InvalidSliceDeclaration,"Declare direction inbound or direction outbound once, inside a Translate slice only",f(A)):s=M[1]==="inbound"?de.Inbound:de.Outbound,a=!0}else T==="event"||T==="public"?m.push(es(t,A)):T==="command"?y.push(us(t,A)):T==="query"?h.push(xs(t,A)):T==="projection"?g.push(Hr(t,A)):T==="capture"?S.push(Gr(t,A)):T==="runs"?Oe(t,A):T==="reaction"?b.push($s(t,A)):T==="constraint"?$.push(fs(t,A)):T==="example"?P.push(ct(t,A)):T==="specification"?x.push(Yr(t,A)):T==="readmodel"?v.push(ts(t,A)):T==="screen"?E.push(Cs(t,A)):Hf.has(T)?(C.push(ss(t,A)),t.skipOpaqueBlock(A.indent)):(t.warning(l.UnknownSliceDirective,`Unknown construct '${T}' in slice '${r}'`,f(A)),t.skipBlock(A.indent))}t.scope=o;let k={kind:"SliceSyntax",type:i,name:r,direction:s,description:d,documentation:u,examples:P,purposes:I,events:m,operations:p,commands:y,queries:h,projections:g,captures:S,reactions:b,constraints:$,specifications:x,readModels:v,screens:E,location:f(e)};return at.set(k,{reducers:C}),k}c(Is,"parseSlice");var Xf=w("^feature\\s+([A-Za-z_]\\w*)$"),em=new Set(["on","uses","contribute"]),io="description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'",wn=class{static{c(this,"FeatureBody")}name;#e=[];#t=[];#s=[];#i=[];#r=[];#o=[];#l=null;#a=null;#n=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"runs":return Oe(e,n),!0;case"description":return this.#l=G(e,n,this.#l,`Feature '${this.name}'`),!0;case"documentation":return this.#a=we(e,n,this.#a,`Feature '${this.name}'`),!0;case"depends":return li(e,n,this.#r,l.UnknownFeatureDirective),!0;case"purpose":return Qt(e,n,this.#o),!0;case"authorize":return this.#n=et(this.#n,xt(e,n)),!0;case"import":return Gt(e,n,this.#i),!0;case"feature":return this.#e.push(Ci(e,n)),!0;case"example":return this.#s.push(ct(e,n)),!0;case"slice":return this.#t.push(Is(e,n)),!0;default:return em.has(i)?(ze(e,n),!0):!1}}build(e,n=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#l,documentation:this.#a,authorize:this.#n,dependsOn:this.#r,purposes:this.#o,features:this.#e,slices:this.#t,examples:this.#s,fileImports:this.#i,isPlacement:n,location:e}}};function Ci(t,e){let n=Xf.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,f(e));let i=new wn(n),r=t.scope;t.scope=[...r,n];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),i.tryParse(t,o)||(t.error(l.UnknownFeatureDirective,`Unexpected '${D(o.content)}' in feature body - expected ${io}`,f(o)),t.skipBlock(o.indent));return t.scope=r,i.build(f(e))}c(Ci,"parseFeature");var ro=w("^module\\s+([A-Za-z_]\\w*)$"),tm=new Set(["on","uses","screen","dialog","form","contribute"]),oo="description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'",On=class{static{c(this,"ModuleBody")}name;#e=[];#t=[];#s=[];#i=[];#r=[];#o=null;#l=null;#a=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"runs":return Oe(e,n),!0;case"description":return this.#o=G(e,n,this.#o,`Module '${this.name}'`),!0;case"documentation":return this.#l=we(e,n,this.#l,`Module '${this.name}'`),!0;case"depends":return li(e,n,this.#i,l.UnknownModuleDirective),!0;case"purpose":return Qt(e,n,this.#r),!0;case"authorize":return this.#a=et(this.#a,xt(e,n)),!0;case"import":return Gt(e,n,this.#s),!0;case"example":return this.#t.push(ct(e,n)),!0;case"feature":return this.#e.push(Ci(e,n)),!0;default:return tm.has(i)?(ze(e,n),!0):!1}}parseChildren(e,n){for(let i=e.peekChild(n.indent);i!==void 0;i=e.peekChild(n.indent))e.reader.takeSignificant(),this.tryParse(e,i)||(e.error(l.UnknownModuleDirective,`Unexpected '${D(i.content)}' in module body - expected ${oo}`,f(i)),e.skipBlock(i.indent))}build(e,n=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#o,documentation:this.#l,authorize:this.#a,dependsOn:this.#i,purposes:this.#r,features:this.#e,examples:this.#t,fileImports:this.#s,isPlacement:n,location:e}}};function ao(t,e){let n=ro.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,f(e));let i=new On(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(f(e))}c(ao,"parseModule");var rm=new WeakMap,Ke=c(t=>JSON.stringify(t),"authoredOrderKey");function Tn(t){return rm.get(t)??new Map}c(Tn,"authoredOrderOf");var $t=["usesFactsFrom","reactsTo","decidesFrom","asks","shows","verifiedWith","outsideTheModel"];var ut=class extends Error{static{c(this,"InvalidDependencyQuery")}};var om={from:"usesFactsFrom",join:"usesFactsFrom",remove:"usesFactsFrom",removeViaJoin:"usesFactsFrom",clear:"usesFactsFrom",entersOn:"usesFactsFrom",reduces:"usesFactsFrom",uniqueEvent:"usesFactsFrom",uniqueProperty:"usesFactsFrom",concurrency:"usesFactsFrom",trigger:"reactsTo",reads:"decidesFrom",invokes:"asks",action:"asks",actionAlternative:"asks",actionOtherwise:"asks",formCommand:"asks",dataQuery:"shows",populate:"shows",navigate:"shows",whenRedeliveredEvent:"verifiedWith",redeliveryReaction:"verifiedWith",refusalConstraint:null,refusalProduces:null,specificationEvent:"verifiedWith",givenEvent:"verifiedWith",whenAppendedEvent:"verifiedWith",thenEvent:"verifiedWith",whenCommand:"verifiedWith",declares:null,uses:null,commandEventSource:null,commandStream:null,specificationEventSource:null,specificationStream:null,thenOperation:null,givenOperationFailure:null,thenCompensated:null,produces:null,authorizes:null,queryResult:null,dataReadModel:null,type:null,exampleType:null,contributes:null,template:null,specificationReadModel:null,thenAbsentReadModel:null,thenReadModel:null,givenReadModel:null,thenQuery:null,compositeKeyType:null,builds:null,buildsVariant:null,appends:null,seed:null};function Ai(t){let e=new Pi;return e.visitSlice(t),{references:e.references.sort((n,i)=>n.location.line-i.location.line||n.location.column-i.location.column),shared:e.shared}}c(Ai,"sliceReferences");function Ts(t,e){let n=new Pi(e);return t.projections.forEach(i=>n.visitProjection(i)),fe(t).reducers?.filter(i=>i.readModel.toLowerCase()===e.toLowerCase()).forEach(i=>n.visitReducer(i)),n.references}c(Ts,"buildingReadModelReferences");function co(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...co(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?co(e.blocks):[])}c(co,"variants");var Pi=class extends Ce{static{c(this,"SliceReferenceCollector")}readModel;references=[];shared=[];specification;projection=!1;constructor(e){super(),this.readModel=e}matches(e){return e.toLowerCase()===this.readModel?.toLowerCase()}visitSlice(e){super.visitSlice(e),fe(e).reducers?.forEach(i=>this.visitReducer(i))}visitCommand(e){let n=fe(e);n.reads?.forEach(i=>this.visitReads(i)),n.concurrency!=null&&this.visitConcurrency(n.concurrency),super.visitCommand(e)}visitReactionTrigger(e){let n=fe(e);n.data?.forEach(i=>this.visitTriggerData(i)),n.reads?.forEach(i=>this.visitReads(i)),super.visitReactionTrigger(e)}visitProjection(e){if(this.readModel!==void 0){let n=co(e.blocks);if(n.length===0?!this.matches(e.readModel??e.name):!n.some(i=>this.matches(i.name)))return}this.projection=!0,super.visitProjection(e),this.projection=!1}visitSpecification(e){this.specification=e,super.visitSpecification(e),this.specification=void 0}visitNode(e){let n=c((i,r,o)=>{this.references.push({name:i,targetKind:r,role:o,kind:om[o],location:e.location,timeline:this.projection||["trigger","reads","reduces"].includes(o)})},"add");switch(e.kind){case"TypeRefSyntax":{let i=e.name;["Uuid","String","Int","Decimal","Bool","Date","DateTime"].includes(i)||this.shared.push({kind:"type",name:i});break}case"PolicyReferenceSyntax":this.shared.push({kind:"policy",name:e.name});break;case"EventSpecSyntax":n(e.event,"Event","from");break;case"JoinEventSyntax":n(e.event,"Event","join");break;case"RemoveWithSyntax":n(e.event,"Event","remove");break;case"RemoveViaJoinSyntax":n(e.event,"Event","removeViaJoin");break;case"ClearWithSyntax":n(e.event,"Event","clear");break;case"ProjectionEntersOnSyntax":n(e.event,"Event","entersOn");break;case"ReducerRuleSyntax":n(e.event,"Event","reduces");break;case"UniqueEventConstraintSyntax":n(e.event,"Event","uniqueEvent");break;case"UniquePropertyConstraintSyntax":n(e.event,"Event","uniqueProperty");break;case"NamedTriggerSourceSyntax":n(e.name,"Event","trigger");break;case"ReadsSyntax":n(e.readModel,"ReadModel","reads");break;case"InvokesSyntax":n(e.command,"Command","invokes");break;case"ScreenActionSyntax":n(e.command,"Command","action");break;case"ScreenActionAlternativeSyntax":n(e.command,"Command","actionAlternative");break;case"ScreenActionOtherwiseSyntax":{let i=e.command;i!==null&&n(i,"Command","actionOtherwise");break}case"FormSyntax":n(e.for,"Command","formCommand");break;case"ScreenDataSyntax":n(e.query,"Query","dataQuery");break;case"FormPopulateViaQuerySyntax":n(e.query,"Query","populate");break;case"ScreenNavigateSyntax":n(e.screen,"Screen","navigate");break;case"SpecificationEventSyntax":n(e.eventType,"Event",this.specification?.given.includes(e)===!0?"givenEvent":this.specification?.whenAppended===e?"whenAppendedEvent":"thenEvent");break;case"SpecificationCommandSyntax":n(e.commandType,"Command","whenCommand");break;case"SpecificationRedeliverySyntax":{let i=e;n(i.eventType,"Event","whenRedeliveredEvent"),n(i.reaction,"Reaction","redeliveryReaction");break}case"ConcurrencySyntax":e.eventTypes.forEach(i=>n(i,"Event","concurrency"));break}}};function Rn(t){let e=new Map,n=new Map,i=[],r=new Set,o=[],s=c(a=>{e.set(a,e.size),n.set(a,e.get(a)),i.push(a),r.add(a);for(let m of[...t.get(a)].sort())e.has(m)?r.has(m)&&n.set(a,Math.min(n.get(a),e.get(m))):(s(m),n.set(a,Math.min(n.get(a),n.get(m))));if(n.get(a)!==e.get(a))return;let d=[],u;do u=i.pop(),r.delete(u),d.push(u);while(u!==a);o.push(d.sort())},"visit");for(let a of[...t.keys()].sort())e.has(a)||s(a);return o}c(Rn,"stronglyConnectedGroups");var Rs=["usesFactsFrom","reactsTo","decidesFrom"],it=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),po=c((t,e)=>JSON.stringify([t,e.toLowerCase()]),"declarationKey"),uo=c((t,e,n,i)=>({kind:t,address:e,scope:n,rank:i,key:`${t}:${e}`}),"nodeOf"),mo=c((t,e)=>t.rank-e.rank||it(t.key,e.key),"compareNodes"),Dn=c(t=>[...new Map([...t].map(e=>[e.key,e])).values()].sort(mo),"distinctNodes"),Ds=c((t,e)=>t.consumer.rank-e.consumer.rank||t.location.line-e.location.line||t.location.column-e.location.column||$t.indexOf(t.kind)-$t.indexOf(e.kind)||t.producer.rank-e.producer.rank||it(t.location.path??"",e.location.path??"")||it(t.role,e.role)||it(t.name,e.name),"compareEvidence");function yo(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...yo(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?yo(e.blocks):[])}c(yo,"variants");var en=class t{static{c(this,"DependencyGraph")}orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=new Map;byKey=new Map;parents=new Map;root=uo("application","",[],-1);static for(e,n=Tn(e)){return new t(e,n)}get nodes(){return this.modelNodes}constructor(e,n){e=_e(e),this.orderSource=n.size>0?"authored":"syntax",this.children.set(this.root.key,[]);let i=c((x,P)=>x.map((I,v)=>({syntax:I,index:v,rank:n.get(Ke([...P.scope,I.name]))??Number.MAX_SAFE_INTEGER})).sort((I,v)=>I.rank-v.rank||I.index-v.index).map(I=>I.syntax),"ordered"),r=c((x,P)=>{let I=this.add("feature",x.name,P);for(let v of i(x.slices,I))this.slices.push({node:this.add("slice",v.name,I),syntax:v});for(let v of i(x.features,I))r(v,I)},"feature");for(let x of i(e.modules,this.root)){let P=this.add("module",x.name,this.root);for(let I of i(x.features,P))r(I,P)}let o=new Map,s=new Map,a=c((x,P,I,v)=>{let E=po(P,I);x.has(E)||x.set(E,[]);let C=x.get(E);C.includes(v)||C.push(v);let k=po(P,[...v.scope,I].join("."));x.has(k)||x.set(k,[]);let A=x.get(k);A.includes(v)||A.push(v)},"declare");for(let{node:x,syntax:P}of this.slices){for(let I of le(P))a(o,"Event",I.name,x);for(let I of P.commands)a(o,"Command",I.name,x);for(let I of P.reactions)a(o,"Reaction",I.name,x);for(let I of P.queries)a(o,"Query",I.name,x);for(let I of P.screens)a(o,"Screen",I.name,x);for(let I of P.readModels)a(o,"ReadModel",I.name,x);for(let I of P.projections){let v=yo(I.blocks);v.length===0&&a(s,"ReadModel",I.readModel??I.name,x);for(let E of v)a(s,"ReadModel",E.name,x)}for(let I of fe(P).reducers??[])a(s,"ReadModel",I.readModel,x)}let d=new Set((e.declaredTriggers??[]).map(x=>x.name.toLowerCase())),u=new Set([...e.concepts,...e.types].map(x=>x.name.toLowerCase())),m=new Set((e.policies??[]).map(x=>x.name.toLowerCase())),p=e.imports.filter(x=>x.qualifiedName.includes(".")).slice().sort((x,P)=>it(x.location.path??"",P.location.path??"")||x.location.line-P.location.line||x.location.column-P.location.column||it(x.qualifiedName,P.qualifiedName)),y=new Map,h=[],g=[],b=new Set,S=0;for(let{node:x,syntax:P}of this.slices){let I=Ai(P);S+=I.shared.filter(v=>(v.kind==="type"?u:m).has(v.name.toLowerCase())).length;for(let v of I.references){let E=po(v.targetKind,v.name),k=(v.targetKind==="ReadModel"&&s.has(E)?s:o).get(E);if(k!==void 0&&k.length>0){let O=k[0];O!==x&&h.push({consumer:x,producer:O,kind:v.kind,role:v.role,name:v.name,ambiguous:k.length>1,alternatives:k.slice(1),location:v.location,testOnly:v.kind==="verifiedWith"});continue}let A=v.targetKind==="Event"?p.filter(O=>O.qualifiedName.slice(O.qualifiedName.lastIndexOf(".")+1).toLowerCase()===v.name.toLowerCase()):[];if(A.length>0){let O=[];for(let T of A){b.add(T.qualifiedName);let M=T.qualifiedName.slice(0,T.qualifiedName.lastIndexOf(".")),N=`context:${M}`;if(!y.has(N)){let q=uo("context",N,[M],this.modelNodes.length);this.modelNodes.push(q),y.set(N,q)}let j=y.get(N);O.includes(j)||O.push(j)}h.push({consumer:x,producer:O[0],kind:"outsideTheModel",role:v.role,name:v.name,ambiguous:O.length>1,alternatives:O.slice(1),location:v.location,testOnly:v.kind==="verifiedWith"});continue}if(v.role==="trigger"&&d.has(v.name.toLowerCase())){S++;continue}g.push({consumer:x,kind:v.kind,role:v.role,name:v.name,location:v.location})}}let $=new Map;for(let x of h.sort(Ds)){let P=JSON.stringify([x.consumer.key,x.producer.key,x.kind]);$.has(P)||$.set(P,[]),$.get(P).push(x)}this.edges=[...$.values()].map(x=>({consumer:x[0].consumer,producer:x[0].producer,kind:x[0].kind,evidence:x})),this.unresolved=g.sort((x,P)=>x.consumer.rank-P.consumer.rank||x.location.line-P.location.line||x.location.column-P.location.column||$t.indexOf(x.kind)-$t.indexOf(P.kind)||it(x.location.path??"",P.location.path??"")||it(x.name,P.name)),this.excludedReferences=S,this.unusedImports=[...new Set(p.filter(x=>!b.has(x.qualifiedName)).map(x=>x.qualifiedName))]}implied(e,n,i,r=!1,o=3){if(!["slice","feature","module"].includes(e))throw new ut(`Unsupported source level '${e}'.`);if(!["slice","feature","module","context"].includes(n))throw new ut(`Unsupported target level '${n}'.`);if(o<0)throw new ut("Evidence limit must not be negative.");let s=new Map;for(let a of this.evidence(i,r))for(let d of this.at(a.consumer,e))for(let u of this.at(a.producer,n).filter(m=>this.disjoint(d,m))){let m=JSON.stringify([d.key,u.key]);s.has(m)||s.set(m,{source:d,target:u,evidence:[]}),s.get(m).evidence.push(a)}return[...s.values()].sort((a,d)=>a.source.rank-d.source.rank||a.target.rank-d.target.rank||it(a.source.key,d.source.key)||it(a.target.key,d.target.key)).map(a=>{let d=a.evidence.sort(Ds),u={};for(let m of $t){let p=d.filter(y=>y.kind===m).length;p>0&&(u[m]=p)}return{source:a.source,target:a.target,sliceEdges:new Set(d.map(m=>JSON.stringify([m.consumer.key,m.producer.key]))).size,references:d.length,byKind:u,consumers:Dn(d.map(m=>m.consumer)),producers:Dn(d.map(m=>m.producer)),evidence:d.slice(0,o),evidenceCount:d.length,evidenceTruncated:d.length>o}})}cycles(e,n){if(!["slice","feature","module"].includes(e))throw new ut(`Unsupported cycle level '${e}'.`);let i=this.implied(e,e,Ms(n)),r=Dn(i.flatMap(o=>[o.source,o.target]));return Ls(fo(r,i),r,null)}siblingGroups(e){let n=this.siblingEdges(e);return this.containers().flatMap(i=>{let r=this.children.get(i.key);return Ls(fo(r,n.filter(o=>o.container===i)),r,i)})}suggestedOrder(e){let n=this.siblingEdges(e),i=[];for(let a of this.containers()){let d=this.children.get(a.key),u=n.filter(S=>S.container===a),m=new Map(d.map(S=>[S.key,S])),p=Rn(fo(d,u)).map(S=>S.map($=>m.get($)).sort(mo)).sort((S,$)=>S[0].rank-$[0].rank),y=new Map(p.flatMap((S,$)=>S.map(x=>[x.key,$]))),h=new Map(d.map(S=>[S.key,new Set]));for(let S of u)y.get(S.source.key)!==y.get(S.target.key)&&h.get(S.source.key).add(S.target.key);for(let S of p)for(let $=1;$<S.length;$++)h.get(S[$].key).add(S[$-1].key);let g=new Set(d.map(S=>S.key)),b=[];for(;g.size>0;){let S=[...g].filter($=>h.get($).size===0).sort(($,x)=>mo(m.get($),m.get(x)))[0];b.push(m.get(S)),g.delete(S);for(let $ of g)h.get($).delete(S)}i.push({container:a,children:b,changed:d.some((S,$)=>S!==b[$])})}let r=new Map(i.map(a=>[a.container.key,a.children])),o=[],s=c(a=>{if(a.kind==="slice")o.push(a);else for(let d of[...r.get(a.key)].sort((u,m)=>+(u.kind!=="slice")-+(m.kind!=="slice")))s(d)},"walk");return s(this.root),{containers:i,slices:o}}traverse(e,n,i,r=!1){if(n!=="incoming"&&n!=="outgoing")throw new ut(`Unsupported dependency direction '${n}'.`);let o=this.evidence(i,r).map(u=>n==="incoming"?{source:u.producer,target:u.consumer}:{source:u.consumer,target:u.producer}),s=new Set([e]),a=[e],d=[];for(let u=0;u<a.length;u++)for(let m of o.filter(p=>p.source.address===a[u]).sort((p,y)=>p.target.rank-y.target.rank))s.has(m.target.address)||(s.add(m.target.address),d.push(m.target),a.push(m.target.address));return Dn(d)}add(e,n,i){let r=[...i.scope,n],o=r.join("."),s=`${e}:${o}`,a=this.byKey.get(s);if(a!==void 0)return a;let d=uo(e,o,r,this.modelNodes.length);return this.modelNodes.push(d),this.byKey.set(s,d),this.parents.set(s,i),this.children.get(i.key).push(d),e!=="slice"&&this.children.set(s,[]),d}ancestors(e){let n=[];for(let i=this.parents.get(e.key);i!==void 0;i=this.parents.get(i.key))n.push(i);return n}disjoint(e,n){return e.key!==n.key&&!this.ancestors(e).includes(n)&&!this.ancestors(n).includes(e)}at(e,n){return[e,...this.ancestors(e)].filter(i=>i.kind===n)}containers(){return[this.root,...this.modelNodes.filter(e=>e.kind==="module"||e.kind==="feature")]}evidence(e,n){let i=js(e);return this.edges.flatMap(r=>r.evidence).filter(r=>i.has(r.kind)&&(n||!r.testOnly))}path(e){return[...this.ancestors(e).reverse(),e].filter(n=>n!==this.root)}siblingEdges(e){let n=[];for(let i of this.evidence(Ms(e),!1)){let r=this.path(i.consumer),o=this.path(i.producer),s=0;for(;s<r.length&&s<o.length&&r[s].key===o[s].key;)s++;s===r.length||s===o.length||n.push({container:s===0?this.root:r[s-1],source:r[s],target:o[s]})}return n}};function js(t){let e=new Set(t??$t);if([...e].some(n=>!$t.includes(n)))throw new ut("Unsupported dependency kind.");return e}c(js,"selectedKinds");function Ms(t){return[...js(t??Rs)].filter(e=>Rs.includes(e))}c(Ms,"selectedOrderingKinds");function fo(t,e){let n=new Map(t.map(i=>[i.key,new Set]));for(let i of e)n.get(i.source.key).add(i.target.key);return n}c(fo,"adjacency");function Ls(t,e,n){let i=new Map(e.map(r=>[r.key,r]));return Rn(t).filter(r=>r.length>1).map(r=>({container:n,members:Dn(r.map(o=>i.get(o)))})).sort((r,o)=>r.members[0].rank-o.members[0].rank)}c(Ls,"groupsOf");var am=["usesFactsFrom","reactsTo","decidesFrom","asks","shows"],rt=c((t,e)=>e===t||e.startsWith(t+"."),"contains"),tn=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),sm=c((t,e)=>tn(t.location.path??"",e.location.path??"")||t.location.line-e.location.line||t.location.column-e.location.column||tn(t.kind,e.kind)||tn(t.consumer.address,e.consumer.address)||tn(t.producer.address,e.producer.address)||tn(t.role,e.role)||tn(t.name,e.name),"orderedEvidence"),nn=class{static{c(this,"DeclaredDependencies")}static for(e){let n=new Map,i=c((p,y)=>{let h=p.join(".");n.has(h)||n.set(h,{location:y.location,dependencies:[]}),n.get(h).dependencies.push(...y.dependsOn??[]),y.features.forEach(g=>i([...p,g.name],g))},"inventory");if(e.modules.forEach(p=>i([p.name],p)),![...n.values()].some(p=>p.dependencies.length))return{containers:[],diagnostics:[]};let r=en.for(e,new Map),o=r.nodes.filter(p=>p.kind==="module"||p.kind==="feature"),s=Ne.containersOf(e),a=c((p,y)=>{let h=Ne.resolve(p,y,s).resolved;return h&&[...h.scope,h.name].join(".")},"resolve"),d=[],u=[],m=c((p,y,h,g)=>u.push({code:p,severity:y,message:h,location:g}),"finding");for(let p of o.filter(y=>n.get(y.address).dependencies.length)){let y=n.get(p.address),h=y.dependencies.map(S=>{let $=a(S.target,p.scope),x=$!==void 0&&!rt(p.address,$)&&!rt($,p.address);return{syntax:S,resolved:$,status:x?"unused":"invalid"}}),g=[],b=new Map;for(let S of r.edges.flatMap($=>$.evidence).filter($=>am.includes($.kind)&&rt(p.address,$.consumer.address)).sort(sm)){let $=[S.producer,...S.alternatives].filter(I=>!rt(p.address,I.address)&&!rt(I.scope.slice(0,-1).join("."),p.address));if(!$.length)continue;let x=h.filter(I=>I.status!=="invalid"&&$.some(v=>rt(I.resolved,v.address)));for(let I of x)I.status=S.ambiguous&&I.status!=="used"?"provisional":"used";let P=S.ambiguous?"provisional":x.length?"declared":"undeclared";if(g.push({evidence:S,status:P,coveringDeclarations:x.map(I=>I.syntax)}),P==="undeclared"){let I=S.producer.scope[0];b.has(I)||b.set(I,[]),b.get(I).push(S)}}for(let S of b.values()){let $=S[0].producer.scope.slice(0,-1),x=$.findIndex((E,C)=>S.some(k=>C>=k.producer.scope.length-1||k.producer.scope[C]!==E));x>=0&&($=$.slice(0,x));let P=$.join("."),I=rt(p.address,P)||rt(P,p.address)?[...new Set(S.map(E=>E.producer.scope.slice(0,-1).map((C,k)=>E.producer.scope.slice(0,k+1).join(".")).find(C=>!rt(p.address,C)&&!rt(C,p.address))))]:[P],v=S.map(E=>`${E.kind} ${E.role} '${E.name}' at ${E.location.path??""}:${E.location.line}:${E.location.column}`).join("; ");m(l.UndeclaredDependency,"warning",`Container '${p.address}' depends on '${I.join("', '")}' without declaring ${I.length===1?"it":"them"} - evidence: ${v}`,y.location)}for(let S of h)S.status==="unused"&&m(l.UnusedDependencyDeclaration,"information",`Dependency '${S.syntax.target}' on '${p.address}' is not used by any counted explicit reference`,S.syntax.location),S.status!=="invalid"&&n.get(S.resolved).dependencies.some($=>a($.target,S.resolved.split("."))===p.address)&&m(l.MutualDependencyDeclarations,"information",`Containers '${p.address}' and '${S.resolved}' declare each other`,S.syntax.location);d.push({container:p,location:y.location,declarations:h,edges:g})}return{containers:d,diagnostics:u}}static validate(e,n){for(let i of this.for(e).diagnostics)n[i.severity==="warning"?"warning":"information"](i.code,i.message,i.location)}};var Ii=class extends Ce{static{c(this,"PublicEventUsageCollector")}command=!1;uses=[];allEvents=[];projectionTargets=[];eventSources=[];visitProjection(e){e.readModel!=null&&this.projectionTargets.push({target:e.readModel,node:e}),super.visitProjection(e)}visitReducer(e){this.projectionTargets.push({target:e.readModel,node:e}),super.visitReducer(e)}visitCaptureSource(e){En(e)&&(this.eventSources.push(e),Ka(e).forEach(n=>this.uses.push({name:n.value,node:n,output:!1,command:!1}))),super.visitCaptureSource(e)}visitSlice(e){super.visitSlice(e),fe(e).reducers?.forEach(n=>this.visitReducer(n))}visitCommand(e){this.command=!0,super.visitCommand(e),this.command=!1}visitProduces(e){e.inlineOperation==null&&this.uses.push({name:e.event,node:e,output:!0,command:this.command})}visitCaptureAppend(e){this.inputOrOutput(e.event,e,!0)}visitJoinEvent(e){this.inputOrOutput(e.event,e)}visitReducerRule(e){this.inputOrOutput(e.event,e)}visitConstraint(e){e.releasedBy.forEach(n=>this.inputOrOutput(n,e)),e.kind!=="FileConstraintSyntax"&&this.inputOrOutput(e.event,e),super.visitConstraint(e)}visitProjectionBlock(e){switch(e.kind){case"FromSyntax":e.events.forEach(n=>this.inputOrOutput(n.event,n));break;case"ClearWithSyntax":case"RemoveWithSyntax":case"RemoveViaJoinSyntax":this.inputOrOutput(e.event,e);break;case"AllSyntax":this.allEvents.push(e);break}super.visitProjectionBlock(e)}visitReactionTrigger(e){e.source.kind==="NamedTriggerSourceSyntax"&&this.inputOrOutput(e.source.name,e.source),super.visitReactionTrigger(e)}visitSpecification(e){}inputOrOutput(e,n,i=!1){this.uses.push({name:e,node:n,output:i,command:!1})}};var ho=class extends Ce{static{c(this,"PublicEventMetadataValidator")}context;constructor(e){super(),this.context=e}visitNode(e){let n=hi(e);if(n===void 0)return;let i=e.kind==="EventSyntax"?l.InvalidEventDeclaration:e.kind==="ImportSyntax"?l.InvalidImportDeclaration:l.InvalidSliceDeclaration;this.context.error(i,n,e.location)}};function Ns(t,e){new ho(e).visitApplication(t)}c(Ns,"validatePublicEventMetadata");function wi(t,e){Ns(t,e);let n=new ie(t);if(!n.declarations.some(r=>r.node.kind==="EventSyntax"&&(r.node.visibility===se.Public||r.node.origin!=null))&&!t.imports.some(r=>r.visibility===se.Public||r.origin!=null)&&!n.slices.some(({slice:r})=>r.direction!=null||cm(r)||dm(r,n)))return;let i=new ie(t,n.declarations.filter(r=>r.kind===H.Event));for(let{slice:r,scope:o}of n.slices)lm(t,r,o,n,i,e);for(let r of t.seeds?.flatMap(o=>o.groups.flatMap(s=>s.events))??[]){let o=go(t,i,[],r.event,r,!0,e);if(o?.visibility!==se.Public)continue;let s=o.origin==null?l.PublicEventRequiresOutboundTranslation:l.ForeignPublicEventProduced;e.error(s,`Seed cannot append public event '${r.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`,r.location)}}c(wi,"validatePublicEventUsage");function lm(t,e,n,i,r,o){let s=new Ii;s.visitSlice(e);let a=[],d=e.type==="Translate"&&e.direction===de.Outbound,u=new Set(e.readModels.map(p=>p.name));for(let{target:p,node:y}of s.projectionTargets){let h=u.has(p)?void 0:go(t,r,n,p,y,!1,o);if(h!==void 0){if(!d){o.error(l.EventTargetOutsideOutboundTranslation,`'${p}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`,y.location);continue}a.push({node:h,output:!0}),So(e,p,y,!0,!1,h,o)}}if(!(e.type==="Translate"&&e.direction===de.Inbound)&&!d)for(let p of s.eventSources)o.error(l.EventsSourceOutsideInboundTranslation,`'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${e.name}'.`,p.location);for(let p of s.uses){let y=go(t,p.node.kind==="ProducesSyntax"?i:r,n,p.name,p.node,p.output,o);y!==void 0&&(a.push({node:y,output:p.output}),So(e,p.name,p.node,p.output,p.command,y,o))}for(let p of s.allEvents){let y=i.declarations.filter(h=>h.kind===H.Event).map(h=>h.node);for(let h of[...y,...t.imports.filter(g=>g.visibility===se.Public)])a.push({node:h,output:!1}),So(e,h.kind==="ImportSyntax"?h.qualifiedName:h.name,p,!1,!1,h,o)}if(e.type!=="Translate"||(e.direction==null&&(le(e).some(p=>p.visibility===se.Public)||a.some(p=>p.node.visibility===se.Public))&&o.error(l.PublicTranslationRequiresDirection,"A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.",e.location),e.direction!==de.Outbound))return;let m=new Set(a.filter(p=>p.output&&p.node.visibility===se.Public&&p.node.origin==null).map(p=>p.node)).size;m!==1&&o.error(l.OutboundPublicEventCount,`Outbound Translate slice '${e.name}' must produce exactly one local public event type; found ${m}.`,e.location);for(let p of e.captures)o.error(l.TranslationConstructDirection,"An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.",p.location)}c(lm,"validateSlice");function So(t,e,n,i,r,o,s){let a=o.origin!=null,d=o.visibility===se.Public,u=c((m,p)=>s.error(m,p,n.location),"error");i?(r&&d&&u(l.CommandProducesPublicEvent,`Command cannot produce public event '${e}'; publish through an outbound Translate slice.`),t.type==="Translate"&&t.direction===de.Outbound&&!d&&u(l.OutboundTranslationOutput,`Outbound translation must produce its one local public event, not private event '${e}'.`),a&&u(l.ForeignPublicEventProduced,`Foreign public event '${e}' cannot be produced locally; translate it into a private local event.`),d&&!a&&(t.type!=="Translate"||t.direction!==de.Outbound)&&u(l.PublicEventRequiresOutboundTranslation,`Local public event '${e}' may only be produced by an explicitly outbound Translate slice.`),t.type==="Translate"&&(t.direction??de.Inbound)===de.Inbound&&(d||a)&&u(l.InboundTranslationOutput,`Inbound translation must produce private local events, not '${e}'.`)):(a&&(t.type!=="Translate"||t.direction!==de.Inbound)&&u(l.ForeignPublicEventConsumer,`Foreign public event '${e}' may only be consumed by an explicitly inbound Translate slice.`),t.type==="Translate"&&t.direction===de.Outbound&&(d||a)&&u(l.OutboundTranslationInput,`Outbound translation must consume private local events, not '${e}'.`),t.type==="Translate"&&t.direction===de.Inbound&&(!d||!a)&&u(l.InboundTranslationInput,`Explicitly inbound translation must consume foreign public events, not '${e}'.`))}c(So,"validateUse");function go(t,e,n,i,r,o,s){let a=e.resolveFromScope(i,n);if(a.declaration?.node.kind==="EventSyntax")return a.declaration.node;if(a.kind===H.Operation)return;if(a.kind===H.Ambiguous){s.warning(l.AmbiguousReference,`Ambiguous event reference '${i}'; qualify it with its owning module, feature and slice.`,r.location);return}let d=t.imports.filter(u=>u.qualifiedName.split(".").at(-1)===i||u.qualifiedName===i);if(d.length===1){let u=d[0],m=e.resolveFromScope(u.qualifiedName,n);if(m.declaration?.node.kind==="EventSyntax")return m.declaration.node;if(m.kind===H.Ambiguous){s.warning(l.AmbiguousReference,`Ambiguous imported event reference '${i}'; qualify its declaration.`,r.location);return}return u.visibility===se.Public?u:void 0}d.length>1?s.warning(l.AmbiguousReference,`Ambiguous imported event reference '${i}'; use its qualified name.`,r.location):(o&&r.kind!=="CaptureAppendSyntax"||r.kind==="CaptureSourceSettingSyntax")&&!s.diagnostics.some(u=>u.code===l.UnknownEvent&&u.location.path===r.location.path&&u.location.line===r.location.line&&u.location.column===r.location.column)&&s.warning(l.UnknownEvent,`Unknown event '${i}' - declare its contract before classifying its usage.`,r.location)}c(go,"resolve");function cm(t){return t.captures.some(e=>e.source!=null&&En(e.source))}c(cm,"usesEventSource");function dm(t,e){return[...t.projections.map(i=>i.readModel),...(fe(t).reducers??[]).map(i=>i.readModel)].some(i=>i!=null&&e.declarations.some(r=>r.kind===H.Event&&r.name===i))}c(dm,"targetsEvent");function Oi(t,e,n,i=!1){let r=[],o=[],s=We,a=!1,d=!1,u=!1,m=new Map,p=new ye(new qe([]),e,n).languages;for(let h of t){let g=h;if(g.number===1&&g.raw.startsWith("\uFEFF")){let b=g.raw.substring(1),S=b.length-b.trimStart().length,$=fn(b.substring(S),i);g={...g,indent:S,contentOffset:1,content:($<0?b.substring(S):b.substring(S,S+$)).trimEnd()}}if(u){Lr(g)&&(u=!1),r.push(g);continue}if(g.content.startsWith("```")&&(["```","```text","```markdown"].includes(g.content)||p.has(g.content.substring(3)))&&(u=!0),!u&&g.indent===0&&D(g.content)==="numbers"){let b=g.content!=="numbers exact"?l.InvalidNumericDirective:a?l.DuplicateNumericDirective:d?l.LateNumericDirective:void 0;b!==void 0?(o.push({severity:"error",code:b,message:"Expected one 'numbers exact' preamble before domain, imports and declarations.",location:f(g)}),s=Object.freeze({numericMode:"invalid"})):s=ci,a=!0,r.push({...g,content:""});continue}!u&&g.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(g.content)&&m.set(g.number,{severity:"error",code:l.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:f(g)}),d||=g.content.trim().length>0,r.push(g)}let y=new ye(new qe(a?r:t),e,n);return y.sourceOptions=s,y.nestedNumericDirectives=m,o.forEach(h=>y.error(h.code,h.message,h.location)),y}c(Oi,"sourceContext");function Ti(t,e){let n=[],i=c(a=>{n.push(...a.slices),a.features.forEach(i)},"inFeature");t.modules.forEach(a=>a.features.forEach(i));let r=new Map;for(let a of n.flatMap(le))r.set(a.name,(r.get(a.name)??0)+1);let o=new Set(t.imports.map(a=>a.qualifiedName.split(".").at(-1))),s=new ie(t);for(let{slice:a,command:d}of n.flatMap(u=>u.commands.map(m=>({slice:u,command:m})))){let u=d.produces.filter(y=>s.isEventProduction(y,a)),m=d.properties.find(y=>y.isIdentifier)?.name,p=$r(d,{resolver:s,slice:a});for(let y of u){let h=y.inlineEvent;h!==null&&((r.get(h.name)??0)>1||o.has(h.name))&&e.error(l.InlineEventCollision,`Inline event '${h.name}' collides with another event declaration or import`,y.location),p&&y.for===null&&e.error(l.ExplicitProducesTargetsRequired,`Production '${y.event}' in command '${d.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,y.location);let g=y.for?.kind==="PathExpressionSyntax"?y.for.path:y.for===null&&h!==null?m:void 0;if(!(m===void 0||g!==m))for(let b of y.mappings.filter(S=>S.source.kind==="PathExpressionSyntax"&&S.source.path===m)){let S=`Event '${y.event}' copies command identifier '${m}' into payload property '${b.property}' although it already identifies the event source`;h===null?e.information(l.EventSourceIdInPayload,S,b.location):e.warning(l.EventSourceIdInPayload,S,b.location)}}}}c(Ti,"validateInlineEvents");function Ri(t,e){let n=new ie(t),i=Jn(t),r=oe(t.concepts),o=new Map([...oe(t.types)].map(([x,P])=>[x,oe(P.properties)])),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),a=new Set(t.imports.map(x=>x.qualifiedName.split(".").at(-1))),d=new Map;for(let x of t.imports){let P=x.qualifiedName.split(".").at(-1);d.set(P,[...d.get(P)??[],x.qualifiedName])}let u=c(x=>{let P=new Map,I=new Map;for(let v of x){let E=P.get(v.name)??[];E.push(v),P.set(v.name,E)}return(v,E)=>{let C=JSON.stringify([v,E]);if(I.has(C))return I.get(C);let k=c(M=>{let N=M.split("."),j=P.get(N.at(-1))??[],q=N.slice(0,-1);if(q.length>0)return j.filter(Q=>q.length<=Q.scope.length&&q.every((K,J)=>Q.scope[Q.scope.length-q.length+J]===K));for(let Q=E.length;Q>=0;Q--){let K=j.filter(J=>Q<=J.scope.length&&E.slice(0,Q).every((W,_)=>J.scope[_]===W));if(K.length>0)return K}return[]},"candidates"),A=k(v),O=d.get(v)??[];A.length===0&&O.length===1&&(A=k(O[0]));let T=A.length===1?A[0].node:null;return I.set(C,T),T}},"scoped"),m=u(n.slices.flatMap(({slice:x,scope:P})=>x.readModels.map(I=>({name:I.name,scope:P,node:I})))),p=u(n.slices.flatMap(({slice:x,scope:P})=>x.commands.map(I=>({name:I.name,scope:P,node:{command:I,slice:x}})))),y=new Map;for(let x of t.systems??[])y.has(x.name)&&e.error(l.InvalidSystemDeclaration,`System '${x.name}' is declared more than once.`,x.location),y.set(x.name,(y.get(x.name)??0)+1);let h=c((x,P,I=!0)=>{let[v,...E]=P.split("."),C=x.filter(T=>T.name===v);if(C.length!==1)return{type:null,missing:C.length===0};let k=C[0].type;if(E.length===0)return{type:k,missing:!1};let A=o.get(k.name);if(A===void 0)return{type:null,missing:s.has(k.name)};let O=h([...A.values()],E.join("."),I);return O.type===null?O:{type:{...O.type,isOptional:I&&k.isOptional||O.type.isOptional,isCollection:k.isCollection||O.type.isCollection},missing:!1}},"pathType"),g=c((x,P,I,v,E=new Set)=>{if(I.has(P)||x.isOptional&&!v.has(P))return!0;if(x.isCollection||E.has(x.name))return!1;let C=o.get(x.name);return C===void 0?v.has(P)&&!s.has(x.name):[...C.values()].every(k=>g(k.type,`${P}.${k.name}`,I,v,new Set([...E,x.name])))},"covered"),b=c((x,P)=>{if(x.kind==="ListExpressionSyntax"&&P.isCollection)return x.items.every(v=>b(v,{...P,isCollection:!1,isOptional:!1}));let I=o.get(P.name);return x.kind!=="ObjectExpressionSyntax"||I===void 0?!0:[...I.values()].every(v=>(v.type.isOptional||x.members.some(E=>E.name===v.name))&&x.members.filter(E=>E.name===v.name).every(E=>b(E.value,v.type)))},"completeValue"),S=c(x=>x.kind==="LiteralExpressionSyntax"?typeof x.value!="number"||Number.isFinite(x.value):x.kind==="ObjectExpressionSyntax"?x.members.every(P=>S(P.value)):x.kind==="ListExpressionSyntax"&&x.items.every(S),"concrete"),$=c((x,P,I,v,E)=>{let C=new Set,k=new Set(x.map(O=>O.property)),A=new Set;for(let O of x){let T=O.property.split(".");for(let M=1;M<=T.length;M++)A.add(T.slice(0,M).join("."))}for(let O of x){C.has(O.property)&&e.error(l.InvalidOperationMapping,`Duplicate operation input mapping '${O.property}'.`,O.location),C.add(O.property);let T=h(P.inputs,O.property,!1);if(T.missing&&e.error(l.InvalidOperationMapping,`Operation '${P.name}' declares no input '${O.property}'.`,O.location),T.type===null)continue;let M=O.property.split(".");for(let N=1;N<M.length;N++)k.has(M.slice(0,N).join("."))&&e.error(l.InvalidOperationMapping,`Operation input mapping '${O.property}' overlaps a whole input mapping.`,O.location);if(I!==null&&O.source.kind==="PathExpressionSyntax"){let N=h(I.properties,O.source.path),j=O.source.path.split("."),q=(xi.get(I)??[]).filter(J=>(J.alias??J.readModel)===j[0]);if(N.missing&&q.length>0){N={type:null,missing:!1};let J=q.length===1?m(q[0].readModel,E):null;j.length>1&&J!==null&&(N=h(J.properties,j.slice(1).join(".")))}N.missing&&e.error(l.InvalidOperationMapping,`Command '${I.name}' declares no source '${O.source.path}'.`,O.source.location);let Q=N.type,K=T.type;Q!==null&&s.has(Q.name)&&s.has(K.name)&&(Q.name!==K.name||Q.isCollection!==K.isCollection||Q.isOptional&&!K.isOptional)&&e.error(l.InvalidOperationMapping,`Source '${O.source.path}' is incompatible with input '${O.property}' of operation '${P.name}'.`,O.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(O.source.kind)&&(!Pe(O.source,T.type,r,o)||v&&!b(O.source,T.type))&&e.error(l.InvalidOperationMapping,`Value is incompatible with input '${O.property}' of operation '${P.name}'.`,O.source.location)}if(v)for(let O of P.inputs)g(O.type,O.name,C,A)||e.error(l.InvalidOperationMapping,`Production of operation '${P.name}' supplies no value for required input '${O.name}'.`,P.location)},"validateMappings");for(let{slice:x,scope:P}of n.slices){let I=Vn(x),v=new Set(le(x).map(E=>E.name));for(let E of I){v.has(E.name)&&e.error(l.ProductionDeclarationCollision,`Operation '${E.name}' collides with another event or operation in slice '${x.name}'.`,E.location),v.add(E.name),E.uses.length>0&&y.get(E.uses)!==1&&e.error(l.InvalidSystemReference,`Operation '${E.name}' must use one declared system; '${E.uses}' does not resolve uniquely.`,E.usesLocation??E.location);for(let C of E.inputs)!s.has(C.type.name)&&!a.has(C.type.name)&&e.warning(l.UnknownType,`Unknown type '${C.type.name}' on input '${C.name}' of operation '${E.name}'.`,C.type.location)}for(let E of x.commands)for(let C of E.produces){let k=n.resolve(C.event,x);k.kind===H.Ambiguous&&k.candidates.some(A=>A.kind===H.Operation)&&e.error(l.InvalidProductionReference,`Production '${C.event}' is ambiguous.`,C.location),C.event.includes(".")&&k.kind!==H.Operation&&e.error(l.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",C.location),k.declaration?.node.kind==="OperationSyntax"&&((C.for!==null||C.tags.length>0)&&e.error(l.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",C.location),$(C.mappings,k.declaration.node,E,!0,P))}for(let E of x.reactions.flatMap(C=>C.triggers).flatMap(C=>C.produces)){let C=n.resolve(E.event,x);C.kind===H.Ambiguous&&C.candidates.some(k=>k.kind===H.Operation)&&e.error(l.InvalidProductionReference,`Production '${E.event}' is ambiguous.`,E.location),E.event.includes(".")&&n.resolve(E.event,x).kind!==H.Operation&&e.error(l.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",E.location),n.isOperation(E,x)&&e.error(l.OperationOutsideCommand,"Operations can only be produced by commands.",E.location)}for(let E of x.specifications){let C=[...E.givenOperationFailures??[],...E.thenOperations??[],...E.thenCompensated??[]];if(C.length===0)continue;let k=p(i(E.when,P)?.commandType??"",P);(k===null||E.whenAppended!==null||E.whenQuery!==null||E.whenTrigger!==null||E.whenClock!==null||E.whenCapture!==null)&&e.error(l.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",E.location);let A=new Map;for(let O of C){if(O.kind==="SpecificationOperationSyntax")for(let N of O.values)S(N.source)||e.error(l.InvalidOperationSpecification,"Operation assertions require concrete input values.",N.source.location);let T=n.resolve(O.operation,x).declaration?.node;if(T?.kind!=="OperationSyntax"){e.error(l.InvalidOperationSpecification,`'${O.operation}' does not resolve uniquely to a declared operation.`,O.location);continue}let M=A.get(T)??new Set;if(M.has(O.kind)&&e.error(l.InvalidOperationSpecification,`Duplicate operation step '${O.operation}'.`,O.location),M.add(O.kind),A.set(T,M),O.kind==="SpecificationCompensatedSyntax"&&T.compensate===null&&e.error(l.InvalidOperationSpecification,`Operation '${O.operation}' declares no compensation.`,O.location),k!==null&&k.command.handler==null){let N=k.command.produces.map(j=>n.resolve(j.event,k.slice));N.every(j=>j.kind===H.Event||j.kind===H.Operation)&&!N.some(j=>j.declaration?.node===T)&&e.error(l.InvalidOperationSpecification,`Command '${k.command.name}' does not produce operation '${O.operation}'.`,O.location)}O.kind==="SpecificationOperationSyntax"&&$(O.values,T,null,!1,P)}}}}c(Ri,"validateOperations");var pm=w("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),um=w(`^claim\\s+"(${z})"$`),fm=w("^query\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(?:\\s+by\\s+(.+))?$");function qs(t,e,n){if(e.content!=="identity")return t.error(l.InvalidIdentityDeclaration,`Invalid identity declaration '${e.content}' - expected 'identity'`,f(e)),t.skipBlock(e.indent),n;if(n!==null)return t.error(l.DuplicateIdentity,"The document already declares an identity block - a document can have at most one",f(e)),t.skipBlock(e.indent),n;let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(o.content)==="description"){r=G(t,o,r,"Identity");continue}let s=pm.exec(o.content);if(s===null){t.error(l.InvalidIdentityDetail,`Invalid identity detail '${o.content}' - expected '<name> <Type> [from claim "<name>" | from query <Query> by <expression>]'`,f(o)),t.skipBlock(o.indent);continue}let a=Ie(s[2],{...f(o),column:o.indent+1+o.content.indexOf(s[2],s[1].length)});Le(t,a,o);let d=s[3]!==void 0?mm(t,o,s[3]):ym(t,o);d!==null&&i.push({kind:"IdentityDetailSyntax",name:re(s[1]),type:a,source:d,location:f(o)}),Bs(t,o,s[3]!==void 0?l.IdentitySourceWithBody:l.InvalidIdentityDetail)}return{kind:"IdentitySyntax",details:i,description:r,location:f(e)}}c(qs,"parseIdentity");function mm(t,e,n){let i=um.exec(n);if(i!==null)return{kind:"ClaimIdentitySourceSyntax",claim:V(i[1]),location:f(e)};let r=fm.exec(n);if(r!==null)return r[2]===void 0?(t.error(l.IdentityQueryWithoutKey,"An identity query source requires 'by <expression>'",f(e)),null):{kind:"QueryIdentitySourceSyntax",query:r[1],by:ae(r[2],f(e),t),location:f(e)};let o=D(n);return t.error(o==="claim"||o==="query"?l.InvalidIdentityDetail:l.UnknownIdentitySource,`Invalid identity source '${n}' - expected 'claim "<name>"' or 'query <Query> by <expression>'`,f(e)),null}c(mm,"parseSource");function ym(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(l.IdentityDetailWithoutSource,"An identity detail requires a claim, query, inline code block or file source",f(e)),null;if(t.reader.takeSignificant(),vt(n)){let i=tt(t,n);return Bs(t,n,l.InvalidIdentityDetail),{kind:"FileIdentitySourceSyntax",file:i,location:f(n)}}if(Tt(t,n)){let i=Te(t,n);return i===null?null:{kind:"CodeIdentitySourceSyntax",code:i,location:f(n)}}return t.error(l.InvalidIdentityDetail,`Unexpected '${n.content}' under an identity detail - expected a file reference or inline code block`,f(n)),t.skipBlock(n.indent),null}c(ym,"parseEscape");function Bs(t,e,n){for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(n,`Unexpected '${i.content}' under an identity source - refresh and caching are the runtime's business; a detail has exactly one source`,f(i)),t.skipBlock(i.indent)}c(Bs,"rejectBody");var Ys=["racialOrEthnicOrigin","politicalOpinions","religiousOrPhilosophicalBeliefs","tradeUnionMembership","genetic","biometric","health","sexLifeOrSexualOrientation"],hm=w("^(@?[a-z_]\\w*)\\s+(reason|scope|special|criminal)(?:\\s+(.*))?$"),Sm=w(`^"(${z})"$`);function xo(t){let e=t.replace(/^@/,"");return e==="personal"?"pii":e==="secret"?"sensitive":e}c(xo,"complianceWireName");function gm(t){let e=xo(t);return e==="sensitive"?"secret":e}c(gm,"canonicalComplianceName");function Fs(t,e,n){let i=n.trim().split(/\s+/).filter(r=>r.length>0);return Ws(t,e,i),i.map(r=>{let o=xo(r);return(!["pii","sensitive"].includes(o)||r==="@personal"||r==="@secret")&&t.error(l.UnknownComplianceMarker,`Unknown concept marker '${r}' - expected pii, personal or secret`,f(e)),{kind:"ConceptAttributeSyntax",name:o,reason:null,scope:null,specialCategory:null,criminal:!1,location:f(e)}})}c(Fs,"parseComplianceMarkers");function Us(t,e,n,i){let r=hm.exec(e.content);if(r===null)return!1;let[,o,s]=r,a=r[3]??"",d=xo(o),u=gm(o);if(Ws(t,e,[o]),!["pii","sensitive"].includes(d)||o==="@personal"||o==="@secret")return t.error(l.UnknownComplianceMarker,`Unknown concept marker '${o}' - expected pii, personal or secret`,f(e)),!0;let m=i.findIndex(y=>y.name===d);if(m<0)return t.error(l.AttributeReasonWithoutAttribute,`Concept '${n}' declares '${u} ${s}' without the marker - write 'concept ${n} : <Type> ${u}'`,f(e)),!0;let p=i[m];switch(s){case"reason":{let y=Sm.exec(a);return y===null?(t.error(l.UnknownConceptDirective,`Invalid '${u} reason' - expected '${u} reason "<text>"'`,f(e)),!0):p.reason!==null?(t.error(l.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${u}' - at most one is allowed`,f(e)),!0):(i[m]={...p,reason:V(y[1])},!0)}case"scope":return d!=="sensitive"||!["subject","namespace","global"].includes(a)?(t.error(l.InvalidSecretScope,`Invalid '${u} scope ${a}' - scope belongs to secret and must be subject, namespace or global`,f(e)),!0):p.scope!=null?(t.error(l.DuplicateSecretScope,`Concept '${n}' already declares secret scope - at most one is allowed`,f(e)),!0):(i[m]={...p,scope:a},i.some(y=>y.name==="pii")&&t.warning(l.SecretScopeIgnoredForPii,`Concept '${n}' is pii secret - secret scope is ignored because only Chronicle [PII] renders`,f(e)),!0);case"special":case"criminal":return d!=="pii"||(s==="special"?!Ys.includes(a):a.length>0)?(t.error(l.InvalidPersonalDataQualifier,`Invalid '${u} ${s}${a.length>0?` ${a}`:""}' - expected 'pii criminal' or 'pii special <category>' with category ${Ys.join(", ")}`,f(e)),!0):s==="special"&&p.specialCategory!=null?(t.error(l.DuplicateSpecialCategory,`Concept '${n}' already declares pii special - at most one is allowed`,f(e)),!0):(i[m]=s==="special"?{...p,specialCategory:a}:{...p,criminal:!0},!0);default:return!1}}c(Us,"parseComplianceDirective");function Ws(t,e,n){n.some(i=>["@pii","sensitive","@sensitive"].includes(i))&&t.information(l.LegacyComplianceMarker,"Legacy compliance spelling - use bare pii for personal data and secret for operational secrets; reason text is preserved",f(e))}c(Ws,"reportLegacy");var xm=Z("^policy\\s+([A-Za-z_]\\w*)$");function zs(t,e){let n=t;t=t.valueContext;let i=xm.exec(e.content)?.[1]??"";i===""&&t.error(l.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,f(e));let r=null,o=null,s=null,a=!1,d=null;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(u.content)==="description")d=G(n,u,d,`Policy '${i}'`);else if(D(u.content)==="require"){let m=u.content.substring(7).trim();for(let h=t.peekChild(u.indent);h!==void 0;h=t.peekChild(u.indent))t.reader.takeSignificant(),m+=` ${h.content}`;let p=vm(t,m);p.includes("not")&&(t=n);let y=$m(t,p,f(u));a?t.error(l.RepeatedPolicyRequirement,`Policy '${i}' has more than one require line; combine the conditions with and/or in one require`,f(u)):r=y,a=!0}else if(D(u.content)==="file"){let m=tt(t,u);o===null&&s===null?s=m:t.error(l.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(u))}else if(u.content.startsWith("```")||t.languages.has(u.content)){let m=Te(t,u);o===null&&s===null?o=m:t.error(l.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(u))}else t.error(l.UnknownPolicyDirective,`Unexpected '${u.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,f(u)),t.skipOpaqueBlock(u.indent);return r!==null&&(o!==null||s!==null)&&t.error(l.MixedPolicyImplementation,`Policy '${i}' cannot combine 'require' with a file or inline code block`,f(e)),r===null&&o===null&&s===null&&t.error(l.PolicyWithoutRequirement,`Policy '${i}' must declare a 'require' condition, a file reference or an inline code block`,f(e)),{kind:"PolicySyntax",name:i,condition:r,code:o,file:s,description:d,location:f(e)}}c(zs,"parsePolicy");function vm(t,e){let n=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]":"[\\w.$]+";return[...e.match(new RegExp(Z(`"${z}"|\\(|\\)|${n}`).source,"gu"))??[]]}c(vm,"tokenizePolicyCondition");function $m(t,e,n){let i=t.sourceOptions.numericMode==="exact"||e.includes("not"),r=0,o=c(p=>p!==void 0&&p.startsWith('"')&&p.endsWith('"'),"quoted"),s=c(p=>V(p.substring(1,p.length-1)),"unquote"),a=c(()=>{if(e[r]==="not"){r++;let g=a();return g===null?null:{kind:"NotPolicyConditionSyntax",operand:g,location:n}}if(e[r]==="("){r++;let g=u();return e[r]===")"?r++:i&&t.error(l.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),g}let p=e[r++];if(p==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(p!=="role"&&p!=="claim")return t.error(p===void 0?l.ExpectedPolicyCondition:l.UnexpectedTokenInPolicyCondition,p===void 0?"Expected a policy condition":`Unexpected '${p}' in policy condition`,n),null;let y=e[r++];if(!o(y))return t.error(p==="role"?l.ExpectedRoleName:l.ExpectedClaimName,`Expected a quoted ${p} name after '${p}'`,n),null;if(p==="role")return{kind:"RoleConditionSyntax",role:s(y),location:n};if(e[r++]!=="matches")return t.error(l.ExpectedClaimMatches,"Expected 'matches' after the claim name",n),null;let h=e[r++];return h===void 0?(t.error(l.ExpectedClaimMatchTarget,"Expected 'subject' or a value after 'matches'",n),null):{kind:"ClaimConditionSyntax",claim:s(y),matchesSubject:h==="subject",matches:h==="subject"?null:Ye(h,n,t),location:n}},"group"),d=c(()=>{let p=a();for(;p!==null&&e[r]==="and";){r++;let y=a();if(y===null)return null;p={kind:"LogicalPolicyConditionSyntax",left:p,operator:"And",right:y,location:n}}return p},"and"),u=c(()=>{let p=d();for(;p!==null&&e[r]==="or";){r++;let y=d();if(y===null)return null;p={kind:"LogicalPolicyConditionSyntax",left:p,operator:"Or",right:y,location:n}}return p},"or"),m=u();return i&&m!==null&&r<e.length&&t.error(l.UnexpectedTokenInPolicyCondition,`Unexpected '${e[r]}' in policy condition`,n),m}c($m,"parsePolicyCondition");var bm=new RegExp(`^for\\s+"(${z})"$`,"u"),km=Z("^[A-Z]\\w*$"),Em=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function Vs(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(l.InvalidSeedDeclaration,`Invalid seed declaration '${e.content}' - expected 'seed'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SeedSyntax",groups:n,location:f(e)};for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=bm.exec(i.content);if(r===null){t.error(l.InvalidSeedGroup,`Invalid seed group '${i.content}' - expected 'for "<event source id>"'`,f(i)),t.skipOpaqueBlock(i.indent);continue}let o=[];for(let s=t.peekChild(i.indent);s!==void 0;s=t.peekChild(i.indent)){if(t.reader.takeSignificant(),!km.test(s.content)){t.error(l.InvalidSeedEvent,`Invalid seed event '${s.content}' - expected an event type name`,f(s)),t.skipOpaqueBlock(s.indent);continue}let a=[];for(let d=t.peekChild(s.indent);d!==void 0;d=t.peekChild(s.indent)){t.reader.takeSignificant();let u=Em.exec(d.content);u!==null?a.push({kind:"PropertyMappingSyntax",property:u[1],source:Ye(u[2],f(d),t),location:f(d)}):t.error(l.InvalidSeedPropertyAssignment,`Invalid property assignment '${d.content}' - expected '<property> = <value>'`,f(d))}o.push({kind:"SeedEventSyntax",event:s.content,properties:a,location:f(s)})}n.push({kind:"SeedGroupSyntax",eventSourceId:V(r[1]),events:o,location:f(i)})}return{kind:"SeedSyntax",groups:n,location:f(e)}}c(Vs,"parseSeed");var vo=`(?:([A-Za-z_]\\w*)|"(${z})")\\.(\\w+(?:\\.\\w+)*)`,Cm=w("^exposure\\s+for\\s+([A-Za-z_]\\w*)$"),Pm=w("^instance\\s+([A-Za-z_]\\w*)$"),Am=w(`^property\\s+${vo}(?:\\s+label\\s+"(${z})")?(?:\\s+operations\\s+([\\w-]+(?:\\s*,\\s*[\\w-]+)*))?(?:\\s+fields\\s+(\\w+(?:\\s*,\\s*\\w+)*))?(?:\\s+reexposes\\s+([A-Za-z_]\\w*))?$`),Im=w(`^set\\s+${vo}\\s*=\\s*(.+)$`),wm=w(`^items\\s+${vo}$`),Om=w(`^item\\s+(?:([A-Za-z_][\\w-]*)|"(${z})")$`),Tm=w("^([A-Za-z_]\\w*)\\s*=\\s*(.+)$"),Rm=["add","remove","reorder","edit-fields"],Dm=`'property <component>.<path> [label "<text>"] [operations <add|remove|reorder|edit-fields>, ...] [fields <field>, ...] [reexposes <Owner>]'`,Di=c((t,e)=>t[e]??V(t[e+1]),"reference"),Qs=c(t=>t.trim()==="none"?[]:t.split(",").map(e=>e.trim()).filter(e=>e.length>0),"list");function Gs(t,e){let n=Cm.exec(e.content);n===null&&t.error(l.InvalidExposureDeclaration,`Invalid exposure declaration '${e.content}' - expected 'exposure for <Owner>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Mm(t,r);o!==void 0&&i.push(o)}return{kind:"ExposureSyntax",owner:n?.[1]??e.content,properties:i,location:f(e)}}c(Gs,"parseExposure");function _s(t,e){let n=Pm.exec(e.content);n===null&&t.error(l.InvalidInstanceContribution,`Invalid instance declaration '${e.content}' - expected 'instance <Screen or Template>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Lm(t,r);o!==void 0&&i.push(o)}return{kind:"InstanceContributionsSyntax",instance:n?.[1]??e.content,contributions:i,location:f(e)}}c(_s,"parseInstance");function Mm(t,e){let n=Am.exec(e.content);if(n===null){t.error(l.InvalidExposureDeclaration,`Invalid exposed property '${e.content}' - expected ${Dm}`,f(e));return}let i=n[5]===void 0?[]:Qs(n[5]),r=i.find(o=>!Rm.includes(o));if(r!==void 0){t.error(l.InvalidExposureDeclaration,`Unknown collection operation '${r}' - expected add, remove, reorder, edit-fields or none`,f(e));return}return{kind:"ExposedPropertySyntax",component:Di(n,1),path:n[3],label:n[4]===void 0?null:V(n[4]),isCollection:n[5]!==void 0,operations:i,restrictsFields:n[6]!==void 0,editableFields:n[6]===void 0?[]:Qs(n[6]),reExposes:n[7]??null,location:f(e)}}c(Mm,"parseExposedProperty");function Lm(t,e){let n=Im.exec(e.content);if(n!==null)return t.skipBlock(e.indent),{kind:"InstanceContributionSyntax",component:Di(n,1),path:n[3],value:ae(n[4],f(e),t),items:[],location:f(e)};let i=wm.exec(e.content);if(i!==null){let r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=jm(t,o);s!==void 0&&r.push(s)}return{kind:"InstanceContributionSyntax",component:Di(i,1),path:i[3],value:null,items:r,location:f(e)}}t.error(l.InvalidInstanceContribution,`Invalid instance contribution '${e.content}' - expected 'set <component>.<path> = <value>' or 'items <component>.<path>'`,f(e)),t.skipBlock(e.indent)}c(Lm,"parseContribution");function jm(t,e){let n=Om.exec(e.content);if(n===null){t.error(l.InvalidInstanceContribution,`Invalid contributed item '${e.content}' - expected 'item <id>'`,f(e)),t.skipBlock(e.indent);return}let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Tm.exec(r.content);if(o===null){t.error(l.InvalidInstanceContribution,`Invalid item value '${r.content}' - expected '<field> = <value>'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ContributedItemValueSyntax",field:o[1],value:ae(o[2],f(r),t),location:f(r)})}return{kind:"ContributedItemSyntax",id:Di(n,1),values:i,location:f(e)}}c(jm,"parseItem");var Nm=w("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Js=w(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${z})")?$`),qm=w("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$"),Bm=w("^@?[a-z_]\\w*$"),Ym=w("^persona\\s+([A-Za-z_]\\w*)$"),Fm=w("^policy\\s+([A-Za-z_]\\w*)$"),Um=/^[ ]*\t/,Zs=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Hs=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),Wm=new Set(["slice","feature","description","documentation","authorize","screen","dialog","form","contribute","on","uses"]);function Mi(t,e,n=Ot){t.deferIdentityValidation=!0,_m(t,e);let i=n.length===1?new On(n[0]):void 0,r=n.length>1?new wn(n[n.length-1]):void 0,o=i??r,s=null,a=null,d=[],u=[],m=[],p=[],y=[],h=[],g=[],b=[],S=[],$=[],x=[],P=[],I=[],v=[],E=[],C=!1;for(let A=t.reader.peekSignificant();A!==void 0;A=t.reader.peekSignificant()){t.reader.takeSignificant();let O=D(A.content);if(O==="runs"){Oe(t,A);continue}if(O==="domain"){t.authoredDeclarations=!0,a=Gm(t,A,a,C);continue}if(C||=Ks(O,A,n),t.authoredDeclarations||=O!=="import"&&Ks(O,A,n),O==="import"&&$a(A.content))o!==void 0?o.tryParse(t,A):Gt(t,A,u);else if(O==="import"){let T=Js.exec(A.content);if(T===null)t.error(l.InvalidImportDeclaration,`Invalid import '${A.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,f(A));else{let M=T.groups?.origin===void 0?null:V(T.groups.origin);M!==null&&Cn(M)&&t.error(l.InvalidImportDeclaration,"An import origin must be a nonblank quoted string",f(A)),d.push({kind:"ImportSyntax",qualifiedName:T[1],origin:M,visibility:M===null?se.Private:se.Public,location:f(A)})}}else if(O==="example")o!==void 0?o.tryParse(t,A):P.push(ct(t,A));else if(O==="eventsource")h.push(Ma(t,A));else if(O==="system")y.push(Fa(t,A));else if(O==="concept")m.push(Zm(t,A));else if(O==="type")p.push(Xa(t,A));else if(O==="module"&&!gn(n))zm(t,A,n,i);else if(O==="module")g.push(ao(t,A));else if(O==="persona")b.push(Km(t,A));else if(O==="seed")x.push(Vs(t.valueContext,A));else if(O==="purpose"&&o!==void 0)o.tryParse(t,A);else if(O==="purpose")$.push(xa(t,A));else if(O==="identity")s=qs(t,A,s);else if(O==="policy")S.push(zs(t,A));else if(O==="exposure")v.push(Gs(t,A));else if(O==="instance")E.push(_s(t,A));else if(O==="trigger"){let T=vs(t,A),M=/^trigger\s+([A-Za-z_]\w*)$/.exec(A.content)?.[1];M!==void 0&&I.push({name:M,data:T})}else Hs.has(O)?O==="behavior"||O==="layout"?ze(t,A):t.skipOpaqueBlock(A.indent):o?.tryParse(t,A)!==!0&&Vm(t,A,n)}i!==void 0?g.unshift(i.build(t.start,!0)):r!==void 0&&g.unshift(Qm(n,r.build(t.start,!0),t.start));let k={kind:"ApplicationSyntax",...s===null?{}:{identity:s},sourceOptions:t.sourceOptions,domain:a,imports:d,concepts:m,types:p,systems:y,eventSources:h,examples:P,modules:g,personas:b,policies:S,purposes:$,seeds:x,declaredTriggers:I,fileImports:u,...v.length>0?{exposures:v}:{},...E.length>0?{instanceContributions:E}:{},location:t.start};return t.authoredDeclarations&&Aa(k),k}c(Mi,"parseApplication");function Ks(t,e,n){return t==="import"?Js.test(e.content):t==="module"?gn(n):t==="identity"?e.content==="identity":t==="purpose"||t==="example"||t==="exposure"||t==="instance"||t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||Hs.has(t)}c(Ks,"declaresConstruct");function zm(t,e,n,i){let r=ro.exec(e.content)?.[1]??"";if(i!==void 0&&r===n[0]){t.authoredDeclarations=!0,i.parseChildren(t,e);return}t.error(l.ModuleInPlacedFile,`This file is imported into ${si(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,f(e)),t.skipBlock(e.indent)}c(zm,"parseModuleInPlacedFile");function Vm(t,e,n){let i=D(e.content);if(gn(n)){let r=Wm.has(i)?` - '${i}' belongs in a module or feature; wrap it in one, or import this file from inside one`:" - expected domain, import, concept, type, policy, persona, authentication, identity, module, seed, trigger, behavior, ui profile, theme or layout";t.error(l.UnknownTopLevelConstruct,`Unexpected '${i}' at the top level${r}`,f(e))}else{let r=n.length===1?oo:io;t.error(l.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${si(n)} - expected an application declaration or ${r}`,f(e))}t.skipBlock(e.indent)}c(Vm,"reportUnexpectedTopLevel");function Qm(t,e,n){let i=e;for(let r=t.length-2;r>=1;r--)i={kind:"FeatureSyntax",name:t[r],description:null,authorize:null,features:[i],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:"ModuleSyntax",name:t[0],description:null,authorize:null,features:[i],fileImports:[],isPlacement:!0,location:n}}c(Qm,"place");function Gm(t,e,n,i){let r=Nm.exec(e.content);return r===null?(t.error(l.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,f(e)),n):n!==null?(t.error(l.DuplicateDomain,"The document already declares a domain - a document can have at most one",f(e)),n):(i&&t.error(l.DomainNotFirst,"'domain' must be declared before any other construct",f(e)),{kind:"DomainSyntax",name:r[1],location:f(e)})}c(Gm,"parseDomain");function _m(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&Um.test(i.raw)&&t.warning(l.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",sa(i))}}c(_m,"warnOnTabIndentation");function Zm(t,e){let n=qm.exec(e.content);if(n===null)return t.error(l.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,f(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:D(e.content),type:"",attributes:[],values:[],location:f(e)};let[,i,r,o]=n,s=Fs(t,e,o);r!=="Enum"&&!Zs.includes(r)&&t.error(l.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${Zs.join(", ")} or Enum`,f(e));let a=[],d=null,u=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(m.content)==="description"&&(r!=="Enum"||m.content!=="description"||t.peekChild(m.indent)?.content.startsWith("```")===!0))d=G(t,m,d,`Concept '${i}'`);else{if(ge(m))continue;if(D(m.content)==="validate"){r==="Enum"&&m.content==="validate"&&t.peekChild(m.indent)===void 0&&t.warning(l.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${i}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,f(m));let p=Kr(t,m,"concept");p!==void 0&&u.push(p)}else Us(t,m,i,s)||(r==="Enum"&&Bm.test(m.content)?a.push(re(m.content)):r==="Enum"?t.error(l.InvalidEnumerationValue,`Invalid enum value '${m.content}' - expected an identifier`,f(m)):(t.error(l.UnknownConceptDirective,`Unexpected '${m.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,f(m)),t.skipBlock(m.indent)))}return{kind:"ConceptSyntax",name:i,type:r,attributes:s,values:a,validations:u,description:d,location:f(e)}}c(Zm,"parseConcept");function Km(t,e){let n=Ym.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,f(e));let i=null,r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);if(s==="description")i=G(t,o,i,`Persona '${n}'`);else if(s==="policy"){let a=Fm.exec(o.content);a===null?t.error(l.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,f(o)):r.push(a[1])}else t.error(l.UnknownPersonaDirective,`Unexpected '${s}' in persona body - expected description or policy`,f(o)),t.skipBlock(o.indent)}return{kind:"PersonaSyntax",name:n,description:i,policies:r,location:f(e)}}c(Km,"parsePersona");var rn=class t{static{c(this,"CommandStreamCandidates")}sources;qualifiedTypes;constructor(e,n){this.sources=e,this.qualifiedTypes=n}hasSource(e){return this.sources.has(e)}hasPropertyType(e){return this.qualifiedTypes.has(e)}hasUniqueStream(e,n){let i=this.sources.get(e);return i?.length===1&&i[0].filter(r=>r===n).length===1}static capture(e,n=Ot,i){return this.capturePlaced([...e].map(r=>({lines:r,placement:n})),i)}static capturePlaced(e,n){let i=new Map,r=new Set,o=new Set;for(let{lines:a,placement:d}of e){let u=Oi(a,a[0]?.path,n);u.scope=d;let m=Mi(u,a,d);for(let p of m.types)r.add(p.name);for(let p of m.concepts)r.add(p.name);for(let p of m.imports)o.add(p.qualifiedName);for(let p of m.eventSources??[])i.set(p.name,[...i.get(p.name)??[],p.streams.map(y=>y.name)])}let s=new Set([...o].filter(a=>r.has(a.substring(a.lastIndexOf(".")+1))));return new t(i,s)}};var ve;(function(t){t.Empty="Empty",t.NotNfc="NotNfc",t.LoneSurrogate="LoneSurrogate",t.OutOfRange="OutOfRange",t.NotIntegral="NotIntegral",t.MalformedUuid="MalformedUuid",t.Arity="Arity",t.Escape="Escape",t.Noncanonical="Noncanonical"})(ve||(ve={}));function Xs(t){return t.length===0?{value:null,failure:ve.Empty}:/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(t)?{value:null,failure:ve.LoneSurrogate}:t.normalize("NFC")!==t?{value:null,failure:ve.NotNfc}:{value:t,failure:null}}c(Xs,"tryFormatText");function el(t){if(!/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}|\{[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\}|\([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\))(?![\s\S])/i.test(t))return{value:null,failure:ve.MalformedUuid};let e=t.replace(/[{}()-]/g,"").toLowerCase();return{value:`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`,failure:null}}c(el,"tryFormatUuidText");function Li(t,e=typeof t=="number"){if(typeof t=="number"&&!Number.isInteger(t))return{value:null,failure:ve.NotIntegral};let n=BigInt(t);return e&&(n<-9007199254740991n||n>9007199254740991n)?{value:null,failure:ve.OutOfRange}:{value:n.toString(),failure:null}}c(Li,"tryFormatInteger");function ji(t){switch(t){case ve.Empty:return"A stream id text literal cannot be empty.";case ve.NotNfc:return"A stream id text literal must be Unicode NFC.";case ve.LoneSurrogate:return"A stream id text literal cannot contain lone UTF-16 surrogates.";case ve.OutOfRange:return"A stream id integer literal must be between -9007199254740991 and 9007199254740991 in Double numeric mode.";case ve.NotIntegral:return"A stream id integer must be a finite integral value.";case ve.MalformedUuid:return"A stream id UUID must use N, D, B or P form.";case ve.Arity:return"A composite stream id must match the declared part count of at least two.";case ve.Escape:return"A composite stream id permits only %25 and %7C escapes.";case ve.Noncanonical:return"A composite stream id part must use canonical scalar spelling."}}c(ji,"streamIdFailureMessage");function Ni(t,e,n,i,r,o,s){if(n){o.error(r,"A composite stream requires a streamId part block, not a scalar mapping.",i);return}let a=t.streamIdParts;for(let u of a.filter(m=>!e.some(p=>p.property===m.name)))o.error(r,`Stream id part '${u.name}' requires a mapping.`,i);let d=new Set;for(let u of e){let m=a.find(p=>p.name===u.property);m===void 0?o.error(r,`Unknown stream id part '${u.property}'.`,u.location):d.has(u.property)?o.error(r,`Stream id part '${u.property}' is mapped more than once.`,u.location):(d.add(u.property),s(u,m.type))}}c(Ni,"validateStreamIdParts");function qi(t,e,n){let i=oe(n.concepts),r=oe(n.types),o=new Map([...r].map(([a,d])=>[a,oe(d.properties)]));if(t?.kind!=="LiteralExpressionSyntax"||!Pe(t,e,i,o))return null;let s=i.get(e.name)?.type??e.name;return["String","Uuid","Int"].includes(s)?Mn(t,e,n)?.value??null:null}c(qi,"formatSpecificationStreamId");function tl(t,e,n,i){if(n!=null)return t==null;if(e==null)return!0;if(t==null)return!1;let r=new Fe(i),o=r.resolve(t.eventSource,t.stream),s=r.resolve(e.eventSource,e.stream);if(o.kind!==pe.Unique||s.kind!==pe.Unique)return null;if(o.sources[0]!==s.sources[0]||o.streams[0]!==s.streams[0])return!1;let a=s.streams[0],d=c((u,m,p)=>{let y=qi(u,p,i),h=qi(m,p,i);return y===null||h===null?null:y===h},"compare");if(a.streamIdParts.length>0){if(t.streamId!==null||e.streamId!==null||t.streamIdParts.length!==a.streamIdParts.length||e.streamIdParts.length!==a.streamIdParts.length)return null;let u=a.streamIdParts.map(m=>{let p=t.streamIdParts.filter(h=>h.property===m.name),y=e.streamIdParts.filter(h=>h.property===m.name);return p.length===1&&y.length===1?d(p[0].source,y[0].source,m.type):null});return u.includes(!1)?!1:u.includes(null)?null:!0}return t.streamIdParts.length>0||e.streamIdParts.length>0?null:a.streamId===null?t.streamId===null&&e.streamId===null?!0:null:d(t.streamId?.source,e.streamId?.source,a.streamId)}c(tl,"matchesSpecificationRoute");function il(t,e){let n=new ie(t).slices.flatMap(({slice:s})=>s.specifications.flatMap(a=>a.cases??[]));if(n.length===0)return nl(t,e);let i=new ye(new qe([]));nl(t,i);let r=new Set,o=new Set;for(let s of i.diagnostics){let a=JSON.stringify([s.code,s.location.path,s.location.line,s.location.column,s.message]);if(o.has(a))continue;o.add(a);let d=s.code===l.InvalidSpecificationStreamRoute?n.find(u=>u.values.some(m=>m.source.location.line===s.location.line&&m.source.location.column===s.location.column&&m.source.location.path===s.location.path)):void 0;if(d===void 0)e.error(s.code,s.message,s.location);else{let u=JSON.stringify(s.location);r.has(u)||e.error(s.code,`Case '${d.name}': ${s.message}`,s.location),r.add(u)}}}c(il,"validateSpecificationStreams");function nl(t,e){let n=Wt(t).resolvedExamples,i=Hn(t);t=i.application;let r=new ie(t),o=new Set,s=n.flatMap(x=>{if(x.kind!=="event")return(x.kind==="command"||x.kind==="readmodel")&&(x.example.stream!=null||x.example.noStream!=null)&&e.error(l.InvalidSpecificationExampleBody,"only event examples carry routes; a command's route comes from its declaration, and read models have none",(x.example.stream??x.example.noStream).location),[];let P={kind:"SpecificationEventSyntax",eventType:x.name,values:x.example.values,for:x.example.for,stream:x.example.stream,noStream:x.example.noStream,location:x.example.location};return o.add(P),[{scope:x.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[P],whenRedelivered:null}}]}),a=new Fe(t),d=oe(t.concepts),u=oe(t.types),m=new Map([...u].map(([x,P])=>[x,oe(P.properties)])),p=c((x,P)=>Pe(x,P,d,m),"compatible"),y=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime",...d.keys(),...u.keys()]),h=c((x,P)=>y.has(x.name)&&y.has(P.name)?x.name===P.name&&x.isCollection===P.isCollection&&(!x.isOptional||P.isOptional):null,"nominallyCompatible"),g=c((x,P)=>qi(x,P,t),"formatStreamId"),b=c((x,P)=>{let I=r.resolve(x,P).declaration;return I?.node.kind==="EventSyntax"?I.node:null},"eventOf"),S=[];for(let{slice:x}of r.slices){for(let P of x.commands)for(let I of P.produces){if(!r.isEventProduction(I,x))continue;let v=b(I.event,x);if(v===null)continue;let E=zt(P,I,t,{resolver:r,slice:x});S.push({event:v,command:P,type:E})}for(let P of x.reactions.flatMap(I=>I.triggers).flatMap(I=>I.produces)){let I=b(P.event,x);I!==null&&S.push({event:I,command:null,type:null})}for(let P of x.captures)for(let I of[...P.appends,...P.children.flatMap(v=>v.appends),...P.nested.flatMap(v=>v.appends)]){let v=b(I.event,x);v!==null&&S.push({event:v,command:null,type:null})}}let $=[...s.flatMap(x=>r.slices.filter(P=>P.scope.join(".")===x.scope.join(".")).map(({slice:P,scope:I})=>({slice:P,scope:I,specification:x.specification}))),...r.slices.flatMap(({slice:x,scope:P})=>x.specifications.map(I=>({slice:x,scope:P,specification:I})))];for(let{slice:x,scope:P,specification:I}of $){let v=r.slices.flatMap(T=>T.slice.commands.map(M=>({command:M,scope:T.scope}))),E=I.when?.commandType.split(".")??[],C=E.slice(0,-1),k=v.filter(T=>T.command.name===E.at(-1)&&C.every((M,N)=>T.scope[T.scope.length-C.length+N]===M)),A=C.length>0&&k.length===1?k[0].command:null;for(let T=P.length;C.length===0&&T>=0&&A===null;T--){let M=k.filter(N=>P.slice(0,T).every((j,q)=>N.scope[q]===j));if(M.length>0){A=M.length===1?M[0].command:null;break}}let O=[...I.given.map(T=>({node:T,required:!0,expected:!1})),...I.whenAppended===null?[]:[{node:I.whenAppended,required:!0,expected:!1}],...I.thenEvents.map(T=>({node:T,required:!1,expected:!o.has(T)})),...I.whenRedelivered==null?[]:[{node:{...I.whenRedelivered,kind:"SpecificationEventSyntax"},required:!1,expected:!1}]];for(let{node:T,required:M,expected:N}of O){let j=i.specifications.flatMap(U=>U.steps).find(U=>U.effective===T),q=j?.route?.origin!=="example",Q=q||T.for!==j?.example?.for,K=c((U,ce,he)=>{e.error(U,j?.example==null?ce:`${ce} Example '${j.example.name}' is used here.`,j?.example==null?he:j.authored.location)},"contextualError");if(T.stream==null&&T.noStream==null)continue;M&&T.noStream!=null&&K(l.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",T.noStream.location);let J=null,W=b(T.eventType,x),_=S.filter(U=>U.event===W);if(T.stream!=null){let U=T.stream,ce=a.resolve(U.eventSource,U.stream);if(ce.kind!==pe.Unique){let Se={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[ce.kind];q&&e.error(l.InvalidSpecificationStreamRoute,`Stream '${U.eventSource}.${U.stream}' is ${Se}; routing requires one physical source and stream.`,U.location);continue}let he=ce.sources[0],Re=ce.streams[0],Ct=c((Se,be)=>{let me=Se.source,R=Mn(me,be,t);R?.failure!=null?e.error(l.InvalidSpecificationStreamRoute,ji(R.failure),me.location):(me.kind!=="LiteralExpressionSyntax"||me.value===null||be!==null&&!p(me,be))&&e.error(l.InvalidSpecificationStreamRoute,"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.",me.location)},"validateLiteral");if(q&&(Re.streamIdParts.length>0?Ni(Re,U.streamIdParts,U.streamId!==null,U.location,l.InvalidSpecificationStreamRoute,e,Ct):U.streamIdParts.length>0?e.error(l.InvalidSpecificationStreamRoute,"A streamId part block requires a composite stream.",U.location):(Re.streamId===null!=(U.streamId===null)&&e.error(l.InvalidSpecificationStreamRoute,Re.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",U.location),U.streamId!==null&&Ct(U.streamId,Re.streamId))),J=he.identifier,J===null){let Se=_.map(me=>me.type),be=new Set(Se.filter(me=>me!==null).map(me=>`${me.name}:${me.isOptional}:${me.isCollection}`));Se.length===0||Se.some(me=>me===null)||be.size!==1?q&&e.error(l.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${he.name}'; the event's producers do not supply one unambiguous destination type.`,U.location):J=Se[0]}let Pt=!1;if(j?.example?.stream!=null&&T.for!==null&&T.for===j.example.for){let Se=a.resolve(j.example.stream.eventSource,j.example.stream.stream);if(Se.kind===pe.Unique){let be=_.map(L=>L.type),me=new Set(be.filter(L=>L!==null).map(L=>`${L.name}:${L.isOptional}:${L.isCollection}`)),R=Se.sources[0].identifier??(be.length>0&&!be.some(L=>L===null)&&me.size===1?be[0]:null);R!==null&&(Pt=T.for.kind!=="LiteralExpressionSyntax"||T.for.value===null||R.isCollection||R.isOptional||!p(T.for,R))}}M&&T.for===null?K(l.InvalidSpecificationStreamEventSource,"A routed given or when append event requires 'for <literal>'.",U.location):Q&&!Pt&&T.for!==null&&(T.for.kind!=="LiteralExpressionSyntax"||T.for.value===null||J!==null&&(J.isCollection||J.isOptional||!p(T.for,J)))&&K(l.InvalidSpecificationStreamEventSource,"A routed event's for value must be a concrete literal compatible with the source's identifier type.",T.for.location)}if(!N||A===null||_.length===0||_.some(U=>U.command!==A))continue;let te=A.stream?.propertyCandidate===null?A.stream:null,$e=T.noStream!=null?te!=null:te==null||te.eventSource!==T.stream.eventSource||te.stream!==T.stream.stream;if(!$e&&T.stream!=null&&te!=null){let U=a.resolve(T.stream.eventSource,T.stream.stream),ce=U.kind===pe.Unique?U.streams[0]:null;if(ce!==null&&ce.streamIdParts.length>0){if(te.streamId===null&&T.stream.streamId===null&&te.streamIdParts.length>0&&T.stream.streamIdParts.length>0)for(let he of ce.streamIdParts){let Re=te.streamIdParts.filter(be=>be.property===he.name),Ct=T.stream.streamIdParts.filter(be=>be.property===he.name);if(Re.length!==1||Ct.length!==1)continue;let Pt=g(Re[0].source,he.type),Se=g(Ct[0].source,he.type);Pt!==null&&Se!==null&&Pt!==Se&&($e=!0)}}else if(ce?.streamId!=null&&te.streamIdParts.length===0&&T.stream.streamIdParts.length===0){let he=g(te.streamId?.source,ce.streamId),Re=g(T.stream.streamId?.source,ce.streamId);he!==null&&Re!==null&&he!==Re&&($e=!0)}}T.for?.kind==="LiteralExpressionSyntax"&&_.every(U=>U.type!==null&&(J!==null?h(U.type,J)===!1:!p(T.for,U.type)))&&($e=!0),$e&&K(l.SpecificationStreamContradictsCommand,"The expected event route contradicts its only producer, the command under test.",(T.stream??T.noStream).location)}}}c(nl,"validateRoutes");var Ln=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function $o(t,e){let n=e.concepts.filter(r=>r.name===t.name),i=n.length===1?n[0].type:n.length===0&&Ln.has(t.name)?t.name:null;return i==="String"||i==="Uuid"||i==="Int"&&n.length===1&&n[0].values.length===0}c($o,"supportsStreamIdentity");function Mn(t,e,n){if(t?.kind!=="LiteralExpressionSyntax")return null;let i=t.value,r=e===null?null:oe(n.concepts).get(e.name)?.type??e.name;return typeof i=="string"?r==="Uuid"?el(i):Xs(i):typeof i=="number"?Li(i):typeof i=="object"&&i!==null&&i.literalType==="ExactNumber"?i.value.includes(".")?Li(NaN):Li(BigInt(i.value),!1):null}c(Mn,"formatStreamIdLiteral");function Bi(t,e){let n=oe(t.concepts),i=oe(t.types),r=new Set([...Ln,...n.keys(),...i.keys()]),o=new Map([...i].map(([y,h])=>[y,oe(h.properties)])),s=c((y,h)=>r.has(y.name)&&r.has(h.name)?y.name===h.name&&y.isCollection===h.isCollection&&(!y.isOptional||h.isOptional):null,"compatible"),a=c((y,h)=>{if(y===null)return;if(y.isOptional||y.isCollection||t.types.some(S=>S.name===y.name)){e.error(l.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",y.location);return}let g=t.concepts.filter(S=>S.name===y.name),b=g.length===1?g[0].type:g.length===0&&Ln.has(y.name)?y.name:null;h&&b!==null&&!$o(y,t)&&e.error(l.UnsupportedStreamIdType,"Stream ids support text and UUID values and their nominal concepts, plus integer-backed concepts; other types need a future portable formatter.",y.location),b===null&&!t.imports.some(S=>S.qualifiedName===y.name||S.qualifiedName.split(".").at(-1)===y.name)&&e.warning(l.UnknownType,`Unknown type '${y.name}' in event source declaration.`,y.location)},"validateType"),d=new Set;for(let y of t.eventSources??[]){d.has(y.name)&&e.error(l.InvalidEventSourceDeclaration,`Event source '${y.name}' has multiple physical declarations.`,y.location),d.add(y.name),a(y.identifier,!1);let h=new Set;for(let g of y.streams){h.has(g.name)&&e.error(l.InvalidEventSourceDeclaration,`Stream '${y.name}.${g.name}' has multiple declarations under this source.`,g.location),h.add(g.name),a(g.streamId,!0);let b=g.streamIdParts;if(b.length>0){b.length<2&&e.error(l.InvalidEventSourceDeclaration,"A composite stream id requires at least two named parts.",g.directiveLocations?.streamId??g.location);for(let S of new Set(b.map($=>$.name)))for(let $ of b.filter(x=>x.name===S).slice(1))e.error(l.InvalidEventSourceDeclaration,`Stream id part '${$.name}' is declared more than once.`,$.location);for(let S of b)a(S.type,!0)}}}let u=c((y,h)=>{let[g,...b]=h.split(".");if(y===null)return{property:null,missing:!1};let S=y.filter(P=>P.name===g);if(S.length!==1)return{property:null,missing:S.length===0};let $=S[0];if(b.length===0)return{property:$,missing:!1};if(Ln.has($.type.name)||n.has($.type.name)&&!i.has($.type.name))return{property:null,missing:!0};let x=u(i.get($.type.name)?.properties??null,b.join("."));return x.property===null?x:{property:{...x.property,type:{...x.property.type,isCollection:$.type.isCollection||x.property.type.isCollection,isOptional:$.type.isOptional||x.property.type.isOptional}},missing:!1}},"pathProperty"),m=new Fe(t),p=new ie(t);for(let{slice:y}of p.slices)for(let h of y.commands){let g=h.stream;if(g==null||g.propertyCandidate!==null)continue;let b=m.resolve(g.eventSource,g.stream);if(b.kind!==pe.Unique){let I={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[b.kind];e.error(l.InvalidCommandStream,`Stream '${g.eventSource}.${g.stream}' is ${I}; routing requires one physical source and stream.`,g.location);continue}let S=b.sources[0],$=b.streams[0],x=h.properties.filter(I=>I.isIdentifier);S.identifier!==null&&x.length===1&&s(x[0].type,S.identifier)===!1&&e.error(l.InvalidCommandStream,`Command identifier '${x[0].name}' does not have the source's nominal identifier type '${S.identifier.name}'. The stream does not supply a destination.`,x[0].location);for(let I of h.produces.filter(v=>p.isEventProduction(v,y))){if(S.identifier===null)continue;let v=zt(h,I,t,{resolver:p,slice:y});if(v===null||I.for===null&&I.inlineEvent!==null&&x.length===1&&s(x[0].type,S.identifier)===!1)continue;let E=I.for===null&&I.inlineEvent===null&&!h.properties.some(A=>A.isGenerated&&A.isIdentifier),C=n.get(S.identifier.name)?.type??(Ln.has(S.identifier.name)?S.identifier.name:null);(E?C===null?null:C==="Uuid":s(v,S.identifier))===!1&&e.error(l.InvalidCommandStream,`Command production destination does not have the source's nominal identifier type '${S.identifier.name}'. The stream does not supply a destination.`,I.for?.location??I.location)}let P=c((I,v)=>{let E=I.source;if(E.kind==="PathExpressionSyntax"){let C=u(h.properties,E.path);(C.missing||C.property!==null&&s(C.property.type,v)===!1)&&e.error(l.InvalidCommandStream,`Stream id source '${E.path}' is absent or incompatible with nominal type '${v.name}'.`,E.location)}else if(E.kind==="LiteralExpressionSyntax"&&E.value!==null){let C=Mn(E,v,t);C?.failure!=null?e.error(l.InvalidCommandStream,ji(C.failure),E.location):Pe(E,v,n,o)||e.error(l.InvalidCommandStream,`Stream id value is incompatible with nominal type '${v.name}'.`,E.location)}else(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(E.kind)||E.kind==="LiteralExpressionSyntax"&&E.value===null)&&e.error(l.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",E.location)},"validateMapping");if($.streamIdParts.length>0){Ni($,g.streamIdParts,g.streamId!==null,g.location,l.InvalidCommandStream,e,P);continue}if(g.streamIdParts.length>0){e.error(l.InvalidCommandStream,"A streamId part block requires a composite stream.",g.location);continue}($.streamId===null&&g.streamId!==null||$.streamId!==null&&g.streamId===null)&&e.error(l.InvalidCommandStream,$.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",g.location),!($.streamId===null||g.streamId===null)&&P(g.streamId,$.streamId)}il(t,e)}c(Bi,"validateEventSources");function Yi(t,e){let n=new ie(t),i=n.slices,r=new Set(t.imports.map(b=>b.qualifiedName)),o=new Set([...i.flatMap(({slice:b})=>le(b).map(S=>S.name)),...t.imports.map(b=>b.qualifiedName.split(".").at(-1))]),s=oe(t.types),a=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(b=>b.name)].filter(b=>!s.has(b))),d=c((b,S)=>{let[$,...x]=S.split(".");if(b===null)return{value:null,missing:!1};let P=b.filter(v=>v.name===$);if(P.length!==1)return{value:null,missing:P.length===0};let I=P[0];return x.length===0?{value:I,missing:!1}:a.has(I.type.name)?{value:null,missing:!0}:d(s.get(I.type.name)?.properties??null,x.join("."))},"property"),u=i.flatMap(({slice:b,scope:S})=>b.readModels.map($=>({node:$,scope:S}))),m=c((b,S)=>{let $=c(I=>{let v=I.split("."),E=u.filter(k=>k.node.name===v.at(-1)),C=v.slice(0,-1);if(C.length>0)return E.filter(k=>C.length<=k.scope.length&&C.every((A,O)=>k.scope[k.scope.length-C.length+O]===A));for(let k=S.length;k>=0;k--){let A=E.filter(O=>k<=O.scope.length&&S.slice(0,k).every((T,M)=>O.scope[M]===T));if(A.length>0)return A}return[]},"candidates"),x=$(b),P=t.imports.filter(I=>I.qualifiedName.split(".").at(-1)===b);return x.length===0&&P.length===1&&(x=$(P[0].qualifiedName)),x.length===1?x[0].node.properties:null},"viewProperties"),p=c((b,S,$)=>{let x=n.resolve(b,$);o.has(b)||r.has(b)||x.declaration?.kind===H.Event||x.candidates.some(I=>I.kind===H.Event)||e.warning(l.UnknownEvent,`Unknown event '${b}' - declare it with 'event ${b}'`,S)},"unknownEvent"),y=c((b,S)=>{for(let $ of b)($.kind==="RemoveWithSyntax"||$.kind==="RemoveViaJoinSyntax")&&p($.event,$.location,S),"blocks"in $&&y($.blocks,S)},"removals"),h=new Set,g=c((b,S,$=!1,x=!1)=>{let P=c((v,E)=>{let C=d(S,v),k=JSON.stringify([E.path,E.line,E.column]);return C.missing&&!h.has(k)&&(h.add(k),e.warning(l.UnknownReadModelProperty,`Projection target '${v}' is not a declared ${$?"element":"read-model"} property`,E)),C.value},"validate"),I=x||b.some(v=>v.kind==="FromSyntax"||v.kind==="JoinSyntax"||v.kind==="AllSyntax");for(let v of b){let E=v.kind==="EverySyntax"&&!I?[]:"mappings"in v?v.mappings:v.kind==="JoinSyntax"?v.events.flatMap(C=>C.mappings):[];for(let C of E)P(C.property,C.location);if(v.kind==="ChildrenSyntax"||v.kind==="NestedSyntax"){let C=P(v.property,v.location);g(v.blocks,C===null?null:s.get(C.type.name)?.properties??null,!0)}}},"walk");for(let{slice:b}of i){for(let S of b.projections)y(S.blocks,b);for(let S of b.captures)for(let $ of[...S.appends,...S.children.flatMap(x=>x.appends),...S.nested.flatMap(x=>x.appends)])p($.event,$.location,b)}for(let{slice:b,scope:S}of i)for(let $ of b.projections){let x=$.blocks.filter(P=>P.kind==="ProjectionVariantSyntax");x.length===0&&g($.blocks,m($.readModel??$.name,S));for(let P of x){let I=m(P.name,S);g($.blocks.filter(E=>E.kind==="ChildrenSyntax"||E.kind==="NestedSyntax"),I);let v=P.entersOn.length>0||$.blocks.some(E=>E.kind==="FromSyntax"||E.kind==="JoinSyntax"||E.kind==="AllSyntax");g(P.blocks,I,!1,v)}}}c(Yi,"validateProjectionTargets");function Fi(t,e){let n=new Set(t.concepts.filter(p=>p.attributes.some(y=>y.name==="pii")).map(p=>p.name)),i=new Set(t.concepts.filter(p=>p.attributes.some(y=>y.name==="sensitive")).map(p=>p.name)),r=oe(t.types),o=new ie(t),s=new Set(t.imports.map(p=>p.qualifiedName.split(".").at(-1))),a=new Map;for(let p of t.declaredTriggers??[]){let y=a.get(p.name)??[];y.push(p.data),a.set(p.name,y)}let d=c((p,y,h="an event source identifier")=>{if(n.has(p.name)||i.has(p.name)){let g=n.has(p.name)?"pii":"secret";e.error(l.PiiNotSupportedOnIdentifier,`Concept '${p.name}' is ${g} and cannot be ${h} - use a surrogate Uuid identifier and keep the ${g} value as a property`,y)}},"validate"),u=c((p,y)=>{let[h,...g]=y.split("."),b=p.filter($=>$.name===h);if(b.length!==1)return null;let S=b[0];return g.length===0?S:u(r.get(S.type.name)?.properties??[],g.join("."))},"property");for(let p of t.eventSources??[]){p.identifier!=null&&d(p.identifier,p.identifier.location);for(let y of p.streams){y.streamId!==null&&d(y.streamId,y.streamId.location,"a stream id");for(let h of y.streamIdParts)d(h.type,h.type.location,`a stream id part '${h.name}'`)}}let m=new Fe(t);for(let{slice:p}of o.slices){for(let y of p.commands){for(let h of y.properties.filter(g=>g.isIdentifier))d(h.type,h.location);for(let h of[...y.stream?[y.stream]:[],...y.streamCandidates??[]].filter(g=>g.propertyCandidate===null)){let g=m.resolve(h.eventSource,h.stream),b=g.kind===pe.Unique?g.streams[0]:void 0,S=[...h.streamId===null?[]:[{mapping:h.streamId,target:b?.streamId}],...h.streamIdParts.map($=>({mapping:$,target:b?.streamIdParts.find(x=>x.name===$.property)?.type}))];for(let{mapping:$,target:x}of S){if($.source.kind!=="PathExpressionSyntax")continue;let P=u(y.properties,$.source.path);P!==null&&(P.type.name===x?.name&&(n.has(P.type.name)||i.has(P.type.name))||d(P.type,$.source.location,"a stream id route mapping"))}}for(let h of y.produces.filter(g=>o.isEventProduction(g,p))){if(h.for?.kind!=="PathExpressionSyntax")continue;let g=u(y.properties,h.for.path);g!==null&&!g.isIdentifier&&d(g.type,h.for.location)}}for(let y of p.reactions.flatMap(h=>h.triggers)){if(y.source.kind!=="NamedTriggerSourceSyntax")continue;let g=o.resolve(y.source.name,p).declaration?.node,b=(fe(y).data??[]).flatMap($=>$.type===null?[]:[{kind:"PropertySyntax",name:$.name,type:$.type,isIdentifier:!1,location:$.location}]),S=[g?.kind==="EventSyntax"?g.properties:[],b];g?.kind!=="EventSyntax"&&!s.has(y.source.name)&&S.push(...a.get(y.source.name)??[]);for(let $ of y.produces.filter(x=>o.isEventProduction(x,p))){if($.for?.kind!=="PathExpressionSyntax")continue;let x=$.for.path,P=S.map(I=>u(I,x)).find(I=>I!==null&&(n.has(I.type.name)||i.has(I.type.name)));P!=null&&d(P.type,$.for.location)}}}}c(Fi,"validateIdentifierCompliance");function Ui(t,e){let n=c((i,r)=>{for(let o of i.filter(s=>s.isSubject))e.error(l.InvalidSubjectOwner,`The subject modifier is only valid on event properties, not ${r} properties (decision 0008: one data subject per event).`,o.location)},"refuse");for(let i of t.types)n(i.properties,"type");for(let{slice:i}of new ie(t).slices){for(let r of i.commands)n(r.properties,"command");for(let r of i.readModels)for(let o of r.properties.filter(s=>s.isSubject))e.error(l.ReadModelSubjectNotSupported,"Read model subject marks are not yet supported. Chronicle resolves read model subjects and reserves _subject, __subject and __subjects; Screenplay support is tracked in #559.",o.location);for(let r of le(i)){let o=r.properties.filter(s=>s.isSubject);for(let s of o.slice(1))e.error(l.DuplicateEventSubject,`Event '${r.name}' has one data subject (decision 0008); '${s.name}' is an extra mark after '${o[0].name}'. Choose one subject; no automatic repair is safe.`,s.location);for(let s of o){let a=s.type;if(a.isOptional){e.error(l.InvalidSubjectType,"A subject must be required: a null value silently falls back to the event source.",s.location);continue}if(a.isCollection||t.types.some(m=>m.name===a.name)){e.error(l.InvalidSubjectType,"A subject must be a scalar identity, not a collection or composite type.",s.location);continue}let d=t.concepts.filter(m=>m.name===a.name);d.some(m=>m.attributes.some(p=>["pii","sensitive"].includes(p.name)))&&e.error(l.ProtectedSubjectType,`Subject concept '${a.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`,s.location);let u=d.length===1?d[0].type:d.length===0&&["String","Uuid","Int","Decimal","Bool","Date","DateTime"].includes(a.name)?a.name:null;d.length===0&&u===null&&t.imports.some(m=>m.qualifiedName===a.name||m.qualifiedName.split(".").at(-1)===a.name)&&e.warning(l.UnknownType,`Unknown type shape '${a.name}' for subject property '${s.name}'; imported subject identity rules cannot be verified.`,s.location),(d.some(m=>m.type==="Enum")||u!==null&&!$o(a,t))&&e.error(l.InvalidSubjectType,"Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.",s.location)}}}}c(Ui,"validateEventSubjects");var Wi=class extends Ce{static{c(this,"RefusalValueWalker")}declarations;context;slice=null;branch=null;properties=null;target=null;mapping=!1;constructor(e,n){super(),this.declarations=e,this.context=n}visitSlice(e){this.slice=e,super.visitSlice(e),this.slice=null}visitInvocationRefusal(e){this.branch=e,super.visitInvocationRefusal(e),this.branch=null}visitProduces(e){if(this.branch===null||this.slice===null){super.visitProduces(e);return}this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.when!=null&&this.visitCondition(e.when),e.tags.forEach(n=>this.visitTag(n)),this.properties=this.declarations.event(e.event,this.slice)?.properties??null,e.mappings.forEach(n=>this.visitPropertyMapping(n)),this.properties=null}visitPropertyMapping(e){this.mapping=this.branch!==null,this.target=this.declarations.property(this.properties,e.property)?.type??null,super.visitPropertyMapping(e),this.target=null,this.mapping=!1}visitObjectMember(e){let n=this.target;this.target=this.declarations.property(n===null?null:this.declarations.types.get(n.name)?.properties??null,e.name)?.type??null,super.visitObjectMember(e),this.target=n}visitExpression(e){e.kind==="RefusalExpressionSyntax"&&(!this.mapping||this.branch===null||!["reason","constraint","message"].includes(e.member)||e.member==="constraint"&&this.branch.selector!=="constraint"?this.context.error(l.InvalidRefusalValue,`'$refusal.${e.member}' is only available in a refusal branch's event mapping; constraint requires 'by constraint'.`,e.location):this.target!==null&&(this.target.isCollection||this.declarations.compatible({...this.target,name:"String",isOptional:!1,isCollection:!1},this.target)===!1&&!this.declarations.application.concepts.some(i=>i.name===this.target.name&&i.type==="String"))&&this.context.error(l.InvalidRefusalValue,`'$refusal.${e.member}' is a String value, incompatible with '${this.target.name}'.`,e.location));let n=this.target;e.kind==="ListExpressionSyntax"&&n!==null&&(this.target={...n,isCollection:!1}),super.visitExpression(e),this.target=n}};function Jm(t){let e=new Set,n=c((i,r)=>{let o=r||i.authorize!==null;o&&i.slices.forEach(s=>e.add(s)),i.features.forEach(s=>n(s,o))},"collect");return t.modules.forEach(i=>i.features.forEach(r=>n(r,i.authorize!==null))),e}c(Jm,"authorizationGatedSlices");function zi(t,e){let n=new Xe(_e(t));new Wi(n,e).visitApplication(n.application);let i=Jm(n.application);for(let{slice:r}of n.slices){let o=c(d=>n.resolve(d,r,u=>u.constraints),"constraintOf"),s=c((d,u)=>d===u||o(d)!==null&&o(d)?.node===o(u)?.node,"sameConstraint"),a=c((d,u)=>d.selector==="any"&&["any","validation","constraint"].includes(u.selector)||d.selector===u.selector&&(d.selector!=="constraint"||d.constraint===null||u.constraint!==null&&s(d.constraint,u.constraint)),"covers");for(let d of r.reactions)d.runsAs!=null&&!d.triggers.some(u=>u.invokes.length>0||fe(u).implementation)&&e.warning(l.UnusedReactionIdentity,`Reaction '${d.name}' declares an identity but has no invocations or implementation body.`,d.runsAs.location);for(let{reaction:d,invocation:u}of r.reactions.flatMap(m=>m.triggers.flatMap(p=>p.invokes).map(p=>({reaction:m,invocation:p})))){let m=n.resolve(u.command,r,g=>g.commands),p=m!==null&&(m.node.authorize!==null||i.has(m.slice)),y=u.onRefused?.find(g=>g.selector==="authorization");d.runsAs==null&&p&&y===void 0&&e.warning(l.GatedInvocationWithoutIdentity,`Command '${u.command}' is authorization-gated, but reaction '${d.name}' has no declared identity. Declare 'runs as system role "<Role>"'.`,u.location);let h=[];for(let g of u.onRefused??[]){if(h.some(P=>a(P,g))&&e.warning(l.UnreachableRefusalBranch,"This refusal selector is covered by an earlier branch; the first matching branch wins.",g.location),h.push(g),g===y&&d.runsAs==null&&p&&e.warning(l.AuthorizationRefusalWithoutIdentity,`Command '${u.command}' is authorization-gated, but this invocation has no declared identity. This authorization refusal branch always fires in the reference runner because there is no caller. Declare 'runs as system role "<Role>"'; Arc runs commands as the system only for a reactor carrying [ExecuteCommandsAsSystem].`,g.location),g.constraint===null)continue;let b=o(g.constraint);if(b===null){e.error(l.UnknownRefusalConstraint,`Unknown or ambiguous refusal constraint '${g.constraint}'.`,g.location);continue}if(m===null||m.node.handler!==null)continue;let S=[b.node,...b.node.additionalRules];if(S.some(P=>P.kind==="FileConstraintSyntax"))continue;let $=S.map(P=>P.kind==="FileConstraintSyntax"?null:n.event(P.event,b.slice)),x=m.node.produces.map(P=>n.event(P.event,m.slice));$.every(P=>P!==null)&&x.every(P=>P!==null)&&!$.some(P=>x.includes(P))&&e.warning(l.UnreachableRefusalBranch,`Constraint '${g.constraint}' targets none of the events produced by '${u.command}'.`,g.location)}}}}c(zi,"validateReactionRefusals");function Vi(t,e,n){let i=e===null||e.isCollection?void 0:n.concepts.get(e.name),r=i!==void 0&&i.type==="Enum"?i:null,o=c(a=>r!==null&&a.startsWith(`${r.name}.`)?a.substring(r.name.length+1):a,"member");if(e?.isCollection&&t.kind==="ListExpressionSyntax"&&n.compatible({...e,isCollection:!1},{...e,isCollection:!1})===!0){let a=t.items.map(d=>Vi(d,{...e,isCollection:!1,isOptional:!1},n));return a.some(d=>d===void 0)?void 0:{canonical:`[${a.map(Qi).join(",")}]`}}let s=e===null?void 0:n.types.get(e.name)?.properties;if(e!==null&&!e.isCollection&&t.kind==="ObjectExpressionSyntax"&&s!==void 0){let a=t.members.map(d=>{let u=n.property(s,d.name);return{name:d.name,value:u===null?void 0:Vi(d.value,u.type,n)}});return a.some(d=>d.value===void 0)?void 0:{canonical:`{${a.sort((d,u)=>d.name<u.name?-1:d.name>u.name?1:0).map(d=>`${JSON.stringify(d.name)}:${Qi(d.value)}`).join(",")}}`}}if(t.kind==="LiteralExpressionSyntax")return r!==null&&typeof t.value=="string"?o(t.value):t.value;if(t.kind==="PathExpressionSyntax"&&r!==null)return o(t.path)}c(Vi,"redeliveryValue");function Qi(t){return typeof t=="object"&&t!==null?"canonical"in t?t.canonical:kr(t):JSON.stringify(t)}c(Qi,"canonical");function bo(t,e,n,i){let r=Vi(t,n,i),o=Vi(e,n,i);return r===void 0||o===void 0?null:Qi(r)===Qi(o)}c(bo,"sameRedeliveryValue");function Gi(t,e){t=_e(t);let n=new Xe(t);for(let{slice:i}of n.slices)for(let r of i.specifications){let o=r.whenRedelivered;if(o==null)continue;let s=n.event(o.eventType,i),a=n.resolve(o.reaction,i,m=>m.reactions);if(a===null||s===null||!a.node.triggers.some(m=>m.source.kind==="NamedTriggerSourceSyntax"&&n.event(m.source.name,a.slice)===s)){e.error(l.UnknownRedeliveryReaction,`Reaction '${o.reaction}' must resolve unambiguously and observe event '${o.eventType}'.`,o.location);continue}let d=r.given.filter(m=>n.event(m.eventType,i)===s).map(m=>Hm(m,o,s,n,t)),u=d.filter(m=>m===!0).length;d.some(m=>m===null)?e.error(l.UnmatchedRedeliveredOccurrence,`Cannot locate redelivery of '${o.eventType}' uniquely: a given source or locator value is not decidable; use 'for', values, 'stream' or 'no stream'.`,o.location):u!==1&&e.error(l.UnmatchedRedeliveredOccurrence,`Redelivery of '${o.eventType}' matches ${u} given occurrences; use 'for', values, 'stream' or 'no stream' to identify exactly one.`,o.location)}}c(Gi,"validateSpecificationRedelivery");function Hm(t,e,n,i,r){let o=[];e.for!==null&&o.push(t.for===null?null:bo(e.for,t.for,null,i));for(let s of e.values){let a=t.values.filter(d=>d.property===s.property);o.push(a.length===1?bo(s.source,a[0].source,i.property(n.properties,s.property)?.type??null,i):null)}return o.push(tl(t.stream,e.stream,e.noStream,r)),o.includes(!1)?!1:o.includes(null)?null:!0}c(Hm,"matches");var rl=64;function ol(t,e){let n=[];for(let i of t.alternatives){let r=ko(i.condition);r!==null&&(r.length>0&&r.every(o=>n.some(s=>[...s].every(a=>o.has(a))))&&e.warning(l.UnreachableActionAlternative,`Alternative executing '${i.command}' is shadowed by earlier alternatives in this action`,i.location),n.push(...r))}}c(ol,"validateGuardedActionShadowing");function ko(t){if(t.kind==="ComparisonConditionSyntax"){if(t.right.kind!=="LiteralExpressionSyntax")return null;let i=t.right.value,r=JSON.stringify([t.left,t.operator,typeof i,i!==null&&typeof i=="object"?i.value:typeof i=="number"?String(i):i]);return[new Set([r])]}let e=ko(t.left),n=ko(t.right);return e===null||n===null?null:t.operator==="Or"?e.length+n.length>rl?null:[...e,...n]:e.length*n.length>rl?null:e.flatMap(i=>n.map(r=>new Set([...i,...r])))}c(ko,"normalize");var Xm=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function _i(t,e){let n=new Xe(t);for(let{slice:i}of n.slices)for(let r of i.screens)Eo(r.directives,[],i,n,e)}c(_i,"validateGuardedActions");function Eo(t,e,n,i,r){let o=t.filter(a=>a.kind==="ScreenDataSyntax"),s=o.length===0?e:o;for(let a of t)switch(a.kind){case"ScreenGuardedActionSyntax":ey(a,s,n,i,r);break;case"ScreenSectionSyntax":Eo(a.directives,s,n,i,r);break;case"ScreenTemplateReferenceSyntax":for(let d of a.slots)Eo(d.directives,s,n,i,r);break}}c(Eo,"validateContainer");function sl(t,e,n){return n.resolve(t,e,i=>i.readModels)?.node.properties??null}c(sl,"viewProperties");function ey(t,e,n,i,r){let o=e.length===1?sl(e[0].type.name,n,i):null;e.length!==1&&r.warning(l.UnresolvedActionSubject,"A guarded action requires exactly one nearest 'data' subject; no data or equally near data bindings leave 'item' unresolved",t.location);for(let s of t.alternatives){for(let a of Co(s.condition))ll(a.left,a.location,o,n,i,r);al(s.command,s.arguments,o,n,i,r)}t.otherwise?.command!=null&&al(t.otherwise.command,t.otherwise.arguments,o,n,i,r),ol(t,r)}c(ey,"validateAction");function al(t,e,n,i,r,o){let s=r.resolve(t,i,a=>a.commands)?.node;for(let a of e){let d=s?.properties.filter(m=>m.name===a.name);d?.length===0&&o.warning(l.UnknownActionArgumentProperty,`Command '${t}' has no argument property '${a.name}'`,a.location);let u=ll(a.binding,a.location,n,i,r,o,!0);d?.length===1&&u!==null&&d[0].type.isCollection!==u.type.isCollection&&o.warning(l.UnknownActionArgumentProperty,`Command argument '${t}.${a.name}' and subject field '${a.binding}' must have matching collection cardinality`,a.location)}}c(al,"validateArguments");function ll(t,e,n,i,r,o,s=!1){if(!t.startsWith("item.")||n===null)return null;let a=t.substring(5).split(".");for(let[d,u]of a.entries()){let m=n.filter(y=>y.name===u);if(m.length===0||m.length===1&&m[0].type.isCollection&&(!s||d<a.length-1))return o.warning(l.UnknownActionSubjectField,`Unknown or collection-valued subject field '${t}' - guarded actions require an item field path`,e),null;if(m.length!==1)return null;if(d===a.length-1)return m[0];let p=m[0].type;if(n=r.types.get(p.name)?.properties??sl(p.name,i,r),n===null)return(Xm.has(p.name)||r.application.concepts.some(y=>y.name===p.name)&&!r.application.types.some(y=>y.name===p.name))&&o.warning(l.UnknownActionSubjectField,`Subject field '${t}' continues past scalar '${u}'`,e),null}return null}c(ll,"validateItemPath");function Co(t){return t.kind==="ComparisonConditionSyntax"?[t]:[...Co(t.left),...Co(t.right)]}c(Co,"comparisons");function Zi(t,e){let n=t.personas.map(r=>r.name),i=c(r=>{for(let o of r){i(o.features);for(let s of o.slices)for(let a of s.specifications){let d=a.givenCallerPersona;if(d!=null){let u=n.filter(m=>m===d.name).length;u!==1&&e.error(l.InvalidSpecificationCallerPersona,`${u===0?"Unknown":"Ambiguous"} persona '${d.name}' - declared personas: ${n.join(", ")}.`,d.location)}}}},"visit");for(let r of t.modules)i(r.features)}c(Zi,"validatePersonaCallers");function Ki(t,e){let n=new Set;for(let o of t.purposes??[])n.has(o.name)&&e.error(l.DuplicatePurposeDeclaration,`Duplicate purpose '${o.name}' - a purpose is declared once`,o.location),n.add(o.name);for(let o of t.purposes??[])o.interest!==null&&o.basis!=="legitimateInterests"?e.warning(l.PurposeInterestMismatch,`Purpose '${o.name}' declares an interest without basis legitimateInterests`,o.location):o.basis==="legitimateInterests"&&!o.interest?.trim()&&e.warning(l.PurposeInterestMismatch,`Purpose '${o.name}' with basis legitimateInterests has no interest statement (Art. 13(1)(d))`,o.location);let i=[],r=c(o=>{i.push(...o.purposes??[],...o.slices.flatMap(s=>s.purposes??[])),o.features.forEach(r)},"collect");for(let o of t.modules)i.push(...o.purposes??[]),o.features.forEach(r);for(let o of i)n.has(o.name)||e.warning(l.UnknownPurpose,`Unknown purpose '${o.name}' - declare it with 'purpose ${o.name}'`,o.location)}c(Ki,"validatePurposes");function Dt(t){return Array.from(t,e=>{if(e==="\u0131"||e==="\u017F")return e;let n=e.codePointAt(0);if(n>=8064&&n<=8071||n>=8080&&n<=8087||n>=8096&&n<=8103)return String.fromCodePoint(n+8);if(n===8115)return"\u1FBC";if(n===8131)return"\u1FCC";if(n===8179)return"\u1FFC";let i=e.toUpperCase();return Array.from(i).length===1?i:e}).join("")}c(Dt,"ordinalIgnoreCaseKey");function Po(t){let e=Tn(t),n=c((h,g)=>h.map(b=>({syntax:b,rank:e.get(Ke([...g,b.name]))??Number.MAX_SAFE_INTEGER})).sort((b,S)=>b.rank-S.rank).map(b=>b.syntax),"ordered"),i=[],r=c((h,g)=>{let b=[...g,h.name];for(let S of n(h.slices,b))i.push({syntax:S,scope:[...b,S.name],identity:[...b.map($=>`container:${$}`),`slice:${S.name}`],index:i.length});for(let S of n(h.features,b))r(S,b)},"feature");for(let h of n(t.modules,[]))for(let g of n(h.features,[h.name]))r(g,[h.name]);let o=new Map(i.map(h=>[h,new Set([...le(h.syntax).map(g=>Dt(g.name)),...h.syntax.commands.flatMap(g=>g.produces.map(b=>Dt(b.event))),...h.syntax.reactions.flatMap(g=>g.triggers.flatMap(b=>b.produces.map(S=>Dt(S.event))))])])),s=new Map;for(let h of i)for(let g of le(h.syntax)){let b=Dt(g.name);s.has(b)||s.set(b,h)}let a=new Map;for(let h of i){let g=Ke(h.scope);a.has(g)||a.set(g,h)}let d=new Map;for(let h of en.for(t,e).edges.filter(g=>g.kind==="decidesFrom"))for(let g of h.evidence){let b=Ke([...h.consumer.scope,g.name.toLowerCase()]);d.has(b)||d.set(b,a.get(Ke(h.producer.scope)))}let u=[];for(let h of i){let g=new Set,b=Ai(h.syntax).references.filter(S=>S.timeline).map(S=>({event:S.name,location:S.location,readModel:S.targetKind==="ReadModel"}));for(let S of b){let $=Dt(S.event),x=`${S.readModel?"ReadModel":"Event"}:${$}`;if(g.has(x))continue;g.add(x);let P=S.readModel?d.get(Ke([...h.scope,S.event.toLowerCase()])):s.get($);if(P===void 0||P===h)continue;let I=0;for(;I<h.scope.length&&I<P.scope.length&&h.identity[I]===P.identity[I];)I++;if(!(I===h.scope.length||I===P.scope.length)){if(S.readModel){let v=h.identity.slice(0,I+1),E=new Set(i.filter(C=>v.every((k,A)=>C.identity[A]===k)).flatMap(C=>[...o.get(C)]));if(Ts(P.syntax,S.event).some(C=>C.timeline&&C.kind==="usesFactsFrom"&&C.targetKind==="Event"&&E.has(Dt(C.name))))continue}u.push({...S,consumer:h,producer:P,container:Ke(h.identity.slice(0,I)),left:h.identity[I],right:P.identity[I]})}}}let m=c((h,g)=>h.consumer.index-g.consumer.index||h.location.line-g.location.line||h.location.column-g.location.column,"compare"),p=new Set,y=[];for(let h of new Set(u.map(g=>g.container))){let g=u.filter(S=>S.container===h),b=new Map;for(let S of g)b.has(S.left)||b.set(S.left,new Set),b.has(S.right)||b.set(S.right,new Set),b.get(S.left).add(S.right);for(let S of Rn(b).filter($=>$.length>1)){let $=new Set(S),x=g.filter(v=>$.has(v.left)&&$.has(v.right));x.forEach(v=>p.add(v));let P=x.filter(v=>v.consumer.index<v.producer.index).sort(m)[0];if(P===void 0)continue;let I=c(v=>Math.min(...x.flatMap(E=>[E.consumer,E.producer]).filter(E=>{let C=JSON.parse(h);return E.identity[C.length]===v}).map(E=>E.index)),"memberIndex");S.sort((v,E)=>I(v)-I(E)),y.push({edge:P,diagnostic:{severity:"information",code:l.TimelineCycleGroup,message:`Timeline group ${S.map(v=>`${v.startsWith("slice:")?"slice":h===Ke([])?"module":"feature"} '${v.slice(v.indexOf(":")+1)}'`).join(", ")} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`,location:P.location}})}}for(let h of u){if(h.consumer.index>=h.producer.index||p.has(h))continue;let g=h.consumer.scope.slice(0,-1),S=h.producer.scope.length>h.consumer.scope.length&&g.every((x,P)=>h.producer.scope[P]===x)?" The producer is in the consumer's own sub-feature; this cannot be fixed by reordering.":" Consider drawing the producer before the consumer.",$=h.readModel?`reads read model '${h.event}' built by`:`uses event '${h.event}' produced by`;y.push({edge:h,diagnostic:{severity:"information",code:l.EventFromLaterSlice,message:`Slice '${h.consumer.syntax.name}' ${$} slice '${h.producer.syntax.name}' drawn after it.${S}`,location:h.location}})}return y.sort((h,g)=>m(h.edge,g.edge)).map(h=>h.diagnostic)}c(Po,"timelineOrderDiagnostics");function nt(t,e,n=Ot,i=!0,r,o){let s=jt(t,!1,e),a=Oi(s,e,o);a.scope=n,a.streamCandidates=r??rn.capture([s],n,o);let d=Mi(a,s,n);if(i){Gn(d,a),Ki(d,a),Ti(d,a),ri(d,a),Ri(d,a),wi(d,a),ni(d,a);let u=_e(d);ei(u,a),Bi(d,a),Yi(d,a),Fi(u,a),Ui(d,a),zi(d,a),Gi(d,a),_i(d,a),Zi(d,a),d=ai(d,a),nn.validate(d,a);for(let m of ii(d))a.information(m.code,m.message,m.location);for(let m of Po(d))a.information(m.code,m.message,m.location)}return{value:d,diagnostics:a.diagnostics,triggerData:a.triggerData,inputUses:a.inputUses,success:!a.diagnostics.some(u=>u.severity==="error")}}c(nt,"parseForAuthoring");function YO(t){return t===l.LegacyOptionalSuffix||t===l.LegacyComplianceMarker||t===l.RedundantEventId||t===l.PublicTranslationRequiresDirection}c(YO,"isQuickFixDiagnostic");function Io(t,e){return e.code!==l.LegacyOptionalSuffix?0:/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?\?/u.exec(t.slice(e.location.column-1))?.[0].length??0}c(Io,"legacyOptionalTypeLength");function FO(t,e={}){let n=nt(t,void 0,e.placement),i=new Set(Array.from({length:14},(v,E)=>`PLAY0${607+E}`)),r=c(v=>v.success||v.diagnostics.every(E=>E.severity!=="error"||i.has(E.code)),"acceptable"),o=c(v=>new Set(v.diagnostics.filter(E=>E.severity==="error").map(E=>E.code)),"errorCodes");if(!r(n))return()=>[];let s=jt(t),a=new Map,d=new Map;new class extends Ce{visitEvent(v){a.set(v.location.line,v)}visitSlice(v){d.set(v.location.line,v),super.visitSlice(v)}}().visitApplication(n.value);let m=new Map,p=new Map,y=new Map,h;for(let v of s)h=a.get(v.number)??h,h!==void 0&&y.set(v.number,h);for(let v of n.diagnostics){m.set(v.code,(m.get(v.code)??0)+1);let E=s[v.location.line-1],C=Io(E.raw,v);if(C>0)p.set(E.number,{line:E.number,fix:{diagnosticCode:v.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:E.startOffset+v.location.column+C-2,length:1,text:" optional"}]}});else if(v.code===l.LegacyComplianceMarker){let k=ty(E.raw,E.startOffset);k!==void 0&&p.set(E.number,{line:E.number,fix:{diagnosticCode:v.code,title:"Use bare pii and secret compliance markers",scope:"occurrence",edits:[k]}})}else if(v.code===l.PublicTranslationRequiresDirection){let k=d.get(E.number),A=/^\s*/.exec(E.raw)[0],O=t.includes(`\r
19
+ `)?`\r
20
+ `:`
21
+ `,T=[de.Inbound,de.Outbound].map(M=>({direction:M,text:`${O}${A} direction ${M===de.Inbound?"inbound":"outbound"}`})).filter(M=>{let N=Ao(t,[{start:E.startOffset+E.raw.length,length:0,text:M.text}]),j=nt(N,void 0,e.placement),q=o(n);return r(j)&&![...o(j)].some(Q=>Q===l.PublicTranslationRequiresDirection||!q.has(Q))});if(T.length===1){let[{direction:M,text:N}]=T;p.set(E.number,{line:E.number,fix:{diagnosticCode:v.code,title:`Declare 'direction ${M===de.Inbound?"inbound":"outbound"}'`,scope:"occurrence",edits:[{start:E.startOffset+E.raw.length,length:0,text:N}]},change:{node:k,replacement:{...k,direction:M}}})}}else if(v.code===l.RedundantEventId&&fn(E.raw)<0){let k=y.get(E.number);if(k?.id!==k?.name||k===void 0)continue;p.set(E.number,{line:E.number,fix:{diagnosticCode:v.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:E.startOffset,length:(s[E.number]?.startOffset??t.length)-E.startOffset,text:""}]},change:{node:k,replacement:{...k,id:null}}})}}let g=[l.LegacyOptionalSuffix,l.LegacyComplianceMarker],b=jn(n),S=new Map,$,x=new Set,P=new Map,I=c((v,E)=>{let C=Ao(t,v.edits);if(C===void 0)return;let k=nt(C,void 0,e.placement);if(!(!r(k)||jn(k)!==(E===void 0?b:jn(n,[E]))))return k.diagnostics.filter(A=>A.code===v.diagnosticCode).length===(m.get(v.diagnosticCode)??0)-v.edits.length?v:void 0},"verify");return(v,E)=>{let C=typeof v=="number"||v===void 0?void 0:v,k=g.filter(N=>C===void 0?E===void 0||E===N:C.some(j=>j.diagnosticCode===N));for(let N of k.filter(j=>!x.has(j))){let j=[...p.values()].filter(q=>q.fix.diagnosticCode===N);if(j.length>0){let q=I({diagnosticCode:N,title:N===l.LegacyOptionalSuffix?"Use 'optional' throughout this document":"Use bare pii and secret throughout this document",scope:"document",edits:j.flatMap(Q=>Q.fix.edits)});q!==void 0&&P.set(N,q)}x.add(N)}let A=k.flatMap(N=>P.has(N)?[P.get(N)]:[]);if(C!==void 0){if($===void 0){$=new Map;let j=s.flatMap(K=>p.has(K.number)?[p.get(K.number)]:[]),q=j.flatMap(K=>K.fix.edits),Q=Ao(t,q);if(q.length>0&&Q!==void 0){let K=nt(Q,void 0,e.placement),J=j.flatMap(W=>W.change===void 0?[]:[W.change]);if(r(K)&&jn(K)===jn(n,J)){let W=new Map,_=new Map;for(let te of K.diagnostics)W.set(te.code,(W.get(te.code)??0)+1);for(let te of j)_.set(te.fix.diagnosticCode,(_.get(te.fix.diagnosticCode)??0)+te.fix.edits.length);if([..._].every(([te,$e])=>(W.get(te)??0)===(m.get(te)??0)-$e))for(let te of j)$.set(te.line,te.fix)}}}let N=new Map;for(let j of C){let q=$.get(j.line);q?.diagnosticCode===j.diagnosticCode&&N.set(j.line,q)}return[...N.values(),...A]}let O=typeof v=="number"?v:void 0,T=O===void 0?void 0:p.get(O),M;return T!==void 0&&O!==void 0&&(E===void 0||T.fix.diagnosticCode===E)&&(S.has(O)||(S.size===32&&S.delete(S.keys().next().value),S.set(O,I(T.fix,T.change))),M=S.get(O)),[...M===void 0?[]:[M],...A]}}c(FO,"prepareQuickFixes");function ty(t,e){let n=w("^(\\s*concept\\s+\\w+\\s*:\\s*\\w+)((?:[^\\S\\r\\n]+@?\\w+)*)").exec(t);if(n!==null){let r=n[2],o=r.replace(/@pii\b|@?sensitive\b/g,s=>s==="@pii"?"pii":"secret");return o===r?void 0:{start:e+n[1].length,length:r.length,text:o}}let i=w("^(\\s*)(@pii|@?sensitive)\\b").exec(t);return i===null?void 0:{start:e+i[1].length,length:i[2].length,text:i[2]==="@pii"?"pii":"secret"}}c(ty,"complianceMarkerEdit");function jn(t,e=[]){let n=new Map(e.map(i=>[i.node,i.replacement]));return JSON.stringify([t.value,t.triggerData],(i,r)=>["location","usesLocation","targetLocation"].includes(i)?void 0:n.get(r)??r)}c(jn,"verificationShape");function Ao(t,e){let n=[],i=0;for(let r of e){if(r.start<i||r.start<0||r.length<0||r.start+r.length>t.length)return;n.push(t.slice(i,r.start),r.text),i=r.start+r.length}return n.push(t.slice(i)),n.join("")}c(Ao,"applyQuickFixEdits");var on=class{static{c(this,"EventSourceReadConfidence")}complete;sources=new Map;constructor(e,n){this.complete=n;for(let i of e)this.sources.set(i.source.name,[...this.sources.get(i.source.name)??[],i])}static hasUnknownExtent(e){return e.some(n=>n.severity==="error"&&["PLAY0001","PLAY0503","PLAY0164"].includes(n.code))}resolve(e,n){let i=this.sources.get(e)??[],r=n===void 0?[]:i.flatMap(u=>u.source.streams).filter(u=>u.name===n),o=i.length>1||r.length>1,s=!this.complete||i.some(u=>!u.placementResolved),a=o?"ambiguous":s?"incomplete":i.length===1&&(n===void 0||r.length===1)?"unique":"notFound",d=[];return i.length>1&&d.push("Multiple physical parent sources claim the exact name."),r.length>1&&d.push("Multiple physical streams claim the exact parent and local name."),i.some(u=>!u.placementResolved)&&d.push("A physical parent has unresolved import placement."),this.complete||d.push("Physical source extent or placement is incomplete; missing declarations cannot be excluded."),{state:a,sources:i.map(u=>u.source),streams:r,reasons:d}}};var ny=ke("^[A-Za-z_]\\w*$"),ot=c((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),X=c(t=>{throw new ue(t)},"refuse"),bt=c((t,e,n)=>{if(!Array.isArray(t))return X(n);for(let i=0;i<t.length;i++)ot(t[i],e)||X(n)},"collection");function an(t){let e=hi(t);if(e!==void 0&&X(e),t.kind==="ConceptSyntax"){let n=t;for(let i of n.validations??[])i.kind==="DeclarativeValidateSyntax"&&i.rules.some(r=>r.implementation!=null)&&X("Implementation wrappers on named rules are supported only on commands.")}if(t.kind==="ValidationRuleSyntax"){let n=t;n.implementation!=null&&(ot(n.implementation,"ImplementationSyntax")||X("A named rule requires an ImplementationSyntax wrapper."),(n.rule!=="Rule"||n.value?.kind!=="PathExpressionSyntax"||!ot(n.value,"PathExpressionSyntax")||typeof n.value.path!="string"||ny.exec(n.value.path)?.[0]!==n.value.path)&&X("An implementation wrapper requires a valid named rule."),n.file!=null&&n.code!=null&&X("A named rule has at most one file or inline payload."),n.file!=null&&(!ot(n.file,"FileReferenceSyntax")||typeof n.file.path!="string")&&X("A named rule file requires a FileReferenceSyntax payload with a string path."),n.code!=null&&(!ot(n.code,"CodeBlockSyntax")||typeof n.code.language!="string"||typeof n.code.code!="string")&&X("A named rule inline payload requires a CodeBlockSyntax with string language and code."),an(n.implementation))}if(t.kind==="ProducesSyntax"){let n=t,i=n.inlineOperation;if(i!=null){n.inlineEvent!=null&&X("A production cannot declare both an event and an operation."),(n.when!=null||n.event!==i.name||n.for!=null||(n.tags??[]).length>0)&&X("An inline operation requires a matching unconditional target without event metadata."),bt(i.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),bt(n.mappings,"PropertyMappingSyntax","Production mappings must be a collection of mappings."),i.inputs.length!==n.mappings.length&&X("Inline operation inputs and mappings must correspond in order.");for(let r=0;r<i.inputs.length;r++)i.inputs[r].name!==n.mappings[r].property&&X("Inline operation inputs and mappings must correspond in order.")}}if(t.kind==="OperationPhaseSyntax"){let n=t;n.file!=null&&n.code!=null&&X("An operation phase has at most one file or inline payload."),n.implementation!=null&&an(n.implementation)}if(t.kind==="HandlerSyntax"){let n=t;n.implementation!=null&&n.file!=null&&n.code!=null&&X("A handler has at most one file or inline payload.")}if(t.kind==="ImplementationSyntax"){let n=t;bt(n.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let i=0;i<n.hints.length;i++)an(n.hints[i])}if(t.kind==="ImplementationHintSyntax"){let n=t;(typeof n.text!="string"||ui(n.text))&&X("An implementation hint must be nonblank.")}wo(t)}c(an,"validateSyntaxInvariants");function wo(t){let e=c(i=>{Dr(i)||X("Event source and stream names must be identifiers.")},"name"),n=c((i,r)=>{bt(r,"PropertyMappingSyntax","Stream id part mappings must be a collection."),i!==null&&r.length>0&&X("A route cannot map both scalar and composite stream ids."),r.forEach(o=>e(o.property))},"mappings");if(t.kind==="ApplicationSyntax"){let i=t.eventSources;i!==void 0&&bt(i,"EventSourceSyntax","Event sources must be a collection of event source nodes without null elements.")}if(t.kind==="EventSourceSyntax"||t.kind==="EventStreamSyntax"){let i=t;e(i.name),i.id!==null&&(typeof i.id!="string"||i.id.trim()==="")&&X("A rename pin must be nonempty.");let r=i.kind==="EventSourceSyntax"?i.identifier:i.streamId;r!==null&&!ot(r,"TypeRefSyntax")&&X("Source identifiers and stream ids require type reference nodes."),r!==null&&(r.isCollection||r.isOptional)&&X("Source identifiers and stream ids require nonoptional scalar type references."),r!==null&&!di(r.name)&&X("Source identifiers and stream ids require an exact type reference name."),i.kind==="EventSourceSyntax"?bt(i.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements."):(bt(i.streamIdParts,"EventStreamIdPartSyntax","Stream id parts must be a collection."),i.streamId!==null&&i.streamIdParts.length>0&&X("A stream cannot declare both scalar and composite stream ids."),i.streamIdParts.forEach(o=>wo(o)))}if(t.kind==="EventStreamIdPartSyntax"){let i=t;e(i.name),ot(i.type,"TypeRefSyntax")||X("A stream id part requires a type."),(i.type.isOptional||i.type.isCollection)&&X("Source identifiers and stream ids require nonoptional scalar type references."),di(i.type.name)||X("Source identifiers and stream ids require an exact type reference name.")}if(t.kind==="CommandSyntax"){let i=t;i.stream?.propertyCandidate!=null&&X("The authoritative command stream cannot contain an ambiguous property candidate."),i.stream!=null&&!ot(i.stream,"CommandStreamSyntax")&&X("The authoritative command stream must be a command stream node."),i.streamCandidates!==void 0&&bt(i.streamCandidates,"CommandStreamSyntax","Command stream candidates must be a collection without null elements.");let r=i.streamCandidates??[];for(let o=0;o<r.length;o++){let s=r[o];if(wo(s),s.propertyCandidate===null&&i.stream==null&&X("A duplicate route candidate requires an authoritative route."),s.propertyCandidate!==null)for(let a=0;a<i.properties.length;a++)i.properties[a]===s.propertyCandidate&&X("An ambiguous property is owned only by its stream candidate.")}}if(t.kind==="SpecificationEventSyntax"||t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax"){let i=t;i.stream!=null&&i.noStream!=null&&X("An event occurrence cannot declare both stream and no stream."),i.stream!=null&&!ot(i.stream,"SpecificationStreamSyntax")&&X("A specification stream requires a specification stream node."),i.noStream!=null&&!ot(i.noStream,"SpecificationNoStreamSyntax")&&X("An unrouted expectation requires a specification no stream node.")}if(t.kind==="SpecificationStreamSyntax"){let i=t;e(i.eventSource),e(i.stream),i.streamId!==null&&i.streamId.property!=="streamId"&&X("A specification stream maps only streamId."),n(i.streamId,i.streamIdParts)}if(t.kind==="CommandStreamSyntax"){let i=t;e(i.eventSource),e(i.stream),i.streamId!==null&&i.streamId.property!=="streamId"&&X("A command stream maps only streamId."),n(i.streamId,i.streamIdParts);let r=i.propertyCandidate;r!==null&&(r.name!=="stream"||r.type.name!==`${i.eventSource}.${i.stream}`||r.type.isCollection||r.type.isOptional||r.isGenerated||r.isIdentifier||i.streamId!==null||i.streamIdParts.length>0)&&X("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}c(wo,"validateSourceStream");var ft={kinds:["AddMappingSyntax","AllSyntax","ApplicationSyntax","ApplicationTriggerInteractionTriggerSyntax","ArrangementContainerSyntax","ArrangementOverrideSyntax","ArrangementSlotSyntax","ArrangementSyntax","AuthenticatedConditionSyntax","AuthenticationProviderSyntax","AuthenticationSyntax","AuthorizeSyntax","BehaviorArgumentSyntax","BehaviorParameterSyntax","BehaviorSyntax","BuiltInInteractionTriggerSyntax","CaptureAppendSyntax","CaptureChildrenSyntax","CaptureMapEntrySyntax","CaptureNestedSyntax","CaptureSourceSettingSyntax","CaptureSourceSyntax","CaptureSplitSyntax","CaptureSyntax","CaptureTranslationSyntax","CaptureWhenSyntax","CausedByExpressionSyntax","CaseValueExpressionSyntax","ChildrenSyntax","ClaimConditionSyntax","ClaimIdentitySourceSyntax","CodeIdentitySourceSyntax","FileIdentitySourceSyntax","IdentitySyntax","IdentityDetailSyntax","QueryIdentitySourceSyntax","ClearMappingSyntax","ClearWithSyntax","CloseDialogActionSyntax","CodeBlockSyntax","ComponentExposedValueSyntax","ComponentOutletSyntax","ComponentPropertySyntax","CodeValidateSyntax","CommandSyntax","CommandStreamSyntax","ComparisonConditionSyntax","CompositeKeySyntax","ConceptAttributeSyntax","ConceptSyntax","ConcurrencySyntax","ConfirmActionSyntax","ContextExpressionSyntax","IdentityExpressionSyntax","ContributionSyntax","CountMappingSyntax","DeclarativeValidateSyntax","DecrementMappingSyntax","DialogTemplateSyntax","DomainSyntax","EnvironmentExpressionSyntax","EventContextExpressionSyntax","EventInteractionTriggerSyntax","EventSourceIdExpressionSyntax","EventSourceSyntax","EventStreamIdPartSyntax","EventStreamSyntax","EventSpecSyntax","EventSyntax","EverySyntax","ExecuteCommandActionSyntax","ExpressionKeySyntax","FeatureSyntax","FileConstraintSyntax","FileImportSyntax","FileReferenceSyntax","FormColumnSyntax","ExposureSyntax","ExposedPropertySyntax","InstanceContributionsSyntax","InstanceContributionSyntax","ContributedItemSyntax","ContributedItemValueSyntax","ScreenContributionSyntax","TemplateSlotContentSyntax","CommandFormLayoutSyntax","FormLayoutColumnSyntax","FormFieldPlacementSyntax","FormWidthSyntax","FormFieldSyntax","FormPopulateFromItemSyntax","FormPopulateViaQuerySyntax","FormSyntax","FromSyntax","HandlerSyntax","ImplementationSyntax","ImplementationHintSyntax","SystemSyntax","OperationSyntax","OperationPhaseSyntax","SpecificationExampleSyntax","SpecificationParameterSyntax","SpecificationCaseSyntax","SpecificationOperationFailureSyntax","SpecificationOperationSyntax","SpecificationCompensatedSyntax","ImportSyntax","IncrementMappingSyntax","InteractionAlternativeSyntax","InteractionOtherwiseSyntax","InteractionArgumentSyntax","InteractionBindingSyntax","IntervalInteractionTriggerSyntax","IntervalTriggerSourceSyntax","InvokesSyntax","InvocationRefusalSyntax","JoinEventSyntax","JoinSyntax","KeyPartSyntax","LayoutSyntax","ListExpressionSyntax","LiteralExpressionSyntax","LogicalConditionSyntax","LogicalPolicyConditionSyntax","LogicalPolicyRequirementSyntax","ModuleSyntax","NamedTriggerSourceSyntax","NavigateActionSyntax","NavigateBackActionSyntax","NestedSyntax","NotPolicyConditionSyntax","NotifyActionSyntax","OpenDialogActionSyntax","ObjectExpressionSyntax","ObjectMemberSyntax","PathExpressionSyntax","PerformerSyntax","PersonaSyntax","PlaceSyntax","PolicyReferenceSyntax","PolicySyntax","PurposeSyntax","PurposeReferenceSyntax","PurposeTransferSyntax","ProducesSyntax","ProjectionEntersOnSyntax","ProjectionSyntax","ProjectionVariantSyntax","PresentationValueSyntax","PropertyMappingSyntax","PropertySyntax","PropertyResponseSourceSyntax","ResponseFieldSyntax","ScalarCommandResponseSyntax","RecordCommandResponseSyntax","ScalarSpecificationReturnSyntax","RecordSpecificationReturnSyntax","QueryParameterSyntax","QuerySyntax","RaiseTriggerActionSyntax","RawExpressionSyntax","ReactionIdentitySyntax","ReactionSyntax","ReactionTriggerSyntax","RefusalExpressionSyntax","ReadModelSyntax","ReadsSyntax","ReducerRuleSyntax","ReducerSyntax","RefreshQueryActionSyntax","RemoveViaJoinSyntax","RemoveWithSyntax","RequirementSyntax","RoleConditionSyntax","ScheduleTriggerSourceSyntax","ScreenActionSyntax","ScreenNavigationParameterSyntax","ScreenGuardedActionSyntax","ScreenActionAlternativeSyntax","ScreenActionOtherwiseSyntax","ScreenBehaviorSyntax","ScreenCodeSyntax","ScreenComponentSyntax","ScreenColumnSyntax","ScreenDataSyntax","ScreenFieldSyntax","ScreenNavigateSyntax","ScreenSectionSyntax","ScreenSlotSyntax","ScreenSummarySyntax","ScreenSyntax","ScreenTableSyntax","ScreenTemplateReferenceSyntax","ScreenTemplateSyntax","ScreenTitleSyntax","ScreenToolbarSyntax","ScreenUsesBehaviorSyntax","SeedEventSyntax","SeedGroupSyntax","SeedSyntax","SetMappingSyntax","TemplateAssignmentSyntax","TemplateExposedValueSyntax","TemplateOutletSyntax","SetStateActionSyntax","SliceSyntax","SlotSyntax","SourceItemExpressionSyntax","SpecificationAbsentReadModelSyntax","SpecificationCallerClaimSyntax","SpecificationCallerPersonaSyntax","SpecificationCallerSyntax","SpecificationCaptureSyntax","SpecificationClockSyntax","SpecificationCommandSyntax","SpecificationDeniedSyntax","SpecificationErrorSyntax","SpecificationEventSyntax","SpecificationNoResultSyntax","SpecificationStreamSyntax","SpecificationNoStreamSyntax","SpecificationQueryResultSyntax","SpecificationQuerySyntax","SpecificationReadModelSyntax","SpecificationRedeliverySyntax","SpecificationSyntax","SpecificationTriggerSyntax","SpecificationWhenQuerySyntax","StringsExpressionSyntax","SubtractMappingSyntax","TagSyntax","ToolbarItemSyntax","TemplateExpressionSyntax","TemplateInterpolationSyntax","TemplateTextSyntax","ThemeSyntax","TriggerDataSyntax","TriggerSyntax","TypeRefSyntax","TypeSyntax","UiBindingSyntax","UiProfileSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","DependsOnSyntax","UsesBehaviorSyntax","ValidationRuleSyntax","VariantSyntax"],names:["property","value","autoMap","mappings","authentication","behaviors","concepts","domain","eventSources","examples","exposures","fileImports","identity","imports","instanceContributions","layouts","modules","personas","policies","purposes","seeds","sourceOptions","numericMode","systems","templates","themes","triggers","types","uiProfiles","triggerName","children","columns","gap","grow","rows","span","syntaxKind","height","root","width","growFactor","name","mode","overrides","variants","alias","providers","requirement","type","bindings","description","file","order","parameters","event","tags","when","appends","identifiedBy","map","source","translations","settings","separator","targets","key","nested","from","to","expression","fromValue","properties","toValue","parameter","blocks","claim","matches","matchesSubject","code","details","by","query","arguments","onFailure","onResult","onSuccess","language","binding","directives","authorize","concurrency","documentation","handler","produces","reads","response","stream","streamCandidates","validations","eventSource","propertyCandidate","streamId","streamIdParts","left","operator","right","parts","criminal","reason","scope","specialCategory","attributes","values","eventSourceType","eventStreamId","eventStreamType","eventTypes","message","messageIsLiteral","path","contributionPoint","label","navigate","requirements","rules","arrangement","category","content","displayName","exposes","outlets","restrictsScopes","scopes","slots","templateType","usedBehaviors","eventName","id","identifier","streams","generation","hasGenerationMarker","origin","visibility","includeChildren","command","contributions","dependsOn","features","isPlacement","slices","additionalRules","ignoreCasing","releasedBy","pattern","owner","component","editableFields","isCollection","operations","reExposes","restrictsFields","instance","items","field","slot","columnGap","placements","rowGap","index","maxWidth","minWidth","column","columnSpan","row","rowSpan","unit","composeUsing","columnMode","fields","for","generationMode","layout","onSubmit","populate","events","parentKey","implementation","hints","text","compensate","execute","inputs","uses","generatedValues","noStream","operation","qualifiedName","actions","condition","alternatives","otherwise","trigger","amount","onRefused","acknowledge","constraint","selector","on","literalType","dialogTemplates","forms","screenTemplates","screen","operand","level","dialogTemplate","members","hidden","sizeHeight","sizeWidth","slotName","x","y","authorization","basis","basisReference","conditionReference","erasureException","interest","recipients","retention","subjects","transfers","destination","safeguard","inlineEvent","inlineOperation","readModel","sequence","entersOn","isGenerated","isIdentifier","isSubject","filters","isObservable","performer","returnType","roles","runsAs","where","data","invokes","member","severity","role","dayOfMonth","dayOfWeek","time","outcome","behavior","context","icon","presentation","stableId","outlet","route","target","rowClick","fitsSlot","eventSourceId","groups","captures","commands","constraints","direction","projections","queries","reactions","readModels","reducers","screens","specifications","contributes","authenticated","claims","capture","record","instant","commandType","inlineProperty","caseValue","eventType","exactly","results","reaction","cases","given","givenCaller","givenCallerPersona","givenCaptures","givenClock","givenOperationFailures","givenReadModels","thenAbsentReadModels","thenCompensated","thenDenied","thenErrors","thenEvents","thenEventsInAnyOrder","thenNoEvents","thenNoResult","thenOperations","thenQueries","thenReadModels","thenResults","thenReturns","whenAppended","whenCapture","whenClock","whenQuery","whenRedelivered","whenTrigger","compatibleWith","isOptional","bindingKind","componentId","componentPropertyPath","expectedValueType","literal","nullBehavior","rawText","defaultSizeClass","icons","packages","platforms","theme","additionalProperties","rule","places"],rules:[["string"],["ref",26,27,52,53,60,61,63,120,121,133,135,160,164,207,228,232],["object",[[0,0,!0],[1,1,!0]]],["enum","Inherit","Disabled","Enabled"],["ref",0,36,55,57,107,200,229],["array",4],["object",[[2,3,!0],[3,5,!1]]],["ref",10],["null"],["union",7,8],["ref",14],["array",10],["ref",49],["array",12],["ref",59],["union",14,8],["ref",64],["array",16],["ref",100],["array",18],["ref",77],["array",20],["ref",74],["array",22],["ref",33],["union",24,8],["ref",106],["array",26],["ref",79],["array",28],["ref",119],["array",30],["union",31,8],["ref",125],["array",33],["ref",137],["array",35],["union",36,8],["ref",140],["array",38],["ref",141],["array",40],["ref",199],["array",42],["union",43,8],["enum","legacy","exact"],["object",[[22,45,!0]]],["ref",97],["array",47],["ref",201],["array",49],["ref",235],["array",51],["union",52,8],["ref",237],["array",54],["union",55,8],["ref",239],["array",57],["union",58,8],["ref",241],["array",60],["union",61,8],["object",[[4,9,!1],[5,11,!1],[6,13,!1],[7,15,!1],[8,17,!1],[9,19,!1],[10,21,!1],[11,23,!1],[12,25,!1],[13,27,!1],[14,29,!1],[15,32,!1],[16,34,!1],[17,37,!1],[18,39,!1],[19,41,!1],[20,44,!1],[21,46,!1],[23,48,!1],[24,50,!1],[25,53,!1],[26,56,!1],[27,59,!1],[28,62,!1]]],["object",[[29,0,!0]]],["ref",4,6],["array",65],["integer",-2147483648,2147483647],["union",67,8],["number"],["union",69,8],["enum","Flat","Row","Column","Grid"],["object",[[30,66,!1],[31,68,!1],[32,68,!1],[33,70,!1],[34,68,!1],[35,68,!1],[36,71,!0]]],["union",0,8],["object",[[37,73,!1],[38,65,!0],[39,73,!1]]],["boolean"],["object",[[33,75,!1],[40,70,!1],[37,68,!1],[41,0,!0],[35,68,!1],[39,68,!1]]],["enum","Flow","Freeform"],["ref",5],["array",78],["union",79,8],["union",65,8],["ref",247],["array",82],["union",83,8],["object",[[42,77,!0],[43,80,!1],[38,81,!1],[44,84,!1]]],["object",[]],["object",[[45,73,!1],[41,0,!0]]],["ref",9],["array",88],["object",[[46,89,!1]]],["ref",124,139],["object",[[47,91,!0]]],["object",[[41,0,!0],[1,0,!0]]],["ref",238],["union",94,8],["object",[[41,0,!0],[48,95,!1]]],["ref",111],["array",97],["ref",75],["union",99,8],["ref",13],["array",101],["object",[[49,98,!1],[50,73,!1],[51,100,!1],[41,73,!1],[52,68,!1],[53,102,!1]]],["enum","Click","DoubleClick","Select","Submit","Change","Load","Unload","Enter","Leave","Unknown"],["object",[[36,104,!0]]],["ref",149],["array",106],["ref",230],["array",108],["union",109,8],["ref",25],["union",111,8],["object",[[54,0,!0],[3,107,!1],[55,110,!1],[56,112,!1]]],["ref",16],["array",114],["ref",18,22],["array",116],["object",[[57,115,!1],[58,0,!0],[59,117,!1],[0,0,!0]]],["ref",24],["array",119],["object",[[0,0,!0],[60,1,!0],[61,120,!1]]],["object",[[57,115,!1],[59,117,!1],[0,0,!0]]],["ref",20],["array",123],["object",[[62,124,!1],[36,0,!0]]],["array",0],["object",[[63,0,!0],[60,1,!0],[64,126,!1]]],["ref",17],["array",128],["ref",19],["array",130],["ref",21],["union",132,8],["object",[[57,115,!1],[30,129,!1],[65,73,!1],[59,117,!1],[41,0,!0],[66,131,!1],[60,133,!1],[21,46,!1]]],["object",[[67,0,!0],[68,0,!0]]],["enum","PropertyChanged","Added","Removed","Changed","LogicalOr","LogicalAnd","ValueTransition","Expression"],["object",[[69,73,!1],[70,73,!1],[71,126,!1],[36,136,!0],[72,73,!1]]],["object",[[0,73,!1]]],["object",[[73,0,!0]]],["ref",1,28,37,69,93,117,129,147,170,171],["array",140],["object",[[2,3,!0],[74,141,!1],[58,1,!0],[0,0,!0]]],["union",1,8],["object",[[75,0,!0],[76,143,!1],[77,75,!0]]],["object",[[75,0,!0]]],["ref",39],["object",[[78,146,!0]]],["object",[[51,99,!0]]],["ref",34],["array",149],["object",[[50,73,!1],[79,150,!1]]],["ref",30,31,32,35],["object",[[41,0,!0],[60,152,!0],[48,94,!0]]],["object",[[80,1,!0],[81,0,!0]]],["object",[[0,0,!0]]],["object",[[54,0,!0]]],["ref",110],["array",157],["ref",38,51,70,127,128,131,132,159,169,204],["array",159],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1]]],["object",[[78,0,!0],[86,0,!0]]],["ref",240],["object",[[87,163,!0],[41,0,!0]]],["ref",175,177,180,181,182,184,186,187,188,189,191,192,194,195,196],["array",165],["object",[[88,166,!1],[41,0,!0]]],["union",163,8],["object",[[87,168,!1],[0,0,!0],[1,143,!1]]],["ref",11],["union",170,8],["ref",50],["union",172,8],["ref",94],["union",174,8],["ref",144],["array",176],["ref",150],["array",178],["ref",166],["array",180],["union",181,8],["ref",153,154],["union",183,8],["ref",45],["union",185,8],["array",185],["ref",43,56],["array",188],["object",[[89,171,!1],[90,173,!1],[50,73,!1],[91,73,!1],[92,175,!1],[41,0,!0],[93,177,!1],[71,179,!1],[94,182,!1],[95,184,!1],[96,186,!1],[97,187,!1],[98,189,!1]]],["union",178,8],["union",106,8],["object",[[99,0,!0],[100,191,!1],[96,0,!0],[101,192,!1],[102,107,!1]]],["enum","Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Contains","StartsWith"],["object",[[103,0,!0],[104,194,!0],[105,1,!0]]],["ref",118],["array",196],["object",[[106,197,!1],[48,0,!0]]],["object",[[107,75,!1],[41,0,!0],[108,73,!1],[109,73,!1],[110,73,!1]]],["ref",48],["array",200],["union",189,8],["object",[[111,201,!1],[50,73,!1],[51,100,!1],[41,0,!0],[48,0,!0],[98,202,!1],[112,126,!1]]],["object",[[99,75,!0],[113,73,!1],[114,73,!1],[115,73,!1],[116,126,!1]]],["object",[[82,158,!1],[117,0,!0],[118,75,!0],[83,160,!1],[84,160,!1],[85,160,!1]]],["object",[[119,0,!0]]],["ref",186],["union",207,8],["object",[[120,0,!0],[121,73,!1],[122,208,!1],[52,68,!1]]],["ref",172],["array",210],["union",211,8],["ref",246],["array",213],["object",[[123,212,!1],[124,214,!1]]],["ref",7],["union",216,8],["ref",84],["array",218],["ref",202],["array",220],["ref",203],["array",222],["ref",206],["array",224],["ref",245],["array",226],["object",[[125,217,!1],[5,11,!1],[126,73,!1],[127,219,!1],[50,73,!1],[128,73,!1],[129,221,!1],[41,0,!0],[130,223,!1],[131,75,!1],[132,126,!1],[133,225,!1],[134,73,!1],[135,227,!1]]],["object",[[41,0,!0]]],["object",[[136,0,!0]]],["ref",66],["array",231],["object",[[50,73,!1],[137,73,!1],[138,95,!1],[41,0,!0],[139,232,!1]]],["object",[[41,0,!0],[48,94,!0]]],["ref",65],["array",235],["object",[[50,73,!1],[137,73,!1],[41,0,!0],[101,95,!1],[102,236,!1]]],["object",[[54,0,!0],[65,143,!1]]],["integer",0,4294967295],["enum","Private","Public"],["object",[[50,73,!1],[91,73,!1],[51,100,!1],[140,239,!1],[141,75,!1],[137,73,!1],[41,0,!0],[142,73,!1],[71,179,!1],[55,110,!1],[143,240,!1]]],["object",[[2,3,!0],[144,75,!0],[3,5,!1]]],["object",[[82,158,!1],[145,0,!0],[83,160,!1],[84,160,!1],[85,160,!1]]],["object",[[69,1,!0]]],["ref",54],["array",245],["union",246,8],["ref",244],["array",248],["ref",72],["array",250],["ref",142],["array",252],["ref",205],["array",254],["object",[[89,171,!1],[5,11,!1],[146,247,!1],[147,249,!1],[50,73,!1],[91,73,!1],[9,19,!1],[148,251,!1],[11,23,!1],[149,75,!0],[41,0,!0],[19,253,!1],[150,255,!1],[24,50,!1],[135,227,!1]]],["ref",73,242,243],["array",257],["object",[[151,258,!1],[50,73,!1],[51,99,!0],[152,75,!0],[117,73,!1],[41,0,!0],[153,126,!1]]],["object",[[154,0,!0]]],["object",[[121,73,!1],[0,0,!0]]],["ref",78],["array",262],["object",[[155,0,!0],[71,263,!1]]],["object",[[156,0,!0],[157,126,!1],[158,75,!0],[121,73,!1],[159,126,!1],[119,0,!0],[160,73,!1],[161,75,!0]]],["ref",80],["array",266],["object",[[146,267,!1],[162,0,!0]]],["ref",81],["array",269],["object",[[156,0,!0],[163,270,!1],[119,0,!0],[1,143,!1]]],["ref",82],["array",272],["object",[[137,0,!0],[112,273,!1]]],["object",[[164,0,!0],[1,1,!0]]],["object",[[120,0,!0],[88,166,!1],[52,68,!1]]],["object",[[88,166,!1],[165,0,!0]]],["ref",88],["union",278,8],["ref",86],["array",280],["ref",87],["array",282],["object",[[166,279,!1],[31,281,!1],[167,283,!1],[168,279,!1]]],["object",[[169,67,!0],[170,279,!1],[171,279,!1],[39,279,!1]]],["object",[[172,67,!0],[173,68,!1],[164,0,!0],[174,67,!0],[175,68,!1],[39,279,!1]]],["enum","Fraction","Pixels","Percent","Auto"],["object",[[176,287,!0],[1,70,!1]]],["object",[[177,73,!1],[67,73,!1],[121,73,!1],[0,0,!0]]],["object",[[80,73,!1],[81,0,!0]]],["enum","Unspecified","Auto","Manual"],["ref",76],["array",292],["ref",89],["array",294],["ref",85],["union",296,8],["ref",90,91],["union",298,8],["object",[[5,11,!1],[178,291,!0],[31,293,!1],[50,73,!1],[179,295,!1],[180,0,!0],[181,291,!0],[182,297,!1],[41,0,!0],[183,208,!1],[184,299,!1],[135,227,!1]]],["ref",67],["array",301],["ref",47,71],["union",303,8],["object",[[185,302,!1],[65,304,!1],[3,5,!1],[186,143,!1]]],["union",146,8],["ref",95],["union",307,8],["object",[[78,306,!1],[51,100,!1],[187,308,!1]]],["ref",96],["array",310],["object",[[188,311,!1]]],["object",[[189,0,!0]]],["object",[[50,73,!1],[41,0,!0]]],["ref",99],["union",315,8],["object",[[190,316,!1],[50,73,!1],[191,316,!1],[192,179,!1],[41,0,!0],[193,0,!0]]],["object",[[78,306,!1],[50,73,!1],[51,100,!1],[187,308,!1]]],["ref",220],["union",319,8],["ref",219],["union",321,8],["object",[[50,73,!1],[180,143,!1],[194,107,!1],[41,0,!0],[195,320,!1],[96,322,!1],[48,0,!0],[112,107,!1]]],["object",[[41,0,!0],[112,107,!1]]],["object",[[196,0,!0]]],["object",[[196,0,!0],[112,107,!1]]],["object",[[142,73,!1],[197,0,!0],[143,240,!1]]],["ref",46,122],["object",[[198,160,!1],[199,328,!0]]],["object",[[198,160,!1]]],["object",[[87,0,!0],[41,0,!0]]],["ref",108],["array",332],["ref",109],["union",334,8],["ref",3,15,62,112],["object",[[198,160,!1],[200,333,!1],[199,73,!1],[201,335,!1],[202,336,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[203,67,!0],[176,338,!0]]],["ref",115],["array",340],["object",[[145,0,!0],[3,107,!1],[204,341,!1]]],["object",[[205,75,!0],[206,73,!1],[93,177,!1],[207,0,!0]]],["object",[[2,3,!0],[54,0,!0],[3,5,!1]]],["ref",116],["array",345],["object",[[185,346,!1],[208,0,!0],[0,0,!0]]],["object",[[69,1,!0],[0,0,!0]]],["object",[[125,217,!1],[5,11,!1],[126,73,!1],[129,221,!1],[41,0,!0],[130,223,!1],[131,75,!1],[132,126,!1],[133,225,!1],[134,73,!1],[135,227,!1]]],["array",1],["object",[[163,350,!1]]],["union",0,75,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[209,354,!0],[1,355,!0]]],["const","ExactNumber"],["string","^(?:0|-?(?:[1-9][0-9]{0,28}|(?:0|[1-9][0-9]{0,28})\\.[0-9]{0,27}[1-9]))$"],["object",[[209,357,!0],[1,358,!0]]],["union",352,353,356,359],["object",[[1,360,!1]]],["enum","And","Or"],["object",[[103,328,!0],[104,362,!0],[105,328,!0]]],["ref",8,29,123,130,173],["object",[[103,364,!0],[104,362,!0],[105,364,!0]]],["object",[[103,91,!0],[104,362,!0],[105,91,!0]]],["ref",58],["array",367],["union",368,8],["ref",92],["array",370],["union",371,8],["ref",193],["array",373],["object",[[89,171,!1],[5,11,!1],[146,247,!1],[147,249,!1],[50,73,!1],[210,369,!1],[91,73,!1],[9,19,!1],[148,251,!1],[11,23,!1],[211,372,!1],[149,75,!0],[41,0,!0],[19,253,!1],[212,374,!1],[24,50,!1],[135,227,!1]]],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1],[213,0,!0]]],["object",[[2,3,!0],[74,141,!1],[0,0,!0]]],["object",[[214,364,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[82,158,!1],[215,379,!0],[117,0,!0],[118,75,!0],[83,160,!1],[84,160,!1],[85,160,!1]]],["object",[[82,158,!1],[216,0,!0],[83,160,!1],[84,160,!1],[85,160,!1]]],["ref",134],["array",382],["object",[[217,383,!1]]],["object",[[41,0,!0],[1,1,!0]]],["object",[[78,306,!1],[51,100,!1]]],["object",[[50,73,!1],[41,0,!0],[18,126,!1]]],["object",[[218,75,!1],[219,73,!1],[220,73,!1],[221,0,!0],[222,68,!1],[223,68,!1]]],["union",364,8],["object",[[78,306,!1],[199,389,!1],[50,73,!1],[51,100,!1],[41,0,!0]]],["ref",143],["array",391],["object",[[224,73,!1],[225,73,!1],[226,73,!1],[199,73,!1],[227,73,!1],[50,73,!1],[228,73,!1],[229,73,!1],[41,0,!0],[230,126,!1],[231,73,!1],[232,126,!1],[233,392,!1]]],["object",[[234,0,!0],[235,0,!0]]],["ref",68],["union",395,8],["ref",98],["union",397,8],["union",328,8],["object",[[54,0,!0],[180,143,!1],[236,396,!1],[237,398,!1],[3,107,!1],[55,110,!1],[56,399,!1]]],["object",[[2,3,!0],[74,141,!1],[50,73,!1],[51,100,!1],[65,304,!1],[41,0,!0],[238,73,!1],[239,73,!1],[21,46,!1]]],["ref",145],["array",402],["object",[[74,141,!1],[240,403,!1],[41,0,!0]]],["object",[[0,0,!0],[60,1,!0]]],["object",[[241,75,!1],[242,75,!1],[243,75,!1],[41,0,!0],[48,94,!0]]],["ref",151],["object",[[41,0,!0],[60,407,!0],[48,95,!1]]],["object",[[60,407,!0]]],["ref",152],["array",410],["object",[[179,411,!1]]],["object",[[1,1,!0]]],["object",[[179,107,!1]]],["object",[[41,0,!0],[60,143,!1],[48,94,!0]]],["ref",157],["union",416,8],["array",416],["ref",136],["union",419,8],["object",[[89,171,!1],[80,417,!1],[50,73,!1],[244,418,!1],[245,75,!1],[41,0,!0],[246,420,!1],[247,94,!0],[109,73,!1]]],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1],[202,0,!0]]],["object",[[248,126,!1],[36,0,!0]]],["ref",161],["union",424,8],["ref",163],["array",426],["object",[[50,73,!1],[91,73,!1],[41,0,!0],[249,425,!1],[26,427,!1],[250,399,!1]]],["ref",236],["array",429],["ref",114],["array",431],["union",432,8],["union",177,8],["ref",113,126,174],["object",[[78,306,!1],[251,430,!1],[50,73,!1],[51,100,!1],[252,433,!1],[93,434,!1],[94,182,!1],[60,435,!0]]],["object",[[253,0,!0]]],["object",[[50,73,!1],[91,73,!1],[51,100,!1],[41,0,!0],[71,179,!1]]],["object",[[45,73,!1],[80,73,!1],[238,0,!0]]],["object",[[78,306,!1],[50,73,!1],[54,0,!0],[51,100,!1]]],["ref",167],["array",441],["object",[[50,73,!1],[41,0,!0],[238,0,!0],[124,442,!1]]],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1],[81,0,!0]]],["object",[[54,0,!0],[65,143,!1],[186,143,!1]]],["enum","Error","Information","Warning"],["object",[[199,328,!0],[117,73,!1],[254,446,!0]]],["object",[[255,0,!0]]],["enum","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["union",449,8],["string","^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]{1,7})?$"],["object",[[256,68,!1],[257,450,!1],[258,451,!0]]],["object",[[145,0,!0],[121,73,!1],[122,208,!1]]],["ref",178],["array",454],["ref",179],["union",456,8],["object",[[200,455,!1],[121,0,!0],[122,208,!1],[201,457,!1]]],["object",[[82,158,!1],[145,0,!0],[199,328,!0]]],["enum","Hidden","Execute","Unknown"],["object",[[82,158,!1],[145,73,!1],[259,460,!0]]],["object",[[260,10,!0]]],["ref",40],["array",463],["ref",41],["array",465],["ref",148],["array",467],["ref",42],["array",469],["object",[[5,11,!1],[156,0,!0],[261,168,!1],[129,464,!1],[262,73,!1],[41,0,!0],[130,466,!1],[263,468,!1],[71,470,!1],[264,73,!1],[135,227,!1]]],["object",[[80,73,!1],[81,0,!0],[48,94,!0]]],["object",[[121,0,!0],[0,0,!0]]],["ref",176],["array",474],["object",[[80,73,!1],[265,73,!1],[53,475,!1],[266,73,!1],[213,0,!0]]],["ref",185],["array",477],["object",[[179,478,!1],[267,0,!0]]],["ref",83],["array",480],["object",[[146,481,!1],[50,73,!1],[88,166,!1],[51,100,!1],[41,0,!0]]],["ref",183],["array",483],["object",[[5,11,!1],[31,484,!1],[268,208,!1],[267,0,!0],[135,227,!1]]],["ref",188],["array",486],["object",[[41,0,!0],[133,487,!1]]],["object",[[125,217,!1],[5,11,!1],[126,73,!1],[127,219,!1],[50,73,!1],[128,73,!1],[129,221,!1],[269,73,!1],[41,0,!0],[130,223,!1],[131,75,!1],[132,126,!1],[133,225,!1],[134,73,!1],[135,227,!1]]],["ref",231],["array",490],["object",[[163,491,!1],[41,0,!0]]],["object",[[193,226,!0]]],["object",[[54,0,!0],[71,107,!1]]],["ref",197],["array",495],["object",[[270,0,!0],[185,496,!1]]],["ref",198],["array",498],["object",[[271,499,!1]]],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1],[267,0,!0],[1,0,!0]]],["ref",23],["array",502],["ref",44],["array",504],["enum","Inbound","Outbound"],["union",506,8],["array",395],["array",397],["ref",146],["array",510],["ref",158],["array",512],["ref",162],["array",514],["ref",165],["array",516],["union",517,8],["ref",168],["array",519],["union",520,8],["ref",190],["array",522],["ref",225],["array",524],["enum","StateChange","StateView","Automation","Translate"],["object",[[272,503,!1],[273,505,!1],[274,258,!1],[50,73,!1],[275,507,!1],[91,73,!1],[185,508,!1],[9,19,!1],[51,100,!1],[41,0,!0],[159,509,!1],[276,511,!1],[19,253,!1],[277,513,!1],[278,515,!1],[279,518,!1],[280,521,!1],[281,523,!1],[282,525,!1],[24,50,!1],[48,526,!0]]],["object",[[283,73,!1],[41,0,!0]]],["object",[[65,1,!0],[41,0,!0]]],["object",[[48,0,!0],[1,0,!0]]],["ref",209],["array",531],["object",[[284,75,!0],[285,532,!1],[248,126,!1]]],["object",[[286,0,!0],[287,107,!1]]],["object",[[288,0,!0]]],["object",[[289,0,!0],[180,143,!1],[194,107,!1],[290,73,!1],[112,107,!1]]],["ref",27],["union",537,8],["object",[[291,538,!1],[41,73,!1]]],["object",[[292,0,!0],[180,143,!1],[290,73,!1],[195,320,!1],[96,322,!1],[112,107,!1]]],["object",[[99,0,!0],[96,0,!0],[101,192,!1],[102,107,!1]]],["object",[[293,75,!0],[71,107,!1]]],["ref",221],["array",543],["object",[[82,107,!1],[293,75,!0],[81,0,!0],[294,544,!1]]],["object",[[293,75,!0],[290,73,!1],[41,0,!0],[71,107,!1]]],["object",[[292,0,!0],[180,143,!1],[195,320,!1],[295,0,!0],[96,322,!1],[112,107,!1]]],["ref",102],["array",548],["ref",217],["array",550],["ref",211],["union",552,8],["ref",210],["union",554,8],["ref",212],["array",556],["ref",213],["union",558,8],["ref",103],["array",560],["ref",223],["array",562],["union",563,8],["ref",101],["array",565],["ref",208],["array",567],["ref",105],["array",569],["ref",215],["union",571,8],["ref",216],["array",573],["ref",218],["union",575,8],["ref",104],["array",577],["ref",222],["array",579],["ref",155,156],["union",581,8],["ref",214],["union",583,8],["union",550,8],["union",556,8],["ref",227],["union",587,8],["ref",224],["union",589,8],["ref",226],["union",591,8],["object",[[296,549,!1],[50,73,!1],[9,19,!1],[51,100,!1],[297,551,!1],[298,553,!1],[299,555,!1],[300,557,!1],[301,559,!1],[302,561,!1],[303,564,!1],[41,0,!0],[53,566,!1],[21,46,!1],[304,568,!1],[305,570,!1],[306,572,!1],[307,574,!1],[308,551,!1],[309,75,!0],[310,75,!1],[311,576,!1],[312,578,!1],[313,580,!1],[314,564,!1],[315,544,!1],[316,582,!1],[56,584,!1],[317,585,!1],[318,586,!1],[319,559,!1],[320,588,!1],[321,590,!1],[322,592,!1]]],["object",[[202,0,!0],[112,107,!1]]],["object",[[82,107,!1],[81,0,!0]]],["object",[[65,0,!0]]],["enum","Unknown","Action","Navigate","Dialog"],["object",[[262,73,!1],[121,73,!1],[41,0,!0],[53,475,!1],[263,468,!1],[36,597,!0],[267,0,!0]]],["ref",233,234],["array",599],["object",[[106,600,!1]]],["object",[[323,126,!1],[41,0,!0]]],["object",[[251,430,!1],[50,73,!1],[51,100,!1],[41,0,!0]]],["object",[[158,75,!0],[324,75,!0],[41,0,!0]]],["object",[[50,73,!1],[51,100,!1],[41,0,!0],[71,179,!1]]],["enum","Invalid","DataContext","QueryResult","ComponentProperty","Literal"],["enum","OneWay","TwoWay"],["union",607,8],["enum","Propagate","Clear","Preserve"],["union",609,8],["object",[[325,606,!0],[326,73,!1],[327,73,!1],[328,73,!1],[329,143,!1],[42,608,!1],[330,610,!1],[119,0,!0],[81,73,!1],[331,73,!1]]],["object",[[332,73,!1],[333,126,!1],[182,73,!1],[41,0,!0],[334,126,!1],[335,126,!1],[336,73,!1]]],["object",[[151,258,!1],[50,73,!1],[54,0,!0],[152,75,!0],[117,73,!1],[41,0,!0],[153,126,!1]]],["object",[[337,126,!1],[151,258,!1],[50,73,!1],[54,0,!0],[152,75,!0],[117,73,!1],[41,0,!0],[0,0,!0],[153,126,!1]]],["object",[[267,0,!0]]],["ref",12],["array",616],["object",[[82,617,!1],[260,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[78,306,!1],[51,100,!1],[187,308,!1],[117,73,!1],[0,0,!0],[338,619,!0],[254,446,!0],[1,143,!1]]],["ref",138],["array",621],["object",[[37,0,!0],[339,622,!1],[39,0,!0]]]],contracts:[2,6,63,64,72,74,76,85,86,87,90,92,93,96,103,105,113,118,121,122,93,125,127,134,135,137,138,139,142,144,145,147,148,151,153,154,155,156,161,162,164,167,169,147,190,193,195,198,199,203,204,205,206,206,209,155,215,155,228,229,229,206,230,86,233,234,237,238,241,242,243,244,256,259,260,206,261,264,265,268,271,274,275,276,277,284,285,286,288,289,86,290,300,305,309,312,313,314,317,318,323,234,324,325,326,325,327,155,329,330,331,337,339,339,342,343,344,347,348,349,351,361,363,365,366,375,229,376,161,377,378,380,381,384,385,206,386,387,388,229,390,393,229,394,400,238,401,404,93,405,406,155,408,409,412,413,414,415,421,422,313,423,428,436,437,438,439,440,443,444,238,445,447,448,452,453,164,458,459,461,462,147,471,261,472,473,476,167,167,479,482,485,488,489,313,492,493,494,497,500,405,229,96,229,501,527,528,206,529,530,229,533,534,535,536,86,539,540,86,541,86,542,545,546,547,593,594,595,596,2,413,598,601,244,313,602,96,603,604,605,611,612,613,614,615,618,620,623]};var Oo=ft.rules,iy=new Map(Oo.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),dl=new Map(ft.kinds.map((t,e)=>[t,Oo[ft.contracts[e]][1]])),ry=new Map([...dl].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>ft.names[n])])])),cl=c(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function To(t){let e=dl.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!pl(t,e))throw new ue(`Invalid typed members for syntax kind '${t.kind}'.`)}c(To,"validateSyntaxMembers");function Ji(t,e){let n=Hi(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new ue(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}c(Ji,"validateClosedSyntaxMembers");function Hi(t){let e=ry.get(t);if(e===void 0)throw new ue(`Unknown syntax kind '${t}'.`);return e}c(Hi,"syntaxMemberNames");function pl(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,ft.names[n])?Ro(t[ft.names[n]],i):!r)}c(pl,"matchesMembers");function oy(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!Ro(t[n],e))return!1;return!0}c(oy,"allIndicesMatch");function Ro(t,e){let[n,...i]=Oo[e];switch(n){case"ref":return cl(t)&&typeof t.kind=="string"&&i.some(r=>ft.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,s)=>o+(Ro(t,s)?1:0),0);return n==="one"?r===1:r>0}case"const":return t===i[0];case"enum":return i.includes(t);case"null":return t===null;case"array":return Array.isArray(t)&&oy(t,i[0]);case"object":return cl(t)&&Object.keys(t).every(r=>i[0].some(([o])=>ft.names[o]===r))&&pl(t,i[0]);case"integer":case"number":return typeof t=="number"&&Number.isFinite(t)&&(n!=="integer"||Number.isInteger(t))&&(i.length===0||t>=i[0]&&t<=i[1]&&!(n==="integer"&&i[0]===0&&Object.is(t,-0)));case"string":return typeof t=="string"&&(i.length===0||iy.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}c(Ro,"matches");var ay=Object.fromEntries("ApplicationSyntax:policies,seeds;ConceptSyntax:validations;DeclarativeValidateSyntax:requirements;CodeValidateSyntax:code;CaptureAppendSyntax:when,mappings,tags;CaptureChildrenSyntax:map;CaptureNestedSyntax:map;CaptureSyntax:map;EventSpecSyntax:key;FromSyntax:key,parentKey;ChildrenSyntax:identifiedBy;RemoveWithSyntax:key,parentKey;RemoveViaJoinSyntax:key;ProjectionEntersOnSyntax:key;ProjectionSyntax:key;QueryParameterSyntax:source;ProducesSyntax:when;InvokesSyntax:mappings;ReactionSyntax:where;SpecificationSyntax:thenAbsentReadModels,thenQueries".split(";").map(t=>t.split(":")).map(([t,e])=>[t,new Set(e.split(","))])),sy=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function ly(t,e){return ay[t]?.has(e)===!0||sy.test(t)&&(e==="source"||e==="value")}c(ly,"isExactOnlyMember");function ul(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:ly(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}c(ul,"isLegacyOmittedMember");var er=c(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),Xi=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers","directiveLocations"]),tr=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function ir(t){let e=cy(t);return Do(e,"legacy",0),nr(e)}c(ir,"toSyntaxJson");function cy(t){let e=new WeakMap,n=[];function i(o){if(typeof o!="object"||o===null)return o;if(e.has(o))return e.get(o);if(Array.isArray(o)){let d=fl();e.set(o,d);let u=o.length;for(let m=u-1;m>=0;m--)n.push(()=>{d[m]=i(Object.hasOwn(o,m)?o[m]:void 0)});return d}let s=Object.create(null);e.set(o,s);let a=Object.keys(o);!a.includes("kind")&&"kind"in o&&a.unshift("kind");for(let d=a.length-1;d>=0;d--)n.push(()=>{let u=a[d],m=o[u];u==="sourceOptions"&&n.push(()=>{typeof m=="object"&&m!==null&&(Object.getPrototypeOf(m)!==Object.prototype&&Object.getPrototypeOf(m)!==null||Reflect.ownKeys(m).length!==Object.keys(m).length)&&(s[u]=Object.assign(Object.create(null),{numericMode:"invalid"}))}),s[u]=i(m)});return s}c(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}c(cy,"snapshot");function fl(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}c(fl,"dataArray");function nr(t,e="legacy",n=!1){if(Array.isArray(t)){let o=fl();for(let s=0;s<t.length;s++)o.push(nr(t[s],e,n));return o}if(er(t)){if(tr.has(t.kind)&&(e=Zt(t.sourceOptions??We).numericMode),an(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&Ji(t,Xi),t.kind==="ValidationRuleSyntax"){let u=t;u.implementation!=null&&(u.file!=null&&Ji(u.file,Xi),u.code!=null&&Ji(u.code,Xi))}let o=Object.create(null);o.kind=t.kind;let s={...t};t.kind==="ApplicationSyntax"&&s.eventSources===void 0&&(s.eventSources=[]),t.kind==="CommandSyntax"&&s.stream===void 0&&(s.stream=null),t.kind==="CommandSyntax"&&s.streamCandidates===void 0&&(s.streamCandidates=[]);let a=e==="exact"?Hi(t.kind):void 0,d=Object.keys(s).filter(u=>(a===void 0||a.has(u))&&!(e==="legacy"&&!n&&ul(t,u))&&!Xi.has(u)&&!(t.kind==="OperationSyntax"&&u==="usesLocation")).sort(dy);for(let u of d){let m=s[u];t.kind==="ApplicationSyntax"&&u==="identity"&&m==null||(t.kind==="EventSyntax"||t.kind==="ImportSyntax")&&(u==="visibility"&&m==="Private"||u==="origin"&&m==null)||t.kind==="SliceSyntax"&&u==="direction"&&m==null||t.kind==="ConceptAttributeSyntax"&&(u==="scope"||u==="specialCategory")&&m==null||t.kind==="ConceptAttributeSyntax"&&u==="criminal"&&m===!1||t.kind==="PropertySyntax"&&u==="isSubject"&&m===!1||u==="description"&&m==null&&["ConceptSyntax","PolicySyntax","FileConstraintSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","ProjectionSyntax","ScreenSyntax","FormSyntax"].includes(t.kind)||u==="documentation"&&t.kind!=="EventSyntax"&&m==null||t.kind==="SpecificationSyntax"&&u==="description"&&m==null||u==="dependsOn"&&(t.kind==="ModuleSyntax"||t.kind==="FeatureSyntax")&&Array.isArray(m)&&m.length===0||u==="sourceOptions"&&m?.numericMode==="legacy"||(u==="examples"||t.kind==="SpecificationSyntax"&&(u==="parameters"||u==="cases"))&&Array.isArray(m)&&m.length===0||t.kind==="SpecificationErrorSyntax"&&u==="caseValue"&&m==null||u==="purposes"&&Array.isArray(m)&&m.length===0||u==="inlineProperty"&&m==null||(t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax")&&(u==="stream"||u==="noStream")&&m==null||t.kind==="SpecificationSyntax"&&u==="thenNoEvents"&&m===!1||t.kind==="SpecificationSyntax"&&u==="whenRedelivered"&&m==null||t.kind==="InvokesSyntax"&&u==="onRefused"&&Array.isArray(m)&&m.length===0||(o[u]=nr(m,e,n))}return o}if(t===void 0)return null;if(typeof t!="object"||t===null)return t;let i=t,r=Object.create(null);if(i.literalType==="ExactNumber")return r.literalType="ExactNumber",r.value=i.value,r;for(let o of Object.keys(i))o!=="toJSON"&&i[o]!==void 0&&(r[o]=nr(i[o],e,n));return r}c(nr,"write");function Do(t,e,n){if(n>96&&e==="exact")throw new ue("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)Do(t[o],e,n+1);return}if(typeof t!="object"||t===null)return;let i=t;if(tr.has(i.kind)||Object.hasOwn(i,"sourceOptions")){let o=Object.hasOwn(i,"sourceOptions")?Zt(i.sourceOptions):We;if(n>0&&e!==o.numericMode)throw new ue("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!tr.has(i.kind))throw new ue("Exact syntax requires a complete source root.");if(e==="exact"&&er(i)&&To(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&mn(i.text))throw new ue("An exact numeric operand must be an explicit ExactNumber, not opaque numeric text.");if(i.kind==="LiteralExpressionSyntax"&&Object.hasOwn(i,"value")){if(e==="exact"&&(typeof i.value=="number"||i.value!==null&&!["string","boolean","object"].includes(typeof i.value)))throw new ue("Exact source requires supported primitive values or an explicit ExactNumber literal.");if(typeof i.value=="object"&&i.value!==null){let o=i.value;if(o.literalType==="ExactNumber"){if(e!=="exact"||typeof o.value!="string"||st(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new ue("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new ue("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&er(i)?Hi(i.kind):void 0;for(let[o,s]of Object.entries(i))(r===void 0||r.has(o)||er(s)&&tr.has(s.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&Do(s,e,n+1)}c(Do,"validateNumbers");function dy(t,e){return t<e?-1:t>e?1:0}c(dy,"ordinal");function yl(t){let e=[],n=t.map($=>$.value),i=new Map,r=!1;for(let $ of n)try{i.set($,Object.hasOwn($,"sourceOptions")?Zt($.sourceOptions):We)}catch(x){if(!(x instanceof ue))throw x;r=!0,e.push(qn(l.IncompatibleNumericSource,x.message,$.location))}let o=n.filter($=>i.get($)?.numericMode==="exact"||py($)),s=i.get(o[0])??We;for(let $ of o.slice(1))i.get($)?.numericMode!==s.numericMode&&(r=!0,e.push(qn(l.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",$.location)));r&&(s=Ca);let a=new Map,d=Nn(n.flatMap($=>$.concepts),"declaration of",e,void 0,a),u=Nn(n.flatMap($=>$.types),"declaration of",e,void 0,a),m=n.flatMap($=>$.identity==null?[]:[$.identity]);for(let $ of m.slice(1))e.push(qn(l.RepeatedSingularDeclarationAcrossFiles,`The folder already declares an identity block in '${sn(m[0].location.path)}' - a folder compiles to one application, which can have at most one`,$.location));let p=n.map($=>$.domain).filter($=>$!==null);for(let $ of p.slice(1))e.push(qn(l.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${sn(p[0].location.path)}' - a folder compiles to one application, which can have at most one`,$.location));let y=uy(n.flatMap($=>$.modules),e),h=Nn(n.flatMap($=>$.personas),"persona",e),g={kind:"ApplicationSyntax",sourceOptions:s,...m.length===0?{}:{identity:m[0]},domain:p[0]??null,imports:Lo(n.flatMap($=>$.imports),$=>$.qualifiedName),concepts:d,types:u,examples:n.flatMap($=>$.examples??[]),systems:n.flatMap($=>$.systems??[]),purposes:Nn(n.flatMap($=>$.purposes??[]),"purpose",e),eventSources:n.flatMap($=>$.eventSources??[]),declaredTriggers:n.flatMap($=>$.declaredTriggers??[]),modules:y,personas:h,policies:n.flatMap($=>$.policies??[]),seeds:n.flatMap($=>$.seeds??[]),fileImports:n.flatMap($=>$.fileImports),...ml("exposures",n.flatMap($=>$.exposures??[])),...ml("instanceContributions",n.flatMap($=>$.instanceContributions??[])),location:n[0]?.location??{line:1,column:1}},b=new ye(new qe([]));Gn(g,b),e.push(...b.diagnostics);let S=[...t.flatMap($=>$.diagnostics),...e];return{value:g,diagnostics:S,success:!S.some($=>$.severity==="error")}}c(yl,"mergeDocuments");function py(t){if(Ia(t)||t.identity!=null||t.domain!==null||t.concepts.length>0||t.types.length>0||t.personas.length>0||(t.policies?.length??0)>0||(t.purposes?.length??0)>0||(t.seeds?.length??0)>0||(t.systems?.length??0)>0||(t.eventSources?.length??0)>0||(t.examples?.length??0)>0)return!0;let e=c(n=>!n.isPlacement||(n.examples?.length??0)>0||n.slices.length>0||n.features.some(e),"feature");return t.modules.some(n=>!n.isPlacement||(n.examples?.length??0)>0||n.features.some(e))}c(py,"hasDeclarations");function uy(t,e){return vl(t).map(gl).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map(Mo)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),purposes:Lo(n.flatMap(i=>i.purposes??[]),i=>i.name),description:bl(n,`module '${n[0].name}'`,e),documentation:$l(n,`module '${n[0].name}'`,e),authorize:xl(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:Sl(n),features:hl(n.flatMap(i=>i.features),e)})}c(uy,"mergeModules");function hl(t,e){return vl(t).map(gl).map(n=>n.length===1?Mo(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),purposes:Lo(n.flatMap(i=>i.purposes??[]),i=>i.name),description:bl(n,`feature '${n[0].name}'`,e),documentation:$l(n,`feature '${n[0].name}'`,e),authorize:xl(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:Sl(n),features:hl(n.flatMap(i=>i.features),e),slices:Nn(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}c(hl,"mergeFeatures");function Sl(t){return[...t].sort((e,n)=>(e.location.path??"")<(n.location.path??"")?-1:(e.location.path??"")>(n.location.path??"")?1:0).flatMap(e=>e.dependsOn??[])}c(Sl,"groupDependencies");function gl(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}c(gl,"placedLast");function Mo(t){return{...t,isPlacement:!1,features:t.features.map(Mo)}}c(Mo,"unplaced");function xl(t,e,n){let i=[];for(let r of t.filter(o=>o!==null)){let o=i.find(s=>s.location.path!==r.location.path&&JSON.stringify(ir(s))===JSON.stringify(ir(r)));if(o!==void 0){n.push(jo(l.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${sn(o.location.path)}' - this repeated gate is ignored`,r.location));continue}i.push(r)}return i.reduce((r,o)=>et(r,o),null)}c(xl,"combineAuthorization");function Lo(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}c(Lo,"firstOfEach");function vl(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}c(vl,"groupByName");function $l(t,e,n){let i=t.filter(r=>r.documentation!=null);for(let r of i.slice(1).filter(o=>o.documentation!==i[0].documentation))n.push(jo(l.ConflictingDocumentationAcrossFiles,`The ${e} is already documented in '${sn(i[0].location.path)}' - keeping that documentation`,r.location));return i[0]?.documentation??null}c($l,"firstDocumentation");function bl(t,e,n){let i=t.filter(r=>r.description!==null);for(let r of i.slice(1).filter(o=>o.description!==i[0].description))n.push(jo(l.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${sn(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}c(bl,"firstDescription");function Nn(t,e,n,i,r=new Map){let o=[];for(let s of t){let a=r.get(s.name);if(a!==void 0&&a.path!==s.location.path){n.push(qn(l.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${s.name}'${i===void 0?"":` in ${i}`} - already declared in '${sn(a.path)}'`,s.location));continue}a===void 0&&r.set(s.name,s.location),o.push(s)}return o}c(Nn,"declaredInOneFile");var sn=c(t=>t??"another file","describe"),qn=c((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),jo=c((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function ml(t,e){return e.length===0?{}:{[t]:e}}c(ml,"presentOnly");function El(t,e){return yy(t,e).result}c(El,"parsePlacedDocuments");function yy(t,e){let n=rn.capturePlaced(t.filter(g=>g.isPlacementResolved!==!1).map(g=>({lines:jt(g.source,!1,g.path),placement:g.placement})),e),i=t.map(g=>nt(g.source,g.path,g.isPlacementResolved===!1?[]:g.placement,!1,n,e)),r=i.flatMap((g,b)=>(g.value.eventSources??[]).map(S=>({source:S,placementResolved:t[b].isPlacementResolved!==!1}))),o=t.every(g=>g.isPlacementResolved!==!1)&&i.every(g=>!on.hasUnknownExtent(g.diagnostics)),s=i.map((g,b)=>t[b].isPlacementResolved===!1?{...g,value:{...g.value,eventSources:[]}}:g),a=yl(s),d=new ye(new qe([]),void 0,e);a.value.sourceOptions!==void 0&&(d.sourceOptions=a.value.sourceOptions),ni(a.value,d);let u=_e(a.value);Bi(a.value,d),Ri(a.value,d),wi(a.value,d),Ti(a.value,d),ri(a.value,d),ei(u,d,s.flatMap(g=>g.inputUses)),Yi(a.value,d),Fi(u,d),Ui(a.value,d),zi(a.value,d),Gi(a.value,d),_i(a.value,d),Zi(a.value,d),Ki(a.value,d);let m=ai(a.value,d);nn.validate(m,d);for(let g of ii(m))d.information(g.code,g.message,g.location);let p=a.diagnostics,y=new Set(p.map(kl)),h=[...p,...d.diagnostics.filter(g=>!y.has(kl(g)))];return{result:{...a,value:m,diagnostics:h,success:!h.some(g=>g.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(s.map((g,b)=>[t[b].path,g.value]))}}c(yy,"parsePlacedDocumentsWithSyntax");function kl(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}c(kl,"diagnosticKey");var Cl=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,Pl=c(t=>`\\u${t.toString(16).padStart(4,"0")}`,"escape");function hy(){let t="";for(let e=0;e<=65535;e++){if(!Cl.test(String.fromCharCode(e)))continue;let n=e;for(;e<65535&&Cl.test(String.fromCharCode(e+1));)e++;t+=Pl(n)+(e>n?`-${Pl(e)}`:"")}return t}c(hy,"ranges");var Mt=hy();var Sy=new RegExp(`^\\s*example\\s+[A-Z][${Mt}]*\\s*:\\s*([${Mt}.]*)$`),gy=new RegExp(`^\\s*(given|when|then)\\s+(?:(readmodel|append)\\s+)?([${Mt}.]*)$`);function Al(t,e,n,i,r,o){let s=t,a=[],d=o.some(v=>v.severity==="error")?o.some(v=>v.code==="PLAY0519")?"**Invalid duplicate assignments; no effective values selected.**":"**Invalid source; no effective values selected.**":null,u=new Map,m=[],p=c((v,E)=>{if(v.location.path===e&&v.location.line>0)for(let C of i(v.location.line-1))u.set(C,E)},"own"),y=c((v,E)=>{for(let C of v??[])a.push({name:C.name,scope:E,example:C}),p(C,E)},"examples");y(s.examples,[]),a.push(...[...s.concepts,...s.types].map(v=>({name:v.name,scope:[]})));let h=c((v,E)=>{for(let C of v){let k=[...E,C.name];p(C,k),y(C.examples,k);for(let A of C.slices){let O=[...E,C.name,A.name];p(A,O),y(A.examples,O);let T=new Map;for(let M of le(A))T.set(M.name,[...T.get(M.name)??[],M]);for(let M of T.values()){let N=Math.max(...M.map(j=>j.generation));a.push(...M.filter(j=>j.generation===N).map(j=>({name:j.name,scope:O,fixtureKind:"event"})))}a.push(...A.commands.map(M=>({name:M.name,scope:O,fixtureKind:"command"})),...A.readModels.map(M=>({name:M.name,scope:O,fixtureKind:"readmodel"})));for(let M of A.specifications)m.push({node:M,scope:O}),p(M,O),y(M.examples,O)}h(C.features,k)}},"features");for(let v of s.modules)p(v,[v.name]),y(v.examples,[v.name]),h(v.features,[v.name]);let g=c((v,E)=>{let C=v.split("."),k=a.filter(O=>O.name===C.at(-1)),A=C.slice(0,-1);if(A.length)return k.filter(O=>A.length<=O.scope.length&&A.every((T,M)=>O.scope[O.scope.length-A.length+M]===T));for(let O=E.length;O>=0;O--){let T=k.filter(M=>O<=M.scope.length&&E.slice(0,O).every((N,j)=>M.scope[j]===N));if(T.length)return T}return[]},"candidates"),b=c((v,E)=>{let C=g(v,E);return C.length===1?C[0]:void 0},"unique"),S=c(v=>v.example?b(v.example.type,v.scope)?.fixtureKind:v.fixtureKind,"kind"),$=c(v=>[...v.scope.filter(E=>!r.has(E)),v.name].join("."),"display"),x=c((v,E,C=!1,k="")=>a.flatMap(A=>{let O=S(A);if(!O||E&&O!==E||C&&A.example)return[];let T=[...A.scope,A.name].join("."),M=b(A.name,v)===A?A.name:T;if(b(M,v)!==A)return[];let N=k.split(".").slice(0,-1).join(".");return N&&!T.endsWith(`${N}.${A.name}`)?[]:M===T&&A.scope.some(j=>r.has(j))&&b(A.name,v)!==A?[]:[{label:b(A.name,v)===A?A.name:$(A),insertText:N?A.name:M,documentation:A.example?`Example of ${A.example.type}. Step assignments override example values; no implicit defaults.`:`Declared ${O}.`}]}),"targets"),P=c((v,E,C,k,A)=>{if(d)return d;let O=c((W,_,te="")=>{if(new Set(W.map(U=>U.property)).size!==W.length||new Set(_.map(U=>U.property)).size!==_.length)return null;let $e=new Map(W.map(U=>[U.property,{value:U,origin:"example",replaced:void 0}]));for(let U of _){let ce=$e.get(U.property)?.value;$e.delete(U.property),$e.set(U.property,{value:U,origin:ce?"override":"authored",replaced:ce})}return[...$e.values()].map(({value:U,origin:ce,replaced:he})=>`${te}${U.property} = ${mt(U.source)} \u2014 ${ce}${ce==="example"?` ${v.name}`:""}${he?` (replaces ${mt(he.source)} from ${v.name})`:""}`)},"merge"),T=O(v?.values??[],E),M=O(v?.generatedValues??[],C,"generated ");if(!T||!M)return"**Invalid duplicate assignments; no effective values selected.**";let N=k??v?.for,j=v?.stream??v?.noStream,q=A?.stream??A?.noStream,Q=q??j,K=c(W=>W.kind==="SpecificationNoStreamSyntax"?"no stream":`stream ${W.eventSource}.${W.stream}${W.streamId?` streamId = ${mt(W.streamId.source)}`:W.streamIdParts.length?` streamId ${W.streamIdParts.map(_=>`${_.property} = ${mt(_.source)}`).join(", ")}`:""}`,"routeText"),J=Q?[`${K(Q)} \u2014 ${q?j?`override (replaces ${K(j)} from ${v.name})`:"authored":`example ${v.name}`}`]:[];return[...T,...M,...J,...N?[`for ${mt(N)} \u2014 ${k?v?.for?`override (replaces ${mt(v.for)} from ${v.name})`:"authored":`example ${v.name}`}`]:[]].join(`
22
+ `)},"effective"),I=new Map;for(let v of a.filter(E=>E.example?.location.path===e)){let E=v.example,C=E.location.line-1,k=Ae(n[C]??"").match(/^\s*example\s+/)?.[0];k&&I.set(C,{start:k.length+1,length:E.name.length,content:`**example ${$(v)} : ${E.type}**
23
+
24
+ ${S(v)?P(E,[],[],null):"Unresolved or ambiguous type; no effective values selected."}`})}for(let{node:v,scope:E}of m){let C=[...v.given.map(k=>({step:k,name:k.eventType,expected:"event",values:k.values,generated:[],destination:k.for,prefix:/^\s*given\s+/})),...v.givenReadModels.map(k=>({step:k,name:k.name,expected:"readmodel",values:k.properties,generated:[],destination:null,prefix:/^\s*given\s+readmodel\s+/})),...v.when?[{step:v.when,name:v.when.commandType,expected:"command",values:v.when.values,generated:v.when.generatedValues??[],destination:v.when.for,prefix:/^\s*when\s+/}]:[],...v.whenAppended?[{step:v.whenAppended,name:v.whenAppended.eventType,expected:"event",values:v.whenAppended.values,generated:[],destination:v.whenAppended.for,prefix:/^\s*when\s+append\s+/}]:[],...v.thenEvents.map(k=>({step:k,name:k.eventType,expected:"event",values:k.values,generated:[],destination:k.for,prefix:/^\s*then\s+/})),...v.thenReadModels.map(k=>({step:k,name:k.name,expected:"readmodel",values:k.properties,generated:[],destination:null,prefix:/^\s*then\s+readmodel\s+/}))];for(let{step:k,name:A,expected:O,values:T,generated:M,destination:N,prefix:j}of C.filter(q=>q.step.location.path===e)){let q=b(A,E),Q=g(A,E).some(_=>_.example);if(!q?.example&&(q||!Q))continue;let K=k.location.line-1,J=Ae(n[K]??"").match(j)?.[0].length;if(J===void 0)continue;let W=q?S(q)!==O?"**Example kind mismatch; no effective values selected.**":`**${O} ${q.example?.type??A}${q.example?` \u2014 example ${$(q)}`:""}**
25
+
26
+ ${P(q.example,T,M,N,"eventType"in k?k:void 0)}
27
+
28
+ Authored fixture values, not execution results. Matching is unchanged.`:"**Ambiguous example; no effective values selected.**";I.set(K,{start:J+1,length:A.length,content:W})}}return{eventExamples:a.filter(v=>v.example?.location.path===e&&S(v)==="event").map(v=>v.example),completions(v,E){let C=u.get(v)??[],k=E.match(Sy);if(k)return x(C,void 0,!0,k[1]);if(!m.some(({node:N})=>N.location.path===e&&i(N.location.line-1).includes(v)))return null;let O=E.match(gy);if(!O||["clock","caller","capture","trigger","query","result","error","denied","returns","no","operation","compensated"].includes(O[3]))return null;let T=O[2]==="readmodel"?"readmodel":O[2]==="append"||O[1]!=="when"?"event":"command",M=x(C,T,!1,O[3]);return M.length?O[2]?M:[...Zo[O[1]],...M]:null},hover(v,E,C){let k=I.get(v);return k&&E>=k.start&&C<=k.start+k.length?k.content:null}}}c(Al,"exampleAnalysis");function mt(t){switch(t.kind){case"LiteralExpressionSyntax":return typeof t.value=="object"&&t.value!==null?t.value.value:JSON.stringify(t.value);case"ListExpressionSyntax":return`[${t.items.map(mt).join(", ")}]`;case"ObjectExpressionSyntax":return`{ ${t.members.map(e=>`${JSON.stringify(e.name)}: ${mt(e.value)}`).join(", ")} }`;case"RawExpressionSyntax":return t.text;case"CaseValueExpressionSyntax":return`case.${t.parameter}`;case"PathExpressionSyntax":return t.path;case"ContextExpressionSyntax":return`$context.${t.path}`;case"IdentityExpressionSyntax":return`$identity.${t.path}`;case"EventContextExpressionSyntax":return`$eventContext.${t.path}`;case"RefusalExpressionSyntax":return`$refusal.${t.member}`;case"EventSourceIdExpressionSyntax":return"$eventSourceId";case"CausedByExpressionSyntax":return`$causedBy${t.property?`.${t.property}`:""}`;case"EnvironmentExpressionSyntax":return`$env.${t.name}`;case"StringsExpressionSyntax":return`$strings.${t.key}`;case"SourceItemExpressionSyntax":return`$.${t.path}`;case"TemplateExpressionSyntax":return"`"+t.parts.map(e=>e.kind==="TemplateTextSyntax"?e.text:"${"+mt(e.expression)+"}").join("")+"`"}}c(mt,"expressionText");var xy=new RegExp(`^\\s*given caller as\\s+[${Mt}]*$`),vy=new RegExp(`^\\s*(?:given caller as|persona)\\s+([A-Za-z_][${Mt}]*)\\s*$`);function Il(t,e){let n=t,i=new Map(n.personas.map(r=>[r.name,Sn(r,n)]));return{completions(r,o){return Ae(o).length<o.length||!xy.test(o)?null:n.personas.map(s=>({label:s.name,insertText:s.name,documentation:"Authenticated deterministic witness of this persona. Negation, needed nonliteral claims, role-URI claims, implementations and policyless personas require an explicit caller."}))},hover(r,o,s){let a=Ae(e[r]??""),d=vy.exec(a);if(!d||a.slice(o-1,s-1)!==d[1])return null;let u=i.get(d[1]);return u?u.refusal?`**${d[1]} caller** \u2014 ${u.refusal.reason}${u.refusal.policy?` in policy ${u.refusal.policy}`:""}. Use an explicit \`given caller\`.`:`**${d[1]} caller** \u2014 authenticated.
29
+
30
+ Roles: ${u.caller.roles.map(m=>JSON.stringify(m)).join(", ")||"(none)"}.
31
+
32
+ Claims: ${u.caller.claims.map(m=>`${JSON.stringify(m.type)} = ${JSON.stringify(m.value)}`).join(", ")||"(none)"}.
33
+
34
+ Contributions: ${u.contributions.map(m=>`${m.policy}: ${m.kind}${m.type?` ${JSON.stringify(m.type)}`:""} ${JSON.stringify(m.value)}`).join("; ")}. This witnesses one deterministic minimal caller, not every caller fitting the persona.`:null}}}c(Il,"personaAnalysis");function wl(t,e,n,i,r){let o=t,s=e,a=Ne.containersOf(o).filter(p=>![...p.scope,p.name].some(y=>r.has(y))),d=new Map,u=new Map,m=c((p,y,h)=>{for(let g of p){let b=[...y,g.name];if(h){if(g.location.path===n&&g.location.line>0)for(let S of i(g.location.line-1))d.set(S,b)}else{let S=b.join(".");u.set(S,[...u.get(S)??[],...(g.dependsOn??[]).map($=>({target:$.target,...$.location}))])}m(g.features,b,h)}},"inventory");return m(o.modules,[],!1),m(s.modules,[],!0),{completions(p,y,h){let g=d.get(p)??h;if(!g?.length||g.some(S=>r.has(S))||!a.some(S=>[...S.scope,S.name].join(".")===g.join(".")))return[];let b=new Set((u.get(g.join("."))??[]).filter(S=>S.path!==n||S.line!==p+1).map(S=>Ne.resolve(S.target,g,a).resolved));return Ne.candidates(g,a).flatMap(({container:S,reference:$,tier:x})=>{if(b.has(S))return[];let P=[...S.scope,S.name].join(".");if(y&&($=y+S.name,Ne.resolve($,g,a).resolved!==S))return[];let I=S.scope.length===0?"module":x===0?"sibling feature":x!=="qualified"?`feature of ${S.scope.join(".")}`:`feature in ${S.scope.join(".")}`,v=a.indexOf(S);return[{label:y?S.name:$,insertText:y?S.name:$,documentation:`${P} \u2014 ${I}.`,detail:I,sortText:`${String(x==="qualified"?g.length:x).padStart(6,"0")}:${String(v).padStart(6,"0")}`}]})}}}c(wl,"dependencyTargetAnalysis");var SM="Executable as ESM v7. Generated values require fixtures in reference execution; other unadmitted constructs still prevent binding.",Bn=new Map;function $y(t,e){let n=De(t),i=t.flatMap((p,y)=>!n[y]&&ne(p)===0&&/^\w/.test(p)?[p.split(/\s+/)[0]]:[]);if(i.includes("module")||!i.some(p=>["feature","slice","command","event","operation","reaction","specification"].includes(p)))return{source:t.join(`
35
+ `),locations:t.map((p,y)=>({line:y+1,column:0}))};let r=[],o=[],s=!1;t.forEach((p,y)=>{!n[y]&&ne(p)===0&&/^\w/.test(p)&&(s=/^(?:concept|type|import|domain|system|eventsource|policy|persona|identity)\b/.test(p)),(s?r:o).push(y)});let a=i.includes("feature")?1:i.includes("slice")?2:3,d=e.slice(0,a),u=[...r.map(p=>t[p]),...d,...o.map(p=>" ".repeat(a*2)+t[p])].join(`
36
+ `),m=[...r.map(p=>({line:p+1,column:0})),...d.map(()=>({line:0,column:0})),...o.map(p=>({line:p+1,column:a*2}))];return{source:u,locations:m}}c($y,"authoringSource");function by(t,e,n,i="current.play",r=!0){let o=e.map((R,L)=>typeof R=="string"?{path:`other-${L}.play`,source:R}:R).filter(R=>R.path!==i),s=[{path:i,source:t.join(`
37
+ `),placement:n,isPlacementResolved:r},...o],a=new Set(s.flatMap(R=>[...R.source.matchAll(/\w+/g)].map(L=>L[0]).concat(R.placement??[]))),d=c(R=>{let L=R;for(let B=1;a.has(L);B++)L=`${R}${B}`;return a.add(L),L},"fresh"),u=d("EditorAuthoring"),m=d("FragmentFeature"),p=new Set([u,m]),y=s.map((R,L)=>{let B=L===0?t:R.source.split(`
38
+ `),F=d(`Fragment${L}`);p.add(F);let yt=R.placement?.length?{source:R.source,locations:B.map((Lt,Wn)=>({line:Wn+1,column:0}))}:$y(B,[`module ${u}`,` feature ${m}`,` slice StateChange ${F}`]);return{...R,...yt,placement:R.placement??[]}}),h=y[0],g=new Map(y.map(R=>[R.path,R.locations])),b=El([...y.slice(1),h]),S=new Map,$=new Map,x=new WeakSet,P=c(R=>{if(R===null||typeof R!="object"||x.has(R))return;if(x.add(R),Array.isArray(R)){R.forEach(P);return}let L=R;if(typeof L.path=="string"&&typeof L.line=="number"&&typeof L.column=="number"){let B=g.get(L.path)?.[L.line-1];B&&(L.line=B.line,L.column=Math.max(1,L.column-B.column));return}for(let B of Object.values(L))P(B);L.location?.path===i&&(L.kind==="CommandSyntax"&&S.set(L.location.line-1,R),L.kind==="SpecificationSyntax"&&$.set(L.location.line-1,R))},"walk");P(b.value),P(b.physicalEventSources);for(let R of b.diagnostics)P(R.location);let I=b.diagnostics.some(R=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(R.code))return!1;let L=y.find(F=>F.path===R.location.path),B=s.find(F=>F.path===R.location.path)?.source.split(`
39
+ `)[R.location.line-1];return L?.locations.some(F=>F.line===0)&&B!==void 0&&ne(B)===0}),v=b.diagnostics.filter(R=>R.location.path===i).flatMap(R=>(P(R.location),R.location.line>0?[R]:[])),E=new ie(b.value),C=new Set(E.slices.flatMap(({slice:R})=>[...R.commands.flatMap(L=>L.produces),...R.reactions.flatMap(L=>L.triggers).flatMap(L=>L.produces)].filter(L=>L.location.path===i&&!E.isEventProduction(L,R)).map(L=>L.location.line-1)));for(let R of v)R.code==="PLAY0499"&&C.add(R.location.line-1);let k=E.declarations.filter(R=>R.kind===H.Operation).map(R=>({...R.node,scope:R.scope.filter(L=>!p.has(L))})),A=new Map,O=De(t),T=c(R=>{let L=[],B=ne(t[R]);for(let F=R;F<t.length&&!(F>R&&!O[F]&&Ae(t[F]).trim()&&ne(t[F])<=B);F++)L.push(F);return L},"range");for(let{slice:R,scope:L}of E.slices){if(R.location.path===i&&R.location.line>0)for(let B of T(R.location.line-1))A.set(B,{scope:L});for(let B of R.specifications.filter(F=>F.location.path===i&&F.location.line>0))for(let F of T(B.location.line-1))A.set(F,{scope:L});for(let B of R.commands.filter(F=>F.location.path===i&&F.location.line>0))for(let F of T(B.location.line-1))A.set(F,{scope:L,commandLine:B.location.line-1})}let M=new Map(E.declarations.map(R=>[R.node.location,R.scope]));for(let R of k.filter(L=>L.location.path===i)){let L=M.get(R.location);for(let B of T(R.location.line-1))A.set(B,{...A.get(B),scope:L,operation:R})}let N=new Map(k.map(R=>[R.location,R])),j=c((R,L)=>{let B=Ae(t[R.line-1]??""),F=B.slice(R.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return F&&B.slice(R.column-1+F.length,R.column-1+F.length+L.length)===L?{...R,column:R.column+F.length}:R},"referenceLocation"),q=[];for(let{slice:R}of E.slices){for(let L of R.commands)for(let B of L.produces){if(B.location.path!==i)continue;let F=E.resolve(B.event,R),yt=F.declaration?N.get(F.declaration.node.location)??null:null,Lt={name:B.event,location:B.location,targetLocation:B.targetLocation??B.location,kind:F.kind,declaration:yt,mappings:B.mappings};if(q.push(Lt),F.kind===H.Operation)for(let Wn of T(B.location.line-1)){let zo=A.get(Wn);zo&&A.set(Wn,{...zo,production:Lt})}}for(let L of R.specifications)for(let B of[...L.givenOperationFailures??[],...L.thenOperations??[],...L.thenCompensated??[]]){if(B.location.path!==i)continue;let F=E.resolve(B.operation,R);q.push({name:B.operation,location:B.location,targetLocation:j(B.location,B.operation),kind:F.kind,declaration:F.declaration?N.get(F.declaration.node.location)??null:null,mappings:[]})}}let Q={declarations:k,systems:b.value.systems??[],references:q,contexts:A,types:b.value.types,concepts:b.value.concepts,targets:c(R=>{let L=E.slices.find(B=>B.scope.length===R.length&&B.scope.every((F,yt)=>F===R[yt]))?.slice;return L?k.flatMap(B=>{let F=E.resolve(B.name,L).declaration?.node.location===B.location?B.name:[...B.scope,B.name].join(".");return E.resolve(F,L).kind===H.Operation&&E.resolve(F,L).declaration?.node.location===B.location?[{name:F,declaration:B}]:[]}):[]},"targets")},K=b.physicalEventSources.map(R=>R.source),J=new on(b.physicalEventSources,b.sourceInventoryComplete&&!I),W=new Map,_=c((R,L)=>{let B=JSON.stringify([R,L]),F=W.get(B);return F||(F=J.resolve(R,L),W.set(B,F)),{...F,source:F.state==="unique"?F.sources[0]:void 0,stream:F.state==="unique"?F.streams[0]:void 0}},"resolve"),te=new Set(b.value.imports.map(R=>R.qualifiedName)),$e=K.flatMap(R=>R.streams.filter(L=>_(R.name,L.name).state==="unique"&&!te.has(`${R.name}.${L.name}`)).map(L=>({name:`${R.name}.${L.name}`,source:R,stream:L}))),U=new Map,ce=[];for(let R of S.values()){for(let L of T(R.location.line-1))U.set(L,{command:R});for(let L of[...R.produces,...R.validations,...R.handler?[R.handler]:[]])for(let B of T(L.location.line-1))U.delete(B);if(R.stream){ce.push(R.stream);for(let L of T(R.stream.location.line-1))U.set(L,{command:R,route:R.stream})}}let he=Al(b.value,i,t,T,p,b.diagnostics),Re=[...[...$.values()].flatMap(R=>[...R.given.map(L=>({event:L,expectation:!1})),...R.whenAppended?[{event:R.whenAppended,expectation:!1}]:[],...R.thenEvents.map(L=>({event:L,expectation:!0})),...R.whenRedelivered?[{event:R.whenRedelivered,expectation:!0}]:[]]),...(he.eventExamples??[]).map(R=>({event:R,expectation:!0}))];for(let R of Re){let L=R.event;for(let B of T(L.location.line-1))U.set(B,R);if(L.stream){ce.push(L.stream);for(let B of T(L.stream.location.line-1))U.set(B,{...R,route:L.stream})}}for(let R of K.filter(L=>L.location.path===i)){for(let L of T(R.location.line-1))U.set(L,{source:R});for(let L of R.streams)for(let B of T(L.location.line-1))U.set(B,{source:R,stream:L})}let Ct=[...S.values()].flatMap(R=>R.streamCandidates??[]).filter(R=>R.propertyCandidate!==null),Pt={declarations:K,routes:ce,ambiguousCandidates:Ct,contexts:U,targets:$e,resolve:_},Se,be={completions(R,L,B){if(Se===void 0){let F=nt(h.source,i,h.placement,!1).value,yt=c(Lt=>{P(Lt.location),Lt.features.forEach(yt)},"remapDependencyHeaders");F.modules.forEach(yt),Se=wl(b.value,F,i,T,p)}return Se.completions(R,L,B)}};return{identityDetails:(b.value.identity?.details??[]).map(R=>({name:R.name,type:`${R.type.name}${R.type.isCollection?"[]":""}${R.type.isOptional?" optional":""}`,line:R.location.line-1})),commands:S,specifications:$,diagnostics:v,operationProductionLines:C,operations:Q,eventSources:Pt,examples:he,personas:Il(b.value,t),dependencies:be}}c(by,"analyze");function ln(t,e=[],n,i="current.play",r=!0){let o=JSON.stringify([t,e,n,i,r]),s=Bn.get(o);return s===void 0&&(s=by(t,e,n,i,r),Bn.size>=16&&Bn.delete(Bn.keys().next().value),Bn.set(o,s)),s}c(ln,"responseAnalysis");var No="file",ky=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,Ey=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function $M(t){return Ey.test(t)}c($M,"isAbsoluteFileReferencePath");function Cy(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}c(Cy,"withoutComment");function qo(t,e){let n=ne(t),i=Cy(t.slice(n)).trimEnd();if(cr(i)!==No)return;let r=i.slice(No.length),o=r.trim();if(o.length===0||ky.test(o))return;let s=r.length-r.trimStart().length,a=n+No.length+s+1;return{path:o,line:e,startColumn:a,endColumn:a+o.length}}c(qo,"fileReferenceOn");function bM(t){let e=De(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=qo(t[i],i);r&&n.push(r)}return n}c(bM,"fileReferences");function kt(t){let e=!1;return t.map(n=>{if(e)return n.trim()==="```"&&(e=!1),n;let i=Ae(n);return/^\s*```(?:[a-z]+)?\s*$/.test(i)&&(e=!0),i.trimEnd()})}c(kt,"eventAnalysisSource");var Py=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,Ay=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?(\s+subject)?\s*$/,Ol=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,Iy=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,wy=["authorize","produces","reads"],Oy=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,Ty=Pn,Ry=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],Dy=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function Et(t){return t.typeReference??dn(t.type)}c(Et,"propertyTypeReference");function Bo(t,e){let n=t.slice(e-1).match(/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?(?:\?|\s+optional\b)?/u)?.[0]??"";return{text:n,startColumn:e,endColumn:e+n.length}}c(Bo,"sourceTypeAt");function Yo(t,e,n){return e.map(i=>({index:i,match:t[i].match(Ay)})).filter(i=>i.match!==null).filter(({match:i})=>i[1].startsWith("@")||i[1]==="as"||!n.includes(i[1])).map(({index:i,match:r})=>({name:r[1].replace(/^@/,""),type:r[2],typeReference:dn(r[2]),sourceType:Bo(t[i],t[i].match(/^\s*\S+\s+/)[0].length+1),isIdentifier:r[4]!==void 0,...r[3]!==void 0?{isGenerated:!0}:{},...r[5]!==void 0?{isSubject:!0}:{},line:i}))}c(Yo,"propertiesIn");function Fn(t,e,n,i){let r=[];for(let o=n+1;o<t.length;o++){if(e[o])continue;let s=t[o];if(s.trim().length!==0){if(ne(s)<=i)break;r.push(o)}}return r}c(Fn,"collectBody");function cn(t,e,n,i){let r=Fn(t,e,n,i).filter(a=>!e[a]&&!/^\s*(?:\/\/|#)/.test(t[a]));if(!/^\s*command\b/.test(t[n]))return r;let o,s=!1;return r.filter(a=>{let d=ne(t[a]),u=t[a].trim();return o!==void 0&&d>o&&(!s||Oy.test(u))?!1:(o=u!=="validate csharp"&&Yo(t,[a],wy).length>0||/^description(?:\s|$)/.test(u)?void 0:d,s=/^authorize(?:\s|$)/.test(u),!0)})}c(cn,"directBody");var Yn=new Map;function Un(t){let e=t.join(`
40
+ `),n=Yn.get(e);if(n)return n;let i=ln(t),r={...i.identityDetails?.length?{identityDetails:i.identityDetails}:{},authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=kt(t);let o=De(t),s=t,a=o,d=t.map(u=>u.replace(/\s*=(?!=|>).*/,""));for(let u=0;u<t.length;u++){if(o[u])continue;let m=t[u],p=m.trim(),y=ne(m),h=s[u].trim().match(/^import\s+([\w.]+)(?:\s+from\s+"(?:[^"\\]|\\.)*")?\s*$/);if(h&&y===0){let E=h[1],C=E.split(".").pop()??E;r.imports.push({qualifiedName:E,shortName:C,line:u});continue}let g=p.match(Py);if(g){let E=Fn(t,o,u,y).map(A=>t[A].trim()),C={};for(let A of E){let O=A.match(Ol);O&&C[O[1]]===void 0&&(C[O[1]]=O[2])}let k=g[2]==="Enum"?E.filter(A=>!Ol.test(A)):[];r.concepts.push({name:g[1],primitive:g[2],attributes:g[3].trim().split(/\s+/).filter(Boolean),attributeReasons:C,enumValues:k,line:u});continue}let b=p.match(/^type\s+(\w+)\s*$/);if(b){r.types.push({name:b[1],properties:Yo(t,Fn(t,o,u,y),Vo),line:u});continue}let S=p.match(/^policy\s+(\w+)\s*$/);if(S){let E=Fn(t,o,u,y).filter(C=>!o[C]).map(C=>t[C].trim());r.policies.push({name:S[1],requires:E,line:u});continue}let $=s[u].trim().match(/^(?:(?:produces|(?<public>public))\s+)?event\s+(?<name>\w+)(?:\s+generation\s+(?<generation>\d+))?(?:\s+from\s+(?<origin>"(?:[^"\\]|\\.)*"))?\s*$/);if($){let E=p.startsWith("produces "),C=cn(s,a,u,y),k=E?C:C.filter(A=>qo(s[A],A)===void 0);r.events.push({name:$.groups.name,...$.groups.generation?{generation:Number($.groups.generation)}:{},...$.groups.public||$.groups.origin?{visibility:se.Public}:{},...$.groups.origin?{origin:V($.groups.origin.slice(1,-1))}:{},inline:E,properties:Yo(E?d:s,k,E?Ry:Ty),line:u});continue}let x=i.commands.get(u);if(x){let E=cn(t,o,u,y),C=E.filter(k=>/^\s*produces\b/.test(t[k])&&!i.operationProductionLines?.has(k));r.commands.push({name:x.name,properties:x.properties.map(k=>({name:k.name,type:`${k.type.name}${k.type.isCollection?"[]":""}${k.type.isOptional?" optional":""}`,typeReference:{name:k.type.name,isCollection:k.type.isCollection,isOptional:k.type.isOptional},sourceType:Bo(t[k.type.location.line-1],k.type.location.column),isIdentifier:k.isIdentifier||/\sidentifier\s*$/.test(t[k.location.line-1]),...k.isGenerated?{isGenerated:!0}:{},line:k.location.line-1})),response:x.response,productionHeaders:C,produces:C.flatMap(k=>{let A=s[k].trim(),O=/^produces\s+event\b/.test(A),T=/^produces\s+when\b/.test(A),M=T?cn(s,a,k,ne(s[k]))[0]:k;if(M===void 0)return[];let N=T?s[M].trim():A.match(O?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(N===void 0||!/^[A-Za-z_]\w*$/.test(N))return[];let j=cn(s,a,M,ne(s[M])),q=j.map(J=>s[J].trim().match(/^for(?:\s+(.*))?$/)).filter(J=>J!==null),Q=q.length===0?void 0:q.length===1?q[0][1]??"":"",K=j.flatMap(J=>{let W=s[J].trim().match(O?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return W===null?[]:[{name:W[1].replace(/^@/,""),source:W[2],line:J}]});return[{name:N,inline:O,conditional:T,line:k,target:Q,mappings:K}]}),reads:E.filter(k=>!o[k]).map(k=>({line:k,match:t[k].match(Iy)})).filter(k=>k.match!==null).map(({line:k,match:A})=>({view:A[1],...A[2]?{alias:A[2]}:{},...A[3]?{by:A[3]}:{},line:k})),line:u});continue}let P=p.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(P){let E=Fn(t,o,u,y).map(C=>({index:C,match:t[C].match(Dy)})).filter(C=>C.match!==null).map(({index:C,match:k})=>({name:k[1],type:k[2],typeReference:dn(k[2]),sourceType:Bo(t[C],t[C].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:C}));r.queries.push({name:P[1],returnType:P[2],returnTypeReference:dn(P[2]),parameters:E,line:u});continue}let I=p.match(/^screen\s+(\w+)\s*$/);if(I){r.screens.push({name:I[1],line:u});continue}let v=p.match(/^trigger\s+(\w+)\s*$/);v&&y===0&&r.triggers.push({name:v[1],line:u})}return Yn.size>=16&&Yn.delete(Yn.keys().next().value),Yn.set(e,r),r}c(Un,"scanDocument");function rr(...t){return{...t.some(e=>e.identityDetails?.length)?{identityDetails:t.flatMap(e=>e.identityDetails??[])}:{},authoringSources:t.flatMap(e=>e.authoringSources??[]),...t.some(e=>e.authoringDocuments)?{authoringDocuments:t.flatMap(e=>e.authoringDocuments??[])}:{},eventSources:t.flatMap(e=>e.eventSources??[]),imports:t.flatMap(e=>e.imports),concepts:t.flatMap(e=>e.concepts),types:t.flatMap(e=>e.types),policies:t.flatMap(e=>e.policies),events:t.flatMap(e=>e.events),commands:t.flatMap(e=>e.commands),queries:t.flatMap(e=>e.queries),screens:t.flatMap(e=>e.screens),triggers:t.flatMap(e=>e.triggers)}}c(rr,"mergeSymbols");function Tl(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...rr(Un(t),e??rr()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}c(Tl,"symbolsForBuffer");function or(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}c(or,"knownEventNames");var My=["Startup","Shutdown"];function NM(t){return[...or(t),...t.triggers.map(e=>e.name),...My]}c(NM,"knownTriggerNames");function Fo(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}c(Fo,"knownTypeNames");function Uo(t){let e=t.properties.filter(o=>o.isIdentifier&&!Et(o).isOptional&&!Et(o).isCollection),n=e.length===1?e[0].name:void 0,i=t.produces??[],r=i.some(o=>o.target!==void 0&&o.target!==n)||i.some(o=>o.inline&&o.target===void 0)&&i.some(o=>!o.inline&&o.target===void 0);return{identifier:n,mixed:r}}c(Uo,"productionDestinations");function VM(t,e){let n=ln(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=kt(t);return Un(i).commands.map(r=>({...r,produces:r.produces?.filter(o=>!n.operationProductionLines?.has(o.line)&&n.operations.references.some(s=>s.location.line-1===o.line&&s.kind==="event")),productionHeaders:r.productionHeaders?.filter(o=>!n.operationProductionLines?.has(o))})).flatMap(r=>{let{identifier:o,mixed:s}=Uo(r);if(s||r.productionHeaders?.length!==r.produces?.length)return[];let a=r.produces?.some(d=>d.target!==void 0||d.inline);return(r.produces??[]).flatMap(d=>d.target!==void 0||d.inline&&(o===void 0||/\bgeneration\b/.test(i[d.line]))?[]:!d.inline&&a?[]:[{line:d.line,column:i[d.line].length+1,label:d.inline?`for ${o}`:"for <new event source>"}])})}c(VM,"destinationHints");var ee={repeatedSingularDeclarationAcrossFiles:"PLAY0172",invalidIdentityDeclaration:"PLAY0633",duplicateIdentity:"PLAY0634",invalidIdentityDetail:"PLAY0635",unknownIdentitySource:"PLAY0636",identityDetailWithoutSource:"PLAY0637",identitySourceWithBody:"PLAY0638",duplicateIdentityDetail:"PLAY0639",builtInIdentityDetail:"PLAY0640",unknownIdentityQuery:"PLAY0641",invalidIdentityQuery:"PLAY0642",identityQueryWithoutKey:"PLAY0643",invalidIdentityQueryKey:"PLAY0644",identityQueryAuthorizationDependency:"PLAY0645",identityQueryTypeMismatch:"PLAY0646",invalidReactionIdentity:"PLAY0647",gatedInvocationWithoutIdentity:"PLAY0648",unusedReactionIdentity:"PLAY0649",unusedReactionRole:"PLAY0650",unsatisfiedReactionIdentity:"PLAY0651",reactionPrivilegeEscalation:"PLAY0652",commandProducesPublicEvent:"PLAY0607",publicEventRequiresOutboundTranslation:"PLAY0608",outboundPublicEventCount:"PLAY0609",foreignPublicEventConsumer:"PLAY0610",outboundTranslationInput:"PLAY0611",inboundTranslationOutput:"PLAY0612",foreignPublicEventProduced:"PLAY0613",publicTranslationRequiresDirection:"PLAY0614",translationConstructDirection:"PLAY0615",inboundTranslationInput:"PLAY0616",outboundTranslationOutput:"PLAY0617",eventTargetOutsideOutboundTranslation:"PLAY0618",eventsSourceOutsideInboundTranslation:"PLAY0619",invalidCaptureEventsSource:"PLAY0620",invalidDescription:"PLAY0145",emptyDescription:"PLAY0146",duplicateDescription:"PLAY0147",unknownConceptDirective:"PLAY0010",attributeReasonWithoutAttribute:"PLAY0012",duplicateAttributeReason:"PLAY0013",legacyComplianceMarker:"PLAY0565",unknownComplianceMarker:"PLAY0566",invalidSecretScope:"PLAY0567",duplicateSecretScope:"PLAY0568",secretScopeIgnoredForPii:"PLAY0569",invalidPersonalDataQualifier:"PLAY0570",duplicateSpecialCategory:"PLAY0571",invalidPurposeDeclaration:"PLAY0596",invalidPurposeVocabulary:"PLAY0597",duplicatePurposeField:"PLAY0598",duplicatePurposeDeclaration:"PLAY0599",unknownPurpose:"PLAY0600",purposeInterestMismatch:"PLAY0601",personalDataWithoutPurpose:"PLAY0602",specialDataWithoutCondition:"PLAY0603",criminalDataWithoutAuthorization:"PLAY0604",purposeWithoutBasis:"PLAY0605",unusedPurpose:"PLAY0606",duplicateEventSubject:"PLAY0590",invalidSubjectType:"PLAY0591",protectedSubjectType:"PLAY0592",invalidSubjectOwner:"PLAY0593",readModelSubjectNotSupported:"PLAY0594",invalidSubjectModifierOrder:"PLAY0595",conflictingScreenDataBinding:"PLAY0530",screenDataQueryMismatch:"PLAY0531",actionWithoutInputSurface:"PLAY0532",commandWithoutInputSurface:"PLAY0533",readModelFieldWithoutOrigin:"PLAY0534",queryParameterNotHeldByView:"PLAY0535",unconsumedEvent:"PLAY0536",unreachableScreen:"PLAY0537",invalidSpecificationCallerPersona:"PLAY0572",unsynthesizablePersonaCaller:"PLAY0573",personaWithoutGate:"PLAY0574",gateWithoutPersona:"PLAY0575",ambiguousPersonaCaller:"PLAY0576",invalidSpecificationParameter:"PLAY0577",invalidSpecificationCase:"PLAY0578",duplicateSpecificationParameter:"PLAY0579",duplicateSpecificationCase:"PLAY0580",incompleteSpecificationTable:"PLAY0581",invalidSpecificationCaseAssignment:"PLAY0582",invalidSpecificationCaseValue:"PLAY0583",invalidSpecificationCaseReference:"PLAY0584",optionalSpecificationParameterTarget:"PLAY0585",specificationCaseNameCollision:"PLAY0586",incompatibleSpecificationParameterType:"PLAY0587",unusedSpecificationParameter:"PLAY0588",singularSpecificationTableExpansion:"PLAY0589",invalidActionAlternative:"PLAY0341",guardedActionWithoutAlternatives:"PLAY0342",misplacedActionOtherwise:"PLAY0343",unsupportedActionConditionOperand:"PLAY0344",unknownActionSubjectField:"PLAY0345",unresolvedActionSubject:"PLAY0346",unreachableActionAlternative:"PLAY0347",unknownActionArgumentProperty:"PLAY0348",invalidRefusalBranch:"PLAY0538",invalidRefusalBranchBody:"PLAY0539",unreachableRefusalBranch:"PLAY0540",invalidRefusalValue:"PLAY0541",unknownRefusalConstraint:"PLAY0542",unmatchedRedeliveredOccurrence:"PLAY0543",unknownRedeliveryReaction:"PLAY0544",invalidNoEventsExpectation:"PLAY0545",indeterminateNegatedClaimTarget:"PLAY0546",invalidAbsentReadModelStep:"PLAY0453",unknownConstraintProperty:"PLAY0391",invalidSpecificationExample:"PLAY0518",duplicateSpecificationAssignment:"PLAY0519",unknownReadModelProperty:"PLAY0514",piiNotSupportedOnIdentifier:"PLAY0515",invalidEventSourceDeclaration:"PLAY0503",invalidCommandStream:"PLAY0504",invalidSpecificationStream:"PLAY0547",specificationStreamOnCommand:"PLAY0548",invalidSpecificationStreamRoute:"PLAY0549",invalidSpecificationStreamEventSource:"PLAY0550",specificationStreamContradictsCommand:"PLAY0551",ambiguousCommandStream:"PLAY0505",unsupportedStreamIdType:"PLAY0506",redundantSourceStreamId:"PLAY0507",eventFromLaterSlice:"PLAY0516",timelineCycleGroup:"PLAY0517",invalidSpecificationExampleBody:"PLAY0526",undeclaredDependency:"PLAY0552",unusedDependencyDeclaration:"PLAY0553",invalidDependencyTarget:"PLAY0554",repeatedDependencyDeclaration:"PLAY0555",mutualDependencyDeclarations:"PLAY0556",authorizationRefusalWithoutIdentity:"PLAY0557",invalidDocumentation:"PLAY0558",conflictingDocumentationAcrossFiles:"PLAY0559",unsupportedInteractionAlternatives:"PLAY0560",mixedInteractionAlternatives:"PLAY0561",interactionAlternativeWithoutActions:"PLAY0562",inlineInteractionAlternative:"PLAY0563",legacyInteractionWhere:"PLAY0564",ambiguousReference:"PLAY0198",invalidImplementationBlock:"PLAY0492",invalidImplementationHint:"PLAY0493",conflictingImplementationSources:"PLAY0494",eventSourceIdInPayload:"PLAY0469",explicitProducesTargetsRequired:"PLAY0470",redundantEventId:"PLAY0471",invalidEventId:"PLAY0472",inlineEventCollision:"PLAY0473",inlineEventOutsideCommand:"PLAY0474",inlineEventGeneration:"PLAY0475",reservedProductionMetadata:"PLAY0476",invalidEventDocumentation:"PLAY0477",tabIndentation:"PLAY0006",unknownPrimitiveType:"PLAY0008",unknownSliceType:"PLAY0028",duplicateCommandIdentifier:"PLAY0036",unknownContextPath:"PLAY0153",unknownContextCausedByProperty:"PLAY0154",unknownContextIdentityProperty:"PLAY0155",unclosedCodeBlock:"PLAY0164",unknownType:"PLAY0165",unknownEvent:"PLAY0166",unknownPolicy:"PLAY0167",duplicateDeclaration:"PLAY0168",unknownEventContextMember:"PLAY0295",unknownEventContextPath:"PLAY0296",eventContextPathBelowCollection:"PLAY0297",missingEventContextPath:"PLAY0298",unresolvedDynamicKeySource:"PLAY0299",invalidFileImport:"PLAY0454",omittedProductionDestination:"PLAY0478",legacyOptionalSuffix:"PLAY0479",invalidOptionalModifierOrder:"PLAY0480",optionalReadsNotSupported:"PLAY0481",unavailableResponseExecution:"PLAY0268",generatedPropertyOutsideCommand:"PLAY0482",invalidGeneratedType:"PLAY0483",invalidGeneratedModifierOrder:"PLAY0484",generatedPropertyInput:"PLAY0485",invalidCommandResponse:"PLAY0486",invalidResponseSource:"PLAY0487",duplicateResponseField:"PLAY0488",invalidResponseShape:"PLAY0489",invalidGeneratedFixture:"PLAY0490",invalidReturnExpectation:"PLAY0491"};var Ly=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,jy=/^import\s+"/;function Dl(t){return jy.test(t.trim())}c(Dl,"isFileImportLine");function Wo(t,e){let n=ne(t),i=t.slice(n).match(Ly);if(!i)return;let r=n+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:r,endColumn:r+i[2].length}}c(Wo,"fileImportOn");function KM(t){let e=De(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=Wo(t[i],i);r&&n.push(r)}return n}c(KM,"fileImports");var Rl=c(t=>t.split("/").slice(0,-1),"folderOf");function Ny(t,e){let n=e.split("/"),i=0;for(;i<t.length&&i<n.length-1&&t[i]===n[i];)i++;return[...t.slice(i).map(()=>".."),...n.slice(i)].join("/")}c(Ny,"relativeTo");function JM(t,e){let n=Rl(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=Ny(n,r),s=Rl(o);i.add(o),i.add([...s,"*.play"].join("/"));for(let a=0;a<=s.length;a++)i.add([...s.slice(0,a),"**","*.play"].join("/"))}return[...i].sort()}c(JM,"importablePaths");var qy=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),By=/^id\s+"((?:[^"\\]|\\.)*)"$/;function Ml(t,e,n,i=new Set){t=kt(t);let r=[],o=De(t),s=Yy(t,o),a=new Set(e.commands.flatMap(y=>y.productionHeaders??[])),d=new Map,u=new Set;for(let y of[e,n]){for(let h of y.events)d.set(h.name,(d.get(h.name)??0)+1);for(let h of y.imports)u.add(h.shortName)}let m=c((y,h,g,b="error")=>{r.push({line:y,startColumn:ne(t[y])+1,endColumn:t[y].length+1,code:h,message:g,severity:b})},"report");for(let y of e.events){let h=cn(t,o,y.line,ne(t[y.line]));if(y.inline){let S=new Set;for(let $ of y.properties)S.has($.name)&&m($.line,ee.duplicateDeclaration,`Event '${y.name}' already declares property '${$.name}'.`),S.add($.name);a.has(y.line)||m(y.line,ee.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),y.generation!==void 0&&m(y.line,ee.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((d.get(y.name)??0)>1||u.has(y.name))&&m(y.line,ee.inlineEventCollision,`Inline event '${y.name}' collides with another declaration or import.`)}let g=!1,b=!1;for(let S of h){let $=t[S].trim(),x=$.split(/\s+/)[0];if(y.inline&&x==="generation"&&m(S,ee.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),y.inline&&x==="origin"&&m(S,ee.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test($)){if(x==="id"){let P=$.match(By);g||P===null||P[1].trim().length===0?m(S,ee.invalidEventId,'Expected one nonempty id "<old-name>".'):P[1]===y.name&&m(S,ee.redundantEventId,"This id repeats the event name; remove it.","information"),g=!0}if(x==="documentation"){let P=S+1;for(;P<t.length&&t[P].trim().length===0;)P++;(b||$!=="documentation"||t[P]?.trim()!=="```markdown"||ne(t[P])<=ne(t[S])||!s.has(P))&&m(S,ee.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),b=!0}}}}let p=[];for(let y=0;y<t.length;y++){if(o[y]||t[y].trim().length===0)continue;let h=ne(t[y]);for(;p.length>0&&p[p.length-1].indent>=h;)p.pop();let g=t[y].trim().split(/\s+/)[0];qy.has(g)&&p.at(-1)?.event&&m(y,ee.reservedProductionMetadata,`'${g}' is system-assigned production metadata.`),g==="produces"&&p.push({indent:h,event:!i.has(y)&&!/^\s*produces\s+operation\b/.test(t[y])})}for(let y of e.commands){let{identifier:h,mixed:g}=Uo(y);for(let b of y.produces??[]){g&&b.target===void 0&&m(b.line,ee.explicitProducesTargetsRequired,`Production '${b.name}' must state for explicitly when destinations differ.`);let S=b.target??(b.inline?h:void 0);if(!(h===void 0||S!==h))for(let $ of b.mappings.filter(x=>x.source===h))m($.line,ee.eventSourceIdInPayload,`The payload copies '${h}', which already identifies the event source.`,b.inline?"warning":"information")}}return r}c(Ml,"validateInlineEvents");function Yy(t,e){let n=new Set,i,r=!1;for(let o=0;o<t.length;o++){if(!e[o])continue;let s=t[o].trim();i===void 0?(i=o,r=!1):s==="```"?(r&&t[i].trim()==="```markdown"&&n.add(i),i=void 0):s.length>0&&(r=!0)}return n}c(Yy,"nonemptyMarkdownBlocks");function Qe(t,e,n,i,r,o){return{severity:t,message:r,line:e,startColumn:n,endColumn:n+i,code:o}}c(Qe,"issue");function Ve(t,e,n,i,r,o){let s=n.indexOf(i)+1;return Qe(t,e,s,i.length,r,o)}c(Ve,"tokenIssue");function Fy(t,e,n){let i=[],r=new Set([...Fo(e,zn),...Fo(n,[])]),o=c((a,d)=>{for(let u of a.filter(m=>!r.has(Et(m).name))){let m=Et(u).name;i.push(Qe("warning",u.line,u.sourceType.startColumn,u.sourceType.text.length,m==="optional"?`Unknown type 'optional' on '${u.name}' of ${d} \u2014 did you forget the type before 'optional'?`:`Unknown type '${m}' on '${u.name}' of ${d} \u2014 declare it with 'concept ${m} : <Primitive>' or 'type ${m}'.`,ee.unknownType))}},"checkProperties");for(let a of e.types)o(a.properties,`type '${a.name}'`);for(let a of e.events)o(a.properties,`event '${a.name}'`);for(let a of e.queries)o(a.parameters,`query '${a.name}'`);for(let a of e.commands){o(a.properties,`command '${a.name}'`);let d=a.properties.filter(u=>u.isIdentifier);for(let u of d.slice(1))i.push(Ve("error",u.line,t[u.line],"identifier",`Command '${a.name}' already marks '${d[0].name}' as identifier \u2014 only one property can be the identifier.`,ee.duplicateCommandIdentifier))}let s=new Map;for(let a of[...e.concepts,...e.types]){if(s.get(a.name)===void 0){s.set(a.name,a.line);continue}i.push(Ve("error",a.line,t[a.line],a.name,`Duplicate declaration of '${a.name}' \u2014 concept and type names must be unique.`,ee.duplicateDeclaration))}return i}c(Fy,"validateDeclarations");function k3(t,e={}){let n=De(t),i=Un(t),r=e.application??rr(),o=Tl(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),s=ln(t,o.authoringDocuments??o.authoringSources?.filter(C=>C!==t.join(`
41
+ `)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),a=new Set(s.eventSources.routes.map(C=>C.location.line-1)),d={...i,commands:i.commands.map(C=>({...C,properties:C.properties.filter(k=>!a.has(k.line)),produces:C.produces?.filter(k=>!s.operationProductionLines?.has(k.line)),productionHeaders:C.productionHeaders?.filter(k=>!s.operationProductionLines?.has(k))}))},u=new Set([...or(d),...or(r)]),m=new Set([...d.policies,...r.policies].map(C=>C.name)),p=Fy(t,d,r);p.push(...Uy(t,d));let y=new Set([l.LegacyOptionalSuffix,l.InvalidOptionalModifierOrder,l.OptionalReadsNotSupported]),h=new Set([l.UnexpectedTokenInPolicyCondition,l.ExpectedPolicyCondition,l.UnclosedPolicyConditionGroup,l.ExpectedRoleName,l.ExpectedClaimName,l.ExpectedClaimMatches,l.ExpectedClaimMatchTarget]),g=new Set([l.UnknownEvent,l.UnknownReadModelProperty,l.PiiNotSupportedOnIdentifier]),b=new Set([l.EventFromLaterSlice,l.TimelineCycleGroup]),S=new Set([l.UndeclaredDependency,l.UnusedDependencyDeclaration,l.InvalidDependencyTarget,l.RepeatedDependencyDeclaration,l.MutualDependencyDeclarations,l.AmbiguousReference]),$=new Set([l.InvalidEventDeclaration,l.InvalidImportDeclaration,l.InvalidSliceDeclaration,l.InvalidDescription,l.DuplicateDescription,l.EmptyDescription,l.DuplicateEventSubject,l.InvalidSubjectType,l.ProtectedSubjectType,l.InvalidSubjectOwner,l.ReadModelSubjectNotSupported,l.InvalidSubjectModifierOrder,l.UnsupportedInteractionAlternatives,l.MixedInteractionAlternatives,l.InteractionAlternativeWithoutActions,l.InlineInteractionAlternative,l.LegacyInteractionWhere,l.InvalidSpecificationParameter,l.InvalidSpecificationCase,l.DuplicateSpecificationParameter,l.DuplicateSpecificationCase,l.IncompleteSpecificationTable,l.InvalidSpecificationCaseAssignment,l.InvalidSpecificationCaseValue,l.InvalidSpecificationCaseReference,l.OptionalSpecificationParameterTarget,l.SpecificationCaseNameCollision,l.IncompatibleSpecificationParameterType,l.UnusedSpecificationParameter,l.SingularSpecificationTableExpansion,l.InvalidSpecificationCallerPersona,l.UnsynthesizablePersonaCaller,l.PersonaWithoutGate,l.GateWithoutPersona,l.AmbiguousPersonaCaller,l.InvalidDocumentation,l.ConflictingDocumentationAcrossFiles,l.InvalidAbsentReadModelStep,l.UnknownConstraintProperty,l.OmittedProductionDestination,l.InvalidSpecificationExample,l.DuplicateSpecificationAssignment]),x=new Set([l.InvalidPurposeDeclaration,l.InvalidPurposeVocabulary,l.DuplicatePurposeField,l.DuplicatePurposeDeclaration,l.UnknownPurpose,l.PurposeInterestMismatch,l.PersonalDataWithoutPurpose,l.SpecialDataWithoutCondition,l.CriminalDataWithoutAuthorization,l.PurposeWithoutBasis,l.UnusedPurpose,l.UnknownConceptDirective,l.AttributeReasonWithoutAttribute,l.DuplicateAttributeReason,l.LegacyComplianceMarker,l.UnknownComplianceMarker,l.InvalidSecretScope,l.DuplicateSecretScope,l.SecretScopeIgnoredForPii,l.InvalidPersonalDataQualifier,l.DuplicateSpecialCategory]),P=new Set;for(let C of e.compilerDiagnostics??s.diagnostics){let k=C.code===l.UnknownType&&(s.identityDetails??[]).some(M=>M.line===C.location.line-1),A=C.code===l.RepeatedSingularDeclarationAcrossFiles&&C.message.includes("identity block");if(!k&&!A&&!x.has(C.code)&&!y.has(C.code)&&!h.has(C.code)&&!g.has(C.code)&&!b.has(C.code)&&!S.has(C.code)&&!$.has(C.code)&&C.code!==l.InvalidSpecificationExampleBody&&C.code!==l.UnknownRuleImplementationDirective&&C.code!==l.InvalidValidationRule&&C.code!==l.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY054[7-9]$|^PLAY055[01]$|^PLAY048[2-9]$|^PLAY004[56]$|^PLAY053[0-9]$|^PLAY054[0-6]$|^PLAY034[1-8]$|^PLAY0557$|^PLAY060[7-9]$|^PLAY061[0-9]$|^PLAY0620$|^PLAY063[3-9]$|^PLAY064[0-9]$|^PLAY065[0-2]$/.test(C.code))continue;let O=C.location.line-1;if(C.code===l.OmittedProductionDestination&&p.some(M=>M.code===C.code&&M.line===O))continue;if(C.code===l.UnknownEvent){if(P.has(O))continue;P.add(O)}let T=Io(t[O],C)||t[O].length-C.location.column+1;p.push(Qe(C.severity,O,C.location.column,T,C.message,C.code))}let I=c((C,k,A)=>{!u.has(A)&&!P.has(C)&&p.push(Ve("warning",C,k,A,`Unknown event type '${A}' \u2014 declare it in a slice or import it.`,ee.unknownEvent))},"checkEvent"),v=-1;for(let C=0;C<t.length;C++){let k=t[C],A=k.trim();if(n[C]||A.length===0)continue;let O=k.match(/^[ ]*(\t+)/);if(O&&p.push(Qe("warning",C,O[0].length-O[1].length+1,O[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",ee.tabIndentation)),v>=0){if(ne(k)>v&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(A)){for(let W of A.split(/\s+/).filter(_=>_!=="or"))m.has(W)||p.push(Ve("warning",C,k,W,`Unknown policy '${W}' \u2014 declare it with 'policy ${W}'.`,ee.unknownPolicy));continue}v=-1}let T=Wy(t,n,C);T&&p.push(T);let M=A.match(/^slice\s+(\w+)/);M&&!lr.includes(M[1])&&p.push(Ve("error",C,k,M[1],`Unknown slice type '${M[1]}' \u2014 expected ${lr.join(", ")}.`,ee.unknownSliceType));let N=A.match(/^concept\s+\w+\s*:\s*(\w+)/);N&&N[1]!=="Enum"&&!zn.includes(N[1])&&p.push(Ve("error",C,k,N[1],`Unknown primitive type '${N[1]}' \u2014 expected ${zn.join(", ")} or Enum.`,ee.unknownPrimitiveType));let j=A.match(/^authorize\s+(.*)$/);if(j){v=ne(k);for(let W of j[1].split(/\s+/).filter(_=>_!=="or"&&_.length>0))m.has(W)||p.push(Ve("warning",C,k,W,`Unknown policy '${W}' \u2014 declare it with 'policy ${W}'.`,ee.unknownPolicy))}let q=A.match(/^on\s+([A-Z]\w*)\s*$/);q&&I(C,k,q[1]);let Q=A.match(/^produces\s+([A-Z]\w*)\s*$/);if(Q&&!s.operationProductionLines?.has(C)&&I(C,k,Q[1]),/^produces\s+when\b/.test(A)&&!s.operationProductionLines?.has(C))for(let W=C+1;W<t.length;W++){let _=t[W];if(!(n[W]||_.trim().length===0)){if(ne(_)>ne(k)){let te=_.trim().match(/^([A-Z]\w*)\s*$/);te&&I(W,_,te[1])}break}}let K=A.match(/^unique\s+event\s+([A-Z]\w*)/);K&&I(C,k,K[1]);let J=A.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);J&&I(C,k,J[1]);for(let W of k.match(/\$identity\.[\w.]+/g)??[]){let _=W.substring(10).split(".")[0],te=[...At,...(s.identityDetails??[]).map($e=>$e.name)];te.includes(_)||p.push(Ve("warning",C,k,W,`Unknown $identity property '${_}' \u2014 expected ${te.join(", ")}.`,ee.unknownContextIdentityProperty))}for(let W of k.match(/\$context\.[\w.]+/g)??[]){let _=W.substring(9).split(".");ar.includes(_[0])?_[0]==="causedBy"&&_.length>1&&!sr.includes(_[1])?p.push(Ve("warning",C,k,W,`Unknown $context.causedBy property '${_[1]}' \u2014 expected ${sr.join(", ")}.`,ee.unknownContextCausedByProperty)):_[0]==="identity"&&_.length>1&&!At.includes(_[1])&&p.push(Ve("warning",C,k,W,`Unknown $context.identity property '${_[1]}' \u2014 expected ${At.join(", ")}.`,ee.unknownContextIdentityProperty)):p.push(Ve("warning",C,k,W,`Unknown $context path '${_.join(".")}' \u2014 expected one of ${ar.join(", ")}.`,ee.unknownContextPath))}}p.push(...Vy(t,n)),p.push(...Ml(t,d,r,s.operationProductionLines));let E=t.map((C,k)=>({line:C,index:k})).filter(({line:C})=>/^\s*```(?:[a-z]+)?\s*$/.test(C));if(E.length%2===1){let C=E[E.length-1];p.push(Qe("error",C.index,1,C.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",ee.unclosedCodeBlock))}return p}c(k3,"validateLines");function Uy(t,e){let n=[];t=kt(t);for(let i of e.commands){let r=i.properties.filter(o=>o.isIdentifier&&!Et(o).isOptional&&!Et(o).isCollection);if(r.length===1)for(let o of i.produces??[]){if(o.inline||o.conditional||o.target!==void 0)continue;let s=o.line;n.push(Qe("information",s,ne(t[s])+1,t[s].trim().length,`Plain 'produces ${o.name}' omits its destination \u2014 use 'for ${r[0].name}' to explicitly select the command's identifier.`,ee.omittedProductionDestination))}}return n}c(Uy,"validateProductionDestinations");function Wy(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||Wo(i,n))return;let o=ne(i);if(!(!(o>0&&["module","feature"].includes(Qo(t,e,n,o)[0]))&&!Dl(i)))return Qe("error",n,o+1,r.length,`Invalid import '${r}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,ee.invalidFileImport)}c(Wy,"validateImport");var zy=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function Vy(t,e){let n=[],i=c(r=>r.map(o=>o.name).join(", "),"names");for(let r=0;r<t.length;r++){let o=t[r];if(e[r])continue;for(let d of o.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let u=d[0].substring(d[1]?.length??0),m=d[2];if(m.length===0){d[1]&&n.push(Qe("error",r,(d.index??0)+2,u.length,`'$eventContext' names no member - expected one of ${i(fr("").expected)}.`,ee.missingEventContextPath));continue}let p=m.substring(1),y=fr(p),h=(d.index??0)+(d[1]?.length??0)+1;switch(y.status){case"missing":n.push(Qe("error",r,h,u.length,`'$eventContext.${p}' names no member - expected one of ${i(y.expected)}.`,ee.missingEventContextPath));break;case"unknownMember":n.push(Qe("warning",r,h,u.length,`Unknown event context member '${y.segment}' in '$eventContext.${p}' - expected one of ${i(y.expected)}.`,ee.unknownEventContextMember));break;case"unknownSubPath":{let g=y.expected.length===0?"no members to address":`members ${i(y.expected)}`;n.push(Qe("warning",r,h,u.length,`Unknown event context path '$eventContext.${p}' - '${y.member?.name}' (${y.member?.type}) has ${g}.`,ee.unknownEventContextPath));break}case"belowCollection":n.push(Qe("error",r,h,u.length,`'$eventContext.${p}' cannot resolve - '${y.member?.name}' is a collection (${y.member?.type}) and cannot be addressed below.`,ee.eventContextPathBelowCollection));break}}let s=o.trim().match(zy)?.[1],a=s?.match(/\.\$(\w+)/)?.[1];s&&a&&a!=="eventContext"&&n.push(Ve("warning",r,o,s,`Dynamic dictionary key '$${a}' in '${s}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${a}' becomes the key.`,ee.unresolvedDynamicKeySource))}return n}c(Vy,"validateEventContextPaths");export{Ll as a,Qy as b,Gy as c,Vo as d,_y as e,ar as f,sr as g,lr as h,zn as i,Zy as j,jl as k,Ky as l,Mt as m,dn as n,Hy as o,l as p,ke as q,Dr as r,di as s,YO as t,FO as u,Ae as v,ne as w,cr as x,De as y,Qo as z,th as A,nh as B,kt as C,fh as D,dr as E,pr as F,ur as G,Nl as H,sh as I,lh as J,ch as K,ql as L,Bl as M,xh as N,vh as O,$h as P,bh as Q,kh as R,Eh as S,Ch as T,Ph as U,Ah as V,Ih as W,wh as X,Fl as Y,Oh as Z,qh as _,Bh as $,Yh as aa,Fh as ba,Uh as ca,Ul as da,Wh as ea,zh as fa,Vh as ga,Qh as ha,Wl as ia,Gh as ja,_h as ka,Zh as la,Kh as ma,Jh as na,Hh as oa,Xh as pa,eS as qa,tS as ra,nS as sa,iS as ta,rS as ua,oS as va,Zo as wa,zl as xa,aS as ya,sS as za,lS as Aa,cS as Ba,dS as Ca,Vl as Da,pS as Ea,Ql as Fa,uS as Ga,fS as Ha,mS as Ia,Gl as Ja,yS as Ka,SM as La,ln as Ma,No as Na,$M as Oa,qo as Pa,bM as Qa,Et as Ra,cn as Sa,Un as Ta,rr as Ua,Tl as Va,or as Wa,My as Xa,NM as Ya,Fo as Za,Uo as _a,VM as $a,ee as ab,Dl as bb,Wo as cb,KM as db,JM as eb,k3 as fb,Vy as gb};
42
+ //# sourceMappingURL=chunk-7GSRLVHB.js.map