@cratis/screenplay-language 4.89.1 → 4.91.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.
- package/dist/bundles/chunk-XOAJQFSV.js +33 -0
- package/dist/bundles/chunk-XOAJQFSV.js.map +7 -0
- package/dist/bundles/index.js +19 -19
- package/dist/bundles/index.js.map +2 -2
- package/dist/bundles/sub-languages/projection/index.js +1 -1
- package/dist/completion-items.d.ts.map +1 -1
- package/dist/diagnostic-codes.d.ts +2 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/dist/documentation-item.d.ts +3 -0
- package/dist/documentation-item.d.ts.map +1 -0
- package/dist/hover-content.d.ts.map +1 -1
- package/dist/language.d.ts.map +1 -1
- package/dist/scope-items.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/bundles/chunk-MQ7ZSHMF.js +0 -33
- package/dist/bundles/chunk-MQ7ZSHMF.js.map +0 -7
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-AYDF3IFZ.js";var Ga="screenplay",qf={id:Ga,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Bf=["domain","import","concept","type","policy","persona","authentication","module","layout","theme","ui","feature","slice","event","system","eventsource","operation","command","query","projection","capture","reaction","reducer","readmodel","trigger","screen","dialog","form","contribute","constraint","specification","example","seed","behavior"];var Ir=["depends","description","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","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"],Ff=["csharp","typescript","react","html","sql"],pi=["command","arguments","tenant","causedBy","causation","occurred","identity"],fi=["subject","name","userName"],ui=["id","name","userName","isAuthenticated","roles","claims"],mi=["StateChange","StateView","Automation","Translate"],rn=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Yf=["@pii","@sensitive"],Ka=/^\s*(?:module|feature|slice\s+\w+|type|command|event|readmodel|reducer|projection|capture|reaction|screen|dialog|form|contribute|specification|constraint|persona|policy|behavior|layout|theme|ui\s+profile|trigger|authentication|seed|system|eventsource|operation|screen\s+template|dialog\s+template|produces\s+event|validate|handler|on)\b[^=]*$/,Wf={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:Ka,action:{indentAction:1}}],indentationRules:{increaseIndentPattern:/^\s*(module|feature|slice|policy|persona|authentication|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+execute\b)|concurrency|seed|for|when|then|arguments|result|every|at|invokes|on)\b.*$/,decreaseIndentPattern:/(?!)/}};function wt(t){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(t);return{name:e?.[1]??t,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}l(wt,"typeReferenceSymbol");function zf(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}l(zf,"typeReferenceText");function be(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}l(be,"withoutComment");function J(t){return t.length-t.trimStart().length}l(J,"indentOf");function yi(t){return t.trim().split(/\s+/)[0]??""}l(yi,"firstWord");function ue(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}l(ue,"fenceMap");function Tr(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=be(t[s]);if(a.trim().length===0)continue;let c=J(a);c<o&&(r.push(yi(a)),o=c)}return r}l(Tr,"enclosingChain");function Gf(t,e,n,i){for(let r=n-1;r>=0&&i>0;r--){if(e[r])continue;let o=be(t[r]);if(o.trim().length!==0&&J(o)<i)return o.trim()}}l(Gf,"nearestEnclosingLine");function Kf(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=be(t[s]);if(a.trim().length===0)continue;let c=J(a);c<o&&(r.push(a.trim()),o=c)}return r}l(Kf,"enclosingHeaders");var Rr="EventContext",Ot={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."}]},hi=[{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 Si(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}l(Si,"namesEventContextMember");var gi=Ot[Rr];function Za(t){let e=gi;for(let n of t){let i=e.find(r=>Si(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=Ot[i.type]??[]}return e}l(Za,"eventContextMembersAfter");function Xf(t){return t.length===0?void 0:Za(t.slice(0,-1))?.find(n=>Si(n,t[t.length-1]))}l(Xf,"eventContextMemberAt");function xi(t){let e,n=gi;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=>Si(o,i));if(!r)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:n};e=r,n=r.kind==="function"?[]:Ot[r.type]??[]}return{status:"known",member:e,expected:[]}}l(xi,"resolveEventContextPath");function eu(){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:**",...gi.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
|
|
2
|
-
`)}l(eu,"describeEventContext");function tu(t,e){let n=e.kind==="collection"||e.kind==="function"?[]:Ot[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
|
-
`)}l(tu,"describeEventContextMember");var rt=[{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 vi=[{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."}],_a=[...rt,{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."},...vi],Ja=[...rt,{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."},...vi],au=[{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."}],su=[{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."}],lu=[{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."},...vi],cu=[{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."}],du=[{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."}],Ee=l((t,e,n)=>({label:t,insertText:e,documentation:n}),"step"),Ha=[Ee("execute","execute ${1:command}","Runs a command."),Ee("navigate to","navigate to ${1:Screen}","Opens a screen."),Ee("open","open ${1:Dialog}","Opens a dialog."),Ee("close","close","Closes the dialog."),Ee("refresh","refresh ${1:query}","Reloads a query."),Ee("set","set ${1:name} ${2:value}","Sets a value."),Ee("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),Ee("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),Ee("raise","raise ${1:Trigger}","Raises a trigger.")],pu=[Ee("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),Ee("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...Ha],fu=[{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."}],uu=[{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."}],mu=[{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."}],yu=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],hu=[{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."}],Xa=[{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."}],Su=[{label:"fits slot",insertText:"fits slot ${1:content}",documentation:"The slot of the shell the template fits."},...Xa,{label:"on",insertText:"on ${1|enter,leave,load,unload|}\n ${2:refresh query}",documentation:"Wires what happens on an interaction."}];var ku=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],me=l(t=>`\`\`\`${t}
|
|
6
|
-
\${1}
|
|
7
|
-
\`\`\``,"fenced"),bu=[...rt,{label:"eventsource",insertText:"eventsource ${1:Name}\n identifier ${2:Type}\n stream ${3:Name}",documentation:"Application-owned source with nested streams; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{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 "\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 is personal data, its purpose and lawful basis}"',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."}],Eu=[{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."}],es=[{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."}))],Cu=[{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."},...es.filter(t=>t.label!=="hint")],Pu=[{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 is personal data, its purpose and lawful basis}"',documentation:"Records why the `@pii` marker applies \u2014 purpose, lawful basis, whose subject it lives under."},{label:"sensitive reason",insertText:'sensitive reason "${1:why this value is sensitive}"',documentation:"Records why the `@sensitive` marker applies."},{label:"validate",insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:"Validation rules that travel with the value everywhere it appears."}],Au=[{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."}],Mr=[...rt,{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:"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."}],wu=[{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."}],ts=[{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."}],Ou=[...ts,{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."}],Iu=[{label:"when",insertText:"when ${1:condition}",documentation:"Guards the produced event with a condition."}],Tu=[{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."}))],Ru=[{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."}],Mu=[{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."}],Du=[{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."}],Nu=[{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."}],ju=[{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."}],Lu=[{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."}],Ge="Syntax-only; reaction refusal handling and redelivery are not yet executable (PLAY0268).",qu=[{label:"on refused",insertText:`on refused
|
|
11
|
-
acknowledge`,documentation:`Handles validation and constraint refusals, not authorization. ${Ge}`},{label:"on refused by validation",insertText:`on refused by validation
|
|
12
|
-
acknowledge`,documentation:`Handles validation refusals. ${Ge}`},{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. ${Ge}`},{label:"on refused by authorization",insertText:`on refused by authorization
|
|
13
|
-
acknowledge`,documentation:`Explicitly handles unauthorized results, never Unsupported. ${Ge}`}],Bu=[{label:"acknowledge",insertText:"acknowledge",documentation:`Acknowledges alone, without productions. ${Ge}`},{label:"produces",insertText:"produces ${1:Event}\n ${2:reason} = \\$refusal.reason",documentation:`Records the refusal with ordinary event productions. ${Ge}`}],Fu=[{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."}],Yu=[{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. ${Ge}`},{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."}],Dr={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. ${Ge}`},{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."}]},ns=[{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."}],Wu=[{label:"implementation",insertText:'implementation\n hint "${1:predicate guidance}"',documentation:"Command named-rule intent with optional file or tagged fence. Pending intent cannot bind."},...ns.filter(t=>t.label!=="hint")],Uu=[{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."}],zu=[{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."}],Vu=[{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."}],Qu=[{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."}],is=[{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."}],Gu=[{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."},...is.filter(t=>t.label!=="label")],Ku=[{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."}],Zu=[{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."}],_u=[{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."},...hi.filter(t=>t.name!=="value").map(t=>({label:`$eventContext.${t.path}`,insertText:`$eventContext.${t.path}`,documentation:`${t.description} (PDL)`}))],rs={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 Ju(t){let e=t?rs[t]:void 0;return e?Mr.filter(n=>n.label==="example"||e.includes(n.label)):Mr}l(Ju,"sliceItemsFor");var d={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",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",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 $i="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}",z="[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";function V(t){let e=`(?=[\\u0000-\\uFFFF])[${$i}]`,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")}l(V,"nativePattern");function O(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?$i:`[${$i}]`:o==="d"?e+="\\p{Nd}":e+=`\\${o}`;continue}r==="["&&!n?n=!0:r==="]"&&n&&(n=!1),e+=r}return new RegExp(e,"u")}l(O,"pattern");var os=new RegExp(`^depends${z}+on(?:${z}|$)`,"u"),as=new RegExp(`${z}+$`,"u");function pt(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,c=a.length-a.trimStart().length,p=ss(a.substring(c),e),m=os.test(p)?p.replace(as,""):p.trimEnd();i.push(n===void 0?{number:r,raw:a,indent:c,content:m,startOffset:o}:{number:r,raw:a,indent:c,content:m,path:n,startOffset:o}),o+=s.length+1}return i}l(pt,"splitLines");function It(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}l(It,"commentStart");function ss(t,e){let n=It(t,e);return n<0?t:t.substring(0,n)}l(ss,"stripComment");function se(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}l(se,"eventDeclarations");function on(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}l(on,"operationDeclarations");var ee;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(ee||(ee={}));var re=class{static{l(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e){let n=l((i,r)=>{for(let o of i){let s=[...r,o.name];for(let a of o.slices)this.slices.push({slice:a,scope:[...s,a.name]});n(o.features,s)}},"collect");e.modules.forEach(i=>n(i.features,[i.name]));for(let{slice:i,scope:r}of this.slices){this.scopes.set(i,r);let o=new Map;for(let a of se(i)){let c=o.get(a.name)??[];c.push(a),o.set(a.name,c)}let s=[...o.values()].flatMap(a=>new Set(a.map(c=>c.generation)).size!==a.length?a:[a.reduce((c,p)=>c.generation>=p.generation?c:p)]);this.declarations.push(...s.map(a=>({kind:ee.Event,name:a.name,node:a,scope:r})),...on(i).map(a=>({kind:ee.Operation,name:a.name,node:a,scope:r})))}for(let i of this.declarations){let r=this.byName.get(i.name)??[];r.push(i),this.byName.set(i.name,r)}}resolve(e,n){let i=this.scopes.get(n);if(i===void 0)return{kind:ee.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.candidates(e,i),a=s.length===1?{kind:s[0].kind,declaration:s[0],candidates:[]}:{kind:s.length===0?ee.Unresolved:ee.Ambiguous,declaration:null,candidates:s};return r.set(e,a),this.resolutions.set(n,r),a}isOperation(e,n){return e.inlineOperation!=null||this.resolve(e.event,n).kind===ee.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==ee.Operation&&!(i.kind===ee.Ambiguous&&i.candidates.some(r=>r.kind===ee.Operation))}candidates(e,n){let i=e.split("."),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,c)=>s.scope[s.scope.length-o.length+c]===a));for(let s=n.length;s>=0;s--){let a=r.filter(c=>s<=c.scope.length&&n.slice(0,s).every((p,m)=>c.scope[m]===p));if(a.length>0)return a}return[]}};function an(t){let e=new re(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:d.OmittedProductionDestination,message:`Plain 'produces ${o.event}' omits its destination - use 'for ${r[0].name}' to explicitly select the command's identifier.`,location:o.location}))}))}l(an,"productionDestinationDiagnostics");function sn(t,e){let n=new re(t).slices.map(r=>r.slice),i=n.flatMap(se);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(c=>c.properties.some(p=>p.name===a))||e.error(d.UnknownConstraintProperty,`Constraint '${o.name}' names property '${a}', which event '${o.event}' does not declare.`,o.location)}}l(sn,"validateConstraintProperties");var Nr=l((t,e)=>t.length===e.length&&t.every((n,i)=>n===e[i]),"same"),ln=l(t=>[...t.scope,t.name].join("."),"addressOf"),ye=class{static{l(this,"DeclaredDependencyTargets")}static containersOf(e){let n=[],i=l((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=>[ln(r),r])).values()]}static candidates(e,n){let i=e.join(".");return n.flatMap(r=>{let o=ln(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 c=s.slice(-a).join(".");if(this.resolve(c,e,n).resolved!==r)continue;let p=a===1?e.length-1-r.scope.length:"qualified";return[{container:r,reference:c,tier:p}]}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=>Nr([...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&&Nr(a.scope,n.slice(0,o)));if(s.length>0)return s.length===1?{resolved:s[0],ambiguous:[]}:{ambiguous:s}}return{ambiguous:[]}}};function cn(t,e){let n=l(a=>(a.dependsOn?.length??0)>0||a.features.some(n),"hasDependencies");if(!t.modules.some(n))return t;let i=ye.containersOf(t),r=new Map,o=l((a,c)=>{let p=[],m=c.join(".");r.has(m)||r.set(m,new Set);let u=r.get(m);for(let y of a){let h=ye.resolve(y.target,c,i),$=h.resolved===void 0?void 0:ln(h.resolved),v=$===void 0?`text:${y.target}`:`resolved:${$}`;if(u.has(v)){e.warning(d.RepeatedDependencyDeclaration,`Dependency '${y.target}' is already declared on this container - this repeated declaration is ignored`,y.location);continue}u.add(v),p.push(y),h.ambiguous.length>0?e.warning(d.AmbiguousReference,`Ambiguous dependency target '${y.target}' - candidates: ${h.ambiguous.map(ln).join(", ")}`,y.location):($===void 0||$===m||$.startsWith(m+".")||m.startsWith($+"."))&&e.warning(d.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 p},"keep"),s=l((a,c)=>{let p=[...c,a.name];return{...a,dependsOn:o(a.dependsOn??[],p),features:a.features.map(m=>s(m,p))}},"normalize");return{...t,modules:t.modules.map(a=>({...a,dependsOn:o(a.dependsOn??[],[a.name]),features:a.features.map(c=>s(c,[a.name]))}))}}l(cn,"validateDependencyDeclarations");var ot=[],Tt=l(t=>t.length===0,"isDocumentPlacement");function dn(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}l(dn,"describePlacement");var ft=l((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var ki=l(t=>t.content.length===0,"isBlank"),f=l(t=>ft(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),jr=l(t=>ft(t.number,1,t.path),"startOf");var ls=O("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),cs=new RegExp(O("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),ds=O("^[A-Z]\\w*$");function Ke(t,e){let n=e.content.substring(9);for(let a=t.peekChild(e.indent);a!==void 0&&ls.test(a.content);a=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${a.content}`;let i=ps(n),r=f(e);if(i.length===0)return t.error(d.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let s=new bi(t,i,r).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:r}}l(Ke,"parseAuthorize");function Te(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}}l(Te,"combineAuthorize");function ps(t){let e=[];for(let n of t.match(cs)??[])e.length>0&&fs(e[e.length-1])&&us(n)&&e.push("and"),e.push(n);return e}l(ps,"tokenize");var Lr=l(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),fs=l(t=>t===")"||Lr(t),"isOperandEnd"),us=l(t=>t==="("||Lr(t),"isOperandStart"),bi=class{static{l(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(d.UnexpectedTokenInAuthorize,`Unexpected '${this.tokens[this.#e]}' in authorize`,this.location),e}#t(){return this.#r("or","Or",()=>this.#o())}#o(){return this.#r("and","And",()=>this.#n())}#r(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}#n(){if(this.tokens[this.#e]!=="(")return this.#i();this.#e++;let e=this.#t();return this.tokens[this.#e]===")"?this.#e++:this.context.error(d.UnclosedAuthorizeGroup,"Expected ')' in authorize",this.location),e}#i(){if(this.#e>=this.tokens.length)return this.context.error(d.AuthorizeWithoutPolicy,"Expected a policy name",this.location),null;let e=this.tokens[this.#e++];return ds.test(e)?{kind:"PolicyReferenceSyntax",name:e,location:this.location}:(this.context.error(d.InvalidPolicyReference,`Invalid policy reference '${e}' - policy names are PascalCase identifiers`,this.location),null)}};var Z='(?:[^"\\\\]|\\\\.)*',ms={"\\":"\\",'"':'"',n:`
|
|
15
|
-
`,r:"\r",t:" "};function H(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.length?ms[t[n+1]]:void 0;t[n]==="\\"&&i!==void 0?(e+=i,n++):e+=t[n]}return e}l(H,"unescapeString");function ut(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(d.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(d.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",f(o));let a=[];for(;;){let c=t.reader.takeRaw();if(c===void 0){t.error(d.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(o));break}if(c.raw.trim()==="```")break;let p=0;for(;p<o.indent&&p<c.raw.length&&c.raw[p]===" ";)p++;a.push(c.raw.substring(p))}return a.join(`
|
|
16
|
-
`)}l(ut,"parseFencedText");var ys=O(`^description\\s+"(${Z})"$`);function _(t,e,n,i,r=!1){if(e.content==="description"){let s=ut(t,"description",e,r);return s===null?n:s.trim().length===0?(t.error(d.EmptyDescription,`${i} declares an empty description - the fenced block must contain text`,f(e)),n):qr(t,e,n,i,s)}let o=ys.exec(e.content);return o===null?(t.error(d.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,f(e)),n):qr(t,e,n,i,H(o[1]))}l(_,"parseDescription");function qr(t,e,n,i,r){return n!==null?(t.error(d.DuplicateDescription,`${i} already declares a description - at most one is allowed`,f(e)),n):r}l(qr,"keep");var hs=V(`^depends${z}+on${z}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function pn(t,e,n,i){let r=hs.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(d.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)})}l(pn,"parseDependsOn");var Ss=O('^import\\s+"([^"\\\\]+)"$'),gs=O('^import\\s+"'),Br=l(t=>gs.test(t),"isFileImport");function Fr(t){let e=Ss.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:f(t)}}l(Fr,"tryParseFileImport");function mt(t,e,n){let i=Fr(e);if(i!==void 0){n.push(i);return}t.error(d.InvalidFileImport,`Invalid import '${e.content}' - inside a module or feature, import names files: 'import "<path or glob>"'`,f(e)),t.skipBlock(e.indent)}l(mt,"parseFileImport");var R=l(t=>{let e=t.indexOf(" ");return e===-1?t:t.substring(0,e)},"firstWord"),X=l(t=>t.replaceAll("@",""),"unescapeIdentifier");function Yr(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}l(Yr,"splitTopLevel");var xs=O("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),vs=O("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),$s=O("^field\\s+([\\w.]+)(?:\\s|$)"),ks=O("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),bs=O("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),Es=O("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),Cs=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on"]);function Ce(t,e){let n=[],i=new Set,r=[],o=R(e.content)==="behavior",s=l(a=>{for(;n.length>0&&n[n.length-1].indent>=a.indent;)n.pop();let c=o&&n.length===0?Es.exec(a.content):null;c!==null&&i.add(c[1]);let p=xs.exec(a.content),m=vs.exec(a.content);if(p!==null)n.push({command:p[1],kind:"form",indent:a.indent});else if(m!==null)n.push({command:m[2],kind:m[1],indent:a.indent});else if(Cs.has(R(a.content)))n.push({command:"",kind:"other",indent:a.indent});else{let u=n.at(-1);if(u===void 0||u.kind==="other")return;let y=(u.kind==="form"?$s:u.kind==="execute"?ks:bs).exec(a.content);y!==null&&r.push({command:u.command,property:X(y[1]),scope:t.scope,location:f(a)})}},"recognize");s(e);for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent))t.reader.takeSignificant(),a.content.startsWith("```")?t.skipFencedBody():s(a);for(let a of r)t.inputUses.push(i.has(a.command)?{...a,isParameter:!0}:a)}l(Ce,"collectInputUses");var Ei="79228162514264337593543950335";function Le(t){let e=Wr(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>Ei.length)return;let a=n.substring(i,r)+"0".repeat(s);if(a.length===Ei.length&&a>Ei)return;let c=Math.max(0,o),p=c===0?a:a.length>c?`${a.substring(0,a.length-c)}.${a.substring(a.length-c)}`:`0.${"0".repeat(c-a.length)}${a}`;return Object.freeze({literalType:"ExactNumber",value:(e.negative?"-":"")+p})}l(Le,"parseExactNumber");function Rt(t){return Wr(t)!==void 0}l(Rt,"isExactNumberToken");function Wr(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&Ci(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let a=++i;for(;i<t.length&&Ci(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 c=i,p=t.length+29;for(;i<t.length&&Ci(t[i]);)s=Math.min(p,s*10+t.charCodeAt(i++)-48);if(i===c)return;a&&(s=-s)}return i===t.length?{negative:e,integer:r,fraction:o,exponent:s}:void 0}l(Wr,"scan");function Ci(t){return t>="0"&&t<="9"}l(Ci,"isDigit");var Ur=64,Se=class extends Error{static{l(this,"InvalidStructuredValue")}},fn=class{static{l(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.#a(),this.#e<this.text.length)throw new Se(`'${this.text[this.#e]}' is invalid after a single JSON value.`);return e}#t(e){this.#a();let n=this.#d(),i=this.text[this.#e];if(i==="["||i==="{"){if(e>=Ur)throw new Se(`The value nests deeper than ${Ur} levels.`);return i==="["?this.#o(e,n):this.#r(e,n)}if(i==='"')return{kind:"LiteralExpressionSyntax",value:this.#n(),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.#s(n)}#o(e,n){this.#e++;let i=[];if(this.#a(),this.#l("]"))return{kind:"ListExpressionSyntax",items:i,location:n};for(;;){if(i.push(this.#t(e+1)),this.#a(),this.#l("]"))return{kind:"ListExpressionSyntax",items:i,location:n};this.#c(",")}}#r(e,n){this.#e++;let i=[],r=new Set;if(this.#a(),this.#l("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};for(;;){this.#a();let o=this.#d();if(this.text[this.#e]!=='"')throw new Se("Expected a property name in double quotes.");let s=this.#n();this.#a(),this.#c(":");let a=this.#t(e+1);if(r.has(s)?this.context?.error(d.DuplicateStructuredValueMember,`Duplicate property '${s}' in structured value`,o):(r.add(s),i.push({kind:"ObjectMemberSyntax",name:s,value:a,location:o})),this.#a(),this.#l("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};this.#c(",")}}#n(){let e=this.#i(this.#e),n=this.text.substring(this.#e,e);this.#e=e;try{return JSON.parse(n)}catch{throw new Se(`${n} is not a valid JSON string.`)}}#i(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 Se("A string is not closed.")}#s(e){let n=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(this.text.substring(this.#e));if(n===null)throw new Se(`'${this.text[this.#e]??""}' is an invalid start of a value.`);if(this.#e+=n[0].length,this.context?.sourceOptions.numericMode==="exact"){let r=Le(n[0]);return r===void 0?(this.context.error(d.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 Se("JSON number is outside the finite Double range.");return{kind:"LiteralExpressionSyntax",value:i,location:e}}#d(){return{...this.start,column:this.start.column+this.#e}}#a(){for(;this.#e<this.text.length&&`
|
|
17
|
-
\r`.includes(this.text[this.#e]);)this.#e++}#l(e){return this.text[this.#e]!==e?!1:(this.#e++,!0)}#c(e){if(!this.#l(e))throw new Se(`Expected '${e}' at position ${this.#e}.`)}};var Ps=O("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),As=V("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),ws=O("^-?\\d+(\\.\\d+)?$"),zr=["command","arguments","tenant","causedBy","causation","occurred","identity"],Vr=["subject","name","userName"],Qr=["id","name","userName","isAuthenticated","roles","claims"];function ge(t,e,n){return te(t,e,n,!0)}l(ge,"parseModeledMappingSource");function te(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.startsWith("$context.")){let o=t.substring(9);return Os(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 fn(t,e,n).parse()}catch(o){if(!(o instanceof Se))throw o;return n?.error(d.InvalidStructuredValue,`Invalid inline structured value: ${o.message}`,e),{kind:"RawExpressionSyntax",text:t,location:e}}let r=n===void 0?Mt(t,e):Mt(t,e,n);return r!==void 0?r:(i||n?.sourceOptions.numericMode==="exact"?As:Ps).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}l(te,"parseMappingSource");function Os(t,e,n){let[i,r]=t.split(".");zr.includes(i)?r!==void 0&&i==="causedBy"&&!Vr.includes(r)?n?.warning(d.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${Vr.join(", ")}`,e):r!==void 0&&i==="identity"&&!Qr.includes(r)&&n?.warning(d.UnknownContextIdentityProperty,`Unknown $context.identity property '${r}' - expected ${Qr.join(", ")}`,e):n?.warning(d.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${zr.join(", ")}`,e)}l(Os,"warnOnUnknownContextPath");function Mt(t,e,n){let i=l(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(H(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!Rt(t))return;let o=Le(t);return o!==void 0?i(o):(n.error(d.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:t,location:e})}if(ws.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}l(Mt,"parseLiteral");var Pi=O("^then\\s+returns\\b"),un=O("^generated\\s+(?=\\S)(?![=])"),mn=O("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),Is=O("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Ts=O(`^(?:"${Z}"|'(?:[^'\\\\]|\\\\.)*')$`);function yn(t,e,n,i){if((e.startsWith('"')||e.startsWith("'"))&&!Ts.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=te(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}l(yn,"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=yn(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}}l(yt,"parseConcreteMapping");function Gr(t,e){let n=Pi.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=f(e);if(i.length>0){let s=yn(t,i,{...r,column:r.column+e.content.indexOf(i,n)},d.InvalidReturnExpectation),a=t.peekChild(e.indent);return a!==void 0&&(t.error(d.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,Is,d.InvalidReturnExpectation);a!==null&&o.push(a)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}l(Gr,"parseReturn");var Rs=V("^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$".replaceAll("\\s",z)),Ms=V("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$".replaceAll("\\s",z));function qe(t,e){let n=Rs.exec(e.content);if(n===null)return t.error(d.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=Ds(t,e,void 0,!0,n[1]);return{kind:"SpecificationExampleSyntax",name:n[1],type:n[2],...i,location:f(e)}}l(qe,"parseExample");function hn(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),c=yn(t,o,{...a,column:a.column+s},d.InvalidSpecificationValue);c!==null&&i.push({kind:"PropertyMappingSyntax",property:r,source:c,location:{...a,column:a.column+e.content.lastIndexOf(r,e.content.indexOf("="))}})}l(hn,"addInlineValue");function Dt(t,e,n,i=[]){if([...e,...i].some(r=>r.property===n.property)){t.error(d.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)}l(Dt,"addFixtureValue");function Ds(t,e,n,i=!1,r){let o=[],s=[],a=null,c=null;hn(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&&R(p.content)==="description"){c=_(t,p,c,`Example '${r}'`);continue}if(i&&un.test(p.content)){let u=yt(t,p,mn,d.InvalidGeneratedFixture);u!==null&&(r===void 0?s.push(u):Dt(t,s,u,o));continue}let m=Ms.exec(p.content);if(r!==void 0&&(R(p.content)==="streamId"||R(p.content)==="stream"&&m===null||p.content.startsWith("no stream"))){t.error(d.InvalidSpecificationExampleBody,"An example cannot declare stream, streamId or no stream; state the route on the specification step.",f(p)),t.skipOpaqueBlock(p.indent);continue}if(m!==null)Dt(t,o,{kind:"PropertyMappingSyntax",property:m[1],source:te(m[2],f(p),t),location:f(p)},s);else if(R(p.content)==="for"){let u=p.content.substring(3).trim();u.length===0?t.error(d.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(p)):a!==null?t.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(p)):a=te(u,f(p),t)}else t.error(d.InvalidSpecificationValue,`Invalid property mapping '${p.content}' - expected '<property> = <value>'`,f(p))}return{values:o,for:a,generatedValues:s,description:c}}l(Ds,"parseFixtureBody");var Kr=["StateChange","StateView","Automation","Translate"];var Nt=["tag"];var Ns=O(`^id\\s+"(${Z})"$`),ht=class{static{l(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=f(n);switch(R(n.content)){case"id":{let r=Ns.exec(n.content),o=r===null?"":H(r[1]);return o.trim().length===0||this.value.id!==null?e.error(d.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,i):(this.value.id=o,o===this.name&&e.information(d.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,i)),!0}case"description":return this.value.description=_(e,n,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":{if(n.content!=="documentation"||e.peekChild(n.indent)?.content!=="```markdown")return e.error(d.InvalidEventDocumentation,`Event '${this.name}' documentation requires a fenced markdown block`,i),e.skipOpaqueBlock(n.indent),!0;let r=ut(e,"markdown",n);return r===null||r.trim().length===0||this.value.documentation!==null?e.error(d.InvalidEventDocumentation,`Event '${this.name}' accepts one nonempty documentation block`,i):this.value.documentation=r,!0}default:return!1}}};var js=O("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Zr=l(t=>R(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),le=l(t=>Zr(t).length>0,"isFileDirective"),Sn=l(t=>le(t)&&!js.test(Zr(t)),"isFileDirectiveAmongProperties");var Ls=O("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?$"),qs=O("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier)(?:\\s+(?:optional|generated|identifier))*)$"),Bs=O("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function at(t){let e=Ls.exec(t.content);if(e===null)return;let n=f(t);return{kind:"PropertySyntax",name:X(e[1]),type:xe(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,location:n}}l(at,"tryParseProperty");function xe(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}}l(xe,"parseTypeRef");function Re(t,e){let n=at(e);return n!==void 0?Pe(t,n.type,e):gn(t,e),n}l(Re,"parseProperty");function Pe(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(d.LegacyOptionalSuffix,`Write '${o} optional' instead of '${o}?'.`,e.location)}}l(Pe,"reportLegacyOptionalSuffix");function gn(t,e){if(Bs.test(e.content))return t.error(d.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",f(e)),!0;{let n=qs.exec(e.content);if(n!==null&&n[1].split(/\s+/).some(i=>i==="generated"||i==="identifier"))return t.error(d.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",f(e)),!0}return!1}l(gn,"reportInvalidModifierOrder");var Fs=O("^type\\s+([A-Za-z_]\\w*)$"),Ys=O("^event\\s+([A-Za-z_]\\w*)(?:\\s+generation\\s+([0-9]+))?$"),Ws=O("^readmodel\\s+([A-Za-z_]\\w*)$"),_r=4294967295,Us=O("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),zs=O("^[A-Za-z_]\\w*$"),Jr=l(t=>R(t.content)==="description"&&at(t)===void 0,"isDescription");function Ai(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,f(n)),{...e,isIdentifier:!1}):e}l(Ai,"withoutIdentifier");function Hr(t,e){let n=Fs.exec(e.content)?.[1]??"";n===""&&t.error(d.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(),Jr(o)){r=_(t,o,r,`Type '${n}'`);continue}if(Sn(o))continue;let s=Re(t,o);if(s===void 0){t.error(d.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,f(o));continue}i.push(Ai(t,s,o,d.IdentifierOutsideCommand,`Property '${s.name}' of type '${n}' cannot be marked identifier - only a command property can be`))}return i.length===0&&t.error(d.TypeWithoutProperties,`Type '${n}' must declare at least one property`,f(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:f(e)}}l(Hr,"parseType");function Xr(t,e){let n=Ys.exec(e.content),i=n?.[1]??"";n===null&&t.error(d.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected 'event <Name> [generation <N>]'`,f(e));let r=n?.[2]!==void 0,o=1;if(r){let p=Number(n[2]);!Number.isSafeInteger(p)||p===0||p>=_r?t.error(d.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${_r-1}`,f(e)):o=p}let s=[],a=[],c=new ht(i);for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Sn(p))continue;if(Nt.includes(R(p.content))){let u=jt(t,p);u!==void 0&&a.push(u);continue}let m=Re(t,p);if(m===void 0){c.tryParse(t,p)||t.error(d.InvalidPropertyDeclaration,`Invalid property '${p.content}' - expected '<name> <Type>'`,f(p));continue}s.push(Ai(t,m,p,d.IdentifierOnEventProperty,`Property '${m.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:s,tags:a,generation:o,hasGenerationMarker:r,...c.value,location:f(e)}}l(Xr,"parseEvent");function jt(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&Us.test(i)&&t.warning(d.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(d.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",f(e));return}if(zs.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:f(e)},location:f(e)};let r=te(i,f(e),t);if(r.kind==="RawExpressionSyntax"){t.error(d.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)}}l(jt,"parseTag");function eo(t,e){let n=Ws.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <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(),Jr(o))r=_(t,o,r,`Read model '${n}'`);else{if(Sn(o))continue;{let s=Re(t,o);if(s===void 0){t.error(d.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,f(o));continue}i.push(Ai(t,s,o,d.IdentifierOutsideCommand,`Property '${s.name}' of read model '${n}' cannot be marked identifier - only a command property can be`))}}return{kind:"ReadModelSyntax",name:n,properties:i,description:r,location:f(e)}}l(eo,"parseReadModel");var Vs=V("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function ce(t,e,n){if(n=n.valueContext,t=t.trim(),t.startsWith("`")){let o=[];if(!t.endsWith("`")||t.length<2)return n.error(d.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 c=0;c<s.length;c++){if(s[c]!=="$"||s[c+1]!=="{")continue;c>a&&o.push({kind:"TemplateTextSyntax",text:s.substring(a,c),location:e});let p=s.indexOf("}",c);if(p<0)return n.error(d.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};o.push({kind:"TemplateInterpolationSyntax",expression:ce(s.substring(c+2,p),e,n),location:e}),c=p,a=p+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 ge(i,e,n);if(t.startsWith("literal ")){let o=Mt(t.substring(8).trim(),e,n);return o!==void 0?o:(n.error(d.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=Mt(t,e,n);return r!==void 0?r:Vs.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(d.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}l(ce,"parseProjectionExpression");var vn=l(t=>({legacy:O(t),native:V(t)}),"grammar"),Qs=vn("^capture\\s+([A-Za-z_]\\w*)$"),Gs=vn("^append\\s+([A-Z]\\w*)$"),Ks=vn("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),Zs=vn("^nested\\s+([\\w.]+)$"),xn=l((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),_s=V("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Js=V("^([a-z_]\\w*)\\s*=\\s*(.+)$"),Hs=V(`^"(${Z})"\\s*=>\\s*(\\w+)$`),Xs=V(`^split\\s+(\\S+)\\s+by\\s+"(${Z})"$`),el=new RegExp(V(`"${Z}"|[\\w.]+`).source,"gu"),tl=V("^[\\w.]+$");function wi(t,e){t=t.valueContext;let n=xn(t,Qs).exec(e.content)?.[1]??"";n===""&&t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,f(e));let i=null,r=null,o=[],s=[],a=[],c=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))switch(t.reader.takeSignificant(),R(p.content)){case"source":i=nl(t,p);break;case"key":r=p.content.substring(3).trim();break;case"map":o.push(...no(t,p));break;case"append":io(t,p,s);break;case"children":{let m=xn(t,Ks).exec(p.content);if(m===null){t.error(d.InvalidChildrenDeclaration,`Invalid children declaration '${p.content}' - expected 'children <collection> identified by <key>'`,f(p)),t.skipOpaqueBlock(p.indent);break}let u=to(t,p);m!==null&&a.push({kind:"CaptureChildrenSyntax",property:m[1],identifiedBy:m[2],...u,location:f(p)});break}case"nested":{let m=xn(t,Zs).exec(p.content);if(m===null){t.error(d.InvalidNestedDeclaration,`Invalid nested declaration '${p.content}' - expected 'nested <Property>'`,f(p)),t.skipOpaqueBlock(p.indent);break}let u=to(t,p);m!==null&&c.push({kind:"CaptureNestedSyntax",property:m[1],...u,location:f(p)});break}default:t.error(d.UnknownCaptureDirective,`Unexpected '${p.content}' in capture body`,f(p)),t.skipOpaqueBlock(p.indent)}return{kind:"CaptureSyntax",sourceOptions:t.sourceOptions,name:n,source:i,key:r,map:o,appends:s,children:a,nested:c,location:f(e)}}l(wi,"parseCapture");function nl(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=R(i.content);n.push({kind:"CaptureSourceSettingSyntax",name:r,value:i.content.substring(r.length).trim(),location:f(i)})}return{kind:"CaptureSourceSyntax",syntaxKind:e.content.substring(6).trim(),settings:n,location:f(e)}}l(nl,"parseSource");function no(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(R(i.content)==="split"){let u=Xs.exec(i.content);if(u===null){t.error(d.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(),tl.test(h.content)?y.push(h.content):t.error(d.InvalidSplitTarget,`Invalid split target '${h.content}' - expected a property path`,f(h));u!==null&&n.push({kind:"CaptureSplitSyntax",source:ce(u[1],r,t),separator:H(u[2]),targets:y,location:r});continue}let o=Js.exec(i.content);if(o===null){t.error(d.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,c=s.startsWith("`")?a>=0&&s.substring(a+1).trim()==="translate":s.endsWith(" translate"),p=s.startsWith("`")&&a>=0&&(t.sourceOptions.numericMode!=="exact"||c||s.substring(a+1).trim()==="")?s.substring(0,a+1):c?s.substring(0,s.length-10).trimEnd():s,m=[];if(c)for(let u=t.peekChild(i.indent);u!==void 0;u=t.peekChild(i.indent)){t.reader.takeSignificant();let y=Hs.exec(u.content);y!==null?m.push({kind:"CaptureTranslationSyntax",from:H(y[1]),to:y[2],location:f(u)}):t.error(d.InvalidTranslation,`Invalid translation '${u.content}' - expected '"<source>" => <target>'`,f(u))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:ce(p,r,t),translations:m,location:r})}return n}l(no,"parseMap");function to(t,e){let n=[],i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),R(r.content)==="map"?n=no(t,r):R(r.content)==="append"?io(t,r,i):(t.error(d.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${R(e.content)} block - expected 'map' or 'append <EventType>'`,f(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}l(to,"mapAndAppends");function io(t,e,n){let i=xn(t,Gs).exec(e.content);if(i===null){t.error(d.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,f(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],s=null,a=l((c,p=!1)=>{let m=f(c);if(R(c.content)==="tag"){let y=jt(t.valueContext,c,!1);y!==void 0&&o.push(y);return}let u=_s.exec(c.content);u!==null?r.push({kind:"PropertyMappingSyntax",property:X(u[1]),source:ge(u[2],m,t.valueContext),location:m}):t.error(p?d.InvalidPropertyMapping:d.UnknownAppendDirective,`Unexpected '${c.content}' in append body`,m)},"mapping");for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent))if(t.reader.takeSignificant(),R(c.content)==="when"){s=il(t,c);for(let p=t.peekChild(c.indent);p!==void 0;p=t.peekChild(c.indent))t.reader.takeSignificant(),a(p,!0)}else a(c);n.push({kind:"CaptureAppendSyntax",event:i[1],when:s,mappings:r,tags:o,location:f(e)})}l(io,"pushAppend");function il(t,e){let n=e.content.substring(4).trim(),i=f(e),r=l((c,p=[],m=null,u=null,y=null)=>({kind:"CaptureWhenSyntax",syntaxKind:c,properties:p,fromValue:m,toValue:u,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(d.UnterminatedTemplateExpression,"Unterminated template expression in 'when' - expected a closing backtick",i),r("Expression",[],null,null,n);if(n.length===0)return t.error(d.WhenWithoutTrigger,"Expected a trigger after 'when'",i),null;let o=[...n.match(t.sourceOptions.numericMode==="exact"?new RegExp(`"${Z}"|[^\\s]+`,"gu"):el)??[]],s=l(c=>c.startsWith('"')&&c.endsWith('"')?H(c.substring(1,c.length-1)):c,"unquote");if(o.length===0)return t.error(d.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(d.InvalidWhenTransitionClause,`Invalid 'when ... from ... to ...' clause '${e.content}'`,i),null);if(o[1]!=="or"&&o[1]!=="and")return t.error(d.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length%2===0)return t.error(d.WhenCombinatorWithoutProperty,`Expected a property after '${o[1]}'`,i),null;let a=[s(o[0])];for(let c=1;c<o.length-1;c+=2){if(o[c]!==o[1])return t.error(d.MixedWhenCombinators,`Cannot mix 'and' and 'or' in a single 'when' clause '${e.content}'`,i),null;a.push(s(o[c+1]))}return r(o[1]==="or"?"LogicalOr":"LogicalAnd",a)}l(il,"parseWhen");var Oi={"==":"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?z:"\\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(V(`"${Z}"|==|!=|>=|<=|>|<|\\(|\\)|${o}${s}`).source,"gu");if(i){let $=e.replace(a,"").replace(new RegExp(z,"gu"),"");if($.length>0)return t.error(d.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${$[0]}'`,n),null}let c=e.match(a)??[],p=0,m=l(()=>{if(c[p]==="("){p++;let E=y();return c[p]===")"?p++:(i||t.sourceOptions.numericMode==="exact")&&t.error(d.UnclosedConditionGroup,"Expected ')' in condition",n),E}let $=c[p++];if(i&&$===void 0)return t.error(d.ExpectedCondition,"Expected a condition",n),null;let v=c[p++];if(v==="starts"&&c[p]==="with"&&(v+=" with",p++),i&&!Object.hasOwn(Oi,v))return t.error(d.ExpectedComparisonOperator,`Expected a comparison operator after '${$}'`,n),null;let k=c[p++];return i&&k===void 0?(t.error(d.ExpectedComparisonValue,"Expected a value to compare against",n),null):$===void 0||k===void 0||Oi[v]===void 0?null:{kind:"ComparisonConditionSyntax",left:$,operator:Oi[v],right:ge(k,n,t),location:n}},"group"),u=l(()=>{let $=m();for(;$!==null&&c[p]==="and";){p++;let v=m();if(v===null)return null;$={kind:"LogicalConditionSyntax",left:$,operator:"And",right:v,location:n}}return $},"and"),y=l(()=>{let $=u();for(;$!==null&&c[p]==="or";){p++;let v=u();if(v===null)return null;$={kind:"LogicalConditionSyntax",left:$,operator:"Or",right:v,location:n}}return $},"or"),h=y();return(i||t.sourceOptions.numericMode==="exact")&&(h===null&&!i?t.error(d.ExpectedCondition,"Expected a condition",n):h!==null&&p<c.length&&t.error(d.UnexpectedTokenInCondition,`Unexpected '${c[p]}' in condition`,n)),h}l(Ze,"parseCondition");function de(t){return O(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}l(de,"sourceStreamPattern");var rl=de("^[A-Za-z_]\\w*(?![\\s\\S])"),ol=de("^[\\w.]+(?![\\s\\S])");function Ii(t){return typeof t=="string"&&rl.test(t)}l(Ii,"isSourceStreamName");function $n(t){return typeof t=="string"&&ol.test(t)}l($n,"isSourceStreamTypeName");var al=O(`^id\\s+"(${Z})"$`),sl=de("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),ll=de("^eventsource\\s+([A-Za-z_]\\w*)$"),cl=de("^stream\\s+([A-Za-z_]\\w*)$");function ro(t,e){let n=ll.exec(e.content)?.[1]??"";n===""&&Be(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(),R(a.content)){case"stream":i.push(dl(t,a));break;case"identifier":r=oo(t,a,"identifier",r);break;case"description":o=_(t,a,o,`Event source '${n}'`,!0);break;case"id":s=ao(t,a,n,s);break;default:Be(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)}}l(ro,"parseEventSource");function dl(t,e){let n=cl.exec(e.content)?.[1]??"";n===""&&Be(t,e,"Expected 'stream <Name>'.");let i=null,r=[],o=!1,s={},a=null,c=null;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))switch(t.reader.takeSignificant(),R(p.content)){case"streamId":o?(Be(t,p,"Declare either one 'streamId <Type>' or one streamId part block."),t.skipBlock(p.indent)):p.content==="streamId"?(o=!0,s.streamId=f(p),r=pl(t,p)):(i=oo(t,p,"streamId",i),o=i!==null);break;case"description":a=_(t,p,a,`Stream '${n}'`,!0);break;case"id":c=ao(t,p,n,c);break;default:Be(t,p,"A stream accepts description, id and streamId declarations."),t.skipBlock(p.indent);break}return{kind:"EventStreamSyntax",name:n,streamId:i,streamIdParts:r,description:a,id:c,directiveLocations:s,location:f(e)}}l(dl,"parseEventStream");function oo(t,e,n,i){let r=sl.exec(e.content);return r===null||i!==null?Be(t,e,`Declare at most one '${n} <Type>'.`):(i=xe(r[2],{...f(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),Pe(t,i,e)),Lt(t,e,d.InvalidEventSourceDeclaration),i}l(oo,"parseType");function ao(t,e,n,i){let r=al.exec(e.content),o=r===null?null:H(r[1]);return o===null||o.trim()===""||i!==null?Be(t,e,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(i=o,o===n&&t.information(d.RedundantSourceStreamId,"The rename pin repeats the current name; omit it for a new declaration.",f(e))),Lt(t,e,d.InvalidEventSourceDeclaration),i}l(ao,"parsePin");function so(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(d.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,f(e)),{...s,propertyCandidate:n};let a=null,c=[],p=!1,m={};for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),u.content==="streamId"){a!==null||p?(t.error(d.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent)):(p=!0,m.streamId=f(u),c=Ti(t,u,d.InvalidCommandStream));continue}let y=/^streamId\s*=\s*(.+)$/.exec(u.content);if(y===null||a!==null||p)t.error(d.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent);else{let h={...f(u),column:u.indent+1+u.content.indexOf(y[1],u.content.indexOf("=")+1)};a={kind:"PropertyMappingSyntax",property:"streamId",source:te(y[1],h,t),location:f(u)},Lt(t,u,d.InvalidCommandStream)}}return{...s,streamId:a,streamIdParts:c,directiveLocations:m}}l(so,"parseCommandStream");function pl(t,e){let n=[],i=de("^([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){Be(t,r,"Expected '<part> <Type>' without modifiers in a streamId part block."),t.skipBlock(r.indent);continue}let s=xe(o[2],{...f(r),column:r.indent+1+r.content.indexOf(o[2],o[1].length)});Pe(t,s,r),n.push({kind:"EventStreamIdPartSyntax",name:o[1],type:s,location:f(r)}),Lt(t,r,d.InvalidEventSourceDeclaration)}return n.length===0&&Be(t,e,"A streamId part block cannot be empty."),n}l(pl,"parseStreamIdParts");function Ti(t,e,n){let i=[],r=de("^([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:te(s[2],a,t),location:f(o)}),Lt(t,o,n)}return i.length===0&&t.error(n,"A streamId part block cannot be empty.",f(e)),i}l(Ti,"parseRouteParts");function Lt(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))}l(Lt,"rejectChildren");function Be(t,e,n){t.error(d.InvalidEventSourceDeclaration,n,f(e))}l(Be,"invalid");var Ri=O("^returns\\s+(@?[A-Za-z_]\\w*)$"),fl=O("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function Mi(t,e){let n=f(e);if(e.content!=="returns"){let r=Ri.exec(e.content);if(r===null)return t.error(d.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(d.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:X(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=fl.exec(r.content);if(o===null){t.error(d.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:xe(o[2],{...s,column:s.column+r.content.indexOf(o[2],o[1].length)});a!==null&&Pe(t,a,r),i.push({kind:"ResponseFieldSyntax",name:X(o[1]),type:a,source:{kind:"PropertyResponseSourceSyntax",property:X(o[3]),location:{...s,column:s.column+r.content.lastIndexOf(o[3])}},location:s});let c=t.peekChild(r.indent);c!==void 0&&(t.error(d.InvalidCommandResponse,"A response field cannot have child directives.",f(c)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}l(Mi,"parseCommandResponse");var ul=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function kn(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||ul.has(n)))return!1}return!0}l(kn,"isBlankImplementationHint");var lo=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),St=l(t=>R(t.content)==="file"&&t.content.substring(4).trim().length>0,"isFile"),qt=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCode");function _e(t,e){let n=e.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(n)&&t.warning(d.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)}}l(_e,"parseFile");var Di=l(t=>t.raw.trim()==="```","isClosingCodeFence");function ve(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n))return t.error(d.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(d.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(d.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(d.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(i));break}if(Di(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)}}l(ve,"parseCode");function co(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(d.HandlerWithoutImplementation,"Expected a 'file' directive or an inline code block in the handler",f(e)),null;if(t.reader.takeSignificant(),R(n.content)==="implementation")return ml(t,e,n);let i=St(n)?_e(t,n):null,r=i===null&&qt(t,n)?ve(t,n):null;if(i!==null||r!==null){let o=t.peekChild(e.indent);return o!==void 0&&R(o.content)==="implementation"&&(t.error(d.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(d.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,f(n)),t.skipBlock(e.indent),null}l(co,"parseHandler");function ml(t,e,n){let i=Bt(t,n);for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(R(r.content)==="implementation"?d.InvalidImplementationBlock:d.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",f(r)),qt(t,r)?ve(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:f(e)}}l(ml,"parseImplementation");function Bt(t,e){let n=[],i=null,r=null,o=!1;e.content!=="implementation"&&t.error(d.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(),R(s.content)==="hint"||lo.test(s.content)){let a=lo.exec(s.content),c=a===null?null:H(a[1]);kn(c)?t.error(d.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",f(s)):n.push({kind:"ImplementationHintSyntax",text:c,location:f(s)});let p=t.peekChild(s.indent);p!==void 0&&(t.error(d.InvalidImplementationHint,"A hint cannot have children.",f(p)),t.skipBlock(s.indent))}else if(St(s)||s.content.startsWith("```")){o&&t.error(d.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",f(s));let a=St(s)?_e(t,s):null,c=a===null?ve(t,s):null;o||(i=a,r=c),o=!0;let p=t.peekChild(s.indent);a!==null&&p!==void 0&&(t.error(d.InvalidImplementationBlock,"A file directive cannot have children.",f(p)),t.skipBlock(s.indent))}else t.error(d.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)}}}l(Bt,"parseImplementationWrapper");var ie=class extends Error{static{l(this,"InvalidSyntaxJson")}};var $e=Object.freeze({numericMode:"legacy"}),bn=Object.freeze({numericMode:"exact"}),po=Object.freeze({numericMode:"invalid"});function gt(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 ie("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new ie("Malformed source numeric options.");return e==="exact"?bn:$e}l(gt,"validatedSourceOptions");var fo=new WeakSet;function uo(t){fo.add(t)}l(uo,"recordAuthoredDocument");function mo(t){return fo.has(t)}l(mo,"isAuthoredDocument");var he=class t{static{l(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=$e;authoredDeclarations=!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 ft(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 En=new WeakMap;var Fe=new WeakMap,Ae=l(t=>Fe.get(t)??{},"dependencySourcesOf");function Cn(t){let e=V(`^reads${z}+([A-Z]\\w*)(?:${z}+as${z}+([a-z_]\\w*))?(?:${z}+by${z}+([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)}}l(Cn,"captureReads");function yo(t){return new he(t.reader.fork(),t.path,t.languages)}l(yo,"fork");function ho(t,e){if(e.content!=="concurrency")return;let n=yo(t),i=!1,r={},o;for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent))switch(n.reader.takeSignificant(),R(s.content)){case"eventSource":s.content==="eventSource"&&(i=!0);break;case"sourceType":case"streamType":case"streamId":{let a=V(`^(sourceType|streamType|streamId)${z}+([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(c=>c.replace(new RegExp(`^${z}+|${z}+$`,"gu"),"")).filter(Boolean);a.length>0&&a.every(c=>V("^[A-Z]\\w*$").test(c))&&(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)}}l(ho,"captureConcurrency");function So(t,e){let n=V(`^reducer${z}+([A-Za-z_]\\w*)${z}*=>${z}*([A-Za-z_]\\w*)$`).exec(e.content),i=yo(t),r=[];for(let o=i.peekChild(e.indent);o!==void 0;o=i.peekChild(e.indent)){if(i.reader.takeSignificant(),R(o.content)==="description"){_(i,o,null,"Reducer");continue}let s=V(`^on${z}+([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)}}l(So,"captureReducer");var yl=O("^system\\s+([A-Za-z_]\\w*)$"),hl=O("^operation\\s+([A-Za-z_]\\w*)$"),Sl=O("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),Ni=O("^uses\\s+([A-Za-z_]\\w*)$"),gl=O("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),xl=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function Ft(t,e,n,i){let r=t.peekChild(e.indent);r!==void 0&&(t.error(n,i,f(r)),t.skipBlock(e.indent))}l(Ft,"rejectOperationChildren");function go(t,e){let n=yl.exec(e.content);n===null&&t.error(d.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(),R(r.content)==="description"?i=_(t,r,i,`System '${n?.[1]??""}'`):(t.error(d.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)}}l(go,"parseSystem");function Pn(t,e,n=!1){let i=(n?Sl:hl).exec(e.content),r=i?.[1]??"";i===null&&t.error(d.InvalidOperationDeclaration,"Expected an operation declaration with one name.",f(e));let o=null,s=null,a=f(e),c=null,p=null,m=[],u=[],y=new Set;for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){t.reader.takeSignificant();let $=gl.exec(h.content),v=n&&$!==null?{...h,content:$[1].trimEnd()}:h;if($===null&&xl.has(R(h.content))){t.error(d.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",f(h)),t.skipBlock(h.indent);continue}if(!Ni.test(h.content)&&at(v)!==void 0){let k=Re(t,v);n&&$===null&&t.error(d.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",f(h)),(k.isIdentifier||k.isGenerated)&&t.error(d.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",f(h)),y.has(k.name)&&t.error(d.DuplicateDeclaration,`Operation '${r}' already declares input '${k.name}'.`,f(h)),y.add(k.name),m.push(k),n&&$!==null&&u.push({kind:"PropertyMappingSyntax",property:k.name,source:te($[2],{...f(h),column:h.indent+h.content.length-$[2].length+1},t),location:f(h)}),Ft(t,h,d.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(R(h.content)==="description")o=_(t,h,o,`Operation '${r}'`);else if(Ni.test(h.content))s!==null?t.error(d.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",f(h)):(s=Ni.exec(h.content)[1],a={...f(h),column:f(h).column+h.content.indexOf(s,4)}),Ft(t,h,d.InvalidSystemReference,"A system reference cannot have children.");else if(h.content==="execute"||h.content==="compensate"){let k=vl(t,h);h.content==="execute"?c!==null?t.error(d.InvalidOperationDeclaration,"An operation declares execute at most once.",f(h)):c=k:p!==null?t.error(d.InvalidOperationDeclaration,"An operation declares compensate at most once.",f(h)):p=k}else t.error(d.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(d.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",f(e)),{operation:{kind:"OperationSyntax",name:r,uses:s??"",usesLocation:a,inputs:m,description:o,execute:c,compensate:p,location:f(e)},mappings:u}}l(Pn,"parseOperation");function vl(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(),R(a.content)==="description"){n=_(t,a,n,`Operation phase '${e.content}'`);continue}if(R(a.content)==="implementation"){s&&t.error(d.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",f(a));let c=Bt(t,a);s||(i=c.file,r=c.code,o=c.implementation),s=!0}else if(le(a)||a.content.startsWith("```")){s&&t.error(d.ConflictingImplementationSources,"A phase has at most one file or inline payload.",f(a));let c=le(a)?_e(t,a):null,p=c===null?ve(t,a):null;s||(i=c,r=p),s=!0,c!==null&&Ft(t,a,d.InvalidImplementationBlock,"A file directive cannot have children.")}else t.error(d.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)}}l(vl,"parseOperationPhase");var $l=O("^produces\\s+operation(?:\\s|$)"),kl=O("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),bl=O("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),xo=O("^produces\\s+when\\s+(.+)$"),El=O("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Cl=O("^for\\s+(\\S.*)$"),Pl=O("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Al=O("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),wl=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function Yt(t,e,n=!1){if($l.test(e.content)){if(!n){t.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",f(e)),t.skipOpaqueBlock(e.indent);return}let $=Pn(t,e,!0);return{kind:"ProducesSyntax",when:null,event:$.operation.name,targetLocation:{...f(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:$.operation,mappings:$.mappings,for:null,tags:[],location:f(e)}}let i=kl.exec(e.content),r=e,o=null,s,a;if(i!==null){if(!n){t.error(d.InlineEventOutsideCommand,"Inline events can only be declared inside commands",f(e)),t.skipOpaqueBlock(e.indent);return}i[2]!==void 0&&t.error(d.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(xo.test(e.content)){o=Ze(t,xo.exec(e.content)[1],f(e));let $=t.peekChild(e.indent);if($===void 0||!El.test($.content)){t.error(d.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",f(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=$,s=$.content,a=$.indent+1}else{let $=bl.exec(e.content);if($===null){t.error(d.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,f(e)),t.skipOpaqueBlock(e.indent);return}s=$[1],a=e.indent+e.content.match(/^produces\s+/)[0].length+1}let c=[],p=new Set,m=[],u=[],y=new ht(s),h=null;for(let $=t.peekChild(r.indent);$!==void 0;$=t.peekChild(r.indent)){t.reader.takeSignificant();let v=R($.content),k=f($);if(wl.has(v)){t.error(d.ReservedProductionMetadata,`'${v}' is system-assigned production metadata and cannot be supplied here`,k),t.skipOpaqueBlock($.indent);continue}if(i!==null&&(v==="generation"||v==="origin")){t.error(v==="generation"?d.InlineEventGeneration:d.ReservedProductionMetadata,v==="generation"?"Inline events are generation 1 - extract the event before declaring generations":"An inline event is local to its command and cannot declare origin",k),t.skipOpaqueBlock($.indent);continue}if(v==="tag"){let A=jt(t,$,!1);A!==void 0&&u.push(A);continue}let E=Cl.exec($.content);if(E!==null){h!==null?t.error(d.DuplicateProducesTarget,`'${r.content}' already declares where it lands - an event is appended to one event source`,k):h=te(E[1],k,t);continue}let b=(i===null?Pl:Al).exec($.content),P=b===null||i===null?void 0:Re(t,{...$,content:b[1].trimEnd()});if(b!==null&&(i===null||P!==void 0)){if(P!==void 0){P.isIdentifier&&(t.error(d.IdentifierOnEventProperty,`Property '${P.name}' of event '${s}' cannot be marked identifier - an event never carries its event source id`,k),P={...P,isIdentifier:!1});let A=P.name;p.has(A)&&t.error(d.DuplicateDeclaration,`Event '${s}' already declares property '${P.name}'`,k),p.add(A),c.push(P)}m.push({kind:"PropertyMappingSyntax",property:P?.name??X(b[1]),source:te(b[2],{...k,column:$.indent+$.content.length-b[2].length+1},t),location:k})}else(i===null||!y.tryParse(t,$))&&t.error(d.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${$.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,k)}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?u:[],location:f(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:s,properties:c,tags:u,generation:1,hasGenerationMarker:!1,...y.value,location:f(e)}}}l(Yt,"parseProduces");var Ol=O("^command\\s+([A-Za-z_]\\w*)$"),Il=de("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),Tl=O("\\bseverity\\s+(\\S+)$"),$o=O(`\\bmessage\\s+(?:"(${Z})"|(\\$strings\\.\\S*))$`),Rl=O("^([\\w.]+)\\s+(.+)$"),Ml=O("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),Dl=de("^[A-Za-z_]\\w*$"),Nl=O("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),jl={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},ko={information:"Information",warning:"Warning",error:"Error"},Ll=new Set(["reads","concurrency"]),ql=new Set(["description","handler","concurrency"]);function bo(t,e){let n=new Set,i=new he(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,vo(i,e,void 0,n),vo(t,e,n)}l(bo,"parseCommand");function vo(t,e,n,i){let r=Ol.exec(e.content)?.[1]??"";r===""&&t.error(d.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,f(e));let o=[],s=[],a,c=[],p=[],m=[],u=[],y,h=null,$=null,v=null,k=null,E=[];for(let x=t.peekChild(e.indent);x!==void 0;x=t.peekChild(e.indent)){t.reader.takeSignificant();let C=R(x.content),I=at(x);if(I!==void 0&&(ql.has(C)||C==="validate"&&x.content!=="validate csharp"))a=An(t,o,I,r,x,a);else if(C==="returns"){let w=Ri.exec(x.content);w!==null&&!w[1].startsWith("@")&&I!==void 0?n===void 0?(o.push(I),s.push({line:x,candidate:I,response:null})):n.has(I.type.name)?s.push({line:x,candidate:null,response:Mi(t,x)}):a=An(t,o,I,r,x,a):I!==void 0?a=An(t,o,I,r,x,a):gn(t,x)?t.skipBlock(x.indent):s.push({line:x,candidate:null,response:Mi(t,x)})}else if(C==="stream"&&Il.test(x.content)&&I!==void 0&&t.streamCandidates?.hasSource(I.type.name.split(".")[0])===!0){let[w,j]=I.type.name.split("."),N=t.streamCandidates.hasPropertyType(I.type.name)&&t.streamCandidates.hasUniqueStream(w,j),L=so(t,x,I,N);(k!==null||E.length>0)&&t.error(d.InvalidCommandStream,"A command declares at most one stream route.",f(x)),N||k!==null?E.push(L):k=L}else if(C==="description")h=_(t,x,h,`Command '${r}'`);else if(C==="authorize")$=Te($,Ke(t,x));else if(C==="validate"){let w=ji(t,x,"command");w!==void 0&&c.push(w)}else if(C==="produces"){let w=Yt(t,x,!0);w!==void 0&&p.push(w)}else if(C==="handler")v=co(t,x);else if(Ll.has(C)){let w=Cn(x);w!==void 0&&u.push(w),C==="concurrency"&&y===void 0&&(y=ho(t,x));let j=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(x.content);j!==null&&m.push({readModel:j[1],alias:j[2]??null}),Nl.test(x.content)&&t.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(x)),t.skipOpaqueBlock(x.indent)}else I!==void 0?a=An(t,o,I,r,x,a):(gn(t,x),t.error(d.UnknownCommandDirective,`Unexpected '${x.content}' in command body`,f(x)),t.skipBlock(x.indent))}let b=new Set(s.flatMap(x=>x.candidate===null?[]:[x.candidate])),P=new Set(o.filter(x=>!b.has(x)).map(x=>x.name));s.some(x=>x.candidate!==null&&!P.has(x.candidate.type.name)&&x.candidate.type.name!=="returns")&&P.add("returns");for(let x of P)i?.add(x);let A=null,S=new Set;for(let x of s){let C=x.response;if(x.candidate!==null){if(!P.has(x.candidate.type.name))continue;S.add(x.candidate),C={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:x.candidate.type.name,location:x.candidate.type.location},location:f(x.line)}}C!==null&&(A!==null?t.error(d.InvalidCommandResponse,"A command declares at most one unconditional response.",f(x.line)):A=C)}v!==null&&p.length>0&&t.error(d.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,f(e));let g={kind:"CommandSyntax",name:r,description:h,authorize:$,properties:o.filter(x=>!S.has(x)),validations:c,produces:p,handler:v,response:A,stream:k,streamCandidates:E,location:f(e)};return En.set(g,m),Fe.set(g,{reads:u,concurrency:y}),g}l(vo,"parseCommandBody");function An(t,e,n,i,r,o){return Pe(t,n.type,r),n.isIdentifier&&o!==void 0&&(t.error(d.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)}l(An,"addProperty");function ji(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=ve(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||R(a.content)==="implementation"){t.error(d.InvalidValidationRule,`Invalid validation rule '${a.content}'`,f(a)),s??=a.indent;continue}}if(R(a.content)==="require"){let p=Ze(n==="concept"?t.valueContext:t,a.content.substring(7).trim(),f(a)),m=null,u="Error",y=!1;for(let h=t.peekChild(a.indent);h!==void 0;h=t.peekChild(a.indent)){t.reader.takeSignificant();let $=$o.exec(h.content);$!==null&&$.index===0?m=$[1]!==void 0?H($[1]):$[2]:R(h.content)==="severity"?(y||(u=ko[h.content.substring(8).trim()]??"Error"),y=!0):t.skipOpaqueBlock(h.indent)}p!==null&&o.push({kind:"RequirementSyntax",condition:p,message:m,severity:u,location:f(a)});continue}let c=Bl(t,n==="concept"?{...a,content:`value ${a.content}`}:a,n);c!==void 0&&r.push(c)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:f(e)}}if(e.content==="validate csharp"){let i=ve(t.valueContext,{...e,content:"csharp"});return i===null&&t.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",code:i,location:f(e)}}t.error(d.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,f(e)),t.skipBlock(e.indent)}l(ji,"parseValidate");function Bl(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=Yl(e.content),s=Wl(i,e,r);if(s===void 0)return;let a=Rl.exec(s.content);if(a===null){i.error(d.InvalidValidationRule,`Invalid validation rule '${e.content}'`,f(e));return}let c=Ul(i,a[2],e);if(c===void 0)return;let p=c.kind==="Rule"?Fl(t,e,n==="command"):{file:null,code:null,implementation:null};return{kind:"ValidationRuleSyntax",property:a[1],rule:c.kind,value:c.value,message:o,severity:s.severity,...p,location:f(e)}}l(Bl,"parseValidationRule");function Fl(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&&R(i.content)==="implementation",o=r?Bt(t,i):{file:St(i)?_e(t,i):null,code:!St(i)&&qt(t,i)?ve(t,i):null,implementation:null};!r&&o.file===null&&o.code===null&&(t.error(d.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&&R(s.content)==="implementation");s=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(r&&R(s.content)==="implementation"?d.InvalidImplementationBlock:d.ConflictingImplementationSources,"A named rule has one implementation wrapper and cannot mix wrapped and direct sources.",f(s)),qt(t,s)?ve(t,s):t.skipBlock(s.indent);return o}l(Fl,"parseRuleImplementation");function Yl(t){let e=$o.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?H(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}l(Yl,"splitMessage");function Wl(t,e,n){let i=Tl.exec(n);if(i===null)return{content:n,severity:"Error"};let r=ko[i[1]];if(r===void 0){t.error(d.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,f(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}l(Wl,"splitSeverity");function Ul(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=Ml.exec(e);if(i===null){t.error(d.InvalidValidationRule,`Invalid validation rule '${n.content}'`,f(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!Dl.test(r)){t.error(d.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:jl[i[1]],value:te(i[2],f(n),t)}}l(Ul,"parseRule");var zl=O("^constraint\\s+([A-Za-z_]\\w*)$"),Vl=O("^unique\\s+event\\s+([A-Z]\\w*)$"),Ql=O("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),Gl=O("^released\\s+by\\s+([A-Z]\\w*)$"),Kl=O(`^message\\s+"(${Z})"$`),Zl=l(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function Eo(t,e){let n=zl.exec(e.content);n===null&&t.error(d.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,f(e));let i=n?.[1]??R(e.content),r=[],o=[],s=new Set,a=new Set,c=null,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=Gl.exec(m.content),y=Kl.exec(m.content);u!==null?s.has(u[1])?t.error(d.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${u[1]}'`,f(m)):(o.push(u[1]),s.add(u[1])):y!==null?c!==null?t.error(d.DuplicateConstraintBody,`Constraint '${i}' already has a message`,f(m)):c=H(y[1]):m.content==="ignore casing"?(p&&t.error(d.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,f(m)),p=!0):_l(t,i,m,r,a)}for(let m of o.filter(u=>a.has(u)))t.error(d.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${m}'`,f(e));return r.length===0&&(t.error(d.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,f(e)),r.push(wn(i,f(e),{kind:"UniqueEventConstraintSyntax",event:""}))),r[0].kind==="FileConstraintSyntax"&&(o.length>0||c!==null||p)&&t.error(d.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,f(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:c,ignoreCasing:p}}l(Eo,"parseConstraint");function _l(t,e,n,i,r){let o=Jl(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(d.DuplicateConstraintBody,`Constraint '${e}' cannot mix constraint kinds`,f(n));return}let s=Zl(o);if(s!==void 0&&r.has(s)){t.error(d.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,f(n));return}s!==void 0&&r.add(s),i.push(o)}l(_l,"addRule");function Jl(t,e,n){let i=f(n),r=Vl.exec(n.content);if(r!==null)return wn(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=Ql.exec(n.content);if(o!==null){let s=o[1].split(",").map(a=>a.trim());if(new Set(s).size!==s.length){t.error(d.DuplicateConstraintBody,`Constraint '${e}' repeats a property in its composite key`,i);return}return wn(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:o[2]})}if(le(n)){t.warning(d.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 wn(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}t.error(d.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}l(Jl,"parseRule");function wn(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}l(wn,"rule");var Hl=O("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),Xl=O("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),ec=O("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),tc=O("^with\\s+(@?[\\w.]+)$"),nc=O("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),ic=O("^nested\\s+(@?[\\w.]+)$"),rc=O("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),oc=O("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),ac=O("^clear\\s+with\\s+(@?[\\w.]+)$"),sc=O("^variant\\s+(@?[\\w.]+)\\s*$"),lc=O("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),cc=O("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),dc=O("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),pc=O("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),Co=O("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),fc={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function qi(t,e){let n=Hl.exec(e.content);if(n===null)return t.error(d.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:R(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:f(e)};let i=n[1],r=null,o="Inherit",s=null,a=[];for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent)){if(t.reader.takeSignificant(),le(c))continue;let p=R(c.content);if(p==="sequence")r=c.content.substring(8).trim();else if(p==="automap")o="Enabled";else if(c.content==="no automap")o="Disabled";else if(p==="key")s=Ao(t,c);else if(p==="variant")a.push(vc(t,c));else{let m=Bi(t,c,!1);m!==void 0&&a.push(m)}}return uc(t,a,i),a.length===0&&t.error(d.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:o,key:s,blocks:a,location:f(e)}}l(qi,"parseProjection");function uc(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(d.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(d.DuplicateVariantEnteringEvent,`Entering event '${s.event}' is claimed more than once in projection '${n}'`,s.location),o.add(s.event)}l(uc,"reportVariantConflicts");function Bi(t,e,n){let i=f(e);switch(R(e.content)){case"from":return mc(t,e);case"every":{let r=!0,{autoMap:o,mappings:s}=Li(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}=Li(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return yc(t,e);case"children":return hc(t,e);case"nested":return Sc(t,e);case"remove":return gc(t,e);case"clear":return n||t.error(d.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),xc(t,e);default:t.error(d.UnknownProjectionDirective,`Unexpected '${R(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}l(Bi,"parseBlock");function mc(t,e){let n=[];for(let s of Yr(e.content.substring(4),",")){let a=s.trim();if(a.length===0){t.error(d.FromWithoutEvent,"Expected an event type after 'from'",f(e));continue}let c=Xl.exec(a);if(c===null){t.error(d.InvalidEventReference,`Invalid event reference '${a}'`,f(e));continue}n.push({kind:"EventSpecSyntax",event:X(c[1]),key:c[2]===void 0?null:ce(c[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=R(s.content);a==="key"?r=Ao(t,s):a==="parent"?o=ce(s.content.substring(6),f(s),t):wo(t,s,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:f(e)}}l(mc,"parseFrom");function yc(t,e){let n=ec.exec(e.content);if(n===null)return t.error(d.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=tc.exec(r.content);if(o===null){t.error(d.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:a}=Li(t,r);i.push({kind:"JoinEventSyntax",event:X(o[1]),autoMap:s,mappings:a,location:f(r)})}return{kind:"JoinSyntax",property:X(n[1]),on:X(n[2]),events:i,location:f(e)}}l(yc,"parseJoin");function hc(t,e){let n=nc.exec(e.content);if(n===null)return t.error(d.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}=Po(t,e);return{kind:"ChildrenSyntax",property:X(n[1]),identifiedBy:ce(n[2],f(e),t),autoMap:i,blocks:r,location:f(e)}}l(hc,"parseChildren");function Sc(t,e){let n=ic.exec(e.content);if(n===null)return t.error(d.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=X(n[1]),{autoMap:r,blocks:o}=Po(t,e);return o.some(s=>s.kind==="FromSyntax")||t.error(d.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,f(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:f(e)}}l(Sc,"parseNested");function Po(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=Bi(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}l(Po,"parseChildBlocks");function gc(t,e){let n=oc.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:X(n[1]),key:n[2]===void 0?null:ce(n[2],f(e),t),location:f(e)};let i=rc.exec(e.content);if(i===null){t.error(d.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(),R(o.content)==="parent"?r=ce(o.content.substring(6),f(o),t):t.error(d.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,f(o));return{kind:"RemoveWithSyntax",event:X(i[1]),key:i[2]===void 0?null:ce(i[2],f(e),t),parentKey:r,location:f(e)}}l(gc,"parseRemove");function xc(t,e){let n=ac.exec(e.content);return n===null?(t.error(d.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,f(e)),{kind:"ClearWithSyntax",event:"",location:f(e)}):{kind:"ClearWithSyntax",event:X(n[1]),location:f(e)}}l(xc,"parseClearWith");function vc(t,e){let n=sc.exec(e.content);if(n===null)return t.error(d.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:R(e.content),entersOn:[],blocks:[],location:f(e)};let i=X(n[1]),r=[],o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=R(s.content);if(a==="enters")r.push($c(t,s));else if(a==="variant")t.error(d.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",f(s)),t.skipBlock(s.indent);else{let c=Bi(t,s,!1);c!==void 0&&o.push(c)}}return r.length===0&&t.error(d.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,f(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:f(e)}}l(vc,"parseVariant");function $c(t,e){let n=lc.exec(e.content);return n===null?(t.error(d.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:X(n[1]),key:n[2]===void 0?null:ce(n[2],f(e),t),location:f(e)}}l($c,"parseEntersOn");function Ao(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:ce(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=Co.exec(o.content);if(s===null){t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,f(o));continue}let a=ce(s[2],f(o),t);t.sourceOptions.numericMode==="exact"&&a.kind==="TemplateExpressionSyntax"&&t.error(d.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",f(o)),i.push({kind:"KeyPartSyntax",property:X(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(d.EmptyCompositeKey,"Composite keys must contain at least one part",f(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:f(e)}}l(Ao,"parseKey");function Li(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)||wo(t,o,r);return{autoMap:i,mappings:r}}l(Li,"parseMappingBlock");function wo(t,e,n){let i=f(e),r=cc.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:fc[r[1]],property:X(r[2]),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(d.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=dc.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:X(o[2]),value:ce(o[3],i,t),location:i});return}let s=pc.exec(e.content)??Co.exec(e.content);s!==null?n.push({kind:"SetMappingSyntax",property:X(s[1]),source:ce(s[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}l(wo,"pushMapping");var kc=O("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),bc=O("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),Ec=O("^scoped\\s+to\\s+([a-z_]\\w*)$"),Cc=new Set(["performer"]);function Io(t,e){let n=kc.exec(e.content);if(n===null)return t.error(d.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,f(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:R(e.content),returnType:xe("",f(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:f(e)};let i=n[1],r=xe(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||Pe(t,r,e);let o=null,s=[],a=null,c=null,p=null;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=R(m.content);if(u==="description")a=_(t,m,a,`Query '${i}'`);else if(u==="by"){let y=Oo(t,m,"by");y!==void 0&&(o!==null&&t.error(d.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,f(m)),o=y)}else if(u==="filter"){let y=Oo(t,m,"filter");y!==void 0&&s.push(y)}else u==="authorize"?p=Te(p,Ke(t,m)):u==="scoped"?c=Pc(t,m,c,i)??c:Cc.has(u)?t.skipOpaqueBlock(m.indent):(t.error(d.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:c,authorize:p,location:f(e)}}l(Io,"parseQuery");function Oo(t,e,n){let i=bc.exec(e.content.substring(n.length).trim());if(i===null){t.error(d.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=xe(i[2],{...f(e),column:e.indent+1+e.content.indexOf(i[2],r+i[1].length)});return Pe(t,o,e),{kind:"QueryParameterSyntax",name:i[1],type:o,source:i[3]===void 0?null:te(i[3],f(e),t.valueContext),location:f(e)}}l(Oo,"parseParameter");function Pc(t,e,n,i){let r=Ec.exec(e.content);if(r===null){t.error(d.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,f(e));return}if(n!==null){t.error(d.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,f(e));return}return r[1]}l(Pc,"parseScope");var Ac=O("^@?[a-z_]\\w*\\s+[\\w.]+");function Fi(t,e){let n=Re(t,e);if(n!==void 0){n.isGenerated&&t.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),t.triggerData.push(n);return}Ac.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(d.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,f(e)),t.skipOpaqueBlock(e.indent)}l(Fi,"parseTriggerData");function To(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(),R(i.content)==="description"?_(t,i,null,`Trigger '${e.content}'`):le(i)||Fi(t,i);return t.triggerData.slice(n)}l(To,"parseTriggerDeclaration");var wc=O("^reaction\\s+([A-Za-z_]\\w*)$"),Oc=O("^when\\s+([A-Za-z_]\\w*)$"),Ic=O("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),Tc=O("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),Rc=new Set(["when","every","at"]),Mc=O("^invokes\\s+([A-Z]\\w*)$"),Dc=V("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Yi=V("^on\\s+refused\\b(?=$|\\s+by\\b)"),Nc=V("^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$"),jc=O("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function Ro(t,e){let n=wc.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,f(e));let i=null,r=null,o=[],s=new Set,a=!1;for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent)){t.reader.takeSignificant();let p=R(c.content);if(p==="description"){i=_(t,c,i,`Reaction '${n}'`);continue}if(p==="where"){r=Ze(t,c.content.substring(5).trim(),f(c));continue}if(Yi.test(c.content)){t.error(d.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(c)),t.skipBlock(c.indent),a=!0;continue}if(!Rc.has(p)){t.error(d.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${c.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,f(c)),t.skipBlock(c.indent),a=!0;continue}let m=Fc(t,c);if(m===void 0){a=!0;continue}let u=Bc(m);if(s.has(u)){t.error(d.DuplicateReactionTrigger,`Reaction '${n}' already declares '${c.content}' - a second says nothing the first did not`,f(c)),t.skipBlock(c.indent);continue}s.add(u),o.push(Lc(t,c,m))}return o.length===0&&!a&&t.error(d.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,f(e)),{kind:"ReactionSyntax",name:n,description:i,where:r,triggers:o,location:f(e)}}l(Ro,"parseReaction");function Lc(t,e,n){let i=null,r=[],o=[],s=[],a=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let m=R(p.content);if(m==="description")i=_(t,p,i,`Trigger '${p.content}'`);else if(m==="produces"){let u=Yt(t,p);u!==void 0&&r.push(u)}else if(m==="invokes"){let u=Mc.exec(p.content);if(u===null)t.error(d.InvalidInvokesDeclaration,`Invalid invokes declaration '${p.content}' - expected 'invokes <Command>'`,f(p)),t.skipBlock(p.indent);else{let y=new he(t.reader.fork(),t.path,t.languages);y.scope=t.scope,y.sourceOptions=t.sourceOptions,Ce(y,p),t.inputUses.push(...y.inputUses);let h=[],$=[];for(let v=t.peekChild(p.indent);v!==void 0;v=t.peekChild(p.indent)){if(t.reader.takeSignificant(),Yi.test(v.content)){let E=qc(t,v);E!==void 0&&$.push(E);continue}let k=Dc.exec(v.content);k!==null?h.push({kind:"PropertyMappingSyntax",property:k[1].replaceAll("@",""),source:ge(k[2],f(v),t.valueContext),location:f(v)}):t.error(d.InvalidPropertyMapping,`Invalid property mapping '${v.content}' - expected '<property> = <source>'`,f(v))}o.push({kind:"InvokesSyntax",command:u[1],mappings:h,onRefused:$,location:f(p)})}}else if(Yi.test(p.content))t.error(d.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent);else if(m==="reads"||m==="file"||p.content==="csharp"||p.content.startsWith("```")){let u=Cn(p);u!==void 0&&s.push(u),jc.test(p.content)&&t.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(p)),p.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(p.indent)}else{let u=t.triggerData.length;Fi(t,p);for(let y of t.triggerData.slice(u))a.push({kind:"TriggerDataSyntax",name:y.name,type:y.type,location:y.location})}}let c={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:f(e)};return Fe.set(c,{reads:s,data:a}),c}l(Lc,"parseTrigger");function qc(t,e){let n=Nc.exec(e.content);if(n===null||n[2]!==void 0&&n[1]!=="constraint"){t.error(d.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(),s.content==="acknowledge")(r||i.length>0||t.peekChild(s.indent)!==void 0)&&(t.error(d.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(R(s.content)==="produces"){r&&(t.error(d.InvalidRefusalBranchBody,"A refusal branch cannot combine 'acknowledge' and 'produces'.",f(s)),o=!0);let a=Yt(t,s);a!==void 0?i.push(a):o=!0}else t.error(d.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(d.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)}}l(qc,"parseRefusal");function Bc(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])}}l(Bc,"sourceKey");function Fc(t,e){let n=f(e);switch(R(e.content)){case"when":{let i=Oc.exec(e.content);if(i===null){t.error(d.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=Ic.exec(e.content),r=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(r)||r<1||r>2147483647){t.error(d.InvalidIntervalTrigger,`Invalid interval '${e.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,n),t.skipBlock(e.indent);return}return{kind:"IntervalTriggerSourceSyntax",amount:r,unit:Uc(i[2]),location:n}}default:return Yc(t,e)}}l(Fc,"parseTriggerSource");function Yc(t,e){let n=f(e),i=Tc.exec(e.content),r=i===null?void 0:Wc(i[1]);if(i===null||r===void 0){t.error(d.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(d.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}}l(Yc,"parseSchedule");function Wc(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}l(Wc,"timeOf");function Uc(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}l(Uc,"unitOf");var zc=O(`^when${z}+([^\\n]+)${z}+execute${z}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Vc=O(`^otherwise${z}+execute${z}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Qc=O(`^with${z}+([A-Za-z_]\\w*)${z}+from${z}+([^\\n]+)$`),Gc=O("^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Kc=new RegExp(`^${z}+|${z}+$`,"gu");function Do(t,e,n,i){let r=[],o=null,s=null,a=!1;for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent)){t.reader.takeSignificant();let p=zc.exec(c.content),m=Vc.exec(c.content);if(p!==null){a&&t.error(d.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(c));let u=Ze(t,p[1],f(c),!0),y=Mo(t,c);u!==null&&(Wi(t,u),r.push({kind:"ScreenActionAlternativeSyntax",condition:u,command:p[2],arguments:y,location:f(c)}))}else if(c.content==="otherwise hidden"||m!==null)if(a&&t.error(d.MisplacedActionOtherwise,"A guarded action permits only one 'otherwise'",f(c)),a=!0,m!==null)o={kind:"ScreenActionOtherwiseSyntax",outcome:"Execute",command:m[1],arguments:Mo(t,c),location:f(c)};else{o={kind:"ScreenActionOtherwiseSyntax",outcome:"Hidden",command:null,arguments:[],location:f(c)};for(let u=t.peekChild(c.indent);u!==void 0;u=t.peekChild(c.indent))t.reader.takeSignificant(),t.error(d.InvalidActionAlternative,"'otherwise hidden' cannot declare command arguments",f(u)),t.skipBlock(u.indent)}else if(R(c.content)==="navigate")s!==null&&t.error(d.InvalidActionAlternative,"A guarded action permits only one 'navigate to'",f(c)),s=i(t,c.content,c)??null;else{let u=R(c.content)==="label";t.error(u?d.UnknownActionDirective:d.InvalidActionAlternative,u?"A guarded action's header already supplies its label":`Unexpected '${c.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,f(c)),t.skipBlock(c.indent)}}return r.length===0&&t.error(d.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)}}l(Do,"parseGuardedAction");function Mo(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(Kc,""),location:f(i)}):(t.error(d.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,f(i)),t.skipBlock(i.indent))}return n}l(Mo,"parseArguments");function Wi(t,e){if(e.kind==="LogicalConditionSyntax"){Wi(t,e.left),Wi(t,e.right);return}let n=e.right.kind==="LiteralExpressionSyntax"?e.right.value:void 0,i=Gc.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(d.UnsupportedActionConditionOperand,"Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string",e.location)}l(Wi,"validateCondition");var Ut=`(?:"(${Z})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,Zc=O("^screen\\s+([A-Za-z_]\\w*)$"),_c=O("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Jc=O("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Hc=O(`^label\\s+${Ut}$`),Xc=O(`^action\\s+${Ut}$`),ed=O("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),td=O("^[a-z_]\\w*$"),nd=O(`^title\\s+${Ut}$`),id=O(`^column\\s+([\\w.]+)(?:\\s+label\\s+${Ut})?$`),rd=O("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),od=O(`^field\\s+([\\w.]+)\\s+label\\s+${Ut}$`),Wt=l((t,e)=>t[e]!==void 0?H(t[e]):t[e+1],"operandText"),ad=l(t=>["on","uses"].includes(R(t.content)),"isInteraction"),sd=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function No(t,e){let n=Zc.exec(e.content);n===null&&t.error(d.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),le(r)||jo(t,r,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,location:f(e)}}l(No,"parseScreen");function jo(t,e,n){let i=ld(t,e);i!==void 0&&n.push(i)}l(jo,"pushDirective");function Lo(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),jo(t,i,n);return n}l(Lo,"parseDirectives");function ld(t,e){switch(R(e.content)){case"data":return cd(t,e);case"action":return dd(t,e);case"template":return pd(t,e);case"section":return fd(t,e);case"title":return ud(t,e);case"table":return md(t,e);case"summary":return yd(t,e);case"navigate":return On(t,e.content,e);case"on":return Ce(t,e),{kind:"ScreenBehaviorSyntax",location:f(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:f(e)};default:if(sd(t,e))return hd(t,e);t.error(d.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,f(e)),t.skipBlock(e.indent);return}}l(ld,"parseDirective");function cd(t,e){let n=_c.exec(e.content);if(n===null){t.error(d.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,f(e));return}return{kind:"ScreenDataSyntax",type:xe(n[1],f(e)),query:n[2],by:n[3]??null,location:f(e)}}l(cd,"parseData");function dd(t,e){let n=Xc.exec(e.content);if(n!==null)return Do(t,e,Wt(n,1),On);let i=Jc.exec(e.content);if(i===null){t.error(d.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=Hc.exec(s.content);a!==null?r=Wt(a,1):R(s.content)==="navigate"?o=On(t,s.content,s)??null:t.error(d.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)}}l(dd,"parseAction");function On(t,e,n){let i=ed.exec(e);if(i===null){t.error(d.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,f(n));return}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,location:f(n)}}l(On,"parseNavigate");function pd(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(),!td.test(r.content)){t.error(d.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:Lo(t,r),location:f(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:f(e)}}l(pd,"parseTemplateReference");function fd(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:Lo(t,e),location:f(e)}}l(fd,"parseSection");function ud(t,e){let n=nd.exec(e.content);return n===null?(t.error(d.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,f(e)),{kind:"ScreenTitleSyntax",text:"",location:f(e)}):{kind:"ScreenTitleSyntax",text:Wt(n,1),location:f(e)}}l(ud,"parseTitle");function md(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=id.exec(o.content),a=rd.exec(o.content);if(s!==null){let c=s[2]!==void 0||s[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:s[1],label:c?Wt(s,2):null,location:f(o)})}else a!==null?r=On(t,a[1],o)??null:R(o.content)==="on"?Ce(t,o):ad(o)?t.skipOpaqueBlock(o.indent):t.error(d.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)}}l(md,"parseTable");function yd(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=od.exec(r.content);if(o===null){t.error(d.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,f(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:Wt(o,2),location:f(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:f(e)}}l(yd,"parseSummary");function hd(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n)){t.error(d.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e));return}e.content.startsWith("```")||t.warning(d.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let i=ut(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:f(e)},location:f(e)}}l(hd,"parseCode");var Sd=O("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),gd=O("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),xd=O("^specification\\s+([A-Za-z_]\\w*)$"),vd="([A-Z]\\w*(?:\\.\\w+)*)",$d="(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?",xt=l((t,e="")=>V(`^${t}\\s+${vd}${e}${$d}$`.replaceAll("\\s",z)),"stepPattern"),kd=xt("given"),bd=xt("when\\s+append"),Ed=xt("when"),Cd=xt("then"),Pd=O("^then\\s+query\\b"),qo=O("^(?:given|then)\\s+readmodel\\b"),Ad=xt("given\\s+readmodel"),wd=xt("then\\s+readmodel","(?<exactly>\\s+exactly)?"),Bo=O("^then\\s+no\\b"),Od=O(`^then\\s+error\\s+"(${Z})"$`),Vi=O("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Id=V("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Td=O("^given\\s+clock\\b"),Rd=O("^given\\s+capture\\b"),Md=O("^when\\s+clock\\b"),Dd=O("^when\\s+trigger\\b"),Nd=O("^when\\s+capture\\b"),jd=O("^when\\s+query\\b"),Ld=O("^then\\s+result\\b"),qd=O("^then\\s+no\\s+result\\b"),Bd=V("^when\\s+redelivered\\b"),Fd=V("^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Yd=O("^then\\s+no\\s+events\\b"),Wd=O('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),Ud=O("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),zd=O("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),Vd=O("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Qd=O("^then\\s+result(\\s+exactly)?$"),Fo=V("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),Gd=V(`^(?:"${Z}"|'(?:[^'\\\\]|\\\\.)*')$`),Kd=V("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function Qi(t,e){let n=xd.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,f(e));let i={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 a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),le(a)||Zd(t,a,i))continue;let c=Bo.test(a.content)?"then":R(a.content);c==="given"?_d(t,a,i):c==="when"?ep(t,a,i,n):c==="then"?tp(t,a,i):(t.error(d.UnknownSpecificationDirective,`Unexpected '${R(a.content)}' in specification body`,f(a)),t.skipBlock(a.indent))}i.noEventsLine!==void 0&&(i.whenAppended!==null||i.thenEvents.length>0||i.thenEventsInAnyOrder||i.thenErrors.length>0||i.thenDenied!==null)&&t.error(d.InvalidNoEventsExpectation,"'then no events' cannot follow 'when append' or accompany event, event-order, error or denial expectations.",f(i.noEventsLine));let{whenDeclared:r,noEventsLine:o,...s}=i;return{kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,...s,location:f(e)}}l(Qi,"parseSpecification");function Zd(t,e,n){if(!Sd.test(e.content))return!1;let i=gd.exec(e.content);if(i===null||i[1]==="given operation"!=(i[3]!==void 0))t.error(d.InvalidOperationSpecification,"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.",f(e)),pe(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,Vi,d.InvalidOperationSpecification);s!==null&&r.push(s)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:f(e)})}else Ft(t,e,d.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}l(Zd,"parseOperationStep");function _d(t,e,n){if(Td.test(e.content))n.givenClock!==null?(t.error(d.InvalidSpecificationClock,"A specification states its clock at most once.",f(e)),pe(t,e.indent)):n.givenClock=Yo(t,e,"given");else if(Rd.test(e.content)){let i=Wo(t,e,"given");i!==null&&n.givenCaptures.push(i)}else if(e.content.startsWith("given caller"))n.givenCaller!==null?(t.error(d.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'given caller' block.",f(e)),t.skipBlock(e.indent)):n.givenCaller=Xd(t,e);else if(qo.test(e.content)){let i=Uo(t,e,Ad,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=Gi(t,e,kd,"given");i!==void 0&&n.given.push(i)}}l(_d,"parseGiven");var Jd=O(`^role${z}+"(${Z})"$`),Hd=O(`^claim${z}+"(${Z})"${z}*=${z}*"(${Z})"$`);function Xd(t,e){if(e.content!=="given caller")return t.error(d.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(H(s[1])):a!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:H(a[1]),value:H(a[2]),location:f(o)}):t.error(d.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)}}l(Xd,"parseCaller");function ep(t,e,n,i){let r=e.content.startsWith("when append");if(n.whenDeclared){let c=n.whenAppended!==null||r?d.ConflictingSpecificationActions:d.DuplicateSpecificationWhen;t.error(c,`Specification '${i}' already declares a 'when' - a specification can have at most one`,f(e)),pe(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=Gi(t,e,bd,"when append")??null;return}if(Bd.test(e.content)){let c=Fd.exec(e.content);c===null?(t.error(d.UnmatchedRedeliveredOccurrence,"Expected 'when redelivered <Event> to <Reaction>'.",f(e)),pe(t,e.indent)):n.whenRedelivered={kind:"SpecificationRedeliverySyntax",eventType:c[1],reaction:c[2],...zi(t,e),location:f(e)};return}if(Md.test(e.content)){n.whenClock=Yo(t,e,"when");return}if(Dd.test(e.content)){n.whenTrigger=Ui(t,e,Ud,d.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(c,p)=>({kind:"SpecificationTriggerSyntax",trigger:c,values:p,location:f(e)}));return}if(Nd.test(e.content)){n.whenCapture=Wo(t,e,"when");return}if(jd.test(e.content)){n.whenQuery=Ui(t,e,Vd,d.InvalidSpecificationQueryAction,"when query","when query <Query>",(c,p)=>({kind:"SpecificationWhenQuerySyntax",query:c,arguments:p,location:f(e)}));return}let o=Ed.exec(e.content);if(o===null){t.error(d.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,f(e)),pe(t,e.indent);return}let s=[],a=zi(t,e,s,o);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...a,generatedValues:s,inlineProperty:o.groups?.property??null,location:f(e)}}l(ep,"parseWhen");function tp(t,e,n){if(Yd.test(e.content)){e.content!=="then no events"||n.thenNoEvents?t.error(d.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(d.InvalidNoEventsExpectation,"'then no events' cannot have child mappings.",f(o)),pe(t,e.indent);return}if(Pi.test(e.content)){let o=Gr(t,e);n.thenReturns!==null?t.error(d.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(d.InvalidSpecificationEventOrder,"Expected one 'then events in any order' directive.",f(e)):n.thenEventsInAnyOrder=!0,pe(t,e.indent);return}if(Ld.test(e.content)){ip(t,e,n);return}if(qd.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(d.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",f(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:f(e)},pe(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(d.InvalidSpecificationDenied,"Expected exactly 'then denied'.",f(e)),pe(t,e.indent)):n.thenDenied!==null?t.error(d.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}let i=Od.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:H(i[1]),location:f(e)});return}if(R(e.content.substring(4).trim())==="error"){t.error(d.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,f(e)),pe(t,e.indent);return}if(Bo.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let s=np(t,e);s!==null&&n.thenAbsentReadModels.push(s);return}let o=Fo.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let s=te(o[2].trim(),f(e),t.valueContext);(s.kind==="LiteralExpressionSyntax"||s.kind==="ObjectExpressionSyntax")&&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=l((u,y,h)=>{if(!o)return t.skipOpaqueBlock(h.indent);t.error(u,y,f(h)),t.skipBlock(h.indent)},"reject"),a=Kd.exec(e.content);if(a===null)return s(d.InvalidSpecificationQuery,`Invalid 'then query' declaration '${e.content}' - expected 'then query <Query> [exactly]'`,e);let c=[],p=[],m=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent))t.reader.takeSignificant(),u.content==="arguments"&&!m?c.push(...zt(t.valueContext,u,!0)):u.content==="arguments"?s(d.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,u):u.content==="result"?p.push({kind:"SpecificationQueryResultSyntax",properties:zt(t.valueContext,u,!0),exactly:!1,location:f(u)}):s(d.UnknownSpecificationQueryDirective,`Unexpected '${R(u.content)}' in 'then query' body - expected arguments or result`,u),m||=u.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:a[1],arguments:c,results:p,exactly:a[2]!==void 0,location:f(e)});return}if(qo.test(e.content)){let o=Uo(t,e,wd,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=Gi(t,e,Cd,"then");r!==void 0&&n.thenEvents.push(r)}l(tp,"parseThen");function np(t,e){let n=Fo.exec(e.content);if(n===null||n[2].endsWith(" exactly"))return t.error(d.InvalidAbsentReadModelStep,`Invalid absence assertion '${e.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,f(e)),pe(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||Gd.test(i)?te(i,f(e),t.valueContext):null,s=o!==null&&(o.kind==="LiteralExpressionSyntax"||o.kind==="ObjectExpressionSyntax");s||t.error(d.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,f(e));let a=!1;for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(d.InvalidAbsentReadModelStep,"An absent read model assertion cannot have child mappings.",f(c)),a=!0;return a||!s?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:f(e)}}l(np,"parseAbsentReadModel");function pe(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}l(pe,"skipBody");function Yo(t,e,n){let i=Wd.exec(e.content);return pe(t,e.indent),i===null||i[1]!==n?(t.error(d.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)}}l(Yo,"parseClock");function Wo(t,e,n){return Ui(t,e,zd,d.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:f(e)}))}l(Wo,"parseCapture");function Ui(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)),pe(t,e.indent),null):s(a[1],zt(t,e))}l(Ui,"parseNamedStep");function ip(t,e,n){let i=Qd.exec(e.content);if(i===null){t.error(d.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,f(e)),pe(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:zt(t,e),exactly:i[1]!==void 0,location:f(e)})}l(ip,"parseResult");function Uo(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(d.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${e.content}' - expected '${i} readmodel <ReadModelType>'`,f(e)),pe(t,e.indent);return}return{kind:"SpecificationReadModelSyntax",name:r[1],properties:zt(t,e,!1,r),exactly:i==="then"&&r.groups?.exactly!==void 0,inlineProperty:r.groups?.property??null,location:f(e)}}l(Uo,"parseReadModelStep");function Gi(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(d.InvalidEventStep,`Invalid '${i}' declaration '${e.content}' - expected '${i} <EventType>'`,f(e)),pe(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...zi(t,e,void 0,r,i),inlineProperty:r.groups?.property??null,location:f(e)}}l(Gi,"parseEventStep");var rp=de("^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$"),op=O("^streamId\\s*=(?!=|>)\\s*(.+)$");function zi(t,e,n,i,r){let o=[];hn(t,e,i,o);let s=null,a,c,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&un.test(m.content)){let y=yt(t,m,mn,d.InvalidGeneratedFixture);y!==null&&n.push(y);continue}let u=Vi.exec(m.content);if(u!==null)Dt(t,o,Vo(t,m,u));else if(R(m.content)==="stream"||m.content.startsWith("no stream")){if(r===void 0){t.error(d.SpecificationStreamOnCommand,"A command occurrence cannot declare a route; assert it on a then event.",f(m)),t.skipBlock(m.indent);continue}if(p){t.error(d.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(m)),t.skipBlock(m.indent);continue}let y=rp.exec(m.content);m.content==="no stream"&&r==="then"?(c={kind:"SpecificationNoStreamSyntax",location:f(m)},p=!0,zo(t,m)):y!==null?(a=ap(t,m,y),p=!0):(t.error(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",f(m)),t.skipBlock(m.indent))}else if(R(m.content)==="for"){let y=m.content.substring(3).trim();y.length===0?t.error(d.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(m)):s!==null?t.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(m)):s=te(y,f(m),t)}else t.error(d.InvalidSpecificationValue,`Invalid property mapping '${m.content}' - expected '<property> = <value>'`,f(m))}return{values:o,for:s,...a===void 0?{}:{stream:a},...c===void 0?{}:{noStream:c}}}l(zi,"parseValuesWithEventSource");function ap(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(d.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=Ti(t,a,d.InvalidSpecificationStream));continue}let c=op.exec(a.content);if(c===null||i!==null||o){t.error(d.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent);continue}let p={...f(a),column:a.indent+1+a.content.indexOf(c[1],a.content.indexOf("=")+1)};i={kind:"PropertyMappingSyntax",property:"streamId",source:te(c[1],p,t),location:f(a)},zo(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)}}l(ap,"parseSpecificationStream");function zo(t,e){let n=t.peekChild(e.indent);n!==void 0&&(t.error(d.InvalidSpecificationStream,"This directive cannot have children.",f(n)),t.skipBlock(e.indent))}l(zo,"rejectSpecificationRouteChildren");function zt(t,e,n=!1,i){let r=[];hn(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"?Id:Vi).exec(o.content);if(s===null){t.error(d.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,f(o));continue}Dt(t,r,Vo(t,o,s,n))}return r}l(zt,"parseValues");function Vo(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:te(n[2],f(e),t,i),location:f(e)}}l(Vo,"mappingOf");var sp=O("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),lp=new Set(["reducer"]);function Qo(t,e){let n=sp.exec(e.content),i="StateChange",r="";n===null?t.error(d.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,f(e)):(r=n[2],Kr.includes(n[1])?i=n[1]:t.error(d.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=[],c=[],p=[],m=[],u=[],y=[],h=[],$=[],v=[],k=[],E=[],b=[],P=[];for(let S=t.peekChild(e.indent);S!==void 0;S=t.peekChild(e.indent)){if(t.reader.takeSignificant(),le(S))continue;let g=R(S.content);g==="description"?s=_(t,S,s,`Slice '${r}'`):g==="operation"?c.push(Pn(t,S).operation):g==="event"?a.push(Xr(t,S)):g==="command"?p.push(bo(t,S)):g==="query"?m.push(Io(t,S)):g==="projection"?u.push(qi(t,S)):g==="capture"?h.push(wi(t,S)):g==="reaction"?y.push(Ro(t,S)):g==="constraint"?$.push(Eo(t,S)):g==="example"?k.push(qe(t,S)):g==="specification"?v.push(Qi(t,S)):g==="readmodel"?E.push(eo(t,S)):g==="screen"?b.push(No(t,S)):lp.has(g)?(P.push(So(t,S)),t.skipOpaqueBlock(S.indent)):(t.warning(d.UnknownSliceDirective,`Unknown construct '${g}' in slice '${r}'`,f(S)),t.skipBlock(S.indent))}t.scope=o;let A={kind:"SliceSyntax",type:i,name:r,description:s,examples:k,events:a,operations:c,commands:p,queries:m,projections:u,captures:h,reactions:y,constraints:$,specifications:v,readModels:E,screens:b,location:f(e)};return Fe.set(A,{reducers:P}),A}l(Qo,"parseSlice");var cp=O("^feature\\s+([A-Za-z_]\\w*)$"),dp=new Set(["on","uses","contribute"]),Ki="description, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'",Vt=class{static{l(this,"FeatureBody")}name;#e=[];#t=[];#o=[];#r=[];#n=[];#i=null;#s=null;constructor(e){this.name=e}tryParse(e,n){let i=R(n.content);switch(i){case"description":return this.#i=_(e,n,this.#i,`Feature '${this.name}'`),!0;case"depends":return pn(e,n,this.#n,d.UnknownFeatureDirective),!0;case"authorize":return this.#s=Te(this.#s,Ke(e,n)),!0;case"import":return mt(e,n,this.#r),!0;case"feature":return this.#e.push(In(e,n)),!0;case"example":return this.#o.push(qe(e,n)),!0;case"slice":return this.#t.push(Qo(e,n)),!0;default:return dp.has(i)?(Ce(e,n),!0):!1}}build(e,n=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#i,authorize:this.#s,dependsOn:this.#n,features:this.#e,slices:this.#t,examples:this.#o,fileImports:this.#r,isPlacement:n,location:e}}};function In(t,e){let n=cp.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,f(e));let i=new Vt(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(d.UnknownFeatureDirective,`Unexpected '${R(o.content)}' in feature body - expected ${Ki}`,f(o)),t.skipBlock(o.indent));return t.scope=r,i.build(f(e))}l(In,"parseFeature");var Zi=O("^module\\s+([A-Za-z_]\\w*)$"),pp=new Set(["on","uses","screen","dialog","form","contribute"]),_i="description, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'",Qt=class{static{l(this,"ModuleBody")}name;#e=[];#t=[];#o=[];#r=[];#n=null;#i=null;constructor(e){this.name=e}tryParse(e,n){let i=R(n.content);switch(i){case"description":return this.#n=_(e,n,this.#n,`Module '${this.name}'`),!0;case"depends":return pn(e,n,this.#r,d.UnknownModuleDirective),!0;case"authorize":return this.#i=Te(this.#i,Ke(e,n)),!0;case"import":return mt(e,n,this.#o),!0;case"example":return this.#t.push(qe(e,n)),!0;case"feature":return this.#e.push(In(e,n)),!0;default:return pp.has(i)?(Ce(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(d.UnknownModuleDirective,`Unexpected '${R(i.content)}' in module body - expected ${_i}`,f(i)),e.skipBlock(i.indent))}build(e,n=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#n,authorize:this.#i,dependsOn:this.#r,features:this.#e,examples:this.#t,fileImports:this.#o,isPlacement:n,location:e}}};function Ji(t,e){let n=Zi.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,f(e));let i=new Qt(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(f(e))}l(Ji,"parseModule");var mp=new WeakMap,we=l(t=>JSON.stringify(t),"authoredOrderKey");function Gt(t){return mp.get(t)??new Map}l(Gt,"authoredOrderOf");function Zo(t){let e=[],n=l((a,c)=>{for(let p of a??[])e.push({name:p.name,scope:c,example:p})},"examples"),i=l((a,c)=>{for(let p of a){let m=[...c,p.name];n(p.examples,m);for(let u of p.slices){let y=[...c,p.name,u.name];n(u.examples,y);for(let h of new Set(se(u).map($=>$.name)))e.push({name:h,scope:y,kind:"event"});for(let h of u.commands)e.push({name:h.name,scope:y,kind:"command"});for(let h of u.readModels)e.push({name:h.name,scope:y,kind:"readmodel"})}i(p.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=l((a,c)=>{let p=l(y=>{let h=y.split("."),$=e.filter(k=>k.name===h.at(-1)),v=h.slice(0,-1);if(v.length)return $.filter(k=>v.length<=k.scope.length&&v.every((E,b)=>k.scope[k.scope.length-v.length+b]===E));for(let k=c.length;k>=0;k--){let E=$.filter(b=>k<=b.scope.length&&c.slice(0,k).every((P,A)=>b.scope[A]===P));if(E.length)return E}return[]},"candidates"),m=p(a),u=t.imports.filter(y=>y.qualifiedName.split(".").at(-1)===a);return!m.length&&u.length===1&&(m=p(u[0].qualifiedName)),m.length===1?m[0]:void 0},"resolve"),o=l((a,c,p)=>{let m=r(a,p),u=m?.example;if(!u)return null;let y=r(u.type,m.scope);return y?.kind===c?{example:u,name:[...y.scope,y.name].join(".")}:null},"fixture"),s=l((a,c)=>[...a.filter(p=>!c.some(m=>m.property===p.property)),...c],"merge");return{command:l((a,c)=>{if(!a)return a;let p=o(a.commandType,"command",c);if(!p)return a;let{example:m,name:u}=p;return{...a,commandType:u,values:s(m.values,a.values),generatedValues:s(m.generatedValues,a.generatedValues??[]),for:a.for??m.for}},"command"),event:l((a,c)=>{let p=o(a.eventType,"event",c);return p?{...a,eventType:p.name,values:s(p.example.values,a.values),for:a.for??p.example.for}:a},"event"),readModel:l((a,c)=>{let p=o(a.name,"readmodel",c);return p?{...a,name:p.name,properties:s(p.example.values,a.properties)}:a},"readModel")}}l(Zo,"specificationExamples");function Tn(t){return Zo(t).command}l(Tn,"specificationCommandExamples");function We(t){let e=Zo(t),n=l((i,r)=>i.map(o=>{let s=[...r,o.name];return{...o,features:n(o.features,s),slices:o.slices.map(a=>{let c=[...r,o.name,a.name],p={...a,specifications:a.specifications.map(m=>({...m,given:m.given.map(u=>e.event(u,c)),givenReadModels:m.givenReadModels.map(u=>e.readModel(u,c)),when:e.command(m.when,c),whenAppended:m.whenAppended===null?null:e.event(m.whenAppended,c),thenEvents:m.thenEvents.map(u=>e.event(u,c)),thenReadModels:m.thenReadModels.map(u=>e.readModel(u,c))}))};return Fe.set(p,Ae(a)),p})}}),"features");return{...t,modules:t.modules.map(i=>({...i,features:n(i.features,[i.name])}))}}l(We,"expandSpecificationExamples");var Je=["usesFactsFrom","reactsTo","decidesFrom","asks","shows","verifiedWith","outsideTheModel"];var Ue=class extends Error{static{l(this,"InvalidDependencyQuery")}};var He=class{static{l(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.seeds?.forEach(n=>this.visitSeed(n)),e.modules.forEach(n=>this.visitModule(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n))}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.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.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.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.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.where!=null&&this.visitCondition(e.where),e.triggers.forEach(n=>this.visitReactionTrigger(n))}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))}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"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"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.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.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))}visitSpecificationRedelivery(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}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.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)}visitExpression(e){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 yp={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 Mn(t){let e=new Rn;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}}l(Mn,"sliceReferences");function _o(t,e){let n=new Rn(e);return t.projections.forEach(i=>n.visitProjection(i)),Ae(t).reducers?.filter(i=>i.readModel.toLowerCase()===e.toLowerCase()).forEach(i=>n.visitReducer(i)),n.references}l(_o,"buildingReadModelReferences");function er(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...er(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?er(e.blocks):[])}l(er,"variants");var Rn=class extends He{static{l(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),Ae(e).reducers?.forEach(i=>this.visitReducer(i))}visitCommand(e){let n=Ae(e);n.reads?.forEach(i=>this.visitReads(i)),n.concurrency!=null&&this.visitConcurrency(n.concurrency),super.visitCommand(e)}visitReactionTrigger(e){let n=Ae(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=er(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=l((i,r,o)=>{this.references.push({name:i,targetKind:r,role:o,kind:yp[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 Kt(t){let e=new Map,n=new Map,i=[],r=new Set,o=[],s=l(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 c=[],p;do p=i.pop(),r.delete(p),c.push(p);while(p!==a);o.push(c.sort())},"visit");for(let a of[...t.keys()].sort())e.has(a)||s(a);return o}l(Kt,"stronglyConnectedGroups");var Jo=["usesFactsFrom","reactsTo","decidesFrom"],Me=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),tr=l((t,e)=>JSON.stringify([t,e.toLowerCase()]),"declarationKey"),nr=l((t,e,n,i)=>({kind:t,address:e,scope:n,rank:i,key:`${t}:${e}`}),"nodeOf"),rr=l((t,e)=>t.rank-e.rank||Me(t.key,e.key),"compareNodes"),Zt=l(t=>[...new Map([...t].map(e=>[e.key,e])).values()].sort(rr),"distinctNodes"),Ho=l((t,e)=>t.consumer.rank-e.consumer.rank||t.location.line-e.location.line||t.location.column-e.location.column||Je.indexOf(t.kind)-Je.indexOf(e.kind)||t.producer.rank-e.producer.rank||Me(t.location.path??"",e.location.path??"")||Me(t.role,e.role)||Me(t.name,e.name),"compareEvidence");function or(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...or(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?or(e.blocks):[])}l(or,"variants");var vt=class t{static{l(this,"DependencyGraph")}orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=new Map;byKey=new Map;parents=new Map;root=nr("application","",[],-1);static for(e,n=Gt(e)){return new t(e,n)}get nodes(){return this.modelNodes}constructor(e,n){e=We(e),this.orderSource=n.size>0?"authored":"syntax",this.children.set(this.root.key,[]);let i=l((b,P)=>b.map((A,S)=>({syntax:A,index:S,rank:n.get(we([...P.scope,A.name]))??Number.MAX_SAFE_INTEGER})).sort((A,S)=>A.rank-S.rank||A.index-S.index).map(A=>A.syntax),"ordered"),r=l((b,P)=>{let A=this.add("feature",b.name,P);for(let S of i(b.slices,A))this.slices.push({node:this.add("slice",S.name,A),syntax:S});for(let S of i(b.features,A))r(S,A)},"feature");for(let b of i(e.modules,this.root)){let P=this.add("module",b.name,this.root);for(let A of i(b.features,P))r(A,P)}let o=new Map,s=new Map,a=l((b,P,A,S)=>{let g=tr(P,A);b.has(g)||b.set(g,[]);let x=b.get(g);x.includes(S)||x.push(S);let C=tr(P,[...S.scope,A].join("."));b.has(C)||b.set(C,[]);let I=b.get(C);I.includes(S)||I.push(S)},"declare");for(let{node:b,syntax:P}of this.slices){for(let A of se(P))a(o,"Event",A.name,b);for(let A of P.commands)a(o,"Command",A.name,b);for(let A of P.reactions)a(o,"Reaction",A.name,b);for(let A of P.queries)a(o,"Query",A.name,b);for(let A of P.screens)a(o,"Screen",A.name,b);for(let A of P.readModels)a(o,"ReadModel",A.name,b);for(let A of P.projections){let S=or(A.blocks);S.length===0&&a(s,"ReadModel",A.readModel??A.name,b);for(let g of S)a(s,"ReadModel",g.name,b)}for(let A of Ae(P).reducers??[])a(s,"ReadModel",A.readModel,b)}let c=new Set((e.declaredTriggers??[]).map(b=>b.name.toLowerCase())),p=new Set([...e.concepts,...e.types].map(b=>b.name.toLowerCase())),m=new Set((e.policies??[]).map(b=>b.name.toLowerCase())),u=e.imports.filter(b=>b.qualifiedName.includes(".")).slice().sort((b,P)=>Me(b.location.path??"",P.location.path??"")||b.location.line-P.location.line||b.location.column-P.location.column||Me(b.qualifiedName,P.qualifiedName)),y=new Map,h=[],$=[],v=new Set,k=0;for(let{node:b,syntax:P}of this.slices){let A=Mn(P);k+=A.shared.filter(S=>(S.kind==="type"?p:m).has(S.name.toLowerCase())).length;for(let S of A.references){let g=tr(S.targetKind,S.name),C=(S.targetKind==="ReadModel"&&s.has(g)?s:o).get(g);if(C!==void 0&&C.length>0){let w=C[0];w!==b&&h.push({consumer:b,producer:w,kind:S.kind,role:S.role,name:S.name,ambiguous:C.length>1,alternatives:C.slice(1),location:S.location,testOnly:S.kind==="verifiedWith"});continue}let I=S.targetKind==="Event"?u.filter(w=>w.qualifiedName.slice(w.qualifiedName.lastIndexOf(".")+1).toLowerCase()===S.name.toLowerCase()):[];if(I.length>0){let w=[];for(let j of I){v.add(j.qualifiedName);let N=j.qualifiedName.slice(0,j.qualifiedName.lastIndexOf(".")),L=`context:${N}`;if(!y.has(L)){let D=nr("context",L,[N],this.modelNodes.length);this.modelNodes.push(D),y.set(L,D)}let q=y.get(L);w.includes(q)||w.push(q)}h.push({consumer:b,producer:w[0],kind:"outsideTheModel",role:S.role,name:S.name,ambiguous:w.length>1,alternatives:w.slice(1),location:S.location,testOnly:S.kind==="verifiedWith"});continue}if(S.role==="trigger"&&c.has(S.name.toLowerCase())){k++;continue}$.push({consumer:b,kind:S.kind,role:S.role,name:S.name,location:S.location})}}let E=new Map;for(let b of h.sort(Ho)){let P=JSON.stringify([b.consumer.key,b.producer.key,b.kind]);E.has(P)||E.set(P,[]),E.get(P).push(b)}this.edges=[...E.values()].map(b=>({consumer:b[0].consumer,producer:b[0].producer,kind:b[0].kind,evidence:b})),this.unresolved=$.sort((b,P)=>b.consumer.rank-P.consumer.rank||b.location.line-P.location.line||b.location.column-P.location.column||Je.indexOf(b.kind)-Je.indexOf(P.kind)||Me(b.location.path??"",P.location.path??"")||Me(b.name,P.name)),this.excludedReferences=k,this.unusedImports=[...new Set(u.filter(b=>!v.has(b.qualifiedName)).map(b=>b.qualifiedName))]}implied(e,n,i,r=!1,o=3){if(!["slice","feature","module"].includes(e))throw new Ue(`Unsupported source level '${e}'.`);if(!["slice","feature","module","context"].includes(n))throw new Ue(`Unsupported target level '${n}'.`);if(o<0)throw new Ue("Evidence limit must not be negative.");let s=new Map;for(let a of this.evidence(i,r))for(let c of this.at(a.consumer,e))for(let p of this.at(a.producer,n).filter(m=>this.disjoint(c,m))){let m=JSON.stringify([c.key,p.key]);s.has(m)||s.set(m,{source:c,target:p,evidence:[]}),s.get(m).evidence.push(a)}return[...s.values()].sort((a,c)=>a.source.rank-c.source.rank||a.target.rank-c.target.rank||Me(a.source.key,c.source.key)||Me(a.target.key,c.target.key)).map(a=>{let c=a.evidence.sort(Ho),p={};for(let m of Je){let u=c.filter(y=>y.kind===m).length;u>0&&(p[m]=u)}return{source:a.source,target:a.target,sliceEdges:new Set(c.map(m=>JSON.stringify([m.consumer.key,m.producer.key]))).size,references:c.length,byKind:p,consumers:Zt(c.map(m=>m.consumer)),producers:Zt(c.map(m=>m.producer)),evidence:c.slice(0,o),evidenceCount:c.length,evidenceTruncated:c.length>o}})}cycles(e,n){if(!["slice","feature","module"].includes(e))throw new Ue(`Unsupported cycle level '${e}'.`);let i=this.implied(e,e,Xo(n)),r=Zt(i.flatMap(o=>[o.source,o.target]));return ea(ir(r,i),r,null)}siblingGroups(e){let n=this.siblingEdges(e);return this.containers().flatMap(i=>{let r=this.children.get(i.key);return ea(ir(r,n.filter(o=>o.container===i)),r,i)})}suggestedOrder(e){let n=this.siblingEdges(e),i=[];for(let a of this.containers()){let c=this.children.get(a.key),p=n.filter(k=>k.container===a),m=new Map(c.map(k=>[k.key,k])),u=Kt(ir(c,p)).map(k=>k.map(E=>m.get(E)).sort(rr)).sort((k,E)=>k[0].rank-E[0].rank),y=new Map(u.flatMap((k,E)=>k.map(b=>[b.key,E]))),h=new Map(c.map(k=>[k.key,new Set]));for(let k of p)y.get(k.source.key)!==y.get(k.target.key)&&h.get(k.source.key).add(k.target.key);for(let k of u)for(let E=1;E<k.length;E++)h.get(k[E].key).add(k[E-1].key);let $=new Set(c.map(k=>k.key)),v=[];for(;$.size>0;){let k=[...$].filter(E=>h.get(E).size===0).sort((E,b)=>rr(m.get(E),m.get(b)))[0];v.push(m.get(k)),$.delete(k);for(let E of $)h.get(E).delete(k)}i.push({container:a,children:v,changed:c.some((k,E)=>k!==v[E])})}let r=new Map(i.map(a=>[a.container.key,a.children])),o=[],s=l(a=>{if(a.kind==="slice")o.push(a);else for(let c of[...r.get(a.key)].sort((p,m)=>+(p.kind!=="slice")-+(m.kind!=="slice")))s(c)},"walk");return s(this.root),{containers:i,slices:o}}traverse(e,n,i,r=!1){if(n!=="incoming"&&n!=="outgoing")throw new Ue(`Unsupported dependency direction '${n}'.`);let o=this.evidence(i,r).map(p=>n==="incoming"?{source:p.producer,target:p.consumer}:{source:p.consumer,target:p.producer}),s=new Set([e]),a=[e],c=[];for(let p=0;p<a.length;p++)for(let m of o.filter(u=>u.source.address===a[p]).sort((u,y)=>u.target.rank-y.target.rank))s.has(m.target.address)||(s.add(m.target.address),c.push(m.target),a.push(m.target.address));return Zt(c)}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 c=nr(e,o,r,this.modelNodes.length);return this.modelNodes.push(c),this.byKey.set(s,c),this.parents.set(s,i),this.children.get(i.key).push(c),e!=="slice"&&this.children.set(s,[]),c}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=ta(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(Xo(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 ta(t){let e=new Set(t??Je);if([...e].some(n=>!Je.includes(n)))throw new Ue("Unsupported dependency kind.");return e}l(ta,"selectedKinds");function Xo(t){return[...ta(t??Jo)].filter(e=>Jo.includes(e))}l(Xo,"selectedOrderingKinds");function ir(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}l(ir,"adjacency");function ea(t,e,n){let i=new Map(e.map(r=>[r.key,r]));return Kt(t).filter(r=>r.length>1).map(r=>({container:n,members:Zt(r.map(o=>i.get(o)))})).sort((r,o)=>r.members[0].rank-o.members[0].rank)}l(ea,"groupsOf");var hp=["usesFactsFrom","reactsTo","decidesFrom","asks","shows"],De=l((t,e)=>e===t||e.startsWith(t+"."),"contains"),$t=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),Sp=l((t,e)=>$t(t.location.path??"",e.location.path??"")||t.location.line-e.location.line||t.location.column-e.location.column||$t(t.kind,e.kind)||$t(t.consumer.address,e.consumer.address)||$t(t.producer.address,e.producer.address)||$t(t.role,e.role)||$t(t.name,e.name),"orderedEvidence"),kt=class{static{l(this,"DeclaredDependencies")}static for(e){let n=new Map,i=l((u,y)=>{let h=u.join(".");n.has(h)||n.set(h,{location:y.location,dependencies:[]}),n.get(h).dependencies.push(...y.dependsOn??[]),y.features.forEach($=>i([...u,$.name],$))},"inventory");if(e.modules.forEach(u=>i([u.name],u)),![...n.values()].some(u=>u.dependencies.length))return{containers:[],diagnostics:[]};let r=vt.for(e,new Map),o=r.nodes.filter(u=>u.kind==="module"||u.kind==="feature"),s=ye.containersOf(e),a=l((u,y)=>{let h=ye.resolve(u,y,s).resolved;return h&&[...h.scope,h.name].join(".")},"resolve"),c=[],p=[],m=l((u,y,h,$)=>p.push({code:u,severity:y,message:h,location:$}),"finding");for(let u of o.filter(y=>n.get(y.address).dependencies.length)){let y=n.get(u.address),h=y.dependencies.map(k=>{let E=a(k.target,u.scope),b=E!==void 0&&!De(u.address,E)&&!De(E,u.address);return{syntax:k,resolved:E,status:b?"unused":"invalid"}}),$=[],v=new Map;for(let k of r.edges.flatMap(E=>E.evidence).filter(E=>hp.includes(E.kind)&&De(u.address,E.consumer.address)).sort(Sp)){let E=[k.producer,...k.alternatives].filter(A=>!De(u.address,A.address)&&!De(A.scope.slice(0,-1).join("."),u.address));if(!E.length)continue;let b=h.filter(A=>A.status!=="invalid"&&E.some(S=>De(A.resolved,S.address)));for(let A of b)A.status=k.ambiguous&&A.status!=="used"?"provisional":"used";let P=k.ambiguous?"provisional":b.length?"declared":"undeclared";if($.push({evidence:k,status:P,coveringDeclarations:b.map(A=>A.syntax)}),P==="undeclared"){let A=k.producer.scope[0];v.has(A)||v.set(A,[]),v.get(A).push(k)}}for(let k of v.values()){let E=k[0].producer.scope.slice(0,-1),b=E.findIndex((g,x)=>k.some(C=>x>=C.producer.scope.length-1||C.producer.scope[x]!==g));b>=0&&(E=E.slice(0,b));let P=E.join("."),A=De(u.address,P)||De(P,u.address)?[...new Set(k.map(g=>g.producer.scope.slice(0,-1).map((x,C)=>g.producer.scope.slice(0,C+1).join(".")).find(x=>!De(u.address,x)&&!De(x,u.address))))]:[P],S=k.map(g=>`${g.kind} ${g.role} '${g.name}' at ${g.location.path??""}:${g.location.line}:${g.location.column}`).join("; ");m(d.UndeclaredDependency,"warning",`Container '${u.address}' depends on '${A.join("', '")}' without declaring ${A.length===1?"it":"them"} - evidence: ${S}`,y.location)}for(let k of h)k.status==="unused"&&m(d.UnusedDependencyDeclaration,"information",`Dependency '${k.syntax.target}' on '${u.address}' is not used by any counted explicit reference`,k.syntax.location),k.status!=="invalid"&&n.get(k.resolved).dependencies.some(E=>a(E.target,k.resolved.split("."))===u.address)&&m(d.MutualDependencyDeclarations,"information",`Containers '${u.address}' and '${k.resolved}' declare each other`,k.syntax.location);c.push({container:u,location:y.location,declarations:h,edges:$})}return{containers:c,diagnostics:p}}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 ar=class extends Error{static{l(this,"InvalidExactNumber")}};function _t(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||Le(t.value)?.value!==t.value)throw new ar("Expected a canonical, bounded ExactNumber value.");return t.value}l(_t,"canonicalExactText");function na(t){return!_t(t).includes(".")}l(na,"exactIsIntegral");var gp=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,xp=/^([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 sr(t,e){let n=(e?xp:gp).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 c=Number(n[7]),p=Number(n[8]);return c<=14&&p<=59&&(c!==14||p===0)}l(sr,"responseDateValue");var Dn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Nn(t,e,n=e.inputUses){let i=Tn(t),r=[],o=l((S,g)=>{let x=[...g,S.name];S.slices.forEach(C=>r.push({slice:C,scope:[...x,C.name]})),S.features.forEach(C=>o(C,x))},"collect");t.modules.forEach(S=>S.features.forEach(g=>o(g,[S.name])));let s=new Map,a=new Map,c=new Map;for(let{slice:S,scope:g}of r)for(let x of S.commands){let C=s.get(x.name)??[];C.push({command:x,scope:g}),s.set(x.name,C),a.set(x,ne(x.properties)),x.response?.kind==="RecordCommandResponseSyntax"&&c.set(x,ne(x.response.fields))}let p=new Map;for(let S of t.imports){let g=S.qualifiedName.split(".").at(-1);p.set(g,[...p.get(g)??[],S.qualifiedName])}let m=new Map,u=l((S,g)=>{let x=`${g.join(".")}|${S}`;if(m.has(x))return m.get(x);let C=p.get(S)??[],j=((s.get(S.split(".").at(-1))??[]).length===0&&C.length===1?C[0]:S).split("."),N=s.get(j.at(-1))??[];if(j.length>1){let q=j.slice(0,-1);N=N.filter(D=>q.length<=D.scope.length&&q.every((F,U)=>D.scope[D.scope.length-q.length+U]===F))}else for(let q=g.length;q>=0;q--){let D=N.filter(F=>q<=F.scope.length&&g.slice(0,q).every((U,Y)=>F.scope[Y]===U));if(D.length>0){N=D;break}}let L=N.length===1?N[0].command:null;return m.set(x,L),L},"resolve"),y=ne(t.concepts),h=new Set(t.concepts.map(S=>S.name)),$=new Map([...ne(t.types)].map(([S,g])=>[S,ne(g.properties)])),v=new Set(r.flatMap(S=>S.slice.readModels.map(g=>g.name))),k=new Set([...a.keys()].flatMap(S=>[...S.properties])),E=l(S=>{for(let g of S)g.isGenerated&&!k.has(g)&&e.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",g.location)},"checkDeclarations"),b=l(S=>{S.features.forEach(b);for(let g of S.slices){for(let x of g.commands)for(let C of x.produces)C.inlineEvent!==null&&E(C.inlineEvent.properties);g.events.forEach(x=>E(x.properties)),g.readModels.forEach(x=>E(x.properties));for(let x of g.reactions)for(let C of x.triggers)for(let I of C.produces)I.inlineEvent!==null&&E(I.inlineEvent.properties)}},"checkFeature");t.types.forEach(S=>E(S.properties)),t.modules.forEach(S=>S.features.forEach(b));let P=l((S,g,x)=>{let C=a.get(x).get(S.property);if(C===void 0){e.error(d.InvalidResponseSource,`Response source '${S.property}' must reference one direct command property.`,S.location);return}let I=C.type;(I.isCollection||v.has(I.name))&&e.error(d.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",S.location),g!==null&&(g.name!==I.name||g.isCollection!==I.isCollection||g.isOptional!==I.isOptional)&&e.error(d.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",g.location)},"validateSource");for(let S of a.keys()){for(let x of S.properties){if(!x.isGenerated)continue;let C=y.get(x.type.name);(x.type.isOptional||x.type.isCollection||(C===void 0?Dn.has(x.type.name)||$.has(x.type.name)||h.has(x.type.name)||v.has(x.type.name):C.type!=="Uuid"))&&e.error(d.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",x.location)}let g=S.response;if(g?.kind==="ScalarCommandResponseSyntax")P(g.source,null,S);else if(g?.kind==="RecordCommandResponseSyntax"){g.fields.length===0&&e.error(d.InvalidCommandResponse,"A response block requires at least one field.",g.location);let x=new Set;for(let C of g.fields)x.has(C.name)&&e.error(d.DuplicateResponseField,`Duplicate response field '${C.name}'.`,C.location),x.add(C.name),P(C.source,C.type,S)}}let A=l((S,g)=>{let x=i(S.when,g),C=x===null?null:u(x.commandType,g);if(x!==null&&C!==null){let N=a.get(C);for(let D of x.values)N.get(D.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${D.property}' cannot be supplied as request or form input.`,D.location);let L=[...N.values()].filter(D=>D.isIdentifier);if(x.for!==null&&L.length===1&&L[0].isGenerated){let D=L[0].type;(Dn.has(D.name)||y.has(D.name)||$.has(D.name))&&(D.isOptional||D.isCollection||y.get(D.name)?.type!=="Uuid"||x.for.kind!=="LiteralExpressionSyntax"||typeof x.for.value!="string"||!ia(x.for.value))&&e.error(d.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",x.for.location)}let q=new Set;for(let D of x.generatedValues??[]){let F=N.get(D.property);(q.has(D.property)||F===void 0||!F.isGenerated||F.isIdentifier||!Oe(D.source,F.type,y,$))&&e.error(d.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",D.location),q.add(D.property)}}let I=S.thenReturns;if(I==null||((x===null||S.thenErrors.length>0||S.thenDenied!=null)&&e.error(d.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",I.location),C===null))return;let w=C.response,j=a.get(C);if(I.kind==="ScalarSpecificationReturnSyntax"&&w?.kind==="ScalarCommandResponseSyntax"&&j.has(w.source.property))Oe(I.value,j.get(w.source.property).type,y,$)||e.error(d.InvalidReturnExpectation,"The expected return value must match the response source's type.",I.location);else if(I.kind==="RecordSpecificationReturnSyntax"&&w?.kind==="RecordCommandResponseSyntax"){I.fields.length===0&&e.error(d.InvalidReturnExpectation,"A record return expectation requires at least one field.",I.location);let N=c.get(C),L=new Set;for(let q of I.fields){let D=N.get(q.property),F=D===void 0?void 0:j.get(D.source.property);(L.has(q.property)||F===void 0||!Oe(q.source,F.type,y,$))&&e.error(d.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",q.location),L.add(q.property)}}else e.error(d.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",I.location)},"validateSpecification");for(let{slice:S,scope:g}of r)S.specifications.forEach(x=>A(x,g));for(let S of n){if(S.isParameter===!0)continue;let g=u(S.command,S.scope);g!==null&&a.get(g).get(S.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${S.property}' cannot be supplied as request or form input.`,S.location)}}l(Nn,"validateResponses");function ne(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}l(ne,"uniqueByName");function Oe(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=>Oe(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 c=r.get(a.name);return c!==void 0&&Oe(a.value,c.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"&&ia(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&&na(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"&&sr(t.value,!1);case"DateTime":return typeof t.value=="string"&&sr(t.value,!0);default:return!Dn.has(s)}return!Dn.has(s)&&o===void 0}l(Oe,"compatibleValue");var vp=/^(?:[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 ia(t){return vp.test(t)}l(ia,"uuidValue");var st=class t{static{l(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every(ki)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&ki(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}};function jn(t,e,n,i=!1){let r=[],o=[],s=$e,a=!1,c=!1,p=!1,m=new Map,u=new he(new st([]),e,n).languages;for(let h of t){let $=h;if($.number===1&&$.raw.startsWith("\uFEFF")){let v=$.raw.substring(1),k=v.length-v.trimStart().length,E=It(v.substring(k),i);$={...$,indent:k,contentOffset:1,content:(E<0?v.substring(k):v.substring(k,k+E)).trimEnd()}}if(p){Di($)&&(p=!1),r.push($);continue}if($.content.startsWith("```")&&(["```","```text","```markdown"].includes($.content)||u.has($.content.substring(3)))&&(p=!0),!p&&$.indent===0&&R($.content)==="numbers"){let v=$.content!=="numbers exact"?d.InvalidNumericDirective:a?d.DuplicateNumericDirective:c?d.LateNumericDirective:void 0;v!==void 0?(o.push({severity:"error",code:v,message:"Expected one 'numbers exact' preamble before domain, imports and declarations.",location:f($)}),s=Object.freeze({numericMode:"invalid"})):s=bn,a=!0,r.push({...$,content:""});continue}!p&&$.indent>0&&/^numbers(\s+(exact|legacy))?$/.test($.content)&&m.set($.number,{severity:"error",code:d.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:f($)}),c||=$.content.trim().length>0,r.push($)}let y=new he(new st(a?r:t),e,n);return y.sourceOptions=s,y.nestedNumericDirectives=m,o.forEach(h=>y.error(h.code,h.message,h.location)),y}l(jn,"sourceContext");function ra(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}l(ra,"eventProductions");function lr(t,e){let n=ra(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)}l(lr,"requiresExplicitDestinations");function oa(t,e,n){let i=ra(t,n);if(e.inlineOperation!=null||n!==void 0&&!n.resolver.isEventProduction(e,n.slice)||e.for!==null||lr(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}l(oa,"implicitDestination");function Ln(t,e){let n=[],i=l(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(se))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 re(t);for(let{slice:a,command:c}of n.flatMap(p=>p.commands.map(m=>({slice:p,command:m})))){let p=c.produces.filter(y=>s.isEventProduction(y,a)),m=c.properties.find(y=>y.isIdentifier)?.name,u=lr(c,{resolver:s,slice:a});for(let y of p){let h=y.inlineEvent;h!==null&&((r.get(h.name)??0)>1||o.has(h.name))&&e.error(d.InlineEventCollision,`Inline event '${h.name}' collides with another event declaration or import`,y.location),u&&y.for===null&&e.error(d.ExplicitProducesTargetsRequired,`Production '${y.event}' in command '${c.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,y.location);let $=y.for?.kind==="PathExpressionSyntax"?y.for.path:y.for===null&&h!==null?m:void 0;if(!(m===void 0||$!==m))for(let v of y.mappings.filter(k=>k.source.kind==="PathExpressionSyntax"&&k.source.path===m)){let k=`Event '${y.event}' copies command identifier '${m}' into payload property '${v.property}' although it already identifies the event source`;h===null?e.information(d.EventSourceIdInPayload,k,v.location):e.warning(d.EventSourceIdInPayload,k,v.location)}}}}l(Ln,"validateInlineEvents");function qn(t,e){let n=new re(t),i=Tn(t),r=ne(t.concepts),o=new Map([...ne(t.types)].map(([b,P])=>[b,ne(P.properties)])),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),a=new Set(t.imports.map(b=>b.qualifiedName.split(".").at(-1))),c=new Map;for(let b of t.imports){let P=b.qualifiedName.split(".").at(-1);c.set(P,[...c.get(P)??[],b.qualifiedName])}let p=l(b=>{let P=new Map,A=new Map;for(let S of b){let g=P.get(S.name)??[];g.push(S),P.set(S.name,g)}return(S,g)=>{let x=JSON.stringify([S,g]);if(A.has(x))return A.get(x);let C=l(N=>{let L=N.split("."),q=P.get(L.at(-1))??[],D=L.slice(0,-1);if(D.length>0)return q.filter(F=>D.length<=F.scope.length&&D.every((U,Y)=>F.scope[F.scope.length-D.length+Y]===U));for(let F=g.length;F>=0;F--){let U=q.filter(Y=>F<=Y.scope.length&&g.slice(0,F).every((Q,oe)=>Y.scope[oe]===Q));if(U.length>0)return U}return[]},"candidates"),I=C(S),w=c.get(S)??[];I.length===0&&w.length===1&&(I=C(w[0]));let j=I.length===1?I[0].node:null;return A.set(x,j),j}},"scoped"),m=p(n.slices.flatMap(({slice:b,scope:P})=>b.readModels.map(A=>({name:A.name,scope:P,node:A})))),u=p(n.slices.flatMap(({slice:b,scope:P})=>b.commands.map(A=>({name:A.name,scope:P,node:{command:A,slice:b}})))),y=new Map;for(let b of t.systems??[])y.has(b.name)&&e.error(d.InvalidSystemDeclaration,`System '${b.name}' is declared more than once.`,b.location),y.set(b.name,(y.get(b.name)??0)+1);let h=l((b,P,A=!0)=>{let[S,...g]=P.split("."),x=b.filter(j=>j.name===S);if(x.length!==1)return{type:null,missing:x.length===0};let C=x[0].type;if(g.length===0)return{type:C,missing:!1};let I=o.get(C.name);if(I===void 0)return{type:null,missing:s.has(C.name)};let w=h([...I.values()],g.join("."),A);return w.type===null?w:{type:{...w.type,isOptional:A&&C.isOptional||w.type.isOptional,isCollection:C.isCollection||w.type.isCollection},missing:!1}},"pathType"),$=l((b,P,A,S,g=new Set)=>{if(A.has(P)||b.isOptional&&!S.has(P))return!0;if(b.isCollection||g.has(b.name))return!1;let x=o.get(b.name);return x===void 0?S.has(P)&&!s.has(b.name):[...x.values()].every(C=>$(C.type,`${P}.${C.name}`,A,S,new Set([...g,b.name])))},"covered"),v=l((b,P)=>{if(b.kind==="ListExpressionSyntax"&&P.isCollection)return b.items.every(S=>v(S,{...P,isCollection:!1,isOptional:!1}));let A=o.get(P.name);return b.kind!=="ObjectExpressionSyntax"||A===void 0?!0:[...A.values()].every(S=>(S.type.isOptional||b.members.some(g=>g.name===S.name))&&b.members.filter(g=>g.name===S.name).every(g=>v(g.value,S.type)))},"completeValue"),k=l(b=>b.kind==="LiteralExpressionSyntax"?typeof b.value!="number"||Number.isFinite(b.value):b.kind==="ObjectExpressionSyntax"?b.members.every(P=>k(P.value)):b.kind==="ListExpressionSyntax"&&b.items.every(k),"concrete"),E=l((b,P,A,S,g)=>{let x=new Set,C=new Set(b.map(w=>w.property)),I=new Set;for(let w of b){let j=w.property.split(".");for(let N=1;N<=j.length;N++)I.add(j.slice(0,N).join("."))}for(let w of b){x.has(w.property)&&e.error(d.InvalidOperationMapping,`Duplicate operation input mapping '${w.property}'.`,w.location),x.add(w.property);let j=h(P.inputs,w.property,!1);if(j.missing&&e.error(d.InvalidOperationMapping,`Operation '${P.name}' declares no input '${w.property}'.`,w.location),j.type===null)continue;let N=w.property.split(".");for(let L=1;L<N.length;L++)C.has(N.slice(0,L).join("."))&&e.error(d.InvalidOperationMapping,`Operation input mapping '${w.property}' overlaps a whole input mapping.`,w.location);if(A!==null&&w.source.kind==="PathExpressionSyntax"){let L=h(A.properties,w.source.path),q=w.source.path.split("."),D=(En.get(A)??[]).filter(Y=>(Y.alias??Y.readModel)===q[0]);if(L.missing&&D.length>0){L={type:null,missing:!1};let Y=D.length===1?m(D[0].readModel,g):null;q.length>1&&Y!==null&&(L=h(Y.properties,q.slice(1).join(".")))}L.missing&&e.error(d.InvalidOperationMapping,`Command '${A.name}' declares no source '${w.source.path}'.`,w.source.location);let F=L.type,U=j.type;F!==null&&s.has(F.name)&&s.has(U.name)&&(F.name!==U.name||F.isCollection!==U.isCollection||F.isOptional&&!U.isOptional)&&e.error(d.InvalidOperationMapping,`Source '${w.source.path}' is incompatible with input '${w.property}' of operation '${P.name}'.`,w.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(w.source.kind)&&(!Oe(w.source,j.type,r,o)||S&&!v(w.source,j.type))&&e.error(d.InvalidOperationMapping,`Value is incompatible with input '${w.property}' of operation '${P.name}'.`,w.source.location)}if(S)for(let w of P.inputs)$(w.type,w.name,x,I)||e.error(d.InvalidOperationMapping,`Production of operation '${P.name}' supplies no value for required input '${w.name}'.`,P.location)},"validateMappings");for(let{slice:b,scope:P}of n.slices){let A=on(b),S=new Set(se(b).map(g=>g.name));for(let g of A){S.has(g.name)&&e.error(d.ProductionDeclarationCollision,`Operation '${g.name}' collides with another event or operation in slice '${b.name}'.`,g.location),S.add(g.name),g.uses.length>0&&y.get(g.uses)!==1&&e.error(d.InvalidSystemReference,`Operation '${g.name}' must use one declared system; '${g.uses}' does not resolve uniquely.`,g.usesLocation??g.location);for(let x of g.inputs)!s.has(x.type.name)&&!a.has(x.type.name)&&e.warning(d.UnknownType,`Unknown type '${x.type.name}' on input '${x.name}' of operation '${g.name}'.`,x.type.location)}for(let g of b.commands)for(let x of g.produces){let C=n.resolve(x.event,b);C.kind===ee.Ambiguous&&C.candidates.some(I=>I.kind===ee.Operation)&&e.error(d.InvalidProductionReference,`Production '${x.event}' is ambiguous.`,x.location),x.event.includes(".")&&C.kind!==ee.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",x.location),C.declaration?.node.kind==="OperationSyntax"&&((x.for!==null||x.tags.length>0)&&e.error(d.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",x.location),E(x.mappings,C.declaration.node,g,!0,P))}for(let g of b.reactions.flatMap(x=>x.triggers).flatMap(x=>x.produces)){let x=n.resolve(g.event,b);x.kind===ee.Ambiguous&&x.candidates.some(C=>C.kind===ee.Operation)&&e.error(d.InvalidProductionReference,`Production '${g.event}' is ambiguous.`,g.location),g.event.includes(".")&&n.resolve(g.event,b).kind!==ee.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",g.location),n.isOperation(g,b)&&e.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",g.location)}for(let g of b.specifications){let x=[...g.givenOperationFailures??[],...g.thenOperations??[],...g.thenCompensated??[]];if(x.length===0)continue;let C=u(i(g.when,P)?.commandType??"",P);(C===null||g.whenAppended!==null||g.whenQuery!==null||g.whenTrigger!==null||g.whenClock!==null||g.whenCapture!==null)&&e.error(d.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",g.location);let I=new Map;for(let w of x){if(w.kind==="SpecificationOperationSyntax")for(let L of w.values)k(L.source)||e.error(d.InvalidOperationSpecification,"Operation assertions require concrete input values.",L.source.location);let j=n.resolve(w.operation,b).declaration?.node;if(j?.kind!=="OperationSyntax"){e.error(d.InvalidOperationSpecification,`'${w.operation}' does not resolve uniquely to a declared operation.`,w.location);continue}let N=I.get(j)??new Set;if(N.has(w.kind)&&e.error(d.InvalidOperationSpecification,`Duplicate operation step '${w.operation}'.`,w.location),N.add(w.kind),I.set(j,N),w.kind==="SpecificationCompensatedSyntax"&&j.compensate===null&&e.error(d.InvalidOperationSpecification,`Operation '${w.operation}' declares no compensation.`,w.location),C!==null&&C.command.handler==null){let L=C.command.produces.map(q=>n.resolve(q.event,C.slice));L.every(q=>q.kind===ee.Event||q.kind===ee.Operation)&&!L.some(q=>q.declaration?.node===j)&&e.error(d.InvalidOperationSpecification,`Command '${C.command.name}' does not produce operation '${w.operation}'.`,w.location)}w.kind==="SpecificationOperationSyntax"&&E(w.values,j,null,!1,P)}}}}l(qn,"validateOperations");var $p=V("^policy\\s+([A-Za-z_]\\w*)$");function aa(t,e){let n=t;t=t.valueContext;let i=$p.exec(e.content)?.[1]??"";i===""&&t.error(d.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,f(e));let r=null,o=null,s=null,a=!1;for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent))if(t.reader.takeSignificant(),R(c.content)==="require"){let p=c.content.substring(7).trim();for(let y=t.peekChild(c.indent);y!==void 0;y=t.peekChild(c.indent))t.reader.takeSignificant(),p+=` ${y.content}`;let m=kp(t,p);m.includes("not")&&(t=n);let u=bp(t,m,f(c));a?t.error(d.RepeatedPolicyRequirement,`Policy '${i}' has more than one require line; combine the conditions with and/or in one require`,f(c)):r=u,a=!0}else if(R(c.content)==="file"){let p=_e(t,c);o===null&&s===null?s=p:t.error(d.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(c))}else if(c.content.startsWith("```")||t.languages.has(c.content)){let p=ve(t,c);o===null&&s===null?o=p:t.error(d.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(c))}else t.error(d.UnknownPolicyDirective,`Unexpected '${c.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,f(c)),t.skipOpaqueBlock(c.indent);return r!==null&&(o!==null||s!==null)&&t.error(d.MixedPolicyImplementation,`Policy '${i}' cannot combine 'require' with a file or inline code block`,f(e)),r===null&&o===null&&s===null&&t.error(d.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,location:f(e)}}l(aa,"parsePolicy");function kp(t,e){let n=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]":"[\\w.$]+";return[...e.match(new RegExp(V(`"${Z}"|\\(|\\)|${n}`).source,"gu"))??[]]}l(kp,"tokenizePolicyCondition");function bp(t,e,n){let i=t.sourceOptions.numericMode==="exact"||e.includes("not"),r=0,o=l(u=>u!==void 0&&u.startsWith('"')&&u.endsWith('"'),"quoted"),s=l(u=>H(u.substring(1,u.length-1)),"unquote"),a=l(()=>{if(e[r]==="not"){r++;let $=a();return $===null?null:{kind:"NotPolicyConditionSyntax",operand:$,location:n}}if(e[r]==="("){r++;let $=p();return e[r]===")"?r++:i&&t.error(d.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),$}let u=e[r++];if(u==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(u!=="role"&&u!=="claim")return t.error(u===void 0?d.ExpectedPolicyCondition:d.UnexpectedTokenInPolicyCondition,u===void 0?"Expected a policy condition":`Unexpected '${u}' in policy condition`,n),null;let y=e[r++];if(!o(y))return t.error(u==="role"?d.ExpectedRoleName:d.ExpectedClaimName,`Expected a quoted ${u} name after '${u}'`,n),null;if(u==="role")return{kind:"RoleConditionSyntax",role:s(y),location:n};if(e[r++]!=="matches")return t.error(d.ExpectedClaimMatches,"Expected 'matches' after the claim name",n),null;let h=e[r++];return h===void 0?(t.error(d.ExpectedClaimMatchTarget,"Expected 'subject' or a value after 'matches'",n),null):{kind:"ClaimConditionSyntax",claim:s(y),matchesSubject:h==="subject",matches:h==="subject"?null:ge(h,n,t),location:n}},"group"),c=l(()=>{let u=a();for(;u!==null&&e[r]==="and";){r++;let y=a();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"And",right:y,location:n}}return u},"and"),p=l(()=>{let u=c();for(;u!==null&&e[r]==="or";){r++;let y=c();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"Or",right:y,location:n}}return u},"or"),m=p();return i&&m!==null&&r<e.length&&t.error(d.UnexpectedTokenInPolicyCondition,`Unexpected '${e[r]}' in policy condition`,n),m}l(bp,"parsePolicyCondition");var Ep=new RegExp(`^for\\s+"(${Z})"$`,"u"),Cp=V("^[A-Z]\\w*$"),Pp=V("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function sa(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(d.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=Ep.exec(i.content);if(r===null){t.error(d.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(),!Cp.test(s.content)){t.error(d.InvalidSeedEvent,`Invalid seed event '${s.content}' - expected an event type name`,f(s)),t.skipOpaqueBlock(s.indent);continue}let a=[];for(let c=t.peekChild(s.indent);c!==void 0;c=t.peekChild(s.indent)){t.reader.takeSignificant();let p=Pp.exec(c.content);p!==null?a.push({kind:"PropertyMappingSyntax",property:p[1],source:ge(p[2],f(c),t),location:f(c)}):t.error(d.InvalidSeedPropertyAssignment,`Invalid property assignment '${c.content}' - expected '<property> = <value>'`,f(c))}o.push({kind:"SeedEventSyntax",event:s.content,properties:a,location:f(s)})}n.push({kind:"SeedGroupSyntax",eventSourceId:H(r[1]),events:o,location:f(i)})}return{kind:"SeedSyntax",groups:n,location:f(e)}}l(sa,"parseSeed");var Ap=O("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),da=O("^import\\s+([\\w.]+)$"),wp=O("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@\\w+)*)$"),Op=O("^@?[a-z_]\\w*$"),Ip=O(`^([a-z_]\\w*)\\s+reason\\s+"(${Z})"$`),Tp=O("^persona\\s+([A-Za-z_]\\w*)$"),Rp=O("^policy\\s+([A-Za-z_]\\w*)$"),Mp=/^[ ]*\t/,la=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],pa=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),Dp=new Set(["slice","feature","description","authorize","screen","dialog","form","contribute","on","uses"]);function Bn(t,e,n=ot){Bp(t,e);let i=n.length===1?new Qt(n[0]):void 0,r=n.length>1?new Vt(n[n.length-1]):void 0,o=i??r,s=null,a=[],c=[],p=[],m=[],u=[],y=[],h=[],$=[],v=[],k=[],E=[],b=[],P=!1;for(let S=t.reader.peekSignificant();S!==void 0;S=t.reader.peekSignificant()){t.reader.takeSignificant();let g=R(S.content);if(g==="domain"){t.authoredDeclarations=!0,s=qp(t,S,s,P);continue}if(P||=ca(g,S,n),t.authoredDeclarations||=g!=="import"&&ca(g,S,n),g==="import"&&Br(S.content))o!==void 0?o.tryParse(t,S):mt(t,S,c);else if(g==="import"){let x=da.exec(S.content);x===null?t.error(d.InvalidImportDeclaration,`Invalid import '${S.content}' - expected 'import <Qualified.Name>'`,f(S)):a.push({kind:"ImportSyntax",qualifiedName:x[1],location:f(S)})}else if(g==="example")o!==void 0?o.tryParse(t,S):E.push(qe(t,S));else if(g==="eventsource")y.push(ro(t,S));else if(g==="system")u.push(go(t,S));else if(g==="concept")p.push(Fp(t,S));else if(g==="type")m.push(Hr(t,S));else if(g==="module"&&!Tt(n))Np(t,S,n,i);else if(g==="module")h.push(Ji(t,S));else if(g==="persona")$.push(Wp(t,S));else if(g==="seed")k.push(sa(t.valueContext,S));else if(g==="policy")v.push(aa(t,S));else if(g==="trigger"){let x=To(t,S),C=/^trigger\s+([A-Za-z_]\w*)$/.exec(S.content)?.[1];C!==void 0&&b.push({name:C,data:x})}else pa.has(g)?g==="behavior"||g==="layout"?Ce(t,S):t.skipOpaqueBlock(S.indent):o?.tryParse(t,S)!==!0&&jp(t,S,n)}i!==void 0?h.unshift(i.build(t.start,!0)):r!==void 0&&h.unshift(Lp(n,r.build(t.start,!0),t.start));let A={kind:"ApplicationSyntax",sourceOptions:t.sourceOptions,domain:s,imports:a,concepts:p,types:m,systems:u,eventSources:y,examples:E,modules:h,personas:$,policies:v,seeds:k,declaredTriggers:b,fileImports:c,location:t.start};return t.authoredDeclarations&&uo(A),A}l(Bn,"parseApplication");function ca(t,e,n){return t==="import"?da.test(e.content):t==="module"?Tt(n):t==="example"||t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||pa.has(t)}l(ca,"declaresConstruct");function Np(t,e,n,i){let r=Zi.exec(e.content)?.[1]??"";if(i!==void 0&&r===n[0]){t.authoredDeclarations=!0,i.parseChildren(t,e);return}t.error(d.ModuleInPlacedFile,`This file is imported into ${dn(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,f(e)),t.skipBlock(e.indent)}l(Np,"parseModuleInPlacedFile");function jp(t,e,n){let i=R(e.content);if(Tt(n)){let r=Dp.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, module, seed, trigger, behavior, ui profile, theme or layout";t.error(d.UnknownTopLevelConstruct,`Unexpected '${i}' at the top level${r}`,f(e))}else{let r=n.length===1?_i:Ki;t.error(d.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${dn(n)} - expected an application declaration or ${r}`,f(e))}t.skipBlock(e.indent)}l(jp,"reportUnexpectedTopLevel");function Lp(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}}l(Lp,"place");function qp(t,e,n,i){let r=Ap.exec(e.content);return r===null?(t.error(d.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,f(e)),n):n!==null?(t.error(d.DuplicateDomain,"The document already declares a domain - a document can have at most one",f(e)),n):(i&&t.error(d.DomainNotFirst,"'domain' must be declared before any other construct",f(e)),{kind:"DomainSyntax",name:r[1],location:f(e)})}l(qp,"parseDomain");function Bp(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&Mp.test(i.raw)&&t.warning(d.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",jr(i))}}l(Bp,"warnOnTabIndentation");function Fp(t,e){let n=wp.exec(e.content);if(n===null)return t.error(d.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,f(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:R(e.content),type:"",attributes:[],values:[],location:f(e)};let[,i,r,o]=n,s=o.split(" ").filter(m=>m.length>0).map(m=>({kind:"ConceptAttributeSyntax",name:m.replace(/^@+/,""),reason:null,location:f(e)}));r!=="Enum"&&!la.includes(r)&&t.error(d.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${la.join(", ")} or Enum`,f(e));let a=new Map;s.forEach((m,u)=>{a.has(m.name)||a.set(m.name,u)});let c=[],p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=Ip.exec(m.content);if(!le(m))if(R(m.content)==="validate"){r==="Enum"&&m.content==="validate"&&t.peekChild(m.indent)===void 0&&t.warning(d.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${i}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,f(m));let y=ji(t,m,"concept");y!==void 0&&p.push(y)}else u!==null?Yp(t,m,i,s,a,u[1],H(u[2])):r==="Enum"&&Op.test(m.content)?c.push(X(m.content)):r==="Enum"?t.error(d.InvalidEnumerationValue,`Invalid enum value '${m.content}' - expected an identifier`,f(m)):(t.error(d.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:c,validations:p,location:f(e)}}l(Fp,"parseConcept");function Yp(t,e,n,i,r,o,s){let a=r.get(o);a===void 0?t.error(d.AttributeReasonWithoutAttribute,`Concept '${n}' declares a reason for '${o}' without the attribute - write 'concept ${n} : <Type> @${o}'`,f(e)):i[a].reason!==null?t.error(d.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${o}' - at most one is allowed`,f(e)):i[a]={...i[a],reason:s}}l(Yp,"applyAttributeReason");function Wp(t,e){let n=Tp.exec(e.content)?.[1]??"";n===""&&t.error(d.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=R(o.content);if(s==="description")i=_(t,o,i,`Persona '${n}'`);else if(s==="policy"){let a=Rp.exec(o.content);a===null?t.error(d.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,f(o)):r.push(a[1])}else t.error(d.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)}}l(Wp,"parsePersona");var bt=class t{static{l(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:c}of e){let p=jn(a,a[0]?.path,n);p.scope=c;let m=Bn(p,a,c);for(let u of m.types)r.add(u.name);for(let u of m.concepts)r.add(u.name);for(let u of m.imports)o.add(u.qualifiedName);for(let u of m.eventSources??[])i.set(u.name,[...i.get(u.name)??[],u.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 fe;(function(t){t.Unique="unique",t.Ambiguous="ambiguous",t.NotFound="notFound",t.WrongKind="wrongKind"})(fe||(fe={}));var Xe=class{static{l(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)?fe.WrongKind:fe.NotFound:i.length>1||r.length>1?o=fe.Ambiguous:o=r.length===1?fe.Unique:fe.NotFound,{kind:o,sources:i,streams:r}}};function Fn(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 p of a.filter(m=>!e.some(u=>u.property===m.name)))o.error(r,`Stream id part '${p.name}' requires a mapping.`,i);let c=new Set;for(let p of e){let m=a.find(u=>u.name===p.property);m===void 0?o.error(r,`Unknown stream id part '${p.property}'.`,p.location):c.has(p.property)?o.error(r,`Stream id part '${p.property}' is mapped more than once.`,p.location):(c.add(p.property),s(p,m.type))}}l(Fn,"validateStreamIdParts");function fa(t,e){t=We(t);let n=new re(t);if(!n.slices.flatMap($=>$.slice.specifications).some($=>[...$.given,...$.thenEvents,...$.whenAppended===null?[]:[$.whenAppended]].some(v=>v.stream!=null||v.noStream!=null)))return;let i=new Xe(t),r=ne(t.concepts),o=ne(t.types),s=new Map([...o].map(([$,v])=>[$,ne(v.properties)])),a=l(($,v)=>Oe($,v,r,s),"compatible"),c=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),p=l(($,v)=>c.has($.name)&&c.has(v.name)?$.name===v.name&&$.isCollection===v.isCollection&&(!$.isOptional||v.isOptional):null,"nominallyCompatible"),m=l(($,v)=>{if($?.kind!=="LiteralExpressionSyntax"||!a($,v))return null;let k=r.get(v.name)?.type??v.name,E=$.value;if(k==="String"&&typeof E=="string")return E;if(k==="Uuid"&&typeof E=="string"){let b=E.replace(/[{}()-]/g,"").toLowerCase();return`${b.slice(0,8)}-${b.slice(8,12)}-${b.slice(12,16)}-${b.slice(16,20)}-${b.slice(20)}`}if(k==="Int"){if(typeof E=="number")return BigInt(E).toString();if(typeof E=="object"&&E!==null&&E.literalType==="ExactNumber")return _t(E)}return null},"formatStreamId"),u=l(($,v)=>{let k=$.properties,E=null,b=!1,P=!1;for(let A of v.split(".")){let S=k.filter(x=>x.name===A);if(S.length!==1)return null;let g=S[0].type;b||=g.isOptional,P||=g.isCollection,E={...g,isOptional:b,isCollection:P},k=o.get(g.name)?.properties??[]}return E},"pathType"),y=l(($,v)=>{let k=n.resolve($,v).declaration;return k?.node.kind==="EventSyntax"?k.node:null},"eventOf"),h=[];for(let{slice:$}of n.slices){for(let v of $.commands)for(let k of v.produces){if(!n.isEventProduction(k,$))continue;let E=y(k.event,$);if(E===null)continue;let b=k.for?.kind==="PathExpressionSyntax"?k.for.path:oa(v,k,{resolver:n,slice:$}),P=b==="new event source"?{kind:"TypeRefSyntax",name:"Uuid",isOptional:!1,isCollection:!1,location:k.location}:b===void 0?null:u(v,b);h.push({event:E,command:v,type:P})}for(let v of $.reactions.flatMap(k=>k.triggers).flatMap(k=>k.produces)){let k=y(v.event,$);k!==null&&h.push({event:k,command:null,type:null})}for(let v of $.captures)for(let k of[...v.appends,...v.children.flatMap(E=>E.appends),...v.nested.flatMap(E=>E.appends)]){let E=y(k.event,$);E!==null&&h.push({event:E,command:null,type:null})}}for(let{slice:$,scope:v}of n.slices)for(let k of $.specifications){let E=n.slices.flatMap(x=>x.slice.commands.map(C=>({command:C,scope:x.scope}))),b=k.when?.commandType.split(".")??[],P=b.slice(0,-1),A=E.filter(x=>x.command.name===b.at(-1)&&P.every((C,I)=>x.scope[x.scope.length-P.length+I]===C)),S=P.length>0&&A.length===1?A[0].command:null;for(let x=v.length;P.length===0&&x>=0&&S===null;x--){let C=A.filter(I=>v.slice(0,x).every((w,j)=>I.scope[j]===w));if(C.length>0){S=C.length===1?C[0].command:null;break}}let g=[...k.given.map(x=>({node:x,required:!0,expected:!1})),...k.whenAppended===null?[]:[{node:k.whenAppended,required:!0,expected:!1}],...k.thenEvents.map(x=>({node:x,required:!1,expected:!0}))];for(let{node:x,required:C,expected:I}of g){if(x.stream==null&&x.noStream==null)continue;C&&x.noStream!=null&&e.error(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",x.noStream.location);let w=null,j=y(x.eventType,$),N=h.filter(D=>D.event===j);if(x.stream!=null){let D=x.stream,F=i.resolve(D.eventSource,D.stream);if(F.kind!==fe.Unique){let oe={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[F.kind];e.error(d.InvalidSpecificationStreamRoute,`Stream '${D.eventSource}.${D.stream}' is ${oe}; routing requires one physical source and stream.`,D.location);continue}let U=F.sources[0],Y=F.streams[0],Q=l((oe,je)=>{let ae=oe.source;(ae.kind!=="LiteralExpressionSyntax"||ae.value===null||ae.value===""||je!==null&&!a(ae,je))&&e.error(d.InvalidSpecificationStreamRoute,"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.",ae.location)},"validateLiteral");if(Y.streamIdParts.length>0?Fn(Y,D.streamIdParts,D.streamId!==null,D.location,d.InvalidSpecificationStreamRoute,e,Q):D.streamIdParts.length>0?e.error(d.InvalidSpecificationStreamRoute,"A streamId part block requires a composite stream.",D.location):(Y.streamId===null!=(D.streamId===null)&&e.error(d.InvalidSpecificationStreamRoute,Y.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",D.location),D.streamId!==null&&Q(D.streamId,Y.streamId)),w=U.identifier,w===null){let oe=N.map(ae=>ae.type),je=new Set(oe.filter(ae=>ae!==null).map(ae=>`${ae.name}:${ae.isOptional}:${ae.isCollection}`));oe.length===0||oe.some(ae=>ae===null)||je.size!==1?e.error(d.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${U.name}'; the event's producers do not supply one unambiguous destination type.`,D.location):w=oe[0]}C&&x.for===null?e.error(d.InvalidSpecificationStreamEventSource,"A routed given or when append event requires 'for <literal>'.",D.location):x.for!==null&&(x.for.kind!=="LiteralExpressionSyntax"||x.for.value===null||w!==null&&(w.isCollection||w.isOptional||!a(x.for,w)))&&e.error(d.InvalidSpecificationStreamEventSource,"A routed event's for value must be a concrete literal compatible with the source's identifier type.",x.for.location)}if(!I||S===null||N.length===0||N.some(D=>D.command!==S))continue;let L=S.stream?.propertyCandidate===null?S.stream:null,q=x.noStream!=null?L!=null:L==null||L.eventSource!==x.stream.eventSource||L.stream!==x.stream.stream;if(!q&&x.stream!=null&&L!=null){let D=i.resolve(x.stream.eventSource,x.stream.stream),F=D.kind===fe.Unique?D.streams[0]:null;if(F!==null&&F.streamIdParts.length>0){if(L.streamId===null&&x.stream.streamId===null&&L.streamIdParts.length>0&&x.stream.streamIdParts.length>0)for(let U of F.streamIdParts){let Y=L.streamIdParts.filter(ae=>ae.property===U.name),Q=x.stream.streamIdParts.filter(ae=>ae.property===U.name);if(Y.length!==1||Q.length!==1)continue;let oe=m(Y[0].source,U.type),je=m(Q[0].source,U.type);oe!==null&&je!==null&&oe!==je&&(q=!0)}}else if(F?.streamId!=null&&L.streamIdParts.length===0&&x.stream.streamIdParts.length===0){let U=m(L.streamId?.source,F.streamId),Y=m(x.stream.streamId?.source,F.streamId);U!==null&&Y!==null&&U!==Y&&(q=!0)}}x.for?.kind==="LiteralExpressionSyntax"&&N.every(D=>D.type!==null&&(w!==null?p(D.type,w)===!1:!a(x.for,D.type)))&&(q=!0),q&&e.error(d.SpecificationStreamContradictsCommand,"The expected event route contradicts its only producer, the command under test.",(x.stream??x.noStream).location)}}}l(fa,"validateSpecificationStreams");var cr=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function Yn(t,e){let n=ne(t.concepts),i=ne(t.types),r=new Set([...cr,...n.keys(),...i.keys()]),o=new Map([...i].map(([u,y])=>[u,ne(y.properties)])),s=l((u,y)=>r.has(u.name)&&r.has(y.name)?u.name===y.name&&u.isCollection===y.isCollection&&(!u.isOptional||y.isOptional):null,"compatible"),a=l((u,y)=>{if(u===null)return;if(u.isOptional||u.isCollection||t.types.some(v=>v.name===u.name)){e.error(d.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",u.location);return}let h=t.concepts.filter(v=>v.name===u.name),$=h.length===1?h[0].type:h.length===0&&cr.has(u.name)?u.name:null;y&&$!==null&&(!["String","Uuid","Int"].includes($)||$==="Int"&&h.length===0||h.some(v=>v.values.length>0))&&e.error(d.UnsupportedStreamIdType,"Stream ids support text and UUID values and their nominal concepts, plus integer-backed concepts; other types need a future portable formatter.",u.location),$===null&&!t.imports.some(v=>v.qualifiedName===u.name||v.qualifiedName.split(".").at(-1)===u.name)&&e.warning(d.UnknownType,`Unknown type '${u.name}' in event source declaration.`,u.location)},"validateType"),c=new Set;for(let u of t.eventSources??[]){c.has(u.name)&&e.error(d.InvalidEventSourceDeclaration,`Event source '${u.name}' has multiple physical declarations.`,u.location),c.add(u.name),a(u.identifier,!1);let y=new Set;for(let h of u.streams){y.has(h.name)&&e.error(d.InvalidEventSourceDeclaration,`Stream '${u.name}.${h.name}' has multiple declarations under this source.`,h.location),y.add(h.name),a(h.streamId,!0);let $=h.streamIdParts;if($.length>0){$.length<2&&e.error(d.InvalidEventSourceDeclaration,"A composite stream id requires at least two named parts.",h.directiveLocations?.streamId??h.location);for(let v of new Set($.map(k=>k.name)))for(let k of $.filter(E=>E.name===v).slice(1))e.error(d.InvalidEventSourceDeclaration,`Stream id part '${k.name}' is declared more than once.`,k.location);for(let v of $)a(v.type,!0)}}}let p=l((u,y)=>{let[h,...$]=y.split(".");if(u===null)return{property:null,missing:!1};let v=u.filter(b=>b.name===h);if(v.length!==1)return{property:null,missing:v.length===0};let k=v[0];if($.length===0)return{property:k,missing:!1};if(cr.has(k.type.name)||n.has(k.type.name)&&!i.has(k.type.name))return{property:null,missing:!0};let E=p(i.get(k.type.name)?.properties??null,$.join("."));return E.property===null?E:{property:{...E.property,type:{...E.property.type,isCollection:k.type.isCollection||E.property.type.isCollection,isOptional:k.type.isOptional||E.property.type.isOptional}},missing:!1}},"pathProperty"),m=new Xe(t);for(let{slice:u}of new re(t).slices)for(let y of u.commands){let h=y.stream;if(h==null||h.propertyCandidate!==null)continue;let $=m.resolve(h.eventSource,h.stream);if($.kind!==fe.Unique){let P={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[$.kind];e.error(d.InvalidCommandStream,`Stream '${h.eventSource}.${h.stream}' is ${P}; routing requires one physical source and stream.`,h.location);continue}let v=$.sources[0],k=$.streams[0],E=y.properties.filter(P=>P.isIdentifier);v.identifier!==null&&E.length===1&&s(E[0].type,v.identifier)===!1&&e.warning(d.InvalidCommandStream,`Command identifier '${E[0].name}' does not have the source's nominal identifier type '${v.identifier.name}'. The stream does not supply a destination.`,E[0].location);let b=l((P,A)=>{let S=P.source;if(S.kind==="PathExpressionSyntax"){let g=p(y.properties,S.path);(g.missing||g.property!==null&&s(g.property.type,A)===!1)&&e.error(d.InvalidCommandStream,`Stream id source '${S.path}' is absent or incompatible with nominal type '${A.name}'.`,S.location)}else S.kind==="LiteralExpressionSyntax"&&!Oe(S,A,n,o)?e.error(d.InvalidCommandStream,`Stream id value is incompatible with nominal type '${A.name}'.`,S.location):(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(S.kind)||S.kind==="LiteralExpressionSyntax"&&S.value===null)&&e.error(d.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",S.location)},"validateMapping");if(k.streamIdParts.length>0){Fn(k,h.streamIdParts,h.streamId!==null,h.location,d.InvalidCommandStream,e,(P,A)=>{b(P,A),P.source.kind==="LiteralExpressionSyntax"&&P.source.value===""&&e.error(d.InvalidCommandStream,"A composite stream id part cannot be empty text.",P.source.location)});continue}if(h.streamIdParts.length>0){e.error(d.InvalidCommandStream,"A streamId part block requires a composite stream.",h.location);continue}(k.streamId===null&&h.streamId!==null||k.streamId!==null&&h.streamId===null)&&e.error(d.InvalidCommandStream,k.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",h.location),!(k.streamId===null||h.streamId===null)&&b(h.streamId,k.streamId)}fa(t,e)}l(Yn,"validateEventSources");function Wn(t,e){let n=new re(t),i=n.slices,r=new Set(t.imports.map(v=>v.qualifiedName)),o=new Set([...i.flatMap(({slice:v})=>se(v).map(k=>k.name)),...t.imports.map(v=>v.qualifiedName.split(".").at(-1))]),s=ne(t.types),a=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(v=>v.name)].filter(v=>!s.has(v))),c=l((v,k)=>{let[E,...b]=k.split(".");if(v===null)return{value:null,missing:!1};let P=v.filter(S=>S.name===E);if(P.length!==1)return{value:null,missing:P.length===0};let A=P[0];return b.length===0?{value:A,missing:!1}:a.has(A.type.name)?{value:null,missing:!0}:c(s.get(A.type.name)?.properties??null,b.join("."))},"property"),p=i.flatMap(({slice:v,scope:k})=>v.readModels.map(E=>({node:E,scope:k}))),m=l((v,k)=>{let E=l(A=>{let S=A.split("."),g=p.filter(C=>C.node.name===S.at(-1)),x=S.slice(0,-1);if(x.length>0)return g.filter(C=>x.length<=C.scope.length&&x.every((I,w)=>C.scope[C.scope.length-x.length+w]===I));for(let C=k.length;C>=0;C--){let I=g.filter(w=>C<=w.scope.length&&k.slice(0,C).every((j,N)=>w.scope[N]===j));if(I.length>0)return I}return[]},"candidates"),b=E(v),P=t.imports.filter(A=>A.qualifiedName.split(".").at(-1)===v);return b.length===0&&P.length===1&&(b=E(P[0].qualifiedName)),b.length===1?b[0].node.properties:null},"viewProperties"),u=l((v,k,E)=>{let b=n.resolve(v,E);o.has(v)||r.has(v)||b.declaration?.kind===ee.Event||b.candidates.some(A=>A.kind===ee.Event)||e.warning(d.UnknownEvent,`Unknown event '${v}' - declare it with 'event ${v}'`,k)},"unknownEvent"),y=l((v,k)=>{for(let E of v)(E.kind==="RemoveWithSyntax"||E.kind==="RemoveViaJoinSyntax")&&u(E.event,E.location,k),"blocks"in E&&y(E.blocks,k)},"removals"),h=new Set,$=l((v,k,E=!1,b=!1)=>{let P=l((S,g)=>{let x=c(k,S),C=JSON.stringify([g.path,g.line,g.column]);return x.missing&&!h.has(C)&&(h.add(C),e.warning(d.UnknownReadModelProperty,`Projection target '${S}' is not a declared ${E?"element":"read-model"} property`,g)),x.value},"validate"),A=b||v.some(S=>S.kind==="FromSyntax"||S.kind==="JoinSyntax"||S.kind==="AllSyntax");for(let S of v){let g=S.kind==="EverySyntax"&&!A?[]:"mappings"in S?S.mappings:S.kind==="JoinSyntax"?S.events.flatMap(x=>x.mappings):[];for(let x of g)P(x.property,x.location);if(S.kind==="ChildrenSyntax"||S.kind==="NestedSyntax"){let x=P(S.property,S.location);$(S.blocks,x===null?null:s.get(x.type.name)?.properties??null,!0)}}},"walk");for(let{slice:v}of i){for(let k of v.projections)y(k.blocks,v);for(let k of v.captures)for(let E of[...k.appends,...k.children.flatMap(b=>b.appends),...k.nested.flatMap(b=>b.appends)])u(E.event,E.location,v)}for(let{slice:v,scope:k}of i)for(let E of v.projections){let b=E.blocks.filter(P=>P.kind==="ProjectionVariantSyntax");b.length===0&&$(E.blocks,m(E.readModel??E.name,k));for(let P of b){let A=m(P.name,k);$(E.blocks.filter(g=>g.kind==="ChildrenSyntax"||g.kind==="NestedSyntax"),A);let S=P.entersOn.length>0||E.blocks.some(g=>g.kind==="FromSyntax"||g.kind==="JoinSyntax"||g.kind==="AllSyntax");$(P.blocks,A,!1,S)}}}l(Wn,"validateProjectionTargets");function Un(t,e){let n=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="pii")).map(u=>u.name)),i=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="sensitive")).map(u=>u.name)),r=ne(t.types),o=new re(t),s=new Set(t.imports.map(u=>u.qualifiedName.split(".").at(-1))),a=new Map;for(let u of t.declaredTriggers??[]){let y=a.get(u.name)??[];y.push(u.data),a.set(u.name,y)}let c=l((u,y,h="an event source identifier")=>{if(n.has(u.name)||i.has(u.name)){let $=n.has(u.name)?"@pii":"@sensitive";e.error(d.PiiNotSupportedOnIdentifier,`Concept '${u.name}' is ${$} and cannot be ${h} - use a surrogate Uuid identifier and keep the ${$} value as a property`,y)}},"validate"),p=l((u,y)=>{let[h,...$]=y.split("."),v=u.filter(E=>E.name===h);if(v.length!==1)return null;let k=v[0];return $.length===0?k:p(r.get(k.type.name)?.properties??[],$.join("."))},"property");for(let u of t.eventSources??[]){u.identifier!=null&&c(u.identifier,u.identifier.location);for(let y of u.streams){y.streamId!==null&&c(y.streamId,y.streamId.location,"a stream id");for(let h of y.streamIdParts)c(h.type,h.type.location,`a stream id part '${h.name}'`)}}let m=new Xe(t);for(let{slice:u}of o.slices){for(let y of u.commands){for(let h of y.properties.filter($=>$.isIdentifier))c(h.type,h.location);for(let h of[...y.stream?[y.stream]:[],...y.streamCandidates??[]].filter($=>$.propertyCandidate===null)){let $=m.resolve(h.eventSource,h.stream),v=$.kind===fe.Unique?$.streams[0]:void 0,k=[...h.streamId===null?[]:[{mapping:h.streamId,target:v?.streamId}],...h.streamIdParts.map(E=>({mapping:E,target:v?.streamIdParts.find(b=>b.name===E.property)?.type}))];for(let{mapping:E,target:b}of k){if(E.source.kind!=="PathExpressionSyntax")continue;let P=p(y.properties,E.source.path);P!==null&&(P.type.name===b?.name&&(n.has(P.type.name)||i.has(P.type.name))||c(P.type,E.source.location,"a stream id route mapping"))}}for(let h of y.produces.filter($=>o.isEventProduction($,u))){if(h.for?.kind!=="PathExpressionSyntax")continue;let $=p(y.properties,h.for.path);$!==null&&!$.isIdentifier&&c($.type,h.for.location)}}for(let y of u.reactions.flatMap(h=>h.triggers)){if(y.source.kind!=="NamedTriggerSourceSyntax")continue;let $=o.resolve(y.source.name,u).declaration?.node,v=(Ae(y).data??[]).flatMap(E=>E.type===null?[]:[{kind:"PropertySyntax",name:E.name,type:E.type,isIdentifier:!1,location:E.location}]),k=[$?.kind==="EventSyntax"?$.properties:[],v];$?.kind!=="EventSyntax"&&!s.has(y.source.name)&&k.push(...a.get(y.source.name)??[]);for(let E of y.produces.filter(b=>o.isEventProduction(b,u))){if(E.for?.kind!=="PathExpressionSyntax")continue;let b=E.for.path,P=k.map(A=>p(A,b)).find(A=>A!==null&&(n.has(A.type.name)||i.has(A.type.name)));P!=null&&c(P.type,E.for.location)}}}}l(Un,"validateIdentifierCompliance");var ua=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]),et=class{static{l(this,"RefusalDeclarations")}application;slices;types;concepts;events;knownTypes;constructor(e){this.application=e,this.slices=new re(e).slices,this.types=ne(e.types),this.concepts=ne(e.concepts),this.knownTypes=new Set([...ua,...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 se(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:c,scope:p})=>i(c).map(m=>({node:m,slice:c,scope:p}))),o=this.slices.find(c=>c.slice===n)?.scope??[],s=l(c=>{let p=c.split("."),m=r.filter(y=>y.node.name===p.at(-1)),u=p.slice(0,-1);if(u.length>0)return m.filter(y=>u.length<=y.scope.length&&u.every((h,$)=>y.scope[y.scope.length-u.length+$]===h));for(let y=o.length;y>=0;y--){let h=m.filter($=>y<=$.scope.length&&o.slice(0,y).every((v,k)=>$.scope[k]===v));if(h.length>0)return h}return[]},"candidates"),a=s(e);if(a.length===0){let c=this.application.imports.filter(p=>p.qualifiedName.split(".").at(-1)===e);c.length===1&&(a=s(c[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(c=>c.name===o)??[];if(s.length!==1)return null;let a=s[0];if(r===i.length-1)return a;if(ua.has(a.type.name)||this.concepts.has(a.type.name)&&!this.application.types.some(c=>c.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 zn=class extends He{static{l(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(d.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(d.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 Up(){return!0}l(Up,"invocationHasNoDeclaredIdentity");function zp(t){let e=new Set,n=l((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}l(zp,"authorizationGatedSlices");function Vn(t,e){let n=new et(We(t));new zn(n,e).visitApplication(n.application);let i=zp(n.application);for(let{slice:r}of n.slices){let o=l(c=>n.resolve(c,r,p=>p.constraints),"constraintOf"),s=l((c,p)=>c===p||o(c)!==null&&o(c)?.node===o(p)?.node,"sameConstraint"),a=l((c,p)=>c.selector==="any"&&["any","validation","constraint"].includes(p.selector)||c.selector===p.selector&&(c.selector!=="constraint"||c.constraint===null||p.constraint!==null&&s(c.constraint,p.constraint)),"covers");for(let c of r.reactions.flatMap(p=>p.triggers).flatMap(p=>p.invokes)){let p=n.resolve(c.command,r,y=>y.commands),m=p!==null&&(p.node.authorize!==null||i.has(p.slice)),u=[];for(let y of c.onRefused??[]){if(u.some(E=>a(E,y))&&e.warning(d.UnreachableRefusalBranch,"This refusal selector is covered by an earlier branch; the first matching branch wins.",y.location),u.push(y),y.selector==="authorization"&&Up()&&m&&e.warning(d.AuthorizationRefusalWithoutIdentity,`Command '${c.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; Arc runs reactor commands as the system. Declare an invoking identity once supported (#383).`,y.location),y.constraint===null)continue;let h=o(y.constraint);if(h===null){e.error(d.UnknownRefusalConstraint,`Unknown or ambiguous refusal constraint '${y.constraint}'.`,y.location);continue}if(p===null||p.node.handler!==null)continue;let $=[h.node,...h.node.additionalRules];if($.some(E=>E.kind==="FileConstraintSyntax"))continue;let v=$.map(E=>E.kind==="FileConstraintSyntax"?null:n.event(E.event,h.slice)),k=p.node.produces.map(E=>n.event(E.event,p.slice));v.every(E=>E!==null)&&k.every(E=>E!==null)&&!v.some(E=>k.includes(E))&&e.warning(d.UnreachableRefusalBranch,`Constraint '${y.constraint}' targets none of the events produced by '${c.command}'.`,y.location)}}}}l(Vn,"validateReactionRefusals");function Qn(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=l(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(c=>Qn(c,{...e,isCollection:!1,isOptional:!1},n));return a.some(c=>c===void 0)?void 0:{canonical:`[${a.map(Gn).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(c=>{let p=n.property(s,c.name);return{name:c.name,value:p===null?void 0:Qn(c.value,p.type,n)}});return a.some(c=>c.value===void 0)?void 0:{canonical:`{${a.sort((c,p)=>c.name<p.name?-1:c.name>p.name?1:0).map(c=>`${JSON.stringify(c.name)}:${Gn(c.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)}l(Qn,"redeliveryValue");function Gn(t){return typeof t=="object"&&t!==null?"canonical"in t?t.canonical:_t(t):JSON.stringify(t)}l(Gn,"canonical");function dr(t,e,n,i){let r=Qn(t,n,i),o=Qn(e,n,i);return r===void 0||o===void 0?null:Gn(r)===Gn(o)}l(dr,"sameRedeliveryValue");function Kn(t,e){let n=new et(We(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(d.UnknownRedeliveryReaction,`Reaction '${o.reaction}' must resolve unambiguously and observe event '${o.eventType}'.`,o.location);continue}let c=r.given.filter(m=>n.event(m.eventType,i)===s).map(m=>Vp(m,o,s,n)),p=c.filter(m=>m===!0).length;p<2&&c.some(m=>m===null)?e.error(d.UnmatchedRedeliveredOccurrence,`Cannot locate redelivery of '${o.eventType}' uniquely: a given source or locator value is not decidable; state explicit concrete 'for' and values.`,o.location):p!==1&&e.error(d.UnmatchedRedeliveredOccurrence,`Redelivery of '${o.eventType}' matches ${p} given occurrences; use 'for' or values to identify exactly one.`,o.location)}}l(Kn,"validateSpecificationRedelivery");function Vp(t,e,n,i){let r=[];e.for!==null&&r.push(t.for===null?null:dr(e.for,t.for,null,i));for(let o of e.values){let s=t.values.filter(a=>a.property===o.property);r.push(s.length===1?dr(o.source,s[0].source,i.property(n.properties,o.property)?.type??null,i):null)}return r.includes(!1)?!1:r.includes(null)?null:!0}l(Vp,"matches");var ma=64;function ya(t,e){let n=[];for(let i of t.alternatives){let r=pr(i.condition);r!==null&&(r.length>0&&r.every(o=>n.some(s=>[...s].every(a=>o.has(a))))&&e.warning(d.UnreachableActionAlternative,`Alternative executing '${i.command}' is shadowed by earlier alternatives in this action`,i.location),n.push(...r))}}l(ya,"validateGuardedActionShadowing");function pr(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=pr(t.left),n=pr(t.right);return e===null||n===null?null:t.operator==="Or"?e.length+n.length>ma?null:[...e,...n]:e.length*n.length>ma?null:e.flatMap(i=>n.map(r=>new Set([...i,...r])))}l(pr,"normalize");var Qp=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Zn(t,e){let n=new et(t);for(let{slice:i}of n.slices)for(let r of i.screens)fr(r.directives,[],i,n,e)}l(Zn,"validateGuardedActions");function fr(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":Gp(a,s,n,i,r);break;case"ScreenSectionSyntax":fr(a.directives,s,n,i,r);break;case"ScreenTemplateReferenceSyntax":for(let c of a.slots)fr(c.directives,s,n,i,r);break}}l(fr,"validateContainer");function Sa(t,e,n){return n.resolve(t,e,i=>i.readModels)?.node.properties??null}l(Sa,"viewProperties");function Gp(t,e,n,i,r){let o=e.length===1?Sa(e[0].type.name,n,i):null;e.length!==1&&r.warning(d.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 ur(s.condition))ga(a.left,a.location,o,n,i,r);ha(s.command,s.arguments,o,n,i,r)}t.otherwise?.command!=null&&ha(t.otherwise.command,t.otherwise.arguments,o,n,i,r),ya(t,r)}l(Gp,"validateAction");function ha(t,e,n,i,r,o){let s=r.resolve(t,i,a=>a.commands)?.node;for(let a of e){let c=s?.properties.filter(m=>m.name===a.name);c?.length===0&&o.warning(d.UnknownActionArgumentProperty,`Command '${t}' has no argument property '${a.name}'`,a.location);let p=ga(a.binding,a.location,n,i,r,o,!0);c?.length===1&&p!==null&&c[0].type.isCollection!==p.type.isCollection&&o.warning(d.UnknownActionArgumentProperty,`Command argument '${t}.${a.name}' and subject field '${a.binding}' must have matching collection cardinality`,a.location)}}l(ha,"validateArguments");function ga(t,e,n,i,r,o,s=!1){if(!t.startsWith("item.")||n===null)return null;let a=t.substring(5).split(".");for(let[c,p]of a.entries()){let m=n.filter(y=>y.name===p);if(m.length===0||m.length===1&&m[0].type.isCollection&&(!s||c<a.length-1))return o.warning(d.UnknownActionSubjectField,`Unknown or collection-valued subject field '${t}' - guarded actions require an item field path`,e),null;if(m.length!==1)return null;if(c===a.length-1)return m[0];let u=m[0].type;if(n=r.types.get(u.name)?.properties??Sa(u.name,i,r),n===null)return(Qp.has(u.name)||r.application.concepts.some(y=>y.name===u.name)&&!r.application.types.some(y=>y.name===u.name))&&o.warning(d.UnknownActionSubjectField,`Subject field '${t}' continues past scalar '${p}'`,e),null}return null}l(ga,"validateItemPath");function ur(t){return t.kind==="ComparisonConditionSyntax"?[t]:[...ur(t.left),...ur(t.right)]}l(ur,"comparisons");function lt(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("")}l(lt,"ordinalIgnoreCaseKey");function mr(t){let e=Gt(t),n=l((h,$)=>h.map(v=>({syntax:v,rank:e.get(we([...$,v.name]))??Number.MAX_SAFE_INTEGER})).sort((v,k)=>v.rank-k.rank).map(v=>v.syntax),"ordered"),i=[],r=l((h,$)=>{let v=[...$,h.name];for(let k of n(h.slices,v))i.push({syntax:k,scope:[...v,k.name],identity:[...v.map(E=>`container:${E}`),`slice:${k.name}`],index:i.length});for(let k of n(h.features,v))r(k,v)},"feature");for(let h of n(t.modules,[]))for(let $ of n(h.features,[h.name]))r($,[h.name]);let o=new Map(i.map(h=>[h,new Set([...se(h.syntax).map($=>lt($.name)),...h.syntax.commands.flatMap($=>$.produces.map(v=>lt(v.event))),...h.syntax.reactions.flatMap($=>$.triggers.flatMap(v=>v.produces.map(k=>lt(k.event))))])])),s=new Map;for(let h of i)for(let $ of se(h.syntax)){let v=lt($.name);s.has(v)||s.set(v,h)}let a=new Map;for(let h of i){let $=we(h.scope);a.has($)||a.set($,h)}let c=new Map;for(let h of vt.for(t,e).edges.filter($=>$.kind==="decidesFrom"))for(let $ of h.evidence){let v=we([...h.consumer.scope,$.name.toLowerCase()]);c.has(v)||c.set(v,a.get(we(h.producer.scope)))}let p=[];for(let h of i){let $=new Set,v=Mn(h.syntax).references.filter(k=>k.timeline).map(k=>({event:k.name,location:k.location,readModel:k.targetKind==="ReadModel"}));for(let k of v){let E=lt(k.event),b=`${k.readModel?"ReadModel":"Event"}:${E}`;if($.has(b))continue;$.add(b);let P=k.readModel?c.get(we([...h.scope,k.event.toLowerCase()])):s.get(E);if(P===void 0||P===h)continue;let A=0;for(;A<h.scope.length&&A<P.scope.length&&h.identity[A]===P.identity[A];)A++;if(!(A===h.scope.length||A===P.scope.length)){if(k.readModel){let S=h.identity.slice(0,A+1),g=new Set(i.filter(x=>S.every((C,I)=>x.identity[I]===C)).flatMap(x=>[...o.get(x)]));if(_o(P.syntax,k.event).some(x=>x.timeline&&x.kind==="usesFactsFrom"&&x.targetKind==="Event"&&g.has(lt(x.name))))continue}p.push({...k,consumer:h,producer:P,container:we(h.identity.slice(0,A)),left:h.identity[A],right:P.identity[A]})}}}let m=l((h,$)=>h.consumer.index-$.consumer.index||h.location.line-$.location.line||h.location.column-$.location.column,"compare"),u=new Set,y=[];for(let h of new Set(p.map($=>$.container))){let $=p.filter(k=>k.container===h),v=new Map;for(let k of $)v.has(k.left)||v.set(k.left,new Set),v.has(k.right)||v.set(k.right,new Set),v.get(k.left).add(k.right);for(let k of Kt(v).filter(E=>E.length>1)){let E=new Set(k),b=$.filter(S=>E.has(S.left)&&E.has(S.right));b.forEach(S=>u.add(S));let P=b.filter(S=>S.consumer.index<S.producer.index).sort(m)[0];if(P===void 0)continue;let A=l(S=>Math.min(...b.flatMap(g=>[g.consumer,g.producer]).filter(g=>{let x=JSON.parse(h);return g.identity[x.length]===S}).map(g=>g.index)),"memberIndex");k.sort((S,g)=>A(S)-A(g)),y.push({edge:P,diagnostic:{severity:"information",code:d.TimelineCycleGroup,message:`Timeline group ${k.map(S=>`${S.startsWith("slice:")?"slice":h===we([])?"module":"feature"} '${S.slice(S.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 p){if(h.consumer.index>=h.producer.index||u.has(h))continue;let $=h.consumer.scope.slice(0,-1),k=h.producer.scope.length>h.consumer.scope.length&&$.every((b,P)=>h.producer.scope[P]===b)?" The producer is in the consumer's own sub-feature; this cannot be fixed by reordering.":" Consider drawing the producer before the consumer.",E=h.readModel?`reads read model '${h.event}' built by`:`uses event '${h.event}' produced by`;y.push({edge:h,diagnostic:{severity:"information",code:d.EventFromLaterSlice,message:`Slice '${h.consumer.syntax.name}' ${E} slice '${h.producer.syntax.name}' drawn after it.${k}`,location:h.location}})}return y.sort((h,$)=>m(h.edge,$.edge)).map(h=>h.diagnostic)}l(mr,"timelineOrderDiagnostics");function Ye(t,e,n=ot,i=!0,r,o){let s=pt(t,!1,e),a=jn(s,e,o);a.scope=n,a.streamCandidates=r??bt.capture([s],n,o);let c=Bn(a,s,n);if(i){Ln(c,a),sn(c,a),qn(c,a),Nn(c,a),Yn(c,a),Wn(c,a),Un(c,a),Vn(c,a),Kn(c,a),Zn(c,a),c=cn(c,a),kt.validate(c,a);for(let p of an(c))a.information(p.code,p.message,p.location);for(let p of mr(c))a.information(p.code,p.message,p.location)}return{value:c,diagnostics:a.diagnostics,triggerData:a.triggerData,inputUses:a.inputUses,success:!a.diagnostics.some(p=>p.severity==="error")}}l(Ye,"parseForAuthoring");function Y1(t){return t===d.LegacyOptionalSuffix||t===d.RedundantEventId}l(Y1,"isQuickFixDiagnostic");function yr(t,e){return e.code!==d.LegacyOptionalSuffix?0:/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?\?/u.exec(t.slice(e.location.column-1))?.[0].length??0}l(yr,"legacyOptionalTypeLength");function W1(t,e={}){let n=Ye(t,void 0,e.placement);if(!n.success)return()=>[];let i=pt(t),r=new Map;new class extends He{visitEvent(E){r.set(E.location.line,E)}}().visitApplication(n.value);let s=new Map,a=new Map,c=new Map,p;for(let E of i)p=r.get(E.number)??p,p!==void 0&&c.set(E.number,p);for(let E of n.diagnostics){s.set(E.code,(s.get(E.code)??0)+1);let b=i[E.location.line-1],P=yr(b.raw,E);if(P>0)a.set(b.number,{line:b.number,fix:{diagnosticCode:E.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:b.startOffset+E.location.column+P-2,length:1,text:" optional"}]}});else if(E.code===d.RedundantEventId&&It(b.raw)<0){let A=c.get(b.number);if(A?.id!==A?.name||A===void 0)continue;a.set(b.number,{line:b.number,fix:{diagnosticCode:E.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:b.startOffset,length:(i[b.number]?.startOffset??t.length)-b.startOffset,text:""}]},change:{node:A,replacement:{...A,id:null}}})}}let m=[...a.values()].filter(E=>E.fix.diagnosticCode===d.LegacyOptionalSuffix),u=Jt(n),y=new Map,h,$=!1,v,k=l((E,b)=>{let P=xa(t,E.edits);if(P===void 0)return;let A=Ye(P,void 0,e.placement);if(!(!A.success||Jt(A)!==(b===void 0?u:Jt(n,[b]))))return A.diagnostics.filter(S=>S.code===E.diagnosticCode).length===(s.get(E.diagnosticCode)??0)-E.edits.length?E:void 0},"verify");return(E,b)=>{let P=typeof E=="number"||E===void 0?void 0:E,A=P===void 0?b===void 0||b===d.LegacyOptionalSuffix:P.some(C=>C.diagnosticCode===d.LegacyOptionalSuffix);if(A&&!$&&(m.length>0&&(v=k({diagnosticCode:d.LegacyOptionalSuffix,title:"Use 'optional' throughout this document",scope:"document",edits:m.flatMap(C=>C.fix.edits)})),$=!0),P!==void 0){if(h===void 0){h=new Map;let I=i.flatMap(N=>a.has(N.number)?[a.get(N.number)]:[]),w=I.flatMap(N=>N.fix.edits),j=xa(t,w);if(w.length>0&&j!==void 0){let N=Ye(j,void 0,e.placement),L=I.flatMap(q=>q.change===void 0?[]:[q.change]);if(N.success&&Jt(N)===Jt(n,L)){let q=new Map,D=new Map;for(let F of N.diagnostics)q.set(F.code,(q.get(F.code)??0)+1);for(let F of I)D.set(F.fix.diagnosticCode,(D.get(F.fix.diagnosticCode)??0)+F.fix.edits.length);if([...D].every(([F,U])=>(q.get(F)??0)===(s.get(F)??0)-U))for(let F of I)h.set(F.line,F.fix)}}}let C=new Map;for(let I of P){let w=h.get(I.line);w?.diagnosticCode===I.diagnosticCode&&C.set(I.line,w)}return[...C.values(),...A&&v!==void 0?[v]:[]]}let S=typeof E=="number"?E:void 0,g=S===void 0?void 0:a.get(S),x;return g!==void 0&&S!==void 0&&(b===void 0||g.fix.diagnosticCode===b)&&(y.has(S)||(y.size===32&&y.delete(y.keys().next().value),y.set(S,k(g.fix,g.change))),x=y.get(S)),[x,A?v:void 0].filter(C=>C!==void 0)}}l(W1,"prepareQuickFixes");function Jt(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)}l(Jt,"verificationShape");function xa(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("")}l(xa,"applyQuickFixEdits");var Et=class{static{l(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(p=>p.source.streams).filter(p=>p.name===n),o=i.length>1||r.length>1,s=!this.complete||i.some(p=>!p.placementResolved),a=o?"ambiguous":s?"incomplete":i.length===1&&(n===void 0||r.length===1)?"unique":"notFound",c=[];return i.length>1&&c.push("Multiple physical parent sources claim the exact name."),r.length>1&&c.push("Multiple physical streams claim the exact parent and local name."),i.some(p=>!p.placementResolved)&&c.push("A physical parent has unresolved import placement."),this.complete||c.push("Physical source extent or placement is incomplete; missing declarations cannot be excluded."),{state:a,sources:i.map(p=>p.source),streams:r,reasons:c}}};var Kp=de("^[A-Za-z_]\\w*$"),Ne=l((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),G=l(t=>{throw new ie(t)},"refuse"),tt=l((t,e,n)=>{if(!Array.isArray(t))return G(n);for(let i=0;i<t.length;i++)Ne(t[i],e)||G(n)},"collection");function Ct(t){if(t.kind==="ConceptSyntax"){let e=t;for(let n of e.validations??[])n.kind==="DeclarativeValidateSyntax"&&n.rules.some(i=>i.implementation!=null)&&G("Implementation wrappers on named rules are supported only on commands.")}if(t.kind==="ValidationRuleSyntax"){let e=t;e.implementation!=null&&(Ne(e.implementation,"ImplementationSyntax")||G("A named rule requires an ImplementationSyntax wrapper."),(e.rule!=="Rule"||e.value?.kind!=="PathExpressionSyntax"||!Ne(e.value,"PathExpressionSyntax")||typeof e.value.path!="string"||Kp.exec(e.value.path)?.[0]!==e.value.path)&&G("An implementation wrapper requires a valid named rule."),e.file!=null&&e.code!=null&&G("A named rule has at most one file or inline payload."),e.file!=null&&(!Ne(e.file,"FileReferenceSyntax")||typeof e.file.path!="string")&&G("A named rule file requires a FileReferenceSyntax payload with a string path."),e.code!=null&&(!Ne(e.code,"CodeBlockSyntax")||typeof e.code.language!="string"||typeof e.code.code!="string")&&G("A named rule inline payload requires a CodeBlockSyntax with string language and code."),Ct(e.implementation))}if(t.kind==="ProducesSyntax"){let e=t,n=e.inlineOperation;if(n!=null){e.inlineEvent!=null&&G("A production cannot declare both an event and an operation."),(e.when!=null||e.event!==n.name||e.for!=null||(e.tags??[]).length>0)&&G("An inline operation requires a matching unconditional target without event metadata."),tt(n.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),tt(e.mappings,"PropertyMappingSyntax","Production mappings must be a collection of mappings."),n.inputs.length!==e.mappings.length&&G("Inline operation inputs and mappings must correspond in order.");for(let i=0;i<n.inputs.length;i++)n.inputs[i].name!==e.mappings[i].property&&G("Inline operation inputs and mappings must correspond in order.")}}if(t.kind==="OperationPhaseSyntax"){let e=t;e.file!=null&&e.code!=null&&G("An operation phase has at most one file or inline payload."),e.implementation!=null&&Ct(e.implementation)}if(t.kind==="HandlerSyntax"){let e=t;e.implementation!=null&&e.file!=null&&e.code!=null&&G("A handler has at most one file or inline payload.")}if(t.kind==="ImplementationSyntax"){let e=t;tt(e.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let n=0;n<e.hints.length;n++)Ct(e.hints[n])}if(t.kind==="ImplementationHintSyntax"){let e=t;(typeof e.text!="string"||kn(e.text))&&G("An implementation hint must be nonblank.")}hr(t)}l(Ct,"validateSyntaxInvariants");function hr(t){let e=l(i=>{Ii(i)||G("Event source and stream names must be identifiers.")},"name"),n=l((i,r)=>{tt(r,"PropertyMappingSyntax","Stream id part mappings must be a collection."),i!==null&&r.length>0&&G("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&&tt(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()==="")&&G("A rename pin must be nonempty.");let r=i.kind==="EventSourceSyntax"?i.identifier:i.streamId;r!==null&&!Ne(r,"TypeRefSyntax")&&G("Source identifiers and stream ids require type reference nodes."),r!==null&&(r.isCollection||r.isOptional)&&G("Source identifiers and stream ids require nonoptional scalar type references."),r!==null&&!$n(r.name)&&G("Source identifiers and stream ids require an exact type reference name."),i.kind==="EventSourceSyntax"?tt(i.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements."):(tt(i.streamIdParts,"EventStreamIdPartSyntax","Stream id parts must be a collection."),i.streamId!==null&&i.streamIdParts.length>0&&G("A stream cannot declare both scalar and composite stream ids."),i.streamIdParts.forEach(o=>hr(o)))}if(t.kind==="EventStreamIdPartSyntax"){let i=t;e(i.name),Ne(i.type,"TypeRefSyntax")||G("A stream id part requires a type."),(i.type.isOptional||i.type.isCollection)&&G("Source identifiers and stream ids require nonoptional scalar type references."),$n(i.type.name)||G("Source identifiers and stream ids require an exact type reference name.")}if(t.kind==="CommandSyntax"){let i=t;i.stream?.propertyCandidate!=null&&G("The authoritative command stream cannot contain an ambiguous property candidate."),i.stream!=null&&!Ne(i.stream,"CommandStreamSyntax")&&G("The authoritative command stream must be a command stream node."),i.streamCandidates!==void 0&&tt(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(hr(s),s.propertyCandidate===null&&i.stream==null&&G("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&&G("An ambiguous property is owned only by its stream candidate.")}}if(t.kind==="SpecificationEventSyntax"){let i=t;i.stream!=null&&i.noStream!=null&&G("An event occurrence cannot declare both stream and no stream."),i.stream!=null&&!Ne(i.stream,"SpecificationStreamSyntax")&&G("A specification stream requires a specification stream node."),i.noStream!=null&&!Ne(i.noStream,"SpecificationNoStreamSyntax")&&G("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"&&G("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"&&G("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)&&G("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}l(hr,"validateSourceStream");var ze={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","ChildrenSyntax","ClaimConditionSyntax","ClearMappingSyntax","ClearWithSyntax","CloseDialogActionSyntax","CodeBlockSyntax","CodeValidateSyntax","CommandSyntax","CommandStreamSyntax","ComparisonConditionSyntax","CompositeKeySyntax","ConceptAttributeSyntax","ConceptSyntax","ConcurrencySyntax","ConfirmActionSyntax","ContextExpressionSyntax","ContributionSyntax","CountMappingSyntax","DeclarativeValidateSyntax","DecrementMappingSyntax","DialogTemplateSyntax","DomainSyntax","EnvironmentExpressionSyntax","EventContextExpressionSyntax","EventInteractionTriggerSyntax","EventSourceIdExpressionSyntax","EventSourceSyntax","EventStreamIdPartSyntax","EventStreamSyntax","EventSpecSyntax","EventSyntax","EverySyntax","ExecuteCommandActionSyntax","ExpressionKeySyntax","FeatureSyntax","FileConstraintSyntax","FileImportSyntax","FileReferenceSyntax","FormFieldSyntax","FormPopulateFromItemSyntax","FormPopulateViaQuerySyntax","FormSyntax","FromSyntax","HandlerSyntax","ImplementationSyntax","ImplementationHintSyntax","SystemSyntax","OperationSyntax","OperationPhaseSyntax","SpecificationExampleSyntax","SpecificationOperationFailureSyntax","SpecificationOperationSyntax","SpecificationCompensatedSyntax","ImportSyntax","IncrementMappingSyntax","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","ProducesSyntax","ProjectionEntersOnSyntax","ProjectionSyntax","ProjectionVariantSyntax","PropertyMappingSyntax","PropertySyntax","PropertyResponseSourceSyntax","ResponseFieldSyntax","ScalarCommandResponseSyntax","RecordCommandResponseSyntax","ScalarSpecificationReturnSyntax","RecordSpecificationReturnSyntax","QueryParameterSyntax","QuerySyntax","RaiseTriggerActionSyntax","RawExpressionSyntax","ReactionSyntax","ReactionTriggerSyntax","RefusalExpressionSyntax","ReadModelSyntax","ReadsSyntax","ReducerRuleSyntax","ReducerSyntax","RefreshQueryActionSyntax","RemoveViaJoinSyntax","RemoveWithSyntax","RequirementSyntax","RoleConditionSyntax","ScheduleTriggerSourceSyntax","ScreenActionSyntax","ScreenGuardedActionSyntax","ScreenActionAlternativeSyntax","ScreenActionOtherwiseSyntax","ScreenBehaviorSyntax","ScreenCodeSyntax","ScreenColumnSyntax","ScreenDataSyntax","ScreenFieldSyntax","ScreenNavigateSyntax","ScreenSectionSyntax","ScreenSlotSyntax","ScreenSummarySyntax","ScreenSyntax","ScreenTableSyntax","ScreenTemplateReferenceSyntax","ScreenTemplateSyntax","ScreenTitleSyntax","ScreenUsesBehaviorSyntax","SeedEventSyntax","SeedGroupSyntax","SeedSyntax","SetMappingSyntax","SetStateActionSyntax","SliceSyntax","SlotSyntax","SourceItemExpressionSyntax","SpecificationAbsentReadModelSyntax","SpecificationCallerClaimSyntax","SpecificationCallerSyntax","SpecificationCaptureSyntax","SpecificationClockSyntax","SpecificationCommandSyntax","SpecificationDeniedSyntax","SpecificationErrorSyntax","SpecificationEventSyntax","SpecificationNoResultSyntax","SpecificationStreamSyntax","SpecificationNoStreamSyntax","SpecificationQueryResultSyntax","SpecificationQuerySyntax","SpecificationReadModelSyntax","SpecificationRedeliverySyntax","SpecificationSyntax","SpecificationTriggerSyntax","SpecificationWhenQuerySyntax","StringsExpressionSyntax","SubtractMappingSyntax","TagSyntax","TemplateExpressionSyntax","TemplateInterpolationSyntax","TemplateTextSyntax","ThemeSyntax","TriggerDataSyntax","TriggerSyntax","TypeRefSyntax","TypeSyntax","UiProfileSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","DependsOnSyntax","UsesBehaviorSyntax","ValidationRuleSyntax","VariantSyntax"],names:["property","value","autoMap","mappings","authentication","behaviors","concepts","domain","eventSources","examples","fileImports","imports","layouts","modules","personas","policies","seeds","sourceOptions","numericMode","systems","themes","triggers","types","uiProfiles","triggerName","children","gap","syntaxKind","height","root","width","grow","name","span","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","blocks","claim","matches","matchesSubject","arguments","onFailure","onResult","onSuccess","code","language","authorize","concurrency","handler","produces","reads","response","stream","streamCandidates","validations","eventSource","propertyCandidate","streamId","streamIdParts","left","operator","right","parts","reason","attributes","values","eventSourceType","eventStreamId","eventStreamType","eventTypes","message","messageIsLiteral","path","contributionPoint","label","navigate","requirements","rules","arrangement","slots","usedBehaviors","eventName","id","identifier","streams","documentation","generation","hasGenerationMarker","includeChildren","command","contributions","dependsOn","features","isPlacement","slices","additionalRules","ignoreCasing","releasedBy","pattern","composeUsing","by","query","fields","for","onSubmit","populate","events","parentKey","implementation","hints","text","compensate","execute","inputs","uses","generatedValues","operation","qualifiedName","binding","actions","condition","trigger","amount","unit","onRefused","acknowledge","constraint","selector","on","items","literalType","dialogTemplates","forms","screenTemplates","screen","operand","level","dialogTemplate","members","hidden","sizeHeight","sizeWidth","slotName","x","y","inlineEvent","inlineOperation","readModel","sequence","entersOn","isGenerated","isIdentifier","filters","isObservable","performer","returnType","scope","where","data","invokes","member","severity","role","dayOfMonth","dayOfWeek","time","alternatives","otherwise","outcome","behavior","directives","target","columns","rowClick","fitsSlot","eventSourceId","groups","captures","commands","constraints","operations","projections","queries","reactions","readModels","reducers","screens","specifications","contributes","authenticated","claims","roles","capture","record","instant","commandType","inlineProperty","eventType","noStream","exactly","results","reaction","given","givenCaller","givenCaptures","givenClock","givenOperationFailures","givenReadModels","thenAbsentReadModels","thenCompensated","thenDenied","thenErrors","thenEvents","thenEventsInAnyOrder","thenNoEvents","thenNoResult","thenOperations","thenQueries","thenReadModels","thenResults","thenReturns","whenAppended","whenCapture","whenClock","whenQuery","whenRedelivered","whenTrigger","compatibleWith","isCollection","isOptional","defaultSizeClass","layout","packages","platforms","theme","additionalProperties","rule","places"],rules:[["string"],["ref",26,42,49,50,52,92,93,105,107,128,131,168,188,191],["object",[[0,0,!0],[1,1,!0]]],["enum","Inherit","Disabled","Enabled"],["ref",0,29,44,46,81,164,189],["array",4],["object",[[2,3,!0],[3,5,!1]]],["ref",10],["null"],["union",7,8],["ref",14],["array",10],["ref",39],["array",12],["ref",48],["union",14,8],["ref",53],["array",16],["ref",76],["array",18],["ref",63],["array",20],["ref",80],["array",22],["ref",91],["array",24],["union",25,8],["ref",97],["array",27],["ref",109],["array",29],["union",30,8],["ref",112],["array",32],["ref",163],["array",34],["union",35,8],["enum","legacy","exact"],["object",[[18,37,!0]]],["ref",73],["array",39],["ref",194],["array",41],["union",42,8],["ref",196],["array",44],["union",45,8],["ref",198],["array",47],["union",48,8],["ref",199],["array",50],["union",51,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,26,!1],[13,28,!1],[14,31,!1],[15,33,!1],[16,36,!1],[17,38,!1],[19,40,!1],[20,43,!1],[21,46,!1],[22,49,!1],[23,52,!1]]],["object",[[24,0,!0]]],["ref",4,6],["array",55],["integer",-2147483648,2147483647],["union",57,8],["enum","Flat","Row","Column","Grid"],["object",[[25,56,!1],[26,58,!1],[27,59,!0]]],["union",0,8],["object",[[28,61,!1],[29,55,!0],[30,61,!1]]],["boolean"],["object",[[31,63,!1],[28,58,!1],[32,0,!0],[33,58,!1],[30,58,!1]]],["enum","Flow","Freeform"],["ref",5],["array",66],["union",67,8],["union",55,8],["ref",205],["array",70],["union",71,8],["object",[[34,65,!0],[35,68,!1],[29,69,!1],[36,72,!1]]],["object",[]],["object",[[37,61,!1],[32,0,!0]]],["ref",9],["array",76],["object",[[38,77,!1]]],["ref",96,111],["object",[[39,79,!0]]],["object",[[32,0,!0],[1,0,!0]]],["ref",197],["union",82,8],["object",[[32,0,!0],[40,83,!1]]],["ref",83],["array",85],["ref",64],["union",87,8],["ref",13],["array",89],["object",[[41,86,!1],[42,61,!1],[43,88,!1],[32,61,!1],[44,58,!1],[45,90,!1]]],["enum","Click","DoubleClick","Select","Submit","Change","Load","Unload","Enter","Leave","Unknown"],["object",[[27,92,!0]]],["ref",117],["array",94],["ref",190],["array",96],["union",97,8],["ref",25],["union",99,8],["object",[[46,0,!0],[3,95,!1],[47,98,!1],[48,100,!1]]],["ref",16],["array",102],["ref",18,22],["array",104],["object",[[49,103,!1],[50,0,!0],[51,105,!1],[0,0,!0]]],["ref",24],["array",107],["object",[[0,0,!0],[52,1,!0],[53,108,!1]]],["object",[[49,103,!1],[51,105,!1],[0,0,!0]]],["ref",20],["array",111],["object",[[54,112,!1],[27,0,!0]]],["array",0],["object",[[55,0,!0],[52,1,!0],[56,114,!1]]],["ref",17],["array",116],["ref",19],["array",118],["ref",21],["union",120,8],["object",[[49,103,!1],[25,117,!1],[57,61,!1],[51,105,!1],[32,0,!0],[58,119,!1],[52,121,!1],[17,38,!1]]],["object",[[59,0,!0],[60,0,!0]]],["enum","PropertyChanged","Added","Removed","Changed","LogicalOr","LogicalAnd","ValueTransition","Expression"],["object",[[61,61,!1],[62,61,!1],[63,114,!1],[27,124,!0],[64,61,!1]]],["object",[[0,61,!1]]],["ref",1,27,30,58,69,89,101,116,137,138],["array",127],["object",[[2,3,!0],[65,128,!1],[50,1,!0],[0,0,!0]]],["union",1,8],["object",[[66,0,!0],[67,130,!1],[68,63,!0]]],["object",[[0,0,!0]]],["object",[[46,0,!0]]],["ref",82],["array",134],["ref",31,41,59,99,100,103,104,127,136,165],["array",136],["object",[[69,135,!1],[70,137,!1],[71,137,!1],[72,137,!1]]],["object",[[73,0,!0],[74,0,!0]]],["ref",32],["object",[[73,140,!0]]],["ref",11],["union",142,8],["ref",40],["union",144,8],["ref",70],["union",146,8],["ref",113],["array",148],["ref",118],["array",150],["ref",133],["array",152],["union",153,8],["ref",121,122],["union",155,8],["ref",35],["union",157,8],["array",157],["ref",33,45],["array",160],["object",[[75,143,!1],[76,145,!1],[42,61,!1],[77,147,!1],[32,0,!0],[78,149,!1],[63,151,!1],[79,154,!1],[80,156,!1],[81,158,!1],[82,159,!1],[83,161,!1]]],["union",150,8],["union",94,8],["object",[[84,0,!0],[85,163,!1],[81,0,!0],[86,164,!1],[87,95,!1]]],["enum","Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Contains","StartsWith"],["object",[[88,0,!0],[89,166,!0],[90,1,!0]]],["ref",90],["array",168],["object",[[91,169,!1],[40,0,!0]]],["object",[[32,0,!0],[92,61,!1]]],["ref",38],["array",172],["union",161,8],["object",[[93,173,!1],[43,88,!1],[32,0,!0],[40,0,!0],[83,174,!1],[94,114,!1]]],["object",[[84,63,!0],[95,61,!1],[96,61,!1],[97,61,!1],[98,114,!1]]],["object",[[69,135,!1],[99,0,!0],[100,63,!0],[70,137,!1],[71,137,!1],[72,137,!1]]],["object",[[101,0,!0]]],["ref",151],["union",179,8],["object",[[102,0,!0],[103,61,!1],[104,180,!1],[44,58,!1]]],["ref",139],["array",182],["union",183,8],["ref",204],["array",185],["object",[[105,184,!1],[106,186,!1]]],["ref",7],["union",188,8],["ref",167],["array",190],["ref",203],["array",192],["object",[[107,189,!1],[5,11,!1],[32,0,!0],[108,191,!1],[109,193,!1]]],["object",[[32,0,!0]]],["object",[[110,0,!0]]],["ref",55],["array",197],["object",[[42,61,!1],[111,61,!1],[112,83,!1],[32,0,!0],[113,198,!1]]],["object",[[32,0,!0],[40,82,!0]]],["ref",54],["array",201],["object",[[42,61,!1],[111,61,!1],[32,0,!0],[86,83,!1],[87,202,!1]]],["object",[[46,0,!0],[57,130,!1]]],["integer",0,4294967295],["object",[[42,61,!1],[114,61,!1],[43,88,!1],[115,205,!1],[116,63,!1],[111,61,!1],[32,0,!0],[63,151,!1],[47,98,!1]]],["object",[[2,3,!0],[117,63,!0],[3,5,!1]]],["object",[[69,135,!1],[118,0,!0],[70,137,!1],[71,137,!1],[72,137,!1]]],["object",[[61,1,!0]]],["ref",43],["array",210],["union",211,8],["ref",202],["array",213],["ref",61],["array",215],["ref",166],["array",217],["object",[[75,143,!1],[5,11,!1],[119,212,!1],[120,214,!1],[42,61,!1],[9,19,!1],[121,216,!1],[10,21,!1],[122,63,!0],[32,0,!0],[123,218,!1],[109,193,!1]]],["ref",62,200,201],["array",220],["object",[[124,221,!1],[43,87,!0],[125,63,!0],[99,61,!1],[32,0,!0],[126,114,!1]]],["object",[[127,0,!0]]],["object",[[128,61,!1],[59,61,!1],[103,61,!1],[0,0,!0]]],["object",[[129,61,!1],[130,0,!0]]],["ref",65],["array",226],["ref",66,67],["union",228,8],["object",[[5,11,!1],[131,227,!1],[132,0,!0],[32,0,!0],[133,180,!1],[134,229,!1],[109,193,!1]]],["ref",56],["array",231],["ref",37,60],["union",233,8],["object",[[135,232,!1],[57,234,!1],[3,5,!1],[136,130,!1]]],["union",140,8],["ref",71],["union",237,8],["object",[[73,236,!1],[43,88,!1],[137,238,!1]]],["ref",72],["array",240],["object",[[138,241,!1]]],["object",[[139,0,!0]]],["object",[[42,61,!1],[32,0,!0]]],["ref",75],["union",245,8],["object",[[140,246,!1],[42,61,!1],[141,246,!1],[142,151,!1],[32,0,!0],[143,0,!0]]],["object",[[73,236,!1],[42,61,!1],[43,88,!1],[137,238,!1]]],["object",[[42,61,!1],[132,130,!1],[144,95,!1],[32,0,!0],[40,0,!0],[94,95,!1]]],["object",[[145,0,!0]]],["object",[[145,0,!0],[94,95,!1]]],["object",[[146,0,!0]]],["object",[[147,0,!0],[32,0,!0]]],["ref",3,15,51,84],["object",[[148,137,!1],[149,61,!1],[150,254,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[151,57,!0],[152,256,!0]]],["ref",87],["array",258],["object",[[118,0,!0],[3,95,!1],[153,259,!1]]],["object",[[154,63,!0],[155,61,!1],[78,149,!1],[156,0,!0]]],["object",[[2,3,!0],[46,0,!0],[3,5,!1]]],["ref",88],["array",263],["object",[[135,264,!1],[157,0,!0],[0,0,!0]]],["object",[[61,1,!0],[0,0,!0]]],["array",1],["object",[[158,267,!1]]],["union",0,63,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[159,271,!0],[1,272,!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",[[159,274,!0],[1,275,!0]]],["union",269,270,273,276],["object",[[1,277,!1]]],["ref",36,94],["enum","And","Or"],["object",[[88,279,!0],[89,280,!0],[90,279,!0]]],["ref",8,28,95,102,140],["object",[[88,282,!0],[89,280,!0],[90,282,!0]]],["object",[[88,79,!0],[89,280,!0],[90,79,!0]]],["ref",47],["array",285],["union",286,8],["ref",68],["array",288],["union",289,8],["ref",158],["array",291],["object",[[75,143,!1],[5,11,!1],[119,212,!1],[120,214,!1],[42,61,!1],[160,287,!1],[9,19,!1],[121,216,!1],[10,21,!1],[161,290,!1],[122,63,!0],[32,0,!0],[162,292,!1],[109,193,!1]]],["object",[[69,135,!1],[70,137,!1],[71,137,!1],[72,137,!1],[163,0,!0]]],["object",[[2,3,!0],[65,128,!1],[0,0,!0]]],["object",[[164,282,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[69,135,!1],[165,297,!0],[99,0,!0],[100,63,!0],[70,137,!1],[71,137,!1],[72,137,!1]]],["object",[[69,135,!1],[166,0,!0],[70,137,!1],[71,137,!1],[72,137,!1]]],["ref",106],["array",300],["object",[[167,301,!1]]],["object",[[32,0,!0],[1,1,!0]]],["object",[[73,236,!1],[43,88,!1]]],["object",[[42,61,!1],[32,0,!0],[15,114,!1]]],["object",[[168,63,!1],[169,61,!1],[170,61,!1],[171,0,!0],[172,58,!1],[173,58,!1]]],["union",282,8],["object",[[73,236,!1],[149,307,!1],[43,88,!1],[32,0,!0]]],["ref",57],["union",309,8],["ref",74],["union",311,8],["union",279,8],["object",[[46,0,!0],[132,130,!1],[174,310,!1],[175,312,!1],[3,95,!1],[47,98,!1],[48,313,!1]]],["object",[[2,3,!0],[65,128,!1],[43,88,!1],[57,234,!1],[32,0,!0],[176,61,!1],[177,61,!1],[17,38,!1]]],["ref",114],["array",316],["object",[[65,128,!1],[178,317,!1],[32,0,!0]]],["object",[[0,0,!0],[52,1,!0]]],["object",[[179,63,!1],[180,63,!1],[32,0,!0],[40,82,!0]]],["ref",119],["object",[[32,0,!0],[52,321,!0],[40,83,!1]]],["object",[[52,321,!0]]],["ref",120],["array",324],["object",[[131,325,!1]]],["object",[[1,1,!0]]],["object",[[131,95,!1]]],["object",[[32,0,!0],[52,130,!1],[40,82,!0]]],["ref",125],["union",330,8],["array",330],["ref",108],["union",333,8],["object",[[75,143,!1],[129,331,!1],[42,61,!1],[181,332,!1],[182,63,!1],[32,0,!0],[183,334,!1],[184,82,!0],[185,61,!1]]],["object",[[69,135,!1],[70,137,!1],[71,137,!1],[72,137,!1],[150,0,!0]]],["ref",130],["array",337],["object",[[42,61,!1],[32,0,!0],[21,338,!1],[186,313,!1]]],["ref",195],["array",340],["ref",86],["array",342],["union",343,8],["union",149,8],["ref",85,98,141],["object",[[73,236,!1],[187,341,!1],[42,61,!1],[43,88,!1],[188,344,!1],[78,345,!1],[79,154,!1],[52,346,!0]]],["object",[[189,0,!0]]],["object",[[42,61,!1],[43,88,!1],[32,0,!0],[63,151,!1]]],["object",[[37,61,!1],[129,61,!1],[176,0,!0]]],["object",[[73,236,!1],[42,61,!1],[46,0,!0],[43,88,!1]]],["ref",134],["array",352],["object",[[42,61,!1],[32,0,!0],[176,0,!0],[106,353,!1]]],["object",[[69,135,!1],[70,137,!1],[71,137,!1],[72,137,!1],[130,0,!0]]],["object",[[46,0,!0],[57,130,!1],[136,130,!1]]],["enum","Error","Information","Warning"],["object",[[149,279,!0],[99,61,!1],[190,357,!0]]],["object",[[191,0,!0]]],["enum","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["union",360,8],["string","^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]{1,7})?$"],["object",[[192,58,!1],[193,361,!1],[194,362,!0]]],["object",[[118,0,!0],[103,61,!1],[104,180,!1]]],["ref",144],["array",365],["ref",145],["union",367,8],["object",[[195,366,!1],[103,0,!0],[104,180,!1],[196,368,!1]]],["object",[[69,135,!1],[118,0,!0],[149,279,!0]]],["enum","Hidden","Execute","Unknown"],["object",[[69,135,!1],[118,61,!1],[197,371,!0]]],["object",[[198,10,!0]]],["object",[[103,61,!1],[0,0,!0]]],["object",[[129,61,!1],[130,0,!0],[40,82,!0]]],["object",[[103,0,!0],[0,0,!0]]],["object",[[129,61,!1],[163,0,!0]]],["ref",142,143,146,147,149,151,152,153,154,156,157,159,160],["array",378],["object",[[199,379,!1],[32,0,!0]]],["ref",150],["array",381],["object",[[131,382,!1],[200,0,!0]]],["object",[[199,379,!1],[43,88,!1],[32,0,!0]]],["ref",148],["array",385],["object",[[5,11,!1],[201,386,!1],[202,180,!1],[200,0,!0],[109,193,!1]]],["ref",153],["array",388],["object",[[32,0,!0],[108,389,!1]]],["object",[[107,189,!1],[5,11,!1],[203,61,!1],[32,0,!0],[108,191,!1],[109,193,!1]]],["object",[[143,192,!0]]],["object",[[46,0,!0],[63,95,!1]]],["ref",161],["array",394],["object",[[204,0,!0],[135,395,!1]]],["ref",162],["array",397],["object",[[205,398,!1]]],["object",[[69,135,!1],[70,137,!1],[71,137,!1],[72,137,!1],[200,0,!0],[1,0,!0]]],["ref",23],["array",401],["ref",34],["array",403],["array",309],["array",311],["ref",115],["array",407],["ref",126],["array",409],["ref",129],["array",411],["ref",132],["array",413],["union",414,8],["ref",135],["array",416],["union",417,8],["ref",155],["array",419],["ref",185],["array",421],["enum","StateChange","StateView","Automation","Translate"],["object",[[206,402,!1],[207,404,!1],[208,221,!1],[42,61,!1],[135,405,!1],[9,19,!1],[43,88,!1],[32,0,!0],[209,406,!1],[210,408,!1],[211,410,!1],[212,412,!1],[213,415,!1],[214,418,!1],[215,420,!1],[216,422,!1],[40,423,!0]]],["object",[[217,61,!1],[32,0,!0]]],["object",[[57,1,!0],[32,0,!0]]],["object",[[40,0,!0],[1,0,!0]]],["ref",170],["array",428],["object",[[218,63,!0],[219,429,!1],[220,114,!1]]],["object",[[221,0,!0],[222,95,!1]]],["object",[[223,0,!0]]],["object",[[224,0,!0],[132,130,!1],[144,95,!1],[225,61,!1],[94,95,!1]]],["object",[[32,61,!1]]],["ref",180],["union",435,8],["ref",179],["union",437,8],["object",[[226,0,!0],[132,130,!1],[225,61,!1],[227,436,!1],[81,438,!1],[94,95,!1]]],["object",[[84,0,!0],[81,0,!0],[86,164,!1],[87,95,!1]]],["object",[[228,63,!0],[63,95,!1]]],["ref",181],["array",442],["object",[[69,95,!1],[228,63,!0],[130,0,!0],[229,443,!1]]],["object",[[228,63,!0],[225,61,!1],[32,0,!0],[63,95,!1]]],["object",[[226,0,!0],[132,130,!1],[230,0,!0],[94,95,!1]]],["ref",177],["array",447],["ref",171],["union",449,8],["ref",172],["array",451],["ref",173],["union",453,8],["ref",77],["array",455],["ref",183],["array",457],["union",458,8],["ref",169],["array",460],["ref",79],["array",462],["ref",175],["union",464,8],["ref",176],["array",466],["ref",178],["union",468,8],["ref",78],["array",470],["ref",182],["array",472],["ref",123,124],["union",474,8],["ref",174],["union",476,8],["union",447,8],["union",451,8],["ref",187],["union",480,8],["ref",184],["union",482,8],["ref",186],["union",484,8],["object",[[9,19,!1],[43,88,!1],[231,448,!1],[232,450,!1],[233,452,!1],[234,454,!1],[235,456,!1],[236,459,!1],[32,0,!0],[17,38,!1],[237,461,!1],[238,463,!1],[239,465,!1],[240,467,!1],[241,448,!1],[242,63,!0],[243,63,!1],[244,469,!1],[245,471,!1],[246,473,!1],[247,459,!1],[248,443,!1],[249,475,!1],[48,477,!1],[250,478,!1],[251,479,!1],[252,454,!1],[253,481,!1],[254,483,!1],[255,485,!1]]],["object",[[150,0,!0],[94,95,!1]]],["object",[[69,95,!1],[130,0,!0]]],["object",[[57,0,!0]]],["ref",192,193],["array",490],["object",[[91,491,!1]]],["object",[[256,114,!1],[32,0,!0]]],["object",[[187,341,!1],[42,61,!1],[43,88,!1],[32,0,!0]]],["object",[[257,63,!0],[258,63,!0],[32,0,!0]]],["object",[[259,61,!1],[260,61,!1],[32,0,!0],[261,114,!1],[262,114,!1],[263,61,!1]]],["object",[[124,221,!1],[46,0,!0],[125,63,!0],[99,61,!1],[32,0,!0],[126,114,!1]]],["object",[[264,114,!1],[124,221,!1],[46,0,!0],[125,63,!0],[99,61,!1],[32,0,!0],[0,0,!0],[126,114,!1]]],["object",[[200,0,!0]]],["ref",12],["array",500],["object",[[69,501,!1],[198,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[73,236,!1],[43,88,!1],[137,238,!1],[99,61,!1],[0,0,!0],[265,503,!0],[190,357,!0],[1,130,!1]]],["ref",110],["array",505],["object",[[28,0,!0],[266,506,!1],[30,0,!0]]]],contracts:[2,6,53,54,60,62,64,73,74,75,78,80,81,84,91,93,101,106,109,110,81,113,115,122,123,125,126,129,131,132,133,138,139,141,162,165,167,170,171,175,176,177,178,181,132,187,132,194,195,195,178,196,74,199,200,203,204,206,207,208,209,219,222,223,178,224,74,225,230,235,239,242,243,244,247,248,249,250,251,250,252,132,253,255,257,257,260,261,262,265,266,194,268,278,281,283,284,293,195,294,138,295,296,298,299,302,303,178,304,305,306,195,308,314,204,315,318,319,320,132,322,323,326,327,328,329,335,336,243,339,347,348,349,350,351,354,355,204,356,358,359,363,364,369,370,372,373,141,374,375,376,377,380,380,383,384,387,390,391,243,392,393,396,399,319,400,424,425,178,426,427,430,431,432,433,74,434,439,74,440,74,441,444,445,446,486,487,488,489,2,327,492,209,243,493,84,494,495,349,496,497,498,499,502,504,507]};var Sr=ze.rules,Zp=new Map(Sr.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),$a=new Map(ze.kinds.map((t,e)=>[t,Sr[ze.contracts[e]][1]])),_p=new Map([...$a].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>ze.names[n])])])),va=l(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function gr(t){let e=$a.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!ka(t,e))throw new ie(`Invalid typed members for syntax kind '${t.kind}'.`)}l(gr,"validateSyntaxMembers");function _n(t,e){let n=Jn(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new ie(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}l(_n,"validateClosedSyntaxMembers");function Jn(t){let e=_p.get(t);if(e===void 0)throw new ie(`Unknown syntax kind '${t}'.`);return e}l(Jn,"syntaxMemberNames");function ka(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,ze.names[n])?xr(t[ze.names[n]],i):!r)}l(ka,"matchesMembers");function Jp(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!xr(t[n],e))return!1;return!0}l(Jp,"allIndicesMatch");function xr(t,e){let[n,...i]=Sr[e];switch(n){case"ref":return va(t)&&typeof t.kind=="string"&&i.some(r=>ze.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,s)=>o+(xr(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)&&Jp(t,i[0]);case"object":return va(t)&&Object.keys(t).every(r=>i[0].some(([o])=>ze.names[o]===r))&&ka(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||Zp.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}l(xr,"matches");var Hp=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(","))])),Xp=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function ef(t,e){return Hp[t]?.has(e)===!0||Xp.test(t)&&(e==="source"||e==="value")}l(ef,"isExactOnlyMember");function ba(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:ef(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}l(ba,"isLegacyOmittedMember");var Xn=l(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),Hn=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers","directiveLocations"]),ei=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function ni(t){let e=tf(t);return vr(e,"legacy",0),ti(e)}l(ni,"toSyntaxJson");function tf(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 c=Ea();e.set(o,c);let p=o.length;for(let m=p-1;m>=0;m--)n.push(()=>{c[m]=i(Object.hasOwn(o,m)?o[m]:void 0)});return c}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 c=a.length-1;c>=0;c--)n.push(()=>{let p=a[c],m=o[p];p==="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[p]=Object.assign(Object.create(null),{numericMode:"invalid"}))}),s[p]=i(m)});return s}l(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}l(tf,"snapshot");function Ea(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}l(Ea,"dataArray");function ti(t,e="legacy",n=!1){if(Array.isArray(t)){let o=Ea();for(let s=0;s<t.length;s++)o.push(ti(t[s],e,n));return o}if(Xn(t)){if(ei.has(t.kind)&&(e=gt(t.sourceOptions??$e).numericMode),Ct(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&_n(t,Hn),t.kind==="ValidationRuleSyntax"){let p=t;p.implementation!=null&&(p.file!=null&&_n(p.file,Hn),p.code!=null&&_n(p.code,Hn))}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"?Jn(t.kind):void 0,c=Object.keys(s).filter(p=>(a===void 0||a.has(p))&&!(e==="legacy"&&!n&&ba(t,p))&&!Hn.has(p)&&!(t.kind==="OperationSyntax"&&p==="usesLocation")).sort(nf);for(let p of c){let m=s[p];p==="dependsOn"&&(t.kind==="ModuleSyntax"||t.kind==="FeatureSyntax")&&Array.isArray(m)&&m.length===0||p==="sourceOptions"&&m?.numericMode==="legacy"||p==="examples"&&Array.isArray(m)&&m.length===0||p==="inlineProperty"&&m==null||t.kind==="SpecificationSyntax"&&p==="thenNoEvents"&&m===!1||t.kind==="SpecificationSyntax"&&p==="whenRedelivered"&&m==null||t.kind==="InvokesSyntax"&&p==="onRefused"&&Array.isArray(m)&&m.length===0||(o[p]=ti(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]=ti(i[o],e,n));return r}l(ti,"write");function vr(t,e,n){if(n>96&&e==="exact")throw new ie("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)vr(t[o],e,n+1);return}if(typeof t!="object"||t===null)return;let i=t;if(ei.has(i.kind)||Object.hasOwn(i,"sourceOptions")){let o=Object.hasOwn(i,"sourceOptions")?gt(i.sourceOptions):$e;if(n>0&&e!==o.numericMode)throw new ie("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!ei.has(i.kind))throw new ie("Exact syntax requires a complete source root.");if(e==="exact"&&Xn(i)&&gr(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&Rt(i.text))throw new ie("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 ie("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"||Le(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new ie("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new ie("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&Xn(i)?Jn(i.kind):void 0;for(let[o,s]of Object.entries(i))(r===void 0||r.has(o)||Xn(s)&&ei.has(s.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&vr(s,e,n+1)}l(vr,"validateNumbers");function nf(t,e){return t<e?-1:t>e?1:0}l(nf,"ordinal");function Ca(t){let e=[],n=t.map(v=>v.value),i=new Map,r=!1;for(let v of n)try{i.set(v,Object.hasOwn(v,"sourceOptions")?gt(v.sourceOptions):$e)}catch(k){if(!(k instanceof ie))throw k;r=!0,e.push(ri(d.IncompatibleNumericSource,k.message,v.location))}let o=n.filter(v=>i.get(v)?.numericMode==="exact"||rf(v)),s=i.get(o[0])??$e;for(let v of o.slice(1))i.get(v)?.numericMode!==s.numericMode&&(r=!0,e.push(ri(d.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",v.location)));r&&(s=po);let a=new Map,c=ii(n.flatMap(v=>v.concepts),"declaration of",e,void 0,a),p=ii(n.flatMap(v=>v.types),"declaration of",e,void 0,a),m=n.map(v=>v.domain).filter(v=>v!==null);for(let v of m.slice(1))e.push(ri(d.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${oi(m[0].location.path)}' - a folder compiles to one application, which can have at most one`,v.location));let u=of(n.flatMap(v=>v.modules),e),y=ii(n.flatMap(v=>v.personas),"persona",e),h={kind:"ApplicationSyntax",sourceOptions:s,domain:m[0]??null,imports:af(n.flatMap(v=>v.imports),v=>v.qualifiedName),concepts:c,types:p,examples:n.flatMap(v=>v.examples??[]),systems:n.flatMap(v=>v.systems??[]),eventSources:n.flatMap(v=>v.eventSources??[]),declaredTriggers:n.flatMap(v=>v.declaredTriggers??[]),modules:u,personas:y,policies:n.flatMap(v=>v.policies??[]),seeds:n.flatMap(v=>v.seeds??[]),fileImports:n.flatMap(v=>v.fileImports),location:n[0]?.location??{line:1,column:1}},$=[...t.flatMap(v=>v.diagnostics),...e];return{value:h,diagnostics:$,success:!$.some(v=>v.severity==="error")}}l(Ca,"mergeDocuments");function rf(t){if(mo(t)||t.domain!==null||t.concepts.length>0||t.types.length>0||t.personas.length>0||(t.policies?.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=l(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))}l(rf,"hasDeclarations");function of(t,e){return Ia(t).map(wa).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map($r)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),description:Ta(n,`module '${n[0].name}'`,e),authorize:Oa(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:Aa(n),features:Pa(n.flatMap(i=>i.features),e)})}l(of,"mergeModules");function Pa(t,e){return Ia(t).map(wa).map(n=>n.length===1?$r(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),description:Ta(n,`feature '${n[0].name}'`,e),authorize:Oa(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:Aa(n),features:Pa(n.flatMap(i=>i.features),e),slices:ii(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}l(Pa,"mergeFeatures");function Aa(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??[])}l(Aa,"groupDependencies");function wa(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}l(wa,"placedLast");function $r(t){return{...t,isPlacement:!1,features:t.features.map($r)}}l($r,"unplaced");function Oa(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(ni(s))===JSON.stringify(ni(r)));if(o!==void 0){n.push(Ra(d.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${oi(o.location.path)}' - this repeated gate is ignored`,r.location));continue}i.push(r)}return i.reduce((r,o)=>Te(r,o),null)}l(Oa,"combineAuthorization");function af(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}l(af,"firstOfEach");function Ia(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}l(Ia,"groupByName");function Ta(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(Ra(d.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${oi(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}l(Ta,"firstDescription");function ii(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(ri(d.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${s.name}'${i===void 0?"":` in ${i}`} - already declared in '${oi(a.path)}'`,s.location));continue}a===void 0&&r.set(s.name,s.location),o.push(s)}return o}l(ii,"declaredInOneFile");var oi=l(t=>t??"another file","describe"),ri=l((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),Ra=l((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function Da(t,e){return cf(t,e).result}l(Da,"parsePlacedDocuments");function cf(t,e){let n=bt.capturePlaced(t.filter(h=>h.isPlacementResolved!==!1).map(h=>({lines:pt(h.source,!1,h.path),placement:h.placement})),e),i=t.map(h=>Ye(h.source,h.path,h.isPlacementResolved===!1?[]:h.placement,!1,n,e)),r=i.flatMap((h,$)=>(h.value.eventSources??[]).map(v=>({source:v,placementResolved:t[$].isPlacementResolved!==!1}))),o=t.every(h=>h.isPlacementResolved!==!1)&&i.every(h=>!Et.hasUnknownExtent(h.diagnostics)),s=i.map((h,$)=>t[$].isPlacementResolved===!1?{...h,value:{...h.value,eventSources:[]}}:h),a=Ca(s),c=new he(new st([]),void 0,e);a.value.sourceOptions!==void 0&&(c.sourceOptions=a.value.sourceOptions),Yn(a.value,c),qn(a.value,c),Ln(a.value,c),sn(a.value,c),Nn(a.value,c,s.flatMap(h=>h.inputUses)),Wn(a.value,c),Un(a.value,c),Vn(a.value,c),Kn(a.value,c),Zn(a.value,c);let p=cn(a.value,c);kt.validate(p,c);for(let h of an(p))c.information(h.code,h.message,h.location);let m=a.diagnostics,u=new Set(m.map(Ma)),y=[...m,...c.diagnostics.filter(h=>!u.has(Ma(h)))];return{result:{...a,value:p,diagnostics:y,success:!y.some(h=>h.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(s.map((h,$)=>[t[$].path,h.value]))}}l(cf,"parsePlacedDocumentsWithSyntax");function Ma(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}l(Ma,"diagnosticKey");var Na=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,ja=l(t=>`\\u${t.toString(16).padStart(4,"0")}`,"escape");function df(){let t="";for(let e=0;e<=65535;e++){if(!Na.test(String.fromCharCode(e)))continue;let n=e;for(;e<65535&&Na.test(String.fromCharCode(e+1));)e++;t+=ja(n)+(e>n?`-${ja(e)}`:"")}return t}l(df,"ranges");var ai=df();var pf=new RegExp(`^\\s*example\\s+[A-Z][${ai}]*\\s*:\\s*([${ai}.]*)$`),ff=new RegExp(`^\\s*(given|when|then)\\s+(?:(readmodel|append)\\s+)?([${ai}.]*)$`);function La(t,e,n,i,r,o){let s=t,a=[],c=o.some(S=>S.severity==="error")?o.some(S=>S.code==="PLAY0519")?"**Invalid duplicate assignments; no effective values selected.**":"**Invalid source; no effective values selected.**":null,p=new Map,m=[],u=l((S,g)=>{if(S.location.path===e&&S.location.line>0)for(let x of i(S.location.line-1))p.set(x,g)},"own"),y=l((S,g)=>{for(let x of S??[])a.push({name:x.name,scope:g,example:x}),u(x,g)},"examples");y(s.examples,[]),a.push(...[...s.concepts,...s.types].map(S=>({name:S.name,scope:[]})));let h=l((S,g)=>{for(let x of S){let C=[...g,x.name];u(x,C),y(x.examples,C);for(let I of x.slices){let w=[...g,x.name,I.name];u(I,w),y(I.examples,w);let j=new Map;for(let N of se(I))j.set(N.name,[...j.get(N.name)??[],N]);for(let N of j.values()){let L=Math.max(...N.map(q=>q.generation));a.push(...N.filter(q=>q.generation===L).map(q=>({name:q.name,scope:w,fixtureKind:"event"})))}a.push(...I.commands.map(N=>({name:N.name,scope:w,fixtureKind:"command"})),...I.readModels.map(N=>({name:N.name,scope:w,fixtureKind:"readmodel"})));for(let N of I.specifications)m.push({node:N,scope:w}),u(N,w),y(N.examples,w)}h(x.features,C)}},"features");for(let S of s.modules)u(S,[S.name]),y(S.examples,[S.name]),h(S.features,[S.name]);let $=l((S,g)=>{let x=S.split("."),C=a.filter(w=>w.name===x.at(-1)),I=x.slice(0,-1);if(I.length)return C.filter(w=>I.length<=w.scope.length&&I.every((j,N)=>w.scope[w.scope.length-I.length+N]===j));for(let w=g.length;w>=0;w--){let j=C.filter(N=>w<=N.scope.length&&g.slice(0,w).every((L,q)=>N.scope[q]===L));if(j.length)return j}return[]},"candidates"),v=l((S,g)=>{let x=$(S,g);return x.length===1?x[0]:void 0},"unique"),k=l(S=>S.example?v(S.example.type,S.scope)?.fixtureKind:S.fixtureKind,"kind"),E=l(S=>[...S.scope.filter(g=>!r.has(g)),S.name].join("."),"display"),b=l((S,g,x=!1,C="")=>a.flatMap(I=>{let w=k(I);if(!w||g&&w!==g||x&&I.example)return[];let j=[...I.scope,I.name].join("."),N=v(I.name,S)===I?I.name:j;if(v(N,S)!==I)return[];let L=C.split(".").slice(0,-1).join(".");return L&&!j.endsWith(`${L}.${I.name}`)?[]:N===j&&I.scope.some(q=>r.has(q))&&v(I.name,S)!==I?[]:[{label:v(I.name,S)===I?I.name:E(I),insertText:L?I.name:N,documentation:I.example?`Example of ${I.example.type}. Step assignments override example values; no implicit defaults.`:`Declared ${w}.`}]}),"targets"),P=l((S,g,x,C)=>{if(c)return c;let I=l((L,q,D="")=>{if(new Set(L.map(U=>U.property)).size!==L.length||new Set(q.map(U=>U.property)).size!==q.length)return null;let F=new Map(L.map(U=>[U.property,{value:U,origin:"example",replaced:void 0}]));for(let U of q){let Y=F.get(U.property)?.value;F.delete(U.property),F.set(U.property,{value:U,origin:Y?"override":"authored",replaced:Y})}return[...F.values()].map(({value:U,origin:Y,replaced:Q})=>`${D}${U.property} = ${ct(U.source)} \u2014 ${Y}${Y==="example"?` ${S.name}`:""}${Q?` (replaces ${ct(Q.source)} from ${S.name})`:""}`)},"merge"),w=I(S?.values??[],g),j=I(S?.generatedValues??[],x,"generated ");if(!w||!j)return"**Invalid duplicate assignments; no effective values selected.**";let N=C??S?.for;return[...w,...j,...N?[`for ${ct(N)} \u2014 ${C?S?.for?`override (replaces ${ct(S.for)} from ${S.name})`:"authored":`example ${S.name}`}`]:[]].join(`
|
|
19
|
-
`)},"effective"),A=new Map;for(let S of a.filter(g=>g.example?.location.path===e)){let g=S.example,x=g.location.line-1,C=be(n[x]??"").match(/^\s*example\s+/)?.[0];C&&A.set(x,{start:C.length+1,length:g.name.length,content:`**example ${E(S)} : ${g.type}**
|
|
20
|
-
|
|
21
|
-
${k(S)?P(g,[],[],null):"Unresolved or ambiguous type; no effective values selected."}`})}for(let{node:S,scope:g}of m){let x=[...S.given.map(C=>({step:C,name:C.eventType,expected:"event",values:C.values,generated:[],destination:C.for,prefix:/^\s*given\s+/})),...S.givenReadModels.map(C=>({step:C,name:C.name,expected:"readmodel",values:C.properties,generated:[],destination:null,prefix:/^\s*given\s+readmodel\s+/})),...S.when?[{step:S.when,name:S.when.commandType,expected:"command",values:S.when.values,generated:S.when.generatedValues??[],destination:S.when.for,prefix:/^\s*when\s+/}]:[],...S.whenAppended?[{step:S.whenAppended,name:S.whenAppended.eventType,expected:"event",values:S.whenAppended.values,generated:[],destination:S.whenAppended.for,prefix:/^\s*when\s+append\s+/}]:[],...S.thenEvents.map(C=>({step:C,name:C.eventType,expected:"event",values:C.values,generated:[],destination:C.for,prefix:/^\s*then\s+/})),...S.thenReadModels.map(C=>({step:C,name:C.name,expected:"readmodel",values:C.properties,generated:[],destination:null,prefix:/^\s*then\s+readmodel\s+/}))];for(let{step:C,name:I,expected:w,values:j,generated:N,destination:L,prefix:q}of x.filter(D=>D.step.location.path===e)){let D=v(I,g),F=$(I,g).some(oe=>oe.example);if(!D?.example&&(D||!F))continue;let U=C.location.line-1,Y=be(n[U]??"").match(q)?.[0].length;if(Y===void 0)continue;let Q=D?k(D)!==w?"**Example kind mismatch; no effective values selected.**":`**${w} ${D.example?.type??I}${D.example?` \u2014 example ${E(D)}`:""}**
|
|
22
|
-
|
|
23
|
-
${P(D.example,j,N,L)}
|
|
24
|
-
|
|
25
|
-
Authored fixture values, not execution results. Matching is unchanged.`:"**Ambiguous example; no effective values selected.**";A.set(U,{start:Y+1,length:I.length,content:Q})}}return{completions(S,g){let x=p.get(S)??[],C=g.match(pf);if(C)return b(x,void 0,!0,C[1]);if(!m.some(({node:L})=>L.location.path===e&&i(L.location.line-1).includes(S)))return null;let w=g.match(ff);if(!w||["clock","caller","capture","trigger","query","result","error","denied","returns","no","operation","compensated"].includes(w[3]))return null;let j=w[2]==="readmodel"?"readmodel":w[2]==="append"||w[1]!=="when"?"event":"command",N=b(x,j,!1,w[3]);return N.length?w[2]?N:[...Dr[w[1]],...N]:null},hover(S,g,x){let C=A.get(S);return C&&g>=C.start&&x<=C.start+C.length?C.content:null}}}l(La,"exampleAnalysis");function ct(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(ct).join(", ")}]`;case"ObjectExpressionSyntax":return`{ ${t.members.map(e=>`${JSON.stringify(e.name)}: ${ct(e.value)}`).join(", ")} }`;case"RawExpressionSyntax":return t.text;case"PathExpressionSyntax":return t.path;case"ContextExpressionSyntax":return`$context.${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:"${"+ct(e.expression)+"}").join("")+"`"}}l(ct,"expressionText");function qa(t,e,n,i,r){let o=t,s=e,a=ye.containersOf(o).filter(u=>![...u.scope,u.name].some(y=>r.has(y))),c=new Map,p=new Map,m=l((u,y,h)=>{for(let $ of u){let v=[...y,$.name];if(h){if($.location.path===n&&$.location.line>0)for(let k of i($.location.line-1))c.set(k,v)}else{let k=v.join(".");p.set(k,[...p.get(k)??[],...($.dependsOn??[]).map(E=>({target:E.target,...E.location}))])}m($.features,v,h)}},"inventory");return m(o.modules,[],!1),m(s.modules,[],!0),{completions(u,y,h){let $=c.get(u)??h;if(!$?.length||$.some(k=>r.has(k))||!a.some(k=>[...k.scope,k.name].join(".")===$.join(".")))return[];let v=new Set((p.get($.join("."))??[]).filter(k=>k.path!==n||k.line!==u+1).map(k=>ye.resolve(k.target,$,a).resolved));return ye.candidates($,a).flatMap(({container:k,reference:E,tier:b})=>{if(v.has(k))return[];let P=[...k.scope,k.name].join(".");if(y&&(E=y+k.name,ye.resolve(E,$,a).resolved!==k))return[];let A=k.scope.length===0?"module":b===0?"sibling feature":b!=="qualified"?`feature of ${k.scope.join(".")}`:`feature in ${k.scope.join(".")}`,S=a.indexOf(k);return[{label:y?k.name:E,insertText:y?k.name:E,documentation:`${P} \u2014 ${A}.`,detail:A,sortText:`${String(b==="qualified"?$.length:b).padStart(6,"0")}:${String(S).padStart(6,"0")}`}]})}}}l(qa,"dependencyTargetAnalysis");var NA="Executable as ESM v7. Generated values require fixtures in reference execution; other unadmitted constructs still prevent binding.",Ht=new Map;function uf(t,e){let n=ue(t),i=t.flatMap((u,y)=>!n[y]&&J(u)===0&&/^\w/.test(u)?[u.split(/\s+/)[0]]:[]);if(i.includes("module")||!i.some(u=>["feature","slice","command","event","operation","reaction","specification"].includes(u)))return{source:t.join(`
|
|
26
|
-
`),locations:t.map((u,y)=>({line:y+1,column:0}))};let r=[],o=[],s=!1;t.forEach((u,y)=>{!n[y]&&J(u)===0&&/^\w/.test(u)&&(s=/^(?:concept|type|import|domain|system|eventsource)\b/.test(u)),(s?r:o).push(y)});let a=i.includes("feature")?1:i.includes("slice")?2:3,c=e.slice(0,a),p=[...r.map(u=>t[u]),...c,...o.map(u=>" ".repeat(a*2)+t[u])].join(`
|
|
27
|
-
`),m=[...r.map(u=>({line:u+1,column:0})),...c.map(()=>({line:0,column:0})),...o.map(u=>({line:u+1,column:a*2}))];return{source:p,locations:m}}l(uf,"authoringSource");function mf(t,e,n,i="current.play",r=!0){let o=e.map((T,M)=>typeof T=="string"?{path:`other-${M}.play`,source:T}:T).filter(T=>T.path!==i),s=[{path:i,source:t.join(`
|
|
28
|
-
`),placement:n,isPlacementResolved:r},...o],a=new Set(s.flatMap(T=>[...T.source.matchAll(/\w+/g)].map(M=>M[0]).concat(T.placement??[]))),c=l(T=>{let M=T;for(let B=1;a.has(M);B++)M=`${T}${B}`;return a.add(M),M},"fresh"),p=c("EditorAuthoring"),m=c("FragmentFeature"),u=new Set([p,m]),y=s.map((T,M)=>{let B=M===0?t:T.source.split(`
|
|
29
|
-
`),W=c(`Fragment${M}`);u.add(W);let Qe=T.placement?.length?{source:T.source,locations:B.map((dt,nn)=>({line:nn+1,column:0}))}:uf(B,[`module ${p}`,` feature ${m}`,` slice StateChange ${W}`]);return{...T,...Qe,placement:T.placement??[]}}),h=y[0],$=new Map(y.map(T=>[T.path,T.locations])),v=Da([...y.slice(1),h]),k=new Map,E=new Map,b=new WeakSet,P=l(T=>{if(T===null||typeof T!="object"||b.has(T))return;if(b.add(T),Array.isArray(T)){T.forEach(P);return}let M=T;if(typeof M.path=="string"&&typeof M.line=="number"&&typeof M.column=="number"){let B=$.get(M.path)?.[M.line-1];B&&(M.line=B.line,M.column=Math.max(1,M.column-B.column));return}for(let B of Object.values(M))P(B);M.location?.path===i&&(M.kind==="CommandSyntax"&&k.set(M.location.line-1,T),M.kind==="SpecificationSyntax"&&E.set(M.location.line-1,T))},"walk");P(v.value),P(v.physicalEventSources);for(let T of v.diagnostics)P(T.location);let A=v.diagnostics.some(T=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(T.code))return!1;let M=y.find(W=>W.path===T.location.path),B=s.find(W=>W.path===T.location.path)?.source.split(`
|
|
30
|
-
`)[T.location.line-1];return M?.locations.some(W=>W.line===0)&&B!==void 0&&J(B)===0}),S=v.diagnostics.filter(T=>T.location.path===i).flatMap(T=>(P(T.location),T.location.line>0?[T]:[])),g=new re(v.value),x=new Set(g.slices.flatMap(({slice:T})=>[...T.commands.flatMap(M=>M.produces),...T.reactions.flatMap(M=>M.triggers).flatMap(M=>M.produces)].filter(M=>M.location.path===i&&!g.isEventProduction(M,T)).map(M=>M.location.line-1)));for(let T of S)T.code==="PLAY0499"&&x.add(T.location.line-1);let C=g.declarations.filter(T=>T.kind===ee.Operation).map(T=>({...T.node,scope:T.scope.filter(M=>!u.has(M))})),I=new Map,w=ue(t),j=l(T=>{let M=[],B=J(t[T]);for(let W=T;W<t.length&&!(W>T&&!w[W]&&be(t[W]).trim()&&J(t[W])<=B);W++)M.push(W);return M},"range");for(let{slice:T,scope:M}of g.slices){if(T.location.path===i&&T.location.line>0)for(let B of j(T.location.line-1))I.set(B,{scope:M});for(let B of T.specifications.filter(W=>W.location.path===i&&W.location.line>0))for(let W of j(B.location.line-1))I.set(W,{scope:M});for(let B of T.commands.filter(W=>W.location.path===i&&W.location.line>0))for(let W of j(B.location.line-1))I.set(W,{scope:M,commandLine:B.location.line-1})}let N=new Map(g.declarations.map(T=>[T.node.location,T.scope]));for(let T of C.filter(M=>M.location.path===i)){let M=N.get(T.location);for(let B of j(T.location.line-1))I.set(B,{...I.get(B),scope:M,operation:T})}let L=new Map(C.map(T=>[T.location,T])),q=l((T,M)=>{let B=be(t[T.line-1]??""),W=B.slice(T.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return W&&B.slice(T.column-1+W.length,T.column-1+W.length+M.length)===M?{...T,column:T.column+W.length}:T},"referenceLocation"),D=[];for(let{slice:T}of g.slices){for(let M of T.commands)for(let B of M.produces){if(B.location.path!==i)continue;let W=g.resolve(B.event,T),Qe=W.declaration?L.get(W.declaration.node.location)??null:null,dt={name:B.event,location:B.location,targetLocation:B.targetLocation??B.location,kind:W.kind,declaration:Qe,mappings:B.mappings};if(D.push(dt),W.kind===ee.Operation)for(let nn of j(B.location.line-1)){let Or=I.get(nn);Or&&I.set(nn,{...Or,production:dt})}}for(let M of T.specifications)for(let B of[...M.givenOperationFailures??[],...M.thenOperations??[],...M.thenCompensated??[]]){if(B.location.path!==i)continue;let W=g.resolve(B.operation,T);D.push({name:B.operation,location:B.location,targetLocation:q(B.location,B.operation),kind:W.kind,declaration:W.declaration?L.get(W.declaration.node.location)??null:null,mappings:[]})}}let F={declarations:C,systems:v.value.systems??[],references:D,contexts:I,types:v.value.types,concepts:v.value.concepts,targets:l(T=>{let M=g.slices.find(B=>B.scope.length===T.length&&B.scope.every((W,Qe)=>W===T[Qe]))?.slice;return M?C.flatMap(B=>{let W=g.resolve(B.name,M).declaration?.node.location===B.location?B.name:[...B.scope,B.name].join(".");return g.resolve(W,M).kind===ee.Operation&&g.resolve(W,M).declaration?.node.location===B.location?[{name:W,declaration:B}]:[]}):[]},"targets")},U=v.physicalEventSources.map(T=>T.source),Y=new Et(v.physicalEventSources,v.sourceInventoryComplete&&!A),Q=new Map,oe=l((T,M)=>{let B=JSON.stringify([T,M]),W=Q.get(B);return W||(W=Y.resolve(T,M),Q.set(B,W)),{...W,source:W.state==="unique"?W.sources[0]:void 0,stream:W.state==="unique"?W.streams[0]:void 0}},"resolve"),je=new Set(v.value.imports.map(T=>T.qualifiedName)),ae=U.flatMap(T=>T.streams.filter(M=>oe(T.name,M.name).state==="unique"&&!je.has(`${T.name}.${M.name}`)).map(M=>({name:`${T.name}.${M.name}`,source:T,stream:M}))),Ve=new Map,ci=[];for(let T of k.values()){for(let M of j(T.location.line-1))Ve.set(M,{command:T});for(let M of[...T.produces,...T.validations,...T.handler?[T.handler]:[]])for(let B of j(M.location.line-1))Ve.delete(B);if(T.stream){ci.push(T.stream);for(let M of j(T.stream.location.line-1))Ve.set(M,{command:T,route:T.stream})}}for(let T of E.values())for(let M of[...T.given,...T.whenAppended?[T.whenAppended]:[],...T.thenEvents]){let B={event:M,expectation:T.thenEvents.includes(M)};for(let W of j(M.location.line-1))Ve.set(W,B);if(M.stream){ci.push(M.stream);for(let W of j(M.stream.location.line-1))Ve.set(W,{...B,route:M.stream})}}for(let T of U.filter(M=>M.location.path===i)){for(let M of j(T.location.line-1))Ve.set(M,{source:T});for(let M of T.streams)for(let B of j(M.location.line-1))Ve.set(B,{source:T,stream:M})}let za=[...k.values()].flatMap(T=>T.streamCandidates??[]).filter(T=>T.propertyCandidate!==null),Va={declarations:U,routes:ci,ambiguousCandidates:za,contexts:Ve,targets:ae,resolve:oe},di,Qa={completions(T,M,B){if(di===void 0){let W=Ye(h.source,i,h.placement,!1).value,Qe=l(dt=>{P(dt.location),dt.features.forEach(Qe)},"remapDependencyHeaders");W.modules.forEach(Qe),di=qa(v.value,W,i,j,u)}return di.completions(T,M,B)}};return{commands:k,specifications:E,diagnostics:S,operationProductionLines:x,operations:F,eventSources:Va,examples:La(v.value,i,t,j,u,v.diagnostics),dependencies:Qa}}l(mf,"analyze");function Pt(t,e=[],n,i="current.play",r=!0){let o=JSON.stringify([t,e,n,i,r]),s=Ht.get(o);return s===void 0&&(s=mf(t,e,n,i,r),Ht.size>=16&&Ht.delete(Ht.keys().next().value),Ht.set(o,s)),s}l(Pt,"responseAnalysis");var kr="file",yf=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,hf=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function BA(t){return hf.test(t)}l(BA,"isAbsoluteFileReferencePath");function Sf(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}l(Sf,"withoutComment");function br(t,e){let n=J(t),i=Sf(t.slice(n)).trimEnd();if(yi(i)!==kr)return;let r=i.slice(kr.length),o=r.trim();if(o.length===0||yf.test(o))return;let s=r.length-r.trimStart().length,a=n+kr.length+s+1;return{path:o,line:e,startColumn:a,endColumn:a+o.length}}l(br,"fileReferenceOn");function FA(t){let e=ue(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=br(t[i],i);r&&n.push(r)}return n}l(FA,"fileReferences");function nt(t){let e=!1;return t.map(n=>{if(e)return n.trim()==="```"&&(e=!1),n;let i=be(n);return/^\s*```(?:[a-z]+)?\s*$/.test(i)&&(e=!0),i.trimEnd()})}l(nt,"eventAnalysisSource");var gf=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,xf=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?\s*$/,Ba=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,vf=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,$f=["authorize","produces","reads"],kf=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,bf=Nt,Ef=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],Cf=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function it(t){return t.typeReference??wt(t.type)}l(it,"propertyTypeReference");function Er(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}}l(Er,"sourceTypeAt");function Cr(t,e,n){return e.map(i=>({index:i,match:t[i].match(xf)})).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:wt(r[2]),sourceType:Er(t[i],t[i].match(/^\s*\S+\s+/)[0].length+1),isIdentifier:r[4]!==void 0,...r[3]!==void 0?{isGenerated:!0}:{},line:i}))}l(Cr,"propertiesIn");function en(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(J(s)<=i)break;r.push(o)}}return r}l(en,"collectBody");function At(t,e,n,i){let r=en(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 c=J(t[a]),p=t[a].trim();return o!==void 0&&c>o&&(!s||kf.test(p))?!1:(o=p!=="validate csharp"&&Cr(t,[a],$f).length>0||/^description(?:\s|$)/.test(p)?void 0:c,s=/^authorize(?:\s|$)/.test(p),!0)})}l(At,"directBody");var Xt=new Map;function tn(t){let e=t.join(`
|
|
31
|
-
`),n=Xt.get(e);if(n)return n;let i=Pt(t),r={authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=nt(t);let o=ue(t),s=t,a=o,c=t.map(p=>p.replace(/\s*=(?!=|>).*/,""));for(let p=0;p<t.length;p++){if(o[p])continue;let m=t[p],u=m.trim(),y=J(m),h=s[p].trim().match(/^import\s+([\w.]+)\s*$/);if(h&&y===0){let g=h[1],x=g.split(".").pop()??g;r.imports.push({qualifiedName:g,shortName:x,line:p});continue}let $=u.match(gf);if($){let g=en(t,o,p,y).map(I=>t[I].trim()),x={};for(let I of g){let w=I.match(Ba);w&&x[w[1]]===void 0&&(x[w[1]]=w[2])}let C=$[2]==="Enum"?g.filter(I=>!Ba.test(I)):[];r.concepts.push({name:$[1],primitive:$[2],attributes:$[3].trim().split(/\s+/).filter(Boolean),attributeReasons:x,enumValues:C,line:p});continue}let v=u.match(/^type\s+(\w+)\s*$/);if(v){r.types.push({name:v[1],properties:Cr(t,en(t,o,p,y),Ir),line:p});continue}let k=u.match(/^policy\s+(\w+)\s*$/);if(k){let g=en(t,o,p,y).filter(x=>!o[x]).map(x=>t[x].trim());r.policies.push({name:k[1],requires:g,line:p});continue}let E=s[p].trim().match(/^(?:produces\s+)?event\s+(\w+)(?:\s+generation\s+(\d+))?\s*$/);if(E){let g=u.startsWith("produces "),x=At(s,a,p,y),C=g?x:x.filter(I=>br(s[I],I)===void 0);r.events.push({name:E[1],...E[2]?{generation:Number(E[2])}:{},inline:g,properties:Cr(g?c:s,C,g?Ef:bf),line:p});continue}let b=i.commands.get(p);if(b){let g=At(t,o,p,y),x=g.filter(C=>/^\s*produces\b/.test(t[C])&&!i.operationProductionLines?.has(C));r.commands.push({name:b.name,properties:b.properties.map(C=>({name:C.name,type:`${C.type.name}${C.type.isCollection?"[]":""}${C.type.isOptional?" optional":""}`,typeReference:{name:C.type.name,isCollection:C.type.isCollection,isOptional:C.type.isOptional},sourceType:Er(t[C.type.location.line-1],C.type.location.column),isIdentifier:C.isIdentifier||/\sidentifier\s*$/.test(t[C.location.line-1]),...C.isGenerated?{isGenerated:!0}:{},line:C.location.line-1})),response:b.response,productionHeaders:x,produces:x.flatMap(C=>{let I=s[C].trim(),w=/^produces\s+event\b/.test(I),j=/^produces\s+when\b/.test(I),N=j?At(s,a,C,J(s[C]))[0]:C;if(N===void 0)return[];let L=j?s[N].trim():I.match(w?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(L===void 0||!/^[A-Za-z_]\w*$/.test(L))return[];let q=At(s,a,N,J(s[N])),D=q.map(Y=>s[Y].trim().match(/^for(?:\s+(.*))?$/)).filter(Y=>Y!==null),F=D.length===0?void 0:D.length===1?D[0][1]??"":"",U=q.flatMap(Y=>{let Q=s[Y].trim().match(w?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return Q===null?[]:[{name:Q[1].replace(/^@/,""),source:Q[2],line:Y}]});return[{name:L,inline:w,conditional:j,line:C,target:F,mappings:U}]}),reads:g.filter(C=>!o[C]).map(C=>({line:C,match:t[C].match(vf)})).filter(C=>C.match!==null).map(({line:C,match:I})=>({view:I[1],...I[2]?{alias:I[2]}:{},...I[3]?{by:I[3]}:{},line:C})),line:p});continue}let P=u.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(P){let g=en(t,o,p,y).map(x=>({index:x,match:t[x].match(Cf)})).filter(x=>x.match!==null).map(({index:x,match:C})=>({name:C[1],type:C[2],typeReference:wt(C[2]),sourceType:Er(t[x],t[x].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:x}));r.queries.push({name:P[1],returnType:P[2],returnTypeReference:wt(P[2]),parameters:g,line:p});continue}let A=u.match(/^screen\s+(\w+)\s*$/);if(A){r.screens.push({name:A[1],line:p});continue}let S=u.match(/^trigger\s+(\w+)\s*$/);S&&y===0&&r.triggers.push({name:S[1],line:p})}return Xt.size>=16&&Xt.delete(Xt.keys().next().value),Xt.set(e,r),r}l(tn,"scanDocument");function si(...t){return{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)}}l(si,"mergeSymbols");function Fa(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...si(tn(t),e??si()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}l(Fa,"symbolsForBuffer");function li(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}l(li,"knownEventNames");var Pf=["Startup","Shutdown"];function tw(t){return[...li(t),...t.triggers.map(e=>e.name),...Pf]}l(tw,"knownTriggerNames");function Pr(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}l(Pr,"knownTypeNames");function Ar(t){let e=t.properties.filter(o=>o.isIdentifier&&!it(o).isOptional&&!it(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}}l(Ar,"productionDestinations");function cw(t,e){let n=Pt(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=nt(t);return tn(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}=Ar(r);if(s||r.productionHeaders?.length!==r.produces?.length)return[];let a=r.produces?.some(c=>c.target!==void 0||c.inline);return(r.produces??[]).flatMap(c=>c.target!==void 0||c.inline&&(o===void 0||/\bgeneration\b/.test(i[c.line]))?[]:!c.inline&&a?[]:[{line:c.line,column:i[c.line].length+1,label:c.inline?`for ${o}`:"for <new event source>"}])})}l(cw,"destinationHints");var K={conflictingScreenDataBinding:"PLAY0530",screenDataQueryMismatch:"PLAY0531",actionWithoutInputSurface:"PLAY0532",commandWithoutInputSurface:"PLAY0533",readModelFieldWithoutOrigin:"PLAY0534",queryParameterNotHeldByView:"PLAY0535",unconsumedEvent:"PLAY0536",unreachableScreen:"PLAY0537",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",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 Af=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,wf=/^import\s+"/;function Wa(t){return wf.test(t.trim())}l(Wa,"isFileImportLine");function wr(t,e){let n=J(t),i=t.slice(n).match(Af);if(!i)return;let r=n+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:r,endColumn:r+i[2].length}}l(wr,"fileImportOn");function mw(t){let e=ue(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=wr(t[i],i);r&&n.push(r)}return n}l(mw,"fileImports");var Ya=l(t=>t.split("/").slice(0,-1),"folderOf");function Of(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("/")}l(Of,"relativeTo");function yw(t,e){let n=Ya(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=Of(n,r),s=Ya(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()}l(yw,"importablePaths");var If=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),Tf=/^id\s+"((?:[^"\\]|\\.)*)"$/;function Ua(t,e,n,i=new Set){t=nt(t);let r=[],o=ue(t),s=Rf(t,o),a=new Set(e.commands.flatMap(y=>y.productionHeaders??[])),c=new Map,p=new Set;for(let y of[e,n]){for(let h of y.events)c.set(h.name,(c.get(h.name)??0)+1);for(let h of y.imports)p.add(h.shortName)}let m=l((y,h,$,v="error")=>{r.push({line:y,startColumn:J(t[y])+1,endColumn:t[y].length+1,code:h,message:$,severity:v})},"report");for(let y of e.events){let h=At(t,o,y.line,J(t[y.line]));if(y.inline){let k=new Set;for(let E of y.properties)k.has(E.name)&&m(E.line,K.duplicateDeclaration,`Event '${y.name}' already declares property '${E.name}'.`),k.add(E.name);a.has(y.line)||m(y.line,K.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),y.generation!==void 0&&m(y.line,K.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((c.get(y.name)??0)>1||p.has(y.name))&&m(y.line,K.inlineEventCollision,`Inline event '${y.name}' collides with another declaration or import.`)}let $=!1,v=!1;for(let k of h){let E=t[k].trim(),b=E.split(/\s+/)[0];if(y.inline&&b==="generation"&&m(k,K.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),y.inline&&b==="origin"&&m(k,K.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test(E)){if(b==="id"){let P=E.match(Tf);$||P===null||P[1].trim().length===0?m(k,K.invalidEventId,'Expected one nonempty id "<old-name>".'):P[1]===y.name&&m(k,K.redundantEventId,"This id repeats the event name; remove it.","information"),$=!0}if(b==="documentation"){let P=k+1;for(;P<t.length&&t[P].trim().length===0;)P++;(v||E!=="documentation"||t[P]?.trim()!=="```markdown"||J(t[P])<=J(t[k])||!s.has(P))&&m(k,K.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),v=!0}}}}let u=[];for(let y=0;y<t.length;y++){if(o[y]||t[y].trim().length===0)continue;let h=J(t[y]);for(;u.length>0&&u[u.length-1].indent>=h;)u.pop();let $=t[y].trim().split(/\s+/)[0];If.has($)&&u.at(-1)?.event&&m(y,K.reservedProductionMetadata,`'${$}' is system-assigned production metadata.`),$==="produces"&&u.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:$}=Ar(y);for(let v of y.produces??[]){$&&v.target===void 0&&m(v.line,K.explicitProducesTargetsRequired,`Production '${v.name}' must state for explicitly when destinations differ.`);let k=v.target??(v.inline?h:void 0);if(!(h===void 0||k!==h))for(let E of v.mappings.filter(b=>b.source===h))m(E.line,K.eventSourceIdInPayload,`The payload copies '${h}', which already identifies the event source.`,v.inline?"warning":"information")}}return r}l(Ua,"validateInlineEvents");function Rf(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}l(Rf,"nonemptyMarkdownBlocks");function ke(t,e,n,i,r,o){return{severity:t,message:r,line:e,startColumn:n,endColumn:n+i,code:o}}l(ke,"issue");function Ie(t,e,n,i,r,o){let s=n.indexOf(i)+1;return ke(t,e,s,i.length,r,o)}l(Ie,"tokenIssue");function Mf(t,e,n){let i=[],r=new Set([...Pr(e,rn),...Pr(n,[])]),o=l((a,c)=>{for(let p of a.filter(m=>!r.has(it(m).name))){let m=it(p).name;i.push(ke("warning",p.line,p.sourceType.startColumn,p.sourceType.text.length,m==="optional"?`Unknown type 'optional' on '${p.name}' of ${c} \u2014 did you forget the type before 'optional'?`:`Unknown type '${m}' on '${p.name}' of ${c} \u2014 declare it with 'concept ${m} : <Primitive>' or 'type ${m}'.`,K.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 c=a.properties.filter(p=>p.isIdentifier);for(let p of c.slice(1))i.push(Ie("error",p.line,t[p.line],"identifier",`Command '${a.name}' already marks '${c[0].name}' as identifier \u2014 only one property can be the identifier.`,K.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(Ie("error",a.line,t[a.line],a.name,`Duplicate declaration of '${a.name}' \u2014 concept and type names must be unique.`,K.duplicateDeclaration))}return i}l(Mf,"validateDeclarations");function Yw(t,e={}){let n=ue(t),i=tn(t),r=e.application??si(),o=Fa(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),s=Pt(t,o.authoringDocuments??o.authoringSources?.filter(g=>g!==t.join(`
|
|
32
|
-
`)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),a=new Set(s.eventSources.routes.map(g=>g.location.line-1)),c={...i,commands:i.commands.map(g=>({...g,properties:g.properties.filter(x=>!a.has(x.line)),produces:g.produces?.filter(x=>!s.operationProductionLines?.has(x.line)),productionHeaders:g.productionHeaders?.filter(x=>!s.operationProductionLines?.has(x))}))},p=new Set([...li(c),...li(r)]),m=new Set([...c.policies,...r.policies].map(g=>g.name)),u=Mf(t,c,r);u.push(...Df(t,c));let y=new Set([d.LegacyOptionalSuffix,d.InvalidOptionalModifierOrder,d.OptionalReadsNotSupported]),h=new Set([d.UnexpectedTokenInPolicyCondition,d.ExpectedPolicyCondition,d.UnclosedPolicyConditionGroup,d.ExpectedRoleName,d.ExpectedClaimName,d.ExpectedClaimMatches,d.ExpectedClaimMatchTarget]),$=new Set([d.UnknownEvent,d.UnknownReadModelProperty,d.PiiNotSupportedOnIdentifier]),v=new Set([d.EventFromLaterSlice,d.TimelineCycleGroup]),k=new Set([d.UndeclaredDependency,d.UnusedDependencyDeclaration,d.InvalidDependencyTarget,d.RepeatedDependencyDeclaration,d.MutualDependencyDeclarations,d.AmbiguousReference]),E=new Set([d.InvalidAbsentReadModelStep,d.UnknownConstraintProperty,d.OmittedProductionDestination,d.InvalidSpecificationExample,d.DuplicateSpecificationAssignment]),b=new Set;for(let g of e.compilerDiagnostics??s.diagnostics){if(!y.has(g.code)&&!h.has(g.code)&&!$.has(g.code)&&!v.has(g.code)&&!k.has(g.code)&&!E.has(g.code)&&g.code!==d.InvalidSpecificationExampleBody&&g.code!==d.UnknownRuleImplementationDirective&&g.code!==d.InvalidValidationRule&&g.code!==d.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$/.test(g.code))continue;let x=g.location.line-1;if(g.code===d.OmittedProductionDestination&&u.some(I=>I.code===g.code&&I.line===x))continue;g.code===d.UnknownEvent&&b.add(x);let C=yr(t[x],g)||t[x].length-g.location.column+1;u.push(ke(g.severity,x,g.location.column,C,g.message,g.code))}let P=l((g,x,C)=>{!p.has(C)&&!b.has(g)&&u.push(Ie("warning",g,x,C,`Unknown event type '${C}' \u2014 declare it in a slice or import it.`,K.unknownEvent))},"checkEvent"),A=-1;for(let g=0;g<t.length;g++){let x=t[g],C=x.trim();if(n[g]||C.length===0)continue;let I=x.match(/^[ ]*(\t+)/);if(I&&u.push(ke("warning",g,I[0].length-I[1].length+1,I[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",K.tabIndentation)),A>=0){if(J(x)>A&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(C)){for(let Y of C.split(/\s+/).filter(Q=>Q!=="or"))m.has(Y)||u.push(Ie("warning",g,x,Y,`Unknown policy '${Y}' \u2014 declare it with 'policy ${Y}'.`,K.unknownPolicy));continue}A=-1}let w=Nf(t,n,g);w&&u.push(w);let j=C.match(/^slice\s+(\w+)/);j&&!mi.includes(j[1])&&u.push(Ie("error",g,x,j[1],`Unknown slice type '${j[1]}' \u2014 expected ${mi.join(", ")}.`,K.unknownSliceType));let N=C.match(/^concept\s+\w+\s*:\s*(\w+)/);N&&N[1]!=="Enum"&&!rn.includes(N[1])&&u.push(Ie("error",g,x,N[1],`Unknown primitive type '${N[1]}' \u2014 expected ${rn.join(", ")} or Enum.`,K.unknownPrimitiveType));let L=C.match(/^authorize\s+(.*)$/);if(L){A=J(x);for(let Y of L[1].split(/\s+/).filter(Q=>Q!=="or"&&Q.length>0))m.has(Y)||u.push(Ie("warning",g,x,Y,`Unknown policy '${Y}' \u2014 declare it with 'policy ${Y}'.`,K.unknownPolicy))}let q=C.match(/^on\s+([A-Z]\w*)\s*$/);q&&P(g,x,q[1]);let D=C.match(/^produces\s+([A-Z]\w*)\s*$/);if(D&&!s.operationProductionLines?.has(g)&&P(g,x,D[1]),/^produces\s+when\b/.test(C)&&!s.operationProductionLines?.has(g))for(let Y=g+1;Y<t.length;Y++){let Q=t[Y];if(!(n[Y]||Q.trim().length===0)){if(J(Q)>J(x)){let oe=Q.trim().match(/^([A-Z]\w*)\s*$/);oe&&P(Y,Q,oe[1])}break}}let F=C.match(/^unique\s+event\s+([A-Z]\w*)/);F&&P(g,x,F[1]);let U=C.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);U&&P(g,x,U[1]);for(let Y of x.match(/\$context\.[\w.]+/g)??[]){let Q=Y.substring(9).split(".");pi.includes(Q[0])?Q[0]==="causedBy"&&Q.length>1&&!fi.includes(Q[1])?u.push(Ie("warning",g,x,Y,`Unknown $context.causedBy property '${Q[1]}' \u2014 expected ${fi.join(", ")}.`,K.unknownContextCausedByProperty)):Q[0]==="identity"&&Q.length>1&&!ui.includes(Q[1])&&u.push(Ie("warning",g,x,Y,`Unknown $context.identity property '${Q[1]}' \u2014 expected ${ui.join(", ")}.`,K.unknownContextIdentityProperty)):u.push(Ie("warning",g,x,Y,`Unknown $context path '${Q.join(".")}' \u2014 expected one of ${pi.join(", ")}.`,K.unknownContextPath))}}u.push(...Lf(t,n)),u.push(...Ua(t,c,r,s.operationProductionLines));let S=t.map((g,x)=>({line:g,index:x})).filter(({line:g})=>/^\s*```(?:[a-z]+)?\s*$/.test(g));if(S.length%2===1){let g=S[S.length-1];u.push(ke("error",g.index,1,g.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",K.unclosedCodeBlock))}return u}l(Yw,"validateLines");function Df(t,e){let n=[];t=nt(t);for(let i of e.commands){let r=i.properties.filter(o=>o.isIdentifier&&!it(o).isOptional&&!it(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(ke("information",s,J(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.`,K.omittedProductionDestination))}}return n}l(Df,"validateProductionDestinations");function Nf(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||wr(i,n))return;let o=J(i);if(!(!(o>0&&["module","feature"].includes(Tr(t,e,n,o)[0]))&&!Wa(i)))return ke("error",n,o+1,r.length,`Invalid import '${r}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,K.invalidFileImport)}l(Nf,"validateImport");var jf=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function Lf(t,e){let n=[],i=l(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 c of o.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let p=c[0].substring(c[1]?.length??0),m=c[2];if(m.length===0){c[1]&&n.push(ke("error",r,(c.index??0)+2,p.length,`'$eventContext' names no member - expected one of ${i(xi("").expected)}.`,K.missingEventContextPath));continue}let u=m.substring(1),y=xi(u),h=(c.index??0)+(c[1]?.length??0)+1;switch(y.status){case"missing":n.push(ke("error",r,h,p.length,`'$eventContext.${u}' names no member - expected one of ${i(y.expected)}.`,K.missingEventContextPath));break;case"unknownMember":n.push(ke("warning",r,h,p.length,`Unknown event context member '${y.segment}' in '$eventContext.${u}' - expected one of ${i(y.expected)}.`,K.unknownEventContextMember));break;case"unknownSubPath":{let $=y.expected.length===0?"no members to address":`members ${i(y.expected)}`;n.push(ke("warning",r,h,p.length,`Unknown event context path '$eventContext.${u}' - '${y.member?.name}' (${y.member?.type}) has ${$}.`,K.unknownEventContextPath));break}case"belowCollection":n.push(ke("error",r,h,p.length,`'$eventContext.${u}' cannot resolve - '${y.member?.name}' is a collection (${y.member?.type}) and cannot be addressed below.`,K.eventContextPathBelowCollection));break}}let s=o.trim().match(jf)?.[1],a=s?.match(/\.\$(\w+)/)?.[1];s&&a&&a!=="eventContext"&&n.push(Ie("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.`,K.unresolvedDynamicKeySource))}return n}l(Lf,"validateEventContextPaths");export{Ga as a,qf as b,Bf as c,Ir as d,Ff as e,pi as f,fi as g,mi as h,rn as i,Yf as j,Ka as k,Wf as l,ai as m,wt as n,zf as o,d as p,de as q,Ii as r,$n as s,Y1 as t,W1 as u,be as v,J as w,yi as x,ue as y,Tr as z,Gf as A,Kf as B,nt as C,hi as D,Si as E,gi as F,Za as G,Xf as H,eu as I,tu as J,_a as K,Ja as L,au as M,su as N,lu as O,cu as P,du as Q,pu as R,fu as S,uu as T,mu as U,yu as V,hu as W,Xa as X,Su as Y,ku as Z,bu as _,Eu as $,es as aa,Cu as ba,Pu as ca,Au as da,wu as ea,ts as fa,Ou as ga,Iu as ha,Tu as ia,Ru as ja,Mu as ka,Du as la,Nu as ma,ju as na,Lu as oa,qu as pa,Bu as qa,Fu as ra,Yu as sa,Dr as ta,ns as ua,Wu as va,Uu as wa,zu as xa,Vu as ya,Qu as za,is as Aa,Gu as Ba,Ku as Ca,Zu as Da,_u as Ea,Ju as Fa,NA as Ga,Pt as Ha,kr as Ia,BA as Ja,br as Ka,FA as La,it as Ma,At as Na,tn as Oa,si as Pa,Fa as Qa,li as Ra,Pf as Sa,tw as Ta,Pr as Ua,Ar as Va,cw as Wa,K as Xa,Wa as Ya,wr as Za,mw as _a,yw as $a,Yw as ab,Lf as bb};
|
|
33
|
-
//# sourceMappingURL=chunk-MQ7ZSHMF.js.map
|