@cratis/screenplay-language 4.106.0 → 4.108.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-GYLT45QG.js +39 -0
- package/dist/bundles/chunk-GYLT45QG.js.map +7 -0
- package/dist/bundles/index.js +37 -37
- package/dist/bundles/index.js.map +3 -3
- package/dist/bundles/sub-languages/projection/index.js +16 -16
- package/dist/bundles/sub-languages/projection/index.js.map +2 -2
- package/dist/completion-items.d.ts.map +1 -1
- package/dist/completion-planner.d.ts.map +1 -1
- package/dist/diagnostic-codes.d.ts +14 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/dist/hover-content.d.ts.map +1 -1
- package/dist/keyword-docs.d.ts +1 -0
- package/dist/keyword-docs.d.ts.map +1 -1
- package/dist/language.d.ts.map +1 -1
- package/dist/purpose-items.d.ts +4 -0
- package/dist/purpose-items.d.ts.map +1 -0
- package/dist/scope-items.d.ts.map +1 -1
- package/dist/sub-languages/pdl.d.ts.map +1 -1
- package/dist/sub-languages/projection/CompletionProvider.d.ts.map +1 -1
- package/dist/sub-languages/projection/HoverProvider.d.ts.map +1 -1
- package/dist/sub-languages/projection/language.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/bundles/chunk-KWZDFRXS.js +0 -39
- package/dist/bundles/chunk-KWZDFRXS.js.map +0 -7
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import{a as c}from"./chunk-AYDF3IFZ.js";var Zs="screenplay",$m={id:Zs,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},bm=["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","case","parameter","example","seed","behavior"];var So=["depends","description","documentation","template","profile","require","authenticated","role","claim","subject","authorize","validate","produces","reads","as","handler","performer","observable","identifier","reason","from","when","given","then","arguments","result","clock","exactly","error","message","not","empty","rule","matches","all","max","min","length","today","true","false","and","or","by","filter","data","via","component","context","property","literal","icons","packages","outlet","toolbar","item","presentation","exposes","mode","oneWay","twoWay","null","propagate","clear","preserve","expected","action","navigate","to","label","section","table","summary","title","column","field","on","unique","file","concurrency","eventSource","sourceType","streamType","streamId","tag","for","readmodel","no","when","every","at","where","invokes","contains","starts","with","provider","uses","parameter","order","open","close","refresh","set","notify","confirm","raise","interval","success","failure","click","double","select","submit","change","load","unload","enter","leave","info","warning"],km=["csharp","typescript","react","html","sql"],Ui=["command","arguments","tenant","causedBy","causation","occurred","identity"],Wi=["subject","name","userName"],Vi=["id","name","userName","isAuthenticated","roles","claims"],zi=["StateChange","StateView","Automation","Translate"],Tn=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Cm=["pii","personal","secret"],Ks=/^\s*(?:module|feature|slice\s+\w+|type|command|event|readmodel|reducer|projection|capture|reaction|screen|dialog|form|contribute|specification|case|constraint|persona|policy|behavior|layout|theme|ui\s+profile|trigger|authentication|seed|system|eventsource|operation|screen\s+template|dialog\s+template|produces\s+event|validate|handler|on)\b[^=]*$/,Em={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:Ks,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*$|\s+execute\b)|concurrency|seed|for|when|then|arguments|result|every|at|invokes|on)\b.*$/,decreaseIndentPattern:/(?!)/}};function Xt(t){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(t);return{name:e?.[1]??t,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}c(Xt,"typeReferenceSymbol");function Am(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}c(Am,"typeReferenceText");function $e(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}c($e,"withoutComment");function X(t){return t.length-t.trimStart().length}c(X,"indentOf");function Qi(t){return t.trim().split(/\s+/)[0]??""}c(Qi,"firstWord");function Ce(t){let e=new Array(t.length).fill(!1),n=!1;for(let i=0;i<t.length;i++){if(/^\s*```(?:[a-z]+)?\s*$/.test(t[i])&&(!n||/^\s*```\s*$/.test(t[i]))){e[i]=!0,n=!n;continue}e[i]=n}return e}c(Ce,"fenceMap");function go(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=$e(t[s]);if(a.trim().length===0)continue;let l=X(a);l<o&&(r.push(Qi(a)),o=l)}return r}c(go,"enclosingChain");function Im(t,e,n,i){for(let r=n-1;r>=0&&i>0;r--){if(e[r])continue;let o=$e(t[r]);if(o.trim().length!==0&&X(o)<i)return o.trim()}}c(Im,"nearestEnclosingLine");function Tm(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=$e(t[s]);if(a.trim().length===0)continue;let l=X(a);l<o&&(r.push(a.trim()),o=l)}return r}c(Tm,"enclosingHeaders");var xo="EventContext",en={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."}]},Gi=[{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 _i(t,e){if(t.kind==="function")return e===t.name||e===`${t.name}()`;let n=t.name[0].toUpperCase()+t.name.slice(1);return e===n||e.length>0&&e[0].toUpperCase()+e.slice(1)===n}c(_i,"namesEventContextMember");var Zi=en[xo];function Js(t){let e=Zi;for(let n of t){let i=e.find(r=>_i(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=en[i.type]??[]}return e}c(Js,"eventContextMembersAfter");function Nm(t){return t.length===0?void 0:Js(t.slice(0,-1))?.find(n=>_i(n,t[t.length-1]))}c(Nm,"eventContextMemberAt");function Ki(t){let e,n=Zi;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=>_i(o,i));if(!r)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:n};e=r,n=r.kind==="function"?[]:en[r.type]??[]}return{status:"known",member:e,expected:[]}}c(Ki,"resolveEventContextPath");function Lm(){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:**",...Zi.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
|
|
2
|
-
`)}c(Lm,"describeEventContext");function qm(t,e){let n=e.kind==="collection"||e.kind==="function"?[]:en[e.type]??[],i=[`**$eventContext.${t}**: \`${e.type}\``,"",e.description];return n.length>0&&i.push("",`**Members:** ${n.map(r=>`\`${r.name}\``).join(", ")}`),i.join(`
|
|
3
|
-
`)}c(qm,"describeEventContextMember");var lt={label:"documentation",insertText:"documentation\n ```markdown\n ${1:Reasoning, assumptions or rejected alternatives}\n ```",documentation:"One nonempty authoring-only Markdown block; report-only (PLAY0270), with no executable effect."};var $t=[{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 Ji=[{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."}],Hs=[lt,...$t,{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."},...Ji],Xs=[lt,...$t,{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."},...Ji],zm=[lt,{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."}],Qm=[{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."}],Gm=[{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."},...Ji],_m=[{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."}],Zm=[{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."}],qe=c((t,e,n)=>({label:t,insertText:e,documentation:n}),"step"),el=[qe("execute","execute ${1:command}","Runs a command."),qe("navigate to","navigate to ${1:Screen}","Opens a screen."),qe("open","open ${1:Dialog}","Opens a dialog."),qe("close","close","Closes the dialog."),qe("refresh","refresh ${1:query}","Reloads a query."),qe("set","set ${1:name} ${2:value}","Sets a value."),qe("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),qe("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),qe("raise","raise ${1:Trigger}","Raises a trigger.")],Km=[qe("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),qe("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...el],Jm=[{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."}],Hm=[{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."}],Xm=[{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."}],ey=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],ty=[{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."}],tl=[{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."}],ny=[{label:"fits slot",insertText:"fits slot ${1:content}",documentation:"The slot of the shell the template fits."},...tl,{label:"on",insertText:"on ${1|enter,leave,load,unload|}\n ${2:refresh query}",documentation:"Wires what happens on an interaction."}];var ly=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],Ee=c(t=>`\`\`\`${t}
|
|
6
|
-
\${1}
|
|
7
|
-
\`\`\``,"fenced"),cy=[...$t,{label:"eventsource",insertText:"eventsource ${1:Name}\n identifier ${2:Type}\n stream ${3:Name}",documentation:"Application-owned source with nested streams, admitted by ESM v8. Pin the stored name before renaming a source with stored events; Default is reserved."},{label:"system",insertText:'system ${1:Name}\n description "${2:external system}"',documentation:"Application-scoped external system; not admitted by any supported executable model (ESM) version yet."},{label:"import",insertText:"import ${1:Module}.${2:Type}",documentation:"Imports a type from another module by its qualified name."},{label:'import "\u2026"',insertText:'import "${1:**/*.play}"',documentation:"Imports other `.play` files by path or glob, relative to this file's folder, as whole documents of the application."},{label:"concept",insertText:"concept ${1:Name} : ${2|Uuid,String,Int,Decimal,Bool,Date,DateTime|}",documentation:"Declares a formalized value type wrapping a primitive."},{label:"concept (enum)",insertText:"concept ${1:Name} : Enum\n ${2:value}",documentation:"Declares an enumeration concept with a fixed set of values."},{label:"concept (pii with reason)",insertText:'concept ${1:Name} : ${2|String,Uuid,Int,Decimal,Bool,Date,DateTime|} pii\n pii reason "${3:why this value is personal data}"',documentation:"Declares a personal-data concept together with the reason it is personal data."},{label:"type",insertText:"type ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a composite value type \u2014 a named shape built from several properties."},{label:"policy",insertText:"policy ${1:Name}\n require ${2:authenticated}",documentation:"Declares a named authorization rule for commands and queries."},{label:"module",insertText:"module ${1:Name}\n ",documentation:"Declares the top-level namespace \u2014 maps to a bounded context."},{label:"domain",insertText:"domain ${1:Name}",documentation:"The domain the file belongs to \u2014 optional, at most one per file, before everything else."},{label:"persona",insertText:'persona ${1:Name}\n description "${2:who they are}"',documentation:"A named role interacting with the application, with the policies it holds."},{label:"authentication",insertText:"authentication\n provider ${1:Name}\n ${2:setting} ${3:value}",documentation:"Declares the identity providers of the application \u2014 at most one block per file."},{label:"seed",insertText:"seed\n for ${1:EventSourceId}\n ${2:EventType}",documentation:"Declares events to seed into the event store per event source id."},{label:"layout",insertText:"layout ${1:Name}\n ${2:slot}",documentation:"Declares the application shell with named slots."},{label:"theme",insertText:"theme ${1:Name}\n compatible with ${2:Package}",documentation:"Declares a theme and the component packages it is compatible with."},{label:"ui profile",insertText:"ui profile ${1:Name}\n target platform ${2:web}\n layout ${3:Layout}\n theme ${4:Theme}",documentation:"Binds a target platform and size to a layout, theme and component packages."},{label:"behavior",insertText:"behavior ${1:Name}\n on ${2:click}\n ${3:execute command}",documentation:"A named interaction wiring, attached to a screen, form or dialog with `uses`."},{label:"trigger",insertText:"trigger ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an integration signal a reaction can run on."}],dy=[{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."}],nl=[{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:Ee(t),documentation:"Selects the phase\u2019s sole inline source; not admitted by any supported executable model (ESM) version yet."}))],py=[{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."},...nl.filter(t=>t.label!=="hint")],fy=[{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"pii reason",insertText:'pii reason "${1:why this value is personal data}"',documentation:"A free-text concept note, not a lawful basis."},{label:"secret reason",insertText:'secret reason "${1:why this value is an operational secret}"',documentation:"Records why the secret marker applies."},{label:"secret scope",insertText:"secret scope ${1|subject,namespace,global|}",documentation:"Explicit encryption scope; omitted scope keeps Chronicle\u2019s Subject default."},{label:"pii special",insertText:"pii special ${1|racialOrEthnicOrigin,politicalOpinions,religiousOrPhilosophicalBeliefs,tradeUnionMembership,genetic,biometric,health,sexLifeOrSexualOrientation|}",documentation:"GDPR Art. 9(1) special category of personal data."},{label:"pii criminal",insertText:"pii criminal",documentation:"Personal data relating to criminal convictions and offenses (GDPR Art. 10)."},{label:"validate",insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:"Validation rules that travel with the value everywhere it appears."}],uy=[{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."}],vo=[lt,...$t,{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."}],my=[lt,{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
|
-
${Ee("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."}],il=[{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."}],yy=[...il,{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."}],hy=[{label:"when",insertText:"when ${1:condition}",documentation:"Guards the produced event with a condition."}],Sy=[{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:Ee(t),documentation:"Selects one inline payload. Handler execution remains unsupported."}))],gy=[{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:Ee("csharp"),documentation:"Inline C# returning the events to append."}],xy=[{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."}],vy=[{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the query implementation to an external file."},{label:"csharp",insertText:Ee("csharp"),documentation:"Inline C# returning the query result, with the QueryContext in scope as context."},{label:"sql",insertText:Ee("sql"),documentation:"Inline SQL returning the query result."}],$y=[{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."}],by=[lt,{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."}],ky=[{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:Ee("csharp"),documentation:"Inline C# returning event side effects."}],ct="Syntax-only; reaction refusal handling and redelivery are not yet executable (PLAY0268).",Cy=[{label:"on refused",insertText:`on refused
|
|
11
|
-
acknowledge`,documentation:`Handles validation and constraint refusals, not authorization. ${ct}`},{label:"on refused by validation",insertText:`on refused by validation
|
|
12
|
-
acknowledge`,documentation:`Handles validation refusals. ${ct}`},{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. ${ct}`},{label:"on refused by authorization",insertText:`on refused by authorization
|
|
13
|
-
acknowledge`,documentation:`Explicitly handles unauthorized results, never Unsupported. ${ct}`}],Ey=[{label:"acknowledge",insertText:"acknowledge",documentation:`Acknowledges alone, without productions. ${ct}`},{label:"produces",insertText:"produces ${1:Event}\n ${2:reason} = \\$refusal.reason",documentation:`Records the refusal with ordinary event productions. ${ct}`}],Py=[{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."}],Ay=[{label:"parameter",insertText:"parameter ${1:name} ${2:Type}",documentation:"One typed value, supplied exactly once by every case."},{label:"case",insertText:"case ${1:Name}\n ${2:parameter} = ${3:value}",documentation:"One named complete set of concrete parameter values."},{label:"given caller as",insertText:"given caller as ${1:Persona}",documentation:"An authenticated deterministic witness of a top-level persona; no body. Use explicit callers for negation, ownership claims and implementations."},{label:"description",insertText:'description "${1:rule or case witnessed}"',documentation:"Authoring-only description of what this scenario demonstrates."},{label:"when redelivered",insertText:"when redelivered ${1:Event} to ${2:Reaction}\n for ${3:value}",documentation:`Selects exactly one given event occurrence for one event-trigger reaction; does not append it again. ${ct}`},{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."}],$o={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. ${ct}`},{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."}]},rl=[{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:Ee("csharp"),documentation:"Opaque named-rule predicate returning a bool. Requires an admitting target."}],wy=[{label:"implementation",insertText:'implementation\n hint "${1:predicate guidance}"',documentation:"Command named-rule intent with optional file or tagged fence. Pending intent cannot bind."},...rl.filter(t=>t.label!=="hint")],Oy=[{label:"file",insertText:"file ${1:Path}",documentation:"Gives the named predicate its implementation in an external C# file."},{label:"csharp",insertText:Ee("csharp"),documentation:"Gives the named predicate its implementation as inline C# returning a bool."}],Iy=[{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:Ee("csharp"),documentation:"Fully custom policy logic in C#, returning a bool."}],Ty=[{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."}],Ry=[{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:Ee("react"),documentation:"Inline React/TSX component receiving the data contract as Props."},{label:"typescript",insertText:Ee("typescript"),documentation:"Inline plain TypeScript."},{label:"html",insertText:Ee("html"),documentation:"Inline static HTML."}],ol=[{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."}],Dy=[{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."},...ol.filter(t=>t.label!=="label")],al=[{label:"execute",insertText:"execute ${1:CommandName}",documentation:"Executes a command; denial never selects another alternative."},{label:"navigate to",insertText:"navigate to ${1:ScreenName}",documentation:"Navigates to the named screen."},{label:"open dialog",insertText:"open dialog ${1:DialogTemplate}",documentation:"Opens a dialog."},{label:"notify",insertText:'notify info "${1:Message}"',documentation:"Displays a message."},{label:"confirm",insertText:'confirm "${1:Message}"\n on success\n execute ${2:CommandName}',documentation:"Asks before continuing."},{label:"refresh",insertText:"refresh ${1:QueryName}",documentation:"Refreshes a query-backed element."}],My=[{label:"when \u2026",insertText:'when item.${1:status} == "${2:open}"\n execute ${3:CommandName}',documentation:"Selects a whole action list once against the rendered subject at gesture time."},{label:"otherwise",insertText:'otherwise\n notify info "${1:Message}"',documentation:"Final fallback list; without a subject nothing runs, including fallback."},...al],jy=[{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."}],Ny=[{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."}],Ly=[{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."},...Gi.filter(t=>t.name!=="value").map(t=>({label:`$eventContext.${t.path}`,insertText:`$eventContext.${t.path}`,documentation:`${t.description} (PDL)`}))],sl={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 qy(t){let e=t?sl[t]:void 0;return e?vo.filter(n=>n.label==="example"||n.label==="documentation"||e.includes(n.label)):vo}c(qy,"sliceItemsFor");var d={LegacyComplianceMarker:"PLAY0565",UnknownComplianceMarker:"PLAY0566",InvalidSecretScope:"PLAY0567",DuplicateSecretScope:"PLAY0568",SecretScopeIgnoredForPii:"PLAY0569",InvalidPersonalDataQualifier:"PLAY0570",DuplicateSpecialCategory:"PLAY0571",ConflictingScreenDataBinding:"PLAY0530",ScreenDataQueryMismatch:"PLAY0531",ActionWithoutInputSurface:"PLAY0532",CommandWithoutInputSurface:"PLAY0533",ReadModelFieldWithoutOrigin:"PLAY0534",QueryParameterNotHeldByView:"PLAY0535",UnconsumedEvent:"PLAY0536",UnreachableScreen:"PLAY0537",UnknownActionSubjectField:"PLAY0345",UnresolvedActionSubject:"PLAY0346",UnreachableActionAlternative:"PLAY0347",UnknownActionArgumentProperty:"PLAY0348",UnreachableRefusalBranch:"PLAY0540",InvalidRefusalValue:"PLAY0541",UnknownRefusalConstraint:"PLAY0542",UnknownRedeliveryReaction:"PLAY0544",IndeterminateNegatedClaimTarget:"PLAY0546",InvalidRefusalBranch:"PLAY0538",InvalidRefusalBranchBody:"PLAY0539",UnmatchedRedeliveredOccurrence:"PLAY0543",InvalidNoEventsExpectation:"PLAY0545",InvalidProducesDeclaration:"PLAY0042",ProducesWhenWithoutEvent:"PLAY0043",InvalidPropertyMapping:"PLAY0044",DuplicateProducesTarget:"PLAY0193",EventSourceIdInPayload:"PLAY0469",ExplicitProducesTargetsRequired:"PLAY0470",RedundantEventId:"PLAY0471",InvalidEventId:"PLAY0472",InlineEventCollision:"PLAY0473",InlineEventOutsideCommand:"PLAY0474",InlineEventGeneration:"PLAY0475",ReservedProductionMetadata:"PLAY0476",InvalidEventDocumentation:"PLAY0477",OmittedProductionDestination:"PLAY0478",UnknownConstraintProperty:"PLAY0391",UnknownTopLevelConstruct:"PLAY0001",InvalidDomainDeclaration:"PLAY0002",DuplicateDomain:"PLAY0003",DomainNotFirst:"PLAY0004",InvalidImportDeclaration:"PLAY0005",TabIndentation:"PLAY0006",InvalidConceptDeclaration:"PLAY0007",UnknownPrimitiveType:"PLAY0008",InvalidEnumerationValue:"PLAY0009",UnknownConceptDirective:"PLAY0010",ValidateReadAsEnumerationBlock:"PLAY0011",AttributeReasonWithoutAttribute:"PLAY0012",DuplicateAttributeReason:"PLAY0013",InvalidTypeDeclaration:"PLAY0014",TypeWithoutProperties:"PLAY0015",InvalidPropertyDeclaration:"PLAY0016",IdentifierOutsideCommand:"PLAY0017",InvalidEventDeclaration:"PLAY0018",IdentifierOnEventProperty:"PLAY0019",TagPropertyReadAsTag:"PLAY0020",InvalidModuleDeclaration:"PLAY0021",UnknownModuleDirective:"PLAY0022",InvalidFeatureDeclaration:"PLAY0023",UnknownFeatureDirective:"PLAY0024",InvalidSliceDeclaration:"PLAY0027",UnknownSliceType:"PLAY0028",UnknownSliceDirective:"PLAY0029",InvalidPersonaDeclaration:"PLAY0030",InvalidPersonaPolicyReference:"PLAY0031",UnknownPersonaDirective:"PLAY0032",InvalidCommandDeclaration:"PLAY0033",UnknownCommandDirective:"PLAY0034",DuplicateCommandIdentifier:"PLAY0036",InvalidQueryDeclaration:"PLAY0047",UnknownQueryDirective:"PLAY0048",InvalidQueryParameter:"PLAY0049",InvalidProjectionDeclaration:"PLAY0056",EmptyProjection:"PLAY0057",UnknownProjectionDirective:"PLAY0058",FromWithoutEvent:"PLAY0061",InvalidEventReference:"PLAY0062",InvalidJoinDeclaration:"PLAY0063",JoinWithoutEvent:"PLAY0064",InvalidChildrenDeclaration:"PLAY0065",InvalidNestedDeclaration:"PLAY0066",NestedBlockWithoutFrom:"PLAY0067",InvalidRemoveDeclaration:"PLAY0068",UnknownRemoveDirective:"PLAY0069",InvalidClearDeclaration:"PLAY0070",ClearWithOutsideNestedBlock:"PLAY0071",InvalidSpecificationDeclaration:"PLAY0094",UnknownSpecificationDirective:"PLAY0095",InvalidSpecificationWhen:"PLAY0096",DuplicateSpecificationWhen:"PLAY0097",InvalidThenError:"PLAY0098",InvalidReadModelStep:"PLAY0099",InvalidEventStep:"PLAY0100",InvalidSpecificationValue:"PLAY0101",InvalidScreenDeclaration:"PLAY0102",UnknownScreenDirective:"PLAY0103",InvalidDataDirective:"PLAY0104",InvalidActionDirective:"PLAY0105",UnknownActionDirective:"PLAY0106",InvalidNavigation:"PLAY0107",InvalidScreenLayoutSlot:"PLAY0108",InvalidTitleDirective:"PLAY0109",UnknownTableDirective:"PLAY0110",UnknownSummaryDirective:"PLAY0111",AuthorizeWithoutPolicy:"PLAY0122",InvalidPolicyReference:"PLAY0123",InvalidConstraintDeclaration:"PLAY0132",ConstraintWithoutRule:"PLAY0133",InvalidConstraintBody:"PLAY0134",DuplicateConstraintBody:"PLAY0135",InvalidReactionDeclaration:"PLAY0136",InvalidReactionTrigger:"PLAY0137",ReactionWithoutTrigger:"PLAY0138",InvalidValidateDeclaration:"PLAY0140",InvalidValidationRule:"PLAY0141",InvalidRuleName:"PLAY0143",UnknownRuleImplementationDirective:"PLAY0144",InvalidDescription:"PLAY0145",EmptyDescription:"PLAY0146",DuplicateDescription:"PLAY0147",TagWithoutValue:"PLAY0148",InvalidTagValue:"PLAY0149",UnknownContextPath:"PLAY0153",UnknownContextCausedByProperty:"PLAY0154",UnknownContextIdentityProperty:"PLAY0155",ExpectedCodeFence:"PLAY0163",UnclosedCodeBlock:"PLAY0164",DuplicateDeclaration:"PLAY0168",RepeatedSingularDeclarationAcrossFiles:"PLAY0172",RepeatedDeclarationAcrossFiles:"PLAY0173",ConflictingDescriptionAcrossFiles:"PLAY0174",UnexpectedTokenInAuthorize:"PLAY0184",UnclosedAuthorizeGroup:"PLAY0185",InvalidReadModelDeclaration:"PLAY0186",InvalidInvokesDeclaration:"PLAY0194",InvalidScopeDeclaration:"PLAY0199",DuplicateScope:"PLAY0200",InvalidIntervalTrigger:"PLAY0249",InvalidScheduleTrigger:"PLAY0250",DuplicateReactionTrigger:"PLAY0253",InvalidSpecificationEventSource:"PLAY0275",DuplicateSpecificationEventSource:"PLAY0276",InvalidProjectionVariantDeclaration:"PLAY0277",InvalidEntersOnDeclaration:"PLAY0279",NestedProjectionVariantNotAllowed:"PLAY0280",InvalidStructuredValue:"PLAY0291",DuplicateStructuredValueMember:"PLAY0294",ConflictingSpecificationActions:"PLAY0358",InvalidSpecificationEventOrder:"PLAY0359",InvalidValidationSeverity:"PLAY0368",VariantRequiresEnteringEvent:"PLAY0382",DuplicateProjectionVariant:"PLAY0384",DuplicateVariantEnteringEvent:"PLAY0385",InvalidSpecificationDenied:"PLAY0388",DuplicateAuthorizationAcrossFiles:"PLAY0394",FileConstraintOnlySupportsUniqueness:"PLAY0396",LegacyInlineCodeFence:"PLAY0397",InvalidEventGeneration:"PLAY0446",InvalidFileImport:"PLAY0454",FileImportMatchesNothing:"PLAY0455",ImportedFileNotFound:"PLAY0456",ConflictingImportPlacement:"PLAY0457",ImportCycle:"PLAY0458",ModuleInPlacedFile:"PLAY0459",UnexpectedInPlacedFile:"PLAY0460",InvalidSpecificationClock:"PLAY0461",InvalidSpecificationTrigger:"PLAY0462",InvalidSpecificationCapture:"PLAY0463",InvalidSpecificationQueryAction:"PLAY0464",InvalidSpecificationQuery:"PLAY0265",UnknownSpecificationQueryDirective:"PLAY0266",DuplicateSpecificationQueryArguments:"PLAY0267",InvalidAbsentReadModelStep:"PLAY0453",LegacyOptionalSuffix:"PLAY0479",InvalidOptionalModifierOrder:"PLAY0480",OptionalReadsNotSupported:"PLAY0481",InvalidSpecificationCaller:"PLAY0386",DuplicateSpecificationCallerOrDenied:"PLAY0387",GeneratedPropertyOutsideCommand:"PLAY0482",InvalidGeneratedType:"PLAY0483",InvalidGeneratedModifierOrder:"PLAY0484",DuplicateEventSubject:"PLAY0590",InvalidSubjectType:"PLAY0591",ProtectedSubjectType:"PLAY0592",InvalidSubjectOwner:"PLAY0593",ReadModelSubjectNotSupported:"PLAY0594",InvalidSubjectModifierOrder:"PLAY0595",GeneratedPropertySuppliedAsInput:"PLAY0485",InvalidCommandResponse:"PLAY0486",InvalidResponseSource:"PLAY0487",DuplicateResponseField:"PLAY0488",InvalidResponseShape:"PLAY0489",InvalidGeneratedFixture:"PLAY0490",InvalidReturnExpectation:"PLAY0491",InvalidImplementationBlock:"PLAY0492",InvalidImplementationHint:"PLAY0493",ConflictingImplementationSources:"PLAY0494",UnknownType:"PLAY0165",InvalidSystemDeclaration:"PLAY0495",InvalidOperationDeclaration:"PLAY0496",InvalidProductionReference:"PLAY0497",ProductionDeclarationCollision:"PLAY0498",OperationOutsideCommand:"PLAY0499",InvalidSystemReference:"PLAY0500",InvalidOperationMapping:"PLAY0501",InvalidOperationSpecification:"PLAY0502",InvalidCaptureDeclaration:"PLAY0078",UnknownCaptureDirective:"PLAY0079",InvalidMapEntry:"PLAY0080",InvalidTranslation:"PLAY0081",InvalidSplitDeclaration:"PLAY0082",InvalidSplitTarget:"PLAY0083",InvalidAppendDeclaration:"PLAY0084",UnknownAppendDirective:"PLAY0085",WhenWithoutTrigger:"PLAY0086",InvalidWhenClause:"PLAY0087",InvalidWhenTransitionClause:"PLAY0088",MixedWhenCombinators:"PLAY0089",WhenCombinatorWithoutProperty:"PLAY0090",UnknownCaptureBlockDirective:"PLAY0091",InvalidCompositeKeyPart:"PLAY0072",TemplateInCompositeKey:"PLAY0073",EmptyCompositeKey:"PLAY0074",InvalidProjectionMapping:"PLAY0075",ExpectedLiteralValue:"PLAY0150",InvalidExpression:"PLAY0152",UnterminatedInterpolation:"PLAY0157",UnterminatedTemplateExpression:"PLAY0156",ProjectionDocumentWithoutProjection:"PLAY0055",CaptureDocumentWithoutCapture:"PLAY0077",SpecificationDocumentWithoutSpecification:"PLAY0093",InvalidSeedDeclaration:"PLAY0128",InvalidSeedGroup:"PLAY0129",InvalidSeedEvent:"PLAY0130",InvalidSeedPropertyAssignment:"PLAY0131",InvalidPolicyDeclaration:"PLAY0112",UnknownPolicyDirective:"PLAY0113",PolicyWithoutRequirement:"PLAY0114",ExpectedRoleName:"PLAY0118",ExpectedClaimName:"PLAY0119",ExpectedClaimMatches:"PLAY0120",ExpectedClaimMatchTarget:"PLAY0121",MixedPolicyImplementation:"PLAY0440",RepeatedPolicyRequirement:"PLAY0441",UnexpectedTokenInPolicyCondition:"PLAY0115",ExpectedPolicyCondition:"PLAY0116",UnclosedPolicyConditionGroup:"PLAY0117",UnexpectedTokenInCondition:"PLAY0158",ExpectedCondition:"PLAY0159",ExpectedComparisonOperator:"PLAY0161",ExpectedComparisonValue:"PLAY0162",InvalidActionAlternative:"PLAY0341",GuardedActionWithoutAlternatives:"PLAY0342",MisplacedActionOtherwise:"PLAY0343",UnsupportedActionConditionOperand:"PLAY0344",InvalidInteractionArgument:"PLAY0319",UnclosedConditionGroup:"PLAY0160",InvalidNumericDirective:"PLAY0508",DuplicateNumericDirective:"PLAY0509",LateNumericDirective:"PLAY0510",InexactNumericLiteral:"PLAY0511",MixedNumericModes:"PLAY0512",IncompatibleNumericSource:"PLAY0513",EventFromLaterSlice:"PLAY0516",TimelineCycleGroup:"PLAY0517",InvalidSpecificationExample:"PLAY0518",DuplicateSpecificationAssignment:"PLAY0519",UnresolvedSpecificationExampleType:"PLAY0520",SpecificationExampleNameCollision:"PLAY0521",SpecificationExampleKindMismatch:"PLAY0522",InvalidSpecificationExampleValue:"PLAY0523",MissingSpecificationProperty:"PLAY0524",UnadmittedSpecificationExampleValue:"PLAY0525",InvalidSpecificationExampleBody:"PLAY0526",AmbiguousReference:"PLAY0198",InvalidSpecificationStream:"PLAY0547",SpecificationStreamOnCommand:"PLAY0548",InvalidSpecificationStreamRoute:"PLAY0549",InvalidSpecificationStreamEventSource:"PLAY0550",SpecificationStreamContradictsCommand:"PLAY0551",InvalidDependencyTarget:"PLAY0554",RepeatedDependencyDeclaration:"PLAY0555",UndeclaredDependency:"PLAY0552",UnusedDependencyDeclaration:"PLAY0553",MutualDependencyDeclarations:"PLAY0556",AuthorizationRefusalWithoutIdentity:"PLAY0557",InvalidDocumentation:"PLAY0558",ConflictingDocumentationAcrossFiles:"PLAY0559",InvalidSpecificationCallerPersona:"PLAY0572",UnsynthesizablePersonaCaller:"PLAY0573",PersonaWithoutGate:"PLAY0574",GateWithoutPersona:"PLAY0575",AmbiguousPersonaCaller:"PLAY0576",InvalidSpecificationParameter:"PLAY0577",InvalidSpecificationCase:"PLAY0578",DuplicateSpecificationParameter:"PLAY0579",DuplicateSpecificationCase:"PLAY0580",IncompleteSpecificationTable:"PLAY0581",InvalidSpecificationCaseAssignment:"PLAY0582",InvalidSpecificationCaseValue:"PLAY0583",InvalidSpecificationCaseReference:"PLAY0584",OptionalSpecificationParameterTarget:"PLAY0585",SpecificationCaseNameCollision:"PLAY0586",IncompatibleSpecificationParameterType:"PLAY0587",UnusedSpecificationParameter:"PLAY0588",SingularSpecificationTableExpansion:"PLAY0589",UnsupportedInteractionAlternatives:"PLAY0560",MixedInteractionAlternatives:"PLAY0561",InteractionAlternativeWithoutActions:"PLAY0562",InlineInteractionAlternative:"PLAY0563",LegacyInteractionWhere:"PLAY0564",InvalidEventSourceDeclaration:"PLAY0503",InvalidCommandStream:"PLAY0504",AmbiguousCommandStream:"PLAY0505",UnsupportedStreamIdType:"PLAY0506",RedundantSourceStreamId:"PLAY0507",UnknownEvent:"PLAY0166",UnknownReadModelProperty:"PLAY0514",PiiNotSupportedOnIdentifier:"PLAY0515",HandlerWithoutImplementation:"PLAY0045",UnknownHandlerDirective:"PLAY0046",CommandWithProducesAndHandler:"PLAY0035",AbsoluteFileReference:"PLAY0264",InvalidTriggerData:"PLAY0246"};var Hi="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}",U="[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";function Q(t){let e=`(?=[\\u0000-\\uFFFF])[${Hi}]`,n=t.replace(/\[([^\]]*\\w[^\]]*)\]/g,(i,r)=>{let o=r.replaceAll("\\w","");return o===""?`(?:${e})`:`(?:${e}|[${o}])`});return new RegExp(n.replaceAll("\\w",`(?:${e})`),"u")}c(Q,"nativePattern");function w(t){let e="",n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&i+1<t.length){let o=t[i+1];i++,o==="w"?e+=n?Hi:`[${Hi}]`:o==="d"?e+="\\p{Nd}":e+=`\\${o}`;continue}r==="["&&!n?n=!0:r==="]"&&n&&(n=!1),e+=r}return new RegExp(e,"u")}c(w,"pattern");var ll=new RegExp(`^depends${U}+on(?:${U}|$)`,"u"),cl=new RegExp(`${U}+$`,"u");function wt(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,l=a.length-a.trimStart().length,p=dl(a.substring(l),e),m=ll.test(p)?p.replace(cl,""):p.trimEnd();i.push(n===void 0?{number:r,raw:a,indent:l,content:m,startOffset:o}:{number:r,raw:a,indent:l,content:m,path:n,startOffset:o}),o+=s.length+1}return i}c(wt,"splitLines");function tn(t,e=!1){let n=!1,i=!1;for(let r=0;r<t.length;r++){let o=t[r];if(o==="\\"&&n&&r+1<t.length)r++;else if(o==='"'&&!i)n=!n;else if(o==="`"&&!n)i=!i;else if(!n&&!i&&(o==="/"&&r+1<t.length&&t[r+1]==="/"||e&&o==="#"))return r}return-1}c(tn,"commentStart");function dl(t,e){let n=tn(t,e);return n<0?t:t.substring(0,n)}c(dl,"stripComment");function ae(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}c(ae,"eventDeclarations");function Rn(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}c(Rn,"operationDeclarations");var ie;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(ie||(ie={}));var re=class{static{c(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e){let n=c((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 ae(i)){let l=o.get(a.name)??[];l.push(a),o.set(a.name,l)}let s=[...o.values()].flatMap(a=>new Set(a.map(l=>l.generation)).size!==a.length?a:[a.reduce((l,p)=>l.generation>=p.generation?l:p)]);this.declarations.push(...s.map(a=>({kind:ie.Event,name:a.name,node:a,scope:r})),...Rn(i).map(a=>({kind:ie.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:ie.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?ie.Unresolved:ie.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===ie.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==ie.Operation&&!(i.kind===ie.Ambiguous&&i.candidates.some(r=>r.kind===ie.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,l)=>s.scope[s.scope.length-o.length+l]===a));for(let s=n.length;s>=0;s--){let a=r.filter(l=>s<=l.scope.length&&n.slice(0,s).every((p,m)=>l.scope[m]===p));if(a.length>0)return a}return[]}};var se;(function(t){t.Unique="unique",t.Ambiguous="ambiguous",t.NotFound="notFound",t.WrongKind="wrongKind"})(se||(se={}));var Oe=class{static{c(this,"EventSourceCatalog")}sources=new Map;otherNames;constructor(e){for(let n of e.eventSources??[])this.sources.set(n.name,[...this.sources.get(n.name)??[],n]);this.otherNames=new Set([...e.concepts,...e.types].map(n=>n.name))}resolve(e,n){let i=this.sources.get(e)??[],r=i.flatMap(s=>s.streams).filter(s=>s.name===n),o;return i.length===0?o=this.otherNames.has(e)?se.WrongKind:se.NotFound:i.length>1||r.length>1?o=se.Ambiguous:o=r.length===1?se.Unique:se.NotFound,{kind:o,sources:i,streams:r}}};function bo(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}c(bo,"eventProductions");function Xi(t,e){let n=bo(t,e),i=t.properties.find(r=>r.isIdentifier)?.name;return n.some(r=>r.for!==null&&(r.for.kind!=="PathExpressionSyntax"||r.for.path!==i))||n.some(r=>r.inlineEvent!==null&&r.for===null)&&n.some(r=>r.inlineEvent===null&&r.for===null)}c(Xi,"requiresExplicitDestinations");function ko(t,e,n){let i=bo(t,n);if(e.inlineOperation!=null||n!==void 0&&!n.resolver.isEventProduction(e,n.slice)||e.for!==null||Xi(t,n))return;if(e.inlineEvent===null)return i.some(o=>o.for!==null||o.inlineEvent!==null)?void 0:"new event source";let r=t.properties.filter(o=>o.isIdentifier&&!o.type.isOptional&&!o.type.isCollection);return r.length===1?r[0].name:void 0}c(ko,"implicitDestination");var er="79228162514264337593543950335";function He(t){let e=Co(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>er.length)return;let a=n.substring(i,r)+"0".repeat(s);if(a.length===er.length&&a>er)return;let l=Math.max(0,o),p=l===0?a:a.length>l?`${a.substring(0,a.length-l)}.${a.substring(a.length-l)}`:`0.${"0".repeat(l-a.length)}${a}`;return Object.freeze({literalType:"ExactNumber",value:(e.negative?"-":"")+p})}c(He,"parseExactNumber");function nn(t){return Co(t)!==void 0}c(nn,"isExactNumberToken");function Co(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&tr(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let a=++i;for(;i<t.length&&tr(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 l=i,p=t.length+29;for(;i<t.length&&tr(t[i]);)s=Math.min(p,s*10+t.charCodeAt(i++)-48);if(i===l)return;a&&(s=-s)}return i===t.length?{negative:e,integer:r,fraction:o,exponent:s}:void 0}c(Co,"scan");function tr(t){return t>="0"&&t<="9"}c(tr,"isDigit");var nr=class extends Error{static{c(this,"InvalidExactNumber")}};function ir(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||He(t.value)?.value!==t.value)throw new nr("Expected a canonical, bounded ExactNumber value.");return t.value}c(ir,"canonicalExactText");function Eo(t){return!ir(t).includes(".")}c(Eo,"exactIsIntegral");var pl=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,fl=/^([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 rr(t,e){let n=(e?fl:pl).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 l=Number(n[7]),p=Number(n[8]);return l<=14&&p<=59&&(l!==14||p===0)}c(rr,"responseDateValue");var ul="http://schemas.microsoft.com/ws/2008/06/identity/claims/role",or=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),dt=c(t=>Array.from(t,e=>{let n=e.toUpperCase();return n.length===e.length&&e!=="\u0131"&&e!=="\u017F"?n:e}).join(""),"claimTypeKey");function on(t,e){let n=[],i=[],r=c(a=>({caller:null,contributions:n,refusal:a}),"refused");if(t.policies.length===0)return r({policy:null,reason:"noPolicies",location:t.location});for(let a of t.policies){let l=(e.policies??[]).find(m=>m.name===a);if(!l)return r({policy:a,reason:"unresolvedPolicy",location:t.location});if(l.condition===null||l.code!==null||l.file!==null)return r({policy:a,reason:"opaqueImplementation",location:l.location});let p=ar(l.condition);if(p)return r({policy:a,reason:"negation",location:p.location});i.push(l)}for(let a of i){let l=sr(a.condition,a.name,n);if(l)return r(l)}for(let a of i){let l=rn(a.condition,a.name,n);if(l)return r(l)}let o=[...new Set(n.filter(a=>a.kind==="role").map(a=>a.value))].sort(or),s=[];for(let a of n.filter(l=>l.kind==="claim"))s.some(l=>dt(l.type)===dt(a.type)&&l.value===a.value)||s.push({kind:"SpecificationCallerClaimSyntax",type:a.type,value:a.value,location:a.location});return s.sort((a,l)=>or(dt(a.type),dt(l.type))||or(a.value,l.value)),{caller:{kind:"SpecificationCallerSyntax",authenticated:!0,roles:o,claims:s,location:t.location},contributions:n,refusal:null}}c(on,"synthesizePersonaCaller");function ar(t){return t.kind==="NotPolicyConditionSyntax"?t:t.kind==="LogicalPolicyConditionSyntax"?ar(t.left)??ar(t.right):null}c(ar,"negation");function Po(t,e,n){switch(t.kind){case"AuthenticatedConditionSyntax":return n.push({kind:"authenticated",value:"true",type:null,policy:e,location:t.location}),null;case"RoleConditionSyntax":return n.push({kind:"role",value:t.role,type:null,policy:e,location:t.location}),null;case"ClaimConditionSyntax":if(dt(t.claim)===dt(ul))return{policy:e,reason:"roleClaim",location:t.location};if(!t.matchesSubject&&t.matches?.kind==="LiteralExpressionSyntax"&&typeof t.matches.value=="string")return n.push({kind:"claim",value:t.matches.value,type:t.claim,policy:e,location:t.location}),null}return{policy:e,reason:"nonLiteralClaim",location:t.location}}c(Po,"atom");function sr(t,e,n){return t.kind!=="LogicalPolicyConditionSyntax"?Po(t,e,n):t.operator==="Or"?null:sr(t.left,e,n)??sr(t.right,e,n)}c(sr,"required");function Ot(t,e){switch(t.kind){case"AuthenticatedConditionSyntax":return!0;case"RoleConditionSyntax":return e.some(n=>n.kind==="role"&&n.value===t.role);case"ClaimConditionSyntax":{let n=t.matches;return!t.matchesSubject&&n?.kind==="LiteralExpressionSyntax"&&e.some(i=>i.kind==="claim"&&dt(i.type)===dt(t.claim)&&i.value===n.value)}case"LogicalPolicyConditionSyntax":return t.operator==="And"?Ot(t.left,e)&&Ot(t.right,e):Ot(t.left,e)||Ot(t.right,e);default:return!1}}c(Ot,"satisfied");function rn(t,e,n){if(t.kind!=="LogicalPolicyConditionSyntax")return Ot(t,n)?null:Po(t,e,n);if(t.operator==="And")return rn(t.left,e,n)??rn(t.right,e,n);if(Ot(t,n))return null;let i=[...n],r=rn(t.left,e,i);if(r===null)return n.push(...i.slice(n.length)),null;let o=[...n];return rn(t.right,e,o)!==null?r:(n.push(...o.slice(n.length)),null)}c(rn,"complete");var lr=new WeakMap;var H='(?:[^"\\\\]|\\\\.)*',ml={"\\":"\\",'"':'"',n:`
|
|
15
|
-
`,r:"\r",t:" "};function ee(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.length?ml[t[n+1]]:void 0;t[n]==="\\"&&i!==void 0?(e+=i,n++):e+=t[n]}return e}c(ee,"unescapeString");var Ao=64,Ie=class extends Error{static{c(this,"InvalidStructuredValue")}},Dn=class{static{c(this,"StructuredValueParser")}text;start;context;#e=0;constructor(e,n,i){this.text=e,this.start=n,this.context=i}parse(){let e=this.#t(0);if(this.#s(),this.#e<this.text.length)throw new Ie(`'${this.text[this.#e]}' is invalid after a single JSON value.`);return e}#t(e){this.#s();let n=this.#l(),i=this.text[this.#e];if(i==="["||i==="{"){if(e>=Ao)throw new Ie(`The value nests deeper than ${Ao} 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.#a(n)}#o(e,n){this.#e++;let i=[];if(this.#s(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};for(;;){if(i.push(this.#t(e+1)),this.#s(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};this.#d(",")}}#r(e,n){this.#e++;let i=[],r=new Set;if(this.#s(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};for(;;){this.#s();let o=this.#l();if(this.text[this.#e]!=='"')throw new Ie("Expected a property name in double quotes.");let s=this.#n();this.#s(),this.#d(":");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.#s(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};this.#d(",")}}#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 Ie(`${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 Ie("A string is not closed.")}#a(e){let n=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(this.text.substring(this.#e));if(n===null)throw new Ie(`'${this.text[this.#e]??""}' is an invalid start of a value.`);if(this.#e+=n[0].length,this.context?.sourceOptions.numericMode==="exact"){let r=He(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 Ie("JSON number is outside the finite Double range.");return{kind:"LiteralExpressionSyntax",value:i,location:e}}#l(){return{...this.start,column:this.start.column+this.#e}}#s(){for(;this.#e<this.text.length&&`
|
|
16
|
-
\r`.includes(this.text[this.#e]);)this.#e++}#c(e){return this.text[this.#e]!==e?!1:(this.#e++,!0)}#d(e){if(!this.#c(e))throw new Ie(`Expected '${e}' at position ${this.#e}.`)}};var yl=w("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),hl=Q("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Sl=w("^-?\\d+(\\.\\d+)?$"),wo=["command","arguments","tenant","causedBy","causation","occurred","identity"],Oo=["subject","name","userName"],Io=["id","name","userName","isAuthenticated","roles","claims"];function Te(t,e,n){return ce(t,e,n,!0)}c(Te,"parseModeledMappingSource");function ce(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 gl(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 Dn(t,e,n).parse()}catch(o){if(!(o instanceof Ie))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?an(t,e):an(t,e,n);return r!==void 0?r:(i||n?.sourceOptions.numericMode==="exact"?hl:yl).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}c(ce,"parseMappingSource");function gl(t,e,n){let[i,r]=t.split(".");wo.includes(i)?r!==void 0&&i==="causedBy"&&!Oo.includes(r)?n?.warning(d.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${Oo.join(", ")}`,e):r!==void 0&&i==="identity"&&!Io.includes(r)&&n?.warning(d.UnknownContextIdentityProperty,`Unknown $context.identity property '${r}' - expected ${Io.join(", ")}`,e):n?.warning(d.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${wo.join(", ")}`,e)}c(gl,"warnOnUnknownContextPath");function an(t,e,n){let i=c(o=>({kind:"LiteralExpressionSyntax",value:o,location:e}),"literal");switch(t){case"true":return i(!0);case"false":return i(!1);case"null":return i(null)}if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")))return i(ee(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!nn(t))return;let o=He(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(Sl.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}c(an,"parseLiteral");var D=c(t=>{let e=t.indexOf(" ");return e===-1?t:t.substring(0,e)},"firstWord"),ne=c(t=>t.replaceAll("@",""),"unescapeIdentifier");function To(t,e){let n=[],i=0,r=!1,o=!1;for(let s=0;s<t.length;s++){let a=t[s];a==="\\"&&r&&s+1<t.length?s++:a==='"'&&!o?r=!r:a==="`"&&!r?o=!o:a===e&&!r&&!o&&(n.push(t.substring(i,s)),i=s+1)}return n.push(t.substring(i)),n}c(To,"splitTopLevel");var It=c((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var cr=c(t=>t.content.length===0,"isBlank"),u=c(t=>It(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),Ro=c(t=>It(t.number,1,t.path),"startOf");var xl=w("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?$"),Do=w("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject)(?:\\s+(?:optional|generated|identifier|subject))*)$"),vl=w("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function Qe(t){let e=xl.exec(t.content);if(e===null)return;let n=u(t);return{kind:"PropertySyntax",name:ne(e[1]),type:Re(e[2],{...n,column:n.column+t.content.indexOf(e[2],e[1].length)}),isGenerated:e[3]!==void 0,nameWasEscaped:e[1].startsWith("@"),isIdentifier:e[4]!==void 0,...e[5]!==void 0?{isSubject:!0}:{},location:n}}c(Qe,"tryParseProperty");function Re(t,e){let n=t.endsWith("?"),i=/\soptional$/.test(t),r=n||i;r&&(t=t.substring(0,t.length-(n?1:8)).trimEnd());let o=t.endsWith("[]");return o&&(t=t.substring(0,t.length-2)),{kind:"TypeRefSyntax",name:t,isCollection:o,isOptional:r,location:e}}c(Re,"parseTypeRef");function De(t,e){let n=Qe(e);return n!==void 0?Be(t,n.type,e):Mn(t,e),n}c(De,"parseProperty");function Be(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)}}c(Be,"reportLegacyOptionalSuffix");function Mn(t,e){let n=Do.exec(e.content);if(n!==null&&n[1].split(/\s+/).includes("subject"))return t.error(d.InvalidSubjectModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier subject'.",u(e)),!0;if(vl.test(e.content))return t.error(d.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",u(e)),!0;{let i=Do.exec(e.content);if(i!==null&&i[1].split(/\s+/).some(r=>r==="generated"||r==="identifier"))return t.error(d.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",u(e)),!0}return!1}c(Mn,"reportInvalidModifierOrder");var dr=w("^then\\s+returns\\b"),jn=w("^generated\\s+(?=\\S)(?![=])"),Nn=w("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),$l=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),bl=w(`^(?:"${H}"|'(?:[^'\\\\]|\\\\.)*')$`);function Tt(t,e,n,i){if(e.startsWith("case."))return Pe(e,n,t);if(Dt(e)&&t.error(d.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",n),(e.startsWith('"')||e.startsWith("'"))&&!bl.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=ce(e,n,t);return!["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(r.kind)||r.kind==="LiteralExpressionSyntax"&&typeof r.value=="number"&&!Number.isFinite(r.value)?(t.error(i,"Expected exactly one concrete literal or structured value, not an expression.",n),null):r}c(Tt,"parseConcrete");function Rt(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.",u(e)),t.skipBlock(e.indent),null;let o=u(e),s=Tt(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.",u(a)),t.skipBlock(e.indent)),s===null?null:{kind:"PropertyMappingSyntax",property:r[1],source:s,location:o}}c(Rt,"parseConcreteMapping");function Mo(t,e){let n=dr.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=u(e);if(i.length>0){let s=Tt(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.",u(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=Rt(t,s,$l,d.InvalidReturnExpectation);a!==null&&o.push(a)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}c(Mo,"parseReturn");var kl=new RegExp(w("^case\\s+([A-Za-z_]\\w*)(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?$").source,"du"),Cl=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),El=w("^case\\.([a-z_]\\w*)$");function Dt(t){return/\bcase\.[a-z_]\w*/.test(t.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,""))}c(Dt,"containsCaseReference");function Pe(t,e,n,i=!1){if(!t.startsWith("case."))return Dt(t)&&n.error(d.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",e),ce(t,e,n,i);let r=El.exec(t);return r===null&&n.error(d.InvalidSpecificationCaseReference,"A case reference fills a whole value position: 'case.<parameter>'.",e),{kind:"CaseValueExpressionSyntax",parameter:r?.[1]??t.substring(5),location:e}}c(Pe,"parseSpecificationValue");function jo(t,e){let n=e.content.indexOf(" ")+1,i=n>0?De(t,{...e,content:e.content.substring(n),indent:e.indent+n}):void 0;if(i===void 0||i.isGenerated||i.isIdentifier)return t.error(d.InvalidSpecificationParameter,"Expected 'parameter <name> <Type>', with optional collection and optional modifiers.",u(e)),t.skipOpaqueBlock(e.indent),null;let r=t.peekChild(e.indent);return r!==void 0&&(t.error(d.InvalidSpecificationParameter,"A parameter has no body or default.",u(r)),t.skipOpaqueBlock(e.indent)),{kind:"SpecificationParameterSyntax",name:i.name,type:i.type,location:u(e)}}c(jo,"parseParameter");function No(t,e){let n=kl.exec(e.content);if(n===null)return t.error(d.InvalidSpecificationCase,"Expected 'case <Name>' with at most one inline parameter assignment.",u(e)),t.skipOpaqueBlock(e.indent),null;let i=[],r=c((o,s,a)=>{let l=u(a),p={...l,column:l.column+a.content.indexOf(s,a.content.indexOf("=")+1)};if(s.startsWith("case.")){t.error(d.InvalidSpecificationCaseValue,"A case assigns concrete values, not case references.",p);return}let m=Tt(t,s,p,d.InvalidSpecificationCaseValue);m!==null&&i.push({kind:"PropertyMappingSyntax",property:o,source:m,location:a===e?{...l,column:l.column+n.indices.groups.property[0]}:l})},"add");n.groups?.property!==void 0&&r(n.groups.property,n.groups.value,e);for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=Cl.exec(o.content);if(s===null){t.error(d.InvalidSpecificationCaseAssignment,"Expected '<parameter> = <concrete value>' in a case.",u(o)),t.skipOpaqueBlock(o.indent);continue}r(s[1],s[2],o);let a=t.peekChild(o.indent);a!==void 0&&(t.error(d.InvalidSpecificationCaseValue,"A case value must fit on one line.",u(a)),t.skipOpaqueBlock(o.indent))}return{kind:"SpecificationCaseSyntax",name:n[1],values:i,location:u(e)}}c(No,"parseCase");function Mt(t){return Array.isArray(t)?t.flatMap(Mt):t===null||typeof t!="object"?[]:"kind"in t&&t.kind==="CaseValueExpressionSyntax"?[t]:Object.values(t).flatMap(Mt)}c(Mt,"caseReferences");function Lo(t,e){let n=t.parameters??[],i=t.cases??[];n.length===0!=(i.length===0)&&e.error(d.IncompleteSpecificationTable,"A specification table requires parameters and at least one case.",t.location),n.forEach((o,s)=>{n.slice(0,s).some(a=>a.name===o.name)&&e.error(d.DuplicateSpecificationParameter,`Parameter '${o.name}' is declared more than once.`,o.location)}),i.forEach((o,s)=>{i.slice(0,s).some(a=>a.name===o.name)&&e.error(d.DuplicateSpecificationCase,`Case '${o.name}' is declared more than once.`,o.location);for(let a of o.values.filter(l=>!n.some(p=>p.name===l.property)))e.error(d.InvalidSpecificationCaseAssignment,`Case '${o.name}' assigns undeclared parameter '${a.property}'.`,a.location);for(let a of n.filter(l=>o.values.filter(p=>p.property===l.name).length!==1))e.error(d.InvalidSpecificationCaseAssignment,`Case '${o.name}' must assign parameter '${a.name}' exactly once.`,o.location)});let r=Mt(t);for(let o of r)(i.length===0||!n.some(s=>s.name===o.parameter))&&e.error(d.InvalidSpecificationCaseReference,`Case reference '${o.parameter}' requires a declared parameter in a specification table.`,o.location);for(let o of n.filter(s=>!r.some(a=>a.parameter===s.name)))e.warning(d.UnusedSpecificationParameter,`Parameter '${o.name}' is never referenced.`,o.location);for(let o of Mt(t.whenRedelivered))e.error(d.InvalidSpecificationCaseReference,"Case references are not permitted in redelivery locators.",o.location)}c(Lo,"validateTable");function bt(t,e,n=new WeakMap){if(t!==null&&typeof t=="object"&&n.has(t))return n.get(t);if(Array.isArray(t)){let r=t.map(o=>bt(o,e,n));return n.set(t,r),r}if(t===null||typeof t!="object"||!("kind"in t))return t;if(t.kind==="CaseValueExpressionSyntax"){let r=t.parameter;return e.values.find(o=>o.property===r)?.source??t}let i=Object.fromEntries(Object.entries(t).map(([r,o])=>[r,bt(o,e,n)]));if(t.kind==="SpecificationErrorSyntax"&&"caseValue"in t&&t.caseValue!==void 0){let r=i.caseValue;i.name=r.kind==="LiteralExpressionSyntax"?r.value:null,delete i.caseValue}return n.set(t,i),i}c(bt,"substituteCase");var Xe=new WeakMap,Ye=c(t=>Xe.get(t)??{},"dependencySourcesOf");function jt(t){let e=[],n=c((a,l)=>{for(let p of a??[])e.push({name:p.name,scope:l,example:p})},"examples"),i=c((a,l)=>{for(let p of a){let m=[...l,p.name];n(p.examples,m);for(let f of p.slices){let y=[...l,p.name,f.name];n(f.examples,y);for(let h of new Set(ae(f).map(v=>v.name)))e.push({name:h,scope:y,kind:"event"});for(let h of f.commands)e.push({name:h.name,scope:y,kind:"command"});for(let h of f.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=c((a,l)=>{let p=c(y=>{let h=y.split("."),v=e.filter(S=>S.name===h.at(-1)),x=h.slice(0,-1);if(x.length)return v.filter(S=>x.length<=S.scope.length&&x.every((E,g)=>S.scope[S.scope.length-x.length+g]===E));for(let S=l.length;S>=0;S--){let E=v.filter(g=>S<=g.scope.length&&l.slice(0,S).every((P,A)=>g.scope[A]===P));if(E.length)return E}return[]},"candidates"),m=p(a),f=t.imports.filter(y=>y.qualifiedName.split(".").at(-1)===a);return!m.length&&f.length===1&&(m=p(f[0].qualifiedName)),m.length===1?m[0]:void 0},"resolve"),o=c((a,l,p)=>{let m=r(a,p),f=m?.example;if(!f)return null;let y=r(f.type,m.scope);return y?.kind===l?{example:f,name:[...y.scope,y.name].join(".")}:null},"fixture"),s=c((a,l)=>[...a.filter(p=>!l.some(m=>m.property===p.property)),...l],"merge");return{resolvedExamples:e.filter(a=>a.example!==void 0).flatMap(a=>{let l=r(a.example.type,a.scope);return l?.kind===void 0?[]:[{example:a.example,kind:l.kind,name:[...l.scope,l.name].join("."),scope:l.scope}]}),eventStep:c((a,l,p)=>{let m=o(a.eventType,"event",p),f=m?.example??null,y=f?.stream??f?.noStream??null,h=a.stream??a.noStream??null,v=h??y,x=m===null?a:{...a,eventType:m.name,values:s(f.values,a.values),for:a.for??f.for,stream:v?.kind==="SpecificationStreamSyntax"?v:null,noStream:v?.kind==="SpecificationNoStreamSyntax"?v:null},S=x.values.map(E=>{let g=f?.values.find(A=>A.property===E.property),P=a.values.includes(E);return{property:E.property,value:E.source,origin:P?g===void 0?"authored":"override":"example",overriddenValue:P?g?.source??null:null}});return x.for!==null&&S.push({property:"for",value:x.for,origin:a.for===null?"example":f?.for==null?"authored":"override",overriddenValue:a.for===null?null:f?.for??null}),{role:l,authored:a,effective:x,example:f,values:S,route:v===null?null:{value:v,origin:h===null?"example":y===null?"authored":"override",overriddenValue:h===null?null:y}}},"eventStep"),command:c((a,l)=>{if(!a)return a;let p=o(a.commandType,"command",l);if(!p)return a;let{example:m,name:f}=p;return{...a,commandType:f,values:s(m.values,a.values),generatedValues:s(m.generatedValues,a.generatedValues??[]),for:a.for??m.for}},"command"),readModel:c((a,l)=>{let p=o(a.name,"readmodel",l);return p?{...a,name:p.name,properties:s(p.example.values,a.properties)}:a},"readModel")}}c(jt,"specificationExamples");function Ln(t){return jt(t).command}c(Ln,"specificationCommandExamples");function Fe(t){return qn(t).application}c(Fe,"expandSpecificationExamples");function qn(t){let e=jt(t),n=[],i=c((r,o)=>r.map(s=>{let a=[...o,s.name];return{...s,features:i(s.features,a),slices:s.slices.map(l=>{let p=[...o,s.name,l.name],m={...l,specifications:l.specifications.flatMap(f=>{let y=[],h=c((g,P)=>{let A=e.eventStep(g,P,p);return y.push(A),A.effective},"event"),v=t.personas.find(g=>g.name===f.givenCallerPersona?.name),x=v===void 0?null:on(v,t),S=x?.caller==null?null:{...x.caller,location:f.givenCallerPersona.location};S!==null&&y.push({role:"given caller",authored:f.givenCallerPersona,effective:S,example:null,route:null,values:x.contributions.map(g=>({property:g.type??g.kind,value:{kind:"LiteralExpressionSyntax",value:g.kind==="authenticated"?!0:g.value,location:g.location},origin:"persona",overriddenValue:null,persona:v.name,policy:g.policy}))});let E={...f,...S===null?{}:{givenCaller:S,givenCallerPersona:void 0},given:f.given.map(g=>h(g,"given")),givenReadModels:f.givenReadModels.map(g=>e.readModel(g,p)),when:e.command(f.when,p),whenAppended:f.whenAppended===null?null:h(f.whenAppended,"when append"),thenEvents:f.thenEvents.map(g=>h(g,"then")),thenReadModels:f.thenReadModels.map(g=>e.readModel(g,p))};return(f.cases?.length??0)===0?(n.push({authored:f,effective:E,steps:y}),[E]):f.cases.map(g=>{let P=new WeakMap,A={...bt(E,g,P),name:`${f.name}_${g.name}`,parameters:[],cases:[]};return lr.set(A,{table:f.name,case:g.name}),n.push({authored:f,effective:A,table:f.name,case:g.name,steps:y.map($=>({...$,effective:bt($.effective,g,P),values:$.values.map(b=>b.value.kind==="CaseValueExpressionSyntax"?{...b,value:bt(b.value,g,P),origin:"case",caseParameter:b.value.parameter}:b),route:$.route===null?null:{...$.route,value:bt($.route.value,g,P)}}))}),A})})};return Xe.set(m,Ye(l)),m})}}),"features");return{application:{...t,modules:t.modules.map(r=>({...r,features:i(r.features,[r.name])}))},specifications:n}}c(qn,"expandEffectiveSpecificationExamples");var Bn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Yn(t,e,n=e.inputUses){let i=Ln(t),r=[],o=c(($,b)=>{let k=[...b,$.name];$.slices.forEach(C=>r.push({slice:C,scope:[...k,C.name]})),$.features.forEach(C=>o(C,k))},"collect");t.modules.forEach($=>$.features.forEach(b=>o(b,[$.name])));let s=new Map,a=new Map,l=new Map;for(let{slice:$,scope:b}of r)for(let k of $.commands){let C=s.get(k.name)??[];C.push({command:k,scope:b}),s.set(k.name,C),a.set(k,te(k.properties)),k.response?.kind==="RecordCommandResponseSyntax"&&l.set(k,te(k.response.fields))}let p=new Map;for(let $ of t.imports){let b=$.qualifiedName.split(".").at(-1);p.set(b,[...p.get(b)??[],$.qualifiedName])}let m=new Map,f=c(($,b)=>{let k=`${b.join(".")}|${$}`;if(m.has(k))return m.get(k);let C=p.get($)??[],R=((s.get($.split(".").at(-1))??[]).length===0&&C.length===1?C[0]:$).split("."),j=s.get(R.at(-1))??[];if(R.length>1){let B=R.slice(0,-1);j=j.filter(L=>B.length<=L.scope.length&&B.every((W,V)=>L.scope[L.scope.length-B.length+V]===W))}else for(let B=b.length;B>=0;B--){let L=j.filter(W=>B<=W.scope.length&&b.slice(0,B).every((V,G)=>W.scope[G]===V));if(L.length>0){j=L;break}}let N=j.length===1?j[0].command:null;return m.set(k,N),N},"resolve"),y=te(t.concepts),h=new Set(t.concepts.map($=>$.name)),v=new Map([...te(t.types)].map(([$,b])=>[$,te(b.properties)])),x=new Set(r.flatMap($=>$.slice.readModels.map(b=>b.name))),S=new Set([...a.keys()].flatMap($=>[...$.properties])),E=c($=>{for(let b of $)b.isGenerated&&!S.has(b)&&e.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",b.location)},"checkDeclarations"),g=c($=>{$.features.forEach(g);for(let b of $.slices){for(let k of b.commands)for(let C of k.produces)C.inlineEvent!==null&&E(C.inlineEvent.properties);b.events.forEach(k=>E(k.properties)),b.readModels.forEach(k=>E(k.properties));for(let k of b.reactions)for(let C of k.triggers)for(let O of C.produces)O.inlineEvent!==null&&E(O.inlineEvent.properties)}},"checkFeature");t.types.forEach($=>E($.properties)),t.modules.forEach($=>$.features.forEach(g));let P=c(($,b,k)=>{let C=a.get(k).get($.property);if(C===void 0){e.error(d.InvalidResponseSource,`Response source '${$.property}' must reference one direct command property.`,$.location);return}let O=C.type;(O.isCollection||x.has(O.name))&&e.error(d.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",$.location),b!==null&&(b.name!==O.name||b.isCollection!==O.isCollection||b.isOptional!==O.isOptional)&&e.error(d.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",b.location)},"validateSource");for(let $ of a.keys()){for(let k of $.properties){if(!k.isGenerated)continue;let C=y.get(k.type.name);(k.type.isOptional||k.type.isCollection||(C===void 0?Bn.has(k.type.name)||v.has(k.type.name)||h.has(k.type.name)||x.has(k.type.name):C.type!=="Uuid"))&&e.error(d.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",k.location)}let b=$.response;if(b?.kind==="ScalarCommandResponseSyntax")P(b.source,null,$);else if(b?.kind==="RecordCommandResponseSyntax"){b.fields.length===0&&e.error(d.InvalidCommandResponse,"A response block requires at least one field.",b.location);let k=new Set;for(let C of b.fields)k.has(C.name)&&e.error(d.DuplicateResponseField,`Duplicate response field '${C.name}'.`,C.location),k.add(C.name),P(C.source,C.type,$)}}let A=c(($,b)=>{let k=i($.when,b),C=k===null?null:f(k.commandType,b);if(k!==null&&C!==null){let j=a.get(C);for(let L of k.values)j.get(L.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${L.property}' cannot be supplied as request or form input.`,L.location);let N=[...j.values()].filter(L=>L.isIdentifier);if(k.for!==null&&N.length===1&&N[0].isGenerated){let L=N[0].type;(Bn.has(L.name)||y.has(L.name)||v.has(L.name))&&(L.isOptional||L.isCollection||y.get(L.name)?.type!=="Uuid"||k.for.kind!=="LiteralExpressionSyntax"||typeof k.for.value!="string"||!qo(k.for.value))&&e.error(d.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",k.for.location)}let B=new Set;for(let L of k.generatedValues??[]){let W=j.get(L.property);(B.has(L.property)||W===void 0||!W.isGenerated||W.isIdentifier||!ve(L.source,W.type,y,v))&&e.error(d.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",L.location),B.add(L.property)}}let O=$.thenReturns;if(O==null||((k===null||$.thenErrors.length>0||$.thenDenied!=null)&&e.error(d.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",O.location),C===null))return;let I=C.response,R=a.get(C);if(O.kind==="ScalarSpecificationReturnSyntax"&&I?.kind==="ScalarCommandResponseSyntax"&&R.has(I.source.property))ve(O.value,R.get(I.source.property).type,y,v)||e.error(d.InvalidReturnExpectation,"The expected return value must match the response source's type.",O.location);else if(O.kind==="RecordSpecificationReturnSyntax"&&I?.kind==="RecordCommandResponseSyntax"){O.fields.length===0&&e.error(d.InvalidReturnExpectation,"A record return expectation requires at least one field.",O.location);let j=l.get(C),N=new Set;for(let B of O.fields){let L=j.get(B.property),W=L===void 0?void 0:R.get(L.source.property);(N.has(B.property)||W===void 0||!ve(B.source,W.type,y,v))&&e.error(d.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",B.location),N.add(B.property)}}else e.error(d.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",O.location)},"validateSpecification");for(let{slice:$,scope:b}of r)$.specifications.forEach(k=>A(k,b));for(let $ of n){if($.isParameter===!0)continue;let b=f($.command,$.scope);b!==null&&a.get(b).get($.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${$.property}' cannot be supplied as request or form input.`,$.location)}}c(Yn,"validateResponses");function te(t){let e=new Map,n=new Set;for(let i of t)e.has(i.name)&&n.add(i.name),e.set(i.name,i);return n.forEach(i=>e.delete(i)),e}c(te,"uniqueByName");function ve(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=>ve(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 l=r.get(a.name);return l!==void 0&&ve(a.value,l.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"&&qo(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&&Eo(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"&&rr(t.value,!1);case"DateTime":return typeof t.value=="string"&&rr(t.value,!0);default:return!Bn.has(s)}return!Bn.has(s)&&o===void 0}c(ve,"compatibleValue");var Pl=/^(?:[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 qo(t){return Pl.test(t)}c(qo,"uuidValue");function Al(t,e,n){let i=te(n.types),r=t.properties,o=null,s=!1,a=!1;for(let l of e.split(".")){let p=r.filter(f=>f.name===l);if(p.length!==1)return null;let m=p[0].type;s||=m.isOptional,a||=m.isCollection,o={...m,isOptional:s,isCollection:a},r=i.get(m.name)?.properties??[]}return o}c(Al,"commandPathType");function Nt(t,e,n,i){let r=e.for?.kind==="PathExpressionSyntax"?e.for.path:ko(t,e,i);return r==="new event source"?t.properties.find(o=>o.isGenerated&&o.isIdentifier)?.type??{kind:"TypeRefSyntax",name:"Uuid",isOptional:!1,isCollection:!1,location:e.location}:r===void 0?null:Al(t,r,n)}c(Nt,"commandDestinationType");var Bo=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]),Ge=class{static{c(this,"RefusalDeclarations")}application;slices;types;concepts;events;knownTypes;constructor(e){this.application=e,this.slices=new re(e).slices,this.types=te(e.types),this.concepts=te(e.concepts),this.knownTypes=new Set([...Bo,...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 ae(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:l,scope:p})=>i(l).map(m=>({node:m,slice:l,scope:p}))),o=this.slices.find(l=>l.slice===n)?.scope??[],s=c(l=>{let p=l.split("."),m=r.filter(y=>y.node.name===p.at(-1)),f=p.slice(0,-1);if(f.length>0)return m.filter(y=>f.length<=y.scope.length&&f.every((h,v)=>y.scope[y.scope.length-f.length+v]===h));for(let y=o.length;y>=0;y--){let h=m.filter(v=>y<=v.scope.length&&o.slice(0,y).every((x,S)=>v.scope[S]===x));if(h.length>0)return h}return[]},"candidates"),a=s(e);if(a.length===0){let l=this.application.imports.filter(p=>p.qualifiedName.split(".").at(-1)===e);l.length===1&&(a=s(l[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(l=>l.name===o)??[];if(s.length!==1)return null;let a=s[0];if(r===i.length-1)return a;if(Bo.has(a.type.name)||this.concepts.has(a.type.name)&&!this.application.types.some(l=>l.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 wl=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Un(t,e,n){let i=new Ge(t),r=jt(t),o=c(l=>wl.has(l)||i.concepts.has(l)||i.types.has(l),"knownType"),s=new Map([...i.types].map(([l,p])=>[l,new Map(p.properties.map(m=>[m.name,m]))])),a=n===void 0?i.slices:[{scope:[],slice:{kind:"SliceSyntax",type:"StateChange",name:"",description:null,location:t.location,events:[],commands:[],queries:[],projections:[],captures:[],reactions:[],constraints:[],readModels:[],screens:[],specifications:n}}];for(let{slice:l,scope:p}of a){let m=new Map;for(let f of l.specifications){let y=(f.cases?.length??0)===0?[f.name]:f.cases.map(h=>`${f.name}_${h.name}`);for(let h of y)m.set(h,(m.get(h)??0)+1);(f.cases?.length??0)>0&&m.set(f.name,(m.get(f.name)??0)+1)}for(let f of l.specifications){for(let x of f.cases??[])(m.get(`${f.name}_${x.name}`)??0)>1&&e.error(d.SpecificationCaseNameCollision,`Case '${x.name}' derives specification '${f.name}_${x.name}', which collides in this ${n===void 0?"slice":"document"}.`,x.location);for(let x of f.parameters??[]){n===void 0&&!o(x.type.name)&&e.error(d.IncompatibleSpecificationParameterType,`Parameter '${x.name}' has unknown type '${x.type.name}'.`,x.type.location);for(let S of f.cases??[])for(let E of S.values.filter(g=>g.property===x.name))ve(E.source,x.type,i.concepts,s)||e.error(d.InvalidSpecificationCaseValue,`Case '${S.name}' parameter '${x.name}' requires a concrete value of type '${x.type.name}'.`,E.source.location)}let y=c((x,S,E)=>{if(x?.kind!=="CaseValueExpressionSyntax"||S===void 0)return;let g=f.parameters?.find(b=>b.name===x.parameter);if(g===void 0||(g.type.isOptional&&!S.isOptional&&e.error(d.OptionalSpecificationParameterTarget,`Optional parameter '${g.name}' cannot supply required target '${E}'.`,x.location),n!==void 0&&(!o(g.type.name)||!o(S.name))))return;let P=i.concepts.get(g.type.name),A=i.concepts.get(S.name);(!(g.type.name===S.name||P?.type!=="Enum"&&P?.type===S.name||A?.type!=="Enum"&&A?.type===g.type.name)||g.type.isCollection!==S.isCollection)&&e.error(d.IncompatibleSpecificationParameterType,`Parameter '${g.name}' type '${g.type.name}' is incompatible with target '${E}' type '${S.name}'.`,x.location)},"check"),h=c((x,S)=>{for(let E of x)y(E.source,i.property(S,E.property)?.type,E.property)},"assignments"),v=r.command(f.when,p);if(v!==null){let x=i.resolve(v.commandType,l,S=>S.commands)?.node.properties??null;h(v.values,x),h(v.generatedValues??[],x),y(v.for,x?.find(S=>S.isIdentifier)?.type,"for")}if(v!==null&&f.thenReturns!=null){let x=i.resolve(v.commandType,l,E=>E.commands)?.node,S=x?.response;if(f.thenReturns.kind==="ScalarSpecificationReturnSyntax"&&S?.kind==="ScalarCommandResponseSyntax"&&y(f.thenReturns.value,x?.properties.find(E=>E.name===S.source.property)?.type,"value"),f.thenReturns.kind==="RecordSpecificationReturnSyntax"&&S?.kind==="RecordCommandResponseSyntax")for(let E of f.thenReturns.fields){let g=S.fields.find(P=>P.name===E.property);y(E.source,g?.type??x?.properties.find(P=>P.name===g?.source.property)?.type,E.property)}}for(let x of[...f.given,...f.thenEvents,...f.whenAppended===null?[]:[f.whenAppended]]){let S=r.eventStep(x,"given",p).effective;h(S.values,i.event(S.eventType,l)?.properties??null);let E=S.stream==null?null:new Oe(t).resolve(S.stream.eventSource,S.stream.stream),g=E?.kind===se.Unique?E.sources[0]:void 0,P=E?.kind===se.Unique?E.streams[0]:void 0;y(S.for,S.stream!=null&&g===void 0?void 0:g?.identifier??Ol(S.eventType,l,t,i),"for"),S.stream?.streamId!=null&&y(S.stream.streamId.source,P?.streamId??void 0,"streamId");for(let A of S.stream?.streamIdParts??[])y(A.source,P?.streamIdParts.find($=>$.name===A.property)?.type,A.property)}for(let x of[...f.givenReadModels,...f.thenReadModels]){let S=r.readModel(x,p);h(S.properties,i.resolve(S.name,l,E=>E.readModels)?.node.properties??null)}if(f.whenTrigger!=null){let x=(t.declaredTriggers??[]).find(S=>S.name===f.whenTrigger.trigger);for(let S of f.whenTrigger.values)y(S.source,x?.data.find(E=>E.name===S.property)?.type,S.property)}for(let x of f.thenErrors)y(x.caseValue??null,{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:x.location},"message");for(let x of f.thenAbsentReadModels??[]){let S=i.resolve(x.name,l,g=>g.readModels)?.node,E=i.slices.flatMap(({slice:g})=>g.queries.filter(P=>P.by!==null&&i.resolve(P.returnType.name,g,A=>A.readModels)?.node===S));y(x.key,S!==void 0&&E.length===1?E[0].by.type:void 0,"for")}for(let x of[...f.thenQueries??[],...f.whenQuery===null?[]:[f.whenQuery]]){let S=i.resolve(x.query,l,A=>A.queries),E=S===null?[]:[...S.node.by===null?[]:[S.node.by],...S.node.filters].map(A=>({...A,kind:"PropertySyntax",isIdentifier:!1}));h(x.arguments,E);let g=S===null?null:i.resolve(S.node.returnType.name,S.slice,A=>A.readModels)?.node.properties??null,P=x.kind==="SpecificationQuerySyntax"?x.results:f.thenResults;for(let A of P)h(A.properties,g)}}}}c(Un,"validateSpecificationCases");function Fn(t){let e=new Map(t.map(n=>[JSON.stringify([n.name,n.isOptional,n.isCollection]),n]));return e.size===1?[...e.values()][0]:void 0}c(Fn,"uniqueDestinationType");function Ol(t,e,n,i){let r=new re(n),o=i.event(t,e);if(o===null)return;let s=c((l,p=i.slices)=>p.flatMap(({slice:m})=>m.commands.flatMap(f=>f.produces.filter(y=>r.isEventProduction(y,m)&&i.event(y.event,m)===l).map(y=>Nt(f,y,n,{resolver:r,slice:m})).filter(y=>y!==null))),"commandTypes"),a=c((l,p)=>{if(p.has(l))return[];p.add(l);let m=s(l);for(let{slice:f}of i.slices){for(let y of f.reactions.flatMap(h=>h.triggers)){let h=y.source.kind==="NamedTriggerSourceSyntax"?y.source.name:void 0,v=h===void 0?null:i.event(h,f);for(let x of y.produces.filter(S=>i.event(S.event,f)===l))if(x.for?.kind==="PathExpressionSyntax"){let S=x.for.path,E=i.property(v?.properties??null,S)?.type??(h===void 0?void 0:(n.declaredTriggers??[]).find(g=>g.name===h)?.data.find(g=>g.name===S)?.type);E!==void 0&&m.push(E)}else x.for?.kind==="LiteralExpressionSyntax"?m.push({kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:x.location}):x.for===null&&v!==null&&m.push(...a(v,p))}f.captures.flatMap(y=>[...y.appends,...y.children.flatMap(h=>h.appends),...y.nested.flatMap(h=>h.appends)]).some(y=>i.event(y.event,f)===l)&&m.push(Fn(s(l))??{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:l.location})}return m},"producerTypes");return Fn(s(o,i.slices.filter(l=>l.slice===e)))??Fn(s(o))??Fn(a(o,new Set))}c(Ol,"eventDestinationType");function Wn(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}))}))}c(Wn,"productionDestinationDiagnostics");function Vn(t,e){let n=new re(t).slices.map(r=>r.slice),i=n.flatMap(ae);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(l=>l.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)}}c(Vn,"validateConstraintProperties");var Yo=c((t,e)=>t.length===e.length&&t.every((n,i)=>n===e[i]),"same"),zn=c(t=>[...t.scope,t.name].join("."),"addressOf"),Ae=class{static{c(this,"DeclaredDependencyTargets")}static containersOf(e){let n=[],i=c((r,o)=>{n.push({name:r.name,scope:o}),r.features.forEach(s=>i(s,[...o,r.name]))},"inventory");for(let r of e.modules)n.push({name:r.name,scope:[]}),r.features.forEach(o=>i(o,[r.name]));return[...new Map(n.map(r=>[zn(r),r])).values()]}static candidates(e,n){let i=e.join(".");return n.flatMap(r=>{let o=zn(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 l=s.slice(-a).join(".");if(this.resolve(l,e,n).resolved!==r)continue;let p=a===1?e.length-1-r.scope.length:"qualified";return[{container:r,reference:l,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=>Yo([...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&&Yo(a.scope,n.slice(0,o)));if(s.length>0)return s.length===1?{resolved:s[0],ambiguous:[]}:{ambiguous:s}}return{ambiguous:[]}}};function Qn(t,e){let n=c(a=>(a.dependsOn?.length??0)>0||a.features.some(n),"hasDependencies");if(!t.modules.some(n))return t;let i=Ae.containersOf(t),r=new Map,o=c((a,l)=>{let p=[],m=l.join(".");r.has(m)||r.set(m,new Set);let f=r.get(m);for(let y of a){let h=Ae.resolve(y.target,l,i),v=h.resolved===void 0?void 0:zn(h.resolved),x=v===void 0?`text:${y.target}`:`resolved:${v}`;if(f.has(x)){e.warning(d.RepeatedDependencyDeclaration,`Dependency '${y.target}' is already declared on this container - this repeated declaration is ignored`,y.location);continue}f.add(x),p.push(y),h.ambiguous.length>0?e.warning(d.AmbiguousReference,`Ambiguous dependency target '${y.target}' - candidates: ${h.ambiguous.map(zn).join(", ")}`,y.location):(v===void 0||v===m||v.startsWith(m+".")||m.startsWith(v+"."))&&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=c((a,l)=>{let p=[...l,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(l=>s(l,[a.name]))}))}}c(Qn,"validateDependencyDeclarations");var kt=[],sn=c(t=>t.length===0,"isDocumentPlacement");function Gn(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}c(Gn,"describePlacement");var Il=w("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),Tl=new RegExp(w("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),Rl=w("^[A-Z]\\w*$");function pt(t,e){let n=e.content.substring(9);for(let a=t.peekChild(e.indent);a!==void 0&&Il.test(a.content);a=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${a.content}`;let i=Dl(n),r=u(e);if(i.length===0)return t.error(d.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let s=new pr(t,i,r).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:r}}c(pt,"parseAuthorize");function _e(t,e){return t===null?e:e===null?t:{kind:"AuthorizeSyntax",requirement:{kind:"LogicalPolicyRequirementSyntax",left:t.requirement,operator:"And",right:e.requirement,location:t.location},location:t.location}}c(_e,"combineAuthorize");function Dl(t){let e=[];for(let n of t.match(Tl)??[])e.length>0&&Ml(e[e.length-1])&&jl(n)&&e.push("and"),e.push(n);return e}c(Dl,"tokenize");var Fo=c(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),Ml=c(t=>t===")"||Fo(t),"isOperandEnd"),jl=c(t=>t==="("||Fo(t),"isOperandStart"),pr=class{static{c(this,"RequirementParser")}context;tokens;location;#e=0;constructor(e,n,i){this.context=e,this.tokens=n,this.location=i}parse(){let e=this.#t();return e!==null&&this.#e<this.tokens.length&&this.context.error(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 Rl.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)}};function Lt(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}'`,u(n)),null;o!==n&&t.reader.takeSignificant(),e==="description"&&o.content==="```"&&t.warning(d.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",u(o));let a=[];for(;;){let l=t.reader.takeRaw();if(l===void 0){t.error(d.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",u(o));break}if(l.raw.trim()==="```")break;let p=0;for(;p<o.indent&&p<l.raw.length&&l.raw[p]===" ";)p++;a.push(l.raw.substring(p))}return a.join(`
|
|
17
|
-
`)}c(Lt,"parseFencedText");var Nl=w(`^description\\s+"(${H})"$`);function Z(t,e,n,i,r=!1){if(e.content==="description"){let s=Lt(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`,u(e)),n):Uo(t,e,n,i,s)}let o=Nl.exec(e.content);return o===null?(t.error(d.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,u(e)),n):Uo(t,e,n,i,ee(o[1]))}c(Z,"parseDescription");function Uo(t,e,n,i,r){return n!==null?(t.error(d.DuplicateDescription,`${i} already declares a description - at most one is allowed`,u(e)),n):r}c(Uo,"keep");function be(t,e,n,i,r=d.InvalidDocumentation){if(e.content!=="documentation"||t.peekChild(e.indent)?.content!=="```markdown")return t.error(r,`${i} documentation requires a fenced markdown block`,u(e)),t.skipOpaqueBlock(e.indent),n;let o=Lt(t,"markdown",e);return o===null||o.trim().length===0||n!==null?(t.error(r,`${i} accepts one nonempty documentation block`,u(e)),n):o}c(be,"parseDocumentation");var Ll=Q(`^depends${U}+on${U}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function _n(t,e,n,i){let r=Ll.exec(e.content)?.[1];if(r===void 0){t.error(i,`Invalid dependency declaration '${e.content}' - expected 'depends on <Name>'`,u(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`,u(e));return}n.push({kind:"DependsOnSyntax",target:r,location:u(e)})}c(_n,"parseDependsOn");var ql=w('^import\\s+"([^"\\\\]+)"$'),Bl=w('^import\\s+"'),Wo=c(t=>Bl.test(t),"isFileImport");function Vo(t){let e=ql.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:u(t)}}c(Vo,"tryParseFileImport");function qt(t,e,n){let i=Vo(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>"'`,u(e)),t.skipBlock(e.indent)}c(qt,"parseFileImport");var fr={"==":"Equal","!=":"NotEqual",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual",contains:"Contains","starts with":"StartsWith"};function Ue(t,e,n,i=!1){i||(t=t.valueContext);let r=i?U:"\\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(Q(`"${H}"|==|!=|>=|<=|>|<|\\(|\\)|${o}${s}`).source,"gu");if(i){let v=e.replace(a,"").replace(new RegExp(U,"gu"),"");if(v.length>0)return t.error(d.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${v[0]}'`,n),null}let l=e.match(a)??[],p=0,m=c(()=>{if(l[p]==="("){p++;let E=y();return l[p]===")"?p++:(i||t.sourceOptions.numericMode==="exact")&&t.error(d.UnclosedConditionGroup,"Expected ')' in condition",n),E}let v=l[p++];if(i&&v===void 0)return t.error(d.ExpectedCondition,"Expected a condition",n),null;let x=l[p++];if(x==="starts"&&l[p]==="with"&&(x+=" with",p++),i&&!Object.hasOwn(fr,x))return t.error(d.ExpectedComparisonOperator,`Expected a comparison operator after '${v}'`,n),null;let S=l[p++];return i&&S===void 0?(t.error(d.ExpectedComparisonValue,"Expected a value to compare against",n),null):v===void 0||S===void 0||fr[x]===void 0?null:{kind:"ComparisonConditionSyntax",left:v,operator:fr[x],right:Te(S,n,t),location:n}},"group"),f=c(()=>{let v=m();for(;v!==null&&l[p]==="and";){p++;let x=m();if(x===null)return null;v={kind:"LogicalConditionSyntax",left:v,operator:"And",right:x,location:n}}return v},"and"),y=c(()=>{let v=f();for(;v!==null&&l[p]==="or";){p++;let x=f();if(x===null)return null;v={kind:"LogicalConditionSyntax",left:v,operator:"Or",right:x,location:n}}return v},"or"),h=y();return(i||t.sourceOptions.numericMode==="exact")&&(h===null&&!i?t.error(d.ExpectedCondition,"Expected a condition",n):h!==null&&p<l.length&&t.error(d.UnexpectedTokenInCondition,`Unexpected '${l[p]}' in condition`,n)),h}c(Ue,"parseCondition");var Yl=w(`^when${U}+([^\\n]+)${U}+execute${U}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Fl=w(`^otherwise${U}+execute${U}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Ul=w(`^with${U}+([A-Za-z_]\\w*)${U}+from${U}+([^\\n]+)$`),Wl=w("^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Vl=new RegExp(`^${U}+|${U}+$`,"gu");function Qo(t,e,n,i){let r=[],o=null,s=null,a=!1;for(let l=t.peekChild(e.indent);l!==void 0;l=t.peekChild(e.indent)){t.reader.takeSignificant();let p=Yl.exec(l.content),m=Fl.exec(l.content);if(p!==null){a&&t.error(d.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",u(l));let f=Ue(t,p[1],u(l),!0),y=zo(t,l);f!==null&&(Bt(t,f),r.push({kind:"ScreenActionAlternativeSyntax",condition:f,command:p[2],arguments:y,location:u(l)}))}else if(l.content==="otherwise hidden"||m!==null)if(a&&t.error(d.MisplacedActionOtherwise,"A guarded action permits only one 'otherwise'",u(l)),a=!0,m!==null)o={kind:"ScreenActionOtherwiseSyntax",outcome:"Execute",command:m[1],arguments:zo(t,l),location:u(l)};else{o={kind:"ScreenActionOtherwiseSyntax",outcome:"Hidden",command:null,arguments:[],location:u(l)};for(let f=t.peekChild(l.indent);f!==void 0;f=t.peekChild(l.indent))t.reader.takeSignificant(),t.error(d.InvalidActionAlternative,"'otherwise hidden' cannot declare command arguments",u(f)),t.skipBlock(f.indent)}else if(D(l.content)==="navigate")s!==null&&t.error(d.InvalidActionAlternative,"A guarded action permits only one 'navigate to'",u(l)),s=i(t,l.content,l)??null;else{let f=D(l.content)==="label";t.error(f?d.UnknownActionDirective:d.InvalidActionAlternative,f?"A guarded action's header already supplies its label":`Unexpected '${l.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,u(l)),t.skipBlock(l.indent)}}return r.length===0&&t.error(d.GuardedActionWithoutAlternatives,"A guarded action must declare at least one 'when' alternative",u(e)),{kind:"ScreenGuardedActionSyntax",label:n,alternatives:r,otherwise:o,navigate:s,location:u(e)}}c(Qo,"parseGuardedAction");function zo(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=Ul.exec(i.content);r!==null?n.push({kind:"InteractionArgumentSyntax",name:r[1],binding:r[2].replace(Vl,""),location:u(i)}):(t.error(d.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,u(i)),t.skipBlock(i.indent))}return n}c(zo,"parseArguments");function Bt(t,e){if(e.kind==="LogicalConditionSyntax"){Bt(t,e.left),Bt(t,e.right);return}let n=e.right.kind==="LiteralExpressionSyntax"?e.right.value:void 0,i=Wl.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)}c(Bt,"validateCondition");var We=class t{static{c(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every(cr)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&cr(this.lines[this.#e]);)this.#e++;return this.#e<this.lines.length?this.lines[this.#e]:void 0}takeSignificant(){let e=this.peekSignificant();if(e===void 0)throw new Error("There is no significant line left to take");return this.#e++,e}takeRaw(){return this.#e<this.lines.length?this.lines[this.#e++]:void 0}};var le=class extends Error{static{c(this,"InvalidSyntaxJson")}};var Me=Object.freeze({numericMode:"legacy"}),Zn=Object.freeze({numericMode:"exact"}),Go=Object.freeze({numericMode:"invalid"});function Yt(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 le("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new le("Malformed source numeric options.");return e==="exact"?Zn:Me}c(Yt,"validatedSourceOptions");var _o=new WeakSet;function Zo(t){_o.add(t)}c(Zo,"recordAuthoredDocument");function Ko(t){return _o.has(t)}c(Ko,"isAuthoredDocument");var me=class t{static{c(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=Me;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 It(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 zl=w(`^when${U}+([^\\n]+)${U}+execute${U}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Ql=w(`^on${U}+([^\\n]+)$`),Ho=w(`^where${U}+([^\\n]+)$`),Jo=new Set(["execute","navigate","open","close","refresh","set","notify","confirm","raise"]);function Xo(t,e){for(let n=0;n<e.length;n++){let i=e[n],r=Ql.exec(i.content);if(r===null||r[1].startsWith("row-click "))continue;let o=[];for(let f=n+1;f<e.length&&e[f].indent>i.indent;f++)o.push(e[f]);let s=o.filter(f=>f.indent===o[0]?.indent),a=s.filter(f=>["when","otherwise"].includes(D(f.content))),l=["click","double click","select"].includes(r[1].trim()),p=s.filter(f=>Ho.test(f.content)),m=!1;for(let f of a){let y=D(f.content)==="when",h=y?zl.exec(f.content):null;if(y){m&&t.error(d.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",u(f));let S=Ue(t,h?.[1]??f.content.slice(4).trim(),u(f),!0);S!==null&&Bt(t,S),h!==null&&t.error(d.InlineInteractionAlternative,"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'",u(f))}else(m||f.content!=="otherwise")&&t.error(d.MisplacedActionOtherwise,"An interaction permits one final block-form 'otherwise'",u(f)),m=!0;let v=o.indexOf(f),x=o[v+1];h===null&&(x===void 0||x.indent<=f.indent||!Jo.has(D(x.content)))&&t.error(d.InteractionAlternativeWithoutActions,"An interaction alternative requires a non-empty action list",u(f))}if(a.length>0&&(l||t.error(d.UnsupportedInteractionAlternatives,"Interaction alternatives are only supported on click, double click and select",u(i)),(p.length>0||s.some(f=>Jo.has(D(f.content))))&&t.error(d.MixedInteractionAlternatives,"Interaction alternatives cannot mix with plain actions or 'where'",u(i)),a.some(f=>D(f.content)==="when")||t.error(d.GuardedActionWithoutAlternatives,"A guarded interaction requires at least one 'when' alternative",u(i))),l)for(let f of p)Gl(t,f)}}c(Xo,"validateInteractionBodies");function Gl(t,e){let n=new me(new We([]));n.sourceOptions=t.sourceOptions;let i=Ue(n,Ho.exec(e.content)[1].trim(),u(e),!0);i!==null&&Bt(n,i);let r="Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions";i!==null&&n.diagnostics.length===0?t.warning(d.LegacyInteractionWhere,r,u(e)):t.information(d.LegacyInteractionWhere,r,u(e))}c(Gl,"deprecateWhere");var _l=w("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Zl=w("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Kl=w("^field\\s+([\\w.]+)(?:\\s|$)"),Jl=w("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),Hl=w("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),Xl=w("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),ec=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on","when","otherwise"]);function je(t,e){let n=[],i=new Set,r=[],o=D(e.content)==="behavior",s=c(l=>{for(;n.length>0&&n[n.length-1].indent>=l.indent;)n.pop();let p=o&&n.length===0?Xl.exec(l.content):null;p!==null&&i.add(p[1]);let m=_l.exec(l.content),f=Zl.exec(l.content);if(m!==null)n.push({command:m[1],kind:"form",indent:l.indent});else if(f!==null)n.push({command:f[2],kind:f[1],indent:l.indent});else if(ec.has(D(l.content)))n.push({command:"",kind:"other",indent:l.indent});else{let y=n.at(-1);if(y===void 0||y.kind==="other")return;let h=(y.kind==="form"?Kl:y.kind==="execute"?Jl:Hl).exec(l.content);h!==null&&r.push({command:y.command,property:ne(h[1]),scope:t.scope,location:u(l)})}},"recognize");s(e);let a=[e];for(let l=t.peekChild(e.indent);l!==void 0;l=t.peekChild(e.indent))t.reader.takeSignificant(),l.content.startsWith("```")?t.skipFencedBody():(a.push(l),s(l));Xo(t,a);for(let l of r)t.inputUses.push(i.has(l.command)?{...l,isParameter:!0}:l)}c(je,"collectInputUses");function ge(t){return w(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}c(ge,"sourceStreamPattern");var tc=ge("^[A-Za-z_]\\w*(?![\\s\\S])"),nc=ge("^[\\w.]+(?![\\s\\S])");function ur(t){return typeof t=="string"&&tc.test(t)}c(ur,"isSourceStreamName");function Kn(t){return typeof t=="string"&&nc.test(t)}c(Kn,"isSourceStreamTypeName");var ic=w(`^id\\s+"(${H})"$`),rc=ge("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),oc=ge("^eventsource\\s+([A-Za-z_]\\w*)$"),ac=ge("^stream\\s+([A-Za-z_]\\w*)$");function ea(t,e){let n=oc.exec(e.content)?.[1]??"";n===""&&et(t,e,"Expected 'eventsource <Name>'.");let i=[],r=null,o=null,s=null;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(a.content)){case"stream":i.push(sc(t,a));break;case"identifier":r=ta(t,a,"identifier",r);break;case"description":o=Z(t,a,o,`Event source '${n}'`,!0);break;case"id":s=na(t,a,n,s);break;default:et(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:u(e)}}c(ea,"parseEventSource");function sc(t,e){let n=ac.exec(e.content)?.[1]??"";n===""&&et(t,e,"Expected 'stream <Name>'.");let i=null,r=[],o=!1,s={},a=null,l=null;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(p.content)){case"streamId":o?(et(t,p,"Declare either one 'streamId <Type>' or one streamId part block."),t.skipBlock(p.indent)):p.content==="streamId"?(o=!0,s.streamId=u(p),r=lc(t,p)):(i=ta(t,p,"streamId",i),o=i!==null);break;case"description":a=Z(t,p,a,`Stream '${n}'`,!0);break;case"id":l=na(t,p,n,l);break;default:et(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:l,directiveLocations:s,location:u(e)}}c(sc,"parseEventStream");function ta(t,e,n,i){let r=rc.exec(e.content);return r===null||i!==null?et(t,e,`Declare at most one '${n} <Type>'.`):(i=Re(r[2],{...u(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),Be(t,i,e)),ln(t,e,d.InvalidEventSourceDeclaration),i}c(ta,"parseType");function na(t,e,n,i){let r=ic.exec(e.content),o=r===null?null:ee(r[1]);return o===null||o.trim()===""||i!==null?et(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.",u(e))),ln(t,e,d.InvalidEventSourceDeclaration),i}c(na,"parsePin");function ia(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:u(e)};if(i)return t.error(d.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,u(e)),{...s,propertyCandidate:n};let a=null,l=[],p=!1,m={};for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent)){if(t.reader.takeSignificant(),f.content==="streamId"){a!==null||p?(t.error(d.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",u(f)),t.skipBlock(f.indent)):(p=!0,m.streamId=u(f),l=mr(t,f,d.InvalidCommandStream));continue}let y=/^streamId\s*=\s*(.+)$/.exec(f.content);if(y===null||a!==null||p)t.error(d.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",u(f)),t.skipBlock(f.indent);else{let h={...u(f),column:f.indent+1+f.content.indexOf(y[1],f.content.indexOf("=")+1)};a={kind:"PropertyMappingSyntax",property:"streamId",source:ce(y[1],h,t),location:u(f)},ln(t,f,d.InvalidCommandStream)}}return{...s,streamId:a,streamIdParts:l,directiveLocations:m}}c(ia,"parseCommandStream");function lc(t,e){let n=[],i=ge("^([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){et(t,r,"Expected '<part> <Type>' without modifiers in a streamId part block."),t.skipBlock(r.indent);continue}let s=Re(o[2],{...u(r),column:r.indent+1+r.content.indexOf(o[2],o[1].length)});Be(t,s,r),n.push({kind:"EventStreamIdPartSyntax",name:o[1],type:s,location:u(r)}),ln(t,r,d.InvalidEventSourceDeclaration)}return n.length===0&&et(t,e,"A streamId part block cannot be empty."),n}c(lc,"parseStreamIdParts");function mr(t,e,n){let i=[],r=ge("^([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.",u(o)),t.skipBlock(o.indent);continue}let a={...u(o),column:o.indent+1+o.content.indexOf(s[2],o.content.indexOf("=")+1)};i.push({kind:"PropertyMappingSyntax",property:s[1],source:ce(s[2],a,t),location:u(o)}),ln(t,o,n)}return i.length===0&&t.error(n,"A streamId part block cannot be empty.",u(e)),i}c(mr,"parseRouteParts");function ln(t,e,n){let i=t.peekChild(e.indent);i!==void 0&&(t.error(n,"This directive cannot have children.",u(i)),t.skipBlock(e.indent))}c(ln,"rejectChildren");function et(t,e,n){t.error(d.InvalidEventSourceDeclaration,n,u(e))}c(et,"invalid");var cc=w("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),ra=c(t=>D(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),fe=c(t=>ra(t).length>0,"isFileDirective"),Jn=c(t=>fe(t)&&!cc.test(ra(t)),"isFileDirectiveAmongProperties");var dc=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function Hn(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||dc.has(n)))return!1}return!0}c(Hn,"isBlankImplementationHint");var oa=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),Ft=c(t=>D(t.content)==="file"&&t.content.substring(4).trim().length>0,"isFile"),cn=c((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCode");function ft(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`,u(e)),{kind:"FileReferenceSyntax",path:n,location:u(e)}}c(ft,"parseFile");var yr=c(t=>t.raw.trim()==="```","isClosingCodeFence");function Ne(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}'`,u(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(d.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,u(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}'`,u(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",u(i));break}if(yr(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:u(e)}}c(Ne,"parseCode");function aa(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",u(e)),null;if(t.reader.takeSignificant(),D(n.content)==="implementation")return pc(t,e,n);let i=Ft(n)?ft(t,n):null,r=i===null&&cn(t,n)?Ne(t,n):null;if(i!==null||r!==null){let o=t.peekChild(e.indent);return o!==void 0&&D(o.content)==="implementation"&&(t.error(d.ConflictingImplementationSources,"A handler cannot mix wrapped and direct sources.",u(o)),t.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:r,implementation:null,location:u(e)}}return t.error(d.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,u(n)),t.skipBlock(e.indent),null}c(aa,"parseHandler");function pc(t,e,n){let i=dn(t,n);for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(D(r.content)==="implementation"?d.InvalidImplementationBlock:d.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",u(r)),cn(t,r)?Ne(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:u(e)}}c(pc,"parseImplementation");function dn(t,e){let n=[],i=null,r=null,o=!1;e.content!=="implementation"&&t.error(d.InvalidImplementationBlock,"Expected 'implementation' with no operand.",u(e));for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="hint"||oa.test(s.content)){let a=oa.exec(s.content),l=a===null?null:ee(a[1]);Hn(l)?t.error(d.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",u(s)):n.push({kind:"ImplementationHintSyntax",text:l,location:u(s)});let p=t.peekChild(s.indent);p!==void 0&&(t.error(d.InvalidImplementationHint,"A hint cannot have children.",u(p)),t.skipBlock(s.indent))}else if(Ft(s)||s.content.startsWith("```")){o&&t.error(d.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",u(s));let a=Ft(s)?ft(t,s):null,l=a===null?Ne(t,s):null;o||(i=a,r=l),o=!0;let p=t.peekChild(s.indent);a!==null&&p!==void 0&&(t.error(d.InvalidImplementationBlock,"A file directive cannot have children.",u(p)),t.skipBlock(s.indent))}else t.error(d.InvalidImplementationBlock,`Unexpected '${s.content}' in implementation - expected hint, file or a tagged fence.`,u(s)),t.skipBlock(s.indent);return{file:i,code:r,implementation:{kind:"ImplementationSyntax",hints:n,location:u(e)}}}c(dn,"parseImplementationWrapper");var fc=w("^system\\s+([A-Za-z_]\\w*)$"),uc=w("^operation\\s+([A-Za-z_]\\w*)$"),mc=w("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),hr=w("^uses\\s+([A-Za-z_]\\w*)$"),yc=w("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),hc=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function pn(t,e,n,i){let r=t.peekChild(e.indent);r!==void 0&&(t.error(n,i,u(r)),t.skipBlock(e.indent))}c(pn,"rejectOperationChildren");function sa(t,e){let n=fc.exec(e.content);n===null&&t.error(d.InvalidSystemDeclaration,"Expected 'system <Name>'.",u(e));let i=null;for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="description"?i=Z(t,r,i,`System '${n?.[1]??""}'`):(t.error(d.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",u(r)),t.skipBlock(r.indent));return{kind:"SystemSyntax",name:n?.[1]??"",description:i,location:u(e)}}c(sa,"parseSystem");function Xn(t,e,n=!1){let i=(n?mc:uc).exec(e.content),r=i?.[1]??"";i===null&&t.error(d.InvalidOperationDeclaration,"Expected an operation declaration with one name.",u(e));let o=null,s=null,a=u(e),l=null,p=null,m=[],f=[],y=new Set;for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){t.reader.takeSignificant();let v=yc.exec(h.content),x=n&&v!==null?{...h,content:v[1].trimEnd()}:h;if(v===null&&hc.has(D(h.content))){t.error(d.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",u(h)),t.skipBlock(h.indent);continue}if(!hr.test(h.content)&&Qe(x)!==void 0){let S=De(t,x);n&&v===null&&t.error(d.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",u(h)),S.isSubject&&t.error(d.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).",u(h)),(S.isIdentifier||S.isGenerated)&&t.error(d.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",u(h)),y.has(S.name)&&t.error(d.DuplicateDeclaration,`Operation '${r}' already declares input '${S.name}'.`,u(h)),y.add(S.name),m.push(S),n&&v!==null&&f.push({kind:"PropertyMappingSyntax",property:S.name,source:ce(v[2],{...u(h),column:h.indent+h.content.length-v[2].length+1},t),location:u(h)}),pn(t,h,d.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(D(h.content)==="description")o=Z(t,h,o,`Operation '${r}'`);else if(hr.test(h.content))s!==null?t.error(d.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",u(h)):(s=hr.exec(h.content)[1],a={...u(h),column:u(h).column+h.content.indexOf(s,4)}),pn(t,h,d.InvalidSystemReference,"A system reference cannot have children.");else if(h.content==="execute"||h.content==="compensate"){let S=Sc(t,h);h.content==="execute"?l!==null?t.error(d.InvalidOperationDeclaration,"An operation declares execute at most once.",u(h)):l=S:p!==null?t.error(d.InvalidOperationDeclaration,"An operation declares compensate at most once.",u(h)):p=S}else t.error(d.InvalidOperationDeclaration,`Unexpected '${h.content}' in operation - expected uses, an input, description, execute or compensate.`,u(h)),t.skipBlock(h.indent)}return s===null&&t.error(d.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",u(e)),{operation:{kind:"OperationSyntax",name:r,uses:s??"",usesLocation:a,inputs:m,description:o,execute:l,compensate:p,location:u(e)},mappings:f}}c(Xn,"parseOperation");function Sc(t,e){let n=null,i=null,r=null,o=null,s=!1;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(a.content)==="description"){n=Z(t,a,n,`Operation phase '${e.content}'`);continue}if(D(a.content)==="implementation"){s&&t.error(d.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",u(a));let l=dn(t,a);s||(i=l.file,r=l.code,o=l.implementation),s=!0}else if(fe(a)||a.content.startsWith("```")){s&&t.error(d.ConflictingImplementationSources,"A phase has at most one file or inline payload.",u(a));let l=fe(a)?ft(t,a):null,p=l===null?Ne(t,a):null;s||(i=l,r=p),s=!0,l!==null&&pn(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.",u(a)),t.skipBlock(a.indent)}return{kind:"OperationPhaseSyntax",description:n,file:i,code:r,implementation:o,location:u(e)}}c(Sc,"parseOperationPhase");var gc=w("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),xc=w("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),vc=w("^specification\\s+([A-Za-z_]\\w*)$"),$c=w("^given caller as ([A-Za-z_]\\w*)$"),bc="([A-Z]\\w*(?:\\.\\w+)*)",kc="(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?",Ut=c((t,e="")=>Q(`^${t}\\s+${bc}${e}${kc}$`.replaceAll("\\s",U)),"stepPattern"),Cc=Ut("given"),Ec=Ut("when\\s+append"),Pc=Ut("when"),Ac=Ut("then"),wc=w("^then\\s+query\\b"),la=w("^(?:given|then)\\s+readmodel\\b"),Oc=Ut("given\\s+readmodel"),Ic=Ut("then\\s+readmodel","(?<exactly>\\s+exactly)?"),ca=w("^then\\s+no\\b"),Tc=w(`^then\\s+error\\s+"(${H})"$`),xr=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Rc=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Dc=w("^given\\s+clock\\b"),Mc=w("^given\\s+capture\\b"),jc=w("^when\\s+clock\\b"),Nc=w("^when\\s+trigger\\b"),Lc=w("^when\\s+capture\\b"),qc=w("^when\\s+query\\b"),Bc=w("^then\\s+result\\b"),Yc=w("^then\\s+no\\s+result\\b"),Fc=Q("^when\\s+redelivered\\b"),Uc=Q("^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Wc=w("^then\\s+no\\s+events\\b"),Vc=w('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),zc=w("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),Qc=w("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),Gc=w("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),_c=w("^then\\s+result(\\s+exactly)?$"),da=Q("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),Zc=Q(`^(?:"${H}"|'(?:[^'\\\\]|\\\\.)*')$`),Kc=Q("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function vr(t,e){let n=vc.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,u(e));let i=null,r=[],o=[],s={givenOperationFailures:[],thenOperations:[],thenCompensated:[],thenAbsentReadModels:[],thenQueries:[],given:[],givenReadModels:[],when:null,whenAppended:null,whenRedelivered:null,whenDeclared:!1,thenEvents:[],thenEventsInAnyOrder:!1,thenNoEvents:!1,thenReadModels:[],thenErrors:[],givenClock:null,givenCaptures:[],whenClock:null,whenTrigger:null,whenCapture:null,whenQuery:null,thenResults:[],thenNoResult:null,thenDenied:null,givenCaller:null,thenReturns:null};for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent)){if(t.reader.takeSignificant(),fe(f)||Jc(t,f,s))continue;let y=ca.test(f.content)?"then":D(f.content);if(y==="parameter"){let h=jo(t,f);h!==null&&r.push(h)}else if(y==="case"){let h=No(t,f);h!==null&&o.push(h)}else y==="description"?i=Z(t,f,i,`Specification '${n}'`):y==="given"?Hc(t,f,s):y==="when"?nd(t,f,s,n):y==="then"?id(t,f,s):(t.error(d.UnknownSpecificationDirective,`Unexpected '${D(f.content)}' in specification body`,u(f)),t.skipBlock(f.indent))}s.noEventsLine!==void 0&&(s.whenAppended!==null||s.thenEvents.length>0||s.thenEventsInAnyOrder||s.thenErrors.length>0||s.thenDenied!==null)&&t.error(d.InvalidNoEventsExpectation,"'then no events' cannot follow 'when append' or accompany event, event-order, error or denial expectations.",u(s.noEventsLine));let{whenDeclared:a,noEventsLine:l,...p}=s,m={kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,description:i,...p,...r.length===0?{}:{parameters:r},...o.length===0?{}:{cases:o},location:u(e)};return Lo(m,t),m}c(vr,"parseSpecification");function Jc(t,e,n){if(!gc.test(e.content))return!1;let i=xc.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>'.",u(e)),ye(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=Rt(t,o,xr,d.InvalidOperationSpecification);s!==null&&r.push(s)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:u(e)})}else pn(t,e,d.InvalidOperationSpecification,"Failure and compensation assertions cannot have children."),i[1]==="given operation"?n.givenOperationFailures.push({kind:"SpecificationOperationFailureSyntax",operation:i[2],location:u(e)}):n.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:u(e)});return!0}c(Jc,"parseOperationStep");function Hc(t,e,n){if(Dc.test(e.content))n.givenClock!==null?(t.error(d.InvalidSpecificationClock,"A specification states its clock at most once.",u(e)),ye(t,e.indent)):n.givenClock=pa(t,e,"given");else if(Mc.test(e.content)){let i=fa(t,e,"given");i!==null&&n.givenCaptures.push(i)}else if(e.content.startsWith("given caller"))if(n.givenCaller!==null||n.givenCallerPersona!==void 0)t.error(d.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'given caller' block.",u(e)),t.skipBlock(e.indent);else if(e.content.startsWith("given caller as")){let i=$c.exec(e.content);i===null&&t.error(d.InvalidSpecificationCallerPersona,"Expected 'given caller as <Persona>'.",u(e));let r=t.peekChild(e.indent);r!==void 0&&t.error(d.InvalidSpecificationCallerPersona,"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.",u(r)),ye(t,e.indent),i!==null&&(n.givenCallerPersona={kind:"SpecificationCallerPersonaSyntax",name:i[1],location:u(e)})}else n.givenCaller=td(t,e);else if(la.test(e.content)){let i=ua(t,e,Oc,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=$r(t,e,Cc,"given");i!==void 0&&n.given.push(i)}}c(Hc,"parseGiven");var Xc=w(`^role${U}+"(${H})"$`),ed=w(`^claim${U}+"(${H})"${U}*=${U}*"(${H})"$`);function td(t,e){if(e.content!=="given caller")return t.error(d.InvalidSpecificationCaller,"Expected exactly 'given caller'.",u(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=Xc.exec(o.content),a=ed.exec(o.content);o.content==="authenticated"&&!n?n=!0:s!==null?i.push(ee(s[1])):a!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:ee(a[1]),value:ee(a[2]),location:u(o)}):t.error(Dt(o.content)?d.InvalidSpecificationCaseReference:d.InvalidSpecificationCaller,`Invalid caller fixture '${o.content}' - expected authenticated, role "...", or claim "..." = "...".`,u(o))}return{kind:"SpecificationCallerSyntax",authenticated:n,roles:i,claims:r,location:u(e)}}c(td,"parseCaller");function nd(t,e,n,i){let r=e.content.startsWith("when append");if(n.whenDeclared){let l=n.whenAppended!==null||r?d.ConflictingSpecificationActions:d.DuplicateSpecificationWhen;t.error(l,`Specification '${i}' already declares a 'when' - a specification can have at most one`,u(e)),ye(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=$r(t,e,Ec,"when append")??null;return}if(Fc.test(e.content)){let l=Uc.exec(e.content);l===null?(t.error(d.UnmatchedRedeliveredOccurrence,"Expected 'when redelivered <Event> to <Reaction>'.",u(e)),ye(t,e.indent)):n.whenRedelivered={kind:"SpecificationRedeliverySyntax",eventType:l[1],reaction:l[2],...gr(t,e,void 0,void 0,"when redelivered"),location:u(e)};return}if(jc.test(e.content)){n.whenClock=pa(t,e,"when");return}if(Nc.test(e.content)){n.whenTrigger=Sr(t,e,zc,d.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(l,p)=>({kind:"SpecificationTriggerSyntax",trigger:l,values:p,location:u(e)}));return}if(Lc.test(e.content)){n.whenCapture=fa(t,e,"when");return}if(qc.test(e.content)){n.whenQuery=Sr(t,e,Gc,d.InvalidSpecificationQueryAction,"when query","when query <Query>",(l,p)=>({kind:"SpecificationWhenQuerySyntax",query:l,arguments:p,location:u(e)}));return}let o=Pc.exec(e.content);if(o===null){t.error(d.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,u(e)),ye(t,e.indent);return}let s=[],a=gr(t,e,s,o);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...a,generatedValues:s,inlineProperty:o.groups?.property??null,location:u(e)}}c(nd,"parseWhen");function id(t,e,n){if(Wc.test(e.content)){e.content!=="then no events"||n.thenNoEvents?t.error(d.InvalidNoEventsExpectation,"Expected one 'then no events' directive.",u(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.",u(o)),ye(t,e.indent);return}if(dr.test(e.content)){let o=Mo(t,e);n.thenReturns!==null?t.error(d.InvalidReturnExpectation,"A specification declares at most one return expectation.",u(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.",u(e)):n.thenEventsInAnyOrder=!0,ye(t,e.indent);return}if(Bc.test(e.content)){od(t,e,n);return}if(Yc.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(d.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",u(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:u(e)},ye(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(d.InvalidSpecificationDenied,"Expected exactly 'then denied'.",u(e)),ye(t,e.indent)):n.thenDenied!==null?t.error(d.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",u(e)):n.thenDenied={kind:"SpecificationDeniedSyntax",location:u(e)};return}if(e.content==="then error"){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:u(e)});return}if(e.content.startsWith("then error case.")){let o=Pe(e.content.substring(11),{...u(e),column:u(e).column+11},t);o.kind==="CaseValueExpressionSyntax"&&n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,caseValue:o,location:u(e)});return}let i=Tc.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:ee(i[1]),location:u(e)});return}if(D(e.content.substring(4).trim())==="error"){t.error(d.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,u(e)),ye(t,e.indent);return}if(ca.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let s=rd(t,e);s!==null&&n.thenAbsentReadModels.push(s);return}let o=da.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let s=Pe(o[2].trim(),u(e),t.valueContext);(s.kind==="LiteralExpressionSyntax"||s.kind==="ObjectExpressionSyntax"||s.kind==="CaseValueExpressionSyntax")&&n.thenAbsentReadModels.push({kind:"SpecificationAbsentReadModelSyntax",name:o[1],key:s,location:u(e)})}t.skipOpaqueBlock(e.indent);return}if(wc.test(e.content)){let o=t.sourceOptions.numericMode==="exact",s=c((f,y,h)=>{if(!o)return t.skipOpaqueBlock(h.indent);t.error(f,y,u(h)),t.skipBlock(h.indent)},"reject"),a=Kc.exec(e.content);if(a===null)return s(d.InvalidSpecificationQuery,`Invalid 'then query' declaration '${e.content}' - expected 'then query <Query> [exactly]'`,e);let l=[],p=[],m=!1;for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent))t.reader.takeSignificant(),f.content==="arguments"&&!m?l.push(...fn(t.valueContext,f,!0)):f.content==="arguments"?s(d.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,f):f.content==="result"?p.push({kind:"SpecificationQueryResultSyntax",properties:fn(t.valueContext,f,!0),exactly:!1,location:u(f)}):s(d.UnknownSpecificationQueryDirective,`Unexpected '${D(f.content)}' in 'then query' body - expected arguments or result`,f),m||=f.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:a[1],arguments:l,results:p,exactly:a[2]!==void 0,location:u(e)});return}if(la.test(e.content)){let o=ua(t,e,Ic,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=$r(t,e,Ac,"then");r!==void 0&&n.thenEvents.push(r)}c(id,"parseThen");function rd(t,e){let n=da.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>'`,u(e)),ye(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||Zc.test(i)?Pe(i,u(e),t.valueContext):null,s=o!==null&&(o.kind==="LiteralExpressionSyntax"||o.kind==="ObjectExpressionSyntax"||o.kind==="CaseValueExpressionSyntax");s||t.error(d.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,u(e));let a=!1;for(let l=t.peekChild(e.indent);l!==void 0;l=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(d.InvalidAbsentReadModelStep,"An absent read model assertion cannot have child mappings.",u(l)),a=!0;return a||!s?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:u(e)}}c(rd,"parseAbsentReadModel");function ye(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}c(ye,"skipBody");function pa(t,e,n){let i=Vc.exec(e.content);return ye(t,e.indent),i===null||i[1]!==n?(t.error(Dt(e.content)?d.InvalidSpecificationCaseReference:d.InvalidSpecificationClock,`Invalid '${n} clock' - expected '${n} clock "<ISO 8601 instant>"', such as '${n} clock "2026-10-05T08:00:00Z"'`,u(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:u(e)}}c(pa,"parseClock");function fa(t,e,n){return Sr(t,e,Qc,d.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:u(e)}))}c(fa,"parseCapture");function Sr(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}'`,u(e)),ye(t,e.indent),null):s(a[1],fn(t,e))}c(Sr,"parseNamedStep");function od(t,e,n){let i=_c.exec(e.content);if(i===null){t.error(d.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,u(e)),ye(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:fn(t,e),exactly:i[1]!==void 0,location:u(e)})}c(od,"parseResult");function ua(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>'`,u(e)),ye(t,e.indent);return}return{kind:"SpecificationReadModelSyntax",name:r[1],properties:fn(t,e,!1,r),exactly:i==="then"&&r.groups?.exactly!==void 0,inlineProperty:r.groups?.property??null,location:u(e)}}c(ua,"parseReadModelStep");function $r(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>'`,u(e)),ye(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...gr(t,e,void 0,r,i),inlineProperty:r.groups?.property??null,location:u(e)}}c($r,"parseEventStep");var br=ge("^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$"),ad=w("^streamId\\s*=(?!=|>)\\s*(.+)$");function gr(t,e,n,i,r){let o=[];ti(t,e,i,o);let s=null,a,l,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&jn.test(m.content)){let y=Rt(t,m,Nn,d.InvalidGeneratedFixture);y!==null&&n.push(y);continue}let f=xr.exec(m.content);if(f!==null)un(t,o,ma(t,m,f));else if(D(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.",u(m)),t.skipBlock(m.indent);continue}if(p){t.error(d.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",u(m)),t.skipBlock(m.indent);continue}let y=br.exec(m.content);m.content==="no stream"&&(r==="then"||r==="when redelivered")?(l={kind:"SpecificationNoStreamSyntax",location:u(m)},p=!0,ei(t,m)):y!==null?(a=kr(t,m,y),p=!0):(t.error(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",u(m)),t.skipBlock(m.indent))}else if(D(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>'",u(m)):s!==null?t.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",u(m)):s=Pe(y,u(m),t)}else t.error(d.InvalidSpecificationValue,`Invalid property mapping '${m.content}' - expected '<property> = <value>'`,u(m))}return{values:o,for:s,...a===void 0?{}:{stream:a},...l===void 0?{}:{noStream:l}}}c(gr,"parseValuesWithEventSource");function kr(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.",u(a)),t.skipBlock(a.indent)):(o=!0,s.streamId=u(a),r=mr(t,a,d.InvalidSpecificationStream).map(m=>m.source.kind==="PathExpressionSyntax"&&m.source.path.startsWith("case.")?{...m,source:Pe(m.source.path,m.source.location,t)}:m));continue}let l=ad.exec(a.content);if(l===null||i!==null||o){t.error(d.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",u(a)),t.skipBlock(a.indent);continue}let p={...u(a),column:a.indent+1+a.content.indexOf(l[1],a.content.indexOf("=")+1)};i={kind:"PropertyMappingSyntax",property:"streamId",source:Pe(l[1],p,t),location:u(a)},ei(t,a)}return{kind:"SpecificationStreamSyntax",eventSource:n[1],stream:n[2],streamId:i,streamIdParts:r,directiveLocations:s,referenceLocation:{...u(e),column:e.indent+1+e.content.indexOf(n[1],6)},referenceLength:n[1].length+1+n[2].length,location:u(e)}}c(kr,"parseSpecificationStream");function ei(t,e){let n=t.peekChild(e.indent);n!==void 0&&(t.error(d.InvalidSpecificationStream,"This directive cannot have children.",u(n)),t.skipBlock(e.indent))}c(ei,"rejectSpecificationRouteChildren");function fn(t,e,n=!1,i){let r=[];ti(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"?Rc:xr).exec(o.content);if(s===null){t.error(d.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,u(o));continue}un(t,r,ma(t,o,s,n))}return r}c(fn,"parseValues");function ma(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:Pe(n[2],u(e),t,i),location:u(e)}}c(ma,"mappingOf");var sd=Q("^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$".replaceAll("\\s",U)),ld=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$".replaceAll("\\s",U));function tt(t,e){let n=sd.exec(e.content);if(n===null)return t.error(d.InvalidSpecificationExample,`Invalid example declaration '${e.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,u(e)),t.skipOpaqueBlock(e.indent),{kind:"SpecificationExampleSyntax",name:"",type:"",values:[],generatedValues:[],for:null,description:null,location:u(e)};let i=cd(t,e,void 0,!0,n[1]);for(let r of Mt(i))t.error(d.InvalidSpecificationCaseReference,"Case references are not permitted in example bodies.",r.location);return{kind:"SpecificationExampleSyntax",name:n[1],type:n[2],...i,location:u(e)}}c(tt,"parseExample");function ti(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=u(e),l=Tt(t,o,{...a,column:a.column+s},d.InvalidSpecificationValue);l!==null&&i.push({kind:"PropertyMappingSyntax",property:r,source:l,location:{...a,column:a.column+e.content.lastIndexOf(r,e.content.indexOf("="))}})}c(ti,"addInlineValue");function un(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)}c(un,"addFixtureValue");function cd(t,e,n,i=!1,r){let o=[],s=[],a=null,l=null,p,m;ti(t,e,n,o);for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r!==void 0&&D(f.content)==="description"){l=Z(t,f,l,`Example '${r}'`);continue}if(i&&jn.test(f.content)){let h=Rt(t,f,Nn,d.InvalidGeneratedFixture);h!==null&&(r===void 0?s.push(h):un(t,s,h,o));continue}let y=ld.exec(f.content);if(r!==void 0&&y===null&&(D(f.content)==="stream"||f.content.startsWith("no stream"))){let h=br.exec(f.content);p!==void 0||m!==void 0?(t.error(d.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",u(f)),t.skipOpaqueBlock(f.indent)):f.content==="no stream"?(m={kind:"SpecificationNoStreamSyntax",location:u(f)},ei(t,f)):h!==null?p=kr(t,f,h):(t.error(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on an event example.",u(f)),t.skipOpaqueBlock(f.indent));continue}if(y!==null)un(t,o,{kind:"PropertyMappingSyntax",property:y[1],source:Pe(y[2],u(f),t),location:u(f)},s);else if(D(f.content)==="for"){let h=f.content.substring(3).trim();h.length===0?t.error(d.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",u(f)):a!==null?t.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",u(f)):a=Pe(h,u(f),t)}else t.error(d.InvalidSpecificationValue,`Invalid property mapping '${f.content}' - expected '<property> = <value>'`,u(f))}return{values:o,for:a,generatedValues:s,description:l,...p===void 0?{}:{stream:p},...m===void 0?{}:{noStream:m}}}c(cd,"parseFixtureBody");var ya=["StateChange","StateView","Automation","Translate"];var mn=["tag"];var dd=w(`^id\\s+"(${H})"$`),Wt=class{static{c(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=u(n);switch(D(n.content)){case"id":{let r=dd.exec(n.content),o=r===null?"":ee(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=Z(e,n,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":return this.value.documentation=be(e,n,this.value.documentation,`Event '${this.name}'`,d.InvalidEventDocumentation),!0;default:return!1}}};var pd=w("^type\\s+([A-Za-z_]\\w*)$"),fd=w("^event\\s+([A-Za-z_]\\w*)(?:\\s+generation\\s+([0-9]+))?$"),ud=w("^readmodel\\s+([A-Za-z_]\\w*)$"),ha=4294967295,md=w("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),yd=w("^[A-Za-z_]\\w*$"),Sa=c(t=>D(t.content)==="description"&&Qe(t)===void 0,"isDescription");function Cr(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,u(n)),{...e,isIdentifier:!1}):e}c(Cr,"withoutIdentifier");function ga(t,e){let n=pd.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,u(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Sa(o)){r=Z(t,o,r,`Type '${n}'`);continue}if(Jn(o))continue;let s=De(t,o);if(s===void 0){t.error(d.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,u(o));continue}i.push(Cr(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`,u(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:u(e)}}c(ga,"parseType");function xa(t,e){let n=fd.exec(e.content),i=n?.[1]??"";n===null&&t.error(d.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected 'event <Name> [generation <N>]'`,u(e));let r=n?.[2]!==void 0,o=1;if(r){let p=Number(n[2]);!Number.isSafeInteger(p)||p===0||p>=ha?t.error(d.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${ha-1}`,u(e)):o=p}let s=[],a=[],l=new Wt(i);for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Jn(p))continue;if(mn.includes(D(p.content))){let f=yn(t,p);f!==void 0&&a.push(f);continue}let m=De(t,p);if(m===void 0){l.tryParse(t,p)||t.error(d.InvalidPropertyDeclaration,`Invalid property '${p.content}' - expected '<name> <Type>'`,u(p));continue}s.push(Cr(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,...l.value,location:u(e)}}c(xa,"parseEvent");function yn(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&md.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`,u(e)),i.length===0){t.error(d.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",u(e));return}if(yd.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:u(e)},location:u(e)};let r=ce(i,u(e),t);if(r.kind==="RawExpressionSyntax"){t.error(d.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,u(e));return}return{kind:"TagSyntax",value:r,location:u(e)}}c(yn,"parseTag");function va(t,e){let n=ud.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,u(e));let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),Sa(s))r=Z(t,s,r,`Read model '${n}'`);else if(D(s.content)==="documentation"&&Qe(s)===void 0)o=be(t,s,o,`Read model '${n}'`);else{if(Jn(s))continue;{let a=De(t,s);if(a===void 0){t.error(d.InvalidPropertyDeclaration,`Invalid property '${s.content}' - expected '<name> <Type>'`,u(s));continue}i.push(Cr(t,a,s,d.IdentifierOutsideCommand,`Property '${a.name}' of read model '${n}' cannot be marked identifier - only a command property can be`))}}return{kind:"ReadModelSyntax",name:n,properties:i,description:r,documentation:o,location:u(e)}}c(va,"parseReadModel");var hd=Q("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function xe(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 l=0;l<s.length;l++){if(s[l]!=="$"||s[l+1]!=="{")continue;l>a&&o.push({kind:"TemplateTextSyntax",text:s.substring(a,l),location:e});let p=s.indexOf("}",l);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:xe(s.substring(l+2,p),e,n),location:e}),l=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 Te(i,e,n);if(t.startsWith("literal ")){let o=an(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=an(t,e,n);return r!==void 0?r:hd.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(d.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}c(xe,"parseProjectionExpression");var ii=c(t=>({legacy:w(t),native:Q(t)}),"grammar"),Sd=ii("^capture\\s+([A-Za-z_]\\w*)$"),gd=ii("^append\\s+([A-Z]\\w*)$"),xd=ii("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),vd=ii("^nested\\s+([\\w.]+)$"),ni=c((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),$d=Q("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),bd=Q("^([a-z_]\\w*)\\s*=\\s*(.+)$"),kd=Q(`^"(${H})"\\s*=>\\s*(\\w+)$`),Cd=Q(`^split\\s+(\\S+)\\s+by\\s+"(${H})"$`),Ed=new RegExp(Q(`"${H}"|[\\w.]+`).source,"gu"),Pd=Q("^[\\w.]+$");function Er(t,e){t=t.valueContext;let n=ni(t,Sd).exec(e.content)?.[1]??"";n===""&&t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,u(e));let i=null,r=null,o=[],s=[],a=[],l=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(p.content)){case"source":i=Ad(t,p);break;case"key":r=p.content.substring(3).trim();break;case"map":o.push(...ba(t,p));break;case"append":ka(t,p,s);break;case"children":{let m=ni(t,xd).exec(p.content);if(m===null){t.error(d.InvalidChildrenDeclaration,`Invalid children declaration '${p.content}' - expected 'children <collection> identified by <key>'`,u(p)),t.skipOpaqueBlock(p.indent);break}let f=$a(t,p);m!==null&&a.push({kind:"CaptureChildrenSyntax",property:m[1],identifiedBy:m[2],...f,location:u(p)});break}case"nested":{let m=ni(t,vd).exec(p.content);if(m===null){t.error(d.InvalidNestedDeclaration,`Invalid nested declaration '${p.content}' - expected 'nested <Property>'`,u(p)),t.skipOpaqueBlock(p.indent);break}let f=$a(t,p);m!==null&&l.push({kind:"CaptureNestedSyntax",property:m[1],...f,location:u(p)});break}default:t.error(d.UnknownCaptureDirective,`Unexpected '${p.content}' in capture body`,u(p)),t.skipOpaqueBlock(p.indent)}return{kind:"CaptureSyntax",sourceOptions:t.sourceOptions,name:n,source:i,key:r,map:o,appends:s,children:a,nested:l,location:u(e)}}c(Er,"parseCapture");function Ad(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=D(i.content);n.push({kind:"CaptureSourceSettingSyntax",name:r,value:i.content.substring(r.length).trim(),location:u(i)})}return{kind:"CaptureSourceSyntax",syntaxKind:e.content.substring(6).trim(),settings:n,location:u(e)}}c(Ad,"parseSource");function ba(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=u(i);if(D(i.content)==="split"){let f=Cd.exec(i.content);if(f===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(),Pd.test(h.content)?y.push(h.content):t.error(d.InvalidSplitTarget,`Invalid split target '${h.content}' - expected a property path`,u(h));f!==null&&n.push({kind:"CaptureSplitSyntax",source:xe(f[1],r,t),separator:ee(f[2]),targets:y,location:r});continue}let o=bd.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,l=s.startsWith("`")?a>=0&&s.substring(a+1).trim()==="translate":s.endsWith(" translate"),p=s.startsWith("`")&&a>=0&&(t.sourceOptions.numericMode!=="exact"||l||s.substring(a+1).trim()==="")?s.substring(0,a+1):l?s.substring(0,s.length-10).trimEnd():s,m=[];if(l)for(let f=t.peekChild(i.indent);f!==void 0;f=t.peekChild(i.indent)){t.reader.takeSignificant();let y=kd.exec(f.content);y!==null?m.push({kind:"CaptureTranslationSyntax",from:ee(y[1]),to:y[2],location:u(f)}):t.error(d.InvalidTranslation,`Invalid translation '${f.content}' - expected '"<source>" => <target>'`,u(f))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:xe(p,r,t),translations:m,location:r})}return n}c(ba,"parseMap");function $a(t,e){let n=[],i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="map"?n=ba(t,r):D(r.content)==="append"?ka(t,r,i):(t.error(d.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${D(e.content)} block - expected 'map' or 'append <EventType>'`,u(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}c($a,"mapAndAppends");function ka(t,e,n){let i=ni(t,gd).exec(e.content);if(i===null){t.error(d.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,u(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],s=null,a=c((l,p=!1)=>{let m=u(l);if(D(l.content)==="tag"){let y=yn(t.valueContext,l,!1);y!==void 0&&o.push(y);return}let f=$d.exec(l.content);f!==null?r.push({kind:"PropertyMappingSyntax",property:ne(f[1]),source:Te(f[2],m,t.valueContext),location:m}):t.error(p?d.InvalidPropertyMapping:d.UnknownAppendDirective,`Unexpected '${l.content}' in append body`,m)},"mapping");for(let l=t.peekChild(e.indent);l!==void 0;l=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(l.content)==="when"){s=wd(t,l);for(let p=t.peekChild(l.indent);p!==void 0;p=t.peekChild(l.indent))t.reader.takeSignificant(),a(p,!0)}else a(l);n.push({kind:"CaptureAppendSyntax",event:i[1],when:s,mappings:r,tags:o,location:u(e)})}c(ka,"pushAppend");function wd(t,e){let n=e.content.substring(4).trim(),i=u(e),r=c((l,p=[],m=null,f=null,y=null)=>({kind:"CaptureWhenSyntax",syntaxKind:l,properties:p,fromValue:m,toValue:f,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(`"${H}"|[^\\s]+`,"gu"):Ed)??[]],s=c(l=>l.startsWith('"')&&l.endsWith('"')?ee(l.substring(1,l.length-1)):l,"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 l=1;l<o.length-1;l+=2){if(o[l]!==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[l+1]))}return r(o[1]==="or"?"LogicalOr":"LogicalAnd",a)}c(wd,"parseWhen");var Pr=w("^returns\\s+(@?[A-Za-z_]\\w*)$"),Od=w("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function Ar(t,e){let n=u(e);if(e.content!=="returns"){let r=Pr.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.",u(o)),t.skipBlock(e.indent));let s=r.index+r[0].length-r[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:ne(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=Od.exec(r.content);if(o===null){Qe({...r,content:r.content.split("=",1)[0].trimEnd()})?.isSubject?t.error(d.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not response fields (decision 0008: one data subject per event).",u(r)):t.error(d.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",u(r)),t.skipBlock(r.indent);continue}let s=u(r),a=o[2]===void 0?null:Re(o[2],{...s,column:s.column+r.content.indexOf(o[2],o[1].length)});a!==null&&Be(t,a,r),i.push({kind:"ResponseFieldSyntax",name:ne(o[1]),type:a,source:{kind:"PropertyResponseSourceSyntax",property:ne(o[3]),location:{...s,column:s.column+r.content.lastIndexOf(o[3])}},location:s});let l=t.peekChild(r.indent);l!==void 0&&(t.error(d.InvalidCommandResponse,"A response field cannot have child directives.",u(l)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}c(Ar,"parseCommandResponse");var ri=new WeakMap;function oi(t){let e=Q(`^reads${U}+([A-Z]\\w*)(?:${U}+as${U}+([a-z_]\\w*))?(?:${U}+by${U}+([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:u(t)}}c(oi,"captureReads");function Ca(t){return new me(t.reader.fork(),t.path,t.languages)}c(Ca,"fork");function Ea(t,e){if(e.content!=="concurrency")return;let n=Ca(t),i=!1,r={},o;for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent))switch(n.reader.takeSignificant(),D(s.content)){case"eventSource":s.content==="eventSource"&&(i=!0);break;case"sourceType":case"streamType":case"streamId":{let a=Q(`^(sourceType|streamType|streamId)${U}+([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(l=>l.replace(new RegExp(`^${U}+|${U}+$`,"gu"),"")).filter(Boolean);a.length>0&&a.every(l=>Q("^[A-Z]\\w*$").test(l))&&(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:u(e)}}c(Ea,"captureConcurrency");function Pa(t,e){let n=Q(`^reducer${U}+([A-Za-z_]\\w*)${U}*=>${U}*([A-Za-z_]\\w*)$`).exec(e.content),i=Ca(t),r=[];for(let o=i.peekChild(e.indent);o!==void 0;o=i.peekChild(e.indent)){if(i.reader.takeSignificant(),D(o.content)==="description"){Z(i,o,null,"Reducer");continue}let s=Q(`^on${U}+([A-Z]\\w*)$`).exec(o.content);s!==null&&r.push({kind:"ReducerRuleSyntax",event:s[1],file:null,code:null,description:null,location:u(o)}),i.skipOpaqueBlock(o.indent)}return{kind:"ReducerSyntax",name:n?.[1]??"",readModel:n?.[2]??"",rules:r,description:null,location:u(e)}}c(Pa,"captureReducer");var Id=w("^produces\\s+operation(?:\\s|$)"),Td=w("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),Rd=w("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Aa=w("^produces\\s+when\\s+(.+)$"),Dd=w("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Md=w("^for\\s+(\\S.*)$"),jd=w("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Nd=w("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Ld=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function hn(t,e,n=!1){if(Id.test(e.content)){if(!n){t.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",u(e)),t.skipOpaqueBlock(e.indent);return}let v=Xn(t,e,!0);return{kind:"ProducesSyntax",when:null,event:v.operation.name,targetLocation:{...u(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:v.operation,mappings:v.mappings,for:null,tags:[],location:u(e)}}let i=Td.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",u(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",u(e)),s=i[1],a=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(Aa.test(e.content)){o=Ue(t,Aa.exec(e.content)[1],u(e));let v=t.peekChild(e.indent);if(v===void 0||!Dd.test(v.content)){t.error(d.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",u(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=v,s=v.content,a=v.indent+1}else{let v=Rd.exec(e.content);if(v===null){t.error(d.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,u(e)),t.skipOpaqueBlock(e.indent);return}s=v[1],a=e.indent+e.content.match(/^produces\s+/)[0].length+1}let l=[],p=new Set,m=[],f=[],y=new Wt(s),h=null;for(let v=t.peekChild(r.indent);v!==void 0;v=t.peekChild(r.indent)){t.reader.takeSignificant();let x=D(v.content),S=u(v);if(Ld.has(x)){t.error(d.ReservedProductionMetadata,`'${x}' is system-assigned production metadata and cannot be supplied here`,S),t.skipOpaqueBlock(v.indent);continue}if(i!==null&&(x==="generation"||x==="origin")){t.error(x==="generation"?d.InlineEventGeneration:d.ReservedProductionMetadata,x==="generation"?"Inline events are generation 1 - extract the event before declaring generations":"An inline event is local to its command and cannot declare origin",S),t.skipOpaqueBlock(v.indent);continue}if(x==="tag"){let A=yn(t,v,!1);A!==void 0&&f.push(A);continue}let E=Md.exec(v.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`,S):h=ce(E[1],S,t);continue}let g=(i===null?jd:Nd).exec(v.content),P=g===null||i===null?void 0:De(t,{...v,content:g[1].trimEnd()});if(g!==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`,S),P={...P,isIdentifier:!1});let A=P.name;p.has(A)&&t.error(d.DuplicateDeclaration,`Event '${s}' already declares property '${P.name}'`,S),p.add(A),l.push(P)}m.push({kind:"PropertyMappingSyntax",property:P?.name??ne(g[1]),source:ce(g[2],{...S,column:v.indent+v.content.length-g[2].length+1},t),location:S})}else(i===null||!y.tryParse(t,v))&&t.error(d.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${v.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,S)}return r!==e&&t.skipBlock(e.indent),{kind:"ProducesSyntax",when:o,event:s,targetLocation:{...u(r),column:a},inlineOperation:null,mappings:m,for:h,tags:i===null?f:[],location:u(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:s,properties:l,tags:f,generation:1,hasGenerationMarker:!1,...y.value,location:u(e)}}}c(hn,"parseProduces");var qd=w("^command\\s+([A-Za-z_]\\w*)$"),Bd=ge("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),Yd=w("\\bseverity\\s+(\\S+)$"),Oa=w(`\\bmessage\\s+(?:"(${H})"|(\\$strings\\.\\S*))$`),Fd=w("^([\\w.]+)\\s+(.+)$"),Ud=w("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),Wd=ge("^[A-Za-z_]\\w*$"),Vd=w("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),zd={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},Ia={information:"Information",warning:"Warning",error:"Error"},Qd=new Set(["reads","concurrency"]),Gd=new Set(["description","documentation","handler","concurrency"]);function Ta(t,e){let n=new Set,i=new me(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,wa(i,e,void 0,n),wa(t,e,n)}c(Ta,"parseCommand");function wa(t,e,n,i){let r=qd.exec(e.content)?.[1]??"";r===""&&t.error(d.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,u(e));let o=[],s=[],a,l=[],p=[],m=[],f=[],y,h=null,v=null,x=null,S=null,E=null,g=[];for(let C=t.peekChild(e.indent);C!==void 0;C=t.peekChild(e.indent)){t.reader.takeSignificant();let O=D(C.content),I=Qe(C);if(I!==void 0&&(Gd.has(O)||O==="validate"&&C.content!=="validate csharp"))a=ai(t,o,I,r,C,a);else if(O==="returns"){let R=Pr.exec(C.content);R!==null&&!R[1].startsWith("@")&&I!==void 0?n===void 0?(o.push(I),s.push({line:C,candidate:I,response:null})):n.has(I.type.name)?s.push({line:C,candidate:null,response:Ar(t,C)}):a=ai(t,o,I,r,C,a):I!==void 0?a=ai(t,o,I,r,C,a):Mn(t,C)?t.skipBlock(C.indent):s.push({line:C,candidate:null,response:Ar(t,C)})}else if(O==="stream"&&Bd.test(C.content)&&I!==void 0&&t.streamCandidates?.hasSource(I.type.name.split(".")[0])===!0){let[R,j]=I.type.name.split("."),N=t.streamCandidates.hasPropertyType(I.type.name)&&t.streamCandidates.hasUniqueStream(R,j),B=ia(t,C,I,N);(E!==null||g.length>0)&&t.error(d.InvalidCommandStream,"A command declares at most one stream route.",u(C)),N||E!==null?g.push(B):E=B}else if(O==="description")h=Z(t,C,h,`Command '${r}'`);else if(O==="documentation")v=be(t,C,v,`Command '${r}'`);else if(O==="authorize")x=_e(x,pt(t,C));else if(O==="validate"){let R=wr(t,C,"command");R!==void 0&&l.push(R)}else if(O==="produces"){let R=hn(t,C,!0);R!==void 0&&p.push(R)}else if(O==="handler")S=aa(t,C);else if(Qd.has(O)){let R=oi(C);R!==void 0&&f.push(R),O==="concurrency"&&y===void 0&&(y=Ea(t,C));let j=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(C.content);j!==null&&m.push({readModel:j[1],alias:j[2]??null}),Vd.test(C.content)&&t.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",u(C)),t.skipOpaqueBlock(C.indent)}else I!==void 0?a=ai(t,o,I,r,C,a):(Mn(t,C),t.error(d.UnknownCommandDirective,`Unexpected '${C.content}' in command body`,u(C)),t.skipBlock(C.indent))}let P=new Set(s.flatMap(C=>C.candidate===null?[]:[C.candidate])),A=new Set(o.filter(C=>!P.has(C)).map(C=>C.name));s.some(C=>C.candidate!==null&&!A.has(C.candidate.type.name)&&C.candidate.type.name!=="returns")&&A.add("returns");for(let C of A)i?.add(C);let $=null,b=new Set;for(let C of s){let O=C.response;if(C.candidate!==null){if(!A.has(C.candidate.type.name))continue;b.add(C.candidate),O={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:C.candidate.type.name,location:C.candidate.type.location},location:u(C.line)}}O!==null&&($!==null?t.error(d.InvalidCommandResponse,"A command declares at most one unconditional response.",u(C.line)):$=O)}S!==null&&p.length>0&&t.error(d.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,u(e));let k={kind:"CommandSyntax",name:r,description:h,documentation:v,authorize:x,properties:o.filter(C=>!b.has(C)),validations:l,produces:p,handler:S,response:$,stream:E,streamCandidates:g,location:u(e)};return ri.set(k,m),Xe.set(k,{reads:f,concurrency:y}),k}c(wa,"parseCommandBody");function ai(t,e,n,i,r,o){return Be(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)}c(ai,"addProperty");function wr(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=Ne(t.valueContext,i);return a===null&&t.skipFencedBody(),{kind:"CodeValidateSyntax",code:a,location:u(e)}}let r=[],o=[],s;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n==="concept"){if(t.sourceOptions.numericMode==="legacy"&&a.content.startsWith("```")){t.skipFencedBody();continue}if(s!==void 0&&a.indent<=s&&(s=void 0),s!==void 0||D(a.content)==="implementation"){t.error(d.InvalidValidationRule,`Invalid validation rule '${a.content}'`,u(a)),s??=a.indent;continue}}if(D(a.content)==="require"){let p=Ue(n==="concept"?t.valueContext:t,a.content.substring(7).trim(),u(a)),m=null,f="Error",y=!1;for(let h=t.peekChild(a.indent);h!==void 0;h=t.peekChild(a.indent)){t.reader.takeSignificant();let v=Oa.exec(h.content);v!==null&&v.index===0?m=v[1]!==void 0?ee(v[1]):v[2]:D(h.content)==="severity"?(y||(f=Ia[h.content.substring(8).trim()]??"Error"),y=!0):t.skipOpaqueBlock(h.indent)}p!==null&&o.push({kind:"RequirementSyntax",condition:p,message:m,severity:f,location:u(a)});continue}let l=_d(t,n==="concept"?{...a,content:`value ${a.content}`}:a,n);l!==void 0&&r.push(l)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:u(e)}}if(e.content==="validate csharp"){let i=Ne(t.valueContext,{...e,content:"csharp"});return i===null&&t.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",code:i,location:u(e)}}t.error(d.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,u(e)),t.skipBlock(e.indent)}c(wr,"parseValidate");function _d(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=Kd(e.content),s=Jd(i,e,r);if(s===void 0)return;let a=Fd.exec(s.content);if(a===null){i.error(d.InvalidValidationRule,`Invalid validation rule '${e.content}'`,u(e));return}let l=Hd(i,a[2],e);if(l===void 0)return;let p=l.kind==="Rule"?Zd(t,e,n==="command"):{file:null,code:null,implementation:null};return{kind:"ValidationRuleSyntax",property:a[1],rule:l.kind,value:l.value,message:o,severity:s.severity,...p,location:u(e)}}c(_d,"parseValidationRule");function Zd(t,e,n){let i=t.peekChild(e.indent);if(i===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let r=n&&D(i.content)==="implementation",o=r?dn(t,i):{file:Ft(i)?ft(t,i):null,code:!Ft(i)&&cn(t,i)?Ne(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`,u(i)),t.skipBlock(i.indent));for(let s=t.peekChild(e.indent);s!==void 0&&(r||n&&D(s.content)==="implementation");s=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(r&&D(s.content)==="implementation"?d.InvalidImplementationBlock:d.ConflictingImplementationSources,"A named rule has one implementation wrapper and cannot mix wrapped and direct sources.",u(s)),cn(t,s)?Ne(t,s):t.skipBlock(s.indent);return o}c(Zd,"parseRuleImplementation");function Kd(t){let e=Oa.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?ee(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}c(Kd,"splitMessage");function Jd(t,e,n){let i=Yd.exec(n);if(i===null)return{content:n,severity:"Error"};let r=Ia[i[1]];if(r===void 0){t.error(d.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,u(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}c(Jd,"splitSeverity");function Hd(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=Ud.exec(e);if(i===null){t.error(d.InvalidValidationRule,`Invalid validation rule '${n.content}'`,u(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!Wd.test(r)){t.error(d.InvalidRuleName,`Invalid rule name '${r}' in '${n.content}' - expected 'rule <Name>' with an identifier`,u(n));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:r,location:u(n)}}}return{kind:zd[i[1]],value:ce(i[2],u(n),t)}}c(Hd,"parseRule");var Xd=w("^constraint\\s+([A-Za-z_]\\w*)$"),ep=w("^unique\\s+event\\s+([A-Z]\\w*)$"),tp=w("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),np=w("^released\\s+by\\s+([A-Z]\\w*)$"),ip=w(`^message\\s+"(${H})"$`),rp=c(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function Ra(t,e){let n=Xd.exec(e.content);n===null&&t.error(d.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,u(e));let i=n?.[1]??D(e.content),r=[],o=[],s=new Set,a=new Set,l=null,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let f=np.exec(m.content),y=ip.exec(m.content);f!==null?s.has(f[1])?t.error(d.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${f[1]}'`,u(m)):(o.push(f[1]),s.add(f[1])):y!==null?l!==null?t.error(d.DuplicateConstraintBody,`Constraint '${i}' already has a message`,u(m)):l=ee(y[1]):m.content==="ignore casing"?(p&&t.error(d.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,u(m)),p=!0):op(t,i,m,r,a)}for(let m of o.filter(f=>a.has(f)))t.error(d.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${m}'`,u(e));return r.length===0&&(t.error(d.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,u(e)),r.push(si(i,u(e),{kind:"UniqueEventConstraintSyntax",event:""}))),r[0].kind==="FileConstraintSyntax"&&(o.length>0||l!==null||p)&&t.error(d.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,u(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:l,ignoreCasing:p}}c(Ra,"parseConstraint");function op(t,e,n,i,r){let o=ap(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`,u(n));return}let s=rp(o);if(s!==void 0&&r.has(s)){t.error(d.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,u(n));return}s!==void 0&&r.add(s),i.push(o)}c(op,"addRule");function ap(t,e,n){let i=u(n),r=ep.exec(n.content);if(r!==null)return si(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=tp.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 si(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:o[2]})}if(fe(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 si(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}t.error(d.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}c(ap,"parseRule");function si(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}c(si,"rule");var sp=w("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),lp=w("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),cp=w("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),dp=w("^with\\s+(@?[\\w.]+)$"),pp=w("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),fp=w("^nested\\s+(@?[\\w.]+)$"),up=w("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),mp=w("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),yp=w("^clear\\s+with\\s+(@?[\\w.]+)$"),hp=w("^variant\\s+(@?[\\w.]+)\\s*$"),Sp=w("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),gp=w("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),xp=w("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),vp=w("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),Da=w("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),$p={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function Ir(t,e){let n=sp.exec(e.content);if(n===null)return t.error(d.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,u(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:D(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:u(e)};let i=n[1],r=null,o="Inherit",s=null,a=[];for(let l=t.peekChild(e.indent);l!==void 0;l=t.peekChild(e.indent)){if(t.reader.takeSignificant(),fe(l))continue;let p=D(l.content);if(p==="sequence")r=l.content.substring(8).trim();else if(p==="automap")o="Enabled";else if(l.content==="no automap")o="Disabled";else if(p==="key")s=ja(t,l);else if(p==="variant")a.push(Op(t,l));else{let m=Tr(t,l,!1);m!==void 0&&a.push(m)}}return bp(t,a,i),a.length===0&&t.error(d.EmptyProjection,`Projection '${i}' must contain at least one directive`,u(e)),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:i,readModel:n[2]??null,sequence:r,autoMap:o,key:s,blocks:a,location:u(e)}}c(Ir,"parseProjection");function bp(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)}c(bp,"reportVariantConflicts");function Tr(t,e,n){let i=u(e);switch(D(e.content)){case"from":return kp(t,e);case"every":{let r=!0,{autoMap:o,mappings:s}=Or(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}=Or(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return Cp(t,e);case"children":return Ep(t,e);case"nested":return Pp(t,e);case"remove":return Ap(t,e);case"clear":return n||t.error(d.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),wp(t,e);default:t.error(d.UnknownProjectionDirective,`Unexpected '${D(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}c(Tr,"parseBlock");function kp(t,e){let n=[];for(let s of To(e.content.substring(4),",")){let a=s.trim();if(a.length===0){t.error(d.FromWithoutEvent,"Expected an event type after 'from'",u(e));continue}let l=lp.exec(a);if(l===null){t.error(d.InvalidEventReference,`Invalid event reference '${a}'`,u(e));continue}n.push({kind:"EventSpecSyntax",event:ne(l[1]),key:l[2]===void 0?null:xe(l[2],u(e),t),location:u(e)})}let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);a==="key"?r=ja(t,s):a==="parent"?o=xe(s.content.substring(6),u(s),t):Na(t,s,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:u(e)}}c(kp,"parseFrom");function Cp(t,e){let n=cp.exec(e.content);if(n===null)return t.error(d.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,u(e)),t.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:u(e)};let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=dp.exec(r.content);if(o===null){t.error(d.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,u(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:a}=Or(t,r);i.push({kind:"JoinEventSyntax",event:ne(o[1]),autoMap:s,mappings:a,location:u(r)})}return{kind:"JoinSyntax",property:ne(n[1]),on:ne(n[2]),events:i,location:u(e)}}c(Cp,"parseJoin");function Ep(t,e){let n=pp.exec(e.content);if(n===null)return t.error(d.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,u(e)),t.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:u(e)};let{autoMap:i,blocks:r}=Ma(t,e);return{kind:"ChildrenSyntax",property:ne(n[1]),identifiedBy:xe(n[2],u(e),t),autoMap:i,blocks:r,location:u(e)}}c(Ep,"parseChildren");function Pp(t,e){let n=fp.exec(e.content);if(n===null)return t.error(d.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,u(e)),t.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:u(e)};let i=ne(n[1]),{autoMap:r,blocks:o}=Ma(t,e);return o.some(s=>s.kind==="FromSyntax")||t.error(d.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,u(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:u(e)}}c(Pp,"parseNested");function Ma(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=Tr(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}c(Ma,"parseChildBlocks");function Ap(t,e){let n=mp.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:ne(n[1]),key:n[2]===void 0?null:xe(n[2],u(e),t),location:u(e)};let i=up.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>'`,u(e)),t.skipBlock(e.indent);return}let r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),D(o.content)==="parent"?r=xe(o.content.substring(6),u(o),t):t.error(d.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,u(o));return{kind:"RemoveWithSyntax",event:ne(i[1]),key:i[2]===void 0?null:xe(i[2],u(e),t),parentKey:r,location:u(e)}}c(Ap,"parseRemove");function wp(t,e){let n=yp.exec(e.content);return n===null?(t.error(d.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,u(e)),{kind:"ClearWithSyntax",event:"",location:u(e)}):{kind:"ClearWithSyntax",event:ne(n[1]),location:u(e)}}c(wp,"parseClearWith");function Op(t,e){let n=hp.exec(e.content);if(n===null)return t.error(d.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,u(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:D(e.content),entersOn:[],blocks:[],location:u(e)};let i=ne(n[1]),r=[],o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);if(a==="enters")r.push(Ip(t,s));else if(a==="variant")t.error(d.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",u(s)),t.skipBlock(s.indent);else{let l=Tr(t,s,!1);l!==void 0&&o.push(l)}}return r.length===0&&t.error(d.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,u(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:u(e)}}c(Op,"parseVariant");function Ip(t,e){let n=Sp.exec(e.content);return n===null?(t.error(d.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,u(e)),t.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",key:null,location:u(e)}):{kind:"ProjectionEntersOnSyntax",event:ne(n[1]),key:n[2]===void 0?null:xe(n[2],u(e),t),location:u(e)}}c(Ip,"parseEntersOn");function ja(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:xe(n,u(e),t),location:u(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=Da.exec(o.content);if(s===null){t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,u(o));continue}let a=xe(s[2],u(o),t);t.sourceOptions.numericMode==="exact"&&a.kind==="TemplateExpressionSyntax"&&t.error(d.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",u(o)),i.push({kind:"KeyPartSyntax",property:ne(s[1]),expression:a,location:u(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",u(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:u(e)}}c(ja,"parseKey");function Or(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)||Na(t,o,r);return{autoMap:i,mappings:r}}c(Or,"parseMappingBlock");function Na(t,e,n){let i=u(e),r=gp.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:$p[r[1]],property:ne(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=xp.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:ne(o[2]),value:xe(o[3],i,t),location:i});return}let s=vp.exec(e.content)??Da.exec(e.content);s!==null?n.push({kind:"SetMappingSyntax",property:ne(s[1]),source:xe(s[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}c(Na,"pushMapping");var Tp=w("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Rp=w("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),Dp=w("^scoped\\s+to\\s+([a-z_]\\w*)$"),Mp=new Set(["performer"]);function qa(t,e){let n=Tp.exec(e.content);if(n===null)return t.error(d.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,u(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:D(e.content),returnType:Re("",u(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:u(e)};let i=n[1],r=Re(n[3],{...u(e),column:e.indent+1+n[0].length-n[3].length});n[2]===void 0&&r.name==="observable"&&r.isOptional&&!r.isCollection||Be(t,r,e);let o=null,s=[],a=null,l=null,p=null;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let f=D(m.content);if(f==="description")a=Z(t,m,a,`Query '${i}'`);else if(f==="by"){let y=La(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`,u(m)),o=y)}else if(f==="filter"){let y=La(t,m,"filter");y!==void 0&&s.push(y)}else f==="authorize"?p=_e(p,pt(t,m)):f==="scoped"?l=jp(t,m,l,i)??l:Mp.has(f)?t.skipOpaqueBlock(m.indent):(t.error(d.UnknownQueryDirective,`Unexpected '${m.content}' in query body - expected description, by, filter, authorize, scoped or performer`,u(m)),t.skipBlock(m.indent))}return{kind:"QuerySyntax",name:i,returnType:r,by:o,filters:s,description:a,isObservable:n[2]!==void 0,scope:l,authorize:p,location:u(e)}}c(qa,"parseQuery");function La(t,e,n){let i=Rp.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>]'`,u(e));return}let r=e.content.indexOf(i[1],n.length),o=Re(i[2],{...u(e),column:e.indent+1+e.content.indexOf(i[2],r+i[1].length)});return Be(t,o,e),{kind:"QueryParameterSyntax",name:i[1],type:o,source:i[3]===void 0?null:ce(i[3],u(e),t.valueContext),location:u(e)}}c(La,"parseParameter");function jp(t,e,n,i){let r=Dp.exec(e.content);if(r===null){t.error(d.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,u(e));return}if(n!==null){t.error(d.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,u(e));return}return r[1]}c(jp,"parseScope");var Np=w("^@?[a-z_]\\w*\\s+[\\w.]+");function Rr(t,e){let n=De(t,e);if(n!==void 0){n.isGenerated&&t.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),n.isSubject&&t.error(d.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not trigger or reaction data properties (decision 0008: one data subject per event).",n.location),t.triggerData.push(n);return}Np.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(d.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,u(e)),t.skipOpaqueBlock(e.indent)}c(Rr,"parseTriggerData");function Ba(t,e){let n=t.triggerData.length;for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),D(i.content)==="description"?Z(t,i,null,`Trigger '${e.content}'`):fe(i)||Rr(t,i);return t.triggerData.slice(n)}c(Ba,"parseTriggerDeclaration");var Lp=w("^reaction\\s+([A-Za-z_]\\w*)$"),qp=w("^when\\s+([A-Za-z_]\\w*)$"),Bp=w("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),Yp=w("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),Fp=new Set(["when","every","at"]),Up=w("^invokes\\s+([A-Z]\\w*)$"),Wp=Q("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Dr=Q("^on\\s+refused\\b(?=$|\\s+by\\b)"),Vp=Q("^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$"),zp=w("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function Ya(t,e){let n=Lp.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,u(e));let i=null,r=null,o=null,s=[],a=new Set,l=!1;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let m=D(p.content);if(m==="description"){i=Z(t,p,i,`Reaction '${n}'`);continue}if(m==="documentation"){r=be(t,p,r,`Reaction '${n}'`);continue}if(m==="where"){o=Ue(t,p.content.substring(5).trim(),u(p));continue}if(Dr.test(p.content)){t.error(d.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",u(p)),t.skipBlock(p.indent),l=!0;continue}if(!Fp.has(m)){t.error(d.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${p.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,u(p)),t.skipBlock(p.indent),l=!0;continue}let f=Zp(t,p);if(f===void 0){l=!0;continue}let y=_p(f);if(a.has(y)){t.error(d.DuplicateReactionTrigger,`Reaction '${n}' already declares '${p.content}' - a second says nothing the first did not`,u(p)),t.skipBlock(p.indent);continue}a.add(y),s.push(Qp(t,p,f))}return s.length===0&&!l&&t.error(d.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,u(e)),{kind:"ReactionSyntax",name:n,description:i,documentation:r,where:o,triggers:s,location:u(e)}}c(Ya,"parseReaction");function Qp(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=D(p.content);if(m==="description")i=Z(t,p,i,`Trigger '${p.content}'`);else if(m==="produces"){let f=hn(t,p);f!==void 0&&r.push(f)}else if(m==="invokes"){let f=Up.exec(p.content);if(f===null)t.error(d.InvalidInvokesDeclaration,`Invalid invokes declaration '${p.content}' - expected 'invokes <Command>'`,u(p)),t.skipBlock(p.indent);else{let y=new me(t.reader.fork(),t.path,t.languages);y.scope=t.scope,y.sourceOptions=t.sourceOptions,je(y,p),t.inputUses.push(...y.inputUses);let h=[],v=[];for(let x=t.peekChild(p.indent);x!==void 0;x=t.peekChild(p.indent)){if(t.reader.takeSignificant(),Dr.test(x.content)){let E=Gp(t,x);E!==void 0&&v.push(E);continue}let S=Wp.exec(x.content);S!==null?h.push({kind:"PropertyMappingSyntax",property:S[1].replaceAll("@",""),source:Te(S[2],u(x),t.valueContext),location:u(x)}):t.error(d.InvalidPropertyMapping,`Invalid property mapping '${x.content}' - expected '<property> = <source>'`,u(x))}o.push({kind:"InvokesSyntax",command:f[1],mappings:h,onRefused:v,location:u(p)})}}else if(Dr.test(p.content))t.error(d.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",u(p)),t.skipBlock(p.indent);else if(m==="reads"||m==="file"||p.content==="csharp"||p.content.startsWith("```")){let f=oi(p);f!==void 0&&s.push(f),zp.test(p.content)&&t.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",u(p)),p.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(p.indent)}else{let f=t.triggerData.length;Rr(t,p);for(let y of t.triggerData.slice(f))a.push({kind:"TriggerDataSyntax",name:y.name,type:y.type,location:y.location})}}let l={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:u(e)};return Xe.set(l,{reads:s,data:a}),l}c(Qp,"parseTrigger");function Gp(t,e){let n=Vp.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]'.",u(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.",u(s)),o=!0),r=!0,t.skipBlock(s.indent);else if(D(s.content)==="produces"){r&&(t.error(d.InvalidRefusalBranchBody,"A refusal branch cannot combine 'acknowledge' and 'produces'.",u(s)),o=!0);let a=hn(t,s);a!==void 0?i.push(a):o=!0}else t.error(d.InvalidRefusalBranchBody,"Expected 'acknowledge' or 'produces <Event>' in a refusal branch.",u(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.",u(e)),{kind:"InvocationRefusalSyntax",selector:n[1]??"any",constraint:n[2]??null,acknowledge:r,produces:i,location:u(e)}}c(Gp,"parseRefusal");function _p(t){switch(t.kind){case"NamedTriggerSourceSyntax":return JSON.stringify([t.kind,t.name]);case"IntervalTriggerSourceSyntax":return JSON.stringify([t.kind,t.amount,t.unit]);case"ScheduleTriggerSourceSyntax":return JSON.stringify([t.kind,t.time,t.dayOfWeek,t.dayOfMonth])}}c(_p,"sourceKey");function Zp(t,e){let n=u(e);switch(D(e.content)){case"when":{let i=qp.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=Bp.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:Hp(i[2]),location:n}}default:return Kp(t,e)}}c(Zp,"parseTriggerSource");function Kp(t,e){let n=u(e),i=Yp.exec(e.content),r=i===null?void 0:Jp(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}}c(Kp,"parseSchedule");function Jp(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}c(Jp,"timeOf");function Hp(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}c(Hp,"unitOf");var Xp=w("^(data|query|component)\\s+(\\S+)(.*)$"),ef=w("^([A-Za-z_]\\w*)(?:\\.(.+))?$"),tf=w("^([A-Za-z_]\\w*)\\.(.+)$"),nf=w("^mode\\s+(oneWay|twoWay)\\b(.*)$"),rf=w("^null\\s+(propagate|clear|preserve)\\b(.*)$"),of=w("^expected\\s+(\\w+(?:\\.\\w+)*)(.*)$");function Vt(t,e,n){let i=e.trim(),r=i.split(/\s+/,1)[0];return r==="data"||r==="query"||r==="component"?Fa(t,`from ${i}`,n):Fa(t,i,n)}c(Vt,"parseFromClause");function Fa(t,e,n){let i=e.trim();if(!i.startsWith("from "))return Ua(t,Ct("DataContext",i,n),"",n);let r=i.substring(5).trim(),o=Xp.exec(r);if(o===null)return t.error(d.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from data <path>', 'from query <Query>[.<path>]' or 'from component <id>.<path>'`,n),{...Ct("Invalid",r,n),rawText:i};let s=af(t,o[1],o[2],i,n);return Ua(t,s,o[3],n)}c(Fa,"parseUiBinding");function af(t,e,n,i,r){return e==="data"?Ct("DataContext",n,r):e==="query"?sf(t,n,i,r):lf(t,n,i,r)}c(af,"parseBindingSource");function sf(t,e,n,i){let r=ef.exec(e);return r===null?(t.error(d.UnknownScreenDirective,`Invalid query binding '${n}' - expected 'from query <Query>[.<path>]'.`,i),{...Ct("Invalid",e,i),rawText:n}):{...Ct("QueryResult",r[2]??"",i),query:r[1]}}c(sf,"queryBinding");function lf(t,e,n,i){let r=tf.exec(e);return r===null?(t.error(d.UnknownScreenDirective,`Invalid component binding '${n}' - expected 'from component <stableInstanceId>.<outputPath>'.`,i),{...Ct("Invalid",e,i),rawText:n}):{...Ct("ComponentProperty",r[2],i),componentId:r[1],componentPropertyPath:r[2]}}c(lf,"componentBinding");function Ua(t,e,n,i){let r=e,o=n.trim();for(;o.length>0;){let s=nf.exec(o);if(s!==null){r={...r,mode:s[1]==="twoWay"?"TwoWay":"OneWay"},o=s[2].trim();continue}let a=rf.exec(o);if(a!==null){r={...r,nullBehavior:a[1]==="clear"?"Clear":a[1]==="preserve"?"Preserve":"Propagate"},o=a[2].trim();continue}let l=of.exec(o);if(l!==null){r={...r,expectedValueType:l[1]},o=l[2].trim();continue}return t.error(d.UnknownScreenDirective,`Unsupported UI binding modifier '${o}' - supported modifiers are 'mode oneWay|twoWay', 'null propagate|clear|preserve' and 'expected <Type>'.`,i),{...r,rawText:r.rawText??o}}return r}c(Ua,"withModifiers");function Ct(t,e,n){return{kind:"UiBindingSyntax",bindingKind:t,path:e,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,rawText:null,location:n}}c(Ct,"create");var ut=`(?:"(${H})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,cf=w("^screen\\s+([A-Za-z_]\\w*)$"),df=w("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),pf=w("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Wa=w(`^label\\s+${ut}$`),ff=w(`^action\\s+${ut}$`),uf=w("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),mf=w(`^route\\s+${ut}$`),Va=w("^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),yf=w("^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$"),hf=w("^property\\s+([\\w.]+)\\s+from\\s+(.+)$"),Sf=w(`^property\\s+([\\w.]+)\\s*=\\s+${ut}$`),gf=w("^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),xf=w(`^presentation\\s+([A-Za-z_]\\w*)\\s+${ut}$`),vf=w("^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),$f=w("^[a-z_]\\w*$"),bf=w(`^title\\s+${ut}$`),kf=w(`^column\\s+([\\w.]+)(?:\\s+label\\s+${ut})?$`),Cf=w("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),Ef=w(`^field\\s+([\\w.]+)\\s+label\\s+${ut}$`),nt=c((t,e)=>t[e]!==void 0?ee(t[e]):t[e+1],"operandText"),Pf=c(t=>["on","uses"].includes(D(t.content)),"isInteraction"),Af=c((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function za(t,e){let n=cf.exec(e.content);n===null&&t.error(d.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,u(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),fe(r)||Qa(t,r,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,location:u(e)}}c(za,"parseScreen");function Qa(t,e,n){let i=wf(t,e);i!==void 0&&n.push(i)}c(Qa,"pushDirective");function Mr(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),Qa(t,i,n);return n}c(Mr,"parseDirectives");function wf(t,e){switch(D(e.content)){case"data":return Of(t,e);case"action":return If(t,e);case"template":return Tf(t,e);case"section":return Rf(t,e);case"title":return Df(t,e);case"table":return Mf(t,e);case"summary":return jf(t,e);case"component":return Nf(t,e);case"toolbar":return Yf(t,e);case"navigate":return li(t,e.content,e);case"on":return je(t,e),{kind:"ScreenBehaviorSyntax",location:u(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:u(e)};default:if(Af(t,e))return Wf(t,e);t.error(d.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,u(e)),t.skipBlock(e.indent);return}}c(wf,"parseDirective");function Of(t,e){let n=df.exec(e.content);if(n===null){t.error(d.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,u(e));return}return{kind:"ScreenDataSyntax",type:Re(n[1],u(e)),query:n[2],by:n[3]??null,location:u(e)}}c(Of,"parseData");function If(t,e){let n=ff.exec(e.content);if(n!==null)return Qo(t,e,nt(n,1),li);let i=pf.exec(e.content);if(i===null){t.error(d.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,u(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=Wa.exec(s.content);a!==null?r=nt(a,1):D(s.content)==="navigate"?o=li(t,s.content,s)??null:t.error(d.UnknownActionDirective,`Unexpected '${s.content}' in action - expected 'label "..."' or 'navigate to ...'`,u(s))}return{kind:"ScreenActionSyntax",command:i[1],label:r,navigate:o,location:u(e)}}c(If,"parseAction");function li(t,e,n){let i=uf.exec(e);if(i===null){t.error(d.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,u(n));return}let r=[],o=null;for(let s=t.peekChild(n.indent);s!==void 0;s=t.peekChild(n.indent)){t.reader.takeSignificant();let a=Va.exec(s.content);if(a!==null){r.push({kind:"ScreenNavigationParameterSyntax",name:a[1],binding:Vt(t,a[2],u(s)),location:u(s)});continue}let l=mf.exec(s.content);if(l!==null){o=nt(l,1);continue}t.error(d.InvalidNavigation,`Unexpected '${s.content}' in navigation - expected 'route "..."' or 'parameter <name> from <binding>'`,u(s))}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,route:o,parameters:r,location:u(n)}}c(li,"parseNavigate");function Tf(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(),!$f.test(r.content)){t.error(d.InvalidScreenLayoutSlot,`Expected a slot name in template '${n}', got '${r.content}'`,u(r)),t.skipBlock(r.indent);continue}i.push({kind:"ScreenSlotSyntax",name:r.content,directives:Mr(t,r),location:u(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:u(e)}}c(Tf,"parseTemplateReference");function Rf(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:Mr(t,e),location:u(e)}}c(Rf,"parseSection");function Df(t,e){let n=bf.exec(e.content);return n===null?(t.error(d.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,u(e)),{kind:"ScreenTitleSyntax",text:"",location:u(e)}):{kind:"ScreenTitleSyntax",text:nt(n,1),location:u(e)}}c(Df,"parseTitle");function Mf(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=kf.exec(o.content),a=Cf.exec(o.content);if(s!==null){let l=s[2]!==void 0||s[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:s[1],label:l?nt(s,2):null,location:u(o)})}else a!==null?r=li(t,a[1],o)??null:D(o.content)==="on"?je(t,o):Pf(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>'`,u(o))}return{kind:"ScreenTableSyntax",target:n,columns:i,rowClick:r,location:u(e)}}c(Mf,"parseTable");function jf(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=Ef.exec(r.content);if(o===null){t.error(d.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,u(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:nt(o,2),location:u(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:u(e)}}c(jf,"parseSummary");function Nf(t,e){let n=yf.exec(e.content);if(n===null){t.error(d.UnknownScreenDirective,`Invalid component directive '${e.content}' - expected 'component <Package.Component> <name>'`,u(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=[],s=[],a=[],l=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(p.content)){case"context":i=Lf(t,p);break;case"property":qf(t,p,o);break;case"icon":r=p.content.substring(4).trim();break;case"presentation":Ga(t,p,a);break;case"exposes":Bf(t,p,s);break;case"outlet":l.push({kind:"ComponentOutletSyntax",name:p.content.substring(6).trim(),directives:Mr(t,p),location:u(p)});break;case"on":je(t,p);break;case"uses":t.skipOpaqueBlock(p.indent);break;default:t.error(d.UnknownScreenDirective,`Unexpected '${p.content}' in component - expected context, property, icon, presentation, exposes, outlet, on or uses`,u(p)),t.skipBlock(p.indent);break}return{kind:"ScreenComponentSyntax",component:n[1],name:n[2],context:i,properties:o,exposes:s,presentation:a,icon:r,outlets:l,location:u(e)}}c(Nf,"parseComponent");function Lf(t,e){return Uf(t,e.content.substring(7).trim(),e)}c(Lf,"parseUiContext");function qf(t,e,n){let i=hf.exec(e.content);if(i!==null){n.push({kind:"ComponentPropertySyntax",property:i[1],binding:Vt(t,i[2],u(e)),value:null,location:u(e)});return}let r=Sf.exec(e.content);if(r!==null){n.push({kind:"ComponentPropertySyntax",property:r[1],binding:null,value:nt(r,2),location:u(e)});return}t.error(d.UnknownScreenDirective,`Invalid component property '${e.content}' - expected 'property <path> from <binding>' or 'property <path> = "value"'`,u(e))}c(qf,"parseComponentProperty");function Bf(t,e,n){let i=gf.exec(e.content);if(i===null){t.error(d.UnknownScreenDirective,`Invalid exposed value '${e.content}' - expected 'exposes <name> from <binding>'`,u(e));return}n.push({kind:"ComponentExposedValueSyntax",name:i[1],binding:Vt(t,i[2],u(e)),location:u(e)})}c(Bf,"parseExposedValue");function Ga(t,e,n){let i=xf.exec(e.content);if(i===null){t.error(d.UnknownScreenDirective,`Invalid presentation value '${e.content}' - expected 'presentation <key> "value"'`,u(e));return}n.push({kind:"PresentationValueSyntax",name:i[1],value:nt(i,2),location:u(e)})}c(Ga,"parsePresentationValue");function Yf(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=Ff(t,r);o!==void 0&&i.push(o)}return{kind:"ScreenToolbarSyntax",name:n,items:i,location:u(e)}}c(Yf,"parseToolbar");function Ff(t,e){let n=vf.exec(e.content);if(n===null){t.error(d.UnknownScreenDirective,`Invalid toolbar item '${e.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>' or 'item <name> dialog <DialogTemplate>'`,u(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=[],s=[];for(let l=t.peekChild(e.indent);l!==void 0;l=t.peekChild(e.indent)){t.reader.takeSignificant();let p=Wa.exec(l.content);if(p!==null){i=nt(p,1);continue}let m=Va.exec(l.content);if(m!==null){o.push({kind:"ScreenNavigationParameterSyntax",name:m[1],binding:Vt(t,m[2],u(l)),location:u(l)});continue}if(D(l.content)==="icon"){r=l.content.substring(4).trim();continue}Ga(t,l,s)}let a=n[2]==="navigate"?"Navigate":n[2]==="dialog"?"Dialog":"Action";return{kind:"ToolbarItemSyntax",name:n[1],syntaxKind:a,target:n[3],label:i,icon:r,parameters:o,presentation:s,location:u(e)}}c(Ff,"parseToolbarItem");function Uf(t,e,n){return Vt(t,e,u(n))}c(Uf,"parseUiBindingValue");function Wf(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}'`,u(e));return}e.content.startsWith("```")||t.warning(d.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,u(e));let i=Lt(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:u(e)},location:u(e)}}c(Wf,"parseCode");var Vf=w("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),zf=new Set(["reducer"]);function _a(t,e){let n=Vf.exec(e.content),i="StateChange",r="";n===null?t.error(d.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,u(e)):(r=n[2],ya.includes(n[1])?i=n[1]:t.error(d.UnknownSliceType,`Unknown slice type '${n[1]}' - expected StateChange, StateView, Automation or Translate`,u(e)));let o=t.scope;t.scope=[...o,r];let s=null,a=null,l=[],p=[],m=[],f=[],y=[],h=[],v=[],x=[],S=[],E=[],g=[],P=[],A=[];for(let b=t.peekChild(e.indent);b!==void 0;b=t.peekChild(e.indent)){if(t.reader.takeSignificant(),fe(b))continue;let k=D(b.content);k==="description"?s=Z(t,b,s,`Slice '${r}'`):k==="documentation"?a=be(t,b,a,`Slice '${r}'`):k==="operation"?p.push(Xn(t,b).operation):k==="event"?l.push(xa(t,b)):k==="command"?m.push(Ta(t,b)):k==="query"?f.push(qa(t,b)):k==="projection"?y.push(Ir(t,b)):k==="capture"?v.push(Er(t,b)):k==="reaction"?h.push(Ya(t,b)):k==="constraint"?x.push(Ra(t,b)):k==="example"?E.push(tt(t,b)):k==="specification"?S.push(vr(t,b)):k==="readmodel"?g.push(va(t,b)):k==="screen"?P.push(za(t,b)):zf.has(k)?(A.push(Pa(t,b)),t.skipOpaqueBlock(b.indent)):(t.warning(d.UnknownSliceDirective,`Unknown construct '${k}' in slice '${r}'`,u(b)),t.skipBlock(b.indent))}t.scope=o;let $={kind:"SliceSyntax",type:i,name:r,description:s,documentation:a,examples:E,events:l,operations:p,commands:m,queries:f,projections:y,captures:v,reactions:h,constraints:x,specifications:S,readModels:g,screens:P,location:u(e)};return Xe.set($,{reducers:A}),$}c(_a,"parseSlice");var Qf=w("^feature\\s+([A-Za-z_]\\w*)$"),Gf=new Set(["on","uses","contribute"]),jr="description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'",Sn=class{static{c(this,"FeatureBody")}name;#e=[];#t=[];#o=[];#r=[];#n=[];#i=null;#a=null;#l=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#i=Z(e,n,this.#i,`Feature '${this.name}'`),!0;case"documentation":return this.#a=be(e,n,this.#a,`Feature '${this.name}'`),!0;case"depends":return _n(e,n,this.#n,d.UnknownFeatureDirective),!0;case"authorize":return this.#l=_e(this.#l,pt(e,n)),!0;case"import":return qt(e,n,this.#r),!0;case"feature":return this.#e.push(ci(e,n)),!0;case"example":return this.#o.push(tt(e,n)),!0;case"slice":return this.#t.push(_a(e,n)),!0;default:return Gf.has(i)?(je(e,n),!0):!1}}build(e,n=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#i,documentation:this.#a,authorize:this.#l,dependsOn:this.#n,features:this.#e,slices:this.#t,examples:this.#o,fileImports:this.#r,isPlacement:n,location:e}}};function ci(t,e){let n=Qf.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,u(e));let i=new Sn(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 '${D(o.content)}' in feature body - expected ${jr}`,u(o)),t.skipBlock(o.indent));return t.scope=r,i.build(u(e))}c(ci,"parseFeature");var Nr=w("^module\\s+([A-Za-z_]\\w*)$"),_f=new Set(["on","uses","screen","dialog","form","contribute"]),Lr="description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'",gn=class{static{c(this,"ModuleBody")}name;#e=[];#t=[];#o=[];#r=[];#n=null;#i=null;#a=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#n=Z(e,n,this.#n,`Module '${this.name}'`),!0;case"documentation":return this.#i=be(e,n,this.#i,`Module '${this.name}'`),!0;case"depends":return _n(e,n,this.#r,d.UnknownModuleDirective),!0;case"authorize":return this.#a=_e(this.#a,pt(e,n)),!0;case"import":return qt(e,n,this.#o),!0;case"example":return this.#t.push(tt(e,n)),!0;case"feature":return this.#e.push(ci(e,n)),!0;default:return _f.has(i)?(je(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 '${D(i.content)}' in module body - expected ${Lr}`,u(i)),e.skipBlock(i.indent))}build(e,n=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#n,documentation:this.#i,authorize:this.#a,dependsOn:this.#r,features:this.#e,examples:this.#t,fileImports:this.#o,isPlacement:n,location:e}}};function qr(t,e){let n=Nr.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,u(e));let i=new gn(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(u(e))}c(qr,"parseModule");var Jf=new WeakMap,Ve=c(t=>JSON.stringify(t),"authoredOrderKey");function xn(t){return Jf.get(t)??new Map}c(xn,"authoredOrderOf");var mt=["usesFactsFrom","reactsTo","decidesFrom","asks","shows","verifiedWith","outsideTheModel"];var rt=class extends Error{static{c(this,"InvalidDependencyQuery")}};var yt=class{static{c(this,"ScreenplaySyntaxWalker")}visitNode(e){}visitApplication(e){this.visitNode(e),e.domain!==null&&this.visitDomain(e.domain),e.imports.forEach(n=>this.visitImport(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.systems?.forEach(n=>this.visitSystem(n)),e.eventSources?.forEach(n=>this.visitEventSource(n)),e.concepts.forEach(n=>this.visitConcept(n)),e.types.forEach(n=>this.visitType(n)),e.personas.forEach(n=>this.visitPersona(n)),e.policies?.forEach(n=>this.visitPolicy(n)),e.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"ScreenNavigateSyntax":e.parameters.forEach(n=>{this.visitNode(n),this.visitNode(n.binding)});break;case"ScreenTemplateReferenceSyntax":e.slots.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenSectionSyntax":e.directives.forEach(n=>this.visitScreenDirective(n));break;case"ScreenTableSyntax":e.columns.forEach(n=>this.visitNode(n)),e.rowClick!==null&&this.visitScreenDirective(e.rowClick);break;case"ScreenSummarySyntax":e.fields.forEach(n=>this.visitNode(n));break;case"ScreenComponentSyntax":e.context!==null&&this.visitNode(e.context),e.properties.forEach(n=>{this.visitNode(n),n.binding!==null&&this.visitNode(n.binding)}),e.exposes.forEach(n=>{this.visitNode(n),this.visitNode(n.binding)}),e.presentation.forEach(n=>this.visitNode(n)),e.outlets.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenToolbarSyntax":e.items.forEach(n=>{this.visitNode(n),n.parameters.forEach(i=>{this.visitNode(i),this.visitNode(i.binding)}),n.presentation.forEach(i=>this.visitNode(i))});break;case"ScreenCodeSyntax":this.visitNode(e.code);break}}visitScreenGuardedAction(e){this.visitNode(e),e.alternatives.forEach(n=>this.visitScreenActionAlternative(n)),e.otherwise!==null&&this.visitScreenActionOtherwise(e.otherwise),e.navigate!==null&&this.visitScreenDirective(e.navigate)}visitScreenActionAlternative(e){this.visitNode(e),this.visitCondition(e.condition),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitScreenActionOtherwise(e){this.visitNode(e),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitInteractionArgument(e){this.visitNode(e)}visitSpecification(e){this.visitNode(e),e.examples?.forEach(n=>this.visitSpecificationExample(n)),e.parameters?.forEach(n=>{this.visitNode(n),this.visitTypeRef(n.type)}),e.cases?.forEach(n=>{this.visitNode(n),n.values.forEach(i=>this.visitPropertyMapping(i))}),e.givenClock!==null&&this.visitSpecificationClock(e.givenClock),e.givenOperationFailures?.forEach(n=>this.visitSpecificationOperationFailure(n)),e.thenOperations?.forEach(n=>this.visitSpecificationOperation(n)),e.thenCompensated?.forEach(n=>this.visitSpecificationCompensated(n)),e.givenCallerPersona!=null&&this.visitNode(e.givenCallerPersona),e.givenCaller!=null&&(this.visitNode(e.givenCaller),e.givenCaller.claims.forEach(n=>this.visitNode(n))),e.given.forEach(n=>this.visitSpecificationEvent(n)),e.givenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.when!==null&&this.visitSpecificationCommand(e.when),e.givenCaptures.forEach(n=>this.visitSpecificationCapture(n)),e.whenAppended!==null&&this.visitSpecificationEvent(e.whenAppended),e.whenRedelivered!=null&&this.visitSpecificationRedelivery(e.whenRedelivered),e.whenClock!==null&&this.visitSpecificationClock(e.whenClock),e.whenTrigger!==null&&this.visitSpecificationTrigger(e.whenTrigger),e.whenCapture!==null&&this.visitSpecificationCapture(e.whenCapture),e.whenQuery!==null&&this.visitSpecificationWhenQuery(e.whenQuery),e.thenEvents.forEach(n=>this.visitSpecificationEvent(n)),e.thenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.thenAbsentReadModels?.forEach(n=>{this.visitNode(n),this.visitExpression(n.key)}),e.thenQueries?.forEach(n=>{this.visitNode(n),n.arguments.forEach(i=>this.visitPropertyMapping(i)),n.results.forEach(i=>this.visitSpecificationQueryResult(i))}),e.thenResults.forEach(n=>this.visitSpecificationQueryResult(n)),e.thenNoResult!==null&&this.visitNode(e.thenNoResult),e.thenDenied!=null&&this.visitNode(e.thenDenied),e.thenReturns!=null&&this.visitSpecificationReturn(e.thenReturns),e.thenErrors.forEach(n=>{this.visitNode(n),n.caseValue!=null&&this.visitExpression(n.caseValue)})}visitSpecificationRedelivery(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationClock(e){this.visitNode(e)}visitSpecificationTrigger(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationCapture(e){this.visitNode(e),e.record.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationWhenQuery(e){this.visitNode(e),e.arguments.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationQueryResult(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationExample(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.generatedValues.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationEvent(e){this.visitNode(e),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationNoStream(e){this.visitNode(e)}visitSpecificationCommand(e){this.visitNode(e),(e.generatedValues??[]).forEach(n=>this.visitPropertyMapping(n)),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitPropertyMapping(e){this.visitNode(e),this.visitExpression(e.source)}visitProperty(e){this.visitNode(e),this.visitTypeRef(e.type)}visitTypeRef(e){this.visitNode(e)}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 Hf={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 pi(t){let e=new di;return e.visitSlice(t),{references:e.references.sort((n,i)=>n.location.line-i.location.line||n.location.column-i.location.column),shared:e.shared}}c(pi,"sliceReferences");function Ja(t,e){let n=new di(e);return t.projections.forEach(i=>n.visitProjection(i)),Ye(t).reducers?.filter(i=>i.readModel.toLowerCase()===e.toLowerCase()).forEach(i=>n.visitReducer(i)),n.references}c(Ja,"buildingReadModelReferences");function Fr(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...Fr(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?Fr(e.blocks):[])}c(Fr,"variants");var di=class extends yt{static{c(this,"SliceReferenceCollector")}readModel;references=[];shared=[];specification;projection=!1;constructor(e){super(),this.readModel=e}matches(e){return e.toLowerCase()===this.readModel?.toLowerCase()}visitSlice(e){super.visitSlice(e),Ye(e).reducers?.forEach(i=>this.visitReducer(i))}visitCommand(e){let n=Ye(e);n.reads?.forEach(i=>this.visitReads(i)),n.concurrency!=null&&this.visitConcurrency(n.concurrency),super.visitCommand(e)}visitReactionTrigger(e){let n=Ye(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=Fr(e.blocks);if(n.length===0?!this.matches(e.readModel??e.name):!n.some(i=>this.matches(i.name)))return}this.projection=!0,super.visitProjection(e),this.projection=!1}visitSpecification(e){this.specification=e,super.visitSpecification(e),this.specification=void 0}visitNode(e){let n=c((i,r,o)=>{this.references.push({name:i,targetKind:r,role:o,kind:Hf[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 vn(t){let e=new Map,n=new Map,i=[],r=new Set,o=[],s=c(a=>{e.set(a,e.size),n.set(a,e.get(a)),i.push(a),r.add(a);for(let m of[...t.get(a)].sort())e.has(m)?r.has(m)&&n.set(a,Math.min(n.get(a),e.get(m))):(s(m),n.set(a,Math.min(n.get(a),n.get(m))));if(n.get(a)!==e.get(a))return;let l=[],p;do p=i.pop(),r.delete(p),l.push(p);while(p!==a);o.push(l.sort())},"visit");for(let a of[...t.keys()].sort())e.has(a)||s(a);return o}c(vn,"stronglyConnectedGroups");var Ha=["usesFactsFrom","reactsTo","decidesFrom"],Ze=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),Ur=c((t,e)=>JSON.stringify([t,e.toLowerCase()]),"declarationKey"),Wr=c((t,e,n,i)=>({kind:t,address:e,scope:n,rank:i,key:`${t}:${e}`}),"nodeOf"),zr=c((t,e)=>t.rank-e.rank||Ze(t.key,e.key),"compareNodes"),$n=c(t=>[...new Map([...t].map(e=>[e.key,e])).values()].sort(zr),"distinctNodes"),Xa=c((t,e)=>t.consumer.rank-e.consumer.rank||t.location.line-e.location.line||t.location.column-e.location.column||mt.indexOf(t.kind)-mt.indexOf(e.kind)||t.producer.rank-e.producer.rank||Ze(t.location.path??"",e.location.path??"")||Ze(t.role,e.role)||Ze(t.name,e.name),"compareEvidence");function Qr(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...Qr(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?Qr(e.blocks):[])}c(Qr,"variants");var zt=class t{static{c(this,"DependencyGraph")}orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=new Map;byKey=new Map;parents=new Map;root=Wr("application","",[],-1);static for(e,n=xn(e)){return new t(e,n)}get nodes(){return this.modelNodes}constructor(e,n){e=Fe(e),this.orderSource=n.size>0?"authored":"syntax",this.children.set(this.root.key,[]);let i=c((g,P)=>g.map((A,$)=>({syntax:A,index:$,rank:n.get(Ve([...P.scope,A.name]))??Number.MAX_SAFE_INTEGER})).sort((A,$)=>A.rank-$.rank||A.index-$.index).map(A=>A.syntax),"ordered"),r=c((g,P)=>{let A=this.add("feature",g.name,P);for(let $ of i(g.slices,A))this.slices.push({node:this.add("slice",$.name,A),syntax:$});for(let $ of i(g.features,A))r($,A)},"feature");for(let g of i(e.modules,this.root)){let P=this.add("module",g.name,this.root);for(let A of i(g.features,P))r(A,P)}let o=new Map,s=new Map,a=c((g,P,A,$)=>{let b=Ur(P,A);g.has(b)||g.set(b,[]);let k=g.get(b);k.includes($)||k.push($);let C=Ur(P,[...$.scope,A].join("."));g.has(C)||g.set(C,[]);let O=g.get(C);O.includes($)||O.push($)},"declare");for(let{node:g,syntax:P}of this.slices){for(let A of ae(P))a(o,"Event",A.name,g);for(let A of P.commands)a(o,"Command",A.name,g);for(let A of P.reactions)a(o,"Reaction",A.name,g);for(let A of P.queries)a(o,"Query",A.name,g);for(let A of P.screens)a(o,"Screen",A.name,g);for(let A of P.readModels)a(o,"ReadModel",A.name,g);for(let A of P.projections){let $=Qr(A.blocks);$.length===0&&a(s,"ReadModel",A.readModel??A.name,g);for(let b of $)a(s,"ReadModel",b.name,g)}for(let A of Ye(P).reducers??[])a(s,"ReadModel",A.readModel,g)}let l=new Set((e.declaredTriggers??[]).map(g=>g.name.toLowerCase())),p=new Set([...e.concepts,...e.types].map(g=>g.name.toLowerCase())),m=new Set((e.policies??[]).map(g=>g.name.toLowerCase())),f=e.imports.filter(g=>g.qualifiedName.includes(".")).slice().sort((g,P)=>Ze(g.location.path??"",P.location.path??"")||g.location.line-P.location.line||g.location.column-P.location.column||Ze(g.qualifiedName,P.qualifiedName)),y=new Map,h=[],v=[],x=new Set,S=0;for(let{node:g,syntax:P}of this.slices){let A=pi(P);S+=A.shared.filter($=>($.kind==="type"?p:m).has($.name.toLowerCase())).length;for(let $ of A.references){let b=Ur($.targetKind,$.name),C=($.targetKind==="ReadModel"&&s.has(b)?s:o).get(b);if(C!==void 0&&C.length>0){let I=C[0];I!==g&&h.push({consumer:g,producer:I,kind:$.kind,role:$.role,name:$.name,ambiguous:C.length>1,alternatives:C.slice(1),location:$.location,testOnly:$.kind==="verifiedWith"});continue}let O=$.targetKind==="Event"?f.filter(I=>I.qualifiedName.slice(I.qualifiedName.lastIndexOf(".")+1).toLowerCase()===$.name.toLowerCase()):[];if(O.length>0){let I=[];for(let R of O){x.add(R.qualifiedName);let j=R.qualifiedName.slice(0,R.qualifiedName.lastIndexOf(".")),N=`context:${j}`;if(!y.has(N)){let L=Wr("context",N,[j],this.modelNodes.length);this.modelNodes.push(L),y.set(N,L)}let B=y.get(N);I.includes(B)||I.push(B)}h.push({consumer:g,producer:I[0],kind:"outsideTheModel",role:$.role,name:$.name,ambiguous:I.length>1,alternatives:I.slice(1),location:$.location,testOnly:$.kind==="verifiedWith"});continue}if($.role==="trigger"&&l.has($.name.toLowerCase())){S++;continue}v.push({consumer:g,kind:$.kind,role:$.role,name:$.name,location:$.location})}}let E=new Map;for(let g of h.sort(Xa)){let P=JSON.stringify([g.consumer.key,g.producer.key,g.kind]);E.has(P)||E.set(P,[]),E.get(P).push(g)}this.edges=[...E.values()].map(g=>({consumer:g[0].consumer,producer:g[0].producer,kind:g[0].kind,evidence:g})),this.unresolved=v.sort((g,P)=>g.consumer.rank-P.consumer.rank||g.location.line-P.location.line||g.location.column-P.location.column||mt.indexOf(g.kind)-mt.indexOf(P.kind)||Ze(g.location.path??"",P.location.path??"")||Ze(g.name,P.name)),this.excludedReferences=S,this.unusedImports=[...new Set(f.filter(g=>!x.has(g.qualifiedName)).map(g=>g.qualifiedName))]}implied(e,n,i,r=!1,o=3){if(!["slice","feature","module"].includes(e))throw new rt(`Unsupported source level '${e}'.`);if(!["slice","feature","module","context"].includes(n))throw new rt(`Unsupported target level '${n}'.`);if(o<0)throw new rt("Evidence limit must not be negative.");let s=new Map;for(let a of this.evidence(i,r))for(let l of this.at(a.consumer,e))for(let p of this.at(a.producer,n).filter(m=>this.disjoint(l,m))){let m=JSON.stringify([l.key,p.key]);s.has(m)||s.set(m,{source:l,target:p,evidence:[]}),s.get(m).evidence.push(a)}return[...s.values()].sort((a,l)=>a.source.rank-l.source.rank||a.target.rank-l.target.rank||Ze(a.source.key,l.source.key)||Ze(a.target.key,l.target.key)).map(a=>{let l=a.evidence.sort(Xa),p={};for(let m of mt){let f=l.filter(y=>y.kind===m).length;f>0&&(p[m]=f)}return{source:a.source,target:a.target,sliceEdges:new Set(l.map(m=>JSON.stringify([m.consumer.key,m.producer.key]))).size,references:l.length,byKind:p,consumers:$n(l.map(m=>m.consumer)),producers:$n(l.map(m=>m.producer)),evidence:l.slice(0,o),evidenceCount:l.length,evidenceTruncated:l.length>o}})}cycles(e,n){if(!["slice","feature","module"].includes(e))throw new rt(`Unsupported cycle level '${e}'.`);let i=this.implied(e,e,es(n)),r=$n(i.flatMap(o=>[o.source,o.target]));return ts(Vr(r,i),r,null)}siblingGroups(e){let n=this.siblingEdges(e);return this.containers().flatMap(i=>{let r=this.children.get(i.key);return ts(Vr(r,n.filter(o=>o.container===i)),r,i)})}suggestedOrder(e){let n=this.siblingEdges(e),i=[];for(let a of this.containers()){let l=this.children.get(a.key),p=n.filter(S=>S.container===a),m=new Map(l.map(S=>[S.key,S])),f=vn(Vr(l,p)).map(S=>S.map(E=>m.get(E)).sort(zr)).sort((S,E)=>S[0].rank-E[0].rank),y=new Map(f.flatMap((S,E)=>S.map(g=>[g.key,E]))),h=new Map(l.map(S=>[S.key,new Set]));for(let S of p)y.get(S.source.key)!==y.get(S.target.key)&&h.get(S.source.key).add(S.target.key);for(let S of f)for(let E=1;E<S.length;E++)h.get(S[E].key).add(S[E-1].key);let v=new Set(l.map(S=>S.key)),x=[];for(;v.size>0;){let S=[...v].filter(E=>h.get(E).size===0).sort((E,g)=>zr(m.get(E),m.get(g)))[0];x.push(m.get(S)),v.delete(S);for(let E of v)h.get(E).delete(S)}i.push({container:a,children:x,changed:l.some((S,E)=>S!==x[E])})}let r=new Map(i.map(a=>[a.container.key,a.children])),o=[],s=c(a=>{if(a.kind==="slice")o.push(a);else for(let l of[...r.get(a.key)].sort((p,m)=>+(p.kind!=="slice")-+(m.kind!=="slice")))s(l)},"walk");return s(this.root),{containers:i,slices:o}}traverse(e,n,i,r=!1){if(n!=="incoming"&&n!=="outgoing")throw new rt(`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],l=[];for(let p=0;p<a.length;p++)for(let m of o.filter(f=>f.source.address===a[p]).sort((f,y)=>f.target.rank-y.target.rank))s.has(m.target.address)||(s.add(m.target.address),l.push(m.target),a.push(m.target.address));return $n(l)}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 l=Wr(e,o,r,this.modelNodes.length);return this.modelNodes.push(l),this.byKey.set(s,l),this.parents.set(s,i),this.children.get(i.key).push(l),e!=="slice"&&this.children.set(s,[]),l}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=ns(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(es(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 ns(t){let e=new Set(t??mt);if([...e].some(n=>!mt.includes(n)))throw new rt("Unsupported dependency kind.");return e}c(ns,"selectedKinds");function es(t){return[...ns(t??Ha)].filter(e=>Ha.includes(e))}c(es,"selectedOrderingKinds");function Vr(t,e){let n=new Map(t.map(i=>[i.key,new Set]));for(let i of e)n.get(i.source.key).add(i.target.key);return n}c(Vr,"adjacency");function ts(t,e,n){let i=new Map(e.map(r=>[r.key,r]));return vn(t).filter(r=>r.length>1).map(r=>({container:n,members:$n(r.map(o=>i.get(o)))})).sort((r,o)=>r.members[0].rank-o.members[0].rank)}c(ts,"groupsOf");var Xf=["usesFactsFrom","reactsTo","decidesFrom","asks","shows"],Ke=c((t,e)=>e===t||e.startsWith(t+"."),"contains"),Qt=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),eu=c((t,e)=>Qt(t.location.path??"",e.location.path??"")||t.location.line-e.location.line||t.location.column-e.location.column||Qt(t.kind,e.kind)||Qt(t.consumer.address,e.consumer.address)||Qt(t.producer.address,e.producer.address)||Qt(t.role,e.role)||Qt(t.name,e.name),"orderedEvidence"),Gt=class{static{c(this,"DeclaredDependencies")}static for(e){let n=new Map,i=c((f,y)=>{let h=f.join(".");n.has(h)||n.set(h,{location:y.location,dependencies:[]}),n.get(h).dependencies.push(...y.dependsOn??[]),y.features.forEach(v=>i([...f,v.name],v))},"inventory");if(e.modules.forEach(f=>i([f.name],f)),![...n.values()].some(f=>f.dependencies.length))return{containers:[],diagnostics:[]};let r=zt.for(e,new Map),o=r.nodes.filter(f=>f.kind==="module"||f.kind==="feature"),s=Ae.containersOf(e),a=c((f,y)=>{let h=Ae.resolve(f,y,s).resolved;return h&&[...h.scope,h.name].join(".")},"resolve"),l=[],p=[],m=c((f,y,h,v)=>p.push({code:f,severity:y,message:h,location:v}),"finding");for(let f of o.filter(y=>n.get(y.address).dependencies.length)){let y=n.get(f.address),h=y.dependencies.map(S=>{let E=a(S.target,f.scope),g=E!==void 0&&!Ke(f.address,E)&&!Ke(E,f.address);return{syntax:S,resolved:E,status:g?"unused":"invalid"}}),v=[],x=new Map;for(let S of r.edges.flatMap(E=>E.evidence).filter(E=>Xf.includes(E.kind)&&Ke(f.address,E.consumer.address)).sort(eu)){let E=[S.producer,...S.alternatives].filter(A=>!Ke(f.address,A.address)&&!Ke(A.scope.slice(0,-1).join("."),f.address));if(!E.length)continue;let g=h.filter(A=>A.status!=="invalid"&&E.some($=>Ke(A.resolved,$.address)));for(let A of g)A.status=S.ambiguous&&A.status!=="used"?"provisional":"used";let P=S.ambiguous?"provisional":g.length?"declared":"undeclared";if(v.push({evidence:S,status:P,coveringDeclarations:g.map(A=>A.syntax)}),P==="undeclared"){let A=S.producer.scope[0];x.has(A)||x.set(A,[]),x.get(A).push(S)}}for(let S of x.values()){let E=S[0].producer.scope.slice(0,-1),g=E.findIndex((b,k)=>S.some(C=>k>=C.producer.scope.length-1||C.producer.scope[k]!==b));g>=0&&(E=E.slice(0,g));let P=E.join("."),A=Ke(f.address,P)||Ke(P,f.address)?[...new Set(S.map(b=>b.producer.scope.slice(0,-1).map((k,C)=>b.producer.scope.slice(0,C+1).join(".")).find(k=>!Ke(f.address,k)&&!Ke(k,f.address))))]:[P],$=S.map(b=>`${b.kind} ${b.role} '${b.name}' at ${b.location.path??""}:${b.location.line}:${b.location.column}`).join("; ");m(d.UndeclaredDependency,"warning",`Container '${f.address}' depends on '${A.join("', '")}' without declaring ${A.length===1?"it":"them"} - evidence: ${$}`,y.location)}for(let S of h)S.status==="unused"&&m(d.UnusedDependencyDeclaration,"information",`Dependency '${S.syntax.target}' on '${f.address}' is not used by any counted explicit reference`,S.syntax.location),S.status!=="invalid"&&n.get(S.resolved).dependencies.some(E=>a(E.target,S.resolved.split("."))===f.address)&&m(d.MutualDependencyDeclarations,"information",`Containers '${f.address}' and '${S.resolved}' declare each other`,S.syntax.location);l.push({container:f,location:y.location,declarations:h,edges:v})}return{containers:l,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)}};function fi(t,e,n,i=!1){let r=[],o=[],s=Me,a=!1,l=!1,p=!1,m=new Map,f=new me(new We([]),e,n).languages;for(let h of t){let v=h;if(v.number===1&&v.raw.startsWith("\uFEFF")){let x=v.raw.substring(1),S=x.length-x.trimStart().length,E=tn(x.substring(S),i);v={...v,indent:S,contentOffset:1,content:(E<0?x.substring(S):x.substring(S,S+E)).trimEnd()}}if(p){yr(v)&&(p=!1),r.push(v);continue}if(v.content.startsWith("```")&&(["```","```text","```markdown"].includes(v.content)||f.has(v.content.substring(3)))&&(p=!0),!p&&v.indent===0&&D(v.content)==="numbers"){let x=v.content!=="numbers exact"?d.InvalidNumericDirective:a?d.DuplicateNumericDirective:l?d.LateNumericDirective:void 0;x!==void 0?(o.push({severity:"error",code:x,message:"Expected one 'numbers exact' preamble before domain, imports and declarations.",location:u(v)}),s=Object.freeze({numericMode:"invalid"})):s=Zn,a=!0,r.push({...v,content:""});continue}!p&&v.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(v.content)&&m.set(v.number,{severity:"error",code:d.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:u(v)}),l||=v.content.trim().length>0,r.push(v)}let y=new me(new We(a?r:t),e,n);return y.sourceOptions=s,y.nestedNumericDirectives=m,o.forEach(h=>y.error(h.code,h.message,h.location)),y}c(fi,"sourceContext");function ui(t,e){let n=[],i=c(a=>{n.push(...a.slices),a.features.forEach(i)},"inFeature");t.modules.forEach(a=>a.features.forEach(i));let r=new Map;for(let a of n.flatMap(ae))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:l}of n.flatMap(p=>p.commands.map(m=>({slice:p,command:m})))){let p=l.produces.filter(y=>s.isEventProduction(y,a)),m=l.properties.find(y=>y.isIdentifier)?.name,f=Xi(l,{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),f&&y.for===null&&e.error(d.ExplicitProducesTargetsRequired,`Production '${y.event}' in command '${l.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,y.location);let v=y.for?.kind==="PathExpressionSyntax"?y.for.path:y.for===null&&h!==null?m:void 0;if(!(m===void 0||v!==m))for(let x of y.mappings.filter(S=>S.source.kind==="PathExpressionSyntax"&&S.source.path===m)){let S=`Event '${y.event}' copies command identifier '${m}' into payload property '${x.property}' although it already identifies the event source`;h===null?e.information(d.EventSourceIdInPayload,S,x.location):e.warning(d.EventSourceIdInPayload,S,x.location)}}}}c(ui,"validateInlineEvents");function mi(t,e){let n=new re(t),i=Ln(t),r=te(t.concepts),o=new Map([...te(t.types)].map(([g,P])=>[g,te(P.properties)])),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),a=new Set(t.imports.map(g=>g.qualifiedName.split(".").at(-1))),l=new Map;for(let g of t.imports){let P=g.qualifiedName.split(".").at(-1);l.set(P,[...l.get(P)??[],g.qualifiedName])}let p=c(g=>{let P=new Map,A=new Map;for(let $ of g){let b=P.get($.name)??[];b.push($),P.set($.name,b)}return($,b)=>{let k=JSON.stringify([$,b]);if(A.has(k))return A.get(k);let C=c(j=>{let N=j.split("."),B=P.get(N.at(-1))??[],L=N.slice(0,-1);if(L.length>0)return B.filter(W=>L.length<=W.scope.length&&L.every((V,G)=>W.scope[W.scope.length-L.length+G]===V));for(let W=b.length;W>=0;W--){let V=B.filter(G=>W<=G.scope.length&&b.slice(0,W).every((z,_)=>G.scope[_]===z));if(V.length>0)return V}return[]},"candidates"),O=C($),I=l.get($)??[];O.length===0&&I.length===1&&(O=C(I[0]));let R=O.length===1?O[0].node:null;return A.set(k,R),R}},"scoped"),m=p(n.slices.flatMap(({slice:g,scope:P})=>g.readModels.map(A=>({name:A.name,scope:P,node:A})))),f=p(n.slices.flatMap(({slice:g,scope:P})=>g.commands.map(A=>({name:A.name,scope:P,node:{command:A,slice:g}})))),y=new Map;for(let g of t.systems??[])y.has(g.name)&&e.error(d.InvalidSystemDeclaration,`System '${g.name}' is declared more than once.`,g.location),y.set(g.name,(y.get(g.name)??0)+1);let h=c((g,P,A=!0)=>{let[$,...b]=P.split("."),k=g.filter(R=>R.name===$);if(k.length!==1)return{type:null,missing:k.length===0};let C=k[0].type;if(b.length===0)return{type:C,missing:!1};let O=o.get(C.name);if(O===void 0)return{type:null,missing:s.has(C.name)};let I=h([...O.values()],b.join("."),A);return I.type===null?I:{type:{...I.type,isOptional:A&&C.isOptional||I.type.isOptional,isCollection:C.isCollection||I.type.isCollection},missing:!1}},"pathType"),v=c((g,P,A,$,b=new Set)=>{if(A.has(P)||g.isOptional&&!$.has(P))return!0;if(g.isCollection||b.has(g.name))return!1;let k=o.get(g.name);return k===void 0?$.has(P)&&!s.has(g.name):[...k.values()].every(C=>v(C.type,`${P}.${C.name}`,A,$,new Set([...b,g.name])))},"covered"),x=c((g,P)=>{if(g.kind==="ListExpressionSyntax"&&P.isCollection)return g.items.every($=>x($,{...P,isCollection:!1,isOptional:!1}));let A=o.get(P.name);return g.kind!=="ObjectExpressionSyntax"||A===void 0?!0:[...A.values()].every($=>($.type.isOptional||g.members.some(b=>b.name===$.name))&&g.members.filter(b=>b.name===$.name).every(b=>x(b.value,$.type)))},"completeValue"),S=c(g=>g.kind==="LiteralExpressionSyntax"?typeof g.value!="number"||Number.isFinite(g.value):g.kind==="ObjectExpressionSyntax"?g.members.every(P=>S(P.value)):g.kind==="ListExpressionSyntax"&&g.items.every(S),"concrete"),E=c((g,P,A,$,b)=>{let k=new Set,C=new Set(g.map(I=>I.property)),O=new Set;for(let I of g){let R=I.property.split(".");for(let j=1;j<=R.length;j++)O.add(R.slice(0,j).join("."))}for(let I of g){k.has(I.property)&&e.error(d.InvalidOperationMapping,`Duplicate operation input mapping '${I.property}'.`,I.location),k.add(I.property);let R=h(P.inputs,I.property,!1);if(R.missing&&e.error(d.InvalidOperationMapping,`Operation '${P.name}' declares no input '${I.property}'.`,I.location),R.type===null)continue;let j=I.property.split(".");for(let N=1;N<j.length;N++)C.has(j.slice(0,N).join("."))&&e.error(d.InvalidOperationMapping,`Operation input mapping '${I.property}' overlaps a whole input mapping.`,I.location);if(A!==null&&I.source.kind==="PathExpressionSyntax"){let N=h(A.properties,I.source.path),B=I.source.path.split("."),L=(ri.get(A)??[]).filter(G=>(G.alias??G.readModel)===B[0]);if(N.missing&&L.length>0){N={type:null,missing:!1};let G=L.length===1?m(L[0].readModel,b):null;B.length>1&&G!==null&&(N=h(G.properties,B.slice(1).join(".")))}N.missing&&e.error(d.InvalidOperationMapping,`Command '${A.name}' declares no source '${I.source.path}'.`,I.source.location);let W=N.type,V=R.type;W!==null&&s.has(W.name)&&s.has(V.name)&&(W.name!==V.name||W.isCollection!==V.isCollection||W.isOptional&&!V.isOptional)&&e.error(d.InvalidOperationMapping,`Source '${I.source.path}' is incompatible with input '${I.property}' of operation '${P.name}'.`,I.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(I.source.kind)&&(!ve(I.source,R.type,r,o)||$&&!x(I.source,R.type))&&e.error(d.InvalidOperationMapping,`Value is incompatible with input '${I.property}' of operation '${P.name}'.`,I.source.location)}if($)for(let I of P.inputs)v(I.type,I.name,k,O)||e.error(d.InvalidOperationMapping,`Production of operation '${P.name}' supplies no value for required input '${I.name}'.`,P.location)},"validateMappings");for(let{slice:g,scope:P}of n.slices){let A=Rn(g),$=new Set(ae(g).map(b=>b.name));for(let b of A){$.has(b.name)&&e.error(d.ProductionDeclarationCollision,`Operation '${b.name}' collides with another event or operation in slice '${g.name}'.`,b.location),$.add(b.name),b.uses.length>0&&y.get(b.uses)!==1&&e.error(d.InvalidSystemReference,`Operation '${b.name}' must use one declared system; '${b.uses}' does not resolve uniquely.`,b.usesLocation??b.location);for(let k of b.inputs)!s.has(k.type.name)&&!a.has(k.type.name)&&e.warning(d.UnknownType,`Unknown type '${k.type.name}' on input '${k.name}' of operation '${b.name}'.`,k.type.location)}for(let b of g.commands)for(let k of b.produces){let C=n.resolve(k.event,g);C.kind===ie.Ambiguous&&C.candidates.some(O=>O.kind===ie.Operation)&&e.error(d.InvalidProductionReference,`Production '${k.event}' is ambiguous.`,k.location),k.event.includes(".")&&C.kind!==ie.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",k.location),C.declaration?.node.kind==="OperationSyntax"&&((k.for!==null||k.tags.length>0)&&e.error(d.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",k.location),E(k.mappings,C.declaration.node,b,!0,P))}for(let b of g.reactions.flatMap(k=>k.triggers).flatMap(k=>k.produces)){let k=n.resolve(b.event,g);k.kind===ie.Ambiguous&&k.candidates.some(C=>C.kind===ie.Operation)&&e.error(d.InvalidProductionReference,`Production '${b.event}' is ambiguous.`,b.location),b.event.includes(".")&&n.resolve(b.event,g).kind!==ie.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",b.location),n.isOperation(b,g)&&e.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",b.location)}for(let b of g.specifications){let k=[...b.givenOperationFailures??[],...b.thenOperations??[],...b.thenCompensated??[]];if(k.length===0)continue;let C=f(i(b.when,P)?.commandType??"",P);(C===null||b.whenAppended!==null||b.whenQuery!==null||b.whenTrigger!==null||b.whenClock!==null||b.whenCapture!==null)&&e.error(d.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",b.location);let O=new Map;for(let I of k){if(I.kind==="SpecificationOperationSyntax")for(let N of I.values)S(N.source)||e.error(d.InvalidOperationSpecification,"Operation assertions require concrete input values.",N.source.location);let R=n.resolve(I.operation,g).declaration?.node;if(R?.kind!=="OperationSyntax"){e.error(d.InvalidOperationSpecification,`'${I.operation}' does not resolve uniquely to a declared operation.`,I.location);continue}let j=O.get(R)??new Set;if(j.has(I.kind)&&e.error(d.InvalidOperationSpecification,`Duplicate operation step '${I.operation}'.`,I.location),j.add(I.kind),O.set(R,j),I.kind==="SpecificationCompensatedSyntax"&&R.compensate===null&&e.error(d.InvalidOperationSpecification,`Operation '${I.operation}' declares no compensation.`,I.location),C!==null&&C.command.handler==null){let N=C.command.produces.map(B=>n.resolve(B.event,C.slice));N.every(B=>B.kind===ie.Event||B.kind===ie.Operation)&&!N.some(B=>B.declaration?.node===R)&&e.error(d.InvalidOperationSpecification,`Command '${C.command.name}' does not produce operation '${I.operation}'.`,I.location)}I.kind==="SpecificationOperationSyntax"&&E(I.values,R,null,!1,P)}}}}c(mi,"validateOperations");var is=["racialOrEthnicOrigin","politicalOpinions","religiousOrPhilosophicalBeliefs","tradeUnionMembership","genetic","biometric","health","sexLifeOrSexualOrientation"],tu=w("^(@?[a-z_]\\w*)\\s+(reason|scope|special|criminal)(?:\\s+(.*))?$"),nu=w(`^"(${H})"$`);function Gr(t){let e=t.replace(/^@/,"");return e==="personal"?"pii":e==="secret"?"sensitive":e}c(Gr,"complianceWireName");function iu(t){let e=Gr(t);return e==="sensitive"?"secret":e}c(iu,"canonicalComplianceName");function rs(t,e,n){let i=n.trim().split(/\s+/).filter(r=>r.length>0);return as(t,e,i),i.map(r=>{let o=Gr(r);return(!["pii","sensitive"].includes(o)||r==="@personal"||r==="@secret")&&t.error(d.UnknownComplianceMarker,`Unknown concept marker '${r}' - expected pii, personal or secret`,u(e)),{kind:"ConceptAttributeSyntax",name:o,reason:null,scope:null,specialCategory:null,criminal:!1,location:u(e)}})}c(rs,"parseComplianceMarkers");function os(t,e,n,i){let r=tu.exec(e.content);if(r===null)return!1;let[,o,s]=r,a=r[3]??"",l=Gr(o),p=iu(o);if(as(t,e,[o]),!["pii","sensitive"].includes(l)||o==="@personal"||o==="@secret")return t.error(d.UnknownComplianceMarker,`Unknown concept marker '${o}' - expected pii, personal or secret`,u(e)),!0;let m=i.findIndex(y=>y.name===l);if(m<0)return t.error(d.AttributeReasonWithoutAttribute,`Concept '${n}' declares '${p} ${s}' without the marker - write 'concept ${n} : <Type> ${p}'`,u(e)),!0;let f=i[m];switch(s){case"reason":{let y=nu.exec(a);return y===null?(t.error(d.UnknownConceptDirective,`Invalid '${p} reason' - expected '${p} reason "<text>"'`,u(e)),!0):f.reason!==null?(t.error(d.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${p}' - at most one is allowed`,u(e)),!0):(i[m]={...f,reason:ee(y[1])},!0)}case"scope":return l!=="sensitive"||!["subject","namespace","global"].includes(a)?(t.error(d.InvalidSecretScope,`Invalid '${p} scope ${a}' - scope belongs to secret and must be subject, namespace or global`,u(e)),!0):f.scope!=null?(t.error(d.DuplicateSecretScope,`Concept '${n}' already declares secret scope - at most one is allowed`,u(e)),!0):(i[m]={...f,scope:a},i.some(y=>y.name==="pii")&&t.warning(d.SecretScopeIgnoredForPii,`Concept '${n}' is pii secret - secret scope is ignored because only Chronicle [PII] renders`,u(e)),!0);case"special":case"criminal":return l!=="pii"||(s==="special"?!is.includes(a):a.length>0)?(t.error(d.InvalidPersonalDataQualifier,`Invalid '${p} ${s}${a.length>0?` ${a}`:""}' - expected 'pii criminal' or 'pii special <category>' with category ${is.join(", ")}`,u(e)),!0):s==="special"&&f.specialCategory!=null?(t.error(d.DuplicateSpecialCategory,`Concept '${n}' already declares pii special - at most one is allowed`,u(e)),!0):(i[m]=s==="special"?{...f,specialCategory:a}:{...f,criminal:!0},!0);default:return!1}}c(os,"parseComplianceDirective");function as(t,e,n){n.some(i=>["@pii","sensitive","@sensitive"].includes(i))&&t.information(d.LegacyComplianceMarker,"Legacy compliance spelling - use bare pii for personal data and secret for operational secrets; reason text is preserved",u(e))}c(as,"reportLegacy");var ru=Q("^policy\\s+([A-Za-z_]\\w*)$");function ss(t,e){let n=t;t=t.valueContext;let i=ru.exec(e.content)?.[1]??"";i===""&&t.error(d.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,u(e));let r=null,o=null,s=null,a=!1;for(let l=t.peekChild(e.indent);l!==void 0;l=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(l.content)==="require"){let p=l.content.substring(7).trim();for(let y=t.peekChild(l.indent);y!==void 0;y=t.peekChild(l.indent))t.reader.takeSignificant(),p+=` ${y.content}`;let m=ou(t,p);m.includes("not")&&(t=n);let f=au(t,m,u(l));a?t.error(d.RepeatedPolicyRequirement,`Policy '${i}' has more than one require line; combine the conditions with and/or in one require`,u(l)):r=f,a=!0}else if(D(l.content)==="file"){let p=ft(t,l);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`,u(l))}else if(l.content.startsWith("```")||t.languages.has(l.content)){let p=Ne(t,l);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`,u(l))}else t.error(d.UnknownPolicyDirective,`Unexpected '${l.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,u(l)),t.skipOpaqueBlock(l.indent);return r!==null&&(o!==null||s!==null)&&t.error(d.MixedPolicyImplementation,`Policy '${i}' cannot combine 'require' with a file or inline code block`,u(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`,u(e)),{kind:"PolicySyntax",name:i,condition:r,code:o,file:s,location:u(e)}}c(ss,"parsePolicy");function ou(t,e){let n=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]":"[\\w.$]+";return[...e.match(new RegExp(Q(`"${H}"|\\(|\\)|${n}`).source,"gu"))??[]]}c(ou,"tokenizePolicyCondition");function au(t,e,n){let i=t.sourceOptions.numericMode==="exact"||e.includes("not"),r=0,o=c(f=>f!==void 0&&f.startsWith('"')&&f.endsWith('"'),"quoted"),s=c(f=>ee(f.substring(1,f.length-1)),"unquote"),a=c(()=>{if(e[r]==="not"){r++;let v=a();return v===null?null:{kind:"NotPolicyConditionSyntax",operand:v,location:n}}if(e[r]==="("){r++;let v=p();return e[r]===")"?r++:i&&t.error(d.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),v}let f=e[r++];if(f==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(f!=="role"&&f!=="claim")return t.error(f===void 0?d.ExpectedPolicyCondition:d.UnexpectedTokenInPolicyCondition,f===void 0?"Expected a policy condition":`Unexpected '${f}' in policy condition`,n),null;let y=e[r++];if(!o(y))return t.error(f==="role"?d.ExpectedRoleName:d.ExpectedClaimName,`Expected a quoted ${f} name after '${f}'`,n),null;if(f==="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:Te(h,n,t),location:n}},"group"),l=c(()=>{let f=a();for(;f!==null&&e[r]==="and";){r++;let y=a();if(y===null)return null;f={kind:"LogicalPolicyConditionSyntax",left:f,operator:"And",right:y,location:n}}return f},"and"),p=c(()=>{let f=l();for(;f!==null&&e[r]==="or";){r++;let y=l();if(y===null)return null;f={kind:"LogicalPolicyConditionSyntax",left:f,operator:"Or",right:y,location:n}}return f},"or"),m=p();return i&&m!==null&&r<e.length&&t.error(d.UnexpectedTokenInPolicyCondition,`Unexpected '${e[r]}' in policy condition`,n),m}c(au,"parsePolicyCondition");var su=new RegExp(`^for\\s+"(${H})"$`,"u"),lu=Q("^[A-Z]\\w*$"),cu=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function ls(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(d.InvalidSeedDeclaration,`Invalid seed declaration '${e.content}' - expected 'seed'`,u(e)),t.skipOpaqueBlock(e.indent),{kind:"SeedSyntax",groups:n,location:u(e)};for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=su.exec(i.content);if(r===null){t.error(d.InvalidSeedGroup,`Invalid seed group '${i.content}' - expected 'for "<event source id>"'`,u(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(),!lu.test(s.content)){t.error(d.InvalidSeedEvent,`Invalid seed event '${s.content}' - expected an event type name`,u(s)),t.skipOpaqueBlock(s.indent);continue}let a=[];for(let l=t.peekChild(s.indent);l!==void 0;l=t.peekChild(s.indent)){t.reader.takeSignificant();let p=cu.exec(l.content);p!==null?a.push({kind:"PropertyMappingSyntax",property:p[1],source:Te(p[2],u(l),t),location:u(l)}):t.error(d.InvalidSeedPropertyAssignment,`Invalid property assignment '${l.content}' - expected '<property> = <value>'`,u(l))}o.push({kind:"SeedEventSyntax",event:s.content,properties:a,location:u(s)})}n.push({kind:"SeedGroupSyntax",eventSourceId:ee(r[1]),events:o,location:u(i)})}return{kind:"SeedSyntax",groups:n,location:u(e)}}c(ls,"parseSeed");var du=w("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),ps=w("^import\\s+([\\w.]+)$"),pu=w("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$"),fu=w("^@?[a-z_]\\w*$"),uu=w("^persona\\s+([A-Za-z_]\\w*)$"),mu=w("^policy\\s+([A-Za-z_]\\w*)$"),yu=/^[ ]*\t/,cs=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],fs=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),hu=new Set(["slice","feature","description","documentation","authorize","screen","dialog","form","contribute","on","uses"]);function yi(t,e,n=kt){$u(t,e);let i=n.length===1?new gn(n[0]):void 0,r=n.length>1?new Sn(n[n.length-1]):void 0,o=i??r,s=null,a=[],l=[],p=[],m=[],f=[],y=[],h=[],v=[],x=[],S=[],E=[],g=[],P=!1;for(let $=t.reader.peekSignificant();$!==void 0;$=t.reader.peekSignificant()){t.reader.takeSignificant();let b=D($.content);if(b==="domain"){t.authoredDeclarations=!0,s=vu(t,$,s,P);continue}if(P||=ds(b,$,n),t.authoredDeclarations||=b!=="import"&&ds(b,$,n),b==="import"&&Wo($.content))o!==void 0?o.tryParse(t,$):qt(t,$,l);else if(b==="import"){let k=ps.exec($.content);k===null?t.error(d.InvalidImportDeclaration,`Invalid import '${$.content}' - expected 'import <Qualified.Name>'`,u($)):a.push({kind:"ImportSyntax",qualifiedName:k[1],location:u($)})}else if(b==="example")o!==void 0?o.tryParse(t,$):E.push(tt(t,$));else if(b==="eventsource")y.push(ea(t,$));else if(b==="system")f.push(sa(t,$));else if(b==="concept")p.push(bu(t,$));else if(b==="type")m.push(ga(t,$));else if(b==="module"&&!sn(n))Su(t,$,n,i);else if(b==="module")h.push(qr(t,$));else if(b==="persona")v.push(ku(t,$));else if(b==="seed")S.push(ls(t.valueContext,$));else if(b==="policy")x.push(ss(t,$));else if(b==="trigger"){let k=Ba(t,$),C=/^trigger\s+([A-Za-z_]\w*)$/.exec($.content)?.[1];C!==void 0&&g.push({name:C,data:k})}else fs.has(b)?b==="behavior"||b==="layout"?je(t,$):t.skipOpaqueBlock($.indent):o?.tryParse(t,$)!==!0&&gu(t,$,n)}i!==void 0?h.unshift(i.build(t.start,!0)):r!==void 0&&h.unshift(xu(n,r.build(t.start,!0),t.start));let A={kind:"ApplicationSyntax",sourceOptions:t.sourceOptions,domain:s,imports:a,concepts:p,types:m,systems:f,eventSources:y,examples:E,modules:h,personas:v,policies:x,seeds:S,declaredTriggers:g,fileImports:l,location:t.start};return t.authoredDeclarations&&Zo(A),A}c(yi,"parseApplication");function ds(t,e,n){return t==="import"?ps.test(e.content):t==="module"?sn(n):t==="example"||t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||fs.has(t)}c(ds,"declaresConstruct");function Su(t,e,n,i){let r=Nr.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 ${Gn(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,u(e)),t.skipBlock(e.indent)}c(Su,"parseModuleInPlacedFile");function gu(t,e,n){let i=D(e.content);if(sn(n)){let r=hu.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}`,u(e))}else{let r=n.length===1?Lr:jr;t.error(d.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${Gn(n)} - expected an application declaration or ${r}`,u(e))}t.skipBlock(e.indent)}c(gu,"reportUnexpectedTopLevel");function xu(t,e,n){let i=e;for(let r=t.length-2;r>=1;r--)i={kind:"FeatureSyntax",name:t[r],description:null,authorize:null,features:[i],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:"ModuleSyntax",name:t[0],description:null,authorize:null,features:[i],fileImports:[],isPlacement:!0,location:n}}c(xu,"place");function vu(t,e,n,i){let r=du.exec(e.content);return r===null?(t.error(d.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,u(e)),n):n!==null?(t.error(d.DuplicateDomain,"The document already declares a domain - a document can have at most one",u(e)),n):(i&&t.error(d.DomainNotFirst,"'domain' must be declared before any other construct",u(e)),{kind:"DomainSyntax",name:r[1],location:u(e)})}c(vu,"parseDomain");function $u(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&yu.test(i.raw)&&t.warning(d.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",Ro(i))}}c($u,"warnOnTabIndentation");function bu(t,e){let n=pu.exec(e.content);if(n===null)return t.error(d.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,u(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:D(e.content),type:"",attributes:[],values:[],location:u(e)};let[,i,r,o]=n,s=rs(t,e,o);r!=="Enum"&&!cs.includes(r)&&t.error(d.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${cs.join(", ")} or Enum`,u(e));let a=[],l=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))if(t.reader.takeSignificant(),!fe(p))if(D(p.content)==="validate"){r==="Enum"&&p.content==="validate"&&t.peekChild(p.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`,u(p));let m=wr(t,p,"concept");m!==void 0&&l.push(m)}else os(t,p,i,s)||(r==="Enum"&&fu.test(p.content)?a.push(ne(p.content)):r==="Enum"?t.error(d.InvalidEnumerationValue,`Invalid enum value '${p.content}' - expected an identifier`,u(p)):(t.error(d.UnknownConceptDirective,`Unexpected '${p.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,u(p)),t.skipBlock(p.indent)));return{kind:"ConceptSyntax",name:i,type:r,attributes:s,values:a,validations:l,location:u(e)}}c(bu,"parseConcept");function ku(t,e){let n=uu.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,u(e));let i=null,r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);if(s==="description")i=Z(t,o,i,`Persona '${n}'`);else if(s==="policy"){let a=mu.exec(o.content);a===null?t.error(d.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,u(o)):r.push(a[1])}else t.error(d.UnknownPersonaDirective,`Unexpected '${s}' in persona body - expected description or policy`,u(o)),t.skipBlock(o.indent)}return{kind:"PersonaSyntax",name:n,description:i,policies:r,location:u(e)}}c(ku,"parsePersona");var _t=class t{static{c(this,"CommandStreamCandidates")}sources;qualifiedTypes;constructor(e,n){this.sources=e,this.qualifiedTypes=n}hasSource(e){return this.sources.has(e)}hasPropertyType(e){return this.qualifiedTypes.has(e)}hasUniqueStream(e,n){let i=this.sources.get(e);return i?.length===1&&i[0].filter(r=>r===n).length===1}static capture(e,n=kt,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:l}of e){let p=fi(a,a[0]?.path,n);p.scope=l;let m=yi(p,a,l);for(let f of m.types)r.add(f.name);for(let f of m.concepts)r.add(f.name);for(let f of m.imports)o.add(f.qualifiedName);for(let f of m.eventSources??[])i.set(f.name,[...i.get(f.name)??[],f.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 he;(function(t){t.Empty="Empty",t.NotNfc="NotNfc",t.LoneSurrogate="LoneSurrogate",t.OutOfRange="OutOfRange",t.NotIntegral="NotIntegral",t.MalformedUuid="MalformedUuid",t.Arity="Arity",t.Escape="Escape",t.Noncanonical="Noncanonical"})(he||(he={}));function us(t){return t.length===0?{value:null,failure:he.Empty}:/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(t)?{value:null,failure:he.LoneSurrogate}:t.normalize("NFC")!==t?{value:null,failure:he.NotNfc}:{value:t,failure:null}}c(us,"tryFormatText");function ms(t){if(!/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}|\{[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\}|\([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\))(?![\s\S])/i.test(t))return{value:null,failure:he.MalformedUuid};let e=t.replace(/[{}()-]/g,"").toLowerCase();return{value:`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`,failure:null}}c(ms,"tryFormatUuidText");function hi(t,e=typeof t=="number"){if(typeof t=="number"&&!Number.isInteger(t))return{value:null,failure:he.NotIntegral};let n=BigInt(t);return e&&(n<-9007199254740991n||n>9007199254740991n)?{value:null,failure:he.OutOfRange}:{value:n.toString(),failure:null}}c(hi,"tryFormatInteger");function Si(t){switch(t){case he.Empty:return"A stream id text literal cannot be empty.";case he.NotNfc:return"A stream id text literal must be Unicode NFC.";case he.LoneSurrogate:return"A stream id text literal cannot contain lone UTF-16 surrogates.";case he.OutOfRange:return"A stream id integer literal must be between -9007199254740991 and 9007199254740991 in Double numeric mode.";case he.NotIntegral:return"A stream id integer must be a finite integral value.";case he.MalformedUuid:return"A stream id UUID must use N, D, B or P form.";case he.Arity:return"A composite stream id must match the declared part count of at least two.";case he.Escape:return"A composite stream id permits only %25 and %7C escapes.";case he.Noncanonical:return"A composite stream id part must use canonical scalar spelling."}}c(Si,"streamIdFailureMessage");function gi(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(f=>f.property===m.name)))o.error(r,`Stream id part '${p.name}' requires a mapping.`,i);let l=new Set;for(let p of e){let m=a.find(f=>f.name===p.property);m===void 0?o.error(r,`Unknown stream id part '${p.property}'.`,p.location):l.has(p.property)?o.error(r,`Stream id part '${p.property}' is mapped more than once.`,p.location):(l.add(p.property),s(p,m.type))}}c(gi,"validateStreamIdParts");function xi(t,e,n){let i=te(n.concepts),r=te(n.types),o=new Map([...r].map(([a,l])=>[a,te(l.properties)]));if(t?.kind!=="LiteralExpressionSyntax"||!ve(t,e,i,o))return null;let s=i.get(e.name)?.type??e.name;return["String","Uuid","Int"].includes(s)?bn(t,e,n)?.value??null:null}c(xi,"formatSpecificationStreamId");function ys(t,e,n,i){if(n!=null)return t==null;if(e==null)return!0;if(t==null)return!1;let r=new Oe(i),o=r.resolve(t.eventSource,t.stream),s=r.resolve(e.eventSource,e.stream);if(o.kind!==se.Unique||s.kind!==se.Unique)return null;if(o.sources[0]!==s.sources[0]||o.streams[0]!==s.streams[0])return!1;let a=s.streams[0],l=c((p,m,f)=>{let y=xi(p,f,i),h=xi(m,f,i);return y===null||h===null?null:y===h},"compare");if(a.streamIdParts.length>0){if(t.streamId!==null||e.streamId!==null||t.streamIdParts.length!==a.streamIdParts.length||e.streamIdParts.length!==a.streamIdParts.length)return null;let p=a.streamIdParts.map(m=>{let f=t.streamIdParts.filter(h=>h.property===m.name),y=e.streamIdParts.filter(h=>h.property===m.name);return f.length===1&&y.length===1?l(f[0].source,y[0].source,m.type):null});return p.includes(!1)?!1:p.includes(null)?null:!0}return t.streamIdParts.length>0||e.streamIdParts.length>0?null:a.streamId===null?t.streamId===null&&e.streamId===null?!0:null:l(t.streamId?.source,e.streamId?.source,a.streamId)}c(ys,"matchesSpecificationRoute");function Ss(t,e){let n=new re(t).slices.flatMap(({slice:s})=>s.specifications.flatMap(a=>a.cases??[]));if(n.length===0)return hs(t,e);let i=new me(new We([]));hs(t,i);let r=new Set,o=new Set;for(let s of i.diagnostics){let a=JSON.stringify([s.code,s.location.path,s.location.line,s.location.column,s.message]);if(o.has(a))continue;o.add(a);let l=s.code===d.InvalidSpecificationStreamRoute?n.find(p=>p.values.some(m=>m.source.location.line===s.location.line&&m.source.location.column===s.location.column&&m.source.location.path===s.location.path)):void 0;if(l===void 0)e.error(s.code,s.message,s.location);else{let p=JSON.stringify(s.location);r.has(p)||e.error(s.code,`Case '${l.name}': ${s.message}`,s.location),r.add(p)}}}c(Ss,"validateSpecificationStreams");function hs(t,e){let n=jt(t).resolvedExamples,i=qn(t);t=i.application;let r=new re(t),o=new Set,s=n.flatMap(g=>{if(g.kind!=="event")return(g.kind==="command"||g.kind==="readmodel")&&(g.example.stream!=null||g.example.noStream!=null)&&e.error(d.InvalidSpecificationExampleBody,"only event examples carry routes; a command's route comes from its declaration, and read models have none",(g.example.stream??g.example.noStream).location),[];let P={kind:"SpecificationEventSyntax",eventType:g.name,values:g.example.values,for:g.example.for,stream:g.example.stream,noStream:g.example.noStream,location:g.example.location};return o.add(P),[{scope:g.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[P],whenRedelivered:null}}]}),a=new Oe(t),l=te(t.concepts),p=te(t.types),m=new Map([...p].map(([g,P])=>[g,te(P.properties)])),f=c((g,P)=>ve(g,P,l,m),"compatible"),y=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime",...l.keys(),...p.keys()]),h=c((g,P)=>y.has(g.name)&&y.has(P.name)?g.name===P.name&&g.isCollection===P.isCollection&&(!g.isOptional||P.isOptional):null,"nominallyCompatible"),v=c((g,P)=>xi(g,P,t),"formatStreamId"),x=c((g,P)=>{let A=r.resolve(g,P).declaration;return A?.node.kind==="EventSyntax"?A.node:null},"eventOf"),S=[];for(let{slice:g}of r.slices){for(let P of g.commands)for(let A of P.produces){if(!r.isEventProduction(A,g))continue;let $=x(A.event,g);if($===null)continue;let b=Nt(P,A,t,{resolver:r,slice:g});S.push({event:$,command:P,type:b})}for(let P of g.reactions.flatMap(A=>A.triggers).flatMap(A=>A.produces)){let A=x(P.event,g);A!==null&&S.push({event:A,command:null,type:null})}for(let P of g.captures)for(let A of[...P.appends,...P.children.flatMap($=>$.appends),...P.nested.flatMap($=>$.appends)]){let $=x(A.event,g);$!==null&&S.push({event:$,command:null,type:null})}}let E=[...s.flatMap(g=>r.slices.filter(P=>P.scope.join(".")===g.scope.join(".")).map(({slice:P,scope:A})=>({slice:P,scope:A,specification:g.specification}))),...r.slices.flatMap(({slice:g,scope:P})=>g.specifications.map(A=>({slice:g,scope:P,specification:A})))];for(let{slice:g,scope:P,specification:A}of E){let $=r.slices.flatMap(R=>R.slice.commands.map(j=>({command:j,scope:R.scope}))),b=A.when?.commandType.split(".")??[],k=b.slice(0,-1),C=$.filter(R=>R.command.name===b.at(-1)&&k.every((j,N)=>R.scope[R.scope.length-k.length+N]===j)),O=k.length>0&&C.length===1?C[0].command:null;for(let R=P.length;k.length===0&&R>=0&&O===null;R--){let j=C.filter(N=>P.slice(0,R).every((B,L)=>N.scope[L]===B));if(j.length>0){O=j.length===1?j[0].command:null;break}}let I=[...A.given.map(R=>({node:R,required:!0,expected:!1})),...A.whenAppended===null?[]:[{node:A.whenAppended,required:!0,expected:!1}],...A.thenEvents.map(R=>({node:R,required:!1,expected:!o.has(R)})),...A.whenRedelivered==null?[]:[{node:{...A.whenRedelivered,kind:"SpecificationEventSyntax"},required:!1,expected:!1}]];for(let{node:R,required:j,expected:N}of I){let B=i.specifications.flatMap(F=>F.steps).find(F=>F.effective===R),L=B?.route?.origin!=="example",W=L||R.for!==B?.example?.for,V=c((F,oe,de)=>{e.error(F,B?.example==null?oe:`${oe} Example '${B.example.name}' is used here.`,B?.example==null?de:B.authored.location)},"contextualError");if(R.stream==null&&R.noStream==null)continue;j&&R.noStream!=null&&V(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",R.noStream.location);let G=null,z=x(R.eventType,g),_=S.filter(F=>F.event===z);if(R.stream!=null){let F=R.stream,oe=a.resolve(F.eventSource,F.stream);if(oe.kind!==se.Unique){let pe={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[oe.kind];L&&e.error(d.InvalidSpecificationStreamRoute,`Stream '${F.eventSource}.${F.stream}' is ${pe}; routing requires one physical source and stream.`,F.location);continue}let de=oe.sources[0],ke=oe.streams[0],xt=c((pe,Se)=>{let T=pe.source,M=bn(T,Se,t);M?.failure!=null?e.error(d.InvalidSpecificationStreamRoute,Si(M.failure),T.location):(T.kind!=="LiteralExpressionSyntax"||T.value===null||Se!==null&&!f(T,Se))&&e.error(d.InvalidSpecificationStreamRoute,"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.",T.location)},"validateLiteral");if(L&&(ke.streamIdParts.length>0?gi(ke,F.streamIdParts,F.streamId!==null,F.location,d.InvalidSpecificationStreamRoute,e,xt):F.streamIdParts.length>0?e.error(d.InvalidSpecificationStreamRoute,"A streamId part block requires a composite stream.",F.location):(ke.streamId===null!=(F.streamId===null)&&e.error(d.InvalidSpecificationStreamRoute,ke.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",F.location),F.streamId!==null&&xt(F.streamId,ke.streamId))),G=de.identifier,G===null){let pe=_.map(T=>T.type),Se=new Set(pe.filter(T=>T!==null).map(T=>`${T.name}:${T.isOptional}:${T.isCollection}`));pe.length===0||pe.some(T=>T===null)||Se.size!==1?L&&e.error(d.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${de.name}'; the event's producers do not supply one unambiguous destination type.`,F.location):G=pe[0]}let vt=!1;if(B?.example?.stream!=null&&R.for!==null&&R.for===B.example.for){let pe=a.resolve(B.example.stream.eventSource,B.example.stream.stream);if(pe.kind===se.Unique){let Se=_.map(q=>q.type),T=new Set(Se.filter(q=>q!==null).map(q=>`${q.name}:${q.isOptional}:${q.isCollection}`)),M=pe.sources[0].identifier??(Se.length>0&&!Se.some(q=>q===null)&&T.size===1?Se[0]:null);M!==null&&(vt=R.for.kind!=="LiteralExpressionSyntax"||R.for.value===null||M.isCollection||M.isOptional||!f(R.for,M))}}j&&R.for===null?V(d.InvalidSpecificationStreamEventSource,"A routed given or when append event requires 'for <literal>'.",F.location):W&&!vt&&R.for!==null&&(R.for.kind!=="LiteralExpressionSyntax"||R.for.value===null||G!==null&&(G.isCollection||G.isOptional||!f(R.for,G)))&&V(d.InvalidSpecificationStreamEventSource,"A routed event's for value must be a concrete literal compatible with the source's identifier type.",R.for.location)}if(!N||O===null||_.length===0||_.some(F=>F.command!==O))continue;let ue=O.stream?.propertyCandidate===null?O.stream:null,we=R.noStream!=null?ue!=null:ue==null||ue.eventSource!==R.stream.eventSource||ue.stream!==R.stream.stream;if(!we&&R.stream!=null&&ue!=null){let F=a.resolve(R.stream.eventSource,R.stream.stream),oe=F.kind===se.Unique?F.streams[0]:null;if(oe!==null&&oe.streamIdParts.length>0){if(ue.streamId===null&&R.stream.streamId===null&&ue.streamIdParts.length>0&&R.stream.streamIdParts.length>0)for(let de of oe.streamIdParts){let ke=ue.streamIdParts.filter(Se=>Se.property===de.name),xt=R.stream.streamIdParts.filter(Se=>Se.property===de.name);if(ke.length!==1||xt.length!==1)continue;let vt=v(ke[0].source,de.type),pe=v(xt[0].source,de.type);vt!==null&&pe!==null&&vt!==pe&&(we=!0)}}else if(oe?.streamId!=null&&ue.streamIdParts.length===0&&R.stream.streamIdParts.length===0){let de=v(ue.streamId?.source,oe.streamId),ke=v(R.stream.streamId?.source,oe.streamId);de!==null&&ke!==null&&de!==ke&&(we=!0)}}R.for?.kind==="LiteralExpressionSyntax"&&_.every(F=>F.type!==null&&(G!==null?h(F.type,G)===!1:!f(R.for,F.type)))&&(we=!0),we&&V(d.SpecificationStreamContradictsCommand,"The expected event route contradicts its only producer, the command under test.",(R.stream??R.noStream).location)}}}c(hs,"validateRoutes");var kn=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function _r(t,e){let n=e.concepts.filter(r=>r.name===t.name),i=n.length===1?n[0].type:n.length===0&&kn.has(t.name)?t.name:null;return i==="String"||i==="Uuid"||i==="Int"&&n.length===1&&n[0].values.length===0}c(_r,"supportsStreamIdentity");function bn(t,e,n){if(t?.kind!=="LiteralExpressionSyntax")return null;let i=t.value,r=e===null?null:te(n.concepts).get(e.name)?.type??e.name;return typeof i=="string"?r==="Uuid"?ms(i):us(i):typeof i=="number"?hi(i):typeof i=="object"&&i!==null&&i.literalType==="ExactNumber"?i.value.includes(".")?hi(NaN):hi(BigInt(i.value),!1):null}c(bn,"formatStreamIdLiteral");function vi(t,e){let n=te(t.concepts),i=te(t.types),r=new Set([...kn,...n.keys(),...i.keys()]),o=new Map([...i].map(([y,h])=>[y,te(h.properties)])),s=c((y,h)=>r.has(y.name)&&r.has(h.name)?y.name===h.name&&y.isCollection===h.isCollection&&(!y.isOptional||h.isOptional):null,"compatible"),a=c((y,h)=>{if(y===null)return;if(y.isOptional||y.isCollection||t.types.some(S=>S.name===y.name)){e.error(d.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",y.location);return}let v=t.concepts.filter(S=>S.name===y.name),x=v.length===1?v[0].type:v.length===0&&kn.has(y.name)?y.name:null;h&&x!==null&&!_r(y,t)&&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.",y.location),x===null&&!t.imports.some(S=>S.qualifiedName===y.name||S.qualifiedName.split(".").at(-1)===y.name)&&e.warning(d.UnknownType,`Unknown type '${y.name}' in event source declaration.`,y.location)},"validateType"),l=new Set;for(let y of t.eventSources??[]){l.has(y.name)&&e.error(d.InvalidEventSourceDeclaration,`Event source '${y.name}' has multiple physical declarations.`,y.location),l.add(y.name),a(y.identifier,!1);let h=new Set;for(let v of y.streams){h.has(v.name)&&e.error(d.InvalidEventSourceDeclaration,`Stream '${y.name}.${v.name}' has multiple declarations under this source.`,v.location),h.add(v.name),a(v.streamId,!0);let x=v.streamIdParts;if(x.length>0){x.length<2&&e.error(d.InvalidEventSourceDeclaration,"A composite stream id requires at least two named parts.",v.directiveLocations?.streamId??v.location);for(let S of new Set(x.map(E=>E.name)))for(let E of x.filter(g=>g.name===S).slice(1))e.error(d.InvalidEventSourceDeclaration,`Stream id part '${E.name}' is declared more than once.`,E.location);for(let S of x)a(S.type,!0)}}}let p=c((y,h)=>{let[v,...x]=h.split(".");if(y===null)return{property:null,missing:!1};let S=y.filter(P=>P.name===v);if(S.length!==1)return{property:null,missing:S.length===0};let E=S[0];if(x.length===0)return{property:E,missing:!1};if(kn.has(E.type.name)||n.has(E.type.name)&&!i.has(E.type.name))return{property:null,missing:!0};let g=p(i.get(E.type.name)?.properties??null,x.join("."));return g.property===null?g:{property:{...g.property,type:{...g.property.type,isCollection:E.type.isCollection||g.property.type.isCollection,isOptional:E.type.isOptional||g.property.type.isOptional}},missing:!1}},"pathProperty"),m=new Oe(t),f=new re(t);for(let{slice:y}of f.slices)for(let h of y.commands){let v=h.stream;if(v==null||v.propertyCandidate!==null)continue;let x=m.resolve(v.eventSource,v.stream);if(x.kind!==se.Unique){let A={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[x.kind];e.error(d.InvalidCommandStream,`Stream '${v.eventSource}.${v.stream}' is ${A}; routing requires one physical source and stream.`,v.location);continue}let S=x.sources[0],E=x.streams[0],g=h.properties.filter(A=>A.isIdentifier);S.identifier!==null&&g.length===1&&s(g[0].type,S.identifier)===!1&&e.error(d.InvalidCommandStream,`Command identifier '${g[0].name}' does not have the source's nominal identifier type '${S.identifier.name}'. The stream does not supply a destination.`,g[0].location);for(let A of h.produces.filter($=>f.isEventProduction($,y))){if(S.identifier===null)continue;let $=Nt(h,A,t,{resolver:f,slice:y});if($===null||A.for===null&&A.inlineEvent!==null&&g.length===1&&s(g[0].type,S.identifier)===!1)continue;let b=A.for===null&&A.inlineEvent===null&&!h.properties.some(O=>O.isGenerated&&O.isIdentifier),k=n.get(S.identifier.name)?.type??(kn.has(S.identifier.name)?S.identifier.name:null);(b?k===null?null:k==="Uuid":s($,S.identifier))===!1&&e.error(d.InvalidCommandStream,`Command production destination does not have the source's nominal identifier type '${S.identifier.name}'. The stream does not supply a destination.`,A.for?.location??A.location)}let P=c((A,$)=>{let b=A.source;if(b.kind==="PathExpressionSyntax"){let k=p(h.properties,b.path);(k.missing||k.property!==null&&s(k.property.type,$)===!1)&&e.error(d.InvalidCommandStream,`Stream id source '${b.path}' is absent or incompatible with nominal type '${$.name}'.`,b.location)}else if(b.kind==="LiteralExpressionSyntax"&&b.value!==null){let k=bn(b,$,t);k?.failure!=null?e.error(d.InvalidCommandStream,Si(k.failure),b.location):ve(b,$,n,o)||e.error(d.InvalidCommandStream,`Stream id value is incompatible with nominal type '${$.name}'.`,b.location)}else(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(b.kind)||b.kind==="LiteralExpressionSyntax"&&b.value===null)&&e.error(d.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",b.location)},"validateMapping");if(E.streamIdParts.length>0){gi(E,v.streamIdParts,v.streamId!==null,v.location,d.InvalidCommandStream,e,P);continue}if(v.streamIdParts.length>0){e.error(d.InvalidCommandStream,"A streamId part block requires a composite stream.",v.location);continue}(E.streamId===null&&v.streamId!==null||E.streamId!==null&&v.streamId===null)&&e.error(d.InvalidCommandStream,E.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",v.location),!(E.streamId===null||v.streamId===null)&&P(v.streamId,E.streamId)}Ss(t,e)}c(vi,"validateEventSources");function $i(t,e){let n=new re(t),i=n.slices,r=new Set(t.imports.map(x=>x.qualifiedName)),o=new Set([...i.flatMap(({slice:x})=>ae(x).map(S=>S.name)),...t.imports.map(x=>x.qualifiedName.split(".").at(-1))]),s=te(t.types),a=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(x=>x.name)].filter(x=>!s.has(x))),l=c((x,S)=>{let[E,...g]=S.split(".");if(x===null)return{value:null,missing:!1};let P=x.filter($=>$.name===E);if(P.length!==1)return{value:null,missing:P.length===0};let A=P[0];return g.length===0?{value:A,missing:!1}:a.has(A.type.name)?{value:null,missing:!0}:l(s.get(A.type.name)?.properties??null,g.join("."))},"property"),p=i.flatMap(({slice:x,scope:S})=>x.readModels.map(E=>({node:E,scope:S}))),m=c((x,S)=>{let E=c(A=>{let $=A.split("."),b=p.filter(C=>C.node.name===$.at(-1)),k=$.slice(0,-1);if(k.length>0)return b.filter(C=>k.length<=C.scope.length&&k.every((O,I)=>C.scope[C.scope.length-k.length+I]===O));for(let C=S.length;C>=0;C--){let O=b.filter(I=>C<=I.scope.length&&S.slice(0,C).every((R,j)=>I.scope[j]===R));if(O.length>0)return O}return[]},"candidates"),g=E(x),P=t.imports.filter(A=>A.qualifiedName.split(".").at(-1)===x);return g.length===0&&P.length===1&&(g=E(P[0].qualifiedName)),g.length===1?g[0].node.properties:null},"viewProperties"),f=c((x,S,E)=>{let g=n.resolve(x,E);o.has(x)||r.has(x)||g.declaration?.kind===ie.Event||g.candidates.some(A=>A.kind===ie.Event)||e.warning(d.UnknownEvent,`Unknown event '${x}' - declare it with 'event ${x}'`,S)},"unknownEvent"),y=c((x,S)=>{for(let E of x)(E.kind==="RemoveWithSyntax"||E.kind==="RemoveViaJoinSyntax")&&f(E.event,E.location,S),"blocks"in E&&y(E.blocks,S)},"removals"),h=new Set,v=c((x,S,E=!1,g=!1)=>{let P=c(($,b)=>{let k=l(S,$),C=JSON.stringify([b.path,b.line,b.column]);return k.missing&&!h.has(C)&&(h.add(C),e.warning(d.UnknownReadModelProperty,`Projection target '${$}' is not a declared ${E?"element":"read-model"} property`,b)),k.value},"validate"),A=g||x.some($=>$.kind==="FromSyntax"||$.kind==="JoinSyntax"||$.kind==="AllSyntax");for(let $ of x){let b=$.kind==="EverySyntax"&&!A?[]:"mappings"in $?$.mappings:$.kind==="JoinSyntax"?$.events.flatMap(k=>k.mappings):[];for(let k of b)P(k.property,k.location);if($.kind==="ChildrenSyntax"||$.kind==="NestedSyntax"){let k=P($.property,$.location);v($.blocks,k===null?null:s.get(k.type.name)?.properties??null,!0)}}},"walk");for(let{slice:x}of i){for(let S of x.projections)y(S.blocks,x);for(let S of x.captures)for(let E of[...S.appends,...S.children.flatMap(g=>g.appends),...S.nested.flatMap(g=>g.appends)])f(E.event,E.location,x)}for(let{slice:x,scope:S}of i)for(let E of x.projections){let g=E.blocks.filter(P=>P.kind==="ProjectionVariantSyntax");g.length===0&&v(E.blocks,m(E.readModel??E.name,S));for(let P of g){let A=m(P.name,S);v(E.blocks.filter(b=>b.kind==="ChildrenSyntax"||b.kind==="NestedSyntax"),A);let $=P.entersOn.length>0||E.blocks.some(b=>b.kind==="FromSyntax"||b.kind==="JoinSyntax"||b.kind==="AllSyntax");v(P.blocks,A,!1,$)}}}c($i,"validateProjectionTargets");function bi(t,e){let n=new Set(t.concepts.filter(f=>f.attributes.some(y=>y.name==="pii")).map(f=>f.name)),i=new Set(t.concepts.filter(f=>f.attributes.some(y=>y.name==="sensitive")).map(f=>f.name)),r=te(t.types),o=new re(t),s=new Set(t.imports.map(f=>f.qualifiedName.split(".").at(-1))),a=new Map;for(let f of t.declaredTriggers??[]){let y=a.get(f.name)??[];y.push(f.data),a.set(f.name,y)}let l=c((f,y,h="an event source identifier")=>{if(n.has(f.name)||i.has(f.name)){let v=n.has(f.name)?"pii":"secret";e.error(d.PiiNotSupportedOnIdentifier,`Concept '${f.name}' is ${v} and cannot be ${h} - use a surrogate Uuid identifier and keep the ${v} value as a property`,y)}},"validate"),p=c((f,y)=>{let[h,...v]=y.split("."),x=f.filter(E=>E.name===h);if(x.length!==1)return null;let S=x[0];return v.length===0?S:p(r.get(S.type.name)?.properties??[],v.join("."))},"property");for(let f of t.eventSources??[]){f.identifier!=null&&l(f.identifier,f.identifier.location);for(let y of f.streams){y.streamId!==null&&l(y.streamId,y.streamId.location,"a stream id");for(let h of y.streamIdParts)l(h.type,h.type.location,`a stream id part '${h.name}'`)}}let m=new Oe(t);for(let{slice:f}of o.slices){for(let y of f.commands){for(let h of y.properties.filter(v=>v.isIdentifier))l(h.type,h.location);for(let h of[...y.stream?[y.stream]:[],...y.streamCandidates??[]].filter(v=>v.propertyCandidate===null)){let v=m.resolve(h.eventSource,h.stream),x=v.kind===se.Unique?v.streams[0]:void 0,S=[...h.streamId===null?[]:[{mapping:h.streamId,target:x?.streamId}],...h.streamIdParts.map(E=>({mapping:E,target:x?.streamIdParts.find(g=>g.name===E.property)?.type}))];for(let{mapping:E,target:g}of S){if(E.source.kind!=="PathExpressionSyntax")continue;let P=p(y.properties,E.source.path);P!==null&&(P.type.name===g?.name&&(n.has(P.type.name)||i.has(P.type.name))||l(P.type,E.source.location,"a stream id route mapping"))}}for(let h of y.produces.filter(v=>o.isEventProduction(v,f))){if(h.for?.kind!=="PathExpressionSyntax")continue;let v=p(y.properties,h.for.path);v!==null&&!v.isIdentifier&&l(v.type,h.for.location)}}for(let y of f.reactions.flatMap(h=>h.triggers)){if(y.source.kind!=="NamedTriggerSourceSyntax")continue;let v=o.resolve(y.source.name,f).declaration?.node,x=(Ye(y).data??[]).flatMap(E=>E.type===null?[]:[{kind:"PropertySyntax",name:E.name,type:E.type,isIdentifier:!1,location:E.location}]),S=[v?.kind==="EventSyntax"?v.properties:[],x];v?.kind!=="EventSyntax"&&!s.has(y.source.name)&&S.push(...a.get(y.source.name)??[]);for(let E of y.produces.filter(g=>o.isEventProduction(g,f))){if(E.for?.kind!=="PathExpressionSyntax")continue;let g=E.for.path,P=S.map(A=>p(A,g)).find(A=>A!==null&&(n.has(A.type.name)||i.has(A.type.name)));P!=null&&l(P.type,E.for.location)}}}}c(bi,"validateIdentifierCompliance");function ki(t,e){let n=c((i,r)=>{for(let o of i.filter(s=>s.isSubject))e.error(d.InvalidSubjectOwner,`The subject modifier is only valid on event properties, not ${r} properties (decision 0008: one data subject per event).`,o.location)},"refuse");for(let i of t.types)n(i.properties,"type");for(let{slice:i}of new re(t).slices){for(let r of i.commands)n(r.properties,"command");for(let r of i.readModels)for(let o of r.properties.filter(s=>s.isSubject))e.error(d.ReadModelSubjectNotSupported,"Read model subject marks are not yet supported. Chronicle resolves read model subjects and reserves _subject, __subject and __subjects; Screenplay support is tracked in #559.",o.location);for(let r of ae(i)){let o=r.properties.filter(s=>s.isSubject);for(let s of o.slice(1))e.error(d.DuplicateEventSubject,`Event '${r.name}' has one data subject (decision 0008); '${s.name}' is an extra mark after '${o[0].name}'. Choose one subject; no automatic repair is safe.`,s.location);for(let s of o){let a=s.type;if(a.isOptional){e.error(d.InvalidSubjectType,"A subject must be required: a null value silently falls back to the event source.",s.location);continue}if(a.isCollection||t.types.some(m=>m.name===a.name)){e.error(d.InvalidSubjectType,"A subject must be a scalar identity, not a collection or composite type.",s.location);continue}let l=t.concepts.filter(m=>m.name===a.name);l.some(m=>m.attributes.some(f=>["pii","sensitive"].includes(f.name)))&&e.error(d.ProtectedSubjectType,`Subject concept '${a.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`,s.location);let p=l.length===1?l[0].type:l.length===0&&["String","Uuid","Int","Decimal","Bool","Date","DateTime"].includes(a.name)?a.name:null;l.length===0&&p===null&&t.imports.some(m=>m.qualifiedName===a.name||m.qualifiedName.split(".").at(-1)===a.name)&&e.warning(d.UnknownType,`Unknown type shape '${a.name}' for subject property '${s.name}'; imported subject identity rules cannot be verified.`,s.location),(l.some(m=>m.type==="Enum")||p!==null&&!_r(a,t))&&e.error(d.InvalidSubjectType,"Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.",s.location)}}}}c(ki,"validateEventSubjects");var Ci=class extends yt{static{c(this,"RefusalValueWalker")}declarations;context;slice=null;branch=null;properties=null;target=null;mapping=!1;constructor(e,n){super(),this.declarations=e,this.context=n}visitSlice(e){this.slice=e,super.visitSlice(e),this.slice=null}visitInvocationRefusal(e){this.branch=e,super.visitInvocationRefusal(e),this.branch=null}visitProduces(e){if(this.branch===null||this.slice===null){super.visitProduces(e);return}this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.when!=null&&this.visitCondition(e.when),e.tags.forEach(n=>this.visitTag(n)),this.properties=this.declarations.event(e.event,this.slice)?.properties??null,e.mappings.forEach(n=>this.visitPropertyMapping(n)),this.properties=null}visitPropertyMapping(e){this.mapping=this.branch!==null,this.target=this.declarations.property(this.properties,e.property)?.type??null,super.visitPropertyMapping(e),this.target=null,this.mapping=!1}visitObjectMember(e){let n=this.target;this.target=this.declarations.property(n===null?null:this.declarations.types.get(n.name)?.properties??null,e.name)?.type??null,super.visitObjectMember(e),this.target=n}visitExpression(e){e.kind==="RefusalExpressionSyntax"&&(!this.mapping||this.branch===null||!["reason","constraint","message"].includes(e.member)||e.member==="constraint"&&this.branch.selector!=="constraint"?this.context.error(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 Cu(){return!0}c(Cu,"invocationHasNoDeclaredIdentity");function Eu(t){let e=new Set,n=c((i,r)=>{let o=r||i.authorize!==null;o&&i.slices.forEach(s=>e.add(s)),i.features.forEach(s=>n(s,o))},"collect");return t.modules.forEach(i=>i.features.forEach(r=>n(r,i.authorize!==null))),e}c(Eu,"authorizationGatedSlices");function Ei(t,e){let n=new Ge(Fe(t));new Ci(n,e).visitApplication(n.application);let i=Eu(n.application);for(let{slice:r}of n.slices){let o=c(l=>n.resolve(l,r,p=>p.constraints),"constraintOf"),s=c((l,p)=>l===p||o(l)!==null&&o(l)?.node===o(p)?.node,"sameConstraint"),a=c((l,p)=>l.selector==="any"&&["any","validation","constraint"].includes(p.selector)||l.selector===p.selector&&(l.selector!=="constraint"||l.constraint===null||p.constraint!==null&&s(l.constraint,p.constraint)),"covers");for(let l of r.reactions.flatMap(p=>p.triggers).flatMap(p=>p.invokes)){let p=n.resolve(l.command,r,y=>y.commands),m=p!==null&&(p.node.authorize!==null||i.has(p.slice)),f=[];for(let y of l.onRefused??[]){if(f.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),f.push(y),y.selector==="authorization"&&Cu()&&m&&e.warning(d.AuthorizationRefusalWithoutIdentity,`Command '${l.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 v=[h.node,...h.node.additionalRules];if(v.some(E=>E.kind==="FileConstraintSyntax"))continue;let x=v.map(E=>E.kind==="FileConstraintSyntax"?null:n.event(E.event,h.slice)),S=p.node.produces.map(E=>n.event(E.event,p.slice));x.every(E=>E!==null)&&S.every(E=>E!==null)&&!x.some(E=>S.includes(E))&&e.warning(d.UnreachableRefusalBranch,`Constraint '${y.constraint}' targets none of the events produced by '${l.command}'.`,y.location)}}}}c(Ei,"validateReactionRefusals");function Pi(t,e,n){let i=e===null||e.isCollection?void 0:n.concepts.get(e.name),r=i!==void 0&&i.type==="Enum"?i:null,o=c(a=>r!==null&&a.startsWith(`${r.name}.`)?a.substring(r.name.length+1):a,"member");if(e?.isCollection&&t.kind==="ListExpressionSyntax"&&n.compatible({...e,isCollection:!1},{...e,isCollection:!1})===!0){let a=t.items.map(l=>Pi(l,{...e,isCollection:!1,isOptional:!1},n));return a.some(l=>l===void 0)?void 0:{canonical:`[${a.map(Ai).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(l=>{let p=n.property(s,l.name);return{name:l.name,value:p===null?void 0:Pi(l.value,p.type,n)}});return a.some(l=>l.value===void 0)?void 0:{canonical:`{${a.sort((l,p)=>l.name<p.name?-1:l.name>p.name?1:0).map(l=>`${JSON.stringify(l.name)}:${Ai(l.value)}`).join(",")}}`}}if(t.kind==="LiteralExpressionSyntax")return r!==null&&typeof t.value=="string"?o(t.value):t.value;if(t.kind==="PathExpressionSyntax"&&r!==null)return o(t.path)}c(Pi,"redeliveryValue");function Ai(t){return typeof t=="object"&&t!==null?"canonical"in t?t.canonical:ir(t):JSON.stringify(t)}c(Ai,"canonical");function Zr(t,e,n,i){let r=Pi(t,n,i),o=Pi(e,n,i);return r===void 0||o===void 0?null:Ai(r)===Ai(o)}c(Zr,"sameRedeliveryValue");function wi(t,e){t=Fe(t);let n=new Ge(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 l=r.given.filter(m=>n.event(m.eventType,i)===s).map(m=>Pu(m,o,s,n,t)),p=l.filter(m=>m===!0).length;l.some(m=>m===null)?e.error(d.UnmatchedRedeliveredOccurrence,`Cannot locate redelivery of '${o.eventType}' uniquely: a given source or locator value is not decidable; use 'for', values, 'stream' or 'no stream'.`,o.location):p!==1&&e.error(d.UnmatchedRedeliveredOccurrence,`Redelivery of '${o.eventType}' matches ${p} given occurrences; use 'for', values, 'stream' or 'no stream' to identify exactly one.`,o.location)}}c(wi,"validateSpecificationRedelivery");function Pu(t,e,n,i,r){let o=[];e.for!==null&&o.push(t.for===null?null:Zr(e.for,t.for,null,i));for(let s of e.values){let a=t.values.filter(l=>l.property===s.property);o.push(a.length===1?Zr(s.source,a[0].source,i.property(n.properties,s.property)?.type??null,i):null)}return o.push(ys(t.stream,e.stream,e.noStream,r)),o.includes(!1)?!1:o.includes(null)?null:!0}c(Pu,"matches");var gs=64;function xs(t,e){let n=[];for(let i of t.alternatives){let r=Kr(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))}}c(xs,"validateGuardedActionShadowing");function Kr(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=Kr(t.left),n=Kr(t.right);return e===null||n===null?null:t.operator==="Or"?e.length+n.length>gs?null:[...e,...n]:e.length*n.length>gs?null:e.flatMap(i=>n.map(r=>new Set([...i,...r])))}c(Kr,"normalize");var Au=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Oi(t,e){let n=new Ge(t);for(let{slice:i}of n.slices)for(let r of i.screens)Jr(r.directives,[],i,n,e)}c(Oi,"validateGuardedActions");function Jr(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":wu(a,s,n,i,r);break;case"ScreenSectionSyntax":Jr(a.directives,s,n,i,r);break;case"ScreenTemplateReferenceSyntax":for(let l of a.slots)Jr(l.directives,s,n,i,r);break}}c(Jr,"validateContainer");function $s(t,e,n){return n.resolve(t,e,i=>i.readModels)?.node.properties??null}c($s,"viewProperties");function wu(t,e,n,i,r){let o=e.length===1?$s(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 Hr(s.condition))bs(a.left,a.location,o,n,i,r);vs(s.command,s.arguments,o,n,i,r)}t.otherwise?.command!=null&&vs(t.otherwise.command,t.otherwise.arguments,o,n,i,r),xs(t,r)}c(wu,"validateAction");function vs(t,e,n,i,r,o){let s=r.resolve(t,i,a=>a.commands)?.node;for(let a of e){let l=s?.properties.filter(m=>m.name===a.name);l?.length===0&&o.warning(d.UnknownActionArgumentProperty,`Command '${t}' has no argument property '${a.name}'`,a.location);let p=bs(a.binding,a.location,n,i,r,o,!0);l?.length===1&&p!==null&&l[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)}}c(vs,"validateArguments");function bs(t,e,n,i,r,o,s=!1){if(!t.startsWith("item.")||n===null)return null;let a=t.substring(5).split(".");for(let[l,p]of a.entries()){let m=n.filter(y=>y.name===p);if(m.length===0||m.length===1&&m[0].type.isCollection&&(!s||l<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(l===a.length-1)return m[0];let f=m[0].type;if(n=r.types.get(f.name)?.properties??$s(f.name,i,r),n===null)return(Au.has(f.name)||r.application.concepts.some(y=>y.name===f.name)&&!r.application.types.some(y=>y.name===f.name))&&o.warning(d.UnknownActionSubjectField,`Subject field '${t}' continues past scalar '${p}'`,e),null}return null}c(bs,"validateItemPath");function Hr(t){return t.kind==="ComparisonConditionSyntax"?[t]:[...Hr(t.left),...Hr(t.right)]}c(Hr,"comparisons");function Ii(t,e){let n=t.personas.map(r=>r.name),i=c(r=>{for(let o of r){i(o.features);for(let s of o.slices)for(let a of s.specifications){let l=a.givenCallerPersona;if(l!=null){let p=n.filter(m=>m===l.name).length;p!==1&&e.error(d.InvalidSpecificationCallerPersona,`${p===0?"Unknown":"Ambiguous"} persona '${l.name}' - declared personas: ${n.join(", ")}.`,l.location)}}}},"visit");for(let r of t.modules)i(r.features)}c(Ii,"validatePersonaCallers");function Et(t){return Array.from(t,e=>{if(e==="\u0131"||e==="\u017F")return e;let n=e.codePointAt(0);if(n>=8064&&n<=8071||n>=8080&&n<=8087||n>=8096&&n<=8103)return String.fromCodePoint(n+8);if(n===8115)return"\u1FBC";if(n===8131)return"\u1FCC";if(n===8179)return"\u1FFC";let i=e.toUpperCase();return Array.from(i).length===1?i:e}).join("")}c(Et,"ordinalIgnoreCaseKey");function Xr(t){let e=xn(t),n=c((h,v)=>h.map(x=>({syntax:x,rank:e.get(Ve([...v,x.name]))??Number.MAX_SAFE_INTEGER})).sort((x,S)=>x.rank-S.rank).map(x=>x.syntax),"ordered"),i=[],r=c((h,v)=>{let x=[...v,h.name];for(let S of n(h.slices,x))i.push({syntax:S,scope:[...x,S.name],identity:[...x.map(E=>`container:${E}`),`slice:${S.name}`],index:i.length});for(let S of n(h.features,x))r(S,x)},"feature");for(let h of n(t.modules,[]))for(let v of n(h.features,[h.name]))r(v,[h.name]);let o=new Map(i.map(h=>[h,new Set([...ae(h.syntax).map(v=>Et(v.name)),...h.syntax.commands.flatMap(v=>v.produces.map(x=>Et(x.event))),...h.syntax.reactions.flatMap(v=>v.triggers.flatMap(x=>x.produces.map(S=>Et(S.event))))])])),s=new Map;for(let h of i)for(let v of ae(h.syntax)){let x=Et(v.name);s.has(x)||s.set(x,h)}let a=new Map;for(let h of i){let v=Ve(h.scope);a.has(v)||a.set(v,h)}let l=new Map;for(let h of zt.for(t,e).edges.filter(v=>v.kind==="decidesFrom"))for(let v of h.evidence){let x=Ve([...h.consumer.scope,v.name.toLowerCase()]);l.has(x)||l.set(x,a.get(Ve(h.producer.scope)))}let p=[];for(let h of i){let v=new Set,x=pi(h.syntax).references.filter(S=>S.timeline).map(S=>({event:S.name,location:S.location,readModel:S.targetKind==="ReadModel"}));for(let S of x){let E=Et(S.event),g=`${S.readModel?"ReadModel":"Event"}:${E}`;if(v.has(g))continue;v.add(g);let P=S.readModel?l.get(Ve([...h.scope,S.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(S.readModel){let $=h.identity.slice(0,A+1),b=new Set(i.filter(k=>$.every((C,O)=>k.identity[O]===C)).flatMap(k=>[...o.get(k)]));if(Ja(P.syntax,S.event).some(k=>k.timeline&&k.kind==="usesFactsFrom"&&k.targetKind==="Event"&&b.has(Et(k.name))))continue}p.push({...S,consumer:h,producer:P,container:Ve(h.identity.slice(0,A)),left:h.identity[A],right:P.identity[A]})}}}let m=c((h,v)=>h.consumer.index-v.consumer.index||h.location.line-v.location.line||h.location.column-v.location.column,"compare"),f=new Set,y=[];for(let h of new Set(p.map(v=>v.container))){let v=p.filter(S=>S.container===h),x=new Map;for(let S of v)x.has(S.left)||x.set(S.left,new Set),x.has(S.right)||x.set(S.right,new Set),x.get(S.left).add(S.right);for(let S of vn(x).filter(E=>E.length>1)){let E=new Set(S),g=v.filter($=>E.has($.left)&&E.has($.right));g.forEach($=>f.add($));let P=g.filter($=>$.consumer.index<$.producer.index).sort(m)[0];if(P===void 0)continue;let A=c($=>Math.min(...g.flatMap(b=>[b.consumer,b.producer]).filter(b=>{let k=JSON.parse(h);return b.identity[k.length]===$}).map(b=>b.index)),"memberIndex");S.sort(($,b)=>A($)-A(b)),y.push({edge:P,diagnostic:{severity:"information",code:d.TimelineCycleGroup,message:`Timeline group ${S.map($=>`${$.startsWith("slice:")?"slice":h===Ve([])?"module":"feature"} '${$.slice($.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||f.has(h))continue;let v=h.consumer.scope.slice(0,-1),S=h.producer.scope.length>h.consumer.scope.length&&v.every((g,P)=>h.producer.scope[P]===g)?" 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.${S}`,location:h.location}})}return y.sort((h,v)=>m(h.edge,v.edge)).map(h=>h.diagnostic)}c(Xr,"timelineOrderDiagnostics");function it(t,e,n=kt,i=!0,r,o){let s=wt(t,!1,e),a=fi(s,e,o);a.scope=n,a.streamCandidates=r??_t.capture([s],n,o);let l=yi(a,s,n);if(i){ui(l,a),Vn(l,a),mi(l,a),Un(l,a);let p=Fe(l);Yn(p,a),vi(l,a),$i(l,a),bi(p,a),ki(l,a),Ei(l,a),wi(l,a),Oi(l,a),Ii(l,a),l=Qn(l,a),Gt.validate(l,a);for(let m of Wn(l))a.information(m.code,m.message,m.location);for(let m of Xr(l))a.information(m.code,m.message,m.location)}return{value:l,diagnostics:a.diagnostics,triggerData:a.triggerData,inputUses:a.inputUses,success:!a.diagnostics.some(p=>p.severity==="error")}}c(it,"parseForAuthoring");function uA(t){return t===d.LegacyOptionalSuffix||t===d.LegacyComplianceMarker||t===d.RedundantEventId}c(uA,"isQuickFixDiagnostic");function eo(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}c(eo,"legacyOptionalTypeLength");function mA(t,e={}){let n=it(t,void 0,e.placement);if(!n.success)return()=>[];let i=wt(t),r=new Map;new class extends yt{visitEvent(E){r.set(E.location.line,E)}}().visitApplication(n.value);let s=new Map,a=new Map,l=new Map,p;for(let E of i)p=r.get(E.number)??p,p!==void 0&&l.set(E.number,p);for(let E of n.diagnostics){s.set(E.code,(s.get(E.code)??0)+1);let g=i[E.location.line-1],P=eo(g.raw,E);if(P>0)a.set(g.number,{line:g.number,fix:{diagnosticCode:E.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:g.startOffset+E.location.column+P-2,length:1,text:" optional"}]}});else if(E.code===d.LegacyComplianceMarker){let A=Ou(g.raw,g.startOffset);A!==void 0&&a.set(g.number,{line:g.number,fix:{diagnosticCode:E.code,title:"Use bare pii and secret compliance markers",scope:"occurrence",edits:[A]}})}else if(E.code===d.RedundantEventId&&tn(g.raw)<0){let A=l.get(g.number);if(A?.id!==A?.name||A===void 0)continue;a.set(g.number,{line:g.number,fix:{diagnosticCode:E.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:g.startOffset,length:(i[g.number]?.startOffset??t.length)-g.startOffset,text:""}]},change:{node:A,replacement:{...A,id:null}}})}}let m=[d.LegacyOptionalSuffix,d.LegacyComplianceMarker],f=Cn(n),y=new Map,h,v=new Set,x=new Map,S=c((E,g)=>{let P=ks(t,E.edits);if(P===void 0)return;let A=it(P,void 0,e.placement);if(!(!A.success||Cn(A)!==(g===void 0?f:Cn(n,[g]))))return A.diagnostics.filter($=>$.code===E.diagnosticCode).length===(s.get(E.diagnosticCode)??0)-E.edits.length?E:void 0},"verify");return(E,g)=>{let P=typeof E=="number"||E===void 0?void 0:E,A=m.filter(O=>P===void 0?g===void 0||g===O:P.some(I=>I.diagnosticCode===O));for(let O of A.filter(I=>!v.has(I))){let I=[...a.values()].filter(R=>R.fix.diagnosticCode===O);if(I.length>0){let R=S({diagnosticCode:O,title:O===d.LegacyOptionalSuffix?"Use 'optional' throughout this document":"Use bare pii and secret throughout this document",scope:"document",edits:I.flatMap(j=>j.fix.edits)});R!==void 0&&x.set(O,R)}v.add(O)}let $=A.flatMap(O=>x.has(O)?[x.get(O)]:[]);if(P!==void 0){if(h===void 0){h=new Map;let I=i.flatMap(N=>a.has(N.number)?[a.get(N.number)]:[]),R=I.flatMap(N=>N.fix.edits),j=ks(t,R);if(R.length>0&&j!==void 0){let N=it(j,void 0,e.placement),B=I.flatMap(L=>L.change===void 0?[]:[L.change]);if(N.success&&Cn(N)===Cn(n,B)){let L=new Map,W=new Map;for(let V of N.diagnostics)L.set(V.code,(L.get(V.code)??0)+1);for(let V of I)W.set(V.fix.diagnosticCode,(W.get(V.fix.diagnosticCode)??0)+V.fix.edits.length);if([...W].every(([V,G])=>(L.get(V)??0)===(s.get(V)??0)-G))for(let V of I)h.set(V.line,V.fix)}}}let O=new Map;for(let I of P){let R=h.get(I.line);R?.diagnosticCode===I.diagnosticCode&&O.set(I.line,R)}return[...O.values(),...$]}let b=typeof E=="number"?E:void 0,k=b===void 0?void 0:a.get(b),C;return k!==void 0&&b!==void 0&&(g===void 0||k.fix.diagnosticCode===g)&&(y.has(b)||(y.size===32&&y.delete(y.keys().next().value),y.set(b,S(k.fix,k.change))),C=y.get(b)),[...C===void 0?[]:[C],...$]}}c(mA,"prepareQuickFixes");function Ou(t,e){let n=w("^(\\s*concept\\s+\\w+\\s*:\\s*\\w+)((?:[^\\S\\r\\n]+@?\\w+)*)").exec(t);if(n!==null){let r=n[2],o=r.replace(/@pii\b|@?sensitive\b/g,s=>s==="@pii"?"pii":"secret");return o===r?void 0:{start:e+n[1].length,length:r.length,text:o}}let i=w("^(\\s*)(@pii|@?sensitive)\\b").exec(t);return i===null?void 0:{start:e+i[1].length,length:i[2].length,text:i[2]==="@pii"?"pii":"secret"}}c(Ou,"complianceMarkerEdit");function Cn(t,e=[]){let n=new Map(e.map(i=>[i.node,i.replacement]));return JSON.stringify([t.value,t.triggerData],(i,r)=>["location","usesLocation","targetLocation"].includes(i)?void 0:n.get(r)??r)}c(Cn,"verificationShape");function ks(t,e){let n=[],i=0;for(let r of e){if(r.start<i||r.start<0||r.length<0||r.start+r.length>t.length)return;n.push(t.slice(i,r.start),r.text),i=r.start+r.length}return n.push(t.slice(i)),n.join("")}c(ks,"applyQuickFixEdits");var Zt=class{static{c(this,"EventSourceReadConfidence")}complete;sources=new Map;constructor(e,n){this.complete=n;for(let i of e)this.sources.set(i.source.name,[...this.sources.get(i.source.name)??[],i])}static hasUnknownExtent(e){return e.some(n=>n.severity==="error"&&["PLAY0001","PLAY0503","PLAY0164"].includes(n.code))}resolve(e,n){let i=this.sources.get(e)??[],r=n===void 0?[]:i.flatMap(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",l=[];return i.length>1&&l.push("Multiple physical parent sources claim the exact name."),r.length>1&&l.push("Multiple physical streams claim the exact parent and local name."),i.some(p=>!p.placementResolved)&&l.push("A physical parent has unresolved import placement."),this.complete||l.push("Physical source extent or placement is incomplete; missing declarations cannot be excluded."),{state:a,sources:i.map(p=>p.source),streams:r,reasons:l}}};var Iu=ge("^[A-Za-z_]\\w*$"),Je=c((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),K=c(t=>{throw new le(t)},"refuse"),ht=c((t,e,n)=>{if(!Array.isArray(t))return K(n);for(let i=0;i<t.length;i++)Je(t[i],e)||K(n)},"collection");function Kt(t){if(t.kind==="ConceptSyntax"){let e=t;for(let n of e.validations??[])n.kind==="DeclarativeValidateSyntax"&&n.rules.some(i=>i.implementation!=null)&&K("Implementation wrappers on named rules are supported only on commands.")}if(t.kind==="ValidationRuleSyntax"){let e=t;e.implementation!=null&&(Je(e.implementation,"ImplementationSyntax")||K("A named rule requires an ImplementationSyntax wrapper."),(e.rule!=="Rule"||e.value?.kind!=="PathExpressionSyntax"||!Je(e.value,"PathExpressionSyntax")||typeof e.value.path!="string"||Iu.exec(e.value.path)?.[0]!==e.value.path)&&K("An implementation wrapper requires a valid named rule."),e.file!=null&&e.code!=null&&K("A named rule has at most one file or inline payload."),e.file!=null&&(!Je(e.file,"FileReferenceSyntax")||typeof e.file.path!="string")&&K("A named rule file requires a FileReferenceSyntax payload with a string path."),e.code!=null&&(!Je(e.code,"CodeBlockSyntax")||typeof e.code.language!="string"||typeof e.code.code!="string")&&K("A named rule inline payload requires a CodeBlockSyntax with string language and code."),Kt(e.implementation))}if(t.kind==="ProducesSyntax"){let e=t,n=e.inlineOperation;if(n!=null){e.inlineEvent!=null&&K("A production cannot declare both an event and an operation."),(e.when!=null||e.event!==n.name||e.for!=null||(e.tags??[]).length>0)&&K("An inline operation requires a matching unconditional target without event metadata."),ht(n.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),ht(e.mappings,"PropertyMappingSyntax","Production mappings must be a collection of mappings."),n.inputs.length!==e.mappings.length&&K("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&&K("Inline operation inputs and mappings must correspond in order.")}}if(t.kind==="OperationPhaseSyntax"){let e=t;e.file!=null&&e.code!=null&&K("An operation phase has at most one file or inline payload."),e.implementation!=null&&Kt(e.implementation)}if(t.kind==="HandlerSyntax"){let e=t;e.implementation!=null&&e.file!=null&&e.code!=null&&K("A handler has at most one file or inline payload.")}if(t.kind==="ImplementationSyntax"){let e=t;ht(e.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let n=0;n<e.hints.length;n++)Kt(e.hints[n])}if(t.kind==="ImplementationHintSyntax"){let e=t;(typeof e.text!="string"||Hn(e.text))&&K("An implementation hint must be nonblank.")}to(t)}c(Kt,"validateSyntaxInvariants");function to(t){let e=c(i=>{ur(i)||K("Event source and stream names must be identifiers.")},"name"),n=c((i,r)=>{ht(r,"PropertyMappingSyntax","Stream id part mappings must be a collection."),i!==null&&r.length>0&&K("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&&ht(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()==="")&&K("A rename pin must be nonempty.");let r=i.kind==="EventSourceSyntax"?i.identifier:i.streamId;r!==null&&!Je(r,"TypeRefSyntax")&&K("Source identifiers and stream ids require type reference nodes."),r!==null&&(r.isCollection||r.isOptional)&&K("Source identifiers and stream ids require nonoptional scalar type references."),r!==null&&!Kn(r.name)&&K("Source identifiers and stream ids require an exact type reference name."),i.kind==="EventSourceSyntax"?ht(i.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements."):(ht(i.streamIdParts,"EventStreamIdPartSyntax","Stream id parts must be a collection."),i.streamId!==null&&i.streamIdParts.length>0&&K("A stream cannot declare both scalar and composite stream ids."),i.streamIdParts.forEach(o=>to(o)))}if(t.kind==="EventStreamIdPartSyntax"){let i=t;e(i.name),Je(i.type,"TypeRefSyntax")||K("A stream id part requires a type."),(i.type.isOptional||i.type.isCollection)&&K("Source identifiers and stream ids require nonoptional scalar type references."),Kn(i.type.name)||K("Source identifiers and stream ids require an exact type reference name.")}if(t.kind==="CommandSyntax"){let i=t;i.stream?.propertyCandidate!=null&&K("The authoritative command stream cannot contain an ambiguous property candidate."),i.stream!=null&&!Je(i.stream,"CommandStreamSyntax")&&K("The authoritative command stream must be a command stream node."),i.streamCandidates!==void 0&&ht(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(to(s),s.propertyCandidate===null&&i.stream==null&&K("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&&K("An ambiguous property is owned only by its stream candidate.")}}if(t.kind==="SpecificationEventSyntax"||t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax"){let i=t;i.stream!=null&&i.noStream!=null&&K("An event occurrence cannot declare both stream and no stream."),i.stream!=null&&!Je(i.stream,"SpecificationStreamSyntax")&&K("A specification stream requires a specification stream node."),i.noStream!=null&&!Je(i.noStream,"SpecificationNoStreamSyntax")&&K("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"&&K("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"&&K("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)&&K("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}c(to,"validateSourceStream");var ot={kinds:["AddMappingSyntax","AllSyntax","ApplicationSyntax","ApplicationTriggerInteractionTriggerSyntax","ArrangementContainerSyntax","ArrangementOverrideSyntax","ArrangementSlotSyntax","ArrangementSyntax","AuthenticatedConditionSyntax","AuthenticationProviderSyntax","AuthenticationSyntax","AuthorizeSyntax","BehaviorArgumentSyntax","BehaviorParameterSyntax","BehaviorSyntax","BuiltInInteractionTriggerSyntax","CaptureAppendSyntax","CaptureChildrenSyntax","CaptureMapEntrySyntax","CaptureNestedSyntax","CaptureSourceSettingSyntax","CaptureSourceSyntax","CaptureSplitSyntax","CaptureSyntax","CaptureTranslationSyntax","CaptureWhenSyntax","CausedByExpressionSyntax","CaseValueExpressionSyntax","ChildrenSyntax","ClaimConditionSyntax","ClearMappingSyntax","ClearWithSyntax","CloseDialogActionSyntax","CodeBlockSyntax","ComponentExposedValueSyntax","ComponentOutletSyntax","ComponentPropertySyntax","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","FormColumnSyntax","FormFieldSyntax","FormPopulateFromItemSyntax","FormPopulateViaQuerySyntax","FormSyntax","FromSyntax","HandlerSyntax","ImplementationSyntax","ImplementationHintSyntax","SystemSyntax","OperationSyntax","OperationPhaseSyntax","SpecificationExampleSyntax","SpecificationParameterSyntax","SpecificationCaseSyntax","SpecificationOperationFailureSyntax","SpecificationOperationSyntax","SpecificationCompensatedSyntax","ImportSyntax","IncrementMappingSyntax","InteractionAlternativeSyntax","InteractionOtherwiseSyntax","InteractionArgumentSyntax","InteractionBindingSyntax","IntervalInteractionTriggerSyntax","IntervalTriggerSourceSyntax","InvokesSyntax","InvocationRefusalSyntax","JoinEventSyntax","JoinSyntax","KeyPartSyntax","LayoutSyntax","ListExpressionSyntax","LiteralExpressionSyntax","LogicalConditionSyntax","LogicalPolicyConditionSyntax","LogicalPolicyRequirementSyntax","ModuleSyntax","NamedTriggerSourceSyntax","NavigateActionSyntax","NavigateBackActionSyntax","NestedSyntax","NotPolicyConditionSyntax","NotifyActionSyntax","OpenDialogActionSyntax","ObjectExpressionSyntax","ObjectMemberSyntax","PathExpressionSyntax","PerformerSyntax","PersonaSyntax","PlaceSyntax","PolicyReferenceSyntax","PolicySyntax","ProducesSyntax","ProjectionEntersOnSyntax","ProjectionSyntax","ProjectionVariantSyntax","PresentationValueSyntax","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","ScreenNavigationParameterSyntax","ScreenGuardedActionSyntax","ScreenActionAlternativeSyntax","ScreenActionOtherwiseSyntax","ScreenBehaviorSyntax","ScreenCodeSyntax","ScreenComponentSyntax","ScreenColumnSyntax","ScreenDataSyntax","ScreenFieldSyntax","ScreenNavigateSyntax","ScreenSectionSyntax","ScreenSlotSyntax","ScreenSummarySyntax","ScreenSyntax","ScreenTableSyntax","ScreenTemplateReferenceSyntax","ScreenTemplateSyntax","ScreenTitleSyntax","ScreenToolbarSyntax","ScreenUsesBehaviorSyntax","SeedEventSyntax","SeedGroupSyntax","SeedSyntax","SetMappingSyntax","TemplateAssignmentSyntax","TemplateExposedValueSyntax","TemplateOutletSyntax","SetStateActionSyntax","SliceSyntax","SlotSyntax","SourceItemExpressionSyntax","SpecificationAbsentReadModelSyntax","SpecificationCallerClaimSyntax","SpecificationCallerPersonaSyntax","SpecificationCallerSyntax","SpecificationCaptureSyntax","SpecificationClockSyntax","SpecificationCommandSyntax","SpecificationDeniedSyntax","SpecificationErrorSyntax","SpecificationEventSyntax","SpecificationNoResultSyntax","SpecificationStreamSyntax","SpecificationNoStreamSyntax","SpecificationQueryResultSyntax","SpecificationQuerySyntax","SpecificationReadModelSyntax","SpecificationRedeliverySyntax","SpecificationSyntax","SpecificationTriggerSyntax","SpecificationWhenQuerySyntax","StringsExpressionSyntax","SubtractMappingSyntax","TagSyntax","ToolbarItemSyntax","TemplateExpressionSyntax","TemplateInterpolationSyntax","TemplateTextSyntax","ThemeSyntax","TriggerDataSyntax","TriggerSyntax","TypeRefSyntax","TypeSyntax","UiBindingSyntax","UiProfileSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","DependsOnSyntax","UsesBehaviorSyntax","ValidationRuleSyntax","VariantSyntax"],names:["property","value","autoMap","mappings","authentication","behaviors","concepts","domain","eventSources","examples","fileImports","imports","layouts","modules","personas","policies","seeds","sourceOptions","numericMode","systems","templates","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","parameter","blocks","claim","matches","matchesSubject","arguments","onFailure","onResult","onSuccess","code","language","binding","directives","authorize","concurrency","documentation","handler","produces","reads","response","stream","streamCandidates","validations","eventSource","propertyCandidate","streamId","streamIdParts","left","operator","right","parts","criminal","reason","scope","specialCategory","attributes","values","eventSourceType","eventStreamId","eventStreamType","eventTypes","message","messageIsLiteral","path","contributionPoint","label","navigate","requirements","rules","arrangement","category","exposes","outlets","slots","templateType","usedBehaviors","eventName","id","identifier","streams","generation","hasGenerationMarker","includeChildren","command","contributions","dependsOn","features","isPlacement","slices","additionalRules","ignoreCasing","releasedBy","pattern","composeUsing","by","query","columnMode","columns","fields","for","onSubmit","populate","events","parentKey","implementation","hints","text","compensate","execute","inputs","uses","generatedValues","noStream","operation","qualifiedName","actions","condition","alternatives","otherwise","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","isSubject","filters","isObservable","performer","returnType","where","data","invokes","member","severity","role","dayOfMonth","dayOfWeek","time","outcome","behavior","component","context","icon","presentation","route","target","rowClick","fitsSlot","eventSourceId","groups","captures","commands","constraints","operations","projections","queries","reactions","readModels","reducers","screens","specifications","contributes","authenticated","claims","roles","capture","record","instant","commandType","inlineProperty","caseValue","eventType","exactly","results","reaction","cases","given","givenCaller","givenCallerPersona","givenCaptures","givenClock","givenOperationFailures","givenReadModels","thenAbsentReadModels","thenCompensated","thenDenied","thenErrors","thenEvents","thenEventsInAnyOrder","thenNoEvents","thenNoResult","thenOperations","thenQueries","thenReadModels","thenResults","thenReturns","whenAppended","whenCapture","whenClock","whenQuery","whenRedelivered","whenTrigger","compatibleWith","isCollection","isOptional","bindingKind","componentId","componentPropertyPath","expectedValueType","nullBehavior","rawText","defaultSizeClass","icons","layout","packages","platforms","theme","additionalProperties","rule","places"],rules:[["string"],["ref",26,27,46,53,54,56,101,102,114,116,138,141,184,205,209],["object",[[0,0,!0],[1,1,!0]]],["enum","Inherit","Disabled","Enabled"],["ref",0,30,48,50,88,177,206],["array",4],["object",[[2,3,!0],[3,5,!1]]],["ref",10],["null"],["union",7,8],["ref",14],["array",10],["ref",43],["array",12],["ref",52],["union",14,8],["ref",57],["array",16],["ref",81],["array",18],["ref",67],["array",20],["ref",87],["array",22],["ref",100],["array",24],["union",25,8],["ref",106],["array",27],["ref",118],["array",29],["union",30,8],["ref",121],["array",32],["ref",176],["array",34],["union",35,8],["enum","legacy","exact"],["object",[[18,37,!0]]],["ref",78],["array",39],["ref",178],["array",41],["ref",212],["array",43],["union",44,8],["ref",214],["array",46],["union",47,8],["ref",216],["array",49],["union",50,8],["ref",218],["array",52],["union",53,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,42,!1],[21,45,!1],[22,48,!1],[23,51,!1],[24,54,!1]]],["object",[[25,0,!0]]],["ref",4,6],["array",57],["integer",-2147483648,2147483647],["union",59,8],["enum","Flat","Row","Column","Grid"],["object",[[26,58,!1],[27,60,!1],[28,61,!0]]],["union",0,8],["object",[[29,63,!1],[30,57,!0],[31,63,!1]]],["boolean"],["object",[[32,65,!1],[29,60,!1],[33,0,!0],[34,60,!1],[31,60,!1]]],["enum","Flow","Freeform"],["ref",5],["array",68],["union",69,8],["union",57,8],["ref",224],["array",72],["union",73,8],["object",[[35,67,!0],[36,70,!1],[30,71,!1],[37,74,!1]]],["object",[]],["object",[[38,63,!1],[33,0,!0]]],["ref",9],["array",78],["object",[[39,79,!1]]],["ref",105,120],["object",[[40,81,!0]]],["object",[[33,0,!0],[1,0,!0]]],["ref",215],["union",84,8],["object",[[33,0,!0],[41,85,!1]]],["ref",92],["array",87],["ref",68],["union",89,8],["ref",13],["array",91],["object",[[42,88,!1],[43,63,!1],[44,90,!1],[33,63,!1],[45,60,!1],[46,92,!1]]],["enum","Click","DoubleClick","Select","Submit","Change","Load","Unload","Enter","Leave","Unknown"],["object",[[28,94,!0]]],["ref",127],["array",96],["ref",207],["array",98],["union",99,8],["ref",25],["union",101,8],["object",[[47,0,!0],[3,97,!1],[48,100,!1],[49,102,!1]]],["ref",16],["array",104],["ref",18,22],["array",106],["object",[[50,105,!1],[51,0,!0],[52,107,!1],[0,0,!0]]],["ref",24],["array",109],["object",[[0,0,!0],[53,1,!0],[54,110,!1]]],["object",[[50,105,!1],[52,107,!1],[0,0,!0]]],["ref",20],["array",113],["object",[[55,114,!1],[28,0,!0]]],["array",0],["object",[[56,0,!0],[53,1,!0],[57,116,!1]]],["ref",17],["array",118],["ref",19],["array",120],["ref",21],["union",122,8],["object",[[50,105,!1],[26,119,!1],[58,63,!1],[52,107,!1],[33,0,!0],[59,121,!1],[53,123,!1],[17,38,!1]]],["object",[[60,0,!0],[61,0,!0]]],["enum","PropertyChanged","Added","Removed","Changed","LogicalOr","LogicalAnd","ValueTransition","Expression"],["object",[[62,63,!1],[63,63,!1],[64,116,!1],[28,126,!0],[65,63,!1]]],["object",[[0,63,!1]]],["object",[[66,0,!0]]],["ref",1,28,31,62,74,98,110,125,147,148],["array",130],["object",[[2,3,!0],[67,131,!1],[51,1,!0],[0,0,!0]]],["union",1,8],["object",[[68,0,!0],[69,133,!1],[70,65,!0]]],["object",[[0,0,!0]]],["object",[[47,0,!0]]],["ref",91],["array",137],["ref",32,45,63,108,109,112,113,137,146,181],["array",139],["object",[[71,138,!1],[72,140,!1],[73,140,!1],[74,140,!1]]],["object",[[75,0,!0],[76,0,!0]]],["ref",217],["object",[[77,143,!0],[33,0,!0]]],["ref",152,154,157,158,159,161,163,164,165,166,168,169,171,172,173],["array",145],["object",[[78,146,!1],[33,0,!0]]],["union",143,8],["object",[[77,148,!1],[0,0,!0],[1,63,!1]]],["ref",33],["object",[[75,150,!0]]],["ref",11],["union",152,8],["ref",44],["union",154,8],["ref",75],["union",156,8],["ref",122],["array",158],["ref",128],["array",160],["ref",143],["array",162],["union",163,8],["ref",131,132],["union",165,8],["ref",39],["union",167,8],["array",167],["ref",37,49],["array",170],["object",[[79,153,!1],[80,155,!1],[43,63,!1],[81,63,!1],[82,157,!1],[33,0,!0],[83,159,!1],[64,161,!1],[84,164,!1],[85,166,!1],[86,168,!1],[87,169,!1],[88,171,!1]]],["union",160,8],["union",96,8],["object",[[89,0,!0],[90,173,!1],[86,0,!0],[91,174,!1],[92,97,!1]]],["enum","Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Contains","StartsWith"],["object",[[93,0,!0],[94,176,!0],[95,1,!0]]],["ref",99],["array",178],["object",[[96,179,!1],[41,0,!0]]],["object",[[97,65,!1],[33,0,!0],[98,63,!1],[99,63,!1],[100,63,!1]]],["ref",42],["array",182],["union",171,8],["object",[[101,183,!1],[44,90,!1],[33,0,!0],[41,0,!0],[88,184,!1],[102,116,!1]]],["object",[[89,65,!0],[103,63,!1],[104,63,!1],[105,63,!1],[106,116,!1]]],["object",[[71,138,!1],[107,0,!0],[108,65,!0],[72,140,!1],[73,140,!1],[74,140,!1]]],["object",[[109,0,!0]]],["ref",163],["union",189,8],["object",[[110,0,!0],[111,63,!1],[112,190,!1],[45,60,!1]]],["ref",149],["array",192],["union",193,8],["ref",223],["array",195],["object",[[113,194,!1],[114,196,!1]]],["ref",7],["union",198,8],["ref",179],["array",200],["ref",180],["array",202],["ref",183],["array",204],["ref",222],["array",206],["object",[[115,199,!1],[5,11,!1],[116,63,!1],[117,201,!1],[33,0,!0],[118,203,!1],[119,205,!1],[120,63,!1],[121,207,!1]]],["object",[[33,0,!0]]],["object",[[122,0,!0]]],["ref",59],["array",211],["object",[[43,63,!1],[123,63,!1],[124,85,!1],[33,0,!0],[125,212,!1]]],["object",[[33,0,!0],[41,84,!0]]],["ref",58],["array",215],["object",[[43,63,!1],[123,63,!1],[33,0,!0],[91,85,!1],[92,216,!1]]],["object",[[47,0,!0],[58,133,!1]]],["integer",0,4294967295],["object",[[43,63,!1],[81,63,!1],[44,90,!1],[126,219,!1],[127,65,!1],[123,63,!1],[33,0,!0],[64,161,!1],[48,100,!1]]],["object",[[2,3,!0],[128,65,!0],[3,5,!1]]],["object",[[71,138,!1],[129,0,!0],[72,140,!1],[73,140,!1],[74,140,!1]]],["object",[[62,1,!0]]],["ref",47],["array",224],["union",225,8],["ref",221],["array",227],["ref",65],["array",229],["ref",182],["array",231],["object",[[79,153,!1],[5,11,!1],[130,226,!1],[131,228,!1],[43,63,!1],[81,63,!1],[9,19,!1],[132,230,!1],[10,21,!1],[133,65,!0],[33,0,!0],[134,232,!1],[20,42,!1],[121,207,!1]]],["ref",66,219,220],["array",234],["object",[[135,235,!1],[44,89,!0],[136,65,!0],[107,63,!1],[33,0,!0],[137,116,!1]]],["object",[[138,0,!0]]],["object",[[111,63,!1],[0,0,!0]]],["object",[[139,63,!1],[60,63,!1],[111,63,!1],[0,0,!0]]],["object",[[140,63,!1],[141,0,!0]]],["enum","Unspecified","Auto","Manual"],["ref",69],["array",242],["ref",70],["array",244],["ref",71,72],["union",246,8],["object",[[5,11,!1],[142,241,!0],[143,243,!1],[144,245,!1],[145,0,!0],[33,0,!0],[146,190,!1],[147,247,!1],[121,207,!1]]],["ref",60],["array",249],["ref",41,64],["union",251,8],["object",[[148,250,!1],[58,252,!1],[3,5,!1],[149,133,!1]]],["union",150,8],["ref",76],["union",255,8],["object",[[75,254,!1],[44,90,!1],[150,256,!1]]],["ref",77],["array",258],["object",[[151,259,!1]]],["object",[[152,0,!0]]],["object",[[43,63,!1],[33,0,!0]]],["ref",80],["union",263,8],["object",[[153,264,!1],[43,63,!1],[154,264,!1],[155,161,!1],[33,0,!0],[156,0,!0]]],["object",[[75,254,!1],[43,63,!1],[44,90,!1],[150,256,!1]]],["ref",197],["union",267,8],["ref",196],["union",269,8],["object",[[43,63,!1],[145,133,!1],[157,97,!1],[33,0,!0],[158,268,!1],[86,270,!1],[41,0,!0],[102,97,!1]]],["object",[[33,0,!0],[102,97,!1]]],["object",[[159,0,!0]]],["object",[[159,0,!0],[102,97,!1]]],["object",[[160,0,!0]]],["ref",40,103],["object",[[161,140,!1],[162,276,!0]]],["object",[[161,140,!1]]],["object",[[77,0,!0],[33,0,!0]]],["ref",89],["array",280],["ref",90],["union",282,8],["ref",3,15,55,93],["object",[[161,140,!1],[163,281,!1],[162,63,!1],[164,283,!1],[165,284,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[166,59,!0],[167,286,!0]]],["ref",96],["array",288],["object",[[129,0,!0],[3,97,!1],[168,289,!1]]],["object",[[169,65,!0],[170,63,!1],[83,159,!1],[171,0,!0]]],["object",[[2,3,!0],[47,0,!0],[3,5,!1]]],["ref",97],["array",293],["object",[[148,294,!1],[172,0,!0],[0,0,!0]]],["object",[[62,1,!0],[0,0,!0]]],["array",1],["object",[[173,297,!1]]],["union",0,65,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[174,301,!0],[1,302,!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",[[174,304,!0],[1,305,!0]]],["union",299,300,303,306],["object",[[1,307,!1]]],["enum","And","Or"],["object",[[93,276,!0],[94,309,!0],[95,276,!0]]],["ref",8,29,104,111,150],["object",[[93,311,!0],[94,309,!0],[95,311,!0]]],["object",[[93,81,!0],[94,309,!0],[95,81,!0]]],["ref",51],["array",314],["union",315,8],["ref",73],["array",317],["union",318,8],["ref",170],["array",320],["object",[[79,153,!1],[5,11,!1],[130,226,!1],[131,228,!1],[43,63,!1],[175,316,!1],[81,63,!1],[9,19,!1],[132,230,!1],[10,21,!1],[176,319,!1],[133,65,!0],[33,0,!0],[177,321,!1],[20,42,!1],[121,207,!1]]],["object",[[71,138,!1],[72,140,!1],[73,140,!1],[74,140,!1],[178,0,!0]]],["object",[[2,3,!0],[67,131,!1],[0,0,!0]]],["object",[[179,311,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[71,138,!1],[180,326,!0],[107,0,!0],[108,65,!0],[72,140,!1],[73,140,!1],[74,140,!1]]],["object",[[71,138,!1],[181,0,!0],[72,140,!1],[73,140,!1],[74,140,!1]]],["ref",115],["array",329],["object",[[182,330,!1]]],["object",[[33,0,!0],[1,1,!0]]],["object",[[75,254,!1],[44,90,!1]]],["object",[[43,63,!1],[33,0,!0],[15,116,!1]]],["object",[[183,65,!1],[184,63,!1],[185,63,!1],[186,0,!0],[187,60,!1],[188,60,!1]]],["union",311,8],["object",[[75,254,!1],[162,336,!1],[44,90,!1],[33,0,!0]]],["ref",61],["union",338,8],["ref",79],["union",340,8],["union",276,8],["object",[[47,0,!0],[145,133,!1],[189,339,!1],[190,341,!1],[3,97,!1],[48,100,!1],[49,342,!1]]],["object",[[2,3,!0],[67,131,!1],[44,90,!1],[58,252,!1],[33,0,!0],[191,63,!1],[192,63,!1],[17,38,!1]]],["ref",123],["array",345],["object",[[67,131,!1],[193,346,!1],[33,0,!0]]],["object",[[0,0,!0],[53,1,!0]]],["object",[[194,65,!1],[195,65,!1],[196,65,!1],[33,0,!0],[41,84,!0]]],["ref",129],["object",[[33,0,!0],[53,350,!0],[41,85,!1]]],["object",[[53,350,!0]]],["ref",130],["array",353],["object",[[144,354,!1]]],["object",[[1,1,!0]]],["object",[[144,97,!1]]],["object",[[33,0,!0],[53,133,!1],[41,84,!0]]],["ref",135],["union",359,8],["array",359],["ref",117],["union",362,8],["object",[[79,153,!1],[140,360,!1],[43,63,!1],[197,361,!1],[198,65,!1],[33,0,!0],[199,363,!1],[200,84,!0],[99,63,!1]]],["object",[[71,138,!1],[72,140,!1],[73,140,!1],[74,140,!1],[165,0,!0]]],["ref",140],["array",366],["object",[[43,63,!1],[81,63,!1],[33,0,!0],[22,367,!1],[201,342,!1]]],["ref",213],["array",369],["ref",95],["array",371],["union",372,8],["union",159,8],["ref",94,107,151],["object",[[75,254,!1],[202,370,!1],[43,63,!1],[44,90,!1],[203,373,!1],[83,374,!1],[84,164,!1],[53,375,!0]]],["object",[[204,0,!0]]],["object",[[43,63,!1],[81,63,!1],[44,90,!1],[33,0,!0],[64,161,!1]]],["object",[[38,63,!1],[140,63,!1],[191,0,!0]]],["object",[[75,254,!1],[43,63,!1],[47,0,!0],[44,90,!1]]],["ref",144],["array",381],["object",[[43,63,!1],[33,0,!0],[191,0,!0],[114,382,!1]]],["object",[[71,138,!1],[72,140,!1],[73,140,!1],[74,140,!1],[141,0,!0]]],["object",[[47,0,!0],[58,133,!1],[149,133,!1]]],["enum","Error","Information","Warning"],["object",[[162,276,!0],[107,63,!1],[205,386,!0]]],["object",[[206,0,!0]]],["enum","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["union",389,8],["string","^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]{1,7})?$"],["object",[[207,60,!1],[208,390,!1],[209,391,!0]]],["object",[[129,0,!0],[111,63,!1],[112,190,!1]]],["ref",155],["array",394],["ref",156],["union",396,8],["object",[[163,395,!1],[111,0,!0],[112,190,!1],[164,397,!1]]],["object",[[71,138,!1],[129,0,!0],[162,276,!0]]],["enum","Hidden","Execute","Unknown"],["object",[[71,138,!1],[129,63,!1],[210,400,!0]]],["object",[[211,10,!0]]],["ref",34],["array",403],["ref",35],["array",405],["ref",126],["array",407],["ref",36],["array",409],["object",[[5,11,!1],[212,0,!0],[213,148,!1],[117,404,!1],[214,63,!1],[33,0,!0],[118,406,!1],[215,408,!1],[64,410,!1],[121,207,!1]]],["object",[[140,63,!1],[141,0,!0],[41,84,!0]]],["object",[[111,0,!0],[0,0,!0]]],["ref",153],["array",414],["object",[[140,63,!1],[46,415,!1],[216,63,!1],[178,0,!0]]],["ref",162],["array",417],["object",[[144,418,!1],[217,0,!0]]],["object",[[78,146,!1],[44,90,!1],[33,0,!0]]],["ref",160],["array",421],["object",[[5,11,!1],[143,422,!1],[218,190,!1],[217,0,!0],[121,207,!1]]],["ref",165],["array",424],["object",[[33,0,!0],[119,425,!1]]],["object",[[115,199,!1],[5,11,!1],[116,63,!1],[117,201,!1],[219,63,!1],[33,0,!0],[118,203,!1],[119,205,!1],[120,63,!1],[121,207,!1]]],["ref",208],["array",428],["object",[[173,429,!1],[33,0,!0]]],["object",[[156,206,!0]]],["object",[[47,0,!0],[64,97,!1]]],["ref",174],["array",433],["object",[[220,0,!0],[148,434,!1]]],["ref",175],["array",436],["object",[[221,437,!1]]],["object",[[71,138,!1],[72,140,!1],[73,140,!1],[74,140,!1],[217,0,!0],[1,0,!0]]],["ref",23],["array",440],["ref",38],["array",442],["array",338],["array",340],["ref",124],["array",446],["ref",136],["array",448],["ref",139],["array",450],["ref",142],["array",452],["union",453,8],["ref",145],["array",455],["union",456,8],["ref",167],["array",458],["ref",202],["array",460],["enum","StateChange","StateView","Automation","Translate"],["object",[[222,441,!1],[223,443,!1],[224,235,!1],[43,63,!1],[81,63,!1],[148,444,!1],[9,19,!1],[44,90,!1],[33,0,!0],[225,445,!1],[226,447,!1],[227,449,!1],[228,451,!1],[229,454,!1],[230,457,!1],[231,459,!1],[232,461,!1],[20,42,!1],[41,462,!0]]],["object",[[233,63,!1],[33,0,!0]]],["object",[[58,1,!0],[33,0,!0]]],["object",[[41,0,!0],[1,0,!0]]],["ref",186],["array",467],["object",[[234,65,!0],[235,468,!1],[236,116,!1]]],["object",[[237,0,!0],[238,97,!1]]],["object",[[239,0,!0]]],["object",[[240,0,!0],[145,133,!1],[157,97,!1],[241,63,!1],[102,97,!1]]],["ref",27],["union",473,8],["object",[[242,474,!1],[33,63,!1]]],["object",[[243,0,!0],[145,133,!1],[241,63,!1],[158,268,!1],[86,270,!1],[102,97,!1]]],["object",[[89,0,!0],[86,0,!0],[91,174,!1],[92,97,!1]]],["object",[[244,65,!0],[64,97,!1]]],["ref",198],["array",479],["object",[[71,97,!1],[244,65,!0],[141,0,!0],[245,480,!1]]],["object",[[244,65,!0],[241,63,!1],[33,0,!0],[64,97,!1]]],["object",[[243,0,!0],[145,133,!1],[158,268,!1],[246,0,!0],[86,270,!1],[102,97,!1]]],["ref",83],["array",484],["ref",194],["array",486],["ref",188],["union",488,8],["ref",187],["union",490,8],["ref",189],["array",492],["ref",190],["union",494,8],["ref",84],["array",496],["ref",200],["array",498],["union",499,8],["ref",82],["array",501],["ref",185],["array",503],["ref",86],["array",505],["ref",192],["union",507,8],["ref",193],["array",509],["ref",195],["union",511,8],["ref",85],["array",513],["ref",199],["array",515],["ref",133,134],["union",517,8],["ref",191],["union",519,8],["union",486,8],["union",492,8],["ref",204],["union",523,8],["ref",201],["union",525,8],["ref",203],["union",527,8],["object",[[247,485,!1],[43,63,!1],[9,19,!1],[44,90,!1],[248,487,!1],[249,489,!1],[250,491,!1],[251,493,!1],[252,495,!1],[253,497,!1],[254,500,!1],[33,0,!0],[46,502,!1],[17,38,!1],[255,504,!1],[256,506,!1],[257,508,!1],[258,510,!1],[259,487,!1],[260,65,!0],[261,65,!1],[262,512,!1],[263,514,!1],[264,516,!1],[265,500,!1],[266,480,!1],[267,518,!1],[49,520,!1],[268,521,!1],[269,522,!1],[270,495,!1],[271,524,!1],[272,526,!1],[273,528,!1]]],["object",[[165,0,!0],[102,97,!1]]],["object",[[71,97,!1],[141,0,!0]]],["object",[[58,0,!0]]],["enum","Unknown","Action","Navigate","Dialog"],["object",[[214,63,!1],[111,63,!1],[33,0,!0],[46,415,!1],[215,408,!1],[28,533,!0],[217,0,!0]]],["ref",210,211],["array",535],["object",[[96,536,!1]]],["object",[[274,116,!1],[33,0,!0]]],["object",[[202,370,!1],[43,63,!1],[44,90,!1],[33,0,!0]]],["object",[[275,65,!0],[276,65,!0],[33,0,!0]]],["object",[[43,63,!1],[44,90,!1],[33,0,!0],[64,161,!1]]],["enum","Invalid","DataContext","QueryResult","ComponentProperty"],["enum","OneWay","TwoWay"],["union",543,8],["enum","Propagate","Clear","Preserve"],["union",545,8],["object",[[277,542,!0],[278,63,!1],[279,63,!1],[280,63,!1],[35,544,!1],[281,546,!1],[109,0,!0],[141,63,!1],[282,63,!1]]],["object",[[283,63,!1],[284,116,!1],[285,63,!1],[33,0,!0],[286,116,!1],[287,116,!1],[288,63,!1]]],["object",[[135,235,!1],[47,0,!0],[136,65,!0],[107,63,!1],[33,0,!0],[137,116,!1]]],["object",[[289,116,!1],[135,235,!1],[47,0,!0],[136,65,!0],[107,63,!1],[33,0,!0],[0,0,!0],[137,116,!1]]],["object",[[217,0,!0]]],["ref",12],["array",552],["object",[[71,553,!1],[211,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[75,254,!1],[44,90,!1],[150,256,!1],[107,63,!1],[0,0,!0],[290,555,!0],[205,386,!0],[1,133,!1]]],["ref",119],["array",557],["object",[[29,0,!0],[291,558,!1],[31,0,!0]]]],contracts:[2,6,55,56,62,64,66,75,76,77,80,82,83,86,93,95,103,108,111,112,83,115,117,124,125,127,128,129,132,134,135,136,141,142,144,147,149,151,172,175,177,180,181,185,186,187,188,191,135,197,135,208,209,209,188,210,76,213,214,217,218,220,221,222,223,233,236,237,188,238,239,76,240,248,253,257,260,261,262,265,266,271,214,272,273,274,273,275,135,277,278,279,285,287,287,290,291,292,295,296,208,298,308,310,312,313,322,209,323,141,324,325,327,328,331,332,188,333,334,335,209,337,343,218,344,347,83,348,349,135,351,352,355,356,357,358,364,365,261,368,376,377,378,379,380,383,384,218,385,387,388,392,393,144,398,399,401,402,151,411,238,412,413,416,147,147,419,420,423,426,427,261,430,431,432,435,438,348,209,86,209,439,463,464,188,465,466,209,469,470,471,472,76,475,476,76,477,76,478,481,482,483,529,530,531,532,2,356,534,537,223,261,538,86,539,540,541,547,548,549,550,551,554,556,559]};var no=ot.rules,Tu=new Map(no.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),Es=new Map(ot.kinds.map((t,e)=>[t,no[ot.contracts[e]][1]])),Ru=new Map([...Es].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>ot.names[n])])])),Cs=c(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function io(t){let e=Es.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!Ps(t,e))throw new le(`Invalid typed members for syntax kind '${t.kind}'.`)}c(io,"validateSyntaxMembers");function Ti(t,e){let n=Ri(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new le(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}c(Ti,"validateClosedSyntaxMembers");function Ri(t){let e=Ru.get(t);if(e===void 0)throw new le(`Unknown syntax kind '${t}'.`);return e}c(Ri,"syntaxMemberNames");function Ps(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,ot.names[n])?ro(t[ot.names[n]],i):!r)}c(Ps,"matchesMembers");function Du(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!ro(t[n],e))return!1;return!0}c(Du,"allIndicesMatch");function ro(t,e){let[n,...i]=no[e];switch(n){case"ref":return Cs(t)&&typeof t.kind=="string"&&i.some(r=>ot.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,s)=>o+(ro(t,s)?1:0),0);return n==="one"?r===1:r>0}case"const":return t===i[0];case"enum":return i.includes(t);case"null":return t===null;case"array":return Array.isArray(t)&&Du(t,i[0]);case"object":return Cs(t)&&Object.keys(t).every(r=>i[0].some(([o])=>ot.names[o]===r))&&Ps(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||Tu.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}c(ro,"matches");var Mu=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(","))])),ju=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function Nu(t,e){return Mu[t]?.has(e)===!0||ju.test(t)&&(e==="source"||e==="value")}c(Nu,"isExactOnlyMember");function As(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:Nu(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}c(As,"isLegacyOmittedMember");var Mi=c(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),Di=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers","directiveLocations"]),ji=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function Li(t){let e=Lu(t);return oo(e,"legacy",0),Ni(e)}c(Li,"toSyntaxJson");function Lu(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 l=ws();e.set(o,l);let p=o.length;for(let m=p-1;m>=0;m--)n.push(()=>{l[m]=i(Object.hasOwn(o,m)?o[m]:void 0)});return l}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 l=a.length-1;l>=0;l--)n.push(()=>{let p=a[l],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}c(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}c(Lu,"snapshot");function ws(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}c(ws,"dataArray");function Ni(t,e="legacy",n=!1){if(Array.isArray(t)){let o=ws();for(let s=0;s<t.length;s++)o.push(Ni(t[s],e,n));return o}if(Mi(t)){if(ji.has(t.kind)&&(e=Yt(t.sourceOptions??Me).numericMode),Kt(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&Ti(t,Di),t.kind==="ValidationRuleSyntax"){let p=t;p.implementation!=null&&(p.file!=null&&Ti(p.file,Di),p.code!=null&&Ti(p.code,Di))}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"?Ri(t.kind):void 0,l=Object.keys(s).filter(p=>(a===void 0||a.has(p))&&!(e==="legacy"&&!n&&As(t,p))&&!Di.has(p)&&!(t.kind==="OperationSyntax"&&p==="usesLocation")).sort(qu);for(let p of l){let m=s[p];t.kind==="ConceptAttributeSyntax"&&(p==="scope"||p==="specialCategory")&&m==null||t.kind==="ConceptAttributeSyntax"&&p==="criminal"&&m===!1||t.kind==="PropertySyntax"&&p==="isSubject"&&m===!1||p==="documentation"&&t.kind!=="EventSyntax"&&m==null||t.kind==="SpecificationSyntax"&&p==="description"&&m==null||p==="dependsOn"&&(t.kind==="ModuleSyntax"||t.kind==="FeatureSyntax")&&Array.isArray(m)&&m.length===0||p==="sourceOptions"&&m?.numericMode==="legacy"||(p==="examples"||t.kind==="SpecificationSyntax"&&(p==="parameters"||p==="cases"))&&Array.isArray(m)&&m.length===0||t.kind==="SpecificationErrorSyntax"&&p==="caseValue"&&m==null||p==="inlineProperty"&&m==null||(t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax")&&(p==="stream"||p==="noStream")&&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]=Ni(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]=Ni(i[o],e,n));return r}c(Ni,"write");function oo(t,e,n){if(n>96&&e==="exact")throw new le("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)oo(t[o],e,n+1);return}if(typeof t!="object"||t===null)return;let i=t;if(ji.has(i.kind)||Object.hasOwn(i,"sourceOptions")){let o=Object.hasOwn(i,"sourceOptions")?Yt(i.sourceOptions):Me;if(n>0&&e!==o.numericMode)throw new le("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!ji.has(i.kind))throw new le("Exact syntax requires a complete source root.");if(e==="exact"&&Mi(i)&&io(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&nn(i.text))throw new le("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 le("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"||He(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new le("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new le("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&Mi(i)?Ri(i.kind):void 0;for(let[o,s]of Object.entries(i))(r===void 0||r.has(o)||Mi(s)&&ji.has(s.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&oo(s,e,n+1)}c(oo,"validateNumbers");function qu(t,e){return t<e?-1:t>e?1:0}c(qu,"ordinal");function Os(t){let e=[],n=t.map(x=>x.value),i=new Map,r=!1;for(let x of n)try{i.set(x,Object.hasOwn(x,"sourceOptions")?Yt(x.sourceOptions):Me)}catch(S){if(!(S instanceof le))throw S;r=!0,e.push(Bi(d.IncompatibleNumericSource,S.message,x.location))}let o=n.filter(x=>i.get(x)?.numericMode==="exact"||Bu(x)),s=i.get(o[0])??Me;for(let x of o.slice(1))i.get(x)?.numericMode!==s.numericMode&&(r=!0,e.push(Bi(d.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",x.location)));r&&(s=Go);let a=new Map,l=qi(n.flatMap(x=>x.concepts),"declaration of",e,void 0,a),p=qi(n.flatMap(x=>x.types),"declaration of",e,void 0,a),m=n.map(x=>x.domain).filter(x=>x!==null);for(let x of m.slice(1))e.push(Bi(d.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${En(m[0].location.path)}' - a folder compiles to one application, which can have at most one`,x.location));let f=Yu(n.flatMap(x=>x.modules),e),y=qi(n.flatMap(x=>x.personas),"persona",e),h={kind:"ApplicationSyntax",sourceOptions:s,domain:m[0]??null,imports:Fu(n.flatMap(x=>x.imports),x=>x.qualifiedName),concepts:l,types:p,examples:n.flatMap(x=>x.examples??[]),systems:n.flatMap(x=>x.systems??[]),eventSources:n.flatMap(x=>x.eventSources??[]),declaredTriggers:n.flatMap(x=>x.declaredTriggers??[]),modules:f,personas:y,policies:n.flatMap(x=>x.policies??[]),seeds:n.flatMap(x=>x.seeds??[]),fileImports:n.flatMap(x=>x.fileImports),location:n[0]?.location??{line:1,column:1}},v=[...t.flatMap(x=>x.diagnostics),...e];return{value:h,diagnostics:v,success:!v.some(x=>x.severity==="error")}}c(Os,"mergeDocuments");function Bu(t){if(Ko(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=c(n=>!n.isPlacement||(n.examples?.length??0)>0||n.slices.length>0||n.features.some(e),"feature");return t.modules.some(n=>!n.isPlacement||(n.examples?.length??0)>0||n.features.some(e))}c(Bu,"hasDeclarations");function Yu(t,e){return Ms(t).map(Rs).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map(ao)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),description:Ns(n,`module '${n[0].name}'`,e),documentation:js(n,`module '${n[0].name}'`,e),authorize:Ds(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:Ts(n),features:Is(n.flatMap(i=>i.features),e)})}c(Yu,"mergeModules");function Is(t,e){return Ms(t).map(Rs).map(n=>n.length===1?ao(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),description:Ns(n,`feature '${n[0].name}'`,e),documentation:js(n,`feature '${n[0].name}'`,e),authorize:Ds(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:Ts(n),features:Is(n.flatMap(i=>i.features),e),slices:qi(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}c(Is,"mergeFeatures");function Ts(t){return[...t].sort((e,n)=>(e.location.path??"")<(n.location.path??"")?-1:(e.location.path??"")>(n.location.path??"")?1:0).flatMap(e=>e.dependsOn??[])}c(Ts,"groupDependencies");function Rs(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}c(Rs,"placedLast");function ao(t){return{...t,isPlacement:!1,features:t.features.map(ao)}}c(ao,"unplaced");function Ds(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(Li(s))===JSON.stringify(Li(r)));if(o!==void 0){n.push(so(d.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${En(o.location.path)}' - this repeated gate is ignored`,r.location));continue}i.push(r)}return i.reduce((r,o)=>_e(r,o),null)}c(Ds,"combineAuthorization");function Fu(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}c(Fu,"firstOfEach");function Ms(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}c(Ms,"groupByName");function js(t,e,n){let i=t.filter(r=>r.documentation!=null);for(let r of i.slice(1).filter(o=>o.documentation!==i[0].documentation))n.push(so(d.ConflictingDocumentationAcrossFiles,`The ${e} is already documented in '${En(i[0].location.path)}' - keeping that documentation`,r.location));return i[0]?.documentation??null}c(js,"firstDocumentation");function Ns(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(so(d.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${En(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}c(Ns,"firstDescription");function qi(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(Bi(d.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${s.name}'${i===void 0?"":` in ${i}`} - already declared in '${En(a.path)}'`,s.location));continue}a===void 0&&r.set(s.name,s.location),o.push(s)}return o}c(qi,"declaredInOneFile");var En=c(t=>t??"another file","describe"),Bi=c((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),so=c((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function qs(t,e){return Vu(t,e).result}c(qs,"parsePlacedDocuments");function Vu(t,e){let n=_t.capturePlaced(t.filter(v=>v.isPlacementResolved!==!1).map(v=>({lines:wt(v.source,!1,v.path),placement:v.placement})),e),i=t.map(v=>it(v.source,v.path,v.isPlacementResolved===!1?[]:v.placement,!1,n,e)),r=i.flatMap((v,x)=>(v.value.eventSources??[]).map(S=>({source:S,placementResolved:t[x].isPlacementResolved!==!1}))),o=t.every(v=>v.isPlacementResolved!==!1)&&i.every(v=>!Zt.hasUnknownExtent(v.diagnostics)),s=i.map((v,x)=>t[x].isPlacementResolved===!1?{...v,value:{...v.value,eventSources:[]}}:v),a=Os(s),l=new me(new We([]),void 0,e);a.value.sourceOptions!==void 0&&(l.sourceOptions=a.value.sourceOptions),Un(a.value,l);let p=Fe(a.value);vi(a.value,l),mi(a.value,l),ui(a.value,l),Vn(a.value,l),Yn(p,l,s.flatMap(v=>v.inputUses)),$i(a.value,l),bi(p,l),ki(a.value,l),Ei(a.value,l),wi(a.value,l),Oi(a.value,l),Ii(a.value,l);let m=Qn(a.value,l);Gt.validate(m,l);for(let v of Wn(m))l.information(v.code,v.message,v.location);let f=a.diagnostics,y=new Set(f.map(Ls)),h=[...f,...l.diagnostics.filter(v=>!y.has(Ls(v)))];return{result:{...a,value:m,diagnostics:h,success:!h.some(v=>v.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(s.map((v,x)=>[t[x].path,v.value]))}}c(Vu,"parsePlacedDocumentsWithSyntax");function Ls(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}c(Ls,"diagnosticKey");var Bs=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,Ys=c(t=>`\\u${t.toString(16).padStart(4,"0")}`,"escape");function zu(){let t="";for(let e=0;e<=65535;e++){if(!Bs.test(String.fromCharCode(e)))continue;let n=e;for(;e<65535&&Bs.test(String.fromCharCode(e+1));)e++;t+=Ys(n)+(e>n?`-${Ys(e)}`:"")}return t}c(zu,"ranges");var Pt=zu();var Qu=new RegExp(`^\\s*example\\s+[A-Z][${Pt}]*\\s*:\\s*([${Pt}.]*)$`),Gu=new RegExp(`^\\s*(given|when|then)\\s+(?:(readmodel|append)\\s+)?([${Pt}.]*)$`);function Fs(t,e,n,i,r,o){let s=t,a=[],l=o.some($=>$.severity==="error")?o.some($=>$.code==="PLAY0519")?"**Invalid duplicate assignments; no effective values selected.**":"**Invalid source; no effective values selected.**":null,p=new Map,m=[],f=c(($,b)=>{if($.location.path===e&&$.location.line>0)for(let k of i($.location.line-1))p.set(k,b)},"own"),y=c(($,b)=>{for(let k of $??[])a.push({name:k.name,scope:b,example:k}),f(k,b)},"examples");y(s.examples,[]),a.push(...[...s.concepts,...s.types].map($=>({name:$.name,scope:[]})));let h=c(($,b)=>{for(let k of $){let C=[...b,k.name];f(k,C),y(k.examples,C);for(let O of k.slices){let I=[...b,k.name,O.name];f(O,I),y(O.examples,I);let R=new Map;for(let j of ae(O))R.set(j.name,[...R.get(j.name)??[],j]);for(let j of R.values()){let N=Math.max(...j.map(B=>B.generation));a.push(...j.filter(B=>B.generation===N).map(B=>({name:B.name,scope:I,fixtureKind:"event"})))}a.push(...O.commands.map(j=>({name:j.name,scope:I,fixtureKind:"command"})),...O.readModels.map(j=>({name:j.name,scope:I,fixtureKind:"readmodel"})));for(let j of O.specifications)m.push({node:j,scope:I}),f(j,I),y(j.examples,I)}h(k.features,C)}},"features");for(let $ of s.modules)f($,[$.name]),y($.examples,[$.name]),h($.features,[$.name]);let v=c(($,b)=>{let k=$.split("."),C=a.filter(I=>I.name===k.at(-1)),O=k.slice(0,-1);if(O.length)return C.filter(I=>O.length<=I.scope.length&&O.every((R,j)=>I.scope[I.scope.length-O.length+j]===R));for(let I=b.length;I>=0;I--){let R=C.filter(j=>I<=j.scope.length&&b.slice(0,I).every((N,B)=>j.scope[B]===N));if(R.length)return R}return[]},"candidates"),x=c(($,b)=>{let k=v($,b);return k.length===1?k[0]:void 0},"unique"),S=c($=>$.example?x($.example.type,$.scope)?.fixtureKind:$.fixtureKind,"kind"),E=c($=>[...$.scope.filter(b=>!r.has(b)),$.name].join("."),"display"),g=c(($,b,k=!1,C="")=>a.flatMap(O=>{let I=S(O);if(!I||b&&I!==b||k&&O.example)return[];let R=[...O.scope,O.name].join("."),j=x(O.name,$)===O?O.name:R;if(x(j,$)!==O)return[];let N=C.split(".").slice(0,-1).join(".");return N&&!R.endsWith(`${N}.${O.name}`)?[]:j===R&&O.scope.some(B=>r.has(B))&&x(O.name,$)!==O?[]:[{label:x(O.name,$)===O?O.name:E(O),insertText:N?O.name:j,documentation:O.example?`Example of ${O.example.type}. Step assignments override example values; no implicit defaults.`:`Declared ${I}.`}]}),"targets"),P=c(($,b,k,C,O)=>{if(l)return l;let I=c((z,_,ue="")=>{if(new Set(z.map(F=>F.property)).size!==z.length||new Set(_.map(F=>F.property)).size!==_.length)return null;let we=new Map(z.map(F=>[F.property,{value:F,origin:"example",replaced:void 0}]));for(let F of _){let oe=we.get(F.property)?.value;we.delete(F.property),we.set(F.property,{value:F,origin:oe?"override":"authored",replaced:oe})}return[...we.values()].map(({value:F,origin:oe,replaced:de})=>`${ue}${F.property} = ${at(F.source)} \u2014 ${oe}${oe==="example"?` ${$.name}`:""}${de?` (replaces ${at(de.source)} from ${$.name})`:""}`)},"merge"),R=I($?.values??[],b),j=I($?.generatedValues??[],k,"generated ");if(!R||!j)return"**Invalid duplicate assignments; no effective values selected.**";let N=C??$?.for,B=$?.stream??$?.noStream,L=O?.stream??O?.noStream,W=L??B,V=c(z=>z.kind==="SpecificationNoStreamSyntax"?"no stream":`stream ${z.eventSource}.${z.stream}${z.streamId?` streamId = ${at(z.streamId.source)}`:z.streamIdParts.length?` streamId ${z.streamIdParts.map(_=>`${_.property} = ${at(_.source)}`).join(", ")}`:""}`,"routeText"),G=W?[`${V(W)} \u2014 ${L?B?`override (replaces ${V(B)} from ${$.name})`:"authored":`example ${$.name}`}`]:[];return[...R,...j,...G,...N?[`for ${at(N)} \u2014 ${C?$?.for?`override (replaces ${at($.for)} from ${$.name})`:"authored":`example ${$.name}`}`]:[]].join(`
|
|
19
|
-
`)},"effective"),A=new Map;for(let $ of a.filter(b=>b.example?.location.path===e)){let b=$.example,k=b.location.line-1,C=$e(n[k]??"").match(/^\s*example\s+/)?.[0];C&&A.set(k,{start:C.length+1,length:b.name.length,content:`**example ${E($)} : ${b.type}**
|
|
20
|
-
|
|
21
|
-
${S($)?P(b,[],[],null):"Unresolved or ambiguous type; no effective values selected."}`})}for(let{node:$,scope:b}of m){let k=[...$.given.map(C=>({step:C,name:C.eventType,expected:"event",values:C.values,generated:[],destination:C.for,prefix:/^\s*given\s+/})),...$.givenReadModels.map(C=>({step:C,name:C.name,expected:"readmodel",values:C.properties,generated:[],destination:null,prefix:/^\s*given\s+readmodel\s+/})),...$.when?[{step:$.when,name:$.when.commandType,expected:"command",values:$.when.values,generated:$.when.generatedValues??[],destination:$.when.for,prefix:/^\s*when\s+/}]:[],...$.whenAppended?[{step:$.whenAppended,name:$.whenAppended.eventType,expected:"event",values:$.whenAppended.values,generated:[],destination:$.whenAppended.for,prefix:/^\s*when\s+append\s+/}]:[],...$.thenEvents.map(C=>({step:C,name:C.eventType,expected:"event",values:C.values,generated:[],destination:C.for,prefix:/^\s*then\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:O,expected:I,values:R,generated:j,destination:N,prefix:B}of k.filter(L=>L.step.location.path===e)){let L=x(O,b),W=v(O,b).some(_=>_.example);if(!L?.example&&(L||!W))continue;let V=C.location.line-1,G=$e(n[V]??"").match(B)?.[0].length;if(G===void 0)continue;let z=L?S(L)!==I?"**Example kind mismatch; no effective values selected.**":`**${I} ${L.example?.type??O}${L.example?` \u2014 example ${E(L)}`:""}**
|
|
22
|
-
|
|
23
|
-
${P(L.example,R,j,N,"eventType"in C?C:void 0)}
|
|
24
|
-
|
|
25
|
-
Authored fixture values, not execution results. Matching is unchanged.`:"**Ambiguous example; no effective values selected.**";A.set(V,{start:G+1,length:O.length,content:z})}}return{eventExamples:a.filter($=>$.example?.location.path===e&&S($)==="event").map($=>$.example),completions($,b){let k=p.get($)??[],C=b.match(Qu);if(C)return g(k,void 0,!0,C[1]);if(!m.some(({node:N})=>N.location.path===e&&i(N.location.line-1).includes($)))return null;let I=b.match(Gu);if(!I||["clock","caller","capture","trigger","query","result","error","denied","returns","no","operation","compensated"].includes(I[3]))return null;let R=I[2]==="readmodel"?"readmodel":I[2]==="append"||I[1]!=="when"?"event":"command",j=g(k,R,!1,I[3]);return j.length?I[2]?j:[...$o[I[1]],...j]:null},hover($,b,k){let C=A.get($);return C&&b>=C.start&&k<=C.start+C.length?C.content:null}}}c(Fs,"exampleAnalysis");function at(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(at).join(", ")}]`;case"ObjectExpressionSyntax":return`{ ${t.members.map(e=>`${JSON.stringify(e.name)}: ${at(e.value)}`).join(", ")} }`;case"RawExpressionSyntax":return t.text;case"CaseValueExpressionSyntax":return`case.${t.parameter}`;case"PathExpressionSyntax":return t.path;case"ContextExpressionSyntax":return`$context.${t.path}`;case"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:"${"+at(e.expression)+"}").join("")+"`"}}c(at,"expressionText");var _u=new RegExp(`^\\s*given caller as\\s+[${Pt}]*$`),Zu=new RegExp(`^\\s*(?:given caller as|persona)\\s+([A-Za-z_][${Pt}]*)\\s*$`);function Us(t,e){let n=t,i=new Map(n.personas.map(r=>[r.name,on(r,n)]));return{completions(r,o){return $e(o).length<o.length||!_u.test(o)?null:n.personas.map(s=>({label:s.name,insertText:s.name,documentation:"Authenticated deterministic witness of this persona. Negation, needed nonliteral claims, role-URI claims, implementations and policyless personas require an explicit caller."}))},hover(r,o,s){let a=$e(e[r]??""),l=Zu.exec(a);if(!l||a.slice(o-1,s-1)!==l[1])return null;let p=i.get(l[1]);return p?p.refusal?`**${l[1]} caller** \u2014 ${p.refusal.reason}${p.refusal.policy?` in policy ${p.refusal.policy}`:""}. Use an explicit \`given caller\`.`:`**${l[1]} caller** \u2014 authenticated.
|
|
26
|
-
|
|
27
|
-
Roles: ${p.caller.roles.map(m=>JSON.stringify(m)).join(", ")||"(none)"}.
|
|
28
|
-
|
|
29
|
-
Claims: ${p.caller.claims.map(m=>`${JSON.stringify(m.type)} = ${JSON.stringify(m.value)}`).join(", ")||"(none)"}.
|
|
30
|
-
|
|
31
|
-
Contributions: ${p.contributions.map(m=>`${m.policy}: ${m.kind}${m.type?` ${JSON.stringify(m.type)}`:""} ${JSON.stringify(m.value)}`).join("; ")}. This witnesses one deterministic minimal caller, not every caller fitting the persona.`:null}}}c(Us,"personaAnalysis");function Ws(t,e,n,i,r){let o=t,s=e,a=Ae.containersOf(o).filter(f=>![...f.scope,f.name].some(y=>r.has(y))),l=new Map,p=new Map,m=c((f,y,h)=>{for(let v of f){let x=[...y,v.name];if(h){if(v.location.path===n&&v.location.line>0)for(let S of i(v.location.line-1))l.set(S,x)}else{let S=x.join(".");p.set(S,[...p.get(S)??[],...(v.dependsOn??[]).map(E=>({target:E.target,...E.location}))])}m(v.features,x,h)}},"inventory");return m(o.modules,[],!1),m(s.modules,[],!0),{completions(f,y,h){let v=l.get(f)??h;if(!v?.length||v.some(S=>r.has(S))||!a.some(S=>[...S.scope,S.name].join(".")===v.join(".")))return[];let x=new Set((p.get(v.join("."))??[]).filter(S=>S.path!==n||S.line!==f+1).map(S=>Ae.resolve(S.target,v,a).resolved));return Ae.candidates(v,a).flatMap(({container:S,reference:E,tier:g})=>{if(x.has(S))return[];let P=[...S.scope,S.name].join(".");if(y&&(E=y+S.name,Ae.resolve(E,v,a).resolved!==S))return[];let A=S.scope.length===0?"module":g===0?"sibling feature":g!=="qualified"?`feature of ${S.scope.join(".")}`:`feature in ${S.scope.join(".")}`,$=a.indexOf(S);return[{label:y?S.name:E,insertText:y?S.name:E,documentation:`${P} \u2014 ${A}.`,detail:A,sortText:`${String(g==="qualified"?v.length:g).padStart(6,"0")}:${String($).padStart(6,"0")}`}]})}}}c(Ws,"dependencyTargetAnalysis");var $T="Executable as ESM v7. Generated values require fixtures in reference execution; other unadmitted constructs still prevent binding.",Pn=new Map;function Ku(t,e){let n=Ce(t),i=t.flatMap((f,y)=>!n[y]&&X(f)===0&&/^\w/.test(f)?[f.split(/\s+/)[0]]:[]);if(i.includes("module")||!i.some(f=>["feature","slice","command","event","operation","reaction","specification"].includes(f)))return{source:t.join(`
|
|
32
|
-
`),locations:t.map((f,y)=>({line:y+1,column:0}))};let r=[],o=[],s=!1;t.forEach((f,y)=>{!n[y]&&X(f)===0&&/^\w/.test(f)&&(s=/^(?:concept|type|import|domain|system|eventsource|policy|persona)\b/.test(f)),(s?r:o).push(y)});let a=i.includes("feature")?1:i.includes("slice")?2:3,l=e.slice(0,a),p=[...r.map(f=>t[f]),...l,...o.map(f=>" ".repeat(a*2)+t[f])].join(`
|
|
33
|
-
`),m=[...r.map(f=>({line:f+1,column:0})),...l.map(()=>({line:0,column:0})),...o.map(f=>({line:f+1,column:a*2}))];return{source:p,locations:m}}c(Ku,"authoringSource");function Ju(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(`
|
|
34
|
-
`),placement:n,isPlacementResolved:r},...o],a=new Set(s.flatMap(T=>[...T.source.matchAll(/\w+/g)].map(M=>M[0]).concat(T.placement??[]))),l=c(T=>{let M=T;for(let q=1;a.has(M);q++)M=`${T}${q}`;return a.add(M),M},"fresh"),p=l("EditorAuthoring"),m=l("FragmentFeature"),f=new Set([p,m]),y=s.map((T,M)=>{let q=M===0?t:T.source.split(`
|
|
35
|
-
`),Y=l(`Fragment${M}`);f.add(Y);let st=T.placement?.length?{source:T.source,locations:q.map((At,In)=>({line:In+1,column:0}))}:Ku(q,[`module ${p}`,` feature ${m}`,` slice StateChange ${Y}`]);return{...T,...st,placement:T.placement??[]}}),h=y[0],v=new Map(y.map(T=>[T.path,T.locations])),x=qs([...y.slice(1),h]),S=new Map,E=new Map,g=new WeakSet,P=c(T=>{if(T===null||typeof T!="object"||g.has(T))return;if(g.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 q=v.get(M.path)?.[M.line-1];q&&(M.line=q.line,M.column=Math.max(1,M.column-q.column));return}for(let q of Object.values(M))P(q);M.location?.path===i&&(M.kind==="CommandSyntax"&&S.set(M.location.line-1,T),M.kind==="SpecificationSyntax"&&E.set(M.location.line-1,T))},"walk");P(x.value),P(x.physicalEventSources);for(let T of x.diagnostics)P(T.location);let A=x.diagnostics.some(T=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(T.code))return!1;let M=y.find(Y=>Y.path===T.location.path),q=s.find(Y=>Y.path===T.location.path)?.source.split(`
|
|
36
|
-
`)[T.location.line-1];return M?.locations.some(Y=>Y.line===0)&&q!==void 0&&X(q)===0}),$=x.diagnostics.filter(T=>T.location.path===i).flatMap(T=>(P(T.location),T.location.line>0?[T]:[])),b=new re(x.value),k=new Set(b.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&&!b.isEventProduction(M,T)).map(M=>M.location.line-1)));for(let T of $)T.code==="PLAY0499"&&k.add(T.location.line-1);let C=b.declarations.filter(T=>T.kind===ie.Operation).map(T=>({...T.node,scope:T.scope.filter(M=>!f.has(M))})),O=new Map,I=Ce(t),R=c(T=>{let M=[],q=X(t[T]);for(let Y=T;Y<t.length&&!(Y>T&&!I[Y]&&$e(t[Y]).trim()&&X(t[Y])<=q);Y++)M.push(Y);return M},"range");for(let{slice:T,scope:M}of b.slices){if(T.location.path===i&&T.location.line>0)for(let q of R(T.location.line-1))O.set(q,{scope:M});for(let q of T.specifications.filter(Y=>Y.location.path===i&&Y.location.line>0))for(let Y of R(q.location.line-1))O.set(Y,{scope:M});for(let q of T.commands.filter(Y=>Y.location.path===i&&Y.location.line>0))for(let Y of R(q.location.line-1))O.set(Y,{scope:M,commandLine:q.location.line-1})}let j=new Map(b.declarations.map(T=>[T.node.location,T.scope]));for(let T of C.filter(M=>M.location.path===i)){let M=j.get(T.location);for(let q of R(T.location.line-1))O.set(q,{...O.get(q),scope:M,operation:T})}let N=new Map(C.map(T=>[T.location,T])),B=c((T,M)=>{let q=$e(t[T.line-1]??""),Y=q.slice(T.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return Y&&q.slice(T.column-1+Y.length,T.column-1+Y.length+M.length)===M?{...T,column:T.column+Y.length}:T},"referenceLocation"),L=[];for(let{slice:T}of b.slices){for(let M of T.commands)for(let q of M.produces){if(q.location.path!==i)continue;let Y=b.resolve(q.event,T),st=Y.declaration?N.get(Y.declaration.node.location)??null:null,At={name:q.event,location:q.location,targetLocation:q.targetLocation??q.location,kind:Y.kind,declaration:st,mappings:q.mappings};if(L.push(At),Y.kind===ie.Operation)for(let In of R(q.location.line-1)){let ho=O.get(In);ho&&O.set(In,{...ho,production:At})}}for(let M of T.specifications)for(let q of[...M.givenOperationFailures??[],...M.thenOperations??[],...M.thenCompensated??[]]){if(q.location.path!==i)continue;let Y=b.resolve(q.operation,T);L.push({name:q.operation,location:q.location,targetLocation:B(q.location,q.operation),kind:Y.kind,declaration:Y.declaration?N.get(Y.declaration.node.location)??null:null,mappings:[]})}}let W={declarations:C,systems:x.value.systems??[],references:L,contexts:O,types:x.value.types,concepts:x.value.concepts,targets:c(T=>{let M=b.slices.find(q=>q.scope.length===T.length&&q.scope.every((Y,st)=>Y===T[st]))?.slice;return M?C.flatMap(q=>{let Y=b.resolve(q.name,M).declaration?.node.location===q.location?q.name:[...q.scope,q.name].join(".");return b.resolve(Y,M).kind===ie.Operation&&b.resolve(Y,M).declaration?.node.location===q.location?[{name:Y,declaration:q}]:[]}):[]},"targets")},V=x.physicalEventSources.map(T=>T.source),G=new Zt(x.physicalEventSources,x.sourceInventoryComplete&&!A),z=new Map,_=c((T,M)=>{let q=JSON.stringify([T,M]),Y=z.get(q);return Y||(Y=G.resolve(T,M),z.set(q,Y)),{...Y,source:Y.state==="unique"?Y.sources[0]:void 0,stream:Y.state==="unique"?Y.streams[0]:void 0}},"resolve"),ue=new Set(x.value.imports.map(T=>T.qualifiedName)),we=V.flatMap(T=>T.streams.filter(M=>_(T.name,M.name).state==="unique"&&!ue.has(`${T.name}.${M.name}`)).map(M=>({name:`${T.name}.${M.name}`,source:T,stream:M}))),F=new Map,oe=[];for(let T of S.values()){for(let M of R(T.location.line-1))F.set(M,{command:T});for(let M of[...T.produces,...T.validations,...T.handler?[T.handler]:[]])for(let q of R(M.location.line-1))F.delete(q);if(T.stream){oe.push(T.stream);for(let M of R(T.stream.location.line-1))F.set(M,{command:T,route:T.stream})}}let de=Fs(x.value,i,t,R,f,x.diagnostics),ke=[...[...E.values()].flatMap(T=>[...T.given.map(M=>({event:M,expectation:!1})),...T.whenAppended?[{event:T.whenAppended,expectation:!1}]:[],...T.thenEvents.map(M=>({event:M,expectation:!0})),...T.whenRedelivered?[{event:T.whenRedelivered,expectation:!0}]:[]]),...(de.eventExamples??[]).map(T=>({event:T,expectation:!0}))];for(let T of ke){let M=T.event;for(let q of R(M.location.line-1))F.set(q,T);if(M.stream){oe.push(M.stream);for(let q of R(M.stream.location.line-1))F.set(q,{...T,route:M.stream})}}for(let T of V.filter(M=>M.location.path===i)){for(let M of R(T.location.line-1))F.set(M,{source:T});for(let M of T.streams)for(let q of R(M.location.line-1))F.set(q,{source:T,stream:M})}let xt=[...S.values()].flatMap(T=>T.streamCandidates??[]).filter(T=>T.propertyCandidate!==null),vt={declarations:V,routes:oe,ambiguousCandidates:xt,contexts:F,targets:we,resolve:_},pe,Se={completions(T,M,q){if(pe===void 0){let Y=it(h.source,i,h.placement,!1).value,st=c(At=>{P(At.location),At.features.forEach(st)},"remapDependencyHeaders");Y.modules.forEach(st),pe=Ws(x.value,Y,i,R,f)}return pe.completions(T,M,q)}};return{commands:S,specifications:E,diagnostics:$,operationProductionLines:k,operations:W,eventSources:vt,examples:de,personas:Us(x.value,t),dependencies:Se}}c(Ju,"analyze");function Jt(t,e=[],n,i="current.play",r=!0){let o=JSON.stringify([t,e,n,i,r]),s=Pn.get(o);return s===void 0&&(s=Ju(t,e,n,i,r),Pn.size>=16&&Pn.delete(Pn.keys().next().value),Pn.set(o,s)),s}c(Jt,"responseAnalysis");var lo="file",Hu=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,Xu=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function ET(t){return Xu.test(t)}c(ET,"isAbsoluteFileReferencePath");function em(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}c(em,"withoutComment");function co(t,e){let n=X(t),i=em(t.slice(n)).trimEnd();if(Qi(i)!==lo)return;let r=i.slice(lo.length),o=r.trim();if(o.length===0||Hu.test(o))return;let s=r.length-r.trimStart().length,a=n+lo.length+s+1;return{path:o,line:e,startColumn:a,endColumn:a+o.length}}c(co,"fileReferenceOn");function PT(t){let e=Ce(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=co(t[i],i);r&&n.push(r)}return n}c(PT,"fileReferences");function St(t){let e=!1;return t.map(n=>{if(e)return n.trim()==="```"&&(e=!1),n;let i=$e(n);return/^\s*```(?:[a-z]+)?\s*$/.test(i)&&(e=!0),i.trimEnd()})}c(St,"eventAnalysisSource");var tm=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,nm=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?(\s+subject)?\s*$/,Vs=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,im=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,rm=["authorize","produces","reads"],om=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,am=mn,sm=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],lm=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function gt(t){return t.typeReference??Xt(t.type)}c(gt,"propertyTypeReference");function po(t,e){let n=t.slice(e-1).match(/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?(?:\?|\s+optional\b)?/u)?.[0]??"";return{text:n,startColumn:e,endColumn:e+n.length}}c(po,"sourceTypeAt");function fo(t,e,n){return e.map(i=>({index:i,match:t[i].match(nm)})).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:Xt(r[2]),sourceType:po(t[i],t[i].match(/^\s*\S+\s+/)[0].length+1),isIdentifier:r[4]!==void 0,...r[3]!==void 0?{isGenerated:!0}:{},...r[5]!==void 0?{isSubject:!0}:{},line:i}))}c(fo,"propertiesIn");function wn(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(X(s)<=i)break;r.push(o)}}return r}c(wn,"collectBody");function Ht(t,e,n,i){let r=wn(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 l=X(t[a]),p=t[a].trim();return o!==void 0&&l>o&&(!s||om.test(p))?!1:(o=p!=="validate csharp"&&fo(t,[a],rm).length>0||/^description(?:\s|$)/.test(p)?void 0:l,s=/^authorize(?:\s|$)/.test(p),!0)})}c(Ht,"directBody");var An=new Map;function On(t){let e=t.join(`
|
|
37
|
-
`),n=An.get(e);if(n)return n;let i=Jt(t),r={authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=St(t);let o=Ce(t),s=t,a=o,l=t.map(p=>p.replace(/\s*=(?!=|>).*/,""));for(let p=0;p<t.length;p++){if(o[p])continue;let m=t[p],f=m.trim(),y=X(m),h=s[p].trim().match(/^import\s+([\w.]+)\s*$/);if(h&&y===0){let b=h[1],k=b.split(".").pop()??b;r.imports.push({qualifiedName:b,shortName:k,line:p});continue}let v=f.match(tm);if(v){let b=wn(t,o,p,y).map(O=>t[O].trim()),k={};for(let O of b){let I=O.match(Vs);I&&k[I[1]]===void 0&&(k[I[1]]=I[2])}let C=v[2]==="Enum"?b.filter(O=>!Vs.test(O)):[];r.concepts.push({name:v[1],primitive:v[2],attributes:v[3].trim().split(/\s+/).filter(Boolean),attributeReasons:k,enumValues:C,line:p});continue}let x=f.match(/^type\s+(\w+)\s*$/);if(x){r.types.push({name:x[1],properties:fo(t,wn(t,o,p,y),So),line:p});continue}let S=f.match(/^policy\s+(\w+)\s*$/);if(S){let b=wn(t,o,p,y).filter(k=>!o[k]).map(k=>t[k].trim());r.policies.push({name:S[1],requires:b,line:p});continue}let E=s[p].trim().match(/^(?:produces\s+)?event\s+(\w+)(?:\s+generation\s+(\d+))?\s*$/);if(E){let b=f.startsWith("produces "),k=Ht(s,a,p,y),C=b?k:k.filter(O=>co(s[O],O)===void 0);r.events.push({name:E[1],...E[2]?{generation:Number(E[2])}:{},inline:b,properties:fo(b?l:s,C,b?sm:am),line:p});continue}let g=i.commands.get(p);if(g){let b=Ht(t,o,p,y),k=b.filter(C=>/^\s*produces\b/.test(t[C])&&!i.operationProductionLines?.has(C));r.commands.push({name:g.name,properties:g.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:po(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:g.response,productionHeaders:k,produces:k.flatMap(C=>{let O=s[C].trim(),I=/^produces\s+event\b/.test(O),R=/^produces\s+when\b/.test(O),j=R?Ht(s,a,C,X(s[C]))[0]:C;if(j===void 0)return[];let N=R?s[j].trim():O.match(I?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(N===void 0||!/^[A-Za-z_]\w*$/.test(N))return[];let B=Ht(s,a,j,X(s[j])),L=B.map(G=>s[G].trim().match(/^for(?:\s+(.*))?$/)).filter(G=>G!==null),W=L.length===0?void 0:L.length===1?L[0][1]??"":"",V=B.flatMap(G=>{let z=s[G].trim().match(I?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return z===null?[]:[{name:z[1].replace(/^@/,""),source:z[2],line:G}]});return[{name:N,inline:I,conditional:R,line:C,target:W,mappings:V}]}),reads:b.filter(C=>!o[C]).map(C=>({line:C,match:t[C].match(im)})).filter(C=>C.match!==null).map(({line:C,match:O})=>({view:O[1],...O[2]?{alias:O[2]}:{},...O[3]?{by:O[3]}:{},line:C})),line:p});continue}let P=f.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(P){let b=wn(t,o,p,y).map(k=>({index:k,match:t[k].match(lm)})).filter(k=>k.match!==null).map(({index:k,match:C})=>({name:C[1],type:C[2],typeReference:Xt(C[2]),sourceType:po(t[k],t[k].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:k}));r.queries.push({name:P[1],returnType:P[2],returnTypeReference:Xt(P[2]),parameters:b,line:p});continue}let A=f.match(/^screen\s+(\w+)\s*$/);if(A){r.screens.push({name:A[1],line:p});continue}let $=f.match(/^trigger\s+(\w+)\s*$/);$&&y===0&&r.triggers.push({name:$[1],line:p})}return An.size>=16&&An.delete(An.keys().next().value),An.set(e,r),r}c(On,"scanDocument");function Yi(...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)}}c(Yi,"mergeSymbols");function zs(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...Yi(On(t),e??Yi()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}c(zs,"symbolsForBuffer");function Fi(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}c(Fi,"knownEventNames");var cm=["Startup","Shutdown"];function FT(t){return[...Fi(t),...t.triggers.map(e=>e.name),...cm]}c(FT,"knownTriggerNames");function uo(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}c(uo,"knownTypeNames");function mo(t){let e=t.properties.filter(o=>o.isIdentifier&&!gt(o).isOptional&&!gt(o).isCollection),n=e.length===1?e[0].name:void 0,i=t.produces??[],r=i.some(o=>o.target!==void 0&&o.target!==n)||i.some(o=>o.inline&&o.target===void 0)&&i.some(o=>!o.inline&&o.target===void 0);return{identifier:n,mixed:r}}c(mo,"productionDestinations");function ZT(t,e){let n=Jt(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=St(t);return On(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}=mo(r);if(s||r.productionHeaders?.length!==r.produces?.length)return[];let a=r.produces?.some(l=>l.target!==void 0||l.inline);return(r.produces??[]).flatMap(l=>l.target!==void 0||l.inline&&(o===void 0||/\bgeneration\b/.test(i[l.line]))?[]:!l.inline&&a?[]:[{line:l.line,column:i[l.line].length+1,label:l.inline?`for ${o}`:"for <new event source>"}])})}c(ZT,"destinationHints");var J={unknownConceptDirective:"PLAY0010",attributeReasonWithoutAttribute:"PLAY0012",duplicateAttributeReason:"PLAY0013",legacyComplianceMarker:"PLAY0565",unknownComplianceMarker:"PLAY0566",invalidSecretScope:"PLAY0567",duplicateSecretScope:"PLAY0568",secretScopeIgnoredForPii:"PLAY0569",invalidPersonalDataQualifier:"PLAY0570",duplicateSpecialCategory:"PLAY0571",duplicateEventSubject:"PLAY0590",invalidSubjectType:"PLAY0591",protectedSubjectType:"PLAY0592",invalidSubjectOwner:"PLAY0593",readModelSubjectNotSupported:"PLAY0594",invalidSubjectModifierOrder:"PLAY0595",conflictingScreenDataBinding:"PLAY0530",screenDataQueryMismatch:"PLAY0531",actionWithoutInputSurface:"PLAY0532",commandWithoutInputSurface:"PLAY0533",readModelFieldWithoutOrigin:"PLAY0534",queryParameterNotHeldByView:"PLAY0535",unconsumedEvent:"PLAY0536",unreachableScreen:"PLAY0537",invalidSpecificationCallerPersona:"PLAY0572",unsynthesizablePersonaCaller:"PLAY0573",personaWithoutGate:"PLAY0574",gateWithoutPersona:"PLAY0575",ambiguousPersonaCaller:"PLAY0576",invalidSpecificationParameter:"PLAY0577",invalidSpecificationCase:"PLAY0578",duplicateSpecificationParameter:"PLAY0579",duplicateSpecificationCase:"PLAY0580",incompleteSpecificationTable:"PLAY0581",invalidSpecificationCaseAssignment:"PLAY0582",invalidSpecificationCaseValue:"PLAY0583",invalidSpecificationCaseReference:"PLAY0584",optionalSpecificationParameterTarget:"PLAY0585",specificationCaseNameCollision:"PLAY0586",incompatibleSpecificationParameterType:"PLAY0587",unusedSpecificationParameter:"PLAY0588",singularSpecificationTableExpansion:"PLAY0589",invalidActionAlternative:"PLAY0341",guardedActionWithoutAlternatives:"PLAY0342",misplacedActionOtherwise:"PLAY0343",unsupportedActionConditionOperand:"PLAY0344",unknownActionSubjectField:"PLAY0345",unresolvedActionSubject:"PLAY0346",unreachableActionAlternative:"PLAY0347",unknownActionArgumentProperty:"PLAY0348",invalidRefusalBranch:"PLAY0538",invalidRefusalBranchBody:"PLAY0539",unreachableRefusalBranch:"PLAY0540",invalidRefusalValue:"PLAY0541",unknownRefusalConstraint:"PLAY0542",unmatchedRedeliveredOccurrence:"PLAY0543",unknownRedeliveryReaction:"PLAY0544",invalidNoEventsExpectation:"PLAY0545",indeterminateNegatedClaimTarget:"PLAY0546",invalidAbsentReadModelStep:"PLAY0453",unknownConstraintProperty:"PLAY0391",invalidSpecificationExample:"PLAY0518",duplicateSpecificationAssignment:"PLAY0519",unknownReadModelProperty:"PLAY0514",piiNotSupportedOnIdentifier:"PLAY0515",invalidEventSourceDeclaration:"PLAY0503",invalidCommandStream:"PLAY0504",invalidSpecificationStream:"PLAY0547",specificationStreamOnCommand:"PLAY0548",invalidSpecificationStreamRoute:"PLAY0549",invalidSpecificationStreamEventSource:"PLAY0550",specificationStreamContradictsCommand:"PLAY0551",ambiguousCommandStream:"PLAY0505",unsupportedStreamIdType:"PLAY0506",redundantSourceStreamId:"PLAY0507",eventFromLaterSlice:"PLAY0516",timelineCycleGroup:"PLAY0517",invalidSpecificationExampleBody:"PLAY0526",undeclaredDependency:"PLAY0552",unusedDependencyDeclaration:"PLAY0553",invalidDependencyTarget:"PLAY0554",repeatedDependencyDeclaration:"PLAY0555",mutualDependencyDeclarations:"PLAY0556",authorizationRefusalWithoutIdentity:"PLAY0557",invalidDocumentation:"PLAY0558",conflictingDocumentationAcrossFiles:"PLAY0559",unsupportedInteractionAlternatives:"PLAY0560",mixedInteractionAlternatives:"PLAY0561",interactionAlternativeWithoutActions:"PLAY0562",inlineInteractionAlternative:"PLAY0563",legacyInteractionWhere:"PLAY0564",ambiguousReference:"PLAY0198",invalidImplementationBlock:"PLAY0492",invalidImplementationHint:"PLAY0493",conflictingImplementationSources:"PLAY0494",eventSourceIdInPayload:"PLAY0469",explicitProducesTargetsRequired:"PLAY0470",redundantEventId:"PLAY0471",invalidEventId:"PLAY0472",inlineEventCollision:"PLAY0473",inlineEventOutsideCommand:"PLAY0474",inlineEventGeneration:"PLAY0475",reservedProductionMetadata:"PLAY0476",invalidEventDocumentation:"PLAY0477",tabIndentation:"PLAY0006",unknownPrimitiveType:"PLAY0008",unknownSliceType:"PLAY0028",duplicateCommandIdentifier:"PLAY0036",unknownContextPath:"PLAY0153",unknownContextCausedByProperty:"PLAY0154",unknownContextIdentityProperty:"PLAY0155",unclosedCodeBlock:"PLAY0164",unknownType:"PLAY0165",unknownEvent:"PLAY0166",unknownPolicy:"PLAY0167",duplicateDeclaration:"PLAY0168",unknownEventContextMember:"PLAY0295",unknownEventContextPath:"PLAY0296",eventContextPathBelowCollection:"PLAY0297",missingEventContextPath:"PLAY0298",unresolvedDynamicKeySource:"PLAY0299",invalidFileImport:"PLAY0454",omittedProductionDestination:"PLAY0478",legacyOptionalSuffix:"PLAY0479",invalidOptionalModifierOrder:"PLAY0480",optionalReadsNotSupported:"PLAY0481",unavailableResponseExecution:"PLAY0268",generatedPropertyOutsideCommand:"PLAY0482",invalidGeneratedType:"PLAY0483",invalidGeneratedModifierOrder:"PLAY0484",generatedPropertyInput:"PLAY0485",invalidCommandResponse:"PLAY0486",invalidResponseSource:"PLAY0487",duplicateResponseField:"PLAY0488",invalidResponseShape:"PLAY0489",invalidGeneratedFixture:"PLAY0490",invalidReturnExpectation:"PLAY0491"};var dm=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,pm=/^import\s+"/;function Gs(t){return pm.test(t.trim())}c(Gs,"isFileImportLine");function yo(t,e){let n=X(t),i=t.slice(n).match(dm);if(!i)return;let r=n+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:r,endColumn:r+i[2].length}}c(yo,"fileImportOn");function eR(t){let e=Ce(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=yo(t[i],i);r&&n.push(r)}return n}c(eR,"fileImports");var Qs=c(t=>t.split("/").slice(0,-1),"folderOf");function fm(t,e){let n=e.split("/"),i=0;for(;i<t.length&&i<n.length-1&&t[i]===n[i];)i++;return[...t.slice(i).map(()=>".."),...n.slice(i)].join("/")}c(fm,"relativeTo");function tR(t,e){let n=Qs(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=fm(n,r),s=Qs(o);i.add(o),i.add([...s,"*.play"].join("/"));for(let a=0;a<=s.length;a++)i.add([...s.slice(0,a),"**","*.play"].join("/"))}return[...i].sort()}c(tR,"importablePaths");var um=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),mm=/^id\s+"((?:[^"\\]|\\.)*)"$/;function _s(t,e,n,i=new Set){t=St(t);let r=[],o=Ce(t),s=ym(t,o),a=new Set(e.commands.flatMap(y=>y.productionHeaders??[])),l=new Map,p=new Set;for(let y of[e,n]){for(let h of y.events)l.set(h.name,(l.get(h.name)??0)+1);for(let h of y.imports)p.add(h.shortName)}let m=c((y,h,v,x="error")=>{r.push({line:y,startColumn:X(t[y])+1,endColumn:t[y].length+1,code:h,message:v,severity:x})},"report");for(let y of e.events){let h=Ht(t,o,y.line,X(t[y.line]));if(y.inline){let S=new Set;for(let E of y.properties)S.has(E.name)&&m(E.line,J.duplicateDeclaration,`Event '${y.name}' already declares property '${E.name}'.`),S.add(E.name);a.has(y.line)||m(y.line,J.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),y.generation!==void 0&&m(y.line,J.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((l.get(y.name)??0)>1||p.has(y.name))&&m(y.line,J.inlineEventCollision,`Inline event '${y.name}' collides with another declaration or import.`)}let v=!1,x=!1;for(let S of h){let E=t[S].trim(),g=E.split(/\s+/)[0];if(y.inline&&g==="generation"&&m(S,J.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),y.inline&&g==="origin"&&m(S,J.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test(E)){if(g==="id"){let P=E.match(mm);v||P===null||P[1].trim().length===0?m(S,J.invalidEventId,'Expected one nonempty id "<old-name>".'):P[1]===y.name&&m(S,J.redundantEventId,"This id repeats the event name; remove it.","information"),v=!0}if(g==="documentation"){let P=S+1;for(;P<t.length&&t[P].trim().length===0;)P++;(x||E!=="documentation"||t[P]?.trim()!=="```markdown"||X(t[P])<=X(t[S])||!s.has(P))&&m(S,J.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),x=!0}}}}let f=[];for(let y=0;y<t.length;y++){if(o[y]||t[y].trim().length===0)continue;let h=X(t[y]);for(;f.length>0&&f[f.length-1].indent>=h;)f.pop();let v=t[y].trim().split(/\s+/)[0];um.has(v)&&f.at(-1)?.event&&m(y,J.reservedProductionMetadata,`'${v}' is system-assigned production metadata.`),v==="produces"&&f.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:v}=mo(y);for(let x of y.produces??[]){v&&x.target===void 0&&m(x.line,J.explicitProducesTargetsRequired,`Production '${x.name}' must state for explicitly when destinations differ.`);let S=x.target??(x.inline?h:void 0);if(!(h===void 0||S!==h))for(let E of x.mappings.filter(g=>g.source===h))m(E.line,J.eventSourceIdInPayload,`The payload copies '${h}', which already identifies the event source.`,x.inline?"warning":"information")}}return r}c(_s,"validateInlineEvents");function ym(t,e){let n=new Set,i,r=!1;for(let o=0;o<t.length;o++){if(!e[o])continue;let s=t[o].trim();i===void 0?(i=o,r=!1):s==="```"?(r&&t[i].trim()==="```markdown"&&n.add(i),i=void 0):s.length>0&&(r=!0)}return n}c(ym,"nonemptyMarkdownBlocks");function Le(t,e,n,i,r,o){return{severity:t,message:r,line:e,startColumn:n,endColumn:n+i,code:o}}c(Le,"issue");function ze(t,e,n,i,r,o){let s=n.indexOf(i)+1;return Le(t,e,s,i.length,r,o)}c(ze,"tokenIssue");function hm(t,e,n){let i=[],r=new Set([...uo(e,Tn),...uo(n,[])]),o=c((a,l)=>{for(let p of a.filter(m=>!r.has(gt(m).name))){let m=gt(p).name;i.push(Le("warning",p.line,p.sourceType.startColumn,p.sourceType.text.length,m==="optional"?`Unknown type 'optional' on '${p.name}' of ${l} \u2014 did you forget the type before 'optional'?`:`Unknown type '${m}' on '${p.name}' of ${l} \u2014 declare it with 'concept ${m} : <Primitive>' or 'type ${m}'.`,J.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 l=a.properties.filter(p=>p.isIdentifier);for(let p of l.slice(1))i.push(ze("error",p.line,t[p.line],"identifier",`Command '${a.name}' already marks '${l[0].name}' as identifier \u2014 only one property can be the identifier.`,J.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(ze("error",a.line,t[a.line],a.name,`Duplicate declaration of '${a.name}' \u2014 concept and type names must be unique.`,J.duplicateDeclaration))}return i}c(hm,"validateDeclarations");function AR(t,e={}){let n=Ce(t),i=On(t),r=e.application??Yi(),o=zs(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),s=Jt(t,o.authoringDocuments??o.authoringSources?.filter(k=>k!==t.join(`
|
|
38
|
-
`)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),a=new Set(s.eventSources.routes.map(k=>k.location.line-1)),l={...i,commands:i.commands.map(k=>({...k,properties:k.properties.filter(C=>!a.has(C.line)),produces:k.produces?.filter(C=>!s.operationProductionLines?.has(C.line)),productionHeaders:k.productionHeaders?.filter(C=>!s.operationProductionLines?.has(C))}))},p=new Set([...Fi(l),...Fi(r)]),m=new Set([...l.policies,...r.policies].map(k=>k.name)),f=hm(t,l,r);f.push(...Sm(t,l));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]),v=new Set([d.UnknownEvent,d.UnknownReadModelProperty,d.PiiNotSupportedOnIdentifier]),x=new Set([d.EventFromLaterSlice,d.TimelineCycleGroup]),S=new Set([d.UndeclaredDependency,d.UnusedDependencyDeclaration,d.InvalidDependencyTarget,d.RepeatedDependencyDeclaration,d.MutualDependencyDeclarations,d.AmbiguousReference]),E=new Set([d.DuplicateEventSubject,d.InvalidSubjectType,d.ProtectedSubjectType,d.InvalidSubjectOwner,d.ReadModelSubjectNotSupported,d.InvalidSubjectModifierOrder,d.UnsupportedInteractionAlternatives,d.MixedInteractionAlternatives,d.InteractionAlternativeWithoutActions,d.InlineInteractionAlternative,d.LegacyInteractionWhere,d.InvalidSpecificationParameter,d.InvalidSpecificationCase,d.DuplicateSpecificationParameter,d.DuplicateSpecificationCase,d.IncompleteSpecificationTable,d.InvalidSpecificationCaseAssignment,d.InvalidSpecificationCaseValue,d.InvalidSpecificationCaseReference,d.OptionalSpecificationParameterTarget,d.SpecificationCaseNameCollision,d.IncompatibleSpecificationParameterType,d.UnusedSpecificationParameter,d.SingularSpecificationTableExpansion,d.InvalidSpecificationCallerPersona,d.UnsynthesizablePersonaCaller,d.PersonaWithoutGate,d.GateWithoutPersona,d.AmbiguousPersonaCaller,d.InvalidDocumentation,d.ConflictingDocumentationAcrossFiles,d.InvalidAbsentReadModelStep,d.UnknownConstraintProperty,d.OmittedProductionDestination,d.InvalidSpecificationExample,d.DuplicateSpecificationAssignment]),g=new Set([d.UnknownConceptDirective,d.AttributeReasonWithoutAttribute,d.DuplicateAttributeReason,d.LegacyComplianceMarker,d.UnknownComplianceMarker,d.InvalidSecretScope,d.DuplicateSecretScope,d.SecretScopeIgnoredForPii,d.InvalidPersonalDataQualifier,d.DuplicateSpecialCategory]),P=new Set;for(let k of e.compilerDiagnostics??s.diagnostics){if(!g.has(k.code)&&!y.has(k.code)&&!h.has(k.code)&&!v.has(k.code)&&!x.has(k.code)&&!S.has(k.code)&&!E.has(k.code)&&k.code!==d.InvalidSpecificationExampleBody&&k.code!==d.UnknownRuleImplementationDirective&&k.code!==d.InvalidValidationRule&&k.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(k.code))continue;let C=k.location.line-1;if(k.code===d.OmittedProductionDestination&&f.some(I=>I.code===k.code&&I.line===C))continue;k.code===d.UnknownEvent&&P.add(C);let O=eo(t[C],k)||t[C].length-k.location.column+1;f.push(Le(k.severity,C,k.location.column,O,k.message,k.code))}let A=c((k,C,O)=>{!p.has(O)&&!P.has(k)&&f.push(ze("warning",k,C,O,`Unknown event type '${O}' \u2014 declare it in a slice or import it.`,J.unknownEvent))},"checkEvent"),$=-1;for(let k=0;k<t.length;k++){let C=t[k],O=C.trim();if(n[k]||O.length===0)continue;let I=C.match(/^[ ]*(\t+)/);if(I&&f.push(Le("warning",k,I[0].length-I[1].length+1,I[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",J.tabIndentation)),$>=0){if(X(C)>$&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(O)){for(let z of O.split(/\s+/).filter(_=>_!=="or"))m.has(z)||f.push(ze("warning",k,C,z,`Unknown policy '${z}' \u2014 declare it with 'policy ${z}'.`,J.unknownPolicy));continue}$=-1}let R=gm(t,n,k);R&&f.push(R);let j=O.match(/^slice\s+(\w+)/);j&&!zi.includes(j[1])&&f.push(ze("error",k,C,j[1],`Unknown slice type '${j[1]}' \u2014 expected ${zi.join(", ")}.`,J.unknownSliceType));let N=O.match(/^concept\s+\w+\s*:\s*(\w+)/);N&&N[1]!=="Enum"&&!Tn.includes(N[1])&&f.push(ze("error",k,C,N[1],`Unknown primitive type '${N[1]}' \u2014 expected ${Tn.join(", ")} or Enum.`,J.unknownPrimitiveType));let B=O.match(/^authorize\s+(.*)$/);if(B){$=X(C);for(let z of B[1].split(/\s+/).filter(_=>_!=="or"&&_.length>0))m.has(z)||f.push(ze("warning",k,C,z,`Unknown policy '${z}' \u2014 declare it with 'policy ${z}'.`,J.unknownPolicy))}let L=O.match(/^on\s+([A-Z]\w*)\s*$/);L&&A(k,C,L[1]);let W=O.match(/^produces\s+([A-Z]\w*)\s*$/);if(W&&!s.operationProductionLines?.has(k)&&A(k,C,W[1]),/^produces\s+when\b/.test(O)&&!s.operationProductionLines?.has(k))for(let z=k+1;z<t.length;z++){let _=t[z];if(!(n[z]||_.trim().length===0)){if(X(_)>X(C)){let ue=_.trim().match(/^([A-Z]\w*)\s*$/);ue&&A(z,_,ue[1])}break}}let V=O.match(/^unique\s+event\s+([A-Z]\w*)/);V&&A(k,C,V[1]);let G=O.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);G&&A(k,C,G[1]);for(let z of C.match(/\$context\.[\w.]+/g)??[]){let _=z.substring(9).split(".");Ui.includes(_[0])?_[0]==="causedBy"&&_.length>1&&!Wi.includes(_[1])?f.push(ze("warning",k,C,z,`Unknown $context.causedBy property '${_[1]}' \u2014 expected ${Wi.join(", ")}.`,J.unknownContextCausedByProperty)):_[0]==="identity"&&_.length>1&&!Vi.includes(_[1])&&f.push(ze("warning",k,C,z,`Unknown $context.identity property '${_[1]}' \u2014 expected ${Vi.join(", ")}.`,J.unknownContextIdentityProperty)):f.push(ze("warning",k,C,z,`Unknown $context path '${_.join(".")}' \u2014 expected one of ${Ui.join(", ")}.`,J.unknownContextPath))}}f.push(...vm(t,n)),f.push(..._s(t,l,r,s.operationProductionLines));let b=t.map((k,C)=>({line:k,index:C})).filter(({line:k})=>/^\s*```(?:[a-z]+)?\s*$/.test(k));if(b.length%2===1){let k=b[b.length-1];f.push(Le("error",k.index,1,k.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",J.unclosedCodeBlock))}return f}c(AR,"validateLines");function Sm(t,e){let n=[];t=St(t);for(let i of e.commands){let r=i.properties.filter(o=>o.isIdentifier&&!gt(o).isOptional&&!gt(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(Le("information",s,X(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.`,J.omittedProductionDestination))}}return n}c(Sm,"validateProductionDestinations");function gm(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||yo(i,n))return;let o=X(i);if(!(!(o>0&&["module","feature"].includes(go(t,e,n,o)[0]))&&!Gs(i)))return Le("error",n,o+1,r.length,`Invalid import '${r}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,J.invalidFileImport)}c(gm,"validateImport");var xm=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function vm(t,e){let n=[],i=c(r=>r.map(o=>o.name).join(", "),"names");for(let r=0;r<t.length;r++){let o=t[r];if(e[r])continue;for(let l of o.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let p=l[0].substring(l[1]?.length??0),m=l[2];if(m.length===0){l[1]&&n.push(Le("error",r,(l.index??0)+2,p.length,`'$eventContext' names no member - expected one of ${i(Ki("").expected)}.`,J.missingEventContextPath));continue}let f=m.substring(1),y=Ki(f),h=(l.index??0)+(l[1]?.length??0)+1;switch(y.status){case"missing":n.push(Le("error",r,h,p.length,`'$eventContext.${f}' names no member - expected one of ${i(y.expected)}.`,J.missingEventContextPath));break;case"unknownMember":n.push(Le("warning",r,h,p.length,`Unknown event context member '${y.segment}' in '$eventContext.${f}' - expected one of ${i(y.expected)}.`,J.unknownEventContextMember));break;case"unknownSubPath":{let v=y.expected.length===0?"no members to address":`members ${i(y.expected)}`;n.push(Le("warning",r,h,p.length,`Unknown event context path '$eventContext.${f}' - '${y.member?.name}' (${y.member?.type}) has ${v}.`,J.unknownEventContextPath));break}case"belowCollection":n.push(Le("error",r,h,p.length,`'$eventContext.${f}' cannot resolve - '${y.member?.name}' is a collection (${y.member?.type}) and cannot be addressed below.`,J.eventContextPathBelowCollection));break}}let s=o.trim().match(xm)?.[1],a=s?.match(/\.\$(\w+)/)?.[1];s&&a&&a!=="eventContext"&&n.push(ze("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.`,J.unresolvedDynamicKeySource))}return n}c(vm,"validateEventContextPaths");export{Zs as a,$m as b,bm as c,So as d,km as e,Ui as f,Wi as g,zi as h,Tn as i,Cm as j,Ks as k,Em as l,Pt as m,Xt as n,Am as o,d as p,ge as q,ur as r,Kn as s,uA as t,mA as u,$e as v,X as w,Qi as x,Ce as y,go as z,Im as A,Tm as B,St as C,Gi as D,_i as E,Zi as F,Js as G,Nm as H,Lm as I,qm as J,Hs as K,Xs as L,zm as M,Qm as N,Gm as O,_m as P,Zm as Q,Km as R,Jm as S,Hm as T,Xm as U,ey as V,ty as W,tl as X,ny as Y,ly as Z,cy as _,dy as $,nl as aa,py as ba,fy as ca,uy as da,my as ea,il as fa,yy as ga,hy as ha,Sy as ia,gy as ja,xy as ka,vy as la,$y as ma,by as na,ky as oa,Cy as pa,Ey as qa,Py as ra,Ay as sa,$o as ta,rl as ua,wy as va,Oy as wa,Iy as xa,Ty as ya,Ry as za,ol as Aa,Dy as Ba,al as Ca,My as Da,jy as Ea,Ny as Fa,Ly as Ga,qy as Ha,$T as Ia,Jt as Ja,lo as Ka,ET as La,co as Ma,PT as Na,gt as Oa,Ht as Pa,On as Qa,Yi as Ra,zs as Sa,Fi as Ta,cm as Ua,FT as Va,uo as Wa,mo as Xa,ZT as Ya,J as Za,Gs as _a,yo as $a,eR as ab,tR as bb,AR as cb,vm as db};
|
|
39
|
-
//# sourceMappingURL=chunk-KWZDFRXS.js.map
|